wizards 0.2.30 → 0.2.32
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/authoring/guide.js +1 -0
- package/apps/runtime/dist/engine/steps.js +3 -1
- package/apps/runtime/dist/files/storage.js +3 -0
- package/apps/runtime/dist/files/web-images.js +101 -0
- package/apps/runtime/dist/render/downloads.js +5 -3
- package/apps/runtime/dist/widgets/step.js +10 -4
- package/apps/web/dist/assets/{Account-9HRO4JWr.js → Account-5PZncmqk.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-DXH1HcDL.js → ChangelogDialog-QMuDmALk.js} +1 -1
- package/apps/web/dist/assets/{CreditsDialog-BtID6slV.js → CreditsDialog-DZaYayDL.js} +1 -1
- package/apps/web/dist/assets/{EditorPage-DhAf6LjO.js → EditorPage-BeM0smMQ.js} +1 -1
- package/apps/web/dist/assets/{FlowPreview-D3ZFAeax.js → FlowPreview-CUebTdyh.js} +1 -1
- package/apps/web/dist/assets/{Harness-mggD1ecl.js → Harness-Be76qecO.js} +1 -1
- package/apps/web/dist/assets/{HomePage-CBhmQH5G.js → HomePage-DH3Dzo9x.js} +1 -1
- package/apps/web/dist/assets/{ImportWizard-BB8oJW0X.js → ImportWizard-oEjwT_0J.js} +1 -1
- package/apps/web/dist/assets/{LocalRuntime-Dyvqh8HP.js → LocalRuntime-CH8_zIK4.js} +1 -1
- package/apps/web/dist/assets/{NewWizardPage-CLFsjQgm.js → NewWizardPage-CDEwNfx-.js} +2 -2
- package/apps/web/dist/assets/{ProjectPage-BwUhAgVx.js → ProjectPage-DR_yX4Y8.js} +1 -1
- package/apps/web/dist/assets/{PublicRunner-EfNAsmpU.js → PublicRunner-Dmw-7x9t.js} +1 -1
- package/apps/web/dist/assets/{RunDrawer-Cwtrh-Iz.js → RunDrawer-Bq23pmJa.js} +1 -1
- package/apps/web/dist/assets/{RunnerView-EQpbU4EU.js → RunnerView-0mWfQEsS.js} +1 -1
- package/apps/web/dist/assets/{SettingsPage-CASSFJS5.js → SettingsPage-CyEalhx-.js} +1 -1
- package/apps/web/dist/assets/{SetupPage-BTjh2p6y.js → SetupPage-DHuFp0PF.js} +1 -1
- package/apps/web/dist/assets/{SharePage-BSD9UL9f.js → SharePage-vr48Pkdg.js} +1 -1
- package/apps/web/dist/assets/arrow-right-CXu8-CPy.js +1 -0
- package/apps/web/dist/assets/changelog-tH5O-JCg.js +1 -0
- package/apps/web/dist/assets/{circle-alert-CN6dFS0d.js → circle-alert-Czg98m49.js} +1 -1
- package/apps/web/dist/assets/{definition-Cx9uG0KU.js → definition-DMIWA8dM.js} +1 -1
- package/apps/web/dist/assets/{esm-CKwbhTDV.js → esm-Ckl7le0A.js} +1 -1
- package/apps/web/dist/assets/{external-link-DvkH63pi.js → external-link-CbxUCKS8.js} +1 -1
- package/apps/web/dist/assets/{image-BUbtvL1h.js → image-BuCJ3Peh.js} +1 -1
- package/apps/web/dist/assets/{index-C4KaV94L.js → index-DyiZlzJ2.js} +4 -4
- package/apps/web/dist/assets/{lock-COAprdab.js → lock-B_LTwWO5.js} +1 -1
- package/apps/web/dist/assets/{meta-vzJM2HEw.js → meta-D5QeOYH-.js} +1 -1
- package/apps/web/dist/assets/{pen-line-JsP-r_aH.js → pen-line-D0OKCmpB.js} +1 -1
- package/apps/web/dist/assets/{refresh-cw-DLXaS3Ri.js → refresh-cw-LyAykaPl.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-Ds_wegZm.js → settings-menu-cjRkf6JU.js} +1 -1
- package/apps/web/dist/assets/{star-CpnGQZXD.js → star-C9ADb1bK.js} +1 -1
- package/apps/web/dist/assets/{surface-BFwNWkx9.js → surface-CywgBXMy.js} +1 -1
- package/apps/web/dist/assets/{trash-CQZuqdcu.js → trash-CGJ09WWJ.js} +1 -1
- package/apps/web/dist/assets/{ui-BTkH_7CG.js → ui-DyazyiaK.js} +1 -1
- package/apps/web/dist/assets/{upload-Dok4YeXQ.js → upload-Dl_w8YOa.js} +1 -1
- package/apps/web/dist/assets/{video-BjQoPIsn.js → video-DDj7eGwZ.js} +1 -1
- package/apps/web/dist/assets/{volume-2-D-Bn77h4.js → volume-2-dg1-eKM_.js} +1 -1
- package/apps/web/dist/assets/{wand-sparkles-D3sDsFFG.js → wand-sparkles-Bmg2IFLf.js} +1 -1
- package/apps/web/dist/index.html +3 -3
- package/apps/web/dist/mcp/flow.html +32 -31
- package/package.json +1 -1
- package/apps/web/dist/assets/arrow-right-CzoY677S.js +0 -1
- package/apps/web/dist/assets/changelog-j7qikrRS.js +0 -1
|
@@ -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{_ as r}from"./surface-BFwNWkx9.js";import{t as i}from"./preload-helper-CNEI7N0N.js";import{D as a,F as o,G as s,H as c,I as l,L as u,N as d,O as f,P as p,U as m,W as h,b as g,c as _,d as v,f as y,g as b,h as x,i as S,j as C,k as w,l as T,m as E,n as D,o as O,p as k,s as A,t as j,u as M,x as N}from"./ui-BTkH_7CG.js";import{t as P}from"./arrow-right-CzoY677S.js";import{t as F}from"./external-link-DvkH63pi.js";import{n as I,t as L}from"./trash-CQZuqdcu.js";import{t as R}from"./pen-line-JsP-r_aH.js";import{t as z}from"./refresh-cw-DLXaS3Ri.js";import{t as ee}from"./video-BjQoPIsn.js";import{C as te,D as B,O as V,S as H,T as ne,_ as re,b as U,ct as ie,dt as ae,f as oe,h as se,nt as ce,ut as le,v as ue,w as de,x as fe,y as pe}from"./index-C4KaV94L.js";import{C as me,S as he,_ as ge,h as _e,m as ve,x as ye,y as be}from"./definition-Cx9uG0KU.js";var xe={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};xe.node;var Se=s(xe),Ce={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`}]]};Ce.node;var we=s(Ce),Te={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`}]]};Te.node;var Ee=s(Te),De={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`}]]};De.node;var Oe=s(De),ke={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`}]]};ke.node;var Ae=s(ke),je={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`}]]};je.node;var Me=s(je),Ne={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`]};Ne.node;var Pe=s(Ne),Fe={name:`film`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]};Fe.node;var Ie=s(Fe),Le={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`}]]};Le.node;var Re=s(Le),ze={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`}]]};ze.node;var Be=s(ze),Ve={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`}]]};Ve.node;var He=s(Ve),Ue={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`}]]};Ue.node;var We=s(Ue),Ge={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`}]]};Ge.node;var Ke=s(Ge),qe={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`}]]};qe.node;var Je=s(qe),Ye={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`}]]};Ye.node;var Xe=s(Ye),Ze={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};Ze.node;var Qe=s(Ze),$e={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`}]]};$e.node;var et=s($e),tt={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`}]]};tt.node;var nt=s(tt),rt={name:`pencil`,size:24,node:[[`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`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};rt.node;var it=s(rt),at={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`}]]};at.node;var W=s(at),ot={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`}]]};ot.node;var st=s(ot),ct={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`}]]};ct.node;var G=s(ct),lt={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`}]]};lt.node;var ut=s(lt),dt={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`}]]};dt.node;var ft=s(dt),pt={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`]};pt.node;var mt=s(pt),ht={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`}]]};ht.node;var gt=s(ht),K=36e5,q=6e4,_t=1e3;function vt(e){return e.fractionDigits===void 0?e.style===`integer`?0:2:e.fractionDigits}function yt(e,t,n=`en`){if(typeof e!=`number`||!Number.isFinite(e))return``;let r=vt(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 bt(e,t,n=`en`){if(typeof e!=`string`||e.length===0)return``;if(t.kind===`time`)return xt(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 xt(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 St(e,t){if(typeof e!=`number`||!Number.isFinite(e))return``;let n=Math.max(0,Math.round(e));if(t.display===`iso`)return Ct(n);if(t.display===`minutes`)return`${Math.round(n/q)} min`;if(t.display===`hours`)return`${(n/K).toFixed(2)} h`;if(t.display===`decimal-hours`)return(n/K).toFixed(2);let r=Math.floor(n/K),i=Math.floor(n%K/q),a=Math.floor(n%q/_t);return`${r}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`}function Ct(e){let t=Math.floor(e/K),n=Math.floor(e%K/q),r=Math.floor(e%q/_t);return`${t>=24?`P${Math.floor(t/24)}D`:`P`}T${t%24}H${n}M${r}S`}function J(e,t,n=`en`){if(t==null)return``;switch(e.type){case`number`:return yt(t,e.format,n);case`date`:return bt(t,e.format,n);case`duration`:return St(t,e.format);case`boolean`:return t===!0?`true`:t===!1?`false`:``;case`select`:return wt(e,t);default:return String(t)}}function wt(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(`, `)}var Y=e(t(),1),X=e(n(),1);function Tt(e,t){let n=encodeURIComponent(e),r=encodeURIComponent(t);return[{id:`mail`,label:C(`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 Et={x:`𝕏`,linkedin:`in`,whatsapp:`WA`,facebook:`f`};function Dt({runId:e,title:t,initial:n}){let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(n),[s,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),m=async()=>{if(i(!0),!a){l(!0),p(null);try{o(await N.post(`/api/runs/${e}/share`))}catch(e){p(e.message)}finally{l(!1)}}},h=async()=>{await N.del(`/api/runs/${e}/share`),o(null),i(!1)},g=()=>{a&&(navigator.clipboard.writeText(a.url),d(!0),setTimeout(()=>d(!1),1500))},_=V(`share`)||typeof navigator<`u`&&`share`in navigator,v=a?.expiresAt?new Intl.DateTimeFormat(w,{dateStyle:`long`}).format(new Date(a.expiresAt)):null;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(j,{variant:`secondary`,onClick:()=>void m(),children:[(0,X.jsx)(G,{className:`size-4`}),` `,C(`shareRun.button`)]}),(0,X.jsx)(S,{open:r,onClose:()=>i(!1),title:C(`shareRun.title`),children:s?(0,X.jsx)(`div`,{className:`flex justify-center py-8 text-ink-4`,children:(0,X.jsx)(y,{})}):f?(0,X.jsx)(`p`,{className:`rounded-lg bg-rose-tint px-3 py-2 text-[0.875rem] text-rose`,children:f}):a?(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-paper-2 p-1.5 pl-3`,children:[(0,X.jsx)(I,{className:`size-4 shrink-0 text-ink-3`}),(0,X.jsx)(`input`,{readOnly:!0,value:a.url,onFocus:e=>e.target.select(),"aria-label":C(`share.link`),className:`min-w-0 flex-1 bg-transparent text-[0.875rem] outline-none coarse:h-11`}),(0,X.jsxs)(j,{size:`sm`,onClick:g,children:[u?(0,X.jsx)(c,{className:`size-3.5`}):(0,X.jsx)(ae,{className:`size-3.5`}),C(u?`share.copied`:`share.copy`)]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 sm:grid-cols-6`,children:[Tt(a.url,t).map(e=>(0,X.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`flex flex-col items-center gap-1.5 text-[0.75rem] text-ink-2 hover:text-ink`,children:[(0,X.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-full bg-paper-2 font-semibold text-[0.9375rem] transition hover:bg-paper-3`,children:e.id===`mail`?(0,X.jsx)(Qe,{className:`size-5`}):Et[e.id]}),e.label]},e.id)),_?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void(V(`share`)?B(`share`,{link:a.url,title:t}):navigator.share({title:t,url:a.url})).catch(()=>void 0),className:`flex flex-col items-center gap-1.5 text-[0.75rem] text-ink-2 hover:text-ink`,children:[(0,X.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-full bg-paper-2 transition hover:bg-paper-3`,children:(0,X.jsx)(G,{className:`size-5`})}),C(`shareRun.more`)]}):null]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-[0.8125rem] text-ink-3`,children:[(0,X.jsx)(`span`,{children:v?C(`shareRun.until`,{date:v}):C(`shareRun.kept`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void h(),className:`shrink-0 hover:text-rose coarse:min-h-11`,children:C(`shareRun.withdraw`)})]})]}):null})]})}function Ot({runId:e,ask:t}){return t.kind===`confirm`?(0,X.jsx)(kt,{runId:e,ask:t}):(0,X.jsx)(At,{runId:e,ask:t})}function kt({runId:e,ask:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),c=async n=>{a(!0),s(null);try{await N.post(`/api/runs/${e}/ask/${t.id}`,n)}catch(e){s(e.message),a(!1)}},l=t.action.destructive?mt:nt;return(0,X.jsxs)(`div`,{className:`animate-rise`,children:[(0,X.jsxs)(`div`,{className:`mb-5 flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:b(`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,X.jsx)(l,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:C(`ask.wants`,{service:t.service})}),(0,X.jsx)(`h2`,{className:`font-display font-semibold text-[1.25rem] leading-snug tracking-tight`,children:t.reason})]})]}),(0,X.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-xl bg-paper-2 p-4 text-[0.8125rem] leading-relaxed ring-1 ring-border-soft`,children:t.input}),(0,X.jsxs)(`div`,{className:`mt-5 flex items-center gap-4`,children:[(0,X.jsx)(E,{checked:n,onChange:r,label:C(`ask.allowRest`)}),(0,X.jsx)(`span`,{className:`flex-1 text-[0.8125rem] text-ink-2`,children:C(`ask.allowRest`)})]}),o?(0,X.jsx)(`div`,{className:`mt-3 rounded-lg bg-rose-tint px-4 py-3 text-[0.875rem] text-rose`,children:o}):null,(0,X.jsxs)(`div`,{className:`action-bar mt-6 flex items-center justify-between gap-3`,children:[(0,X.jsx)(j,{variant:`ghost`,disabled:i,onClick:()=>void c({type:`skip`}),children:C(`ask.deny`)}),(0,X.jsx)(j,{busy:i,onClick:()=>void c({type:`done`,remember:n}),children:C(`ask.allow`)})]})]})}function At({runId:e,ask:t}){let[n,r]=(0,Y.useState)({}),[i,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(0),[p,h]=(0,Y.useState)(``),[g,v]=(0,Y.useState)(!1),y=(0,Y.useRef)(null),x=(0,Y.useCallback)(()=>f(e=>e+1),[]);(0,Y.useEffect)(()=>{let e=setInterval(x,2500);return()=>clearInterval(e)},[x]);let S=async n=>{c(!0),u(null);try{await N.post(`/api/runs/${e}/ask/${t.id}`,n)}catch(e){u(e.message),c(!1)}},w=async t=>{u(null);try{await N.post(`/api/runs/${e}/browser/act`,t)}catch(e){u(e.message)}x()},T=e=>{let t=y.current;if(!t?.naturalWidth)return;let n=t.getBoundingClientRect();w({type:`click`,x:Math.round((e.clientX-n.left)/n.width*t.naturalWidth),y:Math.round((e.clientY-n.top)/n.height*t.naturalHeight)})},D=t.fields.some(e=>n[e.id]);return(0,X.jsxs)(`div`,{className:`animate-rise`,children:[(0,X.jsxs)(`div`,{className:`mb-5 flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-full bg-ember-tint text-ember-strong`,children:(0,X.jsx)(Xe,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h2`,{className:`font-display font-semibold text-[1.25rem] leading-snug tracking-tight`,children:t.reason}),(0,X.jsxs)(`p`,{className:`mt-0.5 truncate text-[0.8125rem] text-ink-3`,children:[t.site.host,t.site.title?` · ${t.site.title}`:``]})]})]}),(0,X.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-paper-2 ring-1 ring-border-soft`,children:[(0,X.jsx)(`img`,{ref:y,src:a(`/api/runs/${e}/browser/screen?t=${d}`),alt:t.site.host,onClick:T,className:`block w-full cursor-pointer`}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-border-soft border-t bg-card p-2`,children:[(0,X.jsx)(A,{type:g?`password`:`text`,autoComplete:`off`,value:p,placeholder:C(`ask.typeInto`),onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w({type:`type`,text:p}).then(()=>h(``)))},autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,enterKeyHint:`send`,className:`h-9 min-w-[9rem] flex-1 basis-full text-[0.8125rem] sm:basis-0 coarse:h-11`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>v(e=>!e),className:b(`h-9 shrink-0 rounded-md px-2.5 text-[0.75rem] coarse:h-11 coarse:px-3.5`,g?`bg-ember-veil text-ink`:`text-ink-3 hover:bg-paper-2`),children:C(`ask.hide`)}),(0,X.jsx)(jt,{label:`Enter`,onClick:()=>void w({type:`key`,key:`Enter`}),children:(0,X.jsx)(Ae,{className:`size-4`})}),(0,X.jsx)(jt,{label:C(`ask.up`),onClick:()=>void w({type:`scroll`,dy:-500}),children:(0,X.jsx)(m,{className:`size-4`})}),(0,X.jsx)(jt,{label:C(`ask.down`),onClick:()=>void w({type:`scroll`,dy:500}),children:(0,X.jsx)(Se,{className:`size-4`})})]})]}),(0,X.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-ink-4`,children:C(`ask.pictureHint`)}),t.fields.length?(0,X.jsxs)(`form`,{className:`mt-5 flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),S({type:`fill`,values:n,remember:i})},children:[t.fields.map((e,i)=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(_,{children:e.label}),(0,X.jsx)(A,{autoFocus:i===0,type:e.secret?`password`:`text`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,enterKeyHint:i===t.fields.length-1?`go`:`next`,value:n[e.id]??``,onChange:t=>r(n=>({...n,[e.id]:t.target.value}))})]},e.id)),(0,X.jsx)(`button`,{type:`submit`,hidden:!0})]}):null,(0,X.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-4`,children:[(0,X.jsx)(E,{checked:i,onChange:o,label:C(`ask.remember`)}),(0,X.jsx)(`span`,{className:`flex-1 text-[0.8125rem] text-ink-2`,children:C(`ask.remember`)})]}),(0,X.jsxs)(`p`,{className:`mt-3 flex items-start gap-2 text-[0.8125rem] text-ink-3`,children:[(0,X.jsx)(ut,{className:`mt-0.5 size-4 shrink-0 text-moss`}),` `,C(`ask.private`)]}),l?(0,X.jsx)(`div`,{className:`mt-3 rounded-lg bg-rose-tint px-4 py-3 text-[0.875rem] text-rose`,children:l}):null,(0,X.jsxs)(`div`,{className:`action-bar mt-6 flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsx)(j,{variant:`ghost`,disabled:s,onClick:()=>void S({type:`skip`}),children:C(`ask.skip`)}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.fields.length?(0,X.jsx)(j,{variant:`secondary`,disabled:s,onClick:()=>void S({type:`done`,remember:i}),children:C(`ask.done`)}):null,t.fields.length?(0,X.jsx)(j,{busy:s,disabled:!D,onClick:()=>void S({type:`fill`,values:n,remember:i}),children:C(`ask.signIn`)}):(0,X.jsx)(j,{busy:s,onClick:()=>void S({type:`done`,remember:i}),children:C(`ask.done`)})]})]})]})}function jt({label:e,onClick:t,children:n}){return(0,X.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})}async function Mt(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 Nt(){return new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`)}function Pt(e){let t=e?.name;return t===`NotFoundError`||t===`OverconstrainedError`?`missing`:t===`NotReadableError`||t===`AbortError`?`busy`:`denied`}function Ft(e){return!!e?.getCapabilities?.()?.torch}function It(e,t,n=!1){let r=(0,Y.useRef)(null),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(1),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1);return(0,Y.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(Ft(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(Pt(e))),()=>{i=!0;for(let e of r?.getTracks()??[])e.stop()}},[e,t,n]),(0,Y.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 Lt({open:e,onClose:t,label:n,children:r}){let i=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let t=i.current;t&&(e&&!t.open?t.showModal():!e&&t.open&&t.close())},[e]),(0,X.jsx)(`dialog`,{ref:i,onClose:t,"aria-label":n,className:`media-sheet`,children:e?(0,X.jsx)(`div`,{className:`flex h-full flex-col`,children:r}):null})}function Rt({label:e,onClick:t,active:n,children:r}){return(0,X.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":n,onClick:t,className:b(`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 zt({title:e,onClose:t,camera:n,onFlip:r}){return(0,X.jsx)(`div`,{className:`safe-top`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,X.jsx)(Rt,{label:C(`common.close`),onClick:t,children:(0,X.jsx)(d,{className:`size-5`})}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-center font-medium text-[0.9375rem]`,children:e}),n.torchable?(0,X.jsx)(Rt,{label:C(`camera.torch`),active:n.torch,onClick:()=>void n.setTorch(!n.torch),children:n.torch?(0,X.jsx)(Be,{className:`size-5`}):(0,X.jsx)(Re,{className:`size-5`})}):null,n.stream&&(n.cameras>1||U)?(0,X.jsx)(Rt,{label:C(`camera.flip`),onClick:r,children:(0,X.jsx)(ft,{className:`size-5`})}):(0,X.jsx)(`span`,{className:`size-11`})]})})}function Bt({camera:e,asking:t,children:n,actions:r}){return(0,X.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[(0,X.jsx)(`video`,{ref:e.video,autoPlay:!0,playsInline:!0,muted:!0,className:b(`absolute inset-0 size-full object-contain`,e.mirrored&&`-scale-x-100`)}),e.error?(0,X.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-5 bg-black px-8 text-center`,children:[(0,X.jsx)(`p`,{className:`max-w-sm text-[0.9375rem] text-white/85 leading-relaxed`,children:C(`camera.${e.error}`)}),r]}):e.stream?n:(0,X.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-4 px-8 text-center text-white/75`,children:[(0,X.jsx)(y,{}),(0,X.jsx)(`p`,{className:`max-w-xs text-[0.875rem] leading-relaxed`,children:t})]})]})}var Vt=30;function Ht(){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 Ut=!!Ht();function Wt({open:e,multiple:t,video:n,onClose:r,onCapture:i,onNative:a}){let[o,s]=(0,Y.useState)(`environment`),[l,u]=(0,Y.useState)(`photo`),[d,f]=(0,Y.useState)(0),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(null),_=(0,Y.useRef)(null),v=It(e,o,l===`video`);(0,Y.useEffect)(()=>{e&&(f(0),u(`photo`),g(null))},[e]);let x=async e=>{m(!0);try{await i(e),f(e=>e+1),t||r()}finally{m(!1)}},S=async()=>{let e=v.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 x(new File([n],`foto-${Nt()}.jpg`,{type:`image/jpeg`}))},w=()=>{_.current?.state===`recording`&&_.current.stop()},T=()=>{let e=Ht();if(!v.stream||!e)return;let t=[],n=new MediaRecorder(v.stream,{mimeType:e,videoBitsPerSecond:25e5,audioBitsPerSecond:96e3});n.ondataavailable=e=>e.data.size&&t.push(e.data),n.onstop=()=>{g(null),_.current=null;let n=e.split(`;`)[0];if(t.length){let e=n===`video/mp4`?`mp4`:`webm`;x(new File(t,`video-${Nt()}.${e}`,{type:n}))}},_.current=n,n.start(1e3),g(0)};(0,Y.useEffect)(()=>{if(h===null)return;if(h>=Vt){_.current?.state===`recording`&&_.current.stop();return}let e=setTimeout(()=>g(e=>e===null?null:e+1),1e3);return()=>clearTimeout(e)},[h]),(0,Y.useEffect)(()=>{!e&&_.current&&(_.current.onstop=null,_.current.stop(),_.current=null)},[e]);let E=e=>`0:${String(e).padStart(2,`0`)}`;return(0,X.jsxs)(Lt,{open:e,onClose:r,label:C(`camera.title`),children:[(0,X.jsx)(zt,{title:h===null?d?C(`camera.taken`,{n:d}):C(`camera.title`):`${E(h)} / ${E(Vt)}`,onClose:r,camera:v,onFlip:()=>s(e=>e===`environment`?`user`:`environment`)}),(0,X.jsx)(Bt,{camera:v,asking:C(`camera.asking`),actions:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a?(0,X.jsxs)(Z,{onClick:()=>{r(),a()},children:[(0,X.jsx)(Oe,{className:`size-4`}),` `,C(U?`camera.native`:`camera.pick`)]}):null,(0,X.jsx)(Z,{quiet:!0,onClick:r,children:C(`common.close`)})]})}),(0,X.jsxs)(`div`,{className:b(`safe-bottom px-4 pt-3`,v.error&&`invisible`),children:[n&&Ut&&h===null?(0,X.jsx)(`div`,{className:`mb-3 flex justify-center gap-1 text-[0.8125rem]`,children:[`photo`,`video`].map(e=>(0,X.jsx)(`button`,{type:`button`,"aria-pressed":l===e,onClick:()=>u(e),className:b(`h-9 rounded-full px-4 font-medium transition`,l===e?`bg-white text-black`:`text-white/70 hover:text-white`),children:C(e===`photo`?`camera.photo`:`camera.video`)},e))}):null,(0,X.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_1fr] items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-[0.8125rem] text-white/70 leading-snug`,children:h===null?l===`video`?C(`camera.clipHint`,{s:Vt}):C(t?`camera.hintMany`:`camera.hint`):C(`camera.recording`)}),(0,X.jsx)(`button`,{type:`button`,"aria-label":C(l===`photo`?`camera.shoot`:h===null?`camera.record`:`camera.stop`),disabled:!v.stream||p,onClick:()=>l===`photo`?void S():h===null?T():w(),className:`flex size-[72px] items-center justify-center rounded-full border-4 border-white transition active:scale-95 disabled:opacity-40`,children:p?(0,X.jsx)(y,{className:`text-white`}):l===`photo`?(0,X.jsx)(`span`,{className:`size-[54px] rounded-full bg-white`}):h===null?(0,X.jsx)(`span`,{className:`flex size-[54px] items-center justify-center rounded-full bg-[#e5484d]`,children:(0,X.jsx)(ee,{className:`size-6 text-white`})}):(0,X.jsx)(`span`,{className:`size-7 rounded-md bg-[#e5484d]`})}),(0,X.jsx)(`div`,{className:`flex justify-end`,children:t&&d&&h===null?(0,X.jsxs)(Z,{onClick:r,children:[(0,X.jsx)(c,{className:`size-4`}),` `,C(`camera.done`)]}):null})]})]})]})}function Z({onClick:e,quiet:t,children:n}){return(0,X.jsx)(`button`,{type:`button`,onClick:e,className:b(`inline-flex h-11 items-center justify-center gap-2 rounded-full px-5 font-medium text-[0.875rem] transition`,t?`text-white/75 hover:text-white`:`bg-white text-black hover:bg-white/90`),children:n})}var Gt=25,Kt=9e3;function qt(e){return e.code===e.PERMISSION_DENIED?`denied`:e.code===e.TIMEOUT?`timeout`:`unavailable`}function Jt({value:e,runId:t,placeholder:n,onChange:r,onBusy:i}){let a=ge(e)?e:null,[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),f=(0,Y.useRef)(!!a?.label),p=(0,Y.useRef)(a);p.current=a;let m=a?.lat!==void 0&&a.lng!==void 0,h=typeof navigator<`u`&&`geolocation`in navigator,g=()=>{u.current!==null&&(navigator.geolocation.clearWatch(u.current),u.current=null),s(!1),i?.(!1)};(0,Y.useEffect)(()=>()=>{u.current!==null&&navigator.geolocation.clearWatch(u.current)},[]);let _=async(e,n)=>{try{let{label:i}=await N.post(`/api/runs/${t}/geocode`,{lat:e,lng:n,language:w}),a=p.current;i&&!f.current&&a?.lat===e&&a.lng===n&&r({...a,label:i})}catch{}},v=()=>{l(null),s(!0),i?.(!0);let e=Date.now(),t=1/0;u.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<=Gt||Date.now()-e>Kt){g();let e=p.current;e?.lat!==void 0&&e.lng!==void 0&&_(e.lat,e.lng)}},e=>{g(),t===1/0&&l(qt(e))},{enableHighAccuracy:!0,timeout:15e3,maximumAge:1e4})},y=e=>{f.current=e.trim().length>0;let t={...m?a:{},label:e};r(m||e.trim()?t:void 0)};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[m?(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-full bg-moss-tint text-moss`,children:(0,X.jsx)(et,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`truncate font-medium text-[0.9375rem] tabular-nums`,children:[a.lat?.toFixed(5),`, `,a.lng?.toFixed(5)]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 text-[0.8125rem] text-ink-3`,children:[(0,X.jsx)(`span`,{children:o?C(`location.refining`):a.accuracy?C(`location.accuracy`,{m:a.accuracy}):null}),(0,X.jsxs)(`a`,{href:`https://www.openstreetmap.org/?mlat=${a.lat}&mlon=${a.lng}#map=17/${a.lat}/${a.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:[C(`location.map`),` `,(0,X.jsx)(F,{className:`size-3`})]})]})]}),(0,X.jsx)(O,{label:C(`location.remove`),onClick:()=>{g(),f.current=!1,r(void 0)},children:(0,X.jsx)(d,{className:`size-4`})})]}):h?(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(j,{variant:`secondary`,size:`lg`,busy:o,onClick:v,className:`w-full sm:w-auto`,children:[o?null:(0,X.jsx)(Je,{className:`size-4`}),C(o?`location.locating`:`location.use`)]}),c?(0,X.jsx)(`p`,{className:`mt-2 rounded-lg bg-amber-tint px-3 py-2 text-[0.8125rem] text-ink-2 leading-relaxed`,children:C(`location.${c}`)}):(0,X.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3 leading-relaxed`,children:C(`location.why`)})]}):null,(0,X.jsx)(A,{value:a?.label??``,placeholder:n??C(m?`location.label`:`location.manual`),autoComplete:`street-address`,enterKeyHint:`done`,"aria-label":C(`location.manual`),onChange:e=>y(e.target.value)})]})}var Yt=null;function Xt(){return Yt??=(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 i(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}}}})(),Yt}function Zt({open:e,onClose:t,onResult:n}){let r=(0,Y.useRef)(n);r.current=n;let i=(0,Y.useRef)(t);return i.current=t,(0,Y.useEffect)(()=>{e&&B(`scan`).then(e=>{e&&r.current(e)}).catch(()=>void 0).finally(()=>i.current())},[e]),null}function Qt(e){return V(`scan`)?(0,X.jsx)(Zt,{...e}):(0,X.jsx)($t,{...e})}function $t({open:e,onClose:t,onResult:n}){let[r,i]=(0,Y.useState)(`environment`),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=(0,Y.useRef)(null),u=It(e,r),d=(0,Y.useRef)(n);d.current=n;let f=(0,Y.useRef)(t);f.current=t,(0,Y.useEffect)(()=>{e&&(c(!1),Xt().then(e=>o(e.qrOnly)))},[e]),(0,Y.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 Xt()).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 Xt()).detect(r).catch(()=>null):null;i?(n(i),t()):c(!0)};return(0,X.jsxs)(Lt,{open:e,onClose:t,label:C(`scan.title`),children:[(0,X.jsx)(zt,{title:C(`scan.title`),onClose:t,camera:u,onFlip:()=>i(e=>e===`environment`?`user`:`environment`)}),(0,X.jsx)(Bt,{camera:u,asking:C(`scan.asking`),actions:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(Z,{onClick:()=>l.current?.click(),children:[(0,X.jsx)(Ke,{className:`size-4`}),` `,C(`scan.fromPhoto`)]}),(0,X.jsx)(Z,{quiet:!0,onClick:t,children:C(`scan.typeInstead`)})]}),children:(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,X.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,X.jsxs)(`div`,{className:`safe-bottom flex flex-col items-center gap-3 px-5 pt-3 text-center`,children:[(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-white/75 leading-snug`,children:C(s?`scan.miss`:a?`scan.hintQr`:`scan.hint`)}),u.stream?(0,X.jsxs)(Z,{quiet:!0,onClick:()=>l.current?.click(),children:[(0,X.jsx)(Ke,{className:`size-4`}),` `,C(`scan.fromPhoto`)]}):null]}),(0,X.jsx)(`input`,{ref:l,type:`file`,hidden:!0,accept:`image/*`,onChange:e=>{p(e.target.files?.[0]),e.target.value=``}})]})}var en=`#1d1a17`,Q={width:1200,height:480};function tn(e,t,n,r,i){e.lineCap=`round`,e.lineJoin=`round`,e.strokeStyle=en,e.fillStyle=en,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 nn({strokes:e,onStrokes:t}){let n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.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),tn(t,r.current?[...i.current,r.current]:i.current,o,s,2.4*a)};(0,Y.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,X.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl bg-white ring-1 ring-input`,children:[(0,X.jsx)(`canvas`,{ref:n,"aria-label":C(`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,X.jsx)(`div`,{className:`pointer-events-none absolute inset-x-6 bottom-[22%] border-[#1d1a17]/25 border-b`}),e.length?null:(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center text-[#1d1a17]/40 text-[0.875rem]`,children:C(`sign.hint`)})]})}async function rn(e){let t=document.createElement(`canvas`);t.width=Q.width,t.height=Q.height;let n=t.getContext(`2d`);if(!n)return null;tn(n,e,Q.width,Q.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 an({label:e,value:t,runId:n,onChange:r}){let[i,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)([]),[l,u]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),m=typeof t==`string`&&t?t:null,h=async()=>{u(!0),p(null);try{let e=await rn(s);if(!e)return;r((await N.upload(`/api/runs/${n}/uploads`,e)).id),o(!1)}catch(e){p(e.message)}finally{u(!1)}};return(0,X.jsxs)(`div`,{children:[m?(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-2 ring-1 ring-input`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>{c([]),o(!0)},className:`min-w-0 flex-1 rounded-lg bg-white px-3`,"aria-label":C(`sign.again`),children:(0,X.jsx)(`img`,{src:a(`/api/runs/${n}/assets/${m}`),alt:e,className:`mx-auto h-20 object-contain`})}),(0,X.jsx)(O,{label:C(`sign.remove`),onClick:()=>r(void 0),children:(0,X.jsx)(d,{className:`size-4`})})]}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{c([]),o(!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-[0.875rem] text-ink-3 transition hover:border-ember hover:text-ink`,children:[(0,X.jsx)(R,{className:`size-6`}),C(`sign.open`)]}),(0,X.jsxs)(S,{open:i,onClose:()=>o(!1),title:e,wide:!0,children:[(0,X.jsx)(nn,{strokes:s,onStrokes:c}),f?(0,X.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:f}):null,(0,X.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-3`,children:[(0,X.jsxs)(j,{variant:`ghost`,disabled:!s.length||l,onClick:()=>c([]),children:[(0,X.jsx)(Me,{className:`size-4`}),` `,C(`sign.clear`)]}),(0,X.jsx)(j,{busy:l,disabled:!s.length,onClick:()=>void h(),children:C(`sign.accept`)})]})]})]})}function on({runId:e,connectionId:t,connector:n,onCancel:r}){let[i,a]=(0,Y.useState)({}),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=async()=>{s(!0),l(null);try{await N.post(`/api/runs/${e}/connections/${t}/credentials/${n.id}`,{values:i})}catch(e){l(e.message)}finally{s(!1)}};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-card p-4 ring-1 ring-input`,children:[(n.fields??[]).map(e=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(_,{children:e.label}),(0,X.jsx)(A,{type:e.secret?`password`:`text`,autoComplete:`off`,value:i[e.key]??``,placeholder:e.placeholder,onChange:t=>a(n=>({...n,[e.key]:t.target.value})),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u())}})]},e.key)),n.hint?(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:n.hint}):null,c?(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:c}):null,(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(j,{variant:`ghost`,size:`sm`,onClick:r,children:C(`common.cancel`)}),(0,X.jsx)(j,{size:`sm`,busy:o,onClick:()=>void u(),children:C(`connect.go`)})]})]})}function sn({runId:e,connection:t}){let[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null);if(!t)return null;if(t.account){let n=t.connectors.find(e=>e.id===t.account?.connector)?.name??``;return(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,X.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-moss-tint text-moss`,children:(0,X.jsx)(c,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate font-medium text-[0.9375rem]`,children:t.account.label}),(0,X.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:C(`connect.connected`,{name:n})})]}),(0,X.jsx)(O,{label:C(`connect.disconnect`),onClick:()=>void N.del(`/api/runs/${e}/connections/${t.id}`),children:(0,X.jsx)(gt,{className:`size-4`})})]})}let l=async n=>{if(s(null),a(null),V(`signIn`)){try{let{url:r}=await N.post(`/api/runs/${e}/connections/${t.id}/oauth/${n.id}`);await B(`signIn`,{url:r})}catch(e){s(e.message)}return}let r=window.open(`about:blank`,`wizard-connect`,`width=540,height=700`);try{let{url:i}=await N.post(`/api/runs/${e}/connections/${t.id}/oauth/${n.id}`);r?r.location.replace(i):a(i)}catch(e){r?.close(),s(e.message)}},u=t.connectors.find(e=>e.id===n);return t.connectors.length?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.connectors.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>e.auth===`oauth2`?void l(e):r(n===e.id?null:e.id),className:b(`inline-flex h-11 items-center gap-2 rounded-full px-4 font-medium text-[0.875rem] 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,X.jsx)(I,{className:`size-4`}),` `,e.name]},e.id))}),u?(0,X.jsx)(on,{runId:e,connectionId:t.id,connector:u,onCancel:()=>r(null)}):null,i?(0,X.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:`text-[0.875rem] text-ember underline`,children:C(`connect.openLink`)}):null,o?(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:o}):null]}):(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:C(`connect.none`)})}function cn(e){return e==null?``:Array.isArray(e)?e.join(`, `):String(e)}function ln(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,Y.useState)(cn(t));(0,Y.useEffect)(()=>a(cn(t)),[t]);let o=b(`w-full min-w-0 rounded-md border border-transparent px-2 text-[0.8125rem] 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,X.jsx)(`label`,{className:`flex size-9 cursor-pointer items-center justify-center coarse:size-11`,children:(0,X.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,X.jsxs)(`select`,{value:i,onChange:e=>r(e.target.value||null),className:o,children:[(0,X.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.label},e.id))]}):(0,X.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!==cn(t)&&r(ln(e,i))},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},className:b(o,e.type===`number`&&`text-right tabular-nums`)})}function un({runId:e,list:t,editable:n}){let{def:r,rows:i}=t,[a,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)({}),u=`/api/runs/${e}/lists/${r.id}/rows`,d=async e=>{s(null);try{await e()}catch(e){s(e instanceof g?e.message:String(e))}},f=()=>d(async()=>{await N.post(u,{cells:c}),l({})}),p=Object.values(c).some(e=>e!=null&&e!==``);if(!i.length&&!n)return(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:C(`list.empty`)});let m=(e,t)=>t===0||e.type===`text`&&e.format?.style===`multiline`,h=(e,t,n)=>void d(()=>N.patch(`${u}/${e}`,{cells:{[t]:n}}));return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:hidden`,children:[i.map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-1.5`,children:r.columns.map((t,r)=>(0,X.jsxs)(`div`,{className:b(`min-w-0`,m(t,r)&&`col-span-2`),children:[(0,X.jsx)(`div`,{className:`px-1 pb-0.5 text-[0.6875rem] text-ink-3`,children:t.name}),n?(0,X.jsx)($,{boxed:!0,column:t,value:e.cells[t.id],onCommit:n=>h(e.id,t.id,n)}):(0,X.jsx)(`div`,{className:b(`break-words px-1 text-[0.875rem]`,t.type===`number`&&`tabular-nums`),children:J(t,e.cells[t.id],w)||`—`})]},t.id))}),n?(0,X.jsx)(`div`,{className:`mt-1 flex justify-end`,children:(0,X.jsx)(O,{label:C(`list.delete`),onClick:()=>void d(()=>N.del(`${u}/${e.id}`)),children:(0,X.jsx)(L,{className:`size-4`})})}):null]},e.id)),n?(0,X.jsxs)(`div`,{className:`rounded-lg border border-input border-dashed p-2`,children:[(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-1.5`,children:r.columns.map((e,t)=>(0,X.jsxs)(`div`,{className:b(`min-w-0`,m(e,t)&&`col-span-2`),children:[(0,X.jsx)(`div`,{className:`px-1 pb-0.5 text-[0.6875rem] text-ink-3`,children:e.name}),(0,X.jsx)($,{boxed:!0,column:e,value:c[e.id],onCommit:t=>l(n=>({...n,[e.id]:t}))})]},e.id))}),(0,X.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,X.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>p?void f():void 0,children:[(0,X.jsx)(o,{className:`size-4`}),` `,C(`run.addRow`)]})})]}):null]}),(0,X.jsx)(`div`,{className:`hidden overflow-x-auto rounded-lg ring-1 ring-border-soft sm:block`,children:(0,X.jsxs)(`table`,{className:`w-full text-[0.8125rem]`,children:[(0,X.jsx)(`thead`,{className:`bg-paper-2 text-ink-2`,children:(0,X.jsxs)(`tr`,{children:[r.columns.map(e=>(0,X.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 text-left font-medium`,children:e.name},e.id)),n?(0,X.jsx)(`th`,{className:`w-10`}):null]})}),(0,X.jsxs)(`tbody`,{children:[i.map(e=>(0,X.jsxs)(`tr`,{className:`border-border-soft border-t align-top`,children:[r.columns.map(t=>(0,X.jsx)(`td`,{className:b(`min-w-[7.5rem]`,n?`px-1 py-0.5`:`px-3 py-2`),children:n?(0,X.jsx)($,{column:t,value:e.cells[t.id],onCommit:n=>h(e.id,t.id,n)}):(0,X.jsx)(`span`,{className:b(t.type===`number`&&`tabular-nums`),children:J(t,e.cells[t.id],w)})},t.id)),n?(0,X.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,X.jsx)(O,{label:C(`list.delete`),className:`size-9`,onClick:()=>void d(()=>N.del(`${u}/${e.id}`)),children:(0,X.jsx)(L,{className:`size-3.5`})})}):null]},e.id)),n?(0,X.jsxs)(`tr`,{className:`border-border-soft border-t bg-paper`,children:[r.columns.map(e=>(0,X.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,X.jsx)($,{column:e,value:c[e.id],onCommit:t=>l(n=>({...n,[e.id]:t}))})},e.id)),(0,X.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,X.jsx)(O,{label:C(`run.addRow`),className:`size-9`,onClick:()=>p?void f():void 0,children:(0,X.jsx)(o,{className:`size-4`})})})]}):null]})]})}),a?(0,X.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:a}):null]})}function dn(e,t,n){let r=t.split(`/`).map(encodeURIComponent).join(`/`);return a(`/api/runs/${e}/store/files/${r}${n?`?inline=1`:``}`)}var fn=[`bg-paper-3 text-ink-3`,`bg-moss-tint text-moss`,`bg-rose-tint text-rose`,`bg-ember-tint text-ember-strong`];function pn({runId:e,list:t}){let{def:n,rows:r}=t,i=n.columns.find(e=>e.id===n.check?.file),a=n.columns.find(e=>e.id===n.check?.status),o=a?.type===`select`?a.format.options:[],s=o[0]?.id,l=e=>a?String(e.cells[a.id]??s??``):``,u=e=>!a||l(e)===s,[d,f]=(0,Y.useState)(()=>(r.find(u)??r[0])?.id??null),[p,m]=(0,Y.useState)(!1),[h,_]=(0,Y.useState)(null),v=`/api/runs/${e}/lists/${n.id}/rows`,y=r.find(e=>e.id===d)??r[0],x=p?r.filter(e=>u(e)||e.id===y?.id):r,S=r.filter(e=>!u(e)).length,T=n.columns.filter(e=>e!==i&&e!==a),E=T.filter(e=>e.id!==n.key),D=E.find(e=>e.type===`text`)??E[0],O=E.filter(e=>e!==D),k=async(e,t)=>{_(null);try{await N.patch(`${v}/${e}`,{cells:t})}catch(e){_(e instanceof g?e.message:String(e))}},A=e=>{let t=x.findIndex(e=>e.id===y?.id),n=x[Math.min(x.length-1,Math.max(0,t+e))];n&&f(n.id)},M=async e=>{if(!y||!a)return;let t=r.findIndex(e=>e.id===y.id),n=[...r.slice(t+1),...r.slice(0,t)].find(u);await k(y.id,{[a.id]:e}),n&&e!==s&&f(n.id)},P=e=>{e.target.closest(`input, textarea, select`)||(e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),A(e.key===`ArrowDown`?1:-1)):/^[1-9]$/.test(e.key)&&o[Number(e.key)]&&(e.preventDefault(),M(o[Number(e.key)].id)))};if(!r.length)return(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:C(`list.empty`)});let F=i&&y?String(y.cells[i.id]??``).trim():``,I=F.split(`.`).pop()?.toLowerCase()??``,L=e=>fn[Math.min(Math.max(0,o.findIndex(t=>t.id===l(e))),3)];return(0,X.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(280px,360px)_minmax(0,1fr)]`,onKeyDown:P,children:[(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-col`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:C(`check.progress`,{done:S,total:r.length})}),a?(0,X.jsx)(`button`,{type:`button`,"aria-pressed":p,onClick:()=>m(e=>!e),className:b(`inline-flex h-8 items-center rounded-full px-3 text-[0.8125rem] ring-1 transition coarse:h-11`,p?`bg-ember-tint text-ink ring-ember`:`bg-card text-ink-2 ring-input hover:text-ink`),children:C(`check.onlyOpen`)}):null]}),(0,X.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:x.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>f(e.id),"aria-current":e.id===y?.id,className:b(`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,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium text-[0.875rem]`,children:D&&J(D,e.cells[D.id],w)||`—`}),(0,X.jsx)(`span`,{className:`block truncate text-[0.75rem] text-ink-3 tabular-nums`,children:O.slice(0,2).map(t=>J(t,e.cells[t.id],w)).filter(Boolean).join(` · `)})]}),a?(0,X.jsx)(`span`,{className:b(`shrink-0 rounded-full px-2 py-0.5 font-medium text-[0.6875rem]`,L(e)),children:o.find(t=>t.id===l(e))?.label??l(e)}):null]})},e.id))})]}),y?(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[o.length>1?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o.slice(1).map((e,t)=>(0,X.jsxs)(j,{size:`md`,variant:l(y)===e.id?`primary`:`secondary`,onClick:()=>void M(e.id),children:[l(y)===e.id?(0,X.jsx)(c,{className:`size-4`}):null,e.label,(0,X.jsx)(`kbd`,{className:`ml-1 hidden rounded bg-black/10 px-1.5 text-[0.6875rem] lg:inline`,children:t+1})]},e.id)),l(y)===s?null:(0,X.jsx)(j,{size:`md`,variant:`ghost`,onClick:()=>void M(s??``),children:C(`check.reopen`)})]}):null,(0,X.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-paper-2 ring-1 ring-border-soft`,children:F?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 border-border-soft border-b bg-card px-3 py-2 text-[0.8125rem]`,children:[(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-ink-3`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:F.split(`/`).pop()}),(0,X.jsx)(`a`,{href:dn(e,F,I===`pdf`),target:`_blank`,rel:`noreferrer`,className:`shrink-0 text-ink-2 underline-offset-2 hover:text-ink hover:underline`,children:C(`run.openFull`)})]}),I===`pdf`?(0,X.jsx)(`iframe`,{title:F,src:`${dn(e,F,!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]`},F):[`png`,`jpg`,`jpeg`,`webp`].includes(I)?(0,X.jsx)(`div`,{className:`flex max-h-[46vh] justify-center overflow-auto bg-white lg:max-h-[calc(100vh-27rem)]`,children:(0,X.jsx)(`img`,{src:dn(e,F,!0),alt:F,className:`max-w-full object-contain`},F)}):(0,X.jsx)(`p`,{className:`px-4 py-10 text-center text-[0.875rem] text-ink-3`,children:C(`check.noPreview`)})]}):(0,X.jsx)(`p`,{className:`px-4 py-14 text-center text-[0.875rem] text-ink-3`,children:C(`check.noFile`)})}),(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3`,children:T.map(e=>(0,X.jsxs)(`div`,{className:b(`min-w-0`,e.type===`text`&&e.format?.style===`multiline`&&`col-span-full`),children:[(0,X.jsx)(`div`,{className:`px-1 pb-0.5 text-[0.6875rem] text-ink-3`,children:e.name}),(0,X.jsx)($,{boxed:!0,column:e,value:y.cells[e.id],onCommit:t=>void k(y.id,{[e.id]:t})})]},e.id))}),h?(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:h}):null]}):null]})}var mn={xlsx:`Excel`,csv:`CSV`,json:`JSON`,md:`Markdown`,zip:`ZIP`};function hn({runId:e,list:t}){return(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.formats.map(n=>(0,X.jsx)(`a`,{href:a(`/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-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink coarse:h-11 coarse:px-4`,children:mn[n]??n},n))})}function gn(e){return e>1e6?`${(e/1e6).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1e3))} KB`}function _n({runId:e}){let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{t&&(s(!1),N.get(`/api/runs/${e}/store`).then(i))},[t,e]);let l=r&&!r.files.length&&!r.connections.length&&!r.keepsSignIns&&r.lists.every(e=>!e.rows);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),className:`inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-4 transition hover:text-ink-2 coarse:min-h-11`,children:[(0,X.jsx)(le,{className:`size-3.5`}),` `,C(`store.open`)]}),(0,X.jsx)(S,{open:t,onClose:()=>n(!1),title:C(`store.title`),wide:!0,children:r?(0,X.jsxs)(`div`,{className:`flex flex-col gap-5 text-[0.875rem]`,children:[(0,X.jsx)(`p`,{className:`text-ink-3`,children:C(`store.explain`)}),l?(0,X.jsx)(`p`,{className:`text-ink-2`,children:C(`store.empty`)}):null,r.lists.some(e=>e.rows)?(0,X.jsx)(`ul`,{className:`flex flex-col gap-1`,children:r.lists.filter(e=>e.rows).map(e=>(0,X.jsxs)(`li`,{className:`flex justify-between gap-3`,children:[(0,X.jsx)(`span`,{children:e.title}),(0,X.jsx)(`span`,{className:`text-ink-3 tabular-nums`,children:C(`store.rows`,{n:e.rows})})]},e.id))}):null,r.connections.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(I,{className:`size-4 text-ink-3`}),` `,e.account?.label]},e.id)),r.keepsSignIns?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(c,{className:`size-4 text-ink-3`}),` `,C(`store.signIns`)]}):null,r.files.length?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-ink-3`,children:C(`store.files`,{n:r.files.length,size:gn(r.files.reduce((e,t)=>e+t.size,0))})}),(0,X.jsx)(`ul`,{className:`max-h-56 overflow-y-auto rounded-lg ring-1 ring-border-soft`,children:r.files.map(t=>(0,X.jsx)(`li`,{className:`border-border-soft border-b last:border-0`,children:(0,X.jsxs)(`a`,{href:a(`/api/runs/${e}/store/files/${t.path}`),className:`flex items-center gap-2 px-3 py-2 text-[0.8125rem] hover:bg-paper-2 coarse:min-h-11`,title:t.source??void 0,children:[(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-ink-3`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.path}),(0,X.jsx)(`span`,{className:`text-ink-4 tabular-nums`,children:gn(t.size)})]})},t.path))})]}):null,(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-1`,children:[l?(0,X.jsx)(`span`,{}):o?(0,X.jsxs)(j,{variant:`secondary`,onClick:async()=>{await N.del(`/api/runs/${e}/store`),i(await N.get(`/api/runs/${e}/store`)),s(!1)},children:[(0,X.jsx)(L,{className:`size-4`}),` `,C(`store.confirmDelete`)]}):(0,X.jsxs)(j,{variant:`ghost`,onClick:()=>s(!0),children:[(0,X.jsx)(L,{className:`size-4`}),` `,C(`store.delete`)]}),(0,X.jsx)(j,{onClick:()=>n(!1),children:C(`common.close`)})]})]}):(0,X.jsx)(`div`,{className:`flex justify-center py-8 text-ink-4`,children:(0,X.jsx)(y,{})})})]})}var vn=300;function yn(){if(typeof MediaRecorder<`u`)return[`audio/webm;codecs=opus`,`audio/mp4`,`audio/webm`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function bn(e){return`${Math.floor(e/60)}:${String(Math.floor(e%60)).padStart(2,`0`)}`}function xn({value:e,runId:t,onChange:n,onBusy:r}){let i=ve(e)?e:null,[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(0),[l,d]=(0,Y.useState)(!1),[f,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(null),b=(0,Y.useRef)(null),x=(0,Y.useRef)(null),S=yn(),w=re&&!!S;(0,Y.useEffect)(()=>()=>{b.current&&(b.current.recorder.onstop=null,b.current.stop())},[]),(0,Y.useEffect)(()=>()=>{_&&URL.revokeObjectURL(_.url)},[_]);let T=async(e,i)=>{d(!0),r?.(!0),m(null);try{let r=await N.upload(`/api/runs/${t}/uploads`,e);v({asset:r.id,url:URL.createObjectURL(e)}),n({asset:r.id,...i===void 0?{}:{seconds:i}})}catch(e){m(e.message)}finally{d(!1),r?.(!1)}},E=async()=>{m(null),g(!1);let e;try{e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}})}catch{g(!0);return}let t=[],n=new MediaRecorder(e,{mimeType:S,audioBitsPerSecond:48e3}),i=Date.now(),a=new AudioContext,s=a.createAnalyser();s.fftSize=256,a.createMediaStreamSource(e).connect(s);let l=new Uint8Array(s.fftSize),u=0,d=()=>{s.getByteTimeDomainData(l);let e=0;for(let t of l)e=Math.max(e,Math.abs(t-128));if(c(Math.min(1,e/64)),o((Date.now()-i)/1e3),(Date.now()-i)/1e3>=vn){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,o(null),c(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));T(new File(t,`sprachnotiz-${Nt()}.${r}`,{type:e}),a)},b.current={recorder:n,stop:f},r?.(!0),n.start(1e3),u=requestAnimationFrame(d)},D=a!==null,O=(0,X.jsxs)(j,{variant:`secondary`,onClick:()=>x.current?.click(),children:[(0,X.jsx)(Pe,{className:`size-4`}),` `,C(`voice.pick`)]});return(0,X.jsxs)(`div`,{children:[D?(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-ember`,children:[(0,X.jsxs)(`span`,{className:`relative flex size-11 shrink-0 items-center justify-center`,children:[(0,X.jsx)(`span`,{className:`absolute inset-0 rounded-full bg-rose-tint transition-transform duration-75`,style:{transform:`scale(${.7+s*.5})`}}),(0,X.jsx)(`span`,{className:`relative size-3.5 animate-pulse-dot rounded-full bg-rose`})]}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`font-medium text-[0.9375rem] tabular-nums`,children:bn(a)}),(0,X.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:a>270?C(`voice.left`,{s:Math.ceil(vn-a)}):C(`voice.recording`)})]}),(0,X.jsxs)(j,{onClick:()=>b.current?.stop(),children:[(0,X.jsx)(p,{className:`size-3.5 fill-current`}),` `,C(`voice.stop`)]})]}):l?(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-4 text-[0.875rem] text-ink-3 ring-1 ring-input`,children:[(0,X.jsx)(y,{className:`size-4`}),` `,C(`run.uploading`)]}):i?(0,X.jsxs)(`div`,{className:`rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,X.jsx)(`audio`,{controls:!0,preload:`metadata`,src:_?.asset===i.asset?_.url:`/api/runs/${t}/assets/${i.asset}`,className:`h-11 w-full`}),i.transcript?(0,X.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap px-1 text-[0.875rem] text-ink-2 leading-relaxed`,children:i.transcript}):null,(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:i.seconds?bn(i.seconds):null}),(0,X.jsxs)(`div`,{className:`flex gap-1`,children:[w?(0,X.jsxs)(j,{variant:`ghost`,size:`sm`,onClick:()=>void E(),children:[(0,X.jsx)(W,{className:`size-3.5`}),` `,C(`voice.again`)]}):null,(0,X.jsx)(j,{variant:`ghost`,size:`sm`,onClick:()=>n(void 0),children:C(`voice.remove`)})]})]})]}):(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[w?(0,X.jsxs)(j,{variant:`secondary`,size:`lg`,onClick:()=>void E(),className:`w-full sm:w-auto`,children:[(0,X.jsx)(u,{className:`size-4`}),` `,C(`voice.start`)]}):O,w&&h?O:null]}),h?(0,X.jsx)(`p`,{className:`mt-2 rounded-lg bg-amber-tint px-3 py-2 text-[0.8125rem] text-ink-2 leading-relaxed`,children:C(`voice.denied`)}):(0,X.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3 leading-relaxed`,children:C(w?`voice.why`:`voice.noRecorder`)})]}),(0,X.jsx)(`input`,{ref:x,type:`file`,hidden:!0,accept:`audio/*`,capture:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&T(t,void 0)}}),f?(0,X.jsx)(`div`,{className:`mt-2 text-[0.8125rem] text-rose`,children:f}):null]})}function Sn(e,t){try{return new Intl.NumberFormat(void 0,{style:`currency`,currency:t}).format(e)}catch{return`${e.toFixed(2)} ${t}`}}function Cn({field:e,value:t,values:n,onChange:r}){let i=e.columns??[],a=Array.isArray(t)&&t.length?t:[{}],s=be(e,a,n),c=(e,t,n)=>{r(a.map((r,i)=>i===e?{...r,[t]:n}:r))},l=i.map(e=>e.kind===`text`&&e===i[0]?`minmax(0,3fr)`:`minmax(0,1fr)`).join(` `);return(0,X.jsxs)(`div`,{className:`rounded-xl bg-card p-2 ring-1 ring-input`,children:[(0,X.jsx)(`div`,{className:`hidden gap-2 px-2 pt-1 pb-2 text-[0.75rem] text-ink-3 sm:grid`,style:{gridTemplateColumns:`${l} 36px`},children:i.map(e=>(0,X.jsx)(`div`,{className:e.kind===`text`?``:`text-right`,children:e.label},e.id))}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map((e,t)=>(0,X.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":`${l} 36px`},children:[i.map((n,r)=>(0,X.jsxs)(`label`,{className:b(`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,X.jsx)(`span`,{className:`px-0.5 text-[0.6875rem] text-ink-3 sm:hidden`,children:n.label}),(0,X.jsx)(`input`,{"aria-label":n.label,placeholder:n.label,inputMode:n.kind===`text`?`text`:`decimal`,autoComplete:`off`,value:String(e[n.id]??``),onChange:e=>c(t,n.id,e.target.value),className:b(`h-11 w-full min-w-0 rounded-md border border-transparent bg-paper-2 px-2.5 text-[0.875rem] 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,X.jsx)(O,{label:C(`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,X.jsx)(L,{className:`size-4`})})]},t))}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-end justify-between gap-3 px-2 pb-1`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r([...a,{}]),className:`inline-flex h-9 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-2 hover:bg-accent coarse:h-11`,children:[(0,X.jsx)(o,{className:`size-4`}),` `,C(`run.addRow`)]}),(0,X.jsxs)(`div`,{className:`text-right text-[0.8125rem] tabular-nums`,children:[(0,X.jsxs)(`div`,{className:`text-ink-3`,children:[C(`run.net`),` `,Sn(s.net,s.currency)]}),s.vatRate?(0,X.jsxs)(`div`,{className:`text-ink-3`,children:[C(`run.vat`,{r:s.vatRate}),` `,Sn(s.vat,s.currency)]}):null,(0,X.jsxs)(`div`,{className:`font-semibold text-[0.9375rem] text-ink`,children:[C(`run.total`),` `,Sn(s.gross,s.currency)]})]})]})]})}function wn(e){return!!e?.closest(`input, textarea, [contenteditable='true']`)}function Tn({field:e,value:t,runId:n,onChange:r,onBusy:i}){let o=(0,Y.useRef)(null),s=(0,Y.useRef)(null),c=(0,Y.useRef)(null),u=(0,Y.useRef)(null),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)({}),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(null),E=(0,Y.useRef)(null),D=e=>{E.current=e,T(e)},k=e.kind===`image`,A=!!e.multiple,j=A?e.max??30:1,M=k||!!e.camera||!!e.video,P=!k&&!!e.video,F=Array.isArray(t)?t:typeof t==`string`&&t?[t]:[],I=(0,Y.useRef)(F);I.current=F;let L=F.length<j,R=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 a=j-(A?I.current.length:0);p(!0),i?.(!0),_(t.length>a&&A?C(`run.maxFiles`,{n:j}):null);try{for(let e of t.slice(0,Math.max(0,a))){let t=await Mt(e),i=await N.upload(`/api/runs/${n}/uploads`,t);h(e=>({...e,[i.id]:{name:i.name,mime:i.mime}}));let a=A?[...I.current,i.id]:i.id;I.current=A?a:[i.id],r(a)}}catch(e){_(e.message)}finally{p(!1),i?.(!1)}},z=(0,Y.useRef)(R);z.current=R;let te=e=>{let t=F.filter(t=>t!==e);r(A?t:void 0)},B=(e,t)=>{let n=I.current.indexOf(e),i=Math.min(I.current.length-1,Math.max(0,t));if(n<0||n===i)return;let a=I.current.filter(t=>t!==e);a.splice(i,0,e),I.current=a,r(a)},V=A&&F.length>1;(0,Y.useEffect)(()=>{if(!L)return;let e=e=>{let t=Array.from(e.clipboardData?.files??[]),n=o.current;if(!t.length||!n||wn(document.activeElement))return;let r=document.querySelectorAll(`[data-upload-field]`);(n.matches(`:hover`)||n.contains(document.activeElement)||r.length===1)&&(e.preventDefault(),z.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[L]);let H=b(`flex flex-col items-center justify-center gap-2 rounded-xl border border-input border-dashed bg-card px-3 text-[0.875rem] text-ink-3 transition hover:border-ember hover:text-ink`,F.length?`py-4`:`py-8`);return(0,X.jsxs)(`div`,{ref:o,"data-upload-field":``,onDragOver:e=>{L&&(e.preventDefault(),S(!0))},onDragLeave:()=>S(!1),onDrop:e=>{S(!1),L&&(e.preventDefault(),R(Array.from(e.dataTransfer.files)))},children:[F.length?(0,X.jsx)(`div`,{className:`mb-2 flex flex-col gap-2`,children:F.map((e,t)=>{let r=m[e],i=r?.mime??(k?`image/`:``);return(0,X.jsxs)(`div`,{"data-file-id":e,className:b(`flex items-center gap-3 rounded-xl bg-card p-2 ring-1 ring-input transition-shadow`,w===e&&`relative z-10 shadow-elevated ring-2 ring-ember`),children:[V?(0,X.jsxs)(`button`,{type:`button`,"aria-label":C(`run.moveFile`,{n:t+1}),title:C(`run.moveFileHint`),className:b(`-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`,w===e?`cursor-grabbing`:`cursor-grab`),onPointerDown:t=>{try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}D(e)},onPointerMove:t=>{if(E.current!==e)return;let n=document.elementFromPoint(t.clientX,t.clientY)?.closest(`[data-file-id]`),r=n?.getAttribute(`data-file-id`);r&&r!==e&&o.current?.contains(n??null)&&B(e,I.current.indexOf(r))},onPointerUp:()=>D(null),onPointerCancel:()=>D(null),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),B(e,t+(n.key===`ArrowUp`?-1:1)))},children:[(0,X.jsx)(`span`,{className:`font-medium text-[0.75rem] tabular-nums`,children:t+1}),(0,X.jsx)(He,{className:`size-4`})]}):null,i.startsWith(`image/`)?(0,X.jsx)(`img`,{src:a(`/api/runs/${n}/assets/${e}`),alt:``,className:`size-14 rounded-lg object-cover`}):(0,X.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-lg bg-paper-2`,children:i.startsWith(`video/`)?(0,X.jsx)(Ie,{className:`size-5 text-ink-3`}):(0,X.jsx)(l,{className:`size-5 text-ink-3`})}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:r?.name??`✓`}),(0,X.jsx)(O,{label:C(`run.removeFile`),onClick:()=>te(e),children:(0,X.jsx)(d,{className:`size-4`})})]},e)})}):null,L?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>s.current?.click(),className:b(H,`min-w-[9rem] flex-1 px-4`,x&&`border-ember text-ink`),children:[k?(0,X.jsx)(We,{className:`size-6`}):(0,X.jsx)(l,{className:`size-6`}),f?C(`run.uploading`):F.length?C(`run.uploadMore`):C(U?`run.uploadTouch`:`run.upload`)]}),M?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>re?y(!0):c.current?.click(),className:b(H,`w-28`),children:[(0,X.jsx)(Oe,{className:`size-6`}),C(`run.camera`)]}):null,P&&!(re&&Ut)?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>u.current?.click(),className:b(H,`w-28`),children:[(0,X.jsx)(ee,{className:`size-6`}),C(`camera.video`)]}):null]}):null,(0,X.jsx)(`input`,{ref:s,type:`file`,hidden:!0,multiple:A,accept:k?`image/*`:void 0,onChange:e=>{R(Array.from(e.target.files??[])),e.target.value=``}}),(0,X.jsx)(`input`,{ref:c,type:`file`,hidden:!0,accept:`image/*`,capture:`environment`,onChange:e=>{R(Array.from(e.target.files??[])),e.target.value=``}}),P?(0,X.jsx)(`input`,{ref:u,type:`file`,hidden:!0,accept:`video/*`,capture:`environment`,onChange:e=>{R(Array.from(e.target.files??[])),e.target.value=``}}):null,(0,X.jsx)(Wt,{open:v,multiple:A,video:P,onClose:()=>y(!1),onCapture:e=>R([e]),onNative:()=>c.current?.click()}),A&&(e.min||e.max)?(0,X.jsx)(`div`,{className:`mt-2 text-[0.8125rem] text-ink-3 tabular-nums`,children:e.min&&F.length<e.min?C(`run.filesMin`,{n:F.length,min:e.min}):e.max?C(`run.filesOf`,{n:F.length,max:e.max}):null}):null,g?(0,X.jsx)(`div`,{className:`mt-2 text-[0.8125rem] text-rose`,children:g}):null]})}function En(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 Dn({field:e,value:t,onChange:n}){let[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(A,{value:t,placeholder:e.placeholder,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,onChange:e=>n(e.target.value)}),(0,X.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-[0.875rem] text-ink-2 transition hover:border-ember hover:text-ink`,children:[(0,X.jsx)(st,{className:`size-4`}),` `,C(`scan.button`)]}),(0,X.jsx)(Qt,{open:r,onClose:()=>i(!1),onResult:n})]})}var On=4;function kn(e){let t=new Map,n=e.map(e=>({value:e,slot:me(e)})).filter(e=>e.slot).sort((e,t)=>Date.parse(e.value)-Date.parse(t.value));for(let{value:e,slot:r}of n){if(!r)continue;let n=t.get(r.day)??{label:he(e,w),times:[]};n.times.push({value:e,time:r.time}),t.set(r.day,n)}return[...t.values()]}function An({name:e,label:t,options:n,value:r,onChange:i,disabled:a}){let o=kn(n),s=o.findIndex(e=>e.times.some(e=>e.value===r)),[c,l]=(0,Y.useState)(s>=On);if(!o.length)return(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:C(`slot.none`)});let u=c?o:o.slice(0,On);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:t}),u.map(t=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-2 font-medium text-[0.75rem] text-ink-3`,children:t.label}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.times.map(n=>(0,X.jsxs)(`label`,{className:`relative`,children:[(0,X.jsx)(`input`,{type:`radio`,name:`slot-${e}`,value:n.value,checked:n.value===r,disabled:a.has(n.value),"aria-label":`${t.label}, ${n.time}`,onChange:()=>i(n.value),className:`peer sr-only`}),(0,X.jsx)(`span`,{className:b(`inline-flex h-10 cursor-pointer items-center rounded-full border px-4 text-sm tabular-nums transition coarse:h-11`,`border-input bg-card text-ink-2 hover:border-ink-4 hover:text-ink`,`peer-checked:border-ember peer-checked:bg-ember-tint peer-checked:text-ink`,`peer-disabled:pointer-events-none peer-disabled:line-through peer-disabled:opacity-60`,`peer-focus-visible:outline-[1.5px] peer-focus-visible:outline-offset-2 peer-focus-visible:outline-(--focus-line) peer-focus-visible:outline-solid`),children:n.time})]},n.value))})]},t.label))]}),o.length>u.length?(0,X.jsx)(`button`,{type:`button`,onClick:()=>l(!0),className:`self-start text-[0.8125rem] text-ink-3 underline-offset-4 transition hover:text-ink hover:underline coarse:min-h-11`,children:C(`slot.later`)}):null]})}function jn({field:e,value:t,values:n,runId:r,view:i,onChange:a,onBusy:o,error:s,closed:c}){let l=t==null?``:String(t),u=new Set(c?.values.map(String)),d;switch(e.kind){case`textarea`:d=(0,X.jsx)(x,{value:l,placeholder:e.placeholder,autoCapitalize:`sentences`,enterKeyHint:`enter`,onChange:e=>a(e.target.value)});break;case`number`:d=(0,X.jsx)(A,{inputMode:`decimal`,autoComplete:`off`,value:l,placeholder:e.placeholder,onChange:e=>a(e.target.value)});break;case`select`:{let t=e.options??[];d=t.length<=5&&t.every(e=>e.length<=28)?(0,X.jsx)(M,{value:l,options:t,onChange:a,disabled:[...u]}):(0,X.jsx)(v,{value:l,placeholder:`—`,onChange:a,options:t.map(e=>({value:e,label:e,disabled:u.has(e)}))});break}case`slot`:d=(0,X.jsx)(An,{name:e.id,label:e.label,options:e.options??[],value:l,onChange:a,disabled:u});break;case`multiselect`:d=(0,X.jsx)(M,{multi:!0,value:Array.isArray(t)?t:[],options:e.options??[],onChange:a});break;case`date`:d=(0,X.jsx)(A,{type:`date`,value:l,onChange:e=>a(e.target.value),className:`w-full sm:w-56`});break;case`email`:d=(0,X.jsx)(A,{type:`email`,inputMode:`email`,autoComplete:`email`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,value:l,placeholder:e.placeholder,onChange:e=>a(e.target.value)});break;case`url`:d=(0,X.jsx)(A,{type:`url`,inputMode:`url`,autoComplete:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,value:l,placeholder:e.placeholder??`https://`,onChange:e=>a(e.target.value)});break;case`toggle`:d=(0,X.jsx)(E,{checked:t===!0,onChange:a,label:e.label,disabled:u.has(String(t!==!0))});break;case`color`:d=(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(k,{value:l||`#e0531b`,onChange:e=>a(e.target.value)}),(0,X.jsx)(A,{value:l,placeholder:`#e0531b`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,onChange:e=>a(e.target.value),className:`w-36`})]});break;case`image`:case`file`:d=(0,X.jsx)(Tn,{field:e,value:t,runId:r,onChange:a,onBusy:o});break;case`items`:d=(0,X.jsx)(Cn,{field:e,value:t,values:n,onChange:a});break;case`connection`:d=(0,X.jsx)(sn,{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);d=t?(0,X.jsx)(un,{runId:r,list:t,editable:!0}):null;break}case`location`:d=(0,X.jsx)(Jt,{value:t,runId:r,placeholder:e.placeholder,onChange:a,onBusy:o});break;case`audio`:d=c?null:(0,X.jsx)(xn,{value:t,runId:r,onChange:a,onBusy:o});break;case`signature`:d=(0,X.jsx)(an,{label:e.label,value:t,runId:r,onChange:a});break;default:d=e.scan?(0,X.jsx)(Dn,{field:e,value:l,onChange:a}):(0,X.jsx)(A,{...En(e),value:l,placeholder:e.placeholder,onChange:e=>a(e.target.value)})}return(0,X.jsxs)(`div`,{children:[e.kind===`toggle`?(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-6`,children:[(0,X.jsx)(_,{hint:e.help,children:e.label}),d]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_,{hint:e.help,required:e.required,children:e.label}),d]}),c?(0,X.jsx)(`div`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:C(`run.closed`,{list:c.classes.map(e=>C(`run.cls.${Mn[e]}`)).join(`, `)})}):null,s?(0,X.jsx)(`div`,{className:`mt-1.5 text-[0.8125rem] text-rose`,children:s}):null]})}var Mn={classifier:`text`,standard:`text`,high:`text`,highest:`text`,image:`image`,video:`video`,speech:`speech`,audio:`audio`},Nn=45e3;function Pn(e){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)({});(0,Y.useEffect)(()=>{if(n(null),s(!1),!e)return;let t=!1,r=0,i,o=null,c=Date.now(),l=()=>{t=!0,o?.close(),s(!0)},u=async()=>{try{let r=await N.get(`/api/runs/${e}`);t||n(r)}catch(e){e instanceof g&&e.status===404&&l()}},d=()=>{if(clearTimeout(i),o?.close(),t)return;let s=new EventSource(a(`/api/runs/${e}/stream`),{withCredentials:!0});o=s,c=Date.now(),s.addEventListener(`view`,e=>{r=0,c=Date.now(),n(JSON.parse(e.data))}),s.addEventListener(`ping`,()=>{c=Date.now()}),s.onerror=()=>{s.close(),!(t||o!==s)&&(o=null,u(),r=Math.min(r+1,6),i=setTimeout(d,500*2**r))}},f=()=>{t||document.visibilityState!==`visible`||(!o||o.readyState===EventSource.CLOSED||Date.now()-c>Nn?(r=0,d()):u())},p=setInterval(()=>{!t&&o&&Date.now()-c>Nn&&(r=0,d())},15e3);return d(),document.addEventListener(`visibilitychange`,f),window.addEventListener(`pageshow`,f),window.addEventListener(`online`,f),()=>{t=!0,clearTimeout(i),clearInterval(p),document.removeEventListener(`visibilitychange`,f),window.removeEventListener(`pageshow`,f),window.removeEventListener(`online`,f),o?.close()}},[e]);let f=(0,Y.useCallback)(async(t,n)=>{if(!e)return!1;l(!0),i(null),d({});try{return await N.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof g&&e.status===422&&Array.isArray(e.body?.fields)&&d(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),i(e.message),!1}finally{l(!1)}},[e]);return{view:t,notFound:o,error:r,busy:c,fieldErrors:u,submitPage:(e,t)=>f(`pages/${e}`,{values:t}),accept:(e,t)=>f(`reviews/${e}`,{type:`accept`,edits:t}),regenerate:(e,t,n,r)=>f(`reviews/${e}`,{type:`regenerate`,target:t,note:n,items:r?.length?r:void 0}),back:()=>f(`back`),retry:()=>f(`retry`)}}function Fn({view:e}){let t=Math.round(Math.min(e.progress.done,e.progress.total)/Math.max(1,e.progress.total)*100);return(0,X.jsx)(`div`,{className:`h-[3px] w-full bg-paper-2`,children:(0,X.jsx)(`div`,{className:`h-full bg-ember transition-[width] duration-700 ease-out`,style:{width:`${t}%`}})})}function In({title:e,description:t,kicker:n}){return(0,X.jsxs)(`div`,{className:`mb-8`,children:[n?(0,X.jsx)(`p`,{className:`mb-4 text-[0.9375rem] text-ink-2 leading-relaxed`,children:n}):null,(0,X.jsx)(`h1`,{className:`font-display font-semibold text-[1.75rem] leading-[1.15] tracking-tight sm:text-[2rem]`,children:e}),t?(0,X.jsx)(`p`,{className:`mt-2 text-[0.9375rem] text-ink-3 leading-relaxed`,children:t}):null]})}function Ln(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 Rn(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 zn({view:e,run:t,step:n}){let[r,i]=(0,Y.useState)(()=>Ln(n,e)),[a,o]=(0,Y.useState)(new Set),s=(0,Y.useRef)(null),c=e.progress.done===0,l=(0,Y.useMemo)(()=>n.fields.filter(t=>!_e(t)||e.decidedFields?.includes(t.id)).map(t=>e.options?.[t.id]?.length?{...t,options:e.options[t.id]}:t),[n.fields,e.options,e.decidedFields]),u=ye(l,e.known??{},r),d=()=>void t.submitPage(n.id,r);return(0,Y.useEffect)(()=>{if(!s.current)return;let e=Rn(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,X.jsxs)(`form`,{ref:s,className:`animate-rise`,onSubmit:e=>{e.preventDefault(),a.size||d()},onKeyDown:e=>{let t=e.target;if(e.key!==`Enter`||e.defaultPrevented||e.nativeEvent.isComposing||!(t instanceof HTMLInputElement)||t.closest(`dialog`))return;let n=Rn(e.currentTarget),r=n[n.indexOf(t)+1];r&&(e.preventDefault(),r.focus())},children:[(0,X.jsx)(In,{title:n.title,description:n.description,kicker:c?e.wizard.intro:null}),(0,X.jsx)(`div`,{className:`flex flex-col gap-7`,children:u.map(n=>(0,X.jsx)(jn,{field:n,value:r[n.id],values:r,runId:e.id,view:e,error:t.fieldErrors[n.id],closed:e.closed?.[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,X.jsx)(Bn,{view:e,run:t,sticky:!0,children:(0,X.jsxs)(j,{type:`submit`,size:`lg`,busy:t.busy,disabled:a.size>0,children:[n.cta||C(`run.next`),` `,(0,X.jsx)(P,{className:`size-4`})]})})]})}function Bn({view:e,run:t,sticky:n,children:r}){return(0,X.jsxs)(`div`,{className:b(`mt-10 flex items-center justify-between gap-3`,n&&`action-bar`),children:[e.canBack?(0,X.jsxs)(j,{variant:`ghost`,onClick:()=>void t.back(),disabled:t.busy,children:[(0,X.jsx)(h,{className:`size-4`}),` `,C(`run.back`)]}):(0,X.jsx)(`span`,{}),r]})}function Vn(){let e=de(),[t,n]=(0,Y.useState)(!1),r=e!==`off`;return(0,X.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:t,onClick:async()=>{if(r){ue();return}n(!0),await pe(),n(!1)},className:b(`inline-flex h-11 items-center gap-2 rounded-full px-4 font-medium text-[0.875rem] 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,X.jsx)(we,{className:`size-4 text-ember-strong`}):(0,X.jsx)(Ee,{className:`size-4`}),C(r?`notify.on`:`notify.ask`)]}),(0,X.jsx)(`p`,{className:`max-w-xs text-[0.75rem] text-ink-4 leading-relaxed`,children:C(e===`off`?`notify.why`:e===`on`?`notify.onHint`:fe()?`notify.blocked`:`notify.quiet`)})]})}function Hn({view:e,compact:t,awake:n}){let i=(0,Y.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,Y.useState)(Date.now());(0,Y.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??C(`run.working`),l=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=i-500),u=l.slice(-4),d=[...new Set(l.map(e=>e.asset).filter(e=>!!e))],p=[...l].reverse().find(e=>e.asset)?.asset;return(0,X.jsxs)(`div`,{className:`flex animate-rise flex-col items-center pt-6 text-center`,children:[(0,X.jsx)(r,{kind:e.wizard.avatar,size:t?130:170,fluffy:!0}),(0,X.jsx)(`h2`,{className:`mt-4 font-display font-semibold text-[1.375rem] tracking-tight`,children:c}),(0,X.jsx)(`div`,{className:`mt-1 text-[0.8125rem] text-ink-4 tabular-nums`,children:C(`run.elapsed`,{s:Math.max(0,Math.round((o-i)/1e3))})}),d.length?(0,X.jsx)(`div`,{className:`mt-5 flex max-w-full flex-wrap justify-center gap-2`,children:d.slice(-8).map(t=>(0,X.jsx)(`img`,{src:a(`/api/runs/${e.id}/assets/${t}`),alt:``,className:b(`size-16 animate-rise rounded-lg bg-paper-2 object-cover ring-1 ring-border-soft transition sm:size-20`,t===p?`ring-2 ring-ember`:`opacity-70`)},t))}):null,(0,X.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,X.jsxs)(`div`,{className:b(`flex items-center justify-center gap-2 text-[0.8125rem] transition-opacity`,t===u.length-1?`text-ink-2`:`text-ink-4`),children:[t===u.length-1?(0,X.jsx)(ce,{className:`size-3.5 animate-breathe text-ember`}):null,(0,X.jsx)(`span`,{className:`truncate`,children:f(e)})]},e.id))}),t?null:(0,X.jsx)(Vn,{}),n?(0,X.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-4`,children:C(`run.awake`)}):null]})}function Un(e){let t=(0,Y.useRef)({running:!1,since:0,ask:null});(0,Y.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}`),H({title:e.wizard.title,body:t,tag:e.id})};r&&e.ask&&e.ask.id!==n.ask?a(C(`notify.needsYou`)):!r&&n.running&&Date.now()-n.since>8e3&&a(e.status===`failed`?C(`run.failed`):e.status===`done`?C(`notify.done`):C(`notify.next`)),t.current={running:r,since:i,ask:e.ask?.id??null}},[e]),(0,Y.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 Wn({view:e,run:t,step:n}){let[r,i]=(0,Y.useState)({}),[a,o]=(0,Y.useState)({}),[s,c]=(0,Y.useState)(``),l=e.shown.filter(e=>e.output),[u,d]=(0,Y.useState)(l.length===1?l[0].step.id:null),[f,p]=(0,Y.useState)({}),m=(0,Y.useRef)(null),h=l.find(e=>e.step.id===u),g=h?.step.type===`generate`&&(h.output?.assets?.length??0)>1,_=()=>{h&&s.trim()&&t.regenerate(n.id,h.step.id,s.trim(),f[h.step.id])};return(0,X.jsxs)(`div`,{className:`animate-rise`,children:[(0,X.jsx)(In,{title:n.title,description:n.description}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[e.shown.filter(e=>e.output).map(({step:t,output:s})=>{let c=!!n.edit&&t.type===`agent`&&t.output.format!==`json`;return(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h3`,{className:`font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.06em]`,children:t.title}),(0,X.jsx)(`div`,{className:`flex items-center`,children:c&&!a[t.id]?(0,X.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-[0.8125rem] text-ink-2 hover:bg-accent hover:text-ink coarse:h-11`,children:[(0,X.jsx)(it,{className:`size-3.5`}),` `,C(`run.edit`)]}):null})]}),(0,X.jsx)(se,{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:f[t.id],onPick:n.regenerate?e=>{d(t.id),p(n=>{let r=n[t.id]??[];return{...n,[t.id]:r.includes(e)?r.filter(t=>t!==e):[...r,e]}}),m.current?.focus()}:void 0,onSurfaceAction:n.regenerate?()=>{d(t.id),m.current?.focus()}:void 0})]},t.id)}),e.lists.map(t=>(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.06em]`,children:t.def.title}),t.def.check?(0,X.jsx)(pn,{runId:e.id,list:t}):(0,X.jsx)(un,{runId:e.id,list:t,editable:!0})]},t.def.id)),n.regenerate&&l.length?(0,X.jsxs)(D,{className:`p-3`,children:[l.length>1?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 px-1 pb-2`,children:[(0,X.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:C(`run.feedbackTarget`)}),l.map(({step:e})=>(0,X.jsx)(`button`,{type:`button`,"aria-pressed":u===e.id,onClick:()=>{d(e.id),m.current?.focus()},className:b(`inline-flex h-8 items-center rounded-full px-3 text-[0.8125rem] ring-1 transition coarse:h-11`,u===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,X.jsx)(x,{ref:m,minRows:2,maxRows:8,value:s,placeholder:C(`run.feedbackPlaceholder`),onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),_())},className:`border-0 bg-transparent shadow-none focus:ring-0`}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1 pt-1`,children:[(0,X.jsx)(`span`,{className:`min-w-0 text-[0.75rem] text-ink-3`,children:g?f[h.step.id]?.length?C(`run.regeneratePicked`,{n:[...f[h.step.id]].sort((e,t)=>e-t).map(e=>e+1).join(`, `)}):C(`run.regenerateAll`):!h&&s.trim()?C(`run.feedbackPick`):null}),(0,X.jsxs)(j,{size:`sm`,variant:`secondary`,busy:t.busy,disabled:!s.trim()||!h,onClick:_,children:[(0,X.jsx)(z,{className:`size-3.5`}),` `,C(`run.regenerateGo`)]})]})]}):null]}),(0,X.jsx)(Bn,{view:e,run:t,sticky:!0,children:(0,X.jsxs)(j,{size:`lg`,busy:t.busy,onClick:()=>void t.accept(n.id,Object.keys(r).length?r:void 0),children:[C(`run.accept`),` `,(0,X.jsx)(P,{className:`size-4`})]})})]})}function Gn({view:e,run:t,step:n,onRestart:i}){let a=e.shown.filter(e=>e.output);return(0,X.jsxs)(`div`,{className:`animate-rise`,children:[(0,X.jsxs)(`div`,{className:`mb-8 flex flex-wrap items-center gap-x-4 gap-y-5`,children:[(0,X.jsx)(r,{kind:e.wizard.avatar,size:64}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 basis-[12rem]`,children:[(0,X.jsx)(`h1`,{className:`text-balance font-display font-semibold text-[1.75rem] leading-tight tracking-tight sm:text-[2rem]`,children:n.title}),n.message?(0,X.jsx)(`p`,{className:`mt-1 text-[0.9375rem] text-ink-3`,children:n.message}):null]}),e.shown.some(e=>e.output)?(0,X.jsx)(`div`,{className:`max-sm:basis-full`,children:(0,X.jsx)(Dt,{runId:e.id,title:`${n.title} · ${e.wizard.title}`,initial:e.shareUrl?{url:e.shareUrl,expiresAt:e.expiresAt}:null})}):null]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[a.map(({step:t,output:n,formats:r,label:i})=>(0,X.jsxs)(D,{className:`p-4 sm:p-5`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsx)(`h3`,{className:`font-display font-semibold text-[1.0625rem]`,children:i??t.title}),(0,X.jsx)(oe,{base:`/api/runs/${e.id}`,stepId:t.id,formats:r,title:i??t.title})]}),(0,X.jsx)(se,{base:`/api/runs/${e.id}`,step:t,output:n}),n?.assets?.some(e=>e.ai)?(0,X.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-3 leading-relaxed`,children:C(`ai.publish`)}):null]},t.id)),e.lists.map(t=>(0,X.jsxs)(D,{className:`p-4 sm:p-5`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsx)(`h3`,{className:`font-display font-semibold text-[1.0625rem]`,children:t.label??t.def.title}),(0,X.jsx)(hn,{runId:e.id,list:t})]}),(0,X.jsx)(un,{runId:e.id,list:t,editable:!0})]},t.def.id))]}),(0,X.jsx)(Bn,{view:e,run:t,children:i?(0,X.jsxs)(j,{variant:`secondary`,onClick:i,children:[(0,X.jsx)(W,{className:`size-4`}),` `,C(`run.again`)]}):(0,X.jsx)(`span`,{})})]})}function Kn({view:e,run:t}){return(0,X.jsxs)(`div`,{className:`flex animate-rise flex-col items-center pt-8 text-center`,children:[(0,X.jsx)(r,{kind:e.wizard.avatar,size:90}),(0,X.jsx)(`h2`,{className:`mt-4 font-display font-semibold text-[1.375rem]`,children:C(`run.failed`)}),(0,X.jsx)(`p`,{className:`mt-2 max-w-md text-[0.9375rem] text-ink-3`,children:(0,X.jsx)(T,{text:e.error??``})}),(0,X.jsxs)(`div`,{className:`mt-8 flex gap-3`,children:[e.canBack?(0,X.jsxs)(j,{variant:`ghost`,onClick:()=>void t.back(),children:[(0,X.jsx)(h,{className:`size-4`}),` `,C(`run.back`)]}):null,(0,X.jsxs)(j,{onClick:()=>void t.retry(),busy:t.busy,children:[(0,X.jsx)(W,{className:`size-4`}),` `,C(`run.retry`)]})]})]})}function qn({runId:e,compact:t,onRestart:n,onView:r,stickyProgress:i}){let a=Pn(e),{view:o}=a;(0,Y.useEffect)(()=>{r?.(o)},[o,r]),te();let s=ne(o?.status===`running`&&!o.ask);if(Un(o),a.notFound)return(0,X.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:C(`run.notFound`)});if(!o)return(0,X.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,X.jsx)(y,{})});let c=o.step,l=null;if(o.status===`running`&&o.ask)l=(0,X.jsx)(Ot,{runId:o.id,ask:o.ask},o.ask.id);else if(o.status===`running`)l=(0,X.jsx)(Hn,{view:o,compact:t,awake:s});else if(o.status===`failed`)l=(0,X.jsx)(Kn,{view:o,run:a});else if(o.status===`cancelled`)l=(0,X.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:C(`run.cancelled`)});else if(c?.type===`page`)l=(0,X.jsx)(zn,{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,X.jsx)(Wn,{view:o,run:a,step:c},`${c.id}:${e}`)}else c?.type===`result`&&(l=(0,X.jsx)(Gn,{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,X.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[i?(0,X.jsx)(`div`,{className:`sticky top-0 z-10`,children:(0,X.jsx)(Fn,{view:o})}):(0,X.jsx)(Fn,{view:o}),(0,X.jsxs)(`div`,{className:b(`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,X.jsx)(`div`,{className:`mt-4 rounded-lg bg-rose-tint px-4 py-3 text-[0.875rem] text-rose`,children:a.error}):null,o.keeps&&o.status!==`running`?(0,X.jsx)(`div`,{className:`mt-10 flex justify-center`,children:(0,X.jsx)(_n,{runId:o.id})}):null]})]})}export{Ie as a,Qe as i,G as n,Se as o,it as r,qn as t};
|
|
2
|
+
import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{_ as r}from"./surface-CywgBXMy.js";import{t as i}from"./preload-helper-CNEI7N0N.js";import{D as a,F as o,G as s,H as c,I as l,L as u,N as d,O as f,P as p,U as m,W as h,b as g,c as _,d as v,f as y,g as b,h as x,i as S,j as C,k as w,l as T,m as E,n as D,o as O,p as k,s as A,t as j,u as M,x as N}from"./ui-DyazyiaK.js";import{t as P}from"./arrow-right-CXu8-CPy.js";import{t as F}from"./external-link-CbxUCKS8.js";import{n as I,t as L}from"./trash-CGJ09WWJ.js";import{t as R}from"./pen-line-D0OKCmpB.js";import{t as z}from"./refresh-cw-LyAykaPl.js";import{t as ee}from"./video-DDj7eGwZ.js";import{C as te,D as B,O as V,S as H,T as ne,_ as re,b as U,ct as ie,dt as ae,f as oe,h as se,nt as ce,ut as le,v as ue,w as de,x as fe,y as pe}from"./index-DyiZlzJ2.js";import{C as me,S as he,_ as ge,h as _e,m as ve,x as ye,y as be}from"./definition-DMIWA8dM.js";var xe={name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]};xe.node;var Se=s(xe),Ce={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`}]]};Ce.node;var we=s(Ce),Te={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`}]]};Te.node;var Ee=s(Te),De={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`}]]};De.node;var Oe=s(De),ke={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`}]]};ke.node;var Ae=s(ke),je={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`}]]};je.node;var Me=s(je),Ne={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`]};Ne.node;var Pe=s(Ne),Fe={name:`film`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]};Fe.node;var Ie=s(Fe),Le={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`}]]};Le.node;var Re=s(Le),ze={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`}]]};ze.node;var Be=s(ze),Ve={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`}]]};Ve.node;var He=s(Ve),Ue={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`}]]};Ue.node;var We=s(Ue),Ge={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`}]]};Ge.node;var Ke=s(Ge),qe={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`}]]};qe.node;var Je=s(qe),Ye={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`}]]};Ye.node;var Xe=s(Ye),Ze={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};Ze.node;var Qe=s(Ze),$e={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`}]]};$e.node;var et=s($e),tt={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`}]]};tt.node;var nt=s(tt),rt={name:`pencil`,size:24,node:[[`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`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};rt.node;var it=s(rt),at={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`}]]};at.node;var W=s(at),ot={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`}]]};ot.node;var st=s(ot),ct={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`}]]};ct.node;var G=s(ct),lt={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`}]]};lt.node;var ut=s(lt),dt={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`}]]};dt.node;var ft=s(dt),pt={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`]};pt.node;var mt=s(pt),ht={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`}]]};ht.node;var gt=s(ht),K=36e5,q=6e4,_t=1e3;function vt(e){return e.fractionDigits===void 0?e.style===`integer`?0:2:e.fractionDigits}function yt(e,t,n=`en`){if(typeof e!=`number`||!Number.isFinite(e))return``;let r=vt(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 bt(e,t,n=`en`){if(typeof e!=`string`||e.length===0)return``;if(t.kind===`time`)return xt(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 xt(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 St(e,t){if(typeof e!=`number`||!Number.isFinite(e))return``;let n=Math.max(0,Math.round(e));if(t.display===`iso`)return Ct(n);if(t.display===`minutes`)return`${Math.round(n/q)} min`;if(t.display===`hours`)return`${(n/K).toFixed(2)} h`;if(t.display===`decimal-hours`)return(n/K).toFixed(2);let r=Math.floor(n/K),i=Math.floor(n%K/q),a=Math.floor(n%q/_t);return`${r}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`}function Ct(e){let t=Math.floor(e/K),n=Math.floor(e%K/q),r=Math.floor(e%q/_t);return`${t>=24?`P${Math.floor(t/24)}D`:`P`}T${t%24}H${n}M${r}S`}function J(e,t,n=`en`){if(t==null)return``;switch(e.type){case`number`:return yt(t,e.format,n);case`date`:return bt(t,e.format,n);case`duration`:return St(t,e.format);case`boolean`:return t===!0?`true`:t===!1?`false`:``;case`select`:return wt(e,t);default:return String(t)}}function wt(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(`, `)}var Y=e(t(),1),X=e(n(),1);function Tt(e,t){let n=encodeURIComponent(e),r=encodeURIComponent(t);return[{id:`mail`,label:C(`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 Et={x:`𝕏`,linkedin:`in`,whatsapp:`WA`,facebook:`f`};function Dt({runId:e,title:t,initial:n}){let[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(n),[s,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),m=async()=>{if(i(!0),!a){l(!0),p(null);try{o(await N.post(`/api/runs/${e}/share`))}catch(e){p(e.message)}finally{l(!1)}}},h=async()=>{await N.del(`/api/runs/${e}/share`),o(null),i(!1)},g=()=>{a&&(navigator.clipboard.writeText(a.url),d(!0),setTimeout(()=>d(!1),1500))},_=V(`share`)||typeof navigator<`u`&&`share`in navigator,v=a?.expiresAt?new Intl.DateTimeFormat(w,{dateStyle:`long`}).format(new Date(a.expiresAt)):null;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(j,{variant:`secondary`,onClick:()=>void m(),children:[(0,X.jsx)(G,{className:`size-4`}),` `,C(`shareRun.button`)]}),(0,X.jsx)(S,{open:r,onClose:()=>i(!1),title:C(`shareRun.title`),children:s?(0,X.jsx)(`div`,{className:`flex justify-center py-8 text-ink-4`,children:(0,X.jsx)(y,{})}):f?(0,X.jsx)(`p`,{className:`rounded-lg bg-rose-tint px-3 py-2 text-[0.875rem] text-rose`,children:f}):a?(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-paper-2 p-1.5 pl-3`,children:[(0,X.jsx)(I,{className:`size-4 shrink-0 text-ink-3`}),(0,X.jsx)(`input`,{readOnly:!0,value:a.url,onFocus:e=>e.target.select(),"aria-label":C(`share.link`),className:`min-w-0 flex-1 bg-transparent text-[0.875rem] outline-none coarse:h-11`}),(0,X.jsxs)(j,{size:`sm`,onClick:g,children:[u?(0,X.jsx)(c,{className:`size-3.5`}):(0,X.jsx)(ae,{className:`size-3.5`}),C(u?`share.copied`:`share.copy`)]})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 sm:grid-cols-6`,children:[Tt(a.url,t).map(e=>(0,X.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`flex flex-col items-center gap-1.5 text-[0.75rem] text-ink-2 hover:text-ink`,children:[(0,X.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-full bg-paper-2 font-semibold text-[0.9375rem] transition hover:bg-paper-3`,children:e.id===`mail`?(0,X.jsx)(Qe,{className:`size-5`}):Et[e.id]}),e.label]},e.id)),_?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>void(V(`share`)?B(`share`,{link:a.url,title:t}):navigator.share({title:t,url:a.url})).catch(()=>void 0),className:`flex flex-col items-center gap-1.5 text-[0.75rem] text-ink-2 hover:text-ink`,children:[(0,X.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-full bg-paper-2 transition hover:bg-paper-3`,children:(0,X.jsx)(G,{className:`size-5`})}),C(`shareRun.more`)]}):null]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-[0.8125rem] text-ink-3`,children:[(0,X.jsx)(`span`,{children:v?C(`shareRun.until`,{date:v}):C(`shareRun.kept`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void h(),className:`shrink-0 hover:text-rose coarse:min-h-11`,children:C(`shareRun.withdraw`)})]})]}):null})]})}function Ot({runId:e,ask:t}){return t.kind===`confirm`?(0,X.jsx)(kt,{runId:e,ask:t}):(0,X.jsx)(At,{runId:e,ask:t})}function kt({runId:e,ask:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),c=async n=>{a(!0),s(null);try{await N.post(`/api/runs/${e}/ask/${t.id}`,n)}catch(e){s(e.message),a(!1)}},l=t.action.destructive?mt:nt;return(0,X.jsxs)(`div`,{className:`animate-rise`,children:[(0,X.jsxs)(`div`,{className:`mb-5 flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:b(`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,X.jsx)(l,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:C(`ask.wants`,{service:t.service})}),(0,X.jsx)(`h2`,{className:`font-display font-semibold text-[1.25rem] leading-snug tracking-tight`,children:t.reason})]})]}),(0,X.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-xl bg-paper-2 p-4 text-[0.8125rem] leading-relaxed ring-1 ring-border-soft`,children:t.input}),(0,X.jsxs)(`div`,{className:`mt-5 flex items-center gap-4`,children:[(0,X.jsx)(E,{checked:n,onChange:r,label:C(`ask.allowRest`)}),(0,X.jsx)(`span`,{className:`flex-1 text-[0.8125rem] text-ink-2`,children:C(`ask.allowRest`)})]}),o?(0,X.jsx)(`div`,{className:`mt-3 rounded-lg bg-rose-tint px-4 py-3 text-[0.875rem] text-rose`,children:o}):null,(0,X.jsxs)(`div`,{className:`action-bar mt-6 flex items-center justify-between gap-3`,children:[(0,X.jsx)(j,{variant:`ghost`,disabled:i,onClick:()=>void c({type:`skip`}),children:C(`ask.deny`)}),(0,X.jsx)(j,{busy:i,onClick:()=>void c({type:`done`,remember:n}),children:C(`ask.allow`)})]})]})}function At({runId:e,ask:t}){let[n,r]=(0,Y.useState)({}),[i,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(0),[p,h]=(0,Y.useState)(``),[g,v]=(0,Y.useState)(!1),y=(0,Y.useRef)(null),x=(0,Y.useCallback)(()=>f(e=>e+1),[]);(0,Y.useEffect)(()=>{let e=setInterval(x,2500);return()=>clearInterval(e)},[x]);let S=async n=>{c(!0),u(null);try{await N.post(`/api/runs/${e}/ask/${t.id}`,n)}catch(e){u(e.message),c(!1)}},w=async t=>{u(null);try{await N.post(`/api/runs/${e}/browser/act`,t)}catch(e){u(e.message)}x()},T=e=>{let t=y.current;if(!t?.naturalWidth)return;let n=t.getBoundingClientRect();w({type:`click`,x:Math.round((e.clientX-n.left)/n.width*t.naturalWidth),y:Math.round((e.clientY-n.top)/n.height*t.naturalHeight)})},D=t.fields.some(e=>n[e.id]);return(0,X.jsxs)(`div`,{className:`animate-rise`,children:[(0,X.jsxs)(`div`,{className:`mb-5 flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-full bg-ember-tint text-ember-strong`,children:(0,X.jsx)(Xe,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h2`,{className:`font-display font-semibold text-[1.25rem] leading-snug tracking-tight`,children:t.reason}),(0,X.jsxs)(`p`,{className:`mt-0.5 truncate text-[0.8125rem] text-ink-3`,children:[t.site.host,t.site.title?` · ${t.site.title}`:``]})]})]}),(0,X.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-paper-2 ring-1 ring-border-soft`,children:[(0,X.jsx)(`img`,{ref:y,src:a(`/api/runs/${e}/browser/screen?t=${d}`),alt:t.site.host,onClick:T,className:`block w-full cursor-pointer`}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-border-soft border-t bg-card p-2`,children:[(0,X.jsx)(A,{type:g?`password`:`text`,autoComplete:`off`,value:p,placeholder:C(`ask.typeInto`),onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w({type:`type`,text:p}).then(()=>h(``)))},autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,enterKeyHint:`send`,className:`h-9 min-w-[9rem] flex-1 basis-full text-[0.8125rem] sm:basis-0 coarse:h-11`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>v(e=>!e),className:b(`h-9 shrink-0 rounded-md px-2.5 text-[0.75rem] coarse:h-11 coarse:px-3.5`,g?`bg-ember-veil text-ink`:`text-ink-3 hover:bg-paper-2`),children:C(`ask.hide`)}),(0,X.jsx)(jt,{label:`Enter`,onClick:()=>void w({type:`key`,key:`Enter`}),children:(0,X.jsx)(Ae,{className:`size-4`})}),(0,X.jsx)(jt,{label:C(`ask.up`),onClick:()=>void w({type:`scroll`,dy:-500}),children:(0,X.jsx)(m,{className:`size-4`})}),(0,X.jsx)(jt,{label:C(`ask.down`),onClick:()=>void w({type:`scroll`,dy:500}),children:(0,X.jsx)(Se,{className:`size-4`})})]})]}),(0,X.jsx)(`p`,{className:`mt-2 text-[0.75rem] text-ink-4`,children:C(`ask.pictureHint`)}),t.fields.length?(0,X.jsxs)(`form`,{className:`mt-5 flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),S({type:`fill`,values:n,remember:i})},children:[t.fields.map((e,i)=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(_,{children:e.label}),(0,X.jsx)(A,{autoFocus:i===0,type:e.secret?`password`:`text`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,enterKeyHint:i===t.fields.length-1?`go`:`next`,value:n[e.id]??``,onChange:t=>r(n=>({...n,[e.id]:t.target.value}))})]},e.id)),(0,X.jsx)(`button`,{type:`submit`,hidden:!0})]}):null,(0,X.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-4`,children:[(0,X.jsx)(E,{checked:i,onChange:o,label:C(`ask.remember`)}),(0,X.jsx)(`span`,{className:`flex-1 text-[0.8125rem] text-ink-2`,children:C(`ask.remember`)})]}),(0,X.jsxs)(`p`,{className:`mt-3 flex items-start gap-2 text-[0.8125rem] text-ink-3`,children:[(0,X.jsx)(ut,{className:`mt-0.5 size-4 shrink-0 text-moss`}),` `,C(`ask.private`)]}),l?(0,X.jsx)(`div`,{className:`mt-3 rounded-lg bg-rose-tint px-4 py-3 text-[0.875rem] text-rose`,children:l}):null,(0,X.jsxs)(`div`,{className:`action-bar mt-6 flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsx)(j,{variant:`ghost`,disabled:s,onClick:()=>void S({type:`skip`}),children:C(`ask.skip`)}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.fields.length?(0,X.jsx)(j,{variant:`secondary`,disabled:s,onClick:()=>void S({type:`done`,remember:i}),children:C(`ask.done`)}):null,t.fields.length?(0,X.jsx)(j,{busy:s,disabled:!D,onClick:()=>void S({type:`fill`,values:n,remember:i}),children:C(`ask.signIn`)}):(0,X.jsx)(j,{busy:s,onClick:()=>void S({type:`done`,remember:i}),children:C(`ask.done`)})]})]})]})}function jt({label:e,onClick:t,children:n}){return(0,X.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})}async function Mt(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 Nt(){return new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`)}function Pt(e){let t=e?.name;return t===`NotFoundError`||t===`OverconstrainedError`?`missing`:t===`NotReadableError`||t===`AbortError`?`busy`:`denied`}function Ft(e){return!!e?.getCapabilities?.()?.torch}function It(e,t,n=!1){let r=(0,Y.useRef)(null),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(1),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1);return(0,Y.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(Ft(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(Pt(e))),()=>{i=!0;for(let e of r?.getTracks()??[])e.stop()}},[e,t,n]),(0,Y.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 Lt({open:e,onClose:t,label:n,children:r}){let i=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let t=i.current;t&&(e&&!t.open?t.showModal():!e&&t.open&&t.close())},[e]),(0,X.jsx)(`dialog`,{ref:i,onClose:t,"aria-label":n,className:`media-sheet`,children:e?(0,X.jsx)(`div`,{className:`flex h-full flex-col`,children:r}):null})}function Rt({label:e,onClick:t,active:n,children:r}){return(0,X.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":n,onClick:t,className:b(`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 zt({title:e,onClose:t,camera:n,onFlip:r}){return(0,X.jsx)(`div`,{className:`safe-top`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,X.jsx)(Rt,{label:C(`common.close`),onClick:t,children:(0,X.jsx)(d,{className:`size-5`})}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-center font-medium text-[0.9375rem]`,children:e}),n.torchable?(0,X.jsx)(Rt,{label:C(`camera.torch`),active:n.torch,onClick:()=>void n.setTorch(!n.torch),children:n.torch?(0,X.jsx)(Be,{className:`size-5`}):(0,X.jsx)(Re,{className:`size-5`})}):null,n.stream&&(n.cameras>1||U)?(0,X.jsx)(Rt,{label:C(`camera.flip`),onClick:r,children:(0,X.jsx)(ft,{className:`size-5`})}):(0,X.jsx)(`span`,{className:`size-11`})]})})}function Bt({camera:e,asking:t,children:n,actions:r}){return(0,X.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[(0,X.jsx)(`video`,{ref:e.video,autoPlay:!0,playsInline:!0,muted:!0,className:b(`absolute inset-0 size-full object-contain`,e.mirrored&&`-scale-x-100`)}),e.error?(0,X.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-5 bg-black px-8 text-center`,children:[(0,X.jsx)(`p`,{className:`max-w-sm text-[0.9375rem] text-white/85 leading-relaxed`,children:C(`camera.${e.error}`)}),r]}):e.stream?n:(0,X.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-4 px-8 text-center text-white/75`,children:[(0,X.jsx)(y,{}),(0,X.jsx)(`p`,{className:`max-w-xs text-[0.875rem] leading-relaxed`,children:t})]})]})}var Vt=30;function Ht(){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 Ut=!!Ht();function Wt({open:e,multiple:t,video:n,onClose:r,onCapture:i,onNative:a}){let[o,s]=(0,Y.useState)(`environment`),[l,u]=(0,Y.useState)(`photo`),[d,f]=(0,Y.useState)(0),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(null),_=(0,Y.useRef)(null),v=It(e,o,l===`video`);(0,Y.useEffect)(()=>{e&&(f(0),u(`photo`),g(null))},[e]);let x=async e=>{m(!0);try{await i(e),f(e=>e+1),t||r()}finally{m(!1)}},S=async()=>{let e=v.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 x(new File([n],`foto-${Nt()}.jpg`,{type:`image/jpeg`}))},w=()=>{_.current?.state===`recording`&&_.current.stop()},T=()=>{let e=Ht();if(!v.stream||!e)return;let t=[],n=new MediaRecorder(v.stream,{mimeType:e,videoBitsPerSecond:25e5,audioBitsPerSecond:96e3});n.ondataavailable=e=>e.data.size&&t.push(e.data),n.onstop=()=>{g(null),_.current=null;let n=e.split(`;`)[0];if(t.length){let e=n===`video/mp4`?`mp4`:`webm`;x(new File(t,`video-${Nt()}.${e}`,{type:n}))}},_.current=n,n.start(1e3),g(0)};(0,Y.useEffect)(()=>{if(h===null)return;if(h>=Vt){_.current?.state===`recording`&&_.current.stop();return}let e=setTimeout(()=>g(e=>e===null?null:e+1),1e3);return()=>clearTimeout(e)},[h]),(0,Y.useEffect)(()=>{!e&&_.current&&(_.current.onstop=null,_.current.stop(),_.current=null)},[e]);let E=e=>`0:${String(e).padStart(2,`0`)}`;return(0,X.jsxs)(Lt,{open:e,onClose:r,label:C(`camera.title`),children:[(0,X.jsx)(zt,{title:h===null?d?C(`camera.taken`,{n:d}):C(`camera.title`):`${E(h)} / ${E(Vt)}`,onClose:r,camera:v,onFlip:()=>s(e=>e===`environment`?`user`:`environment`)}),(0,X.jsx)(Bt,{camera:v,asking:C(`camera.asking`),actions:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a?(0,X.jsxs)(Z,{onClick:()=>{r(),a()},children:[(0,X.jsx)(Oe,{className:`size-4`}),` `,C(U?`camera.native`:`camera.pick`)]}):null,(0,X.jsx)(Z,{quiet:!0,onClick:r,children:C(`common.close`)})]})}),(0,X.jsxs)(`div`,{className:b(`safe-bottom px-4 pt-3`,v.error&&`invisible`),children:[n&&Ut&&h===null?(0,X.jsx)(`div`,{className:`mb-3 flex justify-center gap-1 text-[0.8125rem]`,children:[`photo`,`video`].map(e=>(0,X.jsx)(`button`,{type:`button`,"aria-pressed":l===e,onClick:()=>u(e),className:b(`h-9 rounded-full px-4 font-medium transition`,l===e?`bg-white text-black`:`text-white/70 hover:text-white`),children:C(e===`photo`?`camera.photo`:`camera.video`)},e))}):null,(0,X.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_1fr] items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-[0.8125rem] text-white/70 leading-snug`,children:h===null?l===`video`?C(`camera.clipHint`,{s:Vt}):C(t?`camera.hintMany`:`camera.hint`):C(`camera.recording`)}),(0,X.jsx)(`button`,{type:`button`,"aria-label":C(l===`photo`?`camera.shoot`:h===null?`camera.record`:`camera.stop`),disabled:!v.stream||p,onClick:()=>l===`photo`?void S():h===null?T():w(),className:`flex size-[72px] items-center justify-center rounded-full border-4 border-white transition active:scale-95 disabled:opacity-40`,children:p?(0,X.jsx)(y,{className:`text-white`}):l===`photo`?(0,X.jsx)(`span`,{className:`size-[54px] rounded-full bg-white`}):h===null?(0,X.jsx)(`span`,{className:`flex size-[54px] items-center justify-center rounded-full bg-[#e5484d]`,children:(0,X.jsx)(ee,{className:`size-6 text-white`})}):(0,X.jsx)(`span`,{className:`size-7 rounded-md bg-[#e5484d]`})}),(0,X.jsx)(`div`,{className:`flex justify-end`,children:t&&d&&h===null?(0,X.jsxs)(Z,{onClick:r,children:[(0,X.jsx)(c,{className:`size-4`}),` `,C(`camera.done`)]}):null})]})]})]})}function Z({onClick:e,quiet:t,children:n}){return(0,X.jsx)(`button`,{type:`button`,onClick:e,className:b(`inline-flex h-11 items-center justify-center gap-2 rounded-full px-5 font-medium text-[0.875rem] transition`,t?`text-white/75 hover:text-white`:`bg-white text-black hover:bg-white/90`),children:n})}var Gt=25,Kt=9e3;function qt(e){return e.code===e.PERMISSION_DENIED?`denied`:e.code===e.TIMEOUT?`timeout`:`unavailable`}function Jt({value:e,runId:t,placeholder:n,onChange:r,onBusy:i}){let a=ge(e)?e:null,[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),f=(0,Y.useRef)(!!a?.label),p=(0,Y.useRef)(a);p.current=a;let m=a?.lat!==void 0&&a.lng!==void 0,h=typeof navigator<`u`&&`geolocation`in navigator,g=()=>{u.current!==null&&(navigator.geolocation.clearWatch(u.current),u.current=null),s(!1),i?.(!1)};(0,Y.useEffect)(()=>()=>{u.current!==null&&navigator.geolocation.clearWatch(u.current)},[]);let _=async(e,n)=>{try{let{label:i}=await N.post(`/api/runs/${t}/geocode`,{lat:e,lng:n,language:w}),a=p.current;i&&!f.current&&a?.lat===e&&a.lng===n&&r({...a,label:i})}catch{}},v=()=>{l(null),s(!0),i?.(!0);let e=Date.now(),t=1/0;u.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<=Gt||Date.now()-e>Kt){g();let e=p.current;e?.lat!==void 0&&e.lng!==void 0&&_(e.lat,e.lng)}},e=>{g(),t===1/0&&l(qt(e))},{enableHighAccuracy:!0,timeout:15e3,maximumAge:1e4})},y=e=>{f.current=e.trim().length>0;let t={...m?a:{},label:e};r(m||e.trim()?t:void 0)};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[m?(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-full bg-moss-tint text-moss`,children:(0,X.jsx)(et,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`truncate font-medium text-[0.9375rem] tabular-nums`,children:[a.lat?.toFixed(5),`, `,a.lng?.toFixed(5)]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 text-[0.8125rem] text-ink-3`,children:[(0,X.jsx)(`span`,{children:o?C(`location.refining`):a.accuracy?C(`location.accuracy`,{m:a.accuracy}):null}),(0,X.jsxs)(`a`,{href:`https://www.openstreetmap.org/?mlat=${a.lat}&mlon=${a.lng}#map=17/${a.lat}/${a.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:[C(`location.map`),` `,(0,X.jsx)(F,{className:`size-3`})]})]})]}),(0,X.jsx)(O,{label:C(`location.remove`),onClick:()=>{g(),f.current=!1,r(void 0)},children:(0,X.jsx)(d,{className:`size-4`})})]}):h?(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(j,{variant:`secondary`,size:`lg`,busy:o,onClick:v,className:`w-full sm:w-auto`,children:[o?null:(0,X.jsx)(Je,{className:`size-4`}),C(o?`location.locating`:`location.use`)]}),c?(0,X.jsx)(`p`,{className:`mt-2 rounded-lg bg-amber-tint px-3 py-2 text-[0.8125rem] text-ink-2 leading-relaxed`,children:C(`location.${c}`)}):(0,X.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3 leading-relaxed`,children:C(`location.why`)})]}):null,(0,X.jsx)(A,{value:a?.label??``,placeholder:n??C(m?`location.label`:`location.manual`),autoComplete:`street-address`,enterKeyHint:`done`,"aria-label":C(`location.manual`),onChange:e=>y(e.target.value)})]})}var Yt=null;function Xt(){return Yt??=(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 i(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}}}})(),Yt}function Zt({open:e,onClose:t,onResult:n}){let r=(0,Y.useRef)(n);r.current=n;let i=(0,Y.useRef)(t);return i.current=t,(0,Y.useEffect)(()=>{e&&B(`scan`).then(e=>{e&&r.current(e)}).catch(()=>void 0).finally(()=>i.current())},[e]),null}function Qt(e){return V(`scan`)?(0,X.jsx)(Zt,{...e}):(0,X.jsx)($t,{...e})}function $t({open:e,onClose:t,onResult:n}){let[r,i]=(0,Y.useState)(`environment`),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=(0,Y.useRef)(null),u=It(e,r),d=(0,Y.useRef)(n);d.current=n;let f=(0,Y.useRef)(t);f.current=t,(0,Y.useEffect)(()=>{e&&(c(!1),Xt().then(e=>o(e.qrOnly)))},[e]),(0,Y.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 Xt()).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 Xt()).detect(r).catch(()=>null):null;i?(n(i),t()):c(!0)};return(0,X.jsxs)(Lt,{open:e,onClose:t,label:C(`scan.title`),children:[(0,X.jsx)(zt,{title:C(`scan.title`),onClose:t,camera:u,onFlip:()=>i(e=>e===`environment`?`user`:`environment`)}),(0,X.jsx)(Bt,{camera:u,asking:C(`scan.asking`),actions:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(Z,{onClick:()=>l.current?.click(),children:[(0,X.jsx)(Ke,{className:`size-4`}),` `,C(`scan.fromPhoto`)]}),(0,X.jsx)(Z,{quiet:!0,onClick:t,children:C(`scan.typeInstead`)})]}),children:(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,X.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,X.jsxs)(`div`,{className:`safe-bottom flex flex-col items-center gap-3 px-5 pt-3 text-center`,children:[(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-white/75 leading-snug`,children:C(s?`scan.miss`:a?`scan.hintQr`:`scan.hint`)}),u.stream?(0,X.jsxs)(Z,{quiet:!0,onClick:()=>l.current?.click(),children:[(0,X.jsx)(Ke,{className:`size-4`}),` `,C(`scan.fromPhoto`)]}):null]}),(0,X.jsx)(`input`,{ref:l,type:`file`,hidden:!0,accept:`image/*`,onChange:e=>{p(e.target.files?.[0]),e.target.value=``}})]})}var en=`#1d1a17`,Q={width:1200,height:480};function tn(e,t,n,r,i){e.lineCap=`round`,e.lineJoin=`round`,e.strokeStyle=en,e.fillStyle=en,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 nn({strokes:e,onStrokes:t}){let n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.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),tn(t,r.current?[...i.current,r.current]:i.current,o,s,2.4*a)};(0,Y.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,X.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl bg-white ring-1 ring-input`,children:[(0,X.jsx)(`canvas`,{ref:n,"aria-label":C(`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,X.jsx)(`div`,{className:`pointer-events-none absolute inset-x-6 bottom-[22%] border-[#1d1a17]/25 border-b`}),e.length?null:(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center text-[#1d1a17]/40 text-[0.875rem]`,children:C(`sign.hint`)})]})}async function rn(e){let t=document.createElement(`canvas`);t.width=Q.width,t.height=Q.height;let n=t.getContext(`2d`);if(!n)return null;tn(n,e,Q.width,Q.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 an({label:e,value:t,runId:n,onChange:r}){let[i,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)([]),[l,u]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),m=typeof t==`string`&&t?t:null,h=async()=>{u(!0),p(null);try{let e=await rn(s);if(!e)return;r((await N.upload(`/api/runs/${n}/uploads`,e)).id),o(!1)}catch(e){p(e.message)}finally{u(!1)}};return(0,X.jsxs)(`div`,{children:[m?(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-2 ring-1 ring-input`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>{c([]),o(!0)},className:`min-w-0 flex-1 rounded-lg bg-white px-3`,"aria-label":C(`sign.again`),children:(0,X.jsx)(`img`,{src:a(`/api/runs/${n}/assets/${m}`),alt:e,className:`mx-auto h-20 object-contain`})}),(0,X.jsx)(O,{label:C(`sign.remove`),onClick:()=>r(void 0),children:(0,X.jsx)(d,{className:`size-4`})})]}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{c([]),o(!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-[0.875rem] text-ink-3 transition hover:border-ember hover:text-ink`,children:[(0,X.jsx)(R,{className:`size-6`}),C(`sign.open`)]}),(0,X.jsxs)(S,{open:i,onClose:()=>o(!1),title:e,wide:!0,children:[(0,X.jsx)(nn,{strokes:s,onStrokes:c}),f?(0,X.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:f}):null,(0,X.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-3`,children:[(0,X.jsxs)(j,{variant:`ghost`,disabled:!s.length||l,onClick:()=>c([]),children:[(0,X.jsx)(Me,{className:`size-4`}),` `,C(`sign.clear`)]}),(0,X.jsx)(j,{busy:l,disabled:!s.length,onClick:()=>void h(),children:C(`sign.accept`)})]})]})]})}function on({runId:e,connectionId:t,connector:n,onCancel:r}){let[i,a]=(0,Y.useState)({}),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=async()=>{s(!0),l(null);try{await N.post(`/api/runs/${e}/connections/${t}/credentials/${n.id}`,{values:i})}catch(e){l(e.message)}finally{s(!1)}};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-card p-4 ring-1 ring-input`,children:[(n.fields??[]).map(e=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(_,{children:e.label}),(0,X.jsx)(A,{type:e.secret?`password`:`text`,autoComplete:`off`,value:i[e.key]??``,placeholder:e.placeholder,onChange:t=>a(n=>({...n,[e.key]:t.target.value})),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u())}})]},e.key)),n.hint?(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:n.hint}):null,c?(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:c}):null,(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(j,{variant:`ghost`,size:`sm`,onClick:r,children:C(`common.cancel`)}),(0,X.jsx)(j,{size:`sm`,busy:o,onClick:()=>void u(),children:C(`connect.go`)})]})]})}function sn({runId:e,connection:t}){let[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null);if(!t)return null;if(t.account){let n=t.connectors.find(e=>e.id===t.account?.connector)?.name??``;return(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,X.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-moss-tint text-moss`,children:(0,X.jsx)(c,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate font-medium text-[0.9375rem]`,children:t.account.label}),(0,X.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:C(`connect.connected`,{name:n})})]}),(0,X.jsx)(O,{label:C(`connect.disconnect`),onClick:()=>void N.del(`/api/runs/${e}/connections/${t.id}`),children:(0,X.jsx)(gt,{className:`size-4`})})]})}let l=async n=>{if(s(null),a(null),V(`signIn`)){try{let{url:r}=await N.post(`/api/runs/${e}/connections/${t.id}/oauth/${n.id}`);await B(`signIn`,{url:r})}catch(e){s(e.message)}return}let r=window.open(`about:blank`,`wizard-connect`,`width=540,height=700`);try{let{url:i}=await N.post(`/api/runs/${e}/connections/${t.id}/oauth/${n.id}`);r?r.location.replace(i):a(i)}catch(e){r?.close(),s(e.message)}},u=t.connectors.find(e=>e.id===n);return t.connectors.length?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.connectors.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>e.auth===`oauth2`?void l(e):r(n===e.id?null:e.id),className:b(`inline-flex h-11 items-center gap-2 rounded-full px-4 font-medium text-[0.875rem] 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,X.jsx)(I,{className:`size-4`}),` `,e.name]},e.id))}),u?(0,X.jsx)(on,{runId:e,connectionId:t.id,connector:u,onCancel:()=>r(null)}):null,i?(0,X.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:`text-[0.875rem] text-ember underline`,children:C(`connect.openLink`)}):null,o?(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:o}):null]}):(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:C(`connect.none`)})}function cn(e){return e==null?``:Array.isArray(e)?e.join(`, `):String(e)}function ln(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,Y.useState)(cn(t));(0,Y.useEffect)(()=>a(cn(t)),[t]);let o=b(`w-full min-w-0 rounded-md border border-transparent px-2 text-[0.8125rem] 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,X.jsx)(`label`,{className:`flex size-9 cursor-pointer items-center justify-center coarse:size-11`,children:(0,X.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,X.jsxs)(`select`,{value:i,onChange:e=>r(e.target.value||null),className:o,children:[(0,X.jsx)(`option`,{value:``}),e.format.options.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.label},e.id))]}):(0,X.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!==cn(t)&&r(ln(e,i))},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},className:b(o,e.type===`number`&&`text-right tabular-nums`)})}function un({runId:e,list:t,editable:n}){let{def:r,rows:i}=t,[a,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)({}),u=`/api/runs/${e}/lists/${r.id}/rows`,d=async e=>{s(null);try{await e()}catch(e){s(e instanceof g?e.message:String(e))}},f=()=>d(async()=>{await N.post(u,{cells:c}),l({})}),p=Object.values(c).some(e=>e!=null&&e!==``);if(!i.length&&!n)return(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:C(`list.empty`)});let m=(e,t)=>t===0||e.type===`text`&&e.format?.style===`multiline`,h=(e,t,n)=>void d(()=>N.patch(`${u}/${e}`,{cells:{[t]:n}}));return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:hidden`,children:[i.map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-1.5`,children:r.columns.map((t,r)=>(0,X.jsxs)(`div`,{className:b(`min-w-0`,m(t,r)&&`col-span-2`),children:[(0,X.jsx)(`div`,{className:`px-1 pb-0.5 text-[0.6875rem] text-ink-3`,children:t.name}),n?(0,X.jsx)($,{boxed:!0,column:t,value:e.cells[t.id],onCommit:n=>h(e.id,t.id,n)}):(0,X.jsx)(`div`,{className:b(`break-words px-1 text-[0.875rem]`,t.type===`number`&&`tabular-nums`),children:J(t,e.cells[t.id],w)||`—`})]},t.id))}),n?(0,X.jsx)(`div`,{className:`mt-1 flex justify-end`,children:(0,X.jsx)(O,{label:C(`list.delete`),onClick:()=>void d(()=>N.del(`${u}/${e.id}`)),children:(0,X.jsx)(L,{className:`size-4`})})}):null]},e.id)),n?(0,X.jsxs)(`div`,{className:`rounded-lg border border-input border-dashed p-2`,children:[(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-1.5`,children:r.columns.map((e,t)=>(0,X.jsxs)(`div`,{className:b(`min-w-0`,m(e,t)&&`col-span-2`),children:[(0,X.jsx)(`div`,{className:`px-1 pb-0.5 text-[0.6875rem] text-ink-3`,children:e.name}),(0,X.jsx)($,{boxed:!0,column:e,value:c[e.id],onCommit:t=>l(n=>({...n,[e.id]:t}))})]},e.id))}),(0,X.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,X.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:()=>p?void f():void 0,children:[(0,X.jsx)(o,{className:`size-4`}),` `,C(`run.addRow`)]})})]}):null]}),(0,X.jsx)(`div`,{className:`hidden overflow-x-auto rounded-lg ring-1 ring-border-soft sm:block`,children:(0,X.jsxs)(`table`,{className:`w-full text-[0.8125rem]`,children:[(0,X.jsx)(`thead`,{className:`bg-paper-2 text-ink-2`,children:(0,X.jsxs)(`tr`,{children:[r.columns.map(e=>(0,X.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 text-left font-medium`,children:e.name},e.id)),n?(0,X.jsx)(`th`,{className:`w-10`}):null]})}),(0,X.jsxs)(`tbody`,{children:[i.map(e=>(0,X.jsxs)(`tr`,{className:`border-border-soft border-t align-top`,children:[r.columns.map(t=>(0,X.jsx)(`td`,{className:b(`min-w-[7.5rem]`,n?`px-1 py-0.5`:`px-3 py-2`),children:n?(0,X.jsx)($,{column:t,value:e.cells[t.id],onCommit:n=>h(e.id,t.id,n)}):(0,X.jsx)(`span`,{className:b(t.type===`number`&&`tabular-nums`),children:J(t,e.cells[t.id],w)})},t.id)),n?(0,X.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,X.jsx)(O,{label:C(`list.delete`),className:`size-9`,onClick:()=>void d(()=>N.del(`${u}/${e.id}`)),children:(0,X.jsx)(L,{className:`size-3.5`})})}):null]},e.id)),n?(0,X.jsxs)(`tr`,{className:`border-border-soft border-t bg-paper`,children:[r.columns.map(e=>(0,X.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,X.jsx)($,{column:e,value:c[e.id],onCommit:t=>l(n=>({...n,[e.id]:t}))})},e.id)),(0,X.jsx)(`td`,{className:`px-1 py-0.5`,children:(0,X.jsx)(O,{label:C(`run.addRow`),className:`size-9`,onClick:()=>p?void f():void 0,children:(0,X.jsx)(o,{className:`size-4`})})})]}):null]})]})}),a?(0,X.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-rose`,children:a}):null]})}function dn(e,t,n){let r=t.split(`/`).map(encodeURIComponent).join(`/`);return a(`/api/runs/${e}/store/files/${r}${n?`?inline=1`:``}`)}var fn=[`bg-paper-3 text-ink-3`,`bg-moss-tint text-moss`,`bg-rose-tint text-rose`,`bg-ember-tint text-ember-strong`];function pn({runId:e,list:t}){let{def:n,rows:r}=t,i=n.columns.find(e=>e.id===n.check?.file),a=n.columns.find(e=>e.id===n.check?.status),o=a?.type===`select`?a.format.options:[],s=o[0]?.id,l=e=>a?String(e.cells[a.id]??s??``):``,u=e=>!a||l(e)===s,[d,f]=(0,Y.useState)(()=>(r.find(u)??r[0])?.id??null),[p,m]=(0,Y.useState)(!1),[h,_]=(0,Y.useState)(null),v=`/api/runs/${e}/lists/${n.id}/rows`,y=r.find(e=>e.id===d)??r[0],x=p?r.filter(e=>u(e)||e.id===y?.id):r,S=r.filter(e=>!u(e)).length,T=n.columns.filter(e=>e!==i&&e!==a),E=T.filter(e=>e.id!==n.key),D=E.find(e=>e.type===`text`)??E[0],O=E.filter(e=>e!==D),k=async(e,t)=>{_(null);try{await N.patch(`${v}/${e}`,{cells:t})}catch(e){_(e instanceof g?e.message:String(e))}},A=e=>{let t=x.findIndex(e=>e.id===y?.id),n=x[Math.min(x.length-1,Math.max(0,t+e))];n&&f(n.id)},M=async e=>{if(!y||!a)return;let t=r.findIndex(e=>e.id===y.id),n=[...r.slice(t+1),...r.slice(0,t)].find(u);await k(y.id,{[a.id]:e}),n&&e!==s&&f(n.id)},P=e=>{e.target.closest(`input, textarea, select`)||(e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),A(e.key===`ArrowDown`?1:-1)):/^[1-9]$/.test(e.key)&&o[Number(e.key)]&&(e.preventDefault(),M(o[Number(e.key)].id)))};if(!r.length)return(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:C(`list.empty`)});let F=i&&y?String(y.cells[i.id]??``).trim():``,I=F.split(`.`).pop()?.toLowerCase()??``,L=e=>fn[Math.min(Math.max(0,o.findIndex(t=>t.id===l(e))),3)];return(0,X.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(280px,360px)_minmax(0,1fr)]`,onKeyDown:P,children:[(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-col`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:C(`check.progress`,{done:S,total:r.length})}),a?(0,X.jsx)(`button`,{type:`button`,"aria-pressed":p,onClick:()=>m(e=>!e),className:b(`inline-flex h-8 items-center rounded-full px-3 text-[0.8125rem] ring-1 transition coarse:h-11`,p?`bg-ember-tint text-ink ring-ember`:`bg-card text-ink-2 ring-input hover:text-ink`),children:C(`check.onlyOpen`)}):null]}),(0,X.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:x.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>f(e.id),"aria-current":e.id===y?.id,className:b(`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,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium text-[0.875rem]`,children:D&&J(D,e.cells[D.id],w)||`—`}),(0,X.jsx)(`span`,{className:`block truncate text-[0.75rem] text-ink-3 tabular-nums`,children:O.slice(0,2).map(t=>J(t,e.cells[t.id],w)).filter(Boolean).join(` · `)})]}),a?(0,X.jsx)(`span`,{className:b(`shrink-0 rounded-full px-2 py-0.5 font-medium text-[0.6875rem]`,L(e)),children:o.find(t=>t.id===l(e))?.label??l(e)}):null]})},e.id))})]}),y?(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[o.length>1?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o.slice(1).map((e,t)=>(0,X.jsxs)(j,{size:`md`,variant:l(y)===e.id?`primary`:`secondary`,onClick:()=>void M(e.id),children:[l(y)===e.id?(0,X.jsx)(c,{className:`size-4`}):null,e.label,(0,X.jsx)(`kbd`,{className:`ml-1 hidden rounded bg-black/10 px-1.5 text-[0.6875rem] lg:inline`,children:t+1})]},e.id)),l(y)===s?null:(0,X.jsx)(j,{size:`md`,variant:`ghost`,onClick:()=>void M(s??``),children:C(`check.reopen`)})]}):null,(0,X.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-paper-2 ring-1 ring-border-soft`,children:F?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 border-border-soft border-b bg-card px-3 py-2 text-[0.8125rem]`,children:[(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-ink-3`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:F.split(`/`).pop()}),(0,X.jsx)(`a`,{href:dn(e,F,I===`pdf`),target:`_blank`,rel:`noreferrer`,className:`shrink-0 text-ink-2 underline-offset-2 hover:text-ink hover:underline`,children:C(`run.openFull`)})]}),I===`pdf`?(0,X.jsx)(`iframe`,{title:F,src:`${dn(e,F,!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]`},F):[`png`,`jpg`,`jpeg`,`webp`].includes(I)?(0,X.jsx)(`div`,{className:`flex max-h-[46vh] justify-center overflow-auto bg-white lg:max-h-[calc(100vh-27rem)]`,children:(0,X.jsx)(`img`,{src:dn(e,F,!0),alt:F,className:`max-w-full object-contain`},F)}):(0,X.jsx)(`p`,{className:`px-4 py-10 text-center text-[0.875rem] text-ink-3`,children:C(`check.noPreview`)})]}):(0,X.jsx)(`p`,{className:`px-4 py-14 text-center text-[0.875rem] text-ink-3`,children:C(`check.noFile`)})}),(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3`,children:T.map(e=>(0,X.jsxs)(`div`,{className:b(`min-w-0`,e.type===`text`&&e.format?.style===`multiline`&&`col-span-full`),children:[(0,X.jsx)(`div`,{className:`px-1 pb-0.5 text-[0.6875rem] text-ink-3`,children:e.name}),(0,X.jsx)($,{boxed:!0,column:e,value:y.cells[e.id],onCommit:t=>void k(y.id,{[e.id]:t})})]},e.id))}),h?(0,X.jsx)(`p`,{className:`text-[0.8125rem] text-rose`,children:h}):null]}):null]})}var mn={xlsx:`Excel`,csv:`CSV`,json:`JSON`,md:`Markdown`,zip:`ZIP`};function hn({runId:e,list:t}){return(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.formats.map(n=>(0,X.jsx)(`a`,{href:a(`/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-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink coarse:h-11 coarse:px-4`,children:mn[n]??n},n))})}function gn(e){return e>1e6?`${(e/1e6).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1e3))} KB`}function _n({runId:e}){let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{t&&(s(!1),N.get(`/api/runs/${e}/store`).then(i))},[t,e]);let l=r&&!r.files.length&&!r.connections.length&&!r.keepsSignIns&&r.lists.every(e=>!e.rows);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),className:`inline-flex items-center gap-1.5 text-[0.8125rem] text-ink-4 transition hover:text-ink-2 coarse:min-h-11`,children:[(0,X.jsx)(le,{className:`size-3.5`}),` `,C(`store.open`)]}),(0,X.jsx)(S,{open:t,onClose:()=>n(!1),title:C(`store.title`),wide:!0,children:r?(0,X.jsxs)(`div`,{className:`flex flex-col gap-5 text-[0.875rem]`,children:[(0,X.jsx)(`p`,{className:`text-ink-3`,children:C(`store.explain`)}),l?(0,X.jsx)(`p`,{className:`text-ink-2`,children:C(`store.empty`)}):null,r.lists.some(e=>e.rows)?(0,X.jsx)(`ul`,{className:`flex flex-col gap-1`,children:r.lists.filter(e=>e.rows).map(e=>(0,X.jsxs)(`li`,{className:`flex justify-between gap-3`,children:[(0,X.jsx)(`span`,{children:e.title}),(0,X.jsx)(`span`,{className:`text-ink-3 tabular-nums`,children:C(`store.rows`,{n:e.rows})})]},e.id))}):null,r.connections.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(I,{className:`size-4 text-ink-3`}),` `,e.account?.label]},e.id)),r.keepsSignIns?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(c,{className:`size-4 text-ink-3`}),` `,C(`store.signIns`)]}):null,r.files.length?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-1 text-ink-3`,children:C(`store.files`,{n:r.files.length,size:gn(r.files.reduce((e,t)=>e+t.size,0))})}),(0,X.jsx)(`ul`,{className:`max-h-56 overflow-y-auto rounded-lg ring-1 ring-border-soft`,children:r.files.map(t=>(0,X.jsx)(`li`,{className:`border-border-soft border-b last:border-0`,children:(0,X.jsxs)(`a`,{href:a(`/api/runs/${e}/store/files/${t.path}`),className:`flex items-center gap-2 px-3 py-2 text-[0.8125rem] hover:bg-paper-2 coarse:min-h-11`,title:t.source??void 0,children:[(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-ink-3`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.path}),(0,X.jsx)(`span`,{className:`text-ink-4 tabular-nums`,children:gn(t.size)})]})},t.path))})]}):null,(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-1`,children:[l?(0,X.jsx)(`span`,{}):o?(0,X.jsxs)(j,{variant:`secondary`,onClick:async()=>{await N.del(`/api/runs/${e}/store`),i(await N.get(`/api/runs/${e}/store`)),s(!1)},children:[(0,X.jsx)(L,{className:`size-4`}),` `,C(`store.confirmDelete`)]}):(0,X.jsxs)(j,{variant:`ghost`,onClick:()=>s(!0),children:[(0,X.jsx)(L,{className:`size-4`}),` `,C(`store.delete`)]}),(0,X.jsx)(j,{onClick:()=>n(!1),children:C(`common.close`)})]})]}):(0,X.jsx)(`div`,{className:`flex justify-center py-8 text-ink-4`,children:(0,X.jsx)(y,{})})})]})}var vn=300;function yn(){if(typeof MediaRecorder<`u`)return[`audio/webm;codecs=opus`,`audio/mp4`,`audio/webm`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function bn(e){return`${Math.floor(e/60)}:${String(Math.floor(e%60)).padStart(2,`0`)}`}function xn({value:e,runId:t,onChange:n,onBusy:r}){let i=ve(e)?e:null,[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(0),[l,d]=(0,Y.useState)(!1),[f,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(null),b=(0,Y.useRef)(null),x=(0,Y.useRef)(null),S=yn(),w=re&&!!S;(0,Y.useEffect)(()=>()=>{b.current&&(b.current.recorder.onstop=null,b.current.stop())},[]),(0,Y.useEffect)(()=>()=>{_&&URL.revokeObjectURL(_.url)},[_]);let T=async(e,i)=>{d(!0),r?.(!0),m(null);try{let r=await N.upload(`/api/runs/${t}/uploads`,e);v({asset:r.id,url:URL.createObjectURL(e)}),n({asset:r.id,...i===void 0?{}:{seconds:i}})}catch(e){m(e.message)}finally{d(!1),r?.(!1)}},E=async()=>{m(null),g(!1);let e;try{e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}})}catch{g(!0);return}let t=[],n=new MediaRecorder(e,{mimeType:S,audioBitsPerSecond:48e3}),i=Date.now(),a=new AudioContext,s=a.createAnalyser();s.fftSize=256,a.createMediaStreamSource(e).connect(s);let l=new Uint8Array(s.fftSize),u=0,d=()=>{s.getByteTimeDomainData(l);let e=0;for(let t of l)e=Math.max(e,Math.abs(t-128));if(c(Math.min(1,e/64)),o((Date.now()-i)/1e3),(Date.now()-i)/1e3>=vn){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,o(null),c(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));T(new File(t,`sprachnotiz-${Nt()}.${r}`,{type:e}),a)},b.current={recorder:n,stop:f},r?.(!0),n.start(1e3),u=requestAnimationFrame(d)},D=a!==null,O=(0,X.jsxs)(j,{variant:`secondary`,onClick:()=>x.current?.click(),children:[(0,X.jsx)(Pe,{className:`size-4`}),` `,C(`voice.pick`)]});return(0,X.jsxs)(`div`,{children:[D?(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-3 ring-1 ring-ember`,children:[(0,X.jsxs)(`span`,{className:`relative flex size-11 shrink-0 items-center justify-center`,children:[(0,X.jsx)(`span`,{className:`absolute inset-0 rounded-full bg-rose-tint transition-transform duration-75`,style:{transform:`scale(${.7+s*.5})`}}),(0,X.jsx)(`span`,{className:`relative size-3.5 animate-pulse-dot rounded-full bg-rose`})]}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`font-medium text-[0.9375rem] tabular-nums`,children:bn(a)}),(0,X.jsx)(`div`,{className:`text-[0.8125rem] text-ink-3`,children:a>270?C(`voice.left`,{s:Math.ceil(vn-a)}):C(`voice.recording`)})]}),(0,X.jsxs)(j,{onClick:()=>b.current?.stop(),children:[(0,X.jsx)(p,{className:`size-3.5 fill-current`}),` `,C(`voice.stop`)]})]}):l?(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-card p-4 text-[0.875rem] text-ink-3 ring-1 ring-input`,children:[(0,X.jsx)(y,{className:`size-4`}),` `,C(`run.uploading`)]}):i?(0,X.jsxs)(`div`,{className:`rounded-xl bg-card p-3 ring-1 ring-input`,children:[(0,X.jsx)(`audio`,{controls:!0,preload:`metadata`,src:_?.asset===i.asset?_.url:`/api/runs/${t}/assets/${i.asset}`,className:`h-11 w-full`}),i.transcript?(0,X.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap px-1 text-[0.875rem] text-ink-2 leading-relaxed`,children:i.transcript}):null,(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:i.seconds?bn(i.seconds):null}),(0,X.jsxs)(`div`,{className:`flex gap-1`,children:[w?(0,X.jsxs)(j,{variant:`ghost`,size:`sm`,onClick:()=>void E(),children:[(0,X.jsx)(W,{className:`size-3.5`}),` `,C(`voice.again`)]}):null,(0,X.jsx)(j,{variant:`ghost`,size:`sm`,onClick:()=>n(void 0),children:C(`voice.remove`)})]})]})]}):(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[w?(0,X.jsxs)(j,{variant:`secondary`,size:`lg`,onClick:()=>void E(),className:`w-full sm:w-auto`,children:[(0,X.jsx)(u,{className:`size-4`}),` `,C(`voice.start`)]}):O,w&&h?O:null]}),h?(0,X.jsx)(`p`,{className:`mt-2 rounded-lg bg-amber-tint px-3 py-2 text-[0.8125rem] text-ink-2 leading-relaxed`,children:C(`voice.denied`)}):(0,X.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3 leading-relaxed`,children:C(w?`voice.why`:`voice.noRecorder`)})]}),(0,X.jsx)(`input`,{ref:x,type:`file`,hidden:!0,accept:`audio/*`,capture:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&T(t,void 0)}}),f?(0,X.jsx)(`div`,{className:`mt-2 text-[0.8125rem] text-rose`,children:f}):null]})}function Sn(e,t){try{return new Intl.NumberFormat(void 0,{style:`currency`,currency:t}).format(e)}catch{return`${e.toFixed(2)} ${t}`}}function Cn({field:e,value:t,values:n,onChange:r}){let i=e.columns??[],a=Array.isArray(t)&&t.length?t:[{}],s=be(e,a,n),c=(e,t,n)=>{r(a.map((r,i)=>i===e?{...r,[t]:n}:r))},l=i.map(e=>e.kind===`text`&&e===i[0]?`minmax(0,3fr)`:`minmax(0,1fr)`).join(` `);return(0,X.jsxs)(`div`,{className:`rounded-xl bg-card p-2 ring-1 ring-input`,children:[(0,X.jsx)(`div`,{className:`hidden gap-2 px-2 pt-1 pb-2 text-[0.75rem] text-ink-3 sm:grid`,style:{gridTemplateColumns:`${l} 36px`},children:i.map(e=>(0,X.jsx)(`div`,{className:e.kind===`text`?``:`text-right`,children:e.label},e.id))}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map((e,t)=>(0,X.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":`${l} 36px`},children:[i.map((n,r)=>(0,X.jsxs)(`label`,{className:b(`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,X.jsx)(`span`,{className:`px-0.5 text-[0.6875rem] text-ink-3 sm:hidden`,children:n.label}),(0,X.jsx)(`input`,{"aria-label":n.label,placeholder:n.label,inputMode:n.kind===`text`?`text`:`decimal`,autoComplete:`off`,value:String(e[n.id]??``),onChange:e=>c(t,n.id,e.target.value),className:b(`h-11 w-full min-w-0 rounded-md border border-transparent bg-paper-2 px-2.5 text-[0.875rem] 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,X.jsx)(O,{label:C(`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,X.jsx)(L,{className:`size-4`})})]},t))}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-end justify-between gap-3 px-2 pb-1`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r([...a,{}]),className:`inline-flex h-9 items-center gap-1.5 rounded-full px-3 text-[0.8125rem] text-ink-2 hover:bg-accent coarse:h-11`,children:[(0,X.jsx)(o,{className:`size-4`}),` `,C(`run.addRow`)]}),(0,X.jsxs)(`div`,{className:`text-right text-[0.8125rem] tabular-nums`,children:[(0,X.jsxs)(`div`,{className:`text-ink-3`,children:[C(`run.net`),` `,Sn(s.net,s.currency)]}),s.vatRate?(0,X.jsxs)(`div`,{className:`text-ink-3`,children:[C(`run.vat`,{r:s.vatRate}),` `,Sn(s.vat,s.currency)]}):null,(0,X.jsxs)(`div`,{className:`font-semibold text-[0.9375rem] text-ink`,children:[C(`run.total`),` `,Sn(s.gross,s.currency)]})]})]})]})}function wn(e){return!!e?.closest(`input, textarea, [contenteditable='true']`)}function Tn({field:e,value:t,runId:n,onChange:r,onBusy:i}){let o=(0,Y.useRef)(null),s=(0,Y.useRef)(null),c=(0,Y.useRef)(null),u=(0,Y.useRef)(null),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)({}),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(null),E=(0,Y.useRef)(null),D=e=>{E.current=e,T(e)},k=e.kind===`image`,A=!!e.multiple,j=A?e.max??30:1,M=k||!!e.camera||!!e.video,P=!k&&!!e.video,F=Array.isArray(t)?t:typeof t==`string`&&t?[t]:[],I=(0,Y.useRef)(F);I.current=F;let L=F.length<j,R=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 a=j-(A?I.current.length:0);p(!0),i?.(!0),_(t.length>a&&A?C(`run.maxFiles`,{n:j}):null);try{for(let e of t.slice(0,Math.max(0,a))){let t=await Mt(e),i=await N.upload(`/api/runs/${n}/uploads`,t);h(e=>({...e,[i.id]:{name:i.name,mime:i.mime}}));let a=A?[...I.current,i.id]:i.id;I.current=A?a:[i.id],r(a)}}catch(e){_(e.message)}finally{p(!1),i?.(!1)}},z=(0,Y.useRef)(R);z.current=R;let te=e=>{let t=F.filter(t=>t!==e);r(A?t:void 0)},B=(e,t)=>{let n=I.current.indexOf(e),i=Math.min(I.current.length-1,Math.max(0,t));if(n<0||n===i)return;let a=I.current.filter(t=>t!==e);a.splice(i,0,e),I.current=a,r(a)},V=A&&F.length>1;(0,Y.useEffect)(()=>{if(!L)return;let e=e=>{let t=Array.from(e.clipboardData?.files??[]),n=o.current;if(!t.length||!n||wn(document.activeElement))return;let r=document.querySelectorAll(`[data-upload-field]`);(n.matches(`:hover`)||n.contains(document.activeElement)||r.length===1)&&(e.preventDefault(),z.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[L]);let H=b(`flex flex-col items-center justify-center gap-2 rounded-xl border border-input border-dashed bg-card px-3 text-[0.875rem] text-ink-3 transition hover:border-ember hover:text-ink`,F.length?`py-4`:`py-8`);return(0,X.jsxs)(`div`,{ref:o,"data-upload-field":``,onDragOver:e=>{L&&(e.preventDefault(),S(!0))},onDragLeave:()=>S(!1),onDrop:e=>{S(!1),L&&(e.preventDefault(),R(Array.from(e.dataTransfer.files)))},children:[F.length?(0,X.jsx)(`div`,{className:`mb-2 flex flex-col gap-2`,children:F.map((e,t)=>{let r=m[e],i=r?.mime??(k?`image/`:``);return(0,X.jsxs)(`div`,{"data-file-id":e,className:b(`flex items-center gap-3 rounded-xl bg-card p-2 ring-1 ring-input transition-shadow`,w===e&&`relative z-10 shadow-elevated ring-2 ring-ember`),children:[V?(0,X.jsxs)(`button`,{type:`button`,"aria-label":C(`run.moveFile`,{n:t+1}),title:C(`run.moveFileHint`),className:b(`-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`,w===e?`cursor-grabbing`:`cursor-grab`),onPointerDown:t=>{try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}D(e)},onPointerMove:t=>{if(E.current!==e)return;let n=document.elementFromPoint(t.clientX,t.clientY)?.closest(`[data-file-id]`),r=n?.getAttribute(`data-file-id`);r&&r!==e&&o.current?.contains(n??null)&&B(e,I.current.indexOf(r))},onPointerUp:()=>D(null),onPointerCancel:()=>D(null),onKeyDown:n=>{(n.key===`ArrowUp`||n.key===`ArrowDown`)&&(n.preventDefault(),B(e,t+(n.key===`ArrowUp`?-1:1)))},children:[(0,X.jsx)(`span`,{className:`font-medium text-[0.75rem] tabular-nums`,children:t+1}),(0,X.jsx)(He,{className:`size-4`})]}):null,i.startsWith(`image/`)?(0,X.jsx)(`img`,{src:a(`/api/runs/${n}/assets/${e}`),alt:``,className:`size-14 rounded-lg object-cover`}):(0,X.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-lg bg-paper-2`,children:i.startsWith(`video/`)?(0,X.jsx)(Ie,{className:`size-5 text-ink-3`}):(0,X.jsx)(l,{className:`size-5 text-ink-3`})}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-[0.875rem]`,children:r?.name??`✓`}),(0,X.jsx)(O,{label:C(`run.removeFile`),onClick:()=>te(e),children:(0,X.jsx)(d,{className:`size-4`})})]},e)})}):null,L?(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>s.current?.click(),className:b(H,`min-w-[9rem] flex-1 px-4`,x&&`border-ember text-ink`),children:[k?(0,X.jsx)(We,{className:`size-6`}):(0,X.jsx)(l,{className:`size-6`}),f?C(`run.uploading`):F.length?C(`run.uploadMore`):C(U?`run.uploadTouch`:`run.upload`)]}),M?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>re?y(!0):c.current?.click(),className:b(H,`w-28`),children:[(0,X.jsx)(Oe,{className:`size-6`}),C(`run.camera`)]}):null,P&&!(re&&Ut)?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>u.current?.click(),className:b(H,`w-28`),children:[(0,X.jsx)(ee,{className:`size-6`}),C(`camera.video`)]}):null]}):null,(0,X.jsx)(`input`,{ref:s,type:`file`,hidden:!0,multiple:A,accept:k?`image/*`:void 0,onChange:e=>{R(Array.from(e.target.files??[])),e.target.value=``}}),(0,X.jsx)(`input`,{ref:c,type:`file`,hidden:!0,accept:`image/*`,capture:`environment`,onChange:e=>{R(Array.from(e.target.files??[])),e.target.value=``}}),P?(0,X.jsx)(`input`,{ref:u,type:`file`,hidden:!0,accept:`video/*`,capture:`environment`,onChange:e=>{R(Array.from(e.target.files??[])),e.target.value=``}}):null,(0,X.jsx)(Wt,{open:v,multiple:A,video:P,onClose:()=>y(!1),onCapture:e=>R([e]),onNative:()=>c.current?.click()}),A&&(e.min||e.max)?(0,X.jsx)(`div`,{className:`mt-2 text-[0.8125rem] text-ink-3 tabular-nums`,children:e.min&&F.length<e.min?C(`run.filesMin`,{n:F.length,min:e.min}):e.max?C(`run.filesOf`,{n:F.length,max:e.max}):null}):null,g?(0,X.jsx)(`div`,{className:`mt-2 text-[0.8125rem] text-rose`,children:g}):null]})}function En(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 Dn({field:e,value:t,onChange:n}){let[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(A,{value:t,placeholder:e.placeholder,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,onChange:e=>n(e.target.value)}),(0,X.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-[0.875rem] text-ink-2 transition hover:border-ember hover:text-ink`,children:[(0,X.jsx)(st,{className:`size-4`}),` `,C(`scan.button`)]}),(0,X.jsx)(Qt,{open:r,onClose:()=>i(!1),onResult:n})]})}var On=4;function kn(e){let t=new Map,n=e.map(e=>({value:e,slot:me(e)})).filter(e=>e.slot).sort((e,t)=>Date.parse(e.value)-Date.parse(t.value));for(let{value:e,slot:r}of n){if(!r)continue;let n=t.get(r.day)??{label:he(e,w),times:[]};n.times.push({value:e,time:r.time}),t.set(r.day,n)}return[...t.values()]}function An({name:e,label:t,options:n,value:r,onChange:i,disabled:a}){let o=kn(n),s=o.findIndex(e=>e.times.some(e=>e.value===r)),[c,l]=(0,Y.useState)(s>=On);if(!o.length)return(0,X.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:C(`slot.none`)});let u=c?o:o.slice(0,On);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:t}),u.map(t=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`mb-2 font-medium text-[0.75rem] text-ink-3`,children:t.label}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.times.map(n=>(0,X.jsxs)(`label`,{className:`relative`,children:[(0,X.jsx)(`input`,{type:`radio`,name:`slot-${e}`,value:n.value,checked:n.value===r,disabled:a.has(n.value),"aria-label":`${t.label}, ${n.time}`,onChange:()=>i(n.value),className:`peer sr-only`}),(0,X.jsx)(`span`,{className:b(`inline-flex h-10 cursor-pointer items-center rounded-full border px-4 text-sm tabular-nums transition coarse:h-11`,`border-input bg-card text-ink-2 hover:border-ink-4 hover:text-ink`,`peer-checked:border-ember peer-checked:bg-ember-tint peer-checked:text-ink`,`peer-disabled:pointer-events-none peer-disabled:line-through peer-disabled:opacity-60`,`peer-focus-visible:outline-[1.5px] peer-focus-visible:outline-offset-2 peer-focus-visible:outline-(--focus-line) peer-focus-visible:outline-solid`),children:n.time})]},n.value))})]},t.label))]}),o.length>u.length?(0,X.jsx)(`button`,{type:`button`,onClick:()=>l(!0),className:`self-start text-[0.8125rem] text-ink-3 underline-offset-4 transition hover:text-ink hover:underline coarse:min-h-11`,children:C(`slot.later`)}):null]})}function jn({field:e,value:t,values:n,runId:r,view:i,onChange:a,onBusy:o,error:s,closed:c}){let l=t==null?``:String(t),u=new Set(c?.values.map(String)),d;switch(e.kind){case`textarea`:d=(0,X.jsx)(x,{value:l,placeholder:e.placeholder,autoCapitalize:`sentences`,enterKeyHint:`enter`,onChange:e=>a(e.target.value)});break;case`number`:d=(0,X.jsx)(A,{inputMode:`decimal`,autoComplete:`off`,value:l,placeholder:e.placeholder,onChange:e=>a(e.target.value)});break;case`select`:{let t=e.options??[];d=t.length<=5&&t.every(e=>e.length<=28)?(0,X.jsx)(M,{value:l,options:t,onChange:a,disabled:[...u]}):(0,X.jsx)(v,{value:l,placeholder:`—`,onChange:a,options:t.map(e=>({value:e,label:e,disabled:u.has(e)}))});break}case`slot`:d=(0,X.jsx)(An,{name:e.id,label:e.label,options:e.options??[],value:l,onChange:a,disabled:u});break;case`multiselect`:d=(0,X.jsx)(M,{multi:!0,value:Array.isArray(t)?t:[],options:e.options??[],onChange:a});break;case`date`:d=(0,X.jsx)(A,{type:`date`,value:l,onChange:e=>a(e.target.value),className:`w-full sm:w-56`});break;case`email`:d=(0,X.jsx)(A,{type:`email`,inputMode:`email`,autoComplete:`email`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,value:l,placeholder:e.placeholder,onChange:e=>a(e.target.value)});break;case`url`:d=(0,X.jsx)(A,{type:`url`,inputMode:`url`,autoComplete:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,value:l,placeholder:e.placeholder??`https://`,onChange:e=>a(e.target.value)});break;case`toggle`:d=(0,X.jsx)(E,{checked:t===!0,onChange:a,label:e.label,disabled:u.has(String(t!==!0))});break;case`color`:d=(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(k,{value:l||`#e0531b`,onChange:e=>a(e.target.value)}),(0,X.jsx)(A,{value:l,placeholder:`#e0531b`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,onChange:e=>a(e.target.value),className:`w-36`})]});break;case`image`:case`file`:d=(0,X.jsx)(Tn,{field:e,value:t,runId:r,onChange:a,onBusy:o});break;case`items`:d=(0,X.jsx)(Cn,{field:e,value:t,values:n,onChange:a});break;case`connection`:d=(0,X.jsx)(sn,{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);d=t?(0,X.jsx)(un,{runId:r,list:t,editable:!0}):null;break}case`location`:d=(0,X.jsx)(Jt,{value:t,runId:r,placeholder:e.placeholder,onChange:a,onBusy:o});break;case`audio`:d=c?null:(0,X.jsx)(xn,{value:t,runId:r,onChange:a,onBusy:o});break;case`signature`:d=(0,X.jsx)(an,{label:e.label,value:t,runId:r,onChange:a});break;default:d=e.scan?(0,X.jsx)(Dn,{field:e,value:l,onChange:a}):(0,X.jsx)(A,{...En(e),value:l,placeholder:e.placeholder,onChange:e=>a(e.target.value)})}return(0,X.jsxs)(`div`,{children:[e.kind===`toggle`?(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-6`,children:[(0,X.jsx)(_,{hint:e.help,children:e.label}),d]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_,{hint:e.help,required:e.required,children:e.label}),d]}),c?(0,X.jsx)(`div`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:C(`run.closed`,{list:c.classes.map(e=>C(`run.cls.${Mn[e]}`)).join(`, `)})}):null,s?(0,X.jsx)(`div`,{className:`mt-1.5 text-[0.8125rem] text-rose`,children:s}):null]})}var Mn={classifier:`text`,standard:`text`,high:`text`,highest:`text`,image:`image`,video:`video`,speech:`speech`,audio:`audio`},Nn=45e3;function Pn(e){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)({});(0,Y.useEffect)(()=>{if(n(null),s(!1),!e)return;let t=!1,r=0,i,o=null,c=Date.now(),l=()=>{t=!0,o?.close(),s(!0)},u=async()=>{try{let r=await N.get(`/api/runs/${e}`);t||n(r)}catch(e){e instanceof g&&e.status===404&&l()}},d=()=>{if(clearTimeout(i),o?.close(),t)return;let s=new EventSource(a(`/api/runs/${e}/stream`),{withCredentials:!0});o=s,c=Date.now(),s.addEventListener(`view`,e=>{r=0,c=Date.now(),n(JSON.parse(e.data))}),s.addEventListener(`ping`,()=>{c=Date.now()}),s.onerror=()=>{s.close(),!(t||o!==s)&&(o=null,u(),r=Math.min(r+1,6),i=setTimeout(d,500*2**r))}},f=()=>{t||document.visibilityState!==`visible`||(!o||o.readyState===EventSource.CLOSED||Date.now()-c>Nn?(r=0,d()):u())},p=setInterval(()=>{!t&&o&&Date.now()-c>Nn&&(r=0,d())},15e3);return d(),document.addEventListener(`visibilitychange`,f),window.addEventListener(`pageshow`,f),window.addEventListener(`online`,f),()=>{t=!0,clearTimeout(i),clearInterval(p),document.removeEventListener(`visibilitychange`,f),window.removeEventListener(`pageshow`,f),window.removeEventListener(`online`,f),o?.close()}},[e]);let f=(0,Y.useCallback)(async(t,n)=>{if(!e)return!1;l(!0),i(null),d({});try{return await N.post(`/api/runs/${e}/${t}`,n),!0}catch(e){return e instanceof g&&e.status===422&&Array.isArray(e.body?.fields)&&d(Object.fromEntries(e.body.fields.map(e=>[e.field,e.message]))),i(e.message),!1}finally{l(!1)}},[e]);return{view:t,notFound:o,error:r,busy:c,fieldErrors:u,submitPage:(e,t)=>f(`pages/${e}`,{values:t}),accept:(e,t)=>f(`reviews/${e}`,{type:`accept`,edits:t}),regenerate:(e,t,n,r)=>f(`reviews/${e}`,{type:`regenerate`,target:t,note:n,items:r?.length?r:void 0}),back:()=>f(`back`),retry:()=>f(`retry`)}}function Fn({view:e}){let t=Math.round(Math.min(e.progress.done,e.progress.total)/Math.max(1,e.progress.total)*100);return(0,X.jsx)(`div`,{className:`h-[3px] w-full bg-paper-2`,children:(0,X.jsx)(`div`,{className:`h-full bg-ember transition-[width] duration-700 ease-out`,style:{width:`${t}%`}})})}function In({title:e,description:t,kicker:n}){return(0,X.jsxs)(`div`,{className:`mb-8`,children:[n?(0,X.jsx)(`p`,{className:`mb-4 text-[0.9375rem] text-ink-2 leading-relaxed`,children:n}):null,(0,X.jsx)(`h1`,{className:`font-display font-semibold text-[1.75rem] leading-[1.15] tracking-tight sm:text-[2rem]`,children:e}),t?(0,X.jsx)(`p`,{className:`mt-2 text-[0.9375rem] text-ink-3 leading-relaxed`,children:t}):null]})}function Ln(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 Rn(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 zn({view:e,run:t,step:n}){let[r,i]=(0,Y.useState)(()=>Ln(n,e)),[a,o]=(0,Y.useState)(new Set),s=(0,Y.useRef)(null),c=e.progress.done===0,l=(0,Y.useMemo)(()=>n.fields.filter(t=>!_e(t)||e.decidedFields?.includes(t.id)).map(t=>e.options?.[t.id]?.length?{...t,options:e.options[t.id]}:t),[n.fields,e.options,e.decidedFields]),u=ye(l,e.known??{},r),d=()=>void t.submitPage(n.id,r);return(0,Y.useEffect)(()=>{if(!s.current)return;let e=Rn(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,X.jsxs)(`form`,{ref:s,className:`animate-rise`,onSubmit:e=>{e.preventDefault(),a.size||d()},onKeyDown:e=>{let t=e.target;if(e.key!==`Enter`||e.defaultPrevented||e.nativeEvent.isComposing||!(t instanceof HTMLInputElement)||t.closest(`dialog`))return;let n=Rn(e.currentTarget),r=n[n.indexOf(t)+1];r&&(e.preventDefault(),r.focus())},children:[(0,X.jsx)(In,{title:n.title,description:n.description,kicker:c?e.wizard.intro:null}),(0,X.jsx)(`div`,{className:`flex flex-col gap-7`,children:u.map(n=>(0,X.jsx)(jn,{field:n,value:r[n.id],values:r,runId:e.id,view:e,error:t.fieldErrors[n.id],closed:e.closed?.[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,X.jsx)(Bn,{view:e,run:t,sticky:!0,children:(0,X.jsxs)(j,{type:`submit`,size:`lg`,busy:t.busy,disabled:a.size>0,children:[n.cta||C(`run.next`),` `,(0,X.jsx)(P,{className:`size-4`})]})})]})}function Bn({view:e,run:t,sticky:n,children:r}){return(0,X.jsxs)(`div`,{className:b(`mt-10 flex items-center justify-between gap-3`,n&&`action-bar`),children:[e.canBack?(0,X.jsxs)(j,{variant:`ghost`,onClick:()=>void t.back(),disabled:t.busy,children:[(0,X.jsx)(h,{className:`size-4`}),` `,C(`run.back`)]}):(0,X.jsx)(`span`,{}),r]})}function Vn(){let e=de(),[t,n]=(0,Y.useState)(!1),r=e!==`off`;return(0,X.jsxs)(`div`,{className:`mt-6 flex flex-col items-center gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:t,onClick:async()=>{if(r){ue();return}n(!0),await pe(),n(!1)},className:b(`inline-flex h-11 items-center gap-2 rounded-full px-4 font-medium text-[0.875rem] 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,X.jsx)(we,{className:`size-4 text-ember-strong`}):(0,X.jsx)(Ee,{className:`size-4`}),C(r?`notify.on`:`notify.ask`)]}),(0,X.jsx)(`p`,{className:`max-w-xs text-[0.75rem] text-ink-4 leading-relaxed`,children:C(e===`off`?`notify.why`:e===`on`?`notify.onHint`:fe()?`notify.blocked`:`notify.quiet`)})]})}function Hn({view:e,compact:t,awake:n}){let i=(0,Y.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,Y.useState)(Date.now());(0,Y.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??C(`run.working`),l=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=i-500),u=l.slice(-4),d=[...new Set(l.map(e=>e.asset).filter(e=>!!e))],p=[...l].reverse().find(e=>e.asset)?.asset;return(0,X.jsxs)(`div`,{className:`flex animate-rise flex-col items-center pt-6 text-center`,children:[(0,X.jsx)(r,{kind:e.wizard.avatar,size:t?130:170,fluffy:!0}),(0,X.jsx)(`h2`,{className:`mt-4 font-display font-semibold text-[1.375rem] tracking-tight`,children:c}),(0,X.jsx)(`div`,{className:`mt-1 text-[0.8125rem] text-ink-4 tabular-nums`,children:C(`run.elapsed`,{s:Math.max(0,Math.round((o-i)/1e3))})}),d.length?(0,X.jsx)(`div`,{className:`mt-5 flex max-w-full flex-wrap justify-center gap-2`,children:d.slice(-8).map(t=>(0,X.jsx)(`img`,{src:a(`/api/runs/${e.id}/assets/${t}`),alt:``,className:b(`size-16 animate-rise rounded-lg bg-paper-2 object-cover ring-1 ring-border-soft transition sm:size-20`,t===p?`ring-2 ring-ember`:`opacity-70`)},t))}):null,(0,X.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,X.jsxs)(`div`,{className:b(`flex items-center justify-center gap-2 text-[0.8125rem] transition-opacity`,t===u.length-1?`text-ink-2`:`text-ink-4`),children:[t===u.length-1?(0,X.jsx)(ce,{className:`size-3.5 animate-breathe text-ember`}):null,(0,X.jsx)(`span`,{className:`truncate`,children:f(e)})]},e.id))}),t?null:(0,X.jsx)(Vn,{}),n?(0,X.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-4`,children:C(`run.awake`)}):null]})}function Un(e){let t=(0,Y.useRef)({running:!1,since:0,ask:null});(0,Y.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}`),H({title:e.wizard.title,body:t,tag:e.id})};r&&e.ask&&e.ask.id!==n.ask?a(C(`notify.needsYou`)):!r&&n.running&&Date.now()-n.since>8e3&&a(e.status===`failed`?C(`run.failed`):e.status===`done`?C(`notify.done`):C(`notify.next`)),t.current={running:r,since:i,ask:e.ask?.id??null}},[e]),(0,Y.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 Wn({view:e,run:t,step:n}){let[r,i]=(0,Y.useState)({}),[a,o]=(0,Y.useState)({}),[s,c]=(0,Y.useState)(``),l=e.shown.filter(e=>e.output),[u,d]=(0,Y.useState)(l.length===1?l[0].step.id:null),[f,p]=(0,Y.useState)({}),m=(0,Y.useRef)(null),h=l.find(e=>e.step.id===u),g=h?.step.type===`generate`&&(h.output?.assets?.length??0)>1,_=()=>{h&&s.trim()&&t.regenerate(n.id,h.step.id,s.trim(),f[h.step.id])};return(0,X.jsxs)(`div`,{className:`animate-rise`,children:[(0,X.jsx)(In,{title:n.title,description:n.description}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[e.shown.filter(e=>e.output).map(({step:t,output:s})=>{let c=!!n.edit&&t.type===`agent`&&t.output.format!==`json`;return(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h3`,{className:`font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.06em]`,children:t.title}),(0,X.jsx)(`div`,{className:`flex items-center`,children:c&&!a[t.id]?(0,X.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-[0.8125rem] text-ink-2 hover:bg-accent hover:text-ink coarse:h-11`,children:[(0,X.jsx)(it,{className:`size-3.5`}),` `,C(`run.edit`)]}):null})]}),(0,X.jsx)(se,{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:f[t.id],onPick:n.regenerate?e=>{d(t.id),p(n=>{let r=n[t.id]??[];return{...n,[t.id]:r.includes(e)?r.filter(t=>t!==e):[...r,e]}}),m.current?.focus()}:void 0,onSurfaceAction:n.regenerate?()=>{d(t.id),m.current?.focus()}:void 0})]},t.id)}),e.lists.map(t=>(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-2 font-medium text-[0.8125rem] text-ink-3 uppercase tracking-[0.06em]`,children:t.def.title}),t.def.check?(0,X.jsx)(pn,{runId:e.id,list:t}):(0,X.jsx)(un,{runId:e.id,list:t,editable:!0})]},t.def.id)),n.regenerate&&l.length?(0,X.jsxs)(D,{className:`p-3`,children:[l.length>1?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 px-1 pb-2`,children:[(0,X.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:C(`run.feedbackTarget`)}),l.map(({step:e})=>(0,X.jsx)(`button`,{type:`button`,"aria-pressed":u===e.id,onClick:()=>{d(e.id),m.current?.focus()},className:b(`inline-flex h-8 items-center rounded-full px-3 text-[0.8125rem] ring-1 transition coarse:h-11`,u===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,X.jsx)(x,{ref:m,minRows:2,maxRows:8,value:s,placeholder:C(`run.feedbackPlaceholder`),onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),_())},className:`border-0 bg-transparent shadow-none focus:ring-0`}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1 pt-1`,children:[(0,X.jsx)(`span`,{className:`min-w-0 text-[0.75rem] text-ink-3`,children:g?f[h.step.id]?.length?C(`run.regeneratePicked`,{n:[...f[h.step.id]].sort((e,t)=>e-t).map(e=>e+1).join(`, `)}):C(`run.regenerateAll`):!h&&s.trim()?C(`run.feedbackPick`):null}),(0,X.jsxs)(j,{size:`sm`,variant:`secondary`,busy:t.busy,disabled:!s.trim()||!h,onClick:_,children:[(0,X.jsx)(z,{className:`size-3.5`}),` `,C(`run.regenerateGo`)]})]})]}):null]}),(0,X.jsx)(Bn,{view:e,run:t,sticky:!0,children:(0,X.jsxs)(j,{size:`lg`,busy:t.busy,onClick:()=>void t.accept(n.id,Object.keys(r).length?r:void 0),children:[C(`run.accept`),` `,(0,X.jsx)(P,{className:`size-4`})]})})]})}function Gn({view:e,run:t,step:n,onRestart:i}){let a=e.shown.filter(e=>e.output);return(0,X.jsxs)(`div`,{className:`animate-rise`,children:[(0,X.jsxs)(`div`,{className:`mb-8 flex flex-wrap items-center gap-x-4 gap-y-5`,children:[(0,X.jsx)(r,{kind:e.wizard.avatar,size:64}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 basis-[12rem]`,children:[(0,X.jsx)(`h1`,{className:`text-balance font-display font-semibold text-[1.75rem] leading-tight tracking-tight sm:text-[2rem]`,children:n.title}),n.message?(0,X.jsx)(`p`,{className:`mt-1 text-[0.9375rem] text-ink-3`,children:n.message}):null]}),e.shown.some(e=>e.output)?(0,X.jsx)(`div`,{className:`max-sm:basis-full`,children:(0,X.jsx)(Dt,{runId:e.id,title:`${n.title} · ${e.wizard.title}`,initial:e.shareUrl?{url:e.shareUrl,expiresAt:e.expiresAt}:null})}):null]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[a.map(({step:t,output:n,formats:r,label:i})=>(0,X.jsxs)(D,{className:`p-4 sm:p-5`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsx)(`h3`,{className:`font-display font-semibold text-[1.0625rem]`,children:i??t.title}),(0,X.jsx)(oe,{base:`/api/runs/${e.id}`,stepId:t.id,formats:r,title:i??t.title})]}),(0,X.jsx)(se,{base:`/api/runs/${e.id}`,step:t,output:n}),n?.assets?.some(e=>e.ai)?(0,X.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-3 leading-relaxed`,children:C(`ai.publish`)}):null]},t.id)),e.lists.map(t=>(0,X.jsxs)(D,{className:`p-4 sm:p-5`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsx)(`h3`,{className:`font-display font-semibold text-[1.0625rem]`,children:t.label??t.def.title}),(0,X.jsx)(hn,{runId:e.id,list:t})]}),(0,X.jsx)(un,{runId:e.id,list:t,editable:!0})]},t.def.id))]}),(0,X.jsx)(Bn,{view:e,run:t,children:i?(0,X.jsxs)(j,{variant:`secondary`,onClick:i,children:[(0,X.jsx)(W,{className:`size-4`}),` `,C(`run.again`)]}):(0,X.jsx)(`span`,{})})]})}function Kn({view:e,run:t}){return(0,X.jsxs)(`div`,{className:`flex animate-rise flex-col items-center pt-8 text-center`,children:[(0,X.jsx)(r,{kind:e.wizard.avatar,size:90}),(0,X.jsx)(`h2`,{className:`mt-4 font-display font-semibold text-[1.375rem]`,children:C(`run.failed`)}),(0,X.jsx)(`p`,{className:`mt-2 max-w-md text-[0.9375rem] text-ink-3`,children:(0,X.jsx)(T,{text:e.error??``})}),(0,X.jsxs)(`div`,{className:`mt-8 flex gap-3`,children:[e.canBack?(0,X.jsxs)(j,{variant:`ghost`,onClick:()=>void t.back(),children:[(0,X.jsx)(h,{className:`size-4`}),` `,C(`run.back`)]}):null,(0,X.jsxs)(j,{onClick:()=>void t.retry(),busy:t.busy,children:[(0,X.jsx)(W,{className:`size-4`}),` `,C(`run.retry`)]})]})]})}function qn({runId:e,compact:t,onRestart:n,onView:r,stickyProgress:i}){let a=Pn(e),{view:o}=a;(0,Y.useEffect)(()=>{r?.(o)},[o,r]),te();let s=ne(o?.status===`running`&&!o.ask);if(Un(o),a.notFound)return(0,X.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:C(`run.notFound`)});if(!o)return(0,X.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,X.jsx)(y,{})});let c=o.step,l=null;if(o.status===`running`&&o.ask)l=(0,X.jsx)(Ot,{runId:o.id,ask:o.ask},o.ask.id);else if(o.status===`running`)l=(0,X.jsx)(Hn,{view:o,compact:t,awake:s});else if(o.status===`failed`)l=(0,X.jsx)(Kn,{view:o,run:a});else if(o.status===`cancelled`)l=(0,X.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:C(`run.cancelled`)});else if(c?.type===`page`)l=(0,X.jsx)(zn,{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,X.jsx)(Wn,{view:o,run:a,step:c},`${c.id}:${e}`)}else c?.type===`result`&&(l=(0,X.jsx)(Gn,{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,X.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[i?(0,X.jsx)(`div`,{className:`sticky top-0 z-10`,children:(0,X.jsx)(Fn,{view:o})}):(0,X.jsx)(Fn,{view:o}),(0,X.jsxs)(`div`,{className:b(`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,X.jsx)(`div`,{className:`mt-4 rounded-lg bg-rose-tint px-4 py-3 text-[0.875rem] text-rose`,children:a.error}):null,o.keeps&&o.status!==`running`?(0,X.jsx)(`div`,{className:`mt-10 flex justify-center`,children:(0,X.jsx)(_n,{runId:o.id})}):null]})]})}export{Ie as a,Qe as i,G as n,Se as o,it as r,qn as t};
|