@puddle-code/cli 0.4.11 → 0.4.14

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +5 -16
  2. package/dist/index.js +6 -3
  3. package/dist/public/assets/App-HMdAT-QZ.js +15 -0
  4. package/dist/public/assets/{Dashboard-CEjiJV52.js → Dashboard--rx_rrB_.js} +1 -1
  5. package/dist/public/assets/{LazyTerminal-Bw9C4Swp.js → LazyTerminal-CIclyIWs.js} +2 -2
  6. package/dist/public/assets/{PaneEditorBody-BdoKPslR.js → PaneEditorBody-AMEuxrqB.js} +2 -2
  7. package/dist/public/assets/Ripple-PKD1N1WS.js +12 -0
  8. package/dist/public/assets/Ripple-vJvVFdfw.css +1 -0
  9. package/dist/public/assets/{SettingsDialog-2WaxsH3h.js → SettingsDialog-B15ygzWY.js} +1 -1
  10. package/dist/public/assets/Terminal-D4qZBQDk.js +65 -0
  11. package/dist/public/assets/{Workspace-B8WZOpOl.js → Workspace-Baj8JhOO.js} +6 -6
  12. package/dist/public/assets/{command-CN8HRRWf.js → command--8Svn0Z-.js} +1 -1
  13. package/dist/public/assets/{dist-KPX-s1ou.js → dist-B8heQ9Kq.js} +1 -1
  14. package/dist/public/assets/{dist-a682-VMb.js → dist-Dac0re_p.js} +1 -1
  15. package/dist/public/assets/{expanding-content-DOZTeXd_.js → expanding-content-CXpxNvmA.js} +1 -1
  16. package/dist/public/assets/{index-BuNmxuXx.js → index-B5q_SMZR.js} +2 -2
  17. package/dist/public/assets/{index-CHGSBAX2.css → index-D_XpA70m.css} +1 -1
  18. package/dist/public/assets/{media-refresh-store-DCt4XZrY.js → media-refresh-store-CYiYB60R.js} +1 -1
  19. package/dist/public/assets/notification-delivery-CGw2AFKW.js +1 -0
  20. package/dist/public/assets/{popover-4DSuF34m.js → popover-D5HmbdQ7.js} +1 -1
  21. package/dist/public/assets/preferences-4IYvJCFc.js +1 -0
  22. package/dist/public/assets/render-rich-content-DXt6ncgk.js +4 -0
  23. package/dist/public/assets/{select-D099Wd2u.js → select-CGxTz4dh.js} +1 -1
  24. package/dist/public/assets/selection-actions-BWAzKbbb.js +1 -0
  25. package/dist/public/assets/{session-order-s2zUuZaO.js → session-order-iVRWTB-C.js} +1 -1
  26. package/dist/public/assets/{switch-AY03lzhq.js → switch-DYr-iPWY.js} +1 -1
  27. package/dist/public/assets/{use-ui-state-BpnVbZPm.js → use-ui-state-BZrKAgQ4.js} +1 -1
  28. package/dist/public/assets/ws-DV_MCpbg.js +1 -0
  29. package/dist/public/index.html +2 -2
  30. package/package.json +1 -1
  31. package/dist/public/assets/App-Btf7WD40.js +0 -26
  32. package/dist/public/assets/Ripple-DAeJ5ylo.css +0 -1
  33. package/dist/public/assets/Ripple-sD2osFo9.js +0 -7
  34. package/dist/public/assets/Terminal-D8s2Y67v.js +0 -65
  35. package/dist/public/assets/link-buffer-CsjuZOHH.js +0 -1
  36. package/dist/public/assets/notification-delivery-BkhZwpcS.js +0 -1
  37. package/dist/public/assets/preferences-CbkHsty9.js +0 -1
  38. package/dist/public/assets/render-rich-content-DF6NaC_6.js +0 -4
  39. package/dist/public/assets/ws-CS9chtfK.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./react-CZI7_Jkm.js";import{$ as r,A as i,B as a,Et as o,F as s,H as c,J as l,K as u,P as d,T as f,U as p,Y as m,Z as h,_t as g,at as _,ft as v,it as y,k as b,kt as x,lt as S,n as C,nt as w,o as T,st as ee,tt as E,u as te,ut as ne,vt as re}from"./protocol-support-BwRR1kRO.js";import{B as ie,G as ae,H as oe,Q as se,U as ce,V as le,_ as ue,g as de,h as fe,q as pe,v as me,y as he}from"./auth-C3ruG3fE.js";import{c as ge,i as _e,l as ve,r as ye,u as be}from"./LazyTerminal-Bw9C4Swp.js";import{A as xe,C as Se,E as Ce,M as we,O as Te,P as Ee,S as De,_ as Oe,a as ke,b as Ae,c as je,d as Me,f as Ne,i as Pe,k as Fe,l as Ie,m as Le,n as Re,o as ze,r as Be,s as Ve,t as He,u as Ue,v as We,x as Ge,y as Ke}from"./notification-delivery-BkhZwpcS.js";import{a as qe,i as Je,r as D,t as Ye}from"./client-settings-BdKglwtW.js";import{c as Xe,t as Ze}from"./theme-swfNLod9.js";import{t as Qe}from"./jsx-runtime-By8HlURe.js";import{r as $e}from"./index-BuNmxuXx.js";import{n as et,t as tt}from"./api-CULxlzTe.js";import{t as nt}from"./desktop-Bl69_YmL.js";import{n as O,t as k}from"./createLucideIcon-C9A1vLE-.js";import{a as A,i as j,n as rt,o as it,r as M,s as N,t as P}from"./dialog-DtvE8ATK.js";import{n as F}from"./dist-BOS6OKSE.js";import{a as at,i as I}from"./dist-a682-VMb.js";import{n as ot,r as st}from"./dist-BeQvHdsz.js";import{t as L}from"./button-DtByPSFL.js";import{a as ct,c as lt,i as ut,l as dt,n as ft,o as pt,r as mt,t as R,u as ht}from"./switch-AY03lzhq.js";import{a as z,i as B,n as V,r as H,t as U}from"./select-D099Wd2u.js";import{t as gt}from"./code-Cf4ftdOa.js";import{t as _t}from"./rotate-ccw-BI2k_h3A.js";import{t as vt}from"./x-DV6-RYI2.js";import{a as yt,g as bt,n as xt,o as St,p as Ct,r as wt,v as W}from"./ws-CS9chtfK.js";import{t as Tt}from"./control-tray-c9uXOo-i.js";import{n as G}from"./errors-efDAjyqa.js";import{t as Et}from"./use-debounced-value-C86N-mOK.js";import{n as Dt,r as Ot,t as kt}from"./popover-4DSuF34m.js";import{a as At,o as jt,r as Mt,t as Nt,u as Pt}from"./CompilationCommandForm-DQjUhaHj.js";var Ft=k(`bell`,[[`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`}]]),It=k(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Lt=k(`shield-alert`,[[`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:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Rt=k(`shield-check`,[[`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`}]]),zt=k(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),Bt=k(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),K=e(n(),1),q=Qe();function J({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,K.useState)(String(t));return(0,K.useEffect)(()=>c(String(t)),[t]),(0,q.jsx)(I,{id:e,type:`number`,min:n,max:r,step:i,className:a,value:s,onChange:e=>c(e.target.value),onBlur:()=>{let e=Number(s);if(s.trim()===``||!Number.isFinite(e)){c(String(t));return}let i=Math.min(r??e,Math.max(n??e,e));c(String(i)),i!==t&&o(i)},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}function Y({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,q.jsxs)(`div`,{className:O(`flex items-center gap-4 py-2.5`,a),children:[(0,q.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:O(`text-xs text-fg-muted`,n),children:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function X({children:e,note:t}){return(0,q.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function Vt(){let e=Je(),[t,n]=(0,K.useState)(Xe());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Appearance`}),(0,q.jsx)(Y,{label:`Theme`,children:(0,q.jsxs)(U,{value:t,onValueChange:e=>{n(e),Ze(e)},children:[(0,q.jsx)(B,{className:`w-32`,children:(0,q.jsx)(z,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(H,{value:`dark`,children:`Dark`}),(0,q.jsx)(H,{value:`light`,children:`Light`}),(0,q.jsx)(H,{value:`system`,children:`System`})]})]})}),(0,q.jsx)(Y,{label:`Cursor style`,children:(0,q.jsxs)(U,{value:e.cursorPackage,onValueChange:e=>D({cursorPackage:e}),children:[(0,q.jsx)(B,{className:`w-36`,children:(0,q.jsx)(z,{})}),(0,q.jsx)(V,{children:qe.map(e=>(0,q.jsx)(H,{value:e.id,children:e.label},e.id))})]})}),(0,q.jsx)(Y,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,q.jsx)(J,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>D({uiFontSize:e})})}),(0,q.jsx)(Y,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,q.jsx)(J,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>D({terminalFontSize:e})})}),(0,q.jsx)(Y,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,q.jsx)(J,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>D({editorFontSize:e})})}),(0,q.jsx)(Y,{label:`Ripple (experimental)`,description:`Open agent sessions with a spacious reading view above the native CLI. Right-click a session to override this default.`,htmlFor:`ripple-enabled`,children:(0,q.jsx)(R,{id:`ripple-enabled`,checked:e.rippleEnabled===!0,onCheckedChange:e=>D({rippleEnabled:e})})}),(0,q.jsx)(Y,{label:`Density`,children:(0,q.jsxs)(U,{value:e.density,onValueChange:e=>D({density:e}),children:[(0,q.jsx)(B,{className:`w-36`,children:(0,q.jsx)(z,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(H,{value:`compact`,children:`Compact`}),(0,q.jsx)(H,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,q.jsx)(Y,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,q.jsx)(R,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>D({projectBasedLayout:e})})}),(0,q.jsx)(Y,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,q.jsx)(R,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>D({showAllProjectSessions:e})})}),(0,q.jsx)(Y,{label:`Reduced animation and motion`,htmlFor:`reduce-motion`,children:(0,q.jsx)(R,{id:`reduce-motion`,checked:e.reduceMotion,onCheckedChange:e=>D({reduceMotion:e})})}),(0,q.jsx)(Y,{label:`Show host when returning to the window`,description:`Briefly show the host icon and name when this window or browser tab regains focus.`,htmlFor:`show-host-on-focus`,children:(0,q.jsx)(R,{id:`show-host-on-focus`,checked:e.showHostOnFocus,onCheckedChange:e=>D({showHostOnFocus:e})})})]})}function Ht({profile:e}){let t=y(),[n,r]=(0,K.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>G(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>G(e)});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Icon`,children:(0,q.jsxs)(kt,{open:n,onOpenChange:r,children:[(0,q.jsx)(Ot,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-md text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(Fe,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,q.jsx)(Dt,{align:`end`,className:`w-72`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>i(null),className:O(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!e.icon&&`bg-elevated text-fg`),children:(0,q.jsx)(Fe,{icon:null,colour:null,className:`size-4`})}),xe.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:O(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,q.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,q.jsx)(Y,{label:`Icon colour`,children:(0,q.jsx)(_e,{onCustomChange:a,value:e.icon_colour,onChange:a,label:`Icon colour`})})]})}var Ut=`__none__`;function Wt(){let e=W(),t=ne().data?.find(t=>t.id===e),n=b(e??void 0),r=S(e??void 0),i=y(),a=_(e??``),o=u(),[s,c]=(0,K.useState)(``),[l,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(``);if((0,K.useEffect)(()=>{t&&(c(t.name),d(t.branch_prefix))},[t]),!t)return null;let g=r.data?.default_account_id;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Profile`}),(0,q.jsxs)(Y,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,q.jsx)(I,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44`}),(0,q.jsx)(L,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>G(e)}),children:`Save`})]}),(0,q.jsxs)(Y,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,q.jsx)(I,{id:`branch-prefix`,value:l,onChange:e=>d(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(L,{size:`sm`,variant:`secondary`,disabled:l===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:l},{onError:e=>G(e)}),children:`Save`})]}),(0,q.jsx)(Ht,{profile:t}),(0,q.jsx)(Y,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,q.jsxs)(U,{value:typeof g==`number`?String(g):Ut,onValueChange:e=>a.mutate({default_account_id:e===Ut?null:Number(e)},{onError:e=>G(e)}),children:[(0,q.jsx)(B,{className:`w-56`,children:(0,q.jsx)(z,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(H,{value:Ut,children:`First available`}),n.data?.map(e=>(0,q.jsx)(H,{value:String(e.id),children:(0,q.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,q.jsx)(Y,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,q.jsx)(L,{variant:`danger`,size:`sm`,onClick:()=>p(!0),children:`Delete…`})}),(0,q.jsx)(P,{open:f,onOpenChange:e=>{e||(p(!1),h(``))},children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(it,{children:[(0,q.jsxs)(N,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(j,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(be,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(I,{id:`delete-confirm-name`,value:m,onChange:e=>h(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(L,{variant:`ghost`,onClick:()=>{p(!1),h(``)},children:`Cancel`}),(0,q.jsx)(L,{variant:`danger`,disabled:m!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{mt(),bt.set(null)},onError:e=>{p(!1),h(``),G(e)}}),children:`Delete profile`})]})]})})]})}function Gt({agent:e,profileId:t,onClose:n,onCreated:r}){let i=s(),[a,o]=(0,K.useState)(``),[c,u]=(0,K.useState)(``),d=l(Et(c,150)),f=c.trim(),p=f===``||f.startsWith(`/`)||f.startsWith(`~`),m=a.trim()!==``&&p,h=()=>{!m||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...f===``?{}:{import_dir:f}},{onSuccess:e=>{n(),r(e,f!==``)},onError:e=>G(e)})};return(0,q.jsx)(P,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(it,{children:[(0,q.jsxs)(N,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(j,{children:[`Accounts are isolated config dirs under this profile. Naming one is enough — Puddle creates it and takes you straight to `,e.display_name,`’s login. To reuse an account you already have on this machine, give its config directory: it is copied in and the original is never touched.`]})]}),(0,q.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,q.jsx)(I,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(ye,{value:c,onValueChange:u,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(d.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(L,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(L,{disabled:!m||i.isPending,onClick:h,children:[(0,q.jsx)(st,{}),`Add account`]})]})]})})}function Kt({account:e,gateOpen:t,installed:n}){let i=r(),a=E(),o=p(),[s,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(e.label),m=(0,K.useRef)(null);return(0,K.useEffect)(()=>f(e.label),[e.label]),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`input`,{ref:m,value:d,onChange:e=>f(e.target.value),onBlur:()=>{let t=d.trim();if(t!==e.label){if(t===``){f(e.label);return}a.mutate({id:e.id,label:t},{onError:t=>{G(t),f(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(f(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full min-w-0 truncate rounded-sm bg-transparent px-1 py-0.5 text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,q.jsxs)(`button`,{type:`button`,title:`Rename account`,onClick:()=>{m.current?.focus(),m.current?.select()},className:`shrink-0 rounded-sm p-0.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(ge,{className:`size-3`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,q.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,q.jsx)(R,{checked:e.skip_permissions_default,onCheckedChange:t=>a.mutate({id:e.id,skip_permissions_default:t},{onError:e=>G(e)})})]}),(0,q.jsxs)(L,{size:`sm`,variant:`secondary`,disabled:i.isPending||!n,onClick:()=>i.mutate(e.id,{onSuccess:e=>c({stream:e.stream,hint:e.hint}),onError:e=>G(e)}),children:[(0,q.jsx)(Ee,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(L,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>u(!0),children:[(0,q.jsx)(ot,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),s&&(0,q.jsx)(Se,{stream:s.stream,hint:s.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>c(null)}),(0,q.jsx)(P,{open:l,onOpenChange:u,children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(it,{children:[(0,q.jsxs)(N,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(j,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(L,{variant:`ghost`,onClick:()=>u(!1),children:`Cancel`}),(0,q.jsx)(L,{variant:`danger`,disabled:o.isPending,onClick:()=>o.mutate(e.id,{onSuccess:()=>u(!1),onError:e=>{u(!1),G(e)}}),children:`Delete account`})]})]})})]})}function qt(){let e=W(),t=i(),n=b(e??void 0),a=S(e??void 0),o=r(),[s,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(null),d=a.data?.allowSkipPermissions===!0;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(Y,{label:e.display_name,description:r?`Accounts are initialised in config dirs owned by this profile.`:`No ${e.binary??e.id} on the daemon’s PATH. Install it or add its directory to the agent search path in Sessions.`,className:`py-1`,children:(0,q.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,q.jsx)(Kt,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,q.jsx)(`div`,{className:`flex`,children:(0,q.jsxs)(L,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>u(e),children:[(0,q.jsx)(st,{}),`Add account`]})})]})]},e.id)}),s&&(0,q.jsx)(Se,{stream:s.stream,label:s.label,hint:s.hint,onClose:()=>c(null)}),l!==null&&e!==null&&(0,q.jsx)(Gt,{agent:l,profileId:e,onClose:()=>u(null),onCreated:(e,t)=>{if(t){e.logged_in||F.info(`Imported without credentials — press Login to authenticate.`);return}o.mutate(e.id,{onSuccess:t=>c({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>G(e)})}})]})}function Jt(){let e=d(),t=w(),[n,r]=(0,K.useState)(``);return(0,K.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,q.jsx)(Y,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH; helps find agent CLIs like claude (e.g. ~/.local/bin).`,htmlFor:`agent-path`,children:(0,q.jsx)(I,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function Yt({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=Pt(e,n),o=n.sessionDefaults??{},[s,c]=(0,K.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,q.jsx)(Y,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,q.jsx)(I,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,q.jsx)(Y,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,q.jsx)(R,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,q.jsx)(Y,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`Start on working copy of the selected branch instead of sharing one directory.`,htmlFor:`${e}-default-dir`,children:(0,q.jsx)(R,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function Xt(){return(0,q.jsx)(Y,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,q.jsx)(J,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:Je().terminalScrollback,onCommit:e=>D({terminalScrollback:e})})})}function Zt({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,K.useState)(r);return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,q.jsx)(at,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(L,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(L,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var Qt={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function $t({initial:e,onSave:t,pending:n}){let[r,i]=(0,K.useState)(e),a=r.length>0?r:ce;return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,q.jsx)(I,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:ce}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:ft(Qt,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:ae.map(([e,t])=>(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,q.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(L,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(L,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(ce),t(ce)},children:`Reset to default`})]})]})}function en(){let e=W(),t=ne().data?.find(t=>t.id===e),n=S(e??void 0),r=_(e??``),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(``),c=n.data?.allowSkipPermissions===!0,l=e=>r.mutate({allowSkipPermissions:e},{onSuccess:()=>{a(!1),s(``)},onError:e=>G(e)}),u=e=>t=>r.mutate({[e]:t},{onError:e=>G(e)});return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sessions`}),(0,q.jsx)(Y,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,q.jsx)(R,{id:`gate`,checked:c,onCheckedChange:e=>{e?a(!0):l(!1)}})}),(0,q.jsx)(Y,{label:`Capture exported env variables`,description:n.data?.captureSessionEnv===!1?`No variables are captured or injected; already-captured variabless are kept for when this is re-enabled.`:`Variables exported in a session persist and are re-injected upon terminal and agent restarts.`,htmlFor:`capture-env`,children:(0,q.jsx)(R,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:r.isPending,onCheckedChange:e=>r.mutate({captureSessionEnv:e},{onError:e=>G(e)})})}),(0,q.jsx)(Jt,{}),(0,q.jsx)(Xt,{}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`New session defaults`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Yt,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>G(e)}),pending:r.isPending},`${e}:agent-seed`),(0,q.jsx)(Yt,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>G(e)}),pending:r.isPending},`${e}:terminal-seed`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Zt,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??le,defaultText:le,onSave:u(`onboardingTemplate`),pending:r.isPending},`${e}:onboarding`),(0,q.jsx)(Zt,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??ie,defaultText:ie,onSave:u(`concurrentTemplate`),pending:r.isPending},`${e}:concurrent`),(0,q.jsx)(Zt,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??oe,defaultText:oe,onSave:u(`restartTemplate`),pending:r.isPending},`${e}:restart`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`Tab title`}),n.data&&(0,q.jsx)($t,{initial:n.data.tabTitleTemplate||"${name}",onSave:u(`tabTitleTemplate`),pending:r.isPending},`${e}:tab-title`)]}),(0,q.jsx)(P,{open:i,onOpenChange:e=>{e||(a(!1),s(``))},children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(it,{children:[(0,q.jsxs)(N,{className:`flex items-center gap-2`,children:[(0,q.jsx)(Lt,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(j,{asChild:!0,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,q.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,q.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,q.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,q.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,q.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,q.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,q.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,q.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(be,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(I,{id:`confirm-name`,value:o,onChange:e=>s(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(L,{variant:`ghost`,onClick:()=>{a(!1),s(``)},children:`Cancel`}),(0,q.jsx)(L,{variant:`danger`,disabled:o!==t?.name||r.isPending,onClick:()=>l(!0),children:`Open the gate`})]})]})})]})}var tn=se.parse({});function nn(){let[e,t]=(0,K.useState)(Pe);return(0,K.useEffect)(()=>{let e=()=>t(Pe());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(Pe())]}function rn({permission:e,onRequest:t}){return e===`granted`||e===`unverified`?null:(0,q.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,q.jsxs)(q.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:t,className:`underline underline-offset-2 transition-colors hover:text-fg`,children:`request it now`}),`.`]}),e===`denied`&&`Blocked by the browser — allow notifications for this site in its site settings, then return here.`,e===`unsupported`&&`This browser cannot show desktop notifications.`]})}function an(){let e=W(),t=S(e??void 0),n=_(e??``),r=v(e??void 0),[i,a]=nn(),o=Be(),[s,c]=(0,K.useState)(!1);(0,K.useEffect)(()=>{Re();let e=()=>void Re();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]);let l=se.catch(tn).parse(t.data?.notifications??{}),u=e=>n.mutate({notifications:e},{onError:e=>G(e)}),d=()=>{nt()?.showNotification||typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Notifications`}),(0,q.jsx)(Y,{label:`Agent notifications`,htmlFor:`notify-desktop`,children:(0,q.jsx)(R,{id:`notify-desktop`,checked:l.desktop,onCheckedChange:e=>{e&&d(),u({...l,desktop:e})}})}),l.desktop&&(0,q.jsx)(rn,{permission:i,onRequest:d}),(0,q.jsx)(Y,{label:`Notify while interacting with a session`,htmlFor:`notify-focused`,description:`When off, typing or clicking in a session silences its desktop alerts for five seconds. Mobile Web Push is configured separately on each device.`,children:(0,q.jsx)(R,{id:`notify-focused`,checked:l.when_focused,onCheckedChange:e=>u({...l,when_focused:e})})}),(0,q.jsx)(Y,{label:`Test delivery`,description:`Send a notification to check this device’s permissions.`,children:(0,q.jsx)(L,{variant:`ghost`,disabled:s,onClick:()=>{c(!0),(async()=>{!nt()?.showNotification&&typeof Notification<`u`&&Notification.permission==="default"&&(await Notification.requestPermission(),a()),await He({id:`puddle-test`,title:`Puddle`,body:`Notifications are working on this device.`},()=>{})})().catch(G).finally(()=>c(!1))},children:s?`Sending…`:`Send test`})}),(0,q.jsx)(`p`,{role:`status`,className:`pb-2 text-xs text-fg-muted`,children:o.state===`shown`?`The system accepted the notification. Banner visibility also depends on Focus / Do Not Disturb.`:o.message??`Delivery has not been tested on this device.`}),(0,q.jsx)(Y,{label:`Sound`,htmlFor:`notify-sound`,children:(0,q.jsx)(R,{id:`notify-sound`,checked:l.sound,onCheckedChange:e=>u({...l,sound:e})})}),(0,q.jsx)(Y,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,q.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[l.muted_projects.length,` muted`]})}),(0,q.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,q.jsx)(R,{checked:l.muted_projects.includes(e.id),onCheckedChange:t=>u({...l,muted_projects:t?[...l.muted_projects,e.id]:l.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function on(){let e=W(),t=C(c().data?.protocol),n=At(t&&e!==null),[r,i]=(0,K.useState)(null),a=n.data?.providers??[],o=a.find(e=>e.id===r)??a[0];return!t||!e?null:(0,q.jsxs)(`div`,{className:`mt-8`,children:[(0,q.jsx)(X,{note:`Defaults for this profile on the connected host. Individual files can override them from their tab menu.`,children:`Compilation & running code`}),n.isLoading?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading languages…`}):n.isError?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:`Couldn’t load languages.`}):o?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Language`,htmlFor:`compilation-language`,children:(0,q.jsxs)(U,{value:o.id,onValueChange:i,children:[(0,q.jsx)(B,{id:`compilation-language`,className:`w-48`,children:(0,q.jsx)(z,{})}),(0,q.jsx)(V,{children:a.map(e=>(0,q.jsx)(H,{value:e.id,detail:e.available?void 0:`Not installed`,children:e.display_name},e.id))})]})}),!o.available&&(0,q.jsxs)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:[`No supported `,o.display_name,` tool is installed on this host. Saved commands apply when a supported tool is available.`]}),(0,q.jsx)(sn,{request:{profile_id:e,provider:o.id}},`${e}:${o.id}`)]}):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No languages advertised by this host.`})]})}function sn({request:e}){let t=jt(e),n=x();return t.isLoading?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading commands…`}):t.isError?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.error instanceof Error?t.error.message:`Couldn’t load commands`}):t.data?(0,q.jsx)(Nt,{settings:t.data,onSave:async t=>{for(let r of t){let t=await Mt({...e,...r});n.setQueryData([`compilation-defaults`,e],t),await n.invalidateQueries({queryKey:[`compilation-settings`]})}}}):null}function cn(){let e=Je();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Editor`}),(0,q.jsx)(Y,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,q.jsx)(J,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>D({editorTabSize:e})})}),(0,q.jsx)(Y,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,q.jsx)(R,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>D({editorWordWrap:e})})}),(0,q.jsx)(Y,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,q.jsx)(I,{id:`editor-link-host`,type:`text`,placeholder:$e.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>D({editorLinkSshHost:e.target.value})})}),(0,q.jsx)(on,{})]})}function ln({value:e,isDefault:t,onRecord:n,onReset:r}){let[i,a]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,"data-hotkey-recording":i||void 0,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=yt(e.nativeEvent);t&&(n(t),a(!1))},className:O(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,i?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:i?`Press keys…`:St(e)}),!t&&(0,q.jsxs)(`button`,{type:`button`,title:`Reset to default`,onClick:r,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(_t,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function un(){let e=W(),t=S(e??void 0),n=_(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of xt){let t=i(e.id,Ct(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>G(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>G(e)})};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Hotkeys`}),(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,q.jsx)(Y,{label:`App shortcuts in terminals`,description:t.data?.terminalAppShortcuts===!1?`A focused terminal receives these keys instead.`:`The shortcuts below work while a terminal is focused.`,htmlFor:`terminal-app-shortcuts`,className:`mb-4`,children:(0,q.jsx)(R,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>G(e)})})}),wt.map(e=>{let t=xt.filter(t=>t.group===e);return t.length===0?null:(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=i(e.id,Ct(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,q.jsx)(Y,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,q.jsx)(ln,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var dn=e=>[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);function fn(e,t){let[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(!0),[o,s]=(0,K.useState)(``),c=(0,K.useRef)(0),l=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>{c.current+=1},[]),(0,K.useEffect)(()=>{if(n)return;let e=!0;return l.current=null,a(!0),(async()=>{try{let t=dn(crypto.getRandomValues(new Uint8Array(32))),n=dn(new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t))));e&&(l.current={code:t,challenge:n})}catch(t){e&&s(t instanceof Error?t.message:`Could not prepare sign-in.`)}finally{e&&a(!1)}})(),()=>{e=!1,l.current=null}},[n]);let u=(0,K.useRef)(t);return(0,K.useEffect)(()=>{u.current=t},[t]),(0,K.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{c.current+=1,r(null),s(`Sign-in expired. Try again.`)},Math.max(0,n.request.expires-Date.now()));return()=>clearTimeout(e)},[n]),(0,K.useEffect)(()=>{if(!n||e)return;let t=c.current,i=!1,a,o=async()=>{try{if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);let{ready:e}=ue.parse(await et(`POST`,`/cockpit/remote/registration`,{service:n.request.service,code:n.code}));if(i||t!==c.current)return;if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);e?(r(null),await u.current({t:`enable`,registration:{service:n.request.service,app:n.request.app,code:n.code}})):a=setTimeout(()=>void o(),2e3)}catch(e){if(i||t!==c.current)return;r(null),s(e instanceof Error?e.message:`Sign-in failed. Try again.`)}};return a=setTimeout(()=>void o(),2e3),()=>{i=!0,clearTimeout(a)}},[n,e]),{attempt:n,preparing:i,error:o,begin:(t,n,i)=>{if(!(e||!l.current)){s(``);try{let{code:e,challenge:a}=l.current,o=de.safeParse({service:t.trim(),app:n.trim(),label:i.trim(),challenge:a,expires:Date.now()+me.invitationMs});if(!o.success)throw Error(`Enter a host name and exact HTTPS application and relay origins.`);let s=o.data,u=`${s.app}/#register=${encodeURIComponent(JSON.stringify(s))}`;c.current+=1,l.current=null,r({request:s,code:e,url:u}),window.open(u,`_blank`,`noopener,noreferrer`)}catch(e){s(e instanceof Error?e.message:`Could not start sign-in.`)}}},cancel:()=>{c.current+=1,l.current=null,a(!0),r(null)}}}function pn({service:e=`https://charles.waddlelabs.ai`,app:t=`https://puddle.waddlelabs.ai`,hostName:n,busy:r,disabled:i,enable:a,cancel:o}){let[s,c]=(0,K.useState)(e),[l,u]=(0,K.useState)(t),[d,f]=(0,K.useState)(n),p=fn(i,a),m=i||p.preparing||!!p.attempt;return(0,q.jsxs)(`form`,{className:`mt-4 space-y-4`,onSubmit:e=>{e.preventDefault(),m||p.begin(s,l,d)},children:[(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Application origin`,(0,q.jsx)(I,{type:`url`,required:!0,value:l,onChange:e=>u(e.target.value),placeholder:`https://app.example.com`,autoComplete:`off`,disabled:m})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Relay origin`,(0,q.jsx)(I,{type:`url`,required:!0,value:s,onChange:e=>c(e.target.value),placeholder:`https://relay.example.com`,autoComplete:`off`,disabled:m})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Host name`,(0,q.jsx)(I,{required:!0,maxLength:80,value:d,onChange:e=>f(e.target.value),disabled:m})]}),o&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Saving a new registration revokes existing browser approvals and invitations.`}),p.error&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:p.error}),p.attempt?(0,q.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,q.jsxs)(`p`,{role:`status`,children:[`Confirm this host in your browser. Match request`,` `,(0,q.jsx)(`strong`,{className:`font-mono`,children:p.attempt.request.challenge.slice(0,8).toUpperCase()}),`. Sign-in expires in five minutes.`]}),(0,q.jsx)(`a`,{href:p.attempt.url,target:`_blank`,rel:`noreferrer`,className:`text-accent hover:opacity-80`,children:`Continue in browser ↗`}),(0,q.jsx)(L,{type:`button`,variant:`ghost`,onClick:p.cancel,children:`Cancel sign-in`})]}):(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(L,{type:`submit`,disabled:m||!d.trim()||!s||!l,children:r?`Enabling…`:p.preparing?`Preparing sign-in…`:`Sign in and enable`}),o&&(0,q.jsx)(L,{type:`button`,variant:`ghost`,disabled:m,onClick:o,children:`Cancel`})]})]})}var mn=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),Z=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),hn=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),gn=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),_n=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),vn=t((e=>{var t=Z().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),yn=t((e=>{var t=Z().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),bn=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),xn=t((e=>{var t=hn(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Sn=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Cn=t((e=>{var t=Sn();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),wn=t(((e,t)=>{var n=Cn();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Tn=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),En=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
