okengine 0.21.1 → 0.22.0

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 (140) hide show
  1. package/AGENTS.md +4 -4
  2. package/LICENSE +202 -0
  3. package/NOTICE +2 -0
  4. package/README.md +15 -9
  5. package/manifest.v1.schema.json +10 -0
  6. package/package.json +22 -20
  7. package/site/content/docs/ai/skills.mdx +1 -1
  8. package/site/content/docs/client/calling.mdx +27 -19
  9. package/site/content/docs/client/index.mdx +1 -1
  10. package/site/content/docs/elements/channel/email.mdx +1 -1
  11. package/site/content/docs/elements/channel/index.mdx +1 -1
  12. package/site/content/docs/elements/flow/http.mdx +4 -4
  13. package/site/content/docs/elements/flow/index.mdx +3 -3
  14. package/site/content/docs/elements/flow/meta.json +1 -1
  15. package/site/content/docs/elements/gate/tenancy.mdx +1 -1
  16. package/site/content/docs/elements/vault/rotation.mdx +15 -0
  17. package/site/content/docs/plugins/otp.mdx +31 -31
  18. package/site/content/docs/recipes/mailpit.mdx +1 -1
  19. package/site/content/docs/recipes/meilisearch.mdx +1 -1
  20. package/site/content/docs/recipes/pgdog.mdx +1 -1
  21. package/site/content/docs/reference/configuration.mdx +2 -2
  22. package/site/content/docs/reference/errors.mdx +12 -2
  23. package/site/content/docs/reference/fx.mdx +28 -15
  24. package/site/content/docs/reference/idempotency.mdx +192 -0
  25. package/site/content/docs/reference/index.mdx +6 -1
  26. package/site/content/docs/reference/meta.json +2 -1
  27. package/site/content/docs/understand/meta.json +1 -1
  28. package/site/content/docs/{elements/flow → understand}/routing.mdx +11 -10
  29. package/site/content/docs/understand/the-architecture.mdx +14 -12
  30. package/site/content/docs/understand/try-it.mdx +3 -3
  31. package/src/cli/competitor-mention-removal.test.ts +3 -3
  32. package/src/cli/docker-cli.test.ts +1 -1
  33. package/src/cli/index.ts +9 -1
  34. package/src/cli/load-config.images.test.ts +10 -10
  35. package/src/cli/load-config.ts +1 -1
  36. package/src/cli/vault-cmd.test.ts +23 -0
  37. package/src/cli/vault-cmd.ts +7 -0
  38. package/src/client/create.ts +18 -1
  39. package/src/client/transport.test.ts +225 -0
  40. package/src/client/transport.ts +132 -19
  41. package/src/client/types.ts +29 -3
  42. package/src/compiler/effects-infer.ts +726 -16
  43. package/src/compiler/extract.test.ts +37 -0
  44. package/src/compiler/extract.ts +113 -12
  45. package/src/compiler/fixtures/skyport.expected.json +24 -0
  46. package/src/compiler/fx-follow.test.ts +164 -0
  47. package/src/compiler/fx-index.ts +399 -0
  48. package/src/console/server/flows-invoke.test.ts +2 -2
  49. package/src/console/ui-next/dist/assets/{access-page-Bgt9bq2r.js → access-page-Ze6ckjdd.js} +2 -2
  50. package/src/console/ui-next/dist/assets/agent-disclosure-Bkohc_8X.js +1 -0
  51. package/src/console/ui-next/dist/assets/{cache-glyph-92uM5MO7.js → cache-glyph-rL0lHxat.js} +1 -1
  52. package/src/console/ui-next/dist/assets/{call-pii-button-DtGVPtcs.js → call-pii-button-Deo4PP18.js} +1 -1
  53. package/src/console/ui-next/dist/assets/{collapsible-DN7l6zmC.js → collapsible-CoJ6amHf.js} +1 -1
  54. package/src/console/ui-next/dist/assets/{copy-inline-button-CAYD18cr.js → copy-inline-button-CWG5_ZOh.js} +1 -1
  55. package/src/console/ui-next/dist/assets/{detail-header-DVWNjWjg.js → detail-header-b_ZzIsmU.js} +1 -1
  56. package/src/console/ui-next/dist/assets/{dropdown-menu-4h2LOVXM.js → dropdown-menu-nwXEO1Ac.js} +1 -1
  57. package/src/console/ui-next/dist/assets/duration-tone-BbQ_8z50.js +9 -0
  58. package/src/console/ui-next/dist/assets/element-icons-CwyLpVXz.js +1 -0
  59. package/src/console/ui-next/dist/assets/{explorer-empty-CJs5A-wm.js → explorer-empty-C8sSCqYT.js} +1 -1
  60. package/src/console/ui-next/dist/assets/{flows-page-BMHs-IzK.js → flows-page-D2E7BtKK.js} +1 -1
  61. package/src/console/ui-next/dist/assets/{highlighted-json-BlAEVgNW.js → highlighted-json-CPYBzDh0.js} +1 -1
  62. package/src/console/ui-next/dist/assets/{http-method-BDf7OAHv.js → http-method-DTPevKmM.js} +1 -1
  63. package/src/console/ui-next/dist/assets/index-vTuwmeQz.js +58 -0
  64. package/src/console/ui-next/dist/assets/observability-page-SJTSzHFJ.js +4 -0
  65. package/src/console/ui-next/dist/assets/{replica-lag-B3GLNVfF.js → replica-lag-BM27lXld.js} +3 -3
  66. package/src/console/ui-next/dist/assets/{request-meta-DMbnAe3f.js → request-meta-BjFT7DNl.js} +1 -1
  67. package/src/console/ui-next/dist/assets/shortcut-keys-CUNegEV4.js +1 -0
  68. package/src/console/ui-next/dist/assets/store-page-Qj9ThRE-.js +41 -0
  69. package/src/console/ui-next/dist/assets/{trace-detail-sheet-Htk8Cm9t.js → trace-detail-sheet-Cmitq3da.js} +2 -2
  70. package/src/console/ui-next/dist/assets/{tree-expand-toggle-CFMPWX4f.js → tree-expand-toggle-CbDIB-7x.js} +2 -2
  71. package/src/console/ui-next/dist/assets/units-page-_PuYqFty.js +1 -0
  72. package/src/console/ui-next/dist/assets/{use-vault-list-CT4-gajj.js → use-vault-list-Cs45Czkt.js} +1 -1
  73. package/src/console/ui-next/dist/assets/{vault-page-CBYl0LW_.js → vault-page-BOMr0go9.js} +2 -2
  74. package/src/console/ui-next/dist/index.html +2 -2
  75. package/src/console/ui-next/src/features/units/detail/flow-contract-panel.tsx +9 -0
  76. package/src/docker/docker.test.ts +13 -13
  77. package/src/docker/images-config.test.ts +12 -12
  78. package/src/docker/stack-id.test.ts +1 -1
  79. package/src/drivers/journal-postgres.ts +168 -3
  80. package/src/drivers/meilisearch.ts +2 -0
  81. package/src/drivers/vault-builtin.test.ts +10 -0
  82. package/src/drivers/vault-builtin.ts +13 -1
  83. package/src/drivers/vault-remote-bag.ts +5 -1
  84. package/src/drivers/vault-types.ts +6 -1
  85. package/src/elements/store/emit-drizzle.ts +2 -2
  86. package/src/elements/store/live-default.test.ts +2 -0
  87. package/src/elements/store/live-http.test.ts +1 -0
  88. package/src/elements/store/resource-list-docs.test.ts +2 -2
  89. package/src/elements/store/resource.test.ts +3 -3
  90. package/src/elements/store/schema-decl.test.ts +1 -0
  91. package/src/elements/store/sql-condition.ts +24 -7
  92. package/src/elements/store/upsert-app.test.ts +1 -1
  93. package/src/elements/vault/audit.test.ts +137 -0
  94. package/src/elements/vault/audit.ts +106 -13
  95. package/src/elements/vault/boot-chain.ts +9 -1
  96. package/src/elements/vault/builtin-adapter.ts +33 -3
  97. package/src/i18n/catalogs/ar.ts +4 -0
  98. package/src/i18n/catalogs/en.ts +4 -0
  99. package/src/kernel/abort-scope.ts +33 -2
  100. package/src/kernel/app.ts +191 -18
  101. package/src/kernel/auto-cache.test.ts +6 -6
  102. package/src/kernel/boot-bind/vault.ts +1 -0
  103. package/src/kernel/boot.ts +19 -1
  104. package/src/kernel/builtin-errors.ts +8 -0
  105. package/src/kernel/client-descriptor.ts +1 -0
  106. package/src/kernel/concurrency.test.ts +33 -0
  107. package/src/kernel/effects-stamping.test.ts +2 -2
  108. package/src/kernel/errors-compiler.ts +20 -0
  109. package/src/kernel/external-effects.test.ts +36 -0
  110. package/src/kernel/flow.ts +24 -0
  111. package/src/kernel/fx-fetch.ts +5 -1
  112. package/src/kernel/fx.ts +5 -1
  113. package/src/kernel/idempotency-store.ts +578 -0
  114. package/src/kernel/idempotency.test.ts +556 -0
  115. package/src/kernel/idempotency.ts +304 -0
  116. package/src/kernel/index.ts +1 -0
  117. package/src/kernel/journal.ts +56 -0
  118. package/src/manifest/types.ts +8 -0
  119. package/src/plugins/auth-delivery.mailpit.integration.test.ts +1 -1
  120. package/src/plugins/otp.test.ts +65 -1
  121. package/src/plugins/otp.ts +59 -7
  122. package/src/release/absolute-regression.test.ts +63 -0
  123. package/src/release/http-graph.test.ts +25 -0
  124. package/src/release/http-graph.ts +90 -0
  125. package/src/release/index.ts +3 -0
  126. package/src/release/limits.ts +17 -2
  127. package/src/release/measure.ts +105 -14
  128. package/src/test/create-test-app.test.ts +3 -1
  129. package/src/test/create-test-app.ts +40 -0
  130. package/src/test/live-signals.test.ts +1 -0
  131. package/src/test/provisions.integration.test.ts +1 -0
  132. package/src/test/tenant-isolation.test.ts +1 -0
  133. package/src/console/ui-next/dist/assets/agent-disclosure-B43CXZZR.js +0 -1
  134. package/src/console/ui-next/dist/assets/duration-tone-BmIR9FV8.js +0 -9
  135. package/src/console/ui-next/dist/assets/element-icons-BI8cJgdh.js +0 -1
  136. package/src/console/ui-next/dist/assets/index-BKpaes3n.js +0 -63
  137. package/src/console/ui-next/dist/assets/observability-page-WnVLI-0j.js +0 -4
  138. package/src/console/ui-next/dist/assets/shortcut-keys-3ILd8oGn.js +0 -1
  139. package/src/console/ui-next/dist/assets/store-page-KvFDingJ.js +0 -41
  140. package/src/console/ui-next/dist/assets/units-page-C4NdNuxP.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{r as t}from"./react-dom-Ddte4I-Q.js";import{A as n}from"./xyflow-yApv7D4e.js";import{Cr as r,Dr as i,E as a,Er as o,F as s,I as c,Or as l,R as u,Tr as d,_r as f,a as p,ar as m,br as h,cr as g,dr as _,er as v,fr as y,i as b,ir as x,kr as S,l as C,lr as w,mr as T,nr as E,o as D,or as O,pr as k,rr as A,s as j,tr as M,u as N,ur as P,vr as F,wr as I,x as L,xr as R,yr as ee}from"./shortcut-keys-3ILd8oGn.js";import{c as te,l as ne,n as re,o as ie,r as ae,t as oe}from"./call-pii-button-DtGVPtcs.js";import{a as z,n as se,r as ce,t as le}from"./http-method-BDf7OAHv.js";import{a as ue,b as de,c as fe,g as pe,i as me,m as he,n as ge,o as _e,r as ve,s as ye,t as be}from"./element-icons-BI8cJgdh.js";import{a as xe,i as Se,n as Ce,o as we,r as Te,s as Ee,t as De}from"./collapsible-DN7l6zmC.js";import{a as Oe,c as ke,f as Ae,i as je,s as Me,t as Ne,u as Pe}from"./highlighted-json-BlAEVgNW.js";import{a as Fe,c as Ie,d as Le,f as Re,l as ze,m as Be,o as Ve,p as B,s as He,t as Ue,u as We,w as Ge}from"./request-meta-DMbnAe3f.js";import{t as Ke}from"./UserIcon-DaE2PB5_.js";import{n as qe}from"./dagre.esm-B1_XeuLP.js";import{$ as V,G as Je,Q as H,X as U,Y as W,a as Ye,c as Xe,d as Ze,et as G,f as Qe,h as $e,i as et,n as tt,nt,o as rt,p as it,r as at,s as ot,t as st,u as ct,ut as lt,v as ut}from"./tree-expand-toggle-CFMPWX4f.js";import{d as dt,r as ft,t as pt}from"./dropdown-menu-4h2LOVXM.js";import{at as mt,gt as ht,yt as gt}from"./index-BKpaes3n.js";import{t as _t}from"./explorer-empty-CJs5A-wm.js";import{c as K,n as vt,t as yt,u as bt}from"./detail-header-DVWNjWjg.js";import{c as xt,n as St,s as Ct,t as wt}from"./cache-glyph-92uM5MO7.js";var Tt=[[`path`,{d:`M16.4999 3.26621C17.3443 3.25421 20.1408 2.67328 20.7337 3.26621C21.3266 3.85913 20.7457 6.65559 20.7337 7.5M20.5059 3.49097L13.5021 10.4961`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M3.26636 16.5001C3.25436 17.3445 2.67343 20.141 3.26636 20.7339C3.85928 21.3268 6.65574 20.7459 7.50015 20.7339M10.502 13.4976L3.49824 20.5027`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],Et=[[`path`,{d:`M21 6.5C21 8.15685 19.6569 9.5 18 9.5C16.3431 9.5 15 8.15685 15 6.5C15 4.84315 16.3431 3.5 18 3.5C19.6569 3.5 21 4.84315 21 6.5Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M9 12C9 13.6569 7.65685 15 6 15C4.34315 15 3 13.6569 3 12C3 10.3431 4.34315 9 6 9C7.65685 9 9 10.3431 9 12Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M21 17.5C21 19.1569 19.6569 20.5 18 20.5C16.3431 20.5 15 19.1569 15 17.5C15 15.8431 16.3431 14.5 18 14.5C19.6569 14.5 21 15.8431 21 17.5Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`2`}],[`path`,{d:`M8.72852 10.7495L15.2285 7.75M8.72852 13.25L15.2285 16.2495`,stroke:`currentColor`,strokeWidth:`1.5`,key:`3`}]],Dt=[[`path`,{d:`M15.1312 2.5C14.1462 2.17555 13.0936 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 10.9548 21.8396 9.94704 21.5422 9`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M17 12C17 14.7614 14.7614 17 12 17C9.23858 17 7 14.7614 7 12C7 9.23858 9.23858 7 12 7`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M19.5 4.5L12 12M19.5 4.5V2M19.5 4.5H22`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`2`}]],q=e(t(),1),J=n();function Ot(e,t){let n=ot(e.asGate);return n===`operator`?`Operator`:n===`public`?`Public`:e.asUserId?t.find(t=>t.id===e.asUserId)?.name??e.asUserId:e.asGate?`As · ${e.asGate}`:`As`}function Y(e){let t=ot(e.asGate);return t===`operator`||t===`public`||!!(e.asUserId||e.asGate)}function kt({manifest:e,identities:t,value:n,onChange:r}){let a=Je(!0),s=(0,q.useMemo)(()=>$e(ut(e),a.data??null),[e,a.data]),c=(0,q.useMemo)(()=>Xe(s),[s]),l=(0,q.useMemo)(()=>ct(t,s),[t,s]),u=s.gates.find(e=>e.kind===`public`)?.description??`Intentionally unauthenticated.`,d=ot(n.asGate),f=n.asGate!==null,[p,m]=(0,q.useState)(n.asUserId?`user`:`policy`),h=c.find(e=>e.id===n.asGate)??null,g=l.find(e=>e.id===n.asUserId&&e.gate===n.asGate)??null,_=c.length>0||l.length>0,v=e=>{if(e===`operator`){r({asGate:null,asUserId:null});return}if(e===`public`){r({asGate:`public`,asUserId:null});return}if(d===`as`)return;let t=h?.id??c[0]?.id??l[0]?.gate??null;if(t!==null){if(l[0]&&t===l[0].gate&&c.length===0){m(`user`),r({asGate:l[0].gate,asUserId:l[0].id});return}m(`policy`),r({asGate:t,asUserId:null})}};return(0,J.jsxs)(pt,{children:[(0,J.jsx)(dt,{render:e=>(0,J.jsxs)(L,{...e,type:`button`,variant:`ghost`,size:`sm`,className:o(`h-full max-w-44 min-w-0 rounded-none px-2 text-[11px]`,f&&`text-sky-800 dark:text-sky-300`),"aria-label":f?`Invoke as Gate ${n.asGate}`:`Invoke as Operator (bypass gates)`,"data-slot":`call-api-identity`,children:[(0,J.jsx)(i,{icon:be.gate.icon,"data-icon":`inline-start`,className:`size-3.5`}),(0,J.jsx)(`span`,{className:`truncate`,children:Ot(n,t)})]})}),(0,J.jsxs)(ft,{align:`end`,className:`w-80 overflow-hidden p-0`,children:[(0,J.jsx)(rt,{children:`Invoke as`}),(0,J.jsxs)(Ye,{label:`Invoke as`,children:[(0,J.jsx)(at,{mode:`operator`,title:`Operator`,caption:`Bypass`,selected:d===`operator`,onSelect:()=>v(`operator`)}),(0,J.jsx)(at,{mode:`public`,title:`Public`,caption:`Anonymous`,selected:d===`public`,onSelect:()=>v(`public`)}),(0,J.jsx)(at,{mode:`as`,title:`As`,caption:g?g.label:h?.label??`User / policy`,selected:d===`as`,disabled:!_,onSelect:()=>v(`as`)})]}),d===`operator`?(0,J.jsx)(et,{title:`Operator`,badge:`Default`,children:`Bypasses the flow's gate chain.`}):null,d===`public`?(0,J.jsxs)(et,{title:`Public`,children:[u,` Only `,(0,J.jsx)(`span`,{className:`font-mono`,children:`gate.public`}),` flows succeed.`]}):null,d===`as`?(0,J.jsx)(tt,{tab:p,onTabChange:m,policies:c,users:l,asGate:n.asGate,asUserId:g?.id??null,onSelectPolicy:e=>{m(`policy`),r({asGate:e.id,asUserId:null})},onSelectUser:e=>{m(`user`),r({asGate:e.gate,asUserId:e.id})},hint:g?(0,J.jsxs)(`p`,{className:`border-t border-border/60 px-2 py-2 text-[10px] leading-relaxed text-muted-foreground`,children:[`Calls as `,(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:g.label}),` `,`via `,(0,J.jsx)(`span`,{className:`font-mono`,children:n.asGate}),`.`]}):h?(0,J.jsxs)(`p`,{className:`border-t border-border/60 px-2 py-2 text-[10px] leading-relaxed text-muted-foreground`,children:[h.detail,` Sets scopes for`,` `,(0,J.jsx)(`span`,{className:`font-mono`,children:h.id}),`.`]}):null}):null]})]})}var At=new Set([`q`,`query`,`search`,`limit`,`offset`,`cursor`,`page`,`pageSize`,`perPage`,`per_page`,`page_size`,`order`,`orderBy`,`order_by`,`sort`,`sortBy`,`sort_by`,`direction`]);function jt(e,t=[]){let n=new Set,r=[];for(let i of t){n.add(i);let t=e.find(e=>e.name===i);r.push(t??Mt(i))}let i=[];for(let t of e)n.has(t.name)||(At.has(t.name)?r.push(t):i.push(t));return{parameters:r,fields:i}}function Mt(e){return{path:`/path/${e}`,name:e,type:`string`,required:!0}}function Nt(e,t={}){let n=t.pathParams??[],r=new Set(n);if(t.http!==!0)return{path:[],query:[],body:e};let i=e.filter(e=>!r.has(e.name));return se(t.method)?{path:n,query:[],body:i}:{path:n,query:i,body:[]}}function Pt(e,t){let n={};for(let r of t)Object.hasOwn(e,r.name)&&(n[r.name]=e[r.name]);return n}function X(e,t=``){if(!e)return[];if(e.type===`object`||e.properties){let n=e.properties??{},r=new Set(Array.isArray(e.required)?e.required:[]);return Object.entries(n).map(([e,n])=>Ft(e,`${t}/${e}`,n,r.has(e)))}return[Ft(`value`,t||`/`,e,!0)]}function Ft(e,t,n,r){let i=It(e,n),a=typeof n.description==`string`?n.description:void 0;if(Array.isArray(n.enum)){let o=Ut(n);return{path:t,name:e,type:`enum`,required:r,enumValues:n.enum.map(String),...a===void 0?{}:{description:a},...o===void 0?{}:{valueMeanings:o},...i}}let o=n.type;if(o===`object`||n.properties)return{path:t,name:e,type:`object`,required:r,...a===void 0?{}:{description:a},...i,children:X(n,t)};if(o===`array`)return{path:t,name:e,type:`array`,required:r,...a===void 0?{}:{description:a},...i,children:n.items?X(n.items,`${t}/0`):void 0};let s=o===`integer`||o===`number`||o===`boolean`||o===`string`?o:`unknown`,c=Ut(n);return{path:t,name:e,type:s,required:r,minimum:typeof n.minimum==`number`?n.minimum:void 0,maximum:typeof n.maximum==`number`?n.maximum:void 0,...a===void 0?{}:{description:a},...c===void 0?{}:{valueMeanings:c},...i}}function It(e,t){let n=Lt(e),r=Rt(t.references),i=t.primaryKey===!0||n.primaryKey===!0,a=r!==void 0||n.foreignKey===!0,o=!i&&(t.unique===!0||n.unique===!0);return{...t.pii===!0?{pii:!0}:{},...t.sensitive===!0?{sensitive:!0}:{},...i?{primaryKey:!0}:{},...a?{foreignKey:!0}:{},...o?{unique:!0}:{},...r===void 0?{}:{references:r}}}function Lt(e){return e===`id`?{primaryKey:!0}:/(?:Id|_id)$/.test(e)||/(?:Key|_key)$/.test(e)&&e!==`key`?{foreignKey:!0}:e===`identifier`||e===`key`?{unique:!0}:{}}function Rt(e){if(!e||typeof e!=`object`)return;let t=`table`in e&&typeof e.table==`string`?e.table:void 0;if(!t)return;let n=`column`in e&&typeof e.column==`string`?e.column:void 0;return n===void 0?{table:t}:{table:t,column:n}}var zt=12;function Bt(e){return e.enumValues&&e.enumValues.length>0?e.enumValues.join(` · `):e.minimum!==void 0&&e.maximum!==void 0?`${e.minimum}–${e.maximum}`:e.minimum===void 0?e.maximum===void 0?null:`≤ ${e.maximum}`:`≥ ${e.minimum}`}function Vt(e){return e.minimum!==void 0&&e.maximum!==void 0?`Must be from ${e.minimum} up to ${e.maximum}.`:e.minimum===void 0?e.maximum===void 0?null:`Must be at most ${e.maximum}.`:`Must be at least ${e.minimum}.`}function Ht(e){return e.filter(e=>e.minimum!==void 0||e.maximum!==void 0||(e.enumValues?.length??0)>0||(e.valueMeanings?.length??0)>0)}function Ut(e){let t=Array.isArray(e.oneOf)?e.oneOf:Array.isArray(e.anyOf)?e.anyOf:null;if(t){let e=[];for(let n of t){if(!n||typeof n!=`object`)continue;let t=n;if(!(`const`in t))continue;let r=String(t.const),i=typeof t.title==`string`?t.title:typeof t.description==`string`?t.description:void 0;i&&e.push({value:r,label:i})}return e.length>0?e:void 0}}function Wt(e){if(e.type!==`integer`||e.minimum===void 0||e.maximum===void 0||!Number.isInteger(e.minimum)||!Number.isInteger(e.maximum))return null;let t=e.maximum-e.minimum;return t<0||t>zt?null:Array.from({length:t+1},(t,n)=>e.minimum+n)}function Gt(e){return e?Kt(e):{}}function Kt(e){if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];let t=e.type;if(t===`object`||!t&&e.properties){let t=e.properties??{},n=new Set(Array.isArray(e.required)?e.required:[]),r={};for(let[e,i]of Object.entries(t))(n.has(e)||`default`in i||Object.keys(t).length<=4)&&(r[e]=Kt(i));return r}if(t===`array`){let t=e.items;return t?[Kt(t)]:[]}return t===`integer`||t===`number`?typeof e.default==`number`?e.default:typeof e.minimum==`number`?e.minimum:1:t===`boolean`?!1:t===`string`?e.format===`email`?`user@example.com`:e.format===`uuid`?`00000000-0000-4000-8000-000000000001`:typeof e.default==`string`?e.default:e.minLength?`x`.repeat(Number(e.minLength)):``:null}function qt(e){return!e||typeof e==`string`?null:e}function Jt(e,t){if(!e.foreignKey||!t)return null;let n=Qt(t);if(n.length===0)return null;if(e.references?.table){let t=$t(n,e.references.table);return t?Xt(t,e.references.column??tn(t.table)??`id`):null}let r=Zt(e.name);if(!r)return null;let i=en(n,r.stem);return i?Xt(i,r.kind===`key`?nn(i.table,`key`)??tn(i.table)??`id`:tn(i.table)??`id`):null}function Yt(e,t){if(!t)return[];let n=new Set,r=[];for(let i of e){let e=i[t.column];if(e==null)continue;let a=String(e);if(n.has(a))continue;n.add(a);let o=t.labelColumn?i[t.labelColumn]:void 0,s=o!=null&&String(o)!==a?String(o):null;r.push({value:a,label:s?`${a} · ${s}`:a})}return r}function Xt(e,t){let n=rn(e.table,t);return{ref:e.ref,child:e.name,column:t,...n===void 0?{}:{labelColumn:n}}}function Zt(e){return e===`id`?null:e.endsWith(`Id`)?{stem:e.slice(0,-2),kind:`id`}:e.endsWith(`_id`)?{stem:e.slice(0,-3),kind:`id`}:e.endsWith(`Key`)?{stem:e.slice(0,-3),kind:`key`}:e.endsWith(`_key`)?{stem:e.slice(0,-4),kind:`key`}:null}function Qt(e){let t=[];for(let[n,r]of Object.entries(e.stores??{}))r.facet===`sql`&&r.tables&&t.push({ref:`sql:${n}`,tables:r.tables});return t}function $t(e,t){let n=t.toLowerCase();for(let t of e)for(let[e,r]of Object.entries(t.tables))if(e.toLowerCase()===n)return{ref:t.ref,name:e,table:r};return null}function en(e,t){let n=sn(t),r=[t,n,on(t),on(n)].map(e=>e.toLowerCase());for(let t of e)for(let[e,n]of Object.entries(t.tables))if(r.includes(e.toLowerCase()))return{ref:t.ref,name:e,table:n};return null}function tn(e){for(let[t,n]of Object.entries(e.columns??{}))if(an(n)&&n.primaryKey===!0)return t;if(e.columns&&`id`in e.columns)return`id`}function nn(e,t){return e.columns&&t in e.columns?t:void 0}function rn(e,t){if(t!==`name`&&e.columns&&`name`in e.columns)return`name`}function an(e){return`type`in e||`primaryKey`in e||`references`in e}function on(e){return e.endsWith(`y`)&&!/[aeiou]y$/i.test(e)?`${e.slice(0,-1)}ies`:/(?:s|x|z|ch|sh)$/i.test(e)?`${e}es`:`${e}s`}function sn(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1_$2`).toLowerCase()}function cn(e){let t=[];for(let n of e.split(`/`))n.startsWith(`:`)&&n.length>1&&t.push(n.slice(1));return t}function ln(e){return`:${e}`}var un={"attachments:id":`attachments/tsk_eng_12/spec.pdf`,"tasks:id":`tsk_eng_12`,"comments:id":`cmt_1`,"projects:id":`proj_api`,"spaces:id":`space_eng`,"tags:id":`tag_bug`,"tags:tagId":`tag_feature`,"goals:id":`goal_harbor`,"documents:id":`doc_prd_api`,"members:id":`mem_aria`,"forms:id":`form_customer`,"drafts:id":`ENG-12`,"views:id":`view_web_board`,"inbox:id":`inb_1`};function dn(e,t){let n=e.split(`/`).filter(Boolean),r=`:${t}`,i=n.indexOf(r),a=i>0?n[i-1]:void 0;return(a?un[`${a}:${t}`]:void 0)??un[`:${t}`]}function fn(e,t){let n={};if(!e)return n;for(let r of t){let t=dn(e,r);t&&(n[r]=t)}return n}function pn(e,t){let n=e?.flows?.[t],r=n?.trigger?.cron,i=n?.trigger?.every;if(!r&&!i)return{kind:`unmatched`};let a=e?.clocks??{},o=new Set;for(let[e,n]of Object.entries(a)){if(t===e||t.endsWith(`.${e}`)){o.add(e);continue}if(r&&n.cron===r){o.add(e);continue}i&&n.every===i&&o.add(e)}if(o.size!==1)return{kind:`unmatched`};let s=[...o][0],c=a[s];return{kind:`matched`,clockName:s,timezone:c.timezone??null,description:c.description??null,cron:c.cron??null,every:c.every??null}}function mn(e){let t=e.handlerMs!=null&&Number.isFinite(e.handlerMs)?e.handlerMs:null;return t===null?e.rttMs!==null&&Number.isFinite(e.rttMs)?{primaryMs:e.rttMs,primaryKind:`rtt`,rttMs:e.rttMs}:null:{primaryMs:t,primaryKind:`handler`,rttMs:e.rttMs}}function hn(e){let t=new Set;if(!e?.stores)return t;for(let n of Object.values(e.stores)){for(let e of Object.values(n.tables??{}))for(let[n,r]of Object.entries(e.columns??{}))r?.pii&&ae(t,n);for(let[e,r]of Object.entries(n.classifications??{}))if(r&&typeof r==`object`&&!Array.isArray(r)&&`pii`in r&&r.pii){let n=e.includes(`.`)?e.slice(e.lastIndexOf(`.`)+1):e;ae(t,n)}}return t}function gn(e,t,n=re){if(t.size===0||e==null)return e;if(Array.isArray(e))return e.map(e=>gn(e,t,n));if(typeof e==`object`){let r={};for(let[i,a]of Object.entries(e))r[i]=t.has(i)?n:gn(a,t,n);return r}return e}function _n(e){return e.failure==null?e.response!==void 0&&e.response!==null?JSON.stringify(e.response,null,2):JSON.stringify({status:e.status??200,failure:null,response:null},null,2):JSON.stringify({status:e.status??null,failure:e.failure,response:e.response??null},null,2)}function vn(e,t,n){return t&&e.masked===!1?_n({...e,response:gn(e.response,n),failure:e.failure===void 0?void 0:{...e.failure,data:gn(e.failure.data,n)},masked:!0}):_n(e)}function yn(e){let t=e.flow.effects;return!t||(t.writes?.length??0)===0&&(t.emits?.length??0)===0&&(t.sends?.length??0)===0&&(t.asks?.length??0)===0&&(t.embeds?.length??0)===0&&(t.fetches?.length??0)===0}function bn(e,t){return!t&&yn(e)}function xn(e,t){if(!e)return{ok:!0,errors:[],value:t};let n=[];return Sn(e,t,``,n),{ok:n.length===0,errors:n,value:t}}function Sn(e,t,n,r){let i=e.type;if(i===`object`||e.properties){if(typeof t!=`object`||!t||Array.isArray(t)){r.push({path:n||`/`,message:`must be object`});return}let i=t,a=e.properties??{},o=Array.isArray(e.required)?e.required:[];for(let e of o)(i[e]===void 0||i[e]===null||i[e]===``)&&r.push({path:`${n}/${e}`,message:`required`});for(let[e,t]of Object.entries(a))i[e]!==void 0&&Sn(t,i[e],`${n}/${e}`,r);return}if(Array.isArray(e.enum)){e.enum.map(String).includes(String(t))||r.push({path:n||`/`,message:`invalid enum`});return}i===`string`&&typeof t!=`string`?r.push({path:n||`/`,message:`must be string`}):i===`integer`?typeof t!=`number`||!Number.isInteger(t)?r.push({path:n||`/`,message:`must be integer`}):Cn(e,t,n,r):i===`number`?typeof t!=`number`||Number.isNaN(t)?r.push({path:n||`/`,message:`must be number`}):Cn(e,t,n,r):i===`boolean`&&typeof t!=`boolean`&&r.push({path:n||`/`,message:`must be boolean`})}function Cn(e,t,n,r){let i=typeof e.minimum==`number`?e.minimum:void 0,a=typeof e.maximum==`number`?e.maximum:void 0;i!==void 0&&t<i&&r.push({path:n||`/`,message:`must be ≥ ${i}`}),a!==void 0&&t>a&&r.push({path:n||`/`,message:`must be ≤ ${a}`})}function wn(e){return JSON.stringify(e,null,2)}function Tn({row:e,manifest:t}){let n=B(e.flow.trigger);return n===`cron`||n===`every`?(0,J.jsx)(En,{row:e,manifest:t}):(0,J.jsx)(Dn,{row:e,kind:n,manifest:t})}function En({row:e,manifest:t}){let n=(0,q.useMemo)(()=>pn(t,e.id),[t,e.id]),r=Ze(),a=Qe(),o=it(),[s,c]=(0,q.useState)({asGate:null,asUserId:null}),[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(null);(0,q.useEffect)(()=>{r.reset(),o.reset(),f(null),u(null)},[e.id]);let p=n.kind===`matched`;async function m(){if(u(performance.now()),p){f(`clock`);try{await r.mutateAsync({name:n.clockName})}catch{}return}if(Y(s)){f(`invoke`);try{await o.mutateAsync({flowId:e.id,body:{},...s.asUserId?{asUserId:s.asUserId}:{},...s.asGate?{asGate:s.asGate}:{}})}catch{}}}let h=p?r.isPending:o.isPending,g=p?r.isError:o.isError||o.isSuccess&&o.data?.failure!=null,_=p?r.isSuccess:o.isSuccess&&!o.data?.failure,v=l!==null&&(_||g)?performance.now()-l:null,y=(0,q.useMemo)(()=>p&&r.data?JSON.stringify(r.data,null,2):!p&&o.data?_n(o.data):null,[p,r.data,o.data]),b=p?`Run now`:`Run handler`,x=p?`Run now`:`Run handler once`;return(0,J.jsx)(jn,{title:b,dataMode:p?`clock`:`invoke-fallback`,actions:(0,J.jsxs)(J.Fragment,{children:[p?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(kt,{manifest:t,identities:a.data??[],value:s,onChange:c}),(0,J.jsx)(In,{})]}),(0,J.jsx)(L,{type:`button`,"data-slot":`call-api-submit`,disabled:h||!p&&!Y(s),onClick:()=>void m(),className:Fn,children:h?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{icon:mt,className:`animate-spin`,"data-icon":`inline-start`}),`Running…`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{icon:te,"data-icon":`inline-start`}),x]})})]}),children:(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[p?(0,J.jsxs)(`p`,{className:`px-3 pt-2.5 pb-2 text-[11px] leading-snug text-muted-foreground`,"data-slot":`clock-path-copy`,children:[`Fires Manifest clock`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:n.clockName}),` `,`via`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`/console/clock/run-now`}),` `,`(lease-gated — the real scheduler path).`,n.timezone?(0,J.jsxs)(J.Fragment,{children:[` `,`Timezone · `,(0,J.jsx)(`span`,{className:`font-mono`,children:n.timezone}),`.`]}):null]}):(0,J.jsxs)(`div`,{className:`mx-3 mt-2.5 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-[11px] leading-snug text-foreground/90`,"data-slot":`invoke-fallback-copy`,role:`note`,children:[`No unique Manifest clock matches this flow's schedule.`,` `,(0,J.jsx)(`strong`,{className:`font-medium`,children:`Run handler once`}),` uses`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`/console/flows/invoke`}),` `,`with empty input — it does `,(0,J.jsx)(`em`,{children:`not`}),` exercise the Clock lease / scheduler path.`]}),(0,J.jsx)(On,{failed:!!g,success:!!_,elapsed:v,handlerMs:p?null:o.data?.durationMs,statusCode:p?r.data?.ran?200:409:o.data?.status,errorMessage:p?r.isError?r.error.message:null:o.isError?o.error.message:null,responseJson:y,emptyHint:p?`Run now to fire the real clock tick.`:`Run handler once to invoke with empty input.`,pathUsed:d,cache:p?void 0:o.data?.cache})]})})}function Dn({row:e,kind:t,manifest:n}){let r=Qe(),l=it(),d=qt(e.flow.in),f=(0,q.useMemo)(()=>X(d),[d]),p=(0,q.useMemo)(()=>t===`http`&&e.path?cn(e.path):[],[t,e.path]),m=(0,q.useMemo)(()=>Nt(f,{http:t===`http`,method:e.method,pathParams:p}),[f,t,e.method,p]),h=t!==`http`||se(e.method),[g,_]=(0,q.useState)({asGate:null,asUserId:null}),[v,y]=(0,q.useState)(!0),[b,x]=(0,q.useState)(()=>fn(e.path,p)),S=(0,q.useMemo)(()=>Gt(d)??{},[d]),C=(0,q.useMemo)(()=>Pt(S,m.query),[S,m.query]),w=(0,q.useMemo)(()=>Pt(S,m.body),[S,m.body]),[T,E]=(0,q.useState)(C),[D,O]=(0,q.useState)(w),[k,A]=(0,q.useState)(`fields`),[j,M]=(0,q.useState)(()=>wn(w)),[N,P]=(0,q.useState)(null),[F,I]=(0,q.useState)([]),[R,ee]=(0,q.useState)(null),[ne,re]=(0,q.useState)(null);(0,q.useEffect)(()=>{E(C),O(w),M(wn(w)),P(null),A(`fields`),x(fn(e.path,p)),I([]),re(null),ee(null),l.reset()},[e.id]);function ie(e){try{let t=JSON.parse(e);return typeof t!=`object`||!t||Array.isArray(t)?(P(`Body must be a JSON object.`),!1):(O(t),P(null),!0)}catch(e){return P(e instanceof Error?e.message:`Invalid JSON.`),!1}}function ae(e){if(e!==k){if(e===`raw`){M(wn(D)),P(null),A(`raw`);return}ie(j)&&A(`fields`)}}async function z(t=!v){let n=h?D:{};if(h&&k===`raw`){if(!ie(j))return;try{n=JSON.parse(j)}catch{return}}let r={...T,...n},i=xn(d,{...b,...r});if(!i.ok){I(i.errors);return}if(I([]),Y(g)){ee(performance.now());try{await l.mutateAsync({flowId:e.id,body:r,...g.asUserId?{asUserId:g.asUserId}:{},...g.asGate?{asGate:g.asGate}:{},...p.length>0?{pathParams:b}:{},...t?{revealPii:!0}:{}})}catch{}}}function ce(){E(C),O(w),M(wn(w)),P(null),x(fn(e.path,p)),I([])}(0,q.useEffect)(()=>{R===null||l.isPending||(l.isSuccess||l.isError)&&re(performance.now()-R)},[l.isSuccess,l.isError,l.isPending,R]);let le=(0,q.useMemo)(()=>l.data?vn(l.data,v,hn(n)):null,[l.data,v,n]),ue=l.data?.failure!=null,de=l.data?.status,fe=t===`http`?`Call API`:t===`signal`?`Run handler`:`Invoke`,pe=fe;return(0,J.jsx)(jn,{title:fe,dataTrigger:t,actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(kt,{manifest:n,identities:r.data??[],value:g,onChange:_}),(0,J.jsx)(oe,{piiMasked:v,disabled:l.isPending,onToggle:()=>{let t=!v;y(t),l.data&&!l.isPending&&bn(e,t)&&z(!0)}}),h?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(In,{}),(0,J.jsx)(Mn,{view:k,onChange:ae})]}):null,(0,J.jsx)(In,{}),(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:e=>(0,J.jsxs)(L,{...e,type:`button`,variant:`ghost`,"data-slot":`call-api-reset`,disabled:l.isPending,onClick:ce,className:Pn,children:[(0,J.jsx)(i,{icon:Ae,"data-icon":`inline-start`}),`Reset`]})}),(0,J.jsx)(c,{side:`bottom`,className:`text-[11px]`,children:h?`Reset body to the schema example`:`Reset to schema examples`})]}),(0,J.jsx)(In,{}),(0,J.jsx)(L,{type:`button`,"data-slot":`call-api-submit`,disabled:l.isPending||!Y(g),onClick:()=>void z(),className:Fn,children:l.isPending?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{icon:mt,className:`animate-spin`,"data-icon":`inline-start`}),`Calling…`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{icon:te,"data-icon":`inline-start`}),pe]})})]}),children:(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`min-h-0 min-w-0 shrink overflow-y-auto`,children:[t===`http`?(0,J.jsxs)(`p`,{className:`px-3 pt-2.5 pb-2 text-[11px] leading-snug text-muted-foreground`,children:[`Operator session · invoke-as`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`console:flows:invoke-as`})]}):null,t===`signal`?(0,J.jsxs)(`div`,{className:`mx-3 mt-2.5 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-[11px] leading-snug text-foreground/90`,"data-slot":`signal-honest-copy`,role:`note`,children:[(0,J.jsx)(`strong`,{className:`font-medium`,children:`Run handler directly`}),` — invokes the flow with your payload via`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`/console/flows/invoke`}),`. It does `,(0,J.jsx)(`em`,{children:`not`}),` publish on the signal bus, so it does not test delivery physics (once / broadcast / live, retries, dead-letter).`]}):null,t===`internal`?(0,J.jsxs)(`div`,{className:`mx-3 mt-2.5 rounded-md border border-border/60 bg-muted/20 px-3 py-2 text-[11px] leading-snug text-muted-foreground`,"data-slot":`call-only-bypass-copy`,role:`note`,children:[`This flow has no external trigger. Invoking here bypasses its normal caller (`,(0,J.jsx)(`code`,{className:`font-mono text-[10px]`,children:`fx.call`}),` /`,` `,(0,J.jsx)(`code`,{className:`font-mono text-[10px]`,children:`effects.calls`}),`). The body still matches `,(0,J.jsx)(`code`,{className:`font-mono text-[10px]`,children:`flow.in`}),`.`]}):null,t===`cdc`?(0,J.jsx)(`p`,{className:`px-3 pt-2.5 pb-2 text-[11px] leading-snug text-muted-foreground`,children:`Direct handler invoke — not a Store CDC event.`}):null,p.length>0?(0,J.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Path params`,"data-slot":`call-api-path`,children:[(0,J.jsx)(Rn,{title:`Path params`,hint:e.path??void 0}),p.map(e=>(0,J.jsx)(K,{label:e,className:`[&>span]:px-3`,children:(0,J.jsx)(a,{id:`path-${e}`,flat:!0,className:o(vt,`px-3 font-mono`),placeholder:ln(e),value:b[e]??``,onChange:t=>x(n=>({...n,[e]:t.target.value}))})},e))]}):null,m.query.length>0?(0,J.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Query params`,"data-slot":`call-api-query`,children:[(0,J.jsx)(Rn,{title:`Query params`,hint:`seeded from schema`}),(0,J.jsx)(bt,{children:m.query.map(e=>(0,J.jsx)(zn,{field:e,idPrefix:`query`,value:T[e.name],onChange:t=>E(n=>({...n,[e.name]:t})),error:F.find(t=>t.path===`/${e.name}`||t.path===e.path),wide:e.type===`object`||e.type===`array`,manifest:n},e.path))})]}):null,h?(0,J.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Body`,"data-slot":`call-api-body`,children:[(0,J.jsx)(Rn,{title:`Body`,hint:k===`raw`?`raw JSON`:`seeded from schema`}),k===`raw`?(0,J.jsxs)(`div`,{className:`border-b border-border/50`,children:[(0,J.jsx)(`textarea`,{"data-slot":`call-api-body-raw`,"aria-label":`Raw JSON body`,spellCheck:!1,value:j,onChange:e=>{M(e.target.value),N&&P(null)},className:o(`min-h-40 w-full resize-y rounded-none border-0 bg-transparent px-3 py-2 font-mono text-xs leading-relaxed text-foreground outline-none`,`placeholder:text-muted-foreground focus-visible:bg-muted/20`,N&&`text-destructive`)}),N?(0,J.jsx)(`p`,{role:`alert`,className:`px-3 pb-2 text-xs text-destructive`,"data-slot":`call-api-raw-error`,children:N}):null]}):m.body.length===0?(0,J.jsx)(`p`,{className:`border-b border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:`No body fields (empty object).`}):(0,J.jsx)(bt,{children:m.body.map(e=>(0,J.jsx)(zn,{field:e,value:D[e.name],onChange:t=>O(n=>({...n,[e.name]:t})),error:F.find(t=>t.path===`/${e.name}`||t.path===e.path),wide:e.type===`object`||e.type===`array`,manifest:n},e.path))})]}):null,F.length>0?(0,J.jsx)(`p`,{role:`alert`,className:`px-3 py-2 text-xs text-destructive`,"data-slot":`call-api-validation`,children:`Fix contract errors before sending.`}):null]}),(0,J.jsx)(On,{failed:!!ue,success:!!l.data&&!ue,elapsed:ne,handlerMs:l.data?.durationMs,statusCode:de,errorMessage:l.isError?l.error.message:null,responseJson:le,emptyHint:`Call to see a real host response.`,pathUsed:null,cache:l.data?.cache})]})})}function On({failed:e,success:t,elapsed:n,handlerMs:r,statusCode:a,errorMessage:s,responseJson:c,emptyHint:l,pathUsed:u,cache:d}){let[f,m]=(0,q.useState)(!1),h=(0,J.jsx)(An,{failed:e,success:t,elapsed:n,handlerMs:r,statusCode:a,pathUsed:u,cache:d});return(0,J.jsxs)(`section`,{className:`flex min-h-56 min-w-0 flex-1 flex-col overflow-hidden`,"aria-label":`Response`,"data-slot":`call-api-response-block`,children:[(0,J.jsxs)(`div`,{className:F,children:[(0,J.jsx)(`h4`,{className:o(I,`flex items-center px-2`),children:`Response`}),(0,J.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,children:[h,c?(0,J.jsx)(ye,{label:`Expand response`,className:`flex self-stretch`,children:(0,J.jsx)(`button`,{type:`button`,"aria-label":`Expand response`,"data-slot":`call-api-response-expand`,className:g,onClick:()=>m(!0),children:(0,J.jsx)(i,{icon:Tt,className:`size-3.5`,"aria-hidden":!0})})}):null]})]}),s?(0,J.jsx)(`p`,{role:`alert`,className:`px-2 py-2 text-sm text-destructive`,"data-slot":`call-api-error`,children:s}):null,c?(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,"data-slot":`call-api-response-frame`,children:[(0,J.jsx)(`div`,{className:o(`w-1 shrink-0 self-stretch`,e?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0,"data-slot":`call-api-response-rail`}),(0,J.jsx)(Ne,{json:c,dataSlot:`call-api-response`,className:`flex min-h-0 flex-1 overflow-auto`})]}):(0,J.jsx)(`p`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:l}),c?(0,J.jsx)(b,{open:f,onOpenChange:m,children:(0,J.jsxs)(D,{side:`right`,showCloseButton:!1,className:`gap-0 p-0 data-[side=right]:w-[min(48rem,calc(100vw-2rem))] data-[side=right]:sm:max-w-[min(48rem,calc(100vw-2rem))]`,"data-slot":`call-api-response-dialog`,children:[(0,J.jsxs)(C,{className:o(F,`flex-row gap-0 border-border/60 p-0`),children:[(0,J.jsx)(N,{className:o(I,`flex items-center px-2`),children:`Response`}),(0,J.jsx)(j,{className:`sr-only`,children:`Full Call API response JSON`}),(0,J.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,children:[h,(0,J.jsx)(kn,{json:c}),(0,J.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0}),(0,J.jsxs)(p,{"aria-label":`Close`,className:g,"data-slot":`call-api-response-close`,children:[(0,J.jsx)(i,{icon:S,className:`size-3.5`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,J.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,J.jsx)(`div`,{className:o(`w-1 shrink-0 self-stretch`,e?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0}),(0,J.jsx)(Ne,{json:c,dataSlot:`call-api-response-expanded`,className:`flex min-h-0 flex-1 overflow-auto`})]})})]})}):null]})}function kn({json:e}){let[t,n]=(0,q.useState)(!1);return(0,J.jsx)(ye,{label:t?`Copied`:`Copy response`,className:`flex self-stretch`,children:(0,J.jsx)(`button`,{type:`button`,"aria-label":t?`Copied`:`Copy response`,"data-slot":`call-api-response-copy`,className:g,onClick:()=>{navigator.clipboard&&navigator.clipboard.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1200)})},children:(0,J.jsx)(i,{icon:t?l:de,className:`size-3.5`,"aria-hidden":!0})})})}function An({failed:e,success:t,elapsed:n,handlerMs:r,statusCode:a,pathUsed:d,cache:f}){let p=t||e,m=p?mn({handlerMs:r,rttMs:n}):null;return(0,J.jsxs)(J.Fragment,{children:[d?(0,J.jsxs)(`span`,{className:`flex h-full items-center px-2 font-mono text-[10px] text-muted-foreground`,"data-slot":`call-api-path-used`,"data-path":d,children:[`via `,d===`clock`?`clock.run-now`:`flows.invoke`]}):null,p?(0,J.jsxs)(`span`,{className:o(`inline-flex h-full items-center gap-1 px-2 font-mono text-[10px] font-semibold`,e?`text-destructive`:`text-emerald-700 dark:text-emerald-400`),"data-slot":`call-api-status`,"data-failed":e?`true`:`false`,children:[(0,J.jsx)(i,{icon:e?Ee:l,className:`size-3`,"aria-hidden":!0}),a??(e?`error`:`ok`)]}):null,p?(0,J.jsx)(`span`,{className:`flex h-full items-center px-2`,children:(0,J.jsx)(wt,{cache:f??`none`,dataSlot:`call-api-cache`})}):null,m?(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:e=>(0,J.jsx)(`span`,{...e,className:`flex h-full items-center px-2 font-mono text-[10px] tabular-nums text-muted-foreground`,"data-slot":`call-api-duration`,"data-kind":m.primaryKind,children:je(m.primaryMs)})}),(0,J.jsx)(c,{side:`bottom`,className:`max-w-xs text-[11px]`,children:m.primaryKind===`handler`?`Handler time — same clock as Traces.`:`Browser round-trip. Handler time is on the Traces row.`})]}):null,m?.primaryKind===`handler`&&m.rttMs!==null?(0,J.jsxs)(`span`,{className:`flex h-full items-center px-2 font-mono text-[10px] tabular-nums text-muted-foreground/70`,"data-slot":`call-api-rtt`,title:`Browser round-trip`,children:[je(m.rttMs),` rtt`]}):null]})}function jn({title:e,actions:t,children:n,dataTrigger:a,dataMode:s}){return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`call-api-panel`,"data-trigger":a,"data-mode":s,children:[(0,J.jsxs)(`div`,{className:o(r,`min-w-0`),children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 px-2`,children:[(0,J.jsx)(i,{icon:te,className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsx)(`h3`,{className:o(I,`text-foreground`),children:e})]}),(0,J.jsx)(`div`,{className:`ml-auto flex h-full min-w-0 items-stretch`,children:t})]}),(0,J.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:n})]})}function Mn({view:e,onChange:t}){return(0,J.jsxs)(`div`,{className:`flex h-full shrink-0 items-stretch`,role:`group`,"aria-label":`Body view`,"data-slot":`call-api-body-view-toggle`,children:[(0,J.jsx)(Nn,{active:e===`fields`,label:`Fields`,icon:Ge,onClick:()=>t(`fields`)}),(0,J.jsx)(Nn,{active:e===`raw`,label:`Raw`,icon:xe,onClick:()=>t(`raw`)})]})}function Nn({active:e,label:t,icon:n,onClick:r}){return(0,J.jsxs)(`button`,{type:`button`,className:o(h,`font-semibold tracking-[0.08em] uppercase`,e?ee:R),"aria-pressed":e,"aria-label":t,onClick:r,children:[(0,J.jsx)(i,{icon:n,className:`size-3`}),(0,J.jsx)(`span`,{className:`hidden sm:inline`,children:t})]})}var Pn=`h-full rounded-none border-0 bg-transparent px-2 text-[10px] font-semibold tracking-[0.08em] uppercase shadow-none hover:bg-muted/50`,Fn=`h-full rounded-none border-0 px-3 text-[10px] font-semibold tracking-[0.14em] uppercase shadow-none`;function In(){return(0,J.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0})}var Ln=`h-7 w-full justify-between rounded-none border-0 bg-transparent px-2 shadow-none focus-visible:border-0 focus-visible:ring-0 dark:bg-transparent dark:hover:bg-transparent`;function Rn({title:e,hint:t}){return(0,J.jsxs)(`div`,{className:F,children:[(0,J.jsx)(`h4`,{className:o(I,`flex items-center px-2`),children:e}),t?(0,J.jsx)(`span`,{className:`ml-auto flex items-center px-2 text-[10px] text-muted-foreground`,children:t}):null]})}function zn({field:e,value:t,onChange:n,error:r,wide:i=!1,manifest:s,idPrefix:c=`body`}){let l=`${c}-${e.name}`,u=Bn(e,s),d=[e.required?null:`optional`,u.lookup?`fk · ${u.lookup.child}.${u.lookup.column}`:e.type,u.lookup?null:Bt(e)].filter(Boolean).join(` · `),f=r?(0,J.jsx)(`p`,{className:`px-3 pb-2 text-xs text-destructive`,children:r.message}):null,p=o(i&&`col-span-full border-r-0`);if(u.lookup){let r=t==null||t===``?``:String(t),i=Vn(u.options,r);return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsxs)(W,{value:r||null,onValueChange:e=>{e==null||Array.isArray(e)||n(String(e))},children:[(0,J.jsx)(V,{id:l,className:Ln,disabled:u.isLoading,children:(0,J.jsx)(G,{placeholder:u.isLoading?`Loading…`:`Select…`})}),(0,J.jsx)(U,{children:i.map(e=>(0,J.jsx)(H,{value:e.value,children:e.label},e.value))})]}),f]})}if(e.type===`enum`&&e.enumValues)return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsxs)(W,{value:String(t??``),onValueChange:e=>{e==null||Array.isArray(e)||n(String(e))},children:[(0,J.jsx)(V,{id:l,className:Ln,children:(0,J.jsx)(G,{})}),(0,J.jsx)(U,{children:e.enumValues.map(e=>(0,J.jsx)(H,{value:e,children:e},e))})]}),f]});if(e.type===`boolean`)return(0,J.jsx)(K,{label:e.name,hint:d,dense:!0,className:p,children:(0,J.jsxs)(W,{value:t===!0?`true`:`false`,onValueChange:e=>{e==null||Array.isArray(e)||n(String(e)===`true`)},children:[(0,J.jsx)(V,{id:l,className:Ln,children:(0,J.jsx)(G,{})}),(0,J.jsxs)(U,{children:[(0,J.jsx)(H,{value:`true`,children:`true`}),(0,J.jsx)(H,{value:`false`,children:`false`})]})]})});if(e.type===`integer`||e.type===`number`){let r=Wt(e);if(r){let i=typeof t==`number`?String(t):``;return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsxs)(W,{value:i||null,onValueChange:e=>{e==null||Array.isArray(e)||n(Number(e))},children:[(0,J.jsx)(V,{id:l,className:Ln,children:(0,J.jsx)(G,{placeholder:`Select…`})}),(0,J.jsx)(U,{children:r.map(t=>{let n=e.valueMeanings?.find(e=>e.value===String(t));return(0,J.jsx)(H,{value:String(t),children:n?`${t} · ${n.label}`:t},t)})})]}),f]})}return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsx)(a,{id:l,type:`number`,flat:!0,className:o(vt,`h-7 px-2 font-mono`),min:e.minimum,max:e.maximum,step:e.type===`integer`?1:void 0,value:typeof t==`number`?t:``,onChange:t=>{if(t.target.value===``){n(void 0);return}n(Hn(Number(t.target.value),e.minimum,e.maximum))}}),f]})}return(0,J.jsxs)(K,{label:e.name,hint:d,dense:!0,className:p,children:[(0,J.jsx)(a,{id:l,flat:!0,className:o(vt,`h-7 px-2 font-mono`),value:typeof t==`string`?t:t==null?``:String(t),onChange:e=>n(e.target.value)}),f]})}function Bn(e,t){let n=(0,q.useMemo)(()=>Jt(e,t),[e,t]),r=nt(n?{ref:n.ref,child:n.child,limit:200}:null,n!==null);return{lookup:n,options:(0,q.useMemo)(()=>Yt(r.data?.rows??[],n),[r.data?.rows,n]),isLoading:r.isFetching}}function Vn(e,t){return!t||e.some(e=>e.value===t)?e:[{value:t,label:t},...e]}function Hn(e,t,n){let r=e;return t!==void 0&&r<t&&(r=t),n!==void 0&&r>n&&(r=n),r}function Z({title:e,meta:t,ruled:n=!0}){return(0,J.jsxs)(`div`,{className:o(`flex items-baseline justify-between gap-2`,n&&`border-b border-border/60 pb-1.5`),children:[(0,J.jsx)(`h3`,{className:I,children:e}),t?(0,J.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:t}):null]})}function Un({method:e,className:t}){return(0,J.jsx)(Se,{variant:`outline`,className:o(`h-5 px-1.5 font-mono text-[10px] uppercase`,le(e),t),"data-slot":`http-method-badge`,children:e})}var Wn=[`once`,`broadcast`,`live`],Gn={once:{delivery:`once`,icon:Dt,label:`once`,title:`once — one consumer claims; retries + DLQ`,wellClass:`border-amber-500/35 bg-amber-500/10 text-amber-700 dark:text-amber-400`,badgeClass:`border-amber-500/35 bg-amber-500/15 text-amber-800 dark:text-amber-400`},broadcast:{delivery:`broadcast`,icon:Et,label:`broadcast`,title:`broadcast — every subscriber gets a copy`,wellClass:`border-sky-500/35 bg-sky-500/10 text-sky-700 dark:text-sky-400`,badgeClass:`border-sky-500/35 bg-sky-500/15 text-sky-700 dark:text-sky-400`},live:{delivery:`live`,icon:ne,label:`live`,title:`live — retained feed; late subscribers replay history`,wellClass:`border-emerald-500/35 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`,badgeClass:`border-emerald-500/35 bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`}};function Kn({delivery:e,className:t}){let n=Gn[e];return(0,J.jsx)(Se,{variant:`outline`,title:n.title,className:o(`h-5 px-1.5 font-mono text-[10px]`,n.badgeClass,t),"data-slot":`signal-delivery-badge`,"data-delivery":e,children:n.label})}function qn({effects:e}){let t=Jn(e);return t.length===0?null:(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`effects-summary`,"aria-label":`Effects`,children:[(0,J.jsx)(Z,{title:`Effects`,meta:String(t.length)}),(0,J.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>{let t=He(e.kind),n=Ie(e.kind,e.ref),r=e.kind===`call`?Fe(e.ref):null;return(0,J.jsxs)(`li`,{className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px]`,style:{borderColor:`${t}55`,color:t},title:r??`${Ve[e.kind]} ${e.ref}`,children:[(0,J.jsx)(i,{icon:n,className:`size-3`}),r?(0,J.jsx)(`span`,{className:`text-foreground/90`,children:r}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:Ve[e.kind]}),(0,J.jsx)(`span`,{className:`text-foreground/90`,children:e.ref})]})]},`${e.kind}:${e.ref}`)})})]})}function Jn(e){if(!e)return[];let t=[],n=(e,n)=>{for(let r of n??[]){let n=typeof r==`string`?r:r.ref??String(r);t.push({kind:e,ref:n})}};return n(`read`,e.reads),n(`write`,e.writes),n(`emit`,e.emits),n(`send`,e.sends),n(`ask`,e.asks),n(`embed`,e.embeds),n(`secret`,e.secrets),n(`call`,e.calls),n(`fetch`,e.fetches),t}function Yn({errors:e}){let t=Xn(e);return t.length===0?null:(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`errors-section`,"aria-label":`Flow errors`,children:[(0,J.jsx)(Z,{title:`Flow errors`,meta:String(t.length)}),(0,J.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>{let t=(e.schema?X(e.schema):[]).map(e=>e.name).join(`, `);return(0,J.jsxs)(`li`,{className:`inline-flex items-center gap-1 rounded-md border border-destructive/25 bg-destructive/[0.04] px-1.5 py-0.5 font-mono text-[10px] text-destructive`,title:t?`{ code, data: { ${t} } }`:`Typed error — { code, data }`,"data-slot":`error-code`,"data-code":e.code,children:[(0,J.jsx)(i,{icon:Ee,className:`size-3`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`text-foreground/90`,children:e.code}),t?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:t}):null]},e.code)})})]})}function Xn(e){return e?Array.isArray(e)?e.map(e=>({code:e,schema:null})):Object.entries(e).map(([e,t])=>({code:e,schema:qt(t)})):[]}var Zn=36e5;function Qn(e,t,n,r=Zn){let i=St(e,new Set([t])),a=n-r,o=i.filter(e=>e.startedAt>=a);if(o.length===0)return{kind:`empty`};let s=o.filter(e=>e.error!=null&&e.error.length>0).length,c=o[0];return{kind:`summary`,calls:o.length,errors:s,errorRate:s/o.length,lastStartedAt:c.startedAt,latestRunId:c.id,windowMs:r}}function $n({flowId:e,runs:t,nowMs:n=Date.now(),windowMs:r=Zn,children:i}){let a=Qn(t??[],e,n,r);return(0,J.jsxs)(`div`,{className:o(F,`px-2`),"data-slot":`flow-activity-strip`,"data-kind":a.kind,"aria-label":`Recent activity`,children:[(0,J.jsx)(`span`,{className:o(I,`flex items-center`),children:`Activity`}),(0,J.jsx)(er,{summary:a,nowMs:n}),i?(0,J.jsx)(`div`,{className:`ml-auto flex h-full items-stretch`,children:i}):null]})}function er({summary:e,nowMs:t}){if(e.kind===`empty`)return(0,J.jsx)(`p`,{className:`flex items-center text-[11px] text-muted-foreground`,"data-slot":`flow-activity-empty`,children:`No recent runs in the Console buffer.`});let n=Math.round(e.errorRate*100),r=tr(e.lastStartedAt,t);return(0,J.jsxs)(`p`,{className:`flex min-w-0 items-center gap-x-2 text-[11px] text-foreground/85`,children:[(0,J.jsxs)(`span`,{className:`tabular-nums`,"data-slot":`flow-activity-calls`,children:[e.calls,` call`,e.calls===1?``:`s`]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,"aria-hidden":!0,children:`·`}),(0,J.jsxs)(`span`,{className:`tabular-nums`,"data-slot":`flow-activity-errors`,children:[n,`% errors`]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,"aria-hidden":!0,children:`·`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,"data-slot":`flow-activity-ago`,children:r}),(0,J.jsx)(gt,{to:`/overview`,search:{run:e.latestRunId},className:o(h,R),"data-slot":`flow-activity-open-run`,children:`Open latest`})]})}function tr(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.max(1,Math.round(n/1e3))}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function nr(e){switch(e){case`string`:return`border-teal-500/35 bg-teal-500/10 text-teal-800 dark:text-teal-300`;case`integer`:return`border-blue-500/35 bg-blue-500/10 text-blue-800 dark:text-blue-300`;case`number`:return`border-amber-500/35 bg-amber-500/10 text-amber-800 dark:text-amber-300`;case`boolean`:return`border-violet-500/35 bg-violet-500/10 text-violet-800 dark:text-violet-300`;case`enum`:return`border-indigo-500/35 bg-indigo-500/10 text-indigo-800 dark:text-indigo-300`;case`array`:return`border-cyan-500/35 bg-cyan-500/10 text-cyan-800 dark:text-cyan-300`;case`object`:return`border-zinc-500/35 bg-zinc-500/10 text-zinc-700 dark:text-zinc-300`;default:return`border-border/70 bg-muted/40 text-muted-foreground`}}function rr({fields:e,emptyLabel:t=`No schema fields declared.`,layout:n=`list`}){return e.length===0?(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-slot":`schema-fields-empty`,children:t}):n===`grid`?(0,J.jsx)(`div`,{"data-slot":`schema-fields`,"data-layout":`grid`,children:(0,J.jsx)(bt,{columns:3,children:e.map(e=>(0,J.jsx)(ir,{field:e,depth:0,cell:!0},e.path))})}):(0,J.jsx)(`ul`,{className:`flex flex-col`,"data-slot":`schema-fields`,children:e.map(e=>(0,J.jsx)(ir,{field:e,depth:0},e.path))})}function ir({field:e,depth:t,cell:n=!1}){let r=e.type===`enum`&&e.enumValues,i=Bt(e);return(0,J.jsxs)(n?`div`:`li`,{className:n?`min-w-0 border-b border-border/50`:void 0,children:[(0,J.jsxs)(`div`,{className:n?`flex items-center gap-1.5 px-2 py-1.5`:`flex items-center gap-2 py-1`,style:n?void 0:{paddingLeft:t*14},"data-slot":`schema-field-row`,children:[(0,J.jsx)(`span`,{className:`shrink-0`,"data-slot":`schema-field-keys`,title:ar(e),children:(0,J.jsx)(ie,{primaryKey:e.primaryKey,foreignKey:e.foreignKey,unique:e.unique,empty:`none`})}),(0,J.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] font-medium text-foreground/90`,children:e.name}),e.required?null:(0,J.jsx)(`span`,{className:`shrink-0 rounded border border-border/60 bg-muted/30 px-1 py-px text-[9px] font-medium tracking-wide text-muted-foreground uppercase`,"data-slot":`schema-field-optional`,children:`optional`}),e.pii?(0,J.jsx)(`span`,{className:`shrink-0 rounded border border-amber-500/40 bg-amber-500/10 px-1 py-px text-[9px] font-medium tracking-wide text-amber-800 uppercase dark:text-amber-300`,"data-slot":`schema-field-pii`,children:`pii`}):null,e.sensitive?(0,J.jsx)(`span`,{className:`shrink-0 rounded border border-rose-500/40 bg-rose-500/10 px-1 py-px text-[9px] font-medium tracking-wide text-rose-700 uppercase dark:text-rose-300`,"data-slot":`schema-field-sensitive`,children:`sensitive`}):null,i&&!r?(0,J.jsx)(`span`,{className:`shrink-0 rounded border border-blue-500/35 bg-blue-500/10 px-1 py-px font-mono text-[9px] font-medium tracking-wide text-blue-800 dark:text-blue-300`,"data-slot":`schema-field-constraint`,title:`Allowed range ${i}`,children:i}):null,(0,J.jsx)(`span`,{className:o(`ml-auto shrink-0 rounded border px-1.5 py-px font-mono text-[9px] font-medium tracking-wide`,nr(e.type)),"data-slot":`schema-field-type`,title:r?e.enumValues?.join(` | `):e.type,children:e.type})]}),e.children?.map(e=>(0,J.jsx)(ir,{field:e,depth:t+1,cell:n},e.path))]})}function ar(e){let t=[];if(e.primaryKey&&t.push(`Primary key`),e.foreignKey){let n=e.references?[e.references.table,e.references.column].filter(Boolean).join(`.`):null;t.push(n?`Foreign key → ${n}`:`Foreign key`)}return e.unique&&t.push(`Unique`),t.length>0?t.join(` · `):`None`}function or({fields:e}){let t=Ht(e);return t.length===0?null:(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`validation-section`,"aria-label":`Validation`,children:[(0,J.jsx)(Z,{title:`Validation`,meta:String(t.length)}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-3`,children:t.map(e=>(0,J.jsx)(sr,{field:e},e.path))})]})}function sr({field:e}){let t=Vt(e),n=e.valueMeanings?.length?e.valueMeanings:e.enumValues?.map(e=>({value:e,label:e}));return(0,J.jsxs)(`li`,{className:`flex flex-col gap-1.5`,"data-slot":`validation-field`,"data-field":e.name,children:[(0,J.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,J.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-foreground/90`,children:e.name}),t?(0,J.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t}):null]}),n&&n.length>0?(0,J.jsx)(`ul`,{className:`grid grid-cols-2 gap-x-4 gap-y-1 sm:grid-cols-3 lg:grid-cols-5`,children:n.map(e=>(0,J.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5 font-mono text-[11px]`,"data-slot":`validation-option`,children:[(0,J.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.value}),(0,J.jsx)(`span`,{className:`truncate text-foreground/90`,children:e.label})]},e.value))}):null]})}function cr({row:e,manifest:t,runs:n,leading:r}){let a=B(e.flow.trigger),s=Be(e.flow.trigger),c=Ue(t,e.id,a===`http`?`http`:a===`internal`?`internal`:a),l=qt(e.flow.in),u=qt(e.flow.out),d=We(e.flow.gates??[],t),f=a===`signal`&&e.flow.trigger?.signal?t?.signals?.[e.flow.trigger.signal]:void 0,p=a===`cron`||a===`every`?pn(t,e.id):null,m=a===`internal`?Ct(t,e.id):[],g=a===`http`?`Request`:`Input`,_=a===`http`?`Response`:`Output`,v=a!==`cron`&&a!==`every`,y=X(l),b=X(u),x=jt(y,a===`http`&&e.path?cn(e.path):[]);return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`flow-contract-panel`,"data-trigger":a,children:[(0,J.jsx)(yt,{dataSlot:`endpoint-header`,leading:r,icon:(0,J.jsx)(`span`,{"data-slot":`trigger-kind-icon`,"data-kind":a,children:(0,J.jsx)(i,{icon:s.icon,className:`size-4`})}),wellClassName:s.wellClass,title:(0,J.jsx)(`span`,{className:`font-mono`,children:e.id}),badge:(0,J.jsx)(`span`,{className:`font-mono text-[10px] font-medium tracking-[0.08em] text-muted-foreground uppercase`,"data-slot":`trigger-kind-badge`,children:s.label}),subtitle:a===`http`&&c.method&&c.path?(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,"data-slot":`http-endpoint-line`,children:[(0,J.jsx)(Un,{method:c.method}),(0,J.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[11px] leading-none text-muted-foreground select-all`,children:c.path})]}):a===`signal`&&f?(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,"data-slot":`signal-endpoint-line`,children:[(0,J.jsx)(Kn,{delivery:f.delivery}),(0,J.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[11px] leading-none text-muted-foreground select-all`,children:e.flow.trigger?.signal})]}):(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] leading-none text-muted-foreground`,"data-slot":`trigger-headline`,children:c.headline}),actions:(0,J.jsxs)(gt,{to:`/overview`,search:{flow:e.id},"data-slot":`open-in-graph`,className:o(h,`text-sky-700 dark:text-sky-400`),children:[(0,J.jsx)(i,{icon:be.flow.icon,className:`size-3.5`,"aria-hidden":!0}),`Open in graph`]})}),(0,J.jsxs)($n,{flowId:e.id,runs:n,children:[e.flow.plane?(0,J.jsx)(lr,{plane:e.flow.plane}):null,e.flow.durable?(0,J.jsx)(ur,{icon:Pe,label:`durable`,title:`Durable — long-running, retryable steps`}):null,e.flow.live?(0,J.jsx)(ur,{icon:pe,label:`live`,title:typeof e.flow.live==`string`?`Live — SSE for ${e.flow.live}`:`Live — SSE signal feed`}):null]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsx)(qn,{effects:e.flow.effects}),(0,J.jsx)(ze,{gates:d}),(0,J.jsx)(Yn,{errors:e.flow.errors}),a===`signal`&&f&&(f.retries!==void 0||f.deadLetter)?(0,J.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`signal-delivery`,children:[f.retries===void 0?null:`retries ${f.retries}`,f.deadLetter?`dead-letter`:null].filter(e=>e!==null).join(` · `)}):null,(a===`cron`||a===`every`)&&p?.kind===`matched`?(0,J.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`clock-join`,children:[`Clock · `,(0,J.jsx)(`span`,{className:`font-mono`,children:p.clockName}),p.timezone?` · ${p.timezone}`:``]}):null,a===`internal`?(0,J.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`call-only-note`,children:[`No external trigger — reachable via `,(0,J.jsx)(`code`,{className:`font-mono`,children:`effects.calls`}),` /`,` `,(0,J.jsx)(`code`,{className:`font-mono`,children:`fx.call`}),`.`]}):null,a===`internal`?(0,J.jsxs)(`section`,{className:`flex flex-col gap-1.5`,"aria-label":`Callers`,"data-slot":`callers-list`,children:[(0,J.jsx)(Z,{title:`Called by`,meta:String(m.length)}),m.length===0?(0,J.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`No Manifest caller declares `,(0,J.jsx)(`code`,{className:`font-mono`,children:`effects.calls`}),` for this flow.`]}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:m.map(e=>(0,J.jsx)(`li`,{className:`font-mono text-xs text-foreground/90`,children:e},e))})]}):null,v&&x.parameters.length>0?(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`Parameters`,"data-slot":`parameters`,children:[(0,J.jsx)(Z,{title:`Parameters`,meta:String(x.parameters.length)}),(0,J.jsx)(rr,{fields:x.parameters,layout:`grid`})]}):null,(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[v&&(x.fields.length>0||x.parameters.length===0)?(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":g,"data-slot":`request`,children:[(0,J.jsx)(Z,{title:g,meta:String(x.fields.length)}),(0,J.jsx)(rr,{fields:x.fields,emptyLabel:typeof e.flow.in==`string`?`Schema not expanded in Manifest.`:a===`signal`?`No flow input schema — signal payload shape lives on the signal when declared.`:`No input schema declared.`})]}):null,(0,J.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":_,children:[(0,J.jsx)(Z,{title:_,meta:String(b.length)}),(0,J.jsx)(rr,{fields:b,emptyLabel:typeof e.flow.out==`string`?`Schema not expanded in Manifest.`:`No output schema declared.`})]})]}),v?(0,J.jsx)(or,{fields:y}):null]})})]})}function lr({plane:e}){let t=e===`operator`,n=t?he:Ke,r=t?`operator`:`user`;return(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:t=>(0,J.jsxs)(`span`,{...t,className:o(h,`cursor-help`),"data-slot":`plane-badge`,"data-plane":e,children:[(0,J.jsx)(i,{icon:n,className:`size-3`,"aria-hidden":!0}),r]})}),(0,J.jsx)(c,{side:`bottom`,className:`max-w-xs text-[11px]`,children:t?`Operator plane — runs under a Console operator identity, not an application user.`:`User plane — runs under an application user identity (invoke-as).`})]})}function ur({icon:e,label:t,title:n}){return(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:n=>(0,J.jsxs)(`span`,{...n,className:o(h,R,`cursor-help`),children:[(0,J.jsx)(i,{icon:e,className:`size-3`,"aria-hidden":!0}),t]})}),(0,J.jsx)(c,{side:`bottom`,className:`max-w-xs text-[11px]`,children:n})]})}function dr(e){let t=new Map(Le.map(e=>[e,[]]));for(let n of e){let e=new Map;for(let t of n.flows){let n=B(t.flow.trigger),r=e.get(n)??[];r.push(t),e.set(n,r)}for(let[r,i]of e)t.get(r)?.push({unit:n.unit,flows:i})}return Le.flatMap(e=>{let n=t.get(e)??[];return n.length===0?[]:[{id:e,label:Re[e].label,groups:n}]})}function fr(e){return`band:${e}`}function pr(e,t){return`unit:${e}:${t}`}function mr(e,t,n=!1){let r=t[e];return r===void 0?n:r}function hr(e){let t=[];for(let n of e){t.push(fr(n.id));for(let e of n.groups)t.push(pr(n.id,e.unit))}return t}function gr(e,t){for(let n of e)for(let e of n.groups)if(e.flows.some(e=>e.id===t))return[fr(n.id),pr(n.id,e.unit)];return[]}function _r(e,t){let n=z(e.method)-z(t.method);return n===0?e.id.localeCompare(t.id):n}function vr(e){let t=e?.flows;if(!t)return[];let n=new Map;for(let[r,i]of Object.entries(t)){let t=xt(r),a=r.includes(`.`)?r.slice(r.indexOf(`.`)+1):r,o=i.trigger?.http,s=i.trigger?.signal??null,c={id:r,unit:t,action:a,flow:i,method:o?.method??null,path:o?.path??null,signal:s,delivery:s?e.signals?.[s]?.delivery??null:null},l=n.get(t)??[];l.push(c),n.set(t,l)}return[...n.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({unit:e,flows:t.sort(_r)}))}function yr(e,t){let n=t.trim().toLowerCase();return n?e.map(e=>{let t=e.unit.toLowerCase().includes(n)?e.flows:e.flows.filter(e=>e.id.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)||(e.method?.toLowerCase().includes(n)??!1)||(e.path?.toLowerCase().includes(n)??!1)||(e.signal?.toLowerCase().includes(n)??!1)||(e.delivery?.toLowerCase().includes(n)??!1));return t.length>0?{unit:e.unit,flows:t}:null}).filter(e=>e!==null):e}function br(e){return(e.triggerKinds?.length??0)+(e.planes?.length??0)+(e.deliveries?.length??0)+ +!!e.durableOnly+ +!!e.liveOnly}function xr(e,t){let n=t.triggerKinds?.length?new Set(t.triggerKinds):null,r=t.planes?.length?new Set(t.planes):null,i=t.deliveries?.length?new Set(t.deliveries):null,a=t.durableOnly===!0,o=t.liveOnly===!0;return!n&&!r&&!i&&!a&&!o?e:e.map(e=>{let t=e.flows.filter(e=>!(n&&!n.has(B(e.flow.trigger))||r&&!r.has(e.flow.plane??`user`)||i&&(e.delivery===null||!i.has(e.delivery))||a&&!e.flow.durable||o&&!e.flow.live));return t.length>0?{unit:e.unit,flows:t}:null}).filter(e=>e!==null)}var Sr={user:{icon:Ke,label:`user`},operator:{icon:he,label:`operator`}},Cr=[`user`,`operator`];function wr({groups:e,selectedFlowId:t,onSelect:n}){let[a,l]=(0,q.useState)(``),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)({}),[h,_]=(0,q.useState)({}),v=(0,q.useMemo)(()=>{let t=new Set;for(let n of e)for(let e of n.flows)t.add(B(e.flow.trigger));return Le.filter(e=>t.has(e))},[e]),y=(0,q.useMemo)(()=>{let t=new Set;for(let n of e)for(let e of n.flows)e.flow.plane&&t.add(e.flow.plane);return Cr.filter(e=>t.has(e))},[e]),{hasDurable:b,hasLive:x,availableDeliveries:S}=(0,q.useMemo)(()=>{let t=!1,n=!1,r=new Set;for(let i of e)for(let e of i.flows)e.flow.durable&&(t=!0),e.flow.live&&(n=!0),e.delivery&&r.add(e.delivery);return{hasDurable:t,hasLive:n,availableDeliveries:Wn.filter(e=>r.has(e))}},[e]),C=br(p),w=(0,q.useMemo)(()=>dr(xr(yr(e,a),p)),[e,a,p]),T=(0,q.useMemo)(()=>hr(w),[w]),E=a.trim().length>0,D=T.length>0&&T.every(e=>mr(e,h,E));(0,q.useEffect)(()=>{if(!t)return;let e=gr(w,t);e.length!==0&&_(t=>{let n=!1,r={...t};for(let t of e)r[t]!==!0&&(r[t]=!0,n=!0);return n?r:t})},[t,w]);let O=(e,t)=>{_(n=>n[e]===t?n:{...n,[e]:t})},k=()=>{let e=!D;_(t=>{let n={...t};for(let t of T)n[t]=e;return n})},A=e=>m(t=>({...t,triggerKinds:Tr(t.triggerKinds??[],e)})),j=e=>m(t=>({...t,planes:Tr(t.planes??[],e)})),M=e=>m(t=>({...t,[e]:!t[e]})),N=e=>m(t=>({...t,deliveries:Tr(t.deliveries??[],e)}));return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`units-tree`,children:[(0,J.jsxs)(`div`,{className:`shrink-0 border-b border-border/60`,children:[(0,J.jsxs)(`div`,{className:o(r,`border-b-0`),children:[(0,J.jsx)(fe,{value:a,onChange:e=>l(e.target.value),placeholder:`Search flows…`,"aria-label":`Search flows`,"data-slot":`units-search`}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-stretch pr-0.5`,children:[(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:e=>(0,J.jsxs)(`button`,{...e,type:`button`,"aria-expanded":d,"aria-controls":`units-advanced-panel`,"aria-label":C>0?`Advanced filters, ${C} active`:`Advanced filters`,"data-slot":`units-advanced-toggle`,onClick:t=>{e.onClick?.(t),f(e=>!e)},className:o(g,`relative`,(d||C>0)&&`text-foreground`),children:[(0,J.jsx)(i,{icon:qe,className:`size-3`,"aria-hidden":!0}),C>0?(0,J.jsx)(`span`,{"data-slot":`units-advanced-count`,className:`absolute -top-0.5 -inset-e-0.5 flex size-3.5 items-center justify-center rounded-full bg-foreground text-[8px] font-medium text-background`,"aria-hidden":!0,children:C}):null]})}),(0,J.jsx)(c,{side:`bottom`,children:`Advanced`})]}),(0,J.jsx)(st,{allOpen:D,disabled:T.length===0,onToggle:k,dataSlot:`units-tree-expand-toggle`})]})]}),d?(0,J.jsxs)(`div`,{id:`units-advanced-panel`,"data-slot":`units-advanced-panel`,className:`flex flex-col gap-2 border-t border-border/60 bg-muted/20 p-2`,children:[(0,J.jsx)(Q,{label:`Trigger`,groupLabel:`Trigger kind filter`,children:v.map(e=>{let t=Re[e];return(0,J.jsx)($,{icon:t.icon,label:t.label,pressed:p.triggerKinds?.includes(e)??!1,onToggle:()=>A(e),dataFacet:`kind:${e}`},e)})}),S.length>0?(0,J.jsx)(Q,{label:`Delivery`,groupLabel:`Signal delivery filter`,children:S.map(e=>{let t=Gn[e];return(0,J.jsx)($,{icon:t.icon,label:t.label,pressed:p.deliveries?.includes(e)??!1,onToggle:()=>N(e),dataFacet:`delivery:${e}`},e)})}):null,y.length>0?(0,J.jsx)(Q,{label:`Plane`,groupLabel:`Plane filter`,children:y.map(e=>{let t=Sr[e];return(0,J.jsx)($,{icon:t.icon,label:t.label,pressed:p.planes?.includes(e)??!1,onToggle:()=>j(e),dataFacet:`plane:${e}`},e)})}):null,b||x?(0,J.jsxs)(Q,{label:`Flags`,groupLabel:`Flow flags filter`,children:[b?(0,J.jsx)($,{icon:Pe,label:`durable`,pressed:p.durableOnly??!1,onToggle:()=>M(`durableOnly`),dataFacet:`flag:durable`}):null,x?(0,J.jsx)($,{icon:pe,label:`live`,pressed:p.liveOnly??!1,onToggle:()=>M(`liveOnly`),dataFacet:`flag:live`}):null]}):null,C>0?(0,J.jsx)(`button`,{type:`button`,"data-slot":`units-advanced-clear`,onClick:()=>m({}),className:`self-end px-2 py-1 text-[10px] font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,children:`Clear all`}):null]}):null]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto`,children:w.length===0?(0,J.jsx)(`p`,{className:P,children:`No flows match.`}):(0,J.jsx)(`div`,{className:`flex flex-col`,children:w.map(e=>{let r=fr(e.id);return(0,J.jsx)(Er,{band:e,open:mr(r,h,E),onOpenChange:e=>O(r,e),groupOpen:t=>mr(pr(e.id,t),h,E),onGroupOpenChange:(t,n)=>O(pr(e.id,t),n),selectedFlowId:t,onSelect:n},e.id)})})})]})}function Q({label:e,groupLabel:t,children:n}){return(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`w-14 shrink-0 text-[9px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:e}),(0,J.jsx)(`div`,{className:`flex min-h-7 flex-wrap items-stretch`,role:`group`,"aria-label":t,children:n})]})}function $({icon:e,label:t,pressed:n,onToggle:r,dataFacet:a}){return(0,J.jsxs)(`button`,{type:`button`,"data-slot":`units-facet-chip`,"data-facet":a,"aria-pressed":n,onClick:r,className:o(`inline-flex items-center gap-1 px-2 text-[10px] font-medium transition-colors hover:bg-muted/50`,n?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:[(0,J.jsx)(i,{icon:e,className:`size-3`,"aria-hidden":!0}),t]})}function Tr(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function Er({band:e,open:t,onOpenChange:n,groupOpen:r,onGroupOpenChange:a,selectedFlowId:s,onSelect:c}){let l=Re[e.id],u=e.groups.reduce((e,t)=>e+t.flows.length,0),f=e.groups.map(e=>e.unit),p=f.length>0&&f.every(e=>r(e)),h=()=>{let e=!p;for(let t of f)a(t,e);e&&n(!0)};return(0,J.jsx)(`section`,{"data-slot":`units-trigger-band`,"data-band":e.id,"aria-label":e.label,className:M,children:(0,J.jsxs)(De,{open:t,onOpenChange:n,children:[(0,J.jsx)(Te,{nativeButton:!1,className:E,"data-slot":`units-trigger-band-toggle`,render:n=>(0,J.jsxs)(`div`,{...n,children:[(0,J.jsx)(i,{icon:we,className:o(x,!t&&`-rotate-90`),"aria-hidden":!0}),(0,J.jsx)(i,{icon:l.icon,className:o(w,d(l.wellClass)),"aria-hidden":!0}),(0,J.jsx)(`span`,{className:o(A,`flex-1`),children:e.label}),(0,J.jsx)(`span`,{className:m,children:u}),(0,J.jsx)(`span`,{className:v,children:(0,J.jsx)(st,{allOpen:p,disabled:f.length===0,onToggle:h,collapseLabel:`Collapse all in ${e.label}`,expandLabel:`Expand all in ${e.label}`,dataSlot:`units-band-expand-toggle`,disclose:!0,bare:!0})})]})}),(0,J.jsx)(Ce,{children:(0,J.jsx)(`ul`,{className:`flex flex-col`,children:e.groups.map(t=>(0,J.jsx)(Dr,{group:t,open:r(t.unit),onOpenChange:e=>a(t.unit,e),selectedFlowId:s,onSelect:c},`${e.id}:${t.unit}`))})})]})})}function Dr({group:e,open:t,onOpenChange:n,selectedFlowId:r,onSelect:a}){return(0,J.jsx)(`li`,{"data-slot":`unit-group`,"data-unit":e.unit,children:(0,J.jsxs)(De,{open:t,onOpenChange:n,children:[(0,J.jsxs)(Te,{className:o(O,`pl-4`),children:[(0,J.jsx)(i,{icon:we,className:o(x,!t&&`-rotate-90`),"aria-hidden":!0}),(0,J.jsx)(i,{icon:lt,className:o(w,`text-muted-foreground`),"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.unit}),(0,J.jsx)(`span`,{className:m,children:e.flows.length})]}),(0,J.jsx)(Ce,{children:(0,J.jsx)(`ul`,{className:`flex flex-col`,children:e.flows.map(e=>(0,J.jsx)(Or,{flow:e,selected:r===e.id,onSelect:a},e.id))})})]})})}function Or({flow:e,selected:t,onSelect:n}){let r=Be(e.flow.trigger),a=e.delivery?Gn[e.delivery]:null,l=a?.icon??(e.method?ce(e.method):r.icon),f=d(a?.wellClass??(e.method?le(e.method):r.wellClass)),p=a?e.signal?`${a.title} · ${e.signal}`:a.title:r.detail?`${r.label} · ${r.detail}`:r.label;return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,"data-slot":`unit-flow-item`,"data-flow-id":e.id,"data-delivery":e.delivery??void 0,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:o(T,`group/flow pl-8`,t&&`bg-muted/70 text-foreground`),children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:o(k,t?y:`bg-transparent`)}),(0,J.jsxs)(s,{children:[(0,J.jsx)(u,{render:e=>(0,J.jsx)(`span`,{...e,className:o(w,f),"aria-hidden":!0,children:(0,J.jsx)(i,{icon:l,className:`size-3.5`})})}),(0,J.jsx)(c,{side:`right`,className:`text-[11px]`,children:p})]}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.action}),e.method?(0,J.jsx)(Un,{method:e.method,className:`ml-auto h-3.5 px-1 text-[8px] leading-none`}):null]})})}function kr(){let e=ke(),t=Me();Oe(!0);let{selectedFlowId:n,setSelectedFlow:r}=ht(),i=ge(),a=(0,q.useMemo)(()=>vr(e.data??null),[e.data]),o=(0,J.jsx)(_e,{open:i.open,onToggle:i.toggle,noun:`flows`,controlsId:`flows-tree`,dataSlot:`flows-tree-toggle`}),s=n??a[0]?.flows[0]?.id??null,c=(0,q.useMemo)(()=>{if(!s)return null;for(let e of a){let t=e.flows.find(e=>e.id===s);if(t)return t}return null},[a,s]);return(0,J.jsx)(`div`,{className:_,"data-slot":`units-page`,children:(0,J.jsxs)(ue,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,J.jsx)(me,{panelRef:i.panelRef,collapsible:!0,collapsedSize:0,defaultSize:f.start.defaultSize,minSize:f.start.minSize,onResize:i.onResize,className:`min-h-0 overflow-hidden`,children:(0,J.jsx)(`div`,{id:`flows-tree`,className:`h-full min-h-0 overflow-hidden`,"data-slot":`flows-tree`,children:(0,J.jsx)(wr,{groups:a,selectedFlowId:s,onSelect:e=>{r(e)}})})}),i.open?(0,J.jsx)(ve,{withHandle:!0}):null,(0,J.jsx)(me,{defaultSize:f.end.defaultSize,minSize:f.end.minSize,className:`min-h-0 overflow-hidden`,children:(0,J.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:c?(0,J.jsxs)(ue,{orientation:`vertical`,className:`min-h-0 flex-1`,"data-slot":`units-inspector`,children:[(0,J.jsx)(me,{defaultSize:`56%`,minSize:`28%`,className:`min-h-0 overflow-hidden`,children:(0,J.jsx)(cr,{row:c,manifest:e.data??null,runs:t.data,leading:o})}),(0,J.jsx)(ve,{withHandle:!0}),(0,J.jsx)(me,{defaultSize:`44%`,minSize:`220px`,className:`min-h-0 overflow-hidden`,children:(0,J.jsx)(Tn,{row:c,manifest:e.data??null})})]}):(0,J.jsx)(_t,{icon:be.flow.icon,title:e.isLoading?`Loading Manifest…`:`Select a flow`,description:e.isLoading?`Reading the derived Manifest.`:`Pick a flow from the tree to inspect its contract.`,leading:o})})})]})})}export{kr as UnitsPage};