@puddle-code/cli 0.5.0 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +9 -39
  2. package/README.md +10 -10
  3. package/dist/host-control.mjs +4063 -447
  4. package/dist/index.js +4700 -910
  5. package/dist/install-cli.sh +2 -2
  6. package/dist/install.sh +10 -6
  7. package/dist/public/assets/App-BV_yiDsr.js +19 -0
  8. package/dist/public/assets/{CompilationCommandForm-D7uBn2um.js → CompilationCommandForm-DXHvwQ8Y.js} +1 -1
  9. package/dist/public/assets/Dashboard-BF-uKZKM.js +1 -0
  10. package/dist/public/assets/DraftRecovery-B8Ld4_1b.js +1 -0
  11. package/dist/public/assets/EditorTabClose-CGYLU9GK.js +1 -0
  12. package/dist/public/assets/FileCloseScope-DoZ0oLf8.js +1 -0
  13. package/dist/public/assets/{FileEditorSettingsMenu-DnMJu5pC.js → FileEditorSettingsMenu-BbRHII96.js} +1 -1
  14. package/dist/public/assets/HuddlePane-LF3pjMQM.js +219 -0
  15. package/dist/public/assets/LazyTerminal-9xIh2FZq.js +2 -0
  16. package/dist/public/assets/ModelRefcount-CWfA9XXu.js +1 -0
  17. package/dist/public/assets/{NotebookWidget-DlpLANDa.js → NotebookWidget-BDdx0BOy.js} +1 -1
  18. package/dist/public/assets/PaneEditorBody-C1uu9cRG.js +284 -0
  19. package/dist/public/assets/PdfViewer-DLCPKybn.js +2 -0
  20. package/dist/public/assets/ReadOnlyDiff-C7ZSVRt-.js +2 -0
  21. package/dist/public/assets/{ReleaseNotesDialog-sQVKJ6dm.js → ReleaseNotesDialog-B9fRaZNN.js} +1 -1
  22. package/dist/public/assets/Ripple-BBMjOG3U.css +1 -0
  23. package/dist/public/assets/{Ripple-CLkhZZWa.js → Ripple-Dzg6tdOM.js} +1 -1
  24. package/dist/public/assets/SettingsDialog-BpB0nPgh.js +8 -0
  25. package/dist/public/assets/{Terminal-C3TQK74f.js → Terminal-4785ZuI8.js} +20 -20
  26. package/dist/public/assets/Workspace-DARXD6Je.js +20 -0
  27. package/dist/public/assets/{api--n1Ha6tG.js → api-CrP4jl9e.js} +1 -1
  28. package/dist/public/assets/auth-1SSLu56b.js +1 -0
  29. package/dist/public/assets/{buffer-logic-BAkSBQT7.js → buffer-logic-D9FvoilV.js} +1 -1
  30. package/dist/public/assets/buffer-store-OTFEYxTw.js +1 -0
  31. package/dist/public/assets/colour-picker-DZdAiaVI.js +1 -0
  32. package/dist/public/assets/content-state-CROLtMfN.js +1 -0
  33. package/dist/public/assets/{context-BRrQlmgI.js → context-NsaMZKAN.js} +1 -1
  34. package/dist/public/assets/disclosure-CpSwsC7J.js +1 -0
  35. package/dist/public/assets/drafts-CBbjQQbz.js +1 -0
  36. package/dist/public/assets/editor-context-T5zIHY3K.js +5 -0
  37. package/dist/public/assets/{editor-sync-C5CgYn_q.js → editor-sync-BOfDr2yY.js} +1 -1
  38. package/dist/public/assets/{errors-DWF9D4n6.js → errors-CviT-mvB.js} +1 -1
  39. package/dist/public/assets/expanding-content-ES1E2jvo.js +1 -0
  40. package/dist/public/assets/{file-editor-settings-1cj6VRxs.js → file-editor-settings-BXTs1F7S.js} +1 -1
  41. package/dist/public/assets/{file-links-BEPA2kg5.js → file-links-CgOYgoMC.js} +1 -1
  42. package/dist/public/assets/forward-link-qOyuWj08.js +1 -0
  43. package/dist/public/assets/hotkeys-nP8gYtE7.js +1 -0
  44. package/dist/public/assets/index-BB_BPKbu.css +2 -0
  45. package/dist/public/assets/index-TMXTPMjv.js +10 -0
  46. package/dist/public/assets/local-store-Dy1Cd8sn.js +276 -0
  47. package/dist/public/assets/{markdown-Cseepnv3.js → markdown-Dj7Cr7RL.js} +4 -4
  48. package/dist/public/assets/notification-delivery-DWXh5nfv.js +1 -0
  49. package/dist/public/assets/{preferences-Dy_61zsm.js → preferences-CvSHA-AA.js} +1 -1
  50. package/dist/public/assets/profile-icons-BI2xFWcB.js +1 -0
  51. package/dist/public/assets/{profile-store-CarO9MCP.js → profile-store-D4lZiXgL.js} +2 -2
  52. package/dist/public/assets/{project-actions-Zt9oqLe5.js → project-actions-Ck504AFM.js} +1 -1
  53. package/dist/public/assets/project-drag-BnkK15qk.js +1 -0
  54. package/dist/public/assets/{protocol-support-BUdL5Q-x.js → protocol-support-iXloAH0N.js} +1 -1
  55. package/dist/public/assets/queries-BSkHGZG8.js +1 -0
  56. package/dist/public/assets/queue-4USHmW_D.js +3 -0
  57. package/dist/public/assets/{render-rich-content-BULX1bwr.js → render-rich-content-fo4uQVWR.js} +1 -1
  58. package/dist/public/assets/save-BT7q_AMN.js +1 -0
  59. package/dist/public/assets/{scroll-restoration-Bl3jxJsC.js → scroll-restoration-C_ly1bKS.js} +1 -1
  60. package/dist/public/assets/selection-actions-2wBZeOyh.js +1 -0
  61. package/dist/public/assets/session-display-BUDNzNmg.js +1 -0
  62. package/dist/public/assets/session-order-b3nCJcCG.js +1 -0
  63. package/dist/public/assets/shield-check-CY69Ons-.js +1 -0
  64. package/dist/public/assets/source-anchor-map-BNxSa_bJ.js +1 -0
  65. package/dist/public/assets/square-terminal-CrlDquCd.js +1 -0
  66. package/dist/public/assets/state-CuUqRNo7.js +1 -0
  67. package/dist/public/assets/switch-CGrhQUXr.js +1 -0
  68. package/dist/public/assets/tooltip-Ek-eHPZu.js +1 -0
  69. package/dist/public/assets/trash-2-WYPJMQLN.js +1 -0
  70. package/dist/public/assets/{use-arrangement-ready-D18CpR8E.js → use-arrangement-ready-1vmV5np6.js} +1 -1
  71. package/dist/public/assets/use-desktop-state-CBTzsmlz.js +2 -0
  72. package/dist/public/assets/view-state-store-Dqk7M5ei.js +1 -0
  73. package/dist/public/assets/ws-CDXOuBYB.js +1 -0
  74. package/dist/public/assets/zoom-intent-vemBFIak.js +1 -0
  75. package/dist/public/index.html +8 -8
  76. package/dist/public/manifest.webmanifest +1 -1
  77. package/dist/public/notification-worker.js +1 -1
  78. package/dist/pudl.js +5816 -600
  79. package/package.json +2 -2
  80. package/dist/public/assets/App-ESs-lBsA.js +0 -49
  81. package/dist/public/assets/Dashboard-DWwOy6bQ.js +0 -1
  82. package/dist/public/assets/DraftRecovery-DO-ymSIW.js +0 -1
  83. package/dist/public/assets/EditorTabClose-DEizui0i.js +0 -1
  84. package/dist/public/assets/FileCloseScope-DKbSgHF2.js +0 -1
  85. package/dist/public/assets/LazyTerminal-B0GmOiTE.js +0 -2
  86. package/dist/public/assets/ModelRefcount-DBzR9UEq.js +0 -1
  87. package/dist/public/assets/PaneEditorBody-DRZ6NrJ1.js +0 -284
  88. package/dist/public/assets/PdfViewer-B3z9sh0x.js +0 -2
  89. package/dist/public/assets/Ripple-C8HPFMGB.css +0 -1
  90. package/dist/public/assets/SettingsDialog-DBUHpb9S.js +0 -8
  91. package/dist/public/assets/Workspace-D_NxUGYW.js +0 -20
  92. package/dist/public/assets/auth-eu0vmKkB.js +0 -1
  93. package/dist/public/assets/buffer-store-CBhXNRZm.js +0 -1
  94. package/dist/public/assets/content-state-BDt3NnGs.js +0 -1
  95. package/dist/public/assets/drafts-CCenbr5J.js +0 -1
  96. package/dist/public/assets/editor-links-qwyINDCv.js +0 -1
  97. package/dist/public/assets/expanding-content-BUkS1Qk4.js +0 -1
  98. package/dist/public/assets/forward-link-CcmVXHkx.js +0 -1
  99. package/dist/public/assets/index-Botodnry.js +0 -10
  100. package/dist/public/assets/index-rjm6DMrz.css +0 -2
  101. package/dist/public/assets/local-store-8IcyY3pd.js +0 -64
  102. package/dist/public/assets/notification-delivery-CWj1p0u-.js +0 -1
  103. package/dist/public/assets/project-drag-Bqy-V-45.js +0 -1
  104. package/dist/public/assets/queries-DnuokC1N.js +0 -1
  105. package/dist/public/assets/queue-BlrQxHDl.js +0 -3
  106. package/dist/public/assets/selection-actions-BSqrsD_7.js +0 -1
  107. package/dist/public/assets/session-order-CCDTBSiH.js +0 -1
  108. package/dist/public/assets/switch-BsUkvj8j.js +0 -1
  109. package/dist/public/assets/trash-2-DQeNROsF.js +0 -1
  110. package/dist/public/assets/use-desktop-state-Dw9EfOjg.js +0 -2
  111. package/dist/public/assets/view-state-store-CY9DI6-i.js +0 -1
  112. package/dist/public/assets/ws-DH0dKRnO.js +0 -1