1
+ import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./react-CZI7_Jkm.js";import{$ as r,A as i,B as a,Et as o,F as s,H as c,J as l,K as u,P as d,T as f,U as p,Y as m,Z as h,_t as g,at as _,ft as v,it as y,k as b,kt as x,lt as S,n as C,nt as w,o as T,st as ee,tt as E,u as te,ut as ne,vt as re}from"./protocol-support-BwRR1kRO.js";import{B as ie,G as ae,H as oe,Q as se,U as ce,V as le,_ as ue,g as de,h as fe,q as pe,v as me,y as he}from"./auth-C3ruG3fE.js";import{c as ge,i as _e,l as ve,r as ye,u as be}from"./LazyTerminal-CIclyIWs.js";import{A as xe,C as Se,E as Ce,M as we,O as Te,P as Ee,S as De,_ as Oe,a as ke,b as Ae,c as je,d as Me,f as Ne,i as Pe,k as Fe,l as Ie,m as Le,n as Re,o as ze,r as Be,s as Ve,t as He,u as Ue,v as We,x as Ge,y as Ke}from"./notification-delivery-CGw2AFKW.js";import{a as qe,i as Je,r as D,t as Ye}from"./client-settings-BdKglwtW.js";import{c as Xe,t as Ze}from"./theme-swfNLod9.js";import{t as Qe}from"./jsx-runtime-By8HlURe.js";import{r as $e}from"./index-B5q_SMZR.js";import{n as et,t as tt}from"./api-CULxlzTe.js";import{t as nt}from"./desktop-Bl69_YmL.js";import{n as O,t as k}from"./createLucideIcon-C9A1vLE-.js";import{a as A,i as j,n as rt,o as it,r as M,s as N,t as P}from"./dialog-DtvE8ATK.js";import{n as F}from"./dist-BOS6OKSE.js";import{a as at,i as I}from"./dist-Dac0re_p.js";import{n as ot,r as st}from"./dist-BeQvHdsz.js";import{t as L}from"./button-DtByPSFL.js";import{a as ct,c as lt,i as ut,l as dt,n as ft,o as pt,r as mt,t as R,u as ht}from"./switch-DYr-iPWY.js";import{a as z,i as B,n as V,r as H,t as U}from"./select-CGxTz4dh.js";import{t as gt}from"./code-Cf4ftdOa.js";import{t as _t}from"./rotate-ccw-BI2k_h3A.js";import{t as vt}from"./x-DV6-RYI2.js";import{_ as yt,m as bt,n as xt,o as St,r as Ct,s as wt,y as W}from"./ws-DV_MCpbg.js";import{t as Tt}from"./control-tray-c9uXOo-i.js";import{n as G}from"./errors-efDAjyqa.js";import{t as Et}from"./use-debounced-value-C86N-mOK.js";import{n as Dt,r as Ot,t as kt}from"./popover-D5HmbdQ7.js";import{a as At,o as jt,r as Mt,t as Nt,u as Pt}from"./CompilationCommandForm-DQjUhaHj.js";var Ft=k(`bell`,[[`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`}]]),It=k(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Lt=k(`shield-alert`,[[`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:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Rt=k(`shield-check`,[[`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`}]]),zt=k(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),Bt=k(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),K=e(n(),1),q=Qe();function J({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,K.useState)(String(t));return(0,K.useEffect)(()=>c(String(t)),[t]),(0,q.jsx)(I,{id:e,type:`number`,min:n,max:r,step:i,className:a,value:s,onChange:e=>c(e.target.value),onBlur:()=>{let e=Number(s);if(s.trim()===``||!Number.isFinite(e)){c(String(t));return}let i=Math.min(r??e,Math.max(n??e,e));c(String(i)),i!==t&&o(i)},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}function Y({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,q.jsxs)(`div`,{className:O(`flex items-center gap-4 py-2.5`,a),children:[(0,q.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:O(`text-xs text-fg-muted`,n),children:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function X({children:e,note:t}){return(0,q.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function Vt(){let e=Je(),[t,n]=(0,K.useState)(Xe());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Appearance`}),(0,q.jsx)(Y,{label:`Theme`,children:(0,q.jsxs)(U,{value:t,onValueChange:e=>{n(e),Ze(e)},children:[(0,q.jsx)(B,{className:`w-32`,children:(0,q.jsx)(z,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(H,{value:`dark`,children:`Dark`}),(0,q.jsx)(H,{value:`light`,children:`Light`}),(0,q.jsx)(H,{value:`system`,children:`System`})]})]})}),(0,q.jsx)(Y,{label:`Cursor style`,children:(0,q.jsxs)(U,{value:e.cursorPackage,onValueChange:e=>D({cursorPackage:e}),children:[(0,q.jsx)(B,{className:`w-36`,children:(0,q.jsx)(z,{})}),(0,q.jsx)(V,{children:qe.map(e=>(0,q.jsx)(H,{value:e.id,children:e.label},e.id))})]})}),(0,q.jsx)(Y,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,q.jsx)(J,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>D({uiFontSize:e})})}),(0,q.jsx)(Y,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,q.jsx)(J,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>D({terminalFontSize:e})})}),(0,q.jsx)(Y,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,q.jsx)(J,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>D({editorFontSize:e})})}),(0,q.jsx)(Y,{label:`Ripple (experimental)`,description:`Open agent sessions with a reading view and native CLI controls. Right-click a session to override this default.`,htmlFor:`ripple-enabled`,children:(0,q.jsx)(R,{id:`ripple-enabled`,checked:e.rippleEnabled===!0,onCheckedChange:e=>D({rippleEnabled:e})})}),(0,q.jsx)(Y,{label:`Density`,children:(0,q.jsxs)(U,{value:e.density,onValueChange:e=>D({density:e}),children:[(0,q.jsx)(B,{className:`w-36`,children:(0,q.jsx)(z,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(H,{value:`compact`,children:`Compact`}),(0,q.jsx)(H,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,q.jsx)(Y,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,q.jsx)(R,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>D({projectBasedLayout:e})})}),(0,q.jsx)(Y,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,q.jsx)(R,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>D({showAllProjectSessions:e})})}),(0,q.jsx)(Y,{label:`Reduced animation and motion`,htmlFor:`reduce-motion`,children:(0,q.jsx)(R,{id:`reduce-motion`,checked:e.reduceMotion,onCheckedChange:e=>D({reduceMotion:e})})}),(0,q.jsx)(Y,{label:`Show host when returning to the window`,description:`Briefly show the host icon and name when this window or browser tab regains focus.`,htmlFor:`show-host-on-focus`,children:(0,q.jsx)(R,{id:`show-host-on-focus`,checked:e.showHostOnFocus,onCheckedChange:e=>D({showHostOnFocus:e})})})]})}function Ht({profile:e}){let t=y(),[n,r]=(0,K.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>G(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>G(e)});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Icon`,children:(0,q.jsxs)(kt,{open:n,onOpenChange:r,children:[(0,q.jsx)(Ot,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-md text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(Fe,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,q.jsx)(Dt,{align:`end`,className:`w-72`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>i(null),className:O(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!e.icon&&`bg-elevated text-fg`),children:(0,q.jsx)(Fe,{icon:null,colour:null,className:`size-4`})}),xe.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:O(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,q.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,q.jsx)(Y,{label:`Icon colour`,children:(0,q.jsx)(_e,{onCustomChange:a,value:e.icon_colour,onChange:a,label:`Icon colour`})})]})}var Ut=`__none__`;function Wt(){let e=W(),t=ne().data?.find(t=>t.id===e),n=b(e??void 0),r=S(e??void 0),i=y(),a=_(e??``),o=u(),[s,c]=(0,K.useState)(``),[l,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(``);if((0,K.useEffect)(()=>{t&&(c(t.name),d(t.branch_prefix))},[t]),!t)return null;let g=r.data?.default_account_id;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Profile`}),(0,q.jsxs)(Y,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,q.jsx)(I,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44`}),(0,q.jsx)(L,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>G(e)}),children:`Save`})]}),(0,q.jsxs)(Y,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,q.jsx)(I,{id:`branch-prefix`,value:l,onChange:e=>d(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(L,{size:`sm`,variant:`secondary`,disabled:l===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:l},{onError:e=>G(e)}),children:`Save`})]}),(0,q.jsx)(Ht,{profile:t}),(0,q.jsx)(Y,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,q.jsxs)(U,{value:typeof g==`number`?String(g):Ut,onValueChange:e=>a.mutate({default_account_id:e===Ut?null:Number(e)},{onError:e=>G(e)}),children:[(0,q.jsx)(B,{className:`w-56`,children:(0,q.jsx)(z,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(H,{value:Ut,children:`First available`}),n.data?.map(e=>(0,q.jsx)(H,{value:String(e.id),children:(0,q.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,q.jsx)(Y,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,q.jsx)(L,{variant:`danger`,size:`sm`,onClick:()=>p(!0),children:`Delete…`})}),(0,q.jsx)(P,{open:f,onOpenChange:e=>{e||(p(!1),h(``))},children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(it,{children:[(0,q.jsxs)(N,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(j,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(be,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(I,{id:`delete-confirm-name`,value:m,onChange:e=>h(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(L,{variant:`ghost`,onClick:()=>{p(!1),h(``)},children:`Cancel`}),(0,q.jsx)(L,{variant:`danger`,disabled:m!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{mt(),yt.set(null)},onError:e=>{p(!1),h(``),G(e)}}),children:`Delete profile`})]})]})})]})}function Gt({agent:e,profileId:t,onClose:n,onCreated:r}){let i=s(),[a,o]=(0,K.useState)(``),[c,u]=(0,K.useState)(``),d=l(Et(c,150)),f=c.trim(),p=f===``||f.startsWith(`/`)||f.startsWith(`~`),m=a.trim()!==``&&p,h=()=>{!m||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...f===``?{}:{import_dir:f}},{onSuccess:e=>{n(),r(e,f!==``)},onError:e=>G(e)})};return(0,q.jsx)(P,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(it,{children:[(0,q.jsxs)(N,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(j,{children:[`Accounts are isolated config dirs under this profile. Naming one is enough — Puddle creates it and takes you straight to `,e.display_name,`’s login. To reuse an account you already have on this machine, give its config directory: it is copied in and the original is never touched.`]})]}),(0,q.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,q.jsx)(I,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(ye,{value:c,onValueChange:u,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(d.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(L,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(L,{disabled:!m||i.isPending,onClick:h,children:[(0,q.jsx)(st,{}),`Add account`]})]})]})})}function Kt({account:e,gateOpen:t,installed:n}){let i=r(),a=E(),o=p(),[s,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(e.label),m=(0,K.useRef)(null);return(0,K.useEffect)(()=>f(e.label),[e.label]),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`input`,{ref:m,value:d,onChange:e=>f(e.target.value),onBlur:()=>{let t=d.trim();if(t!==e.label){if(t===``){f(e.label);return}a.mutate({id:e.id,label:t},{onError:t=>{G(t),f(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(f(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full min-w-0 truncate rounded-sm bg-transparent px-1 py-0.5 text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,q.jsxs)(`button`,{type:`button`,title:`Rename account`,onClick:()=>{m.current?.focus(),m.current?.select()},className:`shrink-0 rounded-sm p-0.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(ge,{className:`size-3`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,q.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,q.jsx)(R,{checked:e.skip_permissions_default,onCheckedChange:t=>a.mutate({id:e.id,skip_permissions_default:t},{onError:e=>G(e)})})]}),(0,q.jsxs)(L,{size:`sm`,variant:`secondary`,disabled:i.isPending||!n,onClick:()=>i.mutate(e.id,{onSuccess:e=>c({stream:e.stream,hint:e.hint}),onError:e=>G(e)}),children:[(0,q.jsx)(Ee,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(L,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>u(!0),children:[(0,q.jsx)(ot,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),s&&(0,q.jsx)(Se,{stream:s.stream,hint:s.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>c(null)}),(0,q.jsx)(P,{open:l,onOpenChange:u,children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(it,{children:[(0,q.jsxs)(N,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(j,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(L,{variant:`ghost`,onClick:()=>u(!1),children:`Cancel`}),(0,q.jsx)(L,{variant:`danger`,disabled:o.isPending,onClick:()=>o.mutate(e.id,{onSuccess:()=>u(!1),onError:e=>{u(!1),G(e)}}),children:`Delete account`})]})]})})]})}function qt(){let e=W(),t=i(),n=b(e??void 0),a=S(e??void 0),o=r(),[s,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(null),d=a.data?.allowSkipPermissions===!0;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(Y,{label:e.display_name,description:r?`Accounts are initialised in config dirs owned by this profile.`:`No ${e.binary??e.id} on the daemon’s PATH. Install it or add its directory to the agent search path in Sessions.`,className:`py-1`,children:(0,q.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,q.jsx)(Kt,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,q.jsx)(`div`,{className:`flex`,children:(0,q.jsxs)(L,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>u(e),children:[(0,q.jsx)(st,{}),`Add account`]})})]})]},e.id)}),s&&(0,q.jsx)(Se,{stream:s.stream,label:s.label,hint:s.hint,onClose:()=>c(null)}),l!==null&&e!==null&&(0,q.jsx)(Gt,{agent:l,profileId:e,onClose:()=>u(null),onCreated:(e,t)=>{if(t){e.logged_in||F.info(`Imported without credentials — press Login to authenticate.`);return}o.mutate(e.id,{onSuccess:t=>c({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>G(e)})}})]})}function Jt(){let e=d(),t=w(),[n,r]=(0,K.useState)(``);return(0,K.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,q.jsx)(Y,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH; helps find agent CLIs like claude (e.g. ~/.local/bin).`,htmlFor:`agent-path`,children:(0,q.jsx)(I,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function Yt({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=Pt(e,n),o=n.sessionDefaults??{},[s,c]=(0,K.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,q.jsx)(Y,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,q.jsx)(I,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,q.jsx)(Y,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,q.jsx)(R,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,q.jsx)(Y,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`Start on working copy of the selected branch instead of sharing one directory.`,htmlFor:`${e}-default-dir`,children:(0,q.jsx)(R,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function Xt(){return(0,q.jsx)(Y,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,q.jsx)(J,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:Je().terminalScrollback,onCommit:e=>D({terminalScrollback:e})})})}function Zt({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,K.useState)(r);return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,q.jsx)(at,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(L,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(L,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var Qt={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function $t({initial:e,onSave:t,pending:n}){let[r,i]=(0,K.useState)(e),a=r.length>0?r:ce;return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,q.jsx)(I,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:ce}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:ft(Qt,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:ae.map(([e,t])=>(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,q.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(L,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(L,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(ce),t(ce)},children:`Reset to default`})]})]})}function en(){let e=W(),t=ne().data?.find(t=>t.id===e),n=S(e??void 0),r=_(e??``),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(``),c=n.data?.allowSkipPermissions===!0,l=e=>r.mutate({allowSkipPermissions:e},{onSuccess:()=>{a(!1),s(``)},onError:e=>G(e)}),u=e=>t=>r.mutate({[e]:t},{onError:e=>G(e)});return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sessions`}),(0,q.jsx)(Y,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,q.jsx)(R,{id:`gate`,checked:c,onCheckedChange:e=>{e?a(!0):l(!1)}})}),(0,q.jsx)(Y,{label:`Capture exported env variables`,description:n.data?.captureSessionEnv===!1?`No variables are captured or injected; already-captured variabless are kept for when this is re-enabled.`:`Variables exported in a session persist and are re-injected upon terminal and agent restarts.`,htmlFor:`capture-env`,children:(0,q.jsx)(R,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:r.isPending,onCheckedChange:e=>r.mutate({captureSessionEnv:e},{onError:e=>G(e)})})}),(0,q.jsx)(Jt,{}),(0,q.jsx)(Xt,{}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`New session defaults`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Yt,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>G(e)}),pending:r.isPending},`${e}:agent-seed`),(0,q.jsx)(Yt,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>G(e)}),pending:r.isPending},`${e}:terminal-seed`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Zt,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??le,defaultText:le,onSave:u(`onboardingTemplate`),pending:r.isPending},`${e}:onboarding`),(0,q.jsx)(Zt,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??ie,defaultText:ie,onSave:u(`concurrentTemplate`),pending:r.isPending},`${e}:concurrent`),(0,q.jsx)(Zt,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??oe,defaultText:oe,onSave:u(`restartTemplate`),pending:r.isPending},`${e}:restart`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`Tab title`}),n.data&&(0,q.jsx)($t,{initial:n.data.tabTitleTemplate||"${name}",onSave:u(`tabTitleTemplate`),pending:r.isPending},`${e}:tab-title`)]}),(0,q.jsx)(P,{open:i,onOpenChange:e=>{e||(a(!1),s(``))},children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(it,{children:[(0,q.jsxs)(N,{className:`flex items-center gap-2`,children:[(0,q.jsx)(Lt,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(j,{asChild:!0,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,q.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,q.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,q.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,q.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,q.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,q.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,q.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,q.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(be,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(I,{id:`confirm-name`,value:o,onChange:e=>s(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(L,{variant:`ghost`,onClick:()=>{a(!1),s(``)},children:`Cancel`}),(0,q.jsx)(L,{variant:`danger`,disabled:o!==t?.name||r.isPending,onClick:()=>l(!0),children:`Open the gate`})]})]})})]})}var tn=se.parse({});function nn(){let[e,t]=(0,K.useState)(Pe);return(0,K.useEffect)(()=>{let e=()=>t(Pe());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(Pe())]}function rn({permission:e,onRequest:t}){return e===`granted`||e===`unverified`?null:(0,q.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,q.jsxs)(q.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:t,className:`underline underline-offset-2 transition-colors hover:text-fg`,children:`request it now`}),`.`]}),e===`denied`&&`Blocked by the browser — allow notifications for this site in its site settings, then return here.`,e===`unsupported`&&`This browser cannot show desktop notifications.`]})}function an(){let e=W(),t=S(e??void 0),n=_(e??``),r=v(e??void 0),[i,a]=nn(),o=Be(),[s,c]=(0,K.useState)(!1);(0,K.useEffect)(()=>{Re();let e=()=>void Re();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]);let l=se.catch(tn).parse(t.data?.notifications??{}),u=e=>n.mutate({notifications:e},{onError:e=>G(e)}),d=()=>{nt()?.showNotification||typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Notifications`}),(0,q.jsx)(Y,{label:`Agent notifications`,htmlFor:`notify-desktop`,children:(0,q.jsx)(R,{id:`notify-desktop`,checked:l.desktop,onCheckedChange:e=>{e&&d(),u({...l,desktop:e})}})}),l.desktop&&(0,q.jsx)(rn,{permission:i,onRequest:d}),(0,q.jsx)(Y,{label:`Notify while interacting with a session`,htmlFor:`notify-focused`,description:`When off, typing or clicking in a session silences its desktop alerts for five seconds. Mobile Web Push is configured separately on each device.`,children:(0,q.jsx)(R,{id:`notify-focused`,checked:l.when_focused,onCheckedChange:e=>u({...l,when_focused:e})})}),(0,q.jsx)(Y,{label:`Test delivery`,description:`Send a notification to check this device’s permissions.`,children:(0,q.jsx)(L,{variant:`ghost`,disabled:s,onClick:()=>{c(!0),(async()=>{!nt()?.showNotification&&typeof Notification<`u`&&Notification.permission==="default"&&(await Notification.requestPermission(),a()),await He({id:`puddle-test`,title:`Puddle`,body:`Notifications are working on this device.`},()=>{})})().catch(G).finally(()=>c(!1))},children:s?`Sending…`:`Send test`})}),(0,q.jsx)(`p`,{role:`status`,className:`pb-2 text-xs text-fg-muted`,children:o.state===`shown`?`The system accepted the notification. Banner visibility also depends on Focus / Do Not Disturb.`:o.message??`Delivery has not been tested on this device.`}),(0,q.jsx)(Y,{label:`Sound`,htmlFor:`notify-sound`,children:(0,q.jsx)(R,{id:`notify-sound`,checked:l.sound,onCheckedChange:e=>u({...l,sound:e})})}),(0,q.jsx)(Y,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,q.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[l.muted_projects.length,` muted`]})}),(0,q.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,q.jsx)(R,{checked:l.muted_projects.includes(e.id),onCheckedChange:t=>u({...l,muted_projects:t?[...l.muted_projects,e.id]:l.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function on(){let e=W(),t=C(c().data?.protocol),n=At(t&&e!==null),[r,i]=(0,K.useState)(null),a=n.data?.providers??[],o=a.find(e=>e.id===r)??a[0];return!t||!e?null:(0,q.jsxs)(`div`,{className:`mt-8`,children:[(0,q.jsx)(X,{note:`Defaults for this profile on the connected host. Individual files can override them from their tab menu.`,children:`Compilation & running code`}),n.isLoading?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading languages…`}):n.isError?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:`Couldn’t load languages.`}):o?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Language`,htmlFor:`compilation-language`,children:(0,q.jsxs)(U,{value:o.id,onValueChange:i,children:[(0,q.jsx)(B,{id:`compilation-language`,className:`w-48`,children:(0,q.jsx)(z,{})}),(0,q.jsx)(V,{children:a.map(e=>(0,q.jsx)(H,{value:e.id,detail:e.available?void 0:`Not installed`,children:e.display_name},e.id))})]})}),!o.available&&(0,q.jsxs)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:[`No supported `,o.display_name,` tool is installed on this host. Saved commands apply when a supported tool is available.`]}),(0,q.jsx)(sn,{request:{profile_id:e,provider:o.id}},`${e}:${o.id}`)]}):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No languages advertised by this host.`})]})}function sn({request:e}){let t=jt(e),n=x();return t.isLoading?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading commands…`}):t.isError?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.error instanceof Error?t.error.message:`Couldn’t load commands`}):t.data?(0,q.jsx)(Nt,{settings:t.data,onSave:async t=>{for(let r of t){let t=await Mt({...e,...r});n.setQueryData([`compilation-defaults`,e],t),await n.invalidateQueries({queryKey:[`compilation-settings`]})}}}):null}function cn(){let e=Je();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Editor`}),(0,q.jsx)(Y,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,q.jsx)(J,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>D({editorTabSize:e})})}),(0,q.jsx)(Y,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,q.jsx)(R,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>D({editorWordWrap:e})})}),(0,q.jsx)(Y,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,q.jsx)(I,{id:`editor-link-host`,type:`text`,placeholder:$e.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>D({editorLinkSshHost:e.target.value})})}),(0,q.jsx)(on,{})]})}function ln({value:e,isDefault:t,onRecord:n,onReset:r}){let[i,a]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,"data-hotkey-recording":i||void 0,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=St(e.nativeEvent);t&&(n(t),a(!1))},className:O(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,i?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:i?`Press keys…`:wt(e)}),!t&&(0,q.jsxs)(`button`,{type:`button`,title:`Reset to default`,onClick:r,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(_t,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function un(){let e=W(),t=S(e??void 0),n=_(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of xt){let t=i(e.id,bt(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>G(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>G(e)})};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Hotkeys`}),(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,q.jsx)(Y,{label:`App shortcuts in terminals`,description:t.data?.terminalAppShortcuts===!1?`A focused terminal receives these keys instead.`:`The shortcuts below work while a terminal is focused.`,htmlFor:`terminal-app-shortcuts`,className:`mb-4`,children:(0,q.jsx)(R,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>G(e)})})}),Ct.map(e=>{let t=xt.filter(t=>t.group===e);return t.length===0?null:(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=i(e.id,bt(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,q.jsx)(Y,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,q.jsx)(ln,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var dn=e=>[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);function fn(e,t){let[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(!0),[o,s]=(0,K.useState)(``),c=(0,K.useRef)(0),l=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>{c.current+=1},[]),(0,K.useEffect)(()=>{if(n)return;let e=!0;return l.current=null,a(!0),(async()=>{try{let t=dn(crypto.getRandomValues(new Uint8Array(32))),n=dn(new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t))));e&&(l.current={code:t,challenge:n})}catch(t){e&&s(t instanceof Error?t.message:`Could not prepare sign-in.`)}finally{e&&a(!1)}})(),()=>{e=!1,l.current=null}},[n]);let u=(0,K.useRef)(t);return(0,K.useEffect)(()=>{u.current=t},[t]),(0,K.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{c.current+=1,r(null),s(`Sign-in expired. Try again.`)},Math.max(0,n.request.expires-Date.now()));return()=>clearTimeout(e)},[n]),(0,K.useEffect)(()=>{if(!n||e)return;let t=c.current,i=!1,a,o=async()=>{try{if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);let{ready:e}=ue.parse(await et(`POST`,`/cockpit/remote/registration`,{service:n.request.service,code:n.code}));if(i||t!==c.current)return;if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);e?(r(null),await u.current({t:`enable`,registration:{service:n.request.service,app:n.request.app,code:n.code}})):a=setTimeout(()=>void o(),2e3)}catch(e){if(i||t!==c.current)return;r(null),s(e instanceof Error?e.message:`Sign-in failed. Try again.`)}};return a=setTimeout(()=>void o(),2e3),()=>{i=!0,clearTimeout(a)}},[n,e]),{attempt:n,preparing:i,error:o,begin:(t,n,i)=>{if(!(e||!l.current)){s(``);try{let{code:e,challenge:a}=l.current,o=de.safeParse({service:t.trim(),app:n.trim(),label:i.trim(),challenge:a,expires:Date.now()+me.invitationMs});if(!o.success)throw Error(`Enter a host name and exact HTTPS application and relay origins.`);let s=o.data,u=`${s.app}/#register=${encodeURIComponent(JSON.stringify(s))}`;c.current+=1,l.current=null,r({request:s,code:e,url:u}),window.open(u,`_blank`,`noopener,noreferrer`)}catch(e){s(e instanceof Error?e.message:`Could not start sign-in.`)}}},cancel:()=>{c.current+=1,l.current=null,a(!0),r(null)}}}function pn({service:e=`https://charles.waddlelabs.ai`,app:t=`https://puddle.waddlelabs.ai`,hostName:n,busy:r,disabled:i,enable:a,cancel:o}){let[s,c]=(0,K.useState)(e),[l,u]=(0,K.useState)(t),[d,f]=(0,K.useState)(n),p=fn(i,a),m=i||p.preparing||!!p.attempt;return(0,q.jsxs)(`form`,{className:`mt-4 space-y-4`,onSubmit:e=>{e.preventDefault(),m||p.begin(s,l,d)},children:[(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Application origin`,(0,q.jsx)(I,{type:`url`,required:!0,value:l,onChange:e=>u(e.target.value),placeholder:`https://app.example.com`,autoComplete:`off`,disabled:m})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Relay origin`,(0,q.jsx)(I,{type:`url`,required:!0,value:s,onChange:e=>c(e.target.value),placeholder:`https://relay.example.com`,autoComplete:`off`,disabled:m})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Host name`,(0,q.jsx)(I,{required:!0,maxLength:80,value:d,onChange:e=>f(e.target.value),disabled:m})]}),o&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Saving a new registration revokes existing browser approvals and invitations.`}),p.error&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:p.error}),p.attempt?(0,q.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,q.jsxs)(`p`,{role:`status`,children:[`Confirm this host in your browser. Match request`,` `,(0,q.jsx)(`strong`,{className:`font-mono`,children:p.attempt.request.challenge.slice(0,8).toUpperCase()}),`. Sign-in expires in five minutes.`]}),(0,q.jsx)(`a`,{href:p.attempt.url,target:`_blank`,rel:`noreferrer`,className:`text-accent hover:opacity-80`,children:`Continue in browser ↗`}),(0,q.jsx)(L,{type:`button`,variant:`ghost`,onClick:p.cancel,children:`Cancel sign-in`})]}):(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(L,{type:`submit`,disabled:m||!d.trim()||!s||!l,children:r?`Enabling…`:p.preparing?`Preparing sign-in…`:`Sign in and enable`}),o&&(0,q.jsx)(L,{type:`button`,variant:`ghost`,disabled:m,onClick:o,children:`Cancel`})]})]})}var mn=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),Z=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),hn=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),gn=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),_n=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),vn=t((e=>{var t=Z().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),yn=t((e=>{var t=Z().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),bn=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),xn=t((e=>{var t=hn(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Sn=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Cn=t((e=>{var t=Sn();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),wn=t(((e,t)=>{var n=Cn();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Tn=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),En=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
2
  ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),Q=t((e=>{var t=Tn(),n=En();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),Dn=t((e=>{var t=Z(),n=xn(),r=hn(),i=Q(),a=Tn(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),On=t((e=>{var t=Z(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),kn=t(((e,t)=>{var n=Q();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),An=t(((e,t)=>{var n=Q(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),jn=t(((e,t)=>{var n=Q();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),Mn=t(((e,t)=>{var n=Q(),r=Z();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
3
  Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),Nn=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),Pn=t((e=>{var t=Q(),n=kn(),r=An(),i=jn(),a=Mn(),o=En(),s=Z(),c=Nn();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
4
  Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),Fn=t((e=>{var t=Z(),n=hn(),r=gn(),i=_n(),a=vn(),o=yn(),s=bn(),c=xn(),l=wn(),u=Dn(),d=On(),f=Q(),p=Pn();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`