okengine 0.21.0 → 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 (160) 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 -25
  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/dev.test.ts +105 -2
  33. package/src/cli/dev.ts +37 -2
  34. package/src/cli/docker-cli.test.ts +1 -1
  35. package/src/cli/index.ts +9 -1
  36. package/src/cli/load-config.images.test.ts +10 -10
  37. package/src/cli/load-config.ts +1 -1
  38. package/src/cli/vault-cmd.test.ts +23 -0
  39. package/src/cli/vault-cmd.ts +7 -0
  40. package/src/client/create.ts +31 -27
  41. package/src/client/live.ts +44 -101
  42. package/src/client/sse.ts +20 -66
  43. package/src/client/stream.ts +25 -67
  44. package/src/client/transport.test.ts +225 -0
  45. package/src/client/transport.ts +158 -90
  46. package/src/client/types.ts +29 -3
  47. package/src/client/wire.ts +119 -0
  48. package/src/compiler/aot.ts +3 -32
  49. package/src/compiler/dynamic.ts +13 -11
  50. package/src/compiler/effects-infer.ts +726 -16
  51. package/src/compiler/extract.test.ts +37 -0
  52. package/src/compiler/extract.ts +113 -12
  53. package/src/compiler/fixtures/skyport.expected.json +24 -0
  54. package/src/compiler/fx-follow.test.ts +164 -0
  55. package/src/compiler/fx-index.ts +399 -0
  56. package/src/compiler/interpret.ts +45 -0
  57. package/src/console/server/flows-invoke.test.ts +2 -2
  58. package/src/console/ui-next/dist/assets/{access-page-tIbsiphz.js → access-page-Ze6ckjdd.js} +2 -2
  59. package/src/console/ui-next/dist/assets/agent-disclosure-Bkohc_8X.js +1 -0
  60. package/src/console/ui-next/dist/assets/{cache-glyph-BCC-DxKT.js → cache-glyph-rL0lHxat.js} +1 -1
  61. package/src/console/ui-next/dist/assets/{call-pii-button-jOmYISdc.js → call-pii-button-Deo4PP18.js} +1 -1
  62. package/src/console/ui-next/dist/assets/{collapsible-DC2xNaAb.js → collapsible-CoJ6amHf.js} +1 -1
  63. package/src/console/ui-next/dist/assets/{copy-inline-button-CAYD18cr.js → copy-inline-button-CWG5_ZOh.js} +1 -1
  64. package/src/console/ui-next/dist/assets/{detail-header-DVWNjWjg.js → detail-header-b_ZzIsmU.js} +1 -1
  65. package/src/console/ui-next/dist/assets/{dropdown-menu-4h2LOVXM.js → dropdown-menu-nwXEO1Ac.js} +1 -1
  66. package/src/console/ui-next/dist/assets/duration-tone-BbQ_8z50.js +9 -0
  67. package/src/console/ui-next/dist/assets/element-icons-CwyLpVXz.js +1 -0
  68. package/src/console/ui-next/dist/assets/{explorer-empty-CJs5A-wm.js → explorer-empty-C8sSCqYT.js} +1 -1
  69. package/src/console/ui-next/dist/assets/{flows-page-gT1lsWQK.js → flows-page-D2E7BtKK.js} +1 -1
  70. package/src/console/ui-next/dist/assets/{highlighted-json-C2GZEJNI.js → highlighted-json-CPYBzDh0.js} +1 -1
  71. package/src/console/ui-next/dist/assets/{http-method-BdYjcIrD.js → http-method-DTPevKmM.js} +1 -1
  72. package/src/console/ui-next/dist/assets/index-vTuwmeQz.js +58 -0
  73. package/src/console/ui-next/dist/assets/observability-page-SJTSzHFJ.js +4 -0
  74. package/src/console/ui-next/dist/assets/{replica-lag-C4QdAF7J.js → replica-lag-BM27lXld.js} +3 -3
  75. package/src/console/ui-next/dist/assets/{request-meta-C43DHyld.js → request-meta-BjFT7DNl.js} +1 -1
  76. package/src/console/ui-next/dist/assets/shortcut-keys-CUNegEV4.js +1 -0
  77. package/src/console/ui-next/dist/assets/store-page-Qj9ThRE-.js +41 -0
  78. package/src/console/ui-next/dist/assets/{trace-detail-sheet-Dcpo4Us_.js → trace-detail-sheet-Cmitq3da.js} +2 -2
  79. package/src/console/ui-next/dist/assets/{tree-expand-toggle-CKJTuv43.js → tree-expand-toggle-CbDIB-7x.js} +2 -2
  80. package/src/console/ui-next/dist/assets/units-page-_PuYqFty.js +1 -0
  81. package/src/console/ui-next/dist/assets/{use-vault-list-CT4-gajj.js → use-vault-list-Cs45Czkt.js} +1 -1
  82. package/src/console/ui-next/dist/assets/{vault-page-BwZ9YjTW.js → vault-page-BOMr0go9.js} +2 -2
  83. package/src/console/ui-next/dist/index.html +2 -2
  84. package/src/console/ui-next/src/features/units/detail/flow-contract-panel.tsx +9 -0
  85. package/src/docker/docker.test.ts +13 -13
  86. package/src/docker/images-config.test.ts +12 -12
  87. package/src/docker/stack-id.test.ts +1 -1
  88. package/src/drivers/journal-postgres.ts +168 -3
  89. package/src/drivers/meilisearch.ts +2 -0
  90. package/src/drivers/vault-builtin.test.ts +10 -0
  91. package/src/drivers/vault-builtin.ts +13 -1
  92. package/src/drivers/vault-remote-bag.ts +5 -1
  93. package/src/drivers/vault-types.ts +6 -1
  94. package/src/elements/store/emit-drizzle.ts +2 -2
  95. package/src/elements/store/live-default.test.ts +2 -0
  96. package/src/elements/store/live-http.test.ts +1 -0
  97. package/src/elements/store/resource-list-docs.test.ts +2 -2
  98. package/src/elements/store/resource.test.ts +3 -3
  99. package/src/elements/store/schema-decl.test.ts +1 -0
  100. package/src/elements/store/sql-condition.ts +24 -7
  101. package/src/elements/store/sql-session.ts +20 -4
  102. package/src/elements/store/upsert-app.test.ts +1 -1
  103. package/src/elements/vault/audit.test.ts +137 -0
  104. package/src/elements/vault/audit.ts +106 -13
  105. package/src/elements/vault/boot-chain.ts +9 -1
  106. package/src/elements/vault/builtin-adapter.ts +33 -3
  107. package/src/i18n/catalogs/ar.ts +4 -0
  108. package/src/i18n/catalogs/en.ts +4 -0
  109. package/src/kernel/abort-scope.ts +33 -2
  110. package/src/kernel/app.ts +200 -20
  111. package/src/kernel/auto-cache.test.ts +6 -6
  112. package/src/kernel/boot-bind/vault.ts +1 -0
  113. package/src/kernel/boot.ts +19 -1
  114. package/src/kernel/builtin-errors.ts +8 -0
  115. package/src/kernel/client-descriptor.test.ts +78 -0
  116. package/src/kernel/client-descriptor.ts +24 -0
  117. package/src/kernel/concurrency.test.ts +33 -0
  118. package/src/kernel/effects-stamping.test.ts +2 -2
  119. package/src/kernel/errors-compiler.ts +20 -0
  120. package/src/kernel/errors-text.ts +99 -0
  121. package/src/kernel/errors.ts +90 -138
  122. package/src/kernel/external-effects.test.ts +36 -0
  123. package/src/kernel/flow.ts +24 -0
  124. package/src/kernel/fx-fetch.ts +5 -1
  125. package/src/kernel/fx-sql-handle.ts +305 -0
  126. package/src/kernel/fx.ts +42 -330
  127. package/src/kernel/idempotency-store.ts +578 -0
  128. package/src/kernel/idempotency.test.ts +556 -0
  129. package/src/kernel/idempotency.ts +304 -0
  130. package/src/kernel/index.ts +1 -0
  131. package/src/kernel/journal.ts +56 -0
  132. package/src/kernel/json-result.ts +59 -0
  133. package/src/kernel/project-out.ts +6 -1
  134. package/src/manifest/types.ts +8 -0
  135. package/src/okid-extended.ts +175 -0
  136. package/src/okid-shared.ts +103 -0
  137. package/src/okid.ts +30 -213
  138. package/src/plugins/auth-delivery.mailpit.integration.test.ts +1 -1
  139. package/src/plugins/otp.test.ts +65 -1
  140. package/src/plugins/otp.ts +59 -7
  141. package/src/release/absolute-regression.test.ts +63 -0
  142. package/src/release/build-lib.ts +9 -0
  143. package/src/release/http-graph.test.ts +25 -0
  144. package/src/release/http-graph.ts +90 -0
  145. package/src/release/index.ts +3 -0
  146. package/src/release/limits.ts +17 -2
  147. package/src/release/measure.ts +105 -14
  148. package/src/test/create-test-app.test.ts +3 -1
  149. package/src/test/create-test-app.ts +40 -0
  150. package/src/test/live-signals.test.ts +1 -0
  151. package/src/test/provisions.integration.test.ts +1 -0
  152. package/src/test/tenant-isolation.test.ts +1 -0
  153. package/src/console/ui-next/dist/assets/agent-disclosure-CSKumwS2.js +0 -1
  154. package/src/console/ui-next/dist/assets/duration-tone-CwoV56jn.js +0 -9
  155. package/src/console/ui-next/dist/assets/element-icons-BI8cJgdh.js +0 -1
  156. package/src/console/ui-next/dist/assets/index-Cul17AcV.js +0 -63
  157. package/src/console/ui-next/dist/assets/observability-page-oY9vdYBk.js +0 -4
  158. package/src/console/ui-next/dist/assets/shortcut-keys-3ILd8oGn.js +0 -1
  159. package/src/console/ui-next/dist/assets/store-page-CL0D9dOq.js +0 -41
  160. package/src/console/ui-next/dist/assets/units-page-1PlT19ft.js +0 -1