@@ -0,0 +1,219 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{C as n}from"./protocol-support-iXloAH0N.js";import{At as r,Bt as i,Ct as a,Dt as o,Et as s,Ft as c,Hn as l,It as u,Jt as d,Lt as f,Mt as p,Nt as m,Ot as h,Pt as g,Rt as _,St as v,Tt as y,Vt as b,Yt as x,Zt as S,_t as C,an as w,at as T,bt as ee,cn as E,ct as D,dn as O,dt as te,fn as ne,ft as k,gt as A,hn as j,ht as M,in as N,it as P,jt as F,kt as re,lt as ie,mn as ae,mt as oe,n as se,nn as ce,nt as le,on as ue,ot as de,pt as fe,r as pe,rn as me,rt as he,sn as ge,tn as _e,tt as ve,un as ye,ut as be,vt as xe,wt as Se,xt as Ce,yt as we,zt as Te}from"./local-store-Dy1Cd8sn.js";import{r as Ee}from"./auth-1SSLu56b.js";import{t as De}from"./jsx-runtime-By8HlURe.js";import{n as I}from"./api-CrP4jl9e.js";import{i as Oe,t as ke}from"./profile-store-D4lZiXgL.js";import{At as Ae,Ft as je,J as Me,Mt as Ne,Ot as Pe,St as Fe,U as Ie,_t as Le,b as L,ct as Re,dt as ze,et as Be,ft as Ve,ht as He,it as R,lt as Ue,ot as We,pt as Ge,rt as Ke,s as qe,st as Je,ut as Ye,y as Xe}from"./queries-BSkHGZG8.js";import{J as Ze,m as Qe,n as $e,q as et}from"./editor-context-T5zIHY3K.js";import{c as tt,r as nt,t as rt}from"./square-terminal-CrlDquCd.js";import{t as it}from"./utils-B6KiDbIe.js";import{a as at,i as z,r as B,s as V,t as H}from"./dialog-CTN-Lln6.js";import{n as U}from"./dist-BOS6OKSE.js";import{t as ot}from"./x-CbfJFzGo.js";import{a as st,d as ct,r as lt,u as ut}from"./dist-NuV8HBEc.js";import{a as dt,i as ft,n as pt,r as mt,s as ht,t as gt}from"./select-DzQdQNsv.js";import{i as _t,n as vt,t as yt}from"./tooltip-Ek-eHPZu.js";import{t as bt}from"./button-D-qeQvl5.js";import{n as W,r as xt}from"./chevron-right-DUkOv15w.js";import{n as St,o as G,r as Ct,t as wt}from"./colour-picker-DZdAiaVI.js";import{t as K}from"./createLucideIcon-DyMAgLa3.js";import{n as Tt}from"./profile-icons-BI2xFWcB.js";import{n as Et,t as Dt}from"./shield-check-CY69Ons-.js";import{a as Ot,n as kt,r as At,t as jt}from"./switch-CGrhQUXr.js";import{t as Mt}from"./code-DRWf9a5s.js";import{a as Nt,g as Pt,p as Ft,s as It,t as Lt}from"./ReadOnlyDiff-C7ZSVRt-.js";import{S as Rt,_ as zt,a as Bt,b as Vt,c as Ht,d as Ut,f as Wt,g as Gt,h as Kt,i as qt,m as Jt,n as Yt,o as Xt,p as Zt,r as Qt,t as $t,u as en,v as tn,x as nn,y as rn}from"./state-CuUqRNo7.js";import{n as an,t as on}from"./disclosure-CpSwsC7J.js";import{t as sn}from"./rotate-ccw-CNjR2LSi.js";import{t as cn}from"./save-BT7q_AMN.js";import{t as ln}from"./settings-2-CInoy48z.js";import{t as un}from"./control-tray-CjoJunx1.js";import{n as dn,r as fn,t as pn}from"./popover-Okyclsx8.js";import{r as mn}from"./view-state-store-Dqk7M5ei.js";import{r as hn}from"./buffer-logic-D9FvoilV.js";import{a as gn,m as _n,p as vn,s as yn,t as bn,u as xn}from"./buffer-store-OTFEYxTw.js";import{t as Sn}from"./zoom-intent-vemBFIak.js";function Cn(e,t){let n=new TextEncoder,r=n.encode(e).length;if(r>128*1024)throw Error(`Prompt exceeds its byte limit`);return e.replace(/\{\{\s*input((?:\.[a-zA-Z0-9_-]+)*)\s*\}\}/g,(e,i)=>{let a=t;for(let e of i.split(`.`).filter(Boolean)){if(!a||typeof a!=`object`||!Object.hasOwn(a,e))throw Error(`Missing prompt input field: `+i);a=a[e]}let o=typeof a==`string`?a:JSON.stringify(a);if(o===void 0)throw Error(`Missing prompt input value`);if(r+=n.encode(o).length-n.encode(e).length,r>128*1024)throw Error(`Prompt exceeds its byte limit`);return o})}function wn(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Tn(e,t,n){let r=e.slice(0);return r[t]=n,r}var En=class extends je{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,Fe.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!Ne(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(wn(e,n).forEach(e=>{e.destroy()}),wn(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=Ae(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new Le(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Tn(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&Fe.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},q=e(t(),1);function Dn({queries:e,...t},n){let r=He(n),i=Ge(),a=Ve(),o=q.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{We(e);let t=r.getQueryCache().get(e.queryHash);Ue(e,a,t)}),ze(a);let[s]=q.useState(()=>new En(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;q.useSyncExternalStore(q.useCallback(e=>d?s.subscribe(Fe.batchCalls(e)):Pe,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),q.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>Re(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&Re(n,e)?Je(n,new Le(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&Ye({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}var On=K(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),kn=K(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),An=K(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),jn=K(`cable`,[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]),Mn=K(`calendar-check`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`m9 16 2 2 4-4`,key:`19s6y9`}]]),Nn=K(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),Pn=K(`calendar-days`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M16 18h.01`,key:`kzsmim`}]]),Fn=K(`calendar-range`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M17 14h-6`,key:`bkmgh3`}],[`path`,{d:`M13 18H7`,key:`bb0bb7`}],[`path`,{d:`M7 14h.01`,key:`1qa3f1`}],[`path`,{d:`M17 18h.01`,key:`1bdyru`}]]),In=K(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),Ln=K(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Rn=K(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),zn=K(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),Bn=K(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Vn=K(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),Hn=K(`file-braces`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),Un=K(`file-input`,[[`path`,{d:`M4 11V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-1`,key:`1q9hii`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 15h10`,key:`jfw4w8`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),Wn=K(`file-output`,[[`path`,{d:`M4.226 20.925A2 2 0 0 0 6 22h12a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.127`,key:`wfxp4w`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 11-3 3`,key:`1dgrs4`}],[`path`,{d:`m5 17-3-3h10`,key:`1mvvaf`}]]),Gn=K(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Kn=K(`focus`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}]]),qn=K(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Jn=K(`folder-output`,[[`path`,{d:`M2 7.5V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-1.5`,key:`1yk7aj`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m5 10-3 3 3 3`,key:`1r8ie0`}]]),Yn=K(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),Xn=K(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),Zn=K(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),Qn=K(`hard-drive`,[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]),$n=K(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),er=K(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),tr=K(`inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),nr=K(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),rr=K(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),ir=K(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),ar=K(`merge`,[[`path`,{d:`m8 6 4-4 4 4`,key:`ybng9g`}],[`path`,{d:`M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22`,key:`1hyw0i`}],[`path`,{d:`m20 22-5-5`,key:`1m27yz`}]]),or=K(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),sr=K(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),cr=K(`package-open`,[[`path`,{d:`M12 22v-9`,key:`x3hkom`}],[`path`,{d:`M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z`,key:`2ntwy6`}],[`path`,{d:`M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13`,key:`1pmm1c`}],[`path`,{d:`M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z`,key:`12ttoo`}]]),lr=K(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),ur=K(`panels-top-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]]),dr=K(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),fr=K(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),pr=K(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),mr=K(`redo-2`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]),hr=K(`repeat`,[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]),gr=K(`route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),_r=K(`scan`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}]]),vr=K(`shuffle`,[[`path`,{d:`m18 14 4 4-4 4`,key:`10pe0f`}],[`path`,{d:`m18 2 4 4-4 4`,key:`pucp1d`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`,key:`1ailkh`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`,key:`km57vx`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`,key:`os18l9`}]]),yr=K(`split`,[[`path`,{d:`M16 3h5v5`,key:`1806ms`}],[`path`,{d:`M8 3H3v5`,key:`15dfkv`}],[`path`,{d:`M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3`,key:`1qrqzj`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}]]),br=K(`table`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]),xr=K(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Sr=K(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),Cr=K(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),wr=K(`unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),Tr=K(`webhook`,[[`path`,{d:`M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2`,key:`q3hayz`}],[`path`,{d:`m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06`,key:`1go1hn`}],[`path`,{d:`m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8`,key:`qlwsc0`}]]),Er=K(`workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),J=De();function Y({icon:e,label:t,title:n,className:r,...i}){return(0,J.jsxs)(yt,{children:[(0,J.jsx)(_t,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,"aria-label":t,className:it(lt,r),...i,children:(0,J.jsx)(e,{className:`size-4`})})}),(0,J.jsx)(vt,{side:`bottom`,children:n??t})]})}var X=`island-outline rounded-[var(--ui-surface-radius)] bg-surface p-3`;function Dr({title:e,label:t=e,onClose:n,children:r}){return(0,J.jsxs)(`aside`,{"aria-label":t,"data-state":`open`,className:`${ct} ${ut} absolute right-3 top-[var(--huddle-toolbar-bottom,4rem)] bottom-16 z-20 flex w-80 max-w-[calc(100%-1.5rem)] flex-col overflow-hidden text-sm`,onKeyDown:e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.stopPropagation(),n())},children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 px-4 py-2`,children:[(0,J.jsx)(`h2`,{className:`min-w-0 truncate`,children:e}),(0,J.jsx)(Y,{label:`Close ${t.toLowerCase()}`,icon:ot,onClick:n})]}),(0,J.jsx)(`div`,{className:`no-scrollbar min-h-0 overflow-y-auto overscroll-contain px-3 pb-3`,children:r})]})}function Z({id:e,label:t,value:n,onValueChange:r,options:i,placeholder:a,disabled:o}){return(0,J.jsxs)(gt,{value:i.some(e=>e.value===n)?`value:${n}`:``,onValueChange:e=>r(e.slice(6)),disabled:o,children:[(0,J.jsx)(ft,{"data-value":n,id:e,"aria-label":t,className:`min-w-0`,children:(0,J.jsx)(dt,{placeholder:a})}),(0,J.jsx)(pt,{children:i.map(e=>(0,J.jsx)(mt,{"data-value":e.value,value:`value:${e.value}`,disabled:e.disabled,children:e.label},e.value))})]})}function Or(e,t){let n=new Set(e.map(e=>e.id));if(!n.has(t))return t;for(let e=2;;e++)if(!n.has(`${t}-${e}`))return`${t}-${e}`}function kr(e,t,n,r){let i=w.parse({id:Or(e.nodes,n),source:t,...r?{appearance:r}:{}});return{...e,nodes:[...e.nodes,i]}}function Ar(e,t){let{triggerAdmission:n,...r}=e.execution,i={...n};return delete i[t],{...e,nodes:e.nodes.filter(e=>e.id!==t),edges:e.edges.filter(e=>e.from.node!==t&&e.to.node!==t),execution:{...r,...Object.keys(i).length?{triggerAdmission:i}:{}}}}function jr(e,t,n){let r=e.components[t.node]?.outputs[t.port],i=e.components[n.node]?.inputs[n.port];if(!e.definition.nodes.some(e=>e.id===t.node)||!r)return`The output no longer exists.`;if(!e.definition.nodes.some(e=>e.id===n.node)||!i)return`The input no longer exists.`;if(e.definition.edges.some(e=>e.from.node===t.node&&e.from.port===t.port&&e.to.node===n.node&&e.to.port===n.port))return`This connection already exists.`;if(T(r.schema,i.schema)===`incompatible`)return`These ports have incompatible types.`}function Mr(e,t,n){let r=jr(e,t,n);if(r)throw Error(r);return{...e.definition,edges:[...e.definition.edges,{id:Or(e.definition.edges,`connection`),from:t,to:n}]}}function Nr(e,t=[]){return!e||t.length>16?[]:e.type===`boolean`&&t.length?[t]:Object.entries(e.properties??{}).flatMap(([e,n])=>Nr(n,[...t,e]))}function Pr({edge:e,schema:t,edit:n}){let r=(0,q.useId)(),i=Nr(t),[a,o]=(0,q.useState)(null),s=t=>n(n=>({...n,edges:n.edges.map(n=>{if(n.id!==e.id)return n;let{feedback:r,...i}=n;return t?{...i,feedback:t}:i})}));return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 text-xs`,children:[(0,J.jsxs)(`label`,{htmlFor:`${r}-enabled`,className:`flex cursor-pointer items-center gap-2`,children:[(0,J.jsx)(jt,{id:`${r}-enabled`,checked:!!e.feedback,disabled:!e.feedback&&!i.length,onCheckedChange:e=>s(e?{maxRounds:5,while:{path:i[0],equals:!1}}:void 0)}),`Bounded feedback`]}),e.feedback&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(G,{htmlFor:`${r}-condition`,children:`Continue while`}),(0,J.jsx)(Z,{id:`${r}-condition`,value:JSON.stringify(e.feedback.while.path),onValueChange:t=>s({...e.feedback,while:{...e.feedback.while,path:JSON.parse(t)}}),options:[...i.some(t=>JSON.stringify(t)===JSON.stringify(e.feedback.while.path))?[]:[{value:JSON.stringify(e.feedback.while.path),label:`${e.feedback.while.path.join(`.`)} · unavailable`}],...i.map(e=>({value:JSON.stringify(e),label:e.join(`.`)}))]}),(0,J.jsx)(Z,{label:`Feedback condition value`,value:String(e.feedback.while.equals),onValueChange:t=>s({...e.feedback,while:{...e.feedback.while,equals:t===`true`}}),options:[{value:`false`,label:`False`},{value:`true`,label:`True`}]}),(0,J.jsx)(G,{htmlFor:`${r}-rounds`,children:`Maximum rounds`}),(0,J.jsx)(W,{id:`${r}-rounds`,type:`number`,min:1,max:1e3,value:a??String(e.feedback.maxRounds),onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},onBlur:()=>{let t=Number(a);a!==null&&Number.isInteger(t)&&t>=1&&t<=1e3&&s({...e.feedback,maxRounds:t}),o(null)}})]})]})}var Q=`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`;function Fr({graph:e,edit:t}){let n=(0,q.useId)(),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(``),s=t=>e.definition.nodes.flatMap(n=>Object.keys(e.components[n.id]?.[t]??{}).map(e=>({node:n.id,port:e}))),c=s(`outputs`),l=s(`inputs`),u=c.find(e=>JSON.stringify(e)===r),d=l.find(e=>JSON.stringify(e)===a);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-label":`Edit connections`,children:[(0,J.jsx)(G,{htmlFor:`${n}-output`,children:`Output`}),(0,J.jsx)(Z,{id:`${n}-output`,value:u?r:``,onValueChange:i,placeholder:`Choose output`,options:c.map(e=>({value:JSON.stringify(e),label:`${e.node}.${e.port}`}))}),(0,J.jsx)(G,{htmlFor:`${n}-input`,children:`Input`}),(0,J.jsx)(Z,{id:`${n}-input`,value:d?a:``,onValueChange:o,placeholder:`Choose input`,options:l.map(e=>({value:JSON.stringify(e),label:`${e.node}.${e.port}`}))}),(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:!u||!d,onClick:()=>{u&&d&&t(t=>Mr({...e,definition:t},u,d))},children:`Connect`}),e.definition.edges.map(n=>(0,J.jsxs)(`div`,{className:`${X} flex flex-col gap-2 text-xs`,children:[(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[n.from.node,`.`,n.from.port,` → `,n.to.node,`.`,n.to.port]}),(0,J.jsx)(Pr,{edge:n,schema:e.components[n.from.node]?.outputs[n.from.port]?.schema,edit:t}),(0,J.jsx)(`button`,{type:`button`,className:Q,"aria-label":`Disconnect ${n.id}`,onClick:()=>t(e=>({...e,edges:e.edges.filter(e=>e.id!==n.id)})),children:`Disconnect`})]},n.id))]})}function Ir({value:e,fallback:t,disabled:n,rename:r}){let i=(0,q.useId)(),[a,o]=(0,q.useState)(null);return(0,J.jsxs)(`form`,{className:`${X} flex flex-col gap-2`,onSubmit:t=>{t.preventDefault(),n||(r(a??e),o(null))},children:[(0,J.jsx)(G,{htmlFor:i,children:`Node name`}),(0,J.jsx)(W,{id:i,value:a??e,placeholder:t,maxLength:200,disabled:n,onChange:e=>o(e.target.value)}),(0,J.jsx)(`button`,{type:`submit`,className:Q,disabled:n||a===null,children:`Rename node`}),n&&(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Renaming requires a host supporting node labels.`})]})}var Lr=e=>({x:e.reduce((e,t)=>e+t.x,0)/e.length,y:e.reduce((e,t)=>e+t.y,0)/e.length}),Rr=e=>e.length<2?1:Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y);function zr(e,t,n){let r=(0,q.useRef)(new Map),i=(0,q.useRef)(!1),a=(0,q.useRef)(!1),o=(0,q.useRef)({x:0,y:0}),s=(0,q.useRef)(null);(0,q.useLayoutEffect)(()=>{let n=e.current,i=Sn(n.ownerDocument.defaultView);s.current=i;let a=e=>{e.preventDefault();let a=i.wheel(e);if(a===`ignore`||r.current.size>1)return;let o=e.deltaMode===1?16:e.deltaMode===2?n.clientHeight:1;if(a===`zoom`){let r=n.getBoundingClientRect(),i={x:e.clientX-r.left,y:e.clientY-r.top};t.current?.gesture(Math.exp(-e.deltaY*o*.005),i,i)}else t.current?.gesture(1,{x:0,y:0},{x:-(e.shiftKey&&!e.deltaX?e.deltaY:e.deltaX)*o,y:e.shiftKey&&!e.deltaX?0:-e.deltaY*o})};return n.addEventListener(`wheel`,a,{passive:!1}),()=>{n.removeEventListener(`wheel`,a),i.dispose(),s.current=null}},[e,t]);let c=t=>{let n=e.current.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},l=e=>{r.current.delete(e.pointerId),a.current&&e.stopPropagation(),r.current.size||(i.current=!1,e.currentTarget.style.cursor=``)};return{onPointerDownCapture(e){if(![0,1].includes(e.button))return;r.current.size||(a.current=!1),r.current.set(e.pointerId,c(e));let t=!e.target.closest(`button, [data-huddle-node]`);r.current.size>=2&&(a.current||(o.current=Lr([...r.current.values()])),a.current=!0,n()),(t||a.current||e.button===1)&&(e.preventDefault(),e.stopPropagation(),i.current=!0,e.currentTarget.style.cursor=`grabbing`,e.currentTarget.setPointerCapture(e.pointerId),t&&e.currentTarget.focus({preventScroll:!0}))},onPointerMoveCapture(e){if(!r.current.has(e.pointerId))return;let n=[...r.current.values()];if(r.current.set(e.pointerId,c(e)),!i.current)return;e.preventDefault(),e.stopPropagation();let l=[...r.current.values()];a.current?(s.current?.suppressPan(),l.length>=2&&t.current?.gesture(Rr(l)/Math.max(1,Rr(n)),o.current,o.current)):!e.metaKey&&!e.ctrlKey&&!s.current?.panBlocked()&&t.current?.gesture(1,Lr(n),Lr(l))},onPointerUpCapture:l,onPointerCancelCapture:l,onLostPointerCaptureCapture:l,onClickCapture(e){a.current&&(e.preventDefault(),e.stopPropagation())},onKeyDown(e){if(e.target!==e.currentTarget)return;let n={ArrowLeft:[64,0],ArrowRight:[-64,0],ArrowUp:[0,64],ArrowDown:[0,-64]}[e.key];n&&(e.preventDefault(),t.current?.gesture(1,{x:0,y:0},{x:n[0],y:n[1]}))}}}function Br({locked:e,canUndo:t,canRedo:n,undo:r,redo:i,selected:a,fit:o,zoom:s,setZoom:c}){return(0,J.jsx)(`div`,{className:`absolute bottom-3 left-3 z-10 max-w-[calc(100%-1.5rem)]`,children:(0,J.jsxs)(un,{label:`Graph navigation`,variant:`island`,className:`max-w-full flex-wrap`,children:[(0,J.jsx)(Y,{label:`Undo move`,icon:Zt,onClick:r,disabled:e||!t}),(0,J.jsx)(Y,{label:`Redo move`,icon:mr,onClick:i,disabled:e||!n}),(0,J.jsx)(Y,{label:`Fit graph`,icon:_r,onClick:()=>o(!1)}),(0,J.jsx)(Y,{label:`Fit selected`,icon:Kn,disabled:!a,onClick:()=>o(!0)}),(0,J.jsx)(Y,{label:`Zoom out`,icon:Kt,onClick:()=>c(Math.max(.001,s/1.25))}),(0,J.jsxs)(`button`,{type:`button`,className:`px-2 text-xs tabular-nums`,"aria-label":`Reset zoom`,onClick:()=>c(1),children:[Math.round(s*100),`%`]}),(0,J.jsx)(Y,{label:`Zoom in`,icon:an,onClick:()=>c(Math.min(2,s*1.25))})]})})}function Vr(e){return{x:e%3*320,y:Math.floor(e/3)*220}}function Hr(e,t,n){let r=e=>Math.min(1e6,Math.max(-1e6,Math.round(e)));return{x:r(e.x+t),y:r(e.y+n)}}function Ur(e,t){return!!t&&e.x<=t.right&&e.right>=t.x&&e.y<=t.bottom&&e.bottom>=t.y}function Wr(e,t,n){return{...e,right:e.x+240,bottom:e.y+90+24*Math.max(t,n)}}function Gr(e,t){return{x:Math.min(e.x,t.x-80,t.x),right:Math.max(e.x,e.x+80,t.x),y:Math.min(e.y,t.y),bottom:Math.max(e.y,t.y)}}function Kr(e,t){return!e.clientWidth||!e.clientHeight?null:{x:(e.scrollLeft-200)/t,y:(e.scrollTop-200)/t,right:(e.scrollLeft+e.clientWidth+200)/t,bottom:(e.scrollTop+e.clientHeight+200)/t}}function qr(e,t){return`M ${e.x} ${e.y} C ${e.x+80} ${e.y}, ${t.x-80} ${t.y}, ${t.x} ${t.y}`}function Jr({edges:e,width:t,height:n,socket:r,selected:i,select:a,locked:o,disconnect:s,wire:c,visible:l,focused:u}){let d=c.pending&&r(c.pending.from,`outputs`);return(0,J.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0 text-fg-muted`,width:t,height:n,children:[e.map(e=>{let t=r(e.from,`outputs`),n=r(e.to,`inputs`);if(!t||!n||e.id!==i&&e.id!==u&&!Ur(Gr(t,n),l))return null;let d=qr(t,n);return(0,J.jsxs)(`g`,{"data-huddle-edge":e.id,children:[(0,J.jsx)(`path`,{d,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,"aria-hidden":!0,className:i===e.id?`text-accent`:void 0,strokeDasharray:e.feedback?`5 4`:void 0}),(0,J.jsx)(`path`,{d,fill:`none`,stroke:`transparent`,strokeWidth:14,vectorEffect:`non-scaling-stroke`,className:`pointer-events-auto cursor-pointer hover:stroke-accent/30 focus-visible:stroke-accent/30 focus-visible:outline-none`,role:`button`,tabIndex:0,"aria-pressed":i===e.id,"aria-label":`Connection ${e.from.node}.${e.from.port} to ${e.to.node}.${e.to.port}`,onPointerDown:e=>e.stopPropagation(),onClick:()=>{c.pending&&c.cancel(),a(e.id)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e.id)),(t.key===`Delete`||t.key===`Backspace`)&&!o&&(t.preventDefault(),s(e.id))},children:(0,J.jsx)(`title`,{children:`Select connection; Delete disconnects`})})]},e.id)}),d&&c.pending?.point&&(0,J.jsx)(`path`,{d:qr(d,c.pending.point),fill:`none`,stroke:`currentColor`,"aria-hidden":!0,strokeWidth:1.5,strokeDasharray:`5 4`,className:`text-accent`})]})}var Yr=[{name:`play`,Icon:Ze},{name:`clock`,Icon:Bn},{name:`calendar-days`,Icon:Pn},{name:`calendar-clock`,Icon:Nn},{name:`calendar-range`,Icon:Fn},{name:`folder-tree`,Icon:nn},{name:`git-branch`,Icon:Vt},{name:`activity`,Icon:On},{name:`message-square`,Icon:or},{name:`check-check`,Icon:In},{name:`rotate-ccw`,Icon:sn},{name:`plus`,Icon:an},{name:`file-output`,Icon:Wn},{name:`code`,Icon:Mt},{name:`type`,Icon:Cr},{name:`git-fork`,Icon:Zn},{name:`merge`,Icon:ar},{name:`combine`,Icon:Pt},{name:`radio`,Icon:pr},{name:`braces`,Icon:An},{name:`file-code`,Icon:Rt},{name:`workflow`,Icon:Er},{name:`network`,Icon:sr},{name:`route`,Icon:gr},{name:`split`,Icon:yr},{name:`filter`,Icon:Yn},{name:`repeat`,Icon:hr},{name:`shuffle`,Icon:vr},{name:`list-checks`,Icon:rr},{name:`check`,Icon:ht},{name:`square`,Icon:et},{name:`pause`,Icon:dr},{name:`timer`,Icon:Sr},{name:`hourglass`,Icon:er},{name:`calendar-check`,Icon:Mn},{name:`clipboard-check`,Icon:Rn},{name:`clipboard-list`,Icon:zn},{name:`database`,Icon:Vn},{name:`table`,Icon:br},{name:`layers`,Icon:nr},{name:`boxes`,Icon:kn},{name:`package`,Icon:lr},{name:`package-open`,Icon:cr},{name:`file-input`,Icon:Un},{name:`file-json`,Icon:Hn},{name:`file-text`,Icon:Gn},{name:`folder-input`,Icon:qn},{name:`folder-output`,Icon:Jn},{name:`hard-drive`,Icon:Qn},{name:`terminal`,Icon:xr},{name:`square-terminal`,Icon:rt},{name:`webhook`,Icon:Tr},{name:`plug`,Icon:fr},{name:`cable`,Icon:jn},{name:`link`,Icon:tn},{name:`unlink`,Icon:wr},{name:`send`,Icon:Jt},{name:`inbox`,Icon:tr},{name:`bell`,Icon:Et},{name:`mail`,Icon:ir},{name:`shield-check`,Icon:Dt},{name:`lock`,Icon:Gt},{name:`settings2`,Icon:ln}],Xr={...Tt,...Object.fromEntries(Yr.map(({name:e,Icon:t})=>[e,t]))};function Zr({value:e,onSelect:t}){return(0,J.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,"aria-label":`Node icons`,children:[(0,J.jsx)(`button`,{type:`button`,"aria-label":`Default node icon`,className:lt,onClick:()=>t(null),children:(0,J.jsx)(Ut,{className:`size-4`})}),Yr.map(({name:n,Icon:r})=>(0,J.jsx)(`button`,{type:`button`,title:n,"aria-label":n,"aria-pressed":e===n,className:lt,onClick:()=>t(n),children:(0,J.jsx)(r,{className:`size-4`})},n))]})}function Qr({title:e,label:t,icon:n,selected:r,canRename:i,locked:a,rename:o,changeIcon:s,onKeyDown:c}){let[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(!1),p=(0,q.useRef)(!1),m=(0,q.useRef)(null),h=(0,q.useRef)(!1),g=(0,q.useRef)(null),_=l!==null;(0,q.useLayoutEffect)(()=>{if(_){let e=m.current?.querySelector(`input`);e?.focus({preventScroll:!0}),e?.select()}else h.current&&g.current?.focus({preventScroll:!0});h.current=_},[_]);let v=()=>{p.current&&(p.current=!1,l!==null&&l.trim()!==e&&o(l),u(null))},y=n&&Xr[n]||Ut;return(0,J.jsxs)(`div`,{ref:m,className:`mb-1 flex h-8 items-center gap-2`,"data-node-identity":!0,children:[(0,J.jsxs)(pn,{open:d,onOpenChange:f,children:[(0,J.jsx)(fn,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,"aria-label":`Change icon for ${e}`,disabled:a,className:`flex size-7 shrink-0 cursor-grab items-center justify-center rounded-md hover:bg-explorer-hover disabled:opacity-50`,children:(0,J.jsx)(y,{className:`size-4`})})}),(0,J.jsx)(dn,{className:`w-80`,onPointerDown:e=>e.stopPropagation(),children:(0,J.jsx)(Zr,{value:n,onSelect:e=>{s(e),f(!1)}})})]}),_?(0,J.jsx)(W,{"aria-label":`Node name`,"data-node-control":!0,maxLength:200,className:`h-8 min-w-0 flex-1`,value:l,onChange:e=>u(e.target.value),onBlur:v,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),v()),e.key===`Escape`&&(e.preventDefault(),p.current=!1,u(null))}}):(0,J.jsx)(`button`,{ref:g,type:`button`,"data-node-name":!0,"aria-label":t,"aria-pressed":r,title:`Rename node`,onKeyDown:c,className:`flex h-8 min-w-0 flex-1 cursor-grab touch-none items-center rounded-md text-left text-sm transition-colors hover:bg-explorer-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,onClick:()=>{if(!i){U.warning(`Node renaming requires a supporting host and an editable layout.`);return}p.current=!0,u(e)},children:(0,J.jsx)(`span`,{className:`truncate`,children:e})})]})}function $r({node:e,title:t,rename:n,changeIcon:r,canRename:i,contract:a,position:o,shown:s,selected:c,locked:l,version:u,drag:d,wire:f,onSelect:p,move:m,undo:h,redo:g,onDelete:_}){let v=Object.keys(a?.inputs??{}),y=Object.keys(a?.outputs??{}),b=e.appearance??a?.appearance,x=!!b?.colour,S=`flex h-6 max-w-full items-center gap-2 rounded-sm text-xs hover:bg-explorer-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`;return(0,J.jsxs)(`div`,{"data-huddle-node":e.id,className:it(`island-outline absolute w-60 touch-none select-none rounded-xl p-3`,!l&&(d.preview?.id===e.id?`cursor-grabbing`:`cursor-grab`),c?`bg-elevated text-accent`:`bg-surface text-fg`,St(b?.colour)),style:{left:s.x,top:s.y,...Ct(b?.colour),...x?{backgroundColor:`color-mix(in srgb, currentColor ${c?14:7}%, var(--bg-surface))`,outlineColor:`color-mix(in srgb, currentColor 35%, var(--border))`}:{}},...d.handlers(e.id,o),onClickCapture:e=>{d.suppressClick()&&(e.preventDefault(),e.stopPropagation())},onClick:t=>{t.currentTarget.contains(t.target)&&!t.target.closest(`button, input`)&&p(e.id)},children:[(0,J.jsx)(Qr,{title:t,label:[t,...v,...y,...!v.length&&!y.length?[a?.category??`Unresolved component`]:[]].join(` `),icon:b?.icon,selected:c,canRename:i,locked:l,rename:n,changeIcon:r,onKeyDown:t=>{if(t.key===`Escape`){d.cancel();return}if((t.metaKey||t.ctrlKey)&&t.key.toLowerCase()===`z`){t.preventDefault(),t.shiftKey?g():h();return}if(t.key===`Delete`||t.key===`Backspace`){t.preventDefault(),_(e.id);return}let n={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[t.key];if(!n||l)return;t.preventDefault(),p(e.id);let r=t.shiftKey?50:10;m(e.id,Hr(o,n[0]*r,n[1]*r),u)}}),(0,J.jsxs)(`div`,{className:it(`flex justify-between gap-3`,x?`text-current`:`text-fg-muted`),children:[(0,J.jsx)(`div`,{className:`min-w-0`,children:v.map(t=>{let n={node:e.id,port:t},r=f.problem(n);return(0,J.jsxs)(`button`,{type:`button`,"data-huddle-socket":!0,"aria-label":`Input ${e.id}.${t}`,title:r??`Input ${e.id}.${t}${a?.inputs[t]?.scope===`execution`?` · retained for this execution`:``}`,"aria-description":a?.inputs[t]?.scope===`execution`?`Retained for this execution, including feedback rounds`:void 0,...f.input(n),className:it(S,f.pending&&!r&&`text-accent`,f.pending&&r&&`opacity-50`),children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-current`}),(0,J.jsx)(`span`,{className:`truncate`,children:t})]},t)})}),(0,J.jsx)(`div`,{className:`min-w-0`,children:y.map(t=>(0,J.jsxs)(`button`,{type:`button`,"data-huddle-socket":!0,"aria-label":`Output ${e.id}.${t}`,...f.output({node:e.id,port:t}),className:it(S,`ml-auto touch-none justify-end disabled:opacity-50`),children:[(0,J.jsx)(`span`,{className:`truncate`,children:t}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full bg-current`})]},t))})]}),!v.length&&!y.length&&(0,J.jsx)(`span`,{className:`text-xs text-fg-muted`,children:a?.category??`Unresolved component`})]})}function ei({graph:e,version:t,locked:n,canvas:r,connect:i}){let[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(``),l=(0,q.useRef)(null),u=(0,q.useRef)(!1),d=!n&&a?.version===t?a:null,f=()=>{o(null),l.current=null},p=t=>{if(!d){f();return}let n=jr(e,d.from,t);if(n){o({...d,point:void 0}),c(n);return}if(!i(d.from,t,d.version)){f(),c(`Connection was not added. Choose the output again.`);return}c(`Connected ${d.from.node}.${d.from.port} to ${t.node}.${t.port}.`),f()},m=e=>{let t=r.current;if(!t)return;let n=t.getBoundingClientRect();return{x:(e.clientX-n.left)*t.offsetWidth/n.width,y:(e.clientY-n.top)*t.offsetHeight/n.height}};return{pending:d,message:a&&!d?`Connection cancelled because the graph changed.`:s,cancel:()=>{f(),u.current=!0,c(`Connection cancelled.`)},input(e){return{"data-huddle-input-node":e.node,"data-huddle-input-port":e.port,"aria-disabled":n,onClick(){n||p(e)}}},output(e){return{"aria-pressed":d?.from.node===e.node&&d.from.port===e.port,disabled:n,onClick(n){if(u.current&&n.detail!==0){u.current=!1;return}o({from:e,version:t}),c(`Choose an input for ${e.node}.${e.port}. Escape cancels.`)},onPointerDown(r){n||r.button!==0||!r.isPrimary||(r.stopPropagation(),u.current=!1,r.currentTarget.setPointerCapture(r.pointerId),l.current={id:r.pointerId,x:r.clientX,y:r.clientY,moved:!1},o({from:e,version:t}),c(`Choose an input for ${e.node}.${e.port}. Escape cancels.`))},onPointerMove(e){let t=l.current;if(!(!t||t.id!==e.pointerId)){if(!d){f(),u.current=!0;return}!t.moved&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<4||(t.moved=!0,o({...d,point:m(e)}))}},onPointerUp(e){let t=l.current;if(!(!t||t.id!==e.pointerId)){if(l.current=null,t.moved){u.current=!0;let t=document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-huddle-input-node]`);t&&r.current?.contains(t)?p({node:t.dataset.huddleInputNode,port:t.dataset.huddleInputPort}):(f(),c(`Connection cancelled. Drop on an input socket.`))}e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}},onPointerCancel(){f(),u.current=!0,c(`Connection cancelled.`)},onLostPointerCapture(){l.current&&(f(),u.current=!0)}}},problem(t){return d?jr(e,d.from,t):void 0}}}function ti({viewport:e,zoom:t,version:n,locked:r,move:i,select:a}){let o=(0,q.useRef)(!1),s=(0,q.useRef)(null),[c,l]=(0,q.useState)(null),u=(t,n)=>Hr(t.origin,(n.clientX-t.x+(e.current?.scrollLeft??0)-t.scrollX)/t.zoom,(n.clientY-t.y+(e.current?.scrollTop??0)-t.scrollY)/t.zoom),d=()=>{s.current=null,l(null)};return{preview:c,cancel:d,suppressClick:()=>{let e=o.current;return o.current=!1,e},handlers:(c,f)=>({onPointerDown(i){if(i.button!==0||!i.isPrimary||r||!i.currentTarget.contains(i.target)||i.target.closest(`[data-huddle-socket], [data-node-control]`))return;i.stopPropagation(),o.current=!1,(i.currentTarget.querySelector(`[data-node-name]`)??i.currentTarget).focus({preventScroll:!0});let l=i.target.closest(`button`)??i.currentTarget;l.setPointerCapture(i.pointerId),s.current={captured:l,id:c,origin:f,pointer:i.pointerId,x:i.clientX,y:i.clientY,scrollX:e.current?.scrollLeft??0,scrollY:e.current?.scrollTop??0,zoom:t,version:n,moved:!1},i.target.closest(`[data-node-identity]`)||a(c)},onPointerMove(e){let t=s.current;if(!(!t||t.pointer!==e.pointerId)){if(r||n!==t.version){d();return}!t.moved&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<4||(t.moved=!0,o.current=!0,l({id:c,position:u(t,e)}))}},onPointerUp(e){let t=s.current;!t||t.pointer!==e.pointerId||(t.moved&&!r&&i(c,u(t,e),t.version),d(),t.captured.hasPointerCapture(e.pointerId)&&t.captured.releasePointerCapture(e.pointerId))},onPointerCancel:d,onLostPointerCapture:d})}}function ni(e,t,n,r,i){let a=n??{x:t.left,y:t.top,zoom:1},o={left:e.scrollLeft,top:e.scrollTop},s=``,c=()=>[e.clientWidth,e.clientHeight,e.scrollWidth,e.scrollHeight].join(`:`),l=()=>e.clientWidth>0&&e.clientHeight>0,u=()=>{l()&&(s=c(),e.scrollLeft=(a.x-t.left)*a.zoom,e.scrollTop=(a.y-t.top)*a.zoom,o={left:e.scrollLeft,top:e.scrollTop})},d=()=>{if(l()){if(s!==c()){u();return}e.scrollLeft===o.left&&e.scrollTop===o.top||(a={zoom:a.zoom,x:e.scrollLeft/a.zoom+t.left,y:e.scrollTop/a.zoom+t.top},o={left:e.scrollLeft,top:e.scrollTop},r(a))}},f=e=>{a=e,r(a),i(a.zoom),u()};u(),e.addEventListener(`scroll`,d,{passive:!0});let p=new ResizeObserver(u);return p.observe(e),{geometry:e=>{t=e,u()},zoom:e=>{Number.isFinite(e)&&(d(),f({...a,zoom:Math.min(2,Math.max(.001,e))}))},gesture:(e,t,n)=>{if(!Number.isFinite(e)||e<=0)return;d();let r=Math.min(2,Math.max(.001,a.zoom*e));f({zoom:r,x:a.x+t.x/a.zoom-n.x/r,y:a.y+t.y/a.zoom-n.y/r})},fit:t=>{if(!l())return;let n=Math.min(2,Math.max(.001,Math.min((e.clientWidth-64)/Math.max(1,t.right-t.x),(e.clientHeight-64)/Math.max(1,t.bottom-t.y))));f({zoom:n,x:t.x-(e.clientWidth/n-(t.right-t.x))/2,y:t.y-(e.clientHeight/n-(t.bottom-t.y))/2})},dispose:()=>{d(),p.disconnect(),e.removeEventListener(`scroll`,d)}}}function ri(e,t,{left:n,top:r,width:i,height:a}){let[o,s]=(0,q.useState)(null);return(0,q.useLayoutEffect)(()=>{let n=e.current,r,i=()=>{r=void 0;let e=Kr(n,t);s(t=>t?.x===e?.x&&t?.y===e?.y&&t?.right===e?.right&&t?.bottom===e?.bottom?t:e)},a=()=>{r===void 0&&(r=requestAnimationFrame(i))};i(),n.addEventListener(`scroll`,a,{passive:!0});let o=new ResizeObserver(a);return o.observe(n),()=>{n.removeEventListener(`scroll`,a),o.disconnect(),r!==void 0&&cancelAnimationFrame(r)}},[e,t,n,r,i,a]),o}function ii(){let[e,t]=(0,q.useState)({}),n=(e,n)=>{let r=n instanceof Element&&e.contains(n)?n:null,i=r?.closest(`[data-huddle-node]`)?.getAttribute(`data-huddle-node`)??void 0,a=r?.closest(`[data-huddle-edge]`)?.getAttribute(`data-huddle-edge`)??void 0;t(e=>e.node===i&&e.edge===a?e:{node:i,edge:a})};return{focused:e,handlers:{onFocusCapture:e=>n(e.currentTarget,e.target),onBlurCapture:e=>n(e.currentTarget,e.relatedTarget)}}}function ai({document:e,selected:t,onSelect:n,rename:r,changeIcon:i,canRename:a,move:o,version:s,locked:c,undo:l,redo:u,canUndo:d,canRedo:f,onDelete:p,connect:m,graphVersion:h,graphLocked:g,disconnect:_,camera:v,rememberCamera:y,selectedEdge:b,setSelectedEdge:x}){let[S]=(0,q.useState)(v),[C,w]=(0,q.useState)(v?.zoom??1),T=(0,q.useRef)(null),ee=(0,q.useRef)(null),E=ii(),D=ei({graph:e,version:h,locked:g,canvas:ee,connect:m}),O=(0,q.useRef)(null),te=ti({viewport:O,zoom:C,version:s,locked:c,move:o,select:n}),ne=zr(O,T,()=>{te.cancel(),D.pending&&D.cancel()}),k=e.definition.nodes.map((t,n)=>{let r=e.components[t.id];return{node:t,contract:r,position:e.layout?.nodes[t.id]??Vr(n),inputs:Object.keys(r?.inputs??{}),outputs:Object.keys(r?.outputs??{})}}),A=1600/C,j={x:Math.min(0,...k.map(({position:e})=>e.x))-32,y:Math.min(0,...k.map(({position:e})=>e.y))-32},M=j.x-A,N=j.y-A,P=Math.max(640,...k.map(({position:e})=>e.x-M+272+A)),F=Math.max(400,...k.map(({position:e,inputs:t,outputs:n})=>e.y-N+A+90+Math.max(t.length,n.length)*24)),[re]=(0,q.useState)({left:M,top:N,width:P,height:F});(0,q.useLayoutEffect)(()=>{let e=ni(O.current,re,S??{x:re.left+1600,y:re.top+1600,zoom:1},y,w);return T.current=e,()=>{e.dispose(),T.current=null}},[S,re,y]),(0,q.useLayoutEffect)(()=>{T.current?.geometry({left:M,top:N,width:P,height:F})},[M,N,P,F,C]);let ie=ri(O,C,{left:M,top:N,width:P,height:F}),ae=new Map(k.map(e=>[e.node.id,e])),oe=(e,t)=>te.preview?.id===e?te.preview.position:t;return(0,J.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,onKeyDown:e=>{e.key===`Escape`&&D.cancel()},children:[(0,J.jsx)(Br,{locked:c,canUndo:d,canRedo:f,undo:l,redo:u,selected:t,fit:e=>{let n=O.current,r=k.filter(n=>!e||n.node.id===t);if(!n||!r.length)return;let i=Math.min(...r.map(e=>e.position.x)),a=Math.min(...r.map(e=>e.position.y)),o=Math.max(...r.map(e=>e.position.x+240)),s=Math.max(...r.map(e=>e.position.y+90+24*Math.max(e.inputs.length,e.outputs.length)));T.current?.fit({x:i,y:a,right:o,bottom:s})},zoom:C,setZoom:e=>T.current?.zoom(e)}),(b||D.message||D.pending)&&(0,J.jsxs)(`div`,{className:`island-outline absolute left-3 top-3 z-10 flex max-w-[calc(100%-1.5rem)] flex-wrap items-center gap-2 rounded-[var(--ui-surface-radius)] bg-tray px-3 py-2 text-xs text-fg-muted`,children:[e.definition.edges.some(e=>e.id===b)&&(0,J.jsx)(`button`,{type:`button`,disabled:g,className:`rounded px-2 hover:bg-elevated disabled:opacity-50`,onClick:()=>{_(b),x(null)},children:`Disconnect selected`}),(0,J.jsx)(`span`,{role:`status`,children:D.message}),D.pending&&(0,J.jsx)(`button`,{type:`button`,className:`rounded px-2 hover:bg-elevated`,onClick:D.cancel,children:`Cancel connection`})]}),(0,J.jsx)(`div`,{ref:O,className:`no-scrollbar min-h-0 flex-1 cursor-grab overflow-hidden touch-none overscroll-none [overflow-anchor:none]`,"aria-label":`Huddle graph`,"aria-description":`Only nearby nodes and connections are drawn. Use Node list to browse all nodes, then Fit selected to reveal one.`,tabIndex:0,...ne,children:(0,J.jsx)(`div`,{style:{width:P*C,height:F*C},children:(0,J.jsxs)(`div`,{ref:ee,...E.handlers,className:`relative origin-top-left`,style:{width:P,height:F,transform:`scale(${C})`},children:[(0,J.jsx)(Jr,{edges:e.definition.edges,width:P,height:F,wire:D,visible:ie,focused:E.focused.edge,selected:b,select:x,locked:g,disconnect:e=>{_(e),x(null)},socket:(e,t)=>{let n=ae.get(e.node);if(!n)return;let r=oe(e.node,n.position);return{x:r.x-M+(t===`outputs`?225:15),y:r.y-N+60+Math.max(0,n[t].indexOf(e.port))*24}}}),k.map(({node:d,contract:f,position:m,inputs:h,outputs:g})=>{let _=oe(d.id,m),v={x:_.x-M,y:_.y-N};return d.id!==t&&d.id!==E.focused.node&&d.id!==te.preview?.id&&d.id!==D.pending?.from.node&&!Ur(Wr(v,h.length,g.length),ie)?null:(0,J.jsx)($r,{node:d,contract:f,position:m,locked:c,version:s,drag:te,wire:D,onSelect:n,move:o,undo:l,redo:u,onDelete:p,title:e.layout?.labels?.[d.id]??f?.title??d.id,rename:e=>r(d.id,e),changeIcon:e=>i(d.id,e),canRename:a,selected:t===d.id,shown:v},d.id)})]})})})]})}function oi(e,t){if(e instanceof l){let n=e.issues[0];if(!n)return t;if(n.path.includes(`colour`))return`Choose a preset node colour or a six-digit hex colour.`;let r=n.path.map(String).join(`.`);return`${r?`${r}: `:``}${n.message}`}return e instanceof Error?e.message:t}function si(e,t,n){let r=It(e,t,null,void 0,{focused:n,live:!0}),i=bn(e,t);return(0,q.useEffect)(()=>(xn(i),()=>yn(i)),[i]),{path:t,buffer:r,text:(0,q.useSyncExternalStore)((0,q.useCallback)(e=>vn(i,e),[i]),()=>r.model?.getValue()??``),locked:r.status!==`ready`||Qe(r.conflict)}}function ci(e,t){let n=[...new Set(t?.nodes.flatMap(e=>e.source.kind===`local`?[e.source.manifest]:[])??[])];return Dn({queries:n.map(t=>{let n=`.puddle/huddle/${e.huddle_id}/${t.replace(/^\.\//,``)}`;return{queryKey:[`wt-file`,e.id,n],queryFn:({signal:t})=>I(`GET`,`/api/worktrees/${e.id}/file?path=${encodeURIComponent(n)}`,void 0,t),retry:!1}}),combine:e=>{let t={};for(let[r,i]of e.entries()){let e=i.data;if(i.isPending||(t[n[r]]=void 0),e?.content&&!e.binary&&e.size<=ye.fileBytes)try{t[n[r]]=ge.parse(JSON.parse(e.content))}catch{}}return t}})}function li(e,t,n){let r=S(e.huddle_id),{buffer:i,text:a,locked:o}=si(e.id,r,n),s=(0,q.useMemo)(()=>{try{let t=me.parse(JSON.parse(a));if(t.id!==e.huddle_id)throw Error(`The definition id must match this huddle directory.`);return{definition:t}}catch(e){return{error:e instanceof Error?e.message:`Invalid huddle definition`}}},[a,e.huddle_id]),c=ci(e,s.definition);return{path:r,buffer:i,graph:(0,q.useMemo)(()=>{let e=s.definition;if(!e)return;let n=Object.fromEntries(e.nodes.flatMap(e=>{let n=t?.definition.nodes.find(t=>t.id===e.id),r=e.source.kind===`builtin`?be.get(`${e.source.component}@${e.source.version}`):Object.hasOwn(c,e.source.manifest)?c[e.source.manifest]:JSON.stringify(n?.source)===JSON.stringify(e.source)?t?.components[e.id]:void 0;return r?[[e.id,r]]:[]}));return{digest:t?.digest??`0`.repeat(64),definition:e,components:n,...t?.layout?{layout:t.layout}:{},diagnostics:ve(e,new Map(Object.entries(n)))}},[s,t,c]),error:s.error,locked:o,edit:t=>{let n=i.model;if(!n||o)return!1;try{let r=me.parse(JSON.parse(n.getValue())),i=me.parse(t(r));if(i.id!==e.huddle_id)throw Error(`Cannot change the huddle directory id`);return n.pushStackElement(),hn(n,`${JSON.stringify(i,null,2)}\n`),n.pushStackElement(),!0}catch(e){return U.error(oi(e,`Cannot edit this graph`)),!1}}}}function ui(e,t){let r=en(),i=L().data?.protocol,a=r&&n(i,{major:28,minor:3}),o=e=>r&&n(i,{major:28,minor:e===`builtin`?30:D.find(t=>t.template===e).minor});return{supported:a,supportsTemplate:o,...Ke({retry:!1,mutationFn:async n=>{if(!e||!o(n.template))throw Error(`This node template requires a supporting host`);return M.parse(await I(`POST`,`/api/huddle/${e}/definitions/${t.huddle_id}/components`,{...n,project_id:t.project_id,worktree:t.worktree_path}))}})}}var di=[{id:`triggers`,title:`Triggers`,colour:`text-identity-gold`,colourKey:`gold`},{id:`agents`,title:`Agents`,colour:`text-icon-blue`,colourKey:`blue`},{id:`flow`,title:`Logic & data`,colour:`text-icon-violet`,colourKey:`violet`},{id:`readouts`,title:`Readouts`,colour:`text-icon-green`,colourKey:`green`}],fi={manual:`play`,interval:`clock`,calendar:`calendar-days`,date:`calendar-clock`,"calendar-date":`calendar-range`,filetree:`folder-tree`,git:`git-branch`,session:`activity`,"turn-completed":`check-check`,result:`file-output`,file:`file-output`,prompt:`message-square`,review:`check-check`,spawn:`plus`,resume:`play`,restart:`rotate-ccw`,"native-prompt":`message-square`,"native-review":`check-check`,"prompt-spawned":`message-square`,"review-spawned":`check-check`,transform:`braces`,format:`type`,condition:`git-fork`,merge:`merge`,join:`combine`};function pi(e){let t=e.category===`trigger`?`triggers`:e.category===`readout`?`readouts`:e.id.startsWith(`puddle.agent.`)?`agents`:`flow`,n=fi[e.id.split(`.`).at(-1)]??(t===`agents`?`message-square`:t===`triggers`?`radio`:`code`);return{group:t,Icon:Xr[n],appearance:{icon:n,colour:di.find(e=>e.id===t).colourKey}}}function mi({edit:e,profile:t,session:r}){let i=(0,q.useId)(),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(``),l=ae.safeParse(s),u=ui(t,r),d=L().data?.protocol,f=(0,q.useRef)(e);return(0,q.useLayoutEffect)(()=>{f.current=e},[e]),(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-label":`Add node`,children:[(0,J.jsxs)(`div`,{className:`sticky top-0 z-10 flex flex-col gap-3 bg-elevated pb-3`,children:[(0,J.jsx)(G,{htmlFor:`${i}-search`,children:`Find a node`}),(0,J.jsx)(W,{id:`${i}-search`,value:a,onChange:e=>o(e.target.value),placeholder:`Search nodes`})]}),di.map(t=>{let r=[...[...be.values()].filter(e=>e.id!==oe.id||n(d,{major:28,minor:28})).map(t=>({component:t,disabled:!1,add:()=>e(e=>kr(e,{kind:`builtin`,component:t.id,version:t.version},t.id.endsWith(`.manual`)?`run`:t.id.split(`.`).at(-1),pi(t).appearance))})),...u.supported?D.filter(e=>u.supportsTemplate(e.template)).map(e=>({component:e.component,disabled:u.isPending,add:()=>{let t=`${e.template}-${crypto.randomUUID().replaceAll(`-`,``)}`;u.mutate({template:e.template,component:t},{onSuccess:t=>{f.current(n=>({...n,nodes:[...n.nodes,w.parse({id:Or(n.nodes,e.template),source:{kind:`local`,manifest:t.manifest},appearance:pi(e.component).appearance,parameters:Object.fromEntries(Object.entries(t.component.parameters).flatMap(([e,t])=>t.default===void 0?[]:[[e,{kind:`literal`,value:t.default}]]))})]}))}})}})):[]].filter(({component:e})=>pi(e).group===t.id&&`${t.title} ${e.title} ${e.category}`.toLowerCase().includes(a.toLowerCase()));return r.length?(0,J.jsxs)(`section`,{className:`${X} flex flex-col gap-1`,"aria-label":t.title,children:[(0,J.jsx)(`h3`,{className:`px-2 pb-2 text-xs font-medium ${t.colour}`,children:t.title}),r.map(({component:e,disabled:n,add:r})=>{let{Icon:i}=pi(e);return(0,J.jsxs)(`button`,{type:`button`,"aria-label":`Add ${e.title}`,className:`${Q} flex items-center gap-3 text-left`,disabled:n,onClick:r,children:[(0,J.jsx)(i,{className:`size-4 shrink-0 ${t.colour}`}),(0,J.jsx)(`span`,{children:e.title})]},e.id)})]},t.id):null}),u.error&&(0,J.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[u.error.message,`. Inspect the component files before trying again.`]}),(0,J.jsxs)(`section`,{className:`${X} flex flex-col gap-3`,"aria-label":`Custom nodes`,children:[(0,J.jsx)(G,{htmlFor:`${i}-local`,children:`Local component contract`}),(0,J.jsx)(W,{id:`${i}-local`,value:s,onChange:e=>c(e.target.value),placeholder:`nodes/review/node.json`}),(0,J.jsxs)(`button`,{type:`button`,className:`${Q} flex items-center gap-2`,disabled:!l.success,onClick:()=>{l.success&&e(e=>kr(e,{kind:`local`,manifest:l.data},`script`,{icon:`file-code`,colour:`violet`}))},children:[(0,J.jsx)(Rt,{className:`size-4 text-icon-violet`}),` Add local node`]}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Paths are relative to this huddle directory. Node templates create editable source files.`})]})]})}function hi({node:e,component:t,edit:n}){let[r,i]=(0,q.useState)(!1),a=e.appearance??t?.appearance??{icon:null,colour:null},o=a.icon&&Xr[a.icon]||Ut,s=r=>n(n=>({...n,nodes:n.nodes.map(n=>n.id===e.id?{...n,appearance:{...n.appearance??t?.appearance??{icon:null,colour:null},...r}}:n)}));return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsxs)(pn,{open:r,onOpenChange:i,children:[(0,J.jsx)(fn,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`${Q} flex items-center gap-2`,children:[(0,J.jsx)(o,{className:`size-4`}),`Choose node icon`]})}),(0,J.jsx)(dn,{className:`w-80`,children:(0,J.jsx)(Zr,{value:a.icon,onSelect:e=>{s({icon:e}),i(!1)}})})]}),(0,J.jsx)(wt,{label:`Node colour`,value:a.colour,onChange:e=>s({colour:e}),onCustomChange:e=>s({colour:e})})]})}function gi({template:e}){let t=(0,q.useId)(),[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(`null`),[o,s]=(0,q.useState)(``),c=``,l;if(n)try{let t=JSON.parse(i);if(!j(t))throw Error(`Sample input exceeds the supported JSON limits`);c=Cn(e??o,t)}catch(e){l=e instanceof Error?e.message:`Cannot preview this prompt`}let u=`w-full resize-y rounded-md bg-surface p-2 text-sm text-fg outline-none focus-visible:ring-1 focus-visible:ring-ring`;return(0,J.jsx)(on,{onToggle:e=>r(e.currentTarget.open),summary:`Preview prompt`,summaryClassName:`rounded-md px-2 py-1 text-xs hover:bg-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:n&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 pt-2`,children:[(0,J.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Uses standard `,`{{input}}`,` substitutions with sample data. Custom script formatting may differ. Preview data is not saved or sent to an agent.`]}),e===void 0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(G,{htmlFor:`${t}-template`,children:`Sample prompt template`}),(0,J.jsx)(`textarea`,{id:`${t}-template`,value:o,rows:3,maxLength:131072,className:u,onChange:e=>s(e.target.value)}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`This variable has no text default. Enter a sample template to preview; the host resolves the actual variable when starting the huddle.`})]}),(0,J.jsx)(G,{htmlFor:`${t}-input`,children:`Sample input (JSON)`}),(0,J.jsx)(`textarea`,{id:`${t}-input`,value:i,rows:4,maxLength:262144,className:u,onChange:e=>a(e.target.value)}),l?(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,role:`status`,children:l}):(0,J.jsx)(`pre`,{"aria-label":`Rendered prompt`,role:`region`,className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-sm`,children:c||`(Empty prompt)`})]})})}function _i(e){return JSON.stringify(Object.fromEntries(Object.entries(e.variables).flatMap(([e,t])=>t.default===void 0?[]:[[e,t.default]])),null,2)}function vi(e,t){let n=i.shape.variables.parse(JSON.parse(t));return P(e,n),n}function yi(e){return ne.parse(JSON.parse(e))}function bi(e){let[t,n]=(0,q.useState)(!1);return(0,J.jsx)(on,{className:`py-2`,onToggle:e=>n(e.currentTarget.open),summary:`Preview bindings`,summaryClassName:`rounded-md px-2 py-1 text-xs hover:bg-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:t&&(0,J.jsx)(xi,{...e})})}function xi({definition:e,node:t,component:n}){let r=(0,q.useId)(),[i,a]=(0,q.useState)(()=>_i(e)),o,s;try{o=JSON.stringify(he(e,t,n,vi(e,i)),null,2)}catch(e){s=e instanceof Error?e.message:`Cannot resolve these settings`}return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 pt-2 text-xs`,children:[(0,J.jsx)(`p`,{className:`text-fg-muted`,children:`Current draft settings after Apply setting, using the sample variables below. These samples are not saved or used to start a huddle.`}),(0,J.jsx)(G,{htmlFor:r,children:`Sample variables (JSON)`}),(0,J.jsx)(xt,{id:r,rows:5,maxLength:262144,className:`font-mono text-xs`,value:i,spellCheck:!1,onChange:e=>a(e.target.value)}),s?(0,J.jsx)(`p`,{role:`status`,className:`whitespace-pre-wrap break-words text-fg-muted`,children:s}):(0,J.jsx)(`pre`,{role:`region`,"aria-label":`Resolved node settings`,className:`max-h-64 overflow-auto whitespace-pre-wrap break-words`,children:o}),(0,J.jsx)(`p`,{className:`text-fg-muted`,children:`Resource values are requested selectors. Start or Apply checks the host, worktrees, accounts and sessions. Active revision shows the resource bindings captured by a running huddle.`})]})}function Si(e,t,n,r){let i=Ie(n?e.project_id:void 0),a=Me(n?i.data?.project.repo_id:void 0),o=Be(n?e.project_id:void 0),s=n&&Object.values(r?.parameters??{}).some(e=>[`account`,`agent`,`project`].includes(e.editor))?i.data?.project.profile_id:void 0,c=qe(s),l=R({queryKey:[`puddlang-context`,s],queryFn:async({signal:e})=>Ce.parse(await I(`GET`,`/api/puddlang/${s}/context`,void 0,e)),enabled:!!s,retry:!1}),u=l.data?.agents.filter(e=>e.scripted_turns)??[],d=Object.entries(r?.parameters??{}).flatMap(([e,n])=>{let r=t.parameters[e];return n.editor===`agent`&&r?.kind===`literal`&&typeof r.value==`string`?[r.value]:[]}),f=le(t,r)?.id===fe.id,p=t.parameters.worktree,m=p?.kind===`literal`&&typeof p.value==`string`?p.value:void 0;return{projects:i.data?[{value:i.data.project.id,label:i.data.project.name}]:[],providers:u.map(e=>({value:e.id,label:e.id})),accounts:c.data?.filter(e=>e.profile_id===s&&e.logged_in&&u.some(t=>t.id===e.agent_type)&&(!d.length||d.includes(e.agent_type))).map(e=>({value:String(e.id),label:`${e.label} · ${e.agent_type} · #${e.id}`}))??[],worktrees:a.data?.worktrees.map(e=>({value:e.path,label:`${e.branch??`Detached`} · ${e.path}`}))??[],sessions:o.data?.filter(t=>t.project_id===e.project_id&&(f?t.kind!==`huddle`:t.kind===`agent`&&(r?.lifecycle===`resume`?[`exited`,`interrupted`].includes(t.status):![`archived`,`exited`,`interrupted`].includes(t.status)))&&(!m||t.worktree_path===m)).map(e=>({value:e.id,label:`${e.title??e.agent_title??e.agent_type??(e.kind===`terminal`?`Terminal`:`Agent`)} · ${e.id.slice(0,8)} · ${e.worktree_path}`}))??[],error:i.error?.message??a.error?.message??o.error?.message??c.error?.message??l.error?.message}}function Ci({node:e,component:t,definition:n,components:r,edit:i,session:a}){let{variables:o,nodes:s}=n,c=Si(a,e,Object.values(t?.parameters??{}).some(e=>[`worktree`,`session`,`account`,`agent`,`project`].includes(e.editor)),t),l=(t,n)=>i(r=>({...r,nodes:r.nodes.map(r=>{if(r.id!==e.id)return r;let i={...r.parameters};return n?i[t]=n:delete i[t],{...r,parameters:i}})}));return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[Object.entries(t?.parameters??{}).map(([n,i])=>(0,J.jsx)(wi,{name:n,parameter:i,binding:e.parameters[n],variables:o,resources:c,completionChoices:t?.nativeCompletion===n?s.filter(e=>le(e,r[e.id])?.id===k.id).map(e=>({value:e.id,label:e.id})):void 0,set:e=>l(n,e)},`${n}:${JSON.stringify(e.parameters[n])}`)),c.error&&(0,J.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Resource choices: `,c.error]}),!t&&(0,J.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-xs`,children:JSON.stringify(e.parameters,null,2)}),t&&Object.keys(t.parameters).length===0&&(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No settings for this node.`}),t&&Object.keys(t.parameters).length>0&&(0,J.jsx)(bi,{definition:n,node:e,component:t})]})}function wi({name:e,parameter:t,binding:n,variables:r,set:i,resources:a,completionChoices:o}){let s=(0,q.useId)(),[c,l]=(0,q.useState)(n?.kind??`literal`),u=n?.kind===`literal`?n.value:n?void 0:t.default,d=t.schema.type===`string`,[f,p]=(0,q.useState)(n?.kind===`variable`?n.name:u===void 0?``:d?String(u):JSON.stringify(u)),m;try{t.editor===`secret`&&c===`literal`&&E.parse(f),m=ce.parse(c===`variable`?{kind:c,name:f}:{kind:c,value:d?f:JSON.parse(f)})}catch{}let h=o??(t.editor===`worktree`?a.worktrees:t.editor===`session`?a.sessions:t.editor===`account`?a.accounts:t.editor===`project`?a.projects:t.editor===`agent`?a.providers:void 0);return(0,J.jsxs)(`div`,{className:`${X} flex min-w-0 flex-col gap-2`,role:`group`,"aria-label":t.title??e,children:[(0,J.jsxs)(G,{htmlFor:s,children:[t.title??e,t.required?` *`:``]}),(0,J.jsx)(Z,{label:`${e} binding`,value:c,onValueChange:e=>{l(e),p(``)},options:[{value:`literal`,label:`Value`},{value:`variable`,label:`Variable`}]}),c===`variable`?(0,J.jsx)(Z,{id:s,value:f,onValueChange:p,placeholder:`Choose variable`,options:Object.keys(r).map(e=>({value:e,label:e}))}):h?(0,J.jsx)(Z,{id:s,value:f,onValueChange:p,placeholder:`Choose ${o?`completion trigger`:t.editor===`agent`?`provider`:t.editor}`,options:f&&!h.some(e=>e.value===f)?[{value:f,label:`${f} · unavailable`},...h]:h}):t.schema.enum?(0,J.jsx)(Z,{id:s,value:f,onValueChange:p,placeholder:`Choose value`,options:[...f&&!t.schema.enum.some(e=>(d?String(e):JSON.stringify(e))===f)?[{value:f,label:`${f} · not in options`}]:[],...t.schema.enum.map(e=>({value:d?String(e):JSON.stringify(e),label:typeof e==`string`?e||`(empty string)`:JSON.stringify(e)}))]}):t.editor===`prompt`?(0,J.jsx)(`textarea`,{id:s,value:f,rows:5,className:`min-h-24 w-full resize-y rounded-md bg-surface p-2 text-sm text-fg outline-none focus-visible:ring-1 focus-visible:ring-ring`,onChange:e=>p(e.target.value)}):t.schema.type===`boolean`?(0,J.jsx)(Z,{id:s,value:f,onValueChange:p,placeholder:`Choose value`,options:[{value:`true`,label:`True`},{value:`false`,label:`False`}]}):(0,J.jsx)(W,{id:s,type:[`number`,`integer`].includes(String(t.schema.type))?`number`:`text`,min:t.schema.minimum,max:t.schema.maximum,step:t.schema.type===`integer`?1:`any`,value:f,onChange:e=>p(e.target.value),placeholder:d?t.description:`JSON value`}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:!m,onClick:()=>m&&i(m),children:`Apply setting`}),(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:!n,onClick:()=>i(void 0),children:`Clear setting`})]}),t.description&&(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.description}),t.editor===`prompt`&&(0,J.jsxs)(J.Fragment,{children:[c===`variable`&&typeof r[f]?.default==`string`&&(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Preview uses the variable default. Start bindings may supply another template.`}),(0,J.jsx)(gi,{template:c===`literal`?f:typeof r[f]?.default==`string`?r[f].default:void 0})]}),!n&&t.default!==void 0&&(0,J.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Default: `,JSON.stringify(t.default)]}),t.editor===`secret`&&(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Enter a private host reference, never the secret value. Start/Apply checks availability for this huddle and worktree; workers recheck before running.`}),t.editor===`worktree`&&(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Use an explicit worktree root or a worktree variable.`})]})}async function Ti(e,t,n,r){if(pe()||!Bt())throw Error(`Trigger inspection requires a supporting local or SSH connection`);let i=m.parse({target:n});return de(i.target,await I(`POST`,`/api/huddle/${e}/sessions/${t}/triggers`,i,r))}var Ei=e=>new Date(e).toLocaleString();function Di({profile:e,session:t,target:n,stale:r,focused:i,onClose:a}){let o=R({queryKey:[`huddle-triggers`,e,t,n],queryFn:({signal:r})=>Ti(e,t,n,r),enabled:i&&!r,retry:!1,networkMode:`always`,gcTime:0,refetchInterval:e=>i&&!r&&!e.state.error?5e3:!1,refetchIntervalInBackground:!1}),s=o.data;return(0,J.jsx)(H,{open:!0,onOpenChange:e=>{e||a()},children:(0,J.jsxs)(B,{wide:!0,children:[(0,J.jsx)(V,{children:`Huddle triggers`}),(0,J.jsx)(z,{children:`Installed subscriptions and accepted work. Ready means the subscription is installed; it does not prove an external service is reachable. Counts describe retained events, not unseen work at the source.`}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-fg-muted`,children:[(0,J.jsx)(`span`,{children:s?`Observed ${Ei(s.observed_at)}`:`Waiting for observation…`}),(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:r||!i||o.isFetching,onClick:()=>void o.refetch(),children:`Refresh`})]}),r&&(0,J.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:`The runtime changed. Close and reopen Triggers to inspect the current activation.`}),o.error&&(0,J.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:o.error.message}),s&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`text-xs`,children:[s.backlog.queued,` queued · `,s.backlog.running,` running ·`,` `,s.backlog.uncertain_operations,` uncertain operations`,s.queue_limit!==null&&(0,J.jsxs)(`span`,{className:`text-fg-muted`,children:[` · queue limit `,s.queue_limit]})]}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Backlog includes earlier activations. Source totals below cover this activation only.`}),(0,J.jsx)(`ul`,{className:`max-h-[55vh] space-y-5 overflow-auto py-2 text-xs`,"aria-label":`Trigger health and backlog`,children:s.sources.map(e=>(0,J.jsxs)(`li`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4`,children:[(0,J.jsx)(`span`,{children:e.node}),(0,J.jsx)(`span`,{className:`text-fg-muted`,children:e.health})]}),(0,J.jsx)(`p`,{className:`text-fg-muted`,children:e.component}),e.message&&(0,J.jsx)(`p`,{className:`break-words`,children:e.message}),(0,J.jsxs)(`p`,{children:[e.queued,` queued · `,e.running,` running · `,e.admitted,` admitted`]}),e.last_event_at&&(0,J.jsxs)(`p`,{className:`text-fg-muted`,children:[`Last accepted event `,Ei(e.last_event_at)]}),e.next_at&&(0,J.jsxs)(`p`,{className:`text-fg-muted`,children:[`Next scheduled `,Ei(e.next_at)]}),e.missed&&(0,J.jsxs)(`p`,{className:`text-fg-muted`,children:[`Missed policy: `,e.missed,` · `,e.coalesced,` combined occurrences ·`,` `,e.skipped,` skipped occurrences`]}),e.disposition&&(0,J.jsxs)(`p`,{className:`text-fg-muted`,children:[`One-off date: `,e.disposition]})]},e.node))}),!s.sources.length&&(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No triggers in this activation.`})]})]})})}function Oi({enabled:e,target:t,disabled:n,send:r}){return(0,J.jsx)(Y,{icon:sn,label:`Auto-start after reboot`,"aria-pressed":e,disabled:n,title:`Auto-start after reboot: ${e?`on`:`off`}. Recover this run when the host starts; stopped or interrupted huddles stay stopped.`,onClick:()=>void r({action:`auto-start`,input:{target:t,expected:e,enabled:!e}}).catch(()=>{})})}function ki(){let e=en(),t=L();return e&&n(t.data?.protocol,{major:28,minor:12})}function Ai(e,t){if(pe())throw Error(`Huddle history requires a local or SSH connection`);return`/api/huddle/${e}/sessions/${t}/history`}async function ji(e,t,n,r){return Se.parse(await I(`POST`,`${Ai(e,t)}/owners`,a.parse(n),r))}async function Mi(e,t,n,r){let i=o.parse(n);return h(i,await I(`POST`,`${Ai(e,t)}/input`,i,r))}async function Ni(e,t,n,r){let i=y.parse(n);return v(i,await I(`POST`,`${Ai(e,t)}/retained`,i,r))}function Pi(){let e=en(),t=L().data?.protocol;return e&&n(t,{major:28,minor:10})}async function Fi(e,t,n,r){if(pe()||!Bt())throw Error(`Huddle revision review requires a supporting local or SSH connection`);let i=`expected_digest`in n,a=(i?xe:ee).parse(n);return C(a,await I(`POST`,`/api/huddle/${e}/sessions/${t}/${i?`diff`:`revision`}`,a,r))}function Ii(){let e=en(),t=L().data?.protocol;return e&&n(t,{major:28,minor:13})}async function Li(e,t,n,r){if(pe()||!Bt())throw Error(`Retained revision review requires a supporting local or SSH connection`);let i=we.parse(n);return A(i,await I(`POST`,`/api/huddle/${e}/sessions/${t}/revision/retained`,i,r))}function Ri({profile:e,session:t,review:n}){let r=(0,q.useId)(),i=`source`in n,a=i?n.revision:n.active.revision,o=i?n.activation:n.active,[s,c]=(0,q.useState)(()=>(n.entries.find(e=>![`retained`,`unchanged`].includes(e.change))??n.entries[0])?.entry??null),[l,u]=(0,q.useState)(!n.saved),d=R({queryKey:[`huddle-revision-content`,e,t,i?[`retained`,n.owner,a]:n.target,n.saved?.digest,s],queryFn:({signal:r})=>i?Li(e,t,{owner:n.owner,revision:a,entry:s,...n.saved?{expected_digest:n.saved.digest}:{}},r):Fi(e,t,{target:n.target,entry:s,...n.saved?{expected_digest:n.saved.digest}:{}},r),enabled:s!==null,retry:!1,staleTime:1/0,gcTime:0,refetchOnWindowFocus:!1}),f=n.entries.filter(e=>![`unchanged`,`retained`].includes(e.change)),p=l?n.entries:f,m=d.data?.content,h=s?.kind===`component`?`${s.path}.json`:s?.path??``;return(0,J.jsxs)(`div`,{className:`min-w-0 space-y-3`,"aria-label":`Revision review`,children:[(0,J.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,J.jsxs)(`p`,{className:`break-all`,children:[i?`Recorded revision`:`Active revision`,` `,a]}),n.saved&&(0,J.jsxs)(`p`,{className:`break-all`,children:[`Saved revision `,n.saved.digest]}),(0,J.jsx)(`p`,{children:n.saved?`${f.length} changed ${f.length===1?`entry`:`entries`}`:`${p.length} retained entries`}),o&&(0,J.jsx)(on,{summary:`${i?`Recorded`:`Active`} variables and resolved bindings`,children:(0,J.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap break-words p-2`,children:JSON.stringify({worktree:o.worktree,appliedAt:new Date(o.appliedAt).toLocaleString(),variables:o.variables,bindings:o.bindings},null,2)})}),n.saved?.diagnostics.map((e,t)=>(0,J.jsxs)(`p`,{children:[e.severity,`: `,e.message]},t))]}),n.saved&&(0,J.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,"aria-pressed":l,onClick:()=>u(!l),children:l?`Show changes only`:`Show all entries`}),(0,J.jsx)(`div`,{className:`max-h-32 overflow-auto`,"aria-label":`Revision entries`,children:p.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`${Q} flex w-full items-center justify-between gap-3 text-left aria-pressed:bg-explorer-selection`,"aria-pressed":s?.kind===e.entry.kind&&s.path===e.entry.path,onClick:()=>c(e.entry),children:[(0,J.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.entry.kind===`component`?`Contract · `:``,e.entry.path]}),(0,J.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.change})]},`${e.entry.kind}:${e.entry.path}`))}),d.error&&(0,J.jsxs)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:[d.error.message,` Close and inspect again to review current source.`]}),d.isFetching&&(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading retained source…`}),m&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[s?.path,` ·`,` `,n.saved?`${i?`Retained`:`Active`} on the left · Saved on the right`:`Retained source`,n.saved&&(m.before===null?` · Added`:m.after===null?` · Removed`:``)]}),(0,J.jsx)(`div`,{className:`h-72 min-w-0`,"aria-label":`Revision source`,children:n.saved?(0,J.jsx)(Lt,{session:t,originalRef:`huddle:${a}`,originalPath:h,originalContent:m.before??``,modifiedRef:`huddle:${n.saved.digest}`,modifiedPath:h,modifiedContent:m.after??``},`${s?.kind}:${h}`):(0,J.jsx)(Nt,{session:`${t}:${r}`,refName:`huddle:${a}`,path:h,content:m.before??``},`${s?.kind}:${h}`)})]})]})}function zi({profile:e,session:t,request:n,onBack:r,onClose:i}){let a=R({queryKey:[`huddle-retained-revision`,e,t,n],queryFn:({signal:r})=>Li(e,t,n,r),retry:!1,staleTime:1/0,gcTime:0,refetchOnWindowFocus:!1});return(0,J.jsx)(H,{open:!0,onOpenChange:e=>{e||i()},children:(0,J.jsxs)(B,{wide:!0,children:[(0,J.jsx)(V,{children:`Recorded huddle revision`}),(0,J.jsx)(z,{children:`Retained source from this runtime. Recorded settings describe the last saved activation; they do not establish current activity.`}),(0,J.jsx)(`button`,{type:`button`,className:`${Q} w-fit`,onClick:r,children:`Back to history`}),(0,J.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[`Runtime `,n.owner.runtimeId]}),a.isPending&&(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading recorded revision…`}),a.error&&(0,J.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:a.error.message}),a.data&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Read `,new Date(a.data.observed_at).toLocaleString()]}),(0,J.jsx)(Ri,{profile:e,session:t,review:a.data})]})]})})}var Bi=(e,t)=>`/api/huddle/${e}/sessions/${t}`;function Vi(){if(pe()||!Bt())throw Error(`Huddle execution requires a supporting local or SSH connection`)}async function Hi(e,t,n,r=!1,i=!1,a=!1,o=!1,s=!1,c=!1){Vi();let l=new URLSearchParams;return r&&l.set(`include_readout_observation`,`true`),i&&l.set(`include_custom_triggers`,`true`),a&&l.set(`include_recovery`,`true`),o&&l.set(`include_auto_start`,`true`),s&&l.set(`include_trigger_inspection`,`true`),c&&l.set(`include_crash_recovery`,`true`),Te.parse(await I(`GET`,`${Bi(e,t)}/runtime${l.size?`?`+l.toString():``}`,void 0,n))}async function Ui(e,t,n,r){return Vi(),F.parse(await I(`POST`,`${Bi(e,t)}/history`,p.parse(n),r))}async function Wi(e,t,n){Vi();let a={"auto-start":r,recover:u,"readouts/observe":c,"readouts/observe-retained":s,start:i,apply:re,run:_,rearm:m,interrupt:m,stop:m}[n.action].parse(n.input),o=await I(`POST`,`${Bi(e,t)}/${n.action}`,a);return n.action===`readouts/observe`||n.action===`readouts/observe-retained`?{action:`observing`,value:g.parse(o)}:n.action===`run`?{action:`run`,value:f.parse(o),target:n.input.target}:n.action===`stop`?{action:`stop`,value:b.parse(o)}:{action:`state`,value:Te.parse(o)}}async function Gi(e,t,n){let r=i.parse(n.input),a=_.omit({target:!0}).parse(n.event),o=Ee.get(),s=pe(),c=()=>{if(Ee.get()!==o||pe()!==s)throw Error(`The connection changed`)},l=`start`;try{let n=await Wi(e,t,{action:`start`,input:r});if(l=`verify`,c(),n.action!==`state`||n.value.session_id!==t)throw Error(`Start returned another session`);let i=n.value.owner;if(n.value.unresolved||!i?.connected||i.stopping||i.lifecycle!==`armed`||!i.target.activationId)throw Error(`The started graph is not available`);let o=await Fi(e,t,{target:i.target});if(c(),o.active.revision!==r.expected_digest||O(o.active.variables)!==O(r.variables))throw Error(`The active revision or variables changed`);l=`run`;let s=await Wi(e,t,{action:`run`,input:{...a,target:i.target}});return c(),s}catch(e){let t=e instanceof Error?e.message:`Request failed`;throw Error(`${l===`start`?`Start was not confirmed; manual input was not sent.`:l===`verify`?`Start succeeded, but manual input was not sent.`:`Start succeeded; the manual input outcome needs inspection.`} ${t}`,{cause:e})}}var Ki=(e,t)=>[`huddle-runtime`,e,t],qi=(e,t)=>[`huddle-history`,e,t];function Ji(){let e=en(),t=L().data?.protocol;return e&&n(t,{major:28,minor:2})}function Yi(e,t,r){let i=Ji(),a=L().data?.protocol;return R({queryKey:Ki(e,t),queryFn:({signal:r})=>Hi(e,t,r,n(a,{major:28,minor:6}),n(a,{major:28,minor:7}),n(a,{major:28,minor:15}),n(a,{major:28,minor:16}),n(a,{major:28,minor:17}),n(a,{major:28,minor:18})),enabled:i&&!!e&&r,retry:!1,networkMode:`always`,staleTime:0,refetchInterval:e=>r&&!e.state.error?3e3:!1,refetchIntervalInBackground:!1})}var $={pending:!1,review:!1,error:null,executionId:null};function Xi(e,t){let n=Ji(),r=Pi(),i=He(),a=[`huddle-command`,e,t],o=R({queryKey:a,queryFn:()=>$,initialData:$,enabled:!1,staleTime:1/0,gcTime:1/0}).data,s=Ke({mutationKey:a,retry:!1,networkMode:`always`,mutationFn:n=>n.action===`start-and-run`?Gi(e,t,n):Wi(e,t,n),onSuccess:n=>{n.action===`state`&&i.setQueryData(Ki(e,t),n.value),i.setQueryData(a,{...$,executionId:n.action===`run`?n.value.executionId:null})},onError:e=>i.setQueryData(a,{...$,review:!0,error:e.message}),onSettled:()=>{i.invalidateQueries({queryKey:Ki(e,t)}),i.invalidateQueries({queryKey:qi(e,t)}),i.invalidateQueries({queryKey:[`sessions`]})}});return{status:o,async send(t){let o=i.getQueryData(a)??$;if(!n||!e)throw Error(`This host does not support huddle execution`);if(t.action===`start-and-run`&&!r)throw Error(`Start and run requires a host supporting revision review`);if(o.pending||o.review||i.isMutating({mutationKey:a}))throw Error(`Inspect the previous command before another action`);return i.setQueryData(a,{...$,pending:!0}),s.mutateAsync(t)},reviewed(){let e=i.getQueryData(a)??$;e.pending||i.setQueryData(a,{...e,review:!1,error:null})}}}function Zi({operation:e,target:t,owner:n,disabled:r,send:i,inspect:a}){let[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(null);return(0,J.jsxs)(`div`,{className:`space-y-1 py-2`,children:[(0,J.jsx)(`p`,{className:`text-fg-muted`,children:`Check whether the destination received this delivery.`}),(0,J.jsxs)(un,{label:`Delivery observation`,className:`w-fit`,children:[(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:r||o,onClick:()=>{s(!0),l(null),i(n?{action:`readouts/observe-retained`,input:{owner:n,operation_id:e}}:{action:`readouts/observe`,input:{target:t,operation_id:e}}).catch(e=>{l(e instanceof Error?e.message:`Cannot check delivery`)})},children:`Check delivery`}),o&&(0,J.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,disabled:r,onClick:()=>{a().then(()=>{s(!1),l(null)},e=>{l(e instanceof Error?e.message:`Cannot inspect delivery`)})},children:`Refresh delivery`})]}),o&&!c&&(0,J.jsx)(`p`,{role:`status`,className:`text-fg-muted`,children:`Check requested. The delivery result will refresh here; the ended graph stays ended.`}),c&&(0,J.jsx)(`p`,{role:`alert`,className:`text-fg-muted`,children:c})]})}function Qi({agent:e,onOpen:t}){return(0,J.jsxs)(`div`,{className:`space-y-1 py-1`,children:[(0,J.jsx)(nt,{to:`/project/${encodeURIComponent(e.projectId)}/session/${encodeURIComponent(e.sessionId)}`,onClick:t,className:`${Q} inline-block`,children:`Open agent session`}),(0,J.jsxs)(`p`,{className:`break-all text-fg-muted`,children:[`Recorded worktree: `,e.worktree]}),(0,J.jsxs)(on,{className:`text-fg-muted`,summary:`Recorded agent identity`,children:[(0,J.jsxs)(`p`,{className:`break-all`,children:[`Session `,e.sessionId]}),e.runtimeId&&(0,J.jsxs)(`p`,{className:`break-all`,children:[`Runtime `,e.runtimeId]}),(0,J.jsx)(`p`,{children:`The session may now use a different runtime or conversation.`})]})]})}function $i({profile:e,session:t,request:n}){let[r,i]=(0,q.useState)(!1),a=R({queryKey:[`huddle-trigger-input`,e,t,n],queryFn:({signal:r})=>Mi(e,t,n,r),enabled:r,retry:!1,staleTime:1/0,refetchOnWindowFocus:!1}),o=a.data?.event,s=o?JSON.stringify(o.data,null,2):``;return(0,J.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,J.jsx)(`button`,{type:`button`,className:Q,"aria-expanded":r,onClick:()=>i(!r),children:`Trigger input`}),r&&(0,J.jsxs)(`div`,{className:`space-y-1`,"aria-label":`Recorded trigger input`,children:[a.isPending&&(0,J.jsx)(`p`,{className:`text-fg-muted`,children:`Reading recorded input…`}),a.error&&(0,J.jsx)(`p`,{role:`alert`,className:`text-fg-muted`,children:a.error.message}),a.error&&(0,J.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,disabled:a.isFetching,onClick:()=>void a.refetch(),children:`Refresh input`}),o&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{children:[o.source.node,`.`,o.port,` · `,o.source.component,`@`,o.source.version]}),(0,J.jsxs)(`p`,{className:`break-all text-fg-muted`,children:[`Event `,o.id]}),(0,J.jsxs)(`p`,{className:`text-fg-muted`,children:[`Observed `,new Date(o.observedAt).toLocaleString()]}),o.occurredAt&&(0,J.jsxs)(`p`,{className:`text-fg-muted`,children:[`Occurred `,new Date(o.occurredAt).toLocaleString()]}),(0,J.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words`,children:s.length>16384?`${s.slice(0,16384)}\n… Preview truncated`:s})]})]})]})}function ea(e,t,n,r=!1){return R({queryKey:[...qi(e,t),...r?[`retained`]:[],n],queryFn:({signal:i})=>r?Ni(e,t,n,i).then(e=>({...e.history,observedAt:e.observed_at})):Ui(e,t,n,i),retry:!1,networkMode:`always`,staleTime:0,refetchInterval:e=>r||e.state.error?!1:3e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:!r})}function ta({profile:e,session:t,owner:r,initialExecution:i,retained:a=!1,onRecordedRuntimes:o,onClose:s}){let c=Ii(),l=n(L().data?.protocol,{major:28,minor:33}),[u,d]=(0,q.useState)(null),[f,p]=(0,q.useState)([0]),[m,h]=(0,q.useState)(i??null),g=f.at(-1),_=ea(e,t,{owner:r,collection:`executions`,after:g},a),v=_.data?.collection===`executions`?_.data:void 0,y=v?.records.find(({record:e})=>e.id===m)?.record;return u?(0,J.jsx)(zi,{profile:e,session:t,request:{owner:r,...u.digest?{revision:u.digest}:{}},onBack:()=>d(null),onClose:s}):(0,J.jsx)(H,{open:!0,onOpenChange:e=>{e||s()},children:(0,J.jsxs)(B,{wide:!0,children:[(0,J.jsx)(V,{children:`Huddle history`}),(0,J.jsx)(z,{children:a?`Recorded ledger history. Pending, running and unknown records do not establish current activity or completion. Nothing is restarted or reconciled.`:`Execution acceptance and completion are separate. This view reads the connected runtime.`}),(0,J.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[`Runtime `,r.runtimeId]}),a&&_.data?.observedAt&&(0,J.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Read `,new Date(_.data.observedAt).toLocaleString()]}),(0,J.jsxs)(un,{label:`History pages`,className:`w-fit`,children:[o&&(0,J.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,onClick:o,children:`Recorded runtimes`}),c&&(0,J.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,onClick:()=>d({}),children:`Recorded activation`}),(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:_.isFetching,onClick:()=>void _.refetch(),children:`Refresh executions`}),(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:f.length===1||_.isFetching,onClick:()=>p(f.slice(0,-1)),children:`Previous page`}),(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:!v?.records.length||v.next<=g||_.isFetching,onClick:()=>p([...f,v.next]),children:`Next page`})]}),_.error&&(0,J.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:_.error.message}),_.isPending&&(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading executions…`}),v?.records.length===0&&(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No executions on this page.`}),(0,J.jsxs)(`div`,{className:`grid min-h-0 gap-4 sm:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]`,children:[(0,J.jsxs)(`div`,{className:`max-h-80 space-y-1 overflow-auto`,"aria-label":`Executions`,children:[v?.records.map(({record:e})=>(0,J.jsxs)(`button`,{type:`button`,"aria-pressed":m===e.id,onClick:()=>h(e.id),className:`${Q} flex w-full flex-col items-start gap-1 text-left aria-pressed:bg-explorer-selection`,children:[(0,J.jsxs)(`span`,{children:[e.state,` · `,e.id.slice(0,8)]}),(0,J.jsx)(`span`,{className:`text-fg-muted`,children:new Date(e.acceptedAt).toLocaleString()})]},e.id)),(0,J.jsx)(`p`,{className:`pt-2 text-xs text-fg-muted`,children:`Earlier entries appear first. Refresh a page to see changed outcomes.`})]}),m?(0,J.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,J.jsxs)(`p`,{className:`break-all text-xs`,children:[`Execution `,m]}),l&&(0,J.jsx)($i,{profile:e,session:t,request:{owner:r,execution_id:m}},`trigger-input:${m}`),y&&(0,J.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,J.jsxs)(`p`,{children:[y.state,` · revision `,y.revision.slice(0,12)]}),(0,J.jsxs)(`p`,{children:[y.turns,` turns · `,y.spawns,` spawns ·`,` `,y.invocations,` node invocations`]}),y.error&&(0,J.jsx)(`p`,{role:`alert`,children:y.error}),c&&(0,J.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,onClick:()=>d({digest:y.revision}),children:`Execution source`})]}),(0,J.jsx)(na,{profile:e,session:t,owner:r,execution:m,retained:a,onOpenAgent:s},m)]}):(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Choose an execution to inspect nodes and results.`})]})]})})}function na({profile:e,session:t,owner:r,execution:i,retained:a,onOpenAgent:o}){let[s,c]=(0,q.useState)(`invocations`),[l,u]=(0,q.useState)([0]),d=l.at(-1),f=L().data?.protocol,p=n(f,{major:28,minor:a?21:6}),m=ea(e,t,{owner:r,collection:s,after:d,parent:i,...p?{include_readout_observation:!0}:{},...n(f,{major:28,minor:32})?{include_agent:!0}:{}},a),h=Yi(e,t,!a),g=Xi(e,t),_=h.data?.owner,v=p&&!h.error&&_?.connected&&_.readout_observation&&!_.stopping&&!_.failure&&_.target.runtimeId===r.runtimeId&&_.target.incarnation===r.incarnation?_.target:null;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(un,{label:`Execution detail`,className:`w-fit flex-wrap`,children:[[`invocations`,`operations`].map(e=>(0,J.jsx)(`button`,{type:`button`,className:Q,"aria-pressed":s===e,onClick:()=>{c(e),u([0])},children:e===`invocations`?`Nodes`:`Operations`},e)),(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:l.length===1||m.isFetching,onClick:()=>u(l.slice(0,-1)),children:`Previous details`}),(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:!m.data?.records.length||m.data.next<=d||m.isFetching,onClick:()=>u([...l,m.data.next]),children:`Next details`})]}),m.error&&(0,J.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:m.error.message}),g.status.review&&(0,J.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,disabled:m.isFetching||h.isFetching,onClick:()=>{Promise.all([m.refetch(),h.refetch()]).then(([e,t])=>{!e.error&&!t.error&&g.reviewed()})},children:`Inspect previous command`}),m.data?.records.length===0&&(0,J.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`No `,s,` on this page.`]}),(0,J.jsx)(`div`,{className:`max-h-80 space-y-3 overflow-auto`,children:m.data?.records.map(({record:e})=>(0,J.jsxs)(on,{className:`text-xs`,open:!0,summary:`${`node`in e?e.node:`kind`in e?e.kind:e.id} · ${e.state}`,summaryClassName:`py-1 text-fg`,children:[`error`in e&&e.error&&(0,J.jsx)(`p`,{className:`py-1 text-fg-muted`,children:e.error}),`inputs`in e&&(0,J.jsx)(ra,{label:`Inputs`,value:e.inputs}),`agent`in e&&e.agent&&(0,J.jsx)(Qi,{agent:e.agent,onOpen:o}),`result`in e&&e.result!==void 0&&(0,J.jsx)(ra,{label:`Result`,value:e.result}),`consumed`in e&&(0,J.jsx)(`p`,{className:`text-fg-muted`,children:e.consumed?`Dispatch consumed`:`Not dispatched`}),`readout_observation`in e&&e.readout_observation&&(v||a&&p)&&(0,J.jsx)(Zi,{operation:e.id,target:v??void 0,owner:a?r:void 0,disabled:g.status.pending||g.status.review,send:g.send,inspect:async()=>{if(a){let e=await m.refetch();if(e.error)throw e.error;g.reviewed();return}let[e,t]=await Promise.all([m.refetch(),h.refetch()]);if(e.error)throw e.error;if(t.error)throw t.error}})]},e.id))})]})}function ra({label:e,value:t}){let n=JSON.stringify(t,null,2);return(0,J.jsxs)(`div`,{className:`py-1`,children:[(0,J.jsx)(`p`,{className:`text-fg-muted`,children:e}),(0,J.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words`,children:n.length>16384?`${n.slice(0,16384)}\n… Preview truncated`:n})]})}function ia({profile:e,session:t,onClose:n}){let[r,i]=(0,q.useState)([void 0]),[a,o]=(0,q.useState)(null),s=r.at(-1),c=R({queryKey:[`huddle-history-owners`,e,t,s],queryFn:({signal:n})=>ji(e,t,{after:s},n),enabled:!a,retry:!1,networkMode:`always`,refetchOnWindowFocus:!1});return a?(0,J.jsx)(ta,{profile:e,session:t,owner:a,retained:!0,onRecordedRuntimes:()=>o(null),onClose:n},`${a.runtimeId}:${a.incarnation}`):(0,J.jsx)(H,{open:!0,onOpenChange:e=>{e||n()},children:(0,J.jsxs)(B,{children:[(0,J.jsx)(V,{children:`Recorded huddle runtimes`}),(0,J.jsx)(z,{children:`Choose a retained runtime to inspect its ledger. Recorded states do not prove that a runtime is connected or stopped.`}),(0,J.jsxs)(un,{label:`Recorded runtime pages`,className:`w-fit`,children:[(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:c.isFetching,onClick:()=>void c.refetch(),children:`Refresh runtimes`}),(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:c.isFetching||r.length===1,onClick:()=>i(r.slice(0,-1)),children:`Previous runtimes`}),(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:c.isFetching||!c.data?.next,onClick:()=>i([...r,c.data.next]),children:`Older runtimes`})]}),c.error&&(0,J.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:c.error.message}),c.isPending&&(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading recorded runtimes…`}),c.data?.records.length===0&&(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No recorded runtimes on this page.`}),(0,J.jsx)(`div`,{className:`max-h-80 space-y-1 overflow-auto`,"aria-label":`Recorded runtimes`,children:c.data?.records.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`${Q} flex w-full flex-col items-start text-left`,onClick:()=>o(e.owner),children:[(0,J.jsxs)(`span`,{children:[new Date(e.created_at).toLocaleString(),` · `,e.recorded_state]}),(0,J.jsxs)(`span`,{className:`break-all text-fg-muted`,children:[e.owner.runtimeId,` · `,e.build]})]},e.owner.runtimeId))})]})})}function aa(e){let t=bn(e.id,`.puddle/huddle/${e.huddle_id}/`);return(0,q.useSyncExternalStore)(_n,()=>gn().some(e=>e.startsWith(t)&&e.split(`:`).length===2),()=>!1)}function oa({review:e,profile:t,session:n,worktree:r,blocked:i,pending:a,error:o,send:s,onClose:c}){let l=(0,q.useId)(),[u]=(0,q.useState)(()=>crypto.randomUUID()),d=e.document?.definition.nodes.filter(t=>le(t,e.document?.components[t.id])?.id===te.id)??[],[f,p]=(0,q.useState)(d[0]?.id??``),[m,h]=(0,q.useState)(()=>e.kind===`run`?`null`:e.kind===`apply`&&e.comparison?JSON.stringify(e.comparison.active.variables,null,2):e.document?_i(e.document.definition):`{}`),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(`null`),b=e.kind===`run`,x=e.kind===`start-and-run`,S=b?`Run huddle`:x?`Start and run`:e.kind===`start`?`Start saved graph`:`Apply saved graph`,C=async()=>{if(!(i||a)){_(null);try{if(e.kind===`run`){if(!f.trim())throw Error(`Choose a manual trigger`);await s({action:`run`,input:{target:e.target,node:f.trim(),event_id:u,data:yi(m)}})}else{if(!e.document)throw Error(`Inspect saved source before continuing`);if(e.document.diagnostics.some(e=>e.severity===`error`))throw Error(`Fix the saved graph validation errors first`);let t={expected_digest:e.document.digest,variables:vi(e.document.definition,m)};if(e.kind===`start-and-run`){if(!d.some(e=>e.id===f.trim()))throw Error(`Choose a manual trigger from the saved graph`);await s({action:`start-and-run`,input:t,event:{node:f.trim(),event_id:u,data:yi(v)}})}else await s(e.kind===`start`?{action:`start`,input:t}:{action:`apply`,input:{...t,target:e.target}})}}catch(e){_(e instanceof Error?e.message:`Cannot send this command`)}}};return(0,J.jsx)(H,{open:!0,onOpenChange:e=>{!e&&!a&&c()},children:(0,J.jsxs)(B,{showCloseButton:!a,wide:e.kind===`apply`&&!!e.comparison,children:[(0,J.jsx)(V,{children:S}),(0,J.jsx)(z,{children:b?`Send one input to the active graph. Apply saved edits to use them in future runs.`:x?`Start the saved revision with these variables, then send one manual input after confirming the active revision. Starting also arms automatic triggers, including past one-off dates set to fire. If either step is uncertain, inspect the outcome before continuing.`:`Use the saved files and the variables below. Unsaved script edits are not included. Start arms automatic triggers; Apply resets their schedules. Both create a new activation, so past one-off dates set to fire may run again. Manual input is sent separately.`}),!b&&(0,J.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,J.jsx)(`p`,{children:e.document?.definition.name}),(0,J.jsx)(`p`,{className:`break-all`,children:r}),(0,J.jsxs)(`p`,{children:[`Saved revision `,e.document?.digest.slice(0,12)]}),Object.entries(e.document?.definition.variables??{}).map(([e,t])=>(0,J.jsxs)(`p`,{children:[e,t.required?` · required`:` · optional`,t.description?` · ${t.description}`:``]},e))]}),e.kind===`apply`&&e.comparison&&(0,J.jsx)(Ri,{profile:t,session:n,review:e.comparison}),(0,J.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),C()},children:[(b||x)&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(G,{htmlFor:`${l}-node`,children:`Manual trigger`}),(0,J.jsx)(W,{id:`${l}-node`,value:f,disabled:a,list:`${l}-triggers`,onChange:e=>p(e.target.value)}),(0,J.jsx)(`datalist`,{id:`${l}-triggers`,children:d.map(e=>(0,J.jsx)(`option`,{value:e.id},e.id))}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:x?`Choose a manual trigger in this saved revision.`:`Suggestions come from saved source. Enter an existing trigger id if the active graph differs.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(G,{htmlFor:`${l}-json`,children:b?`Input (JSON)`:`Variables (JSON)`}),(0,J.jsx)(`textarea`,{id:`${l}-json`,className:`${st} min-h-28 resize-y p-2 font-mono text-xs`,value:m,disabled:a,spellCheck:!1,onChange:e=>{h(e.target.value),_(null)}})]}),x&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(G,{htmlFor:`${l}-input`,children:`Input (JSON)`}),(0,J.jsx)(`textarea`,{id:`${l}-input`,className:`rounded-[var(--ui-radius)] bg-border/50 text-sm text-fg placeholder:text-fg-muted transition-colors hover:bg-border/80 focus:bg-border/80 host-accent:bg-explorer-hover host-accent:hover:bg-explorer-selection/50 host-accent:focus:bg-explorer-selection/50 disabled:cursor-not-allowed disabled:opacity-50 min-h-28 resize-y p-2 font-mono text-xs`,value:v,disabled:a,spellCheck:!1,onChange:e=>{y(e.target.value),_(null)}})]}),(i||o||g)&&(0,J.jsx)(`p`,{role:`alert`,className:`whitespace-pre-wrap break-words text-xs text-fg-muted`,children:x&&o?o:i??o??g}),(0,J.jsxs)(at,{children:[(0,J.jsx)(bt,{type:`button`,variant:`ghost`,disabled:a,onClick:c,children:`Cancel`}),(0,J.jsx)(bt,{type:`submit`,disabled:a||!!i,children:a?`Sending…`:b?`Send input`:S})]})]})]})})}function sa({sources:e}){return e.length?(0,J.jsxs)(on,{className:`px-4 pb-2 text-xs`,open:e.some(e=>e.health.state===`gap`),summary:`Custom triggers · ${e.filter(e=>e.health.state===`ready`).length} ready`,summaryClassName:`py-1 text-fg-muted`,children:[(0,J.jsx)(`ul`,{className:`space-y-1 py-1`,"aria-label":`Custom trigger health`,children:e.map(e=>(0,J.jsxs)(`li`,{children:[(0,J.jsxs)(`span`,{children:[e.node,` · `,e.health.state]}),`message`in e.health&&(0,J.jsxs)(`span`,{className:`text-fg-muted`,children:[` · `,e.health.message]})]},e.node))}),e.some(e=>e.health.state===`gap`)&&(0,J.jsx)(`p`,{className:`py-1 text-fg-muted`,children:`Inspect the source, then interrupt and resume to reopen its subscription. Other sources may still be running.`})]}):null}function ca({profile:e,session:t,target:n,stale:r,onClose:i}){let a=R({queryKey:[`huddle-active-revision`,e,t,n],queryFn:({signal:r})=>Fi(e,t,{target:n},r),retry:!1,staleTime:1/0,gcTime:0});return(0,J.jsx)(H,{open:!0,onOpenChange:e=>{e||i()},children:(0,J.jsxs)(B,{wide:!0,children:[(0,J.jsx)(V,{children:`Active huddle revision`}),(0,J.jsx)(z,{children:`Retained source and bindings for this activation. Inspecting does not run code or apply saved edits.`}),r&&(0,J.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:`The runtime changed. This view refers to the inspected activation; close and inspect again for the current revision.`}),a.isPending&&(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading active revision…`}),a.error&&(0,J.jsx)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:a.error.message}),a.data&&(0,J.jsx)(Ri,{profile:e,session:t,review:a.data})]})})}function la(e,t){return e.runtimeId===t.runtimeId&&e.incarnation===t.incarnation&&e.generation===t.generation&&e.activationId===t.activationId}var ua=e=>({runtimeId:e.runtimeId,incarnation:e.incarnation});function da({profile:e,session:t,focused:n,locked:r}){let i=Ji(),a=ki(),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(null),u=Pi(),d=Yi(e,t.id,n),f=Ht(e,t),p=Xi(e,t.id),m=He(),[h,g]=(0,q.useState)(null),[_,v]=(0,q.useState)(null),[y,b]=(0,q.useState)(null),[x,S]=(0,q.useState)(!1),C=aa(t),w=d.data?.owner,T=w?.connected?w:null,ee=Xt(e,i&&n&&!w);if(!i)return null;let E=p.status.pending||x,D=!d.data||d.isError||d.data.unresolved||w?.connected===!1,O=!E&&!p.status.review&&!D&&!T?.stopping,ne=O&&!w&&ee.data?.available&&t.status!==`archived`,k=O&&!!T&&t.status!==`archived`,A=async n=>{if(!O)return;if(n!==`run`&&(C||r)){U.warning(`Save or resolve source edits before Start or Apply.`);return}let i=n===`start`||n===`start-and-run`;S(!0);try{let r=await d.refetch({throwOnError:!0}),a=r.data?.owner;if(!r.data||r.data.unresolved||a?.connected===!1)throw Error(`Runtime observation is unavailable`);if(i&&a)throw Error(`An owner already exists; inspect it before starting`);if(!i&&(!a?.connected||a.stopping))throw Error(`No available owner to control`);let o=f.data;if(n!==`run`&&(o=(await f.refetch({throwOnError:!0})).data),n===`start`||n===`start-and-run`){if(!o)throw Error(`Saved source is unavailable`);g({kind:n,document:o})}else if(a?.connected){let r=n===`apply`&&u&&o?await Fi(e,t.id,{target:a.target,expected_digest:o.digest}):void 0;g({kind:n,document:o,target:a.target,...r?{comparison:r}:{}})}}catch(e){U.error(e instanceof Error?e.message:`Cannot inspect huddle`)}finally{S(!1)}},j=async e=>{let t=await p.send(e).catch(e=>{throw U.error(e instanceof Error?e.message:`Huddle command failed`,{description:`The command was not repeated. Inspect the outcome before another action.`}),e});g(null),t.action===`run`&&b({owner:ua(t.target),execution:t.value.executionId})},M=async()=>{if(!E){S(!0);try{let n=(await d.refetch({throwOnError:!0})).data;if(!n)throw Error(`Runtime outcome is still unavailable`);if(n.unresolved||n.owner?.connected===!1){if(!n.recovery)throw Error(`Runtime outcome is still unavailable`);p.reviewed();return}if(n.owner?.connected){let r=ua(n.owner.target),i={owner:r,collection:`executions`,after:0},a=await Ui(e,t.id,i);m.setQueryData([...qi(e,t.id),i],a),p.status.review&&b({owner:r})}else await ee.refetch();p.reviewed(),n.owner?.failure?U.warning(n.owner.failure):!n.owner&&ee.data?.available===!1?U.warning(ee.data.reason):U.info(P,{description:n.owner?.lifetime===`host_session`?`Runtime lifetime is limited to this host session.`:void 0})}catch(e){U.error(e instanceof Error?e.message:`Cannot inspect outcome`)}finally{S(!1)}}},N=p.status.review?`Close this review and inspect the previous outcome before another action.`:null;h&&!N&&!p.status.pending&&(d.isError||!d.data||d.data.unresolved||w?.connected===!1?N=`Runtime observation is unavailable. Close and inspect again.`:(h.kind===`start`||h.kind===`start-and-run`?w:!T||!la(T.target,h.target))?N=`The active graph changed. Close and inspect again.`:h.kind!==`run`&&(C||r)&&(N=`Save or resolve the source edits before continuing.`));let P=E?`Working…`:D?`Runtime unavailable`:T?T.stopping?`Stopping`:T.executing?`Executing`:T.lifecycle===`armed`?`Armed · idle`:T.lifecycle===`interrupted`?`Interrupted`:`Ready to start`:`Stopped`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`pointer-events-auto ml-auto flex max-w-full shrink-0 flex-wrap items-center justify-end gap-3`,"aria-label":`Huddle execution`,children:(0,J.jsxs)(un,{label:`Huddle execution actions`,variant:`island`,className:`max-w-full flex-wrap`,children:[(0,J.jsx)(`span`,{className:`sr-only`,role:`status`,children:P}),d.data?.recovery&&(0,J.jsx)(Y,{icon:sn,label:`Recover after reboot`,title:`Restore the last active graph and retained trigger cursors after a host reboot. Running scripts remain interrupted.`,disabled:E||p.status.review||t.status===`archived`||r,onClick:()=>void j({action:`recover`,input:{owner:d.data.recovery.owner}}).catch(()=>{})}),d.data?.recovery?.crash_recovery&&(0,J.jsx)(Y,{icon:sn,label:`Recover after crash`,title:`Recover a crashed owner after its recorded kernel scope confirms that script descendants have stopped. Queued events resume; interrupted scripts are not replayed.`,disabled:E||p.status.review||t.status===`archived`||r,onClick:()=>void j({action:`recover`,input:{owner:d.data.recovery.owner,after:`owner-crash`}}).catch(()=>{})}),!w&&!d.data?.recovery&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{icon:Ze,label:`Start`,disabled:!ne,onClick:()=>void A(`start`)}),u&&f.data?.definition.nodes.some(e=>le(e,f.data?.components[e.id])?.id===te.id)&&(0,J.jsx)(Y,{icon:Ln,label:`Start and run`,disabled:!ne,onClick:()=>void A(`start-and-run`)})]}),T&&(0,J.jsxs)(J.Fragment,{children:[u&&(0,J.jsx)(Y,{icon:Xn,label:`Active revision`,disabled:E||!T.target.activationId,onClick:()=>v(T.target)}),(0,J.jsx)(Y,{icon:Wt,label:`Apply saved`,disabled:!k,onClick:()=>void A(`apply`)}),T.lifecycle===`armed`?(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(Y,{icon:Ze,label:`Run`,disabled:!O,onClick:()=>void A(`run`)})}):(0,J.jsx)(Y,{icon:Ze,label:`Resume`,disabled:!O,onClick:()=>void j({action:`rearm`,input:{target:T.target}}).catch(()=>{})}),(0,J.jsx)(Y,{icon:et,label:`Stop`,disabled:!O,onClick:()=>void j({action:`stop`,input:{target:T.target}}).catch(()=>{})})]}),(0,J.jsx)(Y,{icon:dr,label:`Interrupt`,disabled:!O||T?.lifecycle!==`armed`,onClick:()=>{T?.lifecycle===`armed`&&j({action:`interrupt`,input:{target:T.target}}).catch(()=>{})}}),(0,J.jsx)(Y,{title:`${P}${T?.failure?` · ${T.failure}`:``}`,icon:rn,label:p.status.review?`Inspect outcome`:`Inspect runtime`,disabled:E||d.isFetching,onClick:()=>void M()}),T?.trigger_inspection&&(0,J.jsx)(Y,{icon:kt,label:`Triggers`,onClick:()=>l(T.target)}),(T||a)&&(0,J.jsx)(Y,{icon:$n,label:`History`,disabled:E,onClick:()=>T?b({owner:ua(T.target)}):s(!0)}),T&&T.auto_start!==void 0&&(0,J.jsx)(Oi,{enabled:T.auto_start,target:T.target,disabled:!O||t.status===`archived`||r,send:j})]})}),T?.custom_triggers&&!T.trigger_inspection&&(0,J.jsx)(sa,{sources:T.custom_triggers}),c&&(0,J.jsx)(Di,{profile:e,session:t.id,target:c,focused:n,stale:D||!T||!la(T.target,c),onClose:()=>l(null)}),h&&(0,J.jsx)(oa,{review:h,profile:e,session:t.id,worktree:t.worktree_path,blocked:N,pending:p.status.pending,error:p.status.error,send:j,onClose:()=>g(null)}),_&&(0,J.jsx)(ca,{profile:e,session:t.id,target:_,stale:D||!T||!la(T.target,_),onClose:()=>v(null)}),o&&(0,J.jsx)(ia,{profile:e,session:t.id,onClose:()=>s(!1)}),y&&(0,J.jsx)(ta,{profile:e,session:t.id,owner:y.owner,initialExecution:y.execution,onRecordedRuntimes:a?()=>{b(null),s(!0)}:void 0,onClose:()=>b(null)})]})}function fa(e,t,r){let i=si(e.id,_e(e.huddle_id)[1],t),a=L().data?.protocol,o=(0,q.useMemo)(()=>{try{return{layout:N.parse(JSON.parse(i.text))}}catch(e){return{error:e instanceof Error?e.message:`Invalid layout`}}},[i.text]),s=i.locked||!o.layout||!n(a,{major:28,minor:4}),c=i.buffer.model?.getAlternativeVersionId()??0,l=(e,t,n)=>{let a=i.buffer.model;if(s||!a||!r?.nodes.some(t=>t.id===e))return!1;if(a.getAlternativeVersionId()!==n)return U.error(`The layout changed while moving this node. Move it again from its current position.`),!1;try{let n=N.parse(JSON.parse(a.getValue())),i=N.parse({...n,nodes:Object.fromEntries(r.nodes.map((r,i)=>[r.id,r.id===e?t:n.nodes[r.id]??Vr(i)]))});return a.pushStackElement(),hn(a,JSON.stringify(i,null,2)+`
2
+ `),a.pushStackElement(),!0}catch(e){return U.error(oi(e,`Cannot move this node`)),!1}},u=!s&&n(a,{major:28,minor:34}),d=(e,t)=>{let n=i.buffer.model;if(!(!u||!n||!r?.nodes.some(t=>t.id===e)))try{let r=N.parse(JSON.parse(n.getValue())),i={...r.labels};t.trim()?i[e]=t.trim():delete i[e];let{labels:a,...o}=r,s=N.parse({...o,...Object.keys(i).length?{labels:i}:{}});n.pushStackElement(),hn(n,JSON.stringify(s,null,2)+`
3
+ `),n.pushStackElement()}catch(e){U.error(oi(e,`Cannot rename this node`))}};return{...i,...o,locked:s,version:c,move:l,rename:d,canRename:u}}function pa({position:e,locked:t,apply:n}){let r=(0,q.useId)(),[i,a]=(0,q.useState)(String(e.x)),[o,s]=(0,q.useState)(String(e.y)),c=[i,o].every(e=>e.trim()!==``&&Number.isFinite(Number(e))&&Math.abs(Number(e))<=1e6);return(0,J.jsxs)(`fieldset`,{className:`my-4 flex flex-col gap-2`,disabled:t,children:[(0,J.jsx)(`legend`,{className:`mb-2 text-xs text-fg-muted`,children:`Position`}),(0,J.jsx)(G,{htmlFor:`${r}-x`,children:`X`}),(0,J.jsx)(W,{id:`${r}-x`,type:`number`,value:i,onChange:e=>a(e.target.value)}),(0,J.jsx)(G,{htmlFor:`${r}-y`,children:`Y`}),(0,J.jsx)(W,{id:`${r}-y`,type:`number`,value:o,onChange:e=>s(e.target.value)}),(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:!c,onClick:()=>n({x:Number(i),y:Number(o)}),children:`Apply position`}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Drag a node or use its arrow keys. Shift moves farther.`})]})}var ma=`---
4
+ name: puddle-huddle
5
+ description: Create or edit Puddle huddle graphs and their local puddlang components in the explicitly selected project worktree.
6
+ ---
7
+
8
+ # Author a Puddle huddle
9
+
10
+ The invocation supplies the profile, project, worktree, huddle id, directory and
11
+ user's task. Work on that huddle's ordinary source files. An authoring session is
12
+ an ordinary coding agent, separate from agents the graph manages. These
13
+ instructions are supplied in the initial prompt; they do not imply that a skill
14
+ has been installed in the account's home directory.
15
+
16
+ ## Source and contracts
17
+
18
+ When available, \`pudl huddle authoring\` lists bundled schemas, wrapper types,
19
+ editable templates and fake fixtures; \`pudl huddle authoring README.md\` explains
20
+ them, and an exact listed path reads one asset as JSON \`{path, content, ...}\`.
21
+ This command is local and takes no host/profile/worktree flags. MCP exposes the
22
+ same kit as \`huddle_authoring\` with optional \`path\`. Assets identify the bundled
23
+ client protocol, not target-host support. Read relevant templates before adapting
24
+ them; validate the resulting saved graph on the selected host. Kit reads neither
25
+ write files nor execute the examples.
26
+
27
+ - Each worktree contains independent \`.puddle/huddle/<32-lowercase-hex-id>/\`
28
+ directories. Keep the directory id and \`huddle.json\` id equal. Names may change;
29
+ do not rename the directory or alter other huddles to perform an ordinary edit.
30
+ - \`huddle.json\` is a format-1 graph. Nodes have stable ids and either
31
+ \`source: {kind: "builtin", component: "puddle.trigger.manual", version: 1}\`
32
+ or \`source: {kind: "local", manifest: "nodes/example/node.json"}\`.
33
+ Edges use \`{id, from: {node, port}, to: {node, port}}\`.
34
+ - \`layout.json\` is optional format-1 presentation data with
35
+ \`nodes: {"node-id": {x: 0, y: 0}}\`. Preserve unrelated positions and appearance.
36
+ - Local components declare \`format: 1\`, a namespaced \`id\`, positive \`version\`,
37
+ \`category\` (\`trigger\`, \`script\`, or \`readout\`), \`title\`, \`inputs\`, \`outputs\`,
38
+ \`parameters\`, \`capabilities\`, and an \`entry\` relative to the component manifest.
39
+ List imported local helpers in \`dependencies\`. Source capture is bounded and
40
+ rejects symlink/path escapes; do not rely on arbitrary installed packages.
41
+ - Ports and parameters each have a \`schema\`. The supported JSON Schema subset
42
+ includes type, enum, properties, required, additionalProperties, items and
43
+ numeric/string/array bounds; unsupported keywords fail validation. Parameter
44
+ \`editor\` values such as \`prompt\`, \`worktree\`, \`session\`, \`account\`, \`agent\`,
45
+ \`project\`, \`number\`, \`boolean\` and \`json\` select inspector controls.
46
+ - Node parameter bindings use \`{kind: "literal", value: ...}\` or
47
+ \`{kind: "variable", name: "declaredVariable"}\`. Inspect the existing graph's
48
+ bindings and component contracts before changing them. File, Git and session
49
+ capabilities require an explicit \`worktree\` parameter with editor \`worktree\`,
50
+ bound to a literal registered worktree or a declared variable. Never substitute
51
+ the process cwd for that binding. Accounts and sessions remain profile scoped.
52
+
53
+ For a script component, the entry exports a HuddleNode declaration:
54
+
55
+ \`\`\`ts
56
+ import { HuddleNode } from 'puddlang/huddle';
57
+
58
+ export default HuddleNode({
59
+ contract: './node.json',
60
+ async run({ inputs, parameters, bindings, puddlang, signal, emit }) {
61
+ // Return values for declared completion outputs. Await emit for event ports.
62
+ return { completed: inputs.value };
63
+ },
64
+ });
65
+ \`\`\`
66
+
67
+ The matching component needs input \`value\` and output \`completed\` (each can use
68
+ \`{schema: {}}\`). Inputs/settings are immutable; observe cancellation. Use the
69
+ scoped \`puddlang\` bridge for managed agent operations. Do not invent runtime ids
70
+ or dispatch duplicate asks to recover an uncertain response.
71
+
72
+ ## Starter graphs
73
+
74
+ On host 28.27+, huddle_create accepts optional template \`manual\` or \`review-loop\`;
75
+ the CLI uses create --request '{"template":"manual"}' with the usual explicit
76
+ name/project/worktree. Both create inactive source and a stopped placement. The kit
77
+ includes matching starters/ directories. Offline copies must replace the zero id
78
+ and placeholder worktree. Review-loop requires choosing coder/reviewer sessions in
79
+ the declared worktree. Preserve its five-round/ten-turn bounds and approval-only
80
+ Result output unless the user explicitly changes the workflow. Do not start it
81
+ or create/select agents merely because its files have been created.
82
+
83
+ ## Copying a saved graph
84
+
85
+ On host 28.26+, \`pudl huddle duplicate HUDDLE_ID --name NAME --project PROJECT_ID
86
+ --worktree ABSOLUTE_WORKTREE --request '{"expected_digest":"REVIEWED_DIGEST"}'\`
87
+ and MCP \`huddle_duplicate\` create a fresh stopped copy in the same worktree.
88
+ Inspect saved source for the digest first. The copy includes bounded UTF-8 docs,
89
+ fixtures and unused components but excludes private state and unsaved drafts.
90
+ Literal resource bindings remain as written; review them before activation and
91
+ supply separate private variable bindings/secret grants. A failed reply requires
92
+ listing saved huddles before any further copy; never automatically retry.
93
+
94
+ ## Data flow
95
+
96
+ The kit includes editable Transform, Format text, Condition, Merge and Join
97
+ components, also offered in Add node on application 28.25. Start with
98
+ \`examples/flow.json\` for a complete branching/fan-out graph. Transform's initial
99
+ script returns its input; edit source and contracts together. Format text uses
100
+ \`{{input}}\` / \`{{input.field}}\`. Condition compares a field path with a JSON value
101
+ and emits exactly one of \`matched\`/\`unmatched\`; missing fields fail. Merge uses
102
+ \`any\` activation and forwards each arrival independently. Join uses \`all\` and
103
+ requires the same execution and activation, so wire shared fan-out branches.
104
+ Never join unrelated triggers or mutually exclusive condition outputs; use Merge
105
+ for alternatives. Existing bounded feedback edges handle cycles separately.
106
+
107
+ ## Agent flow and feedback
108
+
109
+ Use editable templates from **Add node** when available: Prompt/Review agent
110
+ (application 28.3), Spawn agent (28.8), and Prompt/Review spawned agent (28.9).
111
+ Inspect their published contracts and scripts rather than guessing provider APIs.
112
+ Authoring can use ordinary accounts without scripted-turn support; agents invoked
113
+ by graph nodes still require that support and a capable pinned runtime.
114
+
115
+ Two agents may talk to each other. Feedback must be an explicit bounded edge,
116
+ with a condition and finite round limit; removing feedback edges must leave an
117
+ acyclic graph. Keep execution agent, turn, duration and resource limits finite.
118
+ Never build an unbounded automatic reply loop or silently increase budgets.
119
+ Prompt templates substitute \`{{input}}\` and own-property \`{{input.field}}\` values.
120
+
121
+ On 28.9, required inputs with \`scope: "execution"\` retain a single value for the
122
+ same execution/revision; they need all-input activation plus an ordinary required
123
+ input. Wire Spawn's agent handle into the retained \`agent\` input of a spawned-agent
124
+ template, and replies into its ordinary input. Feedback must not target retained
125
+ inputs. This permits reuse across rounds without spawning another agent each time.
126
+
127
+ Custom triggers use HuddleTrigger with an explicit resume policy, durable cursors
128
+ and acknowledged event admission. Custom readouts use HuddleReadout with declared
129
+ idempotency, reconciliation and cancellation support. Treat unknown delivery as
130
+ unknown, not success or permission to repeat a side effect. Consult available
131
+ trigger/readout templates or supplied wrapper types for the exact adapter methods;
132
+ do not implement external integrations from guessed signatures. Keep credentials
133
+ out of graph source and prompts. On application 28.23 with integrationSecrets:1,
134
+ use string parameters with editor secret and no default. Store only logical
135
+ references in settings; adapters use context.secrets?.PARAMETER_NAME. The operator
136
+ configures exact profile/project/huddle/canonical-worktree grants in private
137
+ huddle-integrations.json under Puddle home. Never request credential values in the
138
+ agent prompt or write them into project files. Start/Apply checks availability;
139
+ workers recheck at startup. Keep secrets out of outputs, receipts and cursors too.
140
+ Secret-worker diagnostics are redacted; Interrupt/Resume or Stop/Start refreshes
141
+ running workers after host-side rotation.
142
+
143
+ ## Save, inspect, activate
144
+
145
+ Saving files, successful static validation and completion of this authoring turn
146
+ do not activate a graph. Keep the existing runtime on its captured revision.
147
+ Do not Start, Apply, Run or arm external triggers unless the user separately
148
+ requested execution. Opening or importing a module to validate it executes trusted
149
+ code: prefer data-only contract/graph inspection. If the installed \`pudl --help\`
150
+ advertises huddle source tools, use:
151
+
152
+ \`\`\`text
153
+ pudl huddle list --profile PROFILE --project PROJECT_ID --worktree ABSOLUTE_WORKTREE
154
+ pudl huddle inspect HUDDLE_ID --profile PROFILE --project PROJECT_ID --worktree ABSOLUTE_WORKTREE
155
+ pudl huddle validate HUDDLE_ID --profile PROFILE --project PROJECT_ID --worktree ABSOLUTE_WORKTREE
156
+ \`\`\`
157
+
158
+ Substitute the exact invocation scope. Paths are on the selected host; use \`--host\`
159
+ only when invoking from a different machine over SSH. Validation returns JSON
160
+ \`{valid, digest, diagnostics}\` and exits 1 for error diagnostics. Unreadable or
161
+ invalid root manifests and authority failures are command errors. It does not
162
+ type-check or execute scripts, test integrations or prove live resource admission.
163
+ The equivalent MCP tools are \`huddle_list\`, \`huddle_inspect\`, \`huddle_validate\`
164
+ with \`project_id\`, \`worktree\` and (except list) \`huddle_id\`; use them only if exposed
165
+ on the current connection. Never claim a check ran when it did not. If these tools
166
+ are unavailable, the IDE's refreshed graph shows diagnostics. Review saved source
167
+ and its diff before explicit activation. External changes use normal editor
168
+ conflict handling; do not overwrite someone else's intervening edits.
169
+
170
+ If execution is explicitly requested and the installed tools support it, use
171
+ \`pudl huddle open HUDDLE_ID --project PROJECT_ID --worktree ABSOLUTE_WORKTREE\`
172
+ to obtain the placement's \`session.id\`; this is distinct from the directory id.
173
+ \`create --name NAME\` with the same scope creates a blank inactive graph/placement.
174
+ \`runtime SESSION_ID\` inspects its exact owner. Start/Apply/Run/Interrupt/Resume/Stop,
175
+ history and observe-readout take \`SESSION_ID --request JSON\`, using the existing
176
+ HTTP request body. Include the reviewed \`expected_digest\` and explicit \`variables\`
177
+ for Start/Apply, and the inspected \`owner.target\` verbatim for Apply and later
178
+ mutations. Run additionally requires \`node\`, a stable caller-chosen UUID \`event_id\`
179
+ and \`data\`. History takes \`owner: {runtimeId, incarnation}\`, \`collection\`, \`after\`
180
+ and the required parent for invocations/operations. MCP equivalents take
181
+ \`{session_id, request}\`. Never invent missing targets, silently fetch replacements,
182
+ or repeat a mutation after a lost reply; inspect runtime/history first. Start,
183
+ Apply and Resume can arm triggers immediately. Resume rearms the graph, not an
184
+ agent session or interrupted script. Tool availability does not grant execution
185
+ authority beyond the user's task.
186
+
187
+ On application 28.10+, \`revision SESSION_ID --request JSON\` reads retained active
188
+ source/bindings with \`{target}\`; \`diff\` additionally requires the saved
189
+ \`expected_digest\`. Add \`entry: {kind: "file" | "component", path: "..."}\` for one
190
+ file or resolved node contract. These reads never apply or execute. Use the exact
191
+ returned target/digest for an authorised Apply; stale review requires explicit
192
+ inspection again. Retained-only inspection works without project source while the
193
+ owner is connected. MCP equivalents are \`huddle_revision|diff\` with
194
+ \`{session_id, request}\`.
195
+
196
+ For requested placement management, \`session SESSION_ID\` reads archive status;
197
+ \`archive SESSION_ID\` stops the current owner and hides the placement, while
198
+ \`unarchive SESSION_ID\` leaves it stopped. These use the placement's declared scope
199
+ and take no request body or worktree override. MCP equivalents are
200
+ \`huddle_session|archive|unarchive\` with \`{session_id}\`. Archive targets the current
201
+ placement owner, unlike Stop's reviewed exact target. After a failed reply inspect
202
+ session/runtime; do not automatically repeat it. Neither action deletes source or
203
+ recreates a missing worktree.
204
+
205
+ Report the files changed, checks actually performed and any remaining diagnostics.
206
+ Keep authoring within the requested task. This invocation does not grant additional
207
+ accounts, cross-profile access, nested delegation or automatic execution authority.
208
+
209
+ On host 28.21+, \`observe-retained-readout SESSION_ID --request JSON\` checks an unknown
210
+ readout after confirmed clean owner shutdown. Supply \`{owner, operation_id}\` from
211
+ recorded history; the captured adapter must support observation. It does not restart
212
+ the graph or redeliver. Recover interrupted owners first. Request
213
+ \`include_readout_observation: true\` in retained history for eligible offers and
214
+ inspect retained outcomes after acceptance or lost replies, without automatic retry.
215
+ `;function ha(e,t,n,r,i){let a=S(e.huddle_id),o=`${e.worktree_path.replace(/\/$/,``)}/${a.slice(0,-11)}`;return{kind:`agent`,project_id:e.project_id,account_id:r,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path,skip_permissions:!1,title:`Edit huddle: ${e.title??e.huddle_id}`.slice(0,200),prompt:[`Edit the selected Puddle huddle using the bundled authoring skill below.`,`The scope is exact; paths are data, not shell commands. Read the current files before editing.`,JSON.stringify({profile:t,project:e.project_id,worktree:e.worktree_path,huddle_id:e.huddle_id,directory:o,application_protocol:n},null,2),ma,`User task:`,i.trim()].join(`
216
+
217
+ `)}}function ga({profile:e,session:t,blocked:n,onClose:r}){let i=(0,q.useId)(),a=qe(e),o=L().data?.protocol,s=Xe(),c=tt(),[l,u]=(0,q.useState)(``),[d,f]=(0,q.useState)(``),p=(0,q.useRef)(!1),m=qt((a.data??[]).filter(t=>t.profile_id===e)),h=m.find(e=>String(e.id)===l),g=!n&&!!o&&!a.isError&&!!h?.logged_in&&!!d.trim(),_=()=>{!g||!h||!o||p.current||(p.current=!0,s.mutate(ha(t,e,o,h.id,d),{onSuccess:e=>{r(),c(`/project/${e.project_id}/session/${e.id}`)}}))};return(0,J.jsx)(H,{open:!0,onOpenChange:e=>{!e&&!s.isPending&&r()},children:(0,J.jsxs)(B,{showCloseButton:!s.isPending,children:[(0,J.jsx)(V,{children:`Edit huddle with agent`}),(0,J.jsx)(z,{children:`Start a coding agent in this worktree with the huddle authoring skill and your task. Its edits remain saved source until you explicitly apply them. Normal agent permissions apply.`}),(0,J.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[t.worktree_path.replace(/\/$/,``),`/.puddle/huddle/`,t.huddle_id,`/`]}),(0,J.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(G,{htmlFor:`${i}-account`,children:`Authoring account`}),(0,J.jsxs)(gt,{value:l,onValueChange:u,disabled:s.isPending||p.current,children:[(0,J.jsx)(ft,{id:`${i}-account`,children:(0,J.jsx)(dt,{placeholder:`Choose account`})}),(0,J.jsxs)(pt,{children:[l&&!h&&(0,J.jsxs)(mt,{value:l,disabled:!0,children:[`Unavailable account (`,l,`)`]}),m.map(e=>(0,J.jsxs)(mt,{value:String(e.id),disabled:!e.logged_in,children:[Qt(e),e.logged_in?``:` · logged out`]},e.id))]})]}),(0,J.jsx)(`button`,{type:`button`,className:`self-start text-xs text-fg-muted hover:text-fg disabled:opacity-50`,disabled:a.isFetching||s.isPending||p.current,onClick:()=>void a.refetch(),children:`Refresh accounts`})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(G,{htmlFor:`${i}-task`,children:`Task`}),(0,J.jsx)(`textarea`,{id:`${i}-task`,className:`${st} min-h-28 resize-y p-2 text-sm`,value:d,onChange:e=>f(e.target.value),disabled:s.isPending||p.current,maxLength:16e3})]}),(n||a.isError||l&&!h?.logged_in)&&(0,J.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:n?`Save or resolve source edits before continuing. Archived huddles cannot start an authoring agent.`:a.isError?`Accounts are unavailable. Refresh before continuing.`:`The selected account is unavailable. Choose an available account explicitly.`}),s.error&&(0,J.jsxs)(`p`,{role:`alert`,className:`text-xs text-fg-muted`,children:[s.error.message,` A session may have been created. Close this dialog and check the session list before trying again.`]}),(0,J.jsxs)(at,{children:[(0,J.jsx)(bt,{type:`button`,variant:`ghost`,disabled:s.isPending,onClick:r,children:`Cancel`}),(0,J.jsx)(bt,{type:`submit`,disabled:!g||s.isPending||p.current,children:s.isPending?`Starting…`:`Start authoring agent`})]})]})]})})}function _a({profile:e,session:t,locked:n}){let[r,i]=(0,q.useState)(!1),a=aa(t),o=n||a;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{icon:Ot,label:`Edit with agent`,disabled:o||t.status===`archived`,title:o?`Save or resolve source edits before starting an authoring agent.`:void 0,onClick:()=>i(!0)}),r&&(0,J.jsx)(ga,{profile:e,session:t,blocked:o||t.status===`archived`,onClose:()=>i(!1)})]})}function va(e){let[t]=(0,q.useState)(()=>({profile:ke(),host:se(``)})),[n,r]=(0,q.useState)(()=>Yt($t.get(e))),i=(0,q.useRef)(n),a=(0,q.useCallback)((n,a=!0)=>{if(ke()!==t.profile||se(``)!==t.host)return;let o={...i.current,...n};i.current=o,$t.set(e,o),a&&r(o)},[t,e]),o=(0,q.useCallback)(e=>a({camera:e},!1),[a]);return{view:n,save:a,camera:i.current.camera,rememberCamera:o}}var ya=[[`concurrency`,`Concurrent executions`,1,16],[`maxTurns`,`Agent turns per execution`,1,1e3],[`maxAgents`,`Agent spawns per execution`,1,32],[`maxInvocations`,`Node invocations per execution`,1,4096],[`timeoutMs`,`Execution timeout (milliseconds)`,1e3,864e5],[`maxQueuedEvents`,`Queued events`,1,4096],[`maxDailyExecutions`,`Executions per UTC day`,1,1e4],[`maxDailyAgentSpawns`,`Agent spawns per UTC day`,1,1e3]];function ba({execution:e,edit:t,locked:n}){return(0,J.jsx)(xa,{execution:e,edit:t,locked:n},JSON.stringify(e))}function xa({execution:e,edit:t,locked:r}){let i=(0,q.useId)(),a=n(L().data?.protocol,{major:28,minor:29}),[o,s]=(0,q.useState)(()=>Object.fromEntries(ya.map(([t])=>[t,String(e[t])]))),[c,l]=(0,q.useState)(e.queue),[u,d]=(0,q.useState)(e.cleanup),f=me.shape.execution.safeParse({...e,...Object.fromEntries(ya.map(([e])=>[e,o[e]?.trim()?Number(o[e]):NaN])),queue:c,cleanup:u}),p=ya.some(([t])=>o[t]!==String(e[t]))||c!==e.queue||u!==e.cleanup;return(0,J.jsx)(`form`,{className:`min-w-0`,"aria-label":`Execution settings`,onSubmit:n=>{n.preventDefault(),!(r||!f.success||!p)&&t(t=>{if(JSON.stringify(t.execution)!==JSON.stringify(e))throw Error(`Execution settings changed. Review the current settings first.`);return{...t,execution:f.data}})},children:(0,J.jsxs)(`fieldset`,{disabled:r,className:`flex flex-col gap-4`,children:[(0,J.jsx)(`legend`,{className:`mb-2 text-sm`,children:`Execution settings`}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Update the draft, then Save. Start or Apply activates saved settings for new executions; accepted work keeps its original limits.`}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[ya.map(([e,t,n,r])=>(0,J.jsxs)(`div`,{className:`${X} flex flex-col gap-2`,children:[(0,J.jsx)(G,{htmlFor:`${i}-${e}`,children:t}),(0,J.jsx)(W,{id:`${i}-${e}`,type:`number`,required:!0,min:n,max:r,step:1,value:o[e],onChange:t=>s({...o,[e]:t.target.value})})]},e)),(0,J.jsxs)(`div`,{className:`${X} flex flex-col gap-2`,children:[(0,J.jsx)(G,{htmlFor:`${i}-queue`,children:`Default event admission`}),(0,J.jsx)(Z,{id:`${i}-queue`,value:c,onValueChange:e=>l(e),disabled:r,options:[{value:`queue`,label:`Queue`},...a?[{value:`coalesce`,label:`Coalesce waiting events`},{value:`drop`,label:`Drop while busy`}]:e.queue===`queue`?[]:[{value:e.queue,label:`${e.queue} · unavailable`,disabled:!0}]]}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a?`Triggers inherit this policy unless overridden in their inspector. Coalesce replaces waiting work only; Drop skips busy sources or full queues. Running work is never interrupted.`:`This host supports queued events only.`})]}),(0,J.jsxs)(`div`,{className:`${X} flex flex-col gap-2`,children:[(0,J.jsx)(G,{htmlFor:`${i}-cleanup`,children:`Owned agent cleanup`}),(0,J.jsx)(Z,{id:`${i}-cleanup`,value:u,onValueChange:e=>d(e),disabled:r,options:[{value:`stop-owned`,label:`Stop owned agents`},{value:`retain-owned`,label:`Keep owned agents`}]}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`On interruption, Stop or execution failure. Kept agents remain in ordinary session controls; attached agents keep their own lifecycle.`})]})]}),(0,J.jsx)(`button`,{type:`submit`,className:`${Q} self-start`,disabled:!f.success||!p,children:`Update execution draft`})]})})}function Sa({node:e,edit:t,locked:n}){let r=(0,q.useId)(),[i,a]=(0,q.useState)(String(e.concurrency)),o=Number(i);return(0,J.jsxs)(`fieldset`,{className:`my-4 flex flex-col gap-2`,disabled:n,children:[(0,J.jsx)(G,{htmlFor:r,children:`Concurrent node invocations`}),(0,J.jsx)(W,{id:r,type:`number`,min:1,max:32,step:1,required:!0,value:i,onChange:e=>a(e.target.value)}),(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:!(Number.isInteger(o)&&o>=1&&o<=32)||o===e.concurrency,onClick:()=>t(t=>({...t,nodes:t.nodes.map(t=>t.id===e.id?{...t,concurrency:o}:t)})),children:`Update node draft`})]})}function Ca({node:e,execution:t,edit:r,locked:i}){let a=n(L().data?.protocol,{major:28,minor:29}),o=(0,q.useId)(),s=t.triggerAdmission?.[e],[c,l]=(0,q.useState)(s?.policy??`inherit`),[u,d]=(0,q.useState)(String(s?.maxQueuedEvents??t.maxQueuedEvents)),f=ue.safeParse({policy:c,maxQueuedEvents:Number(u)}),p=c===`inherit`?!!s:f.success&&(f.data.policy!==s?.policy||f.data.maxQueuedEvents!==s?.maxQueuedEvents);return(0,J.jsxs)(`fieldset`,{className:`my-4 flex flex-col gap-2`,disabled:i||!a,children:[(0,J.jsx)(`legend`,{className:`mb-2 text-xs`,children:`Trigger admission`}),(0,J.jsx)(G,{htmlFor:`${o}-policy`,children:`Event policy`}),(0,J.jsx)(Z,{id:`${o}-policy`,value:c,onValueChange:l,disabled:i||!a,options:[{value:`inherit`,label:`Inherit (${t.queue})`},{value:`queue`,label:`Queue`},{value:`coalesce`,label:`Coalesce waiting events`},{value:`drop`,label:`Drop while busy`}]}),c!==`inherit`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(G,{htmlFor:`${o}-limit`,children:`Queued events for this trigger`}),(0,J.jsx)(W,{id:`${o}-limit`,type:`number`,min:1,max:4096,step:1,value:u,onChange:e=>d(e.target.value)})]}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a?`Coalesce keeps the latest waiting input for each port in the same activation. Drop records skipped events while this trigger is busy or its queue is full. Graph queue limits also apply. Running work is never interrupted.`:`Per-trigger admission settings require a newer host.`}),(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:!p||c!==`inherit`&&!f.success,onClick:()=>r(t=>{let{triggerAdmission:n,...r}=t.execution,i={...n};return c===`inherit`?delete i[e]:f.success&&(i[e]=f.data),{...t,execution:{...r,...Object.keys(i).length?{triggerAdmission:i}:{}}}}),children:`Update trigger draft`})]})}function wa({node:e,session:t,profile:n,edit:r,locked:i}){let a=ui(n,t),o=(0,q.useRef)({edit:r,locked:i});if((0,q.useLayoutEffect)(()=>{o.current={edit:r,locked:i}},[r,i]),e.source.kind!==`builtin`)return null;let s={component:e.source.component,version:e.source.version},c=ie(s);return(0,J.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2`,children:[(0,J.jsx)(on,{summary:`View built-in source`,summaryClassName:Q,children:(0,J.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words py-2 text-xs`,"aria-label":`Built-in adapter source`,children:c.files[`run.ts`]})}),(0,J.jsx)(`button`,{type:`button`,className:Q,disabled:i||a.isPending||!a.supportsTemplate(`builtin`),onClick:()=>a.mutate({template:`builtin`,builtin:s,component:`copy-${crypto.randomUUID().replaceAll(`-`,``)}`},{onSuccess:t=>{o.current.locked||o.current.edit(n=>({...n,nodes:n.nodes.map(n=>n.id===e.id&&n.source.kind===`builtin`&&n.source.component===s.component&&n.source.version===s.version?{...n,source:{kind:`local`,manifest:t.manifest}}:n)}))}}),children:a.isPending?`Creating local copy…`:`Make local copy`}),(0,J.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Creates editable project files and changes this node's draft. Save and Apply to use them.`,c.component.hostTrigger&&` The host keeps observing the source; this script adapts each accepted event.`]}),a.error&&(0,J.jsxs)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:[a.error.message,`. Inspect the component files before trying again.`]})]})}function Ta({profile:e,session:t}){let[r,i]=(0,q.useState)(!1),a=n(L().data?.protocol,{major:28,minor:31});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{icon:Dt,label:`Validate`,disabled:!a,title:a?`Check saved modules and optional contract fixtures`:`Module validation requires a newer host`,onClick:()=>i(!0)}),r&&(0,J.jsx)(Ea,{profile:e,session:t,onClose:()=>i(!1)})]})}function Ea({profile:e,session:t,onClose:n}){let r=(0,q.useId)(),[i,a]=(0,q.useState)(``),o=Ke({retry:!1,mutationFn:async()=>{let n=d.safeParse({project_id:t.project_id,worktree:t.worktree_path,huddle_id:t.huddle_id,fixtures:i.split(`
218
+ `).map(e=>e.trim()).filter(Boolean)});if(!n.success)throw Error(`Use at most 16 relative fixture paths inside this huddle directory.`);let{huddle_id:r,...a}=n.data;return x.parse(await I(`POST`,`/api/huddle/${e}/definitions/${r}/validate`,a))}}),s=o.data;return(0,J.jsx)(H,{open:!0,onOpenChange:e=>{e||n()},children:(0,J.jsxs)(B,{wide:!0,children:[(0,J.jsx)(V,{children:`Validate saved huddle`}),(0,J.jsx)(z,{children:`Check graph wiring, module declarations and optional sample values. Uses saved files; save your edits first to include them. This check does not run scripts or contact agents.`}),(0,J.jsxs)(`form`,{className:`flex flex-col gap-2`,onSubmit:e=>{e.preventDefault(),o.mutate()},children:[(0,J.jsx)(G,{htmlFor:r,children:`Contract fixture paths (optional)`}),(0,J.jsx)(`textarea`,{id:r,className:`${st} min-h-20 resize-y p-2 text-sm`,value:i,disabled:o.isPending,onChange:e=>{a(e.target.value),o.reset()}}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`One JSON file per line, relative to this huddle's directory.`}),(0,J.jsx)(`button`,{className:`${Q} self-start`,type:`submit`,disabled:o.isPending,children:o.isPending?`Checking…`:`Check saved source`})]}),o.error&&(0,J.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:o.error.message}),s&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,role:`status`,children:[(0,J.jsx)(`p`,{children:s.valid?`Saved source checks passed.`:`Saved source needs attention.`}),(0,J.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Checked revision `,s.digest.slice(0,12),`. Recheck after source changes.`]}),s.checks?.fixtures.map(e=>(0,J.jsxs)(`p`,{className:`text-xs`,children:[e.path,`: `,e.cases,` sample cases`]},e.path)),(0,J.jsx)(`ul`,{className:`max-h-64 overflow-auto text-xs`,children:s.diagnostics.map((e,t)=>(0,J.jsxs)(`li`,{className:`py-1`,children:[e.node&&`${e.node}: `,e.message,` `,(0,J.jsx)(`span`,{className:`text-fg-muted`,children:e.path})]},t))}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Samples are checked against contracts, not executed. Runtime value checks and live resource admission still apply.`})]})]})})}function Da({session:e,focused:t=!0}){let n=en(),r=mn(`huddle`,[Oe(),e.id,e.project_id,e.huddle_id]);return!n||!e.huddle_id?(0,J.jsx)(`p`,{className:`p-4 text-sm text-fg-muted`,children:`Use a current desktop or browser over a local or SSH connection to open this huddle.`}):(0,J.jsx)(Oa,{viewKey:r,session:e,focused:t},r)}function Oa({session:e,focused:t,viewKey:n}){let r=Oe()??void 0,i=Ht(r,e),a=li(e,i.data,t),o=fa(e,t,a.graph?.definition),{buffer:s,graph:c,edit:l}=a,u=va(n),d=c?.definition.nodes.some(e=>e.id===u.view.selectedNode)?u.view.selectedNode:null,f=e=>{u.save({selectedNode:e}),h(`node`)},p=u.view.mode===`list`,[m,h]=(0,q.useState)(d?`node`:null),g=e=>h(t=>t===e?null:e),{openFile:_}=$e(),v=`.puddle/huddle/${e.huddle_id}/`,y=c?.definition.nodes.find(e=>e.id===d),b=y&&c?.components[y.id],x=y&&(o.layout?.nodes[y.id]??Vr(c.definition.nodes.indexOf(y))),S=y?.source.kind===`local`?y.source.manifest:null,C=t=>_(e.id,v+t.split(`/`).filter(e=>e!==`.`).join(`/`)),w=`rounded-md px-2 py-1 text-xs text-fg hover:bg-elevated disabled:opacity-50`,T=(0,q.useRef)(null);return(0,q.useLayoutEffect)(()=>{let e=T.current,t=()=>e.parentElement?.style.setProperty(`--huddle-toolbar-bottom`,`${e.offsetHeight+24}px`);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,J.jsxs)(`section`,{className:`relative flex size-full min-h-0 min-w-0 flex-col overflow-hidden text-fg`,"aria-label":`Huddle editor`,children:[(0,J.jsxs)(`div`,{ref:T,className:`pointer-events-none absolute inset-x-3 top-3 z-30 flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(un,{label:`Huddle actions`,variant:`island`,className:`pointer-events-auto max-w-full flex-wrap`,children:[r&&(0,J.jsx)(_a,{profile:r,session:e,locked:a.locked||!!s.conflict||!!o.buffer.conflict},`${r}:${e.id}`),(0,J.jsx)(Y,{icon:an,label:`Add node`,disabled:a.locked||!c,"aria-pressed":m===`add`,onClick:()=>g(`add`)}),(0,J.jsx)(Y,{icon:jn,label:`Connections`,disabled:a.locked||!c,"aria-pressed":m===`connections`,onClick:()=>g(`connections`)}),(0,J.jsx)(Y,{icon:ln,label:`Settings`,disabled:a.locked||!c,"aria-pressed":m===`settings`,onClick:()=>g(`settings`)}),(0,J.jsx)(Y,{icon:Zt,label:`Undo`,disabled:a.locked||!s.model?.canUndo(),onClick:()=>void s.model?.undo()}),(0,J.jsx)(Y,{icon:mr,label:`Redo`,disabled:a.locked||!s.model?.canRedo(),onClick:()=>void s.model?.redo()}),(0,J.jsx)(Y,{icon:cn,label:`Save`,disabled:a.locked||!s.dirty&&!o.buffer.dirty,onClick:()=>{Promise.all([s.save(),o.buffer.save()]).then(async()=>{let e=await i.refetch();e.data?.diagnostics.length&&U.warning(`Huddle needs attention`,{description:e.data.diagnostics.map(e=>`${e.node??e.path}: ${e.message}`).join(`
219
+ `)})}).catch(e=>U.error(e instanceof Error?e.message:`Could not save huddle`))}}),(0,J.jsx)(Y,{icon:p?Er:zt,label:p?`Graph`:`Node list`,"aria-pressed":p,onClick:()=>u.save({mode:p?`graph`:`list`})}),(0,J.jsx)(Y,{icon:Hn,label:`Open definition`,onClick:()=>C(`huddle.json`)}),r&&(0,J.jsx)(Ta,{profile:r,session:e},`validation:${r}:${e.id}`),(0,J.jsx)(Y,{icon:ur,label:`Open layout`,onClick:()=>C(`layout.json`)}),(0,J.jsx)(Y,{icon:At,label:`Refresh`,disabled:i.isFetching,onClick:()=>{i.refetch()}})]}),r&&(0,J.jsx)(da,{profile:r,session:e,focused:t,locked:a.locked||!!s.conflict},`${r}:${e.id}`)]}),(s.peerBadge||o.buffer.peerBadge||s.conflict?.phase===`unresolved`||o.buffer.conflict?.phase===`unresolved`||o.buffer.status===`error`||o.buffer.status===`ready`&&o.error||i.error)&&(0,J.jsxs)(`div`,{className:`island-outline absolute left-3 top-[var(--huddle-toolbar-bottom,4rem)] z-20 flex max-w-[calc(100%-1.5rem)] flex-col gap-2 rounded-[var(--ui-surface-radius)] bg-elevated py-3`,children:[s.peerBadge&&(0,J.jsx)(`p`,{className:`px-4 text-xs text-fg-muted`,children:`This definition has changes in another window.`}),s.conflict?.phase===`unresolved`&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-4 text-xs text-fg-muted`,children:[`The definition changed on disk. Your edits are intact.`,(0,J.jsx)(`button`,{type:`button`,className:w,onClick:s.compare,children:`Compare`})]}),o.buffer.peerBadge&&(0,J.jsx)(`p`,{className:`px-4 text-xs text-fg-muted`,children:`This layout has changes in another window.`}),o.buffer.conflict?.phase===`unresolved`&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-4 text-xs text-fg-muted`,children:[`The layout changed on disk. Your edits are intact.`,(0,J.jsx)(`button`,{type:`button`,className:w,onClick:o.buffer.compare,children:`Compare layout`})]}),o.buffer.status===`error`||o.buffer.status===`ready`&&o.error?(0,J.jsxs)(`p`,{className:`px-4 text-xs text-fg-muted`,children:[`Layout:`,` `,o.buffer.errorMessage??`Fix layout.json in its source editor to arrange nodes.`]}):null,i.error&&(0,J.jsxs)(`p`,{className:`px-4 text-xs text-fg-muted`,children:[`Saved component inspection: `,i.error.message]})]}),(0,J.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col ${s.conflict?.phase&&s.conflict.phase!==`unresolved`||o.buffer.conflict?.phase&&o.buffer.conflict.phase!==`unresolved`?`pt-[var(--huddle-toolbar-bottom,4rem)]`:``}`,children:s.conflict&&s.conflict.phase!==`unresolved`?(0,J.jsx)(Ft,{session:e.id,path:a.path,buffer:s,focused:t}):o.buffer.conflict&&o.buffer.conflict.phase!==`unresolved`?(0,J.jsx)(Ft,{session:e.id,path:o.path,buffer:o.buffer,focused:t}):s.status===`error`||s.status===`binary`||s.status===`too-large`?(0,J.jsx)(`p`,{className:`p-4 text-sm text-fg-muted`,role:`alert`,children:s.errorMessage??`This definition cannot be edited as text.`}):s.status===`loading`?(0,J.jsx)(`p`,{className:`p-4 text-sm text-fg-muted`,children:`Loading huddle…`}):c?(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 overflow-hidden`,children:[m&&m!==`node`&&(0,J.jsx)(Dr,{title:m===`add`?`Add node`:m===`connections`?`Connections`:`Settings`,onClose:()=>h(null),children:(0,J.jsxs)(`div`,{children:[m===`add`&&(0,J.jsx)(mi,{edit:l,profile:r,session:e}),m===`connections`&&(0,J.jsx)(Fr,{graph:c,edit:l}),m===`settings`&&(0,J.jsx)(ba,{execution:c.definition.execution,edit:l,locked:a.locked||!!s.conflict})]})},m),c.definition.nodes.length===0?(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-4`,children:[(0,J.jsx)(Ut,{className:`size-16 text-fg-muted/40`}),(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`This huddle is empty.`}),(0,J.jsx)(`button`,{type:`button`,className:w,onClick:()=>C(`huddle.json`),children:`Edit definition`})]}):(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[p?(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-auto p-4`,children:[c.definition.nodes.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`${w} flex w-full gap-3 text-left`,"aria-pressed":d===e.id,onClick:()=>f(e.id),children:[(0,J.jsx)(`span`,{children:o.layout?.labels?.[e.id]??c.components[e.id]?.title??e.id}),(0,J.jsx)(`span`,{className:`text-fg-muted`,children:e.id})]},e.id)),(0,J.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:`Connections`}),c.definition.edges.map(e=>(0,J.jsxs)(`p`,{className:`py-1 text-xs`,children:[e.from.node,`.`,e.from.port,` → `,e.to.node,`.`,e.to.port,e.feedback?` · up to ${e.feedback.maxRounds} rounds`:``]},e.id))]}):(0,J.jsx)(ai,{canRename:o.canRename,rename:o.rename,changeIcon:(e,t)=>l(n=>({...n,nodes:n.nodes.map(n=>n.id===e?{...n,appearance:{...n.appearance??c.components[e]?.appearance??{colour:null},icon:t}}:n)})),camera:u.camera,rememberCamera:u.rememberCamera,selectedEdge:c.definition.edges.some(e=>e.id===u.view.selectedEdge)?u.view.selectedEdge:null,setSelectedEdge:e=>u.save({selectedEdge:e}),document:{...c,layout:o.layout??c.layout},selected:d,onSelect:f,move:o.move,version:o.version,locked:o.locked||a.locked,undo:()=>{o.locked||o.buffer.model?.undo()},redo:()=>{o.locked||o.buffer.model?.redo()},canUndo:!!o.buffer.model?.canUndo(),canRedo:!!o.buffer.model?.canRedo(),graphVersion:s.model?.getAlternativeVersionId()??0,graphLocked:a.locked,disconnect:e=>l(t=>({...t,edges:t.edges.filter(t=>t.id!==e)})),connect:(e,t,n)=>l(r=>{if(s.model?.getAlternativeVersionId()!==n)throw Error(`The graph changed while connecting. Choose the output again.`);return Mr({...c,definition:r},e,t)}),onDelete:e=>l(t=>Ar(t,e))}),y&&m===`node`&&(0,J.jsx)(Dr,{title:o.layout?.labels?.[y.id]??b?.title??y.id,label:`Node inspector`,onClose:()=>h(null),children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsxs)(`div`,{className:`island-outline rounded-[var(--ui-surface-radius)] bg-surface p-3`,children:[(0,J.jsxs)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:[y.id,` · `,b?.category??`Unresolved`]}),b?.description&&(0,J.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:b.description}),b&&y.source.kind===`builtin`&&(0,J.jsx)(wa,{node:y,session:e,profile:r,edit:l,locked:a.locked||!!s.conflict},`builtin-source:${y.id}`),b&&Object.values(b.inputs).some(e=>e.scope===`execution`)&&(0,J.jsxs)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:[`Retained inputs:`,` `,Object.entries(b.inputs).filter(([,e])=>e.scope===`execution`).map(([e])=>e).join(`, `),`. Connect each once; its value is reused for this execution, including feedback rounds.`]}),S&&(0,J.jsx)(`button`,{type:`button`,className:w,onClick:()=>C(S),children:`Open contract`}),S&&b?.entry&&(0,J.jsx)(`button`,{type:`button`,className:w,onClick:()=>C(`${S.slice(0,S.lastIndexOf(`/`)+1)}${b.entry}`),children:`Open script`})]}),(0,J.jsx)(Ir,{value:o.layout?.labels?.[y.id]??``,fallback:b?.title??y.id,disabled:!o.canRename,rename:e=>o.rename(y.id,e)},`name:${y.id}`),(0,J.jsx)(`p`,{className:`px-1 text-xs text-fg-muted`,children:`Parameters`}),(0,J.jsx)(Ci,{node:y,component:b,definition:c.definition,components:c.components,session:e,edit:l},y.id),(0,J.jsx)(`div`,{className:`island-outline rounded-[var(--ui-surface-radius)] bg-surface p-3`,children:(0,J.jsx)(hi,{node:y,component:b,edit:l})}),b?.category===`trigger`&&(0,J.jsx)(`div`,{className:`island-outline rounded-[var(--ui-surface-radius)] bg-surface p-3`,children:(0,J.jsx)(Ca,{node:y.id,execution:c.definition.execution,edit:l,locked:a.locked||!!s.conflict},`${y.id}:${JSON.stringify(c.definition.execution)}`)}),(0,J.jsx)(`div`,{className:`island-outline rounded-[var(--ui-surface-radius)] bg-surface p-3`,children:(0,J.jsx)(Sa,{node:y,edit:l,locked:a.locked||!!s.conflict},`${y.id}:${y.concurrency}`)}),x&&(0,J.jsx)(`div`,{className:`island-outline rounded-[var(--ui-surface-radius)] bg-surface p-3`,children:(0,J.jsx)(pa,{position:x,locked:o.locked||a.locked,apply:e=>o.move(y.id,e,o.version)},`${y.id}:${x.x}:${x.y}`)}),(0,J.jsx)(`button`,{type:`button`,className:`${w} mt-4`,onClick:()=>l(e=>Ar(e,y.id)),children:`Delete node`})]})},y.id)]})]})}):(0,J.jsxs)(`div`,{className:`overflow-auto p-4 text-sm text-fg-muted`,children:[(0,J.jsx)(`p`,{children:`Fix the definition in its source editor to continue editing the graph.`}),(0,J.jsx)(`pre`,{className:`whitespace-pre-wrap text-xs`,children:a.error})]})}),(s.restoredNotice||o.buffer.restoredNotice)&&(0,J.jsxs)(`div`,{className:`pointer-events-none absolute bottom-3 right-3 z-20 max-w-[calc(100%-1.5rem)] rounded-[var(--ui-radius)] bg-base/90 px-2 py-1 text-right text-xs text-fg-muted`,role:`status`,children:[s.restoredNotice&&(0,J.jsx)(`p`,{children:`Restored unsaved changes`}),o.buffer.restoredNotice&&(0,J.jsx)(`p`,{children:`Restored unsaved layout changes`})]})]})}export{Da as HuddlePane};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-4785ZuI8.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/react-dom-cJyBB_A4.js","assets/protocol-support-iXloAH0N.js","assets/local-store-Dy1Cd8sn.js","assets/client-settings-BdKglwtW.js","assets/theme-swfNLod9.js","assets/jsx-runtime-By8HlURe.js","assets/preload-helper-Czpn1I53.js","assets/profile-store-D4lZiXgL.js","assets/forward-link-qOyuWj08.js","assets/api-CrP4jl9e.js","assets/auth-1SSLu56b.js","assets/queries-BSkHGZG8.js","assets/motion-Bd_MB9cH.js","assets/utils-B6KiDbIe.js","assets/dist-BOS6OKSE.js","assets/FindWidget-ET5pwkkB.js","assets/x-CbfJFzGo.js","assets/createLucideIcon-DyMAgLa3.js","assets/whole-word-2m2pmAFT.js","assets/chevron-down--sjpQEHH.js","assets/selection-actions-2wBZeOyh.js","assets/index-TMXTPMjv.js","assets/index-BB_BPKbu.css","assets/button-D-qeQvl5.js","assets/copy-CGsu8426.js","assets/ws-CDXOuBYB.js","assets/code-DRWf9a5s.js","assets/hotkeys-nP8gYtE7.js","assets/errors-CviT-mvB.js","assets/preferences-CvSHA-AA.js","assets/file-links-CgOYgoMC.js","assets/render-rich-content-fo4uQVWR.js","assets/math-delimiters-BCnTi7Ii.js","assets/render-rich-content-BoTeqQfi.css","assets/Terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{t as i}from"./utils-B6KiDbIe.js";import"./dist-NuV8HBEc.js";import{n as a}from"./chevron-right-DUkOv15w.js";import{t as o}from"./createLucideIcon-DyMAgLa3.js";function s(e){return e.trim().slice(0,5).toUpperCase()}function c(e){return e.abbrev??s(e.name)}function l(e){return e.trim().toUpperCase().slice(0,5)}var u=o(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),d=e(t(),1),f=n();function p({id:e,value:t,onValueChange:n,onChoose:r,hints:o,placeholder:s,className:c,hintsClassName:l,autoFocus:u}){let[p,m]=(0,d.useState)(!1),[h,g]=(0,d.useState)(0),_=e=>{n(e.value),r?.(e),m(!1)};return(0,f.jsxs)(`div`,{className:`relative`,children:[(0,f.jsx)(a,{id:e,value:t,onChange:e=>{n(e.target.value),m(!0),g(0)},onFocus:()=>m(!0),onBlur:()=>m(!1),onKeyDown:e=>{if(!(!p||o.length===0))if(e.key===`ArrowDown`)e.preventDefault(),g(e=>(e+1)%o.length);else if(e.key===`ArrowUp`)e.preventDefault(),g(e=>(e-1+o.length)%o.length);else if(e.key===`Enter`||e.key===`Tab`){let t=o[h]??o[0];t&&(e.preventDefault(),_(t))}else e.key===`Escape`&&(e.stopPropagation(),m(!1))},placeholder:s,className:c,autoComplete:`off`,spellCheck:!1,autoFocus:u}),p&&o.length>0&&(0,f.jsx)(`ul`,{className:i(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,l??`w-full`),children:o.map((e,t)=>(0,f.jsx)(`li`,{children:(0,f.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),_(e)},onMouseEnter:()=>g(t),className:i(`relative flex cursor-pointer select-none items-center gap-2 rounded-[var(--ui-menu-radius)] px-2 py-1.5 text-sm text-fg outline-none transition-colors`,`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,`w-full text-xs`),"data-selected":t===h,children:[(0,f.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,f.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}var m=(0,d.lazy)(()=>r(()=>import(`./Terminal-4785ZuI8.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]))),h=null;async function g(){h=(await r(()=>import(`./Terminal-4785ZuI8.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]))).Terminal}function _(e){return h?(0,f.jsx)(h,{...e}):(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,f.jsx)(m,{...e})})}export{s as a,u as i,g as n,l as o,p as r,c as s,_ as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{s as n,t as r,u as i}from"./buffer-store-OTFEYxTw.js";var a=e(t(),1);function o({buffers:e}){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>{let a=new Set(e.map(e=>r(e.session,e.path,e.root))),o=t.current;for(let e of a)o.has(e)||(i(e),o.add(e));for(let e of[...o])a.has(e)||(n(e),o.delete(e))},[e]),(0,a.useEffect)(()=>()=>{for(let e of t.current)n(e);t.current.clear()},[]),null}export{o as ModelRefcount};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{g as n}from"./local-store-8IcyY3pd.js";import{t as r}from"./context-BRrQlmgI.js";import{r as i,s as a}from"./theme-swfNLod9.js";import{t as o}from"./jsx-runtime-By8HlURe.js";import{t as s}from"./preload-helper-Czpn1I53.js";var c=e(t(),1),l=o(),u=()=>()=>{},d={generation:null,revision:0,events:[]},f=()=>d;function p({modelId:e,fallback:t}){let n=(0,c.useContext)(r),i=n?.session,a=(0,c.useSyncExternalStore)(i?.subscribe??u,i?.getSnapshot??f),o=!!i?.state.state[e]&&!!a.generation&&!a.error,s=o?i.state:n?.saved,[d,p]=(0,c.useState)(!1);return s?.state[e]?(0,l.jsx)(h,{modelId:e,snapshot:s,session:o?i:null,generation:o?a.generation:null,extensions:o||d,onLoadExtension:()=>p(!0)},`${o?a.generation:`saved`}:${e}:${d}`):(0,l.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[t&&(0,l.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-sm text-fg-secondary`,children:t}),(0,l.jsx)(`p`,{children:a.error??(i?`Run this cell to create its widget.`:`Live Jupyter widgets require a local or SSH host with protocol 25.4 or newer.`)})]})}function m(){let e=getComputedStyle(document.documentElement),t=t=>e.getPropertyValue(t).trim();return{"--jp-layout-color0":t(`--bg-base`),"--jp-layout-color1":t(`--bg-surface`),"--jp-layout-color2":t(`--bg-elevated`),"--jp-layout-color3":t(`--bg-elevated`),"--jp-ui-font-color0":t(`--text-primary`),"--jp-ui-font-color1":t(`--text-primary`),"--jp-ui-font-color2":t(`--text-secondary`),"--jp-ui-font-color3":t(`--text-muted`),"--jp-content-font-color1":t(`--text-primary`),"--jp-border-color1":t(`--border`),"--jp-content-font-color0":t(`--text-primary`),"--jp-content-font-color2":t(`--text-secondary`),"--jp-content-font-color3":t(`--text-muted`),"--jp-content-font-family":t(`--font-sans`),"--jp-error-color1":t(`--danger`),"--jp-warn-color1":t(`--warning`),"--jp-success-color1":t(`--success`),"--jp-info-color1":t(`--accent`),"--jp-brand-color1":t(`--accent`),"--jp-ui-font-family":t(`--font-sans`),"--jp-code-font-family":t(`--font-mono`),"--danger":t(`--danger`)}}function h({modelId:e,snapshot:t,session:r,generation:o,extensions:u,onLoadExtension:d}){let f=(0,c.useRef)(null),p=(0,c.useRef)(null),h=(0,c.useRef)(t);h.current=t;let[g,_]=(0,c.useState)(),[v,y]=(0,c.useState)(0),[b,x]=(0,c.useState)(48),[S,C]=(0,c.useState)(),[w,T]=(0,c.useState)();return(0,c.useEffect)(()=>{p.current?.postMessage({type:`theme`,theme:m()})},[(0,c.useSyncExternalStore)(a,i,i)]),(0,c.useEffect)(()=>{let t=!1,i,a=a=>{if(a.source!==f.current?.contentWindow||a.data?.type!==`puddle-widget-ready`||p.current)return;let s=new MessageChannel;p.current=s.port1,s.port1.onmessage=e=>{if(t||!e.data||typeof e.data!=`object`)return;let i=e.data;if(i.type===`height`&&Number.isFinite(i.height)&&x(Math.max(24,Math.min(2e3,i.height))),i.type===`error`&&C(String(i.error).slice(0,1024)),i.type===`extension`&&T(String(i.name).slice(0,256)),i.type!==`comm`||!r||!o)return;let a=n.safeParse({source:r.source,generation:o,message:i.message});if(!a.success||JSON.stringify(a.data).length>2*1024*1024){C(`Widget action exceeds the supported message limits`);return}r.send(o,a.data.message).catch(e=>{t||s.port1.postMessage({type:`error`,msg_id:a.data.message.msg_id,error:e instanceof Error?e.message:`Widget action failed`})})},s.port1.start(),f.current.contentWindow.postMessage({type:`puddle-widget-connect`},`*`,[s.port2]),s.port1.postMessage({type:`init`,snapshot:structuredClone(r?.state??h.current),modelId:e,live:!!o,extensions:u,theme:m()}),i=r?.subscribe(e=>{e.generation!==o||e.error?s.port1.postMessage({type:`error`,error:e.error??`The kernel changed. Run the cell again.`}):e.snapshot?(p.current?.close(),p.current=null,i?.(),y(e=>e+1)):s.port1.postMessage({type:`events`,events:e.events})})};return window.addEventListener(`message`,a),(async()=>{let{default:e}=await s(async()=>{let{default:e}=await import(`./_virtual_notebook-widget-runtime-RX_hqyhn.js`);return{default:e}},[]);t||_(`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; style-src 'unsafe-inline' https:; img-src data: blob: https:; font-src data: https:; media-src data: blob: https:; connect-src https:; worker-src blob:; form-action 'none'; base-uri 'none'"><style>
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{v as n}from"./local-store-Dy1Cd8sn.js";import{t as r}from"./context-NsaMZKAN.js";import{r as i,s as a}from"./theme-swfNLod9.js";import{t as o}from"./jsx-runtime-By8HlURe.js";import{t as s}from"./preload-helper-Czpn1I53.js";var c=e(t(),1),l=o(),u=()=>()=>{},d={generation:null,revision:0,events:[]},f=()=>d;function p({modelId:e,fallback:t}){let n=(0,c.useContext)(r),i=n?.session,a=(0,c.useSyncExternalStore)(i?.subscribe??u,i?.getSnapshot??f),o=!!i?.state.state[e]&&!!a.generation&&!a.error,s=o?i.state:n?.saved,[d,p]=(0,c.useState)(!1);return s?.state[e]?(0,l.jsx)(h,{modelId:e,snapshot:s,session:o?i:null,generation:o?a.generation:null,extensions:o||d,onLoadExtension:()=>p(!0)},`${o?a.generation:`saved`}:${e}:${d}`):(0,l.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[t&&(0,l.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-sm text-fg-secondary`,children:t}),(0,l.jsx)(`p`,{children:a.error??(i?`Run this cell to create its widget.`:`Live Jupyter widgets require a local or SSH host with protocol 25.4 or newer.`)})]})}function m(){let e=getComputedStyle(document.documentElement),t=t=>e.getPropertyValue(t).trim();return{"--jp-layout-color0":t(`--bg-base`),"--jp-layout-color1":t(`--bg-surface`),"--jp-layout-color2":t(`--bg-elevated`),"--jp-layout-color3":t(`--bg-elevated`),"--jp-ui-font-color0":t(`--text-primary`),"--jp-ui-font-color1":t(`--text-primary`),"--jp-ui-font-color2":t(`--text-secondary`),"--jp-ui-font-color3":t(`--text-muted`),"--jp-content-font-color1":t(`--text-primary`),"--jp-border-color1":t(`--border`),"--jp-content-font-color0":t(`--text-primary`),"--jp-content-font-color2":t(`--text-secondary`),"--jp-content-font-color3":t(`--text-muted`),"--jp-content-font-family":t(`--font-sans`),"--jp-error-color1":t(`--danger`),"--jp-warn-color1":t(`--warning`),"--jp-success-color1":t(`--success`),"--jp-info-color1":t(`--accent`),"--jp-brand-color1":t(`--accent`),"--jp-ui-font-family":t(`--font-sans`),"--jp-code-font-family":t(`--font-mono`),"--danger":t(`--danger`)}}function h({modelId:e,snapshot:t,session:r,generation:o,extensions:u,onLoadExtension:d}){let f=(0,c.useRef)(null),p=(0,c.useRef)(null),h=(0,c.useRef)(t);h.current=t;let[g,_]=(0,c.useState)(),[v,y]=(0,c.useState)(0),[b,x]=(0,c.useState)(48),[S,C]=(0,c.useState)(),[w,T]=(0,c.useState)();return(0,c.useEffect)(()=>{p.current?.postMessage({type:`theme`,theme:m()})},[(0,c.useSyncExternalStore)(a,i,i)]),(0,c.useEffect)(()=>{let t=!1,i,a=a=>{if(a.source!==f.current?.contentWindow||a.data?.type!==`puddle-widget-ready`||p.current)return;let s=new MessageChannel;p.current=s.port1,s.port1.onmessage=e=>{if(t||!e.data||typeof e.data!=`object`)return;let i=e.data;if(i.type===`height`&&Number.isFinite(i.height)&&x(Math.max(24,Math.min(2e3,i.height))),i.type===`error`&&C(String(i.error).slice(0,1024)),i.type===`extension`&&T(String(i.name).slice(0,256)),i.type!==`comm`||!r||!o)return;let a=n.safeParse({source:r.source,generation:o,message:i.message});if(!a.success||JSON.stringify(a.data).length>2*1024*1024){C(`Widget action exceeds the supported message limits`);return}r.send(o,a.data.message).catch(e=>{t||s.port1.postMessage({type:`error`,msg_id:a.data.message.msg_id,error:e instanceof Error?e.message:`Widget action failed`})})},s.port1.start(),f.current.contentWindow.postMessage({type:`puddle-widget-connect`},`*`,[s.port2]),s.port1.postMessage({type:`init`,snapshot:structuredClone(r?.state??h.current),modelId:e,live:!!o,extensions:u,theme:m()}),i=r?.subscribe(e=>{e.generation!==o||e.error?s.port1.postMessage({type:`error`,error:e.error??`The kernel changed. Run the cell again.`}):e.snapshot?(p.current?.close(),p.current=null,i?.(),y(e=>e+1)):s.port1.postMessage({type:`events`,events:e.events})})};return window.addEventListener(`message`,a),(async()=>{let{default:e}=await s(async()=>{let{default:e}=await import(`./_virtual_notebook-widget-runtime-RX_hqyhn.js`);return{default:e}},[]);t||_(`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; style-src 'unsafe-inline' https:; img-src data: blob: https:; font-src data: https:; media-src data: blob: https:; connect-src https:; worker-src blob:; form-action 'none'; base-uri 'none'"><style>
2
2
  html,body{margin:0;background:var(--jp-layout-color0)!important;color:var(--jp-ui-font-color1)!important;font-family:var(--jp-ui-font-family)!important}
3
3
  .jupyter-widgets input,.jupyter-widgets select,.jupyter-widgets textarea,.jupyter-widgets button{border:0!important;color:var(--jp-ui-font-color1);background:var(--jp-layout-color1)}
4
4
  .jupyter-widgets button,.jupyter-widgets select,.jupyter-widgets input[type=range]{cursor:pointer}