salidium 0.3.0 → 0.4.1
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/README.md +9 -0
- package/THIRD_PARTY_NOTICES +38 -0
- package/bundle/native/SalidiumMenuBar.swift +383 -0
- package/bundle/salidium.mjs +9217 -3542
- package/bundle/ui/assets/index-YXUyKAPE.js +78 -0
- package/bundle/ui/assets/index-oV3BVDrO.css +1 -0
- package/bundle/ui/assets/react-runtime-DfSeidf4.js +9 -0
- package/bundle/ui/assets/rolldown-runtime-CbXtAM7H.js +1 -0
- package/bundle/ui/assets/ui-runtime-C1c-P_PN.js +1 -0
- package/bundle/ui/index.html +5 -2
- package/package.json +3 -2
- package/bundle/ui/assets/index-D4Id-7NF.css +0 -1
- package/bundle/ui/assets/index-D7VTE7Js.js +0 -86
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{i as t,n,t as r}from"./react-runtime-DfSeidf4.js";import{n as i,t as a}from"./ui-runtime-C1c-P_PN.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var o;function s(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var c=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},l=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(o=globalThis).__zod_globalConfig??(o.__zod_globalConfig={});var u=globalThis.__zod_globalConfig;function d(e){return e&&Object.assign(u,e),u}function f(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function p(e,t){return typeof t==`bigint`?t.toString():t}function m(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function h(e){return e==null}function g(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function _(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var v=Symbol(`evaluating`);function y(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==v)return r===void 0&&(r=v,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function b(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function x(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function S(e){return JSON.stringify(e)}function ee(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var te=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var C=m(()=>{if(u.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function re(e){if(ne(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return ne(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function ie(e){return re(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var ae=new Set([`string`,`number`,`symbol`]);function oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function se(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function w(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ce(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var le={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ue(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return se(e,x(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return b(this,`shape`,e),e},checks:[]}))}function de(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return se(e,x(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return b(this,`shape`,r),r},checks:[]}))}function fe(e,t){if(!re(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return se(e,x(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return b(this,`shape`,n),n}}))}function pe(e,t){if(!re(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return se(e,x(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return b(this,`shape`,n),n}}))}function me(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return se(e,x(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return b(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function he(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return se(t,x(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return b(this,`shape`,i),i},checks:[]}))}function ge(e,t,n){return se(t,x(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return b(this,`shape`,i),i}}))}function _e(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ve(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ye(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function be(e){return typeof e==`string`?e:e?.message}function xe(e,t,n){let r=e.message?e.message:be(e.inst?._zod.def?.error?.(e))??be(t?.error?.(e))??be(n.customError?.(e))??be(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Se(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Ce(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var we=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,p,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Te=s(`$ZodError`,we),Ee=s(`$ZodError`,we,{Parent:Error});function De(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Oe(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var T=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new c;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>xe(e,a,d())));throw te(t,i?.callee),t}return o.value},ke=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>xe(e,a,d())));throw te(t,i?.callee),t}return o.value},Ae=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new c;return a.issues.length?{success:!1,error:new(e??Te)(a.issues.map(e=>xe(e,i,d())))}:{success:!0,data:a.value}},je=Ae(Ee),Me=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>xe(e,i,d())))}:{success:!0,data:a.value}},Ne=Me(Ee),Pe=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return T(e)(t,n,i)},Fe=e=>(t,n,r)=>T(e)(t,n,r),Ie=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ke(e)(t,n,i)},Le=e=>async(t,n,r)=>ke(e)(t,n,r),Re=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ae(e)(t,n,i)},ze=e=>(t,n,r)=>Ae(e)(t,n,r),Be=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Me(e)(t,n,i)},Ve=e=>async(t,n,r)=>Me(e)(t,n,r),He=/^[cC][0-9a-z]{6,}$/,Ue=/^[0-9a-z]+$/,We=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ge=/^[0-9a-vA-V]{20}$/,Ke=/^[A-Za-z0-9]{27}$/,qe=/^[a-zA-Z0-9_-]{21}$/,Je=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ye=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Xe=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ze=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Qe=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function $e(){return new RegExp(Qe,`u`)}var et=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,tt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,nt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,rt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,it=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,at=/^[A-Za-z0-9_-]*$/,ot=/^https?$/,st=/^\+[1-9]\d{6,14}$/,ct=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,lt=RegExp(`^${ct}$`);function ut(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function dt(e){return RegExp(`^${ut(e)}$`)}function ft(e){let t=ut({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${ct}T(?:${r})$`)}var pt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},mt=/^-?\d+$/,ht=/^-?\d+(?:\.\d+)?$/,gt=/^(?:true|false)$/i,_t=/^null$/i,vt=/^[^A-Z]*$/,yt=/^[^a-z]*$/,E=s(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),bt={number:`number`,bigint:`bigint`,object:`date`},xt=s(`$ZodCheckLessThan`,(e,t)=>{E.init(e,t);let n=bt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),St=s(`$ZodCheckGreaterThan`,(e,t)=>{E.init(e,t);let n=bt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ct=s(`$ZodCheckMultipleOf`,(e,t)=>{E.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):_(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),wt=s(`$ZodCheckNumberFormat`,(e,t)=>{E.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=le[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=mt)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Tt=s(`$ZodCheckMaxLength`,(e,t)=>{var n;E.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!h(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Se(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Et=s(`$ZodCheckMinLength`,(e,t)=>{var n;E.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!h(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Se(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Dt=s(`$ZodCheckLengthEquals`,(e,t)=>{var n;E.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!h(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Se(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ot=s(`$ZodCheckStringFormat`,(e,t)=>{var n,r;E.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),kt=s(`$ZodCheckRegex`,(e,t)=>{Ot.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),At=s(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=vt,Ot.init(e,t)}),jt=s(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=yt,Ot.init(e,t)}),Mt=s(`$ZodCheckIncludes`,(e,t)=>{E.init(e,t);let n=oe(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Nt=s(`$ZodCheckStartsWith`,(e,t)=>{E.init(e,t);let n=RegExp(`^${oe(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Pt=s(`$ZodCheckEndsWith`,(e,t)=>{E.init(e,t);let n=RegExp(`.*${oe(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ft=s(`$ZodCheckOverwrite`,(e,t)=>{E.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),It=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
2
|
+
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
3
|
+
`))}},Lt={major:4,minor:4,patch:3},D=s(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Lt;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=_e(e),i;for(let a of t){if(a._zod.def.when){if(ve(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new c;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=_e(e,t))});else{if(e.issues.length===t)continue;r||=_e(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(_e(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new c;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new c;return o.then(e=>t(e,r,a))}return t(o,r,a)}}y(e,`~standard`,()=>({validate:t=>{try{let n=je(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Ne(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Rt=s(`$ZodString`,(e,t)=>{D.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??pt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),O=s(`$ZodStringFormat`,(e,t)=>{Ot.init(e,t),Rt.init(e,t)}),zt=s(`$ZodGUID`,(e,t)=>{t.pattern??=Ye,O.init(e,t)}),Bt=s(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Xe(e)}else t.pattern??=Xe();O.init(e,t)}),Vt=s(`$ZodEmail`,(e,t)=>{t.pattern??=Ze,O.init(e,t)}),Ht=s(`$ZodURL`,(e,t)=>{O.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===ot.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Ut=s(`$ZodEmoji`,(e,t)=>{t.pattern??=$e(),O.init(e,t)}),Wt=s(`$ZodNanoID`,(e,t)=>{t.pattern??=qe,O.init(e,t)}),Gt=s(`$ZodCUID`,(e,t)=>{t.pattern??=He,O.init(e,t)}),Kt=s(`$ZodCUID2`,(e,t)=>{t.pattern??=Ue,O.init(e,t)}),qt=s(`$ZodULID`,(e,t)=>{t.pattern??=We,O.init(e,t)}),Jt=s(`$ZodXID`,(e,t)=>{t.pattern??=Ge,O.init(e,t)}),Yt=s(`$ZodKSUID`,(e,t)=>{t.pattern??=Ke,O.init(e,t)}),Xt=s(`$ZodISODateTime`,(e,t)=>{t.pattern??=ft(t),O.init(e,t)}),Zt=s(`$ZodISODate`,(e,t)=>{t.pattern??=lt,O.init(e,t)}),Qt=s(`$ZodISOTime`,(e,t)=>{t.pattern??=dt(t),O.init(e,t)}),$t=s(`$ZodISODuration`,(e,t)=>{t.pattern??=Je,O.init(e,t)}),en=s(`$ZodIPv4`,(e,t)=>{t.pattern??=et,O.init(e,t),e._zod.bag.format=`ipv4`}),tn=s(`$ZodIPv6`,(e,t)=>{t.pattern??=tt,O.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),nn=s(`$ZodCIDRv4`,(e,t)=>{t.pattern??=nt,O.init(e,t)}),rn=s(`$ZodCIDRv6`,(e,t)=>{t.pattern??=rt,O.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function an(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var on=s(`$ZodBase64`,(e,t)=>{t.pattern??=it,O.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{an(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function sn(e){if(!at.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return an(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var cn=s(`$ZodBase64URL`,(e,t)=>{t.pattern??=at,O.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{sn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ln=s(`$ZodE164`,(e,t)=>{t.pattern??=st,O.init(e,t)});function un(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var dn=s(`$ZodJWT`,(e,t)=>{O.init(e,t),e._zod.check=n=>{un(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),fn=s(`$ZodNumber`,(e,t)=>{D.init(e,t),e._zod.pattern=e._zod.bag.pattern??ht,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),pn=s(`$ZodNumberFormat`,(e,t)=>{wt.init(e,t),fn.init(e,t)}),mn=s(`$ZodBoolean`,(e,t)=>{D.init(e,t),e._zod.pattern=gt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),hn=s(`$ZodNull`,(e,t)=>{D.init(e,t),e._zod.pattern=_t,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),gn=s(`$ZodUnknown`,(e,t)=>{D.init(e,t),e._zod.parse=e=>e}),_n=s(`$ZodNever`,(e,t)=>{D.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function vn(e,t,n){e.issues.length&&t.issues.push(...ye(n,e.issues)),t.value[n]=e.value}var yn=s(`$ZodArray`,(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>vn(t,n,e))):vn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function bn(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...ye(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function xn(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=ce(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Sn(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>bn(e,n,i,t,u,d))):bn(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Cn=s(`$ZodObject`,(e,t)=>{if(D.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=m(()=>xn(t));y(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=ne,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>bn(n,t,e,s,r,i))):bn(a,t,e,s,r,i)}return i?Sn(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),wn=s(`$ZodObjectJIT`,(e,t)=>{Cn.init(e,t);let n=e._zod.parse,r=m(()=>xn(t)),i=e=>{let t=new It([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=S(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=S(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
4
|
+
if (${n}.issues.length) {
|
|
5
|
+
if (${o} in input) {
|
|
6
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
7
|
+
...iss,
|
|
8
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
9
|
+
})));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (${n}.value === undefined) {
|
|
14
|
+
if (${o} in input) {
|
|
15
|
+
newResult[${o}] = undefined;
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
newResult[${o}] = ${n}.value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
`):c?t.write(`
|
|
22
|
+
if (${n}.issues.length) {
|
|
23
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
24
|
+
...iss,
|
|
25
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
26
|
+
})));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (${n}.value === undefined) {
|
|
30
|
+
if (${o} in input) {
|
|
31
|
+
newResult[${o}] = undefined;
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
newResult[${o}] = ${n}.value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
`):t.write(`
|
|
38
|
+
const ${n}_present = ${o} in input;
|
|
39
|
+
if (${n}.issues.length) {
|
|
40
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
41
|
+
...iss,
|
|
42
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
43
|
+
})));
|
|
44
|
+
}
|
|
45
|
+
if (!${n}_present && !${n}.issues.length) {
|
|
46
|
+
payload.issues.push({
|
|
47
|
+
code: "invalid_type",
|
|
48
|
+
expected: "nonoptional",
|
|
49
|
+
input: undefined,
|
|
50
|
+
path: [${o}]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (${n}_present) {
|
|
55
|
+
if (${n}.value === undefined) {
|
|
56
|
+
newResult[${o}] = undefined;
|
|
57
|
+
} else {
|
|
58
|
+
newResult[${o}] = ${n}.value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=ne,s=!u.jitless,c=s&&C.value,l=t.catchall,d;e._zod.parse=(u,f)=>{d??=r.value;let p=u.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),u=a(u,f),l?Sn([],p,u,f,d,e):u):n(u,f):(u.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),u)}});function Tn(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=>!_e(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=>xe(e,r,d())))}),t)}var En=s(`$ZodUnion`,(e,t)=>{D.init(e,t),y(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),y(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),y(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),y(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=>g(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=>Tn(t,r,e,i)):Tn(o,r,e,i)}}),Dn=s(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,En.init(e,t);let n=e._zod.parse;y(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=m(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!ne(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),On=s(`$ZodIntersection`,(e,t)=>{D.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])=>An(e,t,n)):An(e,i,a)}});function kn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(re(e)&&re(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=kn(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=kn(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 An(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}),_e(e))return e;let o=kn(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var jn=s(`$ZodRecord`,(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!re(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>xe(e,r,d())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...ye(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...ye(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&ht.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>xe(e,r,d())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...ye(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...ye(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Mn=s(`$ZodEnum`,(e,t)=>{D.init(e,t);let n=f(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ae.has(typeof e)).map(e=>typeof e==`string`?oe(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}}),Nn=s(`$ZodLiteral`,(e,t)=>{if(D.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`?oe(e):e?oe(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}}),Pn=s(`$ZodTransform`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new l(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 c;return n.value=i,n.fallback=!0,n}});function Fn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var In=s(`$ZodOptional`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,y(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),y(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${g(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=>Fn(e,r)):Fn(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Ln=s(`$ZodExactOptional`,(e,t)=>{In.init(e,t),y(e._zod,`values`,()=>t.innerType._zod.values),y(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Rn=s(`$ZodNullable`,(e,t)=>{D.init(e,t),y(e._zod,`optin`,()=>t.innerType._zod.optin),y(e._zod,`optout`,()=>t.innerType._zod.optout),y(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${g(e.source)}|null)$`):void 0}),y(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)}),zn=s(`$ZodDefault`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,y(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=>Bn(e,t)):Bn(r,t)}});function Bn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Vn=s(`$ZodPrefault`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,y(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))}),Hn=s(`$ZodNonOptional`,(e,t)=>{D.init(e,t),y(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=>Un(t,e)):Un(i,e)}});function Un(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 Wn=s(`$ZodCatch`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,y(e._zod,`optout`,()=>t.innerType._zod.optout),y(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=>xe(e,n,d()))},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=>xe(e,n,d()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Gn=s(`$ZodPipe`,(e,t)=>{D.init(e,t),y(e._zod,`values`,()=>t.in._zod.values),y(e._zod,`optin`,()=>t.in._zod.optin),y(e._zod,`optout`,()=>t.out._zod.optout),y(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=>Kn(e,t.in,n)):Kn(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Kn(e,t.out,n)):Kn(r,t.out,n)}});function Kn(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 qn=s(`$ZodReadonly`,(e,t)=>{D.init(e,t),y(e._zod,`propValues`,()=>t.innerType._zod.propValues),y(e._zod,`values`,()=>t.innerType._zod.values),y(e._zod,`optin`,()=>t.innerType?._zod?.optin),y(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(Jn):Jn(r)}});function Jn(e){return e.value=Object.freeze(e.value),e}var Yn=s(`$ZodCustom`,(e,t)=>{E.init(e,t),D.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=>Xn(t,n,r,e));Xn(i,n,r,e)}});function Xn(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(Ce(e))}}var Zn,Qn=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 $n(){return new Qn}(Zn=globalThis).__zod_globalRegistry??(Zn.__zod_globalRegistry=$n());var er=globalThis.__zod_globalRegistry;function tr(e,t){return new e({type:`string`,...w(t)})}function nr(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...w(t)})}function rr(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...w(t)})}function ir(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...w(t)})}function ar(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...w(t)})}function or(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...w(t)})}function sr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...w(t)})}function cr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...w(t)})}function lr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...w(t)})}function ur(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...w(t)})}function dr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...w(t)})}function fr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...w(t)})}function pr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...w(t)})}function mr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...w(t)})}function hr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...w(t)})}function gr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...w(t)})}function _r(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...w(t)})}function vr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...w(t)})}function yr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...w(t)})}function br(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...w(t)})}function xr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...w(t)})}function Sr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...w(t)})}function Cr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...w(t)})}function wr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...w(t)})}function Tr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...w(t)})}function Er(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...w(t)})}function Dr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...w(t)})}function Or(e,t){return new e({type:`number`,checks:[],...w(t)})}function kr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...w(t)})}function Ar(e,t){return new e({type:`boolean`,...w(t)})}function jr(e,t){return new e({type:`null`,...w(t)})}function Mr(e){return new e({type:`unknown`})}function Nr(e,t){return new e({type:`never`,...w(t)})}function Pr(e,t){return new xt({check:`less_than`,...w(t),value:e,inclusive:!1})}function Fr(e,t){return new xt({check:`less_than`,...w(t),value:e,inclusive:!0})}function Ir(e,t){return new St({check:`greater_than`,...w(t),value:e,inclusive:!1})}function Lr(e,t){return new St({check:`greater_than`,...w(t),value:e,inclusive:!0})}function Rr(e,t){return new Ct({check:`multiple_of`,...w(t),value:e})}function zr(e,t){return new Tt({check:`max_length`,...w(t),maximum:e})}function Br(e,t){return new Et({check:`min_length`,...w(t),minimum:e})}function Vr(e,t){return new Dt({check:`length_equals`,...w(t),length:e})}function Hr(e,t){return new kt({check:`string_format`,format:`regex`,...w(t),pattern:e})}function Ur(e){return new At({check:`string_format`,format:`lowercase`,...w(e)})}function Wr(e){return new jt({check:`string_format`,format:`uppercase`,...w(e)})}function Gr(e,t){return new Mt({check:`string_format`,format:`includes`,...w(t),includes:e})}function Kr(e,t){return new Nt({check:`string_format`,format:`starts_with`,...w(t),prefix:e})}function qr(e,t){return new Pt({check:`string_format`,format:`ends_with`,...w(t),suffix:e})}function Jr(e){return new Ft({check:`overwrite`,tx:e})}function Yr(e){return Jr(t=>t.normalize(e))}function Xr(){return Jr(e=>e.trim())}function Zr(){return Jr(e=>e.toLowerCase())}function Qr(){return Jr(e=>e.toUpperCase())}function $r(){return Jr(e=>ee(e))}function ei(e,t,n){return new e({type:`array`,element:t,...w(n)})}function ti(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...w(n)})}function ni(e,t){let n=ri(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Ce(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(Ce(r))}},e(t.value,t)),t);return n}function ri(e,t){let n=new E({check:`custom`,...w(t)});return n._zod.check=e,n}function ii(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??er,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`&&A(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 ai(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
|
+
|
|
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 oi(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:ci(t,`input`,e.processors),output:ci(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function A(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 A(r.element,n);if(r.type===`set`)return A(r.valueType,n);if(r.type===`lazy`)return A(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 A(r.innerType,n);if(r.type===`intersection`)return A(r.left,n)||A(r.right,n);if(r.type===`record`||r.type===`map`)return A(r.keyType,n)||A(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:A(r.in,n)||A(r.out,n);if(r.type===`object`){for(let e in r.shape)if(A(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(A(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(A(e,n))return!0;return!!(r.rest&&A(r.rest,n))}return!1}var si=(e,t={})=>n=>{let r=ii({...n,processors:t});return k(e,r),ai(r,e),oi(r,e)},ci=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ii({...i??{},target:a,io:t,processors:n});return k(e,o),ai(o,e),oi(o,e)},li={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ui=(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=li[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}))])}},di=(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)},fi=(e,t,n,r)=>{n.type=`boolean`},pi=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},mi=(e,t,n,r)=>{n.not={}},hi=(e,t,n,r)=>{let i=e._zod.def,a=f(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},gi=(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}},_i=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},vi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},yi=(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`]})},bi=(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)},xi=(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},Si=(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]]},Ci=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=k(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=k(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=k(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},wi=(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`}]},Ti=(e,t,n,r)=>{let i=e._zod.def;k(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ei=(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))},Di=(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)))},Oi=(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},ki=(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},Ai=(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},ji=(e,t,n,r)=>{let i=e._zod.def;k(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Mi=s(`ZodISODateTime`,(e,t)=>{Xt.init(e,t),N.init(e,t)});function Ni(e){return wr(Mi,e)}var Pi=s(`ZodISODate`,(e,t)=>{Zt.init(e,t),N.init(e,t)});function Fi(e){return Tr(Pi,e)}var Ii=s(`ZodISOTime`,(e,t)=>{Qt.init(e,t),N.init(e,t)});function Li(e){return Er(Ii,e)}var Ri=s(`ZodISODuration`,(e,t)=>{$t.init(e,t),N.init(e,t)});function zi(e){return Dr(Ri,e)}var Bi=s(`ZodError`,(e,t)=>{Te.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Oe(e,t)},flatten:{value:t=>De(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,p,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,p,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Vi=T(Bi),Hi=ke(Bi),Ui=Ae(Bi),Wi=Me(Bi),Gi=Pe(Bi),Ki=Fe(Bi),qi=Ie(Bi),Ji=Le(Bi),Yi=Re(Bi),Xi=ze(Bi),Zi=Be(Bi),Qi=Ve(Bi),$i=new WeakMap;function ea(e,t,n){let r=Object.getPrototypeOf(e),i=$i.get(r);if(i||(i=new Set,$i.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 j=s(`ZodType`,(e,t)=>(D.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ci(e,`input`),output:ci(e,`output`)}}),e.toJSONSchema=si(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Vi(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ui(e,t,n),e.parseAsync=async(t,n)=>Hi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Wi(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Gi(e,t,n),e.decode=(t,n)=>Ki(e,t,n),e.encodeAsync=async(t,n)=>qi(e,t,n),e.decodeAsync=async(t,n)=>Ji(e,t,n),e.safeEncode=(t,n)=>Yi(e,t,n),e.safeDecode=(t,n)=>Xi(e,t,n),e.safeEncodeAsync=async(t,n)=>Zi(e,t,n),e.safeDecodeAsync=async(t,n)=>Qi(e,t,n),ea(e,`ZodType`,{check(...e){let t=this.def;return this.clone(x(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 se(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(fo(e,t))},superRefine(e,t){return this.check(po(e,t))},overwrite(e){return this.check(Jr(e))},optional(){return qa(this)},exactOptional(){return Ya(this)},nullable(){return Za(this)},nullish(){return qa(Za(this))},nonoptional(e){return ro(this,e)},array(){return I(this)},or(e){return Fa([this,e])},and(e){return za(this,e)},transform(e){return so(this,Ga(e))},default(e){return $a(this,e)},prefault(e){return to(this,e)},catch(e){return ao(this,e)},pipe(e){return so(this,e)},readonly(){return lo(this)},describe(e){let t=this.clone();return er.add(t,{description:e}),t},meta(...e){if(e.length===0)return er.get(this);let t=this.clone();return er.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 er.get(e)?.description},configurable:!0}),e)),ta=s(`_ZodString`,(e,t)=>{Rt.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ui(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,ea(e,`_ZodString`,{regex(...e){return this.check(Hr(...e))},includes(...e){return this.check(Gr(...e))},startsWith(...e){return this.check(Kr(...e))},endsWith(...e){return this.check(qr(...e))},min(...e){return this.check(Br(...e))},max(...e){return this.check(zr(...e))},length(...e){return this.check(Vr(...e))},nonempty(...e){return this.check(Br(1,...e))},lowercase(e){return this.check(Ur(e))},uppercase(e){return this.check(Wr(e))},trim(){return this.check(Xr())},normalize(...e){return this.check(Yr(...e))},toLowerCase(){return this.check(Zr())},toUpperCase(){return this.check(Qr())},slugify(){return this.check($r())}})}),na=s(`ZodString`,(e,t)=>{Rt.init(e,t),ta.init(e,t),e.email=t=>e.check(nr(ra,t)),e.url=t=>e.check(cr(oa,t)),e.jwt=t=>e.check(Cr(xa,t)),e.emoji=t=>e.check(lr(sa,t)),e.guid=t=>e.check(rr(ia,t)),e.uuid=t=>e.check(ir(aa,t)),e.uuidv4=t=>e.check(ar(aa,t)),e.uuidv6=t=>e.check(or(aa,t)),e.uuidv7=t=>e.check(sr(aa,t)),e.nanoid=t=>e.check(ur(ca,t)),e.guid=t=>e.check(rr(ia,t)),e.cuid=t=>e.check(dr(la,t)),e.cuid2=t=>e.check(fr(ua,t)),e.ulid=t=>e.check(pr(da,t)),e.base64=t=>e.check(br(va,t)),e.base64url=t=>e.check(xr(ya,t)),e.xid=t=>e.check(mr(fa,t)),e.ksuid=t=>e.check(hr(pa,t)),e.ipv4=t=>e.check(gr(ma,t)),e.ipv6=t=>e.check(_r(ha,t)),e.cidrv4=t=>e.check(vr(ga,t)),e.cidrv6=t=>e.check(yr(_a,t)),e.e164=t=>e.check(Sr(ba,t)),e.datetime=t=>e.check(Ni(t)),e.date=t=>e.check(Fi(t)),e.time=t=>e.check(Li(t)),e.duration=t=>e.check(zi(t))});function M(e){return tr(na,e)}var N=s(`ZodStringFormat`,(e,t)=>{O.init(e,t),ta.init(e,t)}),ra=s(`ZodEmail`,(e,t)=>{Vt.init(e,t),N.init(e,t)}),ia=s(`ZodGUID`,(e,t)=>{zt.init(e,t),N.init(e,t)}),aa=s(`ZodUUID`,(e,t)=>{Bt.init(e,t),N.init(e,t)}),oa=s(`ZodURL`,(e,t)=>{Ht.init(e,t),N.init(e,t)}),sa=s(`ZodEmoji`,(e,t)=>{Ut.init(e,t),N.init(e,t)}),ca=s(`ZodNanoID`,(e,t)=>{Wt.init(e,t),N.init(e,t)}),la=s(`ZodCUID`,(e,t)=>{Gt.init(e,t),N.init(e,t)}),ua=s(`ZodCUID2`,(e,t)=>{Kt.init(e,t),N.init(e,t)}),da=s(`ZodULID`,(e,t)=>{qt.init(e,t),N.init(e,t)}),fa=s(`ZodXID`,(e,t)=>{Jt.init(e,t),N.init(e,t)}),pa=s(`ZodKSUID`,(e,t)=>{Yt.init(e,t),N.init(e,t)}),ma=s(`ZodIPv4`,(e,t)=>{en.init(e,t),N.init(e,t)}),ha=s(`ZodIPv6`,(e,t)=>{tn.init(e,t),N.init(e,t)}),ga=s(`ZodCIDRv4`,(e,t)=>{nn.init(e,t),N.init(e,t)}),_a=s(`ZodCIDRv6`,(e,t)=>{rn.init(e,t),N.init(e,t)}),va=s(`ZodBase64`,(e,t)=>{on.init(e,t),N.init(e,t)}),ya=s(`ZodBase64URL`,(e,t)=>{cn.init(e,t),N.init(e,t)}),ba=s(`ZodE164`,(e,t)=>{ln.init(e,t),N.init(e,t)}),xa=s(`ZodJWT`,(e,t)=>{dn.init(e,t),N.init(e,t)}),Sa=s(`ZodNumber`,(e,t)=>{fn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>di(e,t,n,r),ea(e,`ZodNumber`,{gt(e,t){return this.check(Ir(e,t))},gte(e,t){return this.check(Lr(e,t))},min(e,t){return this.check(Lr(e,t))},lt(e,t){return this.check(Pr(e,t))},lte(e,t){return this.check(Fr(e,t))},max(e,t){return this.check(Fr(e,t))},int(e){return this.check(wa(e))},safe(e){return this.check(wa(e))},positive(e){return this.check(Ir(0,e))},nonnegative(e){return this.check(Lr(0,e))},negative(e){return this.check(Pr(0,e))},nonpositive(e){return this.check(Fr(0,e))},multipleOf(e,t){return this.check(Rr(e,t))},step(e,t){return this.check(Rr(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});function P(e){return Or(Sa,e)}var Ca=s(`ZodNumberFormat`,(e,t)=>{pn.init(e,t),Sa.init(e,t)});function wa(e){return kr(Ca,e)}var Ta=s(`ZodBoolean`,(e,t)=>{mn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fi(e,t,n,r)});function F(e){return Ar(Ta,e)}var Ea=s(`ZodNull`,(e,t)=>{hn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pi(e,t,n,r)});function Da(e){return jr(Ea,e)}var Oa=s(`ZodUnknown`,(e,t)=>{gn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ka(){return Mr(Oa)}var Aa=s(`ZodNever`,(e,t)=>{_n.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,n,r)});function ja(e){return Nr(Aa,e)}var Ma=s(`ZodArray`,(e,t)=>{yn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yi(e,t,n,r),e.element=t.element,ea(e,`ZodArray`,{min(e,t){return this.check(Br(e,t))},nonempty(e){return this.check(Br(1,e))},max(e,t){return this.check(zr(e,t))},length(e,t){return this.check(Vr(e,t))},unwrap(){return this.element}})});function I(e,t){return ei(Ma,e,t)}var Na=s(`ZodObject`,(e,t)=>{wn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bi(e,t,n,r),y(e,`shape`,()=>t.shape),ea(e,`ZodObject`,{keyof(){return R(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:ka()})},loose(){return this.clone({...this._zod.def,catchall:ka()})},strict(){return this.clone({...this._zod.def,catchall:ja()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return fe(this,e)},safeExtend(e){return pe(this,e)},merge(e){return me(this,e)},pick(e){return ue(this,e)},omit(e){return de(this,e)},partial(...e){return he(Ka,this,e[0])},required(...e){return ge(no,this,e[0])}})});function L(e,t){return new Na({type:`object`,shape:e??{},...w(t)})}var Pa=s(`ZodUnion`,(e,t)=>{En.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r),e.options=t.options});function Fa(e,t){return new Pa({type:`union`,options:e,...w(t)})}var Ia=s(`ZodDiscriminatedUnion`,(e,t)=>{Pa.init(e,t),Dn.init(e,t)});function La(e,t,n){return new Ia({type:`union`,options:t,discriminator:e,...w(n)})}var Ra=s(`ZodIntersection`,(e,t)=>{On.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Si(e,t,n,r)});function za(e,t){return new Ra({type:`intersection`,left:e,right:t})}var Ba=s(`ZodRecord`,(e,t)=>{jn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ci(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Va(e,t,n){return!t||!t._zod?new Ba({type:`record`,keyType:M(),valueType:e,...w(t)}):new Ba({type:`record`,keyType:e,valueType:t,...w(n)})}var Ha=s(`ZodEnum`,(e,t)=>{Mn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hi(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 Ha({...t,checks:[],...w(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 Ha({...t,checks:[],...w(r),entries:i})}});function R(e,t){return new Ha({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...w(t)})}var Ua=s(`ZodLiteral`,(e,t)=>{Nn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gi(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 z(e,t){return new Ua({type:`literal`,values:Array.isArray(e)?e:[e],...w(t)})}var Wa=s(`ZodTransform`,(e,t)=>{Pn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vi(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new l(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ce(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(Ce(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 Ga(e){return new Wa({type:`transform`,transform:e})}var Ka=s(`ZodOptional`,(e,t)=>{In.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ji(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qa(e){return new Ka({type:`optional`,innerType:e})}var Ja=s(`ZodExactOptional`,(e,t)=>{Ln.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ji(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ya(e){return new Ja({type:`optional`,innerType:e})}var Xa=s(`ZodNullable`,(e,t)=>{Rn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Za(e){return new Xa({type:`nullable`,innerType:e})}var Qa=s(`ZodDefault`,(e,t)=>{zn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ei(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function $a(e,t){return new Qa({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}var eo=s(`ZodPrefault`,(e,t)=>{Vn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Di(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function to(e,t){return new eo({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}var no=s(`ZodNonOptional`,(e,t)=>{Hn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ro(e,t){return new no({type:`nonoptional`,innerType:e,...w(t)})}var io=s(`ZodCatch`,(e,t)=>{Wn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ao(e,t){return new io({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var oo=s(`ZodPipe`,(e,t)=>{Gn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ki(e,t,n,r),e.in=t.in,e.out=t.out});function so(e,t){return new oo({type:`pipe`,in:e,out:t})}var co=s(`ZodReadonly`,(e,t)=>{qn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ai(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lo(e){return new co({type:`readonly`,innerType:e})}var uo=s(`ZodCustom`,(e,t)=>{Yn.init(e,t),j.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_i(e,t,n,r)});function fo(e,t={}){return ti(uo,e,t)}function po(e,t){return ni(e,t)}var B=e(t(),1),mo=n(),ho=R([`observed`,`reported`,`inferred`,`planned`,`explained`]),go=Fa([R([`claude-code`,`codex`]),M().regex(/^[a-z][a-z0-9-]{0,62}\/[a-z][a-z0-9-]{0,62}$/,`extension provider id must be a lowercase owner/name namespace`)]),_o=L({provider:go,channel:R([`hook`,`transcript`,`rollout`,`app-server`,`salidium`]),version:M().optional(),ref:L({path:M().optional(),line:P().int().nonnegative().optional(),recordId:M().optional(),recordHash:M().regex(/^sha256:[0-9a-f]{64}$/).optional()}).optional()}),vo=R([`explicit`,`inferred-success`,`inferred-failure`,`unknown`]),yo=L({code:P().int().optional(),observation:vo}),V=Ni({offset:!1,precision:3}),bo=R([`status`,`what`,`why`,`how`,`verified`,`left`,`review`]),xo=L({sessionId:M(),seq:P().int().nonnegative(),ordinal:P().int().nonnegative(),ts:V,facet:bo,summary:M(),epistemic:ho,refs:I(M()),detail:Va(M(),ka()).optional()});R([`command`,`fileEdit`,`fileWrite`,`fileRead`,`search`,`webFetch`,`webSearch`,`subagent`,`plan`,`question`,`mcp`,`other`]);var So=La(`kind`,[L({kind:z(`command`),command:M(),description:M().optional(),cwd:M().optional(),background:F().optional()}),L({kind:R([`fileEdit`,`fileWrite`,`fileRead`]),path:M()}),L({kind:z(`search`),query:M(),path:M().optional()}),L({kind:R([`webFetch`,`webSearch`]),target:M()}),L({kind:z(`subagent`),description:M().optional(),agentType:M().optional(),background:F().optional()}),L({kind:z(`plan`)}),L({kind:z(`question`),questions:I(M())}),L({kind:z(`mcp`),server:M(),tool:M(),pathArgs:I(M().max(1e3)).max(32).optional(),pathArgsTruncated:F().optional(),argsExcerpt:M().optional()}),L({kind:z(`other`),summary:M().optional()})]),Co=L({oldStart:P().int(),oldLines:P().int(),newStart:P().int(),newLines:P().int(),lines:I(M())}),wo=R([`add`,`update`,`delete`,`move`]),To=L({path:M(),change:wo,movedFrom:M().optional(),hunks:I(Co).optional(),linesAdded:P().int().nonnegative(),linesRemoved:P().int().nonnegative(),applied:F(),userModifiedBefore:F().optional()}),Eo=L({commit:L({sha:M(),kind:M().optional()}).optional(),push:L({branch:M().optional()}).optional(),branch:L({ref:M().optional(),action:M().optional()}).optional(),pr:L({number:P().int().optional(),url:M().optional(),action:M().optional()}).optional()}),Do=La(`kind`,[L({kind:z(`command`),exit:yo,outputExcerpt:M(),outputChars:P().int().nonnegative(),truncated:F(),interrupted:F().optional(),timedOut:F().optional(),gitOperation:Eo.optional()}),L({kind:z(`fileChanges`),changes:I(To)}),L({kind:z(`fileRead`),path:M(),suppressed:F().optional()}),L({kind:z(`subagent`),agentId:M().optional(),status:R([`completed`,`launched`,`failed`,`unknown`]),summaryExcerpt:M().optional(),toolCalls:P().int().optional(),durationMs:P().int().optional()}),L({kind:z(`generic`),excerpt:M().optional()})]),Oo=R([`pending`,`in_progress`,`completed`,`cancelled`]),ko=L({id:M(),text:M(),status:Oo,activeForm:M().optional()}),H=L({id:M(),sessionId:M(),ts:V,tsSource:R([`provider`,`ingest`]),agentId:M().optional(),turnId:M().optional(),source:_o,redactions:P().int().nonnegative().optional()}),Ao=H.extend({kind:z(`session.started`),cwd:M(),model:M().optional(),entrypoint:M().optional(),gitBranch:M().optional(),reason:M().optional(),title:M().optional(),transcriptPath:M().optional()}),jo=H.extend({kind:z(`session.updated`),model:M().optional(),title:M().optional(),gitBranch:M().optional(),cwd:M().optional()}),Mo=H.extend({kind:z(`session.ended`),reason:M().optional()}),No=H.extend({kind:z(`turn.started`),prompt:M(),promptTruncated:F().optional()}),Po=H.extend({kind:z(`turn.ended`),lastMessage:M().optional(),outcome:R([`completed`,`interrupted`,`failed`]),error:M().optional()}),Fo=H.extend({kind:z(`agent.message`),text:M(),truncated:F().optional(),phase:R([`commentary`,`final`]).optional(),messageId:M().optional()}),Io=H.extend({kind:z(`agent.thinking`),chars:P().int().nonnegative()}),Lo=H.extend({kind:z(`agent.usage`),messageId:M(),model:M().max(120).optional(),inputTokens:P().int().nonnegative(),outputTokens:P().int().nonnegative(),cacheReadTokens:P().int().nonnegative(),cacheWriteTokens:P().int().nonnegative()}),Ro=H.extend({kind:z(`tool.called`),callId:M(),toolName:M(),input:So,title:M()}),zo=H.extend({kind:z(`tool.completed`),callId:M(),toolName:M(),result:Do,isError:F(),durationMs:P().int().nonnegative().optional()}),Bo=R([`error`,`rejected`,`denied`,`interrupted`,`timeout`]),Vo=H.extend({kind:z(`tool.failed`),callId:M(),toolName:M(),errorExcerpt:M(),cause:Bo,exit:yo.optional(),interrupted:F().optional(),durationMs:P().int().nonnegative().optional()}),Ho=H.extend({kind:z(`subagent.started`),subagentId:M(),agentType:M().optional(),description:M().optional(),transcriptPath:M().optional(),parentCallId:M().optional()}),Uo=H.extend({kind:z(`subagent.ended`),subagentId:M(),lastMessage:M().optional()}),Wo=H.extend({kind:z(`plan.updated`),mode:R([`replace`,`merge`]),items:I(ko),explanation:M().optional()}),Go=H.extend({kind:z(`compaction`),trigger:M().optional(),summaryExcerpt:M().optional()}),Ko=H.extend({kind:z(`permission.requested`),toolName:M(),summary:M()}),qo=H.extend({kind:z(`notification`),notificationType:M().optional(),message:M()}),Jo=H.extend({kind:z(`git.snapshot`),repoRoot:M(),head:M().optional(),branch:M().optional(),dirty:I(L({path:M(),status:M()})),dirtyTruncated:F().optional()}),Yo=H.extend({kind:z(`ingest.warning`),code:R([`malformed-record`,`unsupported-record`,`truncated-record`,`source-gap`]),detail:M().optional()}),Xo=M().max(200).refine(e=>e.trim().split(/\s+/).filter(Boolean).length<=6,`diagram steps contain at most six words`),Zo=H.extend({kind:z(`salidium.explanation`),basedOnSeq:P().int().nonnegative(),model:M().max(120),what:L({summary:M().max(600),currently:M().max(600).nullable()}),why:L({summary:M().max(600),lanes:I(L({title:M().max(100),steps:I(Xo).min(1).max(4)})).max(3).refine(e=>e.length===0||e.length>=2,`lanes are empty or converging`).default([]),chain:I(Xo).min(1).max(6)}),how:L({summary:M().max(600),root:M().max(200).nullable().default(null),steps:I(Xo).min(1).max(6)}),approachChange:L({from:M().max(200),fromSteps:I(Xo).min(2).max(4),why:M().max(600),to:M().max(200),toSteps:I(Xo).min(2).max(4)}).nullable()}),Qo=La(`kind`,[Ao,jo,Mo,No,Po,Fo,Io,Lo,Ro,zo,Vo,Ho,Uo,Wo,Go,Ko,qo,Jo,Yo,Zo]),$o=L({seq:P().int().nonnegative()}),es=Fa([z(`forever`),z(30),z(90),z(365)]),ts=R([`summary`,`expanded`]);L({history:L({days:P().int().min(0).max(2**53-1)}).strict(),retention:L({days:es}).strict(),git:L({enabled:F()}).strict(),providers:L({enabled:I(go).max(32)}).strict(),explainer:L({cadence:R([`off`,`session`,`turn`]),backend:R([`auto`,`claude`,`codex`]),model:M().trim().min(1).max(120).nullable()}).strict(),health:L({sampleIntervalSeconds:P().int().min(5).max(300),historyMinutes:P().int().min(15).max(1440)}).strict(),alerts:L({queueAgeMinutes:P().int().min(1).max(10080),queueGrowthFiles:P().int().min(1).max(1e6),databaseSizeBytes:P().int().min(1048576).max(2**53-1),cooldownMinutes:P().int().min(1).max(10080),nativeNotifications:F()}).strict(),ui:L({operationsDetail:ts}).strict()}).strict(),L({version:z(1),revision:P().int().nonnegative(),updatedAt:V,migratedFrom:R([`settings-v0`,`sqlite-retention`]).optional(),settings:L({history:L({days:P().int().min(0).max(2**53-1).optional()}).strict().optional(),retention:L({days:es.optional()}).strict().optional(),git:L({enabled:F().optional()}).strict().optional(),providers:L({enabled:I(go).max(32).optional()}).strict().optional(),explainer:L({cadence:R([`off`,`session`,`turn`]).optional(),backend:R([`auto`,`claude`,`codex`]).optional(),model:M().trim().min(1).max(120).nullable().optional()}).strict().optional(),health:L({sampleIntervalSeconds:P().int().min(5).max(300).optional(),historyMinutes:P().int().min(15).max(1440).optional()}).strict().optional(),alerts:L({queueAgeMinutes:P().int().min(1).max(10080).optional(),queueGrowthFiles:P().int().min(1).max(1e6).optional(),databaseSizeBytes:P().int().min(1048576).max(2**53-1).optional(),cooldownMinutes:P().int().min(1).max(10080).optional(),nativeNotifications:F().optional()}).strict().optional(),ui:L({operationsDetail:ts.optional()}).strict().optional()}).strict()}).strict().shape.settings.refine(e=>Object.keys(e).length>0,`at least one setting is required`);var ns=R([`default`,`stored`,`environment`]);function U(e){return L({value:e,source:ns,environment:M().optional()}).strict()}var rs=L({contractVersion:z(1),schemaVersion:z(1),revision:P().int().nonnegative(),observedAt:V,restartRequired:I(M()),values:L({history:L({days:U(P().int().min(0).max(2**53-1))}).strict(),retention:L({days:U(es)}).strict(),git:L({enabled:U(F())}).strict(),providers:L({enabled:U(I(go).max(32))}).strict(),explainer:L({cadence:U(R([`off`,`session`,`turn`])),backend:U(R([`auto`,`claude`,`codex`])),model:U(M().trim().min(1).max(120).nullable())}).strict(),health:L({sampleIntervalSeconds:U(P().int().min(5).max(300)),historyMinutes:U(P().int().min(15).max(1440))}).strict(),alerts:L({queueAgeMinutes:U(P().int().min(1).max(10080)),queueGrowthFiles:U(P().int().min(1).max(1e6)),databaseSizeBytes:U(P().int().min(1048576).max(2**53-1)),cooldownMinutes:U(P().int().min(1).max(10080)),nativeNotifications:U(F())}).strict(),ui:L({operationsDetail:U(ts)}).strict()}).strict()}).strict(),is=R([`exact`,`unavailable`]),as=L({availability:is,files:P().int().nonnegative().nullable(),bytes:P().int().nonnegative().nullable(),oldestAt:V.nullable(),reason:M().optional()}).strict(),os=L({availability:is,databaseBytes:P().int().nonnegative().nullable(),walBytes:P().int().nonnegative().nullable(),totalBytes:P().int().nonnegative().nullable(),schemaVersion:P().int().nonnegative().nullable(),layoutVersion:P().int().nonnegative().nullable(),integrity:R([`ok`,`failed`,`not-checked`,`unavailable`]),retention:es.nullable(),lastIngestAt:V.nullable()}).strict(),ss=R([`idle`,`pause`,`drain`,`checkpoint`,`optimize`,`verify`,`resume`,`completed`,`failure`,`recovery`]),cs=L({version:z(1),operationId:M().min(1),kind:R([`queue-drain`,`storage-optimize`,`retention-compact`]),phase:ss,startedAt:V,updatedAt:V,progress:P().min(0).max(1).nullable(),message:M().max(500),resumedFrom:ss.optional(),failure:M().max(1e3).optional()}).strict(),ls=L({value:P().finite(),unit:R([`files/minute`,`bytes/minute`,`seconds`]),sampleWindowSeconds:P().positive(),samples:P().int().min(2),basis:z(`derived`)}).strict(),us=L({id:go,name:M().min(1),detected:F(),configuration:R([`configured`,`not-configured`,`partial`,`invalid`,`unavailable`]),trust:R([`trusted`,`untrusted`,`modified`,`managed`,`unknown`,`not-applicable`])}).strict(),ds=L({active:P().int().nonnegative(),recovered:P().int().nonnegative(),omitted:P().int().nonnegative(),latestFingerprint:M().nullable(),activeEpisodes:I(L({reason:M(),provider:M().nullable(),event:M().nullable(),pressure:M().nullable(),firstDroppedAt:V.nullable(),recoveredAt:V.nullable(),exactCount:Da()})),recoveredEpisodes:I(L({reason:M(),provider:M().nullable(),event:M().nullable(),pressure:M().nullable(),firstDroppedAt:V.nullable(),recoveredAt:V.nullable(),exactCount:Da()}))}).strict(),fs=L({contractVersion:z(1),observedAt:V,overall:R([`healthy`,`attention`,`critical`]),daemon:L({state:R([`running`,`unresponsive`,`stopped`]),pid:P().int().positive().nullable(),startedAt:V.nullable(),version:M().nullable()}).strict(),collection:L({state:R([`active`,`paused`]),pausedAt:V.nullable(),pauseExpiresAt:V.nullable(),pauseReason:R([`manual`,`stop`]).nullable()}).strict(),queue:as,store:os,gaps:ds,maintenance:cs.nullable(),hooks:I(us),estimates:L({queueVelocity:ls.nullable(),drainRate:ls.nullable(),storageGrowth:ls.nullable(),timeToEmpty:ls.nullable()}).strict(),history:L({retentionMinutes:P().int().positive(),retainedSamples:P().int().nonnegative()}).strict()}).strict(),ps=R([`queue-age`,`queue-growth`,`database-size`,`collection-gap`,`daemon-health`,`maintenance-failure`,`hook-trust-change`]),ms=L({id:M().min(1),deduplicationKey:M().min(1),kind:ps,severity:R([`notice`,`warning`,`critical`]),state:R([`active`,`acknowledged`,`recovered`]),title:M().min(1).max(160),detail:M().min(1).max(500),recoveryTitle:M().min(1).max(160).optional(),recoveryDetail:M().min(1).max(500).optional(),firstSeenAt:V,lastSeenAt:V,lastTransitionAt:V,acknowledgedAt:V.nullable(),recoveredAt:V.nullable(),notificationEligible:F()}).strict(),hs=L({contractVersion:z(1),observedAt:V,active:I(ms),recent:I(ms)}).strict(),gs=L({contractVersion:z(1),config:rs,health:fs,alerts:hs}).strict(),_s=L({id:M().min(1),provider:M().nullable(),state:R([`ready`,`processing`,`legacy`,`quarantined`]),bytes:P().int().nonnegative(),queuedAt:V}).strict();L({contractVersion:z(1),observedAt:V,totalFiles:P().int().nonnegative().nullable(),totalBytes:P().int().nonnegative().nullable(),entries:I(_s),entriesTruncated:F(),exactTotals:F()}).strict();var vs=L({name:M().min(1),description:M().min(1),maximumBytes:P().int().nonnegative(),redactions:I(M())}).strict();L({contractVersion:z(1),bundleSchemaVersion:z(1),createdAt:V,privacy:z(`redacted-local-diagnostics`),excludes:I(M()),entries:I(vs)}).strict();var ys=R([`working`,`idle`,`waiting`,`ended`,`unknown`]),bs=R([`generating`,`generated`,`disabled`,`unavailable`,`failed`]),xs=L({id:M(),provider:go,providerSessionId:M(),cwd:M(),repoRoot:M().optional(),title:M().optional(),model:M().optional(),entrypoint:M().optional(),internal:F().optional(),explanationStatus:bs.optional(),status:ys,startedAt:V.optional(),lastEventAt:V.optional(),endedAt:V.optional(),latestSeq:P().int().nonnegative(),counts:L({turns:P().int().nonnegative(),toolCalls:P().int().nonnegative(),filesChanged:P().int().nonnegative(),linesAdded:P().int().nonnegative(),linesRemoved:P().int().nonnegative(),reviewOpen:P().int().nonnegative(),remaining:P().int().nonnegative()}),lastVerification:L({outcome:R([`pass`,`fail`,`partial`,`unknown`]),at:V,epistemic:ho}).optional()});L({sessions:I(xs),matched:P().int().nonnegative(),total:P().int().nonnegative(),query:M()});var Ss=za(Qo,$o);L({summary:xs,state:ka(),reducerVersion:M(),seq:P().int().nonnegative(),changes:I(xo)});var Cs=La(`type`,[L({type:z(`event`),event:Ss}),L({type:z(`changes`),changes:I(xo)}),L({type:z(`session`),summary:xs}),L({type:z(`sessionRemoved`),id:M()}),L({type:z(`heartbeat`),at:V})]),ws=L({error:z(`resnapshot-required`),reason:R([`backlog-exceeded`,`history-gap`,`cursor-ahead`]),sessionId:M(),after:P().int().min(-1),latestSeq:P().int().min(-1)});L({name:z(`salidium`),version:M(),pid:P().int(),startedAt:V,home:M(),providers:I(L({id:go,displayName:M().min(1).optional(),hooksInstalled:F(),hookStatus:R([`configured`,`not-configured`,`partial`,`invalid`]).optional(),hookTrust:R([`trusted`,`untrusted`,`modified`,`managed`,`unknown`,`not-applicable`]).optional(),sourcesWatched:P().int().nonnegative()}))});var Ts=L({reason:M(),provider:M().nullable(),event:M().nullable(),pressure:M().nullable(),firstDroppedAt:V.nullable(),recoveredAt:V.nullable(),exactCount:Da()}),Es=L({observedAt:V,state:R([`active`,`paused`]),pause:L({pausedAt:V,expiresAt:V,reason:R([`manual`,`stop`])}).nullable(),queue:L({files:P().int().nonnegative(),bytes:P().int().nonnegative(),oldestAt:V.nullable()}),store:L({bytes:P().int().nonnegative().nullable(),retention:Fa([z(`forever`),z(30),z(90),z(365)]).nullable(),lastIngestAt:V.nullable()}),health:R([`healthy`,`attention`,`runaway`]),gaps:L({active:I(Ts),recovered:I(Ts),omittedEpisodes:P().int().nonnegative()})});L({action:R([`pause`,`resume`]),reason:R([`manual`,`stop`]).optional()});var Ds=R([`off`,`session`,`turn`]),Os=R([`auto`,`claude`,`codex`]),ks=L({backend:R([`claude`,`codex`]).nullable(),model:M().min(1).max(120).nullable()}),As=M().trim().min(1).max(120).refine(e=>Array.from(e).every(e=>{let t=e.charCodeAt(0);return t>=32&&t!==127}),`model names cannot contain control characters`),js=L({messages:P().int().nonnegative(),inputTokens:P().int().nonnegative(),outputTokens:P().int().nonnegative(),cacheReadTokens:P().int().nonnegative(),cacheWriteTokens:P().int().nonnegative()});L({cadence:Ds,backend:Os,model:As.nullable(),envOff:F(),backendLocked:F(),modelLocked:F(),activeBackend:Os.nullable(),activeModel:As.nullable(),availableBackends:I(R([`claude`,`codex`])),routes:L({claudeCode:ks,codex:ks}),usageStatus:R([`ready`,`preparing`]).optional(),usage:js.optional()}),L({cadence:Ds.optional(),backend:Os.optional(),model:As.nullable().optional()}).strict().refine(e=>Object.keys(e).length>0,`at least one setting is required`);var Ms=L({guidance:M().trim().max(800)}).strict(),Ns=L({version:z(2),enabled:F(),revision:M().min(1).max(80),profile:Ms}).strict().refine(e=>(e.revision!==`none`||!e.enabled&&e.profile.guidance===``)&&(!e.enabled||e.profile.guidance!==``),`enabled personalization requires guidance; the none revision is reserved for the disabled empty profile`);L({enabled:F(),profile:Ms}).strict().refine(e=>!e.enabled||e.profile.guidance!==``,`enabled personalization requires guidance`);var Ps=Zo.pick({basedOnSeq:!0,model:!0,what:!0,why:!0,how:!0,approachChange:!0}).extend({generatedAt:V,profileRevision:M().min(1).max(80),analogies:L({why:M().max(300).nullable(),how:M().max(300).nullable()})}).strict(),Fs=class{token;onUnauthorized;constructor(e,t={}){this.token=e,this.onUnauthorized=t.onUnauthorized}headers(){return{Authorization:`Bearer ${this.token}`}}async get(e,t){let n;try{n=await fetch(e,{headers:this.headers(),signal:t})}catch(e){throw t?.aborted?e:new W(`daemon unreachable${e instanceof Error&&e.message?` (${e.message})`:``}`,0)}if(n.status===401)throw this.onUnauthorized?.(),new W(`unauthorized`,401);if(!n.ok)throw new W(`request failed: ${n.status}`,n.status);return await n.json()}info(){return this.get(`/api/info`)}collectionStatus(){return this.get(`/api/collection`).then(e=>Es.parse(e))}operations(){return this.get(`/api/operations`).then(e=>gs.parse(e))}async setOperationalConfig(e,t){let n=await fetch(`/api/operations/config`,{method:`PUT`,headers:{...this.headers(),"Content-Type":`application/json`,"If-Match":String(t)},body:JSON.stringify(e)});if(n.status===401&&this.onUnauthorized?.(),!n.ok)throw new W(`request failed: ${n.status}`,n.status);return rs.parse(await n.json())}async resetOperationalConfig(e,t){let n=e?`?key=${encodeURIComponent(e)}`:``,r=await fetch(`/api/operations/config${n}`,{method:`DELETE`,headers:{...this.headers(),"If-Match":String(t)}});if(r.status===401&&this.onUnauthorized?.(),!r.ok)throw new W(`request failed: ${r.status}`,r.status);return rs.parse(await r.json())}async drainQueue(){let e=await fetch(`/api/operations/maintenance/drain`,{method:`POST`,headers:this.headers()});if(e.status===401&&this.onUnauthorized?.(),!e.ok)throw new W(`request failed: ${e.status}`,e.status);return await e.json()}async acknowledgeAlert(e){let t=await fetch(`/api/operations/alerts/${encodeURIComponent(e)}/acknowledge`,{method:`POST`,headers:this.headers()});if(t.status===401&&this.onUnauthorized?.(),!t.ok)throw new W(`request failed: ${t.status}`,t.status);return hs.parse(await t.json())}async setCollection(e){let t=await fetch(`/api/collection`,{method:`PUT`,headers:{...this.headers(),"Content-Type":`application/json`},body:JSON.stringify({action:e,reason:`manual`})});if(t.status===401)throw this.onUnauthorized?.(),new W(`unauthorized`,401);if(!t.ok)throw new W(`request failed: ${t.status}`,t.status);return Es.parse(await t.json())}async disconnectHooks(e){let t=await fetch(`/api/collection/hooks/${encodeURIComponent(e)}`,{method:`DELETE`,headers:this.headers()});if(t.status===401)throw this.onUnauthorized?.(),new W(`unauthorized`,401);if(!t.ok)throw new W(`request failed: ${t.status}`,t.status);return Es.parse(await t.json())}explainerSettings(){return this.get(`/api/settings/explainer`)}async setExplainerSettings(e){let t=await fetch(`/api/settings/explainer`,{method:`PUT`,headers:{...this.headers(),"Content-Type":`application/json`},body:JSON.stringify(e)});if(t.status===401)throw this.onUnauthorized?.(),new W(`unauthorized`,401);if(!t.ok)throw new W(`request failed: ${t.status}`,t.status);return await t.json()}async personalizationSettings(){return Ns.parse(await this.get(`/api/settings/personalization`))}async setPersonalizationSettings(e,t){let n=await fetch(`/api/settings/personalization`,{method:`PUT`,headers:{...this.headers(),"Content-Type":`application/json`,"If-Match":t},body:JSON.stringify(e)});if(n.status===401)throw this.onUnauthorized?.(),new W(`unauthorized`,401);if(!n.ok)throw new W(`request failed: ${n.status}`,n.status);return Ns.parse(await n.json())}async deletePersonalizationSettings(e){let t=await fetch(`/api/settings/personalization`,{method:`DELETE`,headers:{...this.headers(),"If-Match":e}});if(t.status===401)throw this.onUnauthorized?.(),new W(`unauthorized`,401);if(!t.ok)throw new W(`request failed: ${t.status}`,t.status);return Ns.parse(await t.json())}async personalizedPresentation(e){let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/personalized-presentation`,{method:`POST`,headers:this.headers()});if(t.status===401)throw this.onUnauthorized?.(),new W(`unauthorized`,401);if(!t.ok)throw new W(`request failed: ${t.status}`,t.status);return Ps.parse(await t.json())}sessions(){return this.get(`/api/sessions`)}searchSessions(e,t={}){let n=e.trim(),r=new URLSearchParams;return n&&r.set(`q`,n),t.limit!==void 0&&r.set(`limit`,String(t.limit)),this.get(`/api/sessions/search?${r}`,t.signal)}snapshot(e){return this.get(`/api/sessions/${encodeURIComponent(e)}/snapshot?changes=400`)}stateAt(e,t){return this.get(`/api/sessions/${encodeURIComponent(e)}/state?at=${t}`)}stateAtTime(e,t){return this.get(`/api/sessions/${encodeURIComponent(e)}/state?atTime=${encodeURIComponent(t)}`)}changes(e,t=-1,n){let r=n===void 0?``:`&until=${n}`;return this.get(`/api/sessions/${encodeURIComponent(e)}/changes?after=${t}${r}`)}events(e,t,n,r=5e3){let i=n===void 0?``:`&until=${n}`;return this.get(`/api/sessions/${encodeURIComponent(e)}/events?after=${t}${i}&limit=${r}`)}raw(e,t){return this.get(`/api/sessions/${encodeURIComponent(e)}/raw/${encodeURIComponent(t)}`)}async forget(e){await fetch(`/api/sessions/${encodeURIComponent(e)}`,{method:`DELETE`,headers:this.headers()})}stream(e,t,n,r){let i=!1,a,o=0;return(async()=>{for(;!i;){n(o===0?`connecting`:`reconnecting`);try{let i=typeof e==`function`?e():e,s=``,c=e=>{s+=e;let n=s.indexOf(`
|
|
65
|
+
|
|
66
|
+
`);for(;n!==-1;){let e=s.slice(0,n);s=s.slice(n+2);for(let n of e.split(`
|
|
67
|
+
`))if(n.startsWith(`data: `))try{let e=Cs.safeParse(JSON.parse(n.slice(6)));e.success&&t(e.data)}catch{}n=s.indexOf(`
|
|
68
|
+
|
|
69
|
+
`)}};if(Is()){let e=await Rs(i,this.token,c,()=>{n(`open`),o=0},e=>{a=e});if(e.status===409&&ws.safeParse(Ls(e.body)).success){n(`closed`),r?.();return}if(e.status===401)throw new W(`unauthorized`,401);if(e.status!==0&&(e.status<200||e.status>=300))throw new W(`stream failed: ${e.status}`,e.status)}else{let e=new AbortController;a=()=>e.abort();let t=await fetch(i,{headers:this.headers(),signal:e.signal});if(t.status===409&&ws.safeParse(await t.json()).success){n(`closed`),r?.();return}if(!t.ok||!t.body)throw new W(`stream failed: ${t.status}`,t.status);n(`open`),o=0;let s=t.body.getReader(),l=new TextDecoder;for(;;){let{value:e,done:t}=await s.read();if(t)break;c(l.decode(e,{stream:!0}))}}}catch(e){if(i)break;if(e instanceof W&&e.status===401){n(`closed`),this.onUnauthorized?.();return}}if(i)break;o++,await new Promise(e=>setTimeout(e,Math.min(15e3,500*2**Math.min(o,5))))}n(`closed`)})(),()=>{i=!0,a?.()}}};function Is(){let e=typeof navigator>`u`?``:navigator.userAgent;return/AppleWebKit/i.test(e)&&!/(?:Chrome|Chromium|Edg|OPR)\//i.test(e)&&typeof XMLHttpRequest<`u`}function Ls(e){try{return JSON.parse(e)}catch{return}}function Rs(e,t,n,r,i){return new Promise((a,o)=>{let s=new XMLHttpRequest,c=0,l=!1,u=()=>{l||s.status!==200||(l=!0,r())},d=()=>{u(),!(s.status!==200||s.responseText.length<=c)&&(n(s.responseText.slice(c)),c=s.responseText.length)};s.open(`GET`,e),s.setRequestHeader(`Authorization`,`Bearer ${t}`),s.onreadystatechange=()=>{s.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&u(),s.readyState===XMLHttpRequest.LOADING&&d()},s.onprogress=d,s.onload=()=>{d(),a({status:s.status,body:s.responseText})},s.onerror=()=>o(Error(`stream failed`)),s.onabort=()=>a({status:0,body:``}),i(()=>s.abort()),s.send()})}var W=class extends Error{status;constructor(e,t){super(e),this.status=t}},zs=`salidium.token`;function Bs(){let e=window.location.hash,t=/token=([0-9a-f]+)/.exec(e);if(t?.[1]){sessionStorage.setItem(zs,t[1]);let n=e.replace(/[#&]?token=[0-9a-f]+/,``).replace(/^#&/,`#`);return history.replaceState(null,``,`${window.location.pathname}${n===`#`?``:n}`),t[1]}return sessionStorage.getItem(zs)??void 0}function Vs(e){sessionStorage.setItem(zs,e)}function Hs(e){let t=e.trim(),n=/token=([0-9a-f]+)/.exec(t);return n?.[1]?n[1]:/^[0-9a-f]{16,}$/.test(t)?t:void 0}function Us(){sessionStorage.removeItem(zs)}var G=r(),Ws=64,Gs=44;function Ks({size:e=24,className:t,decorative:n=!1,label:r=`Salidium`}){return(0,G.jsxs)(`svg`,{className:t,viewBox:`0 0 ${Ws} ${Gs}`,width:e*Ws/Gs,height:e,role:n?void 0:`img`,"aria-hidden":n||void 0,"aria-label":n?void 0:r,focusable:`false`,children:[(0,G.jsx)(`path`,{fill:`currentColor`,d:`M12 1.1C17.2-.2 21.6.1 26.1 2.6l9.1 5c5.4 3 6.6 7.8 3 11.9l-2.7 2.9c-1.4 1.5-1 3.9.8 5.2l3.5 2.8c3.2 2.5 3.9 6.7 1.3 9.8-1.5 1.8-3.6 2.7-6.3 2.7H14.1c-4.3 0-7.3-2.1-9-6L.9 27.1c-1.2-2.7-.9-5.8.1-8.5L5.3 7.3C6.5 4.2 8.8 2 12 1.1Z`}),(0,G.jsx)(`path`,{fill:`currentColor`,d:`M46.3 14.1c1.8-1.4 4.2-1.6 6.2-.4l5.6 3.3c3.1 1.8 4.8 4.7 5.3 8.4l.6 9.4c.3 4.6-2.1 8.1-6.5 8.1h-7.1c-4.1 0-6.6-3.1-6.2-7 .4-3.2-.8-5.8-3.4-7.7-2.7-2-3.1-5.5-1.3-8.1l6.8-6Z`})]})}function qs({markSize:e=24,className:t}){let n=[`brand-lockup`,t].filter(Boolean).join(` `);return(0,G.jsxs)(`span`,{className:n,children:[(0,G.jsx)(Ks,{size:e,className:`brand-lockup-mark`,decorative:!0}),(0,G.jsx)(`span`,{className:`brand-lockup-name`,children:`Salidium`})]})}var Js=/(^|\n)\s*(```|~~~)/,Ys=/^(?:[\w-]+\{"|[[{]"|<\/?[a-z][\w-]*[\s>/])/i,Xs=/^(?:[a-z]+:\/\/\S+|[~./]?[\w./@-]+\.[a-z0-9]{1,6}(?::\d+)?|[$>][^\n]*)$/i;function Zs(e){let t=e.trim(),n=(t.split(`
|
|
70
|
+
`,1)[0]??``).trim();return{heading:/^#{1,6}\s/.test(n),wholeBold:/^\*\*[\s\S]+\*\*$/.test(t)&&!/\*\*[\s\S]*\*\*[\s\S]*\*\*/.test(t.slice(2,-2)),fence:Js.test(t),listItem:/^(?:[-*+]\s|\d{1,3}[.)]\s)/.test(n),quote:/^>\s?/.test(n),table:/^\|/.test(n),artifact:Ys.test(t)||Xs.test(n)}}function Qs(e){return e.heading||e.wholeBold||e.fence||e.table||e.artifact}function $s(e){return e.replace(/(?:^|\n)[ \t]*(```|~~~)[^\n]*\n[\s\S]*?\n[ \t]*\1[^\n]*(?=\n|$)/g,` `).replace(/(?:^|\n)[ \t]*(```|~~~)[\s\S]*$/g,` `).replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]+)\]\[[^\]]*\]/g,`$1`).replace(/<((?:https?|mailto):[^>\s]+)>/g,`$1`).split(`
|
|
71
|
+
`).map(e=>e.replace(/^\s{0,3}#{1,6}\s+/,``).replace(/^\s{0,3}>\s?/,``).replace(/^\s*(?:[-*+]|\d{1,3}[.)])\s+/,``).replace(/^\s*([-*_])(?:\s*\1){2,}\s*$/,``)).join(`
|
|
72
|
+
`).replace(/``([^`]|`(?!`))+``/g,e=>e.slice(2,-2)).replace(/`([^`\n]+)`/g,`$1`).replace(/`/g,``).replace(/~~(?=\S)([\s\S]*?\S)~~/g,`$1`).replace(/\*\*\*(?=\S)([\s\S]*?\S)\*\*\*/g,`$1`).replace(/\*\*(?=\S)([\s\S]*?\S)\*\*/g,`$1`).replace(/(?<![\w*])\*(?=\S)([^*\n]*?\S)\*(?![\w*])/g,`$1`).replace(/(?<![\w_])__(?=\S)([\s\S]*?\S)__(?![\w_])/g,`$1`).replace(/(?<![\w_])_(?=\S)([^_\n]*?\S)_(?![\w_])/g,`$1`).replace(/\\([\\`*_{}[\]()#+\-.!>~|])/g,`$1`).replace(/\s+/g,` `).trim()}var ec=.9,tc=.75,nc=.4,rc={kind:`other`,confidence:0,rule:`none`},ic=400,ac=16,oc=/\?\s*$/,sc=/^(should|do you|would you|which|can you|could you|shall|is it ok|are you|want me|shall i|any preference)\b/i;function cc(e){let t=e.split(`
|
|
73
|
+
`).map(e=>e.trim()).filter(Boolean),n=hc(t[0]??``),r=t[t.length-1]??``;return oc.test(r)||sc.test(n)}function lc(e){return(e.match(/[.!?](?:\s|$)/g)??[]).length}function uc(e){return/:\s*$/.test(e)}var dc=/\b(if|unless|whether|would|could|should|might|maybe|perhaps|want me to|i'?d rather|in case|to see if|to make sure|so that|once|until|before)\b[^.\n]{0,40}$/i;function fc(e,t){return dc.test(e.slice(Math.max(0,t-60),t))}var pc=/`[^`\n]+`|\[[^\]]+\]\([^)\s]+\)|\b[\w@./-]+\.(?:ts|tsx|js|jsx|mjs|cjs|css|scss|json|jsonl|md|rs|swift|py|go|rb|java|kt|sql|sh|toml|yml|yaml|html|astro)\b(?::\d+)?/;function mc(e){return pc.test(e)}function hc(e){return e.replace(/[\u2018\u2019\u02BC]/g,`'`).replace(/[\u201C\u201D]/g,`"`)}var gc=140,_c=/^(?:todo\b|next steps?\b|still\s+(?:need|needs|to do|left)\b|not yet\b|not done\b|left to do\b|follow-?ups?\b|out of scope\b|remaining\b|i(?:'ve| have)? ?ha?ve ?n'?t\b|ha ?ve ?n'?t\b|did ?n'?t get to\b)/i;function vc(e){let t=hc(e.trim());return!(t.length===0||t.length>gc||!_c.test(t)||uc(t)||/\*\*|^#{1,6}\s|```/.test(t)||lc(t)>1)}function yc(e){if(vc(e))return{kind:`remaining`,confidence:ec,rule:`task-lead`};if(/\b(remaining|still need|not yet|left to do|follow-?up|todo)\b/i.test(e))return{kind:`remaining`,confidence:nc,rule:`task-word-in-body`}}var bc=/\b(?:all\s+)?(tests?|checks?|suites?|specs?|build|builds|typecheck|typechecks|lint|compile)\s+(?:are\s+|is\s+|now\s+|still\s+|all\s+)?(pass|passes|passed|passing|green|succeeds|succeeded|clean|fail|fails|failed|failing|red)\b/i,xc=/\b(not|n't|never|should|will|would|until|once|need to|needs to|make sure|to see if|whether|if)\b[^.\n]{0,40}$/i,Sc=/(?:tests?|checks?|cases?|cells?|specs?|suites?|assertions?|examples?|green)/,Cc=RegExp(`(?:${Sc.source}\\b[^.\\n]{0,16}(?<![\\d.])\\d{1,6}\\s*/\\s*\\d{1,6}(?![\\d.])|(?<![\\d.])\\d{1,6}\\s*/\\s*\\d{1,6}(?![\\d.])[^.\\n]{0,16}\\b${Sc.source})`,`i`),wc=/\b\d{1,6}\s+(green|passing|failing|red)\b/i;function Tc(e){let t=bc.exec(e);if(t&&!xc.test(e.slice(Math.max(0,t.index-60),t.index)))return{kind:`verification`,confidence:ec,rule:`runner-outcome`};let n=wc.exec(e);if(n&&!fc(e,n.index))return{kind:`verification`,confidence:tc,rule:`count-with-outcome`};let r=Cc.exec(e);if(r&&!fc(e,r.index))return{kind:`verification`,confidence:tc,rule:`ratio-beside-check-noun`};if(t)return{kind:`verification`,confidence:nc,rule:`runner-outcome-hedged`}}var Ec=/^(?:(?:so|ok|okay|right|good|and|but|well)[,:]?\s+)?/i,Dc=/^(?:now|next|then|first|finally|after that)[,:]?\s+/i,Oc=/^(?:i'?ll|i will|let me|let's|i'?m going to|i'?m about to|i'?m now|i am going to|going to|i plan to|my plan is|the plan is|approach:)\b/i,kc=/^(?:adding|removing|deleting|dropping|fixing|updating|rewriting|writing|wiring|building|measuring|checking|testing|verifying|extracting|switching|replacing|moving|making|reproducing|implementing|refactoring|migrating|renaming|splitting|merging|porting|wrapping|converting|restoring|reverting|generating|instrumenting|profiling|benchmarking)\b/i;function Ac(e){let t=e.slice((Ec.exec(e)?.[0]??``).length),n=Dc.exec(t)?.[0],r=n?t.slice(n.length):t;if(Oc.test(r))return{kind:`approach`,confidence:ec,rule:`intent-modal-lead`};if(n&&kc.test(r))return{kind:`approach`,confidence:tc,rule:`sequenced-step-lead`};if(kc.test(r))return{kind:`approach`,confidence:nc,rule:`bare-gerund`};if(uc(e))return{kind:`approach`,confidence:nc,rule:`announces-list`}}var jc=/^(?:(?:so|ok|okay|and|but|well)[,:]?\s+)?(?:found it|found that|found|i found|i'?ve found|discovered|i discovered|turns out|it turns out|the (?:root )?cause (?:is|was)|the (?:issue|problem|bug|defect|fault|regression) (?:is|was|turned out)|root cause:|cause:|the real (?:cause|problem|issue|reason|bug)|confirmed:)\b/i,Mc=/\b(?:(?:is|was|were|are)\s+(?:wrong|broken|stale|missing|empty|null|undefined|the problem|the cause)|(?:does ?n'?t|do ?n'?t|did ?n'?t|is ?n'?t|are ?n'?t|was ?n'?t|were ?n'?t|ca ?n'?t|could ?n'?t|never|no longer|not actually)\s+\w+)/i;function Nc(e){if(jc.test(e))return{kind:`discovery`,confidence:ec,rule:`finding-lead`};let t=Mc.exec(e);if(t)return{kind:`discovery`,confidence:nc,rule:!fc(e,t.index)&&mc(e)&&lc(e)<=2?`defect-with-referent`:`defect-uncorroborated`};if(/\b(found|discovered|turns out|actually|noticed|the real \w+)\b/i.test(e))return{kind:`discovery`,confidence:nc,rule:`finding-word-in-body`}}var Pc=/^(?:summary|in summary|to summari[sz]e|here'?s what|what i did|what changed|done\b|completed\b|finished\b|all done\b)/i;function Fc(e,t){if(t===`final`&&Pc.test(e))return{kind:`summary`,confidence:ec,rule:`summary-lead`}}function Ic(e,t=`commentary`){if(Qs(Zs(e)))return{kind:`other`,confidence:0,rule:`not-narration`};let n=zc($s(e));if(n.length<ac||n.length>ic)return{kind:`other`,confidence:0,rule:n.length<ac?`too-short`:`too-long`};let r=hc(n),i=[yc(r),Tc(r),Fc(r,t),Nc(r),Ac(r)].filter(e=>e!==void 0),a=rc;for(let e of i)e.confidence>a.confidence&&(a=e);return Lc(a)?a:{kind:`other`,confidence:a.confidence,rule:a.rule}}function Lc(e){return e.confidence>=.7&&e.kind!==`other`}function Rc(e){let t=e.replace(/```[\s\S]*?```/g,` `).replace(/^\s*(?:[-*+]|\d{1,3}[.)])\s+/gm,``).replace(/^(\s*(?:\*\*|__))\s*\d{1,3}[.)]\s+/gm,`$1`),n=[];for(let e of t.split(/\n{2,}|\n(?=[A-Z\d#>*-])/)){let t=e.trim();if(t){if(t.length<=240){n.push(t);continue}for(let e of t.split(/(?<=[.!?:])\s+(?=[A-Z\d])/)){let t=e.trim();t&&n.push(t)}}}return n}function zc(e,t=200){let n=Bc(e);if(n.length<=t)return n;let r=n.slice(0,t),i=r.lastIndexOf(` `);return`${Bc((i>t*.6?r.slice(0,i):r).trimEnd())}…`}function Bc(e){return e.replace(/^(?:`|\*{1,3}|_{1,3})+\s*/,``).replace(/\s*(?:`|\*{1,3}|_{1,3})+$/,``)}function Vc(e,t,n=5){let r=[],i=new Set,a;if(cc(e.trim())){let t=zc($s(Hc(e)));t&&r.push({kind:`question`,text:t,confidence:ec,rule:`question`})}for(let o of Rc(e)){let e=Ic(o,t),s=zc($s(o));if(!s||e.rule===`not-narration`||cc(s))continue;if(!Lc(e)){(!a||e.confidence>a.confidence)&&(a={kind:e.kind,text:s,confidence:e.confidence,rule:e.rule});continue}let c=`${e.kind}:${s}`;if(!i.has(c)&&(i.add(c),r.push({kind:e.kind,text:s,confidence:e.confidence,rule:e.rule}),r.length>=n))break}return r.length>0?r:a?[a]:[]}function Hc(e){let t=e.split(`
|
|
74
|
+
`).map(e=>e.trim()).filter(Boolean);for(let e=t.length-1;e>=0;e--){let n=t[e]??``;if(/\?\s*$/.test(n))return n}return t[0]??``}function Uc(e,t=160){for(let n of e.split(`
|
|
75
|
+
`)){let e=$s(n);if(e.length!==0)return e.length>t?`${e.slice(0,t-1).trimEnd()}…`:e}return``}function Wc(e){return e<1e3?`${e} B`:e<1e6?`${(e/1e3).toFixed(1)} KB`:e<1e9?`${(e/1e6).toFixed(1)} MB`:`${(e/1e9).toFixed(2)} GB`}var Gc=[{runner:`vitest`,method:`test`,pattern:/^vitest(\s|$)/},{runner:`jest`,method:`test`,pattern:/^jest(\s|$)/},{runner:`playwright`,method:`test`,pattern:/^playwright\s+test(\s|$)/},{runner:`mocha`,method:`test`,pattern:/^mocha(\s|$)/},{runner:`pytest`,method:`test`,pattern:/^(pytest|py\.test)(\s|$)/},{runner:`cargo`,method:`test`,pattern:/^cargo\s+(nextest\s+run|test)(\s|$)/},{runner:`go`,method:`test`,pattern:/^go\s+test(\s|$)/},{runner:`xcodebuild`,method:`test`,pattern:/^xcodebuild\b.*\stest(-without-building)?(\s|$)/},{runner:`swift`,method:`test`,pattern:/^swift\s+test(\s|$)/},{runner:`dotnet`,method:`test`,pattern:/^dotnet\s+test(\s|$)/},{runner:`rspec`,method:`test`,pattern:/^rspec(\s|$)/},{runner:`phpunit`,method:`test`,pattern:/^phpunit(\s|$)/},{runner:`mix`,method:`test`,pattern:/^mix\s+test(\s|$)/},{runner:`gradle`,method:`test`,pattern:/^gradlew?\s+(:[\w-]+:)?test(\s|$)/},{runner:`maven`,method:`test`,pattern:/^mvn\s+(-[^\s]+\s+)*(test|verify)(\s|$)/},{runner:`node-test`,method:`test`,pattern:/^node\s+(--[^\s]+\s+)*--test(\s|$)/},{runner:`tsc`,method:`typecheck`,pattern:/^tsc(\s|$)/},{runner:`mypy`,method:`typecheck`,pattern:/^mypy(\s|$)/},{runner:`pyright`,method:`typecheck`,pattern:/^pyright(\s|$)/},{runner:`eslint`,method:`lint`,pattern:/^eslint(\s|$)/},{runner:`biome`,method:`lint`,pattern:/^biome\s+(check|lint|ci)(\s|$)/},{runner:`ruff`,method:`lint`,pattern:/^ruff\s+(check|format\s+--check)(\s|$)/},{runner:`clippy`,method:`lint`,pattern:/^cargo\s+clippy(\s|$)/},{runner:`golangci-lint`,method:`lint`,pattern:/^golangci-lint\s+run(\s|$)/},{runner:`cargo-build`,method:`build`,pattern:/^cargo\s+(build|check)(\s|$)/},{runner:`go-build`,method:`build`,pattern:/^go\s+(build|vet)(\s|$)/},{runner:`xcodebuild`,method:`build`,pattern:/^xcodebuild(\s|$)/},{runner:`swift-build`,method:`build`,pattern:/^swift\s+build(\s|$)/},{runner:`vite-build`,method:`build`,pattern:/^vite\s+build(\s|$)/},{runner:`make`,method:`build`,pattern:/^make(\s|$)/},{runner:`npm-script`,method:`test`,pattern:/^(npm|pnpm|yarn|bun)\s+(run\s+)?test(:[\w-]+)?(\s|$)/,scopeUnknown:!0},{runner:`npm-script`,method:`typecheck`,pattern:/^(npm|pnpm|yarn|bun)\s+(run\s+)?(typecheck|type-check|tsc)(\s|$)/,scopeUnknown:!0},{runner:`npm-script`,method:`lint`,pattern:/^(npm|pnpm|yarn|bun)\s+(run\s+)?lint(\s|$)/,scopeUnknown:!0},{runner:`npm-script`,method:`build`,pattern:/^(npm|pnpm|yarn|bun)\s+(run\s+)?build(\s|$)/,scopeUnknown:!0}],Kc=/(^|\s)(--watch(=\S+)?|-w|--watchAll)(\s|$)/,qc=/(^|\s)(-k|-t|--grep|-g|--filter|-run|--only-testing|--testNamePattern|--testPathPattern|-x|--bail)(\s|=)/,Jc=new Set(`run.test.lint.build.typecheck.type-check.start.dev.exec.dlx.x.add.install.i.remove.rm.update.up.create.init.publish.link.why.ls.list.outdated.audit.view.info.config.cache.store.setup.env.patch`.split(`.`));function Yc(e){let t=[];for(let n of tl(e)){let e=n.real.trim();if(!e)continue;let r=e.split(/\s+/);for(;r.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(r[0]??``);)r.shift();if(r.length===0||r[0]===`cd`)continue;for(let e=0;e<3;e++){let e=r[0]??``,t=r[1]??``;if(e===`npx`||e===`bunx`||e===`yarn`){if(e===`yarn`&&(Jc.has(t)||t.startsWith(`-`)||!t))break;r.shift(),r[0]?.startsWith(`-`)&&r.shift();continue}if((e===`pnpm`||e===`npm`||e===`bun`)&&(t===`exec`||t===`dlx`||t===`x`)){r.splice(0,2);continue}if(e===`pnpm`&&t&&!Jc.has(t)&&!t.startsWith(`-`)){r.shift();continue}if((e===`python`||e===`python3`)&&t===`-m`){r.splice(0,2);continue}if(e===`bundle`&&t===`exec`||(e===`poetry`||e===`uv`||e===`pipenv`)&&t===`run`){r.splice(0,2);continue}break}if(r.length===0)continue;let i=r[0]??``,a=i.slice(i.lastIndexOf(`/`)+1);t.push([a,...r.slice(1)].join(` `))}return t}function Xc(e){return e.split(/\s+/).slice(1).some(e=>!e.startsWith(`-`)&&/\.(test|spec)\.[cm]?[jt]sx?$|\/|\.py$|\.rs$|\.go$|_test\b/.test(e))}function Zc(e){for(let t of Yc(e))for(let e of Gc){if(!e.pattern.test(t))continue;let n=Kc.test(t),r=e.scopeUnknown?`unknown`:`full`;return!e.scopeUnknown&&(qc.test(t)||Xc(t))&&(r=`partial`),{method:e.method,runner:e.runner,scope:r,watch:n}}}var Qc=[{id:`rm-rf`,pattern:/(^|\s)rm\s+(-[a-zA-Z]*r[a-zA-Z]*f|-[a-zA-Z]*f[a-zA-Z]*r)\b/,summary:`Recursive force delete`},{id:`git-force-push`,pattern:/(^|\s)git\s+push\b[^|;&]*(\s--force\b|\s-f\b|\s--force-with-lease\b)/,summary:`Force push`},{id:`git-reset-hard`,pattern:/(^|\s)git\s+reset\s+--hard\b/,summary:`Hard reset`},{id:`git-clean`,pattern:/(^|\s)git\s+clean\s+-[a-zA-Z]*f/,summary:`git clean -f`},{id:`git-checkout-discard`,pattern:/(^|\s)git\s+(checkout|restore)\s+(--\s+)?\.(\s|$)/,summary:`Discard working tree changes`},{id:`drop-table`,pattern:/\bdrop\s+(table|database|schema)\b/i,summary:`DROP TABLE/DATABASE`},{id:`no-verify`,pattern:/(^|\s)git\s+(commit|push)\b[^|;&]*\s--no-verify\b/,summary:`Skipped git hooks (--no-verify)`},{id:`chmod-777`,pattern:/(^|\s)chmod\s+(-R\s+)?777\b/,summary:`chmod 777`},{id:`sudo`,pattern:/(^|\s)sudo\s/,summary:`sudo`}];function $c(e){let t=e=>e.replace(/[^\n]/g,` `);return e.replace(/<<-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1[\s\S]*?^[ \t]*\2[ \t]*$/gm,t).replace(/'[^']*'/g,t).replace(/"[^"]*"/g,t)}var el=/&&|\|\||;|\||\n/g;function tl(e){let t=$c(e),n=[],r=0;el.lastIndex=0;for(let i=el.exec(t);i;i=el.exec(t))n.push({real:e.slice(r,i.index),masked:t.slice(r,i.index)}),r=i.index+i[0].length;return n.push({real:e.slice(r),masked:t.slice(r)}),n}function nl(e){let t=tl(e);for(let e of Qc){let n=t.find(t=>e.pattern.test(t.masked));if(n)return{id:e.id,summary:e.summary,segment:n.real.trim()}}}var rl=String.raw`(?:(?:-C\s+\S+|-c\s+\S+|--[\w-]+(?:=\S+)?|-\w)\s+)*`,il=new RegExp(String.raw`(^|\s)git\s+${rl}commit\b`),al=new RegExp(String.raw`(^|\s)git\s+${rl}push\b`);function ol(e){if(al.test(e))return`push`;if(il.test(e))return`commit`}var sl=/\x1b\[[0-9;?]*[ -/]*[@-~]/g;function cl(e){return e.replace(sl,``)}function K(e){if(e===void 0)return;let t=Number.parseInt(e,10);return Number.isFinite(t)?t:void 0}function q(e,t){let n,r,i=new RegExp(e.source,e.flags.includes(`g`)?e.flags:`${e.flags}g`);for(;(n=i.exec(t))!==null;)r=n;return r}function ll(e){let t={};for(let n of e.matchAll(/(\d+)\s+(failed|passed|skipped|todo|pending|expected fail|flaky)/g)){let e=Number(n[1]);switch(n[2]){case`failed`:t.failed=(t.failed??0)+e;break;case`passed`:t.passed=(t.passed??0)+e;break;default:t.skipped=(t.skipped??0)+e}}return t}function ul(e,t){let n=!1,r={pass:0,fail:0};for(let i of t.matchAll(e))n=!0,i[1]===`pass`?r.pass+=K(i[2])??0:r.fail+=K(i[2])??0;return n?r:void 0}function dl(e){return e?(e.failed??0)>0?`fail`:(e.passed??0)>0?`pass`:`unknown`:`unknown`}var fl={vitest:e=>{let t=q(/^\s*Tests\s+(.+?)\s*\((\d+)\)\s*$/m,e),n=q(/^\s*Test Files\s+(.+?)\s*\((\d+)\)\s*$/m,e),r=t??n;if(!r)return/No test files found/i.test(e)?{runner:`vitest`,outcome:`unknown`,rule:`vitest.none`}:void 0;let i=ll(r[1]??``);return i.total=K(r[2]),{runner:`vitest`,outcome:dl(i),counts:i,rule:`vitest.summary`}},jest:e=>{let t=q(/^Tests:\s+(.+?),\s*(\d+)\s+total\s*$/m,e);if(!t)return;let n=ll(t[1]??``);return n.total=K(t[2]),{runner:`jest`,outcome:dl(n),counts:n,rule:`jest.summary`}},pytest:e=>{let t=q(/^=+\s+(.+?)\s+in\s+[\d.]+s(?:\s+\([^)]*\))?\s+=+\s*$/m,e);if(!t)return/no tests ran/i.test(e)?{runner:`pytest`,outcome:`unknown`,rule:`pytest.none`}:void 0;let n={};for(let e of(t[1]??``).matchAll(/(\d+)\s+(failed|passed|skipped|deselected|xfailed|xpassed|errors?|warnings?)/g)){let t=Number(e[1]),r=e[2]??``;r===`failed`||r.startsWith(`error`)?n.failed=(n.failed??0)+t:r===`passed`||r===`xpassed`?n.passed=(n.passed??0)+t:(r===`skipped`||r===`xfailed`||r===`deselected`)&&(n.skipped=(n.skipped??0)+t)}return n.total=(n.passed??0)+(n.failed??0)+(n.skipped??0),{runner:`pytest`,outcome:dl(n),counts:n,rule:`pytest.summary`}},cargo:e=>{let t=[...e.matchAll(/^test result: (ok|FAILED)\. (\d+) passed; (\d+) failed; (\d+) ignored/gm)];if(t.length===0)return/^error(\[E\d+\])?:/m.test(e)?{runner:`cargo`,outcome:`fail`,rule:`cargo.compile-error`}:void 0;let n={passed:0,failed:0,skipped:0},r=!1;for(let e of t)e[1]===`FAILED`&&(r=!0),n.passed=(n.passed??0)+Number(e[2]),n.failed=(n.failed??0)+Number(e[3]),n.skipped=(n.skipped??0)+Number(e[4]);return n.total=(n.passed??0)+(n.failed??0)+(n.skipped??0),{runner:`cargo`,outcome:r||(n.failed??0)>0?`fail`:`pass`,counts:n,rule:`cargo.summary`}},go:e=>{let t=[...e.matchAll(/^(ok|FAIL|\?)\s+(\S+)/gm)];if(t.length===0)return;let n=[...e.matchAll(/^\s*--- (PASS|FAIL|SKIP): /gm)],r={};return n.length>0&&(r.passed=n.filter(e=>e[1]===`PASS`).length,r.failed=n.filter(e=>e[1]===`FAIL`).length,r.skipped=n.filter(e=>e[1]===`SKIP`).length,r.total=n.length),{runner:`go`,outcome:t.some(e=>e[1]===`FAIL`)||/\[build failed\]/.test(e)?`fail`:`pass`,counts:n.length?r:void 0,rule:`go.package-lines`}},xcodebuild:e=>{let t=q(/\*\* (TEST|BUILD) (SUCCEEDED|FAILED|EXECUTE FAILED) \*\*/,e),n=q(/Executed (\d+) tests?, with (?:(\d+) tests? skipped and )?(\d+) failures?/,e);if(!t&&!n)return;let r=n?{total:K(n[1]),skipped:K(n[2])??0,failed:K(n[3]),passed:(K(n[1])??0)-(K(n[3])??0)-(K(n[2])??0)}:void 0;return{runner:`xcodebuild`,outcome:t?t[2]===`SUCCEEDED`?`pass`:`fail`:dl(r),counts:r,rule:`xcodebuild.marker`}},swift:e=>{let t=q(/Test run with (\d+) tests?(?: in \d+ suites?)? (passed|failed) after [\d.]+ seconds(?: with (\d+) issues?)?/,e),n=q(/Executed (\d+) tests?, with (?:(\d+) tests? skipped and )?(\d+) failures?/,e);if(!t&&!n)return/^error:/m.test(e)||/Compiling.*\n.*error:/.test(e)?{runner:`swift`,outcome:`fail`,rule:`swift.compile-error`}:void 0;let r={},i=`unknown`;if(t){r.total=(r.total??0)+(K(t[1])??0);let e=K(t[3])??0;r.failed=(r.failed??0)+(t[2]===`failed`?Math.max(1,e):0),i=t[2]===`passed`?`pass`:`fail`}n&&(r.total=(r.total??0)+(K(n[1])??0),r.failed=(r.failed??0)+(K(n[3])??0),r.skipped=(r.skipped??0)+(K(n[2])??0),(K(n[3])??0)>0?i=`fail`:i===`unknown`&&(i=`pass`));let a=(r.total??0)-(r.failed??0)-(r.skipped??0);return a>=0&&(r.passed=a),{runner:`swift`,outcome:i,counts:r,rule:`swift.summary`}},playwright:e=>{let t=q(/^\s*(\d+) passed(?: \([^)]*\))?\s*$/m,e),n=q(/^\s*(\d+) failed\s*$/m,e),r=q(/^\s*(\d+) skipped\s*$/m,e),i=q(/^\s*(\d+) flaky\s*$/m,e);if(!t&&!n)return;let a={passed:K(t?.[1])??0,failed:K(n?.[1])??0,skipped:(K(r?.[1])??0)+(K(i?.[1])??0)};return a.total=(a.passed??0)+(a.failed??0)+(a.skipped??0),{runner:`playwright`,outcome:dl(a),counts:a,rule:`playwright.summary`}},mocha:e=>{let t=q(/^\s*(\d+) passing/m,e),n=q(/^\s*(\d+) failing/m,e),r=q(/^\s*(\d+) pending/m,e);if(!t&&!n)return;let i={passed:K(t?.[1])??0,failed:K(n?.[1])??0,skipped:K(r?.[1])??0};return i.total=(i.passed??0)+(i.failed??0)+(i.skipped??0),{runner:`mocha`,outcome:dl(i),counts:i,rule:`mocha.summary`}},"node-test":e=>{let t=ul(/^# (pass|fail) (\d+)$/gm,e),n=ul(/^ℹ (pass|fail) (\d+)$/gm,e),r=n??t;if(!r)return;let i={passed:r.pass,failed:r.fail};return i.total=r.pass+r.fail,{runner:`node-test`,outcome:dl(i),counts:i,rule:n?`node-test.spec`:`node-test.tap`}},astro:e=>{let t=q(/^Result \(\d+ files?\):[ \t]*\n-[ \t]*(\d+) errors?/m,e);if(t){let e=K(t[1])??0;return{runner:`astro`,outcome:e>0?`fail`:`pass`,counts:{failed:e},rule:`astro.check`}}if(/\[build\] Complete!/.test(e))return{runner:`astro`,outcome:`pass`,rule:`astro.build`}},dotnet:e=>{let t=q(/(Passed|Failed)!\s+-\s+Failed:\s+(\d+),\s+Passed:\s+(\d+),\s+Skipped:\s+(\d+),\s+Total:\s+(\d+)/,e);if(!t)return;let n={failed:K(t[2]),passed:K(t[3]),skipped:K(t[4]),total:K(t[5])};return{runner:`dotnet`,outcome:dl(n),counts:n,rule:`dotnet.summary`}},rspec:e=>{let t=q(/^(\d+) examples?, (\d+) failures?(?:, (\d+) pending)?/m,e);if(!t)return;let n={total:K(t[1]),failed:K(t[2]),skipped:K(t[3])??0};return n.passed=(n.total??0)-(n.failed??0)-(n.skipped??0),{runner:`rspec`,outcome:dl(n),counts:n,rule:`rspec.summary`}},mix:e=>{let t=q(/^(\d+) tests?, (\d+) failures?/m,e);if(!t)return;let n={total:K(t[1]),failed:K(t[2])};return n.passed=(n.total??0)-(n.failed??0),{runner:`mix`,outcome:dl(n),counts:n,rule:`mix.summary`}},phpunit:e=>{let t=q(/^OK \((\d+) tests?, \d+ assertions?\)/m,e);if(t)return{runner:`phpunit`,outcome:`pass`,counts:{total:K(t[1]),passed:K(t[1]),failed:0},rule:`phpunit.ok`};let n=q(/^Tests: (\d+), Assertions: \d+(?:, Failures: (\d+))?(?:, Errors: (\d+))?/m,e);if(!n)return;let r=(K(n[2])??0)+(K(n[3])??0);return{runner:`phpunit`,outcome:r>0?`fail`:`pass`,counts:{total:K(n[1]),failed:r,passed:(K(n[1])??0)-r},rule:`phpunit.summary`}},tsc:e=>{let t=q(/Found (\d+) errors?/,e);if(t)return{runner:`tsc`,outcome:Number(t[1])>0?`fail`:`pass`,counts:{failed:K(t[1])},rule:`tsc.found`};if(/error TS\d+:/.test(e))return{runner:`tsc`,outcome:`fail`,counts:{failed:(e.match(/error TS\d+:/g)??[]).length},rule:`tsc.errors`}},eslint:e=>{let t=q(/✖ (\d+) problems? \((\d+) errors?, (\d+) warnings?\)/,e);if(t)return{runner:`eslint`,outcome:Number(t[2])>0?`fail`:`pass`,counts:{failed:K(t[2])},rule:`eslint.summary`}},biome:e=>{let t=q(/Found (\d+) errors?/,e);if(t)return{runner:`biome`,outcome:Number(t[1])>0?`fail`:`pass`,counts:{failed:K(t[1])},rule:`biome.errors`};if(/Checked \d+ files? in/.test(e))return{runner:`biome`,outcome:`pass`,rule:`biome.checked`}}},pl={"npm-script":[`vitest`,`jest`,`playwright`,`mocha`,`node-test`,`tsc`,`eslint`,`biome`,`pytest`,`astro`],ruff:[],mypy:[],pyright:[],clippy:[`cargo`],"cargo-build":[`cargo`],"go-build":[`go`],"swift-build":[`swift`],"vite-build":[],make:[`vitest`,`jest`,`pytest`,`cargo`,`go`],gradle:[],maven:[],"golangci-lint":[]},ml={vitest:`test`,jest:`test`,playwright:`test`,mocha:`test`,"node-test":`test`,pytest:`test`,cargo:`test`,go:`test`,swift:`test`,dotnet:`test`,rspec:`test`,mix:`test`,phpunit:`test`,xcodebuild:`build`,astro:`build`,tsc:`typecheck`,eslint:`lint`,biome:`lint`};function hl(e,t,n){let r=cl(t),i=fl[e];if(i){let e=i(r);if(e)return e}let a=pl[e]??[],o=n===void 0?a:[...a.filter(e=>ml[e]===n),...a.filter(e=>ml[e]!==n)];for(let e of o){let t=fl[e]?.(r);if(t)return t}}Object.keys(fl);function gl(e,t){if(e.input.kind!==`command`)return;let n=Zc(e.input.command);if(!n||n.watch||e.input.background)return;let r=e.result?.kind===`command`?e.result:void 0,i=e.exit??r?.exit??{observation:`unknown`},a=r?.outputExcerpt??e.errorExcerpt??``,o=hl(n.runner,a,n.method),s=(o?ml[o.runner]:void 0)??n.method,c=[];r?.truncated&&c.push(`output-truncated`),n.scope===`partial`&&c.push(`scope-partial`),o||c.push(`no-summary-parsed`);let l=`unknown`,u=`inferred`,d=i.observation===`inferred-failure`||i.observation===`explicit`&&(i.code??0)!==0,f=i.observation===`inferred-success`||i.observation===`explicit`&&i.code===0;o&&o.outcome!==`unknown`?(l=o.outcome,o.outcome===`pass`&&d?(l=`partial`,c.push(`exit-summary-mismatch`)):o.outcome===`fail`&&f&&c.push(`exit-masked`),u=i.observation===`explicit`?`observed`:`inferred`):d?(l=`fail`,u=i.observation===`explicit`?`observed`:`inferred`):f?(l=`pass`,u=i.observation===`explicit`?`observed`:`inferred`,i.observation!==`explicit`&&c.push(`exit-inferred`)):l=`unknown`,e.status===`running`&&(l=`unknown`),(r?.interrupted||r?.timedOut)&&(l=`unknown`,c.push(r.interrupted?`interrupted`:`timed-out`));let p=l===`fail`||l===`partial`?_l(a,800):void 0;return{id:e.callId,callId:e.callId,turnId:e.turnId,at:e.endedAt??e.startedAt,seq:t,command:e.input.command,runner:o?.runner??n.runner,method:s,outcome:l,counts:o?.counts,scope:n.scope,exit:i,outcomeEpistemic:u,caveats:c,failureExcerpt:p,stale:!1}}function _l(e,t){return e.length<=t?e:e.slice(e.length-t)}var vl=class{ordinal=0;changes=[];sessionId;event;constructor(e,t){this.sessionId=e,this.event=t}add(e,t,n,r,i){this.changes.push({sessionId:this.sessionId,seq:this.event.seq,ordinal:this.ordinal++,ts:this.event.ts,facet:e,summary:J(t,160),epistemic:n,refs:i??[this.event.id],...r?{detail:r}:{}})}};function J(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1).trimEnd()}…`:n}function yl(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>=0?e.slice(t+1):e}function bl(e){return e.slice(0,7)}function xl(e){if(e.endedAt)return`ended`;if(e.waiting)return`waiting`;let t=e.turns[e.turns.length-1];return t&&!t.endedAt||e.running.length>0?`working`:t||e.startedAt?`idle`:`unknown`}function Sl(e,t,n,r){if(e.review.some(e=>e.id===r.id&&e.resolvedSeq===void 0))return;let i=r.instance?`${r.label}: ${r.instance}`:r.label;e.review.push({...r,summary:i,refs:r.refs??[t.id],createdSeq:t.seq,createdAt:t.ts,epistemic:r.epistemic??`inferred`}),n.changes.some(e=>e.facet===`review`&&e.summary===J(i,160))||n.add(`review`,i,r.epistemic??`inferred`,{rule:r.rule,severity:r.severity})}function Cl(e,t,n){for(let r of e.review)r.resolvedSeq===void 0&&n(r)&&(r.resolvedSeq=t.seq)}var wl=/\b(?:all\s+)?(tests?|checks?|build|typecheck|lint)\s+(?:are\s+|is\s+|now\s+|still\s+)?(pass|passes|passed|passing|green|succeeds|succeeded|clean)\b/i,Tl=/\b(not|n't|never|should|will|would|until|once|need to|needs to|make sure|to see if|whether|if)\b[^.\n]{0,40}$/i;function El(e){let t=wl.exec(e);if(!t)return!1;let n=e.slice(Math.max(0,t.index-60),t.index);return!Tl.test(n)}function Dl(e,t,n){let r=e.verifications[e.verifications.length-1];if(!(!r||r.seq!==t.seq)){if(r.outcome===`fail`)Sl(e,t,n,{id:`verification-failed:${r.method}`,rule:`verification-failed`,severity:`high`,label:kl(r),epistemic:r.outcomeEpistemic});else if(r.outcome===`pass`&&r.scope!==`partial`){let n=r.method!==`lint`;Cl(e,t,e=>e.id===`verification-failed:${r.method}`||n&&e.rule===`changes-unverified`)}}}function Ol(e,t,n){switch(t.kind){case`permission.requested`:Sl(e,t,n,{id:`waiting:permission:${t.seq}`,rule:`waiting-permission`,severity:`high`,label:`Waiting for your permission`,instance:t.summary,epistemic:`observed`});break;case`notification`:e.waiting?.kind===`input`&&e.waiting.seq===t.seq&&Sl(e,t,n,{id:`waiting:input:${t.seq}`,rule:`waiting-input`,severity:`high`,label:`Agent needs input`,instance:J(t.message,120),epistemic:`observed`});break;case`tool.called`:if(t.input.kind===`question`&&Sl(e,t,n,{id:`waiting:question:${t.callId}`,rule:`waiting-question`,severity:`high`,label:`Asked you a question`,instance:J(t.input.questions[0]??`a question`,120),epistemic:`observed`}),t.input.kind===`command`){let r=nl(t.input.command);r&&Sl(e,t,n,{id:`destructive:${t.callId}`,rule:`destructive:${r.id}`,severity:r.id===`sudo`?`info`:`medium`,label:r.summary,instance:J(r.segment,100),epistemic:`observed`})}Dl(e,t,n),Cl(e,t,e=>e.rule===`waiting-permission`||e.rule===`waiting-input`);break;case`tool.completed`:case`tool.failed`:if(Cl(e,t,e=>e.rule===`waiting-permission`||e.rule===`waiting-input`||e.id===`waiting:question:${t.callId}`),Dl(e,t,n),t.kind===`tool.completed`&&t.result.kind===`command`&&!t.isError&&!t.result.gitOperation?.push){let r=e.activities[t.callId];r?.input.kind===`command`&&ol(r.input.command)===`push`&&Sl(e,t,n,{id:`push:${t.callId}`,rule:`git-push`,severity:`low`,label:`Pushed to remote`,epistemic:`inferred`})}t.kind===`tool.completed`&&t.result.kind===`command`&&t.result.gitOperation?.push&&Sl(e,t,n,{id:`push:${t.callId}`,rule:`git-push`,severity:`low`,label:`Pushed${t.result.gitOperation.push.branch?` ${t.result.gitOperation.push.branch}`:` to remote`}`,epistemic:`observed`});break;case`turn.started`:Cl(e,t,e=>e.rule.startsWith(`waiting-`));break;case`turn.ended`:{Cl(e,t,e=>e.rule.startsWith(`waiting-`));let r=e.turns.find(n=>n.id===(t.turnId??e.turns[e.turns.length-1]?.id));if(t.outcome===`failed`&&Sl(e,t,n,{id:`turn-failed:${t.seq}`,rule:`turn-failed`,severity:`high`,label:`Turn failed`,instance:J(t.error??`error`,120),epistemic:`observed`}),r){let i=[...e.verifications].filter(e=>e.outcome===`pass`&&e.scope!==`partial`&&e.method!==`lint`).sort((e,t)=>e.at.localeCompare(t.at)).pop(),a=Object.values(e.files).filter(e=>!i||e.lastChangedAt>i.at);if(r.filesTouched.length>0&&a.length>0){let r=i?`low`:`medium`,o=i?`${a.length} file${a.length===1?``:`s`} changed since the last passing check`:`${a.length} file${a.length===1?``:`s`} changed with no passing check observed`,s=e.review.find(e=>e.rule===`changes-unverified`&&e.resolvedSeq===void 0);s?(s.label=o,s.summary=o,s.severity=r,s.detail=a.map(e=>e.path).slice(0,50).join(`
|
|
76
|
+
`)):Sl(e,t,n,{id:`changes-unverified:${t.seq}`,rule:`changes-unverified`,severity:r,label:o,detail:a.map(e=>e.path).slice(0,50).join(`
|
|
77
|
+
`)})}t.lastMessage&&El(t.lastMessage)&&(e.verifications.some(e=>e.turnId===r.id&&e.outcome===`pass`)||Sl(e,t,n,{id:`claim-without-evidence:${r.id}`,rule:`claim-without-evidence`,severity:`medium`,label:`Agent reports checks passing, but no passing check was observed this turn`,detail:J(t.lastMessage,300)}))}break}}}function kl(e){let t=e.runner?` (${e.runner})`:``;return e.method===`test`?e.counts?.failed?`${e.counts.failed} test${e.counts.failed===1?``:`s`} failing${t}`:`Tests failing${t}`:`${e.method===`typecheck`?`Typecheck`:e.method===`lint`?`Lint`:e.method===`build`?`Build`:`Check`} failing${t}${e.counts?.failed?` (${e.counts.failed} errors)`:``}`}function Al(e,t){if(t.seq<=e.latestSeq)return[];let n=new vl(e.sessionId,t);switch(e.latestSeq=t.seq,e.revision+=1,e.lastEventAt=_u(e.lastEventAt,t.ts),t.redactions&&(e.counters.redactions+=t.redactions),t.kind){case`session.started`:Ml(e,t,n);break;case`session.updated`:t.model&&(e.model=t.model),t.title&&(e.title=t.title),t.gitBranch&&(e.gitBranch=t.gitBranch),t.cwd&&(e.cwd=t.cwd);break;case`session.ended`:e.endedAt=t.ts,n.add(`status`,`Session ended`,`observed`);break;case`turn.started`:Ll(e,t,n);break;case`turn.ended`:Rl(e,t,n);break;case`agent.message`:zl(e,t,n);break;case`agent.thinking`:break;case`agent.usage`:Vl(e,t);break;case`tool.called`:ql(e,t,n);break;case`tool.completed`:Xl(e,t,n);break;case`tool.failed`:uu(e,t,n);break;case`subagent.started`:e.subagents[t.subagentId]={id:t.subagentId,agentType:t.agentType,description:t.description,startedAt:t.ts,toolCalls:0,eventId:t.id},n.add(`how`,`Delegated to ${t.agentType??`subagent`}: ${t.description??t.subagentId}`,`observed`);break;case`subagent.ended`:{let r=e.subagents[t.subagentId];r&&(r.endedAt=t.ts,r.lastMessage=t.lastMessage?J($s(t.lastMessage),600):void 0,r.lastMessage&&(r.eventId=t.id)),n.add(`how`,`Subagent finished: ${r?.description??t.subagentId}`,`observed`);break}case`plan.updated`:mu(e,t,n);break;case`compaction`:{let r=e.lastCompactionAt?Date.parse(e.lastCompactionAt):NaN,i=Date.parse(t.ts);if(!Number.isNaN(r)&&!Number.isNaN(i)&&Math.abs(i-r)<6e4)break;e.lastCompactionAt=t.ts,e.counters.compactions+=1,n.add(`status`,`Context compacted`,`observed`);break}case`permission.requested`:e.waiting={kind:`permission`,since:t.ts,summary:t.summary,seq:t.seq};break;case`notification`:(t.notificationType===`idle_prompt`||t.notificationType===`agent_needs_input`)&&(e.waiting={kind:`input`,since:t.ts,summary:t.message,seq:t.seq});break;case`git.snapshot`:hu(e,t,n);break;case`ingest.warning`:e.counters.ingestWarnings+=1;break;case`salidium.explanation`:e.explained={basedOnSeq:t.basedOnSeq,model:t.model,at:t.ts,what:t.what,why:{...t.why,lanes:t.why.lanes??[]},how:{...t.how,root:t.how.root??null},approachChange:t.approachChange?{...t.approachChange,fromSteps:t.approachChange.fromSteps??[],toSteps:t.approachChange.toSteps??[]}:null},n.add(`what`,t.what.summary,`explained`,{model:t.model})}Ol(e,t,n);let r=e.status;return e.status=xl(e),e.status!==r&&(e.statusSince=t.ts),n.changes}var jl=/\.salidium[/\\]explainer$/;function Ml(e,t,n){jl.test(t.cwd)&&(e.internal=!0);let r=t.reason===`resume`;if((!e.startedAt||!r)&&(e.startedAt=e.startedAt??t.ts),t.cwd&&(e.cwd=t.cwd),t.model&&(e.model=t.model),t.entrypoint&&(e.entrypoint=t.entrypoint),t.gitBranch&&(e.gitBranch=t.gitBranch),t.title&&(e.title=t.title),t.transcriptPath&&(e.transcriptPath=t.transcriptPath),t.reason===`compact`||t.reason===`clear`)return;let i=yl(e.cwd||``)||e.cwd;r?n.add(`status`,`Session resumed in ${i}`,`observed`,{model:e.model,reason:t.reason}):e.startLogged||(e.startLogged=!0,n.add(`status`,`Session started in ${i}`,`observed`,{model:e.model,reason:t.reason}))}function Nl(e){let t=e.turns[e.turns.length-1];return t&&!t.endedAt?t:void 0}function Pl(e,t){return t.turnId?e.turns.find(e=>e.id===t.turnId)||Fl(e,t.turnId,``,t.ts,t.seq):e.turns.find(e=>e.startedAt<=t.ts&&(!e.endedAt||t.ts<=e.endedAt))??Nl(e)??e.turns[e.turns.length-1]}function Fl(e,t,n,r,i){let a=Nl(e);if(a&&a.id!==t&&a.activityIds.length===0&&a.prompt===``)return a.id=t,a.prompt=n,a;a&&a.id!==t&&Il(a,r,i,`interrupted`,!0);let o={id:t,index:e.turns.length,prompt:n,startedAt:r,activityIds:[],filesTouched:[],verificationIds:[],startSeq:i};return e.turns.push(o),e.counters.turns=e.turns.length,o}function Il(e,t,n,r,i=!1){e.endedAt||(e.endedAt=t,e.endSeq=n,e.outcome=r,e.endInferred=i)}function Ll(e,t,n){t.prompt?.includes(`[salidium-explainer]`)&&(e.internal=!0);let r=t.turnId??`turn-${e.turns.length+1}`,i=e.turns.find(e=>e.id===r);if(i){if(i.prompt)return;i.prompt=t.prompt,i.startedAt=t.ts,i.startSeq=t.seq,e.waiting=void 0;let r=Uc(t.prompt,140);n.add(`why`,r?`Asked: ${r}`:`New request`,`reported`,{author:`user`,turn:i.index});return}let a=Fl(e,r,t.prompt,t.ts,t.seq);e.waiting=void 0;let o=Uc(t.prompt,140);n.add(`why`,o?`Asked: ${o}`:`New request`,`reported`,{author:`user`,turn:a.index})}function Rl(e,t,n){let r=t.turnId?e.turns.find(e=>e.id===t.turnId):Nl(e);if(!r&&t.turnId&&(r=Fl(e,t.turnId,``,t.ts,t.seq)),!r)return;if(r.endedAt&&!r.endInferred){t.lastMessage&&!r.lastMessage&&(r.lastMessage=t.lastMessage,Bl(e,t,t.lastMessage,`final`,n,r));return}r.endInferred=!1,r.endedAt=t.ts,r.endSeq=t.seq,r.outcome=t.outcome,r.lastMessage=t.lastMessage,r.error=t.error,e.waiting=void 0;for(let n of e.running){let i=e.activities[n];i&&i.turnId===r.id&&(i.status=`unknown`,i.endedAt=t.ts)}if(e.running=e.running.filter(t=>e.activities[t]?.turnId!==r.id),t.outcome===`failed`){e.issues.push({id:`turn-failed:${r.id}`,kind:`turnFailed`,summary:t.error??`Turn failed`,seq:t.seq,ts:t.ts}),n.add(`status`,`Turn failed: ${J(t.error??`error`,120)}`,`observed`);return}if(t.outcome===`interrupted`){e.issues.push({id:`interrupted:${r.id}`,kind:`interrupted`,summary:`Turn interrupted`,seq:t.seq,ts:t.ts}),n.add(`status`,`Turn interrupted`,`observed`);return}let i=t.lastMessage?Uc(t.lastMessage,140):``;n.add(`status`,i?`Turn complete: ${i}`:`Turn complete`,i?`reported`:`observed`,{turn:r.index}),t.lastMessage&&Bl(e,t,t.lastMessage,`final`,n,r)}function zl(e,t,n){let r=t.text.trim();if(!r)return;let i=Pl(e,t),a=t.phase??`commentary`;i&&!i.headline&&!t.agentId&&(i.headline=Uc(r,140)),Bl(e,t,r,a,n,i)}function Bl(e,t,n,r,i,a){let o=Vc(n,r),s=a!==void 0&&e.claims.filter(e=>e.turnId===a.id&&!e.agentId).length===0;for(let[n,c]of o.entries()){let o={id:n===0?t.id:`${t.id}::${n}`,eventId:t.id,seq:t.seq,ts:t.ts,turnId:a?.id,agentId:t.agentId,kind:c.kind,text:c.text,confidence:c.confidence,rule:c.rule,phase:r,epistemic:`reported`};if(!e.claims.some(e=>e.text===o.text&&e.turnId===o.turnId)&&(e.claims.push(o),!t.agentId))switch(o.kind){case`discovery`:i.add(`why`,o.text,`reported`,{claim:o.kind,rule:o.rule});break;case`approach`:i.add(`how`,o.text,`reported`,{claim:o.kind,rule:o.rule});break;case`verification`:i.add(`verified`,`Agent says: ${o.text}`,`reported`,{claim:o.kind,rule:o.rule});break;case`remaining`:i.add(`left`,o.text,`reported`,{claim:o.kind,rule:o.rule});break;case`question`:r===`final`&&(e.waiting={kind:`question`,since:t.ts,summary:o.text,seq:t.seq},i.add(`review`,`Agent asks: ${o.text}`,`reported`,{claim:o.kind,rule:o.rule}));break;case`summary`:r===`final`&&i.add(`what`,o.text,`reported`,{claim:o.kind});break;default:s&&n===0&&i.add(`status`,o.text,`reported`,{claim:o.kind,rule:o.rule})}}}function Vl(e,t){let n=e.usage,r=t.agentId??`main`,i=n.lastByLane[r];i?.messageId===t.messageId?(n.inputTokens-=i.inputTokens,n.outputTokens-=i.outputTokens,n.cacheReadTokens-=i.cacheReadTokens,n.cacheWriteTokens-=i.cacheWriteTokens):n.messages+=1,n.inputTokens+=t.inputTokens,n.outputTokens+=t.outputTokens,n.cacheReadTokens+=t.cacheReadTokens,n.cacheWriteTokens+=t.cacheWriteTokens,n.lastByLane[r]={messageId:t.messageId,inputTokens:t.inputTokens,outputTokens:t.outputTokens,cacheReadTokens:t.cacheReadTokens,cacheWriteTokens:t.cacheWriteTokens}}function Hl(e){switch(e.source.channel){case`transcript`:case`rollout`:return 3;case`app-server`:return 2;case`hook`:return 1;case`salidium`:return 0}}function Ul(e){return(e.input.kind===`other`?0:100)+Hl(e)}function Wl(e){let t=100;switch(e.result.kind){case`command`:t=e.result.exit.observation===`explicit`?500:e.result.exit.observation===`unknown`?300:400;break;case`fileChanges`:{let n=e.result.changes.filter(e=>e.applied);t=300+(n.some(e=>e.linesAdded+e.linesRemoved>0)?100:0)+(n.some(e=>!!e.hunks?.length)?50:0);break}case`fileRead`:t=300;break;case`subagent`:t=e.result.status===`completed`?400:300;break;case`generic`:t=e.result.excerpt?200:100}return t*10+Hl(e)}function Gl(e){return(e.exit?.observation===`explicit`?500:e.exit?.observation===`unknown`?300:e.exit?400:200)*10+Hl(e)}function Kl(e,t){e.eventIds.includes(t)||e.eventIds.push(t),e.eventIds.sort((e,t)=>e.localeCompare(t))}function ql(e,t,n){let r=e.activities[t.callId];if(r){Jl(e,r,t,n);return}let i=Pl(e,t),a={callId:t.callId,turnId:i?.id,agentId:t.agentId,toolName:t.toolName,kind:t.input.kind,title:J(t.title,200),input:t.input.kind===`command`&&t.input.command.length>1200?{...t.input,command:`${t.input.command.slice(0,1200)}…`}:t.input,startedAt:t.ts,status:`running`,isError:!1,seqCalled:t.seq,callFidelity:Ul(t),eventIds:[t.id]};e.activities[t.callId]=a,e.activityOrder.push(t.callId),e.running.push(t.callId),e.counters.toolCalls+=1,t.input.kind===`command`&&(e.counters.commands+=1),i?.activityIds.push(t.callId);let o=t.agentId?e.subagents[t.agentId]:void 0;if(o&&(o.toolCalls+=1),t.input.kind===`question`){let n=t.input.questions[0]??`question`;e.waiting={kind:`question`,since:t.ts,summary:n,seq:t.seq}}}function Jl(e,t,n,r){let i=t.input.kind===`other`&&t.seqCompleted!==void 0,a=Ul(n);if(Kl(t,n.id),t.input.kind!==`other`&&a<=(t.callFidelity??-1))return;let o=t.input.kind,s=t.turnId?e.turns.find(e=>e.id===t.turnId):void 0,c=Pl(e,n);s&&c&&s.id!==c.id&&(s.activityIds=s.activityIds.filter(e=>e!==t.callId)),c&&!c.activityIds.includes(t.callId)&&c.activityIds.push(t.callId),t.turnId=c?.id??t.turnId,t.agentId=n.agentId??t.agentId,t.toolName=n.toolName,t.kind=n.input.kind,t.title=J(n.title,200),t.input=n.input.kind===`command`&&n.input.command.length>1200?{...n.input,command:`${n.input.command.slice(0,1200)}…`}:n.input,t.startedAt=n.ts,!t.resultDurationExplicit&&t.endedAt&&(t.durationMs=gu(n.ts,t.endedAt)),t.seqCalled=n.seq,t.callFidelity=a,o!==`command`&&n.input.kind===`command`&&(e.counters.commands+=1),o===`command`&&n.input.kind!==`command`&&--e.counters.commands;let l=n.agentId?e.subagents[n.agentId]:void 0;if(l&&i&&(l.toolCalls+=1),n.input.kind===`command`&&t.status!==`running`){if(t.result?.kind===`command`){su(e,t,{...n,id:t.eventIds.find(e=>e!==n.id)??n.id,kind:`tool.completed`,callId:t.callId,toolName:t.toolName,result:t.result,isError:t.isError,durationMs:t.durationMs},r,c),t.result=ru(t.result);return}if(t.isError&&t.status===`failed`){for(let n=e.issues.length-1;n>=0;n--)e.issues[n]?.callId===t.callId&&e.issues[n]?.kind===`toolError`&&e.issues.splice(n,1);pu(e,t,{...n,id:t.eventIds.find(e=>e!==n.id)??n.id,kind:`tool.failed`,callId:t.callId,toolName:t.toolName,errorExcerpt:t.errorExcerpt??``,cause:t.failureCause??`error`,exit:t.exit,interrupted:t.failureCause===`interrupted`||void 0,durationMs:t.durationMs},r)}}}function Yl(e,t,n){let r=e.activities[t];if(r)return r.status===`running`?(r.endedAt=n.ts,r.seqCompleted=n.seq,Kl(r,n.id),e.running=e.running.filter(e=>e!==t),e.waiting&&(e.waiting.kind===`permission`||e.waiting.kind===`input`)&&(e.waiting=void 0),r):r}function Xl(e,t,n){let r=e.activities[t.callId];if(!r){let n=Pl(e,t);r={callId:t.callId,turnId:n?.id,agentId:t.agentId,toolName:t.toolName,kind:iu(t),title:t.toolName,input:{kind:`other`,summary:t.toolName},startedAt:t.ts,status:`running`,isError:!1,seqCalled:t.seq,callFidelity:0,eventIds:[]},e.activities[t.callId]=r,e.activityOrder.push(t.callId),e.counters.toolCalls+=1,n?.activityIds.push(t.callId),e.running.push(t.callId)}if(r.status!==`running`){Zl(e,r,t,n);return}Yl(e,t.callId,t),r.status=t.isError?`failed`:`completed`,r.isError=t.isError,r.result=t.result,r.resultFidelity=Wl(t),r.resultDurationExplicit=t.durationMs!==void 0,r.durationMs=t.durationMs??r.durationMs??gu(r.startedAt,t.ts),t.result.kind===`command`&&(r.exit=t.result.exit),t.isError&&(e.counters.toolFailures+=1),r.kind===`question`&&e.waiting?.kind===`question`&&(e.waiting=void 0);let i=r.turnId?e.turns.find(e=>e.id===r.turnId):void 0;switch(t.result.kind){case`fileChanges`:for(let a of t.result.changes)au(e,r,a,t,n,i);break;case`command`:su(e,r,t,n,i);break;case`subagent`:{let n=t.result.agentId?e.subagents[t.result.agentId]:void 0;n&&(n.endedAt=n.endedAt??t.ts,n.lastMessage=n.lastMessage??t.result.summaryExcerpt)}}r.result=r.input.kind===`other`&&t.result.kind===`command`?t.result:ru(t.result)}function Zl(e,t,n,r){if(t.sourceConflict){Kl(t,n.id);return}let i=Wl(n);Kl(t,n.id);let a=t.turnId?e.turns.find(e=>e.id===t.turnId):void 0;if(n.result.kind===`command`&&t.result?.kind===`command`){if($l(Ql(t.result.exit,t.isError),Ql(n.result.exit,n.isError))){tu(e,t,n,r);return}if(i<=(t.resultFidelity??-1))return;t.exit=n.result.exit,t.isError=n.isError,t.status=n.isError?`failed`:`completed`,t.endedAt=n.ts,t.seqCompleted=n.seq,t.durationMs=n.durationMs??gu(t.startedAt,n.ts),t.resultDurationExplicit=n.durationMs!==void 0,t.resultFidelity=i;let o={...t,result:n.result,exit:n.result.exit},s=e.verifications.findIndex(e=>e.callId===t.callId),c=s>=0?e.verifications[s]:void 0;c&&(e.verifications.splice(s,1),a&&(a.verificationIds=a.verificationIds.filter(e=>e!==c.id)));let l=gl(o,n.seq);l&&cu(e,t,l,n,r,a,c===void 0||c.outcome!==l.outcome),t.result=ru(n.result);return}if(n.result.kind===`fileChanges`&&t.result?.kind===`fileChanges`){if(i<=(t.resultFidelity??-1))return;for(let i of n.result.changes){let o=t.result.changes.find(e=>e.path===i.path);if(!o){au(e,t,i,n,r,a);continue}let s=o.linesAdded+o.linesRemoved,c=i.linesAdded+i.linesRemoved,l=e.files[i.path];l&&(l.linesAdded+=i.linesAdded-o.linesAdded,l.linesRemoved+=i.linesRemoved-o.linesRemoved,e.counters.linesAdded+=i.linesAdded-o.linesAdded,e.counters.linesRemoved+=i.linesRemoved-o.linesRemoved,l.lastHunks=i.hunks?.slice(0,20),l.lastChangedAt=n.ts,l.lastChangeSeq=n.seq,l.lastAgentId=n.agentId,s===0&&c>0&&r.add(`what`,`${nu(i.change)} ${yl(i.path)} (+${i.linesAdded} −${i.linesRemoved})`,`observed`,{path:i.path,change:i.change,linesAdded:i.linesAdded,linesRemoved:i.linesRemoved,agentId:n.agentId}))}t.endedAt=n.ts,t.seqCompleted=n.seq,t.durationMs=n.durationMs??gu(t.startedAt,n.ts),t.resultDurationExplicit=n.durationMs!==void 0,t.resultFidelity=i,t.isError=n.isError,t.status=n.isError?`failed`:`completed`,t.result=ru(n.result);return}i<=(t.resultFidelity??-1)||(t.endedAt=n.ts,t.seqCompleted=n.seq,t.durationMs=n.durationMs??gu(t.startedAt,n.ts),t.resultDurationExplicit=n.durationMs!==void 0,t.resultFidelity=i,t.isError=n.isError,t.status=n.isError?`failed`:`completed`,t.result=ru(n.result))}function Ql(e,t){return t||e?.observation===`inferred-failure`?`fail`:e?.observation===`inferred-success`?`pass`:e?.observation===`explicit`?e.code===0?`pass`:`fail`:`unknown`}function $l(e,t){return e===`pass`&&t===`fail`||e===`fail`&&t===`pass`}function eu(e){return e.cause===`timeout`||e.cause===`interrupted`||e.cause===`rejected`||e.cause===`denied`?`unknown`:`fail`}function tu(e,t,n,r){let i=[...new Set([...t.eventIds,n.id])].sort(),a=n.kind===`tool.failed`||n.isError,o=t.status===`failed`||t.isError;a&&!o&&(e.counters.toolFailures+=1);let s=t.turnId?e.turns.find(e=>e.id===t.turnId):void 0,c=e.verifications.find(e=>e.callId===t.callId);e.verifications=e.verifications.filter(e=>e.callId!==t.callId),s&&(s.verificationIds=s.verificationIds.filter(e=>e!==t.callId)),e.issues=e.issues.filter(e=>e.callId!==t.callId),e.review=e.review.filter(e=>!(e.rule===`verification-failed`&&e.refs.some(e=>i.includes(e))));let l=t.endedAt&&t.endedAt>n.ts?t.endedAt:n.ts,u=n.durationMs??gu(t.startedAt,n.ts)??0;t.endedAt=l,t.durationMs=Math.max(t.durationMs??0,u),t.seqCompleted=n.seq,t.eventIds=i,t.status=`unknown`,t.sourceConflict=!0,t.isError=!1,t.errorExcerpt=void 0,t.failureCause=void 0,t.exit={observation:`unknown`},t.result={kind:`command`,exit:{observation:`unknown`},outputExcerpt:``,outputChars:0,truncated:!1},e.running=e.running.filter(e=>e!==t.callId);let d=gl(t,n.seq);d?cu(e,t,{...d,outcome:`unknown`,counts:void 0,exit:{observation:`unknown`},outcomeEpistemic:`observed`,caveats:[...new Set([...d.caveats,`source-conflict`])],failureExcerpt:void 0},n,r,s):c&&t.input.kind===`command`&&cu(e,t,{...c,at:l,seq:n.seq,outcome:`unknown`,counts:void 0,exit:{observation:`unknown`},outcomeEpistemic:`observed`,caveats:[...new Set([...c.caveats,`source-conflict`])],failureExcerpt:void 0},n,r,s);let f=`source-conflict:${t.callId}`;if(!e.review.some(e=>e.id===f&&e.resolvedSeq===void 0)){let a=`Conflicting tool results`,o=J(t.input.kind===`command`?t.input.command:t.title,120);e.review.push({id:f,rule:`source-conflict`,severity:`high`,label:a,instance:o,summary:`${a}: ${o}`,detail:`The provider records disagree about whether this call succeeded.`,refs:i,createdSeq:n.seq,createdAt:l,epistemic:`observed`}),r.add(`review`,`${a}: ${o}`,`observed`,{rule:`source-conflict`,severity:`high`})}}function nu(e){return e===`add`?`Created`:e===`delete`?`Deleted`:e===`move`?`Moved`:`Changed`}function ru(e){switch(e.kind){case`command`:return{...e,outputExcerpt:J(e.outputExcerpt,240)};case`fileChanges`:return{...e,changes:e.changes.map(e=>({...e,hunks:void 0}))};case`subagent`:return{...e,summaryExcerpt:e.summaryExcerpt?J(e.summaryExcerpt,400):void 0};case`generic`:return{...e,excerpt:e.excerpt?J(e.excerpt,240):void 0};default:return e}}function iu(e){switch(e.result.kind){case`command`:return`command`;case`fileChanges`:return`fileEdit`;case`fileRead`:return`fileRead`;case`subagent`:return`subagent`;default:return`other`}}function au(e,t,n,r,i,a){if(!n.applied){e.issues.push({id:`patch:${r.id}:${n.path}`,kind:`patchFailed`,summary:`Patch not applied: ${yl(n.path)}`,seq:r.seq,ts:r.ts,callId:t.callId}),i.add(`review`,`Patch not applied: ${yl(n.path)}`,`observed`);return}let o=e.files[n.path],s=o??{path:n.path,changeCount:0,linesAdded:0,linesRemoved:0,kinds:[],firstChangedAt:r.ts,lastChangedAt:r.ts,lastChangeSeq:r.seq,lastCallId:t.callId,turnIds:[]};o||(e.files[n.path]=s,e.counters.filesChanged+=1),s.changeCount+=1,s.linesAdded+=n.linesAdded,s.linesRemoved+=n.linesRemoved,s.kinds.includes(n.change)||s.kinds.push(n.change),s.lastChangedAt=r.ts>s.lastChangedAt?r.ts:s.lastChangedAt,s.lastChangeSeq=r.seq,s.lastCallId=t.callId,s.lastAgentId=r.agentId,n.hunks&&(s.lastHunks=n.hunks.slice(0,20)),n.userModifiedBefore&&(s.userModifiedBefore=!0),a&&!s.turnIds.includes(a.id)&&s.turnIds.push(a.id),a&&!a.filesTouched.includes(n.path)&&a.filesTouched.push(n.path),e.counters.linesAdded+=n.linesAdded,e.counters.linesRemoved+=n.linesRemoved;for(let t of e.verifications)t.at<=r.ts&&(t.stale=!0);let c=nu(n.change),l=n.change===`delete`?``:` (+${n.linesAdded} −${n.linesRemoved})`;n.change===`update`&&n.linesAdded+n.linesRemoved===0&&!n.hunks||i.add(`what`,`${c} ${yl(n.path)}${l}`,`observed`,{path:n.path,change:n.change,linesAdded:n.linesAdded,linesRemoved:n.linesRemoved,agentId:r.agentId}),n.userModifiedBefore&&i.add(`review`,`You had edited ${yl(n.path)} before the agent changed it`,`observed`,{path:n.path,rule:`user-modified`})}var ou=/^\s*(ls|cat|head|tail|grep|rg|find|fd|pwd|which|echo|wc|tree|stat|file|du|df|env|printenv|git\s+(status|log|diff|show|blame|branch|remote|rev-parse|ls-files)|sed\s+-n|awk|jq|less|more|type|node\s+-e|python3?\s+-c|open|curl\s+-s)\b/;function su(e,t,n,r,i){if(t.input.kind!==`command`||n.result.kind!==`command`)return;let a=t.input.command,o=n.result;if(o.gitOperation)e.git.operations.push({op:o.gitOperation,at:n.ts,callId:t.callId}),o.gitOperation.commit&&(e.git.commits.push({sha:o.gitOperation.commit.sha,at:n.ts,callId:t.callId,kind:o.gitOperation.commit.kind}),e.git.head=o.gitOperation.commit.sha,r.add(`what`,`Committed ${bl(o.gitOperation.commit.sha)}`,`observed`,{sha:o.gitOperation.commit.sha})),o.gitOperation.push&&e.git.pushes.push({branch:o.gitOperation.push.branch,at:n.ts,callId:t.callId});else{let i=ol(a);if(i===`commit`&&!n.isError){let i=/\[[^\]]*\s([0-9a-f]{7,40})\]/.exec(o.outputExcerpt)?.[1];e.git.commits.push({sha:i??``,at:n.ts,callId:t.callId}),i&&(e.git.head=i),r.add(`what`,i?`Committed ${bl(i)}`:`Committed`,i?`observed`:`inferred`,{sha:i})}else i===`push`&&!n.isError&&e.git.pushes.push({at:n.ts,callId:t.callId})}let s=gl(t,n.seq);if(s){cu(e,t,s,n,r,i);return}if(n.isError){e.issues.push({id:`command:${n.id}`,kind:`commandFailed`,summary:`Command failed: ${J(a,100)}`,seq:n.seq,ts:n.ts,callId:t.callId}),r.add(`what`,`Command failed: ${J(a,100)}`,`observed`,{exit:o.exit});return}!ou.test(a)&&(t.durationMs??0)>=3e4&&r.add(`what`,`Ran ${J(a,110)} (${Math.round((t.durationMs??0)/1e3)}s)`,`observed`)}function cu(e,t,n,r,i,a,o=!0){if(e.verifications.push(n),a?.verificationIds.push(n.id),o&&i.add(`verified`,lu(n),n.outcomeEpistemic,{outcome:n.outcome,runner:n.runner,method:n.method,counts:n.counts,caveats:n.caveats}),n.outcome===`fail`)e.issues.push({id:`verification:${n.id}`,kind:`commandFailed`,summary:lu(n),seq:r.seq,ts:r.ts,callId:t.callId});else if(n.outcome===`pass`&&n.scope!==`partial`)for(let t of e.issues)t.kind===`commandFailed`&&t.resolvedSeq===void 0&&t.id.startsWith(`verification:`)&&(t.resolvedSeq=r.seq)}function lu(e){let t=e.runner?` (${e.runner})`:``,n=e.counts,r=e.scope===`partial`?` [subset]`:``;if(e.method===`test`){if(e.outcome===`pass`){if(n?.total!==void 0&&n.total>0){let e=n.skipped?`, ${n.skipped} skipped`:``;return`${n.passed??0}/${n.total} tests passed${e}${t}${r}`}return`Tests passed${t}${r}${e.caveats?.includes(`exit-inferred`)?` (exit inferred)`:``}`}return e.outcome===`fail`?n?.failed!==void 0&&n.failed>0?`${n.failed} of ${n.total??`?`} tests failed${t}${r}`:`Tests failed${t}${r}`:e.outcome===`partial`?`Tests passed but command failed${t}`:`Test run result unknown${t}`}let i=e.method===`typecheck`?`Typecheck`:e.method===`lint`?`Lint`:e.method===`build`?`Build`:`Check`;return e.outcome===`pass`?`${i} passed${t}`:e.outcome===`fail`?`${i} failed${t}${n?.failed?` (${n.failed} error${n.failed===1?``:`s`})`:``}`:e.outcome===`partial`?`${i} partially passed${t}`:`${i} result unknown${t}`}function uu(e,t,n){du(e,t,n);let r=e.activities[t.callId];r&&(r.errorExcerpt=r.errorExcerpt===void 0?void 0:J(r.errorExcerpt,400),r.result?.kind===`command`&&(r.result={...r.result,outputExcerpt:J(r.result.outputExcerpt,240)}))}function du(e,t,n){let r=e.activities[t.callId];if(!r){let n=Pl(e,t);r={callId:t.callId,turnId:n?.id,agentId:t.agentId,toolName:t.toolName,kind:`other`,title:t.toolName,input:{kind:`other`,summary:t.toolName},startedAt:t.ts,status:`running`,isError:!1,seqCalled:t.seq,callFidelity:0,eventIds:[]},e.activities[t.callId]=r,e.activityOrder.push(t.callId),e.counters.toolCalls+=1,n?.activityIds.push(t.callId),e.running.push(t.callId)}if(r.sourceConflict){Kl(r,t.id);return}if(r.status!==`running`){r.result?.kind===`command`&&$l(Ql(r.result.exit,r.isError),eu(t))?tu(e,r,t,n):fu(e,r,t,n);return}if(Yl(e,t.callId,t),r.status=`failed`,r.isError=!0,r.errorExcerpt=t.errorExcerpt,r.failureCause=t.cause,r.resultFidelity=Gl(t),r.resultDurationExplicit=t.durationMs!==void 0,r.durationMs=t.durationMs??gu(r.startedAt,t.ts),t.exit&&(r.exit=t.exit),t.cause===`rejected`||t.cause===`denied`){r.status=`unknown`,e.waiting?.kind===`question`&&r.kind===`question`&&(e.waiting=void 0),n.add(`review`,`${t.cause===`rejected`?`You rejected`:`Denied`}: ${r.title}`,`observed`,{cause:t.cause});return}e.counters.toolFailures+=1,pu(e,r,t,n)}function fu(e,t,n,r){let i=Gl(n);if(Kl(t,n.id),i<=(t.resultFidelity??-1))return;let a=new Set(t.eventIds),o=t.turnId?e.turns.find(e=>e.id===t.turnId):void 0;e.verifications=e.verifications.filter(e=>e.callId!==t.callId),o&&(o.verificationIds=o.verificationIds.filter(e=>e!==t.callId)),e.issues=e.issues.filter(e=>e.callId!==t.callId),e.review=e.review.filter(e=>!(e.rule===`verification-failed`&&e.refs.some(e=>a.has(e)))),t.endedAt=n.ts,t.seqCompleted=n.seq,t.status=n.cause===`rejected`||n.cause===`denied`?`unknown`:`failed`,t.isError=!0,t.errorExcerpt=n.errorExcerpt,t.failureCause=n.cause,t.exit=n.exit,t.result=void 0,t.durationMs=n.durationMs??gu(t.startedAt,n.ts),t.resultDurationExplicit=n.durationMs!==void 0,t.resultFidelity=i,pu(e,t,n,r)}function pu(e,t,n,r){if(t.kind===`command`&&t.input.kind===`command`){let i=n.cause===`timeout`||n.cause===`interrupted`;t.result||={kind:`command`,exit:i?{observation:`unknown`}:n.exit??{observation:`inferred-failure`},outputExcerpt:n.errorExcerpt,outputChars:n.errorExcerpt.length,truncated:!1,interrupted:n.interrupted||n.cause===`interrupted`||void 0,timedOut:n.cause===`timeout`||void 0},i&&(t.exit={observation:`unknown`});let a=t.turnId?e.turns.find(e=>e.id===t.turnId):void 0,o=gl(t,n.seq);if(o){cu(e,t,o,n,r,a);return}if(n.interrupted){r.add(`what`,`Interrupted: ${J(t.input.command,100)}`,`observed`);return}e.issues.push({id:`command:${n.id}`,kind:`commandFailed`,summary:`Command failed: ${J(t.input.command,100)}`,seq:n.seq,ts:n.ts,callId:t.callId}),r.add(`what`,`Command failed: ${J(t.input.command,100)}`,`observed`,{exit:n.exit});return}e.issues.push({id:`tool:${n.id}`,kind:`toolError`,summary:`${t.title} failed`,seq:n.seq,ts:n.ts,callId:t.callId}),r.add(`what`,`${t.title} failed`,`observed`)}function mu(e,t,n){let r=e.plan.items,i;if(t.mode===`replace`)i=t.items.map(e=>({...e}));else{let e=new Map(r.map(e=>[e.id,{...e}]));for(let n of t.items){let t=e.get(n.id);e.set(n.id,t?{...t,status:n.status,text:n.text||t.text,activeForm:n.activeForm??t.activeForm}:{...n})}i=[...e.values()].filter(e=>e.status!==`cancelled`||r.some(t=>t.id===e.id))}e.plan={items:i,updatedAt:t.ts,updatedSeq:t.seq,explanation:t.explanation??e.plan.explanation};let a=i.filter(e=>e.status===`completed`).length,o=i.find(e=>e.status===`in_progress`),s=i.filter(e=>e.status===`pending`||e.status===`in_progress`).length,c=i.filter(e=>e.status===`completed`&&r.find(t=>t.id===e.id)?.status!==`completed`),l=r.length===0&&i.length>0;l&&n.add(`how`,`Plan: ${i.length} steps (${i.slice(0,3).map(e=>e.text).join(`; `)})`,`planned`,{items:i.length});for(let e of c)n.add(`left`,`Done: ${e.text}`,`reported`,{itemId:e.id,done:a,total:i.length});o&&(l||r.find(e=>e.id===o.id)?.status!==`in_progress`)&&n.add(`how`,`Now: ${o.activeForm??o.text}`,`planned`,{itemId:o.id}),t.explanation&&n.add(`why`,`Plan changed: ${t.explanation}`,`reported`);let u=JSON.stringify(r)!==JSON.stringify(i);!l&&c.length===0&&!o&&u&&n.add(`left`,s>0?`${s} of ${i.length} steps remaining`:`All plan steps completed`,`planned`,{pending:s,total:i.length})}function hu(e,t,n){let r=e.git.head;if(e.git.head=t.head??e.git.head,e.git.branch=t.branch??e.git.branch,e.git.dirtyCount=t.dirty.length+ +!!t.dirtyTruncated,e.git.snapshotAt=t.ts,e.repoRoot||=t.repoRoot,t.head&&r&&t.head!==r){let i=e.git.commits.find(e=>e.sha&&(t.head?.startsWith(e.sha)||e.sha.startsWith(t.head??``)));i?i.sha.length<t.head.length&&(i.sha=t.head):(e.git.headMoves.push({from:r,to:t.head,at:t.ts}),n.add(`what`,`HEAD moved to ${bl(t.head)}`,`observed`,{sha:t.head,branch:t.branch}))}}function gu(e,t){let n=Date.parse(e),r=Date.parse(t);if(!(Number.isNaN(n)||Number.isNaN(r)||r<n))return r-n}function _u(e,t){return e?t>e?t:e:t}function vu(e,t){if(e.status===`working`&&e.lastEventAt){let n=t-Date.parse(e.lastEventAt);if(Number.isFinite(n)&&n>9e5)return`idle`}return e.status}function yu(e,t=Date.now()){let n=vu(e,t),r=e.verifications.map(t=>ku(e,t)),i=r[r.length-1],a=Object.values(e.files).sort((e,t)=>t.lastChangeSeq-e.lastChangeSeq),o=[...e.verifications].filter(e=>e.outcome===`pass`&&e.scope!==`partial`&&e.method!==`lint`).sort((e,t)=>e.at.localeCompare(t.at)).pop(),s=e.review.filter(e=>e.resolvedSeq===void 0),c=s.filter(e=>e.severity!==`info`),l=s.slice().sort((e,t)=>bu(t.severity)-bu(e.severity)||t.createdSeq-e.createdSeq).map(Au),u=Fu(e),d=[...e.running].reverse().map(t=>e.activities[t]).find(e=>e&&!e.agentId&&t-Date.parse(e.startedAt)<6e5),f={status:n,statusSince:n===e.status?e.statusSince:e.lastEventAt,activeTitle:n===`working`?d?.title:void 0,activeSince:n===`working`?d?.startedAt:void 0,model:e.model,turns:e.turns.length,filesChanged:e.counters.filesChanged,linesAdded:e.counters.linesAdded,linesRemoved:e.counters.linesRemoved,commits:e.git.commits.length,latestVerification:i,reviewOpen:c.length,remaining:u.items.length,waiting:e.waiting?{kind:e.waiting.kind,summary:e.waiting.summary,since:e.waiting.since}:void 0},p=e.turns[e.turns.length-1],m=e=>e.kinds.includes(`delete`)?`-`:e.kinds.includes(`add`)&&e.kinds.length===1?`+`:`~`,h=Tu(e,d,p,a,n)[0];return{strip:f,explained:e.explained,verdict:Cu(e,n,d,o,c.length,a),report:{whatNow:h,editing:d&&(d.kind===`fileEdit`||d.kind===`fileWrite`)?d.title:a[0]?.path,ask:p?.prompt?{text:J(p.prompt,300),epistemic:`reported`,refs:[],at:p.startedAt,author:`user`}:void 0,plan:e.plan.items.map(e=>({text:e.text,status:e.status})),files:a.map(e=>({path:e.path,mark:m(e)})),runtimeMs:e.startedAt?Math.max(0,(e.lastEventAt?Date.parse(e.lastEventAt):t)-Date.parse(e.startedAt)):void 0},review:{glance:c.length===0?s.length===0?`Nothing needs you`:`Nothing needs you · ${s.length} noted`:`${c.length} item${c.length===1?``:`s`} need attention`,items:l,groups:ju(l),resolvedCount:e.review.length-s.length},changes:{glance:Eu(e),files:a.map(t=>Mu(e,t,o)),commands:e.activityOrder.map(t=>e.activities[t]).filter(e=>!!(e&&e.kind===`command`&&e.input.kind===`command`)).map(t=>Pu(e,t)),commits:e.git.commits.map(e=>({sha:e.sha,at:e.at,callId:e.callId}))},verified:{glance:Du(e,i),runs:r.slice().reverse(),summary:Ou(r),unverifiedFiles:a.filter(e=>!o||e.lastChangedAt>o.at).map(e=>e.path),claims:e.claims.filter(e=>e.kind===`verification`).map(e=>wu(e))},left:u,turns:e.turns.map(t=>Iu(e,t,r)),subagents:Object.values(e.subagents).map(e=>({...e})),ingest:{warnings:e.counters.ingestWarnings,redactions:e.counters.redactions,compactions:e.counters.compactions},usage:e.usage.messages>0?{messages:e.usage.messages,inputTokens:e.usage.inputTokens,outputTokens:e.usage.outputTokens,cacheReadTokens:e.usage.cacheReadTokens,cacheWriteTokens:e.usage.cacheWriteTokens}:void 0}}function bu(e){return e===`high`?3:e===`medium`?2:+(e===`low`)}function xu(e){return e.verifications.filter(t=>t.outcome===`fail`&&!e.verifications.some(e=>e.at>=t.at&&e.seq!==t.seq&&e.method===t.method&&e.outcome===`pass`&&e.scope!==`partial`))}function Su(e,t){return t===void 0?e.length:e.filter(e=>e.lastChangedAt>t).length}function Cu(e,t,n,r,i,a){let o=e.counters.filesChanged,s=e=>`${e} file${e===1?``:`s`}`;if(t===`waiting`&&e.waiting)return{headline:`Waiting for you`,tone:`attention`,epistemic:`observed`,because:e.waiting.summary,at:e.waiting.since,refs:[]};let c=xu(e).pop();if(c){let e=Su(a,c.at);return{headline:lu(c),tone:`fail`,epistemic:c.outcomeEpistemic,because:e>0?`${s(e)} changed after this check, so it may be out of date.`:c.caveats.includes(`exit-inferred`)?`Read from the output; the command reported no exit code.`:void 0,at:c.at,refs:[c.callId]}}if(t===`working`&&n)return{headline:n.title,tone:`working`,epistemic:`observed`,because:o>0?`${Eu(e)} so far.`:void 0,at:n.startedAt,refs:[n.callId]};let l=Su(a,r?.at);return o>0&&l>0?{headline:`${s(o)} changed, unverified`,tone:`attention`,epistemic:`observed`,because:r?`${s(l)} changed after the last passing check (${lu(r)}).`:`No passing test, build or typecheck run was observed in this session.`,at:r?.at,refs:r?[r.callId]:[]}:r?{headline:lu(r),tone:`pass`,epistemic:r.outcomeEpistemic,because:r.caveats.includes(`exit-inferred`)?`Read from the output; the command reported no exit code.`:o>0?`Ran after the last of ${s(o)} changed.`:void 0,at:r.at,refs:[r.callId]}:i>0?{headline:`${i} thing${i===1?``:`s`} need${i===1?`s`:``} you`,tone:`attention`,epistemic:`inferred`,refs:[]}:o>0?{headline:`${s(o)} changed`,tone:`neutral`,epistemic:`observed`,because:`No checks were observed in this session.`,refs:[]}:{headline:e.turns.length===0?`Nothing recorded yet`:`No files changed`,tone:`neutral`,epistemic:`observed`,refs:[]}}function wu(e){return{text:e.text,epistemic:`reported`,refs:[e.id],at:e.ts,author:e.agentId?`subagent`:`agent`}}function Tu(e,t,n,r,i){let a=[];if(i===`working`&&n){let t=[...e.claims].reverse().find(e=>e.turnId===n.id&&!e.agentId&&e.kind!==`question`);t?a.push({text:t.text,epistemic:`reported`,refs:[t.id],at:t.ts,author:`agent`}):n.headline?a.push({text:n.headline,epistemic:`reported`,refs:[],at:n.startedAt,author:`agent`}):a.push({text:`Working on: ${J(n.prompt,140)}`,epistemic:`reported`,refs:[],at:n.startedAt,author:`user`})}else if(n?.lastMessage){let t=e.claims.filter(e=>e.turnId===n.id&&e.phase===`final`&&e.kind===`summary`).pop();a.push({text:t?.text??Uc(n.lastMessage,300),epistemic:`reported`,refs:t?[t.id]:[],at:n.endedAt,author:`agent`})}else n?.headline&&a.push({text:n.headline,epistemic:`reported`,refs:[],at:n.startedAt,author:`agent`});let o=r.slice(0,6);t===void 0&&o.length>0&&a.push({text:`Recently: ${o.map(e=>yl(e.path)).join(`, `)}`,epistemic:`observed`,refs:o.map(e=>e.lastCallId)});let s=e.git.commits;return s.length>0&&a.push({text:`${s.length} commit${s.length===1?``:`s`}: ${s.map(e=>bl(e.sha||`???????`)).join(`, `)}`,epistemic:`observed`,refs:s.map(e=>e.callId??``).filter(Boolean)}),a}function Eu(e){let t=e.counters,n=[];return n.push(t.filesChanged===0?`No files changed`:`${t.filesChanged} file${t.filesChanged===1?``:`s`} changed (+${t.linesAdded} −${t.linesRemoved})`),t.commands>0&&n.push(`${t.commands} command${t.commands===1?``:`s`}`),e.git.commits.length>0&&n.push(`${e.git.commits.length} commit${e.git.commits.length===1?``:`s`}`),n.join(` · `)}function Du(e,t){return t?`${t.label}${t.stale?` (before latest changes)`:``}`:e.counters.filesChanged>0?`No checks observed`:`No checks yet`}function Ou(e){let t=new Map;for(let n of e){let e=t.get(n.method);if(n.outcome===`unknown`){e?e.outcome===`unknown`?t.set(n.method,{...n,laterUnreadable:0}):e.laterUnreadable+=1:t.set(n.method,{...n,laterUnreadable:0});continue}t.set(n.method,{...n,laterUnreadable:0})}return[...t.values()]}function ku(e,t){let n=t.turnId?e.turns.find(e=>e.id===t.turnId):void 0;return{id:t.id,callId:t.callId,at:t.at,label:lu(t),method:t.method,runner:t.runner,outcome:t.outcome,counts:t.counts,scope:t.scope,exit:t.exit,epistemic:t.outcomeEpistemic,caveats:t.caveats,stale:t.stale,command:t.command,failureExcerpt:t.failureExcerpt,turnIndex:n?.index}}function Au(e){return{id:e.id,rule:e.rule,severity:e.severity,label:e.label,instance:e.instance,summary:e.summary,detail:e.detail,refs:e.refs,createdAt:e.createdAt,epistemic:e.epistemic}}function ju(e){let t=new Map;for(let n of e){let e=t.get(n.rule);if(!e){t.set(n.rule,{rule:n.rule,label:n.label,severity:n.severity,occurrences:1,items:[{...n,repeats:1}],createdAt:n.createdAt});continue}e.occurrences++,bu(n.severity)>bu(e.severity)&&(e.severity=n.severity),n.createdAt>e.createdAt&&(e.createdAt=n.createdAt);let r=n.instance??n.label,i=e.items.find(e=>(e.instance??e.label)===r);i?i.repeats++:e.items.push({...n,repeats:1})}return[...t.values()]}function Mu(e,t,n){let r=t.turnIds.map(t=>e.turns.find(e=>e.id===t)?.index).filter(e=>e!==void 0),i=t.turnIds[t.turnIds.length-1],a=i?Nu(e,i,t):void 0;return{path:t.path,changeCount:t.changeCount,linesAdded:t.linesAdded,linesRemoved:t.linesRemoved,kinds:t.kinds,lastChangedAt:t.lastChangedAt,lastCallId:t.lastCallId,verifiedAfter:n!==void 0&&n.at>t.lastChangedAt,verifiedBy:n!==void 0&&n.at>t.lastChangedAt?lu(n):void 0,turnIndexes:r,reason:a}}function Nu(e,t,n){let r=n.lastAgentId,i=e.claims.filter(e=>(r?e.agentId===r:e.turnId===t&&!e.agentId)&&e.ts<=n.lastChangedAt&&(e.kind===`approach`||e.kind===`discovery`||e.kind===`status`)).sort((e,t)=>e.ts.localeCompare(t.ts)),a=yl(n.path).replace(/\.[^.]+$/,``),o=[...i].reverse().find(e=>a.length>2&&e.text.includes(a))??i[i.length-1];if(o)return{text:o.text,epistemic:`reported`,refs:[o.id],at:o.ts,author:r?`subagent`:`agent`};if(r){let t=e.subagents[r];if(t?.description)return{text:`Subagent: ${t.description}`,epistemic:`observed`,refs:[],at:t.startedAt,author:`subagent`}}}function Pu(e,t){let n=t.input.kind===`command`?t.input:void 0,r=t.turnId?e.turns.find(e=>e.id===t.turnId):void 0;return{callId:t.callId,command:n?.command??t.title,description:n?.description,at:t.startedAt,status:t.status,exit:t.exit,durationMs:t.durationMs,isVerification:e.verifications.some(e=>e.callId===t.callId),turnIndex:r?.index,agentId:t.agentId}}function Fu(e){let t=[];for(let n of e.plan.items)(n.status===`pending`||n.status===`in_progress`)&&t.push({id:`plan:${n.id}`,text:n.text,status:n.status,epistemic:`planned`,source:`plan`,refs:[]});let n=xu(e),r=new Set;for(let e of n)r.has(e.method)||(r.add(e.method),t.push({id:`verification:${e.id}`,text:lu(e),status:`failing`,epistemic:e.outcomeEpistemic,source:`verification`,refs:[e.callId]}));let i=e.turns[e.turns.length-1],a=e.claims.filter(e=>e.kind===`remaining`&&!e.agentId&&(!i||e.turnId===i.id));for(let e of a.slice(-5))t.push({id:`claim:${e.id}`,text:e.text,status:`reported`,epistemic:`reported`,source:`agent`,refs:[e.id]});let o=e.plan.items.filter(e=>e.status===`pending`||e.status===`in_progress`).length,s=[];return e.plan.items.length>0&&s.push(o===0?`All plan steps done`:`${o} of ${e.plan.items.length} steps remaining`),n.length>0&&s.push(`${n.length} failing check${n.length===1?``:`s`}`),a.length>0&&s.push(`${a.length} item${a.length===1?``:`s`} agent says remain`),{glance:s.length?s.join(` · `):t.length===0?`Nothing recorded as remaining`:`${t.length} remaining`,items:t,planExplanation:e.plan.explanation}}function Iu(e,t,n){let r=t.activityIds.map(t=>e.activities[t]).filter(e=>!!e),i=0,a=0;for(let e of r)if(e.result?.kind===`fileChanges`)for(let t of e.result.changes)i+=t.linesAdded,a+=t.linesRemoved;return{id:t.id,index:t.index,prompt:J(t.prompt,120),headline:t.headline,startedAt:t.startedAt,endedAt:t.endedAt,outcome:t.outcome,lastMessage:t.lastMessage,activityCount:r.length,files:t.filesTouched,linesAdded:i,linesRemoved:a,verifications:n.filter(e=>t.verificationIds.includes(e.id)),activities:r.map(e=>({callId:e.callId,kind:e.kind,title:e.title,toolName:e.toolName,startedAt:e.startedAt,durationMs:e.durationMs,status:e.status,agentId:e.agentId,isVerification:t.verificationIds.includes(e.callId),exit:e.exit,eventIds:e.eventIds})),claims:e.claims.filter(e=>e.turnId===t.id).map(wu)}}var Lu=`(?![A-Za-z0-9._~+/=-])`;[{id:`aws-access-key`,label:`AWS_KEY`,pattern:/\b((?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)[A-Z2-7]{16})\b/g,group:1,entropy:3,keywords:[`akia`,`asia`,`abia`,`acca`,`a3t`]},{id:`aws-secret-key`,label:`AWS_SECRET`,pattern:/(?:aws|secret)[\w.-]{0,24}?(?:secret|access)[\w.-]{0,16}?\s*[:=]\s*['"]?([A-Za-z0-9/+=]{40})\b/gi,group:1,entropy:3.5,keywords:[`aws`,`secret`]},{id:`github-token`,label:`GITHUB_TOKEN`,pattern:/\b((?:ghp|gho|ghu|ghs|ghr)_[0-9a-zA-Z_]{20,255}|github_pat_[0-9a-zA-Z_]{22,255})\b/g,group:1,keywords:[`ghp_`,`gho_`,`ghu_`,`ghs_`,`ghr_`,`github_pat_`]},{id:`gitlab-token`,label:`GITLAB_TOKEN`,pattern:/\b(glpat-[0-9a-zA-Z_-]{20,300})\b/g,group:1,keywords:[`glpat-`]},{id:`openai-key`,label:`OPENAI_KEY`,pattern:new RegExp(String.raw`\b(sk-(?:proj|svcacct|admin)-[A-Za-z0-9_-]{20,}T3BlbkFJ[A-Za-z0-9_-]{20,}|sk-[a-zA-Z0-9]{20}T3BlbkFJ[a-zA-Z0-9]{20})${Lu}`,`g`),group:1,keywords:[`t3blbkfj`]},{id:`anthropic-key`,label:`ANTHROPIC_KEY`,pattern:new RegExp(String.raw`\b(sk-ant-(?:api|admin)\d{2}-[a-zA-Z0-9_-]{80,}AA)${Lu}`,`g`),group:1,keywords:[`sk-ant-`]},{id:`slack-token`,label:`SLACK_TOKEN`,pattern:/\b(xox[abpers]-[0-9]{8,13}-[0-9A-Za-z-]{8,})\b/g,group:1,keywords:[`xox`]},{id:`slack-webhook`,label:`SLACK_WEBHOOK`,pattern:/(https?:\/\/hooks\.slack\.com\/(?:services|workflows|triggers)\/[A-Za-z0-9+/]{20,})/g,group:1,keywords:[`hooks.slack.com`]},{id:`stripe-key`,label:`STRIPE_KEY`,pattern:new RegExp(String.raw`\b((?:sk|rk)_(?:test|live|prod)_[a-zA-Z0-9]{10,99})${Lu}`,`g`),group:1,keywords:[`sk_test`,`sk_live`,`sk_prod`,`rk_test`,`rk_live`,`rk_prod`]},{id:`google-api-key`,label:`GOOGLE_KEY`,pattern:new RegExp(String.raw`\b(AIza[\w-]{35})${Lu}`,`g`),group:1,entropy:4,keywords:[`aiza`]},{id:`npm-token`,label:`NPM_TOKEN`,pattern:new RegExp(String.raw`\b(npm_[a-zA-Z0-9]{36})${Lu}`,`g`),group:1,keywords:[`npm_`]},{id:`pypi-token`,label:`PYPI_TOKEN`,pattern:/\b(pypi-AgEIcHlwaS5vcmc[\w-]{50,1000})\b/g,group:1,keywords:[`pypi-ageichlwas5vcmc`]},{id:`huggingface-token`,label:`HF_TOKEN`,pattern:new RegExp(String.raw`\b(hf_[a-zA-Z]{34})${Lu}`,`g`),group:1,keywords:[`hf_`]},{id:`sendgrid-key`,label:`SENDGRID_KEY`,pattern:new RegExp(String.raw`\b(SG\.[a-zA-Z0-9=_.-]{66})${Lu}`,`g`),group:1,keywords:[`sg.`]},{id:`digitalocean-token`,label:`DO_TOKEN`,pattern:/\b(dop_v1_[a-f0-9]{64})\b/g,group:1,keywords:[`dop_v1_`]},{id:`vault-token`,label:`VAULT_TOKEN`,pattern:/\b(hvs\.[\w-]{90,120})\b/g,group:1,keywords:[`hvs.`]},{id:`jwt`,label:`JWT`,pattern:new RegExp(String.raw`\b(ey[a-zA-Z0-9]{17,}\.ey[a-zA-Z0-9/\\_-]{17,}\.[a-zA-Z0-9/\\_-]{10,}={0,2})${Lu}`,`g`),group:1,entropy:3,keywords:[`ey`]},{id:`private-key`,label:`PRIVATE_KEY`,pattern:/(-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY(?: BLOCK)?-----[\s\S]{0,4000}?-----END[ A-Z0-9_-]{0,100}PRIVATE KEY(?: BLOCK)?-----)/g,group:1,keywords:[`-----begin`]},{id:`bearer-header`,label:`BEARER_TOKEN`,pattern:/(?:authorization|x-api-key)\s*[:=]\s*(?:bearer\s+|token\s+|basic\s+)?['"]?([A-Za-z0-9._~+/=-]{16,})/gi,group:1,entropy:3,keywords:[`authorization`,`x-api-key`]},{id:`url-credentials`,label:`URL_PASSWORD`,pattern:/\b[a-z][a-z0-9+.-]*:\/\/[^/\s:@]+:([^@\s/]{3,})@/gi,group:1,keywords:[`://`]},{id:`generic-secret`,label:`SECRET`,pattern:/(?:^|[\s"'`{(,])(?:[\w.-]{0,30}?(?:passw(?:or)?d|secret|token|api[_-]?key|access[_-]?key|private[_-]?key|client[_-]?secret|auth[_-]?token))[\w.-]{0,10}\s*(?:=|:|=>|:=)\s*["'`]?([A-Za-z0-9_+/=.~!#$%^&*-]{12,200})/gi,group:1,entropy:3.5,keywords:[`password`,`passwd`,`secret`,`token`,`api_key`,`api-key`,`apikey`,`access_key`,`accesskey`,`private_key`,`client_secret`,`auth_token`]}].map(e=>e.id);var Ru=[`status`,`what`,`why`,`how`,`verified`,`left`,`review`],zu=`salidium.detail`,Bu=`salidium.sidebar`,Vu=`salidium.theme`,Hu=`salidium.stats`,Uu=`salidium.ingest`,Wu=`salidium.rewind`,Gu=`salidium.sideFolds`,Ku=`Nothing recorded`;function qu(){let e=localStorage.getItem(Gu);if(e===null)return[Ku];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Ju(e){e===`system`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}function Yu(){let e=localStorage.getItem(Vu);return e===`light`||e===`dark`?e:`system`}function Xu(){let e=localStorage.getItem(zu);return e===`1`?1:e===`2`?2:0}Ju(Yu());function Zu(e,t){return e.ts.localeCompare(t.ts)||e.seq-t.seq||e.ordinal-t.ordinal}var Qu=0,Y=0;function $u(e){return e instanceof Error?e.message:String(e)}function ed(e,t){let n={...e};for(let e of t){if(e.internal||e.title?.includes(`[salidium-explainer]`)){delete n[e.id];continue}n[e.id]=e}return n}function td(e){return Object.values(e).sort((e,t)=>(t.lastEventAt??t.startedAt??``).localeCompare(e.lastEventAt??e.startedAt??``)).map(e=>e.id)}function nd(e){let t=e.health;return{observedAt:t.observedAt,state:t.collection.state,pause:t.collection.pausedAt&&t.collection.pauseExpiresAt&&t.collection.pauseReason?{pausedAt:t.collection.pausedAt,expiresAt:t.collection.pauseExpiresAt,reason:t.collection.pauseReason}:null,queue:{files:t.queue.files??0,bytes:t.queue.bytes??0,oldestAt:t.queue.oldestAt},store:{bytes:t.store.totalBytes,retention:t.store.retention,lastIngestAt:t.store.lastIngestAt},health:t.overall===`critical`?`runaway`:t.overall===`attention`?`attention`:`healthy`,gaps:{active:t.gaps.activeEpisodes,recovered:t.gaps.recoveredEpisodes,omittedEpisodes:t.gaps.omitted}}}var X=i((e,t)=>({api:void 0,detail:Xu(),panel:void 0,sidebarOpen:localStorage.getItem(Bu)!==`0`,statsOpen:localStorage.getItem(Hu)===`1`,ingestOpen:localStorage.getItem(Uu)===`1`,rewindOpen:localStorage.getItem(Wu)===`1`,sessionQuery:``,sessionSearch:void 0,folded:qu(),historyMode:`off`,historyKinds:[...Ru],theme:Yu(),sessions:{},sessionOrder:[],sessionsLoaded:!1,listConnection:`connecting`,selectedId:void 0,live:{},liveErrors:{},rawOpen:void 0,explainer:void 0,operations:void 0,collection:void 0,collectionInfo:void 0,collectionLoading:!1,collectionError:void 0,operationsPending:void 0,operationsActionError:void 0,personalization:void 0,personalizationLoading:!1,personalizationLoadError:void 0,personalized:{},daemonError:void 0,authRejected:!1,openPanel:t=>e({panel:t}),closePanel:()=>e({panel:void 0}),setToken:n=>{Qu++,Y++,e({api:new Fs(n,{onUnauthorized:()=>t().unauthorized()}),authRejected:!1,daemonError:void 0,personalization:void 0,operations:void 0,collection:void 0,collectionInfo:void 0,collectionLoading:!1,collectionError:void 0,operationsPending:void 0,operationsActionError:void 0,personalizationLoading:!1,personalizationLoadError:void 0,personalized:{}})},unauthorized:()=>{t().api&&(Qu++,Y++,Us(),e({api:void 0,authRejected:!0,live:{},liveErrors:{},rawOpen:void 0,explainer:void 0,operations:void 0,collection:void 0,collectionInfo:void 0,collectionLoading:!1,collectionError:void 0,operationsPending:void 0,operationsActionError:void 0,personalization:void 0,personalizationLoading:!1,personalizationLoadError:void 0,personalized:{}}))},setDetail:t=>{localStorage.setItem(zu,String(t)),e({detail:t})},loadExplainer:()=>{let n=t().api;n&&n.explainerSettings().then(t=>e({explainer:t}),()=>{})},loadCollection:()=>{let n=t().api;if(!n||t().operationsPending)return;let r=++Y;t().operations||e({collectionLoading:!0,collectionError:void 0}),Promise.all([n.operations(),n.info()]).then(([i,a])=>{r===Y&&n===t().api&&e({operations:i,collection:nd(i),collectionInfo:a,collectionLoading:!1,collectionError:void 0})},i=>{r===Y&&n===t().api&&e({collectionLoading:!1,collectionError:$u(i)})})},setCollection:async n=>{let r=t().api;if(!r){e({operationsActionError:`daemon is not connected`});return}if(t().operationsPending)throw Error(`another operations action is still running`);let i=++Y;e({operationsPending:`collection`,operationsActionError:void 0});try{let a=await r.setCollection(n),o=await r.operations();i===Y&&r===t().api&&e({collection:a,operations:o,operationsPending:void 0})}catch(n){i===Y&&r===t().api&&e({operationsPending:void 0,operationsActionError:$u(n)})}},setOperationalConfig:async n=>{let r=t().api,i=t().operations;if(!r||!i)throw Error(`operational configuration is not loaded`);if(t().operationsPending)throw Error(`another operations action is still running`);let a=++Y;e({operationsPending:`policy`,operationsActionError:void 0});try{let o=await r.setOperationalConfig(n,i.config.revision);a===Y&&r===t().api&&e(e=>({operations:e.operations?{...e.operations,config:o}:e.operations,operationsPending:void 0}))}catch(n){throw a===Y&&r===t().api&&e({operationsPending:void 0,operationsActionError:$u(n)}),n}},resetOperationalConfig:async n=>{let r=t().api,i=t().operations;if(!r||!i)throw Error(`operational configuration is not loaded`);if(t().operationsPending)throw Error(`another operations action is still running`);let a=++Y;e({operationsPending:`reset`,operationsActionError:void 0});try{let o=await r.resetOperationalConfig(n,i.config.revision);a===Y&&r===t().api&&e(e=>({operations:e.operations?{...e.operations,config:o}:e.operations,operationsPending:void 0}))}catch(n){throw a===Y&&r===t().api&&e({operationsPending:void 0,operationsActionError:$u(n)}),n}},drainQueue:async()=>{let n=t().api;if(!n)throw Error(`daemon is not connected`);if(t().operationsPending)throw Error(`another operations action is still running`);let r=++Y;e({operationsPending:`drain`,operationsActionError:void 0});try{await n.drainQueue();let i=await n.operations();r===Y&&n===t().api&&e({operations:i,collection:nd(i),operationsPending:void 0})}catch(i){throw r===Y&&n===t().api&&e({operationsPending:void 0,operationsActionError:$u(i)}),i}},acknowledgeAlert:async n=>{let r=t().api;if(!r||!t().operations)throw Error(`operations are not loaded`);if(t().operationsPending)throw Error(`another operations action is still running`);let i=++Y;e({operationsPending:`alert`,operationsActionError:void 0});try{let a=await r.acknowledgeAlert(n);i===Y&&r===t().api&&e(e=>({operations:e.operations?{...e.operations,alerts:a}:e.operations,operationsPending:void 0}))}catch(n){throw i===Y&&r===t().api&&e({operationsPending:void 0,operationsActionError:$u(n)}),n}},disconnectHooks:async n=>{let r=t().api;if(!r){e({operationsActionError:`daemon is not connected`});return}if(t().operationsPending)throw Error(`another operations action is still running`);let i=++Y;e({operationsPending:`disconnect`,operationsActionError:void 0});try{let a=await r.disconnectHooks(n),o=await r.info(),s=await r.operations();i===Y&&r===t().api&&e({collection:a,operations:s,collectionInfo:o,operationsPending:void 0})}catch(n){i===Y&&r===t().api&&e({operationsPending:void 0,operationsActionError:$u(n)})}},loadPersonalization:()=>{let n=t().api;if(!n)return;let r=++Qu;e({personalizationLoading:!0,personalizationLoadError:void 0}),n.personalizationSettings().then(i=>{if(r!==Qu||n!==t().api)return;let a=t().personalization;e({personalization:i,personalizationLoading:!1,personalizationLoadError:void 0,...a&&a.revision!==i.revision?{personalized:{}}:{}})},()=>{r===Qu&&n===t().api&&e({personalizationLoading:!1,personalizationLoadError:`Could not load saved terms.`})})},setExplainerSettings:n=>{let r=t().api;if(!r)return;let i=t().explainer;i&&e({explainer:{...i,...n}}),r.setExplainerSettings(n).then(t=>e({explainer:t}),()=>e({explainer:i}))},savePersonalization:async n=>{let r=t().api,i=t().personalization;if(!r||!i)throw Error(`personalization is not loaded`);Qu++;try{e({personalization:await r.setPersonalizationSettings(n,i.revision),personalizationLoading:!1,personalizationLoadError:void 0,personalized:{}})}catch(e){throw e instanceof Error&&`status`in e&&e.status===409&&t().loadPersonalization(),e}},deletePersonalization:async()=>{let n=t().api,r=t().personalization;if(!n||!r)throw Error(`personalization is not loaded`);Qu++;try{e({personalization:await n.deletePersonalizationSettings(r.revision),personalizationLoading:!1,personalizationLoadError:void 0,personalized:{}})}catch(e){throw e instanceof Error&&`status`in e&&e.status===409&&t().loadPersonalization(),e}},personalizeSession:async n=>{let r=t().api;if(!r)throw Error(`daemon is not connected`);let i=await r.personalizedPresentation(n),a=t().personalization,o=t().live[n]?.state.explained;if(!a||i.profileRevision!==a.revision||i.basedOnSeq!==o?.basedOnSeq)throw Error(`the explanation changed while personalization was running`);e(e=>({personalized:{...e.personalized,[n]:i}}))},setTheme:t=>{localStorage.setItem(Vu,t),Ju(t),e({theme:t})},toggleSidebar:()=>e(e=>{let t=!e.sidebarOpen;return localStorage.setItem(Bu,t?`1`:`0`),{sidebarOpen:t}}),toggleRewind:()=>e(e=>{let t=!e.rewindOpen;return localStorage.setItem(Wu,t?`1`:`0`),{rewindOpen:t}}),toggleStats:()=>e(e=>{let t=!e.statsOpen;return localStorage.setItem(Hu,t?`1`:`0`),t&&localStorage.setItem(Uu,`0`),{statsOpen:t,...t?{ingestOpen:!1}:{}}}),toggleIngest:()=>e(e=>{let t=!e.ingestOpen;return localStorage.setItem(Uu,t?`1`:`0`),t&&localStorage.setItem(Hu,`0`),{ingestOpen:t,...t?{statsOpen:!1}:{}}}),setSessionQuery:t=>e({sessionQuery:t}),toggleFold:t=>e(e=>{let n=e.folded.includes(t)?e.folded.filter(e=>e!==t):[...e.folded,t];return localStorage.setItem(Gu,JSON.stringify(n)),{folded:n}}),setHistoryMode:t=>e({historyMode:t}),setHistoryKinds:t=>e({historyKinds:t.length===0?[...Ru]:t}),upsertSessions:t=>e(e=>{let n=ed(e.sessions,t);return{sessions:n,sessionOrder:td(n),sessionsLoaded:!0}}),setSessionSearch:t=>e(e=>{if(t.query!==e.sessionQuery.trim())return{};let n=ed(e.sessions,t.sessions);return{sessions:n,sessionOrder:td(n),sessionSearch:{query:t.query,ids:t.query?t.sessions.map(e=>e.id):void 0,matched:t.matched,total:t.total}}}),removeSession:t=>e(e=>{let n={...e.sessions};delete n[t];let r={...e.live};return delete r[t],{sessions:n,sessionOrder:td(n),live:r,selectedId:e.selectedId===t?void 0:e.selectedId}}),select:t=>e({selectedId:t,rawOpen:void 0}),setListConnection:t=>e(e=>({listConnection:t,daemonError:t===`open`?void 0:t===`reconnecting`||t===`closed`?{message:`connection to the daemon was lost`,unreachable:!0}:e.daemonError})),setDaemonError:t=>e({daemonError:t}),setLiveError:(t,n)=>e(e=>e.liveErrors[t]===n?{}:{liveErrors:{...e.liveErrors,[t]:n}}),initLive:(t,n,r)=>e(e=>({live:{...e.live,[t]:{state:n,revision:1,changes:[...r].sort(Zu),connection:`connecting`,lastSeenSeq:e.live[t]?.lastSeenSeq??n.latestSeq}},liveErrors:e.liveErrors[t]?{...e.liveErrors,[t]:void 0}:e.liveErrors})),applyEvents:(n,r,i)=>{let a=t().live[n];if(!a)return;let o=0;for(let e of r){let t=Al(a.state,e);t.length&&a.changes.push(...t),o++}if(o>0&&i.length===0&&a.changes.sort(Zu),i.length){let e=new Set(a.changes.map(e=>`${e.seq}:${e.ordinal}`));for(let t of i)e.has(`${t.seq}:${t.ordinal}`)||a.changes.push(t);a.changes.sort(Zu)}(o!==0||i.length!==0)&&e(e=>({live:{...e.live,[n]:{...a,revision:a.revision+1}}}))},setLiveConnection:(t,n,r)=>e(e=>{let i=e.live[t];return i?{live:{...e.live,[t]:{...i,connection:n,error:r}}}:{}}),setScrub:(t,n)=>e(e=>{let r=e.live[t];return r?{live:{...e.live,[t]:{...r,scrub:n}}}:{}}),markSeen:t=>e(e=>{let n=e.live[t];return n?{live:{...e.live,[t]:{...n,lastSeenSeq:n.state.latestSeq}}}:{}}),openRaw:(t,n)=>e({rawOpen:{sessionId:t,eventId:n}}),closeRaw:()=>e({rawOpen:void 0})})),rd={copy:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`rect`,{x:`5.5`,y:`5.5`,width:`8`,height:`8`,rx:`1.8`}),(0,G.jsx)(`path`,{d:`M10.5 2.5H4.2A1.7 1.7 0 0 0 2.5 4.2v6.3`})]}),check:(0,G.jsx)(`path`,{d:`M3 8.4l3.4 3.2L13 4.8`}),edit:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{d:`m3 11.8.6-2.8 6.8-6.8 2.4 2.4L6 11.4Z`}),(0,G.jsx)(`path`,{d:`m9.2 3.4 2.4 2.4M3 13h10`})]}),trash:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{d:`M3.5 4.5h9M6 4.5V3h4v1.5M5 6.5l.5 6h5l.5-6`}),(0,G.jsx)(`path`,{d:`M7 7v3.5M9 7v3.5`})]}),panel:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`2`}),(0,G.jsx)(`path`,{d:`M6.5 3v10`})]}),history:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5.5`}),(0,G.jsx)(`path`,{d:`M8 5v3.2l2 1.4`})]}),sliders:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{d:`M2 5h8M12.5 5H14M2 11h2.5M7 11h7`}),(0,G.jsx)(`circle`,{cx:`11`,cy:`5`,r:`1.5`}),(0,G.jsx)(`circle`,{cx:`5.5`,cy:`11`,r:`1.5`})]}),sun:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`circle`,{cx:`8`,cy:`8`,r:`3`}),(0,G.jsx)(`path`,{d:`M8 1.5v1.2M8 13.3v1.2M2.4 2.4l.9.9M12.7 12.7l.9.9M1.5 8h1.2M13.3 8h1.2M2.4 13.6l.9-.9M12.7 3.3l.9-.9`})]}),moon:(0,G.jsx)(`path`,{d:`M13 9.6A5.6 5.6 0 0 1 6.4 3a5.6 5.6 0 1 0 6.6 6.6Z`}),auto:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5.5`}),(0,G.jsx)(`path`,{d:`M8 2.5a5.5 5.5 0 0 1 0 11Z`,fill:`currentColor`,stroke:`none`})]}),latest:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{d:`M3 3.5 8 8l-5 4.5`}),(0,G.jsx)(`path`,{d:`M12.5 3v10`})]}),record:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{d:`M3.5 2.5h6L12.5 5.5v8h-9Z`}),(0,G.jsx)(`path`,{d:`M5.5 7.5h5M5.5 10h3.5`})]}),filter:(0,G.jsx)(`path`,{d:`M2 3.5h12l-4.6 5.2v4.1l-2.8 1.7V8.7Z`}),help:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{d:`M5.9 6.2a2.2 2.2 0 1 1 2.9 2.1c-.6.2-1 .7-1 1.3v.4`}),(0,G.jsx)(`path`,{d:`M7.8 12.4h.4`})]}),search:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`circle`,{cx:`7.2`,cy:`7.2`,r:`4.2`}),(0,G.jsx)(`path`,{d:`M10.3 10.3 13.5 13.5`})]}),reset:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{d:`M2.6 8a5.4 5.4 0 1 0 1.7-3.9`}),(0,G.jsx)(`path`,{d:`M2.3 3.2v3.1h3.1`})]}),table:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),(0,G.jsx)(`path`,{d:`M2 6.5h12M6.5 6.5v6.5`})]}),stats:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{d:`M2.5 13.5h11`}),(0,G.jsx)(`path`,{d:`M4.5 11V7M8 11V3.5M11.5 11V8.5`})]}),storage:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{d:`M3 3.5h5M3 6.5h5M3 9.5h5`}),(0,G.jsx)(`path`,{d:`m9.5 6.5 2 2 2-2M11.5 3v5.5`}),(0,G.jsx)(`path`,{d:`M8.5 12.5h5`})]}),outbound:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{d:`M8 3.5H3.5v9h9V8`}),(0,G.jsx)(`path`,{d:`M10 2.5h3.5V6`}),(0,G.jsx)(`path`,{d:`M13.5 2.5 8.5 7.5`})]}),close:(0,G.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`}),prev:(0,G.jsx)(`path`,{d:`M10 3.5 5.5 8l4.5 4.5`}),next:(0,G.jsx)(`path`,{d:`M6 3.5 10.5 8 6 12.5`}),save:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{d:`M8 2.5v7.5`}),(0,G.jsx)(`path`,{d:`M4.8 7.2 8 10.4l3.2-3.2`}),(0,G.jsx)(`path`,{d:`M3 12.5h10`})]}),flag:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{d:`M4 14.5V2.5`}),(0,G.jsx)(`path`,{d:`M4 3.2h7.6l-1.6 2.9 1.6 2.9H4`})]})};function Z({name:e}){return(0,G.jsx)(`svg`,{className:`ico`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:rd[e]})}function id({label:e,size:t=`sm`,block:n=!1,className:r=``}){return(0,G.jsxs)(`span`,{className:`loading is-${t} ${n?`is-block`:``} ${r}`.trim(),role:`status`,children:[(0,G.jsx)(ad,{}),(0,G.jsx)(`span`,{className:`loading-label shimmer`,children:e})]})}function ad(){return(0,G.jsxs)(`svg`,{className:`orb`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:[(0,G.jsx)(`circle`,{className:`orb-dot`,cx:`8`,cy:`3.2`,r:`1.9`,fill:`currentColor`}),(0,G.jsx)(`circle`,{className:`orb-dot`,cx:`12.2`,cy:`10.4`,r:`1.9`,fill:`currentColor`}),(0,G.jsx)(`circle`,{className:`orb-dot`,cx:`3.8`,cy:`10.4`,r:`1.9`,fill:`currentColor`})]})}function Q({icon:e,label:t,on:n,controls:r,expanded:i,buttonRef:a,disabled:o,title:s,onClick:c}){return(0,G.jsxs)(`button`,{ref:a,type:`button`,className:`btn ${t?``:`btn-icon`} ${n?`is-on`:``}`,onClick:c,"aria-pressed":r?void 0:n,"aria-expanded":r?i??n:void 0,"aria-controls":r,disabled:o,title:s,children:[(0,G.jsx)(Z,{name:e}),t&&(0,G.jsx)(`span`,{children:t}),!t&&(0,G.jsx)(`span`,{className:`sr-only`,children:s})]})}var od=`https://salidium.com/docs`;function sd({icon:e,label:t,href:n,title:r}){return(0,G.jsxs)(`a`,{className:`btn`,href:n,target:`_blank`,rel:`noreferrer`,title:r,children:[(0,G.jsx)(Z,{name:e}),(0,G.jsx)(`span`,{children:t})]})}function cd(e,t){let n=(0,B.useRef)(null);return(0,B.useEffect)(()=>{if(!e)return;let r=e=>{n.current?.contains(e.target)||t()},i=e=>{e.key===`Escape`&&t()};return document.addEventListener(`pointerdown`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,r),document.removeEventListener(`keydown`,i)}},[e,t]),n}var ld=[{value:`system`,icon:`auto`,label:`Match the system`},{value:`light`,icon:`sun`,label:`Light`},{value:`dark`,icon:`moon`,label:`Dark`}];function ud(){let e=X(e=>e.theme),t=X(e=>e.setTheme),n=Math.max(0,ld.findIndex(t=>t.value===e)),r=ld[n],i=ld[(n+1)%ld.length];return(0,G.jsx)(Q,{icon:r.icon,title:`Theme: ${r.label}. Switch to ${i.label.toLowerCase()}.`,onClick:()=>t(i.value)})}function dd({label:e,id:t,children:n}){let[r,i]=(0,B.useState)(!1);return(0,G.jsxs)(`div`,{className:`disclosure`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`disclosure-toggle`,onClick:()=>i(e=>!e),"aria-expanded":r,"aria-controls":`disc-${t}`,children:[(0,G.jsx)(`span`,{className:`chev ${r?`is-open`:``}`,"aria-hidden":`true`,children:`›`}),e]}),(0,G.jsx)(`div`,{className:`disclosure-body ${r?`is-open`:``}`,id:`disc-${t}`,children:(0,G.jsx)(`div`,{children:n})})]})}function fd({status:e}){return e===`connecting`?(0,G.jsx)(`span`,{className:`conn conn-warn`,title:`Opening the connection to the daemon`,children:(0,G.jsx)(id,{label:`Connecting`})}):e===`reconnecting`?(0,G.jsx)(`span`,{className:`conn conn-warn`,title:`Lost contact with the daemon; retrying`,children:(0,G.jsx)(id,{label:`Reconnecting`})}):e===`closed`?(0,G.jsxs)(`span`,{className:`conn conn-bad`,title:`Not receiving updates; the daemon may have stopped`,children:[(0,G.jsx)(`span`,{className:`conn-mark`,"aria-hidden":`true`}),`Disconnected`]}):null}function pd(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}function md(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(Number.isNaN(n))return``;let r=Math.max(0,Math.round((t-n)/1e3));if(r<5)return`just now`;if(r<60)return`${r}s ago`;let i=Math.round(r/60);if(i<60)return`${i}m ago`;let a=Math.round(i/60);return a<48?`${a}h ago`:`${Math.round(a/24)}d ago`}function hd(e,t){let n=bd(e),r=t?bd(t).replace(/\/$/,``):void 0;return r&&n.startsWith(`${r}/`)&&(n=n.slice(r.length+1)),n}function gd(e){return e.replace(/[A-Za-z]:[\\/]Users[\\/][^\\/\s'"]+/g,`~`).replace(/\/(?:Users|home)\/[^/\s'"]+/g,`~`)}function _d(e){let t=e.map(bd),n=t[0];if(!n||e.length<2)return``;let r=n.split(`/`),i=r.length-1;for(let e of t){let t=e.split(`/`),n=0;for(;n<i&&n<t.length-1&&t[n]===r[n];)n++;if(i=n,i===0)return``}return`${r.slice(0,i).join(`/`)}/`}function vd(e){let t=bd(e),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t}function yd(e){let t=bd(e),n=t.lastIndexOf(`/`);return n>0?t.slice(0,n):``}function bd(e){return e.replaceAll(`\\`,`/`)}function xd(e){return e===null?`Unavailable`:Wc(e)}function Sd(e){return e===`critical`?`Critical`:e===`attention`?`Needs attention`:`Healthy`}function Cd(e){return e===`exact`?`measured`:`unavailable`}function wd(e){return e===`failure`?`Did not finish`:e===`recovery`?`Recovering`:e===`completed`?`Finished`:`Running`}function Td(e){return e.state===`recovered`?`Over`:e.state===`acknowledged`?`Acknowledged`:e.severity===`critical`?`Needs attention now`:e.severity===`warning`?`Worth a look`:`For information`}function Ed(e){return e===null?`Unavailable`:e===`forever`?`Kept forever`:`Kept ${e} days`}function Dd(e){return!e||e.value<=0?``:`about ${Wc(e.value*60*24)} a day at this rate`}function Od(e,t){if(e===null)return``;let n=Wc(t);if(e>=t)return`past its ${n} warning mark`;let r=Wc(t-e);return r===n?`warns at ${n}`:`${r} below its ${n} warning mark`}function kd(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function Ad(e){return e.hookStatus===`configured`?`Connected`:e.hookStatus===`partial`?`Incomplete`:e.hookStatus===`invalid`?`Needs repair`:`Not connected`}function jd(e){if(e.id===`codex`&&e.hookStatus!==`not-configured`)return e.hookTrust===`trusted`?`Approved`:e.hookTrust===`managed`?`Managed`:e.hookTrust===`untrusted`?`Approval required`:e.hookTrust===`modified`?`Changed since approval`:`Trust unavailable here`}function Md(e){return e===`policy`?`Saving local policy`:e===`reset`?`Restoring shipped defaults`:e===`drain`?`Draining one batch`:e===`alert`?`Acknowledging alert`:e===`disconnect`?`Disconnecting provider`:`Updating collection`}function Nd(e,t,n=`Needs two measurements`){if(!e)return n;let r=t===`storage`?Wc(Math.abs(e.value)):Math.abs(e.value).toFixed(1);return`${/^[0.]+(?: B)?$/.test(r)?``:e.value>0?`+`:`−`}${r}${t===`storage`?`/min`:` files/min`}`}function Pd({overview:e,now:t}){let{health:n}=e,r=Dd(n.estimates.storageGrowth),i=n.estimates.queueVelocity===null?`Needs two measurements`:`Not shrinking`,a=Od(n.store.totalBytes,e.config.values.alerts.databaseSizeBytes.value),o=!n.estimates.queueVelocity||n.estimates.queueVelocity.value===0?`steady`:n.estimates.queueVelocity.value<0?`draining`:`growing`;return(0,G.jsxs)(`section`,{className:`is-section operations-readout`,"aria-labelledby":`is-readout`,children:[(0,G.jsxs)(`div`,{className:`operations-section-head`,children:[(0,G.jsx)(`h3`,{className:`mu-title`,id:`is-readout`,children:`Current readout`}),(0,G.jsx)(`span`,{className:`operations-health is-${n.overall}`,children:Sd(n.overall)})]}),(0,G.jsxs)(`dl`,{className:`is-readout`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`dt`,{children:[`Collection `,(0,G.jsx)(`small`,{className:`measure-kind`,children:`measured`})]}),(0,G.jsxs)(`dd`,{children:[n.collection.state===`active`?`Active`:`Paused`,n.collection.pauseExpiresAt&&(0,G.jsxs)(`small`,{children:[`until `,kd(n.collection.pauseExpiresAt)]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`dt`,{children:[`Waiting to be stored`,` `,(0,G.jsx)(`small`,{className:`measure-kind`,children:Cd(n.queue.availability)})]}),(0,G.jsxs)(`dd`,{children:[n.queue.files===null?`Unavailable`:`${n.queue.files.toLocaleString()} files`,(0,G.jsx)(`small`,{children:xd(n.queue.bytes)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`dt`,{children:[`Oldest waiting `,(0,G.jsx)(`small`,{className:`measure-kind`,children:`measured`})]}),(0,G.jsx)(`dd`,{children:n.queue.oldestAt?md(n.queue.oldestAt,t):`None`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`dt`,{children:[`On this Mac`,` `,(0,G.jsx)(`small`,{className:`measure-kind`,children:Cd(n.store.availability)})]}),(0,G.jsxs)(`dd`,{children:[xd(n.store.totalBytes),(0,G.jsxs)(`small`,{children:[Ed(n.store.retention),a?` · ${a}`:``]})]})]})]}),(0,G.jsxs)(`div`,{className:`operations-velocity is-${o}`,children:[(0,G.jsx)(`span`,{className:`operations-velocity-line`,"aria-hidden":`true`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`Queue velocity`}),(0,G.jsx)(`span`,{children:Nd(n.estimates.queueVelocity,`queue`)}),(0,G.jsxs)(`small`,{children:[n.estimates.queueVelocity?`${o} · `:``,`estimate`,n.estimates.queueVelocity?` · ${n.estimates.queueVelocity.samples} samples / ${Math.round(n.estimates.queueVelocity.sampleWindowSeconds)}s`:``]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`Drain rate`}),(0,G.jsx)(`span`,{children:Nd(n.estimates.drainRate,`queue`,i)}),(0,G.jsx)(`small`,{children:`estimate`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`Storage growth`}),(0,G.jsx)(`span`,{children:Nd(n.estimates.storageGrowth,`storage`)}),(0,G.jsx)(`small`,{children:r||`estimate`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:`Time to empty`}),(0,G.jsx)(`span`,{children:n.estimates.timeToEmpty?`${Math.max(1,Math.round(n.estimates.timeToEmpty.value/60))} min`:n.queue.files===0?`Already empty`:i}),(0,G.jsx)(`small`,{children:`estimate`})]})]}),(0,G.jsxs)(`p`,{className:`operations-retention-note`,children:[`Health history keeps `,n.history.retentionMinutes,` minutes locally ·`,` `,n.history.retainedSamples,` samples retained`]})]})}function Fd({health:e,info:t,now:n}){let r=window.location.port||(window.location.protocol===`https:`?`443`:`80`);return(0,G.jsxs)(`section`,{className:`is-section operations-runtime`,"aria-labelledby":`operations-runtime-title`,children:[(0,G.jsxs)(`div`,{className:`operations-section-head`,children:[(0,G.jsx)(`h3`,{className:`mu-title`,id:`operations-runtime-title`,children:`Where it runs`}),(0,G.jsx)(`span`,{children:`Local only`})]}),(0,G.jsxs)(`dl`,{className:`is-readout`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Background service`}),(0,G.jsxs)(`dd`,{children:[e.daemon.pid?`PID ${e.daemon.pid}`:`Unavailable`,e.daemon.startedAt&&(0,G.jsxs)(`small`,{children:[`started `,md(e.daemon.startedAt,n)]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Listening on`}),(0,G.jsxs)(`dd`,{children:[`127.0.0.1:`,r,(0,G.jsx)(`small`,{children:`this computer only`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`State stored in`}),(0,G.jsx)(`dd`,{className:`operations-runtime-path`,title:t?.home,children:(0,G.jsx)(`bdi`,{children:t?.home??`Unavailable`})})]})]}),(0,G.jsxs)(`p`,{className:`operations-runtime-note`,children:[`This tab is a control panel, not the service. Closing it does not stop collection. Reopen with `,(0,G.jsx)(`code`,{children:`salidium open`}),`; monitor without a window using`,` `,(0,G.jsx)(`code`,{children:`salidium status --watch`}),`. On macOS, `,(0,G.jsx)(`code`,{children:`salidium service install`}),` also starts it at login, recovers crashes, and adds a menu-bar control.`]})]})}function Id({overview:e,info:t}){let n=X(e=>e.setCollection),r=X(e=>e.drainQueue),i=X(e=>e.disconnectHooks),a=X(e=>e.operationsPending),[o,s]=(0,B.useState)(),{health:c}=e;return(0,G.jsxs)(`section`,{className:`is-section`,"aria-labelledby":`is-controls`,children:[(0,G.jsx)(`h3`,{className:`mu-title`,id:`is-controls`,children:`Collection controls`}),(0,G.jsxs)(`div`,{className:`operations-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn`,disabled:a!==void 0,onClick:()=>void n(c.collection.state===`active`?`pause`:`resume`),children:c.collection.state===`active`?`Pause collection`:`Resume collection`}),(0,G.jsx)(`button`,{type:`button`,className:`btn`,disabled:a!==void 0||c.collection.state===`paused`||c.queue.files===0,onClick:()=>void r().catch(()=>{}),children:`Drain one batch`})]}),(0,G.jsx)(`small`,{className:`operations-control-help`,children:`Pausing stops new observations for up to 24 hours. Draining makes one bounded batch durable; it never deletes work that failed to persist.`}),c.maintenance&&(0,G.jsxs)(`div`,{className:`maintenance-state is-${c.maintenance.phase}`,role:c.maintenance.phase===`failure`?`alert`:`status`,"aria-live":c.maintenance.phase===`failure`?`assertive`:`polite`,children:[(0,G.jsxs)(`span`,{children:[wd(c.maintenance.phase),c.maintenance.progress===null?``:` · ${Math.round(c.maintenance.progress*100)}%`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{children:c.maintenance.message}),c.maintenance.failure&&(0,G.jsx)(`small`,{children:c.maintenance.failure}),c.maintenance.progress!==null&&(0,G.jsx)(`progress`,{"aria-label":`Maintenance progress`,value:c.maintenance.progress,max:1})]})]}),(0,G.jsx)(`div`,{className:`is-providers`,children:(t?.providers??[]).map(e=>{let t=e.hookStatus===`configured`||e.hookStatus===`partial`,n=o===e.id;return(0,G.jsxs)(`div`,{className:`is-provider`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:e.displayName??e.id}),(0,G.jsx)(`span`,{children:Ad(e)}),jd(e)&&(0,G.jsx)(`small`,{children:jd(e)})]}),t&&(0,G.jsx)(`button`,{type:`button`,className:n?`btn is-confirm`:`btn`,disabled:a!==void 0,onBlur:()=>s(void 0),onClick:()=>{if(!n){s(e.id);return}s(void 0),i(e.id)},children:n?`Disconnect ${e.displayName??e.id}?`:`Disconnect`})]},e.id)})})]})}function Ld({source:e,environment:t}){return(0,G.jsx)(`small`,{className:`setting-source`,children:e===`environment`?`Locked by ${t}`:e})}function Rd({config:e}){let t=X(e=>e.setOperationalConfig),n=X(e=>e.resetOperationalConfig),r=X(e=>e.operationsPending),[i,a]=(0,B.useState)(e.values.ui.operationsDetail.value===`expanded`),o=e=>void t(e).catch(()=>{}),s=e=>e===`environment`,c=r!==void 0,l=e.values.retention.days.value,[u,d]=(0,B.useState)(),f=e=>e===`forever`?1/0:e,p=e=>f(e)<f(l);return(0,B.useEffect)(()=>{a(e.values.ui.operationsDetail.value===`expanded`)},[e.values.ui.operationsDetail.value]),(0,G.jsxs)(`section`,{className:`is-section operations-policy`,"aria-labelledby":`operations-policy-title`,children:[(0,G.jsxs)(`button`,{className:`operations-fold`,type:`button`,"aria-expanded":i,"aria-controls":`operations-policy-settings`,disabled:c,onClick:()=>{let n=!i;a(n),t({ui:{operationsDetail:n?`expanded`:`summary`}}).catch(()=>{a(e.values.ui.operationsDetail.value===`expanded`)})},children:[(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`strong`,{id:`operations-policy-title`,children:`Local policy`}),(0,G.jsx)(`small`,{children:`Safe preferences only`})]}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:i?`−`:`+`})]}),i&&(0,G.jsxs)(`div`,{className:`operations-settings`,id:`operations-policy-settings`,children:[(0,G.jsxs)(`label`,{children:[(0,G.jsxs)(`span`,{children:[`Keep session history`,(0,G.jsx)(Ld,{...e.values.retention.days})]}),(0,G.jsxs)(`select`,{value:u??l,disabled:c||s(e.values.retention.days.source),onChange:e=>{let t=e.target.value===`forever`?`forever`:Number(e.target.value);p(t)?d(t):(d(void 0),o({retention:{days:t}}))},children:[(0,G.jsx)(`option`,{value:`forever`,children:`Forever`}),(0,G.jsx)(`option`,{value:`30`,children:`30 days`}),(0,G.jsx)(`option`,{value:`90`,children:`90 days`}),(0,G.jsx)(`option`,{value:`365`,children:`365 days`})]})]}),u!==void 0&&(0,G.jsxs)(`div`,{className:`operations-retention-confirm`,role:`alert`,children:[(0,G.jsxs)(`p`,{children:[`Keeping `,u,` days permanently deletes every unpinned session with no activity in the last `,u,` days, and all of its events. This cannot be undone.`]}),(0,G.jsx)(`button`,{type:`button`,className:`btn is-confirm`,disabled:c,onClick:()=>{let e=u;d(void 0),o({retention:{days:e}})},children:`Delete older sessions`}),(0,G.jsxs)(`button`,{type:`button`,className:`btn`,disabled:c,onClick:()=>d(void 0),children:[`Keep `,Ed(l).toLowerCase()]})]}),(0,G.jsxs)(`label`,{className:`operations-notification`,children:[(0,G.jsxs)(`span`,{children:[`Native desktop notifications`,(0,G.jsx)(Ld,{...e.values.alerts.nativeNotifications}),(0,G.jsx)(`small`,{className:`setting-help`,children:`Alert metadata only; never session content.`})]}),(0,G.jsx)(`input`,{type:`checkbox`,checked:e.values.alerts.nativeNotifications.value,disabled:c||s(e.values.alerts.nativeNotifications.source),onChange:e=>o({alerts:{nativeNotifications:e.target.checked}})})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsxs)(`span`,{children:[`Warn when queue age reaches`,(0,G.jsx)(Ld,{...e.values.alerts.queueAgeMinutes})]}),(0,G.jsxs)(`select`,{value:e.values.alerts.queueAgeMinutes.value,disabled:c||s(e.values.alerts.queueAgeMinutes.source),onChange:e=>o({alerts:{queueAgeMinutes:Number(e.target.value)}}),children:[(0,G.jsx)(`option`,{value:`5`,children:`5 minutes`}),(0,G.jsx)(`option`,{value:`10`,children:`10 minutes`}),(0,G.jsx)(`option`,{value:`30`,children:`30 minutes`}),(0,G.jsx)(`option`,{value:`60`,children:`1 hour`})]})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsxs)(`span`,{children:[`Warn when storage reaches`,(0,G.jsx)(Ld,{...e.values.alerts.databaseSizeBytes})]}),(0,G.jsx)(`select`,{value:e.values.alerts.databaseSizeBytes.value,disabled:c||s(e.values.alerts.databaseSizeBytes.source),onChange:e=>o({alerts:{databaseSizeBytes:Number(e.target.value)}}),children:[1,5,10,20].map(e=>(0,G.jsxs)(`option`,{value:e*1e3*1e3*1e3,children:[e,` GB`]},e))})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsxs)(`span`,{children:[`Alert cooldown`,(0,G.jsx)(Ld,{...e.values.alerts.cooldownMinutes})]}),(0,G.jsxs)(`select`,{value:e.values.alerts.cooldownMinutes.value,disabled:c||s(e.values.alerts.cooldownMinutes.source),onChange:e=>o({alerts:{cooldownMinutes:Number(e.target.value)}}),children:[(0,G.jsx)(`option`,{value:`5`,children:`5 minutes`}),(0,G.jsx)(`option`,{value:`30`,children:`30 minutes`}),(0,G.jsx)(`option`,{value:`60`,children:`1 hour`}),(0,G.jsx)(`option`,{value:`240`,children:`4 hours`})]})]}),(0,G.jsxs)(`label`,{children:[(0,G.jsxs)(`span`,{children:[`Keep health history`,(0,G.jsx)(Ld,{...e.values.health.historyMinutes})]}),(0,G.jsxs)(`select`,{value:e.values.health.historyMinutes.value,disabled:c||s(e.values.health.historyMinutes.source),onChange:e=>o({health:{historyMinutes:Number(e.target.value)}}),children:[(0,G.jsx)(`option`,{value:`15`,children:`15 minutes`}),(0,G.jsx)(`option`,{value:`60`,children:`1 hour`}),(0,G.jsx)(`option`,{value:`360`,children:`6 hours`}),(0,G.jsx)(`option`,{value:`1440`,children:`24 hours`})]})]}),(0,G.jsxs)(`fieldset`,{disabled:c||s(e.values.providers.enabled.source),children:[(0,G.jsx)(`legend`,{children:`Providers after restart`}),[`claude-code`,`codex`].map(t=>{let n=e.values.providers.enabled.value.includes(t);return(0,G.jsxs)(`label`,{className:`operations-check`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>o({providers:{enabled:n?e.values.providers.enabled.value.filter(e=>e!==t):[...e.values.providers.enabled.value,t]}})}),t===`claude-code`?`Claude Code`:`Codex`]},t)})]}),e.restartRequired.length>0&&(0,G.jsxs)(`p`,{className:`operations-restart`,role:`status`,children:[`Restart Salidium to apply `,e.restartRequired.join(`, `),`.`]}),(0,G.jsx)(`button`,{type:`button`,className:`btn operations-reset`,disabled:c,onClick:()=>void n().catch(()=>{}),children:`Restore shipped defaults`}),(0,G.jsx)(`p`,{className:`operations-policy-note`,children:`Relay reserves, payload ceilings, trust bypasses, SQLite pages, and compression limits are safety invariants and are not customizable here.`})]})]})}function zd({alerts:e}){let t=X(e=>e.acknowledgeAlert),n=X(e=>e.operationsPending),r=new Set(e.active.map(e=>e.id)),i=e.recent.filter(e=>e.state===`recovered`&&!r.has(e.id)),a=(e,r)=>(0,G.jsxs)(`li`,{className:`is-${e.severity} ${e.state===`recovered`?`is-recovered`:``}`,"aria-live":e.severity===`critical`&&e.state===`active`?`assertive`:void 0,"aria-atomic":e.severity===`critical`&&e.state===`active`||void 0,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:e.state===`recovered`?e.recoveryTitle??e.title:e.title}),(0,G.jsx)(`span`,{children:e.state===`recovered`?e.recoveryDetail??e.detail:e.detail}),(0,G.jsx)(`small`,{children:Td(e)})]}),r&&e.state===`active`&&(0,G.jsx)(`button`,{type:`button`,className:`btn`,disabled:n!==void 0,onClick:()=>void t(e.id).catch(()=>{}),children:n===`alert`?`Acknowledging…`:`Acknowledge`})]},e.id);return(0,G.jsxs)(`section`,{className:`is-section`,"aria-labelledby":`operations-alerts-title`,children:[(0,G.jsxs)(`div`,{className:`operations-section-head`,children:[(0,G.jsx)(`h3`,{className:`mu-title`,id:`operations-alerts-title`,children:`Local alerts`}),(0,G.jsxs)(`span`,{children:[e.active.length,` active`]})]}),(0,G.jsxs)(`div`,{"aria-live":`polite`,"aria-relevant":`additions text`,children:[e.active.length===0?(0,G.jsx)(`p`,{className:`is-empty`,children:`Nothing needs attention`}):(0,G.jsx)(`ol`,{className:`operations-alerts`,children:e.active.map(e=>a(e,!0))}),i.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h4`,{className:`operations-alerts-subtitle`,children:`Recently resolved`}),(0,G.jsx)(`ol`,{className:`operations-alerts is-recent`,children:i.map(e=>a(e,!1))})]})]})]})}function Bd({health:e,now:t}){let n=[...e.gaps.activeEpisodes.map(e=>({...e,active:!0})),...e.gaps.recoveredEpisodes.slice(-10).reverse().map(e=>({...e,active:!1}))];return(0,G.jsxs)(`section`,{className:`is-section`,"aria-labelledby":`is-ledger`,children:[(0,G.jsx)(`h3`,{className:`mu-title`,id:`is-ledger`,children:`Collection ledger`}),n.length===0?(0,G.jsx)(`p`,{className:`is-empty`,children:`No collection gaps observed`}):(0,G.jsx)(`ol`,{className:`is-ledger`,children:n.map(e=>(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:e.active?`is-gap-mark is-active`:`is-gap-mark`,"aria-hidden":`true`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{children:e.reason===`collection-stopped`?`Stopped interval`:e.reason===`collection-paused`?`Paused interval`:e.reason===`collection-pause-marker-invalid`?`Unreadable pause recovered`:e.active?`Gap active`:`Gap recovered`}),(0,G.jsxs)(`span`,{children:[e.reason.startsWith(`collection-`)?`Hook-only evidence may be absent`:e.event??`Multiple event types`,` `,`· count unavailable`]}),(0,G.jsx)(`small`,{children:e.firstDroppedAt?`first observed ${md(e.firstDroppedAt,t)}`:`start time unavailable`})]})]},JSON.stringify(e)))}),e.gaps.omitted>0&&(0,G.jsxs)(`p`,{className:`is-omitted`,children:[e.gaps.omitted.toLocaleString(),` older episode`,e.gaps.omitted===1?``:`s`,` omitted`]})]})}function Vd({onClose:e,returnFocusRef:t}){let n=X(e=>e.api),r=X(e=>e.operations),i=X(e=>e.collectionInfo),a=X(e=>e.collectionLoading),o=X(e=>e.collectionError),s=X(e=>e.operationsPending),c=X(e=>e.operationsActionError),l=X(e=>e.loadCollection),[u,d]=(0,B.useState)(()=>Date.now()),f=(0,B.useRef)(null),p=(0,B.useRef)(null);return(0,B.useLayoutEffect)(()=>{let e=f.current;return p.current?.focus(),()=>{e?.contains(document.activeElement)&&requestAnimationFrame(()=>t.current?.focus())}},[t]),(0,B.useEffect)(()=>{if(!n)return;l();let e=setInterval(()=>{d(Date.now()),l()},5e3);return()=>clearInterval(e)},[n,l]),(0,G.jsxs)(`aside`,{className:`inspector models-usage ingest-storage`,id:`ingest-storage-inspector`,"aria-label":`Ingest & Storage`,ref:f,children:[(0,G.jsxs)(`div`,{className:`inspector-head`,children:[(0,G.jsx)(Q,{icon:`panel`,title:`Hide Ingest & Storage`,buttonRef:p,onClick:()=>{e(),requestAnimationFrame(()=>t.current?.focus())}}),(0,G.jsx)(`span`,{className:`inspector-title`,children:`Local operations`})]}),(0,G.jsxs)(`div`,{className:`models-usage-body scroll-fade`,children:[!r&&a&&(0,G.jsx)(id,{label:`Reading local health`,block:!0}),o&&(0,G.jsxs)(`p`,{className:`is-load-error`,role:`alert`,children:[r?`Health refresh failed; showing the last readout.`:`Operations readout unavailable.`,` `,o]}),c&&(0,G.jsxs)(`p`,{className:`is-action-error`,role:`alert`,children:[`Action not completed. `,c]}),s&&(0,G.jsx)(`div`,{className:`operations-action-status`,children:(0,G.jsx)(id,{label:Md(s)})}),r&&(0,G.jsxs)(`div`,{className:`is-body`,children:[(0,G.jsx)(Pd,{overview:r,now:u}),(0,G.jsx)(Fd,{health:r.health,info:i,now:u}),(0,G.jsx)(zd,{alerts:r.alerts}),(0,G.jsx)(Id,{overview:r,info:i}),(0,G.jsx)(Rd,{config:r.config}),(0,G.jsx)(Bd,{health:r.health,now:u})]})]})]})}async function Hd(e){if(!navigator.clipboard)return`refused`;try{return await navigator.clipboard.writeText(e),`copied`}catch{return`refused`}}function Ud(e){if(!e)return;let t=document.createRange();t.selectNodeContents(e);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)}function Wd(e){let t=e.source.version?` ${e.source.version}`:``;return{title:Gd(e),meta:`seq ${e.seq} · ${e.source.provider} ${e.source.channel}${t}`,facts:Zd(e),origin:nf(e)}}function Gd(e){switch(e.kind){case`session.started`:return`Session started`;case`session.updated`:return`Session details changed`;case`session.ended`:return`Session ended`;case`turn.started`:return`Turn started`;case`turn.ended`:return`Turn ended`;case`agent.message`:return e.phase===`final`?`The agent’s answer`:`The agent said`;case`agent.thinking`:return`The agent thought`;case`agent.usage`:return`What one model call used`;case`tool.called`:return Kd[e.input.kind];case`tool.completed`:return qd[e.result.kind];case`tool.failed`:return e.cause===`rejected`||e.cause===`denied`?`Tool stopped`:`Tool failed`;case`subagent.started`:return`Subagent started`;case`subagent.ended`:return`Subagent finished`;case`plan.updated`:return`Plan updated`;case`compaction`:return`Context compacted`;case`permission.requested`:return`Permission asked for`;case`notification`:return`Notification`;case`git.snapshot`:return`Repository snapshot`;case`ingest.warning`:return`A record could not be read`;case`salidium.explanation`:return`Generated explanation`;default:return`Record`}}var Kd={command:`Command run`,fileEdit:`File edited`,fileWrite:`File written`,fileRead:`File read`,search:`Search`,webFetch:`Page fetched`,webSearch:`Web search`,subagent:`Subagent launched`,plan:`Plan written`,question:`Question asked`,mcp:`MCP tool called`,other:`Tool called`},qd={command:`Command finished`,fileChanges:`Files changed`,fileRead:`File read`,subagent:`Subagent reported`,generic:`Tool finished`};function Jd(e){let t=e.code===void 0?``:String(e.code);switch(e.observation){case`explicit`:return{value:t===``?`reported, no code`:t};case`inferred-success`:return{value:t===``?`success`:t,note:`inferred, not reported`};case`inferred-failure`:return{value:t===``?`failure`:t,note:`inferred, not reported`};default:return{value:`unknown`,note:`the record does not say`}}}function Yd(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function Xd(e){return e.toLocaleString()}function Zd(e){switch(e.kind){case`tool.called`:return[...ef(e),{label:`Tool`,value:e.toolName,mono:!0}];case`tool.completed`:return[...tf(e),{label:`Tool`,value:e.toolName,mono:!0},...e.durationMs===void 0?[]:[{label:`Took`,value:`${e.durationMs} ms`,mono:!0}]];case`tool.failed`:{let t=e.exit?Jd(e.exit):void 0;return[{label:`Error`,value:e.errorExcerpt,mono:!0,block:!0,copy:!0},{label:`Cause`,value:Qd[e.cause]},...t?[{label:`Exit`,value:t.value,mono:!0,note:t.note}]:[],{label:`Tool`,value:e.toolName,mono:!0},...e.durationMs===void 0?[]:[{label:`Took`,value:`${e.durationMs} ms`,mono:!0}]]}case`agent.message`:return[{label:`Said`,value:e.text,block:!0,copy:!0,note:e.truncated?`cut short by the excerpt limit`:void 0},...e.phase?[{label:`Phase`,value:e.phase}]:[]];case`agent.thinking`:return[{label:`Length`,value:Yd(e.chars,`character`),mono:!0,note:`the reasoning itself is neither stored nor shown`}];case`agent.usage`:return[{label:`Input tokens`,value:Xd(e.inputTokens),mono:!0},{label:`Output tokens`,value:Xd(e.outputTokens),mono:!0},{label:`Cache read tokens`,value:Xd(e.cacheReadTokens),mono:!0},{label:`Cache write tokens`,value:Xd(e.cacheWriteTokens),mono:!0},...$(`Model`,e.model,!0),{label:`Response`,value:e.messageId,mono:!0,copy:!0,note:`one API response; its other records repeat these same figures`}];case`turn.started`:return[{label:`Asked`,value:e.prompt,block:!0,copy:!0,note:e.promptTruncated?`cut short by the excerpt limit`:void 0}];case`turn.ended`:return[{label:`Outcome`,value:e.outcome},...e.error?[{label:`Error`,value:e.error,mono:!0,block:!0}]:[],...e.lastMessage?[{label:`Last message`,value:e.lastMessage,block:!0,copy:!0}]:[]];case`session.started`:return[{label:`Working in`,value:e.cwd,mono:!0,copy:!0},...$(`Title`,e.title),...$(`Model`,e.model,!0),...$(`Branch`,e.gitBranch,!0),...$(`Started by`,e.entrypoint),...$(`Reason`,e.reason),...$(`Transcript`,e.transcriptPath,!0,!0)];case`session.updated`:return[...$(`Title`,e.title),...$(`Model`,e.model,!0),...$(`Branch`,e.gitBranch,!0),...$(`Working in`,e.cwd,!0,!0)];case`session.ended`:return[...$(`Reason`,e.reason)];case`subagent.started`:return[...$(`Task`,e.description),...$(`Kind`,e.agentType,!0),{label:`Lane`,value:e.subagentId,mono:!0},...$(`From call`,e.parentCallId,!0),...$(`Transcript`,e.transcriptPath,!0,!0)];case`subagent.ended`:return[{label:`Lane`,value:e.subagentId,mono:!0},...e.lastMessage?[{label:`Reported`,value:e.lastMessage,block:!0,copy:!0}]:[]];case`plan.updated`:{let t=e.items.filter(e=>e.status===`completed`).length,n=e.items.filter(e=>e.status===`in_progress`).length;return[{label:`Plan`,value:`${Yd(e.items.length,`item`)} · ${t} done · ${n} in progress`},...e.items.map(e=>({label:$d[e.status],value:e.text})),...$(`Why`,e.explanation),{label:`Kind`,value:e.mode===`replace`?`the whole plan`:`an update to it`}]}case`compaction`:return[...$(`Trigger`,e.trigger),...e.summaryExcerpt?[{label:`Kept`,value:e.summaryExcerpt,block:!0,copy:!0}]:[]];case`permission.requested`:return[{label:`Asked`,value:e.summary,block:!0},{label:`Tool`,value:e.toolName,mono:!0}];case`notification`:return[{label:`Message`,value:e.message,block:!0},...$(`Kind`,e.notificationType)];case`git.snapshot`:return[{label:`Repository`,value:e.repoRoot,mono:!0,copy:!0},...$(`Head`,e.head,!0,!0),...$(`Branch`,e.branch,!0),{label:`Dirty`,value:e.dirty.length===0?`nothing uncommitted`:Yd(e.dirty.length,`path`),note:e.dirtyTruncated?`the list is capped, so there may be more`:void 0},...e.dirty.map(e=>({label:e.status.trim()===``?`unchanged`:e.status.trim(),value:e.path,mono:!0}))];case`ingest.warning`:return[{label:`Problem`,value:e.code},...$(`Detail`,e.detail,!0,!1,!0)];case`salidium.explanation`:return[{label:`Summary`,value:e.what.summary,block:!0,note:`generated, not observed`},...$(`Currently`,e.what.currently??void 0),{label:`Generated by`,value:e.model,mono:!0},{label:`From records up to`,value:`seq ${e.basedOnSeq}`,mono:!0}];default:return[]}}var Qd={error:`the tool itself failed`,rejected:`a human declined it`,denied:`policy refused it`,interrupted:`it was interrupted`,timeout:`it ran out of time`},$d={completed:`done`,in_progress:`doing`,pending:`to do`,cancelled:`dropped`};function $(e,t,n=!1,r=!1,i=!1){return t===void 0||t===``?[]:[{label:e,value:t,mono:n,copy:r,block:i}]}function ef(e){let t=e.input;switch(t.kind){case`command`:return[{label:`Command`,value:t.command,mono:!0,block:!0,copy:!0},...$(`Why`,t.description),...$(`In`,t.cwd,!0,!0),...t.background?[{label:`Runs`,value:`in the background`}]:[]];case`fileEdit`:case`fileWrite`:case`fileRead`:return[{label:`File`,value:t.path,mono:!0,copy:!0}];case`search`:return[{label:`Query`,value:t.query,mono:!0,copy:!0},...$(`In`,t.path,!0,!0)];case`webFetch`:case`webSearch`:return[{label:`Target`,value:t.target,mono:!0,copy:!0}];case`subagent`:return[...$(`Task`,t.description),...$(`Kind`,t.agentType,!0)];case`question`:return[{label:`Asked`,value:t.questions.join(`
|
|
78
|
+
`),block:!0,copy:!0}];case`mcp`:return[{label:`Tool`,value:`${t.server}/${t.tool}`,mono:!0,copy:!0},...$(`Arguments`,t.argsExcerpt,!0,!0,!0)];case`plan`:return[{label:`Wrote`,value:e.title}];default:return[...$(`Summary`,t.summary)]}}function tf(e){let t=e.result;switch(t.kind){case`command`:{let e=Jd(t.exit),n=t.gitOperation;return[{label:`Exit`,value:e.value,mono:!0,note:e.note},...t.outputExcerpt?[{label:`Output`,value:t.outputExcerpt,mono:!0,block:!0,copy:!0,note:t.truncated?`excerpt of ${Yd(t.outputChars,`character`)}`:Yd(t.outputChars,`character`)}]:[{label:`Output`,value:`none recorded`}],...t.interrupted?[{label:`Interrupted`,value:`yes`}]:[],...t.timedOut?[{label:`Timed out`,value:`yes`}]:[],...n?.commit?[{label:`Commit`,value:n.commit.sha,mono:!0,copy:!0}]:[],...n?.push?[{label:`Pushed`,value:n.push.branch??`yes`,mono:!0}]:[],...n?.pr?.number===void 0?[]:[{label:`Pull request`,value:`#${n.pr.number}`,mono:!0}]]}case`fileChanges`:{let e=t.changes.reduce((e,t)=>e+t.linesAdded,0),n=t.changes.reduce((e,t)=>e+t.linesRemoved,0);return[{label:`Changed`,value:`${Yd(t.changes.length,`file`)} · +${e} −${n}`},...t.changes.map(e=>({label:e.change,value:`${e.path} +${e.linesAdded} −${e.linesRemoved}`,mono:!0,note:e.applied?void 0:`not applied`}))]}case`fileRead`:return[{label:`File`,value:t.path,mono:!0,copy:!0},...t.suppressed?[{label:`Contents`,value:`withheld: this path holds credentials`}]:[]];case`subagent`:return[{label:`Status`,value:t.status},...t.summaryExcerpt?[{label:`Reported`,value:t.summaryExcerpt,block:!0,copy:!0}]:[],...t.toolCalls===void 0?[]:[{label:`Tool calls`,value:String(t.toolCalls),mono:!0}],...t.durationMs===void 0?[]:[{label:`Ran for`,value:`${t.durationMs} ms`,mono:!0}],...$(`Lane`,t.agentId,!0)];default:return t.excerpt?[{label:`Result`,value:t.excerpt,mono:!0,block:!0,copy:!0}]:[{label:`Result`,value:`nothing recorded`}]}}function nf(e){return[{label:`When`,value:e.ts,mono:!0,note:e.tsSource===`ingest`?`when Salidium received it, not when it happened`:void 0},...$(`Lane`,e.agentId,!0),...$(`Turn`,e.turnId,!0),...e.redactions?[{label:`Redacted`,value:Yd(e.redactions,`credential-shaped string`),note:`removed at ingest, before anything was stored`}]:[],{label:`Id`,value:e.id,mono:!0,copy:!0}]}var rf=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,af=[];function of(e){return Array.from(e.querySelectorAll(rf)).filter(e=>!e.closest(`[hidden], [inert], [aria-hidden="true"]`)&&e.getClientRects().length>0)}function sf({active:e,containerRef:t,onClose:n,initialFocus:r,restoreFocus:i,shouldRestoreFocus:a}){let o=(0,B.useRef)(e),s=(0,B.useRef)(n),c=(0,B.useRef)(r),l=(0,B.useRef)(i),u=(0,B.useRef)(a),d=(0,B.useRef)(null);o.current=e,s.current=n,c.current=r,l.current=i,u.current=a,(0,B.useEffect)(()=>{if(e)return;let t=e=>{let t=e.target instanceof Element?e.target.closest(rf):null;t&&(d.current=t)};return document.addEventListener(`pointerdown`,t,!0),()=>document.removeEventListener(`pointerdown`,t,!0)},[e]),(0,B.useEffect)(()=>{if(!e)return;let n=t.current;if(!n)return;let r=Symbol(`modal`),i=d.current;d.current=null;let a=i?.isConnected===!0?i:document.activeElement instanceof HTMLElement?document.activeElement:null;af.push(r);let f=()=>c.current?.(n)??of(n)[0]??n,p=requestAnimationFrame(()=>f().focus()),m=e=>{if(af.at(-1)!==r)return;if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),s.current();return}if(e.key!==`Tab`)return;let t=of(n),i=t[0],a=t.at(-1);if(!i||!a){e.preventDefault(),n.focus();return}let o=document.activeElement;!(o instanceof Node)||!n.contains(o)?(e.preventDefault(),(e.shiftKey?a:i).focus()):e.shiftKey&&(o===i||o===n)?(e.preventDefault(),a.focus()):!e.shiftKey&&o===a&&(e.preventDefault(),i.focus())},h=e=>{af.at(-1)!==r||n.contains(e.target)||f().focus()};return document.addEventListener(`keydown`,m,!0),document.addEventListener(`focusin`,h,!0),()=>{cancelAnimationFrame(p),document.removeEventListener(`keydown`,m,!0),document.removeEventListener(`focusin`,h,!0);let e=af.lastIndexOf(r);e>=0&&af.splice(e,1),!(o.current||u.current?.()===!1)&&requestAnimationFrame(()=>{let e=l.current?.()??a;e?.isConnected&&e.focus()})}},[e,t])}var cf=900;function lf(){return(0,B.useCallback)(e=>{if(!e)return;let t=0,n,r=()=>{t=0;let n=e.scrollTop>1,r=e.scrollTop+e.clientHeight<e.scrollHeight-1;e.dataset.fade=n&&r?`both`:n?`top`:r?`bottom`:`none`},i=()=>{t||=requestAnimationFrame(r)},a=()=>{e.dataset.scrolling=`true`,n&&clearTimeout(n),n=setTimeout(()=>{delete e.dataset.scrolling},cf),i()};r(),e.addEventListener(`scroll`,a,{passive:!0});let o=new ResizeObserver(i);o.observe(e);for(let t of e.children)o.observe(t);let s=new MutationObserver(i);return s.observe(e,{childList:!0,subtree:!0}),()=>{e.removeEventListener(`scroll`,a),o.disconnect(),s.disconnect(),t&&cancelAnimationFrame(t),n&&clearTimeout(n)}},[])}function uf(){let e=X(e=>e.api),t=X(e=>e.rawOpen),n=X(e=>e.closeRaw),r=X(e=>e.openRaw),[i,a]=(0,B.useState)(),[o,s]=(0,B.useState)(),[c,l]=(0,B.useState)(`event`),[u,d]=(0,B.useState)({}),f=(0,B.useRef)(null),p=lf(),m=(0,B.useCallback)(()=>{!e||!t||(a(void 0),s(void 0),d({}),e.raw(t.sessionId,t.eventId).then(a,e=>s(e instanceof Error?e.message:String(e))))},[e,t]);(0,B.useEffect)(m,[m]);let h=t?.sessionId,g=i?.event.seq;(0,B.useEffect)(()=>{if(!e||h===void 0||g===void 0)return;let t=!0;return e.events(h,g-2,g+1,3).then(e=>{t&&d({prev:e.find(e=>e.seq===g-1)?.id,next:e.find(e=>e.seq===g+1)?.id})},()=>{}),()=>{t=!1}},[e,h,g]);let _=(0,B.useCallback)(e=>{e&&h&&r(h,e)},[r,h]);if(sf({active:t!==void 0,containerRef:f,onClose:n,initialFocus:e=>e.querySelector(`[data-modal-initial]`)}),(0,B.useEffect)(()=>{if(!t)return;let e=e=>{if(e.key===`ArrowLeft`||e.key===`ArrowRight`){let t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),_(e.key===`ArrowLeft`?u.prev:u.next);return}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,_,u]),!t)return null;let v=i?Wd(i.event):void 0;return(0,G.jsxs)(`div`,{className:`drawer`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`drawer-title`,ref:f,tabIndex:-1,children:[(0,G.jsxs)(`div`,{className:`drawer-head`,children:[(0,G.jsx)(`h2`,{className:`drawer-title`,id:`drawer-title`,children:v?v.title:`Source record`}),(0,G.jsxs)(`div`,{className:`drawer-acts`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>_(u.prev),disabled:!u.prev,title:`The record before this one (←)`,children:[(0,G.jsx)(Z,{name:`prev`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`The record before this one`})]}),(0,G.jsxs)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>_(u.next),disabled:!u.next,title:`The record after this one (→)`,children:[(0,G.jsx)(Z,{name:`next`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`The record after this one`})]}),i&&(0,G.jsx)(pf,{data:i}),(0,G.jsx)(`span`,{className:`toolbar-sep`,"aria-hidden":`true`}),(0,G.jsxs)(`button`,{type:`button`,className:`btn btn-icon`,onClick:n,title:`Close (Escape)`,"data-modal-initial":`true`,children:[(0,G.jsx)(Z,{name:`close`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}),(0,G.jsxs)(`div`,{className:`drawer-panes`,children:[(0,G.jsx)(`button`,{type:`button`,"aria-pressed":c===`event`,className:`btn ${c===`event`?`is-on`:``}`,onClick:()=>l(`event`),title:`What Salidium derived and stored`,children:`Salidium event`}),(0,G.jsx)(`button`,{type:`button`,"aria-pressed":c===`raw`,className:`btn ${c===`raw`?`is-on`:``}`,onClick:()=>l(`raw`),title:`The original line from the agent's own file`,children:`Provider record`}),v&&(0,G.jsx)(`span`,{className:`drawer-id mono`,children:v.meta})]}),(0,G.jsxs)(`div`,{className:`drawer-body scroll-fade`,ref:p,children:[o&&(0,G.jsxs)(`div`,{className:`bad`,role:`alert`,children:[(0,G.jsx)(`p`,{className:`bad-title`,children:`Could not load this record`}),(0,G.jsx)(`p`,{className:`mono`,children:o}),(0,G.jsx)(`button`,{type:`button`,className:`btn btn-accent`,onClick:m,children:`Try again`})]}),!i&&!o&&(0,G.jsx)(`div`,{className:`muted`,role:`status`,children:(0,G.jsx)(id,{label:`Loading the record`})}),i&&v&&c===`event`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(df,{facts:v.facts}),(0,G.jsx)(`h3`,{className:`drawer-sub`,children:`How we know`}),(0,G.jsx)(df,{facts:v.origin}),(0,G.jsxs)(`details`,{className:`drawer-full`,children:[(0,G.jsx)(`summary`,{children:`Everything Salidium stored, as it is stored`}),(0,G.jsx)(`pre`,{className:`mono`,children:JSON.stringify(i.event,null,2)})]})]}),i&&c===`raw`&&(0,G.jsxs)(G.Fragment,{children:[i.path!==void 0&&(0,G.jsx)(df,{facts:[{label:`Line`,value:`${i.path}:${(i.line??0)+1}`,mono:!0,copy:!0}]}),i.raw===null||i.raw===void 0?(0,G.jsx)(`p`,{className:`muted`,children:i.reason??`No raw record.`}):(0,G.jsx)(`pre`,{className:`mono drawer-raw`,children:typeof i.raw==`string`?i.raw:JSON.stringify(i.raw,null,2)})]})]})]})}function df({facts:e}){if(e.length===0)return null;let t=new Map,n=e.map(e=>{let n=`${e.label}\u0000${e.value}`,r=(t.get(n)??0)+1;return t.set(n,r),{fact:e,key:r===1?n:`${n}\u0000${r}`}});return(0,G.jsx)(`dl`,{className:`facts`,children:n.map(e=>(0,G.jsx)(ff,{fact:e.fact},e.key))})}function ff({fact:e}){let[t,n]=(0,B.useState)(`idle`),r=(0,B.useRef)(null);return(0,B.useEffect)(()=>{if(t===`idle`)return;let e=setTimeout(()=>n(`idle`),2400);return()=>clearTimeout(e)},[t]),(0,G.jsxs)(`div`,{className:`fact ${e.block?`is-block`:``}`,children:[(0,G.jsx)(`dt`,{className:`fact-label`,children:e.label}),(0,G.jsxs)(`dd`,{className:`fact-value`,children:[(0,G.jsx)(`span`,{className:e.mono?`mono`:void 0,ref:r,children:e.value}),e.note&&(0,G.jsx)(`span`,{className:`fact-note`,children:e.note}),e.copy&&(0,G.jsxs)(`button`,{type:`button`,className:`btn btn-icon fact-copy`,onClick:()=>{Hd(e.value).then(e=>{if(e===`copied`)return n(`copied`);Ud(r.current),n(`selected`)})},title:t===`copied`?`Copied`:t===`selected`?`This window cannot reach the clipboard, so it is selected instead`:`Copy the ${e.label.toLowerCase()}`,children:[(0,G.jsx)(Z,{name:t===`copied`?`check`:`copy`}),(0,G.jsxs)(`span`,{className:`sr-only`,children:[`Copy the `,e.label.toLowerCase()]})]})]})]})}function pf({data:e}){return(0,G.jsxs)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>{let t=JSON.stringify({event:e.event,provider:{path:e.path,line:e.line,record:e.raw,reason:e.reason}},null,2),n=URL.createObjectURL(new Blob([t],{type:`application/json`})),r=document.createElement(`a`);r.href=n,r.download=`salidium-${e.event.seq}-${e.event.kind}.json`,r.click(),URL.revokeObjectURL(n)},title:`Save both records as a JSON file`,children:[(0,G.jsx)(Z,{name:`save`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Save both records as a JSON file`})]})}function mf(e){switch(e){case`working`:return{glyph:`●`,label:`Working`,cls:`st-working`};case`waiting`:return{glyph:`◐`,label:`Waiting for you`,cls:`st-waiting`};case`idle`:return{glyph:`○`,label:`Idle`,cls:`st-idle`};case`ended`:return{glyph:`◌`,label:`Ended`,cls:`st-ended`};default:return{glyph:`·`,label:`Unknown`,cls:`st-unknown`}}}var hf=[`working`,`waiting`,`idle`,`ended`];function gf(){let[e,t]=(0,B.useState)(!1),n=cd(e,()=>t(!1));return(0,G.jsxs)(`div`,{className:`pop`,ref:n,children:[(0,G.jsxs)(`button`,{type:`button`,className:`btn btn-icon ${e?`is-on`:``}`,onClick:()=>t(e=>!e),"aria-expanded":e,title:`What the marks on a row mean`,children:[(0,G.jsx)(Z,{name:`help`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`What the marks on a row mean`})]}),(0,G.jsxs)(`div`,{className:`pop-panel is-narrow marks-key arrives ${e?`is-open`:``}`,children:[(0,G.jsx)(`div`,{className:`pop-head`,children:(0,G.jsx)(`span`,{children:`On a row`})}),(0,G.jsxs)(`dl`,{children:[hf.map(e=>{let t=mf(e);return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`status-dot ${t.cls}`,"aria-hidden":`true`,children:t.glyph}),(0,G.jsx)(`dd`,{children:t.label.toLowerCase()})]},e)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{"aria-hidden":`true`,children:(0,G.jsxs)(`span`,{className:`attn-badge num is-live`,children:[(0,G.jsx)(Z,{name:`flag`}),`1`]})}),(0,G.jsx)(`dd`,{children:`to review`})]})]})]})]})}var _f=18e5;function vf(e,t){if(e.status===`waiting`)return!0;if(e.counts.reviewOpen===0||e.status===`ended`)return!1;if(e.status===`working`)return!0;let n=Date.parse(e.lastEventAt??``);return Number.isFinite(n)&&t-n<_f}function yf(e){return!e.title&&e.counts.turns===0&&e.counts.toolCalls===0&&e.counts.filesChanged===0}function bf(e){return`${e.title??``} ${e.repoRoot??``} ${e.cwd??``} ${e.providerSessionId}`.toLowerCase()}function xf(e){let t=e.toLowerCase().split(/\s+/).filter(Boolean);return t.length===0?()=>!0:e=>{let n=bf(e);return t.every(e=>n.includes(e))}}var Sf=150;function Cf({now:e}){let t=X(e=>e.sessionOrder),n=X(e=>e.sessions),r=X(e=>e.selectedId),i=X(e=>e.sessionsLoaded),a=X(e=>e.select),o=X(e=>e.sessionQuery),s=X(e=>e.setSessionQuery),c=X(e=>e.api),l=X(e=>e.sessionSearch),u=X(e=>e.setSessionSearch),d=lf(),f=o.trim();if((0,B.useEffect)(()=>{if(!c)return;let e=new AbortController,t=setTimeout(()=>{c.searchSessions(f,{limit:f?void 0:0,signal:e.signal}).then(u,()=>{})},Sf);return()=>{clearTimeout(t),e.abort()}},[c,f,u]),!i)return(0,G.jsx)(`div`,{className:`side-empty`,children:(0,G.jsx)(id,{label:`Loading sessions`})});if(t.length===0)return(0,G.jsxs)(`div`,{className:`side-empty`,children:[(0,G.jsx)(`p`,{children:`No agent sessions yet.`}),(0,G.jsx)(`p`,{className:`muted`,children:`Start a Claude Code or Codex session and it will appear here within a second. Sessions from the last few days are read in when the daemon starts.`})]});let p=l?.query===f?l:void 0,m=p?.ids?p.ids.map(e=>n[e]).filter(e=>!!e):t.map(e=>n[e]).filter(e=>!!e).filter(xf(f)),h=m.filter(yf),g=m.filter(e=>!yf(e)),_=[[`Needs you`,g.filter(t=>vf(t,e))],[`Working`,g.filter(t=>!vf(t,e)&&t.status===`working`)],[`Recent`,g.filter(t=>!vf(t,e)&&t.status!==`working`)]],v=f.length>0,y=l?.total,b=p?.matched,x=b!==void 0&&b>0&&y!==void 0?y-b:0,S=b!==void 0&&b>m.length;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(wf,{query:o,setQuery:s}),(0,G.jsxs)(`div`,{className:`side-scroll scroll-fade`,ref:d,children:[_.map(([t,n])=>n.length===0?null:(0,G.jsx)(Tf,{title:t,count:n.length,filtering:v,children:(0,G.jsx)(`ul`,{className:`session-list`,"aria-label":t,children:n.map(t=>(0,G.jsx)(Ef,{s:t,selected:t.id===r,now:e,onSelect:()=>a(t.id)},t.id))})},t)),h.length>0&&(0,G.jsx)(Tf,{title:`Nothing recorded`,count:h.length,filtering:v,title2:`Sessions that started and ended without running a turn`,children:(0,G.jsx)(`ul`,{className:`session-list is-quiet`,"aria-label":`Sessions with nothing recorded`,children:[...h].sort((e,t)=>(t.lastEventAt??t.startedAt??``).localeCompare(e.lastEventAt??e.startedAt??``)).map(t=>(0,G.jsx)(Ef,{s:t,selected:t.id===r,now:e,onSelect:()=>a(t.id)},t.id))})}),!v&&y!==void 0&&y>m.length&&(0,G.jsxs)(`p`,{className:`side-hidden`,children:[m.length,` of `,y,` sessions`]}),v&&b===0&&y!==void 0&&(0,G.jsxs)(`p`,{className:`side-none`,children:[`Nothing matches `,(0,G.jsx)(`strong`,{children:o}),`.`,(0,G.jsxs)(`span`,{className:`muted`,children:[` `,y,` searched by name, repo and id.`]})]}),v&&S&&(0,G.jsxs)(`p`,{className:`side-hidden`,children:[`Showing the newest `,m.length,` of `,b,` matches`]}),v&&x>0&&(0,G.jsxs)(`p`,{className:`side-hidden`,children:[x,` `,x===1?`session`:`sessions`,` hidden by the filter`]})]})]})}function wf({query:e,setQuery:t}){return(0,G.jsxs)(`div`,{className:`side-find`,children:[(0,G.jsx)(`span`,{className:`side-find-mark`,"aria-hidden":`true`,children:(0,G.jsx)(Z,{name:`search`})}),(0,G.jsx)(`input`,{className:`field side-find-field`,type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:`Find a session`,"aria-label":`Find a session by name, repo or id`,spellCheck:!1,autoComplete:`off`}),e!==``&&(0,G.jsxs)(`button`,{type:`button`,className:`btn btn-icon side-find-clear`,onClick:()=>t(``),title:`Clear the filter`,children:[(0,G.jsx)(Z,{name:`close`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Clear the filter`})]})]})}function Tf({title:e,count:t,filtering:n,title2:r,children:i}){let a=X(t=>t.folded.includes(e)),o=X(e=>e.toggleFold),s=n||!a;return(0,G.jsxs)(`section`,{className:`side-section`,children:[(0,G.jsx)(`h2`,{className:`side-section-h`,children:(0,G.jsxs)(`button`,{type:`button`,className:`side-section-head is-toggle`,onClick:()=>o(e),"aria-expanded":s,title:r??(s?`Fold ${e} away`:`Show ${e}`),children:[(0,G.jsx)(`span`,{className:`chev ${s?`is-open`:``}`,"aria-hidden":`true`,children:`›`}),(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`span`,{className:`num`,children:t})]})}),s&&i]})}function Ef({s:e,selected:t,now:n,onSelect:r}){let i=mf(e.status),a=vf(e,n),o=vd(e.repoRoot||e.cwd),s=e.title||(yf(e)?e.providerSessionId.slice(0,8):o)||`unnamed`,c=s!==o,l=[s,c&&`in ${o}`,i.label,e.counts.reviewOpen>0&&`${e.counts.reviewOpen} to review`].filter(Boolean).join(`, `);return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,className:`session-row ${t?`is-selected`:``} ${a?`has-attn`:``}`,onClick:r,"aria-current":t?`true`:void 0,"aria-label":l,title:c?`${s} (${o})`:s,children:[(0,G.jsx)(`span`,{className:`status-dot ${i.cls}`,"aria-hidden":`true`,children:i.glyph}),(0,G.jsx)(`span`,{className:`session-title`,children:s}),(0,G.jsx)(`span`,{className:`session-when`,title:`Last activity`,children:md(e.lastEventAt??e.startedAt,n)}),e.counts.reviewOpen>0&&(0,G.jsxs)(`span`,{className:`attn-badge num ${a?`is-live`:``}`,title:a?`${e.counts.reviewOpen} to review, needs you now`:`${e.counts.reviewOpen} flagged during this session; it is no longer running`,children:[(0,G.jsx)(Z,{name:`flag`}),e.counts.reviewOpen]})]})})}function Df(e,t){return t<e?`duplicate`:t>e?`resnapshot`:`accept`}function Of(e){return e instanceof W&&e.status===404?{kind:`not-found`,message:`Session not found`}:e instanceof W&&e.status===0?{kind:`unreachable`,message:e.message}:{kind:`failed`,message:e instanceof Error?e.message:String(e)}}function kf(e,t=0){let n=X(e=>e.api);(0,B.useEffect)(()=>{if(!n||!e)return;let t=!1,r=0,i,a=[],o=[],s,c=()=>{s=void 0;let t=a,n=o;a=[],o=[],(t.length||n.length)&&X.getState().applyEvents(e,t,n)},l=()=>{a=[],o=[],s!==void 0&&cancelAnimationFrame(s),s=void 0},u=async()=>{let d=++r;i?.(),i=void 0,l();try{let l=await n.snapshot(e);if(t||d!==r)return;let f=X.getState();f.initLive(e,l.state,l.changes),f.setDaemonError(void 0),n.changes(e).then(n=>{!t&&d===r&&n.length>l.changes.length&&X.getState().applyEvents(e,[],n)},()=>void 0);let p=l.seq,m=l.seq+1;i=n.stream(()=>`/api/sessions/${encodeURIComponent(e)}/stream?after=${p}`,e=>{if(!(t||d!==r)){if(e.type===`event`){let t=e.event,n=Df(m,t.seq);if(n===`duplicate`)return;if(n===`resnapshot`){u();return}m+=1,p=t.seq,a.push(t)}else if(e.type===`changes`)o.push(...e.changes);else return;s===void 0&&(s=requestAnimationFrame(c))}},n=>{!t&&d===r&&X.getState().setLiveConnection(e,n)},()=>{!t&&d===r&&u()})}catch(n){if(t||d!==r||n instanceof W&&n.status===401)return;X.getState().setLiveError(e,Of(n))}};return u(),()=>{t=!0,r+=1,i?.(),l()}},[n,e,t])}function Af(){let e=X(e=>e.api);(0,B.useEffect)(()=>{if(!e)return;let t=!1;e.sessions().then(e=>{if(t)return;let n=X.getState();n.upsertSessions(e),n.setDaemonError(void 0)},e=>{t||e instanceof W&&e.status===401||X.getState().setDaemonError({message:e instanceof Error?e.message:String(e),unreachable:e instanceof W&&e.status===0})});let n=e.stream(`/api/stream`,e=>{e.type===`session`&&X.getState().upsertSessions([e.summary]),e.type===`sessionRemoved`&&X.getState().removeSession(e.id)},e=>X.getState().setListConnection(e));return()=>{t=!0,n()}},[e])}var jf={off:{label:`Local only`,detail:`No model calls`},session:{label:`When done`,detail:`One model call after the session ends`},turn:{label:`Each reply`,detail:`One model call after every agent reply`}};function Mf(e){if(e)return e.envOff?`off`:e.cadence}function Nf(e){let t=Mf(e);return t?jf[t]:void 0}function Pf(e){return e===`claude-code`?`Claude Code`:e===`codex`?`Codex`:e}function Ff(e,t,n=new Date().toISOString()){return{format:`salidium.session-report`,version:1,exportedAt:n,session:e,report:t}}function If(e){return`salidium-${e.normalize(`NFKD`).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-|-$/g,``).toLowerCase().slice(0,64)||`session`}.json`}function Lf(e,t){let n=new Blob([`${JSON.stringify(Ff(e,t),null,2)}\n`],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=If(e.title),i.click(),URL.revokeObjectURL(r)}function Rf(e){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null);return(0,B.useLayoutEffect)(()=>{if(!t||!r)return;let e=()=>t.style.setProperty(`--foot-space`,`${r.getBoundingClientRect().height}px`);e();let n=new ResizeObserver(e);return n.observe(r),()=>n.disconnect()},[t,r,e]),[n,i]}function zf(e){let[t,n]=(0,B.useState)(e);return e&&!t&&n(!0),t||e}var Bf={status:`status`,what:`what changed`,why:`why`,how:`how`,verified:`checks`,left:`left to do`,review:`needs review`};function Vf(){let e=X(e=>e.historyKinds),t=X(e=>e.setHistoryKinds),[n,r]=(0,B.useState)(!1),i=cd(n,()=>r(!1)),a=new Set(e),o=a.size===Ru.length,s=n=>t(a.has(n)?e.filter(e=>e!==n):[...e,n]);return(0,G.jsxs)(`div`,{className:`pop`,ref:i,children:[(0,G.jsxs)(`button`,{type:`button`,className:`btn ${n?`is-on`:``}`,onClick:()=>r(e=>!e),"aria-expanded":n,title:`Choose which kinds of change to show`,children:[(0,G.jsx)(Z,{name:`filter`}),(0,G.jsx)(`span`,{children:`Filter`}),(0,G.jsx)(`span`,{className:`btn-pill`,children:o?`All`:`${a.size}/${Ru.length}`})]}),(0,G.jsxs)(`div`,{className:`pop-panel is-left is-narrow arrives ${n?`is-open`:``}`,children:[(0,G.jsxs)(`div`,{className:`pop-head`,children:[(0,G.jsx)(`span`,{children:`Show`}),!o&&(0,G.jsxs)(`button`,{type:`button`,className:`pop-help`,onClick:()=>t([...Ru]),title:`Show every kind again`,children:[(0,G.jsx)(Z,{name:`reset`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Show every kind again`})]})]}),(0,G.jsxs)(`fieldset`,{className:`opts`,children:[(0,G.jsx)(`legend`,{className:`sr-only`,children:`Kinds of change to show`}),Ru.map(e=>(0,G.jsxs)(`label`,{className:`opt is-tight ${a.has(e)?`is-on`:``}`,children:[(0,G.jsx)(`input`,{className:`sr-only`,type:`checkbox`,checked:a.has(e),onChange:()=>s(e)}),(0,G.jsx)(`span`,{className:`opt-swatch facet-${e}`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`opt-name`,children:Bf[e]})]},e))]})]})]})}function Hf(e){return`ep-${e}`}function Uf({changes:e,scrubTs:t,focusSeq:n,onScrub:r,onLive:i,onClose:o,onRef:s}){let c=X(e=>e.historyKinds),l=X(e=>e.setHistoryMode),u=(0,B.useRef)(null),d=lf(),f=(0,B.useCallback)(e=>(u.current=e,d(e)),[d]),[p,m]=(0,B.useState)(n!==void 0);(0,B.useEffect)(()=>m(n!==void 0),[n]);let h=p&&n!==void 0,g=(0,B.useMemo)(()=>new Set(c),[c]),_=(0,B.useMemo)(()=>e.filter(e=>g.has(e.facet)&&(!h||e.seq>n)),[e,g,h,n]),v=a({count:_.length,getScrollElement:()=>u.current,estimateSize:()=>52,overscan:12,useFlushSync:!1,anchorTo:`end`,followOnAppend:!0}),[y,b]=(0,B.useState)(!0),x=v.getTotalSize();return(0,B.useEffect)(()=>{y&&t===void 0&&_.length>0&&x>0&&v.scrollToIndex(_.length-1,{align:`end`})},[_.length,y,t,v,x]),(0,G.jsxs)(`aside`,{className:`inspector history`,"aria-label":`History`,children:[(0,G.jsxs)(`div`,{className:`inspector-head`,children:[(0,G.jsx)(Q,{icon:`panel`,title:`Hide history (h)`,onClick:o}),(0,G.jsx)(Vf,{}),(0,G.jsx)(Q,{icon:`table`,title:`Open the history as a table across the page`,onClick:()=>l(`table`)}),(0,G.jsxs)(`span`,{className:`inspector-title`,children:[h?`Since you looked`:`History`,` `,(0,G.jsx)(`span`,{className:`num`,children:_.length})]})]}),(t!==void 0||h)&&(0,G.jsxs)(`div`,{className:`history-scope`,children:[t!==void 0&&(0,G.jsx)(Q,{icon:`latest`,label:`Back to live`,title:`Stop showing a past moment`,onClick:i}),h&&(0,G.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>m(!1),children:`Show all history`})]}),(0,G.jsxs)(`div`,{className:`history-list scroll-fade`,ref:f,onScroll:()=>{let e=u.current;e&&b(e.scrollTop+e.clientHeight>=e.scrollHeight-40)},children:[_.length===0&&(0,G.jsx)(`div`,{className:`side-empty muted`,children:`No history yet.`}),(0,G.jsx)(`div`,{style:{height:x,position:`relative`},children:v.getVirtualItems().map(e=>{let n=_[e.index];if(!n)return null;let i=t!==void 0&&n.ts===t,a=t!==void 0&&n.ts>t;return(0,G.jsxs)(`div`,{"data-index":e.index,ref:v.measureElement,className:`hist-item facet-${n.facet} ${i?`is-scrub`:``} ${a?`is-future`:``}`,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:[(0,G.jsxs)(`button`,{type:`button`,className:`hist-main`,onClick:()=>r(n.ts,n.seq),title:`Show the session as of this moment`,children:[(0,G.jsxs)(`span`,{className:`hist-meta`,children:[(0,G.jsx)(`span`,{className:`hist-dot`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`hist-facet`,children:Bf[n.facet]}),n.epistemic!==`observed`&&(0,G.jsx)(`span`,{className:`hist-prov ${Hf(n.epistemic)}`,title:n.epistemic===`explained`?`Generated by a model, not observed`:n.epistemic===`reported`?`The agent said so; Salidium did not see it`:`Worked out by Salidium rather than seen directly`,children:n.epistemic}),(0,G.jsx)(`span`,{className:`hist-time mono`,children:pd(n.ts)})]}),(0,G.jsx)(`span`,{className:`hist-text`,children:n.summary})]}),n.refs[0]&&(0,G.jsx)(`button`,{type:`button`,className:`link hist-record`,onClick:()=>s(n.refs[0]??``),title:`Open the raw record this came from`,children:`record`})]},`${n.seq}:${n.ordinal}`)})})]})]})}function Wf(e){return e+1}function Gf(e){return e+2}function Kf({changes:e,scrubTs:t,onScrub:n,onLive:r,onRef:i}){let o=X(e=>e.historyKinds),s=X(e=>e.setHistoryMode),c=(0,B.useRef)(null),l=lf(),u=(0,B.useCallback)(e=>(c.current=e,l(e)),[l]),d=(0,B.useMemo)(()=>new Set(o),[o]),f=(0,B.useMemo)(()=>e.filter(e=>d.has(e.facet)),[e,d]),p=a({count:f.length,getScrollElement:()=>c.current,estimateSize:()=>40,overscan:16,useFlushSync:!1});return(0,G.jsxs)(`div`,{className:`htab`,children:[(0,G.jsxs)(`header`,{className:`htab-head`,children:[(0,G.jsxs)(`h1`,{className:`htab-title`,children:[`History `,(0,G.jsx)(`span`,{className:`num`,children:f.length})]}),(0,G.jsxs)(`div`,{className:`toolbar htab-tools`,children:[(0,G.jsx)(Vf,{}),t!==void 0&&(0,G.jsx)(Q,{icon:`latest`,label:`Back to live`,title:`Stop showing a past moment`,onClick:r}),(0,G.jsx)(Q,{icon:`panel`,label:`Show beside`,title:`Move the history back into the side rail`,onClick:()=>s(`rail`)})]})]}),(0,G.jsxs)(`div`,{className:`htab-grid`,role:`table`,"aria-label":`History`,"aria-rowcount":Wf(f.length),children:[(0,G.jsxs)(`div`,{className:`htab-row is-head`,role:`row`,"aria-rowindex":1,children:[(0,G.jsx)(`span`,{role:`columnheader`,children:`When`}),(0,G.jsx)(`span`,{role:`columnheader`,children:`Kind`}),(0,G.jsx)(`span`,{role:`columnheader`,children:`Change`}),(0,G.jsx)(`span`,{role:`columnheader`,children:`How we know`}),(0,G.jsx)(`span`,{role:`columnheader`,children:(0,G.jsx)(`span`,{className:`sr-only`,children:`Record`})})]}),(0,G.jsx)(`div`,{className:`htab-scroll scroll-fade`,ref:u,children:(0,G.jsx)(`div`,{style:{height:p.getTotalSize(),position:`relative`},children:p.getVirtualItems().map(e=>{let r=f[e.index];if(!r)return null;let a=t!==void 0&&r.ts===t,o=t!==void 0&&r.ts>t;return(0,G.jsxs)(`div`,{"data-index":e.index,ref:p.measureElement,role:`row`,"aria-rowindex":Gf(e.index),className:`htab-row facet-${r.facet} ${a?`is-scrub`:``} ${o?`is-future`:``}`,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:[(0,G.jsx)(`span`,{role:`cell`,children:(0,G.jsx)(`button`,{type:`button`,className:`htab-when mono`,onClick:()=>n(r.ts,r.seq),title:`Show the session as of this moment`,children:pd(r.ts)})}),(0,G.jsxs)(`span`,{role:`cell`,className:`htab-kind`,children:[(0,G.jsx)(`span`,{className:`hist-dot`,"aria-hidden":`true`}),Bf[r.facet]]}),(0,G.jsx)(`span`,{role:`cell`,className:`htab-text`,children:r.summary}),(0,G.jsx)(`span`,{role:`cell`,className:`htab-prov`,children:r.epistemic===`observed`?``:r.epistemic}),(0,G.jsx)(`span`,{role:`cell`,children:r.refs[0]&&(0,G.jsxs)(`button`,{type:`button`,className:`tag-ev`,onClick:()=>i(r.refs[0]??``),title:`Open the raw record this came from`,children:[(0,G.jsx)(Z,{name:`record`}),`record`]})})]},`${r.seq}:${r.ordinal}`)})})})]}),f.length===0&&(0,G.jsx)(`p`,{className:`rp-empty`,children:`No history yet.`})]})}function qf({id:e,title:t,children:n,sections:r}){let i=X(e=>e.panel)===e,a=X(e=>e.closePanel),o=(0,B.useRef)(null),[s,c]=(0,B.useState)(),l=r?.some(e=>e.key===s)?s:r?.[0]?.key,u=r?.find(e=>e.key===l)??r?.[0];sf({active:i,containerRef:o,onClose:a});let d=zf(i);return(0,B.useEffect)(()=>{i&&l!==s&&c(l)},[i,l,s]),d?(0,G.jsxs)(`div`,{className:`panel-scrim arrives ${i?`is-open`:``}`,inert:!i,children:[(0,G.jsx)(`div`,{className:`panel-backdrop`,"aria-hidden":`true`,onClick:a}),(0,G.jsxs)(`div`,{className:`panel-card panel-card-${e}`,ref:o,role:`dialog`,"aria-modal":`true`,"aria-label":t,tabIndex:-1,children:[(0,G.jsxs)(`div`,{className:`panel-head`,children:[(0,G.jsx)(`h2`,{className:`panel-title`,children:t}),(0,G.jsx)(`button`,{type:`button`,className:`panel-close`,onClick:a,title:`Close (Esc)`,children:(0,G.jsx)(Z,{name:`close`})})]}),r&&r.length>0?(0,G.jsxs)(`div`,{className:`panel-split`,children:[(0,G.jsx)(`nav`,{className:`panel-rail`,"aria-label":`${t} sections`,children:r.map(e=>(0,G.jsxs)(`button`,{type:`button`,className:`panel-rail-item ${e.key===l?`is-on`:``}`,"aria-current":e.key===l?`true`:void 0,onClick:()=>c(e.key),children:[(0,G.jsx)(`span`,{className:`panel-rail-label`,children:e.label}),e.count!==void 0&&(0,G.jsx)(`span`,{className:`panel-rail-count num`,children:e.count})]},e.key))}),(0,G.jsx)(`div`,{className:`panel-body`,children:u?.render()})]}):(0,G.jsx)(`div`,{className:`panel-body`,children:n})]})]}):null}var Jf=`Codex CLI default (not pinned)`;function Yf(e){return e===Jf?`Automatic`:e??`Unavailable`}function Xf(e){return e===Jf}var Zf={pass:`✓`,fail:`✕`,partial:`◐`,unknown:`?`};function Qf(e){return Zf[e]??`?`}function $f(e,t){let n=(0,B.useRef)(null),[r,i]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{let t=n.current;if(!t||e)return;let r=()=>i(t.scrollHeight-t.clientHeight>1);r();let a=new ResizeObserver(r);return a.observe(t),()=>a.disconnect()},[e,t]),[n,r]}function ep({steps:e,terminal:t=`accent`}){return e.length===0?null:(0,G.jsx)(`ol`,{className:`fd-chain end-${t}`,children:e.map((e,t)=>(0,G.jsx)(`li`,{className:`fd-node`,children:e},`${t}:${e}`))})}function tp({lanes:e,trunk:t}){return(0,G.jsxs)(`div`,{className:`fd-converge`,children:[(0,G.jsx)(`div`,{className:`fd-lanes`,style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(e=>(0,G.jsxs)(`div`,{className:`fd-lane`,children:[(0,G.jsx)(`p`,{className:`fd-lane-title`,children:e.title}),(0,G.jsx)(`ol`,{className:`fd-lane-steps`,children:e.steps.map((e,t)=>(0,G.jsx)(`li`,{children:e},`${t}:${e}`))})]},e.title))}),t.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(np,{count:e.length}),(0,G.jsx)(ep,{steps:t})]})]})}function np({count:e,fanOut:t=!1}){return(0,G.jsxs)(`div`,{className:`fd-junction ${t?`is-fan`:``}`,style:{"--lanes":e},"aria-hidden":`true`,children:[(0,G.jsx)(`span`,{className:`fd-trunk`}),(0,G.jsx)(`span`,{className:`fd-bus`}),(0,G.jsx)(`div`,{className:`fd-stems`,children:Array.from({length:e},(e,t)=>(0,G.jsx)(`span`,{},t))})]})}function rp({root:e,steps:t}){return t.length===0?null:e?(0,G.jsxs)(`div`,{className:`fd-tree has-root`,children:[(0,G.jsx)(`p`,{className:`fd-root mono`,children:e}),(0,G.jsx)(np,{count:t.length,fanOut:!0}),(0,G.jsx)(ip,{steps:t})]}):(0,G.jsx)(`div`,{className:`fd-tree`,children:(0,G.jsx)(ip,{steps:t})})}function ip({steps:e}){return(0,G.jsx)(`ul`,{className:`fd-branches`,style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map((e,t)=>(0,G.jsx)(`li`,{className:`fd-node`,children:e},`${t}:${e}`))})}function ap({from:e,fromSteps:t,to:n,toSteps:r,why:i}){return(0,G.jsxs)(`div`,{className:`fd-ba`,children:[(0,G.jsxs)(`div`,{className:`fd-ba-side is-was`,children:[(0,G.jsx)(`p`,{className:`fd-ba-label`,children:`Was`}),(0,G.jsx)(`p`,{className:`fd-ba-head`,children:e}),(0,G.jsx)(ep,{steps:t,terminal:`bad`})]}),i&&(0,G.jsxs)(`p`,{className:`fd-ba-why`,children:[(0,G.jsx)(`span`,{className:`fd-ba-pivot`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{children:i})]}),(0,G.jsxs)(`div`,{className:`fd-ba-side is-now`,children:[(0,G.jsx)(`p`,{className:`fd-ba-label`,children:`Now`}),(0,G.jsx)(`p`,{className:`fd-ba-head`,children:n}),(0,G.jsx)(ep,{steps:r,terminal:`good`})]})]})}function op({marks:e}){let t=[];return e.junction&&t.push([`fd-key-junction`,`where separate paths meet`]),e.outcome&&t.push([`fd-key-outcome`,`abandoned, and adopted`]),t.length===0?null:(0,G.jsx)(`ul`,{className:`fd-legend`,children:t.map(([e,t])=>(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`fd-key ${e}`,"aria-hidden":`true`}),t]},e))})}function sp({sessionId:e,hasCurrentPresentation:t,onDone:n}){let r=X(e=>e.personalization),i=X(e=>e.personalizationLoading),a=X(e=>e.personalizationLoadError),o=X(e=>e.explainer),s=X(e=>e.loadPersonalization),c=X(e=>e.savePersonalization),l=X(e=>e.deletePersonalization),u=X(e=>e.personalizeSession),[d,f]=(0,B.useState)(),p=(0,B.useRef)(null),[m,h]=(0,B.useState)(`idle`);if((0,B.useEffect)(()=>s(),[s]),(0,B.useEffect)(()=>p.current?.focus(),[]),(0,B.useEffect)(()=>{r&&d===void 0&&f(r.profile.guidance)},[d,r]),!r||d===void 0)return a?(0,G.jsxs)(`div`,{className:`ex-personalize mu-load-error`,role:`alert`,children:[(0,G.jsx)(`span`,{children:a}),(0,G.jsxs)(`button`,{className:`btn mu-retry`,type:`button`,onClick:s,children:[(0,G.jsx)(Z,{name:`reset`}),`Retry`]})]}):(0,G.jsx)(id,{label:i?`Loading personalization settings`:`Waiting for Salidium`,block:!0});let g=r.profile.guidance,_=d.trim(),v=r.revision!==`none`&&g!==``,y=r.enabled&&v,b=_!==g,x=Mf(o),S=o===void 0,ee=!!(x&&x!==`off`&&o?.activeBackend),te=m===`saving`||m===`generating`||m===`clearing`,ne=b||!y,C=t&&!b,re=b?{icon:`edit`,label:`Unsaved changes`,state:`dirty`}:v?{icon:`check`,label:`Saved on this machine`,state:`saved`}:{icon:`close`,label:`Not saved`,state:`empty`};return(0,G.jsxs)(`form`,{id:`personalization-composer`,className:`ex-personalize`,onSubmit:async t=>{if(t.preventDefault(),!(!_||te)){if(ne)try{h(`saving`),await c({enabled:!0,profile:{guidance:_}})}catch{h(`save-error`);return}if(ee)try{h(`generating`),await u(e),h(`personalized`),n?.()}catch{h(`generation-error`)}else h(`saved`)}},children:[(0,G.jsx)(`label`,{className:`mu-guidance-label`,htmlFor:`personalization-guidance`,children:`Terms and examples`}),(0,G.jsx)(`span`,{className:`sr-only`,id:`personalization-boundary`,children:ee?`Personalizing sends this note and the generated explanation to the selected explanation agent. Evidence and transcripts stay local.`:`Saving keeps this note on this machine.`}),(0,G.jsxs)(`div`,{className:`mu-composer`,children:[(0,G.jsx)(`input`,{id:`personalization-guidance`,ref:p,className:`mu-guidance`,type:`text`,value:d,onChange:e=>{f(e.target.value),h(`idle`)},"aria-describedby":`personalization-boundary`,maxLength:800,placeholder:`Use kitchen examples…`}),(0,G.jsx)(`button`,{className:`btn btn-accent`,type:`submit`,disabled:!_||te||S||(ee?C:!ne),title:ee?t?`Replaces this report's current personalized version`:`Creates one personalized version of this report`:`Saves this note on this machine`,children:m===`saving`||m===`generating`||S?(0,G.jsx)(id,{label:m===`saving`?`Saving`:m===`generating`?`Applying`:`Loading model settings`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Z,{name:C?`check`:ee?`sliders`:`save`}),ee?C?`Applied`:`Apply`:`Save terms`]})})]}),(0,G.jsxs)(`div`,{className:`mu-meta`,children:[(0,G.jsxs)(`p`,{className:`mu-save-state is-${re.state}`,role:`status`,children:[(0,G.jsx)(Z,{name:re.icon}),re.label]}),v&&(0,G.jsx)(`button`,{className:`btn mu-clear`,type:`button`,disabled:te,onClick:async()=>{h(`clearing`);try{await l(),f(``),h(`cleared`)}catch{h(`clear-error`)}},children:m===`clearing`?(0,G.jsx)(id,{label:`Deleting`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Z,{name:`trash`}),`Delete saved terms`]})})]}),(0,G.jsx)(`p`,{className:`mu-status`,role:`status`,children:m===`save-error`?`Not saved. Try again.`:m===`generation-error`?`Saved, but this report was not updated. Try again.`:m===`clear-error`?`Not cleared. Try again.`:``})]})}var cp={fileEdit:`edit`,fileWrite:`edit`,fileRead:`read`,search:`read`,command:`run`,subagent:`delegate`,webFetch:`look`,webSearch:`look`,mcp:`look`,plan:`plan`,question:`plan`,other:`run`},lp=4,up={edit:e=>`edited ${e} ${e===1?`file`:`files`}`,read:e=>`read ${e} ${e===1?`file`:`files`}`,run:e=>`ran ${e} ${e===1?`command`:`commands`}`,delegate:e=>`delegated to ${e} ${e===1?`subagent`:`subagents`}`,look:e=>`${e} ${e===1?`lookup`:`lookups`}`,plan:e=>`planned (${e})`},dp={edit:`±`,read:`⋯`,run:`$`,delegate:`⇢`,look:`@`,plan:`☰`};function fp(e){let t=e.split(/\s+/).find(e=>e.includes(`/`)||/\.[a-z0-9]+$/i.test(e));return t?vd(t):void 0}var pp=new Set([`edit`]);function mp(e,t){let n=new Map(e.verifications.map(e=>[e.callId,e])),r=new Map(t.filter(e=>e.callId).map(e=>[e.callId,e])),i=[],a,o=[],s=()=>{if(!a)return;let e=[...new Set(a.items.map(e=>fp(e.title)).filter(Boolean))],t=a.bucket===`edit`&&e.length===1?`edited ${e[0]}${a.items.length>1?` (${a.items.length}\u00d7)`:``}`:up[a.bucket](e.length||a.items.length);i.push({kind:`work`,bucket:a.bucket,label:t,detail:e.length>1?e.slice(0,3).join(`, `):void 0,at:a.items[0]?.startedAt??``,refs:a.items.map(e=>e.callId),quiet:!1}),a=void 0},c=()=>{if(o.length===0)return;let e=new Map;for(let t of o){let n=cp[t.kind];e.set(n,(e.get(n)??0)+1)}i.push({kind:`work`,bucket:`read`,label:[...e.entries()].map(([e,t])=>up[e](t)).join(`, `),at:o[0]?.startedAt??``,refs:o.map(e=>e.callId),quiet:!0}),o=[]},l=()=>{s(),c()};for(let t of e.activities){let e=n.get(t.callId);if(e){l(),i.push({kind:`check`,row:e});continue}let u=r.get(t.callId);if(u){l(),i.push({kind:`commit`,sha:u.sha,at:u.at,callId:u.callId});continue}let d=cp[t.kind];pp.has(d)?a&&a.bucket===d&&o.length<lp?(o=[],a.items.push(t)):(s(),c(),a={bucket:d,items:[t]}):o.push(t)}l();let u=i.map(e=>e.kind===`check`).lastIndexOf(!0);return i.slice(u+1).some(e=>e.kind===`work`&&e.bucket===`edit`)&&i.push({kind:`gap`,label:`nothing checked these edits`}),i}var hp=6;function gp({turns:e,commits:t,onRef:n}){let[r,i]=(0,B.useState)(hp);if(e.length===0)return null;let a=e.length>r?e.slice(e.length-r):e,o=e.length-a.length;return(0,G.jsxs)(`section`,{className:`viz`,"aria-label":`What the agent did, in order`,children:[(0,G.jsxs)(`h3`,{className:`viz-title`,children:[`What happened `,(0,G.jsxs)(`span`,{className:`viz-count num`,children:[e.length,` turns`]})]}),o>0&&(0,G.jsxs)(`button`,{type:`button`,className:`flow-more`,onClick:()=>i(e=>e+hp),children:[`show `,Math.min(hp,o),` earlier `,o===1?`turn`:`turns`]}),(0,G.jsx)(`ol`,{className:`flow`,children:a.map((e,r)=>(0,G.jsx)(_p,{turn:e,commits:t,onRef:n,defaultOpen:r===a.length-1},e.id))})]})}function _p({turn:e,commits:t,onRef:n,defaultOpen:r}){let[i,a]=(0,B.useState)(r),o=mp(e,t),s=o.filter(e=>e.kind===`check`),c=s.filter(e=>e.kind===`check`&&e.row.outcome===`fail`).length,l=s.filter(e=>e.kind===`check`&&e.row.outcome===`pass`).length,u=o.some(e=>e.kind===`gap`);return(0,G.jsxs)(`li`,{className:`flow-turn ${i?`is-open`:``}`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flow-ask`,onClick:()=>a(e=>!e),"aria-expanded":i,children:[(0,G.jsx)(`span`,{className:`flow-ask-n num`,children:e.index+1}),(0,G.jsx)(`span`,{className:`flow-ask-text`,children:e.prompt||`(prompt not recorded)`}),(0,G.jsxs)(`span`,{className:`flow-sum`,children:[u&&(0,G.jsx)(`span`,{className:`flow-chip flow-sum-gap`,children:`unchecked`}),c>0?(0,G.jsxs)(`span`,{className:`flow-chip flow-sum-bad`,children:[(0,G.jsx)(`span`,{className:`num`,children:c}),` failed`]}):l>0&&(0,G.jsxs)(`span`,{className:`flow-chip flow-sum-ok`,children:[(0,G.jsx)(`span`,{className:`num`,children:l}),` passed`]})]}),(0,G.jsx)(`span`,{className:`flow-ask-caret`,"aria-hidden":`true`,children:`›`})]}),i&&(0,G.jsx)(`ol`,{className:`flow-steps`,children:o.map((e,t)=>(0,G.jsx)(vp,{step:e,onRef:n},t))})]})}function vp({step:e,onRef:t}){if(e.kind===`gap`)return(0,G.jsxs)(`li`,{className:`flow-step is-gap`,children:[(0,G.jsx)(`span`,{className:`flow-node`,"aria-hidden":`true`,children:`!`}),(0,G.jsx)(`span`,{className:`flow-label`,children:e.label})]});if(e.kind===`check`){let n=e.row,r=Qf(n.outcome);return(0,G.jsxs)(`li`,{className:`flow-step is-check v-${n.outcome}`,children:[(0,G.jsx)(`span`,{className:`flow-node`,"aria-hidden":`true`,children:r}),(0,G.jsxs)(`button`,{type:`button`,className:`flow-label as-button`,onClick:()=>t(n.callId),children:[n.label,n.epistemic===`inferred`&&(0,G.jsx)(`span`,{className:`flow-derived`,children:`derived`})]}),(0,G.jsx)(`span`,{className:`flow-at mono`,children:pd(n.at)})]})}return e.kind===`commit`?(0,G.jsxs)(`li`,{className:`flow-step is-commit`,children:[(0,G.jsx)(`span`,{className:`flow-node`,"aria-hidden":`true`,children:`◆`}),(0,G.jsxs)(`button`,{type:`button`,className:`flow-label as-button`,onClick:()=>e.callId&&t(e.callId),children:[`committed `,(0,G.jsx)(`span`,{className:`mono`,children:e.sha.slice(0,7)})]}),(0,G.jsx)(`span`,{className:`flow-at mono`,children:pd(e.at)})]}):(0,G.jsxs)(`li`,{className:`flow-step is-${e.bucket} ${e.quiet?`is-quiet`:``}`,children:[(0,G.jsx)(`span`,{className:`flow-node`,"aria-hidden":`true`,children:dp[e.bucket]}),(0,G.jsxs)(`button`,{type:`button`,className:`flow-label as-button`,onClick:()=>e.refs[0]&&t(e.refs[0]),children:[e.label,e.detail&&(0,G.jsx)(`span`,{className:`flow-detail mono`,children:e.detail})]}),(0,G.jsx)(`span`,{className:`flow-at mono`,children:pd(e.at)})]})}function yp({files:e,cwd:t,limit:n=10,onOpen:r}){if(e.length===0)return null;let i=[...e].sort((e,t)=>t.linesAdded+t.linesRemoved-(e.linesAdded+e.linesRemoved)).slice(0,n),a=Math.max(1,...i.map(e=>e.linesAdded+e.linesRemoved)),o=e.length-i.length,s=_d(i.map(e=>e.path));return(0,G.jsxs)(`section`,{className:`viz`,"aria-label":`Churn for ${e.length} changed files`,children:[(0,G.jsxs)(`h3`,{className:`viz-title`,children:[`Changed `,(0,G.jsx)(`span`,{className:`viz-count num`,children:e.length})]}),s&&(0,G.jsx)(`p`,{className:`viz-root mono`,title:s,children:(0,G.jsx)(`bdi`,{children:gd(s)})}),(0,G.jsx)(`ul`,{className:`churn`,children:i.map(e=>{let n=e.linesAdded+e.linesRemoved;return(0,G.jsxs)(`li`,{className:`churn-row`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`churn-main`,onClick:()=>r(e),children:[(0,G.jsxs)(`span`,{className:`churn-name mono`,title:e.path,children:[vd(e.path),(0,G.jsx)(`span`,{className:`churn-dir`,children:yd(s?e.path.slice(s.length):hd(e.path,t))})]}),(0,G.jsxs)(`span`,{className:`churn-bar`,"aria-hidden":`true`,children:[(0,G.jsx)(`span`,{className:`churn-add`,style:{width:`${e.linesAdded/a*100}%`}}),(0,G.jsx)(`span`,{className:`churn-del`,style:{width:`${e.linesRemoved/a*100}%`}})]}),(0,G.jsxs)(`span`,{className:`churn-num num`,children:[(0,G.jsxs)(`span`,{className:`add`,children:[`+`,e.linesAdded]}),(0,G.jsxs)(`span`,{className:`del`,children:[`−`,e.linesRemoved]})]}),!e.verifiedAfter&&(0,G.jsx)(`span`,{className:`churn-flag`,title:`No passing check ran after this edit`,children:`?`})]}),(0,G.jsxs)(`span`,{className:`sr-only`,children:[hd(e.path,t),`: `,n,` lines changed`,e.verifiedAfter?``:`, unchecked since`]})]},e.path)})}),o>0&&(0,G.jsxs)(`p`,{className:`viz-foot`,children:[o,` smaller changes not shown`]})]})}function bp({runs:e,onOpen:t}){if(e.length===0)return null;let n=[...new Set(e.map(e=>e.method))],r=e=>e===`pass`?`passing`:e===`fail`?`failing`:e===`partial`?`partial`:`unknown`;return(0,G.jsxs)(`section`,{className:`viz checks`,"aria-label":`${e.length} checks across ${n.length} kinds`,children:[(0,G.jsx)(`ul`,{className:`checks-rows`,children:n.map(n=>{let i=e.filter(e=>e.method===n).sort((e,t)=>e.at.localeCompare(t.at)),a=i[i.length-1];if(!a)return null;let o=i.filter(e=>e.outcome===`fail`).length;return(0,G.jsxs)(`li`,{className:`checks-row`,children:[(0,G.jsx)(`span`,{className:`checks-method`,children:n}),(0,G.jsxs)(`span`,{className:`checks-now v-${a.outcome}`,children:[(0,G.jsx)(`span`,{className:`checks-now-mark`,"aria-hidden":`true`,children:Qf(a.outcome)}),r(a.outcome),a.counts?.total!==void 0&&(0,G.jsxs)(`span`,{className:`checks-counts num`,children:[a.counts.passed??0,`/`,a.counts.total]})]}),(0,G.jsx)(`span`,{className:`checks-strip`,children:i.map(e=>(0,G.jsx)(`button`,{type:`button`,className:`checks-tick v-${e.outcome} ${e.epistemic===`inferred`?`is-derived`:``}`,onClick:()=>t(e),title:`${pd(e.at)}, ${e.label}${e.epistemic===`inferred`?` (worked out, not observed)`:``}`,children:(0,G.jsxs)(`span`,{className:`sr-only`,children:[pd(e.at),` `,e.outcome]})},e.id))}),(0,G.jsx)(`span`,{className:`checks-runs`,children:i.length===1?`ran once`:`${i.length} runs${o>0?`, ${o} failed`:``}`}),(0,G.jsx)(`span`,{className:`checks-when`,children:pd(a.at)})]},n)})}),(0,G.jsx)(`p`,{className:`checks-key`,children:`Oldest first. A hollow mark is one Salidium worked out rather than read. Open any run for its record.`})]})}function xp({files:e,failing:t,onOpen:n}){if(e.length===0)return null;let r=e.slice(0,120),i=e.filter(e=>e.verifiedAfter).length,a=e.length-i,o=t.length>0;return(0,G.jsxs)(`section`,{className:`viz cov`,"aria-label":`Which changed files a passing check ran after`,children:[(0,G.jsxs)(`p`,{className:`cov-lead`,children:[(0,G.jsxs)(`strong`,{className:`num`,children:[i,` of `,e.length]}),` `,`changed `,e.length===1?`file has`:`files have`,` had a passing check since it was last edited.`]}),o&&(0,G.jsxs)(`p`,{className:`cov-held`,children:[t.join(` and `),` `,t.length===1?`is`:`are`,` still failing.`]}),(0,G.jsx)(`p`,{className:`cov-scope`,children:`A filled square is one file, not the project. A full grid does not mean the project is green.`}),(0,G.jsx)(`ul`,{className:`cov-grid`,children:r.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(`button`,{type:`button`,className:`cov-cell ${e.verifiedAfter?`is-covered`:`is-stale`}`,onClick:()=>n?.(e),title:`${e.path}: ${e.verifiedAfter?e.verifiedBy??`checked after the last edit`:`changed after the last passing check`}`,children:(0,G.jsxs)(`span`,{className:`sr-only`,children:[e.path,`:`,` `,e.verifiedAfter?`checked since last edit`:`not checked since last edit`]})})},e.path))}),e.length>120&&(0,G.jsxs)(`p`,{className:`cov-more`,children:[`…and `,e.length-120,` more.`]}),(0,G.jsxs)(`ul`,{className:`cov-key`,children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`cov-cell is-covered`,"aria-hidden":`true`}),` checked since last edit`,(0,G.jsx)(`span`,{className:`num cov-key-n`,children:i})]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`cov-cell is-stale`,"aria-hidden":`true`}),` changed since the last check`,(0,G.jsx)(`span`,{className:`num cov-key-n`,children:a})]})]})]})}function Sp({ex:e,sessionId:t,personalized:n=!1,analogies:r,hasAlternate:i=!1,onToggleVersion:a,personalizerOpen:o,onClosePersonalizer:s,personalizationNote:c,hasCurrentPresentation:l=!1}){let u=e.approachChange,d=e.why.lanes.length>1,f=e.why.chain.length>0||e.why.lanes.length>0,p={junction:d,outcome:!!u};return(0,G.jsxs)(`section`,{className:`ex`,"aria-label":`Generated explanation`,children:[(0,G.jsx)(`p`,{className:`ex-what`,children:e.what.summary}),e.what.currently&&(0,G.jsxs)(`p`,{className:`ex-now`,children:[(0,G.jsx)(`span`,{className:`ex-now-key`,children:`Now`}),e.what.currently]}),i&&a&&(0,G.jsxs)(`div`,{className:`ex-version-row`,children:[c&&(0,G.jsxs)(`span`,{className:`ex-version-note`,title:c,children:[(0,G.jsx)(Z,{name:`sliders`}),(0,G.jsx)(`span`,{children:`Saved:`}),c]}),(0,G.jsxs)(`fieldset`,{className:`ex-version-switch`,children:[(0,G.jsx)(`legend`,{className:`sr-only`,children:`Explanation version`}),(0,G.jsxs)(`button`,{type:`button`,className:`btn ex-version-button ${n?``:`is-on`}`,"aria-pressed":!n,onClick:n?a:void 0,children:[(0,G.jsx)(Z,{name:`record`}),`Original`]}),(0,G.jsxs)(`button`,{type:`button`,className:`btn ex-version-button ${n?`is-on`:``}`,"aria-pressed":n,onClick:n?void 0:a,children:[(0,G.jsx)(Z,{name:`check`}),`Personalized`]})]})]}),o&&(0,G.jsx)(sp,{sessionId:t,hasCurrentPresentation:l,onDone:s}),f&&(0,G.jsxs)(`section`,{className:`ex-block`,id:`sec-why`,"data-diagram-tone":`why`,children:[(0,G.jsx)(wp,{title:`Why`,summary:e.why.summary}),r?.why&&(0,G.jsx)(Cp,{children:r.why}),d?(0,G.jsx)(tp,{lanes:e.why.lanes,trunk:e.why.chain}):(0,G.jsx)(ep,{steps:e.why.chain})]}),e.how.steps.length>0&&(0,G.jsxs)(`section`,{className:`ex-block`,id:`sec-how`,"data-diagram-tone":`how`,children:[(0,G.jsx)(wp,{title:`How`,summary:e.how.summary}),r?.how&&(0,G.jsx)(Cp,{children:r.how}),(0,G.jsx)(rp,{root:e.how.root,steps:e.how.steps})]}),u&&(0,G.jsxs)(`section`,{className:`ex-block`,id:`sec-approach`,"data-diagram-tone":`approach`,children:[(0,G.jsx)(wp,{title:`Approach changed`}),(0,G.jsx)(ap,{from:u.from,fromSteps:u.fromSteps,to:u.to,toSteps:u.toSteps,why:u.why})]}),(0,G.jsxs)(`footer`,{className:`ex-foot`,children:[(0,G.jsx)(op,{marks:p}),(0,G.jsx)(`div`,{className:`ex-attribution`,children:(0,G.jsxs)(`p`,{className:`ex-mark`,children:[n?`Personalized`:`Generated`,` by`,` `,Xf(e.model)?`Codex`:e.model]})})]})]})}function Cp({children:e}){return(0,G.jsxs)(`p`,{className:`ex-analogy`,children:[(0,G.jsx)(`span`,{children:`In your terms`}),e]})}function wp({title:e,summary:t}){return(0,G.jsxs)(`header`,{className:`ex-head`,children:[(0,G.jsx)(`h2`,{className:`ex-title`,children:e}),t&&(0,G.jsx)(`p`,{className:`ex-summary`,children:t})]})}function Tp({view:e,onRef:t}){let n=[...new Set(e.left.items.filter(e=>e.source===`verification`&&e.status===`failing`).map(e=>e.text.replace(/\s.*$/,``).toLowerCase()))];return(0,G.jsx)(xp,{files:e.changes.files,failing:n,onOpen:e=>t(e.lastCallId)})}function Ep({view:e,onRef:t}){return(0,G.jsx)(bp,{runs:e.verified.runs,onOpen:e=>t(e.callId)})}function Dp({view:e,cwd:t,onRef:n}){return(0,G.jsx)(yp,{files:e.changes.files,cwd:t,limit:20,onOpen:e=>n(e.lastCallId)})}function Op({view:e,onRef:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(gp,{turns:e.turns,commits:e.changes.commits,onRef:t}),(0,G.jsx)(Fp,{subagents:e.subagents,onRef:t})]})}function kp({which:e,view:t,onRef:n}){return(0,G.jsx)(Pp,{view:t,detail:2,onRef:n,only:e})}var Ap={pass:`passed`,fail:`failed`,partial:`partial`,unknown:`unknown`},jp={"exit-inferred":`exit code not reported, read from the output`,"exit-masked":`exit code hidden by a pipe`,"output-truncated":`output was truncated`,"no-summary-parsed":`no summary line found in the output`,"exit-summary-mismatch":`the output says passed and the exit code says failed`};function Mp(e){return e.filter(e=>e!==`scope-partial`).map(e=>jp[e]??e).join(` · `)}var Np=6;function Pp({view:e,detail:t,onRef:n,only:r}){let i=e.verified.summary,a=e.review.groups.filter(e=>e.severity!==`info`),o=e=>t>1?e:e.slice(0,Np),s=e=>t>1||e<=Np?null:(0,G.jsxs)(`li`,{className:`rp-none`,children:[`…`,e-Np,` more, under Records`]}),c=e=>r===void 0||r===e;return(0,G.jsxs)(`div`,{className:`rp-cols${r?` is-single`:``}`,children:[c(`checks`)&&(0,G.jsxs)(`div`,{className:`rp-block`,id:`sec-verified`,children:[(0,G.jsx)(`h3`,{className:`rp-title`,children:`Verified`}),i.length===0?(0,G.jsx)(`p`,{className:`rp-none`,children:`No checks observed.`}):(0,G.jsx)(`ul`,{className:`rp-status`,children:i.map(e=>{let r=Mp(e.caveats);return(0,G.jsxs)(`li`,{className:`v-${e.outcome}`,children:[(0,G.jsx)(`span`,{className:`rp-mark`,"aria-hidden":`true`,children:Qf(e.outcome)}),(0,G.jsxs)(`button`,{type:`button`,className:`rp-status-label`,onClick:()=>n(e.callId),children:[e.method,(0,G.jsx)(`span`,{className:`sr-only`,children:Ap[e.outcome]??e.outcome}),e.counts?.total!==void 0&&(0,G.jsxs)(`span`,{className:`mono rp-counts`,children:[e.counts.passed??0,`/`,e.counts.total]})]}),e.scope===`partial`&&(0,G.jsx)(`span`,{className:`rp-subset`,children:`subset`}),e.laterUnreadable>0&&(0,G.jsx)(`span`,{className:`rp-stale`,title:`${e.laterUnreadable} later ${e.laterUnreadable===1?`run`:`runs`} of ${e.method} produced no readable outcome`,children:`not the latest run`}),r&&(0,G.jsx)(`span`,{className:`rp-caveat`,children:r}),t>1&&e.epistemic===`inferred`&&(0,G.jsx)(`span`,{className:`rp-derived`,children:`derived`})]},e.id)})})]}),c(`left`)&&(0,G.jsxs)(`div`,{className:`rp-block`,id:`sec-left`,children:[(0,G.jsx)(`h3`,{className:`rp-title`,children:`Left`}),e.left.items.length===0?(0,G.jsx)(`p`,{className:`rp-none`,children:`Nothing recorded.`}):(0,G.jsxs)(`ul`,{className:`rp-status`,children:[o(e.left.items).map(e=>(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`rp-mark`,"aria-hidden":`true`,children:e.status===`failing`?`✕`:e.status===`in_progress`?`▸`:`○`}),(0,G.jsx)(`span`,{children:e.text})]},e.id)),s(e.left.items.length)]})]}),c(`review`)&&(0,G.jsxs)(`div`,{className:`rp-block`,id:`sec-review`,children:[(0,G.jsx)(`h3`,{className:`rp-title`,children:`Review`}),a.length===0?(0,G.jsx)(`p`,{className:`rp-none`,children:`Nothing needs you.`}):(0,G.jsxs)(`ul`,{className:`rp-status`,children:[o(a).map(e=>(0,G.jsx)(Lp,{group:e,onRef:n},e.rule)),s(a.length)]})]})]})}function Fp({subagents:e,onRef:t}){if(e.length===0)return null;let n=e.filter(e=>e.lastMessage).length;return(0,G.jsx)(dd,{label:`Delegated to ${e.length} ${e.length===1?`agent`:`agents`}${n>0?`, ${n} reported back`:``}`,id:`subagents`,children:(0,G.jsx)(`ul`,{className:`rows`,children:e.map(e=>(0,G.jsx)(Ip,{agent:e,onRef:t},e.id))})})}function Ip({agent:e,onRef:t}){let[n,r]=(0,B.useState)(!1),i=e.lastMessage??``,[a,o]=$f(n,i);return(0,G.jsxs)(`li`,{className:`row row-flat is-quote`,children:[(0,G.jsx)(`span`,{className:`attrib`,children:e.description??e.agentType??e.id}),i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{ref:a,className:`rp-statement-body${n?` is-open`:``}`,children:i}),(o||n)&&(0,G.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>r(!n),children:n?`less`:`more`})]}):(0,G.jsx)(`span`,{className:`muted`,children:e.endedAt?`ended without reporting`:`still running`}),e.eventId&&(0,G.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>t(e.eventId),"aria-label":`Open the record for ${e.description??e.agentType??e.id}`,children:`record`})]})}function Lp({group:e,onRef:t}){let[n,r]=(0,B.useState)(!1),i=e.items[0];return e.occurrences===1&&i?(0,G.jsxs)(`li`,{className:`is-attn`,children:[(0,G.jsx)(`span`,{className:`rp-mark`,"aria-hidden":`true`,children:`⚠`}),(0,G.jsx)(`span`,{children:i.summary}),i.refs[0]&&(0,G.jsx)(`button`,{type:`button`,className:`link rp-ev`,onClick:()=>t(i.refs[0]),children:`record`})]}):(0,G.jsxs)(`li`,{className:`is-attn rp-group`,children:[(0,G.jsx)(`span`,{className:`rp-mark`,"aria-hidden":`true`,children:`⚠`}),(0,G.jsxs)(`div`,{className:`rp-group-body`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`rp-group-head`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[(0,G.jsx)(`span`,{className:`rp-group-label`,children:e.label}),(0,G.jsxs)(`span`,{className:`rp-group-count num`,children:[e.occurrences,e.items.length<e.occurrences&&(0,G.jsxs)(`span`,{className:`rp-group-distinct`,children:[` · `,e.items.length,` distinct`]})]})]}),n&&(0,G.jsx)(`ul`,{className:`rp-group-items`,children:e.items.map(e=>(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`mono`,title:e.instance??e.label,children:gd(e.instance??e.label)}),e.repeats>1&&(0,G.jsxs)(`span`,{className:`rp-group-repeats num`,children:[`×`,e.repeats]}),e.refs[0]&&(0,G.jsx)(`button`,{type:`button`,className:`link rp-ev`,onClick:()=>t(e.refs[0]),children:`record`})]},e.id))})]})]})}function Rp({verdict:e,strip:t,onOpen:n}){let r=[e.because,t.waiting?.summary,e.epistemic===`inferred`&&!e.because?`Worked out, not observed.`:void 0].filter(Boolean).join(` `);return(0,G.jsxs)(`div`,{className:`masthead-badges`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`tag is-open`,"data-tone":e.tone,onClick:()=>n(`checks`),title:`Open the checks this verdict was read from`,children:[(0,G.jsx)(`span`,{className:`tag-strong`,children:e.headline}),r&&(0,G.jsx)(`span`,{className:`tag-note`,children:r})]}),t.reviewOpen>0&&(0,G.jsxs)(`button`,{type:`button`,className:`tag is-open`,"data-tone":`attention`,onClick:()=>n(`review`),title:`Things Salidium flagged for a human: failing checks, waiting prompts, destructive commands, claims with no evidence`,children:[(0,G.jsx)(`span`,{className:`tag-key`,children:`to review`}),(0,G.jsx)(`span`,{className:`num tag-strong`,children:t.reviewOpen})]}),t.remaining>0&&(0,G.jsxs)(`button`,{type:`button`,className:`tag is-open`,onClick:()=>n(`left`),title:`Work the agent recorded as not yet finished`,children:[(0,G.jsx)(`span`,{className:`tag-key`,children:`unfinished`}),(0,G.jsx)(`span`,{className:`num tag-strong`,children:t.remaining})]})]})}var zp=[{value:`off`,name:jf.off.label},{value:`session`,name:jf.session.label},{value:`turn`,name:jf.turn.label}],Bp=[{value:`auto`,name:`Same as coding`},{value:`claude`,name:`Claude`},{value:`codex`,name:`Codex`}],Vp=[{model:`gpt-5.6-sol`,detail:`Highest capability`},{model:`gpt-5.6-terra`,detail:`Balanced`},{model:`gpt-5.6-luna`,detail:`Lightweight`}];function Hp(e){return e===`claude`?`Claude Code`:e===`codex`?`Codex`:`Unavailable`}function Up({label:e,model:t,detail:n,exact:r=!0}){return(0,G.jsxs)(`div`,{className:`mu-model-row`,children:[(0,G.jsx)(`dt`,{children:e}),(0,G.jsxs)(`dd`,{children:[(0,G.jsx)(`strong`,{className:r?`mono`:void 0,children:t??`Unavailable`}),n&&(0,G.jsx)(`span`,{children:n})]})]})}function Wp(e){return{name:Yf(e),automatic:Xf(e)}}function Gp({legend:e,value:t,options:n,disabled:r,onChange:i}){return(0,G.jsxs)(`fieldset`,{className:`mu-choice`,"data-choice":e,children:[(0,G.jsx)(`legend`,{children:e}),(0,G.jsx)(`div`,{className:`mu-choice-set`,children:n.map(e=>(0,G.jsx)(`button`,{type:`button`,className:e.value===t?`is-on`:void 0,"aria-pressed":e.value===t,"data-value":e.value,disabled:r,onClick:()=>i(e.value),children:e.name},e.value))})]})}function Kp({label:e,scope:t,usage:n,preparing:r=!1}){return(0,G.jsxs)(`div`,{className:`mu-usage-ledger`,children:[(0,G.jsxs)(`div`,{className:`mu-usage-head`,children:[(0,G.jsxs)(`span`,{children:[e,t&&(0,G.jsx)(`small`,{children:t})]}),(0,G.jsx)(`strong`,{children:r?(0,G.jsx)(id,{label:`Preparing token history`}):n?`${n.messages.toLocaleString()} responses`:`No token data`})]}),n&&(0,G.jsxs)(`dl`,{className:`mu-usage-grid`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Input`}),(0,G.jsx)(`dd`,{children:n.inputTokens.toLocaleString()})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Output`}),(0,G.jsx)(`dd`,{children:n.outputTokens.toLocaleString()})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Cache reused`}),(0,G.jsx)(`dd`,{children:n.cacheReadTokens.toLocaleString()})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Cache stored`}),(0,G.jsx)(`dd`,{children:n.cacheWriteTokens.toLocaleString()})]})]})]})}function qp({provider:e,workModel:t,sessionUsage:n,generatedModel:r}){let i=X(e=>e.api),a=X(e=>e.explainer),o=X(e=>e.loadExplainer),s=X(e=>e.setExplainerSettings),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(!1),m=(0,B.useRef)(null);if((0,B.useEffect)(()=>{i&&o()},[i,o]),(0,B.useEffect)(()=>{if(!i||a?.usageStatus!==`preparing`)return;let e=window.setInterval(()=>void o(),2e3);return()=>window.clearInterval(e)},[i,a?.usageStatus,o]),(0,B.useEffect)(()=>l(a?.model??``),[a?.model]),(0,B.useEffect)(()=>{f&&m.current?.focus()},[f]),!a)return(0,G.jsx)(id,{label:`Loading model settings`,block:!0});let h=e===`codex`?a.routes.codex:e===`claude-code`?a.routes.claudeCode:void 0,g=c.trim()!==(a.model??``),_=Mf(a)??`off`,v=jf[_],y=_!==`off`,b=Wp(r??h?.model),x=Wp(h?.model),S=!!(r&&h?.model&&r!==h.model),ee=e===`codex`?`codex`:e===`claude-code`?`claude`:null,te=h?.backend??(a.backend===`auto`?null:a.backend),ne=h??(te===`claude`?a.routes.claudeCode:te===`codex`?a.routes.codex:void 0),C=[],re=new Set,ie=e=>{e.value&&re.has(e.value)||(e.value&&re.add(e.value),C.push(e))};if(te===`claude`&&!a.model&&ne?.model?ie({value:null,name:ne.model,detail:`Salidium default`}):ie({value:null,name:`Automatic`,detail:te?`${Hp(te)} chooses`:`Uses the coding agent`}),t&&ee===te&&ie({value:t,name:t,detail:`Current coding model`}),te===`codex`)for(let e of Vp)ie({value:e.model,name:e.model,detail:e.detail});return a.model&&ie({value:a.model,name:a.model,detail:`Current selection`}),(0,G.jsxs)(`div`,{className:`mu`,children:[(0,G.jsxs)(`section`,{className:`mu-section`,"aria-labelledby":`mu-models`,children:[(0,G.jsx)(`h3`,{className:`mu-title`,id:`mu-models`,children:`Models`}),(0,G.jsx)(`dl`,{className:`mu-models`,children:e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Up,{label:`Coding`,model:t}),y?(0,G.jsx)(Up,{label:`Explanation`,model:b.name,exact:!b.automatic,detail:b.automatic?`${Hp(h?.backend??null)} chooses the model`:void 0}):(0,G.jsx)(Up,{label:`Explanation`,model:`Local only`,detail:`No model calls`,exact:!1}),y&&S&&(0,G.jsx)(Up,{label:`Next`,model:x.name,exact:!x.automatic})]}):y?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Up,{label:`Claude`,model:a.routes.claudeCode.model}),(0,G.jsx)(Up,{label:`Codex`,model:Wp(a.routes.codex.model).name,exact:!1})]}):(0,G.jsx)(Up,{label:`Explanation`,model:`Local only`,detail:`No model calls`,exact:!1})})]}),(0,G.jsxs)(`section`,{className:`mu-section`,"aria-labelledby":`mu-controls`,children:[(0,G.jsx)(`h3`,{className:`mu-title`,id:`mu-controls`,children:`Explanation`}),a.envOff&&(0,G.jsx)(`p`,{className:`explain-warning`,children:`Disabled by the daemon environment.`}),!a.envOff&&a.cadence!==`off`&&!a.routes.claudeCode.backend&&!a.routes.codex.backend&&(0,G.jsx)(`p`,{className:`explain-warning`,children:a.backendLocked?`The locked helper is unavailable.`:`No selected helper is installed.`}),(0,G.jsxs)(`div`,{className:`mu-control-stack`,children:[(0,G.jsx)(Gp,{legend:`Written Why + How`,value:a.cadence,options:zp,onChange:e=>s({cadence:e})}),(0,G.jsxs)(`p`,{className:`mu-cadence-note is-${_}`,children:[v.detail,`.`]}),y&&(0,G.jsx)(Gp,{legend:`Agent`,value:a.backend,options:Bp,disabled:a.backendLocked,onChange:e=>{e!==a.backend&&(l(``),p(!1),s({backend:e,model:null}))}})]}),y&&u?(0,G.jsxs)(`div`,{className:`mu-model-picker`,children:[(0,G.jsxs)(`div`,{className:`mu-model-picker-head`,children:[(0,G.jsx)(`span`,{children:`Model`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{p(!1),d(!1)},children:`Done`})]}),(0,G.jsxs)(`ul`,{className:`mu-model-options`,"aria-label":`Explanation model choices`,children:[C.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,className:`mu-model-option`,"aria-current":e.value===(a.model??null)?`true`:void 0,disabled:a.modelLocked,onClick:()=>{l(e.value??``),s({model:e.value}),p(!1)},children:[(0,G.jsx)(`span`,{className:`mono`,children:e.name}),(0,G.jsx)(`small`,{children:e.detail})]})},e.value??`automatic`)),(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,className:`mu-model-option`,"aria-expanded":f,disabled:a.modelLocked,onClick:()=>{l(a.model??``),p(!0)},children:[(0,G.jsx)(`span`,{children:`Other model…`}),(0,G.jsx)(`small`,{children:`Enter a model name`})]})})]}),f&&(0,G.jsxs)(`form`,{className:`mu-model-control`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&(s({model:t}),p(!1))},children:[(0,G.jsx)(`label`,{htmlFor:`explainer-model`,children:`Model name`}),(0,G.jsxs)(`div`,{className:`mu-model-input`,children:[(0,G.jsx)(`input`,{ref:m,id:`explainer-model`,className:`field mono`,value:c,onChange:e=>l(e.target.value),placeholder:te===`claude`?`claude-…`:`gpt-…`,maxLength:120,disabled:a.modelLocked}),(0,G.jsx)(`button`,{className:`btn btn-accent`,type:`submit`,disabled:a.modelLocked||!g||!c.trim(),children:`Use`}),(0,G.jsx)(`button`,{className:`btn`,type:`button`,onClick:()=>{l(a.model??``),p(!1)},children:`Cancel`})]})]}),(a.backendLocked||a.modelLocked)&&(0,G.jsx)(`span`,{className:`explain-lock`,children:`Locked by the daemon environment.`})]}):y?(0,G.jsx)(`button`,{type:`button`,className:`mu-exact-trigger`,"aria-expanded":`false`,onClick:()=>d(!0),children:a.model?`Change model…`:`Choose a model…`}):null]}),(0,G.jsxs)(`section`,{className:`mu-section`,"aria-labelledby":`mu-usage`,children:[(0,G.jsx)(`h3`,{className:`mu-title`,id:`mu-usage`,children:`Usage`}),(0,G.jsxs)(`div`,{className:`mu-usage-list`,children:[e&&(0,G.jsx)(Kp,{label:`Session`,usage:n}),(0,G.jsx)(Kp,{label:`Explanations`,scope:`all runs`,usage:a.usage,preparing:a.usageStatus===`preparing`})]})]})]})}var Jp=8,Yp=`live`;function Xp(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];a!==void 0&&a.ts<=t?n=i+1:r=i}return n-1}var Zp=16,Qp=(e,t=0)=>`calc(${Zp/2+t}px + (100% - ${Zp}px) * ${e})`;function $p({startedAt:e,endedAt:t,changes:n,checks:r,commits:i,scrubTs:a,onScrub:o,onLive:s}){let[c,l]=(0,B.useState)(),u=(0,B.useRef)(void 0);(0,B.useEffect)(()=>()=>clearTimeout(u.current),[]);let d=(0,B.useRef)(null),[f,p]=(0,B.useState)(0);(0,B.useLayoutEffect)(()=>{let e=d.current;if(!e)return;p(e.getBoundingClientRect().width);let t=new ResizeObserver(([t])=>p(t?.contentRect.width??e.getBoundingClientRect().width));return t.observe(e),()=>t.disconnect()},[]);let m=(0,B.useMemo)(()=>{let e=[],t=-1;for(let r of n){t=Math.max(t,r.seq);let n=e[e.length-1];n!==void 0&&n.ts===r.ts?n.seq=t:e.push({ts:r.ts,seq:t})}return e},[n,n.length]),h=(0,B.useMemo)(()=>{let e=new Map,t=(t,n)=>{let r=Xp(m,t);if(r<0)return;let i=e.get(r)??{fail:!1,pass:!1,commit:!1,n:0};i[n]=!0,i.n+=1,e.set(r,i)};for(let e of r)e.outcome===`pass`?t(e.at,`pass`):e.outcome===`fail`&&t(e.at,`fail`);for(let e of i)t(e.at,`commit`);let n=Math.max(0,f-Zp),a=n>0&&m.length>0?n/m.length:0,o=a>0?Math.max(1,Math.ceil(Jp/a)):1,s=[];for(let t of[...e.keys()].sort((e,t)=>e-t)){let n=e.get(t),r=s[s.length-1];if(r&&t-r.at<o){r.fail||=n.fail,r.pass||=n.pass,r.commit||=n.commit,r.n+=n.n;continue}s.push({at:t,...n})}return s.map(e=>({at:e.at,f:e.at/m.length,tone:e.fail?`fail`:e.pass?`pass`:`commit`,n:e.n}))},[r,i,m,f]);if(m.length===0)return null;let g=c??a,_=g===void 0||g===Yp?m.length:Math.max(0,Xp(m,g)),v=m[_]?.ts,y=_/m.length,b=e=>{let t=m[e];l(t?t.ts:Yp),clearTimeout(u.current),u.current=setTimeout(()=>{l(void 0),t?o(t.ts,t.seq):s()},90)};return(0,G.jsxs)(`section`,{className:`timeline`,"aria-label":`Session timeline`,children:[(0,G.jsxs)(`div`,{className:`tl-track`,ref:d,children:[(0,G.jsx)(`div`,{className:`tl-marks`,"aria-hidden":`true`,children:h.map(e=>(0,G.jsx)(`span`,{className:`tl-mark tl-${e.tone}`,style:{left:Qp(e.f)},title:`${e.n} ${e.n===1?`event`:`events`} here`},e.at))}),_<m.length&&(0,G.jsx)(`div`,{className:`tl-future`,style:{left:Qp(y)},"aria-hidden":`true`}),(0,G.jsx)(`div`,{className:`tl-stem`,style:{left:Qp(y,-1)},"aria-hidden":`true`}),(0,G.jsx)(`input`,{className:`tl-range`,type:`range`,min:0,max:m.length,step:1,value:_,onChange:e=>b(Number(e.target.value)),"aria-label":`Show the session as it stood at a moment in time`,"aria-valuetext":v===void 0?t?`the whole session`:`now, following live`:`${pd(v)}, change ${_+1} of ${m.length}, later events hidden`})]}),(0,G.jsxs)(`div`,{className:`tl-legend`,children:[(0,G.jsx)(`span`,{className:`mono`,children:pd(e)}),(0,G.jsx)(`span`,{className:`tl-legend-mid`,children:_>=m.length?t?`whole session`:`following live`:(0,G.jsxs)(G.Fragment,{children:[`showing `,(0,G.jsx)(`strong`,{className:`mono`,children:pd(v)}),(0,G.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>b(m.length),children:`back to now`})]})}),(0,G.jsx)(`span`,{className:`mono`,children:t?pd(t):`now`})]})]})}function em(){let[e,t]=(0,B.useState)(!1),n=cd(e,()=>t(!1));return(0,G.jsxs)(`div`,{className:`pop`,ref:n,children:[(0,G.jsxs)(`button`,{type:`button`,className:`btn btn-float ${e?`is-on`:``}`,onClick:()=>t(e=>!e),"aria-expanded":e,title:`What the track shows`,children:[(0,G.jsx)(Z,{name:`help`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`What the track shows`})]}),(0,G.jsxs)(`div`,{className:`pop-panel is-narrow is-up arrives ${e?`is-open`:``}`,children:[(0,G.jsx)(`div`,{className:`pop-head`,children:(0,G.jsx)(`span`,{children:`On the track`})}),(0,G.jsx)(`p`,{className:`pop-note`,children:`One step per change, not per minute. The clock is in the two end labels and in the readout while you drag.`}),(0,G.jsx)(`p`,{className:`pop-note`,children:`A mark is a check or a commit, red where a check failed. Marks too close to draw apart are merged, and a merged mark takes the worst outcome in it.`})]})]})}function tm({sessionId:e,now:t}){let[n,r]=(0,B.useState)(0);kf(e,n);let i=X(e=>e.api),a=X(t=>t.live[e]),o=X(t=>t.liveErrors[e]),s=X(t=>t.sessions[e]),c=X(e=>e.openRaw),l=X(e=>e.setScrub),u=X(e=>e.markSeen),d=X(e=>e.openPanel),f=X(e=>e.rewindOpen),p=X(e=>e.toggleRewind),m=X(e=>e.sidebarOpen),h=X(e=>e.toggleSidebar),g=X(e=>e.statsOpen),_=X(e=>e.toggleStats),v=X(e=>e.ingestOpen),y=X(e=>e.toggleIngest),b=X(e=>e.explainer),x=X(e=>e.personalization),S=X(t=>t.personalized[e]),ee=Nf(b),te=Mf(b),ne=X(e=>e.historyMode),C=X(e=>e.setHistoryMode),[re,ie]=(0,B.useState)(void 0),[ae,oe]=(0,B.useState)(`personalized`),[se,w]=(0,B.useState)(!1),ce=(0,B.useRef)(null),le=lf(),[ue,de]=Rf(`${f}`),fe=zf(f);(0,B.useEffect)(()=>{oe(`personalized`)},[S?.generatedAt,x?.revision,a?.state.explained?.basedOnSeq]),(0,B.useEffect)(()=>{a?.scrub?.seq!==void 0&&w(!1)},[a?.scrub?.seq]);let pe=a?.state,me=a?.scrub?.state,he=a?.revision??0,ge=a?.scrub?.seq,_e=(0,B.useMemo)(()=>pe?yu(pe,t):void 0,[pe,he,t]),ve=(0,B.useMemo)(()=>me?yu(me,t):void 0,[me,ge,t]),ye=(0,B.useCallback)(t=>{let n=X.getState().live[e]?.state;if(!n)return;let r=t.includes(`#`)?t:n.activities[t]?.eventIds[0]??n.claims.find(e=>e.id===t)?.eventId??n.claims.find(e=>e.id===t)?.id;r&&c(e,r)},[c,e]),be=(0,B.useRef)(0),xe=(0,B.useCallback)((t,n)=>{let r=X.getState().live[e];if(!i||!r)return;let a=++be.current;l(e,{ts:t,seq:n,state:r.scrub?.state??r.state,loading:!0}),i.stateAtTime(e,t).then(r=>{be.current===a&&l(e,{ts:t,seq:n,state:r.state,loading:!1})},()=>{be.current===a&&l(e,void 0)})},[i,e,l]),Se=(0,B.useCallback)(()=>{be.current++,l(e,void 0)},[e,l]),Ce=(0,B.useMemo)(()=>a?a.changes.filter(e=>e.seq>a.lastSeenSeq&&(e.facet===`what`||e.facet===`verified`||e.facet===`review`||e.facet===`left`)).length:0,[a]);(0,B.useEffect)(()=>()=>u(e),[e,u]);let we=(0,B.useCallback)(()=>{ie(X.getState().live[e]?.lastSeenSeq),X.getState().statsOpen&&_(),X.getState().ingestOpen&&y(),C(`rail`),u(e)},[e,u,C,_,y]),Te=(0,B.useCallback)(()=>{X.getState().historyMode===`off`?(X.getState().statsOpen&&_(),X.getState().ingestOpen&&y(),C(`rail`)):(ie(void 0),C(`off`))},[C,_,y]),Ee=(0,B.useCallback)(()=>{ie(void 0),C(`off`),_()},[C,_]),De=(0,B.useCallback)(()=>{ie(void 0),C(`off`),y()},[C,y]);if((0,B.useEffect)(()=>{let e=e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.metaKey||e.ctrlKey||e.altKey||(e.key===`h`?Te():e.key===`l`&&ge!==void 0&&Se())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[ge,Se,Te]),!a||!pe||!_e)return o?(0,G.jsx)(am,{error:o,onRetry:()=>r(e=>e+1)}):(0,G.jsx)(`div`,{className:`main-empty`,children:(0,G.jsx)(`div`,{className:`muted`,role:`status`,children:(0,G.jsx)(id,{label:`Loading session`,size:`md`})})});let Oe=me??pe,T=ve??_e,ke=T.changes.files.length>0||T.verified.runs.length>0||T.turns.length+T.subagents.length>0,Ae=mf(T.strip.status),je=_e.strip.status===`ended`?pe.lastEventAt:void 0,Me=T.explained,Ne=!!(Me&&x?.enabled&&S&&S.profileRevision===x.revision&&S.basedOnSeq===Me.basedOnSeq),Pe=Ne&&ae===`original`,Fe=Ne&&!Pe&&S?{basedOnSeq:S.basedOnSeq,model:S.model,at:S.generatedAt,what:S.what,why:S.why,how:S.how,approachChange:S.approachChange}:Me,Ie=Ne&&!Pe;return(0,G.jsxs)(`div`,{className:`session ${g||v||ne===`rail`?`has-inspector`:``} ${g?`has-models`:``}`,children:[(0,G.jsxs)(`div`,{className:`session-main`,ref:ue,children:[(0,G.jsxs)(`div`,{className:`session-actions`,children:[!m&&(0,G.jsx)(Q,{icon:`panel`,title:`Show the session list ([)`,onClick:h}),(0,G.jsxs)(`div`,{className:`toolbar session-actions-end`,children:[ge===void 0&&Ce>0&&(0,G.jsxs)(`button`,{type:`button`,className:`fresh`,onClick:we,title:`Changes since you last had this session open. Opens History filtered to them.`,children:[`Show `,Ce,` new`]}),ke&&(0,G.jsx)(Q,{icon:`table`,label:`Evidence`,title:`Coverage, checks over time, what changed, what happened when`,onClick:()=>d(`evidence`)}),(0,G.jsx)(Q,{icon:`save`,label:`Export`,title:`Save this report as JSON without raw provider records`,onClick:()=>Lf({id:e,provider:pe.provider,title:pe.title||s?.title||pe.cwd,cwd:pe.cwd,...pe.model?{model:pe.model}:{}},_e)}),(0,G.jsx)(Q,{icon:`latest`,label:`Rewind`,on:f,title:`Show the session as it stood at a moment in time`,onClick:p}),(0,G.jsx)(Q,{icon:`stats`,label:`Models & Usage`,on:g,title:`Show explanation timing, models and usage${ee?`. ${ee.label}: ${ee.detail}.`:``}`,onClick:Ee}),(0,G.jsx)(Q,{icon:`storage`,label:`Ingest & Storage`,on:v,controls:`ingest-storage-inspector`,expanded:v,buttonRef:ce,title:`Show collection state, queued observations, storage, and loss history`,onClick:De}),Me&&(0,G.jsx)(Q,{icon:Ne?`check`:`sliders`,label:Ne?`Personalized`:`Personalize`,on:se,controls:`personalization-composer`,expanded:se,disabled:ge!==void 0,title:ge===void 0?Ne?`Edit the saved terms applied to this report`:`Explain the generated report using terms and examples you know`:`Return to live before personalizing this report`,onClick:()=>w(e=>!e)}),(0,G.jsx)(Q,{icon:`history`,label:`History`,on:ne!==`off`,title:`Toggle history (h)`,onClick:Te}),(0,G.jsx)(sd,{icon:`outbound`,label:`Docs`,href:od,title:`Open the Salidium documentation in a new tab`}),(0,G.jsx)(ud,{}),a.connection!==`open`&&a.connection!==`connecting`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`toolbar-sep`,"aria-hidden":`true`}),(0,G.jsx)(fd,{status:a.connection})]})]})]}),ne===`table`?(0,G.jsx)(Kf,{changes:a.changes,scrubTs:a.scrub?.ts,onScrub:xe,onLive:Se,onRef:ye}):(0,G.jsx)(`div`,{className:`session-content scroll-fade`,ref:le,children:(0,G.jsxs)(`article`,{className:`page`,children:[(0,G.jsxs)(`header`,{className:`masthead`,children:[(0,G.jsx)(Ks,{size:16,className:`masthead-mark`}),(0,G.jsx)(`h1`,{className:`masthead-title`,children:Oe.title||s?.title||Oe.cwd}),(0,G.jsxs)(`p`,{className:`masthead-meta`,children:[(0,G.jsxs)(`span`,{className:`tag is-status`,children:[(0,G.jsx)(`span`,{className:`status-dot ${Ae.cls}`,"aria-hidden":`true`,children:Ae.glyph}),Ae.label,T.strip.statusSince&&` ${md(T.strip.statusSince,t)}`]}),(0,G.jsxs)(`span`,{className:`tag masthead-path`,title:Oe.cwd,children:[(0,G.jsx)(`span`,{className:`tag-key`,children:`in`}),(0,G.jsx)(`span`,{className:`mono`,children:gd(hd(Oe.cwd))})]}),Oe.gitBranch&&(0,G.jsxs)(`span`,{className:`tag`,children:[(0,G.jsx)(`span`,{className:`tag-key`,children:`branch`}),(0,G.jsx)(`span`,{className:`mono`,children:Oe.gitBranch})]}),(0,G.jsxs)(`span`,{className:`tag is-${Oe.provider}`,children:[(0,G.jsx)(`span`,{className:`tag-key`,children:`agent`}),Pf(Oe.provider)]}),Oe.model&&(0,G.jsxs)(`span`,{className:`tag`,children:[(0,G.jsx)(`span`,{className:`tag-key`,children:`model`}),(0,G.jsx)(`span`,{className:`mono`,children:Oe.model})]})]}),(0,G.jsx)(Rp,{verdict:T.verdict,strip:T.strip,onOpen:d})]}),ge!==void 0&&(0,G.jsxs)(`p`,{className:`scrub-note`,role:`status`,children:[`Showing this session as it stood at `,(0,G.jsx)(`strong`,{children:pd(a.scrub?.ts)}),`. Anything later is hidden. `,a.scrub?.loading&&(0,G.jsx)(id,{label:`replaying`})]}),Fe?(0,G.jsx)(Sp,{ex:Fe,sessionId:e,personalized:Ie,analogies:Ie?S?.analogies:void 0,hasAlternate:Ne,onToggleVersion:Ne?()=>oe(Pe?`personalized`:`original`):void 0,personalizerOpen:se,onClosePersonalizer:()=>w(!1),personalizationNote:x?.profile.guidance,hasCurrentPresentation:Ne}):(0,G.jsx)(im,{turns:T.turns.length,status:s?.explanationStatus,cadence:te})]})}),(0,G.jsx)(`div`,{className:`session-foot`,ref:de,children:fe&&(0,G.jsxs)(`div`,{className:`rewind arrives ${f?`is-open`:``}`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`btn btn-float`,onClick:p,title:`Close the scrubber`,children:[(0,G.jsx)(Z,{name:`close`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Close the scrubber`})]}),(0,G.jsx)($p,{startedAt:pe.startedAt,endedAt:je,now:t,changes:a.changes,checks:_e.verified.runs,commits:_e.changes.commits,scrubTs:a.scrub?.ts,onScrub:xe,onLive:Se}),(0,G.jsx)(em,{})]})}),(0,G.jsx)(qf,{id:`checks`,title:`Verified`,children:(0,G.jsx)(kp,{which:`checks`,view:T,onRef:ye})}),(0,G.jsx)(qf,{id:`left`,title:`Left`,children:(0,G.jsx)(kp,{which:`left`,view:T,onRef:ye})}),(0,G.jsx)(qf,{id:`review`,title:`Needs you`,children:(0,G.jsx)(kp,{which:`review`,view:T,onRef:ye})}),(0,G.jsx)(nm,{view:T,cwd:Oe.cwd,onRef:ye})]}),g?(0,G.jsx)(rm,{view:T,provider:Oe.provider,generatedModel:T.explained?.model,onClose:_}):v?(0,G.jsx)(Vd,{onClose:y,returnFocusRef:ce}):ne===`rail`?(0,G.jsx)(Uf,{changes:a.changes,scrubTs:a.scrub?.ts,focusSeq:re,onScrub:xe,onLive:Se,onClose:Te,onRef:ye}):null]})}function nm({view:e,cwd:t,onRef:n}){let r=X(e=>e.panel),i=X(e=>e.closePanel),a=e.changes.files.length,o=e.verified.runs.length,s=e.turns.length+e.subagents.length,c=[];return a>0&&c.push({key:`coverage`,label:`Coverage`,count:a,render:()=>(0,G.jsx)(Tp,{view:e,onRef:n})}),o>0&&c.push({key:`checks`,label:`Checks`,count:o,render:()=>(0,G.jsx)(Ep,{view:e,onRef:n})}),a>0&&c.push({key:`changed`,label:`Changed`,count:a,render:()=>(0,G.jsx)(Dp,{view:e,cwd:t,onRef:n})}),s>0&&c.push({key:`happened`,label:`What happened`,count:s,render:()=>(0,G.jsx)(Op,{view:e,onRef:n})}),(0,B.useEffect)(()=>{r===`evidence`&&c.length===0&&i()},[r,c.length,i]),c.length===0?null:(0,G.jsx)(qf,{id:`evidence`,title:`Evidence`,sections:c})}function rm({view:e,provider:t,generatedModel:n,onClose:r}){return(0,G.jsxs)(`aside`,{className:`inspector models-usage`,"aria-label":`Models & Usage`,children:[(0,G.jsxs)(`div`,{className:`inspector-head`,children:[(0,G.jsx)(Q,{icon:`panel`,title:`Hide Models & Usage`,onClick:r}),(0,G.jsx)(`span`,{className:`inspector-title`,children:`Models & Usage`})]}),(0,G.jsx)(`div`,{className:`models-usage-body scroll-fade`,children:(0,G.jsx)(qp,{provider:t,workModel:e.strip.model,sessionUsage:e.usage,generatedModel:n})})]})}function im({turns:e,status:t,cadence:n}){return e===0?(0,G.jsx)(`section`,{className:`ex-pending`,role:`status`,children:(0,G.jsx)(`p`,{children:`Nothing has happened in this session yet.`})}):t===`generating`?(0,G.jsxs)(`section`,{className:`ex-pending is-running`,role:`status`,children:[(0,G.jsx)(`p`,{className:`ex-pending-main`,children:(0,G.jsx)(id,{label:`Reading the session`,size:`md`})}),(0,G.jsx)(`p`,{children:`Your selected agent is writing from a bounded, redacted summary of the session. It takes a few seconds, then the explanation is cached.`})]}):t===`disabled`?(0,G.jsxs)(`section`,{className:`ex-pending`,role:`status`,children:[(0,G.jsx)(`p`,{className:`ex-pending-main`,children:`No model-written Why or How.`}),(0,G.jsx)(`p`,{children:`Local only makes no model calls. Change it in Models & Usage.`})]}):t===`unavailable`?(0,G.jsxs)(`section`,{className:`ex-pending`,role:`status`,children:[(0,G.jsx)(`p`,{className:`ex-pending-main`,children:`No explanation for this session.`}),(0,G.jsx)(`p`,{children:`No compatible Claude Code or Codex command is available, so nothing was sent. Observed facts are still available in Evidence.`})]}):t===`failed`?(0,G.jsxs)(`section`,{className:`ex-pending`,role:`status`,children:[(0,G.jsx)(`p`,{className:`ex-pending-main`,children:`No explanation for this session.`}),(0,G.jsx)(`p`,{children:`The selected agent was asked but returned no usable structured explanation. Observed facts are still available in Evidence; the next turn will try again.`})]}):(0,G.jsxs)(`section`,{className:`ex-pending`,role:`status`,children:[(0,G.jsx)(`p`,{className:`ex-pending-main`,children:`No explanation yet.`}),(0,G.jsx)(`p`,{children:n===`session`?`One is written after this session ends or goes quiet.`:n===`turn`?`One is written after the agent finishes its next reply.`:`Choose when to write one in Models & Usage.`})]})}function am({error:e,onRetry:t}){let n=X(e=>e.select);return(0,G.jsx)(`div`,{className:`main-empty`,children:(0,G.jsxs)(`div`,{className:`session-error`,role:`alert`,children:[e.kind===`not-found`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`session-error-title`,children:`This session is not in the store`}),(0,G.jsx)(`p`,{className:`muted`,children:`It may have been forgotten, or the daemon was restarted with a fresh store. Pick another session from the list.`})]}),e.kind===`unreachable`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`session-error-title`,children:`Cannot reach the Salidium daemon`}),(0,G.jsxs)(`p`,{className:`muted`,children:[e.message,`. Start it again with `,(0,G.jsx)(`code`,{children:`salidium`}),` in a terminal.`]})]}),e.kind===`failed`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`session-error-title`,children:`Could not load this session`}),(0,G.jsx)(`p`,{className:`muted mono`,children:e.message})]}),(0,G.jsxs)(`div`,{className:`session-error-actions`,children:[(0,G.jsx)(`button`,{type:`button`,className:`btn btn-accent`,onClick:t,children:`Try again`}),e.kind===`not-found`&&(0,G.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>n(void 0),children:`Back to sessions`})]})]})})}var om=`salidium open`,sm=/Mac|iPhone|iPad/.test(navigator.platform??``)?`⌘C`:`Ctrl+C`;function cm(){let[e,t]=(0,B.useState)(()=>Date.now());return(0,B.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),3e4);return()=>clearInterval(e)},[]),e}function lm(){let[e,t]=(0,B.useState)(()=>window.matchMedia(`(max-width: 900px)`).matches);return(0,B.useEffect)(()=>{let e=window.matchMedia(`(max-width: 900px)`),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function um(){let e=X(e=>e.api),t=X(e=>e.setToken),n=X(e=>e.authRejected),r=X(e=>e.selectedId),i=X(e=>e.select),a=X(e=>e.sessionOrder),o=X(e=>e.daemonError),s=a.length,c=X(e=>e.listConnection),l=X(e=>e.sidebarOpen),u=X(e=>e.toggleSidebar),d=X(e=>e.loadExplainer),f=X(e=>e.loadPersonalization),p=(0,B.useRef)(null),m=(0,B.useRef)(null),h=lm()&&l,g=cm();return(0,B.useEffect)(()=>{let e=()=>{let e=Bs();e&&t(e)};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[t]),(0,B.useEffect)(()=>{e&&(d(),f())},[e,d,f]),(0,B.useEffect)(()=>{if(!e)return;let t=()=>f(),n=()=>{document.visibilityState===`visible`&&t()};return window.addEventListener(`focus`,t),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`focus`,t),document.removeEventListener(`visibilitychange`,n)}},[e,f]),(0,B.useEffect)(()=>{let e=()=>{let e=/^#\/s\/(.+)$/.exec(window.location.hash);e?.[1]&&i(decodeURIComponent(e[1]))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[i]),(0,B.useEffect)(()=>{let e=r?`#/s/${encodeURIComponent(r)}`:``;window.location.hash!==e&&!/token=/.test(window.location.hash)&&history.replaceState(null,``,`${window.location.pathname}${e}`)},[r]),(0,B.useEffect)(()=>{!r&&a.length>0&&i(a[0])},[r,a,i]),(0,B.useEffect)(()=>{let e=e=>{if(e.key===`Escape`&&window.matchMedia(`(max-width: 900px)`).matches&&X.getState().sidebarOpen){X.getState().toggleSidebar();return}e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.metaKey||e.ctrlKey||e.altKey||e.key===`[`&&X.getState().toggleSidebar()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),sf({active:h&&!!e,containerRef:p,onClose:u,initialFocus:e=>e.querySelector(`[data-modal-initial] button`)??e.querySelector(`button:not([disabled])`),restoreFocus:()=>m.current?.querySelector(`button`)??null,shouldRestoreFocus:()=>!X.getState().sidebarOpen}),Af(),e?(0,G.jsxs)(`div`,{className:`app ${l?``:`no-side`}`,children:[(0,G.jsx)(`div`,{className:`side-backdrop arrives ${l?`is-open`:``}`,"aria-hidden":`true`,onClick:u}),!l&&(0,G.jsx)(`div`,{className:`mobile-side-trigger`,ref:m,children:(0,G.jsx)(Q,{icon:`panel`,title:`Show the session list ([)`,onClick:u})}),(0,G.jsxs)(`aside`,{ref:p,className:`side arrives ${l?`is-open`:``}`,role:h?`dialog`:void 0,"aria-modal":h?`true`:void 0,"aria-labelledby":h?`session-list-title`:void 0,"aria-label":h?void 0:`Sessions`,tabIndex:h?-1:void 0,inert:!l,onClickCapture:e=>{window.matchMedia(`(max-width: 900px)`).matches&&e.target.closest(`.session-row`)&&u()},children:[(0,G.jsxs)(`div`,{className:`side-head`,children:[(0,G.jsx)(Ks,{size:22,className:`side-mark`,decorative:!0}),(0,G.jsx)(`span`,{className:`side-head-title`,id:`session-list-title`,children:`Salidium`}),(0,G.jsx)(fd,{status:c}),s>0&&(0,G.jsx)(gf,{}),(0,G.jsx)(`span`,{"data-modal-initial":`true`,children:(0,G.jsx)(Q,{icon:`panel`,title:`Hide the session list ([)`,onClick:u})})]}),(0,G.jsx)(Cf,{now:g}),o&&(0,G.jsxs)(`div`,{className:`side-error`,role:`alert`,children:[(0,G.jsx)(`p`,{className:`side-error-title`,children:`The session list is not updating`}),(0,G.jsxs)(`p`,{children:[o.message,`.`,` `,o.unreachable?(0,G.jsxs)(G.Fragment,{children:[`Start the daemon again with `,(0,G.jsx)(`code`,{children:`salidium`}),` in a terminal.`]}):`It is reachable, so this is worth reporting rather than restarting.`]})]})]}),(0,G.jsx)(`main`,{className:`main`,inert:h,"aria-hidden":h||void 0,children:r?(0,G.jsx)(tm,{sessionId:r,now:g},r):s===0?(0,G.jsx)(dm,{}):null}),(0,G.jsx)(`div`,{className:`raw-layer`,inert:h,"aria-hidden":h||void 0,children:(0,G.jsx)(uf,{})})]}):(0,G.jsx)(fm,{authRejected:n,onToken:t})}function dm(){let e=X(e=>e.statsOpen),t=X(e=>e.toggleStats),n=X(e=>e.ingestOpen),r=X(e=>e.toggleIngest),i=Nf(X(e=>e.explainer)),a=(0,B.useRef)(null);return(0,G.jsxs)(`div`,{className:`first-run ${e||n?`has-inspector`:``}`,children:[(0,G.jsxs)(`div`,{className:`main-empty first-run-main`,children:[(0,G.jsxs)(`div`,{className:`toolbar first-run-actions`,children:[(0,G.jsx)(Q,{icon:`stats`,label:`Models & Usage`,on:e,title:`Show explanation timing, models and usage${i?`. ${i.label}: ${i.detail}.`:``}`,onClick:t}),(0,G.jsx)(Q,{icon:`storage`,label:`Ingest & Storage`,on:n,controls:`ingest-storage-inspector`,expanded:n,buttonRef:a,title:`Show collection state, queued observations, storage, and loss history`,onClick:r})]}),(0,G.jsxs)(`div`,{className:`main-empty-first`,children:[(0,G.jsx)(`p`,{children:`A report appears here when your agent runs.`}),(0,G.jsx)(`p`,{className:`muted`,children:`Start a run in Claude Code or Codex. Salidium reads the session it writes and turns it into what changed, what was checked, and what it flagged for a human.`}),(0,G.jsx)(`a`,{className:`link`,href:od,target:`_blank`,rel:`noreferrer`,children:`Read the documentation`})]})]}),e?(0,G.jsxs)(`aside`,{className:`inspector models-usage`,"aria-label":`Models & Usage`,children:[(0,G.jsxs)(`div`,{className:`inspector-head`,children:[(0,G.jsx)(Q,{icon:`panel`,title:`Hide Models & Usage`,onClick:t}),(0,G.jsx)(`span`,{className:`inspector-title`,children:`Models & Usage`})]}),(0,G.jsx)(`div`,{className:`models-usage-body scroll-fade`,children:(0,G.jsx)(qp,{})})]}):n?(0,G.jsx)(Vd,{onClose:r,returnFocusRef:a}):null]})}function fm({authRejected:e,onToken:t}){let[n,r]=(0,B.useState)(`idle`),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(!1),c=(0,B.useRef)(null),l=(0,B.useRef)(null);return(0,B.useEffect)(()=>{if(n===`idle`)return;let e=setTimeout(()=>r(`idle`),2400);return()=>clearTimeout(e)},[n]),(0,G.jsx)(`div`,{className:`gate`,children:(0,G.jsxs)(`div`,{className:`gate-inner`,children:[(0,G.jsx)(`h1`,{className:`gate-mark`,children:(0,G.jsx)(qs,{markSize:34})}),(0,G.jsx)(`p`,{className:`gate-lede`,role:e?`alert`:void 0,children:e?`The daemon restarted with a new token, so this page signed out.`:`This page needs the token your daemon is listening for.`}),(0,G.jsx)(`p`,{className:`gate-note`,children:`It is rotated every time the daemon starts, so it is never the same one twice.`}),(0,G.jsxs)(`div`,{className:`gate-cmd`,children:[(0,G.jsx)(`code`,{ref:c,children:om}),(0,G.jsxs)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>{let e=()=>{let e=c.current;if(e){let t=document.createRange();t.selectNodeContents(e);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)}r(`selected`)};if(!navigator.clipboard)return e();navigator.clipboard.writeText(om).then(()=>r(`copied`),e)},title:n===`copied`?`Copied`:`Copy the command`,children:[(0,G.jsx)(Z,{name:n===`copied`?`check`:`copy`}),(0,G.jsx)(`span`,{className:`sr-only`,children:n===`copied`?`Copied`:`Copy the command`})]})]}),(0,G.jsx)(`p`,{className:`gate-hint`,role:n===`idle`?void 0:`status`,children:n===`copied`?`Copied. Run it in a terminal; it opens this page with the token attached.`:n===`selected`?`This window cannot reach the clipboard, so the command is selected. ${sm} to take it.`:`Run it in a terminal; it opens this page with the token attached.`}),(0,G.jsxs)(`form`,{className:`gate-paste`,onSubmit:e=>{if(e.preventDefault(),i.trim()===``){l.current?.focus();return}let n=Hs(i);if(!n){s(!0);return}s(!1),Vs(n),t(n)},children:[(0,G.jsx)(`input`,{ref:l,className:`field gate-field`,value:i,onChange:e=>{a(e.target.value),s(!1)},placeholder:`or paste the token, or the URL carrying it`,"aria-label":`Daemon token, or a URL containing it`,"aria-invalid":o||void 0,spellCheck:!1,autoComplete:`off`}),(0,G.jsx)(`button`,{type:`submit`,className:`btn btn-accent`,children:`Connect`})]}),o&&(0,G.jsxs)(`p`,{className:`gate-bad`,role:`alert`,children:[`That is not a token. It is a long run of hex, and the URL the command prints carries one after `,(0,G.jsx)(`code`,{children:`#token=`}),`.`]})]})})}var pm=document.getElementById(`root`);pm&&(0,mo.createRoot)(pm).render((0,G.jsx)(B.StrictMode,{children:(0,G.jsx)(um,{})}));
|