okengine 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -2
- package/README.md +98 -71
- package/package.json +4 -4
- package/site/content/docs/console/clock.mdx +25 -5
- package/site/content/docs/console/signals.mdx +13 -4
- package/site/content/docs/elements/ai.mdx +29 -2
- package/site/content/docs/elements/channel.mdx +90 -20
- package/site/content/docs/elements/clock.mdx +56 -24
- package/site/content/docs/elements/flow.mdx +2 -0
- package/site/content/docs/elements/gate.mdx +8 -1
- package/site/content/docs/elements/signal.mdx +173 -29
- package/site/content/docs/elements/store.mdx +464 -73
- package/site/content/docs/elements/vault.mdx +15 -5
- package/site/content/docs/get-started/basic-usage.mdx +13 -6
- package/site/content/docs/get-started/installation.mdx +49 -13
- package/site/content/docs/get-started/introduction.mdx +1 -1
- package/site/content/docs/reference/cli.md +30 -2
- package/site/content/docs/reference/configuration.mdx +18 -17
- package/site/content/docs/reference/environment-variables.mdx +44 -18
- package/site/content/docs/reference/errors.mdx +12 -11
- package/site/content/docs/reference/fx.mdx +15 -13
- package/site/content/docs/reference/security.md +3 -1
- package/src/cli/ai-setup/ai-setup.test.ts +144 -0
- package/src/cli/ai-setup/apply.ts +214 -0
- package/src/cli/ai-setup/catalog.ts +263 -0
- package/src/cli/ai-setup/detect-ollama.ts +166 -0
- package/src/cli/ai-setup/index.ts +228 -0
- package/src/cli/ai-setup/prompts.ts +649 -0
- package/src/cli/ai-setup/recommend.test.ts +100 -0
- package/src/cli/ai-setup/recommend.ts +203 -0
- package/src/cli/ai.ts +38 -0
- package/src/cli/db-auto-push.test.ts +6 -1
- package/src/cli/db-auto-push.ts +8 -3
- package/src/cli/dev-db-push.test.ts +59 -0
- package/src/cli/dev.test.ts +40 -0
- package/src/cli/dev.ts +55 -1
- package/src/cli/docker-clean.test.ts +179 -0
- package/src/cli/docker-clean.ts +406 -0
- package/src/cli/docker.ts +16 -4
- package/src/cli/ensure-drizzle-config.ts +1 -1
- package/src/cli/hero-meta.test.ts +6 -5
- package/src/cli/hero-meta.ts +7 -1
- package/src/cli/index.ts +5 -0
- package/src/cli/load-config.ts +4 -4
- package/src/cli/openbao-bootstrap.test.ts +1 -0
- package/src/cli/openbao-bootstrap.ts +9 -2
- package/src/cli/openbao-restart.integration.test.ts +106 -97
- package/src/cli/registry.ts +79 -1
- package/src/client/live-gap.test.ts +35 -0
- package/src/client/transport.test.ts +21 -0
- package/src/client/transport.ts +27 -5
- package/src/compiler/fixtures/skyport/oke.config.ts +1 -1
- package/src/config/define-config.test.ts +6 -6
- package/src/config/index.ts +1 -1
- package/src/console/server/console.test.ts +45 -0
- package/src/console/server/flows.ts +39 -9
- package/src/console/server/i18n.ts +41 -0
- package/src/console/server/vault.ts +12 -38
- package/src/console/ui/dist/assets/index-ClX0ZCe5.js +10 -0
- package/src/console/ui/dist/assets/{panel-access-BGv45snf.js → panel-access-ri1X9Otj.js} +1 -1
- package/src/console/ui/dist/assets/{panel-ai-B2S7LEii.js → panel-ai-DLHjRoJk.js} +1 -1
- package/src/console/ui/dist/assets/{panel-architecture-D7UJh91v.js → panel-architecture-DI3bQF3J.js} +1 -1
- package/src/console/ui/dist/assets/{panel-channels-9T3ybqRu.js → panel-channels-BDYWX29p.js} +1 -1
- package/src/console/ui/dist/assets/{panel-clock-Cb1UXGRQ.js → panel-clock-i-JpTjVB.js} +1 -1
- package/src/console/ui/dist/assets/{panel-diff-DmYbKWmN.js → panel-diff-CFuWxiXy.js} +1 -1
- package/src/console/ui/dist/assets/{panel-flows-PiHwT55z.js → panel-flows-B8TRhcoe.js} +1 -1
- package/src/console/ui/dist/assets/{panel-gates-BQGYXvjT.js → panel-gates-CfkBgco7.js} +1 -1
- package/src/console/ui/dist/assets/{panel-overview-BBnRO18l.js → panel-overview-DONDzBd2.js} +1 -1
- package/src/console/ui/dist/assets/{panel-plugins-D0PsmVw2.js → panel-plugins-DDJwTehL.js} +1 -1
- package/src/console/ui/dist/assets/{panel-runs-CWuRDe0r.js → panel-runs-D5zf-D9c.js} +1 -1
- package/src/console/ui/dist/assets/{panel-signals-Bbg4ewpP.js → panel-signals-Dsxdu_AR.js} +1 -1
- package/src/console/ui/dist/assets/{panel-store-CPCbsDRa.js → panel-store-hy7O8HOs.js} +1 -1
- package/src/console/ui/dist/assets/{panel-traces-DVAzuA_S.js → panel-traces-CBiAe5go.js} +1 -1
- package/src/console/ui/dist/assets/{panel-vault-D1_MvOmo.js → panel-vault-Za1GyJfM.js} +1 -1
- package/src/console/ui/dist/index.html +1 -1
- package/src/console/ui/shell/components/ui.tsx +5 -1
- package/src/console/ui/shell/setup/Wizard.tsx +26 -5
- package/src/docker/cleanup.test.ts +193 -0
- package/src/docker/cleanup.ts +355 -0
- package/src/docker/docker.test.ts +4 -0
- package/src/docker/dockerfile.integration.test.ts +126 -119
- package/src/docker/index.ts +19 -0
- package/src/docker/recipes/ollama.ts +10 -5
- package/src/docker/stack.integration.test.ts +118 -102
- package/src/drivers/ai-ollama-tools.integration.test.ts +8 -6
- package/src/drivers/ai-ollama.integration.test.ts +3 -19
- package/src/drivers/ai-ollama.ts +45 -2
- package/src/drivers/ai-providers.test.ts +31 -0
- package/src/drivers/channel-fcm.ts +49 -53
- package/src/drivers/channel-msegat.ts +61 -0
- package/src/drivers/channel-sently-map.ts +57 -0
- package/src/drivers/channel-sently.test.ts +99 -0
- package/src/drivers/channel-sndr.ts +28 -0
- package/src/drivers/channel-taqnyat.ts +57 -0
- package/src/drivers/channel-types.ts +79 -2
- package/src/drivers/channel-unifonic.ts +26 -43
- package/src/drivers/channel-wa-cloud.ts +33 -47
- package/src/drivers/channel-webpush.ts +39 -239
- package/src/drivers/index.ts +7 -0
- package/src/drivers/signal-engine.ts +98 -25
- package/src/drivers/signal-nats.ts +4 -4
- package/src/drivers/signal-postgres.ts +158 -64
- package/src/drivers/signal-redis.ts +4 -4
- package/src/drivers/signal-types.ts +61 -2
- package/src/drivers/vault-driver-removal.test.ts +5 -1
- package/src/elements/channel/costs.test.ts +2 -2
- package/src/elements/channel/costs.ts +14 -2
- package/src/elements/channel/mime.ts +11 -0
- package/src/elements/channel/runtime.ts +94 -0
- package/src/elements/channel/sndr-webhooks.test.ts +26 -0
- package/src/elements/channel.ts +10 -1
- package/src/elements/clock/chaos-child.ts +150 -0
- package/src/elements/clock/chaos.test.ts +204 -0
- package/src/elements/clock/reconcile.ts +110 -0
- package/src/elements/clock/runtime.ts +11 -0
- package/src/elements/clock.test.ts +164 -2
- package/src/elements/clock.ts +1 -0
- package/src/elements/gate/runtime.ts +6 -0
- package/src/elements/index.ts +9 -0
- package/src/elements/signal/chaos-child.ts +41 -4
- package/src/elements/signal/declare.ts +4 -1
- package/src/elements/signal/delivery-modes.test.ts +179 -0
- package/src/elements/signal/key-ordering.test.ts +306 -0
- package/src/elements/signal/lease-reclaim.test.ts +123 -0
- package/src/elements/signal/optional-emit.test.ts +76 -0
- package/src/elements/signal/order-lifecycle.test.ts +130 -0
- package/src/elements/signal/orphan-messages.test.ts +152 -0
- package/src/elements/signal/runtime.ts +11 -4
- package/src/elements/signal/schema-emit.test.ts +107 -0
- package/src/elements/signal.test.ts +89 -5
- package/src/elements/store/files-fx.ts +104 -0
- package/src/elements/store/files-image.test.ts +251 -0
- package/src/elements/store/files-image.ts +494 -0
- package/src/elements/store/runtime.ts +60 -0
- package/src/elements/store.ts +24 -0
- package/src/elements/vault/boot-chain.ts +150 -0
- package/src/elements/vault/runtime.ts +8 -0
- package/src/kernel/app.ts +3 -1
- package/src/kernel/boot-bind/channel.test.ts +68 -3
- package/src/kernel/boot-bind/channel.ts +93 -2
- package/src/kernel/boot-bind/clock.ts +52 -7
- package/src/kernel/boot-bind/gate.ts +71 -3
- package/src/kernel/boot-bind/honor-config.test.ts +247 -0
- package/src/kernel/boot-bind/signal.ts +64 -7
- package/src/kernel/boot-bind/vault.ts +27 -8
- package/src/kernel/boot.ts +10 -2
- package/src/kernel/errors.ts +8 -2
- package/src/kernel/fx.test.ts +13 -0
- package/src/kernel/fx.ts +27 -4
- package/src/plugins/auth-delivery.mailpit.integration.test.ts +10 -4
- package/src/release/exports.test.ts +26 -0
- package/src/release/exports.ts +64 -5
- package/src/release/index.ts +5 -0
- package/src/release/measure.exports.test.ts +13 -1
- package/src/release/measure.ts +76 -13
- package/src/release/official-plugins.ts +46 -0
- package/src/release/readme.test.ts +30 -2
- package/src/runtime/dev-request-log.test.ts +20 -1
- package/src/runtime/dev-request-log.ts +38 -0
- package/src/term.test.ts +15 -0
- package/src/term.ts +8 -3
- package/src/console/ui/dist/assets/index-CjxwRGVv.js +0 -10
|
@@ -61,4 +61,4 @@ import{a as e,r as t,t as n}from"./rolldown-runtime-B0Z9INg1.js";var r=class{con
|
|
|
61
61
|
|
|
62
62
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=nn,s=!Ut.jitless,c=s&&rn.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?xi([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function wi(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!vn(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Sn(e,r,Wt())))}),t)}var Ti=R(`$ZodUnion`,(e,t)=>{W.init(e,t),z(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),z(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),z(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),z(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Yt(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>wi(t,r,e,i)):wi(o,r,e,i)}}),Ei=R(`$ZodIntersection`,(e,t)=>{W.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Oi(e,t,n)):Oi(e,i,a)}});function Di(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(an(e)&&an(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Di(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Di(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Oi(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),vn(e))return e;let o=Di(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var ki=R(`$ZodEnum`,(e,t)=>{W.init(e,t);let n=Gt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>sn.has(typeof e)).map(e=>typeof e==`string`?cn(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Ai=R(`$ZodLiteral`,(e,t)=>{if(W.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?cn(e):e?cn(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),ji=R(`$ZodTransform`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ht(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Vt;return n.value=i,n.fallback=!0,n}});function Mi(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Ni=R(`$ZodOptional`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,z(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),z(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Yt(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Mi(e,r)):Mi(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Pi=R(`$ZodExactOptional`,(e,t)=>{Ni.init(e,t),z(e._zod,`values`,()=>t.innerType._zod.values),z(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Fi=R(`$ZodNullable`,(e,t)=>{W.init(e,t),z(e._zod,`optin`,()=>t.innerType._zod.optin),z(e._zod,`optout`,()=>t.innerType._zod.optout),z(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Yt(e.source)}|null)$`):void 0}),z(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ii=R(`$ZodDefault`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,z(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Li(e,t)):Li(r,t)}});function Li(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ri=R(`$ZodPrefault`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,z(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),zi=R(`$ZodNonOptional`,(e,t)=>{W.init(e,t),z(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Bi(t,e)):Bi(i,e)}});function Bi(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Vi=R(`$ZodCatch`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,z(e._zod,`optout`,()=>t.innerType._zod.optout),z(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Sn(e,n,Wt()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Sn(e,n,Wt()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Hi=R(`$ZodPipe`,(e,t)=>{W.init(e,t),z(e._zod,`values`,()=>t.in._zod.values),z(e._zod,`optin`,()=>t.in._zod.optin),z(e._zod,`optout`,()=>t.out._zod.optout),z(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Ui(e,t.in,n)):Ui(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ui(e,t.out,n)):Ui(r,t.out,n)}});function Ui(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Wi=R(`$ZodReadonly`,(e,t)=>{W.init(e,t),z(e._zod,`propValues`,()=>t.innerType._zod.propValues),z(e._zod,`values`,()=>t.innerType._zod.values),z(e._zod,`optin`,()=>t.innerType?._zod?.optin),z(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Gi):Gi(r)}});function Gi(e){return e.value=Object.freeze(e.value),e}var Ki=R(`$ZodCustom`,(e,t)=>{U.init(e,t),W.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>qi(t,n,r,e));qi(i,n,r,e)}});function qi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(wn(e))}}var Ji,Yi=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Xi(){return new Yi}(Ji=globalThis).__zod_globalRegistry??(Ji.__zod_globalRegistry=Xi());var Zi=globalThis.__zod_globalRegistry;function Qi(e,t){return new e({type:`string`,...H(t)})}function $i(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...H(t)})}function ea(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...H(t)})}function ta(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...H(t)})}function na(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...H(t)})}function ra(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...H(t)})}function ia(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...H(t)})}function aa(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...H(t)})}function oa(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...H(t)})}function sa(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...H(t)})}function ca(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...H(t)})}function la(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...H(t)})}function ua(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...H(t)})}function da(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...H(t)})}function fa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...H(t)})}function pa(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...H(t)})}function ma(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...H(t)})}function ha(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...H(t)})}function ga(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...H(t)})}function _a(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...H(t)})}function va(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...H(t)})}function ya(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...H(t)})}function ba(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...H(t)})}function xa(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...H(t)})}function Sa(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...H(t)})}function Ca(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...H(t)})}function wa(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...H(t)})}function Ta(e,t){return new e({type:`number`,coerce:!0,checks:[],...H(t)})}function Ea(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...H(t)})}function Da(e,t){return new e({type:`boolean`,...H(t)})}function Oa(e){return new e({type:`unknown`})}function ka(e,t){return new e({type:`never`,...H(t)})}function Aa(e,t){return new Sr({check:`less_than`,...H(t),value:e,inclusive:!1})}function ja(e,t){return new Sr({check:`less_than`,...H(t),value:e,inclusive:!0})}function Ma(e,t){return new Cr({check:`greater_than`,...H(t),value:e,inclusive:!1})}function Na(e,t){return new Cr({check:`greater_than`,...H(t),value:e,inclusive:!0})}function Pa(e,t){return new wr({check:`multiple_of`,...H(t),value:e})}function Fa(e,t){return new Er({check:`max_length`,...H(t),maximum:e})}function Ia(e,t){return new Dr({check:`min_length`,...H(t),minimum:e})}function La(e,t){return new Or({check:`length_equals`,...H(t),length:e})}function Ra(e,t){return new Ar({check:`string_format`,format:`regex`,...H(t),pattern:e})}function za(e){return new jr({check:`string_format`,format:`lowercase`,...H(e)})}function Ba(e){return new Mr({check:`string_format`,format:`uppercase`,...H(e)})}function Va(e,t){return new Nr({check:`string_format`,format:`includes`,...H(t),includes:e})}function Ha(e,t){return new Pr({check:`string_format`,format:`starts_with`,...H(t),prefix:e})}function Ua(e,t){return new Fr({check:`string_format`,format:`ends_with`,...H(t),suffix:e})}function Wa(e){return new Ir({check:`overwrite`,tx:e})}function Ga(e){return Wa(t=>t.normalize(e))}function Ka(){return Wa(e=>e.trim())}function qa(){return Wa(e=>e.toLowerCase())}function Ja(){return Wa(e=>e.toUpperCase())}function Ya(){return Wa(e=>en(e))}function Xa(e,t,n){return new e({type:`array`,element:t,...H(n)})}function Za(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...H(n)})}function Qa(e,t){let n=$a(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(wn(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(wn(r))}},e(t.value,t)),t);return n}function $a(e,t){let n=new U({check:`custom`,...H(t)});return n._zod.check=e,n}function eo(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Zi,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function K(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,K(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&q(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function to(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
63
63
|
|
|
64
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function no(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:io(t,`input`,e.processors),output:io(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function q(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return q(r.element,n);if(r.type===`set`)return q(r.valueType,n);if(r.type===`lazy`)return q(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return q(r.innerType,n);if(r.type===`intersection`)return q(r.left,n)||q(r.right,n);if(r.type===`record`||r.type===`map`)return q(r.keyType,n)||q(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:q(r.in,n)||q(r.out,n);if(r.type===`object`){for(let e in r.shape)if(q(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(q(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(q(e,n))return!0;return!!(r.rest&&q(r.rest,n))}return!1}var ro=(e,t={})=>n=>{let r=eo({...n,processors:t});return K(e,r),to(r,e),no(r,e)},io=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=eo({...i??{},target:a,io:t,processors:n});return K(e,o),to(o,e),no(o,e)},ao={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},oo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ao[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},so=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},co=(e,t,n,r)=>{n.type=`boolean`},lo=(e,t,n,r)=>{n.not={}},uo=(e,t,n,r)=>{let i=e._zod.def,a=Gt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},fo=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},po=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},mo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ho=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=K(a.element,t,{...r,path:[...r.path,`items`]})},go=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=K(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=K(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},_o=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>K(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},vo=(e,t,n,r)=>{let i=e._zod.def,a=K(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=K(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},yo=(e,t,n,r)=>{let i=e._zod.def,a=K(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},bo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},So=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Co=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},wo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;K(o,t,r);let s=t.seen.get(e);s.ref=o},To=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Eo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Do=R(`ZodISODateTime`,(e,t)=>{Zr.init(e,t),X.init(e,t)});function Oo(e){return xa(Do,e)}var ko=R(`ZodISODate`,(e,t)=>{Qr.init(e,t),X.init(e,t)});function Ao(e){return Sa(ko,e)}var jo=R(`ZodISOTime`,(e,t)=>{$r.init(e,t),X.init(e,t)});function Mo(e){return Ca(jo,e)}var No=R(`ZodISODuration`,(e,t)=>{ei.init(e,t),X.init(e,t)});function Po(e){return wa(No,e)}var J=R(`ZodError`,(e,t)=>{En.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>kn(e,t)},flatten:{value:t=>On(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Kt,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Kt,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Fo=An(J),Io=jn(J),Lo=Mn(J),Ro=Pn(J),zo=In(J),Bo=Ln(J),Vo=Rn(J),Ho=zn(J),Uo=Bn(J),Wo=Vn(J),Go=Hn(J),Ko=Un(J),qo=new WeakMap;function Jo(e,t,n){let r=Object.getPrototypeOf(e),i=qo.get(r);if(i||(i=new Set,qo.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Y=R(`ZodType`,(e,t)=>(W.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:io(e,`input`),output:io(e,`output`)}}),e.toJSONSchema=ro(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Fo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Lo(e,t,n),e.parseAsync=async(t,n)=>Io(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ro(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>zo(e,t,n),e.decode=(t,n)=>Bo(e,t,n),e.encodeAsync=async(t,n)=>Vo(e,t,n),e.decodeAsync=async(t,n)=>Ho(e,t,n),e.safeEncode=(t,n)=>Uo(e,t,n),e.safeDecode=(t,n)=>Wo(e,t,n),e.safeEncodeAsync=async(t,n)=>Go(e,t,n),e.safeDecodeAsync=async(t,n)=>Ko(e,t,n),Jo(e,`ZodType`,{check(...e){let t=this.def;return this.clone(B(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return V(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ac(e,t))},superRefine(e,t){return this.check(oc(e,t))},overwrite(e){return this.check(Wa(e))},optional(){return Vs(this)},exactOptional(){return Us(this)},nullable(){return Gs(this)},nullish(){return Vs(Gs(this))},nonoptional(e){return Zs(this,e)},array(){return Ds(this)},or(e){return js([this,e])},and(e){return Ns(this,e)},transform(e){return tc(this,zs(e))},default(e){return qs(this,e)},prefault(e){return Ys(this,e)},catch(e){return $s(this,e)},pipe(e){return tc(this,e)},readonly(){return rc(this)},describe(e){let t=this.clone();return Zi.add(t,{description:e}),t},meta(...e){if(e.length===0)return Zi.get(this);let t=this.clone();return Zi.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Zi.get(e)?.description},configurable:!0}),e)),Yo=R(`_ZodString`,(e,t)=>{zr.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Jo(e,`_ZodString`,{regex(...e){return this.check(Ra(...e))},includes(...e){return this.check(Va(...e))},startsWith(...e){return this.check(Ha(...e))},endsWith(...e){return this.check(Ua(...e))},min(...e){return this.check(Ia(...e))},max(...e){return this.check(Fa(...e))},length(...e){return this.check(La(...e))},nonempty(...e){return this.check(Ia(1,...e))},lowercase(e){return this.check(za(e))},uppercase(e){return this.check(Ba(e))},trim(){return this.check(Ka())},normalize(...e){return this.check(Ga(...e))},toLowerCase(){return this.check(qa())},toUpperCase(){return this.check(Ja())},slugify(){return this.check(Ya())}})}),Xo=R(`ZodString`,(e,t)=>{zr.init(e,t),Yo.init(e,t),e.email=t=>e.check($i(Qo,t)),e.url=t=>e.check(aa(ts,t)),e.jwt=t=>e.check(ba(gs,t)),e.emoji=t=>e.check(oa(ns,t)),e.guid=t=>e.check(ea($o,t)),e.uuid=t=>e.check(ta(es,t)),e.uuidv4=t=>e.check(na(es,t)),e.uuidv6=t=>e.check(ra(es,t)),e.uuidv7=t=>e.check(ia(es,t)),e.nanoid=t=>e.check(sa(rs,t)),e.guid=t=>e.check(ea($o,t)),e.cuid=t=>e.check(ca(is,t)),e.cuid2=t=>e.check(la(as,t)),e.ulid=t=>e.check(ua(os,t)),e.base64=t=>e.check(_a(ps,t)),e.base64url=t=>e.check(va(ms,t)),e.xid=t=>e.check(da(ss,t)),e.ksuid=t=>e.check(fa(cs,t)),e.ipv4=t=>e.check(pa(ls,t)),e.ipv6=t=>e.check(ma(us,t)),e.cidrv4=t=>e.check(ha(ds,t)),e.cidrv6=t=>e.check(ga(fs,t)),e.e164=t=>e.check(ya(hs,t)),e.datetime=t=>e.check(Oo(t)),e.date=t=>e.check(Ao(t)),e.time=t=>e.check(Mo(t)),e.duration=t=>e.check(Po(t))});function Zo(e){return Qi(Xo,e)}var X=R(`ZodStringFormat`,(e,t)=>{G.init(e,t),Yo.init(e,t)}),Qo=R(`ZodEmail`,(e,t)=>{Hr.init(e,t),X.init(e,t)}),$o=R(`ZodGUID`,(e,t)=>{Br.init(e,t),X.init(e,t)}),es=R(`ZodUUID`,(e,t)=>{Vr.init(e,t),X.init(e,t)}),ts=R(`ZodURL`,(e,t)=>{Ur.init(e,t),X.init(e,t)}),ns=R(`ZodEmoji`,(e,t)=>{Wr.init(e,t),X.init(e,t)}),rs=R(`ZodNanoID`,(e,t)=>{Gr.init(e,t),X.init(e,t)}),is=R(`ZodCUID`,(e,t)=>{Kr.init(e,t),X.init(e,t)}),as=R(`ZodCUID2`,(e,t)=>{qr.init(e,t),X.init(e,t)}),os=R(`ZodULID`,(e,t)=>{Jr.init(e,t),X.init(e,t)}),ss=R(`ZodXID`,(e,t)=>{Yr.init(e,t),X.init(e,t)}),cs=R(`ZodKSUID`,(e,t)=>{Xr.init(e,t),X.init(e,t)}),ls=R(`ZodIPv4`,(e,t)=>{ti.init(e,t),X.init(e,t)}),us=R(`ZodIPv6`,(e,t)=>{ni.init(e,t),X.init(e,t)}),ds=R(`ZodCIDRv4`,(e,t)=>{ri.init(e,t),X.init(e,t)}),fs=R(`ZodCIDRv6`,(e,t)=>{ii.init(e,t),X.init(e,t)}),ps=R(`ZodBase64`,(e,t)=>{oi.init(e,t),X.init(e,t)}),ms=R(`ZodBase64URL`,(e,t)=>{ci.init(e,t),X.init(e,t)}),hs=R(`ZodE164`,(e,t)=>{li.init(e,t),X.init(e,t)}),gs=R(`ZodJWT`,(e,t)=>{di.init(e,t),X.init(e,t)}),_s=R(`ZodNumber`,(e,t)=>{fi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>so(e,t,n,r),Jo(e,`ZodNumber`,{gt(e,t){return this.check(Ma(e,t))},gte(e,t){return this.check(Na(e,t))},min(e,t){return this.check(Na(e,t))},lt(e,t){return this.check(Aa(e,t))},lte(e,t){return this.check(ja(e,t))},max(e,t){return this.check(ja(e,t))},int(e){return this.check(ys(e))},safe(e){return this.check(ys(e))},positive(e){return this.check(Ma(0,e))},nonnegative(e){return this.check(Na(0,e))},negative(e){return this.check(Aa(0,e))},nonpositive(e){return this.check(ja(0,e))},multipleOf(e,t){return this.check(Pa(e,t))},step(e,t){return this.check(Pa(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}),vs=R(`ZodNumberFormat`,(e,t)=>{pi.init(e,t),_s.init(e,t)});function ys(e){return Ea(vs,e)}var bs=R(`ZodBoolean`,(e,t)=>{mi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r)});function xs(e){return Da(bs,e)}var Ss=R(`ZodUnknown`,(e,t)=>{hi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Cs(){return Oa(Ss)}var ws=R(`ZodNever`,(e,t)=>{gi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r)});function Ts(e){return ka(ws,e)}var Es=R(`ZodArray`,(e,t)=>{vi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r),e.element=t.element,Jo(e,`ZodArray`,{min(e,t){return this.check(Ia(e,t))},nonempty(e){return this.check(Ia(1,e))},max(e,t){return this.check(Fa(e,t))},length(e,t){return this.check(La(e,t))},unwrap(){return this.element}})});function Ds(e,t){return Xa(Es,e,t)}var Os=R(`ZodObject`,(e,t)=>{Ci.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r),z(e,`shape`,()=>t.shape),Jo(e,`ZodObject`,{keyof(){return Fs(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Cs()})},loose(){return this.clone({...this._zod.def,catchall:Cs()})},strict(){return this.clone({...this._zod.def,catchall:Ts()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return pn(this,e)},safeExtend(e){return mn(this,e)},merge(e){return hn(this,e)},pick(e){return dn(this,e)},omit(e){return fn(this,e)},partial(...e){return gn(Bs,this,e[0])},required(...e){return _n(Xs,this,e[0])}})});function ks(e,t){return new Os({type:`object`,shape:e??{},...H(t)})}var As=R(`ZodUnion`,(e,t)=>{Ti.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r),e.options=t.options});function js(e,t){return new As({type:`union`,options:e,...H(t)})}var Ms=R(`ZodIntersection`,(e,t)=>{Ei.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r)});function Ns(e,t){return new Ms({type:`intersection`,left:e,right:t})}var Ps=R(`ZodEnum`,(e,t)=>{ki.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ps({...t,checks:[],...H(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ps({...t,checks:[],...H(r),entries:i})}});function Fs(e,t){return new Ps({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...H(t)})}var Is=R(`ZodLiteral`,(e,t)=>{Ai.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Ls(e,t){return new Is({type:`literal`,values:Array.isArray(e)?e:[e],...H(t)})}var Rs=R(`ZodTransform`,(e,t)=>{ji.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ht(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(wn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(wn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function zs(e){return new Rs({type:`transform`,transform:e})}var Bs=R(`ZodOptional`,(e,t)=>{Ni.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vs(e){return new Bs({type:`optional`,innerType:e})}var Hs=R(`ZodExactOptional`,(e,t)=>{Pi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Us(e){return new Hs({type:`optional`,innerType:e})}var Ws=R(`ZodNullable`,(e,t)=>{Fi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gs(e){return new Ws({type:`nullable`,innerType:e})}var Ks=R(`ZodDefault`,(e,t)=>{Ii.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qs(e,t){return new Ks({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():on(t)}})}var Js=R(`ZodPrefault`,(e,t)=>{Ri.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ys(e,t){return new Js({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():on(t)}})}var Xs=R(`ZodNonOptional`,(e,t)=>{zi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zs(e,t){return new Xs({type:`nonoptional`,innerType:e,...H(t)})}var Qs=R(`ZodCatch`,(e,t)=>{Vi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $s(e,t){return new Qs({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var ec=R(`ZodPipe`,(e,t)=>{Hi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.in=t.in,e.out=t.out});function tc(e,t){return new ec({type:`pipe`,in:e,out:t})}var nc=R(`ZodReadonly`,(e,t)=>{Wi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rc(e){return new nc({type:`readonly`,innerType:e})}var ic=R(`ZodCustom`,(e,t)=>{Ki.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r)});function ac(e,t={}){return Za(ic,e,t)}function oc(e,t){return Qa(e,t)}var sc=ks({q:Zo().optional(),plane:Fs([`operator`,`user`]).optional(),kind:Fs([`operator`,`user`,`role`,`key`,`invite`]).optional(),id:Zo().optional(),view:Fs([`detail`,`effective`,`create-key`,`grant-role`]).optional()});function cc(e){let t=sc.safeParse(e);return t.success?t.data:{}}function lc(e){let t={};return e.q&&(t.q=e.q),e.plane&&(t.plane=e.plane),e.kind&&(t.kind=e.kind),e.id&&(t.id=e.id),e.view&&(t.view=e.view),t}function uc(e,t,n,r){return{...e,plane:t,kind:n,id:r,view:`detail`}}function dc(e,t={}){let n=t.fetch??globalThis.fetch.bind(globalThis),r=t.retry?.retries??0,i=t.retry?.delay??50,a=t.retry?.backoff??2;return{async call(o,s){let c=!1,l=0,u=i;for(;;)try{let r=await fc(e,o,s,t,n);if(r.status===401&&t.auth?.refresh&&!c){c=!0,await t.auth.refresh();continue}return hc(r)}catch(e){if(!gc(e)||l>=r)return{data:null,error:{code:`TransportError`,data:{message:e instanceof Error?e.message:String(e)}}};await _c(u),u*=a,l+=1}}}}async function fc(e,t,n,r,i){let a=r.routes?.[t.replace(`/`,`.`)],{url:o,method:s,body:c}=a?mc(e,a.method,a.path,n):pc(e,t,n),l=new Headers,u=typeof r.headers==`function`?await r.headers():r.headers;if(Array.isArray(u))for(let[e,t]of u)l.set(e,t);else if(u)for(let[e,t]of Object.entries(u))l.set(e,t);c!==void 0&&!l.has(`content-type`)&&l.set(`content-type`,`application/json`);let d=r.auth?await r.auth.getToken():void 0;d&&!l.has(`authorization`)&&l.set(`authorization`,`Bearer ${d}`);let f=r.timeout===void 0?void 0:new AbortController,p=f&&r.timeout!==void 0?setTimeout(()=>f.abort(),r.timeout):void 0;try{let e=await i(o,{method:s,headers:l,body:c,signal:f?.signal});if(e.status>=500)throw Error(`HTTP ${e.status}`);return e}finally{p!==void 0&&clearTimeout(p)}}function pc(e,t,n){return{url:`${e}/_oke/${t}`,method:`POST`,body:n===void 0?void 0:JSON.stringify(n??{})}}function mc(e,t,n,r){let i=typeof r==`object`&&r?r:{},a=n,o=[],s={};for(let[e,t]of Object.entries(i)){let n=`:${e}`;a.includes(n)?a=a.replaceAll(n,encodeURIComponent(String(t))):s[e]=t}let c=t.toUpperCase(),l;if(c===`GET`||c===`HEAD`)for(let[e,t]of Object.entries(s))t!==void 0&&o.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(t))}`);else(Object.keys(s).length>0||n===a)&&(l=JSON.stringify(Object.keys(s).length>0?s:r??{}));let u=o.length?`?${o.join(`&`)}`:``;return{url:`${e}${a}${u}`,method:c,body:l}}async function hc(e){if(e.status===204)return{data:void 0,error:null};let t=await e.text();if(!t)return e.ok?{data:void 0,error:null}:{data:null,error:{code:`TransportError`,data:{message:`HTTP ${e.status}`,status:e.status}}};let n;try{n=JSON.parse(t)}catch{return{data:null,error:{code:`TransportError`,data:{message:`Invalid JSON (${e.status})`,status:e.status}}}}return typeof n==`object`&&n&&`data`in n&&`error`in n?n:e.ok?{data:n,error:null}:{data:null,error:{code:`TransportError`,data:{message:`HTTP ${e.status}`,status:e.status}}}}function gc(e){return!(!(e instanceof Error)||e.name===`AbortError`)}function _c(e){return new Promise(t=>setTimeout(t,e))}function vc(e,t,n){if(typeof e==`string`)return yc(e,t);let r=typeof t==`string`?t:``,i=typeof t==`string`?n:t;return yc(r,{...i,$routes:i?.$routes??e.$routes})}function yc(e,t={}){let n=e.replace(/\/+$/,``),r=t.routes??bc(t.$routes);return xc(dc(n,{...t,routes:r}),[])}function bc(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))if(!(!r||typeof r!=`object`))for(let[e,i]of Object.entries(r)){if(!i||typeof i!=`object`)continue;let r=`method`in i?i.method:void 0,a=`path`in i?i.path:void 0;typeof r==`string`&&typeof a==`string`&&(t[`${n}.${e}`]={method:r,path:a})}return Object.keys(t).length>0?t:void 0}function xc(e,t){return new Proxy(n=>{if(t.length<2)return Promise.resolve({data:null,error:{code:`TransportError`,data:{message:`Incomplete path: api.${t.join(`.`)||`?`}(…)`}}});let r=t[0],i=t.slice(1).join(`.`);return e.call(`${r}/${i}`,n)},{get(n,r,i){if(typeof r==`symbol`)return Reflect.get(n,r,i);if(r!==`then`)return xc(e,[...t,r])}})}var Sc=null;function Cc(e){Sc=e,e?sessionStorage.setItem(`oke_console_at`,e):sessionStorage.removeItem(`oke_console_at`)}function wc(){Sc=sessionStorage.getItem(`oke_console_at`)}var Z=vc(globalThis.location===void 0?`http://127.0.0.1:6533`:globalThis.location.origin,{headers:()=>Sc?{Authorization:`Bearer ${Sc}`}:{},routes:{"console.setupStatus":{method:`GET`,path:`/console/setup/status`},"console.setupClaim":{method:`POST`,path:`/console/setup/claim`},"console.sessionLogin":{method:`POST`,path:`/console/session/login`},"console.sessionMe":{method:`GET`,path:`/console/session/me`},"console.sessionLogout":{method:`POST`,path:`/console/session/logout`},"console.manifestGet":{method:`GET`,path:`/console/manifest`},"console.runsList":{method:`GET`,path:`/console/runs`},"console.actionPing":{method:`POST`,path:`/console/action/ping`},"console.structuralPropose":{method:`POST`,path:`/console/structural/propose`},"console.flowsIdentities":{method:`GET`,path:`/console/flows/identities`},"console.flowsInvoke":{method:`POST`,path:`/console/flows/invoke`},"console.tracesReplay":{method:`POST`,path:`/console/traces/replay`},"console.signalsList":{method:`GET`,path:`/console/signals`},"console.signalsReplay":{method:`POST`,path:`/console/signals/replay`},"console.signalsDryRunReplay":{method:`POST`,path:`/console/signals/dry-run-replay`},"console.signalsDiscard":{method:`POST`,path:`/console/signals/discard`},"console.storeList":{method:`GET`,path:`/console/store`},"console.storeQuery":{method:`POST`,path:`/console/store/query`},"console.storeReveal":{method:`POST`,path:`/console/store/reveal`},"console.storeEdit":{method:`POST`,path:`/console/store/edit`},"console.storeDelete":{method:`POST`,path:`/console/store/delete`},"console.storePurgeCache":{method:`POST`,path:`/console/store/purge-cache`},"console.storeSql":{method:`POST`,path:`/console/store/sql`},"console.storePreview":{method:`POST`,path:`/console/store/preview`},"console.vaultList":{method:`GET`,path:`/console/vault`},"console.vaultSet":{method:`POST`,path:`/console/vault/set`},"console.vaultRotate":{method:`POST`,path:`/console/vault/rotate`},"console.aiList":{method:`GET`,path:`/console/ai`},"console.clockList":{method:`GET`,path:`/console/clock`},"console.clockRunNow":{method:`POST`,path:`/console/clock/run-now`},"console.clockPause":{method:`POST`,path:`/console/clock/pause`},"console.clockEditSchedule":{method:`POST`,path:`/console/clock/edit-schedule`},"console.clockWakeEarly":{method:`POST`,path:`/console/clock/wake-early`},"console.channelsList":{method:`GET`,path:`/console/channels`},"console.channelPreview":{method:`POST`,path:`/console/channels/preview`},"console.channelVerifyAuth":{method:`POST`,path:`/console/channels/verify-auth`},"console.channelReveal":{method:`POST`,path:`/console/channels/reveal`},"console.channelSendTest":{method:`POST`,path:`/console/channels/send-test`},"console.gatesList":{method:`GET`,path:`/console/gates`},"console.gatesSimulate":{method:`POST`,path:`/console/gates/simulate`},"console.gatesPowers":{method:`POST`,path:`/console/gates/powers`},"console.accessList":{method:`GET`,path:`/console/access`},"console.accessEffective":{method:`POST`,path:`/console/access/effective`},"console.accessKeyBlast":{method:`POST`,path:`/console/access/key-blast`},"console.accessCreateKey":{method:`POST`,path:`/console/access/keys`},"console.accessRevokeKey":{method:`POST`,path:`/console/access/keys/revoke`},"console.accessRotateKey":{method:`POST`,path:`/console/access/keys/rotate`},"console.accessSetRoleGrants":{method:`POST`,path:`/console/access/roles/grants`},"console.diffList":{method:`GET`,path:`/console/diff`},"console.pluginsList":{method:`GET`,path:`/console/plugins`}}}),Tc={async setupStatus(){return Z.console.setupStatus({})},async setupClaim(e){return Z.console.setupClaim(e)},async sessionLogin(e){return Z.console.sessionLogin(e)},async sessionMe(){return Z.console.sessionMe({})},async actionPing(e){return Z.console.actionPing({note:e})},async runsList(){return Z.console.runsList({})},async manifestGet(){return Z.console.manifestGet({})},async flowsIdentities(){return Z.console.flowsIdentities({})},async flowsInvoke(e){return Z.console.flowsInvoke(e)},async tracesReplay(e){return Z.console.tracesReplay(e)},async signalsList(){return Z.console.signalsList({})},async signalsReplay(e){return Z.console.signalsReplay(e)},async signalsDryRunReplay(e){return Z.console.signalsDryRunReplay(e)},async signalsDiscard(e){return Z.console.signalsDiscard(e)},async storeList(){return Z.console.storeList({})},async storeQuery(e){return Z.console.storeQuery(e)},async storeReveal(e){return Z.console.storeReveal(e)},async storeEdit(e){return Z.console.storeEdit(e)},async storeDelete(e){return Z.console.storeDelete(e)},async storePurgeCache(e){return Z.console.storePurgeCache(e)},async storeSql(e){return Z.console.storeSql(e)},async storePreview(e){return Z.console.storePreview(e)},async vaultList(){return Z.console.vaultList({})},async vaultSet(e){return Z.console.vaultSet(e)},async vaultRotate(e){return Z.console.vaultRotate(e)},async aiList(){return Z.console.aiList({})},async clockList(){return Z.console.clockList({})},async clockRunNow(e){return Z.console.clockRunNow(e)},async clockPause(e){return Z.console.clockPause(e)},async clockEditSchedule(e){return Z.console.clockEditSchedule(e)},async clockWakeEarly(e){return Z.console.clockWakeEarly(e)},async channelsList(){return Z.console.channelsList({})},async channelPreview(e){return Z.console.channelPreview(e)},async channelVerifyAuth(e){return Z.console.channelVerifyAuth(e)},async channelReveal(e){return Z.console.channelReveal(e)},async channelSendTest(e){return Z.console.channelSendTest(e)},async gatesList(){return Z.console.gatesList({})},async gatesSimulate(e){return Z.console.gatesSimulate(e)},async gatesPowers(e){return Z.console.gatesPowers(e)},async accessList(){return Z.console.accessList({})},async accessEffective(e){return Z.console.accessEffective(e)},async accessKeyBlast(e){return Z.console.accessKeyBlast(e)},async accessCreateKey(e){return Z.console.accessCreateKey(e)},async accessRevokeKey(e){return Z.console.accessRevokeKey(e)},async accessRotateKey(e){return Z.console.accessRotateKey(e)},async accessSetRoleGrants(e){return Z.console.accessSetRoleGrants(e)},async diffList(){return Z.console.diffList({})},async pluginsList(){return Z.console.pluginsList({})}};function Ec(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Ec(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Dc(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Ec(e))&&(r&&(r+=` `),r+=t);return r}function Oc(){return typeof window<`u`}function kc(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ac(e){return Oc()?e instanceof Element||e instanceof kc(e).Element:!1}function jc(e){return Oc()?e instanceof HTMLElement||e instanceof kc(e).HTMLElement:!1}var Mc={...I},Nc={};function Pc(e,t){let n=I.useRef(Nc);return n.current===Nc&&(n.current=e(t)),n}var Fc=Mc.useInsertionEffect,Ic=Fc&&Fc!==Mc.useLayoutEffect?Fc:e=>e();function Lc(e){let t=Pc(Rc).current;return t.next=e,Ic(t.effect),t.trampoline}function Rc(){let e={next:void 0,callback:zc,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function zc(){}var Bc=typeof document<`u`?I.useLayoutEffect:()=>{};function Vc(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}var Hc={};function Uc(e,t,n,r,i){if(!n&&!r&&!i&&!e)return Gc(t);let a=Gc(e);return t&&(a=Kc(a,t)),n&&(a=Kc(a,n)),r&&(a=Kc(a,r)),i&&(a=Kc(a,i)),a}function Wc(e){if(e.length===0)return Hc;if(e.length===1)return Gc(e[0]);let t=Gc(e[0]);for(let n=1;n<e.length;n+=1)t=Kc(t,e[n]);return t}function Gc(e){return Xc(e)?{...Zc(e,Hc)}:qc(e)}function Kc(e,t){return Xc(t)?Zc(t,e):Jc(e,t)}function qc(e){let t={...e};for(let e in t){let n=t[e];Yc(e,n)&&(t[e]=$c(n))}return t}function Jc(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Vc(e.style,r);break;case`className`:e[n]=tl(e.className,r);break;default:e[n]=Yc(n,r)?Qc(e[n],r):r}}return e}function Yc(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Xc(e){return typeof e==`function`}function Zc(e,t){return Xc(e)?e(t):e??Hc}function Qc(e,t){return t?e?(...n)=>{let r=n[0];if(nl(r)){let i=r;el(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:$c(t):e}function $c(e){return e&&((...t)=>{let n=t[0];return nl(n)&&el(n),e(...t)})}function el(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function tl(e,t){return t?e?t+` `+e:t:e}function nl(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function rl(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var il=rl(`https://base-ui.com/production-error`,`Base UI`),al=I.createContext(void 0);function ol(e=!1){let t=I.useContext(al);if(t===void 0&&!e)throw Error(il(16));return t}function sl(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:I.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function cl(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=I.useRef(null),s=ol(!0),c=a??s!==void 0,{props:l}=sl({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=I.useCallback(()=>{let e=o.current;ll(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return Bc(u,[u]),{getButtonProps:I.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return Uc({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(el(e),o?.(e),e.baseUIHandlerPrevented))return;let r=e.target===e.currentTarget,a=e.currentTarget,s=ll(a),l=!i&&ul(a),u=r&&(i?s:!l),d=e.key===`Enter`,f=e.key===` `,p=a.getAttribute(`role`),m=p?.startsWith(`menuitem`)||p===`option`||p===`gridcell`;if(r&&c&&f){if(e.defaultPrevented&&m)return;e.preventDefault(),l||i&&s?(a.click(),e.preventBaseUIHandler()):u&&(n?.(e),e.preventBaseUIHandler());return}u&&(!i&&(f||d)&&e.preventDefault(),!i&&d&&n?.(e))},onKeyUp(e){if(!t){if(el(e),a?.(e),e.target===e.currentTarget&&i&&c&&ll(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&e.key===` `&&n?.(e)}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:Lc(e=>{o.current=e,u()})}}function ll(e){return jc(e)&&e.tagName===`BUTTON`}function ul(e){return!!(e?.tagName===`A`&&e?.href)}function dl(e,t,n,r){let i=Pc(pl).current;return ml(i,e,t,n,r)&&gl(i,[e,t,n,r]),i.callback}function fl(e){let t=Pc(pl).current;return hl(t,e)&&gl(t,e),t.callback}function pl(){return{callback:null,cleanup:null,refs:[]}}function ml(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function hl(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function gl(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}var _l=19;function vl(e){return _l>=e}function yl(e){if(!I.isValidElement(e))return null;let t=e,n=t.props;return(vl(19)?n?.ref:t.ref)??null}function Q(){}Object.freeze([]);var bl=Object.freeze({});function xl(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Sl(e,t){return typeof e==`function`?e(t):e}function Cl(e,t){return typeof e==`function`?e(t):e}function wl(e,t,n={}){let r=t.render,i=Tl(t,n);return n.enabled===!1?null:Ol(e,r,i,n.state??bl)}function Tl(e,t={}){let{className:n,style:r,render:i}=e,{state:a=bl,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?Sl(n,a):void 0,d=l?Cl(r,a):void 0,f=l?xl(a,c):bl,p=l&&s?El(s):void 0,m=l?Vc(f,p)??{}:bl;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?fl([m.ref,yl(i),...o]):dl(m.ref,yl(i),o):dl(null,null)),l?(u!==void 0&&(m.className=tl(m.className,u)),d!==void 0&&(m.style=Vc(m.style,d)),m):bl}function El(e){return Array.isArray(e)?Wc(e):Uc(void 0,e)}var Dl=Symbol.for(`react.lazy`);function Ol(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Uc(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===Dl&&(i=I.Children.toArray(t)[0]),I.cloneElement(i,e)}if(e&&typeof e==`string`)return kl(e,n);throw Error(il(8))}function kl(e,t){return e===`button`?(0,I.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,I.createElement)(`img`,{alt:``,...t,key:t.key}):I.createElement(e,t)}var Al=I.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=cl({disabled:i,focusableWhenDisabled:a,native:o});return wl(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})}),jl=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Ml={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Nl={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Pl={disabled:!1,...Nl},Fl={valid(e){return e===null?null:e?{[jl.valid]:``}:{[jl.invalid]:``}}},Il={invalid:void 0,name:void 0,validityData:{state:Ml,errors:[],error:``,value:``,initialValue:null},setValidityData:Q,disabled:void 0,touched:Nl.touched,setTouched:Q,dirty:Nl.dirty,setDirty:Q,filled:Nl.filled,setFilled:Q,focused:Nl.focused,setFocused:Q,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:Pl,markedDirtyRef:{current:!1},registerFieldControl:Q,validation:{getValidationProps:(e,t=bl)=>t,inputRef:{current:null},registerInput:Q,commit:async()=>{},change:Q}},Ll=I.createContext(Il);function Rl(e=!0){let t=I.useContext(Ll);if(t.setValidityData===Q&&!e)throw Error(il(28));return t}var zl=I.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Q,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function Bl(){return I.useContext(zl)}var Vl=0;function Hl(e,t=`mui`){let[n,r]=I.useState(e),i=e||n;return I.useEffect(()=>{n??(Vl+=1,r(`${t}-${Vl}`))},[n,t]),i}var Ul=Mc.useId;function Wl(e,t){if(Ul!==void 0){let n=Ul();return e??(t?`${t}-${n}`:n)}return Hl(e,t)}function Gl(e){return Wl(e,`base-ui`)}var Kl=I.createContext({controlId:void 0,registerControlId:Q,labelId:void 0,setLabelId:Q,messageIds:[],setMessageIds:Q,getDescriptionProps:e=>e});function ql(){return I.useContext(Kl)}function Jl(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=ql(),o=Gl(t),s=n?i:void 0,c=Pc(()=>Symbol(`labelable-control`)),l=I.useRef(!1),u=I.useRef(t!=null),d=Lc(()=>{!l.current||a===Q||(l.current=!1,a(c.current,void 0))});return Bc(()=>{if(a===Q)return;let e;if(n){let n=r?.current;e=Ac(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),I.useEffect(()=>d,[d]),i??o}function Yl(e){return e?.ownerDocument||document}function Xl(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Zl({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=I.useRef(e!==void 0),[a,o]=I.useState(t);return[i?e:a,I.useCallback(e=>{i||o(e)},[])]}function Ql(e,t,n,r,i=!0,a){let{registerFieldControl:o}=Rl(),s=I.useRef(null);s.current||=Symbol(),Bc(()=>{let c=s.current;if(!(!c||!i))return o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}),()=>{o(c,void 0)}},[e,i,r,t,a,o,n])}var $l=`none`;function eu(e,t,n,r){let i=!1,a=!1,o=r??bl;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}var tu=I.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFocused:y,setFilled:b,validationMode:x,validation:S}=Rl(),{clearErrors:C}=Bl(),w=h||s,T=m??a,E={...p,disabled:w},{labelId:D}=ql(),O=Jl({id:i});Bc(()=>{let e=o!=null;S.inputRef.current?.value||e&&o!==``?b(!0):e&&o===``&&b(!1)},[S.inputRef,b,o]);let k=I.useRef(null);Bc(()=>{u&&k.current===Xl(Yl(k.current))&&y(!0)},[u,y]);let[A]=Zl({controlled:o,default:l,name:`FieldControl`,state:`value`}),ee=o!==void 0,j=ee?A:void 0,M=Lc(()=>S.inputRef.current?.value);return Ql(S.inputRef,O,j,M,!w,a),wl(`input`,e,{ref:[t,k],state:E,props:[{id:O,disabled:w,name:T,ref:S.inputRef,"aria-labelledby":D,autoFocus:u,...ee?{value:j}:{defaultValue:l},onChange(e){let t=e.currentTarget.value;c?.(t,eu($l,e.nativeEvent)),_(t!==v.initialValue),b(t!==``),e.nativeEvent.defaultPrevented||(C(T),S.change(t))},onFocus(){y(!0)},onBlur(e){g(!0),y(!1),x===`onBlur`&&S.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(g(!0),S.commit(e.currentTarget.value))}},f,e=>S.getValidationProps(w,e)],stateAttributesMapping:Fl})}),nu=I.forwardRef(function(e,t){return(0,L.jsx)(tu,{ref:t,...e})});function $({variant:e=`primary`,className:t,...n}){return(0,L.jsx)(Al,{className:Dc(`inline-flex min-h-8 min-w-8 items-center justify-center px-3 text-sm font-medium transition-opacity duration-150`,`disabled:opacity-40`,e===`primary`&&`bg-[var(--oke-accent)] text-black`,e===`ghost`&&`bg-transparent text-[var(--oke-fg)] border border-[var(--oke-line)]`,e===`danger`&&`bg-[var(--oke-danger)] text-white`,e===`external`&&`bg-[var(--oke-external)] text-black`,t),...n})}function ru({className:e,...t}){return(0,L.jsx)(nu,{className:Dc(`min-h-8 w-full border border-[var(--oke-line)] bg-transparent px-3 text-sm text-[var(--oke-fg)]`,`placeholder:text-[var(--oke-muted)]`,e),...t})}function iu({label:e,error:t,children:n}){return(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:e}),n,t?(0,L.jsx)(`span`,{role:`alert`,className:`text-xs text-[var(--oke-danger)]`,children:t}):null]})}function au({count:e,onFlush:t}){return e<=0?null:(0,L.jsxs)(`button`,{type:`button`,className:`min-h-8 rounded-sm border border-[var(--oke-line)] px-3 text-xs text-[var(--oke-fg)]`,onClick:t,children:[e,` new`]})}var ou=15e3;function su(e,t={production:!0}){return e===`external`&&t.production?{kind:`typed`,phrase:`INVOKE`,requireReason:!0}:{kind:`undo`,windowMs:ou}}function cu(e){let t={};return e.typed.trim()!==e.phrase&&(t.typed=`Type ${e.phrase} to confirm`),e.reason.trim().length<3&&(t.reason=`Reason is required (min 3 characters)`),Object.keys(t).length>0?t:null}function lu(e={production:!0}){return{kind:`typed`,phrase:`REVOKE`,requireReason:!0}}function uu(e={production:!0}){return{kind:`typed`,phrase:`ROTATE`,requireReason:!0}}function du(e){return e.acknowledged===!0}var fu=`I have copied this secret and understand it will not be shown again`,pu=`This secret is shown exactly once. Store it now — dismissal is permanent.`;function mu(e){return{volume:e.callVolume===0?`No recorded calls from Runs`:`${e.callVolume} call${e.callVolume===1?``:`s`} in Runs`,lastUsed:e.lastUsedAt==null?`Never used`:`Last used ${new Date(e.lastUsedAt).toISOString()}`,sources:e.sourceAddresses.length===0?`No source addresses recorded`:`Source addresses: ${e.sourceAddresses.join(`, `)}`,residual:e.residualAccessNote,warn:e.callVolume>0}}function hu(e){let t=[];return e.unusedKeys.length>0&&t.push({code:`unused-keys`,message:`${e.unusedKeys.length} key${e.unusedKeys.length===1?``:`s`} unused 90d+`}),e.neverSignedInOperators.length>0&&t.push({code:`never-signed-in`,message:`${e.neverSignedInOperators.length} operator${e.neverSignedInOperators.length===1?``:`s`} never signed in`}),e.expiredInvitations.length>0&&t.push({code:`expired-invites`,message:`${e.expiredInvitations.length} expired invitation${e.expiredInvitations.length===1?``:`s`}`}),t}function gu(e){return e.scopes.map(e=>({scope:e.scope,sources:e.sources.map(e=>e.kind===`direct`?`direct (${e.name})`:`role ${e.name}`).join(`, `)}))}function _u(){let e=Rt({from:`/access`}),t=zt({from:`/access`}),n=je(),r=e.plane??`operator`,[i,a]=(0,I.useState)([]),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(null),v=e=>{t({search:lc(e),replace:!0})},y=Ke({queryKey:[`console.access.list`],queryFn:async()=>{let e=await Tc.accessList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}).data,b=r===`operator`?y?.operatorPlane:y?.userPlane,x=b?.grantableScopes??[],S=y?.hygiene,C=(0,I.useMemo)(()=>S?hu(S):[],[S]),w=b?.keys.find(t=>e.kind===`key`&&t.id===e.id),T=b?.roles.find(t=>e.kind===`role`&&t.id===e.id),E=b?.operators?.find(t=>e.kind===`operator`&&t.id===e.id),D=b?.users?.find(t=>e.kind===`user`&&t.id===e.id),O=(e.q??``).toLowerCase(),k=e=>O.length===0||e.toLowerCase().includes(O),A=qe({mutationFn:async()=>{if(!o.trim())throw Error(`Name required`);let e=await Tc.accessCreateKey({plane:r,name:o.trim(),scopes:i});if(e.error)throw Error(e.error.code);return e.data},onSuccess:e=>{p({secret:e.secret,keyId:e.key.id,keyName:e.key.name,acknowledged:!1}),s(``),a([]),n.invalidateQueries({queryKey:[`console.access.list`]})}}),ee=qe({mutationFn:async e=>{let t=await Tc.accessKeyBlast({keyId:e});if(t.error)throw Error(t.error.code);return t.data},onSuccess:h}),j=qe({mutationFn:async()=>{if(!w)throw Error(`Select a key`);let e=lu();if(e.kind===`typed`){let t=cu({typed:c,reason:u,phrase:e.phrase});if(t)throw Error(t.typed??t.reason??`confirm`)}let t=await Tc.accessRevokeKey({keyId:w.id,confirmation:c,reason:u});if(t.error)throw Error(t.error.code);return t.data},onSuccess:e=>{h(e.blastRadius),l(``),d(``),n.invalidateQueries({queryKey:[`console.access.list`]})}}),M=qe({mutationFn:async()=>{if(!w)throw Error(`Select a key`);let e=uu();if(e.kind===`typed`){let t=cu({typed:c,reason:u,phrase:e.phrase});if(t)throw Error(t.typed??t.reason??`confirm`)}let t=await Tc.accessRotateKey({keyId:w.id,confirmation:c,reason:u});if(t.error)throw Error(t.error.code);return t.data},onSuccess:e=>{h(e.blastRadius),p({secret:e.secret,keyId:e.key.id,keyName:e.key.name,acknowledged:!1}),l(``),d(``),n.invalidateQueries({queryKey:[`console.access.list`]})}}),N=qe({mutationFn:async()=>{let t=e.kind===`invite`||!e.kind||!e.id?null:e.kind;if(!t||!e.id)throw Error(`Select a principal`);let n=await Tc.accessEffective({kind:t,id:e.id});if(n.error)throw Error(n.error.code);return n.data},onSuccess:_}),te=qe({mutationFn:async()=>{if(!T)throw Error(`Select a role`);let e=await Tc.accessSetRoleGrants({roleId:T.id,scopes:i});if(e.error)throw Error(e.error.code);return e.data},onSuccess:()=>{n.invalidateQueries({queryKey:[`console.access.list`]})}}),P=m?mu(m):null,ne=g?gu(g):[],F=e=>{a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,L.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-3 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-lg font-medium text-[var(--oke-fg)]`,children:`Access`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Identities, roles, API keys — planes never merge`})]}),(0,L.jsxs)(`div`,{role:`group`,"aria-label":`Plane`,className:`flex gap-1`,children:[(0,L.jsx)($,{type:`button`,variant:r===`operator`?`primary`:`ghost`,"aria-pressed":r===`operator`,onClick:()=>v({...e,plane:`operator`,kind:void 0,id:void 0,view:void 0}),children:`Operator plane`}),(0,L.jsx)($,{type:`button`,variant:r===`user`?`primary`:`ghost`,"aria-pressed":r===`user`,onClick:()=>v({...e,plane:`user`,kind:void 0,id:void 0,view:void 0}),children:`User plane`})]}),(0,L.jsxs)(`label`,{className:`ml-auto flex min-w-[12rem] flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter access`}),(0,L.jsx)(ru,{"aria-label":`Filter access`,value:e.q??``,onChange:t=>v({...e,q:t.currentTarget.value||void 0})})]})]}),C.length>0?(0,L.jsxs)(`section`,{"aria-label":`Access hygiene`,className:`border-b border-[var(--oke-line)] px-4 py-2`,role:`status`,children:[(0,L.jsx)(`h2`,{className:`sr-only`,children:`Hygiene`}),(0,L.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-[var(--oke-warn,var(--oke-muted))]`,children:C.map(e=>(0,L.jsx)(`li`,{children:e.message},e.code))})]}):null,(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,L.jsxs)(`section`,{"aria-label":`${r} plane list`,className:`w-80 shrink-0 overflow-y-auto border-r border-[var(--oke-line)]`,children:[(0,L.jsx)(`h2`,{className:`px-4 py-2 text-sm font-medium`,children:r===`operator`?`Operator plane`:`User plane`}),b?.operators?(0,L.jsx)(vu,{label:`Operators`,children:b.operators.filter(e=>k(`${e.name} ${e.email}`)).map(t=>(0,L.jsxs)(yu,{selected:e.kind===`operator`&&e.id===t.id,onClick:()=>v(uc(e,`operator`,`operator`,t.id)),children:[t.name,t.neverSignedIn?(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:` · never`}):null]},t.id))}):null,b?.users?(0,L.jsx)(vu,{label:`Users`,children:b.users.filter(e=>k(`${e.name} ${e.email}`)).map(t=>(0,L.jsx)(yu,{selected:e.kind===`user`&&e.id===t.id,onClick:()=>v(uc(e,`user`,`user`,t.id)),children:t.name},t.id))}):null,(0,L.jsx)(vu,{label:`Roles`,children:(b?.roles??[]).filter(e=>k(e.name)).map(t=>(0,L.jsx)(yu,{selected:e.kind===`role`&&e.id===t.id,onClick:()=>{a([...t.scopes]),v(uc(e,r,`role`,t.id))},children:t.name},t.id))}),(0,L.jsx)(vu,{label:`API keys`,children:(b?.keys??[]).filter(e=>k(e.name)).map(t=>(0,L.jsxs)(yu,{selected:e.kind===`key`&&e.id===t.id,onClick:()=>{h(null),v(uc(e,r,`key`,t.id)),ee.mutate(t.id)},children:[t.name,t.unused90d?(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:` · 90d+`}):null,t.revokedAt==null?null:(0,L.jsx)(`span`,{className:`text-[var(--oke-danger)]`,children:` · revoked`})]},t.id))}),b?.invites&&b.invites.length>0?(0,L.jsx)(vu,{label:`Invitations`,children:b.invites.filter(e=>k(e.email)).map(t=>(0,L.jsxs)(yu,{selected:e.kind===`invite`&&e.id===t.id,onClick:()=>v(uc(e,`operator`,`invite`,t.id)),children:[t.email,t.expired?(0,L.jsx)(`span`,{className:`text-[var(--oke-danger)]`,children:` · expired`}):null]},t.id))}):null,(0,L.jsx)(`div`,{className:`border-t border-[var(--oke-line)] p-3`,children:(0,L.jsx)($,{type:`button`,variant:`ghost`,className:`w-full`,onClick:()=>{a([]),s(``),v({...e,plane:r,view:`create-key`,kind:void 0,id:void 0})},children:`Create API key`})})]}),(0,L.jsxs)(`section`,{"aria-label":`Access detail`,className:`min-w-0 flex-1 overflow-y-auto px-4 py-3`,"aria-live":`polite`,children:[e.view===`create-key`?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:`Create API key`}),(0,L.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:[`Only scopes you hold on the `,r,` plane are shown — impossibility taught by absence. No preview.`]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Name`}),(0,L.jsx)(ru,{"aria-label":`API key name`,value:o,onChange:e=>s(e.currentTarget.value)})]}),(0,L.jsx)(bu,{grantable:x,selected:i,onToggle:F}),(0,L.jsx)($,{type:`button`,disabled:A.isPending||!o.trim(),onClick:()=>A.mutate(),children:`Create key`}),A.error?(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:A.error.message}):null]}):w?(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:w.name}),(0,L.jsx)(`p`,{className:`font-mono text-sm text-[var(--oke-muted)]`,children:w.id}),(0,L.jsx)(`ul`,{className:`mt-2 font-mono text-sm`,children:w.scopes.map(e=>(0,L.jsx)(`li`,{children:e},e))})]}),(0,L.jsxs)(`section`,{"aria-label":`Revocation blast radius`,className:`space-y-1`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Revocation blast radius`}),P?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-sm`,role:P.warn?`alert`:`status`,children:P.volume}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:P.lastUsed}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:P.sources}),(0,L.jsx)(`p`,{className:`text-sm`,role:`status`,children:P.residual})]}):(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Loading…`})]}),w.revokedAt==null?(0,L.jsxs)(`section`,{"aria-label":`Revoke or rotate`,className:`space-y-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Revoke / rotate`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Irreversible. Type the phrase and a reason. No dry-run.`}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Type REVOKE or ROTATE`}),(0,L.jsx)(ru,{"aria-label":`Type REVOKE or ROTATE to confirm`,value:c,onChange:e=>l(e.currentTarget.value),autoComplete:`off`})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Reason`}),(0,L.jsx)(ru,{"aria-label":`Reason`,value:u,onChange:e=>d(e.currentTarget.value)})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)($,{type:`button`,variant:`danger`,disabled:j.isPending,onClick:()=>j.mutate(),children:`Revoke key`}),(0,L.jsx)($,{type:`button`,variant:`danger`,disabled:M.isPending,onClick:()=>M.mutate(),children:`Rotate key`})]}),j.error||M.error?(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:(j.error??M.error).message}):null]}):(0,L.jsxs)(`p`,{role:`status`,className:`text-sm text-[var(--oke-danger)]`,children:[`Revoked `,w.revokedAt?new Date(w.revokedAt).toISOString():``]}),(0,L.jsx)($,{type:`button`,variant:`ghost`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):T?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:T.name}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:T.description}),(0,L.jsx)(bu,{grantable:x,selected:i,onToggle:F}),(0,L.jsx)($,{type:`button`,disabled:te.isPending,onClick:()=>te.mutate(),children:`Save role grants`}),(0,L.jsx)($,{type:`button`,variant:`ghost`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):E||D?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:E?.name??D?.name}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:E?.email??D?.email}),(0,L.jsx)($,{type:`button`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):e.view===`effective`&&ne.length>0?(0,L.jsx)(xu,{provenance:ne}):(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Choose an identity, role, or key. Planes stay separate; scopes you cannot grant do not appear.`}),e.view===`effective`&&ne.length>0&&(w||T||E||D)?(0,L.jsx)(`div`,{className:`mt-6`,children:(0,L.jsx)(xu,{provenance:ne})}):null]})]}),f?(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,role:`presentation`,children:(0,L.jsxs)(`section`,{"aria-label":`New API key secret`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`once-secret-title`,className:`max-w-lg space-y-4 border border-[var(--oke-line)] bg-[var(--oke-bg)] p-6`,children:[(0,L.jsx)(`h2`,{id:`once-secret-title`,className:`text-lg font-medium`,children:`New API key secret`}),(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:pu}),(0,L.jsx)(`p`,{className:`break-all font-mono text-sm`,children:f.secret}),(0,L.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:f.acknowledged,onChange:e=>p({...f,acknowledged:e.currentTarget.checked})}),(0,L.jsx)(`span`,{children:fu})]}),(0,L.jsx)($,{type:`button`,disabled:!du(f),onClick:()=>p(null),children:`Dismiss secret`})]})}):null]})}function vu({label:e,children:t}){return(0,L.jsxs)(`section`,{"aria-label":e,className:`border-t border-[var(--oke-line)]`,children:[(0,L.jsx)(`h3`,{className:`px-4 py-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:e}),(0,L.jsx)(`ul`,{className:`pb-2`,children:t})]})}function yu({selected:e,onClick:t,children:n}){return(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:Dc(`flex min-h-8 w-full items-center px-4 text-left text-sm`,e?`bg-[var(--oke-accent)]/15 text-[var(--oke-fg)]`:`text-[var(--oke-fg)]`),children:n})})}function bu({grantable:e,selected:t,onToggle:n}){return(0,L.jsxs)(`section`,{"aria-label":`Grantable scopes`,className:`space-y-2`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Grantable scopes`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Only scopes you hold appear`}),e.length===0?(0,L.jsx)(`p`,{role:`status`,className:`text-sm text-[var(--oke-muted)]`,children:`No grantable scopes on this plane`}):(0,L.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`label`,{className:`flex min-h-8 items-center gap-2 font-mono text-sm`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:t.includes(e),onChange:()=>n(e)}),e]})},e))})]})}function xu({provenance:e}){return(0,L.jsxs)(`section`,{"aria-label":`Effective permissions`,children:[(0,L.jsx)(`h2`,{className:`mb-2 text-lg font-medium`,children:`Effective permissions`}),(0,L.jsx)(`p`,{className:`mb-3 text-sm text-[var(--oke-muted)]`,children:`Every permission with provenance — inverse of the Gates simulator`}),(0,L.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,L.jsx)(`caption`,{className:`sr-only`,children:`Effective permissions with provenance`}),(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-[var(--oke-line)]`,children:[(0,L.jsx)(`th`,{scope:`col`,className:`py-2 pr-4 font-medium`,children:`Scope`}),(0,L.jsx)(`th`,{scope:`col`,className:`py-2 font-medium`,children:`Granted by`})]})}),(0,L.jsx)(`tbody`,{children:e.map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-[var(--oke-line)]`,children:[(0,L.jsx)(`td`,{className:`py-2 pr-4 font-mono`,children:e.scope}),(0,L.jsx)(`td`,{className:`py-2 text-[var(--oke-muted)]`,children:e.sources})]},e.scope))})]})]})}var Su=t({default:()=>_u});export{Me as $,Tt as A,bt as B,zt as C,Pt as D,It as E,xt as F,st as G,ht as H,ft as I,Ze as J,Je as K,St as L,yt as M,Ct as N,Dt as O,pt as P,Ke as Q,tt as R,Ta as S,Lt as T,$e as U,mt as V,ot as W,Xe as X,Ye as Y,qe as Z,xs as _,r as _t,cu as a,re as at,Zo as b,ru as c,v as ct,Tc as d,h as dt,je as et,wc as f,l as ft,Fs as g,i as gt,_s as h,A as ht,su as i,fe as it,wt as j,Et as k,au as l,_ as lt,cc as m,p as mt,hu as n,De as nt,$ as o,F as ot,Cc as p,y as pt,Qe as q,ou as r,Ce as rt,iu as s,u as st,Su as t,ke as tt,Dc as u,g as ut,Ls as v,Rt as w,js as x,ks as y,it as z};
|
|
64
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function no(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:io(t,`input`,e.processors),output:io(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function q(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return q(r.element,n);if(r.type===`set`)return q(r.valueType,n);if(r.type===`lazy`)return q(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return q(r.innerType,n);if(r.type===`intersection`)return q(r.left,n)||q(r.right,n);if(r.type===`record`||r.type===`map`)return q(r.keyType,n)||q(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:q(r.in,n)||q(r.out,n);if(r.type===`object`){for(let e in r.shape)if(q(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(q(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(q(e,n))return!0;return!!(r.rest&&q(r.rest,n))}return!1}var ro=(e,t={})=>n=>{let r=eo({...n,processors:t});return K(e,r),to(r,e),no(r,e)},io=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=eo({...i??{},target:a,io:t,processors:n});return K(e,o),to(o,e),no(o,e)},ao={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},oo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ao[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},so=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},co=(e,t,n,r)=>{n.type=`boolean`},lo=(e,t,n,r)=>{n.not={}},uo=(e,t,n,r)=>{let i=e._zod.def,a=Gt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},fo=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},po=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},mo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ho=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=K(a.element,t,{...r,path:[...r.path,`items`]})},go=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=K(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=K(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},_o=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>K(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},vo=(e,t,n,r)=>{let i=e._zod.def,a=K(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=K(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},yo=(e,t,n,r)=>{let i=e._zod.def,a=K(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},bo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},So=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Co=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},wo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;K(o,t,r);let s=t.seen.get(e);s.ref=o},To=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Eo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Do=R(`ZodISODateTime`,(e,t)=>{Zr.init(e,t),X.init(e,t)});function Oo(e){return xa(Do,e)}var ko=R(`ZodISODate`,(e,t)=>{Qr.init(e,t),X.init(e,t)});function Ao(e){return Sa(ko,e)}var jo=R(`ZodISOTime`,(e,t)=>{$r.init(e,t),X.init(e,t)});function Mo(e){return Ca(jo,e)}var No=R(`ZodISODuration`,(e,t)=>{ei.init(e,t),X.init(e,t)});function Po(e){return wa(No,e)}var J=R(`ZodError`,(e,t)=>{En.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>kn(e,t)},flatten:{value:t=>On(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Kt,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Kt,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Fo=An(J),Io=jn(J),Lo=Mn(J),Ro=Pn(J),zo=In(J),Bo=Ln(J),Vo=Rn(J),Ho=zn(J),Uo=Bn(J),Wo=Vn(J),Go=Hn(J),Ko=Un(J),qo=new WeakMap;function Jo(e,t,n){let r=Object.getPrototypeOf(e),i=qo.get(r);if(i||(i=new Set,qo.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Y=R(`ZodType`,(e,t)=>(W.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:io(e,`input`),output:io(e,`output`)}}),e.toJSONSchema=ro(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Fo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Lo(e,t,n),e.parseAsync=async(t,n)=>Io(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ro(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>zo(e,t,n),e.decode=(t,n)=>Bo(e,t,n),e.encodeAsync=async(t,n)=>Vo(e,t,n),e.decodeAsync=async(t,n)=>Ho(e,t,n),e.safeEncode=(t,n)=>Uo(e,t,n),e.safeDecode=(t,n)=>Wo(e,t,n),e.safeEncodeAsync=async(t,n)=>Go(e,t,n),e.safeDecodeAsync=async(t,n)=>Ko(e,t,n),Jo(e,`ZodType`,{check(...e){let t=this.def;return this.clone(B(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return V(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ac(e,t))},superRefine(e,t){return this.check(oc(e,t))},overwrite(e){return this.check(Wa(e))},optional(){return Vs(this)},exactOptional(){return Us(this)},nullable(){return Gs(this)},nullish(){return Vs(Gs(this))},nonoptional(e){return Zs(this,e)},array(){return Ds(this)},or(e){return js([this,e])},and(e){return Ns(this,e)},transform(e){return tc(this,zs(e))},default(e){return qs(this,e)},prefault(e){return Ys(this,e)},catch(e){return $s(this,e)},pipe(e){return tc(this,e)},readonly(){return rc(this)},describe(e){let t=this.clone();return Zi.add(t,{description:e}),t},meta(...e){if(e.length===0)return Zi.get(this);let t=this.clone();return Zi.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Zi.get(e)?.description},configurable:!0}),e)),Yo=R(`_ZodString`,(e,t)=>{zr.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Jo(e,`_ZodString`,{regex(...e){return this.check(Ra(...e))},includes(...e){return this.check(Va(...e))},startsWith(...e){return this.check(Ha(...e))},endsWith(...e){return this.check(Ua(...e))},min(...e){return this.check(Ia(...e))},max(...e){return this.check(Fa(...e))},length(...e){return this.check(La(...e))},nonempty(...e){return this.check(Ia(1,...e))},lowercase(e){return this.check(za(e))},uppercase(e){return this.check(Ba(e))},trim(){return this.check(Ka())},normalize(...e){return this.check(Ga(...e))},toLowerCase(){return this.check(qa())},toUpperCase(){return this.check(Ja())},slugify(){return this.check(Ya())}})}),Xo=R(`ZodString`,(e,t)=>{zr.init(e,t),Yo.init(e,t),e.email=t=>e.check($i(Qo,t)),e.url=t=>e.check(aa(ts,t)),e.jwt=t=>e.check(ba(gs,t)),e.emoji=t=>e.check(oa(ns,t)),e.guid=t=>e.check(ea($o,t)),e.uuid=t=>e.check(ta(es,t)),e.uuidv4=t=>e.check(na(es,t)),e.uuidv6=t=>e.check(ra(es,t)),e.uuidv7=t=>e.check(ia(es,t)),e.nanoid=t=>e.check(sa(rs,t)),e.guid=t=>e.check(ea($o,t)),e.cuid=t=>e.check(ca(is,t)),e.cuid2=t=>e.check(la(as,t)),e.ulid=t=>e.check(ua(os,t)),e.base64=t=>e.check(_a(ps,t)),e.base64url=t=>e.check(va(ms,t)),e.xid=t=>e.check(da(ss,t)),e.ksuid=t=>e.check(fa(cs,t)),e.ipv4=t=>e.check(pa(ls,t)),e.ipv6=t=>e.check(ma(us,t)),e.cidrv4=t=>e.check(ha(ds,t)),e.cidrv6=t=>e.check(ga(fs,t)),e.e164=t=>e.check(ya(hs,t)),e.datetime=t=>e.check(Oo(t)),e.date=t=>e.check(Ao(t)),e.time=t=>e.check(Mo(t)),e.duration=t=>e.check(Po(t))});function Zo(e){return Qi(Xo,e)}var X=R(`ZodStringFormat`,(e,t)=>{G.init(e,t),Yo.init(e,t)}),Qo=R(`ZodEmail`,(e,t)=>{Hr.init(e,t),X.init(e,t)}),$o=R(`ZodGUID`,(e,t)=>{Br.init(e,t),X.init(e,t)}),es=R(`ZodUUID`,(e,t)=>{Vr.init(e,t),X.init(e,t)}),ts=R(`ZodURL`,(e,t)=>{Ur.init(e,t),X.init(e,t)}),ns=R(`ZodEmoji`,(e,t)=>{Wr.init(e,t),X.init(e,t)}),rs=R(`ZodNanoID`,(e,t)=>{Gr.init(e,t),X.init(e,t)}),is=R(`ZodCUID`,(e,t)=>{Kr.init(e,t),X.init(e,t)}),as=R(`ZodCUID2`,(e,t)=>{qr.init(e,t),X.init(e,t)}),os=R(`ZodULID`,(e,t)=>{Jr.init(e,t),X.init(e,t)}),ss=R(`ZodXID`,(e,t)=>{Yr.init(e,t),X.init(e,t)}),cs=R(`ZodKSUID`,(e,t)=>{Xr.init(e,t),X.init(e,t)}),ls=R(`ZodIPv4`,(e,t)=>{ti.init(e,t),X.init(e,t)}),us=R(`ZodIPv6`,(e,t)=>{ni.init(e,t),X.init(e,t)}),ds=R(`ZodCIDRv4`,(e,t)=>{ri.init(e,t),X.init(e,t)}),fs=R(`ZodCIDRv6`,(e,t)=>{ii.init(e,t),X.init(e,t)}),ps=R(`ZodBase64`,(e,t)=>{oi.init(e,t),X.init(e,t)}),ms=R(`ZodBase64URL`,(e,t)=>{ci.init(e,t),X.init(e,t)}),hs=R(`ZodE164`,(e,t)=>{li.init(e,t),X.init(e,t)}),gs=R(`ZodJWT`,(e,t)=>{di.init(e,t),X.init(e,t)}),_s=R(`ZodNumber`,(e,t)=>{fi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>so(e,t,n,r),Jo(e,`ZodNumber`,{gt(e,t){return this.check(Ma(e,t))},gte(e,t){return this.check(Na(e,t))},min(e,t){return this.check(Na(e,t))},lt(e,t){return this.check(Aa(e,t))},lte(e,t){return this.check(ja(e,t))},max(e,t){return this.check(ja(e,t))},int(e){return this.check(ys(e))},safe(e){return this.check(ys(e))},positive(e){return this.check(Ma(0,e))},nonnegative(e){return this.check(Na(0,e))},negative(e){return this.check(Aa(0,e))},nonpositive(e){return this.check(ja(0,e))},multipleOf(e,t){return this.check(Pa(e,t))},step(e,t){return this.check(Pa(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}),vs=R(`ZodNumberFormat`,(e,t)=>{pi.init(e,t),_s.init(e,t)});function ys(e){return Ea(vs,e)}var bs=R(`ZodBoolean`,(e,t)=>{mi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r)});function xs(e){return Da(bs,e)}var Ss=R(`ZodUnknown`,(e,t)=>{hi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Cs(){return Oa(Ss)}var ws=R(`ZodNever`,(e,t)=>{gi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r)});function Ts(e){return ka(ws,e)}var Es=R(`ZodArray`,(e,t)=>{vi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r),e.element=t.element,Jo(e,`ZodArray`,{min(e,t){return this.check(Ia(e,t))},nonempty(e){return this.check(Ia(1,e))},max(e,t){return this.check(Fa(e,t))},length(e,t){return this.check(La(e,t))},unwrap(){return this.element}})});function Ds(e,t){return Xa(Es,e,t)}var Os=R(`ZodObject`,(e,t)=>{Ci.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r),z(e,`shape`,()=>t.shape),Jo(e,`ZodObject`,{keyof(){return Fs(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Cs()})},loose(){return this.clone({...this._zod.def,catchall:Cs()})},strict(){return this.clone({...this._zod.def,catchall:Ts()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return pn(this,e)},safeExtend(e){return mn(this,e)},merge(e){return hn(this,e)},pick(e){return dn(this,e)},omit(e){return fn(this,e)},partial(...e){return gn(Bs,this,e[0])},required(...e){return _n(Xs,this,e[0])}})});function ks(e,t){return new Os({type:`object`,shape:e??{},...H(t)})}var As=R(`ZodUnion`,(e,t)=>{Ti.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r),e.options=t.options});function js(e,t){return new As({type:`union`,options:e,...H(t)})}var Ms=R(`ZodIntersection`,(e,t)=>{Ei.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r)});function Ns(e,t){return new Ms({type:`intersection`,left:e,right:t})}var Ps=R(`ZodEnum`,(e,t)=>{ki.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ps({...t,checks:[],...H(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ps({...t,checks:[],...H(r),entries:i})}});function Fs(e,t){return new Ps({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...H(t)})}var Is=R(`ZodLiteral`,(e,t)=>{Ai.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Ls(e,t){return new Is({type:`literal`,values:Array.isArray(e)?e:[e],...H(t)})}var Rs=R(`ZodTransform`,(e,t)=>{ji.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ht(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(wn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(wn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function zs(e){return new Rs({type:`transform`,transform:e})}var Bs=R(`ZodOptional`,(e,t)=>{Ni.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vs(e){return new Bs({type:`optional`,innerType:e})}var Hs=R(`ZodExactOptional`,(e,t)=>{Pi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Us(e){return new Hs({type:`optional`,innerType:e})}var Ws=R(`ZodNullable`,(e,t)=>{Fi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gs(e){return new Ws({type:`nullable`,innerType:e})}var Ks=R(`ZodDefault`,(e,t)=>{Ii.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qs(e,t){return new Ks({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():on(t)}})}var Js=R(`ZodPrefault`,(e,t)=>{Ri.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ys(e,t){return new Js({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():on(t)}})}var Xs=R(`ZodNonOptional`,(e,t)=>{zi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zs(e,t){return new Xs({type:`nonoptional`,innerType:e,...H(t)})}var Qs=R(`ZodCatch`,(e,t)=>{Vi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $s(e,t){return new Qs({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var ec=R(`ZodPipe`,(e,t)=>{Hi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.in=t.in,e.out=t.out});function tc(e,t){return new ec({type:`pipe`,in:e,out:t})}var nc=R(`ZodReadonly`,(e,t)=>{Wi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rc(e){return new nc({type:`readonly`,innerType:e})}var ic=R(`ZodCustom`,(e,t)=>{Ki.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r)});function ac(e,t={}){return Za(ic,e,t)}function oc(e,t){return Qa(e,t)}var sc=ks({q:Zo().optional(),plane:Fs([`operator`,`user`]).optional(),kind:Fs([`operator`,`user`,`role`,`key`,`invite`]).optional(),id:Zo().optional(),view:Fs([`detail`,`effective`,`create-key`,`grant-role`]).optional()});function cc(e){let t=sc.safeParse(e);return t.success?t.data:{}}function lc(e){let t={};return e.q&&(t.q=e.q),e.plane&&(t.plane=e.plane),e.kind&&(t.kind=e.kind),e.id&&(t.id=e.id),e.view&&(t.view=e.view),t}function uc(e,t,n,r){return{...e,plane:t,kind:n,id:r,view:`detail`}}function dc(e,t={}){let n=t.fetch??globalThis.fetch.bind(globalThis),r=t.retry?.retries??0,i=t.retry?.delay??50,a=t.retry?.backoff??2;return{async call(o,s){let c=!1,l=0,u=i;for(;;)try{let r=await fc(e,o,s,t,n);if(r.status===401&&t.auth?.refresh&&!c){c=!0,await t.auth.refresh();continue}if(r.status>=500){let e=await pc(r);if(e)return e;throw Error(`HTTP ${r.status}`)}return gc(r)}catch(e){if(!_c(e)||l>=r)return{data:null,error:{code:`TransportError`,data:{message:e instanceof Error?e.message:String(e)}}};await vc(u),u*=a,l+=1}}}}async function fc(e,t,n,r,i){let a=r.routes?.[t.replace(`/`,`.`)],{url:o,method:s,body:c}=a?hc(e,a.method,a.path,n):mc(e,t,n),l=new Headers,u=typeof r.headers==`function`?await r.headers():r.headers;if(Array.isArray(u))for(let[e,t]of u)l.set(e,t);else if(u)for(let[e,t]of Object.entries(u))l.set(e,t);c!==void 0&&!l.has(`content-type`)&&l.set(`content-type`,`application/json`);let d=r.auth?await r.auth.getToken():void 0;d&&!l.has(`authorization`)&&l.set(`authorization`,`Bearer ${d}`);let f=r.timeout===void 0?void 0:new AbortController,p=f&&r.timeout!==void 0?setTimeout(()=>f.abort(),r.timeout):void 0;try{return await i(o,{method:s,headers:l,body:c,signal:f?.signal})}finally{p!==void 0&&clearTimeout(p)}}async function pc(e){let t=await e.text();if(!t)return null;let n;try{n=JSON.parse(t)}catch{return null}return typeof n==`object`&&n&&`data`in n&&`error`in n?n:null}function mc(e,t,n){return{url:`${e}/_oke/${t}`,method:`POST`,body:n===void 0?void 0:JSON.stringify(n??{})}}function hc(e,t,n,r){let i=typeof r==`object`&&r?r:{},a=n,o=[],s={};for(let[e,t]of Object.entries(i)){let n=`:${e}`;a.includes(n)?a=a.replaceAll(n,encodeURIComponent(String(t))):s[e]=t}let c=t.toUpperCase(),l;if(c===`GET`||c===`HEAD`)for(let[e,t]of Object.entries(s))t!==void 0&&o.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(t))}`);else(Object.keys(s).length>0||n===a)&&(l=JSON.stringify(Object.keys(s).length>0?s:r??{}));let u=o.length?`?${o.join(`&`)}`:``;return{url:`${e}${a}${u}`,method:c,body:l}}async function gc(e){if(e.status===204)return{data:void 0,error:null};let t=await e.text();if(!t)return e.ok?{data:void 0,error:null}:{data:null,error:{code:`TransportError`,data:{message:`HTTP ${e.status}`,status:e.status}}};let n;try{n=JSON.parse(t)}catch{return{data:null,error:{code:`TransportError`,data:{message:`Invalid JSON (${e.status})`,status:e.status}}}}return typeof n==`object`&&n&&`data`in n&&`error`in n?n:e.ok?{data:n,error:null}:{data:null,error:{code:`TransportError`,data:{message:`HTTP ${e.status}`,status:e.status}}}}function _c(e){return!(!(e instanceof Error)||e.name===`AbortError`)}function vc(e){return new Promise(t=>setTimeout(t,e))}function yc(e,t,n){if(typeof e==`string`)return bc(e,t);let r=typeof t==`string`?t:``,i=typeof t==`string`?n:t;return bc(r,{...i,$routes:i?.$routes??e.$routes})}function bc(e,t={}){let n=e.replace(/\/+$/,``),r=t.routes??xc(t.$routes);return Sc(dc(n,{...t,routes:r}),[])}function xc(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))if(!(!r||typeof r!=`object`))for(let[e,i]of Object.entries(r)){if(!i||typeof i!=`object`)continue;let r=`method`in i?i.method:void 0,a=`path`in i?i.path:void 0;typeof r==`string`&&typeof a==`string`&&(t[`${n}.${e}`]={method:r,path:a})}return Object.keys(t).length>0?t:void 0}function Sc(e,t){return new Proxy(n=>{if(t.length<2)return Promise.resolve({data:null,error:{code:`TransportError`,data:{message:`Incomplete path: api.${t.join(`.`)||`?`}(…)`}}});let r=t[0],i=t.slice(1).join(`.`);return e.call(`${r}/${i}`,n)},{get(n,r,i){if(typeof r==`symbol`)return Reflect.get(n,r,i);if(r!==`then`)return Sc(e,[...t,r])}})}var Cc=null;function wc(e){Cc=e,e?sessionStorage.setItem(`oke_console_at`,e):sessionStorage.removeItem(`oke_console_at`)}function Tc(){Cc=sessionStorage.getItem(`oke_console_at`)}var Z=yc(globalThis.location===void 0?`http://127.0.0.1:6533`:globalThis.location.origin,{headers:()=>Cc?{Authorization:`Bearer ${Cc}`}:{},routes:{"console.setupStatus":{method:`GET`,path:`/console/setup/status`},"console.setupClaim":{method:`POST`,path:`/console/setup/claim`},"console.sessionLogin":{method:`POST`,path:`/console/session/login`},"console.sessionMe":{method:`GET`,path:`/console/session/me`},"console.sessionLogout":{method:`POST`,path:`/console/session/logout`},"console.manifestGet":{method:`GET`,path:`/console/manifest`},"console.runsList":{method:`GET`,path:`/console/runs`},"console.actionPing":{method:`POST`,path:`/console/action/ping`},"console.structuralPropose":{method:`POST`,path:`/console/structural/propose`},"console.flowsIdentities":{method:`GET`,path:`/console/flows/identities`},"console.flowsInvoke":{method:`POST`,path:`/console/flows/invoke`},"console.tracesReplay":{method:`POST`,path:`/console/traces/replay`},"console.signalsList":{method:`GET`,path:`/console/signals`},"console.signalsReplay":{method:`POST`,path:`/console/signals/replay`},"console.signalsDryRunReplay":{method:`POST`,path:`/console/signals/dry-run-replay`},"console.signalsDiscard":{method:`POST`,path:`/console/signals/discard`},"console.storeList":{method:`GET`,path:`/console/store`},"console.storeQuery":{method:`POST`,path:`/console/store/query`},"console.storeReveal":{method:`POST`,path:`/console/store/reveal`},"console.storeEdit":{method:`POST`,path:`/console/store/edit`},"console.storeDelete":{method:`POST`,path:`/console/store/delete`},"console.storePurgeCache":{method:`POST`,path:`/console/store/purge-cache`},"console.storeSql":{method:`POST`,path:`/console/store/sql`},"console.storePreview":{method:`POST`,path:`/console/store/preview`},"console.vaultList":{method:`GET`,path:`/console/vault`},"console.vaultSet":{method:`POST`,path:`/console/vault/set`},"console.vaultRotate":{method:`POST`,path:`/console/vault/rotate`},"console.aiList":{method:`GET`,path:`/console/ai`},"console.clockList":{method:`GET`,path:`/console/clock`},"console.clockRunNow":{method:`POST`,path:`/console/clock/run-now`},"console.clockPause":{method:`POST`,path:`/console/clock/pause`},"console.clockEditSchedule":{method:`POST`,path:`/console/clock/edit-schedule`},"console.clockWakeEarly":{method:`POST`,path:`/console/clock/wake-early`},"console.channelsList":{method:`GET`,path:`/console/channels`},"console.channelPreview":{method:`POST`,path:`/console/channels/preview`},"console.channelVerifyAuth":{method:`POST`,path:`/console/channels/verify-auth`},"console.channelReveal":{method:`POST`,path:`/console/channels/reveal`},"console.channelSendTest":{method:`POST`,path:`/console/channels/send-test`},"console.gatesList":{method:`GET`,path:`/console/gates`},"console.gatesSimulate":{method:`POST`,path:`/console/gates/simulate`},"console.gatesPowers":{method:`POST`,path:`/console/gates/powers`},"console.accessList":{method:`GET`,path:`/console/access`},"console.accessEffective":{method:`POST`,path:`/console/access/effective`},"console.accessKeyBlast":{method:`POST`,path:`/console/access/key-blast`},"console.accessCreateKey":{method:`POST`,path:`/console/access/keys`},"console.accessRevokeKey":{method:`POST`,path:`/console/access/keys/revoke`},"console.accessRotateKey":{method:`POST`,path:`/console/access/keys/rotate`},"console.accessSetRoleGrants":{method:`POST`,path:`/console/access/roles/grants`},"console.diffList":{method:`GET`,path:`/console/diff`},"console.pluginsList":{method:`GET`,path:`/console/plugins`}}}),Ec={async setupStatus(){return Z.console.setupStatus({})},async setupClaim(e){return Z.console.setupClaim(e)},async sessionLogin(e){return Z.console.sessionLogin(e)},async sessionMe(){return Z.console.sessionMe({})},async actionPing(e){return Z.console.actionPing({note:e})},async runsList(){return Z.console.runsList({})},async manifestGet(){return Z.console.manifestGet({})},async flowsIdentities(){return Z.console.flowsIdentities({})},async flowsInvoke(e){return Z.console.flowsInvoke(e)},async tracesReplay(e){return Z.console.tracesReplay(e)},async signalsList(){return Z.console.signalsList({})},async signalsReplay(e){return Z.console.signalsReplay(e)},async signalsDryRunReplay(e){return Z.console.signalsDryRunReplay(e)},async signalsDiscard(e){return Z.console.signalsDiscard(e)},async storeList(){return Z.console.storeList({})},async storeQuery(e){return Z.console.storeQuery(e)},async storeReveal(e){return Z.console.storeReveal(e)},async storeEdit(e){return Z.console.storeEdit(e)},async storeDelete(e){return Z.console.storeDelete(e)},async storePurgeCache(e){return Z.console.storePurgeCache(e)},async storeSql(e){return Z.console.storeSql(e)},async storePreview(e){return Z.console.storePreview(e)},async vaultList(){return Z.console.vaultList({})},async vaultSet(e){return Z.console.vaultSet(e)},async vaultRotate(e){return Z.console.vaultRotate(e)},async aiList(){return Z.console.aiList({})},async clockList(){return Z.console.clockList({})},async clockRunNow(e){return Z.console.clockRunNow(e)},async clockPause(e){return Z.console.clockPause(e)},async clockEditSchedule(e){return Z.console.clockEditSchedule(e)},async clockWakeEarly(e){return Z.console.clockWakeEarly(e)},async channelsList(){return Z.console.channelsList({})},async channelPreview(e){return Z.console.channelPreview(e)},async channelVerifyAuth(e){return Z.console.channelVerifyAuth(e)},async channelReveal(e){return Z.console.channelReveal(e)},async channelSendTest(e){return Z.console.channelSendTest(e)},async gatesList(){return Z.console.gatesList({})},async gatesSimulate(e){return Z.console.gatesSimulate(e)},async gatesPowers(e){return Z.console.gatesPowers(e)},async accessList(){return Z.console.accessList({})},async accessEffective(e){return Z.console.accessEffective(e)},async accessKeyBlast(e){return Z.console.accessKeyBlast(e)},async accessCreateKey(e){return Z.console.accessCreateKey(e)},async accessRevokeKey(e){return Z.console.accessRevokeKey(e)},async accessRotateKey(e){return Z.console.accessRotateKey(e)},async accessSetRoleGrants(e){return Z.console.accessSetRoleGrants(e)},async diffList(){return Z.console.diffList({})},async pluginsList(){return Z.console.pluginsList({})}};function Dc(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Dc(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Oc(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Dc(e))&&(r&&(r+=` `),r+=t);return r}function kc(){return typeof window<`u`}function Ac(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function jc(e){return kc()?e instanceof Element||e instanceof Ac(e).Element:!1}function Mc(e){return kc()?e instanceof HTMLElement||e instanceof Ac(e).HTMLElement:!1}var Nc={...I},Pc={};function Fc(e,t){let n=I.useRef(Pc);return n.current===Pc&&(n.current=e(t)),n}var Ic=Nc.useInsertionEffect,Lc=Ic&&Ic!==Nc.useLayoutEffect?Ic:e=>e();function Rc(e){let t=Fc(zc).current;return t.next=e,Lc(t.effect),t.trampoline}function zc(){let e={next:void 0,callback:Bc,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Bc(){}var Vc=typeof document<`u`?I.useLayoutEffect:()=>{};function Hc(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}var Uc={};function Wc(e,t,n,r,i){if(!n&&!r&&!i&&!e)return Kc(t);let a=Kc(e);return t&&(a=qc(a,t)),n&&(a=qc(a,n)),r&&(a=qc(a,r)),i&&(a=qc(a,i)),a}function Gc(e){if(e.length===0)return Uc;if(e.length===1)return Kc(e[0]);let t=Kc(e[0]);for(let n=1;n<e.length;n+=1)t=qc(t,e[n]);return t}function Kc(e){return Zc(e)?{...Qc(e,Uc)}:Jc(e)}function qc(e,t){return Zc(t)?Qc(t,e):Yc(e,t)}function Jc(e){let t={...e};for(let e in t){let n=t[e];Xc(e,n)&&(t[e]=el(n))}return t}function Yc(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Hc(e.style,r);break;case`className`:e[n]=nl(e.className,r);break;default:e[n]=Xc(n,r)?$c(e[n],r):r}}return e}function Xc(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Zc(e){return typeof e==`function`}function Qc(e,t){return Zc(e)?e(t):e??Uc}function $c(e,t){return t?e?(...n)=>{let r=n[0];if(rl(r)){let i=r;tl(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:el(t):e}function el(e){return e&&((...t)=>{let n=t[0];return rl(n)&&tl(n),e(...t)})}function tl(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function nl(e,t){return t?e?t+` `+e:t:e}function rl(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function il(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var al=il(`https://base-ui.com/production-error`,`Base UI`),ol=I.createContext(void 0);function sl(e=!1){let t=I.useContext(ol);if(t===void 0&&!e)throw Error(al(16));return t}function cl(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:I.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function ll(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=I.useRef(null),s=sl(!0),c=a??s!==void 0,{props:l}=cl({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=I.useCallback(()=>{let e=o.current;ul(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return Vc(u,[u]),{getButtonProps:I.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return Wc({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(tl(e),o?.(e),e.baseUIHandlerPrevented))return;let r=e.target===e.currentTarget,a=e.currentTarget,s=ul(a),l=!i&&dl(a),u=r&&(i?s:!l),d=e.key===`Enter`,f=e.key===` `,p=a.getAttribute(`role`),m=p?.startsWith(`menuitem`)||p===`option`||p===`gridcell`;if(r&&c&&f){if(e.defaultPrevented&&m)return;e.preventDefault(),l||i&&s?(a.click(),e.preventBaseUIHandler()):u&&(n?.(e),e.preventBaseUIHandler());return}u&&(!i&&(f||d)&&e.preventDefault(),!i&&d&&n?.(e))},onKeyUp(e){if(!t){if(tl(e),a?.(e),e.target===e.currentTarget&&i&&c&&ul(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&e.key===` `&&n?.(e)}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:Rc(e=>{o.current=e,u()})}}function ul(e){return Mc(e)&&e.tagName===`BUTTON`}function dl(e){return!!(e?.tagName===`A`&&e?.href)}function fl(e,t,n,r){let i=Fc(ml).current;return hl(i,e,t,n,r)&&_l(i,[e,t,n,r]),i.callback}function pl(e){let t=Fc(ml).current;return gl(t,e)&&_l(t,e),t.callback}function ml(){return{callback:null,cleanup:null,refs:[]}}function hl(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function gl(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function _l(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}var vl=19;function yl(e){return vl>=e}function bl(e){if(!I.isValidElement(e))return null;let t=e,n=t.props;return(yl(19)?n?.ref:t.ref)??null}function Q(){}Object.freeze([]);var xl=Object.freeze({});function Sl(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Cl(e,t){return typeof e==`function`?e(t):e}function wl(e,t){return typeof e==`function`?e(t):e}function Tl(e,t,n={}){let r=t.render,i=El(t,n);return n.enabled===!1?null:kl(e,r,i,n.state??xl)}function El(e,t={}){let{className:n,style:r,render:i}=e,{state:a=xl,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?Cl(n,a):void 0,d=l?wl(r,a):void 0,f=l?Sl(a,c):xl,p=l&&s?Dl(s):void 0,m=l?Hc(f,p)??{}:xl;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?pl([m.ref,bl(i),...o]):fl(m.ref,bl(i),o):fl(null,null)),l?(u!==void 0&&(m.className=nl(m.className,u)),d!==void 0&&(m.style=Hc(m.style,d)),m):xl}function Dl(e){return Array.isArray(e)?Gc(e):Wc(void 0,e)}var Ol=Symbol.for(`react.lazy`);function kl(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Wc(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===Ol&&(i=I.Children.toArray(t)[0]),I.cloneElement(i,e)}if(e&&typeof e==`string`)return Al(e,n);throw Error(al(8))}function Al(e,t){return e===`button`?(0,I.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,I.createElement)(`img`,{alt:``,...t,key:t.key}):I.createElement(e,t)}var jl=I.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=ll({disabled:i,focusableWhenDisabled:a,native:o});return Tl(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})}),Ml=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Nl={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Pl={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Fl={disabled:!1,...Pl},Il={valid(e){return e===null?null:e?{[Ml.valid]:``}:{[Ml.invalid]:``}}},Ll={invalid:void 0,name:void 0,validityData:{state:Nl,errors:[],error:``,value:``,initialValue:null},setValidityData:Q,disabled:void 0,touched:Pl.touched,setTouched:Q,dirty:Pl.dirty,setDirty:Q,filled:Pl.filled,setFilled:Q,focused:Pl.focused,setFocused:Q,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:Fl,markedDirtyRef:{current:!1},registerFieldControl:Q,validation:{getValidationProps:(e,t=xl)=>t,inputRef:{current:null},registerInput:Q,commit:async()=>{},change:Q}},Rl=I.createContext(Ll);function zl(e=!0){let t=I.useContext(Rl);if(t.setValidityData===Q&&!e)throw Error(al(28));return t}var Bl=I.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Q,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function Vl(){return I.useContext(Bl)}var Hl=0;function Ul(e,t=`mui`){let[n,r]=I.useState(e),i=e||n;return I.useEffect(()=>{n??(Hl+=1,r(`${t}-${Hl}`))},[n,t]),i}var Wl=Nc.useId;function Gl(e,t){if(Wl!==void 0){let n=Wl();return e??(t?`${t}-${n}`:n)}return Ul(e,t)}function Kl(e){return Gl(e,`base-ui`)}var ql=I.createContext({controlId:void 0,registerControlId:Q,labelId:void 0,setLabelId:Q,messageIds:[],setMessageIds:Q,getDescriptionProps:e=>e});function Jl(){return I.useContext(ql)}function Yl(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=Jl(),o=Kl(t),s=n?i:void 0,c=Fc(()=>Symbol(`labelable-control`)),l=I.useRef(!1),u=I.useRef(t!=null),d=Rc(()=>{!l.current||a===Q||(l.current=!1,a(c.current,void 0))});return Vc(()=>{if(a===Q)return;let e;if(n){let n=r?.current;e=jc(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),I.useEffect(()=>d,[d]),i??o}function Xl(e){return e?.ownerDocument||document}function Zl(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Ql({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=I.useRef(e!==void 0),[a,o]=I.useState(t);return[i?e:a,I.useCallback(e=>{i||o(e)},[])]}function $l(e,t,n,r,i=!0,a){let{registerFieldControl:o}=zl(),s=I.useRef(null);s.current||=Symbol(),Vc(()=>{let c=s.current;if(!(!c||!i))return o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}),()=>{o(c,void 0)}},[e,i,r,t,a,o,n])}var eu=`none`;function tu(e,t,n,r){let i=!1,a=!1,o=r??xl;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}var nu=I.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFocused:y,setFilled:b,validationMode:x,validation:S}=zl(),{clearErrors:C}=Vl(),w=h||s,T=m??a,E={...p,disabled:w},{labelId:D}=Jl(),O=Yl({id:i});Vc(()=>{let e=o!=null;S.inputRef.current?.value||e&&o!==``?b(!0):e&&o===``&&b(!1)},[S.inputRef,b,o]);let k=I.useRef(null);Vc(()=>{u&&k.current===Zl(Xl(k.current))&&y(!0)},[u,y]);let[A]=Ql({controlled:o,default:l,name:`FieldControl`,state:`value`}),ee=o!==void 0,j=ee?A:void 0,M=Rc(()=>S.inputRef.current?.value);return $l(S.inputRef,O,j,M,!w,a),Tl(`input`,e,{ref:[t,k],state:E,props:[{id:O,disabled:w,name:T,ref:S.inputRef,"aria-labelledby":D,autoFocus:u,...ee?{value:j}:{defaultValue:l},onChange(e){let t=e.currentTarget.value;c?.(t,tu(eu,e.nativeEvent)),_(t!==v.initialValue),b(t!==``),e.nativeEvent.defaultPrevented||(C(T),S.change(t))},onFocus(){y(!0)},onBlur(e){g(!0),y(!1),x===`onBlur`&&S.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(g(!0),S.commit(e.currentTarget.value))}},f,e=>S.getValidationProps(w,e)],stateAttributesMapping:Il})}),ru=I.forwardRef(function(e,t){return(0,L.jsx)(nu,{ref:t,...e})});function $({variant:e=`primary`,className:t,...n}){return(0,L.jsx)(jl,{className:Oc(`inline-flex min-h-8 min-w-8 items-center justify-center px-3 text-sm font-medium transition-opacity duration-150`,`disabled:opacity-40`,e===`primary`&&`bg-[var(--oke-accent)] text-black`,e===`ghost`&&`bg-transparent text-[var(--oke-fg)] border border-[var(--oke-line)]`,e===`danger`&&`bg-[var(--oke-danger)] text-white`,e===`external`&&`bg-[var(--oke-external)] text-black`,t),...n})}function iu({className:e,...t}){return(0,L.jsx)(ru,{className:Oc(`min-h-8 w-full border border-[var(--oke-line)] bg-transparent px-3 text-sm text-[var(--oke-fg)]`,`placeholder:text-[var(--oke-muted)]`,e),...t})}function au({label:e,hint:t,error:n,children:r}){return(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:e}),r,n?(0,L.jsx)(`span`,{role:`alert`,className:`text-xs text-[var(--oke-danger)]`,children:n}):t?(0,L.jsx)(`span`,{className:`text-xs text-[var(--oke-muted)]`,children:t}):null]})}function ou({count:e,onFlush:t}){return e<=0?null:(0,L.jsxs)(`button`,{type:`button`,className:`min-h-8 rounded-sm border border-[var(--oke-line)] px-3 text-xs text-[var(--oke-fg)]`,onClick:t,children:[e,` new`]})}var su=15e3;function cu(e,t={production:!0}){return e===`external`&&t.production?{kind:`typed`,phrase:`INVOKE`,requireReason:!0}:{kind:`undo`,windowMs:su}}function lu(e){let t={};return e.typed.trim()!==e.phrase&&(t.typed=`Type ${e.phrase} to confirm`),e.reason.trim().length<3&&(t.reason=`Reason is required (min 3 characters)`),Object.keys(t).length>0?t:null}function uu(e={production:!0}){return{kind:`typed`,phrase:`REVOKE`,requireReason:!0}}function du(e={production:!0}){return{kind:`typed`,phrase:`ROTATE`,requireReason:!0}}function fu(e){return e.acknowledged===!0}var pu=`I have copied this secret and understand it will not be shown again`,mu=`This secret is shown exactly once. Store it now — dismissal is permanent.`;function hu(e){return{volume:e.callVolume===0?`No recorded calls from Runs`:`${e.callVolume} call${e.callVolume===1?``:`s`} in Runs`,lastUsed:e.lastUsedAt==null?`Never used`:`Last used ${new Date(e.lastUsedAt).toISOString()}`,sources:e.sourceAddresses.length===0?`No source addresses recorded`:`Source addresses: ${e.sourceAddresses.join(`, `)}`,residual:e.residualAccessNote,warn:e.callVolume>0}}function gu(e){let t=[];return e.unusedKeys.length>0&&t.push({code:`unused-keys`,message:`${e.unusedKeys.length} key${e.unusedKeys.length===1?``:`s`} unused 90d+`}),e.neverSignedInOperators.length>0&&t.push({code:`never-signed-in`,message:`${e.neverSignedInOperators.length} operator${e.neverSignedInOperators.length===1?``:`s`} never signed in`}),e.expiredInvitations.length>0&&t.push({code:`expired-invites`,message:`${e.expiredInvitations.length} expired invitation${e.expiredInvitations.length===1?``:`s`}`}),t}function _u(e){return e.scopes.map(e=>({scope:e.scope,sources:e.sources.map(e=>e.kind===`direct`?`direct (${e.name})`:`role ${e.name}`).join(`, `)}))}function vu(){let e=Rt({from:`/access`}),t=zt({from:`/access`}),n=je(),r=e.plane??`operator`,[i,a]=(0,I.useState)([]),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(null),v=e=>{t({search:lc(e),replace:!0})},y=Ke({queryKey:[`console.access.list`],queryFn:async()=>{let e=await Ec.accessList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}).data,b=r===`operator`?y?.operatorPlane:y?.userPlane,x=b?.grantableScopes??[],S=y?.hygiene,C=(0,I.useMemo)(()=>S?gu(S):[],[S]),w=b?.keys.find(t=>e.kind===`key`&&t.id===e.id),T=b?.roles.find(t=>e.kind===`role`&&t.id===e.id),E=b?.operators?.find(t=>e.kind===`operator`&&t.id===e.id),D=b?.users?.find(t=>e.kind===`user`&&t.id===e.id),O=(e.q??``).toLowerCase(),k=e=>O.length===0||e.toLowerCase().includes(O),A=qe({mutationFn:async()=>{if(!o.trim())throw Error(`Name required`);let e=await Ec.accessCreateKey({plane:r,name:o.trim(),scopes:i});if(e.error)throw Error(e.error.code);return e.data},onSuccess:e=>{p({secret:e.secret,keyId:e.key.id,keyName:e.key.name,acknowledged:!1}),s(``),a([]),n.invalidateQueries({queryKey:[`console.access.list`]})}}),ee=qe({mutationFn:async e=>{let t=await Ec.accessKeyBlast({keyId:e});if(t.error)throw Error(t.error.code);return t.data},onSuccess:h}),j=qe({mutationFn:async()=>{if(!w)throw Error(`Select a key`);let e=uu();if(e.kind===`typed`){let t=lu({typed:c,reason:u,phrase:e.phrase});if(t)throw Error(t.typed??t.reason??`confirm`)}let t=await Ec.accessRevokeKey({keyId:w.id,confirmation:c,reason:u});if(t.error)throw Error(t.error.code);return t.data},onSuccess:e=>{h(e.blastRadius),l(``),d(``),n.invalidateQueries({queryKey:[`console.access.list`]})}}),M=qe({mutationFn:async()=>{if(!w)throw Error(`Select a key`);let e=du();if(e.kind===`typed`){let t=lu({typed:c,reason:u,phrase:e.phrase});if(t)throw Error(t.typed??t.reason??`confirm`)}let t=await Ec.accessRotateKey({keyId:w.id,confirmation:c,reason:u});if(t.error)throw Error(t.error.code);return t.data},onSuccess:e=>{h(e.blastRadius),p({secret:e.secret,keyId:e.key.id,keyName:e.key.name,acknowledged:!1}),l(``),d(``),n.invalidateQueries({queryKey:[`console.access.list`]})}}),N=qe({mutationFn:async()=>{let t=e.kind===`invite`||!e.kind||!e.id?null:e.kind;if(!t||!e.id)throw Error(`Select a principal`);let n=await Ec.accessEffective({kind:t,id:e.id});if(n.error)throw Error(n.error.code);return n.data},onSuccess:_}),te=qe({mutationFn:async()=>{if(!T)throw Error(`Select a role`);let e=await Ec.accessSetRoleGrants({roleId:T.id,scopes:i});if(e.error)throw Error(e.error.code);return e.data},onSuccess:()=>{n.invalidateQueries({queryKey:[`console.access.list`]})}}),P=m?hu(m):null,ne=g?_u(g):[],F=e=>{a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,L.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-3 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-lg font-medium text-[var(--oke-fg)]`,children:`Access`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Identities, roles, API keys — planes never merge`})]}),(0,L.jsxs)(`div`,{role:`group`,"aria-label":`Plane`,className:`flex gap-1`,children:[(0,L.jsx)($,{type:`button`,variant:r===`operator`?`primary`:`ghost`,"aria-pressed":r===`operator`,onClick:()=>v({...e,plane:`operator`,kind:void 0,id:void 0,view:void 0}),children:`Operator plane`}),(0,L.jsx)($,{type:`button`,variant:r===`user`?`primary`:`ghost`,"aria-pressed":r===`user`,onClick:()=>v({...e,plane:`user`,kind:void 0,id:void 0,view:void 0}),children:`User plane`})]}),(0,L.jsxs)(`label`,{className:`ml-auto flex min-w-[12rem] flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter access`}),(0,L.jsx)(iu,{"aria-label":`Filter access`,value:e.q??``,onChange:t=>v({...e,q:t.currentTarget.value||void 0})})]})]}),C.length>0?(0,L.jsxs)(`section`,{"aria-label":`Access hygiene`,className:`border-b border-[var(--oke-line)] px-4 py-2`,role:`status`,children:[(0,L.jsx)(`h2`,{className:`sr-only`,children:`Hygiene`}),(0,L.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-[var(--oke-warn,var(--oke-muted))]`,children:C.map(e=>(0,L.jsx)(`li`,{children:e.message},e.code))})]}):null,(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,L.jsxs)(`section`,{"aria-label":`${r} plane list`,className:`w-80 shrink-0 overflow-y-auto border-r border-[var(--oke-line)]`,children:[(0,L.jsx)(`h2`,{className:`px-4 py-2 text-sm font-medium`,children:r===`operator`?`Operator plane`:`User plane`}),b?.operators?(0,L.jsx)(yu,{label:`Operators`,children:b.operators.filter(e=>k(`${e.name} ${e.email}`)).map(t=>(0,L.jsxs)(bu,{selected:e.kind===`operator`&&e.id===t.id,onClick:()=>v(uc(e,`operator`,`operator`,t.id)),children:[t.name,t.neverSignedIn?(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:` · never`}):null]},t.id))}):null,b?.users?(0,L.jsx)(yu,{label:`Users`,children:b.users.filter(e=>k(`${e.name} ${e.email}`)).map(t=>(0,L.jsx)(bu,{selected:e.kind===`user`&&e.id===t.id,onClick:()=>v(uc(e,`user`,`user`,t.id)),children:t.name},t.id))}):null,(0,L.jsx)(yu,{label:`Roles`,children:(b?.roles??[]).filter(e=>k(e.name)).map(t=>(0,L.jsx)(bu,{selected:e.kind===`role`&&e.id===t.id,onClick:()=>{a([...t.scopes]),v(uc(e,r,`role`,t.id))},children:t.name},t.id))}),(0,L.jsx)(yu,{label:`API keys`,children:(b?.keys??[]).filter(e=>k(e.name)).map(t=>(0,L.jsxs)(bu,{selected:e.kind===`key`&&e.id===t.id,onClick:()=>{h(null),v(uc(e,r,`key`,t.id)),ee.mutate(t.id)},children:[t.name,t.unused90d?(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:` · 90d+`}):null,t.revokedAt==null?null:(0,L.jsx)(`span`,{className:`text-[var(--oke-danger)]`,children:` · revoked`})]},t.id))}),b?.invites&&b.invites.length>0?(0,L.jsx)(yu,{label:`Invitations`,children:b.invites.filter(e=>k(e.email)).map(t=>(0,L.jsxs)(bu,{selected:e.kind===`invite`&&e.id===t.id,onClick:()=>v(uc(e,`operator`,`invite`,t.id)),children:[t.email,t.expired?(0,L.jsx)(`span`,{className:`text-[var(--oke-danger)]`,children:` · expired`}):null]},t.id))}):null,(0,L.jsx)(`div`,{className:`border-t border-[var(--oke-line)] p-3`,children:(0,L.jsx)($,{type:`button`,variant:`ghost`,className:`w-full`,onClick:()=>{a([]),s(``),v({...e,plane:r,view:`create-key`,kind:void 0,id:void 0})},children:`Create API key`})})]}),(0,L.jsxs)(`section`,{"aria-label":`Access detail`,className:`min-w-0 flex-1 overflow-y-auto px-4 py-3`,"aria-live":`polite`,children:[e.view===`create-key`?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:`Create API key`}),(0,L.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:[`Only scopes you hold on the `,r,` plane are shown — impossibility taught by absence. No preview.`]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Name`}),(0,L.jsx)(iu,{"aria-label":`API key name`,value:o,onChange:e=>s(e.currentTarget.value)})]}),(0,L.jsx)(xu,{grantable:x,selected:i,onToggle:F}),(0,L.jsx)($,{type:`button`,disabled:A.isPending||!o.trim(),onClick:()=>A.mutate(),children:`Create key`}),A.error?(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:A.error.message}):null]}):w?(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:w.name}),(0,L.jsx)(`p`,{className:`font-mono text-sm text-[var(--oke-muted)]`,children:w.id}),(0,L.jsx)(`ul`,{className:`mt-2 font-mono text-sm`,children:w.scopes.map(e=>(0,L.jsx)(`li`,{children:e},e))})]}),(0,L.jsxs)(`section`,{"aria-label":`Revocation blast radius`,className:`space-y-1`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Revocation blast radius`}),P?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-sm`,role:P.warn?`alert`:`status`,children:P.volume}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:P.lastUsed}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:P.sources}),(0,L.jsx)(`p`,{className:`text-sm`,role:`status`,children:P.residual})]}):(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Loading…`})]}),w.revokedAt==null?(0,L.jsxs)(`section`,{"aria-label":`Revoke or rotate`,className:`space-y-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Revoke / rotate`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Irreversible. Type the phrase and a reason. No dry-run.`}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Type REVOKE or ROTATE`}),(0,L.jsx)(iu,{"aria-label":`Type REVOKE or ROTATE to confirm`,value:c,onChange:e=>l(e.currentTarget.value),autoComplete:`off`})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Reason`}),(0,L.jsx)(iu,{"aria-label":`Reason`,value:u,onChange:e=>d(e.currentTarget.value)})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)($,{type:`button`,variant:`danger`,disabled:j.isPending,onClick:()=>j.mutate(),children:`Revoke key`}),(0,L.jsx)($,{type:`button`,variant:`danger`,disabled:M.isPending,onClick:()=>M.mutate(),children:`Rotate key`})]}),j.error||M.error?(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:(j.error??M.error).message}):null]}):(0,L.jsxs)(`p`,{role:`status`,className:`text-sm text-[var(--oke-danger)]`,children:[`Revoked `,w.revokedAt?new Date(w.revokedAt).toISOString():``]}),(0,L.jsx)($,{type:`button`,variant:`ghost`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):T?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:T.name}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:T.description}),(0,L.jsx)(xu,{grantable:x,selected:i,onToggle:F}),(0,L.jsx)($,{type:`button`,disabled:te.isPending,onClick:()=>te.mutate(),children:`Save role grants`}),(0,L.jsx)($,{type:`button`,variant:`ghost`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):E||D?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:E?.name??D?.name}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:E?.email??D?.email}),(0,L.jsx)($,{type:`button`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):e.view===`effective`&&ne.length>0?(0,L.jsx)(Su,{provenance:ne}):(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Choose an identity, role, or key. Planes stay separate; scopes you cannot grant do not appear.`}),e.view===`effective`&&ne.length>0&&(w||T||E||D)?(0,L.jsx)(`div`,{className:`mt-6`,children:(0,L.jsx)(Su,{provenance:ne})}):null]})]}),f?(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,role:`presentation`,children:(0,L.jsxs)(`section`,{"aria-label":`New API key secret`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`once-secret-title`,className:`max-w-lg space-y-4 border border-[var(--oke-line)] bg-[var(--oke-bg)] p-6`,children:[(0,L.jsx)(`h2`,{id:`once-secret-title`,className:`text-lg font-medium`,children:`New API key secret`}),(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:mu}),(0,L.jsx)(`p`,{className:`break-all font-mono text-sm`,children:f.secret}),(0,L.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:f.acknowledged,onChange:e=>p({...f,acknowledged:e.currentTarget.checked})}),(0,L.jsx)(`span`,{children:pu})]}),(0,L.jsx)($,{type:`button`,disabled:!fu(f),onClick:()=>p(null),children:`Dismiss secret`})]})}):null]})}function yu({label:e,children:t}){return(0,L.jsxs)(`section`,{"aria-label":e,className:`border-t border-[var(--oke-line)]`,children:[(0,L.jsx)(`h3`,{className:`px-4 py-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:e}),(0,L.jsx)(`ul`,{className:`pb-2`,children:t})]})}function bu({selected:e,onClick:t,children:n}){return(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:Oc(`flex min-h-8 w-full items-center px-4 text-left text-sm`,e?`bg-[var(--oke-accent)]/15 text-[var(--oke-fg)]`:`text-[var(--oke-fg)]`),children:n})})}function xu({grantable:e,selected:t,onToggle:n}){return(0,L.jsxs)(`section`,{"aria-label":`Grantable scopes`,className:`space-y-2`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Grantable scopes`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Only scopes you hold appear`}),e.length===0?(0,L.jsx)(`p`,{role:`status`,className:`text-sm text-[var(--oke-muted)]`,children:`No grantable scopes on this plane`}):(0,L.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`label`,{className:`flex min-h-8 items-center gap-2 font-mono text-sm`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:t.includes(e),onChange:()=>n(e)}),e]})},e))})]})}function Su({provenance:e}){return(0,L.jsxs)(`section`,{"aria-label":`Effective permissions`,children:[(0,L.jsx)(`h2`,{className:`mb-2 text-lg font-medium`,children:`Effective permissions`}),(0,L.jsx)(`p`,{className:`mb-3 text-sm text-[var(--oke-muted)]`,children:`Every permission with provenance — inverse of the Gates simulator`}),(0,L.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,L.jsx)(`caption`,{className:`sr-only`,children:`Effective permissions with provenance`}),(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-[var(--oke-line)]`,children:[(0,L.jsx)(`th`,{scope:`col`,className:`py-2 pr-4 font-medium`,children:`Scope`}),(0,L.jsx)(`th`,{scope:`col`,className:`py-2 font-medium`,children:`Granted by`})]})}),(0,L.jsx)(`tbody`,{children:e.map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-[var(--oke-line)]`,children:[(0,L.jsx)(`td`,{className:`py-2 pr-4 font-mono`,children:e.scope}),(0,L.jsx)(`td`,{className:`py-2 text-[var(--oke-muted)]`,children:e.sources})]},e.scope))})]})]})}var Cu=t({default:()=>vu});export{Me as $,Tt as A,bt as B,zt as C,Pt as D,It as E,xt as F,st as G,ht as H,ft as I,Ze as J,Je as K,St as L,yt as M,Ct as N,Dt as O,pt as P,Ke as Q,tt as R,Ta as S,Lt as T,$e as U,mt as V,ot as W,Xe as X,Ye as Y,qe as Z,xs as _,r as _t,lu as a,re as at,Zo as b,iu as c,v as ct,Ec as d,h as dt,je as et,Tc as f,l as ft,Fs as g,i as gt,_s as h,A as ht,cu as i,fe as it,wt as j,Et as k,ou as l,_ as lt,cc as m,p as mt,gu as n,De as nt,$ as o,F as ot,wc as p,y as pt,Qe as q,su as r,Ce as rt,au as s,u as st,Cu as t,ke as tt,Oc as u,g as ut,Ls as v,Rt as w,js as x,ks as y,it as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,r as t}from"./rolldown-runtime-B0Z9INg1.js";import{C as n,Q as r,S as i,b as a,d as o,h as s,nt as c,tt as l,u,w as d,y as f}from"./panel-access-BGv45snf.js";function p(e){return i(s,e)}var m=f({prompt:a().optional(),version:p().int().optional(),agent:a().optional(),run:a().optional(),q:a().optional()});function h(e){let t=m.safeParse(e);return t.success?t.data:{}}function g(e){let t={};return e.prompt&&(t.prompt=e.prompt),e.version!==void 0&&(t.version=e.version),e.agent&&(t.agent=e.agent),e.run&&(t.run=e.run),e.q&&(t.q=e.q),t}function _(e,t,n){return{...e,prompt:t,version:n,agent:void 0,run:void 0}}function v(e,t,n){return{...e,agent:t,run:n}}function y(e){return`/manifest-diff?${new URLSearchParams({path:e}).toString()}`}function b(e,t){if(e.prompt!==t.prompt)throw Error(`promotionDecision: prompt mismatch (${e.prompt} vs ${t.prompt})`);let n={fromEvalMean:e.evalScore.mean,toEvalMean:t.evalScore.mean,fromSchemaInvalidRate:e.schemaInvalidRate,toSchemaInvalidRate:t.schemaInvalidRate,fromOverBudgetRate:e.overBudgetRate,toOverBudgetRate:t.overBudgetRate,fromP95Cost:e.cost.p95,toP95Cost:t.cost.p95,budgetMaxCostPerCall:t.budgetMaxCostPerCall??e.budgetMaxCostPerCall},r=[];t.schemaInvalidRate>e.schemaInvalidRate+1e-12&&r.push(`schema_validity`);let i=n.budgetMaxCostPerCall;(t.overBudgetRate>e.overBudgetRate+1e-12||i!==null&&t.cost.p95>i&&e.cost.p95<=i)&&r.push(`budget`);let a=t.evalScore.mean>e.evalScore.mean+1e-12;return r.length>0?{allowed:!1,from:e,to:t,blockers:r,evalImproved:a,numbers:n}:{allowed:!0,from:e,to:t,evalImproved:a,numbers:n}}function x(e){let t=[],n=e.numbers;if(e.blockers.includes(`schema_validity`)&&t.push(`schema-invalid ${(n.fromSchemaInvalidRate*100).toFixed(1)}% → ${(n.toSchemaInvalidRate*100).toFixed(1)}%`),e.blockers.includes(`budget`)){let e=n.budgetMaxCostPerCall===null?`budget`:`budget $${n.budgetMaxCostPerCall.toFixed(4)}`;t.push(`over-budget ${(n.fromOverBudgetRate*100).toFixed(1)}% → ${(n.toOverBudgetRate*100).toFixed(1)}% · p95 $${n.fromP95Cost.toFixed(4)} → $${n.toP95Cost.toFixed(4)} (${e})`)}return e.evalImproved&&t.push(`eval mean ${(n.fromEvalMean*100).toFixed(1)}% → ${(n.toEvalMean*100).toFixed(1)}% (improved — still blocked)`),t}function S(e,t){let n=t?.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||(e.model?.toLowerCase().includes(n)??!1)):e}function C(e,t){let n=t?.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||e.tools.some(e=>e.toLowerCase().includes(n))):e}function w(e,t){return e.filter(e=>e.prompt===t).sort((e,t)=>e.version-t.version)}function T(e,t){return e.filter(e=>e.agent===t)}function E(e){return e.filter(e=>e.allowPii)}function D(e){return`${(e*100).toFixed(1)}%`}function O(e){return`$${e.toFixed(4)}`}function k(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${Math.round(e)}ms`}function A(e){return`${(e*100).toFixed(1)}%`}function j(e,t,n,r,i){return`${e}: mean ${i(t)}, p50 ${i(n)}, p95 ${i(r)}`}function M(e){return e.reduce((e,t)=>Math.max(e,t.count),0)}function N(e){return e===`denied`?`DENIED`:`ok`}function P(e){return e.filter(e=>e.overBudgetRate>0).map(e=>({prompt:e.prompt,version:e.version,overBudgetRate:e.overBudgetRate,budgetMaxCostPerCall:e.budgetMaxCostPerCall,p95Cost:e.cost.p95})).sort((e,t)=>t.overBudgetRate-e.overBudgetRate||e.prompt.localeCompare(t.prompt)||t.version-e.version)}var F=e(c(),1),I=l();function L(){let e=d({from:`/ai`}),t=n({from:`/ai`}),i=e=>{t({search:g(e),replace:!0})},a=r({queryKey:[`console.ai.list`],queryFn:async()=>{let e=await o.aiList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}),s=a.data,c=(0,F.useMemo)(()=>S(s?.prompts??[],e.q),[s?.prompts,e.q]),l=(0,F.useMemo)(()=>C(s?.agents??[],e.q),[s?.agents,e.q]),f=e.prompt??c[0]?.name,p=(0,F.useMemo)(()=>f?w(s?.versions??[],f):[],[s?.versions,f]),m=p.find(t=>t.version===e.version)??p[p.length-1],h=p.length>=2?p[p.length-2]:p[0],x=h&&m&&h.version!==m.version?b(h,m):null,D=e.agent??l[0]?.name,k=(0,F.useMemo)(()=>D?T(s?.agentRuns??[],D):[],[s?.agentRuns,D]),A=k.find(t=>t.id===e.run)??k[0],j=E(s?.allowPii??[]),M=c.find(e=>e.name===f);return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,I.jsxs)(`header`,{className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,I.jsx)(`h1`,{className:`text-base font-medium text-[var(--oke-fg)]`,children:`AI`}),(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Distributions per prompt version — cost, latency, eval score. Schema-invalid is its own class.`}),(0,I.jsxs)(`label`,{className:`mt-2 flex max-w-sm flex-col gap-1 text-sm`,children:[(0,I.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter`}),(0,I.jsx)(`input`,{"aria-label":`Filter prompts and agents`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:e.q??``,onChange:t=>i({...e,q:t.target.value||void 0})})]})]}),(0,I.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[14rem_1fr_18rem]`,children:[(0,I.jsxs)(`aside`,{"aria-label":`Prompts and agents`,className:`min-h-0 overflow-y-auto border-b border-[var(--oke-line)] lg:border-b-0 lg:border-r`,children:[(0,I.jsxs)(`section`,{"aria-label":`Prompts`,className:`p-3`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`Prompts`}),(0,I.jsx)(`ul`,{className:`space-y-1`,children:c.map(t=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":t.name===f,className:u(`flex min-h-8 w-full items-center px-2 text-left text-sm`,t.name===f?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:()=>i(_(e,t.name,t.version??0)),children:[t.name,t.version===void 0?null:(0,I.jsxs)(`span`,{className:`ml-1 font-mono text-xs`,children:[`@`,t.version]})]})},t.name))})]}),(0,I.jsxs)(`section`,{"aria-label":`Agents`,className:`p-3`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`Agents`}),(0,I.jsx)(`ul`,{className:`space-y-1`,children:l.map(t=>(0,I.jsx)(`li`,{children:(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t.name===D,className:u(`flex min-h-8 w-full items-center px-2 text-left text-sm`,t.name===D?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:()=>i({...e,agent:t.name,run:void 0}),children:t.name})},t.name))})]})]}),(0,I.jsxs)(`main`,{id:`ai-main`,className:`min-h-0 overflow-y-auto p-4`,children:[a.isLoading?(0,I.jsx)(`p`,{className:`text-[var(--oke-muted)]`,children:`Loading…`}):null,a.isError?(0,I.jsx)(`p`,{role:`alert`,children:`Failed to load AI projection`}):null,m?(0,I.jsx)(R,{metrics:m,versions:p,onSelectVersion:t=>i(_(e,m.prompt,t)),catalogueHref:M?y(M.manifestDiffPath):null,decision:x}):(0,I.jsx)(`p`,{className:`text-[var(--oke-muted)]`,children:`No prompt versions with samples yet.`}),A?(0,I.jsxs)(`section`,{"aria-label":`Agent run trail`,className:`mt-8`,children:[(0,I.jsxs)(`h2`,{className:`mb-2 text-sm font-medium`,children:[`Agent run · `,A.agent]}),(0,I.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:k.map(t=>(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t.id===A.id,className:u(`min-h-8 px-2 text-xs font-mono`,t.id===A.id?`bg-[var(--oke-line)]`:`text-[var(--oke-muted)]`),onClick:()=>i(v(e,t.agent,t.id)),children:t.id},t.id))}),(0,I.jsx)(`ol`,{className:`space-y-3 border-l border-[var(--oke-line)] pl-4`,children:A.trail.map((e,t)=>(0,I.jsxs)(`li`,{className:`text-sm`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:u(`font-mono text-xs tracking-wide`,e.status===`denied`?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),children:N(e.status)}),(0,I.jsx)(`span`,{className:`font-mono`,children:e.tool})]}),e.status===`denied`&&e.denial?(0,I.jsxs)(`p`,{role:`status`,className:`mt-1 text-[var(--oke-muted)]`,children:[`DENIED by gate`,` `,(0,I.jsx)(`span`,{className:`font-mono text-[var(--oke-fg)]`,children:e.denial.gate}),`:`,` `,e.denial.reason]}):null,(0,I.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs text-[var(--oke-muted)]`,children:[e.effects.map(e=>(0,I.jsxs)(`li`,{children:[(0,I.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,e.resource]},`${e.kind}:${e.resource}`)),e.effects.length===0?(0,I.jsx)(`li`,{children:`no declared effects`}):null]})]},`${e.tool}-${t}`))})]}):null,(0,I.jsxs)(`section`,{"aria-label":`Fallback chains`,className:`mt-8`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-sm font-medium`,children:`Fallback chains`}),(s?.fallbackChains.length??0)===0?(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`No multi-model chains recorded.`}):(0,I.jsx)(`ul`,{className:`space-y-2 text-sm`,children:(s?.fallbackChains??[]).map((e,t)=>(0,I.jsxs)(`li`,{className:`border border-[var(--oke-line)] px-3 py-2`,children:[(0,I.jsxs)(`div`,{className:`font-mono text-xs`,children:[e.prompt,e.version===void 0?``:`@${e.version}`]}),(0,I.jsx)(`div`,{className:`mt-1`,children:e.attempts.map((e,t)=>(0,I.jsxs)(`span`,{children:[t>0?` → `:``,(0,I.jsx)(`span`,{className:e.ok?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)] line-through`,children:e.model}),e.cost===void 0?``:` (${O(e.cost)})`]},`${e.model}-${t}`))}),(0,I.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--oke-muted)]`,children:[`actual `,O(e.actualCost),e.costConsequence===null?``:` · cost consequence ${O(e.costConsequence)}`]})]},`${e.prompt}-${e.at}-${t}`))})]})]}),(0,I.jsxs)(`aside`,{"aria-label":`allowPii security review`,className:`min-h-0 overflow-y-auto border-t border-[var(--oke-line)] p-4 lg:border-l lg:border-t-0`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`allowPii`}),(0,I.jsx)(`p`,{className:`mb-3 text-xs text-[var(--oke-muted)]`,children:`Standing security review — flows that acknowledge PII egress to a model.`}),j.length===0?(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`None declared.`}):(0,I.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,I.jsx)(`caption`,{className:`sr-only`,children:`Standing security review — PII egress acknowledgements`}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`text-[var(--oke-muted)]`,children:[(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Flow`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Asks`})]})}),(0,I.jsx)(`tbody`,{children:j.map(e=>(0,I.jsxs)(`tr`,{className:`align-top`,children:[(0,I.jsx)(`td`,{className:`py-1 pr-2 font-mono text-[var(--oke-fg)]`,children:e.flowId}),(0,I.jsx)(`td`,{className:`py-1 font-mono text-[var(--oke-muted)]`,children:e.asks.join(`, `)||`—`})]},e.flowId))})]})]})]})]})}function R(e){let t=e.metrics;return(0,I.jsxs)(`section`,{"aria-label":`Version distributions`,"aria-live":`polite`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-baseline gap-3`,children:[(0,I.jsxs)(`h2`,{className:`text-sm font-medium`,children:[t.prompt,` `,(0,I.jsxs)(`span`,{className:`font-mono text-[var(--oke-muted)]`,children:[`@`,t.version]})]}),e.catalogueHref?(0,I.jsx)(`a`,{href:e.catalogueHref,className:`text-xs text-[var(--oke-muted)] underline`,children:`Manifest Diff — version bump is a deploy`}):null]}),(0,I.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-2`,role:`group`,"aria-label":`Versions`,children:e.versions.map(n=>(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":n.version===t.version,className:u(`min-h-8 px-2 font-mono text-xs`,n.version===t.version?`bg-[var(--oke-line)]`:`text-[var(--oke-muted)]`),onClick:()=>e.onSelectVersion(n.version),children:[`v`,n.version]},n.version))}),(0,I.jsx)(z,{label:`Cost`,summary:j(`Cost`,t.cost.mean,t.cost.p50,t.cost.p95,O),buckets:t.cost.buckets,formatTick:O}),(0,I.jsx)(z,{label:`Latency`,summary:j(`Latency`,t.latencyMs.mean,t.latencyMs.p50,t.latencyMs.p95,k),buckets:t.latencyMs.buckets,formatTick:k}),(0,I.jsx)(z,{label:`Eval score`,summary:j(`Eval score`,t.evalScore.mean,t.evalScore.p50,t.evalScore.p95,A),buckets:t.evalScore.buckets,formatTick:A}),(0,I.jsxs)(`table`,{className:`mt-4 w-full max-w-md text-left text-sm`,children:[(0,I.jsx)(`caption`,{className:`mb-2 text-left text-xs text-[var(--oke-muted)]`,children:`Outcome classes — schema-invalid ≠ provider-error`}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`text-[var(--oke-muted)]`,children:[(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Class`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Rate`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Count`})]})}),(0,I.jsxs)(`tbody`,{children:[(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`schema-invalid`}),(0,I.jsx)(`td`,{children:D(t.schemaInvalidRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.schema_invalid})]}),(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`provider-error`}),(0,I.jsx)(`td`,{children:D(t.providerErrorRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.provider_error})]}),(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`ok`}),(0,I.jsx)(`td`,{children:D(t.okRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.ok})]})]})]}),e.decision&&!e.decision.allowed?(0,I.jsxs)(`div`,{className:`mt-4 border border-[var(--oke-line)] px-3 py-2`,role:`status`,"aria-label":`Promotion gate`,children:[(0,I.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Promotion v`,e.decision.from.version,` → v`,e.decision.to.version,` blocked`]}),(0,I.jsx)(`ul`,{className:`mt-1 list-disc pl-5 text-sm text-[var(--oke-muted)]`,children:x(e.decision).map(e=>(0,I.jsx)(`li`,{children:e},e))})]}):e.decision?.allowed?(0,I.jsxs)(`p`,{className:`mt-4 text-sm text-[var(--oke-muted)]`,role:`status`,children:[`Promotion v`,e.decision.from.version,` → v`,e.decision.to.version,` allowed`,e.decision.evalImproved?` (eval improved)`:``,`.`]}):null]})}function z(e){let t=M(e.buckets);return(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsxs)(`h3`,{className:`text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:[e.label,` distribution`]}),(0,I.jsx)(`p`,{className:`mb-2 text-sm`,children:e.summary}),(0,I.jsx)(`div`,{role:`img`,"aria-label":e.summary,className:`flex h-16 items-end gap-px`,children:e.buckets.map((n,r)=>(0,I.jsx)(`div`,{title:`${e.formatTick(n.min)}–${e.formatTick(n.max)}: ${n.count}`,className:`min-w-[4px] flex-1 bg-[var(--oke-fg)] opacity-70`,style:{height:`${t===0?0:Math.max(4,n.count/t*100)}%`}},r))})]})}var B=t({default:()=>L});export{p as i,P as n,h as r,B as t};
|
|
1
|
+
import{a as e,r as t}from"./rolldown-runtime-B0Z9INg1.js";import{C as n,Q as r,S as i,b as a,d as o,h as s,nt as c,tt as l,u,w as d,y as f}from"./panel-access-ri1X9Otj.js";function p(e){return i(s,e)}var m=f({prompt:a().optional(),version:p().int().optional(),agent:a().optional(),run:a().optional(),q:a().optional()});function h(e){let t=m.safeParse(e);return t.success?t.data:{}}function g(e){let t={};return e.prompt&&(t.prompt=e.prompt),e.version!==void 0&&(t.version=e.version),e.agent&&(t.agent=e.agent),e.run&&(t.run=e.run),e.q&&(t.q=e.q),t}function _(e,t,n){return{...e,prompt:t,version:n,agent:void 0,run:void 0}}function v(e,t,n){return{...e,agent:t,run:n}}function y(e){return`/manifest-diff?${new URLSearchParams({path:e}).toString()}`}function b(e,t){if(e.prompt!==t.prompt)throw Error(`promotionDecision: prompt mismatch (${e.prompt} vs ${t.prompt})`);let n={fromEvalMean:e.evalScore.mean,toEvalMean:t.evalScore.mean,fromSchemaInvalidRate:e.schemaInvalidRate,toSchemaInvalidRate:t.schemaInvalidRate,fromOverBudgetRate:e.overBudgetRate,toOverBudgetRate:t.overBudgetRate,fromP95Cost:e.cost.p95,toP95Cost:t.cost.p95,budgetMaxCostPerCall:t.budgetMaxCostPerCall??e.budgetMaxCostPerCall},r=[];t.schemaInvalidRate>e.schemaInvalidRate+1e-12&&r.push(`schema_validity`);let i=n.budgetMaxCostPerCall;(t.overBudgetRate>e.overBudgetRate+1e-12||i!==null&&t.cost.p95>i&&e.cost.p95<=i)&&r.push(`budget`);let a=t.evalScore.mean>e.evalScore.mean+1e-12;return r.length>0?{allowed:!1,from:e,to:t,blockers:r,evalImproved:a,numbers:n}:{allowed:!0,from:e,to:t,evalImproved:a,numbers:n}}function x(e){let t=[],n=e.numbers;if(e.blockers.includes(`schema_validity`)&&t.push(`schema-invalid ${(n.fromSchemaInvalidRate*100).toFixed(1)}% → ${(n.toSchemaInvalidRate*100).toFixed(1)}%`),e.blockers.includes(`budget`)){let e=n.budgetMaxCostPerCall===null?`budget`:`budget $${n.budgetMaxCostPerCall.toFixed(4)}`;t.push(`over-budget ${(n.fromOverBudgetRate*100).toFixed(1)}% → ${(n.toOverBudgetRate*100).toFixed(1)}% · p95 $${n.fromP95Cost.toFixed(4)} → $${n.toP95Cost.toFixed(4)} (${e})`)}return e.evalImproved&&t.push(`eval mean ${(n.fromEvalMean*100).toFixed(1)}% → ${(n.toEvalMean*100).toFixed(1)}% (improved — still blocked)`),t}function S(e,t){let n=t?.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||(e.model?.toLowerCase().includes(n)??!1)):e}function C(e,t){let n=t?.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||e.tools.some(e=>e.toLowerCase().includes(n))):e}function w(e,t){return e.filter(e=>e.prompt===t).sort((e,t)=>e.version-t.version)}function T(e,t){return e.filter(e=>e.agent===t)}function E(e){return e.filter(e=>e.allowPii)}function D(e){return`${(e*100).toFixed(1)}%`}function O(e){return`$${e.toFixed(4)}`}function k(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${Math.round(e)}ms`}function A(e){return`${(e*100).toFixed(1)}%`}function j(e,t,n,r,i){return`${e}: mean ${i(t)}, p50 ${i(n)}, p95 ${i(r)}`}function M(e){return e.reduce((e,t)=>Math.max(e,t.count),0)}function N(e){return e===`denied`?`DENIED`:`ok`}function P(e){return e.filter(e=>e.overBudgetRate>0).map(e=>({prompt:e.prompt,version:e.version,overBudgetRate:e.overBudgetRate,budgetMaxCostPerCall:e.budgetMaxCostPerCall,p95Cost:e.cost.p95})).sort((e,t)=>t.overBudgetRate-e.overBudgetRate||e.prompt.localeCompare(t.prompt)||t.version-e.version)}var F=e(c(),1),I=l();function L(){let e=d({from:`/ai`}),t=n({from:`/ai`}),i=e=>{t({search:g(e),replace:!0})},a=r({queryKey:[`console.ai.list`],queryFn:async()=>{let e=await o.aiList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}),s=a.data,c=(0,F.useMemo)(()=>S(s?.prompts??[],e.q),[s?.prompts,e.q]),l=(0,F.useMemo)(()=>C(s?.agents??[],e.q),[s?.agents,e.q]),f=e.prompt??c[0]?.name,p=(0,F.useMemo)(()=>f?w(s?.versions??[],f):[],[s?.versions,f]),m=p.find(t=>t.version===e.version)??p[p.length-1],h=p.length>=2?p[p.length-2]:p[0],x=h&&m&&h.version!==m.version?b(h,m):null,D=e.agent??l[0]?.name,k=(0,F.useMemo)(()=>D?T(s?.agentRuns??[],D):[],[s?.agentRuns,D]),A=k.find(t=>t.id===e.run)??k[0],j=E(s?.allowPii??[]),M=c.find(e=>e.name===f);return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,I.jsxs)(`header`,{className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,I.jsx)(`h1`,{className:`text-base font-medium text-[var(--oke-fg)]`,children:`AI`}),(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Distributions per prompt version — cost, latency, eval score. Schema-invalid is its own class.`}),(0,I.jsxs)(`label`,{className:`mt-2 flex max-w-sm flex-col gap-1 text-sm`,children:[(0,I.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter`}),(0,I.jsx)(`input`,{"aria-label":`Filter prompts and agents`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:e.q??``,onChange:t=>i({...e,q:t.target.value||void 0})})]})]}),(0,I.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[14rem_1fr_18rem]`,children:[(0,I.jsxs)(`aside`,{"aria-label":`Prompts and agents`,className:`min-h-0 overflow-y-auto border-b border-[var(--oke-line)] lg:border-b-0 lg:border-r`,children:[(0,I.jsxs)(`section`,{"aria-label":`Prompts`,className:`p-3`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`Prompts`}),(0,I.jsx)(`ul`,{className:`space-y-1`,children:c.map(t=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":t.name===f,className:u(`flex min-h-8 w-full items-center px-2 text-left text-sm`,t.name===f?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:()=>i(_(e,t.name,t.version??0)),children:[t.name,t.version===void 0?null:(0,I.jsxs)(`span`,{className:`ml-1 font-mono text-xs`,children:[`@`,t.version]})]})},t.name))})]}),(0,I.jsxs)(`section`,{"aria-label":`Agents`,className:`p-3`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`Agents`}),(0,I.jsx)(`ul`,{className:`space-y-1`,children:l.map(t=>(0,I.jsx)(`li`,{children:(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t.name===D,className:u(`flex min-h-8 w-full items-center px-2 text-left text-sm`,t.name===D?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:()=>i({...e,agent:t.name,run:void 0}),children:t.name})},t.name))})]})]}),(0,I.jsxs)(`main`,{id:`ai-main`,className:`min-h-0 overflow-y-auto p-4`,children:[a.isLoading?(0,I.jsx)(`p`,{className:`text-[var(--oke-muted)]`,children:`Loading…`}):null,a.isError?(0,I.jsx)(`p`,{role:`alert`,children:`Failed to load AI projection`}):null,m?(0,I.jsx)(R,{metrics:m,versions:p,onSelectVersion:t=>i(_(e,m.prompt,t)),catalogueHref:M?y(M.manifestDiffPath):null,decision:x}):(0,I.jsx)(`p`,{className:`text-[var(--oke-muted)]`,children:`No prompt versions with samples yet.`}),A?(0,I.jsxs)(`section`,{"aria-label":`Agent run trail`,className:`mt-8`,children:[(0,I.jsxs)(`h2`,{className:`mb-2 text-sm font-medium`,children:[`Agent run · `,A.agent]}),(0,I.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:k.map(t=>(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t.id===A.id,className:u(`min-h-8 px-2 text-xs font-mono`,t.id===A.id?`bg-[var(--oke-line)]`:`text-[var(--oke-muted)]`),onClick:()=>i(v(e,t.agent,t.id)),children:t.id},t.id))}),(0,I.jsx)(`ol`,{className:`space-y-3 border-l border-[var(--oke-line)] pl-4`,children:A.trail.map((e,t)=>(0,I.jsxs)(`li`,{className:`text-sm`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:u(`font-mono text-xs tracking-wide`,e.status===`denied`?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),children:N(e.status)}),(0,I.jsx)(`span`,{className:`font-mono`,children:e.tool})]}),e.status===`denied`&&e.denial?(0,I.jsxs)(`p`,{role:`status`,className:`mt-1 text-[var(--oke-muted)]`,children:[`DENIED by gate`,` `,(0,I.jsx)(`span`,{className:`font-mono text-[var(--oke-fg)]`,children:e.denial.gate}),`:`,` `,e.denial.reason]}):null,(0,I.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs text-[var(--oke-muted)]`,children:[e.effects.map(e=>(0,I.jsxs)(`li`,{children:[(0,I.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,e.resource]},`${e.kind}:${e.resource}`)),e.effects.length===0?(0,I.jsx)(`li`,{children:`no declared effects`}):null]})]},`${e.tool}-${t}`))})]}):null,(0,I.jsxs)(`section`,{"aria-label":`Fallback chains`,className:`mt-8`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-sm font-medium`,children:`Fallback chains`}),(s?.fallbackChains.length??0)===0?(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`No multi-model chains recorded.`}):(0,I.jsx)(`ul`,{className:`space-y-2 text-sm`,children:(s?.fallbackChains??[]).map((e,t)=>(0,I.jsxs)(`li`,{className:`border border-[var(--oke-line)] px-3 py-2`,children:[(0,I.jsxs)(`div`,{className:`font-mono text-xs`,children:[e.prompt,e.version===void 0?``:`@${e.version}`]}),(0,I.jsx)(`div`,{className:`mt-1`,children:e.attempts.map((e,t)=>(0,I.jsxs)(`span`,{children:[t>0?` → `:``,(0,I.jsx)(`span`,{className:e.ok?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)] line-through`,children:e.model}),e.cost===void 0?``:` (${O(e.cost)})`]},`${e.model}-${t}`))}),(0,I.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--oke-muted)]`,children:[`actual `,O(e.actualCost),e.costConsequence===null?``:` · cost consequence ${O(e.costConsequence)}`]})]},`${e.prompt}-${e.at}-${t}`))})]})]}),(0,I.jsxs)(`aside`,{"aria-label":`allowPii security review`,className:`min-h-0 overflow-y-auto border-t border-[var(--oke-line)] p-4 lg:border-l lg:border-t-0`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`allowPii`}),(0,I.jsx)(`p`,{className:`mb-3 text-xs text-[var(--oke-muted)]`,children:`Standing security review — flows that acknowledge PII egress to a model.`}),j.length===0?(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`None declared.`}):(0,I.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,I.jsx)(`caption`,{className:`sr-only`,children:`Standing security review — PII egress acknowledgements`}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`text-[var(--oke-muted)]`,children:[(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Flow`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Asks`})]})}),(0,I.jsx)(`tbody`,{children:j.map(e=>(0,I.jsxs)(`tr`,{className:`align-top`,children:[(0,I.jsx)(`td`,{className:`py-1 pr-2 font-mono text-[var(--oke-fg)]`,children:e.flowId}),(0,I.jsx)(`td`,{className:`py-1 font-mono text-[var(--oke-muted)]`,children:e.asks.join(`, `)||`—`})]},e.flowId))})]})]})]})]})}function R(e){let t=e.metrics;return(0,I.jsxs)(`section`,{"aria-label":`Version distributions`,"aria-live":`polite`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-baseline gap-3`,children:[(0,I.jsxs)(`h2`,{className:`text-sm font-medium`,children:[t.prompt,` `,(0,I.jsxs)(`span`,{className:`font-mono text-[var(--oke-muted)]`,children:[`@`,t.version]})]}),e.catalogueHref?(0,I.jsx)(`a`,{href:e.catalogueHref,className:`text-xs text-[var(--oke-muted)] underline`,children:`Manifest Diff — version bump is a deploy`}):null]}),(0,I.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-2`,role:`group`,"aria-label":`Versions`,children:e.versions.map(n=>(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":n.version===t.version,className:u(`min-h-8 px-2 font-mono text-xs`,n.version===t.version?`bg-[var(--oke-line)]`:`text-[var(--oke-muted)]`),onClick:()=>e.onSelectVersion(n.version),children:[`v`,n.version]},n.version))}),(0,I.jsx)(z,{label:`Cost`,summary:j(`Cost`,t.cost.mean,t.cost.p50,t.cost.p95,O),buckets:t.cost.buckets,formatTick:O}),(0,I.jsx)(z,{label:`Latency`,summary:j(`Latency`,t.latencyMs.mean,t.latencyMs.p50,t.latencyMs.p95,k),buckets:t.latencyMs.buckets,formatTick:k}),(0,I.jsx)(z,{label:`Eval score`,summary:j(`Eval score`,t.evalScore.mean,t.evalScore.p50,t.evalScore.p95,A),buckets:t.evalScore.buckets,formatTick:A}),(0,I.jsxs)(`table`,{className:`mt-4 w-full max-w-md text-left text-sm`,children:[(0,I.jsx)(`caption`,{className:`mb-2 text-left text-xs text-[var(--oke-muted)]`,children:`Outcome classes — schema-invalid ≠ provider-error`}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`text-[var(--oke-muted)]`,children:[(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Class`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Rate`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Count`})]})}),(0,I.jsxs)(`tbody`,{children:[(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`schema-invalid`}),(0,I.jsx)(`td`,{children:D(t.schemaInvalidRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.schema_invalid})]}),(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`provider-error`}),(0,I.jsx)(`td`,{children:D(t.providerErrorRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.provider_error})]}),(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`ok`}),(0,I.jsx)(`td`,{children:D(t.okRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.ok})]})]})]}),e.decision&&!e.decision.allowed?(0,I.jsxs)(`div`,{className:`mt-4 border border-[var(--oke-line)] px-3 py-2`,role:`status`,"aria-label":`Promotion gate`,children:[(0,I.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Promotion v`,e.decision.from.version,` → v`,e.decision.to.version,` blocked`]}),(0,I.jsx)(`ul`,{className:`mt-1 list-disc pl-5 text-sm text-[var(--oke-muted)]`,children:x(e.decision).map(e=>(0,I.jsx)(`li`,{children:e},e))})]}):e.decision?.allowed?(0,I.jsxs)(`p`,{className:`mt-4 text-sm text-[var(--oke-muted)]`,role:`status`,children:[`Promotion v`,e.decision.from.version,` → v`,e.decision.to.version,` allowed`,e.decision.evalImproved?` (eval improved)`:``,`.`]}):null]})}function z(e){let t=M(e.buckets);return(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsxs)(`h3`,{className:`text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:[e.label,` distribution`]}),(0,I.jsx)(`p`,{className:`mb-2 text-sm`,children:e.summary}),(0,I.jsx)(`div`,{role:`img`,"aria-label":e.summary,className:`flex h-16 items-end gap-px`,children:e.buckets.map((n,r)=>(0,I.jsx)(`div`,{title:`${e.formatTick(n.min)}–${e.formatTick(n.max)}: ${n.count}`,className:`min-w-[4px] flex-1 bg-[var(--oke-fg)] opacity-70`,style:{height:`${t===0?0:Math.max(4,n.count/t*100)}%`}},r))})]})}var B=t({default:()=>L});export{p as i,P as n,h as r,B as t};
|
package/src/console/ui/dist/assets/{panel-architecture-D7UJh91v.js → panel-architecture-DI3bQF3J.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,r as t}from"./rolldown-runtime-B0Z9INg1.js";import{C as n,Q as r,_ as i,b as a,d as o,nt as s,o as c,tt as l,u,v as d,w as f,x as p,y as m}from"./panel-access-BGv45snf.js";var h=[`data`,`messaging`,`time`,`external`],g={data:`Data`,messaging:`Messaging`,time:`Time`,external:`External`},_={data:!0,messaging:!0,time:!0,external:!0},v=p([i(),d(`true`),d(`false`)]).transform(e=>e===!0||e===`true`),ee=m({focus:a().optional(),depth:p([d(1),d(2),d(`1`),d(`2`)]).transform(e=>Number(e)===2?2:1).default(1),data:v.optional(),messaging:v.optional(),time:v.optional(),external:v.optional()});function te(e){let t=ee.safeParse(e);return t.success?t.data:{depth:1}}function ne(e){let t={};e.focus&&(t.focus=e.focus),e.depth===2&&(t.depth=`2`);for(let n of h)e[n]===!1&&(t[n]=`false`);return t}function y(e){return{data:e.data??_.data,messaging:e.messaging??_.messaging,time:e.time??_.time,external:e.external??_.external}}function b(e,t){return{...e,focus:t}}function re(e){let{focus:t,...n}=e;return{...n,depth:e.depth}}function ie(e,t){return{...e,depth:t}}function x(e,t,n){return{...e,[t]:n}}function S(e){return e.startsWith(`sql:`)||e.startsWith(`kv:`)||e.startsWith(`files:`)||e.startsWith(`index:`)?`data`:e.startsWith(`signal:`)?`messaging`:e.startsWith(`channel:`)||e.startsWith(`ai:`)?`external`:null}function ae(e){return e.kind===`signal`?`messaging`:e.kind===`cron`||e.kind===`every`?`time`:null}function C(e){return e.startsWith(`channel:`)||e.startsWith(`ai:`)}function w(e){let t=e.indexOf(`:`);return t===-1?e:e.slice(t+1)}function oe(e){let t=new Set;for(let n of e.flows)for(let e of n.effectRefs)C(e)&&t.add(e);return t.size}function se(e){let t=new Set;for(let n of e.flows)for(let e of n.effectRefs)C(e)&&t.add(e);return[...t].sort()}function ce(e,t){switch(e){case`emit`:return t.startsWith(`signal:`)?t:`signal:${t}`;case`send`:return t.startsWith(`channel:`)?t:`channel:${t}`;case`ask`:return t.startsWith(`ai:`)?t:`ai:${t}`;case`secret`:return t.startsWith(`secret:`)?t:`secret:${t}`;case`call`:return t.startsWith(`flow:`)?t:`flow:${t}`;default:return t}}function T(e,t){return`${e}\0${t}`}function le(e){let t=new Map;for(let n of e){for(let e of n.effects){let r=ce(e.kind,e.resource),i=T(n.flow,r);t.set(i,(t.get(i)??0)+1)}n.parentId}return t}function E(e,t,n){return e.get(T(t,n))??0}function ue(e,t){if(e<=0)return 1;if(t<=1)return 2;let n=e/t;return Math.max(1,Math.min(8,Math.ceil(n*8)))}function D(e){let t=[],n=pe(e);for(let r of e.flows){for(let n of r.causeIds){let i=e.causeById.get(n);if(!i)continue;let a=ae(i);a&&t.push({from:`cause:${i.id}`,to:`flow:${r.id}`,flowId:r.id,layer:a,fromUnit:r.unit,toUnit:r.unit})}for(let i of r.effectRefs){if(i.startsWith(`flow:`)){let e=i.slice(5),n=O(e);t.push({from:`flow:${r.id}`,to:`flow:${e}`,flowId:r.id,ref:i,layer:`call`,fromUnit:r.unit,toUnit:n});continue}let a=S(i);if(!a)continue;let o=C(i)?`external`:de(i,e);if(t.push({from:`flow:${r.id}`,to:i,flowId:r.id,ref:i,layer:a,fromUnit:r.unit,toUnit:o}),a===`messaging`&&i.startsWith(`signal:`)){let a=i.slice(7);for(let o of n.get(a)??[]){let n=e.flowById.get(o);!n||n.id===r.id||t.push({from:`flow:${r.id}`,to:`flow:${n.id}`,flowId:r.id,ref:i,layer:`messaging`,fromUnit:r.unit,toUnit:n.unit})}}}}return t}function de(e,t){let n=t.effectByRef.get(e);if(!n||n.flowIds.length===0)return`shared`;let r=n.flowIds.filter(n=>{let r=t.flowById.get(n);return r?fe(r,e):!1})[0]??n.flowIds[0];return r?O(r):`shared`}function fe(e,t){let n=e.raw.effects;if(!n)return!1;if(t.startsWith(`signal:`)){let e=t.slice(7);return(n.emits??[]).includes(e)}return!!(n.writes??[]).includes(t)}function pe(e){let t=new Map;for(let n of e.flows){let e=n.raw.trigger?.signal;if(!e)continue;let r=t.get(e)??[];r.push(n.id),t.set(e,r)}return t}function O(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function k(e){let t=[];return t.push(...A(e)),t.push(...j(e)),t.push(...M(e)),t.push(...N(e)),t}function A(e){let t=new Map,n=e=>{let n=t.get(e);return n||(n=new Set,t.set(e,n)),n};for(let t of D(e)){if(!t.from.startsWith(`flow:`)||!t.to.startsWith(`flow:`))continue;let e=t.from.slice(5),r=t.to.slice(5);n(e).add(r)}let r=[],i=new Set,a=[],o=new Set,s=e=>{i.add(e),a.push(e),o.add(e);for(let n of t.get(e)??[])if(!i.has(n))s(n);else if(o.has(n)){let e=a.indexOf(n);e!==-1&&r.push([...a.slice(e),n])}a.pop(),o.delete(e)};for(let t of e.flows.map(e=>e.id))i.has(t)||s(t);let c=new Set,l=[];for(let e of r){let t=P(e.slice(0,-1)),n=t.join(`→`);c.has(n)||(c.add(n),l.push({kind:`cycle`,severity:`critical`,title:`Cycle`,detail:`Causal cycle: ${t.join(` → `)}`,nodeIds:t.map(e=>`flow:${e}`)}))}return l}function j(e){if(e.effects.length===0)return[];let t=[...e.effects].filter(e=>e.touchCount>0).sort((e,t)=>t.touchCount-e.touchCount||e.ref.localeCompare(t.ref)),n=t[0];if(!n||n.touchCount<2)return[];let r=t[1]?.touchCount??0;return n.touchCount===r&&t.filter(e=>e.touchCount===n.touchCount).length>1?t.filter(e=>e.touchCount===n.touchCount).map(e=>({kind:`god-node`,severity:`warning`,title:`God node`,detail:`${e.ref} is touched by ${e.touchCount} flows — the most in the system`,nodeIds:[e.ref]})):[{kind:`god-node`,severity:`warning`,title:`God node`,detail:`${n.ref} is touched by ${n.touchCount} flows — the most in the system`,nodeIds:[n.ref]}]}function M(e){let t=[],n=new Set;for(let t of e.effects)t.ref.startsWith(`signal:`)&&n.add(t.ref.slice(7));for(let t of e.flows){for(let e of t.raw.effects?.emits??[])n.add(e);let e=t.raw.trigger?.signal;e&&n.add(e)}for(let r of[...n].sort()){let n=`signal:${r}`,i=e.flows.filter(e=>(e.raw.effects?.emits??[]).includes(r)),a=e.flows.filter(e=>e.raw.trigger?.signal===r);if(i.length===0&&a.length===0){t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} is declared but has no producers and no consumers`,nodeIds:[n]});continue}if(i.length===0){t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} has consumers but no producer`,nodeIds:[n,...a.map(e=>`flow:${e.id}`)]});continue}a.length===0&&t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} is emitted but has no consumers`,nodeIds:[n,...i.map(e=>`flow:${e.id}`)]})}return t}function N(e){let t=[];for(let n of e.effects){if(n.touchCount<2||n.ref.startsWith(`secret:`)||n.ref.startsWith(`channel:`)||n.ref.startsWith(`ai:`))continue;let r=n.flowIds.filter(t=>{let r=e.flowById.get(t);if(!r?.raw.effects)return!1;if(n.ref.startsWith(`signal:`)){let e=n.ref.slice(7);return(r.raw.effects.emits??[]).includes(e)}return(r.raw.effects.writes??[]).includes(n.ref)});if(r.length!==1)continue;let i=r[0];t.push({kind:`spof`,severity:`critical`,title:`Single point of failure`,detail:`${n.ref} is touched by ${n.touchCount} flows but written/emitted by only ${i}`,nodeIds:[n.ref,`flow:${i}`]})}return t}function P(e){if(e.length===0)return[];let t=[...e],n=t.join(`\0`);for(let r=1;r<e.length;r++){let i=[...e.slice(r),...e.slice(0,r)],a=i.join(`\0`);a<n&&(t=i,n=a)}return t}function F(e,t={}){let n=t.focus??null,r=t.depth===2?2:1,i=t.layers??_,a=le(t.runs??[]),o=D(e),s=k(e),c=oe(e);return n?L({graph:e,declared:o,traffic:a,focus:n,depth:r,layers:i,findings:s,crossings:c}):I({graph:e,declared:o,traffic:a,layers:i,findings:s,crossings:c})}function I(e){let{graph:t,declared:n,traffic:r,layers:i,findings:a,crossings:o}=e,s=[...new Set(t.flows.map(e=>e.unit))].sort().map(e=>({id:`unit:${e}`,kind:`unit`,label:e,unit:e,insideBoundary:!0,flowCount:t.flows.filter(t=>t.unit===e).length}));for(let e of se(t))s.push({id:e,kind:`external`,label:w(e),layer:`external`,insideBoundary:!1});let c=new Map;for(let e of n){if(!V(e.layer,i))continue;let t=`unit:${e.fromUnit}`,n=null;if(e.toUnit===`external`||C(e.to))n=e.ref??e.to;else if(e.fromUnit!==e.toUnit)n=`unit:${e.toUnit}`;else continue;if(t===n)continue;let a=`${t}\0${n}\0${e.layer}`,o=e.ref?E(r,e.flowId,e.ref):0,s=c.get(a);s?s.traversals+=o:c.set(a,{from:t,to:n,layer:e.layer,traversals:o,declared:!0})}let l=H(c,!0);return{nodes:U(s),edges:l,boundaryCrossingCount:o,findings:a,focus:null,depth:1,layers:i}}function L(e){let{graph:t,declared:n,traffic:r,focus:i,depth:a,layers:o,findings:s,crossings:c}=e,l=z(t,n,i,a),u=[];for(let e of l){let r=B(t,n,i,e,a);if(e.startsWith(`unit:`)){let n=e.slice(5);u.push({id:e,kind:`unit`,label:n,unit:n,insideBoundary:!0,flowCount:t.flows.filter(e=>e.unit===n).length,focused:e===i,depth:r});continue}if(e.startsWith(`flow:`)){let n=e.slice(5),a=t.flowById.get(n);u.push({id:e,kind:`flow`,label:n,unit:a?.unit??O(n),insideBoundary:!0,focused:e===i,depth:r});continue}if(e.startsWith(`cause:`)){let n=e.slice(6),a=t.causeById.get(n),s=a?.kind===`cron`||a?.kind===`every`?`time`:a?.kind===`signal`?`messaging`:void 0;if(!s||!o[s])continue;u.push({id:e,kind:`resource`,label:a?.label??n,layer:s,insideBoundary:!0,focused:e===i,depth:r});continue}u.push({id:e,kind:C(e)?`external`:`resource`,label:w(e),layer:C(e)?`external`:e.startsWith(`signal:`)?`messaging`:`data`,insideBoundary:!C(e),focused:e===i,depth:r})}u.some(e=>e.id===i)||u.push(...R(t,i));let d=new Map,f=new Set(u.map(e=>e.id));for(let e of n){if(!V(e.layer,o))continue;let t=e.from,n=e.to;if(!f.has(t)||!f.has(n))continue;let i=`${t}\0${n}\0${e.layer}`,a=e.ref?E(r,e.flowId,e.ref):0,s=d.get(i);s?s.traversals+=a:d.set(i,{from:t,to:n,layer:e.layer,traversals:a,declared:!0})}return{nodes:U(u),edges:H(d,!1),boundaryCrossingCount:c,findings:s,focus:i,depth:a,layers:o}}function R(e,t){if(t.startsWith(`unit:`)){let n=t.slice(5);return[{id:t,kind:`unit`,label:n,unit:n,insideBoundary:!0,flowCount:e.flows.filter(e=>e.unit===n).length,focused:!0,depth:0}]}if(t.startsWith(`flow:`)){let n=t.slice(5);return[{id:t,kind:`flow`,label:n,unit:e.flowById.get(n)?.unit??O(n),insideBoundary:!0,focused:!0,depth:0}]}return[{id:t,kind:C(t)?`external`:`resource`,label:w(t),layer:C(t)?`external`:t.startsWith(`signal:`)?`messaging`:`data`,insideBoundary:!C(t),focused:!0,depth:0}]}function z(e,t,n,r){let i=new Set([n]);if(n.startsWith(`unit:`)){let t=n.slice(5);for(let n of e.flows)n.unit===t&&i.add(`flow:${n.id}`)}let a=new Set(i);for(let e=0;e<r;e++){let e=new Set;for(let n of t){let t=n.from,r=n.to;a.has(t)&&e.add(r),a.has(r)&&e.add(t);for(let n of[t,r]){if(!n.startsWith(`flow:`))continue;let t=`unit:${O(n.slice(5))}`;a.has(n)&&e.add(t),a.has(t)&&e.add(n)}}for(let t of e)i.add(t);a=e}return i}function B(e,t,n,r,i){if(n===r)return 0;let a=new Set([n]),o=new Set([n]);for(let n=1;n<=i;n++){let i=new Set;for(let e of t){let t=e.from,s=e.to;for(let[e,c]of[[t,s],[s,t]])if(o.has(e)){if(c===r)return n;a.has(c)||(a.add(c),i.add(c))}}for(let t of o){if(t.startsWith(`flow:`)){let e=`unit:${O(t.slice(5))}`;if(e===r)return n;a.has(e)||(a.add(e),i.add(e))}if(t.startsWith(`unit:`)){let o=t.slice(5);for(let t of e.flows){if(t.unit!==o)continue;let e=`flow:${t.id}`;if(e===r)return n;a.has(e)||(a.add(e),i.add(e))}}}o=i}return i}function V(e,t){return e===`call`||t[e]}function H(e,t){let n=Math.max(0,...[...e.values()].map(e=>e.traversals));return[...e.values()].map(e=>({id:`${e.from}->${e.to}:${e.layer}`,from:e.from,to:e.to,layer:e.layer,declared:e.declared,traversals:e.traversals,dashed:e.declared&&e.traversals===0,thickness:ue(e.traversals,n),aggregated:t})).sort((e,t)=>e.id.localeCompare(t.id))}function U(e){let t=new Map;for(let n of e)t.has(n.id)||t.set(n.id,n);return[...t.values()].sort((e,t)=>e.id.localeCompare(t.id))}function W(e){let t={...e.dimensions??{}};return t.flow===void 0&&(t.flow=e.flow),t.unit===void 0&&(t.unit=e.unit??null),t.trigger===void 0&&(t.trigger=e.trigger),t.plane===void 0&&(t.plane=e.plane),t.tenant===void 0&&(t.tenant=e.tenant??null),t.principal===void 0&&(t.principal=e.principal??null),t.cache===void 0&&(t.cache=e.cache??`none`),t.duration_ms===void 0&&(t.duration_ms=e.durationMs),t.error_code===void 0&&e.error&&(t.error_code=e.error),{id:e.id,parentId:e.parentId??null,flow:e.flow,unit:e.unit??null,trigger:e.trigger,plane:e.plane,tenant:e.tenant??null,principal:e.principal??null,gates:e.gates??[],cache:e.cache??`none`,replica:e.replica??null,replicaLagMs:e.replicaLagMs??null,cost:e.cost??null,promptVersion:e.promptVersion??null,buildVersion:e.buildVersion??null,startedAt:e.startedAt,endedAt:e.endedAt,durationMs:e.durationMs,error:e.error??null,effects:e.effects??[],logs:e.logs??[],dimensions:t}}function me(e){return{id:e.id,...e.parentId?{parentId:e.parentId}:{},flow:e.flow,...e.unit?{unit:e.unit}:{},trigger:e.trigger,plane:e.plane,tenant:e.tenant,principal:e.principal,gates:e.gates,cache:e.cache,...e.replica?{replica:e.replica}:{},...e.replicaLagMs==null?{}:{replicaLagMs:e.replicaLagMs},...e.cost==null?{}:{cost:e.cost},...e.promptVersion==null?{}:{promptVersion:e.promptVersion},...e.buildVersion?{buildVersion:e.buildVersion}:{},error:e.error?{code:e.error}:null,effects:e.effects,logs:e.logs,durationMs:e.durationMs,startedAt:e.startedAt,endedAt:e.endedAt,dimensions:{...e.dimensions}}}var G=e(s(),1),K={x:32,y:40,width:440,height:300};function he(e){let t=e.filter(e=>e.insideBoundary),n=e.filter(e=>!e.insideBoundary),r=new Map,i=Math.max(1,Math.ceil(Math.sqrt(t.length))),a=K.width/(i+1),o=Math.max(1,Math.ceil(t.length/i)),s=K.height/(o+1);return t.forEach((e,t)=>{let n=t%i,o=Math.floor(t/i);r.set(e.id,{id:e.id,x:K.x+a*(n+1),y:K.y+s*(o+1)})}),n.forEach((e,t)=>{r.set(e.id,{id:e.id,x:K.x+K.width+96,y:K.y+48+t*56})}),r}var q={read:`none`,write:`reversible`,emit:`deferred`,send:`irreversible`,ask:`irreversible`,secret:`capability`,call:`portal`};function ge(e){return q[e]}Object.entries(q).map(([e,t])=>({kind:e,reversibility:t}));function _e(e,t={}){if(!e)return[];let n=t.touchCounts,r=t.emitFanOut,i=[],a=(e,a,o)=>{for(let s of o??[])i.push({tier:e,kind:a,ref:s,reversibility:ge(a),touchCount:n?.get(s)??1,fanOut:a===`emit`?r?.get(s)??0:void 0,transitive:t.transitive})};return a(`reads`,`read`,e.reads),a(`writes`,`write`,e.writes),a(`emits`,`emit`,e.emits),a(`external`,`send`,e.sends),a(`external`,`ask`,e.asks),a(`capabilities`,`secret`,e.secrets),i}function J(e){return e?(e.sends?.length??0)>0||(e.asks?.length??0)>0?`external`:(e.secrets?.length??0)>0?`capabilities`:(e.emits?.length??0)>0?`emits`:(e.writes?.length??0)>0?`writes`:(e.reads?.length??0)>0?`reads`:`none`:`none`}function Y(e){return ve(J(e))}function ve(e){return e===`external`}var ye=[`reads`,`writes`,`emits`,`external`,`capabilities`],be={reads:`Reads`,writes:`Writes`,emits:`Emits`,external:`External`,capabilities:`Capabilities`};function xe(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function Se(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(t+1)}function Ce(e,t,n){let r=[];if(e?.http){let n=`http:${e.http.method}:${e.http.path}`;r.push({id:n,kind:`http`,label:`${e.http.method} ${e.http.path}`,flowIds:[t]})}if(e?.signal&&r.push({id:`signal:${e.signal}`,kind:`signal`,label:e.signal,flowIds:[t]}),e?.cron&&r.push({id:`cron:${e.cron}`,kind:`cron`,label:e.cron,flowIds:[t]}),e?.every&&r.push({id:`every:${e.every}`,kind:`every`,label:`every ${e.every}`,flowIds:[t]}),e?.cdc){let n=e.cdc.column?`.${e.cdc.column}`:``,i=`cdc:${e.cdc.table}${n}`;r.push({id:i,kind:`cdc`,label:`cdc ${e.cdc.table}${n}`,flowIds:[t]})}if(r.length===0)for(let e of n)r.push({id:`caller:${e}`,kind:`caller`,label:e,flowIds:[t]});return r}function X(e){if(!e)return[];let t=[];for(let n of e.reads??[])t.push(n);for(let n of e.writes??[])t.push(n);for(let n of e.emits??[])t.push(`signal:${n}`);for(let n of e.sends??[])t.push(`channel:${n}`);for(let n of e.asks??[])t.push(`ai:${n}`);for(let n of e.secrets??[])t.push(`secret:${n}`);for(let n of e.calls??[])t.push(`flow:${n}`);return t}function Z(e){return!e||typeof e==`string`?null:e}function we(e){return e.errors?Array.isArray(e.errors)?[...e.errors]:Object.keys(e.errors):[]}function Q(e){let t=e?.flows??{},n=Object.keys(t).sort(),r=new Map;for(let e of n){let n=t[e]?.effects?.calls??[];for(let t of n){let n=r.get(t)??[];n.push(e),r.set(t,n)}}let i=new Map;for(let e of n){let n=t[e]?.trigger?.signal;if(!n)continue;let r=i.get(n)??[];r.push(e),i.set(n,r)}let a=new Map,o=new Map,s=[];for(let e of n){let n=t[e];if(!n)continue;let c=r.get(e)??[],l=Ce(n.trigger,e,c);for(let t of l){let n=a.get(t.id);n?a.set(t.id,{...n,flowIds:[...new Set([...n.flowIds,e])]}):a.set(t.id,t)}let u=new Map,d=new Map;for(let e of n.effects?.emits??[])d.set(e,i.get(e)?.length??0);let f=_e(n.effects,{touchCounts:u,emitFanOut:d}),p=X(n.effects);for(let t of f){let n=t.kind===`emit`?`signal:${t.ref}`:t.kind===`send`?`channel:${t.ref}`:t.kind===`ask`?`ai:${t.ref}`:t.kind===`secret`?`secret:${t.ref}`:t.kind===`call`?`flow:${t.ref}`:t.ref,r=o.get(n);r?(r.flowIds.push(e),r.fanOut=Math.max(r.fanOut,t.fanOut??0)):o.set(n,{tier:t.tier,flowIds:[e],fanOut:t.fanOut??0})}s.push({id:e,unit:xe(e),action:Se(e),plane:n.plane??`user`,causeIds:l.map(e=>e.id),effectRefs:p,effects:f,peakTier:J(n.effects),external:Y(n.effects),flags:{durable:n.durable===!0,live:n.live===!0,cached:n.cache!==void 0&&n.cache!==!1,costsMoney:(n.cost?.estimatePerCall??0)>0,readsSecret:(n.effects?.secrets?.length??0)>0,touchesPii:n.pii!==void 0||n.allowPii===!0,external:Y(n.effects)},inSchema:Z(n.in),outSchema:Z(n.out),errorNames:we(n),source:n.source,deprecated:!!n.deprecated,raw:n})}if(e?.stores){for(let t of Object.values(e.stores))if(t.facet===`sql`&&t.tables)for(let e of Object.keys(t.tables)){let t=`sql:${e}`;o.has(t)||o.set(t,{tier:`reads`,flowIds:[],fanOut:0})}}if(e?.signals)for(let t of Object.keys(e.signals)){let e=`signal:${t}`;o.has(e)||o.set(e,{tier:`emits`,flowIds:[],fanOut:0})}if(e?.channels)for(let t of Object.keys(e.channels)){let e=`channel:${t}`;o.has(e)||o.set(e,{tier:`external`,flowIds:[],fanOut:0})}if(e?.vault)for(let t of Object.keys(e.vault)){let e=`secret:${t}`;o.has(e)||o.set(e,{tier:`capabilities`,flowIds:[],fanOut:0})}let c=[...a.values()].sort((e,t)=>e.label.localeCompare(t.label)),l=[...o.entries()].map(([e,t])=>({ref:e,tier:t.tier,flowIds:[...new Set(t.flowIds)].sort(),touchCount:new Set(t.flowIds).size,fanOut:t.fanOut})).sort((e,t)=>t.touchCount-e.touchCount||e.ref.localeCompare(t.ref));return{causes:c,flows:s,effects:l,causeById:new Map(c.map(e=>[e.id,e])),flowById:new Map(s.map(e=>[e.id,e])),effectByRef:new Map(l.map(e=>[e.ref,e]))}}function Te(e,t){let n=null;if(t.sel===`cause`&&t.cause){let r=e.causeById.get(t.cause);n=new Set(r?.flowIds??[])}else if(t.sel===`effect`&&t.effect){let r=e.effectByRef.get(t.effect);n=new Set(r?.flowIds??[])}else t.sel===`flow`&&t.flow&&(n=new Set([t.flow]));return e.flows.map(e=>{let r=n===null||n.has(e.id),i=Oe(e,t.q),a=!t.unit||e.unit===t.unit,o=r&&i&&a;return{...e,match:o,related:r}})}function Ee(e,t){let n=null;if(t.sel===`flow`&&t.flow){let r=e.flowById.get(t.flow);n=new Set(r?.causeIds??[])}else if(t.sel===`effect`&&t.effect){let r=e.effectByRef.get(t.effect),i=new Set;for(let t of r?.flowIds??[]){let n=e.flowById.get(t);for(let e of n?.causeIds??[])i.add(e)}n=i}return e.causes.map(e=>{let r=n===null||n.has(e.id),i=!t.q||e.label.toLowerCase().includes(t.q.toLowerCase())||e.id.toLowerCase().includes(t.q.toLowerCase());return{...e,match:r&&i,related:r}})}function De(e,t,n={}){let r=null;if(t.sel===`flow`&&t.flow){let n=e.flowById.get(t.flow);r=new Set(n?.effectRefs??[])}else if(t.sel===`cause`&&t.cause){let n=e.causeById.get(t.cause),i=new Set;for(let t of n?.flowIds??[]){let n=e.flowById.get(t);for(let e of n?.effectRefs??[])i.add(e)}r=i}let i=n.ubiquitousThreshold??8;return e.effects.map(e=>{let a=r===null||r.has(e.ref),o=!t.q||e.ref.toLowerCase().includes(t.q.toLowerCase()),s=!n.hideUbiquitous||e.touchCount<i||r!==null;return{...e,match:a&&o&&s,related:a}})}function Oe(e,t){if(!t?.trim())return!0;let n=t.toLowerCase();return e.id.toLowerCase().includes(n)||e.unit.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)}var $=l();function ke(){let e=f({from:`/architecture`}),t=n({from:`/architecture`}),i=e=>{t({search:ne(e),replace:!0})},a=r({queryKey:[`console.manifest.get`],queryFn:async()=>{let e=await o.manifestGet();if(e.error)throw Error(e.error.code);return e.data.manifest}}),s=r({queryKey:[`console.runs.list`],queryFn:async()=>{let e=await o.runsList();if(e.error)throw Error(e.error.code);return e.data.runs.map(W)},refetchInterval:1e4}),l=(0,G.useMemo)(()=>Q(a.data),[a.data]),d=y(e),p=(0,G.useMemo)(()=>F(l,{focus:e.focus??null,depth:e.depth,layers:y(e),runs:s.data??[]}),[l,e.focus,e.depth,e.data,e.messaging,e.time,e.external,s.data]),m=(0,G.useMemo)(()=>he(p.nodes),[p.nodes]);return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-4 border-b border-[var(--oke-line)] px-6 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`p`,{className:`text-xs uppercase tracking-[0.2em] text-[var(--oke-muted)]`,children:`Architecture`}),(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`System shape`}),(0,$.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Clustered by unit · typed layers · traffic from Runs`})]}),(0,$.jsxs)(`p`,{className:`ml-auto font-mono text-sm`,role:`status`,"aria-live":`polite`,children:[(0,$.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Boundary crossings`}),` `,(0,$.jsx)(`span`,{className:`text-lg font-semibold tabular-nums`,children:p.boundaryCrossingCount})]})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-0 lg:flex-row`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-4 border-b border-[var(--oke-line)] px-6 py-3`,children:[(0,$.jsxs)(`fieldset`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Element layers`}),(0,$.jsx)(`span`,{className:`text-xs uppercase tracking-[0.15em] text-[var(--oke-muted)]`,children:`Layers`}),h.map(t=>(0,$.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:d[t],onChange:n=>i(x(e,t,n.target.checked)),"aria-label":`${g[t]} layer`}),g[t]]},t))]}),e.focus?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsxs)(`fieldset`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Focus depth`}),(0,$.jsx)(`span`,{className:`text-xs text-[var(--oke-muted)]`,children:`Depth`}),[1,2].map(t=>(0,$.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-1.5 text-sm`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`arch-depth`,checked:e.depth===t,onChange:()=>i(ie(e,t))}),t]},t))]}),(0,$.jsx)(c,{type:`button`,variant:`ghost`,onClick:()=>i(re(e)),children:`Clear focus`})]}):(0,$.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Select a unit to focus at depth 1–2`})]}),(0,$.jsxs)(`section`,{"aria-label":`System diagram`,className:`min-h-0 flex-1 overflow-auto px-4 py-4`,children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`mb-4 overflow-x-auto`,children:(0,$.jsxs)(`svg`,{className:`h-auto w-full max-w-5xl text-[var(--oke-fg)]`,viewBox:`0 0 640 380`,children:[(0,$.jsx)(`rect`,{x:K.x,y:K.y,width:K.width,height:K.height,fill:`color-mix(in oklab, var(--oke-fg) 3%, transparent)`,stroke:`var(--oke-muted)`,strokeDasharray:`8 5`,strokeWidth:1.5,rx:4}),(0,$.jsxs)(`text`,{x:K.x+12,y:K.y+18,className:`fill-[var(--oke-muted)]`,fontSize:11,fontFamily:`var(--oke-mono)`,children:[`System boundary · `,p.boundaryCrossingCount,` crossings`]}),p.edges.map(e=>{let t=m.get(e.from),n=m.get(e.to);return!t||!n?null:(0,$.jsx)(`line`,{x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:e.layer===`external`?`var(--oke-external)`:`var(--oke-muted)`,strokeWidth:e.thickness,strokeDasharray:e.dashed?`6 4`:void 0,opacity:e.dashed?.55:.9},e.id)}),p.nodes.map(e=>{let t=m.get(e.id);if(!t)return null;let n=e.kind===`unit`?28:22;return(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`circle`,{cx:t.x,cy:t.y,r:n,fill:e.focused?`var(--oke-accent)`:e.insideBoundary?`var(--oke-bg)`:`color-mix(in oklab, var(--oke-external) 25%, var(--oke-bg))`,stroke:e.insideBoundary?`var(--oke-fg)`:`var(--oke-external)`,strokeWidth:e.focused?2.5:1.25}),(0,$.jsx)(`text`,{x:t.x,y:t.y+4,textAnchor:`middle`,fontSize:10,fontFamily:`var(--oke-mono)`,className:`fill-[var(--oke-fg)]`,children:Ae(e.label,12)})]},e.id)})]})}),(0,$.jsx)(`ul`,{"aria-label":`Nodes`,className:`flex flex-wrap gap-2 border-t border-[var(--oke-line)] pt-4`,children:p.nodes.map(t=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t.focused===!0,className:u(`inline-flex min-h-8 items-center gap-2 border px-3 text-sm`,t.focused?`border-[var(--oke-accent)] text-[var(--oke-fg)]`:`border-[var(--oke-line)] text-[var(--oke-muted)]`),onClick:()=>i(b(e,t.id)),children:[(0,$.jsx)(`span`,{children:t.label}),t.kind===`unit`&&t.flowCount!==void 0?(0,$.jsx)(`span`,{className:`font-mono text-xs`,children:t.flowCount}):null,t.insideBoundary?null:(0,$.jsx)(`span`,{className:`text-xs text-[var(--oke-external)]`,children:`external`})]})},t.id))}),(0,$.jsx)(`ul`,{className:`sr-only`,"aria-label":`Edges`,children:p.edges.map(e=>(0,$.jsxs)(`li`,{children:[e.from,` → `,e.to,e.dashed?` (declared, never traversed)`:` · ${e.traversals} traversals`,` · ${e.layer}`]},e.id))})]})]}),(0,$.jsxs)(`aside`,{"aria-label":`Findings`,className:`w-full shrink-0 overflow-auto border-t border-[var(--oke-line)] lg:w-80 lg:border-l lg:border-t-0`,children:[(0,$.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-medium`,children:`Findings`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-[var(--oke-muted)]`,children:`Pathologies from the graph as data`})]}),p.findings.length===0?(0,$.jsx)(`p`,{className:`px-5 pb-4 text-sm text-[var(--oke-muted)]`,children:`No pathologies detected.`}):(0,$.jsx)(`ul`,{className:`divide-y divide-[var(--oke-line)] border-t border-[var(--oke-line)]`,children:p.findings.map((t,n)=>(0,$.jsxs)(`li`,{className:`px-5 py-3`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,$.jsx)(`span`,{className:u(`inline-block size-1.5 rounded-full`,t.severity===`critical`?`bg-[var(--oke-danger)]`:`bg-[var(--oke-external)]`),"aria-hidden":!0}),t.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:t.detail}),t.nodeIds[0]?(0,$.jsx)(`button`,{type:`button`,className:`mt-2 min-h-8 text-sm text-[var(--oke-accent)] underline-offset-2 hover:underline`,onClick:()=>i(b(e,t.nodeIds[0])),children:`Focus`}):null]},`${t.kind}-${n}`))})]})]})]})}function Ae(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}var je=t({default:()=>ke});export{De as a,W as c,te as d,Ee as i,me as l,Q as n,be as o,Te as r,ye as s,je as t,A as u};
|
|
1
|
+
import{a as e,r as t}from"./rolldown-runtime-B0Z9INg1.js";import{C as n,Q as r,_ as i,b as a,d as o,nt as s,o as c,tt as l,u,v as d,w as f,x as p,y as m}from"./panel-access-ri1X9Otj.js";var h=[`data`,`messaging`,`time`,`external`],g={data:`Data`,messaging:`Messaging`,time:`Time`,external:`External`},_={data:!0,messaging:!0,time:!0,external:!0},v=p([i(),d(`true`),d(`false`)]).transform(e=>e===!0||e===`true`),ee=m({focus:a().optional(),depth:p([d(1),d(2),d(`1`),d(`2`)]).transform(e=>Number(e)===2?2:1).default(1),data:v.optional(),messaging:v.optional(),time:v.optional(),external:v.optional()});function te(e){let t=ee.safeParse(e);return t.success?t.data:{depth:1}}function ne(e){let t={};e.focus&&(t.focus=e.focus),e.depth===2&&(t.depth=`2`);for(let n of h)e[n]===!1&&(t[n]=`false`);return t}function y(e){return{data:e.data??_.data,messaging:e.messaging??_.messaging,time:e.time??_.time,external:e.external??_.external}}function b(e,t){return{...e,focus:t}}function re(e){let{focus:t,...n}=e;return{...n,depth:e.depth}}function ie(e,t){return{...e,depth:t}}function x(e,t,n){return{...e,[t]:n}}function S(e){return e.startsWith(`sql:`)||e.startsWith(`kv:`)||e.startsWith(`files:`)||e.startsWith(`index:`)?`data`:e.startsWith(`signal:`)?`messaging`:e.startsWith(`channel:`)||e.startsWith(`ai:`)?`external`:null}function ae(e){return e.kind===`signal`?`messaging`:e.kind===`cron`||e.kind===`every`?`time`:null}function C(e){return e.startsWith(`channel:`)||e.startsWith(`ai:`)}function w(e){let t=e.indexOf(`:`);return t===-1?e:e.slice(t+1)}function oe(e){let t=new Set;for(let n of e.flows)for(let e of n.effectRefs)C(e)&&t.add(e);return t.size}function se(e){let t=new Set;for(let n of e.flows)for(let e of n.effectRefs)C(e)&&t.add(e);return[...t].sort()}function ce(e,t){switch(e){case`emit`:return t.startsWith(`signal:`)?t:`signal:${t}`;case`send`:return t.startsWith(`channel:`)?t:`channel:${t}`;case`ask`:return t.startsWith(`ai:`)?t:`ai:${t}`;case`secret`:return t.startsWith(`secret:`)?t:`secret:${t}`;case`call`:return t.startsWith(`flow:`)?t:`flow:${t}`;default:return t}}function T(e,t){return`${e}\0${t}`}function le(e){let t=new Map;for(let n of e){for(let e of n.effects){let r=ce(e.kind,e.resource),i=T(n.flow,r);t.set(i,(t.get(i)??0)+1)}n.parentId}return t}function E(e,t,n){return e.get(T(t,n))??0}function ue(e,t){if(e<=0)return 1;if(t<=1)return 2;let n=e/t;return Math.max(1,Math.min(8,Math.ceil(n*8)))}function D(e){let t=[],n=pe(e);for(let r of e.flows){for(let n of r.causeIds){let i=e.causeById.get(n);if(!i)continue;let a=ae(i);a&&t.push({from:`cause:${i.id}`,to:`flow:${r.id}`,flowId:r.id,layer:a,fromUnit:r.unit,toUnit:r.unit})}for(let i of r.effectRefs){if(i.startsWith(`flow:`)){let e=i.slice(5),n=O(e);t.push({from:`flow:${r.id}`,to:`flow:${e}`,flowId:r.id,ref:i,layer:`call`,fromUnit:r.unit,toUnit:n});continue}let a=S(i);if(!a)continue;let o=C(i)?`external`:de(i,e);if(t.push({from:`flow:${r.id}`,to:i,flowId:r.id,ref:i,layer:a,fromUnit:r.unit,toUnit:o}),a===`messaging`&&i.startsWith(`signal:`)){let a=i.slice(7);for(let o of n.get(a)??[]){let n=e.flowById.get(o);!n||n.id===r.id||t.push({from:`flow:${r.id}`,to:`flow:${n.id}`,flowId:r.id,ref:i,layer:`messaging`,fromUnit:r.unit,toUnit:n.unit})}}}}return t}function de(e,t){let n=t.effectByRef.get(e);if(!n||n.flowIds.length===0)return`shared`;let r=n.flowIds.filter(n=>{let r=t.flowById.get(n);return r?fe(r,e):!1})[0]??n.flowIds[0];return r?O(r):`shared`}function fe(e,t){let n=e.raw.effects;if(!n)return!1;if(t.startsWith(`signal:`)){let e=t.slice(7);return(n.emits??[]).includes(e)}return!!(n.writes??[]).includes(t)}function pe(e){let t=new Map;for(let n of e.flows){let e=n.raw.trigger?.signal;if(!e)continue;let r=t.get(e)??[];r.push(n.id),t.set(e,r)}return t}function O(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function k(e){let t=[];return t.push(...A(e)),t.push(...j(e)),t.push(...M(e)),t.push(...N(e)),t}function A(e){let t=new Map,n=e=>{let n=t.get(e);return n||(n=new Set,t.set(e,n)),n};for(let t of D(e)){if(!t.from.startsWith(`flow:`)||!t.to.startsWith(`flow:`))continue;let e=t.from.slice(5),r=t.to.slice(5);n(e).add(r)}let r=[],i=new Set,a=[],o=new Set,s=e=>{i.add(e),a.push(e),o.add(e);for(let n of t.get(e)??[])if(!i.has(n))s(n);else if(o.has(n)){let e=a.indexOf(n);e!==-1&&r.push([...a.slice(e),n])}a.pop(),o.delete(e)};for(let t of e.flows.map(e=>e.id))i.has(t)||s(t);let c=new Set,l=[];for(let e of r){let t=P(e.slice(0,-1)),n=t.join(`→`);c.has(n)||(c.add(n),l.push({kind:`cycle`,severity:`critical`,title:`Cycle`,detail:`Causal cycle: ${t.join(` → `)}`,nodeIds:t.map(e=>`flow:${e}`)}))}return l}function j(e){if(e.effects.length===0)return[];let t=[...e.effects].filter(e=>e.touchCount>0).sort((e,t)=>t.touchCount-e.touchCount||e.ref.localeCompare(t.ref)),n=t[0];if(!n||n.touchCount<2)return[];let r=t[1]?.touchCount??0;return n.touchCount===r&&t.filter(e=>e.touchCount===n.touchCount).length>1?t.filter(e=>e.touchCount===n.touchCount).map(e=>({kind:`god-node`,severity:`warning`,title:`God node`,detail:`${e.ref} is touched by ${e.touchCount} flows — the most in the system`,nodeIds:[e.ref]})):[{kind:`god-node`,severity:`warning`,title:`God node`,detail:`${n.ref} is touched by ${n.touchCount} flows — the most in the system`,nodeIds:[n.ref]}]}function M(e){let t=[],n=new Set;for(let t of e.effects)t.ref.startsWith(`signal:`)&&n.add(t.ref.slice(7));for(let t of e.flows){for(let e of t.raw.effects?.emits??[])n.add(e);let e=t.raw.trigger?.signal;e&&n.add(e)}for(let r of[...n].sort()){let n=`signal:${r}`,i=e.flows.filter(e=>(e.raw.effects?.emits??[]).includes(r)),a=e.flows.filter(e=>e.raw.trigger?.signal===r);if(i.length===0&&a.length===0){t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} is declared but has no producers and no consumers`,nodeIds:[n]});continue}if(i.length===0){t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} has consumers but no producer`,nodeIds:[n,...a.map(e=>`flow:${e.id}`)]});continue}a.length===0&&t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} is emitted but has no consumers`,nodeIds:[n,...i.map(e=>`flow:${e.id}`)]})}return t}function N(e){let t=[];for(let n of e.effects){if(n.touchCount<2||n.ref.startsWith(`secret:`)||n.ref.startsWith(`channel:`)||n.ref.startsWith(`ai:`))continue;let r=n.flowIds.filter(t=>{let r=e.flowById.get(t);if(!r?.raw.effects)return!1;if(n.ref.startsWith(`signal:`)){let e=n.ref.slice(7);return(r.raw.effects.emits??[]).includes(e)}return(r.raw.effects.writes??[]).includes(n.ref)});if(r.length!==1)continue;let i=r[0];t.push({kind:`spof`,severity:`critical`,title:`Single point of failure`,detail:`${n.ref} is touched by ${n.touchCount} flows but written/emitted by only ${i}`,nodeIds:[n.ref,`flow:${i}`]})}return t}function P(e){if(e.length===0)return[];let t=[...e],n=t.join(`\0`);for(let r=1;r<e.length;r++){let i=[...e.slice(r),...e.slice(0,r)],a=i.join(`\0`);a<n&&(t=i,n=a)}return t}function F(e,t={}){let n=t.focus??null,r=t.depth===2?2:1,i=t.layers??_,a=le(t.runs??[]),o=D(e),s=k(e),c=oe(e);return n?L({graph:e,declared:o,traffic:a,focus:n,depth:r,layers:i,findings:s,crossings:c}):I({graph:e,declared:o,traffic:a,layers:i,findings:s,crossings:c})}function I(e){let{graph:t,declared:n,traffic:r,layers:i,findings:a,crossings:o}=e,s=[...new Set(t.flows.map(e=>e.unit))].sort().map(e=>({id:`unit:${e}`,kind:`unit`,label:e,unit:e,insideBoundary:!0,flowCount:t.flows.filter(t=>t.unit===e).length}));for(let e of se(t))s.push({id:e,kind:`external`,label:w(e),layer:`external`,insideBoundary:!1});let c=new Map;for(let e of n){if(!V(e.layer,i))continue;let t=`unit:${e.fromUnit}`,n=null;if(e.toUnit===`external`||C(e.to))n=e.ref??e.to;else if(e.fromUnit!==e.toUnit)n=`unit:${e.toUnit}`;else continue;if(t===n)continue;let a=`${t}\0${n}\0${e.layer}`,o=e.ref?E(r,e.flowId,e.ref):0,s=c.get(a);s?s.traversals+=o:c.set(a,{from:t,to:n,layer:e.layer,traversals:o,declared:!0})}let l=H(c,!0);return{nodes:U(s),edges:l,boundaryCrossingCount:o,findings:a,focus:null,depth:1,layers:i}}function L(e){let{graph:t,declared:n,traffic:r,focus:i,depth:a,layers:o,findings:s,crossings:c}=e,l=z(t,n,i,a),u=[];for(let e of l){let r=B(t,n,i,e,a);if(e.startsWith(`unit:`)){let n=e.slice(5);u.push({id:e,kind:`unit`,label:n,unit:n,insideBoundary:!0,flowCount:t.flows.filter(e=>e.unit===n).length,focused:e===i,depth:r});continue}if(e.startsWith(`flow:`)){let n=e.slice(5),a=t.flowById.get(n);u.push({id:e,kind:`flow`,label:n,unit:a?.unit??O(n),insideBoundary:!0,focused:e===i,depth:r});continue}if(e.startsWith(`cause:`)){let n=e.slice(6),a=t.causeById.get(n),s=a?.kind===`cron`||a?.kind===`every`?`time`:a?.kind===`signal`?`messaging`:void 0;if(!s||!o[s])continue;u.push({id:e,kind:`resource`,label:a?.label??n,layer:s,insideBoundary:!0,focused:e===i,depth:r});continue}u.push({id:e,kind:C(e)?`external`:`resource`,label:w(e),layer:C(e)?`external`:e.startsWith(`signal:`)?`messaging`:`data`,insideBoundary:!C(e),focused:e===i,depth:r})}u.some(e=>e.id===i)||u.push(...R(t,i));let d=new Map,f=new Set(u.map(e=>e.id));for(let e of n){if(!V(e.layer,o))continue;let t=e.from,n=e.to;if(!f.has(t)||!f.has(n))continue;let i=`${t}\0${n}\0${e.layer}`,a=e.ref?E(r,e.flowId,e.ref):0,s=d.get(i);s?s.traversals+=a:d.set(i,{from:t,to:n,layer:e.layer,traversals:a,declared:!0})}return{nodes:U(u),edges:H(d,!1),boundaryCrossingCount:c,findings:s,focus:i,depth:a,layers:o}}function R(e,t){if(t.startsWith(`unit:`)){let n=t.slice(5);return[{id:t,kind:`unit`,label:n,unit:n,insideBoundary:!0,flowCount:e.flows.filter(e=>e.unit===n).length,focused:!0,depth:0}]}if(t.startsWith(`flow:`)){let n=t.slice(5);return[{id:t,kind:`flow`,label:n,unit:e.flowById.get(n)?.unit??O(n),insideBoundary:!0,focused:!0,depth:0}]}return[{id:t,kind:C(t)?`external`:`resource`,label:w(t),layer:C(t)?`external`:t.startsWith(`signal:`)?`messaging`:`data`,insideBoundary:!C(t),focused:!0,depth:0}]}function z(e,t,n,r){let i=new Set([n]);if(n.startsWith(`unit:`)){let t=n.slice(5);for(let n of e.flows)n.unit===t&&i.add(`flow:${n.id}`)}let a=new Set(i);for(let e=0;e<r;e++){let e=new Set;for(let n of t){let t=n.from,r=n.to;a.has(t)&&e.add(r),a.has(r)&&e.add(t);for(let n of[t,r]){if(!n.startsWith(`flow:`))continue;let t=`unit:${O(n.slice(5))}`;a.has(n)&&e.add(t),a.has(t)&&e.add(n)}}for(let t of e)i.add(t);a=e}return i}function B(e,t,n,r,i){if(n===r)return 0;let a=new Set([n]),o=new Set([n]);for(let n=1;n<=i;n++){let i=new Set;for(let e of t){let t=e.from,s=e.to;for(let[e,c]of[[t,s],[s,t]])if(o.has(e)){if(c===r)return n;a.has(c)||(a.add(c),i.add(c))}}for(let t of o){if(t.startsWith(`flow:`)){let e=`unit:${O(t.slice(5))}`;if(e===r)return n;a.has(e)||(a.add(e),i.add(e))}if(t.startsWith(`unit:`)){let o=t.slice(5);for(let t of e.flows){if(t.unit!==o)continue;let e=`flow:${t.id}`;if(e===r)return n;a.has(e)||(a.add(e),i.add(e))}}}o=i}return i}function V(e,t){return e===`call`||t[e]}function H(e,t){let n=Math.max(0,...[...e.values()].map(e=>e.traversals));return[...e.values()].map(e=>({id:`${e.from}->${e.to}:${e.layer}`,from:e.from,to:e.to,layer:e.layer,declared:e.declared,traversals:e.traversals,dashed:e.declared&&e.traversals===0,thickness:ue(e.traversals,n),aggregated:t})).sort((e,t)=>e.id.localeCompare(t.id))}function U(e){let t=new Map;for(let n of e)t.has(n.id)||t.set(n.id,n);return[...t.values()].sort((e,t)=>e.id.localeCompare(t.id))}function W(e){let t={...e.dimensions??{}};return t.flow===void 0&&(t.flow=e.flow),t.unit===void 0&&(t.unit=e.unit??null),t.trigger===void 0&&(t.trigger=e.trigger),t.plane===void 0&&(t.plane=e.plane),t.tenant===void 0&&(t.tenant=e.tenant??null),t.principal===void 0&&(t.principal=e.principal??null),t.cache===void 0&&(t.cache=e.cache??`none`),t.duration_ms===void 0&&(t.duration_ms=e.durationMs),t.error_code===void 0&&e.error&&(t.error_code=e.error),{id:e.id,parentId:e.parentId??null,flow:e.flow,unit:e.unit??null,trigger:e.trigger,plane:e.plane,tenant:e.tenant??null,principal:e.principal??null,gates:e.gates??[],cache:e.cache??`none`,replica:e.replica??null,replicaLagMs:e.replicaLagMs??null,cost:e.cost??null,promptVersion:e.promptVersion??null,buildVersion:e.buildVersion??null,startedAt:e.startedAt,endedAt:e.endedAt,durationMs:e.durationMs,error:e.error??null,effects:e.effects??[],logs:e.logs??[],dimensions:t}}function me(e){return{id:e.id,...e.parentId?{parentId:e.parentId}:{},flow:e.flow,...e.unit?{unit:e.unit}:{},trigger:e.trigger,plane:e.plane,tenant:e.tenant,principal:e.principal,gates:e.gates,cache:e.cache,...e.replica?{replica:e.replica}:{},...e.replicaLagMs==null?{}:{replicaLagMs:e.replicaLagMs},...e.cost==null?{}:{cost:e.cost},...e.promptVersion==null?{}:{promptVersion:e.promptVersion},...e.buildVersion?{buildVersion:e.buildVersion}:{},error:e.error?{code:e.error}:null,effects:e.effects,logs:e.logs,durationMs:e.durationMs,startedAt:e.startedAt,endedAt:e.endedAt,dimensions:{...e.dimensions}}}var G=e(s(),1),K={x:32,y:40,width:440,height:300};function he(e){let t=e.filter(e=>e.insideBoundary),n=e.filter(e=>!e.insideBoundary),r=new Map,i=Math.max(1,Math.ceil(Math.sqrt(t.length))),a=K.width/(i+1),o=Math.max(1,Math.ceil(t.length/i)),s=K.height/(o+1);return t.forEach((e,t)=>{let n=t%i,o=Math.floor(t/i);r.set(e.id,{id:e.id,x:K.x+a*(n+1),y:K.y+s*(o+1)})}),n.forEach((e,t)=>{r.set(e.id,{id:e.id,x:K.x+K.width+96,y:K.y+48+t*56})}),r}var q={read:`none`,write:`reversible`,emit:`deferred`,send:`irreversible`,ask:`irreversible`,secret:`capability`,call:`portal`};function ge(e){return q[e]}Object.entries(q).map(([e,t])=>({kind:e,reversibility:t}));function _e(e,t={}){if(!e)return[];let n=t.touchCounts,r=t.emitFanOut,i=[],a=(e,a,o)=>{for(let s of o??[])i.push({tier:e,kind:a,ref:s,reversibility:ge(a),touchCount:n?.get(s)??1,fanOut:a===`emit`?r?.get(s)??0:void 0,transitive:t.transitive})};return a(`reads`,`read`,e.reads),a(`writes`,`write`,e.writes),a(`emits`,`emit`,e.emits),a(`external`,`send`,e.sends),a(`external`,`ask`,e.asks),a(`capabilities`,`secret`,e.secrets),i}function J(e){return e?(e.sends?.length??0)>0||(e.asks?.length??0)>0?`external`:(e.secrets?.length??0)>0?`capabilities`:(e.emits?.length??0)>0?`emits`:(e.writes?.length??0)>0?`writes`:(e.reads?.length??0)>0?`reads`:`none`:`none`}function Y(e){return ve(J(e))}function ve(e){return e===`external`}var ye=[`reads`,`writes`,`emits`,`external`,`capabilities`],be={reads:`Reads`,writes:`Writes`,emits:`Emits`,external:`External`,capabilities:`Capabilities`};function xe(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function Se(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(t+1)}function Ce(e,t,n){let r=[];if(e?.http){let n=`http:${e.http.method}:${e.http.path}`;r.push({id:n,kind:`http`,label:`${e.http.method} ${e.http.path}`,flowIds:[t]})}if(e?.signal&&r.push({id:`signal:${e.signal}`,kind:`signal`,label:e.signal,flowIds:[t]}),e?.cron&&r.push({id:`cron:${e.cron}`,kind:`cron`,label:e.cron,flowIds:[t]}),e?.every&&r.push({id:`every:${e.every}`,kind:`every`,label:`every ${e.every}`,flowIds:[t]}),e?.cdc){let n=e.cdc.column?`.${e.cdc.column}`:``,i=`cdc:${e.cdc.table}${n}`;r.push({id:i,kind:`cdc`,label:`cdc ${e.cdc.table}${n}`,flowIds:[t]})}if(r.length===0)for(let e of n)r.push({id:`caller:${e}`,kind:`caller`,label:e,flowIds:[t]});return r}function X(e){if(!e)return[];let t=[];for(let n of e.reads??[])t.push(n);for(let n of e.writes??[])t.push(n);for(let n of e.emits??[])t.push(`signal:${n}`);for(let n of e.sends??[])t.push(`channel:${n}`);for(let n of e.asks??[])t.push(`ai:${n}`);for(let n of e.secrets??[])t.push(`secret:${n}`);for(let n of e.calls??[])t.push(`flow:${n}`);return t}function Z(e){return!e||typeof e==`string`?null:e}function we(e){return e.errors?Array.isArray(e.errors)?[...e.errors]:Object.keys(e.errors):[]}function Q(e){let t=e?.flows??{},n=Object.keys(t).sort(),r=new Map;for(let e of n){let n=t[e]?.effects?.calls??[];for(let t of n){let n=r.get(t)??[];n.push(e),r.set(t,n)}}let i=new Map;for(let e of n){let n=t[e]?.trigger?.signal;if(!n)continue;let r=i.get(n)??[];r.push(e),i.set(n,r)}let a=new Map,o=new Map,s=[];for(let e of n){let n=t[e];if(!n)continue;let c=r.get(e)??[],l=Ce(n.trigger,e,c);for(let t of l){let n=a.get(t.id);n?a.set(t.id,{...n,flowIds:[...new Set([...n.flowIds,e])]}):a.set(t.id,t)}let u=new Map,d=new Map;for(let e of n.effects?.emits??[])d.set(e,i.get(e)?.length??0);let f=_e(n.effects,{touchCounts:u,emitFanOut:d}),p=X(n.effects);for(let t of f){let n=t.kind===`emit`?`signal:${t.ref}`:t.kind===`send`?`channel:${t.ref}`:t.kind===`ask`?`ai:${t.ref}`:t.kind===`secret`?`secret:${t.ref}`:t.kind===`call`?`flow:${t.ref}`:t.ref,r=o.get(n);r?(r.flowIds.push(e),r.fanOut=Math.max(r.fanOut,t.fanOut??0)):o.set(n,{tier:t.tier,flowIds:[e],fanOut:t.fanOut??0})}s.push({id:e,unit:xe(e),action:Se(e),plane:n.plane??`user`,causeIds:l.map(e=>e.id),effectRefs:p,effects:f,peakTier:J(n.effects),external:Y(n.effects),flags:{durable:n.durable===!0,live:n.live===!0,cached:n.cache!==void 0&&n.cache!==!1,costsMoney:(n.cost?.estimatePerCall??0)>0,readsSecret:(n.effects?.secrets?.length??0)>0,touchesPii:n.pii!==void 0||n.allowPii===!0,external:Y(n.effects)},inSchema:Z(n.in),outSchema:Z(n.out),errorNames:we(n),source:n.source,deprecated:!!n.deprecated,raw:n})}if(e?.stores){for(let t of Object.values(e.stores))if(t.facet===`sql`&&t.tables)for(let e of Object.keys(t.tables)){let t=`sql:${e}`;o.has(t)||o.set(t,{tier:`reads`,flowIds:[],fanOut:0})}}if(e?.signals)for(let t of Object.keys(e.signals)){let e=`signal:${t}`;o.has(e)||o.set(e,{tier:`emits`,flowIds:[],fanOut:0})}if(e?.channels)for(let t of Object.keys(e.channels)){let e=`channel:${t}`;o.has(e)||o.set(e,{tier:`external`,flowIds:[],fanOut:0})}if(e?.vault)for(let t of Object.keys(e.vault)){let e=`secret:${t}`;o.has(e)||o.set(e,{tier:`capabilities`,flowIds:[],fanOut:0})}let c=[...a.values()].sort((e,t)=>e.label.localeCompare(t.label)),l=[...o.entries()].map(([e,t])=>({ref:e,tier:t.tier,flowIds:[...new Set(t.flowIds)].sort(),touchCount:new Set(t.flowIds).size,fanOut:t.fanOut})).sort((e,t)=>t.touchCount-e.touchCount||e.ref.localeCompare(t.ref));return{causes:c,flows:s,effects:l,causeById:new Map(c.map(e=>[e.id,e])),flowById:new Map(s.map(e=>[e.id,e])),effectByRef:new Map(l.map(e=>[e.ref,e]))}}function Te(e,t){let n=null;if(t.sel===`cause`&&t.cause){let r=e.causeById.get(t.cause);n=new Set(r?.flowIds??[])}else if(t.sel===`effect`&&t.effect){let r=e.effectByRef.get(t.effect);n=new Set(r?.flowIds??[])}else t.sel===`flow`&&t.flow&&(n=new Set([t.flow]));return e.flows.map(e=>{let r=n===null||n.has(e.id),i=Oe(e,t.q),a=!t.unit||e.unit===t.unit,o=r&&i&&a;return{...e,match:o,related:r}})}function Ee(e,t){let n=null;if(t.sel===`flow`&&t.flow){let r=e.flowById.get(t.flow);n=new Set(r?.causeIds??[])}else if(t.sel===`effect`&&t.effect){let r=e.effectByRef.get(t.effect),i=new Set;for(let t of r?.flowIds??[]){let n=e.flowById.get(t);for(let e of n?.causeIds??[])i.add(e)}n=i}return e.causes.map(e=>{let r=n===null||n.has(e.id),i=!t.q||e.label.toLowerCase().includes(t.q.toLowerCase())||e.id.toLowerCase().includes(t.q.toLowerCase());return{...e,match:r&&i,related:r}})}function De(e,t,n={}){let r=null;if(t.sel===`flow`&&t.flow){let n=e.flowById.get(t.flow);r=new Set(n?.effectRefs??[])}else if(t.sel===`cause`&&t.cause){let n=e.causeById.get(t.cause),i=new Set;for(let t of n?.flowIds??[]){let n=e.flowById.get(t);for(let e of n?.effectRefs??[])i.add(e)}r=i}let i=n.ubiquitousThreshold??8;return e.effects.map(e=>{let a=r===null||r.has(e.ref),o=!t.q||e.ref.toLowerCase().includes(t.q.toLowerCase()),s=!n.hideUbiquitous||e.touchCount<i||r!==null;return{...e,match:a&&o&&s,related:a}})}function Oe(e,t){if(!t?.trim())return!0;let n=t.toLowerCase();return e.id.toLowerCase().includes(n)||e.unit.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)}var $=l();function ke(){let e=f({from:`/architecture`}),t=n({from:`/architecture`}),i=e=>{t({search:ne(e),replace:!0})},a=r({queryKey:[`console.manifest.get`],queryFn:async()=>{let e=await o.manifestGet();if(e.error)throw Error(e.error.code);return e.data.manifest}}),s=r({queryKey:[`console.runs.list`],queryFn:async()=>{let e=await o.runsList();if(e.error)throw Error(e.error.code);return e.data.runs.map(W)},refetchInterval:1e4}),l=(0,G.useMemo)(()=>Q(a.data),[a.data]),d=y(e),p=(0,G.useMemo)(()=>F(l,{focus:e.focus??null,depth:e.depth,layers:y(e),runs:s.data??[]}),[l,e.focus,e.depth,e.data,e.messaging,e.time,e.external,s.data]),m=(0,G.useMemo)(()=>he(p.nodes),[p.nodes]);return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-4 border-b border-[var(--oke-line)] px-6 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`p`,{className:`text-xs uppercase tracking-[0.2em] text-[var(--oke-muted)]`,children:`Architecture`}),(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`System shape`}),(0,$.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Clustered by unit · typed layers · traffic from Runs`})]}),(0,$.jsxs)(`p`,{className:`ml-auto font-mono text-sm`,role:`status`,"aria-live":`polite`,children:[(0,$.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Boundary crossings`}),` `,(0,$.jsx)(`span`,{className:`text-lg font-semibold tabular-nums`,children:p.boundaryCrossingCount})]})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-0 lg:flex-row`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-4 border-b border-[var(--oke-line)] px-6 py-3`,children:[(0,$.jsxs)(`fieldset`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Element layers`}),(0,$.jsx)(`span`,{className:`text-xs uppercase tracking-[0.15em] text-[var(--oke-muted)]`,children:`Layers`}),h.map(t=>(0,$.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:d[t],onChange:n=>i(x(e,t,n.target.checked)),"aria-label":`${g[t]} layer`}),g[t]]},t))]}),e.focus?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsxs)(`fieldset`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Focus depth`}),(0,$.jsx)(`span`,{className:`text-xs text-[var(--oke-muted)]`,children:`Depth`}),[1,2].map(t=>(0,$.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-1.5 text-sm`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`arch-depth`,checked:e.depth===t,onChange:()=>i(ie(e,t))}),t]},t))]}),(0,$.jsx)(c,{type:`button`,variant:`ghost`,onClick:()=>i(re(e)),children:`Clear focus`})]}):(0,$.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Select a unit to focus at depth 1–2`})]}),(0,$.jsxs)(`section`,{"aria-label":`System diagram`,className:`min-h-0 flex-1 overflow-auto px-4 py-4`,children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`mb-4 overflow-x-auto`,children:(0,$.jsxs)(`svg`,{className:`h-auto w-full max-w-5xl text-[var(--oke-fg)]`,viewBox:`0 0 640 380`,children:[(0,$.jsx)(`rect`,{x:K.x,y:K.y,width:K.width,height:K.height,fill:`color-mix(in oklab, var(--oke-fg) 3%, transparent)`,stroke:`var(--oke-muted)`,strokeDasharray:`8 5`,strokeWidth:1.5,rx:4}),(0,$.jsxs)(`text`,{x:K.x+12,y:K.y+18,className:`fill-[var(--oke-muted)]`,fontSize:11,fontFamily:`var(--oke-mono)`,children:[`System boundary · `,p.boundaryCrossingCount,` crossings`]}),p.edges.map(e=>{let t=m.get(e.from),n=m.get(e.to);return!t||!n?null:(0,$.jsx)(`line`,{x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:e.layer===`external`?`var(--oke-external)`:`var(--oke-muted)`,strokeWidth:e.thickness,strokeDasharray:e.dashed?`6 4`:void 0,opacity:e.dashed?.55:.9},e.id)}),p.nodes.map(e=>{let t=m.get(e.id);if(!t)return null;let n=e.kind===`unit`?28:22;return(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`circle`,{cx:t.x,cy:t.y,r:n,fill:e.focused?`var(--oke-accent)`:e.insideBoundary?`var(--oke-bg)`:`color-mix(in oklab, var(--oke-external) 25%, var(--oke-bg))`,stroke:e.insideBoundary?`var(--oke-fg)`:`var(--oke-external)`,strokeWidth:e.focused?2.5:1.25}),(0,$.jsx)(`text`,{x:t.x,y:t.y+4,textAnchor:`middle`,fontSize:10,fontFamily:`var(--oke-mono)`,className:`fill-[var(--oke-fg)]`,children:Ae(e.label,12)})]},e.id)})]})}),(0,$.jsx)(`ul`,{"aria-label":`Nodes`,className:`flex flex-wrap gap-2 border-t border-[var(--oke-line)] pt-4`,children:p.nodes.map(t=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t.focused===!0,className:u(`inline-flex min-h-8 items-center gap-2 border px-3 text-sm`,t.focused?`border-[var(--oke-accent)] text-[var(--oke-fg)]`:`border-[var(--oke-line)] text-[var(--oke-muted)]`),onClick:()=>i(b(e,t.id)),children:[(0,$.jsx)(`span`,{children:t.label}),t.kind===`unit`&&t.flowCount!==void 0?(0,$.jsx)(`span`,{className:`font-mono text-xs`,children:t.flowCount}):null,t.insideBoundary?null:(0,$.jsx)(`span`,{className:`text-xs text-[var(--oke-external)]`,children:`external`})]})},t.id))}),(0,$.jsx)(`ul`,{className:`sr-only`,"aria-label":`Edges`,children:p.edges.map(e=>(0,$.jsxs)(`li`,{children:[e.from,` → `,e.to,e.dashed?` (declared, never traversed)`:` · ${e.traversals} traversals`,` · ${e.layer}`]},e.id))})]})]}),(0,$.jsxs)(`aside`,{"aria-label":`Findings`,className:`w-full shrink-0 overflow-auto border-t border-[var(--oke-line)] lg:w-80 lg:border-l lg:border-t-0`,children:[(0,$.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-medium`,children:`Findings`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-[var(--oke-muted)]`,children:`Pathologies from the graph as data`})]}),p.findings.length===0?(0,$.jsx)(`p`,{className:`px-5 pb-4 text-sm text-[var(--oke-muted)]`,children:`No pathologies detected.`}):(0,$.jsx)(`ul`,{className:`divide-y divide-[var(--oke-line)] border-t border-[var(--oke-line)]`,children:p.findings.map((t,n)=>(0,$.jsxs)(`li`,{className:`px-5 py-3`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,$.jsx)(`span`,{className:u(`inline-block size-1.5 rounded-full`,t.severity===`critical`?`bg-[var(--oke-danger)]`:`bg-[var(--oke-external)]`),"aria-hidden":!0}),t.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:t.detail}),t.nodeIds[0]?(0,$.jsx)(`button`,{type:`button`,className:`mt-2 min-h-8 text-sm text-[var(--oke-accent)] underline-offset-2 hover:underline`,onClick:()=>i(b(e,t.nodeIds[0])),children:`Focus`}):null]},`${t.kind}-${n}`))})]})]})]})}function Ae(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}var je=t({default:()=>ke});export{De as a,W as c,te as d,Ee as i,me as l,Q as n,be as o,Te as r,ye as s,je as t,A as u};
|