okengine 0.23.1 → 0.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/site/content/docs/ai/mcp.mdx +3 -3
- package/site/content/docs/elements/signal/broadcast.mdx +4 -2
- package/site/content/docs/reference/configuration.mdx +16 -0
- package/site/content/docs/reference/errors.mdx +31 -19
- package/src/compiler/aot.test.ts +3 -2
- package/src/compiler/aot.ts +45 -1
- package/src/compiler/dynamic.ts +1 -1
- package/src/compiler/http-parse.test.ts +101 -0
- package/src/compiler/http-parse.ts +188 -9
- package/src/compiler/interpret.ts +25 -2
- package/src/console/ui-next/dist/assets/{access-page-C_N4qvai.js → access-page-zBMhZnFm.js} +1 -1
- package/src/console/ui-next/dist/assets/{agent-disclosure-Cq1TxniW.js → agent-disclosure-CBj9f7Ju.js} +1 -1
- package/src/console/ui-next/dist/assets/{cache-glyph-BaI4uxZz.js → cache-glyph-D3MY49h3.js} +1 -1
- package/src/console/ui-next/dist/assets/{call-pii-button-DNyK7IIY.js → call-pii-button-L9JxdBhp.js} +1 -1
- package/src/console/ui-next/dist/assets/{collapsible-CRhBJMZR.js → collapsible-BvFaX-Zt.js} +1 -1
- package/src/console/ui-next/dist/assets/{decisions-page-D9twj8Xy.js → decisions-page-DgB76m-X.js} +1 -1
- package/src/console/ui-next/dist/assets/{duration-tone-CsHWlVPU.js → duration-tone-l1DSJ2Vz.js} +1 -1
- package/src/console/ui-next/dist/assets/{flows-page-ZaTJAhR9.js → flows-page-Bb9t1lu6.js} +1 -1
- package/src/console/ui-next/dist/assets/{highlighted-json-DQ-EMAfz.js → highlighted-json-DMvsi3Ti.js} +1 -1
- package/src/console/ui-next/dist/assets/{http-method-Cn_Fl79s.js → http-method-BwhJBTcQ.js} +1 -1
- package/src/console/ui-next/dist/assets/{index-CmRFeWdT.js → index-RhV2jT_7.js} +3 -3
- package/src/console/ui-next/dist/assets/{observability-page-Cn6R_dXz.js → observability-page-BRfUILBq.js} +1 -1
- package/src/console/ui-next/dist/assets/{replica-lag-Bx6EZhSe.js → replica-lag-BsceAzIG.js} +1 -1
- package/src/console/ui-next/dist/assets/{request-meta-DmdiUrfh.js → request-meta-C6lTyCXp.js} +1 -1
- package/src/console/ui-next/dist/assets/{store-page-8P6vGXnn.js → store-page-YmE806bJ.js} +1 -1
- package/src/console/ui-next/dist/assets/{trace-detail-sheet-BfGvpFSv.js → trace-detail-sheet-Di4irS49.js} +1 -1
- package/src/console/ui-next/dist/assets/{tree-expand-toggle-CWdUHbc0.js → tree-expand-toggle-DYeL6Rye.js} +1 -1
- package/src/console/ui-next/dist/assets/{units-page-CZOFZzay.js → units-page-07agasRA.js} +1 -1
- package/src/console/ui-next/dist/assets/{vault-page-ki_ishmX.js → vault-page-CHBck4n_.js} +1 -1
- package/src/console/ui-next/dist/index.html +1 -1
- package/src/console/ui-next/seed-parked-approval.ts +5 -1
- package/src/drivers/journal-postgres.test.ts +84 -1
- package/src/drivers/journal-postgres.ts +282 -32
- package/src/drivers/postgres.test.ts +60 -0
- package/src/drivers/postgres.ts +79 -5
- package/src/drivers/signal-compete.test.ts +6 -2
- package/src/drivers/signal-postgres.test.ts +170 -0
- package/src/drivers/signal-postgres.ts +449 -196
- package/src/drivers/signal-redis.test.ts +224 -0
- package/src/drivers/signal-redis.ts +835 -150
- package/src/elements/ai/approval.test.ts +15 -3
- package/src/elements/ai/approval.ts +15 -9
- package/src/elements/channel/runtime.ts +31 -4
- package/src/elements/channel/sql-ledger.test.ts +404 -0
- package/src/elements/channel/sql-ledger.ts +177 -33
- package/src/elements/clock/chaos-child.ts +12 -2
- package/src/elements/clock/durable.ts +11 -0
- package/src/elements/store/cache-bus.test.ts +121 -0
- package/src/elements/store/cache-bus.ts +278 -0
- package/src/elements/store/cache.test.ts +59 -0
- package/src/elements/store/cache.ts +157 -12
- package/src/elements/store/runtime.ts +44 -2
- package/src/elements/store/sql-errors.test.ts +131 -0
- package/src/elements/store/sql-errors.ts +39 -16
- package/src/elements/store/sql-nested-tx.test.ts +344 -0
- package/src/elements/store/sql-session.ts +183 -3
- package/src/kernel/app.ts +176 -28
- package/src/kernel/auto-registry.test.ts +5 -1
- package/src/kernel/boot-bind/signal.ts +13 -2
- package/src/kernel/boot-bind/store.ts +16 -1
- package/src/kernel/boot.test.ts +2 -2
- package/src/kernel/boot.ts +41 -11
- package/src/kernel/boundary-contract.ts +7 -0
- package/src/kernel/builtin-errors.ts +2 -0
- package/src/kernel/call.test.ts +1 -0
- package/src/kernel/fx-sql-handle.ts +7 -1
- package/src/kernel/horizontal-child.ts +54 -1
- package/src/kernel/horizontal.integration.test.ts +131 -7
- package/src/kernel/idempotency.test.ts +5 -6
- package/src/kernel/journal-boot.test.ts +83 -6
- package/src/kernel/journal.test.ts +44 -0
- package/src/kernel/journal.ts +171 -26
- package/src/mcp/authorization.ts +5 -11
- package/src/mcp/confirmation.ts +203 -38
- package/src/mcp/docs-server.ts +7 -2
- package/src/mcp/index.ts +4 -0
- package/src/mcp/mcp.test.ts +321 -33
- package/src/mcp/server.ts +8 -3
- package/src/mcp/session.ts +7 -0
- package/src/mcp/tools.ts +68 -19
- package/src/runtime/bun.ts +5 -0
- package/src/runtime/types.ts +5 -0
|
@@ -1 +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{$n as r,E as i,F as a,I as o,Qn as s,R as c,a as l,er as u,i as d,l as f,o as p,s as m,tr as h,u as g,x as _}from"./shortcut-keys-DTE1sjTC.js";import{C as v,D as y,E as b,O as x,S,_ as C,a as w,b as T,c as E,d as D,f as O,g as k,h as A,i as j,l as M,m as N,o as P,p as F,r as I,s as L,w as R,x as z}from"./explorer-chrome-Dslh2yE8.js";import{c as ee,l as te,n as ne,o as re,r as ie,t as ae}from"./call-pii-button-DNyK7IIY.js";import{a as B,n as oe,r as se,t as ce}from"./http-method-Cn_Fl79s.js";import{a as V,b as le,c as ue,g as de,i as H,m as fe,n as pe,o as me,r as he,s as ge,t as _e}from"./element-icons-C6t8Vlml.js";import{a as ve,i as ye,n as be,o as xe,r as Se,s as Ce,t as we}from"./collapsible-CRhBJMZR.js";import{a as Te,c as Ee,f as De,i as Oe,s as ke,t as Ae,u as je}from"./highlighted-json-DQ-EMAfz.js";import{T as Me,c as Ne,d as Pe,f as Fe,h as Ie,l as Le,m as U,o as Re,p as ze,s as Be,t as Ve,u as He}from"./request-meta-DmdiUrfh.js";import{t as Ue}from"./UserIcon-DaE2PB5_.js";import{n as We}from"./dagre.esm-B1_XeuLP.js";import{$ as W,G as Ge,Q as G,X as K,Y as q,a as Ke,c as qe,d as Je,et as Ye,f as Xe,h as Ze,i as Qe,n as $e,nt as et,o as tt,p as nt,r as rt,s as it,t as at,u as ot,ut as st,v as ct}from"./tree-expand-toggle-CWdUHbc0.js";import{d as lt,r as ut,t as dt}from"./dropdown-menu-CRGrj5JU.js";import{Ot as ft,gt as pt,jt as mt}from"./index-CmRFeWdT.js";import{t as ht}from"./explorer-empty-CIVg7Jgb.js";import{c as J,n as gt,t as _t,u as vt}from"./detail-header-Dk5LipF6.js";import{c as yt,n as bt,s as xt,t as St}from"./cache-glyph-BaI4uxZz.js";var Ct=[[`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`}]],wt=[[`path`,{d:`M3 21L8 16`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M13.2585 18.8714C9.51516 18.0215 5.97844 14.4848 5.12853 10.7415C4.99399 10.1489 4.92672 9.85266 5.12161 9.37197C5.3165 8.89129 5.55457 8.74255 6.03071 8.44509C7.10705 7.77265 8.27254 7.55888 9.48209 7.66586C11.1793 7.81598 12.0279 7.89104 12.4512 7.67048C12.8746 7.44991 13.1622 6.93417 13.7376 5.90269L14.4664 4.59604C14.9465 3.73528 15.1866 3.3049 15.7513 3.10202C16.316 2.89913 16.6558 3.02199 17.3355 3.26771C18.9249 3.84236 20.1576 5.07505 20.7323 6.66449C20.978 7.34417 21.1009 7.68401 20.898 8.2487C20.6951 8.8134 20.2647 9.05346 19.4039 9.53358L18.0672 10.2792C17.0376 10.8534 16.5229 11.1406 16.3024 11.568C16.0819 11.9955 16.162 12.8256 16.3221 14.4859C16.4399 15.7068 16.2369 16.88 15.5555 17.9697C15.2577 18.4458 15.1088 18.6839 14.6283 18.8786C14.1477 19.0733 13.8513 19.006 13.2585 18.8714Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],Tt=[[`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`}]],Et=[[`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`}]],Y=e(t(),1),X=n();function Dt(e,t){let n=it(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 Ot(e){let t=it(e.asGate);return t===`operator`||t===`public`||!!(e.asUserId||e.asGate)}function kt({manifest:e,identities:t,value:n,onChange:i}){let a=Ge(!0),o=(0,Y.useMemo)(()=>Ze(ct(e),a.data??null),[e,a.data]),c=(0,Y.useMemo)(()=>qe(o),[o]),l=(0,Y.useMemo)(()=>ot(t,o),[t,o]),u=o.gates.find(e=>e.kind===`public`)?.description??`Intentionally unauthenticated.`,d=it(n.asGate),f=n.asGate!==null,[p,m]=(0,Y.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,v=c.length>0||l.length>0,y=e=>{if(e===`operator`){i({asGate:null,asUserId:null});return}if(e===`public`){i({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`),i({asGate:l[0].gate,asUserId:l[0].id});return}m(`policy`),i({asGate:t,asUserId:null})}};return(0,X.jsxs)(dt,{children:[(0,X.jsx)(lt,{render:e=>(0,X.jsxs)(_,{...e,type:`button`,variant:`ghost`,size:`sm`,className:s(`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,X.jsx)(r,{icon:_e.gate.icon,"data-icon":`inline-start`,className:`size-3.5`}),(0,X.jsx)(`span`,{className:`truncate`,children:Dt(n,t)})]})}),(0,X.jsxs)(ut,{align:`end`,className:`w-80 overflow-hidden p-0`,children:[(0,X.jsx)(tt,{children:`Invoke as`}),(0,X.jsxs)(Ke,{label:`Invoke as`,children:[(0,X.jsx)(rt,{mode:`operator`,title:`Operator`,caption:`Bypass`,selected:d===`operator`,onSelect:()=>y(`operator`)}),(0,X.jsx)(rt,{mode:`public`,title:`Public`,caption:`Anonymous`,selected:d===`public`,onSelect:()=>y(`public`)}),(0,X.jsx)(rt,{mode:`as`,title:`As`,caption:g?g.label:h?.label??`User / policy`,selected:d===`as`,disabled:!v,onSelect:()=>y(`as`)})]}),d===`operator`?(0,X.jsx)(Qe,{title:`Operator`,badge:`Default`,children:`Bypasses the flow's gate chain.`}):null,d===`public`?(0,X.jsxs)(Qe,{title:`Public`,children:[u,` Only `,(0,X.jsx)(`span`,{className:`font-mono`,children:`gate.public`}),` flows succeed.`]}):null,d===`as`?(0,X.jsx)($e,{tab:p,onTabChange:m,policies:c,users:l,asGate:n.asGate,asUserId:g?.id??null,onSelectPolicy:e=>{m(`policy`),i({asGate:e.id,asUserId:null})},onSelectUser:e=>{m(`user`),i({asGate:e.gate,asUserId:e.id})},hint:g?(0,X.jsxs)(`p`,{className:`border-t border-border/60 px-2 py-2 text-[10px] leading-relaxed text-muted-foreground`,children:[`Calls as `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:g.label}),` `,`via `,(0,X.jsx)(`span`,{className:`font-mono`,children:n.asGate}),`.`]}):h?(0,X.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,X.jsx)(`span`,{className:`font-mono`,children:h.id}),`.`]}):null}):null]})]})}var At=new Set([`q`,`query`,`search`,`limit`,`offset`,`cursor`,`page`,`pageSize`,`perPage`,`per_page`,`page_size`,`order`,`orderBy`,`order_by`,`sort`,`sortBy`,`sort_by`,`direction`]);function jt(e,t=[]){let n=new Set,r=[];for(let i of t){n.add(i);let t=e.find(e=>e.name===i);r.push(t??Mt(i))}let i=[];for(let t of e)n.has(t.name)||(At.has(t.name)?r.push(t):i.push(t));return{parameters:r,fields:i}}function Mt(e){return{path:`/path/${e}`,name:e,type:`string`,required:!0}}function Nt(e,t={}){let n=t.pathParams??[],r=new Set(n);if(t.http!==!0)return{path:[],query:[],body:e};let i=e.filter(e=>!r.has(e.name));return oe(t.method)?{path:n,query:[],body:i}:{path:n,query:i,body:[]}}function Pt(e,t){let n={};for(let r of t)Object.hasOwn(e,r.name)&&(n[r.name]=e[r.name]);return n}function Z(e,t=``){if(!e)return[];if(e.type===`object`||e.properties){let n=e.properties??{},r=new Set(Array.isArray(e.required)?e.required:[]);return Object.entries(n).map(([e,n])=>Ft(e,`${t}/${e}`,n,r.has(e)))}return[Ft(`value`,t||`/`,e,!0)]}function Ft(e,t,n,r){let i=It(e,n),a=typeof n.description==`string`?n.description:void 0;if(Array.isArray(n.enum)){let o=Ut(n);return{path:t,name:e,type:`enum`,required:r,enumValues:n.enum.map(String),...a===void 0?{}:{description:a},...o===void 0?{}:{valueMeanings:o},...i}}let o=n.type;if(o===`object`||n.properties)return{path:t,name:e,type:`object`,required:r,...a===void 0?{}:{description:a},...i,children:Z(n,t)};if(o===`array`)return{path:t,name:e,type:`array`,required:r,...a===void 0?{}:{description:a},...i,children:n.items?Z(n.items,`${t}/0`):void 0};let s=o===`integer`||o===`number`||o===`boolean`||o===`string`?o:`unknown`,c=Ut(n);return{path:t,name:e,type:s,required:r,minimum:typeof n.minimum==`number`?n.minimum:void 0,maximum:typeof n.maximum==`number`?n.maximum:void 0,...a===void 0?{}:{description:a},...c===void 0?{}:{valueMeanings:c},...i}}function It(e,t){let n=Lt(e),r=Rt(t.references),i=t.primaryKey===!0||n.primaryKey===!0,a=r!==void 0||n.foreignKey===!0,o=!i&&(t.unique===!0||n.unique===!0);return{...t.pii===!0?{pii:!0}:{},...t.sensitive===!0?{sensitive:!0}:{},...i?{primaryKey:!0}:{},...a?{foreignKey:!0}:{},...o?{unique:!0}:{},...r===void 0?{}:{references:r}}}function Lt(e){return e===`id`?{primaryKey:!0}:/(?:Id|_id)$/.test(e)||/(?:Key|_key)$/.test(e)&&e!==`key`?{foreignKey:!0}:e===`identifier`||e===`key`?{unique:!0}:{}}function Rt(e){if(!e||typeof e!=`object`)return;let t=`table`in e&&typeof e.table==`string`?e.table:void 0;if(!t)return;let n=`column`in e&&typeof e.column==`string`?e.column:void 0;return n===void 0?{table:t}:{table:t,column:n}}var zt=12;function Bt(e){return e.enumValues&&e.enumValues.length>0?e.enumValues.join(` · `):e.minimum!==void 0&&e.maximum!==void 0?`${e.minimum}–${e.maximum}`:e.minimum===void 0?e.maximum===void 0?null:`≤ ${e.maximum}`:`≥ ${e.minimum}`}function Vt(e){return e.minimum!==void 0&&e.maximum!==void 0?`Must be from ${e.minimum} up to ${e.maximum}.`:e.minimum===void 0?e.maximum===void 0?null:`Must be at most ${e.maximum}.`:`Must be at least ${e.minimum}.`}function Ht(e){return e.filter(e=>e.minimum!==void 0||e.maximum!==void 0||(e.enumValues?.length??0)>0||(e.valueMeanings?.length??0)>0)}function Ut(e){let t=Array.isArray(e.oneOf)?e.oneOf:Array.isArray(e.anyOf)?e.anyOf:null;if(t){let e=[];for(let n of t){if(!n||typeof n!=`object`)continue;let t=n;if(!(`const`in t))continue;let r=String(t.const),i=typeof t.title==`string`?t.title:typeof t.description==`string`?t.description:void 0;i&&e.push({value:r,label:i})}return e.length>0?e:void 0}}function Wt(e){if(e.type!==`integer`||e.minimum===void 0||e.maximum===void 0||!Number.isInteger(e.minimum)||!Number.isInteger(e.maximum))return null;let t=e.maximum-e.minimum;return t<0||t>zt?null:Array.from({length:t+1},(t,n)=>e.minimum+n)}function Gt(e){return e?Kt(e):{}}function Kt(e){if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];let t=e.type;if(t===`object`||!t&&e.properties){let t=e.properties??{},n=new Set(Array.isArray(e.required)?e.required:[]),r={};for(let[e,i]of Object.entries(t))(n.has(e)||`default`in i||Object.keys(t).length<=4)&&(r[e]=Kt(i));return r}if(t===`array`){let t=e.items;return t?[Kt(t)]:[]}return t===`integer`||t===`number`?typeof e.default==`number`?e.default:typeof e.minimum==`number`?e.minimum:1:t===`boolean`?!1:t===`string`?e.format===`email`?`user@example.com`:e.format===`uuid`?`00000000-0000-4000-8000-000000000001`:typeof e.default==`string`?e.default:e.minLength?`x`.repeat(Number(e.minLength)):``:null}function qt(e){return!e||typeof e==`string`?null:e}function Jt(e,t){if(!e.foreignKey||!t)return null;let n=Qt(t);if(n.length===0)return null;if(e.references?.table){let t=$t(n,e.references.table);return t?Xt(t,e.references.column??tn(t.table)??`id`):null}let r=Zt(e.name);if(!r)return null;let i=en(n,r.stem);return i?Xt(i,r.kind===`key`?nn(i.table,`key`)??tn(i.table)??`id`:tn(i.table)??`id`):null}function Yt(e,t){if(!t)return[];let n=new Set,r=[];for(let i of e){let e=i[t.column];if(e==null)continue;let a=String(e);if(n.has(a))continue;n.add(a);let o=t.labelColumn?i[t.labelColumn]:void 0,s=o!=null&&String(o)!==a?String(o):null;r.push({value:a,label:s?`${a} · ${s}`:a})}return r}function Xt(e,t){let n=rn(e.table,t);return{ref:e.ref,child:e.name,column:t,...n===void 0?{}:{labelColumn:n}}}function Zt(e){return e===`id`?null:e.endsWith(`Id`)?{stem:e.slice(0,-2),kind:`id`}:e.endsWith(`_id`)?{stem:e.slice(0,-3),kind:`id`}:e.endsWith(`Key`)?{stem:e.slice(0,-3),kind:`key`}:e.endsWith(`_key`)?{stem:e.slice(0,-4),kind:`key`}:null}function Qt(e){let t=[];for(let[n,r]of Object.entries(e.stores??{}))r.facet===`sql`&&r.tables&&t.push({ref:`sql:${n}`,tables:r.tables});return t}function $t(e,t){let n=t.toLowerCase();for(let t of e)for(let[e,r]of Object.entries(t.tables))if(e.toLowerCase()===n)return{ref:t.ref,name:e,table:r};return null}function en(e,t){let n=sn(t),r=[t,n,on(t),on(n)].map(e=>e.toLowerCase());for(let t of e)for(let[e,n]of Object.entries(t.tables))if(r.includes(e.toLowerCase()))return{ref:t.ref,name:e,table:n};return null}function tn(e){for(let[t,n]of Object.entries(e.columns??{}))if(an(n)&&n.primaryKey===!0)return t;if(e.columns&&`id`in e.columns)return`id`}function nn(e,t){return e.columns&&t in e.columns?t:void 0}function rn(e,t){if(t!==`name`&&e.columns&&`name`in e.columns)return`name`}function an(e){return`type`in e||`primaryKey`in e||`references`in e}function on(e){return e.endsWith(`y`)&&!/[aeiou]y$/i.test(e)?`${e.slice(0,-1)}ies`:/(?:s|x|z|ch|sh)$/i.test(e)?`${e}es`:`${e}s`}function sn(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1_$2`).toLowerCase()}function cn(e){let t=[];for(let n of e.split(`/`))n.startsWith(`:`)&&n.length>1&&t.push(n.slice(1));return t}function ln(e){return`:${e}`}var un={"attachments:id":`attachments/tsk_eng_12/spec.pdf`,"tasks:id":`tsk_eng_12`,"comments:id":`cmt_1`,"projects:id":`proj_api`,"spaces:id":`space_eng`,"tags:id":`tag_bug`,"tags:tagId":`tag_feature`,"goals:id":`goal_harbor`,"documents:id":`doc_prd_api`,"members:id":`mem_aria`,"forms:id":`form_customer`,"drafts:id":`ENG-12`,"views:id":`view_web_board`,"inbox:id":`inb_1`};function dn(e,t){let n=e.split(`/`).filter(Boolean),r=`:${t}`,i=n.indexOf(r),a=i>0?n[i-1]:void 0;return(a?un[`${a}:${t}`]:void 0)??un[`:${t}`]}function fn(e,t){let n={};if(!e)return n;for(let r of t){let t=dn(e,r);t&&(n[r]=t)}return n}function pn(e,t){let n=e?.flows?.[t],r=n?.trigger?.cron,i=n?.trigger?.every;if(!r&&!i)return{kind:`unmatched`};let a=e?.clocks??{},o=new Set;for(let[e,n]of Object.entries(a)){if(t===e||t.endsWith(`.${e}`)){o.add(e);continue}if(r&&n.cron===r){o.add(e);continue}i&&n.every===i&&o.add(e)}if(o.size!==1)return{kind:`unmatched`};let s=[...o][0],c=a[s];return{kind:`matched`,clockName:s,timezone:c.timezone??null,description:c.description??null,cron:c.cron??null,every:c.every??null}}function mn(e){let t=e.handlerMs!=null&&Number.isFinite(e.handlerMs)?e.handlerMs:null;return t===null?e.rttMs!==null&&Number.isFinite(e.rttMs)?{primaryMs:e.rttMs,primaryKind:`rtt`,rttMs:e.rttMs}:null:{primaryMs:t,primaryKind:`handler`,rttMs:e.rttMs}}function hn(e){let t=new Set;if(!e?.stores)return t;for(let n of Object.values(e.stores)){for(let e of Object.values(n.tables??{}))for(let[n,r]of Object.entries(e.columns??{}))r?.pii&&ie(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;ie(t,n)}}return t}function gn(e,t,n=ne){if(t.size===0||e==null)return e;if(Array.isArray(e))return e.map(e=>gn(e,t,n));if(typeof e==`object`){let r={};for(let[i,a]of Object.entries(e))r[i]=t.has(i)?n:gn(a,t,n);return r}return e}function _n(e){return e.failure==null?e.response!==void 0&&e.response!==null?JSON.stringify(e.response,null,2):JSON.stringify({status:e.status??200,failure:null,response:null},null,2):JSON.stringify({status:e.status??null,failure:e.failure,response:e.response??null},null,2)}function vn(e,t,n){return t&&e.masked===!1?_n({...e,response:gn(e.response,n),failure:e.failure===void 0?void 0:{...e.failure,data:gn(e.failure.data,n)},masked:!0}):_n(e)}function yn(e){let t=e.flow.effects;return!t||(t.writes?.length??0)===0&&(t.emits?.length??0)===0&&(t.sends?.length??0)===0&&(t.asks?.length??0)===0&&(t.embeds?.length??0)===0&&(t.fetches?.length??0)===0}function bn(e,t){return!t&&yn(e)}function xn(e,t){if(!e)return{ok:!0,errors:[],value:t};let n=[];return Sn(e,t,``,n),{ok:n.length===0,errors:n,value:t}}function Sn(e,t,n,r){let i=e.type;if(i===`object`||e.properties){if(typeof t!=`object`||!t||Array.isArray(t)){r.push({path:n||`/`,message:`must be object`});return}let i=t,a=e.properties??{},o=Array.isArray(e.required)?e.required:[];for(let e of o)(i[e]===void 0||i[e]===null||i[e]===``)&&r.push({path:`${n}/${e}`,message:`required`});for(let[e,t]of Object.entries(a))i[e]!==void 0&&Sn(t,i[e],`${n}/${e}`,r);return}if(Array.isArray(e.enum)){e.enum.map(String).includes(String(t))||r.push({path:n||`/`,message:`invalid enum`});return}i===`string`&&typeof t!=`string`?r.push({path:n||`/`,message:`must be string`}):i===`integer`?typeof t!=`number`||!Number.isInteger(t)?r.push({path:n||`/`,message:`must be integer`}):Cn(e,t,n,r):i===`number`?typeof t!=`number`||Number.isNaN(t)?r.push({path:n||`/`,message:`must be number`}):Cn(e,t,n,r):i===`boolean`&&typeof t!=`boolean`&&r.push({path:n||`/`,message:`must be boolean`})}function Cn(e,t,n,r){let i=typeof e.minimum==`number`?e.minimum:void 0,a=typeof e.maximum==`number`?e.maximum:void 0;i!==void 0&&t<i&&r.push({path:n||`/`,message:`must be ≥ ${i}`}),a!==void 0&&t>a&&r.push({path:n||`/`,message:`must be ≤ ${a}`})}function wn(e){return JSON.stringify(e,null,2)}function Tn({row:e,manifest:t}){let n=U(e.flow.trigger);return n===`cron`||n===`every`?(0,X.jsx)(En,{row:e,manifest:t}):(0,X.jsx)(Dn,{row:e,kind:n,manifest:t})}function En({row:e,manifest:t}){let n=(0,Y.useMemo)(()=>pn(t,e.id),[t,e.id]),i=Je(),a=Xe(),o=nt(),[s,c]=(0,Y.useState)({asGate:null,asUserId:null}),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{i.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 i.mutateAsync({name:n.clockName})}catch{}return}if(Ot(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?i.isPending:o.isPending,g=p?i.isError:o.isError||o.isSuccess&&o.data?.failure!=null,v=p?i.isSuccess:o.isSuccess&&!o.data?.failure,y=l!==null&&(v||g)?performance.now()-l:null,b=(0,Y.useMemo)(()=>p&&i.data?JSON.stringify(i.data,null,2):!p&&o.data?_n(o.data):null,[p,i.data,o.data]),x=p?`Run now`:`Run handler`,S=p?`Run now`:`Run handler once`;return(0,X.jsx)(jn,{title:x,dataMode:p?`clock`:`invoke-fallback`,actions:(0,X.jsxs)(X.Fragment,{children:[p?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(kt,{manifest:t,identities:a.data??[],value:s,onChange:c}),(0,X.jsx)(In,{})]}),(0,X.jsx)(_,{type:`button`,"data-slot":`call-api-submit`,disabled:h||!p&&!Ot(s),onClick:()=>void m(),className:Fn,children:h?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{icon:pt,className:`animate-spin`,"data-icon":`inline-start`}),`Running…`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{icon:ee,"data-icon":`inline-start`}),S]})})]}),children:(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[p?(0,X.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,X.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:n.clockName}),` `,`via`,` `,(0,X.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,X.jsxs)(X.Fragment,{children:[` `,`Timezone · `,(0,X.jsx)(`span`,{className:`font-mono`,children:n.timezone}),`.`]}):null]}):(0,X.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,X.jsx)(`strong`,{className:`font-medium`,children:`Run handler once`}),` uses`,` `,(0,X.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,X.jsx)(`em`,{children:`not`}),` exercise the Clock lease / scheduler path.`]}),(0,X.jsx)(On,{failed:!!g,success:!!v,elapsed:y,handlerMs:p?null:o.data?.durationMs,statusCode:p?i.data?.ran?200:409:o.data?.status,errorMessage:p?i.isError?i.error.message:null:o.isError?o.error.message:null,responseJson:b,emptyHint:p?`Run now to fire the real clock tick.`:`Run handler once to invoke with empty input.`,pathUsed:d,cache:p?void 0:o.data?.cache})]})})}function Dn({row:e,kind:t,manifest:n}){let l=Xe(),u=nt(),d=qt(e.flow.in),f=(0,Y.useMemo)(()=>Z(d),[d]),p=(0,Y.useMemo)(()=>t===`http`&&e.path?cn(e.path):[],[t,e.path]),m=(0,Y.useMemo)(()=>Nt(f,{http:t===`http`,method:e.method,pathParams:p}),[f,t,e.method,p]),h=t!==`http`||oe(e.method),[g,v]=(0,Y.useState)({asGate:null,asUserId:null}),[y,b]=(0,Y.useState)(!0),[x,S]=(0,Y.useState)(()=>fn(e.path,p)),C=(0,Y.useMemo)(()=>Gt(d)??{},[d]),w=(0,Y.useMemo)(()=>Pt(C,m.query),[C,m.query]),T=(0,Y.useMemo)(()=>Pt(C,m.body),[C,m.body]),[E,D]=(0,Y.useState)(w),[O,k]=(0,Y.useState)(T),[A,j]=(0,Y.useState)(`fields`),[M,N]=(0,Y.useState)(()=>wn(T)),[P,F]=(0,Y.useState)(null),[I,L]=(0,Y.useState)([]),[R,z]=(0,Y.useState)(null),[te,ne]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{D(w),k(T),N(wn(T)),F(null),j(`fields`),S(fn(e.path,p)),L([]),ne(null),z(null),u.reset()},[e.id]);function re(e){try{let t=JSON.parse(e);return typeof t!=`object`||!t||Array.isArray(t)?(F(`Body must be a JSON object.`),!1):(k(t),F(null),!0)}catch(e){return F(e instanceof Error?e.message:`Invalid JSON.`),!1}}function ie(e){if(e!==A){if(e===`raw`){N(wn(O)),F(null),j(`raw`);return}re(M)&&j(`fields`)}}async function B(t=!y){let n=h?O:{};if(h&&A===`raw`){if(!re(M))return;try{n=JSON.parse(M)}catch{return}}let r={...E,...n},i=xn(d,{...x,...r});if(!i.ok){L(i.errors);return}if(L([]),Ot(g)){z(performance.now());try{await u.mutateAsync({flowId:e.id,body:r,...g.asUserId?{asUserId:g.asUserId}:{},...g.asGate?{asGate:g.asGate}:{},...p.length>0?{pathParams:x}:{},...t?{revealPii:!0}:{}})}catch{}}}function se(){D(w),k(T),N(wn(T)),F(null),S(fn(e.path,p)),L([])}(0,Y.useEffect)(()=>{R===null||u.isPending||(u.isSuccess||u.isError)&&ne(performance.now()-R)},[u.isSuccess,u.isError,u.isPending,R]);let ce=(0,Y.useMemo)(()=>u.data?vn(u.data,y,hn(n)):null,[u.data,y,n]),V=u.data?.failure!=null,le=u.data?.status,ue=t===`http`?`Call API`:t===`signal`?`Run handler`:`Invoke`,de=ue;return(0,X.jsx)(jn,{title:ue,dataTrigger:t,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(kt,{manifest:n,identities:l.data??[],value:g,onChange:v}),(0,X.jsx)(ae,{piiMasked:y,disabled:u.isPending,onToggle:()=>{let t=!y;b(t),u.data&&!u.isPending&&bn(e,t)&&B(!0)}}),h?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(In,{}),(0,X.jsx)(Mn,{view:A,onChange:ie})]}):null,(0,X.jsx)(In,{}),(0,X.jsxs)(a,{children:[(0,X.jsx)(c,{render:e=>(0,X.jsxs)(_,{...e,type:`button`,variant:`ghost`,"data-slot":`call-api-reset`,disabled:u.isPending,onClick:se,className:Pn,children:[(0,X.jsx)(r,{icon:De,"data-icon":`inline-start`}),`Reset`]})}),(0,X.jsx)(o,{side:`bottom`,className:`text-[11px]`,children:h?`Reset body to the schema example`:`Reset to schema examples`})]}),(0,X.jsx)(In,{}),(0,X.jsx)(_,{type:`button`,"data-slot":`call-api-submit`,disabled:u.isPending||!Ot(g),onClick:()=>void B(),className:Fn,children:u.isPending?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{icon:pt,className:`animate-spin`,"data-icon":`inline-start`}),`Calling…`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{icon:ee,"data-icon":`inline-start`}),de]})})]}),children:(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,X.jsxs)(`div`,{className:`min-h-0 min-w-0 shrink overflow-y-auto`,children:[t===`http`?(0,X.jsxs)(`p`,{className:`px-3 pt-2.5 pb-2 text-[11px] leading-snug text-muted-foreground`,children:[`Operator session · invoke-as`,` `,(0,X.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`console:flows:invoke-as`})]}):null,t===`signal`?(0,X.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,X.jsx)(`strong`,{className:`font-medium`,children:`Run handler directly`}),` — invokes the flow with your payload via`,` `,(0,X.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`/console/flows/invoke`}),`. It does `,(0,X.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,X.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,X.jsx)(`code`,{className:`font-mono text-[10px]`,children:`fx.call`}),` /`,` `,(0,X.jsx)(`code`,{className:`font-mono text-[10px]`,children:`effects.calls`}),`). The body still matches `,(0,X.jsx)(`code`,{className:`font-mono text-[10px]`,children:`flow.in`}),`.`]}):null,t===`cdc`?(0,X.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,X.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Path params`,"data-slot":`call-api-path`,children:[(0,X.jsx)(Rn,{title:`Path params`,hint:e.path??void 0}),p.map(e=>(0,X.jsx)(J,{label:e,className:`[&>span]:px-3`,children:(0,X.jsx)(i,{id:`path-${e}`,flat:!0,className:s(gt,`px-3 font-mono`),placeholder:ln(e),value:x[e]??``,onChange:t=>S(n=>({...n,[e]:t.target.value}))})},e))]}):null,m.query.length>0?(0,X.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Query params`,"data-slot":`call-api-query`,children:[(0,X.jsx)(Rn,{title:`Query params`,hint:`seeded from schema`}),(0,X.jsx)(vt,{children:m.query.map(e=>(0,X.jsx)(zn,{field:e,idPrefix:`query`,value:E[e.name],onChange:t=>D(n=>({...n,[e.name]:t})),error:I.find(t=>t.path===`/${e.name}`||t.path===e.path),wide:e.type===`object`||e.type===`array`,manifest:n},e.path))})]}):null,h?(0,X.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Body`,"data-slot":`call-api-body`,children:[(0,X.jsx)(Rn,{title:`Body`,hint:A===`raw`?`raw JSON`:`seeded from schema`}),A===`raw`?(0,X.jsxs)(`div`,{className:`border-b border-border/50`,children:[(0,X.jsx)(`textarea`,{"data-slot":`call-api-body-raw`,"aria-label":`Raw JSON body`,spellCheck:!1,value:M,onChange:e=>{N(e.target.value),P&&F(null)},className:s(`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`,P&&`text-destructive`)}),P?(0,X.jsx)(`p`,{role:`alert`,className:`px-3 pb-2 text-xs text-destructive`,"data-slot":`call-api-raw-error`,children:P}):null]}):m.body.length===0?(0,X.jsx)(`p`,{className:`border-b border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:`No body fields (empty object).`}):(0,X.jsx)(vt,{children:m.body.map(e=>(0,X.jsx)(zn,{field:e,value:O[e.name],onChange:t=>k(n=>({...n,[e.name]:t})),error:I.find(t=>t.path===`/${e.name}`||t.path===e.path),wide:e.type===`object`||e.type===`array`,manifest:n},e.path))})]}):null,I.length>0?(0,X.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,X.jsx)(On,{failed:!!V,success:!!u.data&&!V,elapsed:te,handlerMs:u.data?.durationMs,statusCode:le,errorMessage:u.isError?u.error.message:null,responseJson:ce,emptyHint:`Call to see a real host response.`,pathUsed:null,cache:u.data?.cache})]})})}function On({failed:e,success:t,elapsed:n,handlerMs:i,statusCode:a,errorMessage:o,responseJson:c,emptyHint:u,pathUsed:_,cache:v}){let[b,x]=(0,Y.useState)(!1),S=(0,X.jsx)(An,{failed:e,success:t,elapsed:n,handlerMs:i,statusCode:a,pathUsed:_,cache:v});return(0,X.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,X.jsxs)(`div`,{className:z,children:[(0,X.jsx)(`h4`,{className:s(y,`flex items-center px-2`),children:`Response`}),(0,X.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,children:[S,c?(0,X.jsx)(ge,{label:`Expand response`,className:`flex self-stretch`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":`Expand response`,"data-slot":`call-api-response-expand`,className:D,onClick:()=>x(!0),children:(0,X.jsx)(r,{icon:Ct,className:`size-3.5`,"aria-hidden":!0})})}):null]})]}),o?(0,X.jsx)(`p`,{role:`alert`,className:`px-2 py-2 text-sm text-destructive`,"data-slot":`call-api-error`,children:o}):null,c?(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,"data-slot":`call-api-response-frame`,children:[(0,X.jsx)(`div`,{className:s(`w-1 shrink-0 self-stretch`,e?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0,"data-slot":`call-api-response-rail`}),(0,X.jsx)(Ae,{json:c,dataSlot:`call-api-response`,className:`flex min-h-0 flex-1 overflow-auto`})]}):(0,X.jsx)(`p`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:u}),c?(0,X.jsx)(d,{open:b,onOpenChange:x,children:(0,X.jsxs)(p,{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,X.jsxs)(f,{className:s(z,`flex-row gap-0 border-border/60 p-0`),children:[(0,X.jsx)(g,{className:s(y,`flex items-center px-2`),children:`Response`}),(0,X.jsx)(m,{className:`sr-only`,children:`Full Call API response JSON`}),(0,X.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,children:[S,(0,X.jsx)(kn,{json:c}),(0,X.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0}),(0,X.jsxs)(l,{"aria-label":`Close`,className:D,"data-slot":`call-api-response-close`,children:[(0,X.jsx)(r,{icon:h,className:`size-3.5`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,X.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,X.jsx)(`div`,{className:s(`w-1 shrink-0 self-stretch`,e?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0}),(0,X.jsx)(Ae,{json:c,dataSlot:`call-api-response-expanded`,className:`flex min-h-0 flex-1 overflow-auto`})]})})]})}):null]})}function kn({json:e}){let[t,n]=(0,Y.useState)(!1);return(0,X.jsx)(ge,{label:t?`Copied`:`Copy response`,className:`flex self-stretch`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":t?`Copied`:`Copy response`,"data-slot":`call-api-response-copy`,className:D,onClick:()=>{navigator.clipboard&&navigator.clipboard.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1200)})},children:(0,X.jsx)(r,{icon:t?u:le,className:`size-3.5`,"aria-hidden":!0})})})}function An({failed:e,success:t,elapsed:n,handlerMs:i,statusCode:l,pathUsed:d,cache:f}){let p=t||e,m=p?mn({handlerMs:i,rttMs:n}):null;return(0,X.jsxs)(X.Fragment,{children:[d?(0,X.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,X.jsxs)(`span`,{className:s(`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,X.jsx)(r,{icon:e?Ce:u,className:`size-3`,"aria-hidden":!0}),l??(e?`error`:`ok`)]}):null,p?(0,X.jsx)(`span`,{className:`flex h-full items-center px-2`,children:(0,X.jsx)(St,{cache:f??`none`,dataSlot:`call-api-cache`})}):null,m?(0,X.jsxs)(a,{children:[(0,X.jsx)(c,{render:e=>(0,X.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:Oe(m.primaryMs)})}),(0,X.jsx)(o,{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,X.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:[Oe(m.rttMs),` rtt`]}):null]})}function jn({title:e,actions:t,children:n,dataTrigger:i,dataMode:a}){return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`call-api-panel`,"data-trigger":i,"data-mode":a,children:[(0,X.jsxs)(`div`,{className:s(b,`min-w-0`),children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 px-2`,children:[(0,X.jsx)(r,{icon:ee,className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(`h3`,{className:s(y,`text-foreground`),children:e})]}),(0,X.jsx)(`div`,{className:`ml-auto flex h-full min-w-0 items-stretch`,children:t})]}),(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:n})]})}function Mn({view:e,onChange:t}){return(0,X.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,X.jsx)(Nn,{active:e===`fields`,label:`Fields`,icon:Me,onClick:()=>t(`fields`)}),(0,X.jsx)(Nn,{active:e===`raw`,label:`Raw`,icon:ve,onClick:()=>t(`raw`)})]})}function Nn({active:e,label:t,icon:n,onClick:i}){return(0,X.jsxs)(`button`,{type:`button`,className:s(v,`font-semibold tracking-[0.08em] uppercase`,e?S:R),"aria-pressed":e,"aria-label":t,onClick:i,children:[(0,X.jsx)(r,{icon:n,className:`size-3`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:t})]})}var Pn=`h-full rounded-none border-0 bg-transparent px-2 text-[10px] font-semibold tracking-[0.08em] uppercase shadow-none hover:bg-muted/50`,Fn=`h-full rounded-none border-0 px-3 text-[10px] font-semibold tracking-[0.14em] uppercase shadow-none`;function In(){return(0,X.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0})}var Ln=`h-7 w-full justify-between rounded-none border-0 bg-transparent px-2 shadow-none focus-visible:border-0 focus-visible:ring-0 dark:bg-transparent dark:hover:bg-transparent`;function Rn({title:e,hint:t}){return(0,X.jsxs)(`div`,{className:z,children:[(0,X.jsx)(`h4`,{className:s(y,`flex items-center px-2`),children:e}),t?(0,X.jsx)(`span`,{className:`ml-auto flex items-center px-2 text-[10px] text-muted-foreground`,children:t}):null]})}function zn({field:e,value:t,onChange:n,error:r,wide:a=!1,manifest:o,idPrefix:c=`body`}){let l=`${c}-${e.name}`,u=Bn(e,o),d=[e.required?null:`optional`,u.lookup?`fk · ${u.lookup.child}.${u.lookup.column}`:e.type,u.lookup?null:Bt(e)].filter(Boolean).join(` · `),f=r?(0,X.jsx)(`p`,{className:`px-3 pb-2 text-xs text-destructive`,children:r.message}):null,p=s(a&&`col-span-full border-r-0`);if(u.lookup){let r=t==null||t===``?``:String(t),i=Vn(u.options,r);return(0,X.jsxs)(J,{label:e.name,hint:d,dense:!0,className:p,children:[(0,X.jsxs)(q,{value:r||null,onValueChange:e=>{e==null||Array.isArray(e)||n(String(e))},children:[(0,X.jsx)(W,{id:l,className:Ln,disabled:u.isLoading,children:(0,X.jsx)(Ye,{placeholder:u.isLoading?`Loading…`:`Select…`})}),(0,X.jsx)(K,{children:i.map(e=>(0,X.jsx)(G,{value:e.value,children:e.label},e.value))})]}),f]})}if(e.type===`enum`&&e.enumValues)return(0,X.jsxs)(J,{label:e.name,hint:d,dense:!0,className:p,children:[(0,X.jsxs)(q,{value:String(t??``),onValueChange:e=>{e==null||Array.isArray(e)||n(String(e))},children:[(0,X.jsx)(W,{id:l,className:Ln,children:(0,X.jsx)(Ye,{})}),(0,X.jsx)(K,{children:e.enumValues.map(e=>(0,X.jsx)(G,{value:e,children:e},e))})]}),f]});if(e.type===`boolean`)return(0,X.jsx)(J,{label:e.name,hint:d,dense:!0,className:p,children:(0,X.jsxs)(q,{value:t===!0?`true`:`false`,onValueChange:e=>{e==null||Array.isArray(e)||n(String(e)===`true`)},children:[(0,X.jsx)(W,{id:l,className:Ln,children:(0,X.jsx)(Ye,{})}),(0,X.jsxs)(K,{children:[(0,X.jsx)(G,{value:`true`,children:`true`}),(0,X.jsx)(G,{value:`false`,children:`false`})]})]})});if(e.type===`integer`||e.type===`number`){let r=Wt(e);if(r){let i=typeof t==`number`?String(t):``;return(0,X.jsxs)(J,{label:e.name,hint:d,dense:!0,className:p,children:[(0,X.jsxs)(q,{value:i||null,onValueChange:e=>{e==null||Array.isArray(e)||n(Number(e))},children:[(0,X.jsx)(W,{id:l,className:Ln,children:(0,X.jsx)(Ye,{placeholder:`Select…`})}),(0,X.jsx)(K,{children:r.map(t=>{let n=e.valueMeanings?.find(e=>e.value===String(t));return(0,X.jsx)(G,{value:String(t),children:n?`${t} · ${n.label}`:t},t)})})]}),f]})}return(0,X.jsxs)(J,{label:e.name,hint:d,dense:!0,className:p,children:[(0,X.jsx)(i,{id:l,type:`number`,flat:!0,className:s(gt,`h-7 px-2 font-mono`),min:e.minimum,max:e.maximum,step:e.type===`integer`?1:void 0,value:typeof t==`number`?t:``,onChange:t=>{if(t.target.value===``){n(void 0);return}n(Hn(Number(t.target.value),e.minimum,e.maximum))}}),f]})}return(0,X.jsxs)(J,{label:e.name,hint:d,dense:!0,className:p,children:[(0,X.jsx)(i,{id:l,flat:!0,className:s(gt,`h-7 px-2 font-mono`),value:typeof t==`string`?t:t==null?``:String(t),onChange:e=>n(e.target.value)}),f]})}function Bn(e,t){let n=(0,Y.useMemo)(()=>Jt(e,t),[e,t]),r=et(n?{ref:n.ref,child:n.child,limit:200}:null,n!==null);return{lookup:n,options:(0,Y.useMemo)(()=>Yt(r.data?.rows??[],n),[r.data?.rows,n]),isLoading:r.isFetching}}function Vn(e,t){return!t||e.some(e=>e.value===t)?e:[{value:t,label:t},...e]}function Hn(e,t,n){let r=e;return t!==void 0&&r<t&&(r=t),n!==void 0&&r>n&&(r=n),r}function Q({title:e,meta:t,ruled:n=!0}){return(0,X.jsxs)(`div`,{className:s(`flex items-baseline justify-between gap-2`,n&&`border-b border-border/60 pb-1.5`),children:[(0,X.jsx)(`h3`,{className:y,children:e}),t?(0,X.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:t}):null]})}function Un({method:e,className:t}){return(0,X.jsx)(ye,{variant:`outline`,className:s(`h-5 px-1.5 font-mono text-[10px] uppercase`,ce(e),t),"data-slot":`http-method-badge`,children:e})}var Wn=[`once`,`broadcast`,`live`],Gn={once:{delivery:`once`,icon:Et,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:Tt,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:te,label:`live`,title:`live — retained feed; late subscribers replay history`,wellClass:`border-emerald-500/35 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`,badgeClass:`border-emerald-500/35 bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`}};function Kn({delivery:e,className:t}){let n=Gn[e];return(0,X.jsx)(ye,{variant:`outline`,title:n.title,className:s(`h-5 px-1.5 font-mono text-[10px]`,n.badgeClass,t),"data-slot":`signal-delivery-badge`,"data-delivery":e,children:n.label})}function qn({effects:e}){let t=Jn(e);return t.length===0?null:(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`effects-summary`,"aria-label":`Effects`,children:[(0,X.jsx)(Q,{title:`Effects`,meta:String(t.length)}),(0,X.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>{let t=Ne(e.kind),n=Le(e.kind,e.ref),i=e.kind===`call`?Re(e.ref):null;return(0,X.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:i??`${Be[e.kind]} ${e.ref}`,children:[(0,X.jsx)(r,{icon:n,className:`size-3`}),i?(0,X.jsx)(`span`,{className:`text-foreground/90`,children:i}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:Be[e.kind]}),(0,X.jsx)(`span`,{className:`text-foreground/90`,children:e.ref})]})]},`${e.kind}:${e.ref}`)})})]})}function Jn(e){if(!e)return[];let t=[],n=(e,n)=>{for(let r of n??[]){let n=typeof r==`string`?r:r.ref??String(r);t.push({kind:e,ref:n})}};return n(`read`,e.reads),n(`write`,e.writes),n(`emit`,e.emits),n(`send`,e.sends),n(`ask`,e.asks),n(`embed`,e.embeds),n(`secret`,e.secrets),n(`call`,e.calls),n(`fetch`,e.fetches),t}function Yn({errors:e}){let t=Xn(e);return t.length===0?null:(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`errors-section`,"aria-label":`Flow errors`,children:[(0,X.jsx)(Q,{title:`Flow errors`,meta:String(t.length)}),(0,X.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>{let t=(e.schema?Z(e.schema):[]).map(e=>e.name).join(`, `);return(0,X.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,X.jsx)(r,{icon:Ce,className:`size-3`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`text-foreground/90`,children:e.code}),t?(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:t}):null]},e.code)})})]})}function Xn(e){return e?Array.isArray(e)?e.map(e=>({code:e,schema:null})):Object.entries(e).map(([e,t])=>({code:e,schema:qt(t)})):[]}var Zn=36e5;function Qn(e,t,n,r=Zn){let i=bt(e,new Set([t])),a=n-r,o=i.filter(e=>e.startedAt>=a);if(o.length===0)return{kind:`empty`};let s=o.filter(e=>e.error!=null&&e.error.length>0).length,c=o[0];return{kind:`summary`,calls:o.length,errors:s,errorRate:s/o.length,lastStartedAt:c.startedAt,latestRunId:c.id,windowMs:r}}function $n({flowId:e,runs:t,nowMs:n=Date.now(),windowMs:r=Zn,children:i}){let a=Qn(t??[],e,n,r);return(0,X.jsxs)(`div`,{className:s(z,`px-2`),"data-slot":`flow-activity-strip`,"data-kind":a.kind,"aria-label":`Recent activity`,children:[(0,X.jsx)(`span`,{className:s(y,`flex items-center`),children:`Activity`}),(0,X.jsx)(er,{summary:a,nowMs:n}),i?(0,X.jsx)(`div`,{className:`ml-auto flex h-full items-stretch`,children:i}):null]})}function er({summary:e,nowMs:t}){if(e.kind===`empty`)return(0,X.jsx)(`p`,{className:`flex items-center text-[11px] text-muted-foreground`,"data-slot":`flow-activity-empty`,children:`No recent runs in the Console buffer.`});let n=Math.round(e.errorRate*100),r=tr(e.lastStartedAt,t);return(0,X.jsxs)(`p`,{className:`flex min-w-0 items-center gap-x-2 text-[11px] text-foreground/85`,children:[(0,X.jsxs)(`span`,{className:`tabular-nums`,"data-slot":`flow-activity-calls`,children:[e.calls,` call`,e.calls===1?``:`s`]}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,"aria-hidden":!0,children:`·`}),(0,X.jsxs)(`span`,{className:`tabular-nums`,"data-slot":`flow-activity-errors`,children:[n,`% errors`]}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,"aria-hidden":!0,children:`·`}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,"data-slot":`flow-activity-ago`,children:r}),(0,X.jsx)(mt,{to:`/overview`,search:{run:e.latestRunId},className:s(v,R),"data-slot":`flow-activity-open-run`,children:`Open latest`})]})}function tr(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.max(1,Math.round(n/1e3))}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function nr(e){switch(e){case`string`:return`border-teal-500/35 bg-teal-500/10 text-teal-800 dark:text-teal-300`;case`integer`:return`border-blue-500/35 bg-blue-500/10 text-blue-800 dark:text-blue-300`;case`number`:return`border-amber-500/35 bg-amber-500/10 text-amber-800 dark:text-amber-300`;case`boolean`:return`border-violet-500/35 bg-violet-500/10 text-violet-800 dark:text-violet-300`;case`enum`:return`border-indigo-500/35 bg-indigo-500/10 text-indigo-800 dark:text-indigo-300`;case`array`:return`border-cyan-500/35 bg-cyan-500/10 text-cyan-800 dark:text-cyan-300`;case`object`:return`border-zinc-500/35 bg-zinc-500/10 text-zinc-700 dark:text-zinc-300`;default:return`border-border/70 bg-muted/40 text-muted-foreground`}}function rr({fields:e,emptyLabel:t=`No schema fields declared.`,layout:n=`list`}){return e.length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-slot":`schema-fields-empty`,children:t}):n===`grid`?(0,X.jsx)(`div`,{"data-slot":`schema-fields`,"data-layout":`grid`,children:(0,X.jsx)(vt,{columns:3,children:e.map(e=>(0,X.jsx)(ir,{field:e,depth:0,cell:!0},e.path))})}):(0,X.jsx)(`ul`,{className:`flex flex-col`,"data-slot":`schema-fields`,children:e.map(e=>(0,X.jsx)(ir,{field:e,depth:0},e.path))})}function ir({field:e,depth:t,cell:n=!1}){let r=e.type===`enum`&&e.enumValues,i=Bt(e);return(0,X.jsxs)(n?`div`:`li`,{className:n?`min-w-0 border-b border-border/50`:void 0,children:[(0,X.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,X.jsx)(`span`,{className:`shrink-0`,"data-slot":`schema-field-keys`,title:ar(e),children:(0,X.jsx)(re,{primaryKey:e.primaryKey,foreignKey:e.foreignKey,unique:e.unique,empty:`none`})}),(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] font-medium text-foreground/90`,children:e.name}),e.required?null:(0,X.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,X.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,X.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,X.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,X.jsx)(`span`,{className:s(`ml-auto shrink-0 rounded border px-1.5 py-px font-mono text-[9px] font-medium tracking-wide`,nr(e.type)),"data-slot":`schema-field-type`,title:r?e.enumValues?.join(` | `):e.type,children:e.type})]}),e.children?.map(e=>(0,X.jsx)(ir,{field:e,depth:t+1,cell:n},e.path))]})}function ar(e){let t=[];if(e.primaryKey&&t.push(`Primary key`),e.foreignKey){let n=e.references?[e.references.table,e.references.column].filter(Boolean).join(`.`):null;t.push(n?`Foreign key → ${n}`:`Foreign key`)}return e.unique&&t.push(`Unique`),t.length>0?t.join(` · `):`None`}function or({fields:e}){let t=Ht(e);return t.length===0?null:(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`validation-section`,"aria-label":`Validation`,children:[(0,X.jsx)(Q,{title:`Validation`,meta:String(t.length)}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-3`,children:t.map(e=>(0,X.jsx)(sr,{field:e},e.path))})]})}function sr({field:e}){let t=Vt(e),n=e.valueMeanings?.length?e.valueMeanings:e.enumValues?.map(e=>({value:e,label:e}));return(0,X.jsxs)(`li`,{className:`flex flex-col gap-1.5`,"data-slot":`validation-field`,"data-field":e.name,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-foreground/90`,children:e.name}),t?(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t}):null]}),n&&n.length>0?(0,X.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,X.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5 font-mono text-[11px]`,"data-slot":`validation-option`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.value}),(0,X.jsx)(`span`,{className:`truncate text-foreground/90`,children:e.label})]},e.value))}):null]})}function cr({row:e,manifest:t,runs:n,leading:i,trailing:a}){let o=U(e.flow.trigger),c=Ie(e.flow.trigger),l=Ve(t,e.id,o===`http`?`http`:o===`internal`?`internal`:o),u=qt(e.flow.in),d=qt(e.flow.out),f=Pe(e.flow.gates??[],t),p=o===`signal`&&e.flow.trigger?.signal?t?.signals?.[e.flow.trigger.signal]:void 0,m=o===`cron`||o===`every`?pn(t,e.id):null,h=o===`internal`?xt(t,e.id):[],g=o===`http`?`Request`:`Input`,_=o===`http`?`Response`:`Output`,y=o!==`cron`&&o!==`every`,b=Z(u),x=Z(d),S=jt(b,o===`http`&&e.path?cn(e.path):[]);return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`flow-contract-panel`,"data-trigger":o,children:[(0,X.jsx)(_t,{dataSlot:`endpoint-header`,leading:i,trailing:a,icon:(0,X.jsx)(`span`,{"data-slot":`trigger-kind-icon`,"data-kind":o,children:(0,X.jsx)(r,{icon:c.icon,className:`size-4`})}),wellClassName:c.wellClass,title:(0,X.jsx)(`span`,{className:`font-mono`,children:e.id}),badge:(0,X.jsx)(`span`,{className:`font-mono text-[10px] font-medium tracking-[0.08em] text-muted-foreground uppercase`,"data-slot":`trigger-kind-badge`,children:c.label}),subtitle:o===`http`&&l.method&&l.path?(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,"data-slot":`http-endpoint-line`,children:[(0,X.jsx)(Un,{method:l.method}),(0,X.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[11px] leading-none text-muted-foreground select-all`,children:l.path})]}):o===`signal`&&p?(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,"data-slot":`signal-endpoint-line`,children:[(0,X.jsx)(Kn,{delivery:p.delivery}),(0,X.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[11px] leading-none text-muted-foreground select-all`,children:e.flow.trigger?.signal})]}):(0,X.jsx)(`span`,{className:`truncate font-mono text-[11px] leading-none text-muted-foreground`,"data-slot":`trigger-headline`,children:l.headline}),actions:(0,X.jsxs)(mt,{to:`/overview`,search:{flow:e.id},"data-slot":`open-in-graph`,className:s(v,`text-sky-700 dark:text-sky-400`),children:[(0,X.jsx)(r,{icon:_e.flow.icon,className:`size-3.5`,"aria-hidden":!0}),`Open in graph`]})}),(0,X.jsxs)($n,{flowId:e.id,runs:n,children:[e.flow.plane?(0,X.jsx)(lr,{plane:e.flow.plane}):null,e.flow.durable?(0,X.jsx)(ur,{icon:je,label:`durable`,title:`Durable — long-running, retryable steps`}):null,e.flow.idempotency&&e.flow.idempotency.mode!==`off`?(0,X.jsx)(ur,{icon:fe,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,X.jsx)(ur,{icon:de,label:`live`,title:typeof e.flow.live==`string`?`Live — SSE for ${e.flow.live}`:`Live — SSE signal feed`}):null]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(qn,{effects:e.flow.effects}),(0,X.jsx)(He,{gates:f}),(0,X.jsx)(Yn,{errors:e.flow.errors}),o===`signal`&&p&&(p.retries!==void 0||p.deadLetter)?(0,X.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`signal-delivery`,children:[p.retries===void 0?null:`retries ${p.retries}`,p.deadLetter?`dead-letter`:null].filter(e=>e!==null).join(` · `)}):null,(o===`cron`||o===`every`)&&m?.kind===`matched`?(0,X.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`clock-join`,children:[`Clock · `,(0,X.jsx)(`span`,{className:`font-mono`,children:m.clockName}),m.timezone?` · ${m.timezone}`:``]}):null,o===`internal`?(0,X.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`call-only-note`,children:[`No external trigger — reachable via `,(0,X.jsx)(`code`,{className:`font-mono`,children:`effects.calls`}),` /`,` `,(0,X.jsx)(`code`,{className:`font-mono`,children:`fx.call`}),`.`]}):null,o===`internal`?(0,X.jsxs)(`section`,{className:`flex flex-col gap-1.5`,"aria-label":`Callers`,"data-slot":`callers-list`,children:[(0,X.jsx)(Q,{title:`Called by`,meta:String(h.length)}),h.length===0?(0,X.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`No Manifest caller declares `,(0,X.jsx)(`code`,{className:`font-mono`,children:`effects.calls`}),` for this flow.`]}):(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:h.map(e=>(0,X.jsx)(`li`,{className:`font-mono text-xs text-foreground/90`,children:e},e))})]}):null,y&&S.parameters.length>0?(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`Parameters`,"data-slot":`parameters`,children:[(0,X.jsx)(Q,{title:`Parameters`,meta:String(S.parameters.length)}),(0,X.jsx)(rr,{fields:S.parameters,layout:`grid`})]}):null,(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[y&&(S.fields.length>0||S.parameters.length===0)?(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":g,"data-slot":`request`,children:[(0,X.jsx)(Q,{title:g,meta:String(S.fields.length)}),(0,X.jsx)(rr,{fields:S.fields,emptyLabel:typeof e.flow.in==`string`?`Schema not expanded in Manifest.`:o===`signal`?`No flow input schema — signal payload shape lives on the signal when declared.`:`No input schema declared.`})]}):null,(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":_,children:[(0,X.jsx)(Q,{title:_,meta:String(x.length)}),(0,X.jsx)(rr,{fields:x,emptyLabel:typeof e.flow.out==`string`?`Schema not expanded in Manifest.`:`No output schema declared.`})]})]}),y?(0,X.jsx)(or,{fields:b}):null]})})]})}function lr({plane:e}){let t=e===`operator`,n=t?fe:Ue,i=t?`operator`:`user`;return(0,X.jsxs)(a,{children:[(0,X.jsx)(c,{render:t=>(0,X.jsxs)(`span`,{...t,className:s(v,`cursor-help`),"data-slot":`plane-badge`,"data-plane":e,children:[(0,X.jsx)(r,{icon:n,className:`size-3`,"aria-hidden":!0}),i]})}),(0,X.jsx)(o,{side:`bottom`,className:`max-w-xs text-[11px]`,children:t?`Operator plane — runs under a Console operator identity, not an application user.`:`User plane — runs under an application user identity (invoke-as).`})]})}function ur({icon:e,label:t,title:n}){return(0,X.jsxs)(a,{children:[(0,X.jsx)(c,{render:n=>(0,X.jsxs)(`span`,{...n,className:s(v,R,`cursor-help`),children:[(0,X.jsx)(r,{icon:e,className:`size-3`,"aria-hidden":!0}),t]})}),(0,X.jsx)(o,{side:`bottom`,className:`max-w-xs text-[11px]`,children:n})]})}function dr(e){let t=new Map(Fe.map(e=>[e,[]]));for(let n of e){let e=new Map;for(let t of n.flows){let n=U(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 Fe.flatMap(e=>{let n=t.get(e)??[];return n.length===0?[]:[{id:e,label:ze[e].label,groups:n}]})}var fr=`oke_units_pinned`;function pr(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e)typeof r!=`string`||r.length===0||t.has(r)||(t.add(r),n.push(r));return n}function mr(){try{if(typeof localStorage>`u`)return[];let e=localStorage.getItem(fr);return e?pr(JSON.parse(e)):[]}catch{return[]}}function hr(e){try{if(typeof localStorage>`u`)return;localStorage.setItem(fr,JSON.stringify(e))}catch{}}function gr(e,t){return e.includes(t)?e.filter(e=>e!==t):[t,...e]}function _r(e,t){if(t.length===0||e.length<2)return e;let n=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({group:e,index:t,pin:n.get(e.unit)})).sort((e,t)=>e.pin!==void 0&&t.pin!==void 0?e.pin-t.pin:e.pin===void 0?t.pin===void 0?e.index-t.index:1:-1).map(e=>e.group)}function vr(e){return`band:${e}`}function yr(e,t){return`unit:${e}:${t}`}function br(e,t,n=!1){let r=t[e];return r===void 0?n:r}function xr(e){let t=[];for(let n of e){t.push(vr(n.id));for(let e of n.groups)t.push(yr(n.id,e.unit))}return t}function Sr(e,t){for(let n of e)for(let e of n.groups)if(e.flows.some(e=>e.id===t))return[vr(n.id),yr(n.id,e.unit)];return[]}function Cr(e,t){let n=B(e.method)-B(t.method);return n===0?e.id.localeCompare(t.id):n}function wr(e){let t=e?.flows;if(!t)return[];let n=new Map;for(let[r,i]of Object.entries(t)){let t=yt(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(Cr)}))}function Tr(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 Er(e){return(e.triggerKinds?.length??0)+(e.planes?.length??0)+(e.deliveries?.length??0)+ +!!e.durableOnly+ +!!e.liveOnly}function Dr(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(U(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 Or={user:{icon:Ue,label:`user`},operator:{icon:fe,label:`operator`}},kr=[`user`,`operator`];function Ar({groups:e,selectedFlowId:t,onSelect:n}){let[i,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)({}),[m,h]=(0,Y.useState)({}),[g,_]=(0,Y.useState)(()=>mr()),v=(0,Y.useMemo)(()=>{let t=new Set;for(let n of e)for(let e of n.flows)t.add(U(e.flow.trigger));return Fe.filter(e=>t.has(e))},[e]),y=(0,Y.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 kr.filter(e=>t.has(e))},[e]),{hasDurable:x,hasLive:S,availableDeliveries:C}=(0,Y.useMemo)(()=>{let t=!1,n=!1,r=new Set;for(let i of e)for(let e of i.flows)e.flow.durable&&(t=!0),e.flow.live&&(n=!0),e.delivery&&r.add(e.delivery);return{hasDurable:t,hasLive:n,availableDeliveries:Wn.filter(e=>r.has(e))}},[e]),w=Er(f),T=(0,Y.useMemo)(()=>dr(Dr(Tr(e,i),f)),[e,i,f]),E=(0,Y.useMemo)(()=>xr(T),[T]),O=i.trim().length>0,k=E.length>0&&E.every(e=>br(e,m,O));(0,Y.useEffect)(()=>{if(!t)return;let e=Sr(T,t);e.length!==0&&h(t=>{let n=!1,r={...t};for(let t of e)r[t]!==!0&&(r[t]=!0,n=!0);return n?r:t})},[t,T]);let A=(e,t)=>{h(n=>n[e]===t?n:{...n,[e]:t})},j=()=>{let e=!k;h(t=>{let n={...t};for(let t of E)n[t]=e;return n})},M=e=>p(t=>({...t,triggerKinds:Mr(t.triggerKinds??[],e)})),N=e=>p(t=>({...t,planes:Mr(t.planes??[],e)})),P=e=>p(t=>({...t,[e]:!t[e]})),I=e=>p(t=>({...t,deliveries:Mr(t.deliveries??[],e)})),L=e=>{_(t=>{let n=gr(t,e);return hr(n),n})};return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`units-tree`,children:[(0,X.jsxs)(`div`,{className:`shrink-0 border-b border-border/60`,children:[(0,X.jsxs)(`div`,{className:s(b,`border-b-0`),children:[(0,X.jsx)(ue,{value:i,onChange:e=>l(e.target.value),placeholder:`Search flows…`,"aria-label":`Search flows`,"data-slot":`units-search`}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-stretch pr-0.5`,children:[(0,X.jsxs)(a,{children:[(0,X.jsx)(c,{render:e=>(0,X.jsxs)(`button`,{...e,type:`button`,"aria-expanded":u,"aria-controls":`units-advanced-panel`,"aria-label":w>0?`Advanced filters, ${w} active`:`Advanced filters`,"data-slot":`units-advanced-toggle`,onClick:t=>{e.onClick?.(t),d(e=>!e)},className:s(D,`relative`,(u||w>0)&&`text-foreground`),children:[(0,X.jsx)(r,{icon:We,className:`size-3`,"aria-hidden":!0}),w>0?(0,X.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:w}):null]})}),(0,X.jsx)(o,{side:`bottom`,children:`Advanced`})]}),(0,X.jsx)(at,{allOpen:k,disabled:E.length===0,onToggle:j,dataSlot:`units-tree-expand-toggle`})]})]}),u?(0,X.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,X.jsx)(jr,{label:`Trigger`,groupLabel:`Trigger kind filter`,children:v.map(e=>{let t=ze[e];return(0,X.jsx)($,{icon:t.icon,label:t.label,pressed:f.triggerKinds?.includes(e)??!1,onToggle:()=>M(e),dataFacet:`kind:${e}`},e)})}),C.length>0?(0,X.jsx)(jr,{label:`Delivery`,groupLabel:`Signal delivery filter`,children:C.map(e=>{let t=Gn[e];return(0,X.jsx)($,{icon:t.icon,label:t.label,pressed:f.deliveries?.includes(e)??!1,onToggle:()=>I(e),dataFacet:`delivery:${e}`},e)})}):null,y.length>0?(0,X.jsx)(jr,{label:`Plane`,groupLabel:`Plane filter`,children:y.map(e=>{let t=Or[e];return(0,X.jsx)($,{icon:t.icon,label:t.label,pressed:f.planes?.includes(e)??!1,onToggle:()=>N(e),dataFacet:`plane:${e}`},e)})}):null,x||S?(0,X.jsxs)(jr,{label:`Flags`,groupLabel:`Flow flags filter`,children:[x?(0,X.jsx)($,{icon:je,label:`durable`,pressed:f.durableOnly??!1,onToggle:()=>P(`durableOnly`),dataFacet:`flag:durable`}):null,S?(0,X.jsx)($,{icon:de,label:`live`,pressed:f.liveOnly??!1,onToggle:()=>P(`liveOnly`),dataFacet:`flag:live`}):null]}):null,w>0?(0,X.jsx)(`button`,{type:`button`,"data-slot":`units-advanced-clear`,onClick:()=>p({}),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,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto`,children:T.length===0?(0,X.jsx)(`p`,{className:F,children:`No flows match.`}):(0,X.jsx)(`div`,{className:`flex flex-col`,children:T.map(e=>{let r=vr(e.id);return(0,X.jsx)(Nr,{band:e,open:br(r,m,O),onOpenChange:e=>A(r,e),groupOpen:t=>br(yr(e.id,t),m,O),onGroupOpenChange:(t,n)=>A(yr(e.id,t),n),selectedFlowId:t,onSelect:n,pinned:g,onTogglePin:L},e.id)})})})]})}function jr({label:e,groupLabel:t,children:n}){return(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-14 shrink-0 text-[9px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:e}),(0,X.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:i,dataFacet:a}){return(0,X.jsxs)(`button`,{type:`button`,"data-slot":`units-facet-chip`,"data-facet":a,"aria-pressed":n,onClick:i,className:s(`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,X.jsx)(r,{icon:e,className:`size-3`,"aria-hidden":!0}),t]})}function Mr(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function Nr({band:e,open:t,onOpenChange:n,groupOpen:i,onGroupOpenChange:a,selectedFlowId:o,onSelect:c,pinned:l,onTogglePin:u}){let d=ze[e.id],f=_r(e.groups,l),p=f.reduce((e,t)=>e+t.flows.length,0),m=f.map(e=>e.unit),h=m.length>0&&m.every(e=>i(e)),g=()=>{let e=!h;for(let t of m)a(t,e);e&&n(!0)};return(0,X.jsx)(`section`,{"data-slot":`units-trigger-band`,"data-band":e.id,"aria-label":e.label,className:j,children:(0,X.jsxs)(we,{open:t,onOpenChange:n,children:[(0,X.jsx)(Se,{nativeButton:!1,className:w,"data-slot":`units-trigger-band-toggle`,render:n=>(0,X.jsxs)(`div`,{...n,children:[(0,X.jsx)(r,{icon:xe,className:s(L,!t&&`-rotate-90`),"aria-hidden":!0}),(0,X.jsx)(r,{icon:d.icon,className:s(O,x(d.wellClass)),"aria-hidden":!0}),(0,X.jsx)(`span`,{className:s(P,`flex-1`),children:e.label}),(0,X.jsx)(`span`,{className:E,children:p}),(0,X.jsx)(`span`,{className:I,children:(0,X.jsx)(at,{allOpen:h,disabled:m.length===0,onToggle:g,collapseLabel:`Collapse all in ${e.label}`,expandLabel:`Expand all in ${e.label}`,dataSlot:`units-band-expand-toggle`,disclose:!0,bare:!0})})]})}),(0,X.jsx)(be,{children:(0,X.jsx)(`ul`,{className:`flex flex-col`,children:f.map(t=>(0,X.jsx)(Pr,{group:t,open:i(t.unit),onOpenChange:e=>a(t.unit,e),selectedFlowId:o,onSelect:c,pinned:l.includes(t.unit),onTogglePin:()=>u(t.unit)},`${e.id}:${t.unit}`))})})]})})}function Pr({group:e,open:t,onOpenChange:n,selectedFlowId:i,onSelect:a,pinned:o,onTogglePin:c}){let l=o?`Unpin ${e.unit}`:`Pin ${e.unit}`;return(0,X.jsx)(`li`,{"data-slot":`unit-group`,"data-unit":e.unit,"data-pinned":o?`true`:void 0,children:(0,X.jsxs)(we,{open:t,onOpenChange:n,children:[(0,X.jsx)(Se,{nativeButton:!1,className:s(M,`pl-4`),"data-slot":`unit-group-toggle`,render:n=>(0,X.jsxs)(`div`,{...n,children:[(0,X.jsx)(r,{icon:xe,className:s(L,!t&&`-rotate-90`),"aria-hidden":!0}),(0,X.jsx)(r,{icon:st,className:s(O,`text-muted-foreground`),"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:e.unit}),(0,X.jsx)(`button`,{type:`button`,"aria-label":l,"aria-pressed":o,"data-slot":`unit-pin`,onClick:e=>{e.stopPropagation(),c()},className:s(`inline-flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground transition-[width,opacity,margin] hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:outline-none`,o?`ml-1.5 size-3.5 text-foreground`:`pointer-events-none ml-0 size-0 opacity-0 group-hover/folder:pointer-events-auto group-hover/folder:ml-1.5 group-hover/folder:size-3.5 group-hover/folder:opacity-100 group-focus-within/folder:pointer-events-auto group-focus-within/folder:ml-1.5 group-focus-within/folder:size-3.5 group-focus-within/folder:opacity-100`),children:(0,X.jsx)(r,{icon:wt,className:`size-3 shrink-0`,"aria-hidden":!0})})]}),(0,X.jsx)(`span`,{className:E,children:e.flows.length})]})}),(0,X.jsx)(be,{children:(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.flows.map(e=>(0,X.jsx)(Fr,{flow:e,selected:i===e.id,onSelect:a},e.id))})})]})})}function Fr({flow:e,selected:t,onSelect:n}){let i=Ie(e.flow.trigger),l=e.delivery?Gn[e.delivery]:null,u=l?.icon??(e.method?se(e.method):i.icon),d=x(l?.wellClass??(e.method?ce(e.method):i.wellClass)),f=l?e.signal?`${l.title} · ${e.signal}`:l.title:i.detail?`${i.label} · ${i.detail}`:i.label;return(0,X.jsx)(`li`,{children:(0,X.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:s(C,`group/flow pl-8`,t&&`bg-muted/70 text-foreground`),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:s(k,t?A:`bg-transparent`)}),(0,X.jsxs)(a,{children:[(0,X.jsx)(c,{render:e=>(0,X.jsx)(`span`,{...e,className:s(O,d),"aria-hidden":!0,children:(0,X.jsx)(r,{icon:u,className:`size-3.5`})})}),(0,X.jsx)(o,{side:`right`,className:`text-[11px]`,children:f})]}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.action}),e.method?(0,X.jsx)(Un,{method:e.method,className:`ml-auto h-3.5 px-1 text-[8px] leading-none`}):null]})})}function Ir(){let e=Ee(),t=ke();Te(!0);let{selectedFlowId:n,setSelectedFlow:r}=ft(),i=pe(),a=pe(),o=(0,Y.useMemo)(()=>wr(e.data??null),[e.data]),s=(0,X.jsx)(me,{open:i.open,onToggle:i.toggle,noun:`flows`,controlsId:`flows-tree`,dataSlot:`flows-tree-toggle`}),c=(0,X.jsx)(me,{open:a.open,onToggle:a.toggle,noun:`Call API`,controlsId:`call-api-rail`,dataSlot:`call-api-toggle`,side:`end`}),l=n??o[0]?.flows[0]?.id??null,u=(0,Y.useMemo)(()=>{if(!l)return null;for(let e of o){let t=e.flows.find(e=>e.id===l);if(t)return t}return null},[o,l]);return(0,X.jsx)(`div`,{className:N,"data-slot":`units-page`,children:(0,X.jsxs)(V,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,X.jsx)(H,{panelRef:i.panelRef,collapsible:!0,collapsedSize:0,defaultSize:T.start.defaultSize,minSize:T.start.minSize,onResize:i.onResize,className:`min-h-0 overflow-hidden`,children:(0,X.jsx)(`div`,{id:`flows-tree`,className:`h-full min-h-0 overflow-hidden`,"data-slot":`flows-tree`,children:(0,X.jsx)(Ar,{groups:o,selectedFlowId:l,onSelect:e=>{r(e)}})})}),i.open?(0,X.jsx)(he,{withHandle:!0}):null,(0,X.jsx)(H,{defaultSize:T.end.defaultSize,minSize:T.end.minSize,className:`min-h-0 overflow-hidden`,children:(0,X.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:u?(0,X.jsxs)(V,{orientation:`horizontal`,className:`min-h-0 flex-1`,"data-slot":`units-inspector`,children:[(0,X.jsx)(H,{defaultSize:`62%`,minSize:`36%`,className:`min-h-0 overflow-hidden`,children:(0,X.jsx)(cr,{row:u,manifest:e.data??null,runs:t.data,leading:s,trailing:c})}),a.open?(0,X.jsx)(he,{withHandle:!0}):null,(0,X.jsx)(H,{panelRef:a.panelRef,collapsible:!0,collapsedSize:0,defaultSize:`38%`,minSize:`352px`,onResize:a.onResize,className:`min-h-0 overflow-hidden`,children:(0,X.jsx)(`div`,{id:`call-api-rail`,className:`h-full min-h-0 overflow-hidden`,children:(0,X.jsx)(Tn,{row:u,manifest:e.data??null})})})]}):(0,X.jsx)(ht,{icon:_e.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:s})})})]})})}export{Ir as UnitsPage};
|
|
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{$n as r,E as i,F as a,I as o,Qn as s,R as c,a as l,er as u,i as d,l as f,o as p,s as m,tr as h,u as g,x as _}from"./shortcut-keys-DTE1sjTC.js";import{C as v,D as y,E as b,O as x,S,_ as C,a as w,b as T,c as E,d as D,f as O,g as k,h as A,i as j,l as M,m as N,o as P,p as F,r as I,s as L,w as R,x as z}from"./explorer-chrome-Dslh2yE8.js";import{c as ee,l as te,n as ne,o as re,r as ie,t as ae}from"./call-pii-button-L9JxdBhp.js";import{a as B,n as oe,r as se,t as ce}from"./http-method-BwhJBTcQ.js";import{a as V,b as le,c as ue,g as de,i as H,m as fe,n as pe,o as me,r as he,s as ge,t as _e}from"./element-icons-C6t8Vlml.js";import{a as ve,i as ye,n as be,o as xe,r as Se,s as Ce,t as we}from"./collapsible-BvFaX-Zt.js";import{a as Te,c as Ee,f as De,i as Oe,s as ke,t as Ae,u as je}from"./highlighted-json-DMvsi3Ti.js";import{T as Me,c as Ne,d as Pe,f as Fe,h as Ie,l as Le,m as U,o as Re,p as ze,s as Be,t as Ve,u as He}from"./request-meta-C6lTyCXp.js";import{t as Ue}from"./UserIcon-DaE2PB5_.js";import{n as We}from"./dagre.esm-B1_XeuLP.js";import{$ as W,G as Ge,Q as G,X as K,Y as q,a as Ke,c as qe,d as Je,et as Ye,f as Xe,h as Ze,i as Qe,n as $e,nt as et,o as tt,p as nt,r as rt,s as it,t as at,u as ot,ut as st,v as ct}from"./tree-expand-toggle-DYeL6Rye.js";import{d as lt,r as ut,t as dt}from"./dropdown-menu-CRGrj5JU.js";import{Ot as ft,gt as pt,jt as mt}from"./index-RhV2jT_7.js";import{t as ht}from"./explorer-empty-CIVg7Jgb.js";import{c as J,n as gt,t as _t,u as vt}from"./detail-header-Dk5LipF6.js";import{c as yt,n as bt,s as xt,t as St}from"./cache-glyph-D3MY49h3.js";var Ct=[[`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`}]],wt=[[`path`,{d:`M3 21L8 16`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M13.2585 18.8714C9.51516 18.0215 5.97844 14.4848 5.12853 10.7415C4.99399 10.1489 4.92672 9.85266 5.12161 9.37197C5.3165 8.89129 5.55457 8.74255 6.03071 8.44509C7.10705 7.77265 8.27254 7.55888 9.48209 7.66586C11.1793 7.81598 12.0279 7.89104 12.4512 7.67048C12.8746 7.44991 13.1622 6.93417 13.7376 5.90269L14.4664 4.59604C14.9465 3.73528 15.1866 3.3049 15.7513 3.10202C16.316 2.89913 16.6558 3.02199 17.3355 3.26771C18.9249 3.84236 20.1576 5.07505 20.7323 6.66449C20.978 7.34417 21.1009 7.68401 20.898 8.2487C20.6951 8.8134 20.2647 9.05346 19.4039 9.53358L18.0672 10.2792C17.0376 10.8534 16.5229 11.1406 16.3024 11.568C16.0819 11.9955 16.162 12.8256 16.3221 14.4859C16.4399 15.7068 16.2369 16.88 15.5555 17.9697C15.2577 18.4458 15.1088 18.6839 14.6283 18.8786C14.1477 19.0733 13.8513 19.006 13.2585 18.8714Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}]],Tt=[[`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`}]],Et=[[`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`}]],Y=e(t(),1),X=n();function Dt(e,t){let n=it(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 Ot(e){let t=it(e.asGate);return t===`operator`||t===`public`||!!(e.asUserId||e.asGate)}function kt({manifest:e,identities:t,value:n,onChange:i}){let a=Ge(!0),o=(0,Y.useMemo)(()=>Ze(ct(e),a.data??null),[e,a.data]),c=(0,Y.useMemo)(()=>qe(o),[o]),l=(0,Y.useMemo)(()=>ot(t,o),[t,o]),u=o.gates.find(e=>e.kind===`public`)?.description??`Intentionally unauthenticated.`,d=it(n.asGate),f=n.asGate!==null,[p,m]=(0,Y.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,v=c.length>0||l.length>0,y=e=>{if(e===`operator`){i({asGate:null,asUserId:null});return}if(e===`public`){i({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`),i({asGate:l[0].gate,asUserId:l[0].id});return}m(`policy`),i({asGate:t,asUserId:null})}};return(0,X.jsxs)(dt,{children:[(0,X.jsx)(lt,{render:e=>(0,X.jsxs)(_,{...e,type:`button`,variant:`ghost`,size:`sm`,className:s(`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,X.jsx)(r,{icon:_e.gate.icon,"data-icon":`inline-start`,className:`size-3.5`}),(0,X.jsx)(`span`,{className:`truncate`,children:Dt(n,t)})]})}),(0,X.jsxs)(ut,{align:`end`,className:`w-80 overflow-hidden p-0`,children:[(0,X.jsx)(tt,{children:`Invoke as`}),(0,X.jsxs)(Ke,{label:`Invoke as`,children:[(0,X.jsx)(rt,{mode:`operator`,title:`Operator`,caption:`Bypass`,selected:d===`operator`,onSelect:()=>y(`operator`)}),(0,X.jsx)(rt,{mode:`public`,title:`Public`,caption:`Anonymous`,selected:d===`public`,onSelect:()=>y(`public`)}),(0,X.jsx)(rt,{mode:`as`,title:`As`,caption:g?g.label:h?.label??`User / policy`,selected:d===`as`,disabled:!v,onSelect:()=>y(`as`)})]}),d===`operator`?(0,X.jsx)(Qe,{title:`Operator`,badge:`Default`,children:`Bypasses the flow's gate chain.`}):null,d===`public`?(0,X.jsxs)(Qe,{title:`Public`,children:[u,` Only `,(0,X.jsx)(`span`,{className:`font-mono`,children:`gate.public`}),` flows succeed.`]}):null,d===`as`?(0,X.jsx)($e,{tab:p,onTabChange:m,policies:c,users:l,asGate:n.asGate,asUserId:g?.id??null,onSelectPolicy:e=>{m(`policy`),i({asGate:e.id,asUserId:null})},onSelectUser:e=>{m(`user`),i({asGate:e.gate,asUserId:e.id})},hint:g?(0,X.jsxs)(`p`,{className:`border-t border-border/60 px-2 py-2 text-[10px] leading-relaxed text-muted-foreground`,children:[`Calls as `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:g.label}),` `,`via `,(0,X.jsx)(`span`,{className:`font-mono`,children:n.asGate}),`.`]}):h?(0,X.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,X.jsx)(`span`,{className:`font-mono`,children:h.id}),`.`]}):null}):null]})]})}var At=new Set([`q`,`query`,`search`,`limit`,`offset`,`cursor`,`page`,`pageSize`,`perPage`,`per_page`,`page_size`,`order`,`orderBy`,`order_by`,`sort`,`sortBy`,`sort_by`,`direction`]);function jt(e,t=[]){let n=new Set,r=[];for(let i of t){n.add(i);let t=e.find(e=>e.name===i);r.push(t??Mt(i))}let i=[];for(let t of e)n.has(t.name)||(At.has(t.name)?r.push(t):i.push(t));return{parameters:r,fields:i}}function Mt(e){return{path:`/path/${e}`,name:e,type:`string`,required:!0}}function Nt(e,t={}){let n=t.pathParams??[],r=new Set(n);if(t.http!==!0)return{path:[],query:[],body:e};let i=e.filter(e=>!r.has(e.name));return oe(t.method)?{path:n,query:[],body:i}:{path:n,query:i,body:[]}}function Pt(e,t){let n={};for(let r of t)Object.hasOwn(e,r.name)&&(n[r.name]=e[r.name]);return n}function Z(e,t=``){if(!e)return[];if(e.type===`object`||e.properties){let n=e.properties??{},r=new Set(Array.isArray(e.required)?e.required:[]);return Object.entries(n).map(([e,n])=>Ft(e,`${t}/${e}`,n,r.has(e)))}return[Ft(`value`,t||`/`,e,!0)]}function Ft(e,t,n,r){let i=It(e,n),a=typeof n.description==`string`?n.description:void 0;if(Array.isArray(n.enum)){let o=Ut(n);return{path:t,name:e,type:`enum`,required:r,enumValues:n.enum.map(String),...a===void 0?{}:{description:a},...o===void 0?{}:{valueMeanings:o},...i}}let o=n.type;if(o===`object`||n.properties)return{path:t,name:e,type:`object`,required:r,...a===void 0?{}:{description:a},...i,children:Z(n,t)};if(o===`array`)return{path:t,name:e,type:`array`,required:r,...a===void 0?{}:{description:a},...i,children:n.items?Z(n.items,`${t}/0`):void 0};let s=o===`integer`||o===`number`||o===`boolean`||o===`string`?o:`unknown`,c=Ut(n);return{path:t,name:e,type:s,required:r,minimum:typeof n.minimum==`number`?n.minimum:void 0,maximum:typeof n.maximum==`number`?n.maximum:void 0,...a===void 0?{}:{description:a},...c===void 0?{}:{valueMeanings:c},...i}}function It(e,t){let n=Lt(e),r=Rt(t.references),i=t.primaryKey===!0||n.primaryKey===!0,a=r!==void 0||n.foreignKey===!0,o=!i&&(t.unique===!0||n.unique===!0);return{...t.pii===!0?{pii:!0}:{},...t.sensitive===!0?{sensitive:!0}:{},...i?{primaryKey:!0}:{},...a?{foreignKey:!0}:{},...o?{unique:!0}:{},...r===void 0?{}:{references:r}}}function Lt(e){return e===`id`?{primaryKey:!0}:/(?:Id|_id)$/.test(e)||/(?:Key|_key)$/.test(e)&&e!==`key`?{foreignKey:!0}:e===`identifier`||e===`key`?{unique:!0}:{}}function Rt(e){if(!e||typeof e!=`object`)return;let t=`table`in e&&typeof e.table==`string`?e.table:void 0;if(!t)return;let n=`column`in e&&typeof e.column==`string`?e.column:void 0;return n===void 0?{table:t}:{table:t,column:n}}var zt=12;function Bt(e){return e.enumValues&&e.enumValues.length>0?e.enumValues.join(` · `):e.minimum!==void 0&&e.maximum!==void 0?`${e.minimum}–${e.maximum}`:e.minimum===void 0?e.maximum===void 0?null:`≤ ${e.maximum}`:`≥ ${e.minimum}`}function Vt(e){return e.minimum!==void 0&&e.maximum!==void 0?`Must be from ${e.minimum} up to ${e.maximum}.`:e.minimum===void 0?e.maximum===void 0?null:`Must be at most ${e.maximum}.`:`Must be at least ${e.minimum}.`}function Ht(e){return e.filter(e=>e.minimum!==void 0||e.maximum!==void 0||(e.enumValues?.length??0)>0||(e.valueMeanings?.length??0)>0)}function Ut(e){let t=Array.isArray(e.oneOf)?e.oneOf:Array.isArray(e.anyOf)?e.anyOf:null;if(t){let e=[];for(let n of t){if(!n||typeof n!=`object`)continue;let t=n;if(!(`const`in t))continue;let r=String(t.const),i=typeof t.title==`string`?t.title:typeof t.description==`string`?t.description:void 0;i&&e.push({value:r,label:i})}return e.length>0?e:void 0}}function Wt(e){if(e.type!==`integer`||e.minimum===void 0||e.maximum===void 0||!Number.isInteger(e.minimum)||!Number.isInteger(e.maximum))return null;let t=e.maximum-e.minimum;return t<0||t>zt?null:Array.from({length:t+1},(t,n)=>e.minimum+n)}function Gt(e){return e?Kt(e):{}}function Kt(e){if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];let t=e.type;if(t===`object`||!t&&e.properties){let t=e.properties??{},n=new Set(Array.isArray(e.required)?e.required:[]),r={};for(let[e,i]of Object.entries(t))(n.has(e)||`default`in i||Object.keys(t).length<=4)&&(r[e]=Kt(i));return r}if(t===`array`){let t=e.items;return t?[Kt(t)]:[]}return t===`integer`||t===`number`?typeof e.default==`number`?e.default:typeof e.minimum==`number`?e.minimum:1:t===`boolean`?!1:t===`string`?e.format===`email`?`user@example.com`:e.format===`uuid`?`00000000-0000-4000-8000-000000000001`:typeof e.default==`string`?e.default:e.minLength?`x`.repeat(Number(e.minLength)):``:null}function qt(e){return!e||typeof e==`string`?null:e}function Jt(e,t){if(!e.foreignKey||!t)return null;let n=Qt(t);if(n.length===0)return null;if(e.references?.table){let t=$t(n,e.references.table);return t?Xt(t,e.references.column??tn(t.table)??`id`):null}let r=Zt(e.name);if(!r)return null;let i=en(n,r.stem);return i?Xt(i,r.kind===`key`?nn(i.table,`key`)??tn(i.table)??`id`:tn(i.table)??`id`):null}function Yt(e,t){if(!t)return[];let n=new Set,r=[];for(let i of e){let e=i[t.column];if(e==null)continue;let a=String(e);if(n.has(a))continue;n.add(a);let o=t.labelColumn?i[t.labelColumn]:void 0,s=o!=null&&String(o)!==a?String(o):null;r.push({value:a,label:s?`${a} · ${s}`:a})}return r}function Xt(e,t){let n=rn(e.table,t);return{ref:e.ref,child:e.name,column:t,...n===void 0?{}:{labelColumn:n}}}function Zt(e){return e===`id`?null:e.endsWith(`Id`)?{stem:e.slice(0,-2),kind:`id`}:e.endsWith(`_id`)?{stem:e.slice(0,-3),kind:`id`}:e.endsWith(`Key`)?{stem:e.slice(0,-3),kind:`key`}:e.endsWith(`_key`)?{stem:e.slice(0,-4),kind:`key`}:null}function Qt(e){let t=[];for(let[n,r]of Object.entries(e.stores??{}))r.facet===`sql`&&r.tables&&t.push({ref:`sql:${n}`,tables:r.tables});return t}function $t(e,t){let n=t.toLowerCase();for(let t of e)for(let[e,r]of Object.entries(t.tables))if(e.toLowerCase()===n)return{ref:t.ref,name:e,table:r};return null}function en(e,t){let n=sn(t),r=[t,n,on(t),on(n)].map(e=>e.toLowerCase());for(let t of e)for(let[e,n]of Object.entries(t.tables))if(r.includes(e.toLowerCase()))return{ref:t.ref,name:e,table:n};return null}function tn(e){for(let[t,n]of Object.entries(e.columns??{}))if(an(n)&&n.primaryKey===!0)return t;if(e.columns&&`id`in e.columns)return`id`}function nn(e,t){return e.columns&&t in e.columns?t:void 0}function rn(e,t){if(t!==`name`&&e.columns&&`name`in e.columns)return`name`}function an(e){return`type`in e||`primaryKey`in e||`references`in e}function on(e){return e.endsWith(`y`)&&!/[aeiou]y$/i.test(e)?`${e.slice(0,-1)}ies`:/(?:s|x|z|ch|sh)$/i.test(e)?`${e}es`:`${e}s`}function sn(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/([A-Z])([A-Z][a-z])/g,`$1_$2`).toLowerCase()}function cn(e){let t=[];for(let n of e.split(`/`))n.startsWith(`:`)&&n.length>1&&t.push(n.slice(1));return t}function ln(e){return`:${e}`}var un={"attachments:id":`attachments/tsk_eng_12/spec.pdf`,"tasks:id":`tsk_eng_12`,"comments:id":`cmt_1`,"projects:id":`proj_api`,"spaces:id":`space_eng`,"tags:id":`tag_bug`,"tags:tagId":`tag_feature`,"goals:id":`goal_harbor`,"documents:id":`doc_prd_api`,"members:id":`mem_aria`,"forms:id":`form_customer`,"drafts:id":`ENG-12`,"views:id":`view_web_board`,"inbox:id":`inb_1`};function dn(e,t){let n=e.split(`/`).filter(Boolean),r=`:${t}`,i=n.indexOf(r),a=i>0?n[i-1]:void 0;return(a?un[`${a}:${t}`]:void 0)??un[`:${t}`]}function fn(e,t){let n={};if(!e)return n;for(let r of t){let t=dn(e,r);t&&(n[r]=t)}return n}function pn(e,t){let n=e?.flows?.[t],r=n?.trigger?.cron,i=n?.trigger?.every;if(!r&&!i)return{kind:`unmatched`};let a=e?.clocks??{},o=new Set;for(let[e,n]of Object.entries(a)){if(t===e||t.endsWith(`.${e}`)){o.add(e);continue}if(r&&n.cron===r){o.add(e);continue}i&&n.every===i&&o.add(e)}if(o.size!==1)return{kind:`unmatched`};let s=[...o][0],c=a[s];return{kind:`matched`,clockName:s,timezone:c.timezone??null,description:c.description??null,cron:c.cron??null,every:c.every??null}}function mn(e){let t=e.handlerMs!=null&&Number.isFinite(e.handlerMs)?e.handlerMs:null;return t===null?e.rttMs!==null&&Number.isFinite(e.rttMs)?{primaryMs:e.rttMs,primaryKind:`rtt`,rttMs:e.rttMs}:null:{primaryMs:t,primaryKind:`handler`,rttMs:e.rttMs}}function hn(e){let t=new Set;if(!e?.stores)return t;for(let n of Object.values(e.stores)){for(let e of Object.values(n.tables??{}))for(let[n,r]of Object.entries(e.columns??{}))r?.pii&&ie(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;ie(t,n)}}return t}function gn(e,t,n=ne){if(t.size===0||e==null)return e;if(Array.isArray(e))return e.map(e=>gn(e,t,n));if(typeof e==`object`){let r={};for(let[i,a]of Object.entries(e))r[i]=t.has(i)?n:gn(a,t,n);return r}return e}function _n(e){return e.failure==null?e.response!==void 0&&e.response!==null?JSON.stringify(e.response,null,2):JSON.stringify({status:e.status??200,failure:null,response:null},null,2):JSON.stringify({status:e.status??null,failure:e.failure,response:e.response??null},null,2)}function vn(e,t,n){return t&&e.masked===!1?_n({...e,response:gn(e.response,n),failure:e.failure===void 0?void 0:{...e.failure,data:gn(e.failure.data,n)},masked:!0}):_n(e)}function yn(e){let t=e.flow.effects;return!t||(t.writes?.length??0)===0&&(t.emits?.length??0)===0&&(t.sends?.length??0)===0&&(t.asks?.length??0)===0&&(t.embeds?.length??0)===0&&(t.fetches?.length??0)===0}function bn(e,t){return!t&&yn(e)}function xn(e,t){if(!e)return{ok:!0,errors:[],value:t};let n=[];return Sn(e,t,``,n),{ok:n.length===0,errors:n,value:t}}function Sn(e,t,n,r){let i=e.type;if(i===`object`||e.properties){if(typeof t!=`object`||!t||Array.isArray(t)){r.push({path:n||`/`,message:`must be object`});return}let i=t,a=e.properties??{},o=Array.isArray(e.required)?e.required:[];for(let e of o)(i[e]===void 0||i[e]===null||i[e]===``)&&r.push({path:`${n}/${e}`,message:`required`});for(let[e,t]of Object.entries(a))i[e]!==void 0&&Sn(t,i[e],`${n}/${e}`,r);return}if(Array.isArray(e.enum)){e.enum.map(String).includes(String(t))||r.push({path:n||`/`,message:`invalid enum`});return}i===`string`&&typeof t!=`string`?r.push({path:n||`/`,message:`must be string`}):i===`integer`?typeof t!=`number`||!Number.isInteger(t)?r.push({path:n||`/`,message:`must be integer`}):Cn(e,t,n,r):i===`number`?typeof t!=`number`||Number.isNaN(t)?r.push({path:n||`/`,message:`must be number`}):Cn(e,t,n,r):i===`boolean`&&typeof t!=`boolean`&&r.push({path:n||`/`,message:`must be boolean`})}function Cn(e,t,n,r){let i=typeof e.minimum==`number`?e.minimum:void 0,a=typeof e.maximum==`number`?e.maximum:void 0;i!==void 0&&t<i&&r.push({path:n||`/`,message:`must be ≥ ${i}`}),a!==void 0&&t>a&&r.push({path:n||`/`,message:`must be ≤ ${a}`})}function wn(e){return JSON.stringify(e,null,2)}function Tn({row:e,manifest:t}){let n=U(e.flow.trigger);return n===`cron`||n===`every`?(0,X.jsx)(En,{row:e,manifest:t}):(0,X.jsx)(Dn,{row:e,kind:n,manifest:t})}function En({row:e,manifest:t}){let n=(0,Y.useMemo)(()=>pn(t,e.id),[t,e.id]),i=Je(),a=Xe(),o=nt(),[s,c]=(0,Y.useState)({asGate:null,asUserId:null}),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{i.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 i.mutateAsync({name:n.clockName})}catch{}return}if(Ot(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?i.isPending:o.isPending,g=p?i.isError:o.isError||o.isSuccess&&o.data?.failure!=null,v=p?i.isSuccess:o.isSuccess&&!o.data?.failure,y=l!==null&&(v||g)?performance.now()-l:null,b=(0,Y.useMemo)(()=>p&&i.data?JSON.stringify(i.data,null,2):!p&&o.data?_n(o.data):null,[p,i.data,o.data]),x=p?`Run now`:`Run handler`,S=p?`Run now`:`Run handler once`;return(0,X.jsx)(jn,{title:x,dataMode:p?`clock`:`invoke-fallback`,actions:(0,X.jsxs)(X.Fragment,{children:[p?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(kt,{manifest:t,identities:a.data??[],value:s,onChange:c}),(0,X.jsx)(In,{})]}),(0,X.jsx)(_,{type:`button`,"data-slot":`call-api-submit`,disabled:h||!p&&!Ot(s),onClick:()=>void m(),className:Fn,children:h?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{icon:pt,className:`animate-spin`,"data-icon":`inline-start`}),`Running…`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{icon:ee,"data-icon":`inline-start`}),S]})})]}),children:(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[p?(0,X.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,X.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:n.clockName}),` `,`via`,` `,(0,X.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,X.jsxs)(X.Fragment,{children:[` `,`Timezone · `,(0,X.jsx)(`span`,{className:`font-mono`,children:n.timezone}),`.`]}):null]}):(0,X.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,X.jsx)(`strong`,{className:`font-medium`,children:`Run handler once`}),` uses`,` `,(0,X.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,X.jsx)(`em`,{children:`not`}),` exercise the Clock lease / scheduler path.`]}),(0,X.jsx)(On,{failed:!!g,success:!!v,elapsed:y,handlerMs:p?null:o.data?.durationMs,statusCode:p?i.data?.ran?200:409:o.data?.status,errorMessage:p?i.isError?i.error.message:null:o.isError?o.error.message:null,responseJson:b,emptyHint:p?`Run now to fire the real clock tick.`:`Run handler once to invoke with empty input.`,pathUsed:d,cache:p?void 0:o.data?.cache})]})})}function Dn({row:e,kind:t,manifest:n}){let l=Xe(),u=nt(),d=qt(e.flow.in),f=(0,Y.useMemo)(()=>Z(d),[d]),p=(0,Y.useMemo)(()=>t===`http`&&e.path?cn(e.path):[],[t,e.path]),m=(0,Y.useMemo)(()=>Nt(f,{http:t===`http`,method:e.method,pathParams:p}),[f,t,e.method,p]),h=t!==`http`||oe(e.method),[g,v]=(0,Y.useState)({asGate:null,asUserId:null}),[y,b]=(0,Y.useState)(!0),[x,S]=(0,Y.useState)(()=>fn(e.path,p)),C=(0,Y.useMemo)(()=>Gt(d)??{},[d]),w=(0,Y.useMemo)(()=>Pt(C,m.query),[C,m.query]),T=(0,Y.useMemo)(()=>Pt(C,m.body),[C,m.body]),[E,D]=(0,Y.useState)(w),[O,k]=(0,Y.useState)(T),[A,j]=(0,Y.useState)(`fields`),[M,N]=(0,Y.useState)(()=>wn(T)),[P,F]=(0,Y.useState)(null),[I,L]=(0,Y.useState)([]),[R,z]=(0,Y.useState)(null),[te,ne]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{D(w),k(T),N(wn(T)),F(null),j(`fields`),S(fn(e.path,p)),L([]),ne(null),z(null),u.reset()},[e.id]);function re(e){try{let t=JSON.parse(e);return typeof t!=`object`||!t||Array.isArray(t)?(F(`Body must be a JSON object.`),!1):(k(t),F(null),!0)}catch(e){return F(e instanceof Error?e.message:`Invalid JSON.`),!1}}function ie(e){if(e!==A){if(e===`raw`){N(wn(O)),F(null),j(`raw`);return}re(M)&&j(`fields`)}}async function B(t=!y){let n=h?O:{};if(h&&A===`raw`){if(!re(M))return;try{n=JSON.parse(M)}catch{return}}let r={...E,...n},i=xn(d,{...x,...r});if(!i.ok){L(i.errors);return}if(L([]),Ot(g)){z(performance.now());try{await u.mutateAsync({flowId:e.id,body:r,...g.asUserId?{asUserId:g.asUserId}:{},...g.asGate?{asGate:g.asGate}:{},...p.length>0?{pathParams:x}:{},...t?{revealPii:!0}:{}})}catch{}}}function se(){D(w),k(T),N(wn(T)),F(null),S(fn(e.path,p)),L([])}(0,Y.useEffect)(()=>{R===null||u.isPending||(u.isSuccess||u.isError)&&ne(performance.now()-R)},[u.isSuccess,u.isError,u.isPending,R]);let ce=(0,Y.useMemo)(()=>u.data?vn(u.data,y,hn(n)):null,[u.data,y,n]),V=u.data?.failure!=null,le=u.data?.status,ue=t===`http`?`Call API`:t===`signal`?`Run handler`:`Invoke`,de=ue;return(0,X.jsx)(jn,{title:ue,dataTrigger:t,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(kt,{manifest:n,identities:l.data??[],value:g,onChange:v}),(0,X.jsx)(ae,{piiMasked:y,disabled:u.isPending,onToggle:()=>{let t=!y;b(t),u.data&&!u.isPending&&bn(e,t)&&B(!0)}}),h?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(In,{}),(0,X.jsx)(Mn,{view:A,onChange:ie})]}):null,(0,X.jsx)(In,{}),(0,X.jsxs)(a,{children:[(0,X.jsx)(c,{render:e=>(0,X.jsxs)(_,{...e,type:`button`,variant:`ghost`,"data-slot":`call-api-reset`,disabled:u.isPending,onClick:se,className:Pn,children:[(0,X.jsx)(r,{icon:De,"data-icon":`inline-start`}),`Reset`]})}),(0,X.jsx)(o,{side:`bottom`,className:`text-[11px]`,children:h?`Reset body to the schema example`:`Reset to schema examples`})]}),(0,X.jsx)(In,{}),(0,X.jsx)(_,{type:`button`,"data-slot":`call-api-submit`,disabled:u.isPending||!Ot(g),onClick:()=>void B(),className:Fn,children:u.isPending?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{icon:pt,className:`animate-spin`,"data-icon":`inline-start`}),`Calling…`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{icon:ee,"data-icon":`inline-start`}),de]})})]}),children:(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,X.jsxs)(`div`,{className:`min-h-0 min-w-0 shrink overflow-y-auto`,children:[t===`http`?(0,X.jsxs)(`p`,{className:`px-3 pt-2.5 pb-2 text-[11px] leading-snug text-muted-foreground`,children:[`Operator session · invoke-as`,` `,(0,X.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`console:flows:invoke-as`})]}):null,t===`signal`?(0,X.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,X.jsx)(`strong`,{className:`font-medium`,children:`Run handler directly`}),` — invokes the flow with your payload via`,` `,(0,X.jsx)(`code`,{className:`rounded bg-muted/50 px-1 py-px font-mono text-[10px]`,children:`/console/flows/invoke`}),`. It does `,(0,X.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,X.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,X.jsx)(`code`,{className:`font-mono text-[10px]`,children:`fx.call`}),` /`,` `,(0,X.jsx)(`code`,{className:`font-mono text-[10px]`,children:`effects.calls`}),`). The body still matches `,(0,X.jsx)(`code`,{className:`font-mono text-[10px]`,children:`flow.in`}),`.`]}):null,t===`cdc`?(0,X.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,X.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Path params`,"data-slot":`call-api-path`,children:[(0,X.jsx)(Rn,{title:`Path params`,hint:e.path??void 0}),p.map(e=>(0,X.jsx)(J,{label:e,className:`[&>span]:px-3`,children:(0,X.jsx)(i,{id:`path-${e}`,flat:!0,className:s(gt,`px-3 font-mono`),placeholder:ln(e),value:x[e]??``,onChange:t=>S(n=>({...n,[e]:t.target.value}))})},e))]}):null,m.query.length>0?(0,X.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Query params`,"data-slot":`call-api-query`,children:[(0,X.jsx)(Rn,{title:`Query params`,hint:`seeded from schema`}),(0,X.jsx)(vt,{children:m.query.map(e=>(0,X.jsx)(zn,{field:e,idPrefix:`query`,value:E[e.name],onChange:t=>D(n=>({...n,[e.name]:t})),error:I.find(t=>t.path===`/${e.name}`||t.path===e.path),wide:e.type===`object`||e.type===`array`,manifest:n},e.path))})]}):null,h?(0,X.jsxs)(`section`,{className:`min-w-0`,"aria-label":`Body`,"data-slot":`call-api-body`,children:[(0,X.jsx)(Rn,{title:`Body`,hint:A===`raw`?`raw JSON`:`seeded from schema`}),A===`raw`?(0,X.jsxs)(`div`,{className:`border-b border-border/50`,children:[(0,X.jsx)(`textarea`,{"data-slot":`call-api-body-raw`,"aria-label":`Raw JSON body`,spellCheck:!1,value:M,onChange:e=>{N(e.target.value),P&&F(null)},className:s(`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`,P&&`text-destructive`)}),P?(0,X.jsx)(`p`,{role:`alert`,className:`px-3 pb-2 text-xs text-destructive`,"data-slot":`call-api-raw-error`,children:P}):null]}):m.body.length===0?(0,X.jsx)(`p`,{className:`border-b border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:`No body fields (empty object).`}):(0,X.jsx)(vt,{children:m.body.map(e=>(0,X.jsx)(zn,{field:e,value:O[e.name],onChange:t=>k(n=>({...n,[e.name]:t})),error:I.find(t=>t.path===`/${e.name}`||t.path===e.path),wide:e.type===`object`||e.type===`array`,manifest:n},e.path))})]}):null,I.length>0?(0,X.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,X.jsx)(On,{failed:!!V,success:!!u.data&&!V,elapsed:te,handlerMs:u.data?.durationMs,statusCode:le,errorMessage:u.isError?u.error.message:null,responseJson:ce,emptyHint:`Call to see a real host response.`,pathUsed:null,cache:u.data?.cache})]})})}function On({failed:e,success:t,elapsed:n,handlerMs:i,statusCode:a,errorMessage:o,responseJson:c,emptyHint:u,pathUsed:_,cache:v}){let[b,x]=(0,Y.useState)(!1),S=(0,X.jsx)(An,{failed:e,success:t,elapsed:n,handlerMs:i,statusCode:a,pathUsed:_,cache:v});return(0,X.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,X.jsxs)(`div`,{className:z,children:[(0,X.jsx)(`h4`,{className:s(y,`flex items-center px-2`),children:`Response`}),(0,X.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,children:[S,c?(0,X.jsx)(ge,{label:`Expand response`,className:`flex self-stretch`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":`Expand response`,"data-slot":`call-api-response-expand`,className:D,onClick:()=>x(!0),children:(0,X.jsx)(r,{icon:Ct,className:`size-3.5`,"aria-hidden":!0})})}):null]})]}),o?(0,X.jsx)(`p`,{role:`alert`,className:`px-2 py-2 text-sm text-destructive`,"data-slot":`call-api-error`,children:o}):null,c?(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,"data-slot":`call-api-response-frame`,children:[(0,X.jsx)(`div`,{className:s(`w-1 shrink-0 self-stretch`,e?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0,"data-slot":`call-api-response-rail`}),(0,X.jsx)(Ae,{json:c,dataSlot:`call-api-response`,className:`flex min-h-0 flex-1 overflow-auto`})]}):(0,X.jsx)(`p`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:u}),c?(0,X.jsx)(d,{open:b,onOpenChange:x,children:(0,X.jsxs)(p,{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,X.jsxs)(f,{className:s(z,`flex-row gap-0 border-border/60 p-0`),children:[(0,X.jsx)(g,{className:s(y,`flex items-center px-2`),children:`Response`}),(0,X.jsx)(m,{className:`sr-only`,children:`Full Call API response JSON`}),(0,X.jsxs)(`div`,{className:`ml-auto flex h-full items-stretch`,children:[S,(0,X.jsx)(kn,{json:c}),(0,X.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0}),(0,X.jsxs)(l,{"aria-label":`Close`,className:D,"data-slot":`call-api-response-close`,children:[(0,X.jsx)(r,{icon:h,className:`size-3.5`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,X.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,X.jsx)(`div`,{className:s(`w-1 shrink-0 self-stretch`,e?`bg-destructive`:`bg-emerald-500`),"aria-hidden":!0}),(0,X.jsx)(Ae,{json:c,dataSlot:`call-api-response-expanded`,className:`flex min-h-0 flex-1 overflow-auto`})]})})]})}):null]})}function kn({json:e}){let[t,n]=(0,Y.useState)(!1);return(0,X.jsx)(ge,{label:t?`Copied`:`Copy response`,className:`flex self-stretch`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":t?`Copied`:`Copy response`,"data-slot":`call-api-response-copy`,className:D,onClick:()=>{navigator.clipboard&&navigator.clipboard.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1200)})},children:(0,X.jsx)(r,{icon:t?u:le,className:`size-3.5`,"aria-hidden":!0})})})}function An({failed:e,success:t,elapsed:n,handlerMs:i,statusCode:l,pathUsed:d,cache:f}){let p=t||e,m=p?mn({handlerMs:i,rttMs:n}):null;return(0,X.jsxs)(X.Fragment,{children:[d?(0,X.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,X.jsxs)(`span`,{className:s(`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,X.jsx)(r,{icon:e?Ce:u,className:`size-3`,"aria-hidden":!0}),l??(e?`error`:`ok`)]}):null,p?(0,X.jsx)(`span`,{className:`flex h-full items-center px-2`,children:(0,X.jsx)(St,{cache:f??`none`,dataSlot:`call-api-cache`})}):null,m?(0,X.jsxs)(a,{children:[(0,X.jsx)(c,{render:e=>(0,X.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:Oe(m.primaryMs)})}),(0,X.jsx)(o,{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,X.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:[Oe(m.rttMs),` rtt`]}):null]})}function jn({title:e,actions:t,children:n,dataTrigger:i,dataMode:a}){return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`call-api-panel`,"data-trigger":i,"data-mode":a,children:[(0,X.jsxs)(`div`,{className:s(b,`min-w-0`),children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 px-2`,children:[(0,X.jsx)(r,{icon:ee,className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(`h3`,{className:s(y,`text-foreground`),children:e})]}),(0,X.jsx)(`div`,{className:`ml-auto flex h-full min-w-0 items-stretch`,children:t})]}),(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:n})]})}function Mn({view:e,onChange:t}){return(0,X.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,X.jsx)(Nn,{active:e===`fields`,label:`Fields`,icon:Me,onClick:()=>t(`fields`)}),(0,X.jsx)(Nn,{active:e===`raw`,label:`Raw`,icon:ve,onClick:()=>t(`raw`)})]})}function Nn({active:e,label:t,icon:n,onClick:i}){return(0,X.jsxs)(`button`,{type:`button`,className:s(v,`font-semibold tracking-[0.08em] uppercase`,e?S:R),"aria-pressed":e,"aria-label":t,onClick:i,children:[(0,X.jsx)(r,{icon:n,className:`size-3`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:t})]})}var Pn=`h-full rounded-none border-0 bg-transparent px-2 text-[10px] font-semibold tracking-[0.08em] uppercase shadow-none hover:bg-muted/50`,Fn=`h-full rounded-none border-0 px-3 text-[10px] font-semibold tracking-[0.14em] uppercase shadow-none`;function In(){return(0,X.jsx)(`span`,{className:`w-px shrink-0 self-stretch bg-border/60`,"aria-hidden":!0})}var Ln=`h-7 w-full justify-between rounded-none border-0 bg-transparent px-2 shadow-none focus-visible:border-0 focus-visible:ring-0 dark:bg-transparent dark:hover:bg-transparent`;function Rn({title:e,hint:t}){return(0,X.jsxs)(`div`,{className:z,children:[(0,X.jsx)(`h4`,{className:s(y,`flex items-center px-2`),children:e}),t?(0,X.jsx)(`span`,{className:`ml-auto flex items-center px-2 text-[10px] text-muted-foreground`,children:t}):null]})}function zn({field:e,value:t,onChange:n,error:r,wide:a=!1,manifest:o,idPrefix:c=`body`}){let l=`${c}-${e.name}`,u=Bn(e,o),d=[e.required?null:`optional`,u.lookup?`fk · ${u.lookup.child}.${u.lookup.column}`:e.type,u.lookup?null:Bt(e)].filter(Boolean).join(` · `),f=r?(0,X.jsx)(`p`,{className:`px-3 pb-2 text-xs text-destructive`,children:r.message}):null,p=s(a&&`col-span-full border-r-0`);if(u.lookup){let r=t==null||t===``?``:String(t),i=Vn(u.options,r);return(0,X.jsxs)(J,{label:e.name,hint:d,dense:!0,className:p,children:[(0,X.jsxs)(q,{value:r||null,onValueChange:e=>{e==null||Array.isArray(e)||n(String(e))},children:[(0,X.jsx)(W,{id:l,className:Ln,disabled:u.isLoading,children:(0,X.jsx)(Ye,{placeholder:u.isLoading?`Loading…`:`Select…`})}),(0,X.jsx)(K,{children:i.map(e=>(0,X.jsx)(G,{value:e.value,children:e.label},e.value))})]}),f]})}if(e.type===`enum`&&e.enumValues)return(0,X.jsxs)(J,{label:e.name,hint:d,dense:!0,className:p,children:[(0,X.jsxs)(q,{value:String(t??``),onValueChange:e=>{e==null||Array.isArray(e)||n(String(e))},children:[(0,X.jsx)(W,{id:l,className:Ln,children:(0,X.jsx)(Ye,{})}),(0,X.jsx)(K,{children:e.enumValues.map(e=>(0,X.jsx)(G,{value:e,children:e},e))})]}),f]});if(e.type===`boolean`)return(0,X.jsx)(J,{label:e.name,hint:d,dense:!0,className:p,children:(0,X.jsxs)(q,{value:t===!0?`true`:`false`,onValueChange:e=>{e==null||Array.isArray(e)||n(String(e)===`true`)},children:[(0,X.jsx)(W,{id:l,className:Ln,children:(0,X.jsx)(Ye,{})}),(0,X.jsxs)(K,{children:[(0,X.jsx)(G,{value:`true`,children:`true`}),(0,X.jsx)(G,{value:`false`,children:`false`})]})]})});if(e.type===`integer`||e.type===`number`){let r=Wt(e);if(r){let i=typeof t==`number`?String(t):``;return(0,X.jsxs)(J,{label:e.name,hint:d,dense:!0,className:p,children:[(0,X.jsxs)(q,{value:i||null,onValueChange:e=>{e==null||Array.isArray(e)||n(Number(e))},children:[(0,X.jsx)(W,{id:l,className:Ln,children:(0,X.jsx)(Ye,{placeholder:`Select…`})}),(0,X.jsx)(K,{children:r.map(t=>{let n=e.valueMeanings?.find(e=>e.value===String(t));return(0,X.jsx)(G,{value:String(t),children:n?`${t} · ${n.label}`:t},t)})})]}),f]})}return(0,X.jsxs)(J,{label:e.name,hint:d,dense:!0,className:p,children:[(0,X.jsx)(i,{id:l,type:`number`,flat:!0,className:s(gt,`h-7 px-2 font-mono`),min:e.minimum,max:e.maximum,step:e.type===`integer`?1:void 0,value:typeof t==`number`?t:``,onChange:t=>{if(t.target.value===``){n(void 0);return}n(Hn(Number(t.target.value),e.minimum,e.maximum))}}),f]})}return(0,X.jsxs)(J,{label:e.name,hint:d,dense:!0,className:p,children:[(0,X.jsx)(i,{id:l,flat:!0,className:s(gt,`h-7 px-2 font-mono`),value:typeof t==`string`?t:t==null?``:String(t),onChange:e=>n(e.target.value)}),f]})}function Bn(e,t){let n=(0,Y.useMemo)(()=>Jt(e,t),[e,t]),r=et(n?{ref:n.ref,child:n.child,limit:200}:null,n!==null);return{lookup:n,options:(0,Y.useMemo)(()=>Yt(r.data?.rows??[],n),[r.data?.rows,n]),isLoading:r.isFetching}}function Vn(e,t){return!t||e.some(e=>e.value===t)?e:[{value:t,label:t},...e]}function Hn(e,t,n){let r=e;return t!==void 0&&r<t&&(r=t),n!==void 0&&r>n&&(r=n),r}function Q({title:e,meta:t,ruled:n=!0}){return(0,X.jsxs)(`div`,{className:s(`flex items-baseline justify-between gap-2`,n&&`border-b border-border/60 pb-1.5`),children:[(0,X.jsx)(`h3`,{className:y,children:e}),t?(0,X.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:t}):null]})}function Un({method:e,className:t}){return(0,X.jsx)(ye,{variant:`outline`,className:s(`h-5 px-1.5 font-mono text-[10px] uppercase`,ce(e),t),"data-slot":`http-method-badge`,children:e})}var Wn=[`once`,`broadcast`,`live`],Gn={once:{delivery:`once`,icon:Et,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:Tt,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:te,label:`live`,title:`live — retained feed; late subscribers replay history`,wellClass:`border-emerald-500/35 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`,badgeClass:`border-emerald-500/35 bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`}};function Kn({delivery:e,className:t}){let n=Gn[e];return(0,X.jsx)(ye,{variant:`outline`,title:n.title,className:s(`h-5 px-1.5 font-mono text-[10px]`,n.badgeClass,t),"data-slot":`signal-delivery-badge`,"data-delivery":e,children:n.label})}function qn({effects:e}){let t=Jn(e);return t.length===0?null:(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`effects-summary`,"aria-label":`Effects`,children:[(0,X.jsx)(Q,{title:`Effects`,meta:String(t.length)}),(0,X.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>{let t=Ne(e.kind),n=Le(e.kind,e.ref),i=e.kind===`call`?Re(e.ref):null;return(0,X.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:i??`${Be[e.kind]} ${e.ref}`,children:[(0,X.jsx)(r,{icon:n,className:`size-3`}),i?(0,X.jsx)(`span`,{className:`text-foreground/90`,children:i}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:Be[e.kind]}),(0,X.jsx)(`span`,{className:`text-foreground/90`,children:e.ref})]})]},`${e.kind}:${e.ref}`)})})]})}function Jn(e){if(!e)return[];let t=[],n=(e,n)=>{for(let r of n??[]){let n=typeof r==`string`?r:r.ref??String(r);t.push({kind:e,ref:n})}};return n(`read`,e.reads),n(`write`,e.writes),n(`emit`,e.emits),n(`send`,e.sends),n(`ask`,e.asks),n(`embed`,e.embeds),n(`secret`,e.secrets),n(`call`,e.calls),n(`fetch`,e.fetches),t}function Yn({errors:e}){let t=Xn(e);return t.length===0?null:(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`errors-section`,"aria-label":`Flow errors`,children:[(0,X.jsx)(Q,{title:`Flow errors`,meta:String(t.length)}),(0,X.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.map(e=>{let t=(e.schema?Z(e.schema):[]).map(e=>e.name).join(`, `);return(0,X.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,X.jsx)(r,{icon:Ce,className:`size-3`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`text-foreground/90`,children:e.code}),t?(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:t}):null]},e.code)})})]})}function Xn(e){return e?Array.isArray(e)?e.map(e=>({code:e,schema:null})):Object.entries(e).map(([e,t])=>({code:e,schema:qt(t)})):[]}var Zn=36e5;function Qn(e,t,n,r=Zn){let i=bt(e,new Set([t])),a=n-r,o=i.filter(e=>e.startedAt>=a);if(o.length===0)return{kind:`empty`};let s=o.filter(e=>e.error!=null&&e.error.length>0).length,c=o[0];return{kind:`summary`,calls:o.length,errors:s,errorRate:s/o.length,lastStartedAt:c.startedAt,latestRunId:c.id,windowMs:r}}function $n({flowId:e,runs:t,nowMs:n=Date.now(),windowMs:r=Zn,children:i}){let a=Qn(t??[],e,n,r);return(0,X.jsxs)(`div`,{className:s(z,`px-2`),"data-slot":`flow-activity-strip`,"data-kind":a.kind,"aria-label":`Recent activity`,children:[(0,X.jsx)(`span`,{className:s(y,`flex items-center`),children:`Activity`}),(0,X.jsx)(er,{summary:a,nowMs:n}),i?(0,X.jsx)(`div`,{className:`ml-auto flex h-full items-stretch`,children:i}):null]})}function er({summary:e,nowMs:t}){if(e.kind===`empty`)return(0,X.jsx)(`p`,{className:`flex items-center text-[11px] text-muted-foreground`,"data-slot":`flow-activity-empty`,children:`No recent runs in the Console buffer.`});let n=Math.round(e.errorRate*100),r=tr(e.lastStartedAt,t);return(0,X.jsxs)(`p`,{className:`flex min-w-0 items-center gap-x-2 text-[11px] text-foreground/85`,children:[(0,X.jsxs)(`span`,{className:`tabular-nums`,"data-slot":`flow-activity-calls`,children:[e.calls,` call`,e.calls===1?``:`s`]}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,"aria-hidden":!0,children:`·`}),(0,X.jsxs)(`span`,{className:`tabular-nums`,"data-slot":`flow-activity-errors`,children:[n,`% errors`]}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,"aria-hidden":!0,children:`·`}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,"data-slot":`flow-activity-ago`,children:r}),(0,X.jsx)(mt,{to:`/overview`,search:{run:e.latestRunId},className:s(v,R),"data-slot":`flow-activity-open-run`,children:`Open latest`})]})}function tr(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.max(1,Math.round(n/1e3))}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function nr(e){switch(e){case`string`:return`border-teal-500/35 bg-teal-500/10 text-teal-800 dark:text-teal-300`;case`integer`:return`border-blue-500/35 bg-blue-500/10 text-blue-800 dark:text-blue-300`;case`number`:return`border-amber-500/35 bg-amber-500/10 text-amber-800 dark:text-amber-300`;case`boolean`:return`border-violet-500/35 bg-violet-500/10 text-violet-800 dark:text-violet-300`;case`enum`:return`border-indigo-500/35 bg-indigo-500/10 text-indigo-800 dark:text-indigo-300`;case`array`:return`border-cyan-500/35 bg-cyan-500/10 text-cyan-800 dark:text-cyan-300`;case`object`:return`border-zinc-500/35 bg-zinc-500/10 text-zinc-700 dark:text-zinc-300`;default:return`border-border/70 bg-muted/40 text-muted-foreground`}}function rr({fields:e,emptyLabel:t=`No schema fields declared.`,layout:n=`list`}){return e.length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-slot":`schema-fields-empty`,children:t}):n===`grid`?(0,X.jsx)(`div`,{"data-slot":`schema-fields`,"data-layout":`grid`,children:(0,X.jsx)(vt,{columns:3,children:e.map(e=>(0,X.jsx)(ir,{field:e,depth:0,cell:!0},e.path))})}):(0,X.jsx)(`ul`,{className:`flex flex-col`,"data-slot":`schema-fields`,children:e.map(e=>(0,X.jsx)(ir,{field:e,depth:0},e.path))})}function ir({field:e,depth:t,cell:n=!1}){let r=e.type===`enum`&&e.enumValues,i=Bt(e);return(0,X.jsxs)(n?`div`:`li`,{className:n?`min-w-0 border-b border-border/50`:void 0,children:[(0,X.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,X.jsx)(`span`,{className:`shrink-0`,"data-slot":`schema-field-keys`,title:ar(e),children:(0,X.jsx)(re,{primaryKey:e.primaryKey,foreignKey:e.foreignKey,unique:e.unique,empty:`none`})}),(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] font-medium text-foreground/90`,children:e.name}),e.required?null:(0,X.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,X.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,X.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,X.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,X.jsx)(`span`,{className:s(`ml-auto shrink-0 rounded border px-1.5 py-px font-mono text-[9px] font-medium tracking-wide`,nr(e.type)),"data-slot":`schema-field-type`,title:r?e.enumValues?.join(` | `):e.type,children:e.type})]}),e.children?.map(e=>(0,X.jsx)(ir,{field:e,depth:t+1,cell:n},e.path))]})}function ar(e){let t=[];if(e.primaryKey&&t.push(`Primary key`),e.foreignKey){let n=e.references?[e.references.table,e.references.column].filter(Boolean).join(`.`):null;t.push(n?`Foreign key → ${n}`:`Foreign key`)}return e.unique&&t.push(`Unique`),t.length>0?t.join(` · `):`None`}function or({fields:e}){let t=Ht(e);return t.length===0?null:(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,"data-slot":`validation-section`,"aria-label":`Validation`,children:[(0,X.jsx)(Q,{title:`Validation`,meta:String(t.length)}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-3`,children:t.map(e=>(0,X.jsx)(sr,{field:e},e.path))})]})}function sr({field:e}){let t=Vt(e),n=e.valueMeanings?.length?e.valueMeanings:e.enumValues?.map(e=>({value:e,label:e}));return(0,X.jsxs)(`li`,{className:`flex flex-col gap-1.5`,"data-slot":`validation-field`,"data-field":e.name,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-foreground/90`,children:e.name}),t?(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t}):null]}),n&&n.length>0?(0,X.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,X.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5 font-mono text-[11px]`,"data-slot":`validation-option`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.value}),(0,X.jsx)(`span`,{className:`truncate text-foreground/90`,children:e.label})]},e.value))}):null]})}function cr({row:e,manifest:t,runs:n,leading:i,trailing:a}){let o=U(e.flow.trigger),c=Ie(e.flow.trigger),l=Ve(t,e.id,o===`http`?`http`:o===`internal`?`internal`:o),u=qt(e.flow.in),d=qt(e.flow.out),f=Pe(e.flow.gates??[],t),p=o===`signal`&&e.flow.trigger?.signal?t?.signals?.[e.flow.trigger.signal]:void 0,m=o===`cron`||o===`every`?pn(t,e.id):null,h=o===`internal`?xt(t,e.id):[],g=o===`http`?`Request`:`Input`,_=o===`http`?`Response`:`Output`,y=o!==`cron`&&o!==`every`,b=Z(u),x=Z(d),S=jt(b,o===`http`&&e.path?cn(e.path):[]);return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`flow-contract-panel`,"data-trigger":o,children:[(0,X.jsx)(_t,{dataSlot:`endpoint-header`,leading:i,trailing:a,icon:(0,X.jsx)(`span`,{"data-slot":`trigger-kind-icon`,"data-kind":o,children:(0,X.jsx)(r,{icon:c.icon,className:`size-4`})}),wellClassName:c.wellClass,title:(0,X.jsx)(`span`,{className:`font-mono`,children:e.id}),badge:(0,X.jsx)(`span`,{className:`font-mono text-[10px] font-medium tracking-[0.08em] text-muted-foreground uppercase`,"data-slot":`trigger-kind-badge`,children:c.label}),subtitle:o===`http`&&l.method&&l.path?(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,"data-slot":`http-endpoint-line`,children:[(0,X.jsx)(Un,{method:l.method}),(0,X.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[11px] leading-none text-muted-foreground select-all`,children:l.path})]}):o===`signal`&&p?(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,"data-slot":`signal-endpoint-line`,children:[(0,X.jsx)(Kn,{delivery:p.delivery}),(0,X.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[11px] leading-none text-muted-foreground select-all`,children:e.flow.trigger?.signal})]}):(0,X.jsx)(`span`,{className:`truncate font-mono text-[11px] leading-none text-muted-foreground`,"data-slot":`trigger-headline`,children:l.headline}),actions:(0,X.jsxs)(mt,{to:`/overview`,search:{flow:e.id},"data-slot":`open-in-graph`,className:s(v,`text-sky-700 dark:text-sky-400`),children:[(0,X.jsx)(r,{icon:_e.flow.icon,className:`size-3.5`,"aria-hidden":!0}),`Open in graph`]})}),(0,X.jsxs)($n,{flowId:e.id,runs:n,children:[e.flow.plane?(0,X.jsx)(lr,{plane:e.flow.plane}):null,e.flow.durable?(0,X.jsx)(ur,{icon:je,label:`durable`,title:`Durable — long-running, retryable steps`}):null,e.flow.idempotency&&e.flow.idempotency.mode!==`off`?(0,X.jsx)(ur,{icon:fe,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,X.jsx)(ur,{icon:de,label:`live`,title:typeof e.flow.live==`string`?`Live — SSE for ${e.flow.live}`:`Live — SSE signal feed`}):null]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(qn,{effects:e.flow.effects}),(0,X.jsx)(He,{gates:f}),(0,X.jsx)(Yn,{errors:e.flow.errors}),o===`signal`&&p&&(p.retries!==void 0||p.deadLetter)?(0,X.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`signal-delivery`,children:[p.retries===void 0?null:`retries ${p.retries}`,p.deadLetter?`dead-letter`:null].filter(e=>e!==null).join(` · `)}):null,(o===`cron`||o===`every`)&&m?.kind===`matched`?(0,X.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`clock-join`,children:[`Clock · `,(0,X.jsx)(`span`,{className:`font-mono`,children:m.clockName}),m.timezone?` · ${m.timezone}`:``]}):null,o===`internal`?(0,X.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,"data-slot":`call-only-note`,children:[`No external trigger — reachable via `,(0,X.jsx)(`code`,{className:`font-mono`,children:`effects.calls`}),` /`,` `,(0,X.jsx)(`code`,{className:`font-mono`,children:`fx.call`}),`.`]}):null,o===`internal`?(0,X.jsxs)(`section`,{className:`flex flex-col gap-1.5`,"aria-label":`Callers`,"data-slot":`callers-list`,children:[(0,X.jsx)(Q,{title:`Called by`,meta:String(h.length)}),h.length===0?(0,X.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`No Manifest caller declares `,(0,X.jsx)(`code`,{className:`font-mono`,children:`effects.calls`}),` for this flow.`]}):(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:h.map(e=>(0,X.jsx)(`li`,{className:`font-mono text-xs text-foreground/90`,children:e},e))})]}):null,y&&S.parameters.length>0?(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":`Parameters`,"data-slot":`parameters`,children:[(0,X.jsx)(Q,{title:`Parameters`,meta:String(S.parameters.length)}),(0,X.jsx)(rr,{fields:S.parameters,layout:`grid`})]}):null,(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[y&&(S.fields.length>0||S.parameters.length===0)?(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":g,"data-slot":`request`,children:[(0,X.jsx)(Q,{title:g,meta:String(S.fields.length)}),(0,X.jsx)(rr,{fields:S.fields,emptyLabel:typeof e.flow.in==`string`?`Schema not expanded in Manifest.`:o===`signal`?`No flow input schema — signal payload shape lives on the signal when declared.`:`No input schema declared.`})]}):null,(0,X.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":_,children:[(0,X.jsx)(Q,{title:_,meta:String(x.length)}),(0,X.jsx)(rr,{fields:x,emptyLabel:typeof e.flow.out==`string`?`Schema not expanded in Manifest.`:`No output schema declared.`})]})]}),y?(0,X.jsx)(or,{fields:b}):null]})})]})}function lr({plane:e}){let t=e===`operator`,n=t?fe:Ue,i=t?`operator`:`user`;return(0,X.jsxs)(a,{children:[(0,X.jsx)(c,{render:t=>(0,X.jsxs)(`span`,{...t,className:s(v,`cursor-help`),"data-slot":`plane-badge`,"data-plane":e,children:[(0,X.jsx)(r,{icon:n,className:`size-3`,"aria-hidden":!0}),i]})}),(0,X.jsx)(o,{side:`bottom`,className:`max-w-xs text-[11px]`,children:t?`Operator plane — runs under a Console operator identity, not an application user.`:`User plane — runs under an application user identity (invoke-as).`})]})}function ur({icon:e,label:t,title:n}){return(0,X.jsxs)(a,{children:[(0,X.jsx)(c,{render:n=>(0,X.jsxs)(`span`,{...n,className:s(v,R,`cursor-help`),children:[(0,X.jsx)(r,{icon:e,className:`size-3`,"aria-hidden":!0}),t]})}),(0,X.jsx)(o,{side:`bottom`,className:`max-w-xs text-[11px]`,children:n})]})}function dr(e){let t=new Map(Fe.map(e=>[e,[]]));for(let n of e){let e=new Map;for(let t of n.flows){let n=U(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 Fe.flatMap(e=>{let n=t.get(e)??[];return n.length===0?[]:[{id:e,label:ze[e].label,groups:n}]})}var fr=`oke_units_pinned`;function pr(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e)typeof r!=`string`||r.length===0||t.has(r)||(t.add(r),n.push(r));return n}function mr(){try{if(typeof localStorage>`u`)return[];let e=localStorage.getItem(fr);return e?pr(JSON.parse(e)):[]}catch{return[]}}function hr(e){try{if(typeof localStorage>`u`)return;localStorage.setItem(fr,JSON.stringify(e))}catch{}}function gr(e,t){return e.includes(t)?e.filter(e=>e!==t):[t,...e]}function _r(e,t){if(t.length===0||e.length<2)return e;let n=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({group:e,index:t,pin:n.get(e.unit)})).sort((e,t)=>e.pin!==void 0&&t.pin!==void 0?e.pin-t.pin:e.pin===void 0?t.pin===void 0?e.index-t.index:1:-1).map(e=>e.group)}function vr(e){return`band:${e}`}function yr(e,t){return`unit:${e}:${t}`}function br(e,t,n=!1){let r=t[e];return r===void 0?n:r}function xr(e){let t=[];for(let n of e){t.push(vr(n.id));for(let e of n.groups)t.push(yr(n.id,e.unit))}return t}function Sr(e,t){for(let n of e)for(let e of n.groups)if(e.flows.some(e=>e.id===t))return[vr(n.id),yr(n.id,e.unit)];return[]}function Cr(e,t){let n=B(e.method)-B(t.method);return n===0?e.id.localeCompare(t.id):n}function wr(e){let t=e?.flows;if(!t)return[];let n=new Map;for(let[r,i]of Object.entries(t)){let t=yt(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(Cr)}))}function Tr(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 Er(e){return(e.triggerKinds?.length??0)+(e.planes?.length??0)+(e.deliveries?.length??0)+ +!!e.durableOnly+ +!!e.liveOnly}function Dr(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(U(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 Or={user:{icon:Ue,label:`user`},operator:{icon:fe,label:`operator`}},kr=[`user`,`operator`];function Ar({groups:e,selectedFlowId:t,onSelect:n}){let[i,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)({}),[m,h]=(0,Y.useState)({}),[g,_]=(0,Y.useState)(()=>mr()),v=(0,Y.useMemo)(()=>{let t=new Set;for(let n of e)for(let e of n.flows)t.add(U(e.flow.trigger));return Fe.filter(e=>t.has(e))},[e]),y=(0,Y.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 kr.filter(e=>t.has(e))},[e]),{hasDurable:x,hasLive:S,availableDeliveries:C}=(0,Y.useMemo)(()=>{let t=!1,n=!1,r=new Set;for(let i of e)for(let e of i.flows)e.flow.durable&&(t=!0),e.flow.live&&(n=!0),e.delivery&&r.add(e.delivery);return{hasDurable:t,hasLive:n,availableDeliveries:Wn.filter(e=>r.has(e))}},[e]),w=Er(f),T=(0,Y.useMemo)(()=>dr(Dr(Tr(e,i),f)),[e,i,f]),E=(0,Y.useMemo)(()=>xr(T),[T]),O=i.trim().length>0,k=E.length>0&&E.every(e=>br(e,m,O));(0,Y.useEffect)(()=>{if(!t)return;let e=Sr(T,t);e.length!==0&&h(t=>{let n=!1,r={...t};for(let t of e)r[t]!==!0&&(r[t]=!0,n=!0);return n?r:t})},[t,T]);let A=(e,t)=>{h(n=>n[e]===t?n:{...n,[e]:t})},j=()=>{let e=!k;h(t=>{let n={...t};for(let t of E)n[t]=e;return n})},M=e=>p(t=>({...t,triggerKinds:Mr(t.triggerKinds??[],e)})),N=e=>p(t=>({...t,planes:Mr(t.planes??[],e)})),P=e=>p(t=>({...t,[e]:!t[e]})),I=e=>p(t=>({...t,deliveries:Mr(t.deliveries??[],e)})),L=e=>{_(t=>{let n=gr(t,e);return hr(n),n})};return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`units-tree`,children:[(0,X.jsxs)(`div`,{className:`shrink-0 border-b border-border/60`,children:[(0,X.jsxs)(`div`,{className:s(b,`border-b-0`),children:[(0,X.jsx)(ue,{value:i,onChange:e=>l(e.target.value),placeholder:`Search flows…`,"aria-label":`Search flows`,"data-slot":`units-search`}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-stretch pr-0.5`,children:[(0,X.jsxs)(a,{children:[(0,X.jsx)(c,{render:e=>(0,X.jsxs)(`button`,{...e,type:`button`,"aria-expanded":u,"aria-controls":`units-advanced-panel`,"aria-label":w>0?`Advanced filters, ${w} active`:`Advanced filters`,"data-slot":`units-advanced-toggle`,onClick:t=>{e.onClick?.(t),d(e=>!e)},className:s(D,`relative`,(u||w>0)&&`text-foreground`),children:[(0,X.jsx)(r,{icon:We,className:`size-3`,"aria-hidden":!0}),w>0?(0,X.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:w}):null]})}),(0,X.jsx)(o,{side:`bottom`,children:`Advanced`})]}),(0,X.jsx)(at,{allOpen:k,disabled:E.length===0,onToggle:j,dataSlot:`units-tree-expand-toggle`})]})]}),u?(0,X.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,X.jsx)(jr,{label:`Trigger`,groupLabel:`Trigger kind filter`,children:v.map(e=>{let t=ze[e];return(0,X.jsx)($,{icon:t.icon,label:t.label,pressed:f.triggerKinds?.includes(e)??!1,onToggle:()=>M(e),dataFacet:`kind:${e}`},e)})}),C.length>0?(0,X.jsx)(jr,{label:`Delivery`,groupLabel:`Signal delivery filter`,children:C.map(e=>{let t=Gn[e];return(0,X.jsx)($,{icon:t.icon,label:t.label,pressed:f.deliveries?.includes(e)??!1,onToggle:()=>I(e),dataFacet:`delivery:${e}`},e)})}):null,y.length>0?(0,X.jsx)(jr,{label:`Plane`,groupLabel:`Plane filter`,children:y.map(e=>{let t=Or[e];return(0,X.jsx)($,{icon:t.icon,label:t.label,pressed:f.planes?.includes(e)??!1,onToggle:()=>N(e),dataFacet:`plane:${e}`},e)})}):null,x||S?(0,X.jsxs)(jr,{label:`Flags`,groupLabel:`Flow flags filter`,children:[x?(0,X.jsx)($,{icon:je,label:`durable`,pressed:f.durableOnly??!1,onToggle:()=>P(`durableOnly`),dataFacet:`flag:durable`}):null,S?(0,X.jsx)($,{icon:de,label:`live`,pressed:f.liveOnly??!1,onToggle:()=>P(`liveOnly`),dataFacet:`flag:live`}):null]}):null,w>0?(0,X.jsx)(`button`,{type:`button`,"data-slot":`units-advanced-clear`,onClick:()=>p({}),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,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto`,children:T.length===0?(0,X.jsx)(`p`,{className:F,children:`No flows match.`}):(0,X.jsx)(`div`,{className:`flex flex-col`,children:T.map(e=>{let r=vr(e.id);return(0,X.jsx)(Nr,{band:e,open:br(r,m,O),onOpenChange:e=>A(r,e),groupOpen:t=>br(yr(e.id,t),m,O),onGroupOpenChange:(t,n)=>A(yr(e.id,t),n),selectedFlowId:t,onSelect:n,pinned:g,onTogglePin:L},e.id)})})})]})}function jr({label:e,groupLabel:t,children:n}){return(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-14 shrink-0 text-[9px] font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:e}),(0,X.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:i,dataFacet:a}){return(0,X.jsxs)(`button`,{type:`button`,"data-slot":`units-facet-chip`,"data-facet":a,"aria-pressed":n,onClick:i,className:s(`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,X.jsx)(r,{icon:e,className:`size-3`,"aria-hidden":!0}),t]})}function Mr(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function Nr({band:e,open:t,onOpenChange:n,groupOpen:i,onGroupOpenChange:a,selectedFlowId:o,onSelect:c,pinned:l,onTogglePin:u}){let d=ze[e.id],f=_r(e.groups,l),p=f.reduce((e,t)=>e+t.flows.length,0),m=f.map(e=>e.unit),h=m.length>0&&m.every(e=>i(e)),g=()=>{let e=!h;for(let t of m)a(t,e);e&&n(!0)};return(0,X.jsx)(`section`,{"data-slot":`units-trigger-band`,"data-band":e.id,"aria-label":e.label,className:j,children:(0,X.jsxs)(we,{open:t,onOpenChange:n,children:[(0,X.jsx)(Se,{nativeButton:!1,className:w,"data-slot":`units-trigger-band-toggle`,render:n=>(0,X.jsxs)(`div`,{...n,children:[(0,X.jsx)(r,{icon:xe,className:s(L,!t&&`-rotate-90`),"aria-hidden":!0}),(0,X.jsx)(r,{icon:d.icon,className:s(O,x(d.wellClass)),"aria-hidden":!0}),(0,X.jsx)(`span`,{className:s(P,`flex-1`),children:e.label}),(0,X.jsx)(`span`,{className:E,children:p}),(0,X.jsx)(`span`,{className:I,children:(0,X.jsx)(at,{allOpen:h,disabled:m.length===0,onToggle:g,collapseLabel:`Collapse all in ${e.label}`,expandLabel:`Expand all in ${e.label}`,dataSlot:`units-band-expand-toggle`,disclose:!0,bare:!0})})]})}),(0,X.jsx)(be,{children:(0,X.jsx)(`ul`,{className:`flex flex-col`,children:f.map(t=>(0,X.jsx)(Pr,{group:t,open:i(t.unit),onOpenChange:e=>a(t.unit,e),selectedFlowId:o,onSelect:c,pinned:l.includes(t.unit),onTogglePin:()=>u(t.unit)},`${e.id}:${t.unit}`))})})]})})}function Pr({group:e,open:t,onOpenChange:n,selectedFlowId:i,onSelect:a,pinned:o,onTogglePin:c}){let l=o?`Unpin ${e.unit}`:`Pin ${e.unit}`;return(0,X.jsx)(`li`,{"data-slot":`unit-group`,"data-unit":e.unit,"data-pinned":o?`true`:void 0,children:(0,X.jsxs)(we,{open:t,onOpenChange:n,children:[(0,X.jsx)(Se,{nativeButton:!1,className:s(M,`pl-4`),"data-slot":`unit-group-toggle`,render:n=>(0,X.jsxs)(`div`,{...n,children:[(0,X.jsx)(r,{icon:xe,className:s(L,!t&&`-rotate-90`),"aria-hidden":!0}),(0,X.jsx)(r,{icon:st,className:s(O,`text-muted-foreground`),"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:e.unit}),(0,X.jsx)(`button`,{type:`button`,"aria-label":l,"aria-pressed":o,"data-slot":`unit-pin`,onClick:e=>{e.stopPropagation(),c()},className:s(`inline-flex shrink-0 items-center justify-center overflow-hidden text-muted-foreground transition-[width,opacity,margin] hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:outline-none`,o?`ml-1.5 size-3.5 text-foreground`:`pointer-events-none ml-0 size-0 opacity-0 group-hover/folder:pointer-events-auto group-hover/folder:ml-1.5 group-hover/folder:size-3.5 group-hover/folder:opacity-100 group-focus-within/folder:pointer-events-auto group-focus-within/folder:ml-1.5 group-focus-within/folder:size-3.5 group-focus-within/folder:opacity-100`),children:(0,X.jsx)(r,{icon:wt,className:`size-3 shrink-0`,"aria-hidden":!0})})]}),(0,X.jsx)(`span`,{className:E,children:e.flows.length})]})}),(0,X.jsx)(be,{children:(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.flows.map(e=>(0,X.jsx)(Fr,{flow:e,selected:i===e.id,onSelect:a},e.id))})})]})})}function Fr({flow:e,selected:t,onSelect:n}){let i=Ie(e.flow.trigger),l=e.delivery?Gn[e.delivery]:null,u=l?.icon??(e.method?se(e.method):i.icon),d=x(l?.wellClass??(e.method?ce(e.method):i.wellClass)),f=l?e.signal?`${l.title} · ${e.signal}`:l.title:i.detail?`${i.label} · ${i.detail}`:i.label;return(0,X.jsx)(`li`,{children:(0,X.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:s(C,`group/flow pl-8`,t&&`bg-muted/70 text-foreground`),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:s(k,t?A:`bg-transparent`)}),(0,X.jsxs)(a,{children:[(0,X.jsx)(c,{render:e=>(0,X.jsx)(`span`,{...e,className:s(O,d),"aria-hidden":!0,children:(0,X.jsx)(r,{icon:u,className:`size-3.5`})})}),(0,X.jsx)(o,{side:`right`,className:`text-[11px]`,children:f})]}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.action}),e.method?(0,X.jsx)(Un,{method:e.method,className:`ml-auto h-3.5 px-1 text-[8px] leading-none`}):null]})})}function Ir(){let e=Ee(),t=ke();Te(!0);let{selectedFlowId:n,setSelectedFlow:r}=ft(),i=pe(),a=pe(),o=(0,Y.useMemo)(()=>wr(e.data??null),[e.data]),s=(0,X.jsx)(me,{open:i.open,onToggle:i.toggle,noun:`flows`,controlsId:`flows-tree`,dataSlot:`flows-tree-toggle`}),c=(0,X.jsx)(me,{open:a.open,onToggle:a.toggle,noun:`Call API`,controlsId:`call-api-rail`,dataSlot:`call-api-toggle`,side:`end`}),l=n??o[0]?.flows[0]?.id??null,u=(0,Y.useMemo)(()=>{if(!l)return null;for(let e of o){let t=e.flows.find(e=>e.id===l);if(t)return t}return null},[o,l]);return(0,X.jsx)(`div`,{className:N,"data-slot":`units-page`,children:(0,X.jsxs)(V,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,X.jsx)(H,{panelRef:i.panelRef,collapsible:!0,collapsedSize:0,defaultSize:T.start.defaultSize,minSize:T.start.minSize,onResize:i.onResize,className:`min-h-0 overflow-hidden`,children:(0,X.jsx)(`div`,{id:`flows-tree`,className:`h-full min-h-0 overflow-hidden`,"data-slot":`flows-tree`,children:(0,X.jsx)(Ar,{groups:o,selectedFlowId:l,onSelect:e=>{r(e)}})})}),i.open?(0,X.jsx)(he,{withHandle:!0}):null,(0,X.jsx)(H,{defaultSize:T.end.defaultSize,minSize:T.end.minSize,className:`min-h-0 overflow-hidden`,children:(0,X.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:u?(0,X.jsxs)(V,{orientation:`horizontal`,className:`min-h-0 flex-1`,"data-slot":`units-inspector`,children:[(0,X.jsx)(H,{defaultSize:`62%`,minSize:`36%`,className:`min-h-0 overflow-hidden`,children:(0,X.jsx)(cr,{row:u,manifest:e.data??null,runs:t.data,leading:s,trailing:c})}),a.open?(0,X.jsx)(he,{withHandle:!0}):null,(0,X.jsx)(H,{panelRef:a.panelRef,collapsible:!0,collapsedSize:0,defaultSize:`38%`,minSize:`352px`,onResize:a.onResize,className:`min-h-0 overflow-hidden`,children:(0,X.jsx)(`div`,{id:`call-api-rail`,className:`h-full min-h-0 overflow-hidden`,children:(0,X.jsx)(Tn,{row:u,manifest:e.data??null})})})]}):(0,X.jsx)(ht,{icon:_e.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:s})})})]})})}export{Ir as UnitsPage};
|
|
@@ -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{$n as r,Cr as i,E as a,Qn as o,_ as s,b as c,c as l,d as u,er as d,h as f,i as p,l as m,o as h,p as g,s as _,u as v,x as y,y as b}from"./shortcut-keys-DTE1sjTC.js";import{At as x,C as S,D as C,Dt as w,E as T,Et as E,O as D,S as ee,W as te,_ as O,a as ne,b as re,c as ie,d as ae,f as k,g as oe,i as se,jt as ce,kt as le,m as ue,o as A,p as j,r as de,s as M,w as N,x as P}from"./explorer-chrome-Dslh2yE8.js";import{a as fe,b as pe,c as F,h as me,i as he,m as ge,n as _e,o as ve,r as ye,s as I,t as L,v as R,x as be}from"./element-icons-C6t8Vlml.js";import{a as z,i as xe,n as Se,o as Ce,r as we,s as B,t as Te}from"./collapsible-CRhBJMZR.js";import{t as Ee}from"./FileExportIcon-Ck-5od4R.js";import{t as De}from"./MoreHorizontalCircle01Icon-gMNGsE37.js";import{n as Oe,t as ke}from"./copy-inline-button-BTjPVjRT.js";import{t as Ae}from"./UnavailableIcon-D9cvHVPr.js";import{a as V,d as je,i as Me,l as Ne,r as Pe,t as Fe}from"./dropdown-menu-CRGrj5JU.js";import{Mt as Ie,jt as Le,xt as Re}from"./index-CmRFeWdT.js";import{t as ze}from"./explorer-empty-CIVg7Jgb.js";import{a as H,c as U,l as W,n as G,o as Be,s as Ve,t as He}from"./detail-header-Dk5LipF6.js";import{t as Ue}from"./confirm-sheet-DZfuJXP4.js";import{a as We,i as Ge,n as Ke,o as qe,r as Je,s as Ye,t as Xe}from"./use-vault-list-BAyQG8Re.js";var Ze=[[`path`,{d:`M16 21C15.7668 18.0685 13.3422 15.7477 10.3085 15.5521L9.49999 15.5C9.21121 15.5076 8.94209 15.5178 8.68816 15.5298C5.68124 15.6723 3.23089 18.0974 3 21`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M12.75 9.75C12.75 11.5449 11.2949 13 9.5 13C7.70508 13 6.25 11.5449 6.25 9.75C6.25 7.95507 7.70508 6.5 9.5 6.5C11.2949 6.5 12.75 7.95507 12.75 9.75Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M21 17.501C20.7709 14.6314 18.4541 12.2748 15.5 11.9961`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}],[`path`,{d:`M15.9877 9C16.8965 8.42434 17.5001 7.40788 17.5001 6.25C17.5001 4.45507 16.0496 3 14.2602 3C13.3811 3 12.5838 3.35121 12.0001 3.92139`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`3`}]],K=e(t(),1);function Qe(e){if(e.count===0)return{summary:`No in-flight durable runs hold this secret`,detail:null,warn:!1};let t=e.longestOutstandingMs==null?null:$e(e.longestOutstandingMs);return{summary:`${e.count} in-flight durable run(s) will wake holding a new key`,detail:t?`Longest outstanding wake in ${t}`:e.longestWakeAt==null?null:`Longest wake at ${new Date(e.longestWakeAt).toISOString()}`,warn:!0}}function $e(e){if(e<1e3)return`${e}ms`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<48?`${r}h`:`${Math.floor(r/24)}d`}function et(e){return`await fx.vault.get(${e})`}function tt(e){return`oke vault set ${e}`}function nt(e){return`oke vault rotate ${e}`}function rt(e){return`${e}=`}function it(e,t,n){switch(e){case`process.env`:return{source:e,label:`env`,command:`export ${t}=`,hint:`Process environment for this Console process`};case`.env.local`:return{source:e,label:`local`,command:rt(t),hint:`Write to .env.local (gitignored)`};case`driver`:return{source:e,label:qe(n),command:tt(t),hint:Ge(n)};case`dev-fallback`:return{source:e,label:`fallback`,command:`dev: "…"`,hint:`Local-only option on the contract — never used in prod`}}}function at(e){return{name:e.name,kind:e.kind,sensitive:e.sensitive,description:e.description??null,rotate:e.rotate??null,fingerprints:{...e.fingerprints},fingerprint:e.fingerprint,cleartext:e.sensitive?null:e.cleartext,winner:e.winner,resolution:e.resolution.map(e=>({...e})),readers:[...e.readers],blastRadius:{count:e.blastRadius.count,longestWakeAt:e.blastRadius.longestWakeAt,longestOutstandingMs:e.blastRadius.longestOutstandingMs,runIds:[...e.blastRadius.runIds]},lastReadAt:e.lastReadAt,sharedFingerprintEnvs:[...e.sharedFingerprintEnvs]}}function ot(e){return JSON.stringify(e.map(e=>at(e)),null,2)}var st=[{id:`blast`,label:`Blast`,token:`blast`,tone:`danger`},{id:`unset`,label:`Unset`,token:`unset`,tone:`warn`},{id:`overdue`,label:`Overdue`,token:`overdue`,tone:`warn`},{id:`shared`,label:`Shared`,token:`shared`,tone:`warn`},{id:`dormant`,label:`Dormant`,token:`dormant`,tone:`neutral`}],ct=[`blast`,`unset`,`overdue`,`shared`,`dormant`];function lt(e){if(!e)return 0;let t=/^(\d+)(ms|s|m|h|d)$/.exec(e.trim());if(!t)return 0;let n=Number(t[1]);switch(t[2]){case`ms`:return n;case`s`:return n*1e3;case`m`:return n*6e4;case`h`:return n*36e5;case`d`:return n*864e5;default:return 0}}var ut=new Set([`never`,`none`,`off`]);function q(e){return lt(e)>0}function dt(e){if(q(e))return e.trim();let t=e?.trim().toLowerCase()??``;return t.length===0||ut.has(t)?`no rotate`:e.trim()}function ft(e){return e.sensitive?e.fingerprint!=null&&e.fingerprint.length>0:e.cleartext!=null&&e.cleartext.length>0}function pt(e,t){let n=ft(e),r=!n,i=e.blastRadius.count>0,a=e.sharedFingerprintEnvs.length>0,o=e.lastReadAt==null,s=e.kind===`secret`&&(o||e.lastReadAt!=null&&t-e.lastReadAt>=7776e6),c=lt(e.rotate),l=e.kind===`secret`&&n&&c>0&&(o||e.lastReadAt!=null&&t-e.lastReadAt>=c),u=[];return i&&u.push(`blast`),r&&u.push(`unset`),l&&u.push(`overdue`),a&&u.push(`shared`),s&&u.push(`dormant`),{unset:r,set:n,blast:i,shared:a,dormant:s,overdue:l,unread:o,healthy:n&&!i&&!a&&!s&&!l,risks:u,primary:e.kind===`config`&&!r&&!i&&!a?`config`:ct.find(e=>u.includes(e))??`healthy`}}function mt(e,t){let n=0,r=0,i=0,a=0,o=0,s=0,c=0,l=0;for(let u of e){u.kind===`secret`?n+=1:r+=1;let e=pt(u,t);e.unset&&(i+=1),e.blast&&(a+=1),e.shared&&(o+=1),e.dormant&&(s+=1),e.overdue&&(c+=1),e.healthy&&(l+=1)}return{total:e.length,secrets:n,config:r,unset:i,blast:a,shared:o,dormant:s,overdue:c,healthy:l}}function ht(e,t){let n=Math.max(0,t-e);if(n<6e4)return`just now`;if(n<36e5)return`${Math.floor(n/6e4)}m ago`;if(n<864e5)return`${Math.floor(n/36e5)}h ago`;let r=Math.floor(n/864e5);return r<14?`${r}d ago`:r<60?`${Math.floor(r/7)}w ago`:`${Math.floor(r/30)}mo ago`}function gt(e){switch(e){case`blast`:return`blast`;case`unset`:return`unset`;case`overdue`:return`overdue`;case`shared`:return`shared`;case`dormant`:return`dormant`;case`config`:return`config`;case`healthy`:return`set`}}function _t(e,t){switch(e){case`blast`:return`In-flight durable runs hold this secret`;case`unset`:return`No value in this environment`;case`overdue`:return t?`Last read older than rotate ${t} — never-read counts`:`Last read older than the rotate hint — never-read counts`;case`shared`:return`Fingerprint matches another environment`;case`dormant`:return`Unread for 90 days, or never`;case`config`:return`vault.config — shown in the clear`;case`healthy`:return`Set, no blast, no shared, not dormant`}}var J=`#94A3B8`,Y=n(),vt={driver:`driver`,"process.env":`env`,".env.local":`local`,"dev-fallback":`fallback`},yt={driver:me,"process.env":z,".env.local":R,"dev-fallback":Ae},bt=`text-emerald-700 dark:text-emerald-400`,xt=[`driver`,`process.env`,`.env.local`,`dev-fallback`];function St(e){let t=e.resolution.length>0?e.resolution:xt.map(t=>({source:t,present:!1,won:e.winner===t})),n=new Map(t.map(e=>[e.source,e]));return xt.map(t=>n.get(t)??{source:t,present:!1,won:e.winner===t})}function Ct(e){return e.find(e=>e.won)?.source??e.find(e=>!e.present)?.source??e[0].source}function wt(e,t,n){return e.won?`won`:n>=0&&t>n?e.present?`shadowed`:`skipped`:e.present?`shadowed`:`missed`}function Tt({row:e,env:t,now:n,backend:i=null,onSet:a,onRotate:o,onQueryChange:s,leading:c}){let l=Qe(e.blastRadius),u=pt(e,n),d=e.description??e.name,f=jt(e,t),p=St(e),m=p.find(e=>e.won)??null,[h,g]=(0,K.useState)(()=>Ct(p)),_=u.unset,v=u.overdue&&q(e.rotate)&&!l.warn&&!u.unset;(0,K.useEffect)(()=>{g(Ct(St(e)))},[e.name]);let b=p.find(e=>e.source===h)??p[0],x=it(b.source,e.name,i);return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-y-auto`,"data-slot":`vault-detail`,"aria-label":`Vault detail`,"aria-live":`polite`,children:[(0,Y.jsx)(He,{dataSlot:`vault-detail-header`,leading:c,icon:(0,Y.jsx)(r,{icon:L.vault.icon,className:`size-4`}),wellStyle:{color:J},title:d,badge:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`font-mono text-[10px] font-medium tracking-[0.08em] text-muted-foreground uppercase`,children:e.kind}),e.kind===`secret`?(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:dt(e.rotate)}):null,e.origin===`console`?(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:`console`}):null,(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:We(i)})]}),subtitle:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[11px] leading-none text-foreground/80`,children:e.name}),(0,Y.jsx)(ke,{value:e.name,label:`Copy ${e.name}`})]}),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Et,{row:e}),_?null:(0,Y.jsx)(I,{label:e.kind===`config`?`Updates this vault.config value. Console shows it in the clear.`:`Write-only. The new value is never shown again.`,className:`flex self-stretch`,children:(0,Y.jsx)(y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-full rounded-none`,onClick:a,children:`Set`})}),_||v?null:(0,Y.jsx)(I,{label:l.warn?l.summary:`Re-encrypt with a new value. Review the fingerprint before it writes.`,className:`flex self-stretch`,children:(0,Y.jsx)(y,{type:`button`,variant:`destructive`,size:`sm`,className:`h-full rounded-none`,disabled:l.warn,onClick:o,children:`Rotate`})})]})}),(0,Y.jsx)(Dt,{row:e,env:t,postureUnset:u.unset,blastWarn:l.warn,blastSummary:l.summary,blastDetail:l.detail,overdue:u.overdue,onSet:a,onRotate:o}),(0,Y.jsxs)(`div`,{className:P,"data-slot":`vault-briefing`,role:`group`,"aria-label":`Posture`,children:[(0,Y.jsx)(X,{label:`from`,value:e.winner?vt[e.winner]:`none`,hint:m?e.winner===`driver`?Ye(i):`First layer that had a value`:`No layer provided a value`,warn:!e.winner,won:!!e.winner,onClick:s?()=>s(e.winner?`from:${e.winner}`:`is:unset`):void 0}),(0,Y.jsx)(X,{label:`read`,value:e.lastReadAt==null?`never`:ht(e.lastReadAt,n),hint:e.lastReadAt==null?`Possible dead secret`:new Date(e.lastReadAt).toISOString(),warn:e.lastReadAt==null&&e.kind===`secret`,onClick:s?()=>s(`is:dormant`):void 0}),(0,Y.jsx)(X,{label:`readers`,value:String(e.readers.length),hint:e.readers.length===0?`No Flow declares a read`:e.readers.join(`, `),onClick:s&&e.readers[0]?()=>s(`reader:${e.readers[0]}`):void 0}),(0,Y.jsx)(X,{label:`blast`,value:e.blastRadius.count===0?`clear`:`${e.blastRadius.count} run${e.blastRadius.count===1?``:`s`}`,hint:l.detail??(e.blastRadius.longestOutstandingMs==null?l.summary:$e(e.blastRadius.longestOutstandingMs)),warn:l.warn,onClick:s?()=>s(`is:blast`):void 0}),e.sharedFingerprintEnvs.length>0?(0,Y.jsx)(X,{label:`shared`,value:e.sharedFingerprintEnvs.join(`, `),hint:`Same fingerprint in another environment`,warn:!0,onClick:s?()=>s(`is:shared`):void 0}):null]}),(0,Y.jsx)(kt,{steps:p,selected:b,fill:x,backend:i,onSelect:g}),(0,Y.jsxs)(`section`,{className:`shrink-0 border-b border-border/60`,"aria-label":`Fingerprints by environment`,children:[(0,Y.jsx)(Ot,{title:e.sensitive?`Fingerprints`:`Value`,meta:e.sensitive?`${f.length} env`:t}),e.sensitive?(0,Y.jsx)(At,{slots:f,env:t}):(0,Y.jsx)(`p`,{className:`px-2 py-1.5 font-mono text-[12px]`,role:`status`,children:e.cleartext??`unset`})]}),(0,Y.jsx)(Mt,{readers:e.readers,name:e.name,onFilterReader:s?e=>s(`reader:${e}`):void 0})]})}function Et({row:e}){let t=[{id:`fx`,label:`Flow read`,value:et(e.name)},{id:`set`,label:`oke vault set`,value:tt(e.name)},{id:`rotate`,label:`oke vault rotate`,value:nt(e.name)},{id:`env`,label:`.env assignment`,value:rt(e.name)},{id:`json`,label:`Export fingerprints`,value:JSON.stringify(at(e),null,2)}];return(0,Y.jsxs)(Fe,{children:[(0,Y.jsx)(I,{label:`Copy snippets (no secret values)`,className:`flex self-stretch`,children:(0,Y.jsx)(je,{render:e=>(0,Y.jsx)(`button`,{...e,type:`button`,"aria-label":`Copy`,className:ae,children:(0,Y.jsx)(r,{icon:De,className:`size-3.5`})})})}),(0,Y.jsxs)(Pe,{align:`end`,className:`min-w-52`,children:[(0,Y.jsx)(Me,{children:t.slice(0,4).map(e=>(0,Y.jsx)(V,{onClick:()=>{navigator.clipboard?.writeText(e.value)},children:e.label},e.id))}),(0,Y.jsx)(Ne,{}),(0,Y.jsx)(V,{onClick:()=>{navigator.clipboard?.writeText(t[4].value)},children:`Export fingerprints`})]})]})}function Dt({row:e,env:t,postureUnset:n,blastWarn:r,blastSummary:i,blastDetail:a,overdue:s,onSet:c,onRotate:l}){return r?(0,Y.jsxs)(`section`,{className:`shrink-0 border-b border-destructive/25 bg-destructive/5`,"aria-label":`Rotation blast radius`,role:`alert`,children:[(0,Y.jsx)(`div`,{className:o(P,`border-b-0`),children:(0,Y.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center px-2 text-[12px] text-destructive`,children:[i,a?(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,a]}):null]})}),e.blastRadius.runIds.length>0?(0,Y.jsx)(`ul`,{children:e.blastRadius.runIds.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(Le,{to:`/overview`,search:{run:e},className:o(O,`text-destructive`),children:(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px]`,children:e})})},e))}):null]}):n?(0,Y.jsxs)(`section`,{className:o(P,`border-amber-500/25 bg-amber-500/5`),"aria-label":`Unset contract`,role:`status`,children:[(0,Y.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center px-2 text-[12px] text-amber-900 dark:text-amber-300`,children:[`No value in `,t,e.readers[0]?(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`· `,(0,Y.jsx)(`span`,{className:`font-mono`,children:e.readers[0]}),` will fail boot`]}):(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · boot gap until a layer provides one`})]}),(0,Y.jsx)(y,{type:`button`,size:`sm`,onClick:c,className:`h-full shrink-0 rounded-none`,children:`Set`})]}):s&&q(e.rotate)?(0,Y.jsxs)(`section`,{className:o(P,`border-amber-500/25 bg-amber-500/5`),"aria-label":`Rotation overdue`,role:`status`,children:[(0,Y.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center px-2 text-[12px] text-amber-900 dark:text-amber-300`,children:[`Past rotate `,e.rotate,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · blast is clear`})]}),(0,Y.jsx)(y,{type:`button`,variant:`destructive`,size:`sm`,onClick:l,className:`h-full shrink-0 rounded-none`,children:`Rotate`})]}):null}function Ot({title:e,meta:t,children:n}){return(0,Y.jsxs)(`header`,{className:o(P,`items-center gap-2 px-2`),children:[(0,Y.jsx)(`h3`,{className:o(C,`shrink-0 leading-none`),children:e}),n,t?(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-[10px] leading-none tabular-nums text-muted-foreground`,children:t}):null]})}function X({label:e,value:t,hint:n,warn:r=!1,won:i=!1,onClick:a}){let s=o(S,N,`gap-1.5`),c=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`tracking-[0.08em] uppercase`,children:e}),(0,Y.jsx)(`span`,{className:o(`font-mono tabular-nums text-foreground`,r&&`text-amber-800 dark:text-amber-400`,i&&bt),children:t})]});return a?(0,Y.jsx)(`button`,{type:`button`,title:n,onClick:a,className:s,children:c}):(0,Y.jsx)(`span`,{title:n,className:s,children:c})}function kt({steps:e,selected:t,fill:n,backend:i,onSelect:a}){let s=e.findIndex(e=>e.won);return(0,Y.jsxs)(`section`,{className:`shrink-0 border-b border-border/60`,"aria-label":`Resolution chain`,children:[(0,Y.jsx)(Ot,{title:`Resolution`,meta:`first hit wins`}),(0,Y.jsxs)(`ol`,{className:`relative`,"data-slot":`vault-lock-path`,children:[(0,Y.jsx)(`span`,{className:`pointer-events-none absolute top-3 bottom-3 left-[15px] w-px bg-border/60`,"aria-hidden":!0}),e.map((e,c)=>{let l=e.source===t.source,u=wt(e,c,s);return(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":l,onClick:()=>a(e.source),className:o(O,l&&`bg-muted/70 text-foreground`,s>=0&&c>s&&!l&&`opacity-50`),children:[(0,Y.jsx)(`span`,{className:o(oe,l&&`bg-sky-500`),"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:o(`relative z-10 size-2 shrink-0 rounded-full border`,u===`won`&&`border-emerald-500 bg-emerald-500`,u===`shadowed`&&`border-muted-foreground/50 bg-muted-foreground/40`,u===`missed`&&`border-muted-foreground/50 bg-transparent`,u===`skipped`&&`border-border bg-transparent`),"aria-hidden":!0}),(0,Y.jsx)(r,{icon:yt[e.source],className:o(k,u===`won`?bt:`text-muted-foreground`),"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:o(`min-w-0 flex-1 truncate font-mono`,u===`won`?bt:`text-foreground`),children:[vt[e.source],e.source===`driver`?(0,Y.jsx)(`span`,{className:`ml-1.5 font-sans text-[10px] text-muted-foreground`,children:We(i)}):null]}),(0,Y.jsx)(`span`,{className:o(`shrink-0 text-[10px]`,u===`won`?bt:`text-muted-foreground`),children:u})]}),l?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 py-1.5 pr-2 pl-8`,children:[(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground`,children:n.command}),(0,Y.jsx)(`span`,{className:`hidden min-w-0 truncate text-[10px] text-muted-foreground sm:inline`,children:n.hint}),(0,Y.jsx)(ke,{value:n.command,label:`Copy ${e.source} fill`})]}):null]},e.source)})]}),(0,Y.jsxs)(`p`,{className:`sr-only`,children:[`Winner: `,e.find(e=>e.won)?.source??`none`,`. `,n.hint]})]})}function At({slots:e,env:t}){return(0,Y.jsx)(`ul`,{"data-slot":`vault-fingerprints`,children:e.map(e=>(0,Y.jsxs)(`li`,{className:O,children:[(0,Y.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[e.env,e.env===t?(0,Y.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:`this`}):null]}),e.fp?(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px]`,children:e.fp}):(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 text-[11px] text-muted-foreground`,children:`—`}),e.shared?(0,Y.jsxs)(`span`,{role:`status`,className:`shrink-0 text-[10px] text-amber-800 dark:text-amber-400`,children:[`matches `,t]}):null,e.fp?(0,Y.jsx)(ke,{value:e.fp,label:`Copy ${e.env} fingerprint`}):null]},e.env))})}function jt(e,t){let n=new Set,r=[],i=(t,i)=>{n.has(t)||(n.add(t),r.push({env:t,fp:i,shared:i!=null&&e.sharedFingerprintEnvs.includes(t)}))};i(t,e.fingerprint);for(let[t,n]of Object.entries(e.fingerprints))i(t,n);return r}function Mt({readers:e,name:t,onFilterReader:n}){return(0,Y.jsxs)(`section`,{className:`shrink-0 border-b border-border/60`,"aria-label":`Readers`,children:[(0,Y.jsx)(Ot,{title:`Readers`,meta:String(e.length),children:(0,Y.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[10px] leading-none text-muted-foreground`,children:et(t)})}),e.length===0?(0,Y.jsx)(`p`,{className:`px-2 py-1.5 text-[11px] text-muted-foreground`,children:`None declared.`}):(0,Y.jsx)(`ul`,{children:e.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`div`,{className:o(O,`group/reader`),children:[(0,Y.jsx)(r,{icon:L.flow.icon,className:o(k,`text-sky-500`),"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e}),(0,Y.jsxs)(`div`,{className:o(de,`group-hover/reader:opacity-100 group-focus-within/reader:opacity-100`),children:[n?(0,Y.jsx)(`button`,{type:`button`,className:`shrink-0 text-[10px] text-muted-foreground hover:text-foreground`,onClick:()=>n(e),children:`filter`}):null,(0,Y.jsx)(Le,{to:`/flows`,search:{flow:e},className:`shrink-0 text-[10px] text-muted-foreground hover:text-foreground`,children:`Flows`}),(0,Y.jsx)(Le,{to:`/overview`,search:{flow:e},className:`shrink-0 text-[10px] text-muted-foreground hover:text-foreground`,children:`Graph`})]})]})},e))})]})}function Nt({loading:e=!1,hasContracts:t,query:n,onClearQuery:r,leading:i}){return e?(0,Y.jsx)(`div`,{"data-slot":`vault-overview`,className:`h-full`,children:(0,Y.jsx)(ze,{icon:L.vault.icon,iconClassName:`border-border/70`,title:`Loading vault…`,description:`Reading contracts and posture.`,leading:i})}):(0,Y.jsx)(`div`,{"data-slot":`vault-overview`,className:`h-full`,children:(0,Y.jsx)(ze,{icon:L.vault.icon,iconClassName:`border-border/70`,title:t?`No contracts match`:`No contracts`,leading:i,description:t?(0,Y.jsxs)(Y.Fragment,{children:[`Nothing matches `,(0,Y.jsx)(`span`,{className:`font-mono`,children:n}),`.`,` `,(0,Y.jsx)(`button`,{type:`button`,className:`underline underline-offset-2 hover:text-foreground`,onClick:r,children:`Clear search`})]}):`Declare vault.secret (fingerprinted) or vault.config (shown in the Config band) in the Manifest.`})})}var Pt={secret:`border-indigo-500/40 bg-indigo-500/12 text-indigo-600 dark:text-indigo-300`,config:`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`},Ft={secret:L.vault.icon,config:z},It={secret:`fingerprints only`,config:`vault.config · shown in clear`},Lt={blast:`border-destructive/40 bg-destructive/10 text-destructive`,unset:`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-400`,overdue:`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-400`,shared:`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-400`,dormant:`border-zinc-500/35 bg-zinc-500/10 text-zinc-500 dark:text-zinc-400`,healthy:Pt.secret,config:Pt.config},Rt={blast:B,unset:Ae,overdue:be,shared:Ze,dormant:Ae,healthy:L.vault.icon,config:z},zt={blast:`text-destructive`,unset:`text-amber-800 dark:text-amber-400`,overdue:`text-amber-800 dark:text-amber-400`,shared:`text-amber-800 dark:text-amber-400`,dormant:`text-muted-foreground`,healthy:`text-indigo-600 dark:text-indigo-300`,config:`text-emerald-700 dark:text-emerald-400`};function Bt({groups:e,selectedName:t,loading:n=!1,matchCount:i,totalCount:a,now:s,onSelect:c}){let[l,u]=(0,K.useState)({secret:!0,config:!0});return(0,K.useEffect)(()=>{let n=e.find(e=>e.secrets.some(e=>e.name===t));n&&u(e=>e[n.kind]===!1?{...e,[n.kind]:!0}:e)},[e,t]),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,"data-slot":`vault-list`,children:[(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[n&&e.length===0?(0,Y.jsx)(`p`,{className:j,children:`Loading…`}):null,!n&&e.length===0?(0,Y.jsxs)(`p`,{className:j,children:[`No contracts match. Try `,(0,Y.jsx)(`span`,{className:`font-mono`,children:`is:unset`}),` or clear the search.`]}):null,e.map(e=>{let n=l[e.kind]!==!1;return(0,Y.jsx)(`section`,{"aria-label":e.label,className:se,"data-slot":`vault-kind-band`,"data-kind":e.kind,children:(0,Y.jsxs)(Te,{open:n,onOpenChange:t=>u(n=>({...n,[e.kind]:t})),children:[(0,Y.jsx)(we,{nativeButton:!1,className:ne,"data-slot":`vault-kind-band-toggle`,render:t=>(0,Y.jsxs)(`div`,{...t,children:[(0,Y.jsx)(r,{icon:Ce,className:o(M,!n&&`-rotate-90`),"aria-hidden":!0}),(0,Y.jsx)(r,{icon:Ft[e.kind],className:o(k,D(Pt[e.kind])),"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:o(A,`flex-1`),title:It[e.kind],children:e.label}),(0,Y.jsx)(`span`,{className:ie,children:e.secrets.length})]})}),(0,Y.jsx)(Se,{children:(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:e.secrets.map(e=>(0,Y.jsx)(Vt,{row:e,selected:e.name===t,now:s,onSelect:c},e.name))})})]})},e.kind)})]}),e.length>0?(0,Y.jsx)(`p`,{className:`sr-only`,children:i===a?`${a} contracts`:`${i} of ${a} contracts`}):null]})}function Vt({row:e,selected:t,now:n,onSelect:i}){let a=e.description?.trim()||e.name,s=e.kind===`config`?e.cleartext??`unset`:e.name,c=s!==a,l=pt(e,n),u=l.primary!==`healthy`&&l.primary!==`config`,d=e.readers.length===0?`no readers`:`${e.readers.length} reader${e.readers.length===1?``:`s`}`,f=[e.origin===`console`?`console`:null,e.kind===`secret`&&!q(e.rotate)?`no rotate`:null].filter(e=>e!==null);return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,"aria-label":`${a}, ${s}, ${d}, ${gt(l.primary)}`,onClick:()=>i(e.name),className:o(O,`items-start py-2`,t&&`bg-muted/70 text-foreground`),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:o(oe,t&&`bg-[var(--vault-accent)]`),style:{"--vault-accent":J}}),(0,Y.jsx)(I,{label:_t(l.primary,e.rotate),children:(0,Y.jsx)(r,{icon:Rt[l.primary],className:o(k,`mt-0.5`,D(Lt[l.primary])),"aria-hidden":!0})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:a}),u?(0,Y.jsx)(Ht,{posture:l}):null]}),(0,Y.jsxs)(`span`,{className:`mt-0.5 flex min-w-0 items-center gap-1.5 text-[10px] text-muted-foreground`,children:[c?(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono`,children:s}):null,c?(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`·`}):null,(0,Y.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:d}),f.map(e=>(0,Y.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e]},e))]})]})]})})}function Ht({posture:e}){return(0,Y.jsx)(`span`,{role:`status`,className:o(`shrink-0 text-[10px] font-medium`,zt[e.primary]),children:gt(e.primary)})}var Ut=new Set([`unset`,`set`,`dormant`,`blast`,`shared`,`overdue`,`unread`,`healthy`]),Wt=new Set([`secret`,`config`]),Gt=new Set([`readers`,`rotate`,`blast`,`shared`]),Kt=[{token:`is:unset`,label:`No value in this environment`},{token:`is:set`,label:`Has a fingerprint or config value`},{token:`is:blast`,label:`In-flight durable runs hold this secret`},{token:`is:shared`,label:`Fingerprint matches another environment`},{token:`is:dormant`,label:`Unread for 90 days, or never`},{token:`is:overdue`,label:`Last read older than rotate — never-read counts`},{token:`is:healthy`,label:`Set, no blast, no shared, not dormant`},{token:`kind:secret`,label:`Sensitive contracts only`},{token:`kind:config`,label:`Non-sensitive config only`},{token:`from:.env.local`,label:`Winner is .env.local`},{token:`from:driver`,label:`Winner is the vault backend (built-in / managed / memory)`},{token:`has:readers`,label:`At least one Flow declares a read`},{token:`has:rotate`,label:`Contract declares a rotate cadence`},{token:`rotate:never`,label:`No rotate cadence (stable secret)`},{token:`reader:`,label:`Flow id contains…`},{token:`fp:`,label:`Fingerprint contains…`}],qt=[`driver`,`process.env`,`.env.local`,`dev-fallback`];function Jt(e){let t=[],n=/"([^"]+)"|(\S+)/g,r;for(;(r=n.exec(e))!==null;){let e=r[1]??r[2]??``;e.length>0&&t.push(e)}return t}function Yt(e){let t=[];for(let n of Jt(e)){let e=nn(n);e?t.push(e):t.push({kind:`text`,value:n})}return{tokens:t,raw:e}}function Xt(e){let t=[],n=[];for(let r of e){if(r.kind===`text`){n.push(sn(r.value)?`"${r.value}"`:r.value);continue}t.push(`${r.kind}:${r.value}`)}return[...t,...n].join(` `).trim()}function Zt(e,t){let n=Yt(e);return Xt(n.tokens.some(e=>e.kind===`is`&&e.value===t)?n.tokens.filter(e=>e.kind!==`is`||e.value!==t):[...n.tokens,{kind:`is`,value:t}])}function Qt(e,t){return Yt(e).tokens.some(e=>e.kind===`is`&&e.value===t)}function $t(e,t,n){if(t.tokens.length===0)return!0;let r=pt(e,n);for(let n of t.tokens)if(!rn(e,n,r))return!1;return!0}function en(e,t){let n=cn(e);if(n===null)return Kt;let r=n.toLowerCase();if(r.startsWith(`is:`)||r===`is`)return Z(Kt.filter(e=>e.token.startsWith(`is:`)),n);if(r.startsWith(`kind:`)||r===`kind`)return Z([{token:`kind:secret`,label:`Sensitive contracts only`},{token:`kind:config`,label:`Non-sensitive config only`}],n);if(r.startsWith(`from:`)||r===`from`)return Z(qt.map(e=>({token:`from:${e}`,label:e===`driver`?`Winner is the vault backend (built-in / managed / memory)`:`Winner is ${e}`})),n);if(r.startsWith(`has:`)||r===`has`)return Z(Kt.filter(e=>e.token.startsWith(`has:`)),n);if(r.startsWith(`reader:`)||r===`reader`){let e=r.startsWith(`reader:`)?r.slice(7):``,n=new Set;for(let r of t)for(let t of r.readers)(e.length===0||t.toLowerCase().includes(e))&&n.add(t);return[...n].slice(0,8).map(e=>({token:`reader:${e}`,label:`Flow that reads this contract`}))}if(r.startsWith(`fp:`)||r===`fp`){let e=r.startsWith(`fp:`)?r.slice(3):``,n=new Set;for(let r of t){for(let t of Object.values(r.fingerprints))(e.length===0||t.toLowerCase().includes(e))&&n.add(t);r.fingerprint&&(e.length===0||r.fingerprint.toLowerCase().includes(e))&&n.add(r.fingerprint)}return[...n].slice(0,8).map(e=>({token:`fp:${e}`,label:`Exact fingerprint`}))}if(r.startsWith(`rotate:`)||r===`rotate`)return Z([{token:`rotate:due`,label:`Last read older than rotate — never-read counts`},{token:`has:rotate`,label:`Contract declares a rotate cadence`},{token:`rotate:never`,label:`No rotate cadence (stable secret)`}],n);let i=r;return Kt.filter(e=>e.token.includes(i)||e.label.toLowerCase().includes(i))}function tn(e,t){if(e.length===0||/\s$/.test(e))return`${e}${t} `.replace(/^\s+/,``);let n=e.lastIndexOf(` `);return n<0?`${t} `:`${e.slice(0,n+1)}${t} `}function nn(e){if(e.startsWith(`"`))return null;let t=e.indexOf(`:`);if(t<=0)return null;let n=e.slice(0,t).toLowerCase(),r=e.slice(t+1);if(r.length===0)return null;if(n===`is`){let e=r.toLowerCase();return Ut.has(e)?{kind:`is`,value:e}:Wt.has(e)?{kind:`kind`,value:e}:null}if(n===`kind`){let e=r.toLowerCase();return Wt.has(e)?{kind:`kind`,value:e}:null}if(n===`from`)return{kind:`from`,value:r.toLowerCase()};if(n===`reader`)return{kind:`reader`,value:r.toLowerCase()};if(n===`fp`)return{kind:`fp`,value:r.toLowerCase()};if(n===`has`){let e=r.toLowerCase();return Gt.has(e)?{kind:`has`,value:e}:null}if(n===`rotate`){let e=r.toLowerCase();return e===`due`?{kind:`is`,value:`overdue`}:{kind:`rotate`,value:e}}return null}function rn(e,t,n){switch(t.kind){case`is`:return n[t.value];case`kind`:return e.kind===t.value;case`from`:return(e.winner??``).toLowerCase()===t.value;case`reader`:return e.readers.some(e=>e.toLowerCase().includes(t.value));case`fp`:return an(e).some(e=>e.includes(t.value));case`has`:return t.value===`readers`?e.readers.length>0:t.value===`rotate`?q(e.rotate):t.value===`blast`?e.blastRadius.count>0:e.sharedFingerprintEnvs.length>0;case`rotate`:return t.value===`never`?e.kind===`secret`&&!q(e.rotate):(e.rotate??``).toLowerCase()===t.value;case`text`:return on(e).includes(t.value.toLowerCase())}}function an(e){let t=Object.values(e.fingerprints).map(e=>e.toLowerCase());return e.fingerprint&&t.push(e.fingerprint.toLowerCase()),t}function on(e){return[e.name,e.description??``,e.winner??``,e.kind,...e.readers,...Object.keys(e.fingerprints),...Object.values(e.fingerprints),e.fingerprint??``,e.sensitive?``:e.cleartext??``].join(`
|
|
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{$n as r,Cr as i,E as a,Qn as o,_ as s,b as c,c as l,d as u,er as d,h as f,i as p,l as m,o as h,p as g,s as _,u as v,x as y,y as b}from"./shortcut-keys-DTE1sjTC.js";import{At as x,C as S,D as C,Dt as w,E as T,Et as E,O as D,S as ee,W as te,_ as O,a as ne,b as re,c as ie,d as ae,f as k,g as oe,i as se,jt as ce,kt as le,m as ue,o as A,p as j,r as de,s as M,w as N,x as P}from"./explorer-chrome-Dslh2yE8.js";import{a as fe,b as pe,c as F,h as me,i as he,m as ge,n as _e,o as ve,r as ye,s as I,t as L,v as R,x as be}from"./element-icons-C6t8Vlml.js";import{a as z,i as xe,n as Se,o as Ce,r as we,s as B,t as Te}from"./collapsible-BvFaX-Zt.js";import{t as Ee}from"./FileExportIcon-Ck-5od4R.js";import{t as De}from"./MoreHorizontalCircle01Icon-gMNGsE37.js";import{n as Oe,t as ke}from"./copy-inline-button-BTjPVjRT.js";import{t as Ae}from"./UnavailableIcon-D9cvHVPr.js";import{a as V,d as je,i as Me,l as Ne,r as Pe,t as Fe}from"./dropdown-menu-CRGrj5JU.js";import{Mt as Ie,jt as Le,xt as Re}from"./index-RhV2jT_7.js";import{t as ze}from"./explorer-empty-CIVg7Jgb.js";import{a as H,c as U,l as W,n as G,o as Be,s as Ve,t as He}from"./detail-header-Dk5LipF6.js";import{t as Ue}from"./confirm-sheet-DZfuJXP4.js";import{a as We,i as Ge,n as Ke,o as qe,r as Je,s as Ye,t as Xe}from"./use-vault-list-BAyQG8Re.js";var Ze=[[`path`,{d:`M16 21C15.7668 18.0685 13.3422 15.7477 10.3085 15.5521L9.49999 15.5C9.21121 15.5076 8.94209 15.5178 8.68816 15.5298C5.68124 15.6723 3.23089 18.0974 3 21`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M12.75 9.75C12.75 11.5449 11.2949 13 9.5 13C7.70508 13 6.25 11.5449 6.25 9.75C6.25 7.95507 7.70508 6.5 9.5 6.5C11.2949 6.5 12.75 7.95507 12.75 9.75Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M21 17.501C20.7709 14.6314 18.4541 12.2748 15.5 11.9961`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}],[`path`,{d:`M15.9877 9C16.8965 8.42434 17.5001 7.40788 17.5001 6.25C17.5001 4.45507 16.0496 3 14.2602 3C13.3811 3 12.5838 3.35121 12.0001 3.92139`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`3`}]],K=e(t(),1);function Qe(e){if(e.count===0)return{summary:`No in-flight durable runs hold this secret`,detail:null,warn:!1};let t=e.longestOutstandingMs==null?null:$e(e.longestOutstandingMs);return{summary:`${e.count} in-flight durable run(s) will wake holding a new key`,detail:t?`Longest outstanding wake in ${t}`:e.longestWakeAt==null?null:`Longest wake at ${new Date(e.longestWakeAt).toISOString()}`,warn:!0}}function $e(e){if(e<1e3)return`${e}ms`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<48?`${r}h`:`${Math.floor(r/24)}d`}function et(e){return`await fx.vault.get(${e})`}function tt(e){return`oke vault set ${e}`}function nt(e){return`oke vault rotate ${e}`}function rt(e){return`${e}=`}function it(e,t,n){switch(e){case`process.env`:return{source:e,label:`env`,command:`export ${t}=`,hint:`Process environment for this Console process`};case`.env.local`:return{source:e,label:`local`,command:rt(t),hint:`Write to .env.local (gitignored)`};case`driver`:return{source:e,label:qe(n),command:tt(t),hint:Ge(n)};case`dev-fallback`:return{source:e,label:`fallback`,command:`dev: "…"`,hint:`Local-only option on the contract — never used in prod`}}}function at(e){return{name:e.name,kind:e.kind,sensitive:e.sensitive,description:e.description??null,rotate:e.rotate??null,fingerprints:{...e.fingerprints},fingerprint:e.fingerprint,cleartext:e.sensitive?null:e.cleartext,winner:e.winner,resolution:e.resolution.map(e=>({...e})),readers:[...e.readers],blastRadius:{count:e.blastRadius.count,longestWakeAt:e.blastRadius.longestWakeAt,longestOutstandingMs:e.blastRadius.longestOutstandingMs,runIds:[...e.blastRadius.runIds]},lastReadAt:e.lastReadAt,sharedFingerprintEnvs:[...e.sharedFingerprintEnvs]}}function ot(e){return JSON.stringify(e.map(e=>at(e)),null,2)}var st=[{id:`blast`,label:`Blast`,token:`blast`,tone:`danger`},{id:`unset`,label:`Unset`,token:`unset`,tone:`warn`},{id:`overdue`,label:`Overdue`,token:`overdue`,tone:`warn`},{id:`shared`,label:`Shared`,token:`shared`,tone:`warn`},{id:`dormant`,label:`Dormant`,token:`dormant`,tone:`neutral`}],ct=[`blast`,`unset`,`overdue`,`shared`,`dormant`];function lt(e){if(!e)return 0;let t=/^(\d+)(ms|s|m|h|d)$/.exec(e.trim());if(!t)return 0;let n=Number(t[1]);switch(t[2]){case`ms`:return n;case`s`:return n*1e3;case`m`:return n*6e4;case`h`:return n*36e5;case`d`:return n*864e5;default:return 0}}var ut=new Set([`never`,`none`,`off`]);function q(e){return lt(e)>0}function dt(e){if(q(e))return e.trim();let t=e?.trim().toLowerCase()??``;return t.length===0||ut.has(t)?`no rotate`:e.trim()}function ft(e){return e.sensitive?e.fingerprint!=null&&e.fingerprint.length>0:e.cleartext!=null&&e.cleartext.length>0}function pt(e,t){let n=ft(e),r=!n,i=e.blastRadius.count>0,a=e.sharedFingerprintEnvs.length>0,o=e.lastReadAt==null,s=e.kind===`secret`&&(o||e.lastReadAt!=null&&t-e.lastReadAt>=7776e6),c=lt(e.rotate),l=e.kind===`secret`&&n&&c>0&&(o||e.lastReadAt!=null&&t-e.lastReadAt>=c),u=[];return i&&u.push(`blast`),r&&u.push(`unset`),l&&u.push(`overdue`),a&&u.push(`shared`),s&&u.push(`dormant`),{unset:r,set:n,blast:i,shared:a,dormant:s,overdue:l,unread:o,healthy:n&&!i&&!a&&!s&&!l,risks:u,primary:e.kind===`config`&&!r&&!i&&!a?`config`:ct.find(e=>u.includes(e))??`healthy`}}function mt(e,t){let n=0,r=0,i=0,a=0,o=0,s=0,c=0,l=0;for(let u of e){u.kind===`secret`?n+=1:r+=1;let e=pt(u,t);e.unset&&(i+=1),e.blast&&(a+=1),e.shared&&(o+=1),e.dormant&&(s+=1),e.overdue&&(c+=1),e.healthy&&(l+=1)}return{total:e.length,secrets:n,config:r,unset:i,blast:a,shared:o,dormant:s,overdue:c,healthy:l}}function ht(e,t){let n=Math.max(0,t-e);if(n<6e4)return`just now`;if(n<36e5)return`${Math.floor(n/6e4)}m ago`;if(n<864e5)return`${Math.floor(n/36e5)}h ago`;let r=Math.floor(n/864e5);return r<14?`${r}d ago`:r<60?`${Math.floor(r/7)}w ago`:`${Math.floor(r/30)}mo ago`}function gt(e){switch(e){case`blast`:return`blast`;case`unset`:return`unset`;case`overdue`:return`overdue`;case`shared`:return`shared`;case`dormant`:return`dormant`;case`config`:return`config`;case`healthy`:return`set`}}function _t(e,t){switch(e){case`blast`:return`In-flight durable runs hold this secret`;case`unset`:return`No value in this environment`;case`overdue`:return t?`Last read older than rotate ${t} — never-read counts`:`Last read older than the rotate hint — never-read counts`;case`shared`:return`Fingerprint matches another environment`;case`dormant`:return`Unread for 90 days, or never`;case`config`:return`vault.config — shown in the clear`;case`healthy`:return`Set, no blast, no shared, not dormant`}}var J=`#94A3B8`,Y=n(),vt={driver:`driver`,"process.env":`env`,".env.local":`local`,"dev-fallback":`fallback`},yt={driver:me,"process.env":z,".env.local":R,"dev-fallback":Ae},bt=`text-emerald-700 dark:text-emerald-400`,xt=[`driver`,`process.env`,`.env.local`,`dev-fallback`];function St(e){let t=e.resolution.length>0?e.resolution:xt.map(t=>({source:t,present:!1,won:e.winner===t})),n=new Map(t.map(e=>[e.source,e]));return xt.map(t=>n.get(t)??{source:t,present:!1,won:e.winner===t})}function Ct(e){return e.find(e=>e.won)?.source??e.find(e=>!e.present)?.source??e[0].source}function wt(e,t,n){return e.won?`won`:n>=0&&t>n?e.present?`shadowed`:`skipped`:e.present?`shadowed`:`missed`}function Tt({row:e,env:t,now:n,backend:i=null,onSet:a,onRotate:o,onQueryChange:s,leading:c}){let l=Qe(e.blastRadius),u=pt(e,n),d=e.description??e.name,f=jt(e,t),p=St(e),m=p.find(e=>e.won)??null,[h,g]=(0,K.useState)(()=>Ct(p)),_=u.unset,v=u.overdue&&q(e.rotate)&&!l.warn&&!u.unset;(0,K.useEffect)(()=>{g(Ct(St(e)))},[e.name]);let b=p.find(e=>e.source===h)??p[0],x=it(b.source,e.name,i);return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-y-auto`,"data-slot":`vault-detail`,"aria-label":`Vault detail`,"aria-live":`polite`,children:[(0,Y.jsx)(He,{dataSlot:`vault-detail-header`,leading:c,icon:(0,Y.jsx)(r,{icon:L.vault.icon,className:`size-4`}),wellStyle:{color:J},title:d,badge:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`font-mono text-[10px] font-medium tracking-[0.08em] text-muted-foreground uppercase`,children:e.kind}),e.kind===`secret`?(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:dt(e.rotate)}):null,e.origin===`console`?(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:`console`}):null,(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:We(i)})]}),subtitle:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[11px] leading-none text-foreground/80`,children:e.name}),(0,Y.jsx)(ke,{value:e.name,label:`Copy ${e.name}`})]}),actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Et,{row:e}),_?null:(0,Y.jsx)(I,{label:e.kind===`config`?`Updates this vault.config value. Console shows it in the clear.`:`Write-only. The new value is never shown again.`,className:`flex self-stretch`,children:(0,Y.jsx)(y,{type:`button`,variant:`ghost`,size:`sm`,className:`h-full rounded-none`,onClick:a,children:`Set`})}),_||v?null:(0,Y.jsx)(I,{label:l.warn?l.summary:`Re-encrypt with a new value. Review the fingerprint before it writes.`,className:`flex self-stretch`,children:(0,Y.jsx)(y,{type:`button`,variant:`destructive`,size:`sm`,className:`h-full rounded-none`,disabled:l.warn,onClick:o,children:`Rotate`})})]})}),(0,Y.jsx)(Dt,{row:e,env:t,postureUnset:u.unset,blastWarn:l.warn,blastSummary:l.summary,blastDetail:l.detail,overdue:u.overdue,onSet:a,onRotate:o}),(0,Y.jsxs)(`div`,{className:P,"data-slot":`vault-briefing`,role:`group`,"aria-label":`Posture`,children:[(0,Y.jsx)(X,{label:`from`,value:e.winner?vt[e.winner]:`none`,hint:m?e.winner===`driver`?Ye(i):`First layer that had a value`:`No layer provided a value`,warn:!e.winner,won:!!e.winner,onClick:s?()=>s(e.winner?`from:${e.winner}`:`is:unset`):void 0}),(0,Y.jsx)(X,{label:`read`,value:e.lastReadAt==null?`never`:ht(e.lastReadAt,n),hint:e.lastReadAt==null?`Possible dead secret`:new Date(e.lastReadAt).toISOString(),warn:e.lastReadAt==null&&e.kind===`secret`,onClick:s?()=>s(`is:dormant`):void 0}),(0,Y.jsx)(X,{label:`readers`,value:String(e.readers.length),hint:e.readers.length===0?`No Flow declares a read`:e.readers.join(`, `),onClick:s&&e.readers[0]?()=>s(`reader:${e.readers[0]}`):void 0}),(0,Y.jsx)(X,{label:`blast`,value:e.blastRadius.count===0?`clear`:`${e.blastRadius.count} run${e.blastRadius.count===1?``:`s`}`,hint:l.detail??(e.blastRadius.longestOutstandingMs==null?l.summary:$e(e.blastRadius.longestOutstandingMs)),warn:l.warn,onClick:s?()=>s(`is:blast`):void 0}),e.sharedFingerprintEnvs.length>0?(0,Y.jsx)(X,{label:`shared`,value:e.sharedFingerprintEnvs.join(`, `),hint:`Same fingerprint in another environment`,warn:!0,onClick:s?()=>s(`is:shared`):void 0}):null]}),(0,Y.jsx)(kt,{steps:p,selected:b,fill:x,backend:i,onSelect:g}),(0,Y.jsxs)(`section`,{className:`shrink-0 border-b border-border/60`,"aria-label":`Fingerprints by environment`,children:[(0,Y.jsx)(Ot,{title:e.sensitive?`Fingerprints`:`Value`,meta:e.sensitive?`${f.length} env`:t}),e.sensitive?(0,Y.jsx)(At,{slots:f,env:t}):(0,Y.jsx)(`p`,{className:`px-2 py-1.5 font-mono text-[12px]`,role:`status`,children:e.cleartext??`unset`})]}),(0,Y.jsx)(Mt,{readers:e.readers,name:e.name,onFilterReader:s?e=>s(`reader:${e}`):void 0})]})}function Et({row:e}){let t=[{id:`fx`,label:`Flow read`,value:et(e.name)},{id:`set`,label:`oke vault set`,value:tt(e.name)},{id:`rotate`,label:`oke vault rotate`,value:nt(e.name)},{id:`env`,label:`.env assignment`,value:rt(e.name)},{id:`json`,label:`Export fingerprints`,value:JSON.stringify(at(e),null,2)}];return(0,Y.jsxs)(Fe,{children:[(0,Y.jsx)(I,{label:`Copy snippets (no secret values)`,className:`flex self-stretch`,children:(0,Y.jsx)(je,{render:e=>(0,Y.jsx)(`button`,{...e,type:`button`,"aria-label":`Copy`,className:ae,children:(0,Y.jsx)(r,{icon:De,className:`size-3.5`})})})}),(0,Y.jsxs)(Pe,{align:`end`,className:`min-w-52`,children:[(0,Y.jsx)(Me,{children:t.slice(0,4).map(e=>(0,Y.jsx)(V,{onClick:()=>{navigator.clipboard?.writeText(e.value)},children:e.label},e.id))}),(0,Y.jsx)(Ne,{}),(0,Y.jsx)(V,{onClick:()=>{navigator.clipboard?.writeText(t[4].value)},children:`Export fingerprints`})]})]})}function Dt({row:e,env:t,postureUnset:n,blastWarn:r,blastSummary:i,blastDetail:a,overdue:s,onSet:c,onRotate:l}){return r?(0,Y.jsxs)(`section`,{className:`shrink-0 border-b border-destructive/25 bg-destructive/5`,"aria-label":`Rotation blast radius`,role:`alert`,children:[(0,Y.jsx)(`div`,{className:o(P,`border-b-0`),children:(0,Y.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center px-2 text-[12px] text-destructive`,children:[i,a?(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,a]}):null]})}),e.blastRadius.runIds.length>0?(0,Y.jsx)(`ul`,{children:e.blastRadius.runIds.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(Le,{to:`/overview`,search:{run:e},className:o(O,`text-destructive`),children:(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px]`,children:e})})},e))}):null]}):n?(0,Y.jsxs)(`section`,{className:o(P,`border-amber-500/25 bg-amber-500/5`),"aria-label":`Unset contract`,role:`status`,children:[(0,Y.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center px-2 text-[12px] text-amber-900 dark:text-amber-300`,children:[`No value in `,t,e.readers[0]?(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`· `,(0,Y.jsx)(`span`,{className:`font-mono`,children:e.readers[0]}),` will fail boot`]}):(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · boot gap until a layer provides one`})]}),(0,Y.jsx)(y,{type:`button`,size:`sm`,onClick:c,className:`h-full shrink-0 rounded-none`,children:`Set`})]}):s&&q(e.rotate)?(0,Y.jsxs)(`section`,{className:o(P,`border-amber-500/25 bg-amber-500/5`),"aria-label":`Rotation overdue`,role:`status`,children:[(0,Y.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center px-2 text-[12px] text-amber-900 dark:text-amber-300`,children:[`Past rotate `,e.rotate,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · blast is clear`})]}),(0,Y.jsx)(y,{type:`button`,variant:`destructive`,size:`sm`,onClick:l,className:`h-full shrink-0 rounded-none`,children:`Rotate`})]}):null}function Ot({title:e,meta:t,children:n}){return(0,Y.jsxs)(`header`,{className:o(P,`items-center gap-2 px-2`),children:[(0,Y.jsx)(`h3`,{className:o(C,`shrink-0 leading-none`),children:e}),n,t?(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-[10px] leading-none tabular-nums text-muted-foreground`,children:t}):null]})}function X({label:e,value:t,hint:n,warn:r=!1,won:i=!1,onClick:a}){let s=o(S,N,`gap-1.5`),c=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`tracking-[0.08em] uppercase`,children:e}),(0,Y.jsx)(`span`,{className:o(`font-mono tabular-nums text-foreground`,r&&`text-amber-800 dark:text-amber-400`,i&&bt),children:t})]});return a?(0,Y.jsx)(`button`,{type:`button`,title:n,onClick:a,className:s,children:c}):(0,Y.jsx)(`span`,{title:n,className:s,children:c})}function kt({steps:e,selected:t,fill:n,backend:i,onSelect:a}){let s=e.findIndex(e=>e.won);return(0,Y.jsxs)(`section`,{className:`shrink-0 border-b border-border/60`,"aria-label":`Resolution chain`,children:[(0,Y.jsx)(Ot,{title:`Resolution`,meta:`first hit wins`}),(0,Y.jsxs)(`ol`,{className:`relative`,"data-slot":`vault-lock-path`,children:[(0,Y.jsx)(`span`,{className:`pointer-events-none absolute top-3 bottom-3 left-[15px] w-px bg-border/60`,"aria-hidden":!0}),e.map((e,c)=>{let l=e.source===t.source,u=wt(e,c,s);return(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":l,onClick:()=>a(e.source),className:o(O,l&&`bg-muted/70 text-foreground`,s>=0&&c>s&&!l&&`opacity-50`),children:[(0,Y.jsx)(`span`,{className:o(oe,l&&`bg-sky-500`),"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:o(`relative z-10 size-2 shrink-0 rounded-full border`,u===`won`&&`border-emerald-500 bg-emerald-500`,u===`shadowed`&&`border-muted-foreground/50 bg-muted-foreground/40`,u===`missed`&&`border-muted-foreground/50 bg-transparent`,u===`skipped`&&`border-border bg-transparent`),"aria-hidden":!0}),(0,Y.jsx)(r,{icon:yt[e.source],className:o(k,u===`won`?bt:`text-muted-foreground`),"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:o(`min-w-0 flex-1 truncate font-mono`,u===`won`?bt:`text-foreground`),children:[vt[e.source],e.source===`driver`?(0,Y.jsx)(`span`,{className:`ml-1.5 font-sans text-[10px] text-muted-foreground`,children:We(i)}):null]}),(0,Y.jsx)(`span`,{className:o(`shrink-0 text-[10px]`,u===`won`?bt:`text-muted-foreground`),children:u})]}),l?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 py-1.5 pr-2 pl-8`,children:[(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground`,children:n.command}),(0,Y.jsx)(`span`,{className:`hidden min-w-0 truncate text-[10px] text-muted-foreground sm:inline`,children:n.hint}),(0,Y.jsx)(ke,{value:n.command,label:`Copy ${e.source} fill`})]}):null]},e.source)})]}),(0,Y.jsxs)(`p`,{className:`sr-only`,children:[`Winner: `,e.find(e=>e.won)?.source??`none`,`. `,n.hint]})]})}function At({slots:e,env:t}){return(0,Y.jsx)(`ul`,{"data-slot":`vault-fingerprints`,children:e.map(e=>(0,Y.jsxs)(`li`,{className:O,children:[(0,Y.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[e.env,e.env===t?(0,Y.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:`this`}):null]}),e.fp?(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px]`,children:e.fp}):(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 text-[11px] text-muted-foreground`,children:`—`}),e.shared?(0,Y.jsxs)(`span`,{role:`status`,className:`shrink-0 text-[10px] text-amber-800 dark:text-amber-400`,children:[`matches `,t]}):null,e.fp?(0,Y.jsx)(ke,{value:e.fp,label:`Copy ${e.env} fingerprint`}):null]},e.env))})}function jt(e,t){let n=new Set,r=[],i=(t,i)=>{n.has(t)||(n.add(t),r.push({env:t,fp:i,shared:i!=null&&e.sharedFingerprintEnvs.includes(t)}))};i(t,e.fingerprint);for(let[t,n]of Object.entries(e.fingerprints))i(t,n);return r}function Mt({readers:e,name:t,onFilterReader:n}){return(0,Y.jsxs)(`section`,{className:`shrink-0 border-b border-border/60`,"aria-label":`Readers`,children:[(0,Y.jsx)(Ot,{title:`Readers`,meta:String(e.length),children:(0,Y.jsx)(`code`,{className:`min-w-0 truncate font-mono text-[10px] leading-none text-muted-foreground`,children:et(t)})}),e.length===0?(0,Y.jsx)(`p`,{className:`px-2 py-1.5 text-[11px] text-muted-foreground`,children:`None declared.`}):(0,Y.jsx)(`ul`,{children:e.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`div`,{className:o(O,`group/reader`),children:[(0,Y.jsx)(r,{icon:L.flow.icon,className:o(k,`text-sky-500`),"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e}),(0,Y.jsxs)(`div`,{className:o(de,`group-hover/reader:opacity-100 group-focus-within/reader:opacity-100`),children:[n?(0,Y.jsx)(`button`,{type:`button`,className:`shrink-0 text-[10px] text-muted-foreground hover:text-foreground`,onClick:()=>n(e),children:`filter`}):null,(0,Y.jsx)(Le,{to:`/flows`,search:{flow:e},className:`shrink-0 text-[10px] text-muted-foreground hover:text-foreground`,children:`Flows`}),(0,Y.jsx)(Le,{to:`/overview`,search:{flow:e},className:`shrink-0 text-[10px] text-muted-foreground hover:text-foreground`,children:`Graph`})]})]})},e))})]})}function Nt({loading:e=!1,hasContracts:t,query:n,onClearQuery:r,leading:i}){return e?(0,Y.jsx)(`div`,{"data-slot":`vault-overview`,className:`h-full`,children:(0,Y.jsx)(ze,{icon:L.vault.icon,iconClassName:`border-border/70`,title:`Loading vault…`,description:`Reading contracts and posture.`,leading:i})}):(0,Y.jsx)(`div`,{"data-slot":`vault-overview`,className:`h-full`,children:(0,Y.jsx)(ze,{icon:L.vault.icon,iconClassName:`border-border/70`,title:t?`No contracts match`:`No contracts`,leading:i,description:t?(0,Y.jsxs)(Y.Fragment,{children:[`Nothing matches `,(0,Y.jsx)(`span`,{className:`font-mono`,children:n}),`.`,` `,(0,Y.jsx)(`button`,{type:`button`,className:`underline underline-offset-2 hover:text-foreground`,onClick:r,children:`Clear search`})]}):`Declare vault.secret (fingerprinted) or vault.config (shown in the Config band) in the Manifest.`})})}var Pt={secret:`border-indigo-500/40 bg-indigo-500/12 text-indigo-600 dark:text-indigo-300`,config:`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`},Ft={secret:L.vault.icon,config:z},It={secret:`fingerprints only`,config:`vault.config · shown in clear`},Lt={blast:`border-destructive/40 bg-destructive/10 text-destructive`,unset:`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-400`,overdue:`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-400`,shared:`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-400`,dormant:`border-zinc-500/35 bg-zinc-500/10 text-zinc-500 dark:text-zinc-400`,healthy:Pt.secret,config:Pt.config},Rt={blast:B,unset:Ae,overdue:be,shared:Ze,dormant:Ae,healthy:L.vault.icon,config:z},zt={blast:`text-destructive`,unset:`text-amber-800 dark:text-amber-400`,overdue:`text-amber-800 dark:text-amber-400`,shared:`text-amber-800 dark:text-amber-400`,dormant:`text-muted-foreground`,healthy:`text-indigo-600 dark:text-indigo-300`,config:`text-emerald-700 dark:text-emerald-400`};function Bt({groups:e,selectedName:t,loading:n=!1,matchCount:i,totalCount:a,now:s,onSelect:c}){let[l,u]=(0,K.useState)({secret:!0,config:!0});return(0,K.useEffect)(()=>{let n=e.find(e=>e.secrets.some(e=>e.name===t));n&&u(e=>e[n.kind]===!1?{...e,[n.kind]:!0}:e)},[e,t]),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,"data-slot":`vault-list`,children:[(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[n&&e.length===0?(0,Y.jsx)(`p`,{className:j,children:`Loading…`}):null,!n&&e.length===0?(0,Y.jsxs)(`p`,{className:j,children:[`No contracts match. Try `,(0,Y.jsx)(`span`,{className:`font-mono`,children:`is:unset`}),` or clear the search.`]}):null,e.map(e=>{let n=l[e.kind]!==!1;return(0,Y.jsx)(`section`,{"aria-label":e.label,className:se,"data-slot":`vault-kind-band`,"data-kind":e.kind,children:(0,Y.jsxs)(Te,{open:n,onOpenChange:t=>u(n=>({...n,[e.kind]:t})),children:[(0,Y.jsx)(we,{nativeButton:!1,className:ne,"data-slot":`vault-kind-band-toggle`,render:t=>(0,Y.jsxs)(`div`,{...t,children:[(0,Y.jsx)(r,{icon:Ce,className:o(M,!n&&`-rotate-90`),"aria-hidden":!0}),(0,Y.jsx)(r,{icon:Ft[e.kind],className:o(k,D(Pt[e.kind])),"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:o(A,`flex-1`),title:It[e.kind],children:e.label}),(0,Y.jsx)(`span`,{className:ie,children:e.secrets.length})]})}),(0,Y.jsx)(Se,{children:(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:e.secrets.map(e=>(0,Y.jsx)(Vt,{row:e,selected:e.name===t,now:s,onSelect:c},e.name))})})]})},e.kind)})]}),e.length>0?(0,Y.jsx)(`p`,{className:`sr-only`,children:i===a?`${a} contracts`:`${i} of ${a} contracts`}):null]})}function Vt({row:e,selected:t,now:n,onSelect:i}){let a=e.description?.trim()||e.name,s=e.kind===`config`?e.cleartext??`unset`:e.name,c=s!==a,l=pt(e,n),u=l.primary!==`healthy`&&l.primary!==`config`,d=e.readers.length===0?`no readers`:`${e.readers.length} reader${e.readers.length===1?``:`s`}`,f=[e.origin===`console`?`console`:null,e.kind===`secret`&&!q(e.rotate)?`no rotate`:null].filter(e=>e!==null);return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,"aria-label":`${a}, ${s}, ${d}, ${gt(l.primary)}`,onClick:()=>i(e.name),className:o(O,`items-start py-2`,t&&`bg-muted/70 text-foreground`),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:o(oe,t&&`bg-[var(--vault-accent)]`),style:{"--vault-accent":J}}),(0,Y.jsx)(I,{label:_t(l.primary,e.rotate),children:(0,Y.jsx)(r,{icon:Rt[l.primary],className:o(k,`mt-0.5`,D(Lt[l.primary])),"aria-hidden":!0})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:a}),u?(0,Y.jsx)(Ht,{posture:l}):null]}),(0,Y.jsxs)(`span`,{className:`mt-0.5 flex min-w-0 items-center gap-1.5 text-[10px] text-muted-foreground`,children:[c?(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono`,children:s}):null,c?(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`·`}):null,(0,Y.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:d}),f.map(e=>(0,Y.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e]},e))]})]})]})})}function Ht({posture:e}){return(0,Y.jsx)(`span`,{role:`status`,className:o(`shrink-0 text-[10px] font-medium`,zt[e.primary]),children:gt(e.primary)})}var Ut=new Set([`unset`,`set`,`dormant`,`blast`,`shared`,`overdue`,`unread`,`healthy`]),Wt=new Set([`secret`,`config`]),Gt=new Set([`readers`,`rotate`,`blast`,`shared`]),Kt=[{token:`is:unset`,label:`No value in this environment`},{token:`is:set`,label:`Has a fingerprint or config value`},{token:`is:blast`,label:`In-flight durable runs hold this secret`},{token:`is:shared`,label:`Fingerprint matches another environment`},{token:`is:dormant`,label:`Unread for 90 days, or never`},{token:`is:overdue`,label:`Last read older than rotate — never-read counts`},{token:`is:healthy`,label:`Set, no blast, no shared, not dormant`},{token:`kind:secret`,label:`Sensitive contracts only`},{token:`kind:config`,label:`Non-sensitive config only`},{token:`from:.env.local`,label:`Winner is .env.local`},{token:`from:driver`,label:`Winner is the vault backend (built-in / managed / memory)`},{token:`has:readers`,label:`At least one Flow declares a read`},{token:`has:rotate`,label:`Contract declares a rotate cadence`},{token:`rotate:never`,label:`No rotate cadence (stable secret)`},{token:`reader:`,label:`Flow id contains…`},{token:`fp:`,label:`Fingerprint contains…`}],qt=[`driver`,`process.env`,`.env.local`,`dev-fallback`];function Jt(e){let t=[],n=/"([^"]+)"|(\S+)/g,r;for(;(r=n.exec(e))!==null;){let e=r[1]??r[2]??``;e.length>0&&t.push(e)}return t}function Yt(e){let t=[];for(let n of Jt(e)){let e=nn(n);e?t.push(e):t.push({kind:`text`,value:n})}return{tokens:t,raw:e}}function Xt(e){let t=[],n=[];for(let r of e){if(r.kind===`text`){n.push(sn(r.value)?`"${r.value}"`:r.value);continue}t.push(`${r.kind}:${r.value}`)}return[...t,...n].join(` `).trim()}function Zt(e,t){let n=Yt(e);return Xt(n.tokens.some(e=>e.kind===`is`&&e.value===t)?n.tokens.filter(e=>e.kind!==`is`||e.value!==t):[...n.tokens,{kind:`is`,value:t}])}function Qt(e,t){return Yt(e).tokens.some(e=>e.kind===`is`&&e.value===t)}function $t(e,t,n){if(t.tokens.length===0)return!0;let r=pt(e,n);for(let n of t.tokens)if(!rn(e,n,r))return!1;return!0}function en(e,t){let n=cn(e);if(n===null)return Kt;let r=n.toLowerCase();if(r.startsWith(`is:`)||r===`is`)return Z(Kt.filter(e=>e.token.startsWith(`is:`)),n);if(r.startsWith(`kind:`)||r===`kind`)return Z([{token:`kind:secret`,label:`Sensitive contracts only`},{token:`kind:config`,label:`Non-sensitive config only`}],n);if(r.startsWith(`from:`)||r===`from`)return Z(qt.map(e=>({token:`from:${e}`,label:e===`driver`?`Winner is the vault backend (built-in / managed / memory)`:`Winner is ${e}`})),n);if(r.startsWith(`has:`)||r===`has`)return Z(Kt.filter(e=>e.token.startsWith(`has:`)),n);if(r.startsWith(`reader:`)||r===`reader`){let e=r.startsWith(`reader:`)?r.slice(7):``,n=new Set;for(let r of t)for(let t of r.readers)(e.length===0||t.toLowerCase().includes(e))&&n.add(t);return[...n].slice(0,8).map(e=>({token:`reader:${e}`,label:`Flow that reads this contract`}))}if(r.startsWith(`fp:`)||r===`fp`){let e=r.startsWith(`fp:`)?r.slice(3):``,n=new Set;for(let r of t){for(let t of Object.values(r.fingerprints))(e.length===0||t.toLowerCase().includes(e))&&n.add(t);r.fingerprint&&(e.length===0||r.fingerprint.toLowerCase().includes(e))&&n.add(r.fingerprint)}return[...n].slice(0,8).map(e=>({token:`fp:${e}`,label:`Exact fingerprint`}))}if(r.startsWith(`rotate:`)||r===`rotate`)return Z([{token:`rotate:due`,label:`Last read older than rotate — never-read counts`},{token:`has:rotate`,label:`Contract declares a rotate cadence`},{token:`rotate:never`,label:`No rotate cadence (stable secret)`}],n);let i=r;return Kt.filter(e=>e.token.includes(i)||e.label.toLowerCase().includes(i))}function tn(e,t){if(e.length===0||/\s$/.test(e))return`${e}${t} `.replace(/^\s+/,``);let n=e.lastIndexOf(` `);return n<0?`${t} `:`${e.slice(0,n+1)}${t} `}function nn(e){if(e.startsWith(`"`))return null;let t=e.indexOf(`:`);if(t<=0)return null;let n=e.slice(0,t).toLowerCase(),r=e.slice(t+1);if(r.length===0)return null;if(n===`is`){let e=r.toLowerCase();return Ut.has(e)?{kind:`is`,value:e}:Wt.has(e)?{kind:`kind`,value:e}:null}if(n===`kind`){let e=r.toLowerCase();return Wt.has(e)?{kind:`kind`,value:e}:null}if(n===`from`)return{kind:`from`,value:r.toLowerCase()};if(n===`reader`)return{kind:`reader`,value:r.toLowerCase()};if(n===`fp`)return{kind:`fp`,value:r.toLowerCase()};if(n===`has`){let e=r.toLowerCase();return Gt.has(e)?{kind:`has`,value:e}:null}if(n===`rotate`){let e=r.toLowerCase();return e===`due`?{kind:`is`,value:`overdue`}:{kind:`rotate`,value:e}}return null}function rn(e,t,n){switch(t.kind){case`is`:return n[t.value];case`kind`:return e.kind===t.value;case`from`:return(e.winner??``).toLowerCase()===t.value;case`reader`:return e.readers.some(e=>e.toLowerCase().includes(t.value));case`fp`:return an(e).some(e=>e.includes(t.value));case`has`:return t.value===`readers`?e.readers.length>0:t.value===`rotate`?q(e.rotate):t.value===`blast`?e.blastRadius.count>0:e.sharedFingerprintEnvs.length>0;case`rotate`:return t.value===`never`?e.kind===`secret`&&!q(e.rotate):(e.rotate??``).toLowerCase()===t.value;case`text`:return on(e).includes(t.value.toLowerCase())}}function an(e){let t=Object.values(e.fingerprints).map(e=>e.toLowerCase());return e.fingerprint&&t.push(e.fingerprint.toLowerCase()),t}function on(e){return[e.name,e.description??``,e.winner??``,e.kind,...e.readers,...Object.keys(e.fingerprints),...Object.values(e.fingerprints),e.fingerprint??``,e.sensitive?``:e.cleartext??``].join(`
|
|
2
2
|
`).toLowerCase()}function sn(e){return/\s/.test(e)}function cn(e){if(e.length===0||/\s$/.test(e))return null;let t=Jt(e);return t[t.length-1]??null}function Z(e,t){let n=t.toLowerCase();return e.filter(e=>e.token.toLowerCase().startsWith(n)||e.token.toLowerCase().includes(n))}function ln({card:e,env:t,summary:n,query:r,progress:i,verifyNote:a,onQueryChange:s,onOpenSecurity:c}){return(0,Y.jsxs)(`section`,{"aria-label":`Vault posture`,className:`shrink-0 border-b border-border/60`,"data-slot":`vault-posture-strip`,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-10 flex-wrap items-stretch`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`Open vault security`,className:`flex items-center px-2 text-left text-xs font-medium text-foreground hover:bg-muted/50`,children:e?.title??`Vault backend`}),(0,Y.jsx)(`span`,{className:`flex items-center px-2 font-mono text-[10px] text-muted-foreground`,children:t}),e?.badges.map(e=>(0,Y.jsxs)(`span`,{role:e.tone===`warn`?`alert`:`status`,className:o(`flex items-center gap-1.5 px-2 text-[10px]`,e.tone===`warn`?`text-amber-800 dark:text-amber-400`:`text-muted-foreground`,e.id===`rewrap`&&`text-[color:var(--vault-accent)]`),style:e.id===`rewrap`?{"--vault-accent":J}:void 0,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:o(`size-1.5 shrink-0 rounded-full`,e.tone===`warn`?`bg-amber-500`:`bg-muted-foreground/50`,e.id===`rewrap`&&`bg-[var(--vault-accent)]`)}),e.label]},e.id)),st.map(e=>{let t=n[e.id],i=Qt(r,e.token);return t===0&&!i?null:(0,Y.jsx)(I,{label:_t(e.id),className:`flex self-stretch`,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:()=>s(Zt(r,e.token)),className:o(S,i?ee:N,e.tone===`danger`&&!i&&`text-destructive`,e.tone===`warn`&&!i&&`text-amber-800 dark:text-amber-400`),children:[e.label,(0,Y.jsx)(`span`,{className:`font-mono tabular-nums`,children:t})]})},e.id)}),(0,Y.jsx)(`span`,{className:`ml-auto flex items-center px-2 font-mono text-[10px] text-muted-foreground`,children:a??`${n.secrets}s · ${n.config}c`})]}),i?(0,Y.jsxs)(`p`,{className:`border-t border-border/60 px-2 py-1 font-mono text-[11px]`,style:{color:J},role:`status`,"data-slot":`vault-rewrap-progress`,"data-phase":i.phase,children:[i.headline,(0,Y.jsx)(`span`,{className:`ml-2 font-sans text-muted-foreground`,children:i.detail})]}):null]})}function un({query:e,secrets:t,onQueryChange:n}){let r=(0,K.useId)(),i=(0,K.useRef)(null),[a,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(0),u=(0,K.useMemo)(()=>en(e,t),[e,t]);(0,K.useEffect)(()=>{l(0)},[e]),(0,K.useEffect)(()=>{let e=e=>{i.current?.contains(e.target)||s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let d=t=>{n(tn(e,t.token)),s(!0)};return(0,Y.jsxs)(`div`,{ref:i,className:`relative flex h-full min-w-0 flex-1`,"data-slot":`vault-search`,children:[(0,Y.jsx)(F,{"data-slot":`vault-search-input`,value:e,onChange:e=>{n(e.target.value),s(!0)},onFocus:()=>s(!0),onKeyDown:e=>{if(e.key===`Escape`){s(!1);return}if(!a||u.length===0){e.key===`ArrowDown`&&u.length>0&&(e.preventDefault(),s(!0));return}if(e.key===`ArrowDown`){e.preventDefault(),l(e=>(e+1)%u.length);return}if(e.key===`ArrowUp`){e.preventDefault(),l(e=>(e-1+u.length)%u.length);return}e.key===`Enter`&&u[c]&&(e.preventDefault(),d(u[c]))},placeholder:`Search vault…`,"aria-label":`Search vault`,"aria-autocomplete":`list`,"aria-expanded":a,"aria-controls":r,role:`combobox`,title:`name, fingerprint, reader… is:unset from:.env.local`}),a&&u.length>0?(0,Y.jsx)(`ul`,{id:r,role:`listbox`,className:`absolute top-full z-30 mt-1 max-h-72 w-[min(20rem,calc(100vw-4rem))] overflow-y-auto rounded-lg border border-border/70 bg-popover p-1 shadow-md`,children:u.map((e,t)=>(0,Y.jsx)(`li`,{role:`option`,"aria-selected":t===c,children:(0,Y.jsxs)(`button`,{type:`button`,onMouseEnter:()=>l(t),onClick:()=>d(e),className:o(`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5 text-left`,t===c&&`bg-muted/70`),children:[(0,Y.jsx)(`span`,{className:`font-mono text-[11px] text-foreground`,children:e.token}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[10px] text-muted-foreground`,children:e.label})]})},`${e.token}-${t}`))}):null]})}function dn(e,t=``,n=Date.now()){let r=Yt(t),i=e.filter(e=>$t(e,r,n)),a=[`secret`,`config`],o={secret:`Secrets`,config:`Config`};return a.map(e=>({kind:e,label:o[e],secrets:i.filter(t=>t.kind===e)})).filter(e=>e.secrets.length>0)}function fn(e){let t=e.remaining,n=e.rewrapTargetKekVersion;if(!(t!==null&&t>0||n!==null))return t===0?{phase:2,headline:`KEK v${e.kekVersion} — rotation complete`,detail:`The previous master key no longer opens this vault.`}:null;let r=n??e.kekVersion,i=t??0;return{phase:1,headline:`kek v${e.kekVersion} → v${r}`,detail:i>0?`${i} DEK${i===1?``:`s`} still on the old key. Both master keys stay live.`:`Both master keys stay live until remaining is 0.`}}function pn({masterKey:e,onDismiss:t}){let[n,r]=(0,K.useState)(!1);return(0,Y.jsx)(p,{open:e!==null,onOpenChange:e=>{e||t()},children:(0,Y.jsxs)(h,{side:`right`,showOverlay:!1,className:`sm:max-w-md`,"data-slot":`vault-master-key-sheet`,children:[(0,Y.jsxs)(m,{children:[(0,Y.jsx)(v,{children:`New master key`}),(0,Y.jsx)(_,{children:`Shown once. Store it offline. This Console process does not keep it for you.`})]}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,Y.jsx)(`p`,{className:`border-b border-border/50 px-4 py-3 font-mono text-[11px] break-all`,children:e}),(0,Y.jsx)(`p`,{className:`px-4 py-3 text-[11px] text-muted-foreground`,role:`status`,children:`Copying puts the key on the clipboard. Anyone with this device can read it until you clear it.`})]}),(0,Y.jsxs)(l,{children:[(0,Y.jsx)(W,{split:!0,disabled:!e,onClick:()=>{e&&(navigator.clipboard?.writeText(e),r(!0))},children:n?`Copied`:`Copy (clipboard warning)`}),(0,Y.jsx)(W,{variant:`destructive`,onClick:()=>{r(!1),t()},children:`I have stored this key`})]})]})})}function mn({open:e,onOpenChange:t,pending:n=!1,error:r,onConfirm:i}){return(0,Y.jsx)(Ue,{open:e,onOpenChange:t,phrase:`ROTATE_MASTER`,title:`Rotate master key`,description:`Generates a new master key and rewraps DEKs in batches. Both keys stay live until remaining is 0. The new key is shown once.`,pending:n,error:r,confirmLabel:`Confirm rotate master`,slot:`vault-rotate-master-sheet`,onConfirm:i})}var hn=[{id:`status`,cmd:`oke vault status`,label:`Backend seal + KEK`},{id:`audit`,cmd:`oke vault audit`,label:`Hash-chained audit log`},{id:`verify`,cmd:`oke vault audit verify`,label:`Verify the chain on disk`},{id:`backup`,cmd:`oke vault backup`,label:`Encrypted backup`},{id:`restore`,cmd:`oke vault restore`,label:`Restore from backup`}];function gn({open:e,onOpenChange:t,card:n,env:r,progress:i,verifyPending:a=!1,verifyNote:s,onVerify:c,onRotateMaster:l,onExport:u}){return(0,Y.jsx)(p,{open:e,onOpenChange:t,children:(0,Y.jsxs)(h,{side:`right`,showOverlay:!1,className:`sm:max-w-md`,"data-slot":`vault-security-sheet`,children:[(0,Y.jsxs)(m,{children:[(0,Y.jsx)(v,{children:`Vault security`}),(0,Y.jsx)(_,{children:`Fingerprints and backend status only. Backup, restore, and unseal stay on the CLI.`})]}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,Y.jsxs)(`section`,{className:`flex flex-col gap-2 border-b border-border/50 px-4 py-3`,children:[(0,Y.jsx)(`h3`,{className:`text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`Backend`}),(0,Y.jsx)(`p`,{className:`text-[12px] font-medium`,children:n?.title??`Unresolved`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:n?.description??`The server could not resolve a vault backend.`}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Y.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:[`env `,r]}),n?.badges.map(e=>(0,Y.jsx)(xe,{variant:`outline`,role:e.tone===`warn`?`alert`:`status`,className:o(`h-5 rounded-md text-[10px]`,e.tone===`warn`&&`border-amber-500/35 bg-amber-500/10 text-amber-800 dark:text-amber-400`),children:e.label},e.id))]}),n?.facts.length?(0,Y.jsx)(`dl`,{className:`flex flex-col gap-1`,children:n.facts.map(e=>(0,Y.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,Y.jsx)(`dt`,{className:`text-[10px] tracking-[0.12em] text-muted-foreground uppercase`,children:e.label}),(0,Y.jsx)(`dd`,{className:`font-mono text-[11px]`,children:e.value})]},e.label))}):null,n?.hint?(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,role:`status`,children:n.hint}):null,i?(0,Y.jsxs)(`p`,{className:`font-mono text-[11px]`,style:{color:J},role:`status`,children:[i.headline,(0,Y.jsx)(`span`,{className:`ml-2 font-sans text-muted-foreground`,children:i.detail})]}):null]}),(0,Y.jsxs)(`section`,{className:`flex flex-col gap-2 border-b border-border/50 px-4 py-3`,children:[(0,Y.jsx)(`h3`,{className:`text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`Actions`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(y,{type:`button`,variant:`outline`,size:`sm`,disabled:a,onClick:c,children:`Verify audit chain`}),s?(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,role:`status`,children:s}):null,(0,Y.jsx)(y,{type:`button`,variant:`outline`,size:`sm`,onClick:l,children:`Rotate master key`}),(0,Y.jsx)(y,{type:`button`,variant:`outline`,size:`sm`,onClick:u,children:`Export fingerprints`})]}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Master rotation rewraps DEKs in batches. Both keys stay live until remaining is 0. The new key is shown once.`})]}),(0,Y.jsxs)(`section`,{className:`flex flex-col gap-2 px-4 py-3`,children:[(0,Y.jsx)(`h3`,{className:`text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:`CLI`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`The Console never accepts a master key in the HTTP body.`}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:hn.map(e=>(0,Y.jsx)(_n,{cmd:e.cmd,label:e.label},e.id))})]})]})]})})}function _n({cmd:e,label:t}){let[n,i]=(0,K.useState)(!1);return(0,Y.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{className:`font-mono text-[11px]`,children:e}),(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:t})]}),(0,Y.jsx)(y,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Copy ${e}`,onClick:()=>{navigator.clipboard?.writeText(e),i(!0),window.setTimeout(()=>i(!1),1200)},children:(0,Y.jsx)(r,{icon:n?d:pe})})]})}function vn({result:e,onClose:t}){let n=e!==null&&e.ok===!1,r=e?.reason===`link`?`prev-hash does not match the previous row`:e?.reason===`payload`?`stored row hash does not match the payload`:`the chain failed verification`;return(0,Y.jsx)(p,{open:n,onOpenChange:e=>{e||t()},children:(0,Y.jsxs)(h,{side:`right`,showOverlay:!1,className:`sm:max-w-md`,"data-slot":`vault-verify-sheet`,children:[(0,Y.jsxs)(m,{children:[(0,Y.jsx)(v,{children:`Chain broken`}),(0,Y.jsxs)(_,{children:[`The audit hash chain failed at`,` `,(0,Y.jsx)(`span`,{className:`font-mono`,children:e?.brokenAt??`unknown`}),`.`]})]}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto text-[11px]`,children:[(0,Y.jsxs)(`p`,{className:`border-b border-border/50 px-4 py-3`,role:`alert`,children:[`Reason: `,r,`.`]}),e?.row?(0,Y.jsxs)(`dl`,{className:`divide-y divide-border/50`,children:[(0,Y.jsx)(Q,{label:`id`,value:e.row.id,mono:!0}),(0,Y.jsx)(Q,{label:`seq`,value:String(e.row.seq),mono:!0}),(0,Y.jsx)(Q,{label:`action`,value:e.row.action}),(0,Y.jsx)(Q,{label:`path`,value:e.row.path??`—`,mono:!0}),(0,Y.jsx)(Q,{label:`actor`,value:`${e.row.actorType} ${e.row.actorId??``}`}),(0,Y.jsx)(Q,{label:`time`,value:new Date(e.row.createdAt).toISOString(),mono:!0}),e.row.errorMessage?(0,Y.jsx)(Q,{label:`error`,value:e.row.errorMessage}):null]}):null]}),(0,Y.jsx)(l,{children:(0,Y.jsx)(W,{onClick:t,children:`Close`})})]})})}function Q({label:e,value:t,mono:n}){return(0,Y.jsxs)(`div`,{className:`px-4 py-2.5`,children:[(0,Y.jsx)(`dt`,{className:`text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:e}),(0,Y.jsx)(`dd`,{className:n?`font-mono text-[11px] break-all`:`text-[11px]`,children:t})]})}async function yn(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``).slice(0,16)}`}async function bn(e){let t=e.name.trim(),n=e.value;if(t.length===0)return{error:`Name is required`};if(n.trim().length===0)return{error:`Value is required`};if(e.action!==`create`&&(e.reason?.trim()??``).length<3)return{error:`Reason is required`};let r=e.kind??(e.sensitive?`secret`:`config`),i=await yn(n),a=e.action===`create`?null:e.reason?.trim()??null;return{action:e.action,name:t,kind:r,fingerprint:i,preview:e.sensitive?null:n,reason:a,rotate:e.rotate??null,commit:{name:t,value:n,reason:a,kind:r,description:e.description?.trim()??``,rotate:e.rotate??(r===`secret`?`90d`:`never`)}}}function xn(e,t){return e===null?null:t(e)}function Sn(){return null}function Cn(e){return g(`alert-dialog`,e)}function wn({...e}){return(0,Y.jsx)(Cn,{"data-slot":`alert-dialog`,...e})}function Tn({...e}){return(0,Y.jsx)(f,{"data-slot":`alert-dialog-portal`,...e})}function En({className:e,...t}){return(0,Y.jsx)(c,{"data-slot":`alert-dialog-overlay`,className:o(`fixed inset-0 z-50 bg-black/20 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs`,e),...t})}function Dn({className:e,children:t,...n}){return(0,Y.jsxs)(Tn,{children:[(0,Y.jsx)(En,{}),(0,Y.jsx)(s,{"data-slot":`alert-dialog-content`,className:o(`fixed top-1/2 left-1/2 z-50 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-none border border-border bg-popover text-sm text-popover-foreground shadow-lg outline-none transition duration-150 data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0`,e),...n,children:t})]})}function On({className:e,...t}){return(0,Y.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:o(`flex flex-col gap-1 border-b border-border/50 px-4 py-3`,e),...t})}function kn({className:e,...t}){return(0,Y.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:o(`flex flex-row items-stretch border-t border-border/50 p-0`,e),...t})}function An({className:e,...t}){return(0,Y.jsx)(u,{"data-slot":`alert-dialog-title`,className:o(`text-sm font-medium text-foreground`,e),...t})}function jn({className:e,...t}){return(0,Y.jsx)(b,{"data-slot":`alert-dialog-description`,className:o(`text-[11px] text-muted-foreground`,e),...t})}var Mn={create:`Confirm add`,set:`Confirm set`,rotate:`Confirm rotate`},Nn={create:`Add contract`,set:`Set value`,rotate:`Rotate`};function Pn({review:e,pending:t=!1,onCancel:n,onConfirm:r}){return(0,Y.jsx)(wn,{open:e!==null,onOpenChange:e=>{!e&&!t&&n()},children:(0,Y.jsxs)(Dn,{"data-slot":`vault-write-review`,children:[(0,Y.jsxs)(On,{children:[(0,Y.jsx)(An,{children:e?`${Mn[e.action]} ${e.name}`:`Confirm write`}),(0,Y.jsx)(jn,{children:e?.preview==null?`Write-only. The value is never shown again.`:`Config is shown in the clear after submit.`})]}),e?(0,Y.jsx)(Fn,{review:e}):null,(0,Y.jsxs)(kn,{children:[(0,Y.jsx)(W,{split:!0,onClick:n,disabled:t,"data-slot":`vault-write-review-cancel`,children:`Cancel`}),(0,Y.jsx)(W,{variant:e?.action===`rotate`?`destructive`:`default`,disabled:t||e===null,onClick:r,"data-slot":`vault-write-review-confirm`,children:t?`Working…`:e?Nn[e.action]:`Confirm`})]})]})})}function Fn({review:e}){return(0,Y.jsxs)(`dl`,{className:`flex flex-col`,"data-slot":`vault-write-review-facts`,children:[(0,Y.jsx)($,{label:`Name`,value:e.name,mono:!0}),e.action===`create`?(0,Y.jsx)($,{label:`Kind`,value:e.kind}):null,(0,Y.jsx)($,{label:`Fingerprint`,value:e.fingerprint,mono:!0}),e.preview==null?null:(0,Y.jsx)($,{label:`Value`,value:e.preview,mono:!0}),e.reason?(0,Y.jsx)($,{label:`Reason`,value:e.reason}):null,e.action===`create`&&e.rotate?(0,Y.jsx)($,{label:`Rotate`,value:e.rotate}):null]})}function $({label:e,value:t,mono:n=!1}){return(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 border-b border-border/50 px-4 py-2 last:border-b-0`,children:[(0,Y.jsx)(`dt`,{className:`shrink-0 text-[10px] font-semibold tracking-[0.12em] text-muted-foreground uppercase`,children:e}),(0,Y.jsx)(`dd`,{className:n?`min-w-0 truncate font-mono text-[11px]`:`min-w-0 truncate text-[12px]`,children:t})]})}function In({open:e,onOpenChange:t,pending:n=!1,error:r,onSubmit:i}){let[s,c]=(0,K.useState)(`secret`),[u,d]=(0,K.useState)(``),[f,g]=(0,K.useState)(``),[y,b]=(0,K.useState)(`90d`),[x,S]=(0,K.useState)(``),[C,w]=(0,K.useState)(null),[T,E]=(0,K.useState)(null);(0,K.useEffect)(()=>{e||(c(`secret`),d(``),g(``),b(`90d`),S(``),w(null),E(null))},[e]);let D=u.trim().length>0&&x.trim().length>0&&!n,ee=async()=>{let e=await bn({action:`create`,name:u.trim(),value:x,sensitive:s===`secret`,kind:s,description:f.trim(),rotate:s===`secret`?y:`never`});if(`error`in e){w(e.error);return}w(null),E(e)};return(0,Y.jsxs)(p,{open:e,onOpenChange:t,children:[(0,Y.jsxs)(h,{side:`right`,showOverlay:!1,className:`gap-0 p-0 data-[side=right]:sm:max-w-md`,"data-slot":`vault-create-sheet`,children:[(0,Y.jsxs)(m,{className:`gap-1 border-b border-border/50`,children:[(0,Y.jsx)(v,{className:`text-sm`,children:`Add vault contract`}),(0,Y.jsx)(_,{className:`text-[11px]`,children:s===`secret`?`Writes the value and lists the contract here. Promote it to vault.secret in source when a Flow should read it.`:`vault.config — shown in the clear on the Config band after submit.`})]}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,Y.jsxs)(Be,{label:`Kind`,children:[(0,Y.jsx)(H,{active:s===`secret`,onClick:()=>c(`secret`),children:`secret`}),(0,Y.jsx)(H,{active:s===`config`,onClick:()=>c(`config`),children:`config`})]}),(0,Y.jsx)(U,{label:`Name`,children:(0,Y.jsx)(a,{value:u,onChange:e=>d(e.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,``)),placeholder:`STRIPE_KEY`,autoComplete:`off`,"aria-label":`Contract name`,flat:!0,className:o(G,`font-mono`)})}),(0,Y.jsx)(U,{label:`Description`,children:(0,Y.jsx)(a,{value:f,onChange:e=>g(e.target.value),placeholder:`Optional title`,autoComplete:`off`,"aria-label":`Description`,flat:!0,className:G})}),s===`secret`?(0,Y.jsxs)(Be,{label:`Rotate`,children:[(0,Y.jsx)(H,{active:y===`90d`,onClick:()=>b(`90d`),children:`90d`}),(0,Y.jsx)(H,{active:y===`never`,onClick:()=>b(`never`),children:`no rotate`})]}):null,(0,Y.jsx)(U,{label:`Value`,children:(0,Y.jsx)(a,{type:`password`,autoComplete:`off`,value:x,onChange:e=>S(e.target.value),placeholder:s===`secret`?`Paste the secret`:`Public value`,"aria-label":`New vault value`,flat:!0,className:G})}),C||r?(0,Y.jsx)(Ve,{slot:`vault-create-error`,children:C??r}):null]}),(0,Y.jsxs)(l,{children:[(0,Y.jsx)(W,{split:!0,onClick:()=>t(!1),disabled:n,children:`Cancel`}),(0,Y.jsx)(W,{variant:`default`,disabled:!D,onClick:()=>{ee()},"data-slot":`vault-create-submit`,children:s===`secret`?`Review secret`:`Review config`})]})]}),(0,Y.jsx)(Pn,{review:T,pending:n,onCancel:()=>E(Sn()),onConfirm:()=>{xn(T,e=>{i({name:e.commit.name,value:e.commit.value,kind:e.commit.kind,description:e.commit.description,rotate:e.commit.rotate})})}})]})}var Ln=[{id:`first`,label:`first`,text:`Initial value`},{id:`fix`,label:`fix`,text:`Correct a bad value`},{id:`provider`,label:`provider`,text:`Provider changed it`},{id:`other`,label:`other`,text:``}],Rn=[{id:`scheduled`,label:`scheduled`,text:`Scheduled rotation`},{id:`leak`,label:`leak`,text:`Key compromise`},{id:`provider`,label:`provider`,text:`Provider rotated`},{id:`other`,label:`other`,text:``}];function zn(e){return e===`rotate`?Rn:Ln}function Bn(e){return e===`rotate`?`scheduled`:`first`}function Vn(e,t,n){return t===`other`?n.trim():zn(e).find(e=>e.id===t)?.text??``}function Hn({open:e,onOpenChange:t,mode:n,name:r,sensitive:i=!0,pending:o=!1,error:s,onSubmit:c}){let[u,d]=(0,K.useState)(``),[f,g]=(0,K.useState)(()=>Bn(n)),[y,b]=(0,K.useState)(``),[x,S]=(0,K.useState)(null),[C,w]=(0,K.useState)(null);(0,K.useEffect)(()=>{e||(d(``),g(Bn(n)),b(``),S(null),w(null))},[e,n]);let T=Vn(n,f,y),E=u.trim().length>0&&T.length>=3&&!o,D=zn(n),ee=async()=>{let e=await bn({action:n,name:r,value:u,sensitive:i,reason:T,kind:i?`secret`:`config`});if(`error`in e){S(e.error);return}S(null),w(e)};return(0,Y.jsxs)(p,{open:e,onOpenChange:t,children:[(0,Y.jsxs)(h,{side:`right`,showOverlay:!1,className:`gap-0 p-0 data-[side=right]:sm:max-w-md`,"data-slot":`vault-write-sheet`,children:[(0,Y.jsxs)(m,{className:`gap-1 border-b border-border/50`,children:[(0,Y.jsx)(v,{className:`text-sm`,children:n===`set`?`Set ${r}`:`Rotate ${r}`}),(0,Y.jsx)(_,{className:`text-[11px]`,children:i?`Write-only. The new value is never shown again after submit.`:`This vault.config value is shown in the clear on the Config band after submit.`})]}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:[(0,Y.jsx)(U,{label:`New value`,children:(0,Y.jsx)(a,{type:`password`,autoComplete:`off`,value:u,onChange:e=>d(e.target.value),placeholder:i?`Paste the new secret`:`Paste the new value`,"aria-label":`New vault value`,flat:!0,className:G})}),(0,Y.jsx)(Be,{label:`Reason`,children:D.map(e=>(0,Y.jsx)(H,{active:f===e.id,onClick:()=>g(e.id),children:e.label},e.id))}),f===`other`?(0,Y.jsx)(U,{label:`Other`,children:(0,Y.jsx)(a,{value:y,onChange:e=>b(e.target.value),placeholder:`Why is this change needed?`,"aria-label":`Custom reason`,flat:!0,className:G})}):null,x||s?(0,Y.jsx)(Ve,{slot:`vault-write-error`,children:x??s}):null]}),(0,Y.jsxs)(l,{children:[(0,Y.jsx)(W,{split:!0,onClick:()=>t(!1),disabled:o,children:`Cancel`}),(0,Y.jsx)(W,{variant:n===`rotate`?`destructive`:`default`,disabled:!E,onClick:()=>{ee()},"data-slot":`vault-write-submit`,children:n===`set`?`Review set`:`Review rotate`})]})]}),(0,Y.jsx)(Pn,{review:C,pending:o,onCancel:()=>w(Sn()),onConfirm:()=>{xn(C,e=>{c({value:e.commit.value,reason:e.commit.reason??T})})}})]})}function Un(){let e=Ke(),t=i(),{query:n,selectedName:a,action:s,setQuery:c,setSelectedName:l,setAction:u}=Re(),d=_e(),f=(0,Y.jsx)(ve,{open:d.open,onToggle:d.toggle,noun:`vault`,controlsId:`vault-list`,dataSlot:`vault-list-toggle`}),[p]=(0,K.useState)(()=>Date.now()),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(null),[v,y]=(0,K.useState)(null),[b,S]=(0,K.useState)(null),[C,D]=(0,K.useState)(null),[ee,O]=(0,K.useState)(null),[ne,ie]=(0,K.useState)(null),[k,oe]=(0,K.useState)(null),[se,A]=(0,K.useState)(null),j=e.data?.secrets??[],de=e.data?.env??`dev`,M=e.data?.backend??null,N=(0,K.useMemo)(()=>Je(M),[M]),P=(0,K.useMemo)(()=>dn(j,n,p),[j,n,p]),pe=(0,K.useMemo)(()=>mt(j,p),[j,p]),F=(0,K.useMemo)(()=>P.flatMap(e=>e.secrets),[P]),L=F.length,R=F.find(e=>e.name===a)??F[0]??null,be=fn({kekVersion:ne??M?.status?.kekVersion??1,remaining:ee,rewrapTargetKekVersion:M?.status?.rewrapTargetKekVersion??null});(0,K.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;if(t instanceof HTMLElement){let e=t.tagName;if(e===`INPUT`||e===`TEXTAREA`||t.isContentEditable)return}e.preventDefault(),document.querySelector(`[data-slot='vault-search-input']`)?.focus()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let z=async()=>{await t.invalidateQueries({queryKey:Xe})},xe=()=>{let e=ot(j);navigator.clipboard?.writeText(e),_(`Exported fingerprints only (no secret values)`)},Se=Ie({mutationFn:async e=>{if(e.value.trim().length===0)throw Error(`New value is required`);let t=await(e.mode===`set`?ce:le)({name:e.name,value:e.value,reason:e.reason});if(t.error)throw Error(te(t.error));return t.data},onSuccess:async()=>{y(null),u(null),await z()},onError:e=>{y(e.message)}}),Ce=Ie({mutationFn:async e=>{if(e.name.trim().length===0)throw Error(`Name is required`);if(e.value.trim().length===0)throw Error(`Value is required`);let t=await w({name:e.name,value:e.value,kind:e.kind,...e.description.length>0?{description:e.description}:{},...e.rotate.length>0?{rotate:e.rotate}:{}});if(t.error)throw Error(te(t.error));return t.data},onSuccess:async e=>{y(null),u(null),e?.name&&l(e.name),await z()},onError:e=>{y(e.message)}}),we=Ie({mutationFn:async e=>{let t=0,n=M?.status?.kekVersion??1;for(;;){let r=await x(e);if(r.error)throw Error(te(r.error));if(!r.data)throw Error(`Empty rotate-master response`);if(t=r.data.remaining,n=r.data.kekVersion,O(r.data.remaining),ie(r.data.kekVersion),r.data.masterKey&&D(r.data.masterKey),await z(),r.data.remaining===0)break}return{remaining:t,kekVersion:n}},onSuccess:()=>{S(null),u(null)},onError:e=>{S(e.message)}}),B=Ie({mutationFn:async()=>{let e=await E();if(e.error)throw Error(te(e.error));if(!e.data)throw Error(`Empty verify response`);return e.data},onSuccess:e=>{e.ok?(A(null),oe(`chain intact`)):(oe(null),A(e))}});return(0,Y.jsxs)(`div`,{className:ue,"data-slot":`vault-page`,children:[(0,Y.jsxs)(fe,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,Y.jsx)(he,{panelRef:d.panelRef,collapsible:!0,collapsedSize:0,defaultSize:re.start.defaultSize,minSize:re.start.minSize,onResize:d.onResize,className:`min-h-0 overflow-hidden`,children:(0,Y.jsxs)(`div`,{id:`vault-list`,className:`flex h-full min-h-0 flex-col overflow-hidden`,"data-slot":`vault-list`,children:[(0,Y.jsxs)(`div`,{className:o(T,`relative z-20 pr-1.5`),children:[(0,Y.jsx)(un,{query:n,secrets:j,onQueryChange:c}),(0,Y.jsx)(I,{label:`Add secret or config`,className:`flex self-stretch`,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Add secret or config`,onClick:()=>u(`create`),className:ae,children:(0,Y.jsx)(r,{icon:Oe,className:`size-3.5`})})}),g?(0,Y.jsx)(`span`,{className:`sr-only`,role:`status`,children:g}):null,(0,Y.jsx)(I,{label:`Verify the audit hash chain`,className:`flex self-stretch`,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Verify chain`,disabled:B.isPending,onClick:()=>B.mutate(),className:ae,children:(0,Y.jsx)(r,{icon:ge,className:`size-3.5`})})}),(0,Y.jsxs)(Fe,{children:[(0,Y.jsx)(I,{label:`Vault security`,className:`flex self-stretch`,children:(0,Y.jsx)(je,{render:e=>(0,Y.jsx)(`button`,{...e,type:`button`,"aria-label":`Vault security`,className:ae,children:(0,Y.jsx)(r,{icon:De,className:`size-3.5`})})})}),(0,Y.jsxs)(Pe,{align:`end`,className:`min-w-52`,children:[(0,Y.jsxs)(Me,{children:[(0,Y.jsx)(V,{onClick:()=>h(!0),children:`Security`}),(0,Y.jsxs)(V,{onClick:()=>u(`rotate-master`),children:[(0,Y.jsx)(r,{icon:me,"data-icon":`inline-start`}),`Rotate master key`]}),(0,Y.jsxs)(V,{onClick:xe,children:[(0,Y.jsx)(r,{icon:Ee,"data-icon":`inline-start`}),`Export fingerprints`]})]}),(0,Y.jsx)(Ne,{}),(0,Y.jsxs)(V,{disabled:B.isPending,onClick:()=>B.mutate(),children:[(0,Y.jsx)(r,{icon:ge,"data-icon":`inline-start`}),`Verify audit chain`]})]})]})]}),(0,Y.jsx)(ln,{card:N,env:de,summary:pe,query:n,progress:be,verifyNote:k,onQueryChange:c,onOpenSecurity:()=>h(!0)}),(0,Y.jsx)(Bt,{groups:P,selectedName:R?.name??a,loading:e.isLoading,matchCount:L,totalCount:j.length,now:p,onSelect:l})]})}),d.open?(0,Y.jsx)(ye,{withHandle:!0}):null,(0,Y.jsx)(he,{defaultSize:re.end.defaultSize,minSize:re.end.minSize,className:`min-h-0 overflow-hidden`,children:R?(0,Y.jsx)(Tt,{row:R,env:de,now:p,backend:M,onSet:()=>u(`set`),onRotate:()=>u(`rotate`),onQueryChange:c,leading:f}):(0,Y.jsx)(Nt,{loading:e.isLoading,hasContracts:j.length>0,query:n,onClearQuery:()=>c(``),leading:f})})]}),(0,Y.jsx)(In,{open:s===`create`,onOpenChange:e=>{e||(y(null),u(null))},pending:Ce.isPending,error:s===`create`?v:null,onSubmit:e=>Ce.mutate(e)}),(0,Y.jsx)(Hn,{open:s===`set`||s===`rotate`,onOpenChange:e=>{e||(y(null),u(null))},mode:s===`rotate`?`rotate`:`set`,name:R?.name??``,sensitive:R?.sensitive??!0,pending:Se.isPending,error:v,onSubmit:e=>{R&&Se.mutate({mode:s===`rotate`?`rotate`:`set`,name:R.name,...e})}}),(0,Y.jsx)(mn,{open:s===`rotate-master`,onOpenChange:e=>{e||(S(null),u(null))},pending:we.isPending,error:b,onConfirm:e=>we.mutate(e)}),(0,Y.jsx)(gn,{open:m,onOpenChange:h,card:N,env:de,progress:be,verifyPending:B.isPending,verifyNote:k,onVerify:()=>B.mutate(),onRotateMaster:()=>{h(!1),u(`rotate-master`)},onExport:xe}),(0,Y.jsx)(pn,{masterKey:C,onDismiss:()=>D(null)}),(0,Y.jsx)(vn,{result:se,onClose:()=>A(null)})]})}export{Un as VaultPage};
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
} catch (e) {}
|
|
38
38
|
})();
|
|
39
39
|
</script>
|
|
40
|
-
<script type="module" crossorigin src="/assets/index-
|
|
40
|
+
<script type="module" crossorigin src="/assets/index-RhV2jT_7.js"></script>
|
|
41
41
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
42
42
|
<link rel="modulepreload" crossorigin href="/assets/react-dom-Ddte4I-Q.js">
|
|
43
43
|
<link rel="modulepreload" crossorigin href="/assets/xyflow-yApv7D4e.js">
|
|
@@ -94,7 +94,11 @@ export async function bootParkedApproval(): Promise<ParkedApproval> {
|
|
|
94
94
|
});
|
|
95
95
|
await app.boot({ env: "test" });
|
|
96
96
|
const parked = await app.fetch(
|
|
97
|
-
new Request("http://localhost/assist", {
|
|
97
|
+
new Request("http://localhost/assist", {
|
|
98
|
+
method: "POST",
|
|
99
|
+
headers: { "content-type": "application/json" },
|
|
100
|
+
body: "{}",
|
|
101
|
+
}),
|
|
98
102
|
);
|
|
99
103
|
if (parked.status >= 500) {
|
|
100
104
|
throw new Error(`seeded approval failed to park (${parked.status})`);
|