@@ -1,2 +1,2 @@
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{Dr as r,Er as i,F as a,I as o,Or as s,R as c,Tr as l,ar as u,br as d,cr as f,i as p,ir as m,l as h,lr as g,mr as _,o as ee,pr as te,s as ne,sr as v,u as re,vr as y,wr as ie,xr as b,yi as ae,yr as x}from"./shortcut-keys-3ILd8oGn.js";import{i as oe,o as se,t as S}from"./http-method-BdYjcIrD.js";import{b as ce,t as C}from"./element-icons-BI8cJgdh.js";import{a as le,i as ue,n as de,o as fe,r as pe,s as w,t as me}from"./collapsible-DC2xNaAb.js";import{a as he,c as ge,i as _e,o as T,s as ve,t as E}from"./duration-tone-CwoV56jn.js";import{c as ye,f as be,i as D,t as xe,u as O}from"./highlighted-json-C2GZEJNI.js";import{T as Se,c as k,f as Ce,i as we,l as Te,n as Ee,r as De,s as A,t as Oe,u as ke,w as Ae,y as j}from"./request-meta-C43DHyld.js";import{t as je}from"./PlusSignIcon-CwG3nxfu.js";import{D as M,J as N,L as P,N as F,O as I,R as L,c as R,d as z,l as Me,q as B}from"./index-Cul17AcV.js";var Ne=[[`path`,{d:`M20 12L4 12`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]];function V(...e){let t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],i=e[1+n],a=e[2+n],o=e[3+n],s=F(i,a,o);return t?s(r):s}var H=e(t(),1);function U(e){let t=N(()=>I(e)),{isStatic:n}=(0,H.useContext)(z);if(n){let[,n]=(0,H.useState)(e);(0,H.useEffect)(()=>t.on(`change`,n),[])}return t}function W(e,t){let n=U(t()),r=()=>n.set(t());return r(),B(()=>{let t=()=>L.preRender(r,!1,!0),n=e.map(e=>e.on(`change`,t));return()=>{n.forEach(e=>e()),P(r)}}),n}function G(e){M.current=[],e();let t=W(M.current,e);return M.current=void 0,t}function K(e,t,n,r){if(typeof e==`function`)return G(e);if(n!==void 0&&!Array.isArray(n)&&typeof t!=`function`)return Fe(e,t,n,r);let i=typeof t==`function`?t:V(t,n,r),a=Array.isArray(e)?Pe(e,i):Pe([e],([e])=>i(e)),o=Array.isArray(e)?void 0:e.accelerate;return o&&!o.isTransformed&&typeof t!=`function`&&Array.isArray(n)&&r?.clamp!==!1&&(a.accelerate={...o,times:t,keyframes:n,isTransformed:!0,...r?.ease?{ease:r.ease}:{}}),a}function Pe(e,t){let n=N(()=>[]);return W(e,()=>{n.length=0;let r=e.length;for(let t=0;t<r;t++)n[t]=e[t].get();return t(n)})}function Fe(e,t,n,r){let i=N(()=>Object.keys(n)),a=N(()=>({}));for(let o of i)a[o]=K(e,t,n[o],r);return a}var q=n();function Ie(e){return!Number.isFinite(e)||e<=0?900:Math.min(1600,Math.max(700,e*6))}function Le(e,t){let n=t?.flows??{},r=[...e],i=[];for(let e=0;e<r.length;e++){let t=r[e];i.push(`flow:${t}`);let a=r[e+1];if(!a)break;let o=Re(t,a,n);o&&i.push(`signal:${o}`)}return i}function Re(e,t,n){let r=n[e],i=n[t];if(!r||!i)return null;let a=i.trigger?.signal;return a&&r.effects?.emits?.includes(a)?a:null}function ze(e,t){return e.length===0?null:e[Math.floor(Math.min(.999,Math.max(0,t))*e.length)]??null}function Be(e){return typeof e!=`object`||!e||Array.isArray(e)?null:Object.entries(e).map(([e,t])=>({key:e,value:t,display:Ge(t),kind:We(t)}))}function Ve(e){if(Array.isArray(e)){let t=e.length;return`${t} ${t===1?`item`:`items`}`}if(typeof e==`object`&&e){let t=Object.keys(e).length;return`${t} ${t===1?`field`:`fields`}`}return typeof e==`string`?`${e.length} chars`:null}function He(e){let t=new TextEncoder().encode(e).length;return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function Ue(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function We(e){if(e===null)return`null`;if(Array.isArray(e))return`array`;switch(typeof e){case`string`:return`string`;case`number`:return`number`;case`boolean`:return`boolean`;case`object`:return`object`;default:return`string`}}function Ge(e){if(e===null)return`null`;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}var J=`flex min-h-0 flex-1 flex-col`,Ke=`flex min-h-0 flex-1 overflow-auto pb-3 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`;function qe({method:e,path:t,headline:n,input:a,output:o,error:s,errorMessage:c,inputOpen:l,onInputOpenChange:u,outputOpen:d,onOutputOpenChange:f}){let p=e&&t?`${e} ${t}`:n,m=s!==null,h=a!=null,g=d&&!m&&o!=null,_=l&&h&&!g;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`section`,{className:i(`border-b border-border/60 last:border-b-0`,_&&i(J,`pb-3`)),"data-slot":`trace-request`,children:[(0,q.jsxs)(`div`,{className:y,children:[(0,q.jsx)(`h3`,{className:i(ie,`flex items-center px-2`),children:`Request`}),p?(0,q.jsx)(`div`,{className:`ml-auto flex h-full items-stretch`,children:(0,q.jsx)(Y,{label:`Copy endpoint`,text:p,dataSlot:`trace-request-copy-endpoint`})}):null]}),(0,q.jsx)(`div`,{"data-slot":`trace-request-frame`,className:_?J:void 0,children:(0,q.jsxs)(`div`,{className:i(`flex min-w-0`,_&&`min-h-0 flex-1`),children:[(0,q.jsx)(Ye,{method:e}),(0,q.jsxs)(`div`,{className:i(`flex min-w-0 flex-1 flex-col`,_&&`min-h-0`),children:[(0,q.jsx)(Xe,{method:e,path:t,headline:n}),(0,q.jsx)(Je,{value:a,open:l,onOpenChange:u,label:`Body`,empty:`No stored input — replay uses an empty body when the ledger has none.`,copyLabel:`Copy body JSON`,copySlot:`trace-request-copy-input`,toggleSlot:`trace-input-toggle`,fieldsSlot:`trace-request-fields`,jsonSlot:`trace-input-json`,fill:_})]})]})})]}),(0,q.jsxs)(`section`,{className:i(`border-b border-border/60 last:border-b-0`,g&&i(J,`pb-3`)),"data-slot":`trace-response`,children:[(0,q.jsxs)(`div`,{className:y,children:[(0,q.jsx)(`h3`,{className:i(ie,`flex items-center px-2`),children:`Response`}),(0,q.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,children:[!m&&o!=null?(0,q.jsx)(Y,{label:`Copy response JSON`,text:JSON.stringify(o,null,2),dataSlot:`trace-response-copy`}):null,m?(0,q.jsx)(Y,{label:`Copy error`,text:[s,c].filter(Boolean).join(`
2
- `),dataSlot:`trace-response-copy-error`}):null]})]}),m?(0,q.jsx)(`div`,{"data-slot":`trace-response-error`,role:`alert`,children:(0,q.jsxs)(`div`,{className:`flex min-w-0`,children:[(0,q.jsx)(`div`,{className:`w-1 shrink-0 self-stretch bg-destructive`,"aria-hidden":!0,"data-slot":`trace-response-rail`}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 px-2.5 py-2.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(r,{icon:w,className:`size-3.5 shrink-0 text-destructive`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`font-mono text-xs font-semibold text-destructive`,children:s})]}),c?(0,q.jsx)(`p`,{className:`text-[11px] leading-snug text-destructive/90`,children:c}):(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Run failed with this error code — no return value was stored.`})]})]})}):(0,q.jsx)(`div`,{"data-slot":`trace-response-frame`,className:g?J:void 0,children:(0,q.jsxs)(`div`,{className:i(`flex min-w-0`,g&&`min-h-0 flex-1`),children:[(0,q.jsx)(`div`,{className:`w-1 shrink-0 self-stretch bg-emerald-500`,"aria-hidden":!0,"data-slot":`trace-response-rail`}),(0,q.jsx)(`div`,{className:i(`flex min-w-0 flex-1 flex-col`,g&&`min-h-0`),children:(0,q.jsx)(Je,{value:o,open:d,onOpenChange:f,label:`Body`,empty:`No stored response — this run completed without a return value.`,copyLabel:`Copy response JSON`,copySlot:`trace-response-copy-body`,toggleSlot:`trace-response-toggle`,fieldsSlot:`trace-response-fields`,jsonSlot:`trace-response-json`,fill:g})})]})})]})]})}function Je({value:e,open:t,onOpenChange:n,label:a,empty:o,copyLabel:s,copySlot:c,toggleSlot:l,fieldsSlot:u,jsonSlot:f,fill:p=!1}){let h=e!=null,g=(0,H.useMemo)(()=>h?JSON.stringify(e,null,2):``,[h,e]),_=(0,H.useMemo)(()=>h?Be(e):null,[h,e]),ee=(0,H.useMemo)(()=>h?Ve(e):null,[h,e]),te=(0,H.useMemo)(()=>h?He(g):null,[h,g]),[ne,v]=(0,H.useState)(_?`fields`:`raw`);return(0,H.useEffect)(()=>{v(_?`fields`:`raw`)},[_]),h?(0,q.jsxs)(me,{open:t,onOpenChange:n,className:p?J:void 0,children:[(0,q.jsxs)(`div`,{className:i(y,`border-t`),children:[(0,q.jsxs)(pe,{className:i(d,`min-w-0 flex-1 justify-start`),"data-slot":l,children:[(0,q.jsx)(r,{icon:fe,className:i(m,!t&&`-rotate-90`)}),(0,q.jsx)(`span`,{children:a}),ee?(0,q.jsxs)(`span`,{className:`truncate font-normal text-muted-foreground`,children:[`· `,ee]}):null,te?(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] font-normal text-muted-foreground tabular-nums`,children:te}):null]}),_?(0,q.jsx)(Ze,{view:ne,onChange:v}):null,(0,q.jsx)(Y,{label:s,text:g,dataSlot:c})]}),(0,q.jsx)(de,{className:p?i(J,`overflow-hidden`):void 0,children:(0,q.jsx)(`div`,{className:i(`border-t border-border/60`,p&&J),children:ne===`fields`&&_?(0,q.jsx)(`div`,{className:p?`min-h-0 flex-1 overflow-auto pb-3`:void 0,children:(0,q.jsx)($e,{rows:_,dataSlot:u})}):(0,q.jsx)(xe,{json:g,dataSlot:f,className:p?Ke:void 0})})})]}):(0,q.jsx)(`p`,{className:`border-t border-border/60 px-2 py-2 text-[11px] text-muted-foreground`,children:o})}function Ye({method:e}){return(0,q.jsx)(`div`,{className:i(`w-1 shrink-0 self-stretch`,e?oe(e):`bg-muted-foreground/50`),"aria-hidden":!0,"data-slot":`trace-request-rail`})}function Xe({method:e,path:t,headline:n}){return e&&t?(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-2.5 py-2`,"data-slot":`trace-request-endpoint`,children:[(0,q.jsx)(`span`,{className:i(`shrink-0 font-mono text-[10px] font-semibold tracking-[0.08em] uppercase`,l(S(e))),"data-slot":`trace-request-method`,children:e}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground select-all`,children:t})]}):(0,q.jsx)(`div`,{className:`px-2.5 py-2 font-mono text-xs text-foreground select-all`,"data-slot":`trace-request-endpoint`,children:n})}function Ze({view:e,onChange:t}){return(0,q.jsxs)(`div`,{className:`flex h-full shrink-0 items-stretch`,role:`group`,"aria-label":`Body view`,"data-slot":`trace-request-view-toggle`,children:[(0,q.jsx)(Qe,{active:e===`fields`,label:`Fields`,icon:Ae,onClick:()=>t(`fields`)}),(0,q.jsx)(Qe,{active:e===`raw`,label:`Raw`,icon:le,onClick:()=>t(`raw`)})]})}function Qe({active:e,label:t,icon:n,onClick:a}){return(0,q.jsxs)(`button`,{type:`button`,className:i(d,`font-semibold tracking-[0.08em] uppercase`,e?x:b),"aria-pressed":e,"aria-label":t,onClick:a,children:[(0,q.jsx)(r,{icon:n,className:`size-3`}),(0,q.jsx)(`span`,{className:`hidden sm:inline`,children:t})]})}function $e({rows:e,dataSlot:t}){return(0,q.jsx)(`ul`,{"data-slot":t,children:e.map(e=>(0,q.jsxs)(`li`,{className:i(_,`group/field items-start`),"data-slot":`trace-payload-field`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 sm:flex-row sm:items-baseline sm:gap-3`,children:[(0,q.jsx)(`span`,{className:`w-[7.5rem] shrink-0 truncate font-mono text-[11px] font-medium text-sky-600 dark:text-sky-400`,children:e.key}),(0,q.jsx)(`span`,{className:i(`min-w-0 flex-1 break-all font-mono text-[11px] leading-snug`,et(e.kind)),title:e.display,children:e.display})]}),(0,q.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-[9px] tracking-wide text-muted-foreground uppercase opacity-70`,children:e.kind}),(0,q.jsx)(`div`,{className:`opacity-0 transition-opacity group-hover/field:opacity-100 group-focus-within/field:opacity-100`,children:(0,q.jsx)(Y,{label:`Copy ${e.key}`,text:Ue(e.value),dataSlot:`trace-payload-copy-field`,bare:!0})})]},e.key))})}function et(e){switch(e){case`string`:return`text-teal-800/90 dark:text-teal-300/90`;case`number`:return`text-amber-800 dark:text-amber-300`;case`boolean`:return`text-violet-800 dark:text-violet-300`;case`null`:return`text-muted-foreground italic`;default:return`text-foreground/80`}}function Y({text:e,label:t,dataSlot:n,bare:i=!1}){let[l,u]=(0,H.useState)(!1),d=async t=>{t.stopPropagation();try{await navigator.clipboard.writeText(e),u(!0),window.setTimeout(()=>u(!1),1200)}catch{u(!1)}};return(0,q.jsxs)(a,{children:[(0,q.jsx)(c,{render:e=>(0,q.jsx)(`button`,{...e,type:`button`,className:i?v:f,"aria-label":l?`Copied`:t,"data-slot":n,onClick:t=>{e.onClick?.(t),d(t)},children:(0,q.jsx)(r,{icon:l?s:ce,className:`size-3.5`})})}),(0,q.jsx)(o,{side:`bottom`,className:`text-[11px]`,children:l?`Copied`:t})]})}function tt(e){return e.effects.some(e=>e.kind===`send`||e.kind===`ask`||e.reversibility===`irreversible`)}function nt(e){return{rootId:e.id,dryRun:tt(e)}}async function rt(e,t=ae){return t(nt(e))}function it(e){return e.id}function at(e){let t=ot(e),n=Ce[t];return{icon:n.icon,label:n.label}}function ot(e){switch(e){case`http`:return`http`;case`signal`:return`signal`;case`every`:return`every`;case`cron`:return`cron`;case`cdc`:return`cdc`;case`internal`:return`internal`;default:return`internal`}}function st(e,t,n){return!Number.isFinite(t)||!Number.isFinite(n)||n<=0?e.map((e,t)=>({index:t,kind:e.kind,resource:e.resource,startOffsetMs:0,durationMs:0,offsetRatio:0,widthRatio:0,...e.external===void 0?{}:{external:e.external}})):e.map((e,r)=>{let i=Number.isFinite(e.timestamp)?e.timestamp-t:0,a=Number.isFinite(e.duration)?Math.max(0,e.duration):0,o=Math.min(n,Math.max(0,i)),s=Math.min(n,Math.max(o,i+a))-o;return{index:r,kind:e.kind,resource:e.resource,startOffsetMs:o,durationMs:s,offsetRatio:o/n,widthRatio:s/n,...e.external===void 0?{}:{external:e.external}}})}var X=[1,2,4,8];function Z(e,t=0){let n=Number.isFinite(e)&&e>=1?e:1,r=1/n;return{startRatio:Math.min(Number.isFinite(t)?Math.max(0,t):0,Math.max(0,1-r)),widthRatio:r,zoom:n}}function Q(e,t,n){let r=e,i=e+t,a=n.startRatio+n.widthRatio;if(i<=n.startRatio||r>=a)return null;let o=Math.max(r,n.startRatio),s=Math.min(i,a);return{left:(o-n.startRatio)/n.widthRatio,width:(s-o)/n.widthRatio}}function ct(e,t=5){if(!Number.isFinite(e)||e<=0)return[0];let n=pt(e,t),r=[0];for(let t=n;t<e-n*.25;t+=n)r.push(Math.round(t*1e3)/1e3);return r[r.length-1]!==e&&r.push(e),r}function lt(e,t,n=5){if(!Number.isFinite(e)||e<=0)return[{offsetMs:0,viewRatio:0,isEnd:!0}];let r=t.startRatio*e,i=t.widthRatio*e,a=ct(i,n).map(e=>r+e),o=Math.min(e,r+i);return a[a.length-1]!==o&&(a[a.length-1]=o),a.map((e,t)=>({offsetMs:e,viewRatio:(e-r)/i,isEnd:t===a.length-1}))}function ut(e,t){if(!Number.isFinite(t)||t<=0)return[];let n=ft(e,t),r=[],i=0;for(let[e,a]of n)e>i&&r.push(dt(i,e,t)),i=Math.max(i,a);return i<t&&r.push(dt(i,t,t)),r.filter(e=>e.durationMs>0&&e.widthRatio>0)}function dt(e,t,n){let r=Math.max(0,e),i=Math.max(0,t-r);return{startOffsetMs:r,durationMs:i,offsetRatio:r/n,widthRatio:i/n}}function ft(e,t){let n=e.map(e=>{let n=Math.max(0,Math.min(t,e.startOffsetMs));return[n,Math.max(n,Math.min(t,e.startOffsetMs+e.durationMs))]}).filter(([e,t])=>t>e).sort((e,t)=>e[0]-t[0]),r=[];for(let e of n){let t=r[r.length-1];!t||e[0]>t[1]?r.push([e[0],e[1]]):t[1]=Math.max(t[1],e[1])}return r}function pt(e,t){let n=e/Math.max(1,t),r=10**Math.floor(Math.log10(Math.max(n,1e-6))),i=n/r,a;return a=i<=1?1:i<=2?2:i<=5?5:10,a*r}function mt(e){return X.find(t=>t>e)??X[X.length-1]}function ht(e){let t=X[0];for(let n of X){if(n>=e)return t;t=n}return t}function gt(e){let t=`${De(e)} · ${e.resource} · ${D(e.durationMs)} · +${D(e.startOffsetMs)}`;if(!e.external)return t;let n=[e.external.host];return e.external.provider&&n.push(e.external.provider),e.external.kind&&n.push(e.external.kind),`${t} · ↗ ${n.join(` · `)}`}var $=`border-b border-border/60 last:border-b-0`;function _t({run:e,onClose:t,replay:n=ae,focusEffectIndex:a=null,onFocusEffectChange:o,playbackKey:s=0,onReplayStart:c}){let l=ye(),v=Me(),b=e?at(e.trigger):null,x=e?Ee(e.cache):null,oe=(0,H.useMemo)(()=>e?we(e):[],[e]),se=(0,H.useMemo)(()=>e?ke(e.gates,l.data??null):[],[e,l.data]),S=(0,H.useMemo)(()=>e?st(e.effects,e.startedAt,e.durationMs):[],[e]),ce=(0,H.useMemo)(()=>e?ut(S,e.durationMs):[],[e,S]),C=(0,H.useMemo)(()=>e?Oe(l.data??null,e.flow,e.trigger):{method:null,path:null,headline:``},[e,l.data]),[le,w]=(0,H.useState)(!1),[T,E]=(0,H.useState)(null),[xe,O]=(0,H.useState)(null),[Se,k]=(0,H.useState)(!0),[Ce,A]=(0,H.useState)(!0),[Ae,j]=(0,H.useState)(!0),[M,N]=(0,H.useState)(null),[P,F]=(0,H.useState)(1),[I,L]=(0,H.useState)(0),[z,B]=(0,H.useState)(!1),V=U(0),W=U(0),G=(0,H.useMemo)(()=>Z(P,I),[P,I]),Pe=(0,H.useMemo)(()=>e?lt(e.durationMs,G):[],[e,G]),Fe=K(V,e=>{let t=Q(e,1e-4,G);return t?`${t.left*100}%`:`-10%`});(0,H.useEffect)(()=>{if(E(null),O(null),w(!1),k(!0),A(!0),j(!0),N(null),F(1),L(0),B(!1),V.set(0),!e)return;if(v){W.set(e.durationMs);return}W.set(0);let t=_e(W,e.durationMs,{duration:.6,ease:[.16,1,.3,1]});return()=>t.stop()},[e?.id,v]),(0,H.useEffect)(()=>{if(s===0||!e)return;if(v){V.set(1),W.set(e.durationMs),B(!1);return}B(!0),V.set(0),W.set(0);let t=_e(V,1,{duration:Ie(e.durationMs)/1e3,ease:`linear`,onUpdate:t=>W.set(t*e.durationMs),onComplete:()=>{W.set(e.durationMs),B(!1)}});return()=>{t.stop(),B(!1)}},[s]);let Le=async t=>{if(t.stopPropagation(),e&&!le){w(!0),E(null),O(null);try{let t=await rt(e,n);if(t.error){E(t.error.message??t.error.code),O(`error`);return}E(t.data?.dryRun?`Replayed (dry-run)`:`Replayed`),O(`ok`),c?.()}catch(e){E(e instanceof Error?e.message:`Replay failed`),O(`error`)}finally{w(!1)}}};return(0,q.jsx)(p,{open:e!==null,modal:!1,disablePointerDismissal:!0,onOpenChange:e=>{e||t()},children:(0,q.jsx)(ee,{side:`left`,showOverlay:!1,"data-slot":`trace-detail-sheet`,className:`inset-y-0 h-dvh w-full max-w-none gap-0 rounded-none p-0 shadow-xl md:left-12! data-[side=left]:sm:max-w-2xl`,children:e&&b?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(h,{className:`gap-1.5 border-b border-border/60 px-2 py-2 pr-12`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(`span`,{className:`mt-0.5 text-muted-foreground`,title:b.label,"aria-hidden":!0,children:(0,q.jsx)(r,{icon:b.icon,className:g})}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(re,{className:`truncate font-mono text-base font-semibold tracking-tight`,children:e.flow}),(0,q.jsxs)(ne,{className:`mt-0.5 flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:b.label}),x?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,q.jsxs)(`span`,{className:i(`inline-flex items-center gap-1`,x.className),"data-slot":`trace-sheet-cache`,"data-cache":e.cache,title:x.label,children:[(0,q.jsx)(r,{icon:x.icon,className:`size-3`,"aria-hidden":!0}),x.label]})]}):null]})]})]}),(0,q.jsx)(he,{mode:`wait`,children:T?(0,q.jsx)(R.div,{initial:!v&&{opacity:0,y:-4,scale:.96},animate:{opacity:1,y:0,scale:1},exit:v?void 0:{opacity:0,y:-4,scale:.96},transition:{duration:.18,ease:`easeOut`},children:(0,q.jsx)(ue,{variant:`outline`,role:`status`,className:i(`h-5 w-fit rounded-md px-1.5 text-[10px] font-medium`,xe===`ok`&&`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`,xe===`error`&&`border-destructive/40 bg-destructive/10 text-destructive`),children:T})},T):null})]}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-0 overflow-y-auto p-0`,children:[(0,q.jsx)(`section`,{className:$,"data-slot":`trace-summary`,children:(0,q.jsx)(yt,{chips:oe,durationMs:e.durationMs,durationValue:W})}),se.length>0?(0,q.jsx)(`section`,{className:$,"data-slot":`trace-gates`,children:(0,q.jsx)(Te,{gates:se})}):null,(0,q.jsxs)(`section`,{className:$,"data-slot":`trace-waterfall`,children:[(0,q.jsxs)(`div`,{className:y,children:[(0,q.jsx)(`h3`,{className:i(ie,`flex items-center px-2`),children:`Waterfall`}),(0,q.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,"data-slot":`trace-waterfall-zoom`,children:[(0,q.jsx)(`button`,{type:`button`,className:f,"aria-label":`Pan left`,disabled:P<=1||G.startRatio<=0,onClick:()=>L(e=>Z(P,Math.max(0,e-G.widthRatio*.5)).startRatio),children:(0,q.jsx)(r,{icon:ge,className:`size-3.5`})}),(0,q.jsx)(`button`,{type:`button`,className:f,"aria-label":`Zoom out`,disabled:P<=1,onClick:()=>{let e=ht(P);F(e),L(t=>Z(e,t).startRatio)},children:(0,q.jsx)(r,{icon:Ne,className:`size-3.5`})}),(0,q.jsxs)(`span`,{className:`flex min-w-8 items-center justify-center font-mono text-[10px] tabular-nums text-muted-foreground`,children:[P,`×`]}),(0,q.jsx)(`button`,{type:`button`,className:f,"aria-label":`Zoom in`,disabled:P>=8,onClick:()=>{let e=mt(P);F(e),L(t=>Z(e,t).startRatio)},children:(0,q.jsx)(r,{icon:je,className:`size-3.5`})}),(0,q.jsx)(`button`,{type:`button`,className:f,"aria-label":`Pan right`,disabled:P<=1||G.startRatio+G.widthRatio>=1,onClick:()=>L(e=>Z(P,e+G.widthRatio*.5).startRatio),children:(0,q.jsx)(r,{icon:ve,className:`size-3.5`})})]})]}),S.length===0?(0,q.jsx)(`p`,{className:`px-2 py-2 text-[11px] text-muted-foreground`,children:`No effects recorded`}):(0,q.jsxs)(`div`,{className:`relative flex flex-col gap-1.5 px-2 py-2`,children:[(0,q.jsx)(Ct,{ticks:Pe}),(0,q.jsx)(wt,{bars:S,gaps:ce,view:G,hoverIndex:M,onHover:N,onSelect:e=>o?.(a===e?null:e),focusIndex:a}),S.map(e=>(0,q.jsx)(Et,{bar:e,view:G,dimmed:M!==null&&M!==e.index,focused:a===e.index,progress:V,playing:z,onHover:N,onSelect:e=>o?.(a===e?null:e)},e.index)),z?(0,q.jsx)(R.div,{className:`pointer-events-none absolute top-4 bottom-0 w-px bg-foreground/70`,style:{left:Fe},"data-slot":`trace-waterfall-playhead`,"aria-hidden":!0}):null,ce.length>0?(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Hatched spans are idle time — no effects recorded.`}):null]})]}),(0,q.jsx)(`section`,{className:$,"data-slot":`trace-events-section`,children:(0,q.jsxs)(me,{open:Se,onOpenChange:k,children:[(0,q.jsxs)(`div`,{className:y,children:[(0,q.jsxs)(pe,{className:i(d,`min-w-0 flex-1 justify-start`),"data-slot":`trace-events-toggle`,children:[(0,q.jsx)(r,{icon:fe,className:i(m,!Se&&`-rotate-90`)}),(0,q.jsx)(`span`,{className:`truncate`,children:`Event Details`}),(0,q.jsxs)(`span`,{className:u,children:[e.effects.length,` `,e.effects.length===1?`event`:`events`]})]}),(0,q.jsxs)(`button`,{type:`button`,className:d,disabled:le,"data-slot":`trace-sheet-replay`,onClick:e=>void Le(e),children:[(0,q.jsx)(r,{icon:be,className:`size-3.5`}),`Replay`]})]}),(0,q.jsx)(de,{children:(0,q.jsx)(`ul`,{className:`flex flex-col`,"data-slot":`trace-events`,children:e.effects.map((e,t)=>{let n=S[t],r=a===t;return(0,q.jsxs)(`li`,{"data-slot":`trace-event-row`,"data-index":t,"data-focused":r?`true`:`false`,"data-external":e.external?`true`:void 0,className:i(_,`cursor-pointer flex-col items-stretch gap-1 text-[11px]`,r&&`bg-muted/70 text-foreground`,M===t&&!r&&`bg-muted/50`),onClick:()=>o?.(a===t?null:t),onMouseEnter:()=>N(t),onMouseLeave:()=>N(null),children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:i(te,r&&`bg-sky-500`)}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(vt,{kind:e.kind,resource:e.resource}),(0,q.jsx)(`span`,{className:`w-[4.5rem] shrink-0 font-medium text-foreground/90`,children:De(e)}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-muted-foreground`,children:[e.resource,e.external?` · ↗ ${e.external.host}${e.external.kind?` (${e.external.kind})`:``}`:``]}),(0,q.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:D(e.duration)})]}),n?(0,q.jsx)(`div`,{className:`relative ml-7 h-1.5 w-[calc(100%-1.75rem)] rounded-full bg-muted/70`,"data-slot":`trace-event-bar-track`,"aria-hidden":!0,children:(0,q.jsx)(Dt,{bar:n,left:n.offsetRatio,width:n.widthRatio,progress:V,playing:z,slot:`trace-event-bar`})}):null]},`${e.kind}:${e.resource}:${t}`)})})})]})}),(0,q.jsx)(qe,{method:C.method,path:C.path,headline:C.headline,input:e.input,output:e.output,error:e.error,errorMessage:e.errorMessage,inputOpen:Ce,onInputOpenChange:A,outputOpen:Ae,onOutputOpenChange:j})]})]}):null})})}function vt({kind:e,resource:t}){let n=A(e);return(0,q.jsx)(`span`,{className:g,style:{color:n},"aria-hidden":!0,children:(0,q.jsx)(r,{icon:k(e,t),className:`size-3.5`})})}function yt({chips:e,durationMs:t,durationValue:n}){let s=e.find(e=>e.variant===`duration`),l=e.filter(e=>e.variant!==`duration`),u=K(n,e=>D(Math.round(e)));return(0,q.jsxs)(`div`,{className:y,"data-slot":`trace-summary-strip`,role:`group`,"aria-label":`Run summary`,children:[s?(0,q.jsxs)(a,{children:[(0,q.jsx)(c,{render:e=>(0,q.jsxs)(`div`,{...e,className:`flex h-full shrink-0 items-center gap-1.5 px-2`,"data-slot":`trace-summary-duration`,children:[(0,q.jsx)(r,{icon:O,className:i(`size-3.5`,E(t)),"aria-hidden":!0}),(0,q.jsx)(R.span,{className:i(`font-mono text-sm font-semibold tracking-tight tabular-nums leading-none`,E(t)),children:u})]})}),(0,q.jsx)(o,{side:`bottom`,className:`max-w-xs text-[11px]`,children:s.detail})]}):null,l.length>0?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0}),(0,q.jsx)(`ul`,{className:`flex h-full min-w-0 flex-1 flex-nowrap items-stretch overflow-x-auto overscroll-x-contain [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:l.map(e=>(0,q.jsx)(`li`,{className:`list-none shrink-0`,children:(0,q.jsx)(bt,{chip:e})},e.key))})]}):null]})}function bt({chip:e}){let t=St(e.variant),n=xt(e.variant);return(0,q.jsxs)(a,{children:[(0,q.jsx)(c,{render:a=>(0,q.jsxs)(`span`,{...a,className:i(d,`text-foreground/90`),"data-slot":`trace-summary-chip`,"data-variant":e.variant,children:[(0,q.jsx)(`span`,{style:{color:t},"aria-hidden":!0,children:(0,q.jsx)(r,{icon:n,className:`size-3`})}),(0,q.jsx)(`span`,{className:`tabular-nums font-medium`,children:e.shortLabel}),(0,q.jsx)(`span`,{className:`sr-only`,children:e.label})]})}),(0,q.jsxs)(o,{side:`bottom`,className:`max-w-xs flex-col items-start gap-0.5 text-[11px]`,children:[(0,q.jsx)(`p`,{className:`font-medium text-background`,children:e.label}),(0,q.jsx)(`p`,{className:`text-background/70`,children:e.detail})]})]})}function xt(e){switch(e){case`duration`:return O;case`api`:return se;case`gate`:return C.gate.icon;case`cache`:return Se;case`db`:return C.store.icon;case`logs`:return T;default:return k(e)}}function St(e){switch(e){case`duration`:return`currentColor`;case`api`:return`var(--foreground)`;case`gate`:return j.gate.accent;case`cache`:return`var(--color-sky-500)`;case`db`:return j.store.accent;case`logs`:return`var(--muted-foreground)`;default:return A(e)}}function Ct({ticks:e}){return(0,q.jsx)(`div`,{className:`relative h-4 w-full border-b border-border/60`,"data-slot":`trace-waterfall-ruler`,children:e.map(e=>(0,q.jsxs)(`div`,{className:`absolute top-0 flex h-full flex-col items-center`,style:{left:`${e.viewRatio*100}%`,transform:e.isEnd?`translateX(-100%)`:e.viewRatio===0?`none`:`translateX(-50%)`},children:[(0,q.jsx)(`span`,{className:`font-mono text-[9px] tabular-nums text-muted-foreground`,children:D(e.offsetMs)}),(0,q.jsx)(`span`,{className:`mt-auto h-1.5 w-px bg-border`,"aria-hidden":!0})]},`${e.offsetMs}-${e.viewRatio}`))})}function wt({bars:e,gaps:t,view:n,hoverIndex:r,onHover:s,onSelect:l,focusIndex:u}){return(0,q.jsxs)(`div`,{className:`relative h-3 w-full overflow-hidden rounded-full bg-muted/50`,"data-slot":`trace-waterfall-overview`,children:[t.map(e=>{let t=Q(e.offsetRatio,e.widthRatio,n);return!t||t.width<=0?null:(0,q.jsx)(Tt,{left:t.left,width:t.width,gap:e},`gap-${e.startOffsetMs}`)}),e.map(e=>{let t=Q(e.offsetRatio,e.widthRatio,n);if(!t||t.width<=0)return null;let d=u===e.index;return(0,q.jsxs)(a,{children:[(0,q.jsx)(c,{render:n=>(0,q.jsx)(`div`,{...n,className:i(`absolute inset-y-0.5 cursor-pointer rounded-full transition-opacity`,r!==null&&r!==e.index&&!d&&`opacity-35`,d&&`ring-1 ring-foreground/40`,e.external&&`outline outline-1 outline-dashed outline-foreground/50`),style:{left:`${t.left*100}%`,width:`${Math.max(t.width*100,.4)}%`,backgroundColor:A(e.kind)},"data-slot":`trace-waterfall-overview-bar`,"data-external":e.external?`true`:void 0,onClick:t=>{t.stopPropagation(),l?.(e.index)},onMouseEnter:t=>{n.onMouseEnter?.(t),s(e.index)},onMouseLeave:e=>{n.onMouseLeave?.(e),s(null)}})}),(0,q.jsx)(o,{side:`top`,className:`max-w-xs font-mono text-[11px]`,children:gt(e)})]},`ov-${e.index}`)})]})}function Tt({left:e,width:t,gap:n}){return(0,q.jsxs)(a,{children:[(0,q.jsx)(c,{render:n=>(0,q.jsx)(`div`,{...n,className:`absolute inset-y-0 overflow-hidden rounded-sm`,style:{left:`${e*100}%`,width:`${t*100}%`},"data-slot":`trace-waterfall-gap`,children:(0,q.jsx)(`div`,{className:`size-full opacity-70`,style:{backgroundImage:`repeating-linear-gradient(-45deg, color-mix(in oklab, var(--muted-foreground) 28%, transparent) 0 1px, transparent 1px 5px)`},"aria-hidden":!0})})}),(0,q.jsxs)(o,{side:`top`,className:`max-w-xs text-[11px]`,children:[`Idle · `,D(n.durationMs),` — no effects recorded`]})]})}function Et({bar:e,view:t,dimmed:n,focused:r,progress:i,playing:s,onHover:l,onSelect:u}){let d=Q(e.offsetRatio,e.widthRatio,t);return!d||d.width<=0?null:(0,q.jsxs)(a,{children:[(0,q.jsx)(c,{render:t=>(0,q.jsx)(`div`,{...t,className:`relative h-2.5 w-full cursor-pointer rounded-full bg-muted/70`,"data-slot":`trace-waterfall-track`,"data-index":e.index,onClick:t=>{t.stopPropagation(),u?.(e.index)},onMouseEnter:n=>{t.onMouseEnter?.(n),l(e.index)},onMouseLeave:e=>{t.onMouseLeave?.(e),l(null)},children:(0,q.jsx)(Dt,{bar:e,left:d.left,width:d.width,progress:i,playing:s,dimmed:n,focused:r,slot:`trace-waterfall-bar`})})}),(0,q.jsx)(o,{side:`top`,className:`max-w-xs font-mono text-[11px]`,children:gt(e)})]})}function Dt({bar:e,left:t,width:n,progress:r,playing:a,dimmed:o=!1,focused:s=!1,slot:c}){let l=Math.max(e.widthRatio,.02),u=K(r,[e.offsetRatio,e.offsetRatio+l],[0,1],{clamp:!0}),d=K(r,t=>t>=e.offsetRatio?1:.25),f=a;return(0,q.jsx)(R.div,{className:i(`absolute inset-y-0 rounded-full transition-opacity`,!f&&o&&!s&&`opacity-35`,s&&`ring-1 ring-foreground/40`,e.external&&`outline outline-1 outline-dashed outline-foreground/50`),style:{left:`${t*100}%`,width:`${Math.max(n*100,.5)}%`,backgroundColor:A(e.kind),transformOrigin:`left`,...f?{scaleX:u,opacity:d}:{}},"data-slot":c,"data-external":e.external?`true`:void 0})}export{Ie as a,U as c,ze as i,at as n,Le as o,it as r,K as s,_t as t};
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{Dr as r,Er as i,F as a,I as o,Or as s,R as c,Tr as l,ar as u,br as d,cr as f,i as p,ir as m,l as h,lr as g,mr as _,o as ee,pr as te,s as ne,sr as v,u as re,vr as y,wr as ie,xr as b,yi as ae,yr as x}from"./shortcut-keys-CUNegEV4.js";import{i as oe,o as se,t as S}from"./http-method-DTPevKmM.js";import{b as ce,t as C}from"./element-icons-CwyLpVXz.js";import{a as le,i as ue,n as de,o as fe,r as pe,s as w,t as me}from"./collapsible-CoJ6amHf.js";import{a as he,c as ge,i as _e,o as T,s as ve,t as E}from"./duration-tone-BbQ_8z50.js";import{c as ye,f as be,i as D,t as xe,u as O}from"./highlighted-json-CPYBzDh0.js";import{T as Se,c as k,f as Ce,i as we,l as Te,n as Ee,r as De,s as A,t as Oe,u as ke,w as Ae,y as j}from"./request-meta-BjFT7DNl.js";import{t as je}from"./PlusSignIcon-CwG3nxfu.js";import{D as M,H as N,J as P,O as F,at as I,c as L,d as R,it as z,l as Me,q as B}from"./index-vTuwmeQz.js";var Ne=[[`path`,{d:`M20 12L4 12`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]];function V(...e){let t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],i=e[1+n],a=e[2+n],o=e[3+n],s=N(i,a,o);return t?s(r):s}var H=e(t(),1);function U(e){let t=I(()=>F(e)),{isStatic:n}=(0,H.useContext)(R);if(n){let[,n]=(0,H.useState)(e);(0,H.useEffect)(()=>t.on(`change`,n),[])}return t}function W(e,t){let n=U(t()),r=()=>n.set(t());return r(),z(()=>{let t=()=>P.preRender(r,!1,!0),n=e.map(e=>e.on(`change`,t));return()=>{n.forEach(e=>e()),B(r)}}),n}function G(e){M.current=[],e();let t=W(M.current,e);return M.current=void 0,t}function K(e,t,n,r){if(typeof e==`function`)return G(e);if(n!==void 0&&!Array.isArray(n)&&typeof t!=`function`)return Fe(e,t,n,r);let i=typeof t==`function`?t:V(t,n,r),a=Array.isArray(e)?Pe(e,i):Pe([e],([e])=>i(e)),o=Array.isArray(e)?void 0:e.accelerate;return o&&!o.isTransformed&&typeof t!=`function`&&Array.isArray(n)&&r?.clamp!==!1&&(a.accelerate={...o,times:t,keyframes:n,isTransformed:!0,...r?.ease?{ease:r.ease}:{}}),a}function Pe(e,t){let n=I(()=>[]);return W(e,()=>{n.length=0;let r=e.length;for(let t=0;t<r;t++)n[t]=e[t].get();return t(n)})}function Fe(e,t,n,r){let i=I(()=>Object.keys(n)),a=I(()=>({}));for(let o of i)a[o]=K(e,t,n[o],r);return a}var q=n();function Ie(e){return!Number.isFinite(e)||e<=0?900:Math.min(1600,Math.max(700,e*6))}function Le(e,t){let n=t?.flows??{},r=[...e],i=[];for(let e=0;e<r.length;e++){let t=r[e];i.push(`flow:${t}`);let a=r[e+1];if(!a)break;let o=Re(t,a,n);o&&i.push(`signal:${o}`)}return i}function Re(e,t,n){let r=n[e],i=n[t];if(!r||!i)return null;let a=i.trigger?.signal;return a&&r.effects?.emits?.includes(a)?a:null}function ze(e,t){return e.length===0?null:e[Math.floor(Math.min(.999,Math.max(0,t))*e.length)]??null}function Be(e){return typeof e!=`object`||!e||Array.isArray(e)?null:Object.entries(e).map(([e,t])=>({key:e,value:t,display:Ge(t),kind:We(t)}))}function Ve(e){if(Array.isArray(e)){let t=e.length;return`${t} ${t===1?`item`:`items`}`}if(typeof e==`object`&&e){let t=Object.keys(e).length;return`${t} ${t===1?`field`:`fields`}`}return typeof e==`string`?`${e.length} chars`:null}function He(e){let t=new TextEncoder().encode(e).length;return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function Ue(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function We(e){if(e===null)return`null`;if(Array.isArray(e))return`array`;switch(typeof e){case`string`:return`string`;case`number`:return`number`;case`boolean`:return`boolean`;case`object`:return`object`;default:return`string`}}function Ge(e){if(e===null)return`null`;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}var J=`flex min-h-0 flex-1 flex-col`,Ke=`flex min-h-0 flex-1 overflow-auto pb-3 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`;function qe({method:e,path:t,headline:n,input:a,output:o,error:s,errorMessage:c,inputOpen:l,onInputOpenChange:u,outputOpen:d,onOutputOpenChange:f}){let p=e&&t?`${e} ${t}`:n,m=s!==null,h=a!=null,g=d&&!m&&o!=null,_=l&&h&&!g;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`section`,{className:i(`border-b border-border/60 last:border-b-0`,_&&i(J,`pb-3`)),"data-slot":`trace-request`,children:[(0,q.jsxs)(`div`,{className:y,children:[(0,q.jsx)(`h3`,{className:i(ie,`flex items-center px-2`),children:`Request`}),p?(0,q.jsx)(`div`,{className:`ml-auto flex h-full items-stretch`,children:(0,q.jsx)(Y,{label:`Copy endpoint`,text:p,dataSlot:`trace-request-copy-endpoint`})}):null]}),(0,q.jsx)(`div`,{"data-slot":`trace-request-frame`,className:_?J:void 0,children:(0,q.jsxs)(`div`,{className:i(`flex min-w-0`,_&&`min-h-0 flex-1`),children:[(0,q.jsx)(Ye,{method:e}),(0,q.jsxs)(`div`,{className:i(`flex min-w-0 flex-1 flex-col`,_&&`min-h-0`),children:[(0,q.jsx)(Xe,{method:e,path:t,headline:n}),(0,q.jsx)(Je,{value:a,open:l,onOpenChange:u,label:`Body`,empty:`No stored input — replay uses an empty body when the ledger has none.`,copyLabel:`Copy body JSON`,copySlot:`trace-request-copy-input`,toggleSlot:`trace-input-toggle`,fieldsSlot:`trace-request-fields`,jsonSlot:`trace-input-json`,fill:_})]})]})})]}),(0,q.jsxs)(`section`,{className:i(`border-b border-border/60 last:border-b-0`,g&&i(J,`pb-3`)),"data-slot":`trace-response`,children:[(0,q.jsxs)(`div`,{className:y,children:[(0,q.jsx)(`h3`,{className:i(ie,`flex items-center px-2`),children:`Response`}),(0,q.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,children:[!m&&o!=null?(0,q.jsx)(Y,{label:`Copy response JSON`,text:JSON.stringify(o,null,2),dataSlot:`trace-response-copy`}):null,m?(0,q.jsx)(Y,{label:`Copy error`,text:[s,c].filter(Boolean).join(`
2
+ `),dataSlot:`trace-response-copy-error`}):null]})]}),m?(0,q.jsx)(`div`,{"data-slot":`trace-response-error`,role:`alert`,children:(0,q.jsxs)(`div`,{className:`flex min-w-0`,children:[(0,q.jsx)(`div`,{className:`w-1 shrink-0 self-stretch bg-destructive`,"aria-hidden":!0,"data-slot":`trace-response-rail`}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 px-2.5 py-2.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(r,{icon:w,className:`size-3.5 shrink-0 text-destructive`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`font-mono text-xs font-semibold text-destructive`,children:s})]}),c?(0,q.jsx)(`p`,{className:`text-[11px] leading-snug text-destructive/90`,children:c}):(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Run failed with this error code — no return value was stored.`})]})]})}):(0,q.jsx)(`div`,{"data-slot":`trace-response-frame`,className:g?J:void 0,children:(0,q.jsxs)(`div`,{className:i(`flex min-w-0`,g&&`min-h-0 flex-1`),children:[(0,q.jsx)(`div`,{className:`w-1 shrink-0 self-stretch bg-emerald-500`,"aria-hidden":!0,"data-slot":`trace-response-rail`}),(0,q.jsx)(`div`,{className:i(`flex min-w-0 flex-1 flex-col`,g&&`min-h-0`),children:(0,q.jsx)(Je,{value:o,open:d,onOpenChange:f,label:`Body`,empty:`No stored response — this run completed without a return value.`,copyLabel:`Copy response JSON`,copySlot:`trace-response-copy-body`,toggleSlot:`trace-response-toggle`,fieldsSlot:`trace-response-fields`,jsonSlot:`trace-response-json`,fill:g})})]})})]})]})}function Je({value:e,open:t,onOpenChange:n,label:a,empty:o,copyLabel:s,copySlot:c,toggleSlot:l,fieldsSlot:u,jsonSlot:f,fill:p=!1}){let h=e!=null,g=(0,H.useMemo)(()=>h?JSON.stringify(e,null,2):``,[h,e]),_=(0,H.useMemo)(()=>h?Be(e):null,[h,e]),ee=(0,H.useMemo)(()=>h?Ve(e):null,[h,e]),te=(0,H.useMemo)(()=>h?He(g):null,[h,g]),[ne,v]=(0,H.useState)(_?`fields`:`raw`);return(0,H.useEffect)(()=>{v(_?`fields`:`raw`)},[_]),h?(0,q.jsxs)(me,{open:t,onOpenChange:n,className:p?J:void 0,children:[(0,q.jsxs)(`div`,{className:i(y,`border-t`),children:[(0,q.jsxs)(pe,{className:i(d,`min-w-0 flex-1 justify-start`),"data-slot":l,children:[(0,q.jsx)(r,{icon:fe,className:i(m,!t&&`-rotate-90`)}),(0,q.jsx)(`span`,{children:a}),ee?(0,q.jsxs)(`span`,{className:`truncate font-normal text-muted-foreground`,children:[`· `,ee]}):null,te?(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] font-normal text-muted-foreground tabular-nums`,children:te}):null]}),_?(0,q.jsx)(Ze,{view:ne,onChange:v}):null,(0,q.jsx)(Y,{label:s,text:g,dataSlot:c})]}),(0,q.jsx)(de,{className:p?i(J,`overflow-hidden`):void 0,children:(0,q.jsx)(`div`,{className:i(`border-t border-border/60`,p&&J),children:ne===`fields`&&_?(0,q.jsx)(`div`,{className:p?`min-h-0 flex-1 overflow-auto pb-3`:void 0,children:(0,q.jsx)($e,{rows:_,dataSlot:u})}):(0,q.jsx)(xe,{json:g,dataSlot:f,className:p?Ke:void 0})})})]}):(0,q.jsx)(`p`,{className:`border-t border-border/60 px-2 py-2 text-[11px] text-muted-foreground`,children:o})}function Ye({method:e}){return(0,q.jsx)(`div`,{className:i(`w-1 shrink-0 self-stretch`,e?oe(e):`bg-muted-foreground/50`),"aria-hidden":!0,"data-slot":`trace-request-rail`})}function Xe({method:e,path:t,headline:n}){return e&&t?(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-2.5 py-2`,"data-slot":`trace-request-endpoint`,children:[(0,q.jsx)(`span`,{className:i(`shrink-0 font-mono text-[10px] font-semibold tracking-[0.08em] uppercase`,l(S(e))),"data-slot":`trace-request-method`,children:e}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground select-all`,children:t})]}):(0,q.jsx)(`div`,{className:`px-2.5 py-2 font-mono text-xs text-foreground select-all`,"data-slot":`trace-request-endpoint`,children:n})}function Ze({view:e,onChange:t}){return(0,q.jsxs)(`div`,{className:`flex h-full shrink-0 items-stretch`,role:`group`,"aria-label":`Body view`,"data-slot":`trace-request-view-toggle`,children:[(0,q.jsx)(Qe,{active:e===`fields`,label:`Fields`,icon:Ae,onClick:()=>t(`fields`)}),(0,q.jsx)(Qe,{active:e===`raw`,label:`Raw`,icon:le,onClick:()=>t(`raw`)})]})}function Qe({active:e,label:t,icon:n,onClick:a}){return(0,q.jsxs)(`button`,{type:`button`,className:i(d,`font-semibold tracking-[0.08em] uppercase`,e?x:b),"aria-pressed":e,"aria-label":t,onClick:a,children:[(0,q.jsx)(r,{icon:n,className:`size-3`}),(0,q.jsx)(`span`,{className:`hidden sm:inline`,children:t})]})}function $e({rows:e,dataSlot:t}){return(0,q.jsx)(`ul`,{"data-slot":t,children:e.map(e=>(0,q.jsxs)(`li`,{className:i(_,`group/field items-start`),"data-slot":`trace-payload-field`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 sm:flex-row sm:items-baseline sm:gap-3`,children:[(0,q.jsx)(`span`,{className:`w-[7.5rem] shrink-0 truncate font-mono text-[11px] font-medium text-sky-600 dark:text-sky-400`,children:e.key}),(0,q.jsx)(`span`,{className:i(`min-w-0 flex-1 break-all font-mono text-[11px] leading-snug`,et(e.kind)),title:e.display,children:e.display})]}),(0,q.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-[9px] tracking-wide text-muted-foreground uppercase opacity-70`,children:e.kind}),(0,q.jsx)(`div`,{className:`opacity-0 transition-opacity group-hover/field:opacity-100 group-focus-within/field:opacity-100`,children:(0,q.jsx)(Y,{label:`Copy ${e.key}`,text:Ue(e.value),dataSlot:`trace-payload-copy-field`,bare:!0})})]},e.key))})}function et(e){switch(e){case`string`:return`text-teal-800/90 dark:text-teal-300/90`;case`number`:return`text-amber-800 dark:text-amber-300`;case`boolean`:return`text-violet-800 dark:text-violet-300`;case`null`:return`text-muted-foreground italic`;default:return`text-foreground/80`}}function Y({text:e,label:t,dataSlot:n,bare:i=!1}){let[l,u]=(0,H.useState)(!1),d=async t=>{t.stopPropagation();try{await navigator.clipboard.writeText(e),u(!0),window.setTimeout(()=>u(!1),1200)}catch{u(!1)}};return(0,q.jsxs)(a,{children:[(0,q.jsx)(c,{render:e=>(0,q.jsx)(`button`,{...e,type:`button`,className:i?v:f,"aria-label":l?`Copied`:t,"data-slot":n,onClick:t=>{e.onClick?.(t),d(t)},children:(0,q.jsx)(r,{icon:l?s:ce,className:`size-3.5`})})}),(0,q.jsx)(o,{side:`bottom`,className:`text-[11px]`,children:l?`Copied`:t})]})}function tt(e){return e.effects.some(e=>e.kind===`send`||e.kind===`ask`||e.reversibility===`irreversible`)}function nt(e){return{rootId:e.id,dryRun:tt(e)}}async function rt(e,t=ae){return t(nt(e))}function it(e){return e.id}function at(e){let t=ot(e),n=Ce[t];return{icon:n.icon,label:n.label}}function ot(e){switch(e){case`http`:return`http`;case`signal`:return`signal`;case`every`:return`every`;case`cron`:return`cron`;case`cdc`:return`cdc`;case`internal`:return`internal`;default:return`internal`}}function st(e,t,n){return!Number.isFinite(t)||!Number.isFinite(n)||n<=0?e.map((e,t)=>({index:t,kind:e.kind,resource:e.resource,startOffsetMs:0,durationMs:0,offsetRatio:0,widthRatio:0,...e.external===void 0?{}:{external:e.external}})):e.map((e,r)=>{let i=Number.isFinite(e.timestamp)?e.timestamp-t:0,a=Number.isFinite(e.duration)?Math.max(0,e.duration):0,o=Math.min(n,Math.max(0,i)),s=Math.min(n,Math.max(o,i+a))-o;return{index:r,kind:e.kind,resource:e.resource,startOffsetMs:o,durationMs:s,offsetRatio:o/n,widthRatio:s/n,...e.external===void 0?{}:{external:e.external}}})}var X=[1,2,4,8];function Z(e,t=0){let n=Number.isFinite(e)&&e>=1?e:1,r=1/n;return{startRatio:Math.min(Number.isFinite(t)?Math.max(0,t):0,Math.max(0,1-r)),widthRatio:r,zoom:n}}function Q(e,t,n){let r=e,i=e+t,a=n.startRatio+n.widthRatio;if(i<=n.startRatio||r>=a)return null;let o=Math.max(r,n.startRatio),s=Math.min(i,a);return{left:(o-n.startRatio)/n.widthRatio,width:(s-o)/n.widthRatio}}function ct(e,t=5){if(!Number.isFinite(e)||e<=0)return[0];let n=pt(e,t),r=[0];for(let t=n;t<e-n*.25;t+=n)r.push(Math.round(t*1e3)/1e3);return r[r.length-1]!==e&&r.push(e),r}function lt(e,t,n=5){if(!Number.isFinite(e)||e<=0)return[{offsetMs:0,viewRatio:0,isEnd:!0}];let r=t.startRatio*e,i=t.widthRatio*e,a=ct(i,n).map(e=>r+e),o=Math.min(e,r+i);return a[a.length-1]!==o&&(a[a.length-1]=o),a.map((e,t)=>({offsetMs:e,viewRatio:(e-r)/i,isEnd:t===a.length-1}))}function ut(e,t){if(!Number.isFinite(t)||t<=0)return[];let n=ft(e,t),r=[],i=0;for(let[e,a]of n)e>i&&r.push(dt(i,e,t)),i=Math.max(i,a);return i<t&&r.push(dt(i,t,t)),r.filter(e=>e.durationMs>0&&e.widthRatio>0)}function dt(e,t,n){let r=Math.max(0,e),i=Math.max(0,t-r);return{startOffsetMs:r,durationMs:i,offsetRatio:r/n,widthRatio:i/n}}function ft(e,t){let n=e.map(e=>{let n=Math.max(0,Math.min(t,e.startOffsetMs));return[n,Math.max(n,Math.min(t,e.startOffsetMs+e.durationMs))]}).filter(([e,t])=>t>e).sort((e,t)=>e[0]-t[0]),r=[];for(let e of n){let t=r[r.length-1];!t||e[0]>t[1]?r.push([e[0],e[1]]):t[1]=Math.max(t[1],e[1])}return r}function pt(e,t){let n=e/Math.max(1,t),r=10**Math.floor(Math.log10(Math.max(n,1e-6))),i=n/r,a;return a=i<=1?1:i<=2?2:i<=5?5:10,a*r}function mt(e){return X.find(t=>t>e)??X[X.length-1]}function ht(e){let t=X[0];for(let n of X){if(n>=e)return t;t=n}return t}function gt(e){let t=`${De(e)} · ${e.resource} · ${D(e.durationMs)} · +${D(e.startOffsetMs)}`;if(!e.external)return t;let n=[e.external.host];return e.external.provider&&n.push(e.external.provider),e.external.kind&&n.push(e.external.kind),`${t} · ↗ ${n.join(` · `)}`}var $=`border-b border-border/60 last:border-b-0`;function _t({run:e,onClose:t,replay:n=ae,focusEffectIndex:a=null,onFocusEffectChange:o,playbackKey:s=0,onReplayStart:c}){let l=ye(),v=Me(),b=e?at(e.trigger):null,x=e?Ee(e.cache):null,oe=(0,H.useMemo)(()=>e?we(e):[],[e]),se=(0,H.useMemo)(()=>e?ke(e.gates,l.data??null):[],[e,l.data]),S=(0,H.useMemo)(()=>e?st(e.effects,e.startedAt,e.durationMs):[],[e]),ce=(0,H.useMemo)(()=>e?ut(S,e.durationMs):[],[e,S]),C=(0,H.useMemo)(()=>e?Oe(l.data??null,e.flow,e.trigger):{method:null,path:null,headline:``},[e,l.data]),[le,w]=(0,H.useState)(!1),[T,E]=(0,H.useState)(null),[xe,O]=(0,H.useState)(null),[Se,k]=(0,H.useState)(!0),[Ce,A]=(0,H.useState)(!0),[Ae,j]=(0,H.useState)(!0),[M,N]=(0,H.useState)(null),[P,F]=(0,H.useState)(1),[I,R]=(0,H.useState)(0),[z,B]=(0,H.useState)(!1),V=U(0),W=U(0),G=(0,H.useMemo)(()=>Z(P,I),[P,I]),Pe=(0,H.useMemo)(()=>e?lt(e.durationMs,G):[],[e,G]),Fe=K(V,e=>{let t=Q(e,1e-4,G);return t?`${t.left*100}%`:`-10%`});(0,H.useEffect)(()=>{if(E(null),O(null),w(!1),k(!0),A(!0),j(!0),N(null),F(1),R(0),B(!1),V.set(0),!e)return;if(v){W.set(e.durationMs);return}W.set(0);let t=_e(W,e.durationMs,{duration:.6,ease:[.16,1,.3,1]});return()=>t.stop()},[e?.id,v]),(0,H.useEffect)(()=>{if(s===0||!e)return;if(v){V.set(1),W.set(e.durationMs),B(!1);return}B(!0),V.set(0),W.set(0);let t=_e(V,1,{duration:Ie(e.durationMs)/1e3,ease:`linear`,onUpdate:t=>W.set(t*e.durationMs),onComplete:()=>{W.set(e.durationMs),B(!1)}});return()=>{t.stop(),B(!1)}},[s]);let Le=async t=>{if(t.stopPropagation(),e&&!le){w(!0),E(null),O(null);try{let t=await rt(e,n);if(t.error){E(t.error.message??t.error.code),O(`error`);return}E(t.data?.dryRun?`Replayed (dry-run)`:`Replayed`),O(`ok`),c?.()}catch(e){E(e instanceof Error?e.message:`Replay failed`),O(`error`)}finally{w(!1)}}};return(0,q.jsx)(p,{open:e!==null,modal:!1,disablePointerDismissal:!0,onOpenChange:e=>{e||t()},children:(0,q.jsx)(ee,{side:`left`,showOverlay:!1,"data-slot":`trace-detail-sheet`,className:`inset-y-0 h-dvh w-full max-w-none gap-0 rounded-none p-0 shadow-xl md:left-12! data-[side=left]:sm:max-w-2xl`,children:e&&b?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(h,{className:`gap-1.5 border-b border-border/60 px-2 py-2 pr-12`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(`span`,{className:`mt-0.5 text-muted-foreground`,title:b.label,"aria-hidden":!0,children:(0,q.jsx)(r,{icon:b.icon,className:g})}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(re,{className:`truncate font-mono text-base font-semibold tracking-tight`,children:e.flow}),(0,q.jsxs)(ne,{className:`mt-0.5 flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:b.label}),x?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,q.jsxs)(`span`,{className:i(`inline-flex items-center gap-1`,x.className),"data-slot":`trace-sheet-cache`,"data-cache":e.cache,title:x.label,children:[(0,q.jsx)(r,{icon:x.icon,className:`size-3`,"aria-hidden":!0}),x.label]})]}):null]})]})]}),(0,q.jsx)(he,{mode:`wait`,children:T?(0,q.jsx)(L.div,{initial:!v&&{opacity:0,y:-4,scale:.96},animate:{opacity:1,y:0,scale:1},exit:v?void 0:{opacity:0,y:-4,scale:.96},transition:{duration:.18,ease:`easeOut`},children:(0,q.jsx)(ue,{variant:`outline`,role:`status`,className:i(`h-5 w-fit rounded-md px-1.5 text-[10px] font-medium`,xe===`ok`&&`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`,xe===`error`&&`border-destructive/40 bg-destructive/10 text-destructive`),children:T})},T):null})]}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-0 overflow-y-auto p-0`,children:[(0,q.jsx)(`section`,{className:$,"data-slot":`trace-summary`,children:(0,q.jsx)(yt,{chips:oe,durationMs:e.durationMs,durationValue:W})}),se.length>0?(0,q.jsx)(`section`,{className:$,"data-slot":`trace-gates`,children:(0,q.jsx)(Te,{gates:se})}):null,(0,q.jsxs)(`section`,{className:$,"data-slot":`trace-waterfall`,children:[(0,q.jsxs)(`div`,{className:y,children:[(0,q.jsx)(`h3`,{className:i(ie,`flex items-center px-2`),children:`Waterfall`}),(0,q.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,"data-slot":`trace-waterfall-zoom`,children:[(0,q.jsx)(`button`,{type:`button`,className:f,"aria-label":`Pan left`,disabled:P<=1||G.startRatio<=0,onClick:()=>R(e=>Z(P,Math.max(0,e-G.widthRatio*.5)).startRatio),children:(0,q.jsx)(r,{icon:ge,className:`size-3.5`})}),(0,q.jsx)(`button`,{type:`button`,className:f,"aria-label":`Zoom out`,disabled:P<=1,onClick:()=>{let e=ht(P);F(e),R(t=>Z(e,t).startRatio)},children:(0,q.jsx)(r,{icon:Ne,className:`size-3.5`})}),(0,q.jsxs)(`span`,{className:`flex min-w-8 items-center justify-center font-mono text-[10px] tabular-nums text-muted-foreground`,children:[P,`×`]}),(0,q.jsx)(`button`,{type:`button`,className:f,"aria-label":`Zoom in`,disabled:P>=8,onClick:()=>{let e=mt(P);F(e),R(t=>Z(e,t).startRatio)},children:(0,q.jsx)(r,{icon:je,className:`size-3.5`})}),(0,q.jsx)(`button`,{type:`button`,className:f,"aria-label":`Pan right`,disabled:P<=1||G.startRatio+G.widthRatio>=1,onClick:()=>R(e=>Z(P,e+G.widthRatio*.5).startRatio),children:(0,q.jsx)(r,{icon:ve,className:`size-3.5`})})]})]}),S.length===0?(0,q.jsx)(`p`,{className:`px-2 py-2 text-[11px] text-muted-foreground`,children:`No effects recorded`}):(0,q.jsxs)(`div`,{className:`relative flex flex-col gap-1.5 px-2 py-2`,children:[(0,q.jsx)(Ct,{ticks:Pe}),(0,q.jsx)(wt,{bars:S,gaps:ce,view:G,hoverIndex:M,onHover:N,onSelect:e=>o?.(a===e?null:e),focusIndex:a}),S.map(e=>(0,q.jsx)(Et,{bar:e,view:G,dimmed:M!==null&&M!==e.index,focused:a===e.index,progress:V,playing:z,onHover:N,onSelect:e=>o?.(a===e?null:e)},e.index)),z?(0,q.jsx)(L.div,{className:`pointer-events-none absolute top-4 bottom-0 w-px bg-foreground/70`,style:{left:Fe},"data-slot":`trace-waterfall-playhead`,"aria-hidden":!0}):null,ce.length>0?(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Hatched spans are idle time — no effects recorded.`}):null]})]}),(0,q.jsx)(`section`,{className:$,"data-slot":`trace-events-section`,children:(0,q.jsxs)(me,{open:Se,onOpenChange:k,children:[(0,q.jsxs)(`div`,{className:y,children:[(0,q.jsxs)(pe,{className:i(d,`min-w-0 flex-1 justify-start`),"data-slot":`trace-events-toggle`,children:[(0,q.jsx)(r,{icon:fe,className:i(m,!Se&&`-rotate-90`)}),(0,q.jsx)(`span`,{className:`truncate`,children:`Event Details`}),(0,q.jsxs)(`span`,{className:u,children:[e.effects.length,` `,e.effects.length===1?`event`:`events`]})]}),(0,q.jsxs)(`button`,{type:`button`,className:d,disabled:le,"data-slot":`trace-sheet-replay`,onClick:e=>void Le(e),children:[(0,q.jsx)(r,{icon:be,className:`size-3.5`}),`Replay`]})]}),(0,q.jsx)(de,{children:(0,q.jsx)(`ul`,{className:`flex flex-col`,"data-slot":`trace-events`,children:e.effects.map((e,t)=>{let n=S[t],r=a===t;return(0,q.jsxs)(`li`,{"data-slot":`trace-event-row`,"data-index":t,"data-focused":r?`true`:`false`,"data-external":e.external?`true`:void 0,className:i(_,`cursor-pointer flex-col items-stretch gap-1 text-[11px]`,r&&`bg-muted/70 text-foreground`,M===t&&!r&&`bg-muted/50`),onClick:()=>o?.(a===t?null:t),onMouseEnter:()=>N(t),onMouseLeave:()=>N(null),children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:i(te,r&&`bg-sky-500`)}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(vt,{kind:e.kind,resource:e.resource}),(0,q.jsx)(`span`,{className:`w-[4.5rem] shrink-0 font-medium text-foreground/90`,children:De(e)}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-muted-foreground`,children:[e.resource,e.external?` · ↗ ${e.external.host}${e.external.kind?` (${e.external.kind})`:``}`:``]}),(0,q.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:D(e.duration)})]}),n?(0,q.jsx)(`div`,{className:`relative ml-7 h-1.5 w-[calc(100%-1.75rem)] rounded-full bg-muted/70`,"data-slot":`trace-event-bar-track`,"aria-hidden":!0,children:(0,q.jsx)(Dt,{bar:n,left:n.offsetRatio,width:n.widthRatio,progress:V,playing:z,slot:`trace-event-bar`})}):null]},`${e.kind}:${e.resource}:${t}`)})})})]})}),(0,q.jsx)(qe,{method:C.method,path:C.path,headline:C.headline,input:e.input,output:e.output,error:e.error,errorMessage:e.errorMessage,inputOpen:Ce,onInputOpenChange:A,outputOpen:Ae,onOutputOpenChange:j})]})]}):null})})}function vt({kind:e,resource:t}){let n=A(e);return(0,q.jsx)(`span`,{className:g,style:{color:n},"aria-hidden":!0,children:(0,q.jsx)(r,{icon:k(e,t),className:`size-3.5`})})}function yt({chips:e,durationMs:t,durationValue:n}){let s=e.find(e=>e.variant===`duration`),l=e.filter(e=>e.variant!==`duration`),u=K(n,e=>D(Math.round(e)));return(0,q.jsxs)(`div`,{className:y,"data-slot":`trace-summary-strip`,role:`group`,"aria-label":`Run summary`,children:[s?(0,q.jsxs)(a,{children:[(0,q.jsx)(c,{render:e=>(0,q.jsxs)(`div`,{...e,className:`flex h-full shrink-0 items-center gap-1.5 px-2`,"data-slot":`trace-summary-duration`,children:[(0,q.jsx)(r,{icon:O,className:i(`size-3.5`,E(t)),"aria-hidden":!0}),(0,q.jsx)(L.span,{className:i(`font-mono text-sm font-semibold tracking-tight tabular-nums leading-none`,E(t)),children:u})]})}),(0,q.jsx)(o,{side:`bottom`,className:`max-w-xs text-[11px]`,children:s.detail})]}):null,l.length>0?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0}),(0,q.jsx)(`ul`,{className:`flex h-full min-w-0 flex-1 flex-nowrap items-stretch overflow-x-auto overscroll-x-contain [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:l.map(e=>(0,q.jsx)(`li`,{className:`list-none shrink-0`,children:(0,q.jsx)(bt,{chip:e})},e.key))})]}):null]})}function bt({chip:e}){let t=St(e.variant),n=xt(e.variant);return(0,q.jsxs)(a,{children:[(0,q.jsx)(c,{render:a=>(0,q.jsxs)(`span`,{...a,className:i(d,`text-foreground/90`),"data-slot":`trace-summary-chip`,"data-variant":e.variant,children:[(0,q.jsx)(`span`,{style:{color:t},"aria-hidden":!0,children:(0,q.jsx)(r,{icon:n,className:`size-3`})}),(0,q.jsx)(`span`,{className:`tabular-nums font-medium`,children:e.shortLabel}),(0,q.jsx)(`span`,{className:`sr-only`,children:e.label})]})}),(0,q.jsxs)(o,{side:`bottom`,className:`max-w-xs flex-col items-start gap-0.5 text-[11px]`,children:[(0,q.jsx)(`p`,{className:`font-medium text-background`,children:e.label}),(0,q.jsx)(`p`,{className:`text-background/70`,children:e.detail})]})]})}function xt(e){switch(e){case`duration`:return O;case`api`:return se;case`gate`:return C.gate.icon;case`cache`:return Se;case`db`:return C.store.icon;case`logs`:return T;default:return k(e)}}function St(e){switch(e){case`duration`:return`currentColor`;case`api`:return`var(--foreground)`;case`gate`:return j.gate.accent;case`cache`:return`var(--color-sky-500)`;case`db`:return j.store.accent;case`logs`:return`var(--muted-foreground)`;default:return A(e)}}function Ct({ticks:e}){return(0,q.jsx)(`div`,{className:`relative h-4 w-full border-b border-border/60`,"data-slot":`trace-waterfall-ruler`,children:e.map(e=>(0,q.jsxs)(`div`,{className:`absolute top-0 flex h-full flex-col items-center`,style:{left:`${e.viewRatio*100}%`,transform:e.isEnd?`translateX(-100%)`:e.viewRatio===0?`none`:`translateX(-50%)`},children:[(0,q.jsx)(`span`,{className:`font-mono text-[9px] tabular-nums text-muted-foreground`,children:D(e.offsetMs)}),(0,q.jsx)(`span`,{className:`mt-auto h-1.5 w-px bg-border`,"aria-hidden":!0})]},`${e.offsetMs}-${e.viewRatio}`))})}function wt({bars:e,gaps:t,view:n,hoverIndex:r,onHover:s,onSelect:l,focusIndex:u}){return(0,q.jsxs)(`div`,{className:`relative h-3 w-full overflow-hidden rounded-full bg-muted/50`,"data-slot":`trace-waterfall-overview`,children:[t.map(e=>{let t=Q(e.offsetRatio,e.widthRatio,n);return!t||t.width<=0?null:(0,q.jsx)(Tt,{left:t.left,width:t.width,gap:e},`gap-${e.startOffsetMs}`)}),e.map(e=>{let t=Q(e.offsetRatio,e.widthRatio,n);if(!t||t.width<=0)return null;let d=u===e.index;return(0,q.jsxs)(a,{children:[(0,q.jsx)(c,{render:n=>(0,q.jsx)(`div`,{...n,className:i(`absolute inset-y-0.5 cursor-pointer rounded-full transition-opacity`,r!==null&&r!==e.index&&!d&&`opacity-35`,d&&`ring-1 ring-foreground/40`,e.external&&`outline outline-1 outline-dashed outline-foreground/50`),style:{left:`${t.left*100}%`,width:`${Math.max(t.width*100,.4)}%`,backgroundColor:A(e.kind)},"data-slot":`trace-waterfall-overview-bar`,"data-external":e.external?`true`:void 0,onClick:t=>{t.stopPropagation(),l?.(e.index)},onMouseEnter:t=>{n.onMouseEnter?.(t),s(e.index)},onMouseLeave:e=>{n.onMouseLeave?.(e),s(null)}})}),(0,q.jsx)(o,{side:`top`,className:`max-w-xs font-mono text-[11px]`,children:gt(e)})]},`ov-${e.index}`)})]})}function Tt({left:e,width:t,gap:n}){return(0,q.jsxs)(a,{children:[(0,q.jsx)(c,{render:n=>(0,q.jsx)(`div`,{...n,className:`absolute inset-y-0 overflow-hidden rounded-sm`,style:{left:`${e*100}%`,width:`${t*100}%`},"data-slot":`trace-waterfall-gap`,children:(0,q.jsx)(`div`,{className:`size-full opacity-70`,style:{backgroundImage:`repeating-linear-gradient(-45deg, color-mix(in oklab, var(--muted-foreground) 28%, transparent) 0 1px, transparent 1px 5px)`},"aria-hidden":!0})})}),(0,q.jsxs)(o,{side:`top`,className:`max-w-xs text-[11px]`,children:[`Idle · `,D(n.durationMs),` — no effects recorded`]})]})}function Et({bar:e,view:t,dimmed:n,focused:r,progress:i,playing:s,onHover:l,onSelect:u}){let d=Q(e.offsetRatio,e.widthRatio,t);return!d||d.width<=0?null:(0,q.jsxs)(a,{children:[(0,q.jsx)(c,{render:t=>(0,q.jsx)(`div`,{...t,className:`relative h-2.5 w-full cursor-pointer rounded-full bg-muted/70`,"data-slot":`trace-waterfall-track`,"data-index":e.index,onClick:t=>{t.stopPropagation(),u?.(e.index)},onMouseEnter:n=>{t.onMouseEnter?.(n),l(e.index)},onMouseLeave:e=>{t.onMouseLeave?.(e),l(null)},children:(0,q.jsx)(Dt,{bar:e,left:d.left,width:d.width,progress:i,playing:s,dimmed:n,focused:r,slot:`trace-waterfall-bar`})})}),(0,q.jsx)(o,{side:`top`,className:`max-w-xs font-mono text-[11px]`,children:gt(e)})]})}function Dt({bar:e,left:t,width:n,progress:r,playing:a,dimmed:o=!1,focused:s=!1,slot:c}){let l=Math.max(e.widthRatio,.02),u=K(r,[e.offsetRatio,e.offsetRatio+l],[0,1],{clamp:!0}),d=K(r,t=>t>=e.offsetRatio?1:.25),f=a;return(0,q.jsx)(L.div,{className:i(`absolute inset-y-0 rounded-full transition-opacity`,!f&&o&&!s&&`opacity-35`,s&&`ring-1 ring-foreground/40`,e.external&&`outline outline-1 outline-dashed outline-foreground/50`),style:{left:`${t*100}%`,width:`${Math.max(n*100,.5)}%`,backgroundColor:A(e.kind),transformOrigin:`left`,...f?{scaleX:u,opacity:d}:{}},"data-slot":c,"data-external":e.external?`true`:void 0})}export{Ie as a,U as c,ze as i,at as n,Le as o,it as r,K as s,_t as t};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{r as t}from"./react-dom-Ddte4I-Q.js";import{A as n,f as r}from"./xyflow-yApv7D4e.js";import{$ as i,A as a,B as o,Bn as s,Bt as c,Ct as l,D as u,Dr as d,E as f,Er as p,Et as m,Gn as h,Gr as g,H as _,Ht as v,In as y,Jn as b,Jt as ee,Kn as x,Kr as S,Kt as C,M as w,Mn as T,N as E,O as D,On as O,Or as k,Ot as A,P as j,Q as M,Qt as N,S as P,St as F,Tt as I,U as L,Un as R,Ur as z,Ut as te,V as ne,Vr as re,Wn as B,Wr as ie,Wt as V,Xt as ae,Yi as H,Yt as oe,Zn as se,Zt as U,_n as W,bn as G,br as K,cr as ce,dn as q,dt as le,ft as ue,g as de,gn as fe,ht as pe,in as me,j as he,jn as ge,k as _e,lt as ve,mn as ye,mr as be,mt as xe,nn as Se,pi as Ce,pr as we,pt as Te,qn as Ee,qt as De,sr as Oe,st as ke,un as Ae,v as je,wr as Me,xr as Ne,yr as Pe,yt as Fe,z as J}from"./shortcut-keys-3ILd8oGn.js";import{i as Ie}from"./call-pii-button-jOmYISdc.js";import{m as Le,s as Re}from"./element-icons-BI8cJgdh.js";import{t as ze}from"./UserIcon-DaE2PB5_.js";import{t as Be}from"./dagre.esm-B1_XeuLP.js";import{_ as Ve,b as He,f as Ue,g as We,h as Ge,m as Ke,p as qe,x as Je,y as Ye}from"./dropdown-menu-4h2LOVXM.js";import{bt as Xe,it as Ze}from"./index-Cul17AcV.js";var Qe=[[`path`,{d:`M8 7H16.75C18.8567 7 19.91 7 20.6667 7.50559C20.9943 7.72447 21.2755 8.00572 21.4944 8.33329C22 9.08996 22 10.1433 22 12.25C22 15.7612 22 17.5167 21.1573 18.7779C20.7926 19.3238 20.3238 19.7926 19.7779 20.1573C18.5167 21 16.7612 21 13.25 21H12C7.28595 21 4.92893 21 3.46447 19.5355C2 18.0711 2 15.714 2 11V7.94427C2 6.1278 2 5.21956 2.38032 4.53806C2.65142 4.05227 3.05227 3.65142 3.53806 3.38032C4.21956 3 5.1278 3 6.94427 3C8.10802 3 8.6899 3 9.19926 3.19101C10.3622 3.62712 10.8418 4.68358 11.3666 5.73313L12 7`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}]],$e=[[`path`,{d:`M18 19C18 19 13.5811 14 12 14C10.4188 14 6 19 6 19`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M18 5.00004C18 5.00004 13.5811 9.99999 12 10C10.4188 10 6 5 6 5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],et=[[`path`,{d:`M18 14C18 14 13.5811 19 12 19C10.4188 19 6 14 6 14`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M18 9.99996C18 9.99996 13.5811 5.00001 12 5C10.4188 4.99999 6 10 6 10`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]];function tt(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=A(),a=Fe()!=null,o=se(()=>new le({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new M,floatingId:i,syncOnly:!1,nested:a})).current;return h(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=T(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}var Y=e(t(),1);function nt(e){let[t,n]=Y.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}var X=n();function Z(e){return e.kind===`index`||e.kind===`function`||e.kind===`trigger`||e.kind===`extension`||e.kind===`policy`?e.kind:null}function rt(e){return Z(e)!==null}function it(e){return e.kind===`table`&&typeof e.rls==`boolean`}function at(e,t,n){return typeof e.rlsPolicyCount==`number`?e.rlsPolicyCount:Object.keys(t?.stores?.[n]?.tables?.[e.name]?.policies??{}).length}function ot(e){let t=Z(e);return t===`index`?`Indexes`:t===`function`?`Functions`:t===`trigger`?`Triggers`:t===`extension`?`Extensions`:t===`policy`?`RLS Policies`:e.name}function st(e){let t=[],n=[];for(let r of e)rt(r)?n.push(r):t.push(r);return{tables:t,catalog:n}}function ct(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var lt=[`console.store.query`];function ut(e,t,n){if(!e||!n||!t)return;let r=t[1];if(ft(r)&&r.ref===n.ref&&(r.child??``)===(n.child??``)&&(r.tenant??``)===(n.tenant??``))return e}function dt(e,t){return H({queryKey:[...lt,e],enabled:t&&e!==null,placeholderData:(t,n)=>ut(t,n?.queryKey,e),queryFn:async()=>{if(!e)throw Error(`Missing store query input`);let t=await Ce(e);if(t.error)throw Error(re(t.error));if(!t.data)throw Error(`Empty store query`);return t.data}})}function ft(e){return typeof e==`object`&&!!e&&`ref`in e&&typeof e.ref==`string`}function pt(e){let t=Y.useRef(!0);t.current&&(t.current=!1,e())}var mt=Y.createContext(void 0),ht=Y.createContext(void 0),gt=Y.createContext(void 0);function Q(){let e=Y.useContext(mt);if(e===void 0)throw Error(B(60));return e}function _t(){let e=Y.useContext(ht);if(e===void 0)throw Error(B(101));return e}function vt(){let e=Y.useContext(gt);if(e===void 0)throw Error(B(61));return e}function yt(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var bt=(e,t)=>Object.is(e,t);function xt(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function St(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!yt(e,t,(e,t)=>xt(e,t,n)):e!==t}function Ct(e,t,n){return e?e.some(e=>e!==void 0&&xt(t,e,n)):!1}function wt(e,t,n){return e?e.findIndex(e=>e!==void 0&&xt(e,t,n)):-1}function Tt(e,t){if(t!==bt)return n=>Ct(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function Et(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(Tt(t,n)):wt(e,t,n);return i===-1?null:i}function Dt(e,t,n,r,i,a){return Ct(r,t,i)?a!=null&&e>a&&Ct(r,n[a],i)?a:e:e===a?Et(n,r,i,!0):a}function Ot(e,t,n){return e.filter(e=>!xt(t,e,n))}function kt(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function At(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function jt(e){return At(e?.[0])}function Mt(e){return jt(e)?e.flatMap(e=>e.items):e}function Nt(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(jt(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function Pt(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return kt(e)}function Ft(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?kt(e.value):kt(e)}function It(e,t,n){function r(){return Pt(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=Mt(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function Lt(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,X.jsx)(Y.Fragment,{children:It(r,t,n)},i)),e),[])}var Rt={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:Ft(t,r)!==``},hasNullItemLabel:(e,t)=>t?Nt(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>xt(t,e,n)):xt(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function zt(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function Bt(e,t){return Math.max(0,e-t)}function Vt(e,t){if(t<=0)return 0;let n=zt(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function Ht(e){let{id:t,value:n,defaultValue:r=null,onValueChange:o,open:s,defaultOpen:c=!1,onOpenChange:l,name:d,form:f,autoComplete:p,disabled:g=!1,readOnly:_=!1,required:y=!1,modal:S=!0,actionsRef:C,inputRef:T,onOpenChangeComplete:O,items:k,multiple:A=!1,itemToStringLabel:j,itemToStringValue:M,isItemEqualToValue:N=bt,highlightItemOnHover:P=!0,children:F}=e,{clearErrors:I}=w(),{setDirty:L,setTouched:R,setFocused:z,validityData:ne,setFilled:re,name:B,disabled:ie,validation:V,validationMode:ae}=E(),H=a({id:t}),W=ie||g,G=B??d,[K,ce]=_e({controlled:n,default:A?r??x:r,name:`Select`,state:`value`}),[q,le]=_e({controlled:s,default:c,name:`Select`,state:`open`}),de=Y.useRef([]),fe=Y.useRef([]),pe=Y.useRef(null),he=Y.useRef(null),ge=Y.useRef(0),ye=Y.useRef(null),be=Y.useRef([]),Se=Y.useRef(!1),Ce=Y.useRef(null),we=Y.useRef(null),Te=Y.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),Oe=Y.useRef(!1),Ae=Y.useRef(K),{mounted:je,setMounted:Me,transitionStatus:Ne}=ve(q),{openMethod:Pe,triggerProps:Fe}=Ve(q),J=se(()=>new ue({id:H,labelId:void 0,modal:S,multiple:A,itemToStringLabel:j,itemToStringValue:M,isItemEqualToValue:N,value:K,open:q,mounted:je,transitionStatus:Ne,items:k,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:Ee,triggerProps:Ee,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:b,setOpen:b,handleScrollArrowVisibility:b,onOpenChangeComplete:b,listRef:de,popupRef:pe,scrollHandlerRef:he,scrollArrowsMountedCountRef:ge,valueRef:ye,valuesRef:be,labelsRef:fe,typingRef:Se,selectionRef:Te,firstItemTextRef:Ce,selectedItemTextRef:we,alignItemWithTriggerActiveRef:Oe,initialValueRef:Ae},Rt)).current,Ie=J.useState(`activeIndex`),Le=J.useState(`selectedIndex`),Re=J.useState(`triggerElement`),ze=J.useState(`positionerElement`),Be=nt(Pe),Ue=Pe??Be,We=Y.useMemo(()=>A?``:Ft(K,M),[A,K,M]),Ge=Y.useMemo(()=>A&&Array.isArray(K)?K.map(e=>Ft(e,M)):Ft(K,M),[A,K,M]),Ke=ee(Re),qe=De(()=>Ge);D(Ke,H,K,qe,!W,d);let Xe=A?Array.isArray(K)&&K.length>0:K!=null&&We!==``;h(()=>{re(Xe)},[Xe,re]),h(function(){let e=Et(be.current,K,N,A);e===null&&(we.current=null),!q&&J.set(`selectedIndex`,e)},[A,q,K,N,J]),u(K,()=>{I(G),L(St(K,ne.initialValue,N)),V.change(K)});let Ze=De((e,t)=>{l?.(e,t),!t.isCanceled&&(le(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(R(!0),z(!1),ae===`onBlur`&&V.commit(K)))}),Qe=De(()=>{Me(!1),J.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),O?.(!1)});ke({enabled:!C,open:q,ref:pe,onComplete(){q||Qe()}}),Y.useImperativeHandle(C,()=>({unmount:Qe}),[Qe]);let $e=De((e,t)=>{o?.(e,t),!t.isCanceled&&ce(e)}),et=De(e=>{let t=Bt(e.scrollHeight,e.clientHeight),n=Vt(e.scrollTop,t),r=n>0,i=n<t;J.set(`scrollUpArrowVisible`,r),J.set(`scrollDownArrowVisible`,i)}),Z=tt({open:q,onOpenChange:Ze,elements:{reference:Re,floating:ze}}),rt=Je(Z,{enabled:!W,event:`mousedown`}),it=xe(Z),at=He(Z,{enabled:!W,listRef:de,activeIndex:Ie,selectedIndex:Le,disabledIndices:x,onNavigate(e){(e!==null||q)&&J.set(`activeIndex`,e)},focusItemOnHover:P}),ot=Ye(Z,{enabled:!W&&(q||!_&&!A),listRef:fe,activeIndex:Ie,selectedIndex:Le,disabledIndices:e=>ct(de.current[e]),onMatch(e){q?J.set(`activeIndex`,e):$e(be.current[e],U(me))},onTyping(e){Se.current=e}}),st=Y.useMemo(()=>m(ot.reference,at.reference,it.reference,rt.reference,Fe),[rt.reference,ot.reference,at.reference,it.reference,Fe]),lt=Y.useMemo(()=>m(i,ot.floating,at.floating,it.floating),[ot.floating,at.floating,it.floating]),ut=at.item??Ee;J.useContextCallback(`setValue`,$e),J.useContextCallback(`setOpen`,Ze),J.useContextCallback(`handleScrollArrowVisibility`,et),J.useContextCallback(`onOpenChangeComplete`,O),pt(()=>{J.update({popupProps:lt,triggerProps:st})}),J.useSyncedValues({id:H,modal:S,multiple:A,value:K,open:q,mounted:je,transitionStatus:Ne,popupProps:lt,triggerProps:st,items:k,itemToStringLabel:j,itemToStringValue:M,isItemEqualToValue:N,openMethod:Ue});let dt=Y.useMemo(()=>({disabled:W,readOnly:_,required:y,multiple:A,highlightItemOnHover:P,itemProps:ut}),[W,_,y,A,P,ut]),ft=oe(T,V.inputRef),Q=A?void 0:G,_t=Y.useMemo(()=>!A||!Array.isArray(K)||!G?null:K.map(e=>{let t=Ft(e,M);return(0,X.jsx)(`input`,{type:`hidden`,form:f,name:G,value:t,disabled:W},t)}),[A,K,f,G,M,W]);return(0,X.jsxs)(mt.Provider,{value:J,children:[(0,X.jsx)(ht.Provider,{value:dt,children:(0,X.jsx)(gt.Provider,{value:Z,children:F})}),(0,X.jsx)(`input`,{...V.getValidationProps(W,{onFocus(){J.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||W||_)return;let t=e.currentTarget.value,n=U(me,e.nativeEvent);function r(){if(A)return;let e=t.toLowerCase(),r=be.current.findIndex(t=>Ft(t,M).toLowerCase()===e||Pt(t,j).toLowerCase()===e);r===-1&&(r=be.current.findIndex((t,n)=>{let r=fe.current[n];return r!=null&&r.toLowerCase()===e}));let i=be.current[r];i!=null&&$e(i,n)}J.set(`forceMount`,!0),queueMicrotask(r)}}),id:H&&Q==null?`${H}-hidden-input`:void 0,form:f,name:Q,autoComplete:p,value:We,disabled:W,required:y&&!(A&&Xe),readOnly:_,ref:ft,style:G?te:v,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),_t]})}function Ut(e,t){return e??t}var Wt=`data-popup-side`,Gt=400,Kt={...fe,...j,popupSide:e=>e?{[Wt]:e}:null,value:()=>null},qt=Y.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:o=!1,nativeButton:s=!0,style:c,...l}=e,{setTouched:u,setFocused:d,validationMode:f,validation:p,state:h,disabled:g}=E(),{labelId:_}=he(),v=Q(),{readOnly:y,required:b,disabled:x}=_t(),S=g||x||o,C=v.useState(`open`),w=v.useState(`mounted`),T=v.useState(`value`),D=v.useState(`triggerProps`),k=v.useState(`positionerElement`),A=v.useState(`listElement`),j=v.useState(`popupSide`),M=v.useState(`id`),F=v.useState(`labelId`),L=v.useState(`hasSelectedValue`),z=w&&k?j:null,te=i??M,ne=Ut(_,F);a({id:i});let re=ee(k),B=Y.useRef(null),{getButtonProps:ie,buttonRef:ae}=P({disabled:S,native:s}),H=v.useStateSetter(`triggerElement`),oe=R(),se=R(),W=R();Y.useEffect(()=>{if(C)return W.start(Gt,()=>{v.context.selectionRef.current.allowUnselectedMouseUp=!0,v.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{W.clear()};v.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},se.clear()},[C,v,se,W]);let G=m(D,{id:te,role:`combobox`,"aria-expanded":C,"aria-haspopup":`listbox`,"aria-controls":C?A?.id??q(k)?.id:void 0,"aria-labelledby":ne,"aria-readonly":y||void 0,"aria-required":b||void 0,tabIndex:S?-1:0,onFocus(e){d(!0),C&&v.context.alignItemWithTriggerActiveRef.current&&v.context.setOpen(!1,U(me,e.nativeEvent)),oe.start(0,()=>{v.set(`forceMount`,!0)})},onBlur(e){O(k,e.relatedTarget)||(u(!0),d(!1),f===`onBlur`&&p.commit(T))},onMouseDown(e){if(C)return;let t=V(e.currentTarget);function n(e){if(!B.current)return;let t=e.target;O(B.current,t)||O(re.current,t)||Ue(e,B.current)||v.context.setOpen(!1,U(N,e))}se.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},l,ie),K=p.getValidationProps(S,G);K.role=`combobox`;let ce={...h,open:C,disabled:S,value:T,readOnly:y,popupSide:z,placeholder:!L};return I(`button`,e,{ref:[t,B,ae,H],state:ce,stateAttributesMapping:Kt,props:K})}),Jt={value:()=>null},Yt=Y.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=Q(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?Lt(l,u,d):It(l,u,d)),I(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:Jt})}),Xt=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o={open:Q().useState(`open`)};return I(`span`,e,{state:o,ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:W})}),Zt=Y.forwardRef(function(e,t){let n=Q(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,X.jsx)(F,{ref:t,...e}):null}),Qt=Y.createContext(void 0);function $t(){let e=Y.useContext(Qt);if(!e)throw Error(B(59));return e}function en(e,t){e&&Object.assign(e.style,t)}var tn={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},nn={position:`fixed`},rn=Y.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:s,align:c,sideOffset:u,alignOffset:d,collisionBoundary:f=`clipping-ancestors`,collisionPadding:p,arrowPadding:m,sticky:g,disableAnchorTracking:v,alignItemWithTrigger:y=!0,collisionAvoidance:b=l,style:ee,...x}=e,S=Q(),C=vt(),w=S.useState(`open`),T=S.useState(`mounted`),E=S.useState(`modal`),D=S.useState(`value`),O=S.useState(`openMethod`),k=S.useState(`positionerElement`),A=S.useState(`triggerElement`),j=S.useState(`isItemEqualToValue`),M=S.useState(`transitionStatus`),N=Y.useRef(null),P=Y.useRef(null),[F,I]=Y.useState(y),L=T&&F&&O!==`touch`;!T&&F!==y&&I(y),Y.useImperativeHandle(S.context.alignItemWithTriggerActiveRef,()=>L),qe((L||E)&&w,O===`touch`,k,A);let R=_({anchor:n,floatingRootContext:C,positionMethod:a,mounted:T,side:s,sideOffset:u,align:c,alignOffset:d,arrowPadding:m,collisionBoundary:f,collisionPadding:p,sticky:g,disableAnchorTracking:v??L,collisionAvoidance:b,keepMounted:!0}),z=L?`none`:R.side,te=L?nn:R.positionerStyles,ne={open:w,side:z,align:R.align,anchorHidden:R.anchorHidden};h(()=>{S.set(`popupSide`,R.side)},[S,R.side]);let re=S.useStateSetter(`positionerElement`),B=o(e,ne,{styles:te,transitionStatus:M,props:x,refs:[t,re],hidden:!T,inert:!w}),ie=Y.useRef(0),V=De(e=>{if(S.context.valuesRef.current.length===0)return;let t=ie.current;ie.current=e.size;let n=U(me);if(t!==0&&!S.state.multiple&&D!==null&&wt(S.context.valuesRef.current,D,j)===-1){let e=S.context.initialValueRef.current,t=e!=null&&wt(S.context.valuesRef.current,e,j)!==-1?e:null;S.context.setValue(t,n),t===null&&(S.set(`selectedIndex`,null),S.context.selectedItemTextRef.current=null)}if(t!==0&&S.state.multiple&&Array.isArray(D)){let e=D.filter(e=>wt(S.context.valuesRef.current,e,j)!==-1);e.length!==D.length&&(S.context.setValue(e,n),e.length===0&&(S.set(`selectedIndex`,null),S.context.selectedItemTextRef.current=null))}if(w&&L){S.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};en(k,e),en(S.context.popupRef.current,e)}}),ae=Y.useMemo(()=>({...R,side:z,alignItemWithTriggerActive:L,setControlledAlignItemWithTrigger:I,scrollUpArrowRef:N,scrollDownArrowRef:P}),[R,z,L,I]);return(0,X.jsx)(Ke,{elementsRef:S.context.listRef,labelsRef:S.context.labelsRef,onMapChange:V,children:(0,X.jsxs)(Qt.Provider,{value:ae,children:[T&&E&&(0,X.jsx)(de,{inert:J(!w),cutout:A}),B]})})}),an=`base-ui-disable-scrollbar`,on={className:an,getElement(e){return(0,X.jsx)(`style`,{nonce:e,href:an,precedence:`base-ui:low`,children:`.${an}{scrollbar-width:none}.${an}::-webkit-scrollbar{display:none}`})}},sn=Y.createContext(void 0),cn={disableStyleElements:!1};function ln(){return Y.useContext(sn)??cn}var un=`--transform-origin`,dn={...ye,...G},fn=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,c=Q(),{multiple:l,readOnly:u,highlightItemOnHover:d}=_t(),f=vt(),{side:p,align:m,alignItemWithTriggerActive:g,isPositioned:_,setControlledAlignItemWithTrigger:v}=$t(),y=Ge(!0)!=null,b=L(),{nonce:ee,disableStyleElements:x}=ln(),S=c.useState(`id`),w=c.useState(`open`),T=c.useState(`openMethod`),E=c.useState(`mounted`),D=c.useState(`popupProps`),O=c.useState(`transitionStatus`),k=c.useState(`triggerElement`),A=c.useState(`positionerElement`),j=c.useState(`listElement`),M=Y.useRef(!1),N=Y.useRef(!1),P=Y.useRef({}),F=C(),R=De(e=>{if(!A||!c.context.popupRef.current||!N.current)return;let t=A.style.top===`0px`,n=A.style.bottom===`0px`;if(M.current||!g||!t&&!n){c.context.handleScrollArrowVisibility(e);return}let r=hn(A),i=gn(A.getBoundingClientRect().height,`y`,r),a=V(A),o=ge(A),s=o.getComputedStyle(A),l=parseFloat(s.marginTop),u=parseFloat(s.marginBottom),d=pn(o.getComputedStyle(c.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,m=mn(e),h=null,_=e=>{A.style.height=`${e}px`},v=t?m-p:p,y=Math.min(i+v,f);if(v<=1){let n=zt(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?m:0,f-(i+n)<=1&&(M.current=!0),c.context.handleScrollArrowVisibility(e);return}f-y>1?h=t?1/0:0:n&&p<m&&(h=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),h!=null){let t=zt(h,0,mn(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(M.current=!0),c.context.handleScrollArrowVisibility(e)});Y.useImperativeHandle(c.context.scrollHandlerRef,()=>R,[R]),ke({open:w,ref:c.context.popupRef,onComplete(){w&&c.context.onOpenChangeComplete(!0)}});let z={open:w,transitionStatus:O,side:p,align:m};h(()=>{A&&c.context.popupRef.current&&!Object.keys(P.current).length&&(P.current={top:A.style.top||`0`,left:A.style.left||`0`,right:A.style.right,height:A.style.height,bottom:A.style.bottom,minHeight:A.style.minHeight,maxHeight:A.style.maxHeight,marginTop:A.style.marginTop,marginBottom:A.style.marginBottom})},[c,A]),h(()=>{w||g||(N.current=!1,M.current=!1,en(A,P.current))},[w,g,A]),h(()=>{let e=c.context.popupRef.current;if(!w||!k||!A||!e||g&&!_||c.state.transitionStatus===`ending`)return;if(N.current=!0,e.style.removeProperty(un),!g){F.request(()=>c.context.handleScrollArrowVisibility(j||e));return}let t=yn(e);try{let t=c.context.selectedItemTextRef.current;t?.isConnected||(t=!c.select(`hasSelectedValue`)&&c.context.firstItemTextRef.current?.isConnected?c.context.firstItemTextRef.current:null);let n=c.context.valueRef.current,r=ge(A),i=r.getComputedStyle(A),a=r.getComputedStyle(e),o=V(k),l=hn(k),u=_n(k.getBoundingClientRect(),l),f=_n(A.getBoundingClientRect(),l),p=u.height,m=j||e,h=m.scrollHeight,g=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,y=parseFloat(i.marginBottom)||10,ee=parseFloat(i.minHeight)||100,x=pn(a),S=o.documentElement.clientHeight-_-y,C=o.documentElement.clientWidth,w=S-u.bottom+p,T,E=b===`rtl`?u.right-f.width:u.left,D=0;if(t&&n){let e=_n(n.getBoundingClientRect(),l);T=_n(t.getBoundingClientRect(),l),E=f.left+(b===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-u.top+e.height/2;D=T.top-f.top+T.height/2-r}let O=w+D+y+g,N=Math.min(S,O),F=S-_-y,I=O-N,L=C-5;A.style.left=`${zt(E,5,L-f.width)}px`,A.style.height=`${N}px`,A.style.maxHeight=`none`,A.style.marginTop=`${_}px`,A.style.marginBottom=`${y}px`,e.style.height=`100%`;let R=mn(m),z=I>=R-1;z&&(N=Math.min(S,f.height)-(I-R));let te=u.top<20||u.bottom>S-20||Math.ceil(N)+1<Math.min(h,ee),ne=(r.visualViewport?.scale??1)!==1&&s;if(te||ne){en(A,P.current),v(!1);return}let re=Math.max(ee,N);if(z){let e=Math.max(0,S-O);A.style.top=f.height>=F?`0`:`${e}px`,A.style.height=`${N}px`,m.scrollTop=mn(m)}else A.style.bottom=`0`,m.scrollTop=I;if(T){let t=f.top,n=f.height,r=T.top+T.height/2,i=zt(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(un,`50% ${i}%`)}(re===S||N>=x)&&(M.current=!0),c.context.handleScrollArrowVisibility(m),d&&c.state.selectedIndex===null&&c.state.activeIndex===null&&c.context.listRef.current[0]!=null&&c.set(`activeIndex`,0)}finally{t()}},[c,w,A,k,g,v,F,j,d,b,_]),Y.useEffect(()=>{if(!g||!A||!w)return;let e=ge(A);function t(e){c.context.setOpen(!1,U(Ae,e))}return ae(e,`resize`,t)},[c,g,A,w]);let te={...j?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":l||void 0,"aria-readonly":u||void 0,id:`${S}-list`},onKeyDown(e){y&&je.has(e.key)&&e.stopPropagation()},onScroll(e){j||R(e.currentTarget)},...g&&{style:j?{height:`100%`}:tn},className:!j&&g?on.className:void 0},re=I(`div`,e,{ref:[t,c.context.popupRef],state:z,stateAttributesMapping:dn,props:[D,te,ne(O),o]});return(0,X.jsxs)(Y.Fragment,{children:[!x&&on.getElement(ee),(0,X.jsx)(pe,{context:f,modal:!1,disabled:!E,openInteractionType:T,returnFocus:a,restoreFocus:!0,children:re})]})});function pn(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function mn(e){return Bt(e.scrollHeight,e.clientHeight)}function hn(e){return Te.getScale(e)}function gn(e,t,n){return e/n[t]}function _n(e,t){return c({x:gn(e.x,`x`,t),y:gn(e.y,`y`,t),width:gn(e.width,`x`,t),height:gn(e.height,`y`,t)})}var vn=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function yn(e){let{style:t}=e,n={};for(let[e,r]of vn)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of vn){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var bn=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Q(),{multiple:s,readOnly:c}=_t(),{alignItemWithTriggerActive:l}=$t(),u=o.useState(`hasScrollArrows`),d=o.useState(`openMethod`),f={id:`${o.useState(`id`)}-list`,role:`listbox`,"aria-multiselectable":s||void 0,"aria-readonly":c||void 0,onScroll(e){o.context.scrollHandlerRef.current?.(e.currentTarget)},...l&&{style:tn},className:u&&d!==`touch`?on.className:void 0},p=o.useStateSetter(`listElement`);return I(`div`,e,{ref:[t,p],props:[f,a]})}),xn=Y.createContext(void 0);function Sn(){let e=Y.useContext(xn);if(!e)throw Error(B(57));return e}var Cn=Y.memo(Y.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=Y.useRef(null),d=We({guess:!0,label:o,textRef:u}),f=Q(),{itemProps:p,multiple:m,disabled:g,readOnly:_}=_t(),v=g||s,b=f.useState(`isActive`,d.index),ee=f.useState(`open`),x=f.useState(`isSelected`,a),S=f.useState(`isSelectedByFocus`,d.index),C=f.useState(`isItemEqualToValue`),w=d.index,T=Y.useRef(null);h(()=>{let e=f.context.valuesRef.current;return e[w]=a,()=>{delete e[w]}},[w,a,f]),h(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=Dt(w,a,f.context.valuesRef.current,e,C,t),r=n===w,w===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&xt(a,e,C),r&&(n=w)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[w,m,C,f,a]);let E=Y.useRef(`mouse`),D=Y.useRef(!1),{getButtonProps:O,buttonRef:k}=P({disabled:v,focusableWhenDisabled:!0,native:c,composite:!0}),A={disabled:v,selected:x,highlighted:b};function j(e){if(g||_)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=x?Ot(n,a,C):[...n,a];f.context.setValue(r,U(Se,e))}else f.context.setValue(a,U(Se,e)),f.context.setOpen(!1,U(Se,e))}function M(){f.context.selectionRef.current.dragY=0}let N={role:`option`,"aria-selected":x,tabIndex:ee&&b?0:-1,onKeyDown(e){f.set(`activeIndex`,w),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=E.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&y(e.nativeEvent)&&(n!==void 0||b),i=t&&!r&&!D.current;D.current=!1,!(v||i)&&j(e.nativeEvent)},onPointerEnter(e){E.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){E.current=e.pointerType,D.current=!0,M()},onMouseUp(){if(M(),v||E.current===`touch`||D.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&x,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!x;e||t||(D.current=!0,T.current?.click(),D.current=!1)}},F=I(`div`,e,{ref:[k,t,d.ref,T],state:A,props:[p,N,l,O]}),L=Y.useMemo(()=>({selected:x,index:w,textRef:u,selectedByFocus:S}),[x,w,u,S]);return(0,X.jsx)(xn.Provider,{value:L,children:F})})),wn=Y.forwardRef(function(e,t){let{selected:n}=Sn();return e.keepMounted||n?(0,X.jsx)(Tn,{...e,ref:t}):null}),Tn=Y.memo(Y.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=Sn(),c=Y.useRef(null),{transitionStatus:l,setMounted:u}=ve(s),d=I(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:G});return ke({batch:!0,enabled:!s,open:s,ref:c,onComplete(){s||u(!1)}}),d})),En=Y.memo(Y.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=Sn(),a=Q(),{render:o,className:s,style:c,...l}=e,u=Y.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]);return I(`div`,e,{ref:[u,t,r],props:l})})),Dn=Y.createContext(void 0),On=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Y.useState(),c=Y.useMemo(()=>({labelId:o,setLabelId:s}),[o,s]),l=I(`div`,e,{ref:t,props:[{role:`group`,"aria-labelledby":o},a]});return(0,X.jsx)(Dn.Provider,{value:c,children:l})}),kn=Ht;function An({className:e,...t}){return(0,X.jsx)(On,{"data-slot":`select-group`,className:p(`scroll-my-1 p-1`,e),...t})}function jn({className:e,...t}){return(0,X.jsx)(Yt,{"data-slot":`select-value`,className:p(`flex flex-1 text-left`,e),...t})}function Mn({className:e,size:t=`default`,flat:n=!1,children:r,...i}){return(0,X.jsxs)(qt,{"data-slot":`select-trigger`,"data-size":t,"data-flat":n?`true`:void 0,className:p(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,n&&`rounded-none border-0 bg-transparent shadow-none hover:bg-transparent focus-visible:border-0 focus-visible:ring-0 dark:bg-transparent dark:hover:bg-transparent`,e),...i,children:[r,(0,X.jsx)(Xt,{render:(0,X.jsx)(d,{icon:et,className:`pointer-events-none size-4 text-muted-foreground`,strokeWidth:1.5})})]})}function Nn({className:e,children:t,side:n=`bottom`,sideOffset:r=4,align:i=`center`,alignOffset:a=0,alignItemWithTrigger:o=!0,...s}){return(0,X.jsx)(Zt,{children:(0,X.jsx)(rn,{side:n,sideOffset:r,align:i,alignOffset:a,alignItemWithTrigger:o,className:`isolate z-50`,children:(0,X.jsx)(fn,{"data-slot":`select-content`,"data-align-trigger":o,className:p(`cn-menu-target cn-menu-translucent relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...s,children:(0,X.jsx)(bn,{children:t})})})})}function Pn({className:e,children:t,...n}){return(0,X.jsxs)(Cn,{"data-slot":`select-item`,className:p(`relative flex w-full cursor-default items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[(0,X.jsx)(En,{className:`flex min-w-0 flex-1 items-center gap-2`,children:t}),(0,X.jsx)(wn,{render:(0,X.jsx)(`span`,{className:`pointer-events-none absolute top-1/2 right-2 flex size-4 -translate-y-1/2 items-center justify-center`}),children:(0,X.jsx)(d,{icon:k,className:`pointer-events-none size-3.5`,strokeWidth:1.5})})]})}var Fn=new Set([`ALL`,`SELECT`,`INSERT`,`UPDATE`,`DELETE`]),In=new Set([`PERMISSIVE`,`RESTRICTIVE`]),Ln=new Set([`public`,`current_role`,`current_user`,`session_user`]),Rn=`oke_app`;`${[`CREATE SCHEMA IF NOT EXISTS oke`,`SET search_path TO public, oke`,`DO $oke_search_path$
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{r as t}from"./react-dom-Ddte4I-Q.js";import{A as n,f as r}from"./xyflow-yApv7D4e.js";import{$ as i,A as a,B as o,Bn as s,Bt as c,Ct as l,D as u,Dr as d,E as f,Er as p,Et as m,Gn as h,Gr as g,H as _,Ht as v,In as y,Jn as b,Jt as ee,Kn as x,Kr as S,Kt as C,M as w,Mn as T,N as E,O as D,On as O,Or as k,Ot as A,P as j,Q as M,Qt as N,S as P,St as F,Tt as I,U as L,Un as R,Ur as z,Ut as te,V as ne,Vr as re,Wn as B,Wr as ie,Wt as V,Xt as ae,Yt as oe,Zi as H,Zn as se,Zt as U,_n as W,bn as G,br as K,cr as ce,dn as q,dt as le,ft as ue,g as de,gn as fe,ht as pe,in as me,j as he,jn as ge,k as _e,lt as ve,mn as ye,mr as be,mt as xe,nn as Se,pi as Ce,pr as we,pt as Te,qn as Ee,qt as De,sr as Oe,st as ke,un as Ae,v as je,wr as Me,xr as Ne,yr as Pe,yt as Fe,z as J}from"./shortcut-keys-CUNegEV4.js";import{i as Ie}from"./call-pii-button-Deo4PP18.js";import{m as Le,s as Re}from"./element-icons-CwyLpVXz.js";import{t as ze}from"./UserIcon-DaE2PB5_.js";import{t as Be}from"./dagre.esm-B1_XeuLP.js";import{_ as Ve,b as He,f as Ue,g as We,h as Ge,m as Ke,p as qe,x as Je,y as Ye}from"./dropdown-menu-nwXEO1Ac.js";import{ht as Xe,jt as Ze}from"./index-vTuwmeQz.js";var Qe=[[`path`,{d:`M8 7H16.75C18.8567 7 19.91 7 20.6667 7.50559C20.9943 7.72447 21.2755 8.00572 21.4944 8.33329C22 9.08996 22 10.1433 22 12.25C22 15.7612 22 17.5167 21.1573 18.7779C20.7926 19.3238 20.3238 19.7926 19.7779 20.1573C18.5167 21 16.7612 21 13.25 21H12C7.28595 21 4.92893 21 3.46447 19.5355C2 18.0711 2 15.714 2 11V7.94427C2 6.1278 2 5.21956 2.38032 4.53806C2.65142 4.05227 3.05227 3.65142 3.53806 3.38032C4.21956 3 5.1278 3 6.94427 3C8.10802 3 8.6899 3 9.19926 3.19101C10.3622 3.62712 10.8418 4.68358 11.3666 5.73313L12 7`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`1.5`,key:`0`}]],$e=[[`path`,{d:`M18 19C18 19 13.5811 14 12 14C10.4188 14 6 19 6 19`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M18 5.00004C18 5.00004 13.5811 9.99999 12 10C10.4188 10 6 5 6 5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],et=[[`path`,{d:`M18 14C18 14 13.5811 19 12 19C10.4188 19 6 14 6 14`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M18 9.99996C18 9.99996 13.5811 5.00001 12 5C10.4188 4.99999 6 10 6 10`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]];function tt(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=A(),a=Fe()!=null,o=se(()=>new le({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new M,floatingId:i,syncOnly:!1,nested:a})).current;return h(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=T(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}var Y=e(t(),1);function nt(e){let[t,n]=Y.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}var X=n();function Z(e){return e.kind===`index`||e.kind===`function`||e.kind===`trigger`||e.kind===`extension`||e.kind===`policy`?e.kind:null}function rt(e){return Z(e)!==null}function it(e){return e.kind===`table`&&typeof e.rls==`boolean`}function at(e,t,n){return typeof e.rlsPolicyCount==`number`?e.rlsPolicyCount:Object.keys(t?.stores?.[n]?.tables?.[e.name]?.policies??{}).length}function ot(e){let t=Z(e);return t===`index`?`Indexes`:t===`function`?`Functions`:t===`trigger`?`Triggers`:t===`extension`?`Extensions`:t===`policy`?`RLS Policies`:e.name}function st(e){let t=[],n=[];for(let r of e)rt(r)?n.push(r):t.push(r);return{tables:t,catalog:n}}function ct(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var lt=[`console.store.query`];function ut(e,t,n){if(!e||!n||!t)return;let r=t[1];if(ft(r)&&r.ref===n.ref&&(r.child??``)===(n.child??``)&&(r.tenant??``)===(n.tenant??``))return e}function dt(e,t){return H({queryKey:[...lt,e],enabled:t&&e!==null,placeholderData:(t,n)=>ut(t,n?.queryKey,e),queryFn:async()=>{if(!e)throw Error(`Missing store query input`);let t=await Ce(e);if(t.error)throw Error(re(t.error));if(!t.data)throw Error(`Empty store query`);return t.data}})}function ft(e){return typeof e==`object`&&!!e&&`ref`in e&&typeof e.ref==`string`}function pt(e){let t=Y.useRef(!0);t.current&&(t.current=!1,e())}var mt=Y.createContext(void 0),ht=Y.createContext(void 0),gt=Y.createContext(void 0);function Q(){let e=Y.useContext(mt);if(e===void 0)throw Error(B(60));return e}function _t(){let e=Y.useContext(ht);if(e===void 0)throw Error(B(101));return e}function vt(){let e=Y.useContext(gt);if(e===void 0)throw Error(B(61));return e}function yt(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var bt=(e,t)=>Object.is(e,t);function xt(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function St(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!yt(e,t,(e,t)=>xt(e,t,n)):e!==t}function Ct(e,t,n){return e?e.some(e=>e!==void 0&&xt(t,e,n)):!1}function wt(e,t,n){return e?e.findIndex(e=>e!==void 0&&xt(e,t,n)):-1}function Tt(e,t){if(t!==bt)return n=>Ct(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function Et(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(Tt(t,n)):wt(e,t,n);return i===-1?null:i}function Dt(e,t,n,r,i,a){return Ct(r,t,i)?a!=null&&e>a&&Ct(r,n[a],i)?a:e:e===a?Et(n,r,i,!0):a}function Ot(e,t,n){return e.filter(e=>!xt(t,e,n))}function kt(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function At(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function jt(e){return At(e?.[0])}function Mt(e){return jt(e)?e.flatMap(e=>e.items):e}function Nt(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(jt(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function Pt(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return kt(e)}function Ft(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?kt(e.value):kt(e)}function It(e,t,n){function r(){return Pt(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=Mt(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function Lt(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,X.jsx)(Y.Fragment,{children:It(r,t,n)},i)),e),[])}var Rt={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:Ft(t,r)!==``},hasNullItemLabel:(e,t)=>t?Nt(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>xt(t,e,n)):xt(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function zt(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function Bt(e,t){return Math.max(0,e-t)}function Vt(e,t){if(t<=0)return 0;let n=zt(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function Ht(e){let{id:t,value:n,defaultValue:r=null,onValueChange:o,open:s,defaultOpen:c=!1,onOpenChange:l,name:d,form:f,autoComplete:p,disabled:g=!1,readOnly:_=!1,required:y=!1,modal:S=!0,actionsRef:C,inputRef:T,onOpenChangeComplete:O,items:k,multiple:A=!1,itemToStringLabel:j,itemToStringValue:M,isItemEqualToValue:N=bt,highlightItemOnHover:P=!0,children:F}=e,{clearErrors:I}=w(),{setDirty:L,setTouched:R,setFocused:z,validityData:ne,setFilled:re,name:B,disabled:ie,validation:V,validationMode:ae}=E(),H=a({id:t}),W=ie||g,G=B??d,[K,ce]=_e({controlled:n,default:A?r??x:r,name:`Select`,state:`value`}),[q,le]=_e({controlled:s,default:c,name:`Select`,state:`open`}),de=Y.useRef([]),fe=Y.useRef([]),pe=Y.useRef(null),he=Y.useRef(null),ge=Y.useRef(0),ye=Y.useRef(null),be=Y.useRef([]),Se=Y.useRef(!1),Ce=Y.useRef(null),we=Y.useRef(null),Te=Y.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),Oe=Y.useRef(!1),Ae=Y.useRef(K),{mounted:je,setMounted:Me,transitionStatus:Ne}=ve(q),{openMethod:Pe,triggerProps:Fe}=Ve(q),J=se(()=>new ue({id:H,labelId:void 0,modal:S,multiple:A,itemToStringLabel:j,itemToStringValue:M,isItemEqualToValue:N,value:K,open:q,mounted:je,transitionStatus:Ne,items:k,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:Ee,triggerProps:Ee,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:b,setOpen:b,handleScrollArrowVisibility:b,onOpenChangeComplete:b,listRef:de,popupRef:pe,scrollHandlerRef:he,scrollArrowsMountedCountRef:ge,valueRef:ye,valuesRef:be,labelsRef:fe,typingRef:Se,selectionRef:Te,firstItemTextRef:Ce,selectedItemTextRef:we,alignItemWithTriggerActiveRef:Oe,initialValueRef:Ae},Rt)).current,Ie=J.useState(`activeIndex`),Le=J.useState(`selectedIndex`),Re=J.useState(`triggerElement`),ze=J.useState(`positionerElement`),Be=nt(Pe),Ue=Pe??Be,We=Y.useMemo(()=>A?``:Ft(K,M),[A,K,M]),Ge=Y.useMemo(()=>A&&Array.isArray(K)?K.map(e=>Ft(e,M)):Ft(K,M),[A,K,M]),Ke=ee(Re),qe=De(()=>Ge);D(Ke,H,K,qe,!W,d);let Xe=A?Array.isArray(K)&&K.length>0:K!=null&&We!==``;h(()=>{re(Xe)},[Xe,re]),h(function(){let e=Et(be.current,K,N,A);e===null&&(we.current=null),!q&&J.set(`selectedIndex`,e)},[A,q,K,N,J]),u(K,()=>{I(G),L(St(K,ne.initialValue,N)),V.change(K)});let Ze=De((e,t)=>{l?.(e,t),!t.isCanceled&&(le(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(R(!0),z(!1),ae===`onBlur`&&V.commit(K)))}),Qe=De(()=>{Me(!1),J.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),O?.(!1)});ke({enabled:!C,open:q,ref:pe,onComplete(){q||Qe()}}),Y.useImperativeHandle(C,()=>({unmount:Qe}),[Qe]);let $e=De((e,t)=>{o?.(e,t),!t.isCanceled&&ce(e)}),et=De(e=>{let t=Bt(e.scrollHeight,e.clientHeight),n=Vt(e.scrollTop,t),r=n>0,i=n<t;J.set(`scrollUpArrowVisible`,r),J.set(`scrollDownArrowVisible`,i)}),Z=tt({open:q,onOpenChange:Ze,elements:{reference:Re,floating:ze}}),rt=Je(Z,{enabled:!W,event:`mousedown`}),it=xe(Z),at=He(Z,{enabled:!W,listRef:de,activeIndex:Ie,selectedIndex:Le,disabledIndices:x,onNavigate(e){(e!==null||q)&&J.set(`activeIndex`,e)},focusItemOnHover:P}),ot=Ye(Z,{enabled:!W&&(q||!_&&!A),listRef:fe,activeIndex:Ie,selectedIndex:Le,disabledIndices:e=>ct(de.current[e]),onMatch(e){q?J.set(`activeIndex`,e):$e(be.current[e],U(me))},onTyping(e){Se.current=e}}),st=Y.useMemo(()=>m(ot.reference,at.reference,it.reference,rt.reference,Fe),[rt.reference,ot.reference,at.reference,it.reference,Fe]),lt=Y.useMemo(()=>m(i,ot.floating,at.floating,it.floating),[ot.floating,at.floating,it.floating]),ut=at.item??Ee;J.useContextCallback(`setValue`,$e),J.useContextCallback(`setOpen`,Ze),J.useContextCallback(`handleScrollArrowVisibility`,et),J.useContextCallback(`onOpenChangeComplete`,O),pt(()=>{J.update({popupProps:lt,triggerProps:st})}),J.useSyncedValues({id:H,modal:S,multiple:A,value:K,open:q,mounted:je,transitionStatus:Ne,popupProps:lt,triggerProps:st,items:k,itemToStringLabel:j,itemToStringValue:M,isItemEqualToValue:N,openMethod:Ue});let dt=Y.useMemo(()=>({disabled:W,readOnly:_,required:y,multiple:A,highlightItemOnHover:P,itemProps:ut}),[W,_,y,A,P,ut]),ft=oe(T,V.inputRef),Q=A?void 0:G,_t=Y.useMemo(()=>!A||!Array.isArray(K)||!G?null:K.map(e=>{let t=Ft(e,M);return(0,X.jsx)(`input`,{type:`hidden`,form:f,name:G,value:t,disabled:W},t)}),[A,K,f,G,M,W]);return(0,X.jsxs)(mt.Provider,{value:J,children:[(0,X.jsx)(ht.Provider,{value:dt,children:(0,X.jsx)(gt.Provider,{value:Z,children:F})}),(0,X.jsx)(`input`,{...V.getValidationProps(W,{onFocus(){J.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||W||_)return;let t=e.currentTarget.value,n=U(me,e.nativeEvent);function r(){if(A)return;let e=t.toLowerCase(),r=be.current.findIndex(t=>Ft(t,M).toLowerCase()===e||Pt(t,j).toLowerCase()===e);r===-1&&(r=be.current.findIndex((t,n)=>{let r=fe.current[n];return r!=null&&r.toLowerCase()===e}));let i=be.current[r];i!=null&&$e(i,n)}J.set(`forceMount`,!0),queueMicrotask(r)}}),id:H&&Q==null?`${H}-hidden-input`:void 0,form:f,name:Q,autoComplete:p,value:We,disabled:W,required:y&&!(A&&Xe),readOnly:_,ref:ft,style:G?te:v,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),_t]})}function Ut(e,t){return e??t}var Wt=`data-popup-side`,Gt=400,Kt={...fe,...j,popupSide:e=>e?{[Wt]:e}:null,value:()=>null},qt=Y.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:o=!1,nativeButton:s=!0,style:c,...l}=e,{setTouched:u,setFocused:d,validationMode:f,validation:p,state:h,disabled:g}=E(),{labelId:_}=he(),v=Q(),{readOnly:y,required:b,disabled:x}=_t(),S=g||x||o,C=v.useState(`open`),w=v.useState(`mounted`),T=v.useState(`value`),D=v.useState(`triggerProps`),k=v.useState(`positionerElement`),A=v.useState(`listElement`),j=v.useState(`popupSide`),M=v.useState(`id`),F=v.useState(`labelId`),L=v.useState(`hasSelectedValue`),z=w&&k?j:null,te=i??M,ne=Ut(_,F);a({id:i});let re=ee(k),B=Y.useRef(null),{getButtonProps:ie,buttonRef:ae}=P({disabled:S,native:s}),oe=v.useStateSetter(`triggerElement`),H=R(),se=R(),W=R();Y.useEffect(()=>{if(C)return W.start(Gt,()=>{v.context.selectionRef.current.allowUnselectedMouseUp=!0,v.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{W.clear()};v.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},se.clear()},[C,v,se,W]);let G=m(D,{id:te,role:`combobox`,"aria-expanded":C,"aria-haspopup":`listbox`,"aria-controls":C?A?.id??q(k)?.id:void 0,"aria-labelledby":ne,"aria-readonly":y||void 0,"aria-required":b||void 0,tabIndex:S?-1:0,onFocus(e){d(!0),C&&v.context.alignItemWithTriggerActiveRef.current&&v.context.setOpen(!1,U(me,e.nativeEvent)),H.start(0,()=>{v.set(`forceMount`,!0)})},onBlur(e){O(k,e.relatedTarget)||(u(!0),d(!1),f===`onBlur`&&p.commit(T))},onMouseDown(e){if(C)return;let t=V(e.currentTarget);function n(e){if(!B.current)return;let t=e.target;O(B.current,t)||O(re.current,t)||Ue(e,B.current)||v.context.setOpen(!1,U(N,e))}se.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},l,ie),K=p.getValidationProps(S,G);K.role=`combobox`;let ce={...h,open:C,disabled:S,value:T,readOnly:y,popupSide:z,placeholder:!L};return I(`button`,e,{ref:[t,B,ae,oe],state:ce,stateAttributesMapping:Kt,props:K})}),Jt={value:()=>null},Yt=Y.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=Q(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?Lt(l,u,d):It(l,u,d)),I(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:Jt})}),Xt=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o={open:Q().useState(`open`)};return I(`span`,e,{state:o,ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:W})}),Zt=Y.forwardRef(function(e,t){let n=Q(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,X.jsx)(F,{ref:t,...e}):null}),Qt=Y.createContext(void 0);function $t(){let e=Y.useContext(Qt);if(!e)throw Error(B(59));return e}function en(e,t){e&&Object.assign(e.style,t)}var tn={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},nn={position:`fixed`},rn=Y.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:s,align:c,sideOffset:u,alignOffset:d,collisionBoundary:f=`clipping-ancestors`,collisionPadding:p,arrowPadding:m,sticky:g,disableAnchorTracking:v,alignItemWithTrigger:y=!0,collisionAvoidance:b=l,style:ee,...x}=e,S=Q(),C=vt(),w=S.useState(`open`),T=S.useState(`mounted`),E=S.useState(`modal`),D=S.useState(`value`),O=S.useState(`openMethod`),k=S.useState(`positionerElement`),A=S.useState(`triggerElement`),j=S.useState(`isItemEqualToValue`),M=S.useState(`transitionStatus`),N=Y.useRef(null),P=Y.useRef(null),[F,I]=Y.useState(y),L=T&&F&&O!==`touch`;!T&&F!==y&&I(y),Y.useImperativeHandle(S.context.alignItemWithTriggerActiveRef,()=>L),qe((L||E)&&w,O===`touch`,k,A);let R=_({anchor:n,floatingRootContext:C,positionMethod:a,mounted:T,side:s,sideOffset:u,align:c,alignOffset:d,arrowPadding:m,collisionBoundary:f,collisionPadding:p,sticky:g,disableAnchorTracking:v??L,collisionAvoidance:b,keepMounted:!0}),z=L?`none`:R.side,te=L?nn:R.positionerStyles,ne={open:w,side:z,align:R.align,anchorHidden:R.anchorHidden};h(()=>{S.set(`popupSide`,R.side)},[S,R.side]);let re=S.useStateSetter(`positionerElement`),B=o(e,ne,{styles:te,transitionStatus:M,props:x,refs:[t,re],hidden:!T,inert:!w}),ie=Y.useRef(0),V=De(e=>{if(S.context.valuesRef.current.length===0)return;let t=ie.current;ie.current=e.size;let n=U(me);if(t!==0&&!S.state.multiple&&D!==null&&wt(S.context.valuesRef.current,D,j)===-1){let e=S.context.initialValueRef.current,t=e!=null&&wt(S.context.valuesRef.current,e,j)!==-1?e:null;S.context.setValue(t,n),t===null&&(S.set(`selectedIndex`,null),S.context.selectedItemTextRef.current=null)}if(t!==0&&S.state.multiple&&Array.isArray(D)){let e=D.filter(e=>wt(S.context.valuesRef.current,e,j)!==-1);e.length!==D.length&&(S.context.setValue(e,n),e.length===0&&(S.set(`selectedIndex`,null),S.context.selectedItemTextRef.current=null))}if(w&&L){S.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};en(k,e),en(S.context.popupRef.current,e)}}),ae=Y.useMemo(()=>({...R,side:z,alignItemWithTriggerActive:L,setControlledAlignItemWithTrigger:I,scrollUpArrowRef:N,scrollDownArrowRef:P}),[R,z,L,I]);return(0,X.jsx)(Ke,{elementsRef:S.context.listRef,labelsRef:S.context.labelsRef,onMapChange:V,children:(0,X.jsxs)(Qt.Provider,{value:ae,children:[T&&E&&(0,X.jsx)(de,{inert:J(!w),cutout:A}),B]})})}),an=`base-ui-disable-scrollbar`,on={className:an,getElement(e){return(0,X.jsx)(`style`,{nonce:e,href:an,precedence:`base-ui:low`,children:`.${an}{scrollbar-width:none}.${an}::-webkit-scrollbar{display:none}`})}},sn=Y.createContext(void 0),cn={disableStyleElements:!1};function ln(){return Y.useContext(sn)??cn}var un=`--transform-origin`,dn={...ye,...G},fn=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,c=Q(),{multiple:l,readOnly:u,highlightItemOnHover:d}=_t(),f=vt(),{side:p,align:m,alignItemWithTriggerActive:g,isPositioned:_,setControlledAlignItemWithTrigger:v}=$t(),y=Ge(!0)!=null,b=L(),{nonce:ee,disableStyleElements:x}=ln(),S=c.useState(`id`),w=c.useState(`open`),T=c.useState(`openMethod`),E=c.useState(`mounted`),D=c.useState(`popupProps`),O=c.useState(`transitionStatus`),k=c.useState(`triggerElement`),A=c.useState(`positionerElement`),j=c.useState(`listElement`),M=Y.useRef(!1),N=Y.useRef(!1),P=Y.useRef({}),F=C(),R=De(e=>{if(!A||!c.context.popupRef.current||!N.current)return;let t=A.style.top===`0px`,n=A.style.bottom===`0px`;if(M.current||!g||!t&&!n){c.context.handleScrollArrowVisibility(e);return}let r=hn(A),i=gn(A.getBoundingClientRect().height,`y`,r),a=V(A),o=ge(A),s=o.getComputedStyle(A),l=parseFloat(s.marginTop),u=parseFloat(s.marginBottom),d=pn(o.getComputedStyle(c.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,m=mn(e),h=null,_=e=>{A.style.height=`${e}px`},v=t?m-p:p,y=Math.min(i+v,f);if(v<=1){let n=zt(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?m:0,f-(i+n)<=1&&(M.current=!0),c.context.handleScrollArrowVisibility(e);return}f-y>1?h=t?1/0:0:n&&p<m&&(h=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),h!=null){let t=zt(h,0,mn(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(M.current=!0),c.context.handleScrollArrowVisibility(e)});Y.useImperativeHandle(c.context.scrollHandlerRef,()=>R,[R]),ke({open:w,ref:c.context.popupRef,onComplete(){w&&c.context.onOpenChangeComplete(!0)}});let z={open:w,transitionStatus:O,side:p,align:m};h(()=>{A&&c.context.popupRef.current&&!Object.keys(P.current).length&&(P.current={top:A.style.top||`0`,left:A.style.left||`0`,right:A.style.right,height:A.style.height,bottom:A.style.bottom,minHeight:A.style.minHeight,maxHeight:A.style.maxHeight,marginTop:A.style.marginTop,marginBottom:A.style.marginBottom})},[c,A]),h(()=>{w||g||(N.current=!1,M.current=!1,en(A,P.current))},[w,g,A]),h(()=>{let e=c.context.popupRef.current;if(!w||!k||!A||!e||g&&!_||c.state.transitionStatus===`ending`)return;if(N.current=!0,e.style.removeProperty(un),!g){F.request(()=>c.context.handleScrollArrowVisibility(j||e));return}let t=yn(e);try{let t=c.context.selectedItemTextRef.current;t?.isConnected||(t=!c.select(`hasSelectedValue`)&&c.context.firstItemTextRef.current?.isConnected?c.context.firstItemTextRef.current:null);let n=c.context.valueRef.current,r=ge(A),i=r.getComputedStyle(A),a=r.getComputedStyle(e),o=V(k),l=hn(k),u=_n(k.getBoundingClientRect(),l),f=_n(A.getBoundingClientRect(),l),p=u.height,m=j||e,h=m.scrollHeight,g=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,y=parseFloat(i.marginBottom)||10,ee=parseFloat(i.minHeight)||100,x=pn(a),S=o.documentElement.clientHeight-_-y,C=o.documentElement.clientWidth,w=S-u.bottom+p,T,E=b===`rtl`?u.right-f.width:u.left,D=0;if(t&&n){let e=_n(n.getBoundingClientRect(),l);T=_n(t.getBoundingClientRect(),l),E=f.left+(b===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-u.top+e.height/2;D=T.top-f.top+T.height/2-r}let O=w+D+y+g,N=Math.min(S,O),F=S-_-y,I=O-N,L=C-5;A.style.left=`${zt(E,5,L-f.width)}px`,A.style.height=`${N}px`,A.style.maxHeight=`none`,A.style.marginTop=`${_}px`,A.style.marginBottom=`${y}px`,e.style.height=`100%`;let R=mn(m),z=I>=R-1;z&&(N=Math.min(S,f.height)-(I-R));let te=u.top<20||u.bottom>S-20||Math.ceil(N)+1<Math.min(h,ee),ne=(r.visualViewport?.scale??1)!==1&&s;if(te||ne){en(A,P.current),v(!1);return}let re=Math.max(ee,N);if(z){let e=Math.max(0,S-O);A.style.top=f.height>=F?`0`:`${e}px`,A.style.height=`${N}px`,m.scrollTop=mn(m)}else A.style.bottom=`0`,m.scrollTop=I;if(T){let t=f.top,n=f.height,r=T.top+T.height/2,i=zt(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(un,`50% ${i}%`)}(re===S||N>=x)&&(M.current=!0),c.context.handleScrollArrowVisibility(m),d&&c.state.selectedIndex===null&&c.state.activeIndex===null&&c.context.listRef.current[0]!=null&&c.set(`activeIndex`,0)}finally{t()}},[c,w,A,k,g,v,F,j,d,b,_]),Y.useEffect(()=>{if(!g||!A||!w)return;let e=ge(A);function t(e){c.context.setOpen(!1,U(Ae,e))}return ae(e,`resize`,t)},[c,g,A,w]);let te={...j?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":l||void 0,"aria-readonly":u||void 0,id:`${S}-list`},onKeyDown(e){y&&je.has(e.key)&&e.stopPropagation()},onScroll(e){j||R(e.currentTarget)},...g&&{style:j?{height:`100%`}:tn},className:!j&&g?on.className:void 0},re=I(`div`,e,{ref:[t,c.context.popupRef],state:z,stateAttributesMapping:dn,props:[D,te,ne(O),o]});return(0,X.jsxs)(Y.Fragment,{children:[!x&&on.getElement(ee),(0,X.jsx)(pe,{context:f,modal:!1,disabled:!E,openInteractionType:T,returnFocus:a,restoreFocus:!0,children:re})]})});function pn(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function mn(e){return Bt(e.scrollHeight,e.clientHeight)}function hn(e){return Te.getScale(e)}function gn(e,t,n){return e/n[t]}function _n(e,t){return c({x:gn(e.x,`x`,t),y:gn(e.y,`y`,t),width:gn(e.width,`x`,t),height:gn(e.height,`y`,t)})}var vn=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function yn(e){let{style:t}=e,n={};for(let[e,r]of vn)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of vn){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var bn=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Q(),{multiple:s,readOnly:c}=_t(),{alignItemWithTriggerActive:l}=$t(),u=o.useState(`hasScrollArrows`),d=o.useState(`openMethod`),f={id:`${o.useState(`id`)}-list`,role:`listbox`,"aria-multiselectable":s||void 0,"aria-readonly":c||void 0,onScroll(e){o.context.scrollHandlerRef.current?.(e.currentTarget)},...l&&{style:tn},className:u&&d!==`touch`?on.className:void 0},p=o.useStateSetter(`listElement`);return I(`div`,e,{ref:[t,p],props:[f,a]})}),xn=Y.createContext(void 0);function Sn(){let e=Y.useContext(xn);if(!e)throw Error(B(57));return e}var Cn=Y.memo(Y.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=Y.useRef(null),d=We({guess:!0,label:o,textRef:u}),f=Q(),{itemProps:p,multiple:m,disabled:g,readOnly:_}=_t(),v=g||s,b=f.useState(`isActive`,d.index),ee=f.useState(`open`),x=f.useState(`isSelected`,a),S=f.useState(`isSelectedByFocus`,d.index),C=f.useState(`isItemEqualToValue`),w=d.index,T=Y.useRef(null);h(()=>{let e=f.context.valuesRef.current;return e[w]=a,()=>{delete e[w]}},[w,a,f]),h(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=Dt(w,a,f.context.valuesRef.current,e,C,t),r=n===w,w===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&xt(a,e,C),r&&(n=w)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[w,m,C,f,a]);let E=Y.useRef(`mouse`),D=Y.useRef(!1),{getButtonProps:O,buttonRef:k}=P({disabled:v,focusableWhenDisabled:!0,native:c,composite:!0}),A={disabled:v,selected:x,highlighted:b};function j(e){if(g||_)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=x?Ot(n,a,C):[...n,a];f.context.setValue(r,U(Se,e))}else f.context.setValue(a,U(Se,e)),f.context.setOpen(!1,U(Se,e))}function M(){f.context.selectionRef.current.dragY=0}let N={role:`option`,"aria-selected":x,tabIndex:ee&&b?0:-1,onKeyDown(e){f.set(`activeIndex`,w),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=E.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&y(e.nativeEvent)&&(n!==void 0||b),i=t&&!r&&!D.current;D.current=!1,!(v||i)&&j(e.nativeEvent)},onPointerEnter(e){E.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){E.current=e.pointerType,D.current=!0,M()},onMouseUp(){if(M(),v||E.current===`touch`||D.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&x,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!x;e||t||(D.current=!0,T.current?.click(),D.current=!1)}},F=I(`div`,e,{ref:[k,t,d.ref,T],state:A,props:[p,N,l,O]}),L=Y.useMemo(()=>({selected:x,index:w,textRef:u,selectedByFocus:S}),[x,w,u,S]);return(0,X.jsx)(xn.Provider,{value:L,children:F})})),wn=Y.forwardRef(function(e,t){let{selected:n}=Sn();return e.keepMounted||n?(0,X.jsx)(Tn,{...e,ref:t}):null}),Tn=Y.memo(Y.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=Sn(),c=Y.useRef(null),{transitionStatus:l,setMounted:u}=ve(s),d=I(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:G});return ke({batch:!0,enabled:!s,open:s,ref:c,onComplete(){s||u(!1)}}),d})),En=Y.memo(Y.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=Sn(),a=Q(),{render:o,className:s,style:c,...l}=e,u=Y.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]);return I(`div`,e,{ref:[u,t,r],props:l})})),Dn=Y.createContext(void 0),On=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Y.useState(),c=Y.useMemo(()=>({labelId:o,setLabelId:s}),[o,s]),l=I(`div`,e,{ref:t,props:[{role:`group`,"aria-labelledby":o},a]});return(0,X.jsx)(Dn.Provider,{value:c,children:l})}),kn=Ht;function An({className:e,...t}){return(0,X.jsx)(On,{"data-slot":`select-group`,className:p(`scroll-my-1 p-1`,e),...t})}function jn({className:e,...t}){return(0,X.jsx)(Yt,{"data-slot":`select-value`,className:p(`flex flex-1 text-left`,e),...t})}function Mn({className:e,size:t=`default`,flat:n=!1,children:r,...i}){return(0,X.jsxs)(qt,{"data-slot":`select-trigger`,"data-size":t,"data-flat":n?`true`:void 0,className:p(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,n&&`rounded-none border-0 bg-transparent shadow-none hover:bg-transparent focus-visible:border-0 focus-visible:ring-0 dark:bg-transparent dark:hover:bg-transparent`,e),...i,children:[r,(0,X.jsx)(Xt,{render:(0,X.jsx)(d,{icon:et,className:`pointer-events-none size-4 text-muted-foreground`,strokeWidth:1.5})})]})}function Nn({className:e,children:t,side:n=`bottom`,sideOffset:r=4,align:i=`center`,alignOffset:a=0,alignItemWithTrigger:o=!0,...s}){return(0,X.jsx)(Zt,{children:(0,X.jsx)(rn,{side:n,sideOffset:r,align:i,alignOffset:a,alignItemWithTrigger:o,className:`isolate z-50`,children:(0,X.jsx)(fn,{"data-slot":`select-content`,"data-align-trigger":o,className:p(`cn-menu-target cn-menu-translucent relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...s,children:(0,X.jsx)(bn,{children:t})})})})}function Pn({className:e,children:t,...n}){return(0,X.jsxs)(Cn,{"data-slot":`select-item`,className:p(`relative flex w-full cursor-default items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[(0,X.jsx)(En,{className:`flex min-w-0 flex-1 items-center gap-2`,children:t}),(0,X.jsx)(wn,{render:(0,X.jsx)(`span`,{className:`pointer-events-none absolute top-1/2 right-2 flex size-4 -translate-y-1/2 items-center justify-center`}),children:(0,X.jsx)(d,{icon:k,className:`pointer-events-none size-3.5`,strokeWidth:1.5})})]})}var Fn=new Set([`ALL`,`SELECT`,`INSERT`,`UPDATE`,`DELETE`]),In=new Set([`PERMISSIVE`,`RESTRICTIVE`]),Ln=new Set([`public`,`current_role`,`current_user`,`session_user`]),Rn=`oke_app`;`${[`CREATE SCHEMA IF NOT EXISTS oke`,`SET search_path TO public, oke`,`DO $oke_search_path$
2
2
  BEGIN
3
3
  EXECUTE 'ALTER ROLE CURRENT_USER SET search_path TO public, oke';
4
4
  EXCEPTION
@@ -52,4 +52,4 @@ $oke_app_search_path$`].join(`;
52
52
  `;t.push(`CREATE TABLE ${Fr(r.name)} (${i});`)}return t.join(`
53
53
 
54
54
  `)}function xr(e,t,n,r,i){let a=i?.stores?.[e.name]?.tables?.[t];if(a?.columns)return Sr(a.columns,r);let o=Ie(r);return[...new Set([...Object.keys(n),...r])].map(e=>({name:e,type:`unknown`,...o.has(e)?{pii:!0}:{}}))}function Sr(e,t){let n=Ie(t);return Object.entries(e).map(([e,t])=>{let r=Cr(t)?t:null,i=r?.type===`integer`?`integer`:r?.type===`text`?`text`:`unknown`,a=t.pii===!0||n.has(e),o=r?.references;return{name:e,type:i,...a?{pii:!0}:{},...r?.primaryKey===!0?{primaryKey:!0}:{},...r?.unique===!0?{unique:!0}:{},...r?.nullable===!1||r?.primaryKey===!0?{nullable:!1}:{nullable:!0},...o?.table?{references:{table:o.table,...o.column?{column:o.column}:{}}}:{}}})}function Cr(e){return`type`in e||`nullable`in e||`primaryKey`in e||`unique`in e||`sqlName`in e||`description`in e||`references`in e||`default`in e}function wr(e){return e.map(t=>({...t,columns:t.columns.map(n=>{if(n.references?.table)return n;let r=Tr(t,n.name,e);return r?{...n,references:r,inferredRef:!0}:n})}))}function Tr(e,t,n){let r=n.filter(t=>t.storeRef===e.storeRef),i=e=>e.columns.find(e=>e.primaryKey)?.name??`id`;if(t===`parent_id`||t===`parentId`)return e.columns.some(e=>e.name===`parent_kind`||e.name===`parentKind`)?null:{table:e.name,column:i(e)};let a=Er(t);if(!a)return null;let o=Dr(a,e,r);return o?{table:o.name,column:i(o)}:null}function Er(e){return e===`id`||e===`Id`?null:e.endsWith(`_id`)&&e.length>3?e.slice(0,-3):e.endsWith(`Id`)&&e.length>2?e.slice(0,-2):null}function Dr(e,t,n){let r=kr(e),i=[e,r,Or(e),Or(r)];for(let e of i){let r=n.find(t=>t.name===e);if(r)return r.id===t.id?null:r}let a=[`_${Or(r)}`,`_${r}`,`_${Or(e)}`,`_${e}`],o=n.filter(e=>e.id!==t.id&&a.some(t=>e.name.endsWith(t)));return o.length===1?o[0]??null:null}function Or(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 kr(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1_$2`).toLowerCase()}function Ar(e){let t=new Map;for(let n of e){let e=[n.name.toLowerCase(),n.id.toLowerCase()];for(let r of e){let e=t.get(r)??[];e.push(n),t.set(r,e)}}return t}function jr(e,t,n){let r=n.get(t.toLowerCase())??[];return r.length===0?null:r.find(t=>t.storeRef===e.storeRef)??r[0]??null}function Mr(e,t){let n=[],i=new Set;for(let a of e)for(let e of a.columns){let o=e.references;if(!o?.table)continue;let s=jr(a,o.table,t);if(!s)continue;let c=o.column??s.columns.find(e=>e.primaryKey)?.name,l=`${a.id}.${e.name}->${s.id}.${c??`*`}`;if(i.has(l))continue;i.add(l);let u=e.inferredRef===!0,d=pr(e,a,s);n.push({id:l,source:a.id,target:s.id,sourceHandle:`out:${e.name}`,...c?{targetHandle:`in:${c}`}:{},type:`relation`,animated:!1,markerEnd:{type:r.ArrowClosed,width:16,height:16,color:`#38BDF8`},style:{stroke:`#38BDF8`,strokeWidth:1.5,...u?{strokeDasharray:`5 4`}:{}},data:{kind:`references`,inferred:u,relation:d,column:e.name}})}return n}function Nr(e,t,n){let r=new Be.graphlib.Graph;r.setGraph({rankdir:`LR`,align:`UL`,nodesep:72,ranksep:160,edgesep:28,marginx:40,marginy:40}),r.setDefaultEdgeLabel(()=>({}));for(let t of e)r.setNode(t.id,{width:cr,height:fr(t.columns.length)});let i=new Set;for(let e of t){let t=`${e.source}->${e.target}`;i.has(t)||r.hasNode(e.source)&&r.hasNode(e.target)&&(i.add(t),r.setEdge(e.source,e.target))}return Be.layout(r),e.map(e=>{let t=r.node(e.id),i=fr(e.columns.length);return{id:e.id,type:`table`,position:{x:(t?.x??0)-cr/2,y:(t?.y??0)-i/2},data:{table:e,showStore:n},width:cr,height:i,style:{width:cr,height:i}}})}function Pr(e){return e.columns.filter(t=>t.references?.table&&t.references.table!==e.name).length<2?!1:e.columns.every(e=>e.primaryKey===!0||e.references!==void 0)}function Fr(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)?e:`"${e.replaceAll(`"`,`""`)}"`}var $=`oke.gate()`,Ir=`oke.user()`,Lr=[{id:`read-all`,name:`read_all`,title:`Enable read access for everyone`,detail:`SELECT using true. Any role that reaches the table can read.`,command:`SELECT`,using:`true`},{id:`deny-read`,name:`deny_read`,title:`Deny all reads`,detail:`SELECT using false. Rows stay hidden until another policy allows them.`,command:`SELECT`,using:`false`},{id:`owner-read`,name:`owner_read`,title:`Enable read for owners`,detail:`SELECT when a text owner column matches oke.user().`,command:`SELECT`,using:`owner = ${Ir}`},{id:`gate-read`,name:`gate_read`,title:`Enable read when oke.gate() matches`,detail:`SELECT when ${$} equals a Gate name (pair Policy & scope).`,command:`SELECT`,using:`${$} = 'member'`},{id:`join-read`,name:`join_read`,title:`Enable read via a related table`,detail:`SELECT with EXISTS against members — membership joins, not a column on this table.`,command:`SELECT`,using:`exists (select 1 from members m where m.user_id = oke.user() and m.team_id = team_id)`},{id:`insert-all`,name:`insert_all`,title:`Enable insert for everyone`,detail:`INSERT WITH CHECK true. New rows are accepted without a row predicate.`,command:`INSERT`,withCheck:`true`},{id:`insert-owner`,name:`insert_owner`,title:`Enable insert for owners`,detail:`INSERT WITH CHECK so new rows set owner to oke.user().`,command:`INSERT`,withCheck:`owner = ${Ir}`},{id:`insert-gate`,name:`insert_gate`,title:`Enable insert when oke.gate() matches`,detail:`INSERT WITH CHECK when ${$} equals a Gate name.`,command:`INSERT`,withCheck:`${$} = 'member'`},{id:`update-owner`,name:`update_owner`,title:`Enable update for owners`,detail:`UPDATE own rows. USING and WITH CHECK both require owner = oke.user().`,command:`UPDATE`,using:`owner = ${Ir}`,withCheck:`owner = ${Ir}`},{id:`update-gate`,name:`update_gate`,title:`Enable update when oke.gate() matches`,detail:`UPDATE when ${$} equals a Gate name.`,command:`UPDATE`,using:`${$} = 'member'`,withCheck:`${$} = 'member'`},{id:`delete-owner`,name:`delete_owner`,title:`Enable delete for owners`,detail:`DELETE when a text owner column matches oke.user().`,command:`DELETE`,using:`owner = ${Ir}`},{id:`deny-delete`,name:`deny_delete`,title:`Deny all deletes`,detail:`DELETE using false. Rows cannot be removed until another policy allows it.`,command:`DELETE`,using:`false`},{id:`all-owner`,name:`owner_all`,title:`Enable all commands for owners`,detail:`ALL commands when owner = oke.user() (USING and WITH CHECK).`,command:`ALL`,using:`owner = ${Ir}`,withCheck:`owner = ${Ir}`},{id:`all-gate`,name:`gate_all`,title:`Enable all commands when oke.gate() matches`,detail:`ALL commands when ${$} equals a Gate name.`,command:`ALL`,using:`${$} = 'member'`,withCheck:`${$} = 'member'`},{id:`restrictive-gate`,name:`restrictive_gate`,title:`Restrictive extra Gate check`,detail:`RESTRICTIVE policy ANDs with permissive ones. Requires oke.gate() to be set.`,command:`ALL`,behavior:`RESTRICTIVE`,using:`${$} is not null`,withCheck:`${$} is not null`}];function Rr(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>[e.id,e.name,e.title,e.detail,e.command,e.behavior??``].some(e=>e.toLowerCase().includes(n)))}var zr=[`SELECT`,`INSERT`,`UPDATE`,`DELETE`,`ALL`];function Br(e){return e===`INSERT`?{using:!1,withCheck:!0}:e===`UPDATE`||e===`ALL`?{using:!0,withCheck:!0}:{using:!0,withCheck:!1}}function Vr(e){return e===`SELECT`?`read`:e===`ALL`?`both`:`write`}function Hr(e,t){return e===`read`?`SELECT`:e===`both`?`ALL`:t===`INSERT`||t===`UPDATE`||t===`DELETE`?t:`INSERT`}function Ur(e){return e===`read`?[`store.sql:read`]:e===`write`?[`store.sql:write`]:[`store.sql:read`,`store.sql:write`]}function Wr(e){return`${Qn(e)}\n\n${Zn(e)}`}function Gr(e){return e.length===0?`true`:e.map(e=>{let t=`'${e.replaceAll(`'`,`''`)}'`;return e.includes(`:`)?`oke.has_scope(${t})`:`oke.gate() = ${t}`}).join(` OR `)}function Kr(e,t){let n=ai(e);return t?`${Jn(e.table,!0)};\n${n};`:`${n};`}var qr=[`owner`,`owner_id`,`owner_email`,`user_id`,`created_by`,`creator`,`creator_id`,`creator_email`,`author`,`author_id`,`author_email`];function Jr(e,t,n){let r=t.indexOf(`:`),i=r>=0?t.slice(r+1):t,a=e?.stores?.[i]?.tables?.[n]?.columns??{};return Object.entries(a).map(([e,t])=>{let n=ii(e,t),r=Xr(t)?t:null,i=r?.primaryKey===!0,a=r?.references?.table!==void 0,o=!a&&!i&&Er(n)!==null;return{sqlName:n,primaryKey:i,foreignKey:a||o,unique:r?.unique===!0&&!i,inferred:o}})}function Yr(e,t,n){return Jr(e,t,n).map(e=>e.sqlName)}function Xr(e){return`type`in e||`nullable`in e||`primaryKey`in e||`unique`in e||`sqlName`in e||`description`in e||`references`in e||`default`in e}function Zr(e){let t=new Map(e.map(e=>[e.toLowerCase(),e]));for(let e of qr){let n=t.get(e);if(n)return n}return null}function Qr(e,t){return e.replace(/\bowner\b/g,t)}function $r(e){return/\bowner\b/.test(e)}function ei(e){return $r(e.using??``)||$r(e.withCheck??``)}function ti(e){return $r(e)||/oke\.user\(\)/.test(e)}function ni(e,t,n){if(!n||t===n)return e;let r=e;return $r(r)&&(r=Qr(r,n)),t!==``&&t!==`owner`&&(r=r.replace(RegExp(`\\b${ri(t)}\\b`,`g`),n)),r}function ri(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ii(e,t){return t&&typeof t==`object`&&`sqlName`in t&&typeof t.sqlName==`string`?t.sqlName:e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1_$2`).toLowerCase()}function ai(e){let t=e.roles.length===0?`public`:e.roles.map(e=>qn(e)).join(`, `),n=[`CREATE POLICY ${zn(e.name)}`,` ON ${zn(e.table)}`,` AS ${e.behavior}`,` FOR ${e.command}`,` TO ${t}`];return e.using!==void 0&&e.using.trim()!==``&&n.push(` USING (${e.using.trim()})`),e.withCheck!==void 0&&e.withCheck.trim()!==``&&n.push(` WITH CHECK (${e.withCheck.trim()})`),n.join(`
55
- `)}var oi={oke:`1.0`,app:``},si=`public`;function ci(e){let t=e??oi,n=[{name:si,kind:`public`,variant:`public`,description:`Intentionally unauthenticated`,scopes:[],roles:[]}];for(let[e,r]of Object.entries(t.gates??{})){if(r.kind===`rate`||r.kind===`all`||e.startsWith(`rate:`))continue;let t=r.scopes??[],i=r.roles??[];if(e===`public`){let e=n[0];e&&(n[0]={...e,description:r.description??e.description,scopes:t,roles:i});continue}n.push({name:e,kind:`policy`,variant:mi({name:e,kind:`policy`,scopes:t}),...r.description===void 0?{}:{description:r.description},scopes:t,roles:i})}let r=_i(n.flatMap(e=>[...e.roles]));return{gates:n,actions:ir(t),roles:r}}function li(e,t){if(t===null)return e;let n=_i([...e.roles,...(t.principals??[]).filter(e=>e.kind===`role`).map(e=>e.name)]);return{...e,actions:_i([...t.moduleActions??[],...e.actions]),roles:n}}function ui(e,t){let n=t.trim().toLowerCase();return n===``?e:{gates:e.gates.filter(e=>pi(n,e.name,e.kind,e.variant,e.description,...e.scopes,...e.roles)),actions:e.actions.filter(e=>pi(n,e)),roles:e.roles.filter(e=>pi(n,e))}}function di(e,t){let n=e.filter(e=>e!==`store.sql:read`&&e!==`store.sql:write`);return _i([...Ur(Vr(t)),...n])}function fi(e){return e.gates.length}function pi(e,...t){return t.some(t=>t!==void 0&&t.toLowerCase().includes(e))}function mi(e){return e.kind===`public`||e.name===`public`?`public`:e.scopes.length>0?`scope`:`policy`}function hi(e){return e.gates.filter(e=>e.variant!==`scope`)}function gi(e){return e.gates.filter(e=>e.variant===`scope`)}function _i(e){return[...new Set(e)].sort((e,t)=>e.localeCompare(t))}var vi=[`console.flows.identities`];function yi(){return H({queryKey:vi,queryFn:async()=>{let e=await ie();if(e.error)throw Error(e.error.code);return e.data?.identities??[]}})}function bi(){return Xe({mutationFn:async e=>{let t=await g(e);if(t.error){let e=Error(t.error.code);throw e.code=t.error.code,e.data=t.error.data,e}if(!t.data)throw Error(`Empty invoke response`);return t.data}})}function xi(){return Xe({mutationFn:async e=>{let t=await z(e);if(t.error){let e=Error(t.error.code);throw e.code=t.error.code,e.data=t.error.data,e}if(!t.data)throw Error(`Empty clock run-now response`);return t.data}})}function Si(e){return e===null||e.length===0?`operator`:e===`public`?`public`:`as`}function Ci(e){return e.gates.filter(e=>e.kind===`policy`).map(e=>({id:e.name,label:e.name,detail:Oi(e)}))}function wi(e,t){let n=[];for(let r of e){if(r.status!==`active`)continue;let e=Ti(r.scopes,t);e!==null&&n.push({id:r.id,label:r.name||r.email,detail:r.email,gate:e})}return n}function Ti(e,t){let n=t.gates.filter(e=>e.kind===`policy`);for(let t of e)if(n.some(e=>e.name===t))return t;for(let t of e){let e=n.find(e=>e.roles.includes(t));if(e)return e.name}return null}function Ei(e,t,n=()=>[]){let r=t.trim().toLowerCase();return r===``?e:e.filter(e=>[e.id,e.label,e.detail,...n(e)].some(e=>e.toLowerCase().includes(r)))}function Di(e,t,n){return t&&n?`User · ${n}`:t?`User · ${t}`:e&&e.length>0?`Gate · ${e}`:`Gate`}function Oi(e){return e.description?e.description:e.roles.length>0?`Roles ${e.roles.join(`, `)}`:e.scopes.length>0?e.scopes.join(` · `):`Policy gate`}function ki({mode:e,active:t,className:n}){let r=`${(0,Y.useId)().replace(/:/g,``)}-hatch`;return(0,X.jsxs)(`svg`,{viewBox:`0 0 72 40`,className:p(`h-10 w-full`,t?`text-foreground`:`text-muted-foreground/70`,n),"aria-hidden":!0,"data-slot":`store-query-gate-viz`,"data-mode":e,children:[(0,X.jsx)(`defs`,{children:(0,X.jsx)(`pattern`,{id:r,width:`4`,height:`4`,patternUnits:`userSpaceOnUse`,patternTransform:`rotate(45)`,children:(0,X.jsx)(`path`,{d:`M0 0 H4`,className:`stroke-current`,strokeWidth:`0.7`,opacity:`0.35`})})}),e===`operator`?(0,X.jsx)(ji,{hatchId:r}):null,e===`public`?(0,X.jsx)(Mi,{hatchId:r}):null,e===`as`?(0,X.jsx)(Ni,{hatchId:r}):null]})}function Ai({hatchId:e}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`rect`,{x:`22`,y:`10`,width:`28`,height:`20`,rx:`5`,fill:`url(#${e})`,className:`stroke-current`,strokeWidth:`1.15`}),(0,X.jsx)(`path`,{d:`M22 17 H50`,className:`stroke-current`,strokeWidth:`0.8`,opacity:`0.45`})]})}function ji({hatchId:e}){return(0,X.jsxs)(`g`,{children:[(0,X.jsx)(`path`,{d:`M4 14 C18 14, 18 26, 68 26`,fill:`none`,className:`stroke-sky-500 dark:stroke-sky-400`,strokeWidth:`1.35`,strokeDasharray:`2.4 2`}),(0,X.jsx)(`path`,{d:`M4 26 C18 26, 18 14, 68 14`,fill:`none`,className:`stroke-sky-500 dark:stroke-sky-400`,strokeWidth:`1.35`,strokeDasharray:`2.4 2`}),(0,X.jsx)(Ai,{hatchId:e})]})}function Mi({hatchId:e}){return(0,X.jsxs)(`g`,{children:[(0,X.jsx)(`path`,{d:`M4 14 H18`,fill:`none`,className:`stroke-current`,strokeWidth:`1.2`,strokeDasharray:`2.4 2`,opacity:`0.55`}),(0,X.jsx)(`path`,{d:`M4 26 H18`,fill:`none`,className:`stroke-current`,strokeWidth:`1.2`,strokeDasharray:`2.4 2`,opacity:`0.55`}),(0,X.jsx)(Ai,{hatchId:e}),(0,X.jsx)(`path`,{d:`M54 14 H68`,fill:`none`,className:`stroke-current`,strokeWidth:`1.2`,strokeDasharray:`2.4 2`,opacity:`0.28`}),(0,X.jsx)(`path`,{d:`M54 26 H68`,fill:`none`,className:`stroke-current`,strokeWidth:`1.2`,strokeDasharray:`2.4 2`,opacity:`0.28`})]})}function Ni({hatchId:e}){return(0,X.jsxs)(`g`,{children:[(0,X.jsx)(`circle`,{cx:`10`,cy:`16`,r:`3.1`,className:`fill-violet-500 dark:fill-violet-400`}),(0,X.jsx)(`path`,{d:`M5.5 26 C5.5 22.2, 14.5 22.2, 14.5 26`,fill:`none`,className:`stroke-violet-500 dark:stroke-violet-400`,strokeWidth:`1.2`}),(0,X.jsx)(`path`,{d:`M16 20 H22`,fill:`none`,className:`stroke-violet-500 dark:stroke-violet-400`,strokeWidth:`1.25`}),(0,X.jsx)(Ai,{hatchId:e}),(0,X.jsx)(`path`,{d:`M50 20 H56`,fill:`none`,className:`stroke-violet-500 dark:stroke-violet-400`,strokeWidth:`1.25`}),(0,X.jsx)(`path`,{d:`M59 13.5 L64.5 17 L59 26.5 L53.5 17 Z`,className:`fill-background stroke-violet-500 dark:stroke-violet-400`,strokeWidth:`1.15`})]})}function Pi({children:e}){return(0,X.jsx)(`p`,{className:p(Me,`border-b border-border/60 px-2 py-1.5`),children:e})}function Fi({label:e,children:t}){return(0,X.jsx)(`div`,{role:`radiogroup`,"aria-label":e,className:`flex items-stretch border-b border-border/60`,children:t})}function Ii({mode:e,title:t,caption:n,selected:r,disabled:i=!1,onSelect:a}){return(0,X.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,disabled:i,title:n,onClick:a,"data-slot":`store-query-gate-card`,"data-mode":e,className:p(`flex min-w-0 flex-1 flex-col items-stretch gap-1 px-1.5 pt-2 pb-1.5 text-left transition-colors hover:bg-muted/50 hover:text-foreground`,r?`bg-muted/70 text-foreground`:`text-muted-foreground`,i&&`pointer-events-none opacity-40`),children:[(0,X.jsx)(ki,{mode:e,active:r}),(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center justify-center gap-1 px-0.5`,children:[(0,X.jsx)(`span`,{className:`truncate text-[10px] font-medium`,children:t}),r&&e===`as`?(0,X.jsx)(`span`,{className:`max-w-28 truncate text-[10px] text-muted-foreground`,children:n}):null]})]})}function Li({title:e,badge:t,children:n}){return(0,X.jsxs)(`div`,{className:`px-2 py-2`,"data-slot":`store-query-gate-detail`,children:[(0,X.jsxs)(`p`,{className:`text-[11px] font-medium text-foreground`,children:[e,t?(0,X.jsx)(`span`,{className:`ml-1.5 text-[10px] text-muted-foreground`,children:t}):null]}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[10px] leading-relaxed text-muted-foreground`,children:n})]})}function Ri({tab:e,onTabChange:t,policies:n,users:r,asGate:i,asUserId:a,onSelectPolicy:o,onSelectUser:s,hint:c}){let[l,u]=(0,Y.useState)(``),p=e===`user`?r.find(e=>e.id===a):n.find(e=>e.id===i),m=Ei(r,l,e=>[e.gate]),h=Ei(n,l),g=e===`user`?m:h,_=l.trim()!==``;return(0,X.jsxs)(`div`,{className:`flex flex-col`,"data-slot":`store-query-gate-as`,children:[(0,X.jsxs)(`div`,{className:`flex h-7 items-stretch border-b border-border/60`,role:`tablist`,"aria-label":`As a user or policy`,children:[(0,X.jsx)(zi,{active:e===`user`,disabled:r.length===0,onClick:()=>t(`user`),children:`User`}),(0,X.jsx)(zi,{active:e===`policy`,disabled:n.length===0,onClick:()=>t(`policy`),children:`Policy`})]}),(0,X.jsxs)(`label`,{className:`relative block border-b border-border/60`,children:[(0,X.jsx)(d,{icon:Ze,className:`pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(f,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:e===`user`?`Search users`:`Search policies`,"aria-label":e===`user`?`Search users`:`Search policies`,flat:!0,className:`h-8 pl-7 font-mono text-[12px]`})]}),(0,X.jsx)(`ul`,{role:`listbox`,"aria-label":e===`user`?`Users`:`Policy gates`,className:`max-h-40 overflow-y-auto`,children:g.length===0?(0,X.jsx)(`li`,{className:`px-1 py-2 text-[10px] text-muted-foreground`,children:_?`No matches.`:e===`user`?`No identities map to a policy Gate.`:`No policy Gates declared.`}):e===`user`?m.map(e=>(0,X.jsx)(Bi,{icon:ze,label:e.label,detail:`${e.detail} · ${e.gate}`,selected:e.id===a,onSelect:()=>s(e)},e.id)):h.map(e=>(0,X.jsx)(Bi,{icon:Le,label:e.label,detail:e.detail,selected:e.id===i,onSelect:()=>o(e)},e.id))}),c===void 0?p?(0,X.jsx)(`p`,{className:`border-t border-border/60 px-2 py-2 text-[10px] leading-relaxed text-muted-foreground`,children:e===`user`&&a?(0,X.jsxs)(X.Fragment,{children:[`View as `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:p.label}),` via`,` `,(0,X.jsx)(`span`,{className:`font-mono`,children:i}),`.`]}):(0,X.jsxs)(X.Fragment,{children:[p.detail,` Sets `,(0,X.jsx)(`span`,{className:`font-mono`,children:`oke.gate()`}),` /`,` `,(0,X.jsx)(`span`,{className:`font-mono`,children:`oke.user()`}),` for RLS.`]})}):null:c]})}function zi({active:e,disabled:t,onClick:n,children:r}){return(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e,disabled:t,onClick:n,className:p(K,`font-semibold tracking-[0.08em] uppercase`,e?Pe:Ne,t&&`pointer-events-none opacity-40`),children:r})}function Bi({icon:e,label:t,detail:n,selected:r,onSelect:i}){return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r,onClick:i,className:p(be,`items-start px-2`,r&&`bg-muted/70 text-foreground`),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:p(we,r&&`bg-sky-500`)}),(0,X.jsx)(d,{icon:e,className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate text-xs font-medium`,children:t}),(0,X.jsx)(`span`,{className:`block truncate text-[10px] text-muted-foreground`,children:n})]}),r?(0,X.jsx)(d,{icon:k,className:`mt-0.5 size-3.5 shrink-0`}):null]})})}function Vi({allOpen:e,disabled:t,onToggle:n,collapseLabel:r=`Collapse all`,expandLabel:i=`Expand all`,dataSlot:a,className:o,disclose:s=!1,bare:c=!1}){let l=e?r:i;return(0,X.jsx)(Re,{label:l,className:c?void 0:`flex self-stretch`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":l,"aria-expanded":s?e:void 0,"data-slot":a,disabled:t,onClick:e=>{e.stopPropagation(),n()},className:p(c?Oe:ce,o),children:(0,X.jsx)(d,{icon:e?$e:et,className:`size-3.5`,"aria-hidden":!0})})})}export{Mn as $,Gr as A,yr as B,Rr as C,ti as D,$r as E,ni as F,nr as G,hr as H,Jr as I,zn as J,Bn as K,Yr as L,Wr as M,Br as N,Ur as O,Kr as P,Pn as Q,ei as R,Lr as S,Hr as T,br as U,vr as V,mr as W,Nn as X,kn as Y,An as Z,gi as _,Fi as a,rt as at,di as b,Ci as c,it as ct,xi as d,jn as et,yi as f,hi as g,li as h,Li as i,st as it,Zr as j,Vr as k,Di as l,et as lt,ui as m,Ri as n,dt as nt,Pi as o,ot,bi as p,Yn as q,Ii as r,Z as rt,Si as s,at as st,Vi as t,lt as tt,wi as u,Qe as ut,ci as v,Qr as w,zr as x,fi as y,gr as z};
55
+ `)}var oi={oke:`1.0`,app:``},si=`public`;function ci(e){let t=e??oi,n=[{name:si,kind:`public`,variant:`public`,description:`Intentionally unauthenticated`,scopes:[],roles:[]}];for(let[e,r]of Object.entries(t.gates??{})){if(r.kind===`rate`||r.kind===`all`||e.startsWith(`rate:`))continue;let t=r.scopes??[],i=r.roles??[];if(e===`public`){let e=n[0];e&&(n[0]={...e,description:r.description??e.description,scopes:t,roles:i});continue}n.push({name:e,kind:`policy`,variant:mi({name:e,kind:`policy`,scopes:t}),...r.description===void 0?{}:{description:r.description},scopes:t,roles:i})}let r=_i(n.flatMap(e=>[...e.roles]));return{gates:n,actions:ir(t),roles:r}}function li(e,t){if(t===null)return e;let n=_i([...e.roles,...(t.principals??[]).filter(e=>e.kind===`role`).map(e=>e.name)]);return{...e,actions:_i([...t.moduleActions??[],...e.actions]),roles:n}}function ui(e,t){let n=t.trim().toLowerCase();return n===``?e:{gates:e.gates.filter(e=>pi(n,e.name,e.kind,e.variant,e.description,...e.scopes,...e.roles)),actions:e.actions.filter(e=>pi(n,e)),roles:e.roles.filter(e=>pi(n,e))}}function di(e,t){let n=e.filter(e=>e!==`store.sql:read`&&e!==`store.sql:write`);return _i([...Ur(Vr(t)),...n])}function fi(e){return e.gates.length}function pi(e,...t){return t.some(t=>t!==void 0&&t.toLowerCase().includes(e))}function mi(e){return e.kind===`public`||e.name===`public`?`public`:e.scopes.length>0?`scope`:`policy`}function hi(e){return e.gates.filter(e=>e.variant!==`scope`)}function gi(e){return e.gates.filter(e=>e.variant===`scope`)}function _i(e){return[...new Set(e)].sort((e,t)=>e.localeCompare(t))}var vi=[`console.flows.identities`];function yi(){return H({queryKey:vi,queryFn:async()=>{let e=await ie();if(e.error)throw Error(e.error.code);return e.data?.identities??[]}})}function bi(){return Ze({mutationFn:async e=>{let t=await g(e);if(t.error){let e=Error(t.error.code);throw e.code=t.error.code,e.data=t.error.data,e}if(!t.data)throw Error(`Empty invoke response`);return t.data}})}function xi(){return Ze({mutationFn:async e=>{let t=await z(e);if(t.error){let e=Error(t.error.code);throw e.code=t.error.code,e.data=t.error.data,e}if(!t.data)throw Error(`Empty clock run-now response`);return t.data}})}function Si(e){return e===null||e.length===0?`operator`:e===`public`?`public`:`as`}function Ci(e){return e.gates.filter(e=>e.kind===`policy`).map(e=>({id:e.name,label:e.name,detail:Oi(e)}))}function wi(e,t){let n=[];for(let r of e){if(r.status!==`active`)continue;let e=Ti(r.scopes,t);e!==null&&n.push({id:r.id,label:r.name||r.email,detail:r.email,gate:e})}return n}function Ti(e,t){let n=t.gates.filter(e=>e.kind===`policy`);for(let t of e)if(n.some(e=>e.name===t))return t;for(let t of e){let e=n.find(e=>e.roles.includes(t));if(e)return e.name}return null}function Ei(e,t,n=()=>[]){let r=t.trim().toLowerCase();return r===``?e:e.filter(e=>[e.id,e.label,e.detail,...n(e)].some(e=>e.toLowerCase().includes(r)))}function Di(e,t,n){return t&&n?`User · ${n}`:t?`User · ${t}`:e&&e.length>0?`Gate · ${e}`:`Gate`}function Oi(e){return e.description?e.description:e.roles.length>0?`Roles ${e.roles.join(`, `)}`:e.scopes.length>0?e.scopes.join(` · `):`Policy gate`}function ki({mode:e,active:t,className:n}){let r=`${(0,Y.useId)().replace(/:/g,``)}-hatch`;return(0,X.jsxs)(`svg`,{viewBox:`0 0 72 40`,className:p(`h-10 w-full`,t?`text-foreground`:`text-muted-foreground/70`,n),"aria-hidden":!0,"data-slot":`store-query-gate-viz`,"data-mode":e,children:[(0,X.jsx)(`defs`,{children:(0,X.jsx)(`pattern`,{id:r,width:`4`,height:`4`,patternUnits:`userSpaceOnUse`,patternTransform:`rotate(45)`,children:(0,X.jsx)(`path`,{d:`M0 0 H4`,className:`stroke-current`,strokeWidth:`0.7`,opacity:`0.35`})})}),e===`operator`?(0,X.jsx)(ji,{hatchId:r}):null,e===`public`?(0,X.jsx)(Mi,{hatchId:r}):null,e===`as`?(0,X.jsx)(Ni,{hatchId:r}):null]})}function Ai({hatchId:e}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`rect`,{x:`22`,y:`10`,width:`28`,height:`20`,rx:`5`,fill:`url(#${e})`,className:`stroke-current`,strokeWidth:`1.15`}),(0,X.jsx)(`path`,{d:`M22 17 H50`,className:`stroke-current`,strokeWidth:`0.8`,opacity:`0.45`})]})}function ji({hatchId:e}){return(0,X.jsxs)(`g`,{children:[(0,X.jsx)(`path`,{d:`M4 14 C18 14, 18 26, 68 26`,fill:`none`,className:`stroke-sky-500 dark:stroke-sky-400`,strokeWidth:`1.35`,strokeDasharray:`2.4 2`}),(0,X.jsx)(`path`,{d:`M4 26 C18 26, 18 14, 68 14`,fill:`none`,className:`stroke-sky-500 dark:stroke-sky-400`,strokeWidth:`1.35`,strokeDasharray:`2.4 2`}),(0,X.jsx)(Ai,{hatchId:e})]})}function Mi({hatchId:e}){return(0,X.jsxs)(`g`,{children:[(0,X.jsx)(`path`,{d:`M4 14 H18`,fill:`none`,className:`stroke-current`,strokeWidth:`1.2`,strokeDasharray:`2.4 2`,opacity:`0.55`}),(0,X.jsx)(`path`,{d:`M4 26 H18`,fill:`none`,className:`stroke-current`,strokeWidth:`1.2`,strokeDasharray:`2.4 2`,opacity:`0.55`}),(0,X.jsx)(Ai,{hatchId:e}),(0,X.jsx)(`path`,{d:`M54 14 H68`,fill:`none`,className:`stroke-current`,strokeWidth:`1.2`,strokeDasharray:`2.4 2`,opacity:`0.28`}),(0,X.jsx)(`path`,{d:`M54 26 H68`,fill:`none`,className:`stroke-current`,strokeWidth:`1.2`,strokeDasharray:`2.4 2`,opacity:`0.28`})]})}function Ni({hatchId:e}){return(0,X.jsxs)(`g`,{children:[(0,X.jsx)(`circle`,{cx:`10`,cy:`16`,r:`3.1`,className:`fill-violet-500 dark:fill-violet-400`}),(0,X.jsx)(`path`,{d:`M5.5 26 C5.5 22.2, 14.5 22.2, 14.5 26`,fill:`none`,className:`stroke-violet-500 dark:stroke-violet-400`,strokeWidth:`1.2`}),(0,X.jsx)(`path`,{d:`M16 20 H22`,fill:`none`,className:`stroke-violet-500 dark:stroke-violet-400`,strokeWidth:`1.25`}),(0,X.jsx)(Ai,{hatchId:e}),(0,X.jsx)(`path`,{d:`M50 20 H56`,fill:`none`,className:`stroke-violet-500 dark:stroke-violet-400`,strokeWidth:`1.25`}),(0,X.jsx)(`path`,{d:`M59 13.5 L64.5 17 L59 26.5 L53.5 17 Z`,className:`fill-background stroke-violet-500 dark:stroke-violet-400`,strokeWidth:`1.15`})]})}function Pi({children:e}){return(0,X.jsx)(`p`,{className:p(Me,`border-b border-border/60 px-2 py-1.5`),children:e})}function Fi({label:e,children:t}){return(0,X.jsx)(`div`,{role:`radiogroup`,"aria-label":e,className:`flex items-stretch border-b border-border/60`,children:t})}function Ii({mode:e,title:t,caption:n,selected:r,disabled:i=!1,onSelect:a}){return(0,X.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,disabled:i,title:n,onClick:a,"data-slot":`store-query-gate-card`,"data-mode":e,className:p(`flex min-w-0 flex-1 flex-col items-stretch gap-1 px-1.5 pt-2 pb-1.5 text-left transition-colors hover:bg-muted/50 hover:text-foreground`,r?`bg-muted/70 text-foreground`:`text-muted-foreground`,i&&`pointer-events-none opacity-40`),children:[(0,X.jsx)(ki,{mode:e,active:r}),(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center justify-center gap-1 px-0.5`,children:[(0,X.jsx)(`span`,{className:`truncate text-[10px] font-medium`,children:t}),r&&e===`as`?(0,X.jsx)(`span`,{className:`max-w-28 truncate text-[10px] text-muted-foreground`,children:n}):null]})]})}function Li({title:e,badge:t,children:n}){return(0,X.jsxs)(`div`,{className:`px-2 py-2`,"data-slot":`store-query-gate-detail`,children:[(0,X.jsxs)(`p`,{className:`text-[11px] font-medium text-foreground`,children:[e,t?(0,X.jsx)(`span`,{className:`ml-1.5 text-[10px] text-muted-foreground`,children:t}):null]}),(0,X.jsx)(`p`,{className:`mt-0.5 text-[10px] leading-relaxed text-muted-foreground`,children:n})]})}function Ri({tab:e,onTabChange:t,policies:n,users:r,asGate:i,asUserId:a,onSelectPolicy:o,onSelectUser:s,hint:c}){let[l,u]=(0,Y.useState)(``),p=e===`user`?r.find(e=>e.id===a):n.find(e=>e.id===i),m=Ei(r,l,e=>[e.gate]),h=Ei(n,l),g=e===`user`?m:h,_=l.trim()!==``;return(0,X.jsxs)(`div`,{className:`flex flex-col`,"data-slot":`store-query-gate-as`,children:[(0,X.jsxs)(`div`,{className:`flex h-7 items-stretch border-b border-border/60`,role:`tablist`,"aria-label":`As a user or policy`,children:[(0,X.jsx)(zi,{active:e===`user`,disabled:r.length===0,onClick:()=>t(`user`),children:`User`}),(0,X.jsx)(zi,{active:e===`policy`,disabled:n.length===0,onClick:()=>t(`policy`),children:`Policy`})]}),(0,X.jsxs)(`label`,{className:`relative block border-b border-border/60`,children:[(0,X.jsx)(d,{icon:Xe,className:`pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(f,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:e===`user`?`Search users`:`Search policies`,"aria-label":e===`user`?`Search users`:`Search policies`,flat:!0,className:`h-8 pl-7 font-mono text-[12px]`})]}),(0,X.jsx)(`ul`,{role:`listbox`,"aria-label":e===`user`?`Users`:`Policy gates`,className:`max-h-40 overflow-y-auto`,children:g.length===0?(0,X.jsx)(`li`,{className:`px-1 py-2 text-[10px] text-muted-foreground`,children:_?`No matches.`:e===`user`?`No identities map to a policy Gate.`:`No policy Gates declared.`}):e===`user`?m.map(e=>(0,X.jsx)(Bi,{icon:ze,label:e.label,detail:`${e.detail} · ${e.gate}`,selected:e.id===a,onSelect:()=>s(e)},e.id)):h.map(e=>(0,X.jsx)(Bi,{icon:Le,label:e.label,detail:e.detail,selected:e.id===i,onSelect:()=>o(e)},e.id))}),c===void 0?p?(0,X.jsx)(`p`,{className:`border-t border-border/60 px-2 py-2 text-[10px] leading-relaxed text-muted-foreground`,children:e===`user`&&a?(0,X.jsxs)(X.Fragment,{children:[`View as `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:p.label}),` via`,` `,(0,X.jsx)(`span`,{className:`font-mono`,children:i}),`.`]}):(0,X.jsxs)(X.Fragment,{children:[p.detail,` Sets `,(0,X.jsx)(`span`,{className:`font-mono`,children:`oke.gate()`}),` /`,` `,(0,X.jsx)(`span`,{className:`font-mono`,children:`oke.user()`}),` for RLS.`]})}):null:c]})}function zi({active:e,disabled:t,onClick:n,children:r}){return(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e,disabled:t,onClick:n,className:p(K,`font-semibold tracking-[0.08em] uppercase`,e?Pe:Ne,t&&`pointer-events-none opacity-40`),children:r})}function Bi({icon:e,label:t,detail:n,selected:r,onSelect:i}){return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r,onClick:i,className:p(be,`items-start px-2`,r&&`bg-muted/70 text-foreground`),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:p(we,r&&`bg-sky-500`)}),(0,X.jsx)(d,{icon:e,className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate text-xs font-medium`,children:t}),(0,X.jsx)(`span`,{className:`block truncate text-[10px] text-muted-foreground`,children:n})]}),r?(0,X.jsx)(d,{icon:k,className:`mt-0.5 size-3.5 shrink-0`}):null]})})}function Vi({allOpen:e,disabled:t,onToggle:n,collapseLabel:r=`Collapse all`,expandLabel:i=`Expand all`,dataSlot:a,className:o,disclose:s=!1,bare:c=!1}){let l=e?r:i;return(0,X.jsx)(Re,{label:l,className:c?void 0:`flex self-stretch`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":l,"aria-expanded":s?e:void 0,"data-slot":a,disabled:t,onClick:e=>{e.stopPropagation(),n()},className:p(c?Oe:ce,o),children:(0,X.jsx)(d,{icon:e?$e:et,className:`size-3.5`,"aria-hidden":!0})})})}export{Mn as $,Gr as A,yr as B,Rr as C,ti as D,$r as E,ni as F,nr as G,hr as H,Jr as I,zn as J,Bn as K,Yr as L,Wr as M,Br as N,Ur as O,Kr as P,Pn as Q,ei as R,Lr as S,Hr as T,br as U,vr as V,mr as W,Nn as X,kn as Y,An as Z,gi as _,Fi as a,rt as at,di as b,Ci as c,it as ct,xi as d,jn as et,yi as f,hi as g,li as h,Li as i,st as it,Zr as j,Vr as k,Di as l,et as lt,ui as m,Ri as n,dt as nt,Pi as o,ot,bi as p,Yn as q,Ii as r,Z as rt,Si as s,at as st,Vi as t,lt as tt,wi as u,Qe as ut,ci as v,Qr as w,zr as x,fi as y,gr as z};
@@ -0,0 +1 @@
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-CUNegEV4.js";import{c as te,l as ne,n as re,o as ie,r as ae,t as oe}from"./call-pii-button-Deo4PP18.js";import{a as se,n as ce,r as le,t as ue}from"./http-method-DTPevKmM.js";import{a as de,b as fe,c as pe,g as me,i as he,m as ge,n as _e,o as ve,r as ye,s as be,t as xe}from"./element-icons-CwyLpVXz.js";import{a as Se,i as Ce,n as we,o as Te,r as Ee,s as De,t as Oe}from"./collapsible-CoJ6amHf.js";import{a as ke,c as Ae,f as je,i as Me,s as Ne,t as Pe,u as Fe}from"./highlighted-json-CPYBzDh0.js";import{a as Ie,c as Le,d as Re,f as ze,l as Be,m as Ve,o as He,p as z,s as Ue,t as We,u as Ge,w as Ke}from"./request-meta-BjFT7DNl.js";import{t as qe}from"./UserIcon-DaE2PB5_.js";import{n as Je}from"./dagre.esm-B1_XeuLP.js";import{$ as B,G as Ye,Q as V,X as H,Y as U,a as Xe,c as Ze,d as Qe,et as W,f as $e,h as et,i as tt,n as nt,nt as rt,o as it,p as at,r as ot,s as st,t as ct,u as lt,ut,v as dt}from"./tree-expand-toggle-CbDIB-7x.js";import{d as ft,r as pt,t as mt}from"./dropdown-menu-nwXEO1Ac.js";import{At as ht,Dt as gt,gt as _t}from"./index-vTuwmeQz.js";import{t as vt}from"./explorer-empty-C8sSCqYT.js";import{c as G,n as yt,t as bt,u as xt}from"./detail-header-b_ZzIsmU.js";import{c as St,n as Ct,s as wt,t as Tt}from"./cache-glyph-rL0lHxat.js";var Et=[[`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`}]],Dt=[[`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`}]],Ot=[[`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`}]],K=e(t(),1),q=n();function kt(e,t){let n=st(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 J(e){let t=st(e.asGate);return t===`operator`||t===`public`||!!(e.asUserId||e.asGate)}function At({manifest:e,identities:t,value:n,onChange:r}){let a=Ye(!0),s=(0,K.useMemo)(()=>et(dt(e),a.data??null),[e,a.data]),c=(0,K.useMemo)(()=>Ze(s),[s]),l=(0,K.useMemo)(()=>lt(t,s),[t,s]),u=s.gates.find(e=>e.kind===`public`)?.description??`Intentionally unauthenticated.`,d=st(n.asGate),f=n.asGate!==null,[p,m]=(0,K.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,q.jsxs)(mt,{children:[(0,q.jsx)(ft,{render:e=>(0,q.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,q.jsx)(i,{icon:xe.gate.icon,"data-icon":`inline-start`,className:`size-3.5`}),(0,q.jsx)(`span`,{className:`truncate`,children:kt(n,t)})]})}),(0,q.jsxs)(pt,{align:`end`,className:`w-80 overflow-hidden p-0`,children:[(0,q.jsx)(it,{children:`Invoke as`}),(0,q.jsxs)(Xe,{label:`Invoke as`,children:[(0,q.jsx)(ot,{mode:`operator`,title:`Operator`,caption:`Bypass`,selected:d===`operator`,onSelect:()=>v(`operator`)}),(0,q.jsx)(ot,{mode:`public`,title:`Public`,caption:`Anonymous`,selected:d===`public`,onSelect:()=>v(`public`)}),(0,q.jsx)(ot,{mode:`as`,title:`As`,caption:g?g.label:h?.label??`User / policy`,selected:d===`as`,disabled:!_,onSelect:()=>v(`as`)})]}),d===`operator`?(0,q.jsx)(tt,{title:`Operator`,badge:`Default`,children:`Bypasses the flow's gate chain.`}):null,d===`public`?(0,q.jsxs)(tt,{title:`Public`,children:[u,` Only `,(0,q.jsx)(`span`,{className:`font-mono`,children:`gate.public`}),` flows succeed.`]}):null,d===`as`?(0,q.jsx)(nt,{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,q.jsxs)(`p`,{className:`border-t border-border/60 px-2 py-2 text-[10px] leading-relaxed text-muted-foreground`,children:[`Calls as `,(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:g.label}),` `,`via `,(0,q.jsx)(`span`,{className:`font-mono`,children:n.asGate}),`.`]}):h?(0,q.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,q.jsx)(`span`,{className:`font-mono`,children:h.id}),`.`]}):null}):null]})]})}var jt=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 Mt(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??Nt(i))}let i=[];for(let t of e)n.has(t.name)||(jt.has(t.name)?r.push(t):i.push(t));return{parameters:r,fields:i}}function Nt(e){return{path:`/path/${e}`,name:e,type:`string`,required:!0}}function Pt(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 ce(t.method)?{path:n,query:[],body:i}:{path:n,query:i,body:[]}}function Ft(e,t){let n={};for(let r of t)Object.hasOwn(e,r.name)&&(n[r.name]=e[r.name]);return n}function Y(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])=>It(e,`${t}/${e}`,n,r.has(e)))}return[It(`value`,t||`/`,e,!0)]}function It(e,t,n,r){let i=Lt(e,n),a=typeof n.description==`string`?n.description:void 0;if(Array.isArray(n.enum)){let o=Wt(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:Y(n,t)};if(o===`array`)return{path:t,name:e,type:`array`,required:r,...a===void 0?{}:{description:a},...i,children:n.items?Y(n.items,`${t}/0`):void 0};let s=o===`integer`||o===`number`||o===`boolean`||o===`string`?o:`unknown`,c=Wt(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 Lt(e,t){let n=Rt(e),r=zt(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 Rt(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 zt(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 Bt=12;function Vt(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 Ht(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 Ut(e){return e.filter(e=>e.minimum!==void 0||e.maximum!==void 0||(e.enumValues?.length??0)>0||(e.valueMeanings?.length??0)>0)}function Wt(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 Gt(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>Bt?null:Array.from({length:t+1},(t,n)=>e.minimum+n)}function Kt(e){return e?qt(e):{}}function qt(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]=qt(i));return r}if(t===`array`){let t=e.items;return t?[qt(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 Jt(e){return!e||typeof e==`string`?null:e}function Yt(e,t){if(!e.foreignKey||!t)return null;let n=$t(t);if(n.length===0)return null;if(e.references?.table){let t=en(n,e.references.table);return t?Zt(t,e.references.column??nn(t.table)??`id`):null}let r=Qt(e.name);if(!r)return null;let i=tn(n,r.stem);return i?Zt(i,r.kind===`key`?rn(i.table,`key`)??nn(i.table)??`id`:nn(i.table)??`id`):null}function Xt(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 Zt(e,t){let n=an(e.table,t);return{ref:e.ref,child:e.name,column:t,...n===void 0?{}:{labelColumn:n}}}function Qt(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 $t(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 en(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 tn(e,t){let n=cn(t),r=[t,n,sn(t),sn(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 nn(e){for(let[t,n]of Object.entries(e.columns??{}))if(on(n)&&n.primaryKey===!0)return t;if(e.columns&&`id`in e.columns)return`id`}function rn(e,t){return e.columns&&t in e.columns?t:void 0}function an(e,t){if(t!==`name`&&e.columns&&`name`in e.columns)return`name`}function on(e){return`type`in e||`primaryKey`in e||`references`in e}function sn(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 cn(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1_$2`).toLowerCase()}function ln(e){let t=[];for(let n of e.split(`/`))n.startsWith(`:`)&&n.length>1&&t.push(n.slice(1));return t}function un(e){return`:${e}`}var dn={"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 fn(e,t){let n=e.split(`/`).filter(Boolean),r=`:${t}`,i=n.indexOf(r),a=i>0?n[i-1]:void 0;return(a?dn[`${a}:${t}`]:void 0)??dn[`:${t}`]}function pn(e,t){let n={};if(!e)return n;for(let r of t){let t=fn(e,r);t&&(n[r]=t)}return n}function mn(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 hn(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 gn(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 _n(e,t,n=re){if(t.size===0||e==null)return e;if(Array.isArray(e))return e.map(e=>_n(e,t,n));if(typeof e==`object`){let r={};for(let[i,a]of Object.entries(e))r[i]=t.has(i)?n:_n(a,t,n);return r}return e}function vn(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 yn(e,t,n){return t&&e.masked===!1?vn({...e,response:_n(e.response,n),failure:e.failure===void 0?void 0:{...e.failure,data:_n(e.failure.data,n)},masked:!0}):vn(e)}function bn(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 xn(e,t){return!t&&bn(e)}function Sn(e,t){if(!e)return{ok:!0,errors:[],value:t};let n=[];return Cn(e,t,``,n),{ok:n.length===0,errors:n,value:t}}function Cn(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&&Cn(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`}):wn(e,t,n,r):i===`number`?typeof t!=`number`||Number.isNaN(t)?r.push({path:n||`/`,message:`must be number`}):wn(e,t,n,r):i===`boolean`&&typeof t!=`boolean`&&r.push({path:n||`/`,message:`must be boolean`})}function wn(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 Tn(e){return JSON.stringify(e,null,2)}function En({row:e,manifest:t}){let n=z(e.flow.trigger);return n===`cron`||n===`every`?(0,q.jsx)(Dn,{row:e,manifest:t}):(0,q.jsx)(On,{row:e,kind:n,manifest:t})}function Dn({row:e,manifest:t}){let n=(0,K.useMemo)(()=>mn(t,e.id),[t,e.id]),r=Qe(),a=$e(),o=at(),[s,c]=(0,K.useState)({asGate:null,asUserId:null}),[l,u]=(0,K.useState)(null),[d,f]=(0,K.useState)(null);(0,K.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(J(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,K.useMemo)(()=>p&&r.data?JSON.stringify(r.data,null,2):!p&&o.data?vn(o.data):null,[p,r.data,o.data]),b=p?`Run now`:`Run handler`,x=p?`Run now`:`Run handler once`;return(0,q.jsx)(Mn,{title:b,dataMode:p?`clock`:`invoke-fallback`,actions:(0,q.jsxs)(q.Fragment,{children:[p?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(At,{manifest:t,identities:a.data??[],value:s,onChange:c}),(0,q.jsx)(Ln,{})]}),(0,q.jsx)(L,{type:`button`,"data-slot":`call-api-submit`,disabled:h||!p&&!J(s),onClick:()=>void m(),className:In,children:h?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(i,{icon:_t,className:`animate-spin`,"data-icon":`inline-start`}),`Running…`]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(i,{icon:te,"data-icon":`inline-start`}),x]})})]}),children:(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[p?(0,q.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,q.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:n.clockName}),` `,`via`,` `,(0,q.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,q.jsxs)(q.Fragment,{children:[` `,`Timezone · `,(0,q.jsx)(`span`,{className:`font-mono`,children:n.timezone}),`.`]}):null]}):(0,q.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,q.jsx)(`strong`,{className:`font-medium`,children:`Run handler once`}),` uses`,` `,(0,q.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,q.jsx)(`em`,{children:`not`}),` exercise the Clock lease / scheduler path.`]}),(0,q.jsx)(kn,{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 On({row:e,kind:t,manifest:n}){let r=$e(),l=at(),d=Jt(e.flow.in),f=(0,K.useMemo)(()=>Y(d),[d]),p=(0,K.useMemo)(()=>t===`http`&&e.path?ln(e.path):[],[t,e.path]),m=(0,K.useMemo)(()=>Pt(f,{http:t===`http`,method:e.method,pathParams:p}),[f,t,e.method,p]),h=t!==`http`||ce(e.method),[g,_]=(0,K.useState)({asGate:null,asUserId:null}),[v,y]=(0,K.useState)(!0),[b,x]=(0,K.useState)(()=>pn(e.path,p)),S=(0,K.useMemo)(()=>Kt(d)??{},[d]),C=(0,K.useMemo)(()=>Ft(S,m.query),[S,m.query]),w=(0,K.useMemo)(()=>Ft(S,m.body),[S,m.body]),[T,E]=(0,K.useState)(C),[D,O]=(0,K.useState)(w),[k,A]=(0,K.useState)(`fields`),[j,M]=(0,K.useState)(()=>Tn(w)),[N,P]=(0,K.useState)(null),[F,I]=(0,K.useState)([]),[R,ee]=(0,K.useState)(null),[ne,re]=(0,K.useState)(null);(0,K.useEffect)(()=>{E(C),O(w),M(Tn(w)),P(null),A(`fields`),x(pn(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(Tn(D)),P(null),A(`raw`);return}ie(j)&&A(`fields`)}}async function se(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=Sn(d,{...b,...r});if(!i.ok){I(i.errors);return}if(I([]),J(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 le(){E(C),O(w),M(Tn(w)),P(null),x(pn(e.path,p)),I([])}(0,K.useEffect)(()=>{R===null||l.isPending||(l.isSuccess||l.isError)&&re(performance.now()-R)},[l.isSuccess,l.isError,l.isPending,R]);let ue=(0,K.useMemo)(()=>l.data?yn(l.data,v,gn(n)):null,[l.data,v,n]),de=l.data?.failure!=null,fe=l.data?.status,pe=t===`http`?`Call API`:t===`signal`?`Run handler`:`Invoke`,me=pe;return(0,q.jsx)(Mn,{title:pe,dataTrigger:t,actions:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(At,{manifest:n,identities:r.data??[],value:g,onChange:_}),(0,q.jsx)(oe,{piiMasked:v,disabled:l.isPending,onToggle:()=>{let t=!v;y(t),l.data&&!l.isPending&&xn(e,t)&&se(!0)}}),h?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Ln,{}),(0,q.jsx)(Nn,{view:k,onChange:ae})]}):null,(0,q.jsx)(Ln,{}),(0,q.jsxs)(s,{children:[(0,q.jsx)(u,{render:e=>(0,q.jsxs)(L,{...e,type:`button`,variant:`ghost`,"data-slot":`call-api-reset`,disabled:l.isPending,onClick:le,className:Fn,children:[(0,q.jsx)(i,{icon:je,"data-icon":`inline-start`}),`Reset`]})}),(0,q.jsx)(c,{side:`bottom`,className:`text-[11px]`,children:h?`Reset body to the schema example`:`Reset to schema examples`})]}),(0,q.jsx)(Ln,{}),(0,q.jsx)(L,{type:`button`,"data-slot":`call-api-submit`,disabled:l.isPending||!J(g),onClick:()=>void se(),className:In,children:l.isPending?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(i,{icon:_t,className:`animate-spin`,"data-icon":`inline-start`}),`Calling…`]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(i,{icon:te,"data-icon":`inline-start`}),me]})})]}),children:(0,q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`min-h-0 min-w-0 shrink overflow-y-auto`,children:[t===`http`?(0,q.jsxs)(`p`,{className:`px-3 pt-2.5 pb-2 text-[11px] leading-snug text-muted-foreground`,children:[`Operator session · invoke-as`,` `,(0,q.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`console:flows:invoke-as`})]}):null,t===`signal`?(0,q.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,q.jsx)(`strong`,{className:`font-medium`,children:`Run handler directly`}),` — invokes the flow with your payload via`,` `,(0,q.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`/console/flows/invoke`}),`. It does `,(0,q.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,q.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,q.jsx)(`code`,{className:`font-mono text-[10px]`,children:`fx.call`}),` /`,` `,(0,q.jsx)(`code`,{className:`font-mono text-[10px]`,children:`effects.calls`}),`). The body still matches `,(0,q.jsx)(`code`,{className:`font-mono text-[10px]`,children:`flow.in`}),`.`]}):null,t===`cdc`?(0,q.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,q.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Path params`,"data-slot":`call-api-path`,children:[(0,q.jsx)(zn,{title:`Path params`,hint:e.path??void 0}),p.map(e=>(0,q.jsx)(G,{label:e,className:`[&>span]:px-3`,children:(0,q.jsx)(a,{id:`path-${e}`,flat:!0,className:o(yt,`px-3 font-mono`),placeholder:un(e),value:b[e]??``,onChange:t=>x(n=>({...n,[e]:t.target.value}))})},e))]}):null,m.query.length>0?(0,q.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Query params`,"data-slot":`call-api-query`,children:[(0,q.jsx)(zn,{title:`Query params`,hint:`seeded from schema`}),(0,q.jsx)(xt,{children:m.query.map(e=>(0,q.jsx)(Bn,{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,q.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Body`,"data-slot":`call-api-body`,children:[(0,q.jsx)(zn,{title:`Body`,hint:k===`raw`?`raw JSON`:`seeded from schema`}),k===`raw`?(0,q.jsxs)(`div`,{className:`border-b border-border/50`,children:[(0,q.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,q.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,q.jsx)(`p`,{className:`border-b border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:`No body fields (empty object).`}):(0,q.jsx)(xt,{children:m.body.map(e=>(0,q.jsx)(Bn,{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,q.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,q.jsx)(kn,{failed:!!de,success:!!l.data&&!de,elapsed:ne,handlerMs:l.data?.durationMs,statusCode:fe,errorMessage:l.isError?l.error.message:null,responseJson:ue,emptyHint:`Call to see a real host response.`,pathUsed:null,cache:l.data?.cache})]})})}function kn({failed:e,success:t,elapsed:n,handlerMs:r,statusCode:a,errorMessage:s,responseJson:c,emptyHint:l,pathUsed:u,cache:d}){let[f,m]=(0,K.useState)(!1),h=(0,q.jsx)(jn,{failed:e,success:t,elapsed:n,handlerMs:r,statusCode:a,pathUsed:u,cache:d});return(0,q.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,q.jsxs)(`div`,{className:F,children:[(0,q.jsx)(`h4`,{className:o(I,`flex items-center px-2`),children:`Response`}),(0,q.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,children:[h,c?(0,q.jsx)(be,{label:`Expand response`,className:`flex self-stretch`,children:(0,q.jsx)(`button`,{type:`button`,"aria-label":`Expand response`,"data-slot":`call-api-response-expand`,className:g,onClick:()=>m(!0),children:(0,q.jsx)(i,{icon:Et,className:`size-3.5`,"aria-hidden":!0})})}):null]})]}),s?(0,q.jsx)(`p`,{role:`alert`,className:`px-2 py-2 text-sm text-destructive`,"data-slot":`call-api-error`,children:s}):null,c?(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,"data-slot":`call-api-response-frame`,children:[(0,q.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,q.jsx)(Pe,{json:c,dataSlot:`call-api-response`,className:`flex min-h-0 flex-1 overflow-auto`})]}):(0,q.jsx)(`p`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:l}),c?(0,q.jsx)(b,{open:f,onOpenChange:m,children:(0,q.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,q.jsxs)(C,{className:o(F,`flex-row gap-0 border-border/60 p-0`),children:[(0,q.jsx)(N,{className:o(I,`flex items-center px-2`),children:`Response`}),(0,q.jsx)(j,{className:`sr-only`,children:`Full Call API response JSON`}),(0,q.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,children:[h,(0,q.jsx)(An,{json:c}),(0,q.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0}),(0,q.jsxs)(p,{"aria-label":`Close`,className:g,"data-slot":`call-api-response-close`,children:[(0,q.jsx)(i,{icon:S,className:`size-3.5`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,q.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,q.jsx)(`div`,{className:o(`w-1 shrink-0 self-stretch`,e?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0}),(0,q.jsx)(Pe,{json:c,dataSlot:`call-api-response-expanded`,className:`flex min-h-0 flex-1 overflow-auto`})]})})]})}):null]})}function An({json:e}){let[t,n]=(0,K.useState)(!1);return(0,q.jsx)(be,{label:t?`Copied`:`Copy response`,className:`flex self-stretch`,children:(0,q.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,q.jsx)(i,{icon:t?l:fe,className:`size-3.5`,"aria-hidden":!0})})})}function jn({failed:e,success:t,elapsed:n,handlerMs:r,statusCode:a,pathUsed:d,cache:f}){let p=t||e,m=p?hn({handlerMs:r,rttMs:n}):null;return(0,q.jsxs)(q.Fragment,{children:[d?(0,q.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,q.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,q.jsx)(i,{icon:e?De:l,className:`size-3`,"aria-hidden":!0}),a??(e?`error`:`ok`)]}):null,p?(0,q.jsx)(`span`,{className:`flex h-full items-center px-2`,children:(0,q.jsx)(Tt,{cache:f??`none`,dataSlot:`call-api-cache`})}):null,m?(0,q.jsxs)(s,{children:[(0,q.jsx)(u,{render:e=>(0,q.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:Me(m.primaryMs)})}),(0,q.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,q.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:[Me(m.rttMs),` rtt`]}):null]})}function Mn({title:e,actions:t,children:n,dataTrigger:a,dataMode:s}){return(0,q.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,q.jsxs)(`div`,{className:o(r,`min-w-0`),children:[(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 px-2`,children:[(0,q.jsx)(i,{icon:te,className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),(0,q.jsx)(`h3`,{className:o(I,`text-foreground`),children:e})]}),(0,q.jsx)(`div`,{className:`ml-auto flex h-full min-w-0 items-stretch`,children:t})]}),(0,q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:n})]})}function Nn({view:e,onChange:t}){return(0,q.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,q.jsx)(Pn,{active:e===`fields`,label:`Fields`,icon:Ke,onClick:()=>t(`fields`)}),(0,q.jsx)(Pn,{active:e===`raw`,label:`Raw`,icon:Se,onClick:()=>t(`raw`)})]})}function Pn({active:e,label:t,icon:n,onClick:r}){return(0,q.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,q.jsx)(i,{icon:n,className:`size-3`}),(0,q.jsx)(`span`,{className:`hidden sm:inline`,children:t})]})}var Fn=`h-full rounded-none border-0 bg-transparent px-2 text-[10px] font-semibold tracking-[0.08em] uppercase shadow-none hover:bg-muted/50`,In=`h-full rounded-none border-0 px-3 text-[10px] font-semibold tracking-[0.14em] uppercase shadow-none`;function Ln(){return(0,q.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0})}var Rn=`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 zn({title:e,hint:t}){return(0,q.jsxs)(`div`,{className:F,children:[(0,q.jsx)(`h4`,{className:o(I,`flex items-center px-2`),children:e}),t?(0,q.jsx)(`span`,{className:`ml-auto flex items-center px-2 text-[10px] text-muted-foreground`,children:t}):null]})}function Bn({field:e,value:t,onChange:n,error:r,wide:i=!1,manifest:s,idPrefix:c=`body`}){let l=`${c}-${e.name}`,u=Vn(e,s),d=[e.required?null:`optional`,u.lookup?`fk · ${u.lookup.child}.${u.lookup.column}`:e.type,u.lookup?null:Vt(e)].filter(Boolean).join(` · `),f=r?(0,q.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=Hn(u.options,r);return(0,q.jsxs)(G,{label:e.name,hint:d,dense:!0,className:p,children:[(0,q.jsxs)(U,{value:r||null,onValueChange:e=>{e==null||Array.isArray(e)||n(String(e))},children:[(0,q.jsx)(B,{id:l,className:Rn,disabled:u.isLoading,children:(0,q.jsx)(W,{placeholder:u.isLoading?`Loading…`:`Select…`})}),(0,q.jsx)(H,{children:i.map(e=>(0,q.jsx)(V,{value:e.value,children:e.label},e.value))})]}),f]})}if(e.type===`enum`&&e.enumValues)return(0,q.jsxs)(G,{label:e.name,hint:d,dense:!0,className:p,children:[(0,q.jsxs)(U,{value:String(t??``),onValueChange:e=>{e==null||Array.isArray(e)||n(String(e))},children:[(0,q.jsx)(B,{id:l,className:Rn,children:(0,q.jsx)(W,{})}),(0,q.jsx)(H,{children:e.enumValues.map(e=>(0,q.jsx)(V,{value:e,children:e},e))})]}),f]});if(e.type===`boolean`)return(0,q.jsx)(G,{label:e.name,hint:d,dense:!0,className:p,children:(0,q.jsxs)(U,{value:t===!0?`true`:`false`,onValueChange:e=>{e==null||Array.isArray(e)||n(String(e)===`true`)},children:[(0,q.jsx)(B,{id:l,className:Rn,children:(0,q.jsx)(W,{})}),(0,q.jsxs)(H,{children:[(0,q.jsx)(V,{value:`true`,children:`true`}),(0,q.jsx)(V,{value:`false`,children:`false`})]})]})});if(e.type===`integer`||e.type===`number`){let r=Gt(e);if(r){let i=typeof t==`number`?String(t):``;return(0,q.jsxs)(G,{label:e.name,hint:d,dense:!0,className:p,children:[(0,q.jsxs)(U,{value:i||null,onValueChange:e=>{e==null||Array.isArray(e)||n(Number(e))},children:[(0,q.jsx)(B,{id:l,className:Rn,children:(0,q.jsx)(W,{placeholder:`Select…`})}),(0,q.jsx)(H,{children:r.map(t=>{let n=e.valueMeanings?.find(e=>e.value===String(t));return(0,q.jsx)(V,{value:String(t),children:n?`${t} · ${n.label}`:t},t)})})]}),f]})}return(0,q.jsxs)(G,{label:e.name,hint:d,dense:!0,className:p,children:[(0,q.jsx)(a,{id:l,type:`number`,flat:!0,className:o(yt,`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(Un(Number(t.target.value),e.minimum,e.maximum))}}),f]})}return(0,q.jsxs)(G,{label:e.name,hint:d,dense:!0,className:p,children:[(0,q.jsx)(a,{id:l,flat:!0,className:o(yt,`h-7 px-2 font-mono`),value:typeof t==`string`?t:t==null?``:String(t),onChange:e=>n(e.target.value)}),f]})}function Vn(e,t){let n=(0,K.useMemo)(()=>Yt(e,t),[e,t]),r=rt(n?{ref:n.ref,child:n.child,limit:200}:null,n!==null);return{lookup:n,options:(0,K.useMemo)(()=>Xt(r.data?.rows??[],n),[r.data?.rows,n]),isLoading:r.isFetching}}function Hn(e,t){return!t||e.some(e=>e.value===t)?e:[{value:t,label:t},...e]}function Un(e,t,n){let r=e;return t!==void 0&&r<t&&(r=t),n!==void 0&&r>n&&(r=n),r}function X({title:e,meta:t,ruled:n=!0}){return(0,q.jsxs)(`div`,{className:o(`flex items-baseline justify-between gap-2`,n&&`border-b border-border/60 pb-1.5`),children:[(0,q.jsx)(`h3`,{className:I,children:e}),t?(0,q.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:t}):null]})}function Wn({method:e,className:t}){return(0,q.jsx)(Ce,{variant:`outline`,className:o(`h-5 px-1.5 font-mono text-[10px] uppercase`,ue(e),t),"data-slot":`http-method-badge`,children:e})}var Gn=[`once`,`broadcast`,`live`],Kn={once:{delivery:`once`,icon:Ot,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:Dt,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 qn({delivery:e,className:t}){let n=Kn[e];return(0,q.jsx)(Ce,{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 Jn({effects:e}){let t=Yn(e);return t.length===0?null:(0,q.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`effects-summary`,"aria-label":`Effects`,children:[(0,q.jsx)(X,{title:`Effects`,meta:String(t.length)}),(0,q.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>{let t=Ue(e.kind),n=Le(e.kind,e.ref),r=e.kind===`call`?Ie(e.ref):null;return(0,q.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??`${He[e.kind]} ${e.ref}`,children:[(0,q.jsx)(i,{icon:n,className:`size-3`}),r?(0,q.jsx)(`span`,{className:`text-foreground/90`,children:r}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:He[e.kind]}),(0,q.jsx)(`span`,{className:`text-foreground/90`,children:e.ref})]})]},`${e.kind}:${e.ref}`)})})]})}function Yn(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 Xn({errors:e}){let t=Zn(e);return t.length===0?null:(0,q.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`errors-section`,"aria-label":`Flow errors`,children:[(0,q.jsx)(X,{title:`Flow errors`,meta:String(t.length)}),(0,q.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>{let t=(e.schema?Y(e.schema):[]).map(e=>e.name).join(`, `);return(0,q.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,q.jsx)(i,{icon:De,className:`size-3`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`text-foreground/90`,children:e.code}),t?(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:t}):null]},e.code)})})]})}function Zn(e){return e?Array.isArray(e)?e.map(e=>({code:e,schema:null})):Object.entries(e).map(([e,t])=>({code:e,schema:Jt(t)})):[]}var Qn=36e5;function $n(e,t,n,r=Qn){let i=Ct(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 er({flowId:e,runs:t,nowMs:n=Date.now(),windowMs:r=Qn,children:i}){let a=$n(t??[],e,n,r);return(0,q.jsxs)(`div`,{className:o(F,`px-2`),"data-slot":`flow-activity-strip`,"data-kind":a.kind,"aria-label":`Recent activity`,children:[(0,q.jsx)(`span`,{className:o(I,`flex items-center`),children:`Activity`}),(0,q.jsx)(tr,{summary:a,nowMs:n}),i?(0,q.jsx)(`div`,{className:`ml-auto flex h-full items-stretch`,children:i}):null]})}function tr({summary:e,nowMs:t}){if(e.kind===`empty`)return(0,q.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=nr(e.lastStartedAt,t);return(0,q.jsxs)(`p`,{className:`flex min-w-0 items-center gap-x-2 text-[11px] text-foreground/85`,children:[(0,q.jsxs)(`span`,{className:`tabular-nums`,"data-slot":`flow-activity-calls`,children:[e.calls,` call`,e.calls===1?``:`s`]}),(0,q.jsx)(`span`,{className:`text-muted-foreground`,"aria-hidden":!0,children:`·`}),(0,q.jsxs)(`span`,{className:`tabular-nums`,"data-slot":`flow-activity-errors`,children:[n,`% errors`]}),(0,q.jsx)(`span`,{className:`text-muted-foreground`,"aria-hidden":!0,children:`·`}),(0,q.jsx)(`span`,{className:`text-muted-foreground`,"data-slot":`flow-activity-ago`,children:r}),(0,q.jsx)(ht,{to:`/overview`,search:{run:e.latestRunId},className:o(h,R),"data-slot":`flow-activity-open-run`,children:`Open latest`})]})}function nr(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 rr(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 ir({fields:e,emptyLabel:t=`No schema fields declared.`,layout:n=`list`}){return e.length===0?(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-slot":`schema-fields-empty`,children:t}):n===`grid`?(0,q.jsx)(`div`,{"data-slot":`schema-fields`,"data-layout":`grid`,children:(0,q.jsx)(xt,{columns:3,children:e.map(e=>(0,q.jsx)(ar,{field:e,depth:0,cell:!0},e.path))})}):(0,q.jsx)(`ul`,{className:`flex flex-col`,"data-slot":`schema-fields`,children:e.map(e=>(0,q.jsx)(ar,{field:e,depth:0},e.path))})}function ar({field:e,depth:t,cell:n=!1}){let r=e.type===`enum`&&e.enumValues,i=Vt(e);return(0,q.jsxs)(n?`div`:`li`,{className:n?`min-w-0 border-b border-border/50`:void 0,children:[(0,q.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,q.jsx)(`span`,{className:`shrink-0`,"data-slot":`schema-field-keys`,title:or(e),children:(0,q.jsx)(ie,{primaryKey:e.primaryKey,foreignKey:e.foreignKey,unique:e.unique,empty:`none`})}),(0,q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] font-medium text-foreground/90`,children:e.name}),e.required?null:(0,q.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,q.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,q.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,q.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,q.jsx)(`span`,{className:o(`ml-auto shrink-0 rounded border px-1.5 py-px font-mono text-[9px] font-medium tracking-wide`,rr(e.type)),"data-slot":`schema-field-type`,title:r?e.enumValues?.join(` | `):e.type,children:e.type})]}),e.children?.map(e=>(0,q.jsx)(ar,{field:e,depth:t+1,cell:n},e.path))]})}function or(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 sr({fields:e}){let t=Ut(e);return t.length===0?null:(0,q.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`validation-section`,"aria-label":`Validation`,children:[(0,q.jsx)(X,{title:`Validation`,meta:String(t.length)}),(0,q.jsx)(`ul`,{className:`flex flex-col gap-3`,children:t.map(e=>(0,q.jsx)(cr,{field:e},e.path))})]})}function cr({field:e}){let t=Ht(e),n=e.valueMeanings?.length?e.valueMeanings:e.enumValues?.map(e=>({value:e,label:e}));return(0,q.jsxs)(`li`,{className:`flex flex-col gap-1.5`,"data-slot":`validation-field`,"data-field":e.name,children:[(0,q.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,q.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-foreground/90`,children:e.name}),t?(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t}):null]}),n&&n.length>0?(0,q.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,q.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5 font-mono text-[11px]`,"data-slot":`validation-option`,children:[(0,q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.value}),(0,q.jsx)(`span`,{className:`truncate text-foreground/90`,children:e.label})]},e.value))}):null]})}function lr({row:e,manifest:t,runs:n,leading:r}){let a=z(e.flow.trigger),s=Ve(e.flow.trigger),c=We(t,e.id,a===`http`?`http`:a===`internal`?`internal`:a),l=Jt(e.flow.in),u=Jt(e.flow.out),d=Ge(e.flow.gates??[],t),f=a===`signal`&&e.flow.trigger?.signal?t?.signals?.[e.flow.trigger.signal]:void 0,p=a===`cron`||a===`every`?mn(t,e.id):null,m=a===`internal`?wt(t,e.id):[],g=a===`http`?`Request`:`Input`,_=a===`http`?`Response`:`Output`,v=a!==`cron`&&a!==`every`,y=Y(l),b=Y(u),x=Mt(y,a===`http`&&e.path?ln(e.path):[]);return(0,q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`flow-contract-panel`,"data-trigger":a,children:[(0,q.jsx)(bt,{dataSlot:`endpoint-header`,leading:r,icon:(0,q.jsx)(`span`,{"data-slot":`trigger-kind-icon`,"data-kind":a,children:(0,q.jsx)(i,{icon:s.icon,className:`size-4`})}),wellClassName:s.wellClass,title:(0,q.jsx)(`span`,{className:`font-mono`,children:e.id}),badge:(0,q.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,q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,"data-slot":`http-endpoint-line`,children:[(0,q.jsx)(Wn,{method:c.method}),(0,q.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,q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,"data-slot":`signal-endpoint-line`,children:[(0,q.jsx)(qn,{delivery:f.delivery}),(0,q.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[11px] leading-none text-muted-foreground select-all`,children:e.flow.trigger?.signal})]}):(0,q.jsx)(`span`,{className:`truncate font-mono text-[11px] leading-none text-muted-foreground`,"data-slot":`trigger-headline`,children:c.headline}),actions:(0,q.jsxs)(ht,{to:`/overview`,search:{flow:e.id},"data-slot":`open-in-graph`,className:o(h,`text-sky-700 dark:text-sky-400`),children:[(0,q.jsx)(i,{icon:xe.flow.icon,className:`size-3.5`,"aria-hidden":!0}),`Open in graph`]})}),(0,q.jsxs)(er,{flowId:e.id,runs:n,children:[e.flow.plane?(0,q.jsx)(ur,{plane:e.flow.plane}):null,e.flow.durable?(0,q.jsx)(dr,{icon:Fe,label:`durable`,title:`Durable — long-running, retryable steps`}):null,e.flow.idempotency&&e.flow.idempotency.mode!==`off`?(0,q.jsx)(dr,{icon:ge,label:e.flow.idempotency.mode===`required`?`idempotency required`:`idempotency`,title:`Idempotency ${e.flow.idempotency.mode} — stored responses expire after ${e.flow.idempotency.ttl}`}):null,e.flow.live?(0,q.jsx)(dr,{icon:me,label:`live`,title:typeof e.flow.live==`string`?`Live — SSE for ${e.flow.live}`:`Live — SSE signal feed`}):null]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsx)(Jn,{effects:e.flow.effects}),(0,q.jsx)(Be,{gates:d}),(0,q.jsx)(Xn,{errors:e.flow.errors}),a===`signal`&&f&&(f.retries!==void 0||f.deadLetter)?(0,q.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,q.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`clock-join`,children:[`Clock · `,(0,q.jsx)(`span`,{className:`font-mono`,children:p.clockName}),p.timezone?` · ${p.timezone}`:``]}):null,a===`internal`?(0,q.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`call-only-note`,children:[`No external trigger — reachable via `,(0,q.jsx)(`code`,{className:`font-mono`,children:`effects.calls`}),` /`,` `,(0,q.jsx)(`code`,{className:`font-mono`,children:`fx.call`}),`.`]}):null,a===`internal`?(0,q.jsxs)(`section`,{className:`flex flex-col gap-1.5`,"aria-label":`Callers`,"data-slot":`callers-list`,children:[(0,q.jsx)(X,{title:`Called by`,meta:String(m.length)}),m.length===0?(0,q.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`No Manifest caller declares `,(0,q.jsx)(`code`,{className:`font-mono`,children:`effects.calls`}),` for this flow.`]}):(0,q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:m.map(e=>(0,q.jsx)(`li`,{className:`font-mono text-xs text-foreground/90`,children:e},e))})]}):null,v&&x.parameters.length>0?(0,q.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`Parameters`,"data-slot":`parameters`,children:[(0,q.jsx)(X,{title:`Parameters`,meta:String(x.parameters.length)}),(0,q.jsx)(ir,{fields:x.parameters,layout:`grid`})]}):null,(0,q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[v&&(x.fields.length>0||x.parameters.length===0)?(0,q.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":g,"data-slot":`request`,children:[(0,q.jsx)(X,{title:g,meta:String(x.fields.length)}),(0,q.jsx)(ir,{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,q.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":_,children:[(0,q.jsx)(X,{title:_,meta:String(b.length)}),(0,q.jsx)(ir,{fields:b,emptyLabel:typeof e.flow.out==`string`?`Schema not expanded in Manifest.`:`No output schema declared.`})]})]}),v?(0,q.jsx)(sr,{fields:y}):null]})})]})}function ur({plane:e}){let t=e===`operator`,n=t?ge:qe,r=t?`operator`:`user`;return(0,q.jsxs)(s,{children:[(0,q.jsx)(u,{render:t=>(0,q.jsxs)(`span`,{...t,className:o(h,`cursor-help`),"data-slot":`plane-badge`,"data-plane":e,children:[(0,q.jsx)(i,{icon:n,className:`size-3`,"aria-hidden":!0}),r]})}),(0,q.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 dr({icon:e,label:t,title:n}){return(0,q.jsxs)(s,{children:[(0,q.jsx)(u,{render:n=>(0,q.jsxs)(`span`,{...n,className:o(h,R,`cursor-help`),children:[(0,q.jsx)(i,{icon:e,className:`size-3`,"aria-hidden":!0}),t]})}),(0,q.jsx)(c,{side:`bottom`,className:`max-w-xs text-[11px]`,children:n})]})}function fr(e){let t=new Map(Re.map(e=>[e,[]]));for(let n of e){let e=new Map;for(let t of n.flows){let n=z(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 Re.flatMap(e=>{let n=t.get(e)??[];return n.length===0?[]:[{id:e,label:ze[e].label,groups:n}]})}function pr(e){return`band:${e}`}function Z(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(pr(n.id));for(let e of n.groups)t.push(Z(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[pr(n.id),Z(n.id,e.unit)];return[]}function _r(e,t){let n=se(e.method)-se(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=St(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(z(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:qe,label:`user`},operator:{icon:ge,label:`operator`}},Cr=[`user`,`operator`];function wr({groups:e,selectedFlowId:t,onSelect:n}){let[a,l]=(0,K.useState)(``),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)({}),[h,_]=(0,K.useState)({}),v=(0,K.useMemo)(()=>{let t=new Set;for(let n of e)for(let e of n.flows)t.add(z(e.flow.trigger));return Re.filter(e=>t.has(e))},[e]),y=(0,K.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,K.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:Gn.filter(e=>r.has(e))}},[e]),C=br(p),w=(0,K.useMemo)(()=>fr(xr(yr(e,a),p)),[e,a,p]),T=(0,K.useMemo)(()=>hr(w),[w]),E=a.trim().length>0,D=T.length>0&&T.every(e=>mr(e,h,E));(0,K.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,q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`units-tree`,children:[(0,q.jsxs)(`div`,{className:`shrink-0 border-b border-border/60`,children:[(0,q.jsxs)(`div`,{className:o(r,`border-b-0`),children:[(0,q.jsx)(pe,{value:a,onChange:e=>l(e.target.value),placeholder:`Search flows…`,"aria-label":`Search flows`,"data-slot":`units-search`}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-stretch pr-0.5`,children:[(0,q.jsxs)(s,{children:[(0,q.jsx)(u,{render:e=>(0,q.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,q.jsx)(i,{icon:Je,className:`size-3`,"aria-hidden":!0}),C>0?(0,q.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,q.jsx)(c,{side:`bottom`,children:`Advanced`})]}),(0,q.jsx)(ct,{allOpen:D,disabled:T.length===0,onToggle:k,dataSlot:`units-tree-expand-toggle`})]})]}),d?(0,q.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,q.jsx)(Q,{label:`Trigger`,groupLabel:`Trigger kind filter`,children:v.map(e=>{let t=ze[e];return(0,q.jsx)($,{icon:t.icon,label:t.label,pressed:p.triggerKinds?.includes(e)??!1,onToggle:()=>A(e),dataFacet:`kind:${e}`},e)})}),S.length>0?(0,q.jsx)(Q,{label:`Delivery`,groupLabel:`Signal delivery filter`,children:S.map(e=>{let t=Kn[e];return(0,q.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,q.jsx)(Q,{label:`Plane`,groupLabel:`Plane filter`,children:y.map(e=>{let t=Sr[e];return(0,q.jsx)($,{icon:t.icon,label:t.label,pressed:p.planes?.includes(e)??!1,onToggle:()=>j(e),dataFacet:`plane:${e}`},e)})}):null,b||x?(0,q.jsxs)(Q,{label:`Flags`,groupLabel:`Flow flags filter`,children:[b?(0,q.jsx)($,{icon:Fe,label:`durable`,pressed:p.durableOnly??!1,onToggle:()=>M(`durableOnly`),dataFacet:`flag:durable`}):null,x?(0,q.jsx)($,{icon:me,label:`live`,pressed:p.liveOnly??!1,onToggle:()=>M(`liveOnly`),dataFacet:`flag:live`}):null]}):null,C>0?(0,q.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,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto`,children:w.length===0?(0,q.jsx)(`p`,{className:P,children:`No flows match.`}):(0,q.jsx)(`div`,{className:`flex flex-col`,children:w.map(e=>{let r=pr(e.id);return(0,q.jsx)(Er,{band:e,open:mr(r,h,E),onOpenChange:e=>O(r,e),groupOpen:t=>mr(Z(e.id,t),h,E),onGroupOpenChange:(t,n)=>O(Z(e.id,t),n),selectedFlowId:t,onSelect:n},e.id)})})})]})}function Q({label:e,groupLabel:t,children:n}){return(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`w-14 shrink-0 text-[9px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:e}),(0,q.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,q.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,q.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=ze[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,q.jsx)(`section`,{"data-slot":`units-trigger-band`,"data-band":e.id,"aria-label":e.label,className:M,children:(0,q.jsxs)(Oe,{open:t,onOpenChange:n,children:[(0,q.jsx)(Ee,{nativeButton:!1,className:E,"data-slot":`units-trigger-band-toggle`,render:n=>(0,q.jsxs)(`div`,{...n,children:[(0,q.jsx)(i,{icon:Te,className:o(x,!t&&`-rotate-90`),"aria-hidden":!0}),(0,q.jsx)(i,{icon:l.icon,className:o(w,d(l.wellClass)),"aria-hidden":!0}),(0,q.jsx)(`span`,{className:o(A,`flex-1`),children:e.label}),(0,q.jsx)(`span`,{className:m,children:u}),(0,q.jsx)(`span`,{className:v,children:(0,q.jsx)(ct,{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,q.jsx)(we,{children:(0,q.jsx)(`ul`,{className:`flex flex-col`,children:e.groups.map(t=>(0,q.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,q.jsx)(`li`,{"data-slot":`unit-group`,"data-unit":e.unit,children:(0,q.jsxs)(Oe,{open:t,onOpenChange:n,children:[(0,q.jsxs)(Ee,{className:o(O,`pl-4`),children:[(0,q.jsx)(i,{icon:Te,className:o(x,!t&&`-rotate-90`),"aria-hidden":!0}),(0,q.jsx)(i,{icon:ut,className:o(w,`text-muted-foreground`),"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.unit}),(0,q.jsx)(`span`,{className:m,children:e.flows.length})]}),(0,q.jsx)(we,{children:(0,q.jsx)(`ul`,{className:`flex flex-col`,children:e.flows.map(e=>(0,q.jsx)(Or,{flow:e,selected:r===e.id,onSelect:a},e.id))})})]})})}function Or({flow:e,selected:t,onSelect:n}){let r=Ve(e.flow.trigger),a=e.delivery?Kn[e.delivery]:null,l=a?.icon??(e.method?le(e.method):r.icon),f=d(a?.wellClass??(e.method?ue(e.method):r.wellClass)),p=a?e.signal?`${a.title} · ${e.signal}`:a.title:r.detail?`${r.label} · ${r.detail}`:r.label;return(0,q.jsx)(`li`,{children:(0,q.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,q.jsx)(`span`,{"aria-hidden":!0,className:o(k,t?y:`bg-transparent`)}),(0,q.jsxs)(s,{children:[(0,q.jsx)(u,{render:e=>(0,q.jsx)(`span`,{...e,className:o(w,f),"aria-hidden":!0,children:(0,q.jsx)(i,{icon:l,className:`size-3.5`})})}),(0,q.jsx)(c,{side:`right`,className:`text-[11px]`,children:p})]}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.action}),e.method?(0,q.jsx)(Wn,{method:e.method,className:`ml-auto h-3.5 px-1 text-[8px] leading-none`}):null]})})}function kr(){let e=Ae(),t=Ne();ke(!0);let{selectedFlowId:n,setSelectedFlow:r}=gt(),i=_e(),a=(0,K.useMemo)(()=>vr(e.data??null),[e.data]),o=(0,q.jsx)(ve,{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,K.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,q.jsx)(`div`,{className:_,"data-slot":`units-page`,children:(0,q.jsxs)(de,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,q.jsx)(he,{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,q.jsx)(`div`,{id:`flows-tree`,className:`h-full min-h-0 overflow-hidden`,"data-slot":`flows-tree`,children:(0,q.jsx)(wr,{groups:a,selectedFlowId:s,onSelect:e=>{r(e)}})})}),i.open?(0,q.jsx)(ye,{withHandle:!0}):null,(0,q.jsx)(he,{defaultSize:f.end.defaultSize,minSize:f.end.minSize,className:`min-h-0 overflow-hidden`,children:(0,q.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:c?(0,q.jsxs)(de,{orientation:`vertical`,className:`min-h-0 flex-1`,"data-slot":`units-inspector`,children:[(0,q.jsx)(he,{defaultSize:`56%`,minSize:`28%`,className:`min-h-0 overflow-hidden`,children:(0,q.jsx)(lr,{row:c,manifest:e.data??null,runs:t.data,leading:o})}),(0,q.jsx)(ye,{withHandle:!0}),(0,q.jsx)(he,{defaultSize:`44%`,minSize:`220px`,className:`min-h-0 overflow-hidden`,children:(0,q.jsx)(En,{row:c,manifest:e.data??null})})]}):(0,q.jsx)(vt,{icon:xe.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};
@@ -1 +1 @@
1
- import{Si as e,Yi as t}from"./shortcut-keys-3ILd8oGn.js";var n={vault:`okengine's own store — encrypted at rest, sealed until unsealed with the master key`,env:`No remote store — values come from process.env and .env.local`,managed:`Managed KMS / provider secret store`,memory:`In-memory bag — test only, nothing survives restart`},r={"aws-secrets-manager":`AWS Secrets Manager`,"azure-key-vault":`Azure Key Vault`,"gcp-secret-manager":`GCP Secret Manager`,doppler:`Doppler`,"1password":`1Password`},i={"aws-secrets-manager":`aws`,"azure-key-vault":`azure`,"gcp-secret-manager":`gcp`,doppler:`doppler`,"1password":`1password`};function a(e){return`driver`}function o(e){if(!e)return`Vault backend`;switch(e.driverId){case`vault`:return`Built-in vault`;case`managed`:{let t=e.provider?.trim()??``;return t.length===0?`Managed vault`:r[t]??`Managed · ${t}`}case`memory`:return`Memory bag`;case`env`:return`Simulated env`}}function s(e){if(!e)return`unknown`;switch(e.driverId){case`vault`:return`built-in`;case`managed`:{let t=e.provider?.trim()??``,n=i[t];return n===void 0?t.length>0?`managed · ${t.length>8?t.slice(0,8):t}`:`managed`:`managed · ${n}`}case`memory`:return`memory`;case`env`:return`simulate`}}function c(e){if(!e)return`Set drivers.vault to built-in vault or a managed provider`;switch(e.driverId){case`vault`:return`Built-in vault — encrypted at rest, sealed until unsealed with the master key`;case`managed`:{let t=e.provider?.trim()??``,n=r[t];return n===void 0?t.length>0?`Managed provider — ${t}`:`Managed provider — platform-injected secrets (no remote provider id)`:`Managed provider — ${n}`}case`memory`:return`In-memory driver — test only, nothing survives restart`;case`env`:return`No built-in vault or managed provider — values come from process.env and .env.local`;default:return n[e.driverId]??`Custom vault backend`}}function l(e){if(!e)return null;let t=o(e),n=c(e);if(!e.builtin)return{title:t,description:n,badges:[],facts:[],hint:null};let r=e.status;if(!r)return{title:t,description:n,badges:[{id:`unreachable`,label:`status unavailable`,tone:`warn`}],facts:[],hint:e.unavailable??"Run `oke vault status` to inspect the backend directly"};if(!r.initialized)return{title:t,description:n,badges:[{id:`uninitialized`,label:`not initialized`,tone:`warn`}],facts:[],hint:"Run `oke vault init` to create the vault and print its master key once"};let i=[{id:`initialized`,label:`initialized`,tone:`ok`},r.sealed?{id:`sealed`,label:`sealed`,tone:`warn`}:{id:`unsealed`,label:`unsealed`,tone:`ok`}];r.rewrapTargetKekVersion!==null&&i.push({id:`rewrap`,label:`rewrap → kek v${r.rewrapTargetKekVersion}`,tone:`warn`});let a=[{label:`KEK generation`,value:`v${r.kekVersion}`},{label:`Secrets stored`,value:String(r.secretCount)},{label:`Seal count`,value:String(r.sealCount)}];return r.lastUnsealedAt!==null&&a.push({label:`Last unsealed`,value:new Date(r.lastUnsealedAt).toISOString()}),r.lastSealedAt!==null&&a.push({label:`Last sealed`,value:new Date(r.lastSealedAt).toISOString()}),{title:t,description:n,badges:i,facts:a,hint:r.sealed?"This process holds no master key — export OKE_VAULT_MASTER_KEY or run `oke vault unseal`":null}}var u=[`console.vault.list`];function d(){return t({queryKey:u,queryFn:async()=>{let t=await e();if(t.error)throw Error(t.error.code);if(!t.data)throw Error(`Empty vault list`);return t.data},refetchInterval:1e4})}export{s as a,c as i,d as n,a as o,l as r,o as s,u as t};
1
+ import{Si as e,Zi as t}from"./shortcut-keys-CUNegEV4.js";var n={vault:`okengine's own store — encrypted at rest, sealed until unsealed with the master key`,env:`No remote store — values come from process.env and .env.local`,managed:`Managed KMS / provider secret store`,memory:`In-memory bag — test only, nothing survives restart`},r={"aws-secrets-manager":`AWS Secrets Manager`,"azure-key-vault":`Azure Key Vault`,"gcp-secret-manager":`GCP Secret Manager`,doppler:`Doppler`,"1password":`1Password`},i={"aws-secrets-manager":`aws`,"azure-key-vault":`azure`,"gcp-secret-manager":`gcp`,doppler:`doppler`,"1password":`1password`};function a(e){return`driver`}function o(e){if(!e)return`Vault backend`;switch(e.driverId){case`vault`:return`Built-in vault`;case`managed`:{let t=e.provider?.trim()??``;return t.length===0?`Managed vault`:r[t]??`Managed · ${t}`}case`memory`:return`Memory bag`;case`env`:return`Simulated env`}}function s(e){if(!e)return`unknown`;switch(e.driverId){case`vault`:return`built-in`;case`managed`:{let t=e.provider?.trim()??``,n=i[t];return n===void 0?t.length>0?`managed · ${t.length>8?t.slice(0,8):t}`:`managed`:`managed · ${n}`}case`memory`:return`memory`;case`env`:return`simulate`}}function c(e){if(!e)return`Set drivers.vault to built-in vault or a managed provider`;switch(e.driverId){case`vault`:return`Built-in vault — encrypted at rest, sealed until unsealed with the master key`;case`managed`:{let t=e.provider?.trim()??``,n=r[t];return n===void 0?t.length>0?`Managed provider — ${t}`:`Managed provider — platform-injected secrets (no remote provider id)`:`Managed provider — ${n}`}case`memory`:return`In-memory driver — test only, nothing survives restart`;case`env`:return`No built-in vault or managed provider — values come from process.env and .env.local`;default:return n[e.driverId]??`Custom vault backend`}}function l(e){if(!e)return null;let t=o(e),n=c(e);if(!e.builtin)return{title:t,description:n,badges:[],facts:[],hint:null};let r=e.status;if(!r)return{title:t,description:n,badges:[{id:`unreachable`,label:`status unavailable`,tone:`warn`}],facts:[],hint:e.unavailable??"Run `oke vault status` to inspect the backend directly"};if(!r.initialized)return{title:t,description:n,badges:[{id:`uninitialized`,label:`not initialized`,tone:`warn`}],facts:[],hint:"Run `oke vault init` to create the vault and print its master key once"};let i=[{id:`initialized`,label:`initialized`,tone:`ok`},r.sealed?{id:`sealed`,label:`sealed`,tone:`warn`}:{id:`unsealed`,label:`unsealed`,tone:`ok`}];r.rewrapTargetKekVersion!==null&&i.push({id:`rewrap`,label:`rewrap → kek v${r.rewrapTargetKekVersion}`,tone:`warn`});let a=[{label:`KEK generation`,value:`v${r.kekVersion}`},{label:`Secrets stored`,value:String(r.secretCount)},{label:`Seal count`,value:String(r.sealCount)}];return r.lastUnsealedAt!==null&&a.push({label:`Last unsealed`,value:new Date(r.lastUnsealedAt).toISOString()}),r.lastSealedAt!==null&&a.push({label:`Last sealed`,value:new Date(r.lastSealedAt).toISOString()}),{title:t,description:n,badges:i,facts:a,hint:r.sealed?"This process holds no master key — export OKE_VAULT_MASTER_KEY or run `oke vault unseal`":null}}var u=[`console.vault.list`];function d(){return t({queryKey:u,queryFn:async()=>{let t=await e();if(t.error)throw Error(t.error.code);if(!t.data)throw Error(`Empty vault list`);return t.data},refetchInterval:1e4})}export{s as a,c as i,d as n,a as o,l as r,o as s,u as t};