@tonyclaw/agent-inspector 3.0.31 → 3.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/{CompareDrawer-DB2KggLE.js → CompareDrawer-DZHbDuyp.js} +1 -1
  3. package/.output/public/assets/{InspectorPet-CfwDw6kD.js → InspectorPet-CcB16ERo.js} +1 -1
  4. package/.output/public/assets/{ProxyViewerContainer-PcrO96_F.js → ProxyViewerContainer-CeL2S9LL.js} +32 -32
  5. package/.output/public/assets/{ReplayDialog-3Pl7EKjp.js → ReplayDialog-C9QR9m_y.js} +1 -1
  6. package/.output/public/assets/{RequestAnatomy-BcPjcHLX.js → RequestAnatomy-CUY83fwY.js} +1 -1
  7. package/.output/public/assets/{ResponseView-DOx51wV3.js → ResponseView-B_9r-cyE.js} +1 -1
  8. package/.output/public/assets/{StreamingChunkSequence-LkYJWM1A.js → StreamingChunkSequence--jQP7nh3.js} +1 -1
  9. package/.output/public/assets/{_sessionId-C0CA68QV.js → _sessionId-BknJcfp0.js} +1 -1
  10. package/.output/public/assets/{_sessionId-BSg32vC6.js → _sessionId-CsSBVKu4.js} +1 -1
  11. package/.output/public/assets/{index-FV5sxqx3.js → index-BLp02enl.js} +1 -1
  12. package/.output/public/assets/{index-BpBUqdAB.js → index-Bc0XyWoF.js} +1 -1
  13. package/.output/public/assets/{index-D93dCgAQ.js → index-CwydCGrP.js} +1 -1
  14. package/.output/public/assets/{index-hyQHZeQI.css → index-D17dU-mX.css} +1 -1
  15. package/.output/public/assets/{index-VUsF4nhf.js → index-YFDJS5sG.js} +3 -3
  16. package/.output/public/assets/{json-viewer-WctIbAh_.js → json-viewer-CeXNLNRL.js} +1 -1
  17. package/.output/public/assets/{jszip.min-DnSIoTix.js → jszip.min-D_dylbU1.js} +1 -1
  18. package/.output/server/{_sessionId-CyuJ6Kfl.mjs → _sessionId-CGdREF8T.mjs} +1 -1
  19. package/.output/server/{_sessionId-BHBK3VbF.mjs → _sessionId-CYC17d-B.mjs} +2 -2
  20. package/.output/server/_ssr/{CompareDrawer-27amlv_a.mjs → CompareDrawer-DeMqLFuI.mjs} +2 -2
  21. package/.output/server/_ssr/{InspectorPet-CQnGXfLs.mjs → InspectorPet-BAO2jCB7.mjs} +1 -1
  22. package/.output/server/_ssr/{ProxyViewerContainer-DlAl0uF-.mjs → ProxyViewerContainer-Ba1qfnbK.mjs} +41 -10
  23. package/.output/server/_ssr/{ReplayDialog-5m2jtlLa.mjs → ReplayDialog-CpUv_dIy.mjs} +3 -3
  24. package/.output/server/_ssr/{RequestAnatomy--1WtQNY9.mjs → RequestAnatomy-CRq6ZnER.mjs} +2 -2
  25. package/.output/server/_ssr/{ResponseView-CgbqS8sr.mjs → ResponseView-uqImoWhn.mjs} +2 -2
  26. package/.output/server/_ssr/{StreamingChunkSequence-BwpnopWx.mjs → StreamingChunkSequence-DEGDwgVR.mjs} +2 -2
  27. package/.output/server/_ssr/{index-CNVi1TzT.mjs → index-BkPapItF.mjs} +2 -2
  28. package/.output/server/_ssr/{index-DMCjH_4V.mjs → index-CE7xR-Gg.mjs} +1 -1
  29. package/.output/server/_ssr/index.mjs +2 -2
  30. package/.output/server/_ssr/{json-viewer-DNGN2uoe.mjs → json-viewer-C5CvnZkM.mjs} +2 -2
  31. package/.output/server/_ssr/{router-CgsqLnk5.mjs → router-CA2uwvv6.mjs} +6 -6
  32. package/.output/server/{_tanstack-start-manifest_v-BH5f_kWV.mjs → _tanstack-start-manifest_v-DMn6yvSV.mjs} +1 -1
  33. package/.output/server/index.mjs +84 -84
  34. package/package.json +1 -1
  35. package/src/components/pi-agent/PiAgentPanel.tsx +25 -1
  36. package/src/components/pi-agent/piAgentChatLogic.ts +24 -0
@@ -1,49 +1,49 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-DnSIoTix.js","assets/index-VUsF4nhf.js","assets/CompareDrawer-DB2KggLE.js","assets/InspectorPet-CfwDw6kD.js","assets/ReplayDialog-3Pl7EKjp.js","assets/ResponseView-DOx51wV3.js","assets/RequestAnatomy-BcPjcHLX.js","assets/StreamingChunkSequence-LkYJWM1A.js","assets/json-viewer-WctIbAh_.js","assets/index-FV5sxqx3.js"])))=>i.map(i=>d[i]);
2
- import{u as Bt,a as Xd,r as c,j as r,_ as Gt,b as Cg,c as Ti,p as Tg,T as Eg,n as Rg,d as Pg,e as Mg,f as Ei,U as Ig,g as Qd,h as Bo,i as Os,k as $,B as ee,l as Jn,m as ef,o as Me,q as tf,s as Pt,t as Ag,L as co,v as nf,w as Og,x as uo,C as sf,y as zg}from"./index-VUsF4nhf.js";var Pc;function O(e,t,n){function s(l,u){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:u,constr:a,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,u);const d=a.prototype,f=Object.keys(d);for(let p=0;p<f.length;p++){const m=f[p];m in l||(l[m]=d[m].bind(l))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(l){var u;const d=n?.Parent?new i:this;s(d,l),(u=d._zod).deferred??(u.deferred=[]);for(const f of d._zod.deferred)f();return d}return Object.defineProperty(a,"init",{value:s}),Object.defineProperty(a,Symbol.hasInstance,{value:l=>n?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}class xs extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class rf extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Pc=globalThis).__zod_globalConfig??(Pc.__zod_globalConfig={});const ul=globalThis.__zod_globalConfig;function on(e){return ul}function of(e){const t=Object.values(e).filter(s=>typeof s=="number");return Object.entries(e).filter(([s,o])=>t.indexOf(+s)===-1).map(([s,o])=>o)}function va(e,t){return typeof t=="bigint"?t.toString():t}function Vo(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function dl(e){return e==null}function fl(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Lg(e,t){const n=e/t,s=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-s)<o?0:n-s}const Mc=Symbol("evaluating");function Ce(e,t,n){let s;Object.defineProperty(e,t,{get(){if(s!==Mc)return s===void 0&&(s=Mc,s=n()),s},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Yn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Nn(...e){const t={};for(const n of e){const s=Object.getOwnPropertyDescriptors(n);Object.assign(t,s)}return Object.defineProperties({},t)}function Ic(e){return JSON.stringify(e)}function $g(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const af="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function tr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Dg=Vo(()=>{if(ul.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Ss(e){if(tr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(tr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function lf(e){return Ss(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Fg=new Set(["string","number","symbol"]);function _s(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cn(e,t,n){const s=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(s._zod.parent=e),s}function re(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new 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 Ug(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Bg={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Vg(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=Nn(e._zod.def,{get shape(){const a={};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(a[l]=n.shape[l])}return Yn(this,"shape",a),a},checks:[]});return Cn(e,i)}function qg(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=Nn(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete a[l]}return Yn(this,"shape",a),a},checks:[]});return Cn(e,i)}function Hg(e,t){if(!Ss(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const a in t)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=Nn(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Yn(this,"shape",i),i}});return Cn(e,o)}function Wg(e,t){if(!Ss(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Nn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Yn(this,"shape",s),s}});return Cn(e,n)}function Zg(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Nn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return Yn(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Cn(e,n)}function Kg(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const a=Nn(t._zod.def,{get shape(){const l=t._zod.def.shape,u={...l};if(n)for(const d in n){if(!(d in l))throw new Error(`Unrecognized key: "${d}"`);n[d]&&(u[d]=e?new e({type:"optional",innerType:l[d]}):l[d])}else for(const d in l)u[d]=e?new e({type:"optional",innerType:l[d]}):l[d];return Yn(this,"shape",u),u},checks:[]});return Cn(t,a)}function Gg(e,t,n){const s=Nn(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const a in n){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=new e({type:"nonoptional",innerType:o[a]}))}else for(const a in o)i[a]=new e({type:"nonoptional",innerType:o[a]});return Yn(this,"shape",i),i}});return Cn(t,s)}function ms(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 Jg(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 hs(e,t){return t.map(n=>{var s;return(s=n).path??(s.path=[]),n.path.unshift(e),n})}function Sr(e){return typeof e=="string"?e:e?.message}function an(e,t,n){const s=e.message?e.message:Sr(e.inst?._zod.def?.error?.(e))??Sr(t?.error?.(e))??Sr(n.customError?.(e))??Sr(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:a,...l}=e;return l.path??(l.path=[]),l.message=s,t?.reportInput&&(l.input=a),l}function pl(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function nr(...e){const[t,n,s]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:s}:{...t}}const cf=(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,va,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},uf=O("$ZodError",cf),df=O("$ZodError",cf,{Parent:Error});function Yg(e,t=n=>n.message){const n={},s=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):s.push(t(o));return{formErrors:s,fieldErrors:n}}function Xg(e,t=n=>n.message){const n={_errors:[]},s=(o,i=[])=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(l=>s({issues:l},[...i,...a.path]));else if(a.code==="invalid_key")s({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")s({issues:a.issues},[...i,...a.path]);else{const l=[...i,...a.path];if(l.length===0)n._errors.push(t(a));else{let u=n,d=0;for(;d<l.length;){const f=l[d];d===l.length-1?(u[f]=u[f]||{_errors:[]},u[f]._errors.push(t(a))):u[f]=u[f]||{_errors:[]},u=u[f],d++}}}};return s(e),n}const ml=e=>(t,n,s,o)=>{const i=s?{...s,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new xs;if(a.issues.length){const l=new(o?.Err??e)(a.issues.map(u=>an(u,i,on())));throw af(l,o?.callee),l}return a.value},hl=e=>async(t,n,s,o)=>{const i=s?{...s,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const l=new(o?.Err??e)(a.issues.map(u=>an(u,i,on())));throw af(l,o?.callee),l}return a.value},qo=e=>(t,n,s)=>{const o=s?{...s,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new xs;return i.issues.length?{success:!1,error:new(e??uf)(i.issues.map(a=>an(a,o,on())))}:{success:!0,data:i.value}},Qg=qo(df),Ho=e=>async(t,n,s)=>{const o=s?{...s,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>an(a,o,on())))}:{success:!0,data:i.value}},ex=Ho(df),tx=e=>(t,n,s)=>{const o=s?{...s,direction:"backward"}:{direction:"backward"};return ml(e)(t,n,o)},nx=e=>(t,n,s)=>ml(e)(t,n,s),sx=e=>async(t,n,s)=>{const o=s?{...s,direction:"backward"}:{direction:"backward"};return hl(e)(t,n,o)},rx=e=>async(t,n,s)=>hl(e)(t,n,s),ox=e=>(t,n,s)=>{const o=s?{...s,direction:"backward"}:{direction:"backward"};return qo(e)(t,n,o)},ix=e=>(t,n,s)=>qo(e)(t,n,s),ax=e=>async(t,n,s)=>{const o=s?{...s,direction:"backward"}:{direction:"backward"};return Ho(e)(t,n,o)},lx=e=>async(t,n,s)=>Ho(e)(t,n,s),cx=/^[cC][0-9a-z]{6,}$/,ux=/^[0-9a-z]+$/,dx=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,fx=/^[0-9a-vA-V]{20}$/,px=/^[A-Za-z0-9]{27}$/,mx=/^[a-zA-Z0-9_-]{21}$/,hx=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gx=/^([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})$/,Ac=e=>e?new 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)$/,xx=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,bx="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function vx(){return new RegExp(bx,"u")}const yx=/^(?:(?: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])$/,wx=/^(([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}|:))$/,jx=/^((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])$/,kx=/^(([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])$/,Sx=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ff=/^[A-Za-z0-9_-]*$/,_x=/^https?$/,Nx=/^\+[1-9]\d{6,14}$/,pf="(?:(?:\\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])))",Cx=new RegExp(`^${pf}$`);function mf(e){const 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 Tx(e){return new RegExp(`^${mf(e)}$`)}function Ex(e){const t=mf({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const s=`${t}(?:${n.join("|")})`;return new RegExp(`^${pf}T(?:${s})$`)}const Rx=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Px=/^-?\d+$/,hf=/^-?\d+(?:\.\d+)?$/,Mx=/^(?:true|false)$/i,Ix=/^null$/i,Ax=/^[^A-Z]*$/,Ox=/^[^a-z]*$/,ut=O("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),gf={number:"number",bigint:"bigint",object:"date"},xf=O("$ZodCheckLessThan",(e,t)=>{ut.init(e,t);const n=gf[typeof t.value];e._zod.onattach.push(s=>{const o=s._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value<=t.value:s.value<t.value)||s.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),bf=O("$ZodCheckGreaterThan",(e,t)=>{ut.init(e,t);const n=gf[typeof t.value];e._zod.onattach.push(s=>{const o=s._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value>=t.value:s.value>t.value)||s.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),zx=O("$ZodCheckMultipleOf",(e,t)=>{ut.init(e,t),e._zod.onattach.push(n=>{var s;(s=n._zod.bag).multipleOf??(s.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Lg(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})}}),Lx=O("$ZodCheckNumberFormat",(e,t)=>{ut.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),s=n?"int":"number",[o,i]=Bg[t.format];e._zod.onattach.push(a=>{const l=a._zod.bag;l.format=t.format,l.minimum=o,l.maximum=i,n&&(l.pattern=Px)}),e._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:s,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort});return}}l<o&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),l>i&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),$x=O("$ZodCheckMaxLength",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!dl(o)&&o.length!==void 0}),e._zod.onattach.push(s=>{const o=s._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(s._zod.bag.maximum=t.maximum)}),e._zod.check=s=>{const o=s.value;if(o.length<=t.maximum)return;const a=pl(o);s.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Dx=O("$ZodCheckMinLength",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!dl(o)&&o.length!==void 0}),e._zod.onattach.push(s=>{const o=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(s._zod.bag.minimum=t.minimum)}),e._zod.check=s=>{const o=s.value;if(o.length>=t.minimum)return;const a=pl(o);s.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Fx=O("$ZodCheckLengthEquals",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!dl(o)&&o.length!==void 0}),e._zod.onattach.push(s=>{const o=s._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=s=>{const o=s.value,i=o.length;if(i===t.length)return;const a=pl(o),l=i>t.length;s.issues.push({origin:a,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:s.value,inst:e,continue:!t.abort})}}),Wo=O("$ZodCheckStringFormat",(e,t)=>{var n,s;ut.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(s=e._zod).check??(s.check=()=>{})}),Ux=O("$ZodCheckRegex",(e,t)=>{Wo.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})}}),Bx=O("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ax),Wo.init(e,t)}),Vx=O("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ox),Wo.init(e,t)}),qx=O("$ZodCheckIncludes",(e,t)=>{ut.init(e,t);const n=_s(t.includes),s=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=s,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(s)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Hx=O("$ZodCheckStartsWith",(e,t)=>{ut.init(e,t);const n=new RegExp(`^${_s(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=s=>{s.value.startsWith(t.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:s.value,inst:e,continue:!t.abort})}}),Wx=O("$ZodCheckEndsWith",(e,t)=>{ut.init(e,t);const n=new RegExp(`.*${_s(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=s=>{s.value.endsWith(t.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:s.value,inst:e,continue:!t.abort})}}),Zx=O("$ZodCheckOverwrite",(e,t)=>{ut.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Kx{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const s=t.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-D_dylbU1.js","assets/index-YFDJS5sG.js","assets/CompareDrawer-DZHbDuyp.js","assets/InspectorPet-CcB16ERo.js","assets/ReplayDialog-C9QR9m_y.js","assets/ResponseView-B_9r-cyE.js","assets/RequestAnatomy-CUY83fwY.js","assets/StreamingChunkSequence--jQP7nh3.js","assets/json-viewer-CeXNLNRL.js","assets/index-BLp02enl.js"])))=>i.map(i=>d[i]);
2
+ import{u as Bt,a as Xd,r as c,j as r,_ as Gt,b as Cg,c as Ti,p as Tg,T as Eg,n as Rg,d as Pg,e as Ig,f as Ei,U as Mg,g as Qd,h as Bo,i as Os,k as $,B as ee,l as Jn,m as ep,o as Ie,q as tp,s as Pt,t as Ag,L as co,v as np,w as Og,x as uo,C as sp,y as zg}from"./index-YFDJS5sG.js";var Pc;function O(e,t,n){function s(l,u){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:u,constr:a,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,u);const d=a.prototype,p=Object.keys(d);for(let f=0;f<p.length;f++){const m=p[f];m in l||(l[m]=d[m].bind(l))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(l){var u;const d=n?.Parent?new i:this;s(d,l),(u=d._zod).deferred??(u.deferred=[]);for(const p of d._zod.deferred)p();return d}return Object.defineProperty(a,"init",{value:s}),Object.defineProperty(a,Symbol.hasInstance,{value:l=>n?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}class xs extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class rp extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Pc=globalThis).__zod_globalConfig??(Pc.__zod_globalConfig={});const ul=globalThis.__zod_globalConfig;function on(e){return ul}function op(e){const t=Object.values(e).filter(s=>typeof s=="number");return Object.entries(e).filter(([s,o])=>t.indexOf(+s)===-1).map(([s,o])=>o)}function va(e,t){return typeof t=="bigint"?t.toString():t}function Vo(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function dl(e){return e==null}function pl(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Lg(e,t){const n=e/t,s=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-s)<o?0:n-s}const Ic=Symbol("evaluating");function Ce(e,t,n){let s;Object.defineProperty(e,t,{get(){if(s!==Ic)return s===void 0&&(s=Ic,s=n()),s},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Yn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Nn(...e){const t={};for(const n of e){const s=Object.getOwnPropertyDescriptors(n);Object.assign(t,s)}return Object.defineProperties({},t)}function Mc(e){return JSON.stringify(e)}function $g(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const ip="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function tr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Dg=Vo(()=>{if(ul.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function _s(e){if(tr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(tr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function ap(e){return _s(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Fg=new Set(["string","number","symbol"]);function Ss(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cn(e,t,n){const s=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(s._zod.parent=e),s}function re(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new 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 Ug(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Bg={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Vg(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=Nn(e._zod.def,{get shape(){const a={};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(a[l]=n.shape[l])}return Yn(this,"shape",a),a},checks:[]});return Cn(e,i)}function qg(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=Nn(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete a[l]}return Yn(this,"shape",a),a},checks:[]});return Cn(e,i)}function Hg(e,t){if(!_s(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const a in t)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=Nn(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Yn(this,"shape",i),i}});return Cn(e,o)}function Wg(e,t){if(!_s(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Nn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Yn(this,"shape",s),s}});return Cn(e,n)}function Zg(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Nn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return Yn(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Cn(e,n)}function Kg(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const a=Nn(t._zod.def,{get shape(){const l=t._zod.def.shape,u={...l};if(n)for(const d in n){if(!(d in l))throw new Error(`Unrecognized key: "${d}"`);n[d]&&(u[d]=e?new e({type:"optional",innerType:l[d]}):l[d])}else for(const d in l)u[d]=e?new e({type:"optional",innerType:l[d]}):l[d];return Yn(this,"shape",u),u},checks:[]});return Cn(t,a)}function Gg(e,t,n){const s=Nn(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const a in n){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=new e({type:"nonoptional",innerType:o[a]}))}else for(const a in o)i[a]=new e({type:"nonoptional",innerType:o[a]});return Yn(this,"shape",i),i}});return Cn(t,s)}function ms(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 Jg(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 hs(e,t){return t.map(n=>{var s;return(s=n).path??(s.path=[]),n.path.unshift(e),n})}function _r(e){return typeof e=="string"?e:e?.message}function an(e,t,n){const s=e.message?e.message:_r(e.inst?._zod.def?.error?.(e))??_r(t?.error?.(e))??_r(n.customError?.(e))??_r(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:a,...l}=e;return l.path??(l.path=[]),l.message=s,t?.reportInput&&(l.input=a),l}function fl(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function nr(...e){const[t,n,s]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:s}:{...t}}const lp=(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,va,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},cp=O("$ZodError",lp),up=O("$ZodError",lp,{Parent:Error});function Yg(e,t=n=>n.message){const n={},s=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):s.push(t(o));return{formErrors:s,fieldErrors:n}}function Xg(e,t=n=>n.message){const n={_errors:[]},s=(o,i=[])=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(l=>s({issues:l},[...i,...a.path]));else if(a.code==="invalid_key")s({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")s({issues:a.issues},[...i,...a.path]);else{const l=[...i,...a.path];if(l.length===0)n._errors.push(t(a));else{let u=n,d=0;for(;d<l.length;){const p=l[d];d===l.length-1?(u[p]=u[p]||{_errors:[]},u[p]._errors.push(t(a))):u[p]=u[p]||{_errors:[]},u=u[p],d++}}}};return s(e),n}const ml=e=>(t,n,s,o)=>{const i=s?{...s,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new xs;if(a.issues.length){const l=new(o?.Err??e)(a.issues.map(u=>an(u,i,on())));throw ip(l,o?.callee),l}return a.value},hl=e=>async(t,n,s,o)=>{const i=s?{...s,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const l=new(o?.Err??e)(a.issues.map(u=>an(u,i,on())));throw ip(l,o?.callee),l}return a.value},qo=e=>(t,n,s)=>{const o=s?{...s,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new xs;return i.issues.length?{success:!1,error:new(e??cp)(i.issues.map(a=>an(a,o,on())))}:{success:!0,data:i.value}},Qg=qo(up),Ho=e=>async(t,n,s)=>{const o=s?{...s,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>an(a,o,on())))}:{success:!0,data:i.value}},ex=Ho(up),tx=e=>(t,n,s)=>{const o=s?{...s,direction:"backward"}:{direction:"backward"};return ml(e)(t,n,o)},nx=e=>(t,n,s)=>ml(e)(t,n,s),sx=e=>async(t,n,s)=>{const o=s?{...s,direction:"backward"}:{direction:"backward"};return hl(e)(t,n,o)},rx=e=>async(t,n,s)=>hl(e)(t,n,s),ox=e=>(t,n,s)=>{const o=s?{...s,direction:"backward"}:{direction:"backward"};return qo(e)(t,n,o)},ix=e=>(t,n,s)=>qo(e)(t,n,s),ax=e=>async(t,n,s)=>{const o=s?{...s,direction:"backward"}:{direction:"backward"};return Ho(e)(t,n,o)},lx=e=>async(t,n,s)=>Ho(e)(t,n,s),cx=/^[cC][0-9a-z]{6,}$/,ux=/^[0-9a-z]+$/,dx=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,px=/^[0-9a-vA-V]{20}$/,fx=/^[A-Za-z0-9]{27}$/,mx=/^[a-zA-Z0-9_-]{21}$/,hx=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gx=/^([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})$/,Ac=e=>e?new 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)$/,xx=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,bx="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function vx(){return new RegExp(bx,"u")}const yx=/^(?:(?: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])$/,wx=/^(([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}|:))$/,jx=/^((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])$/,kx=/^(([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])$/,_x=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,dp=/^[A-Za-z0-9_-]*$/,Sx=/^https?$/,Nx=/^\+[1-9]\d{6,14}$/,pp="(?:(?:\\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])))",Cx=new RegExp(`^${pp}$`);function fp(e){const 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 Tx(e){return new RegExp(`^${fp(e)}$`)}function Ex(e){const t=fp({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const s=`${t}(?:${n.join("|")})`;return new RegExp(`^${pp}T(?:${s})$`)}const Rx=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Px=/^-?\d+$/,mp=/^-?\d+(?:\.\d+)?$/,Ix=/^(?:true|false)$/i,Mx=/^null$/i,Ax=/^[^A-Z]*$/,Ox=/^[^a-z]*$/,ut=O("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),hp={number:"number",bigint:"bigint",object:"date"},gp=O("$ZodCheckLessThan",(e,t)=>{ut.init(e,t);const n=hp[typeof t.value];e._zod.onattach.push(s=>{const o=s._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value<=t.value:s.value<t.value)||s.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xp=O("$ZodCheckGreaterThan",(e,t)=>{ut.init(e,t);const n=hp[typeof t.value];e._zod.onattach.push(s=>{const o=s._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value>=t.value:s.value>t.value)||s.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),zx=O("$ZodCheckMultipleOf",(e,t)=>{ut.init(e,t),e._zod.onattach.push(n=>{var s;(s=n._zod.bag).multipleOf??(s.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Lg(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})}}),Lx=O("$ZodCheckNumberFormat",(e,t)=>{ut.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),s=n?"int":"number",[o,i]=Bg[t.format];e._zod.onattach.push(a=>{const l=a._zod.bag;l.format=t.format,l.minimum=o,l.maximum=i,n&&(l.pattern=Px)}),e._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:s,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort});return}}l<o&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),l>i&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),$x=O("$ZodCheckMaxLength",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!dl(o)&&o.length!==void 0}),e._zod.onattach.push(s=>{const o=s._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(s._zod.bag.maximum=t.maximum)}),e._zod.check=s=>{const o=s.value;if(o.length<=t.maximum)return;const a=fl(o);s.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Dx=O("$ZodCheckMinLength",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!dl(o)&&o.length!==void 0}),e._zod.onattach.push(s=>{const o=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(s._zod.bag.minimum=t.minimum)}),e._zod.check=s=>{const o=s.value;if(o.length>=t.minimum)return;const a=fl(o);s.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Fx=O("$ZodCheckLengthEquals",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!dl(o)&&o.length!==void 0}),e._zod.onattach.push(s=>{const o=s._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=s=>{const o=s.value,i=o.length;if(i===t.length)return;const a=fl(o),l=i>t.length;s.issues.push({origin:a,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:s.value,inst:e,continue:!t.abort})}}),Wo=O("$ZodCheckStringFormat",(e,t)=>{var n,s;ut.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(s=e._zod).check??(s.check=()=>{})}),Ux=O("$ZodCheckRegex",(e,t)=>{Wo.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})}}),Bx=O("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ax),Wo.init(e,t)}),Vx=O("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ox),Wo.init(e,t)}),qx=O("$ZodCheckIncludes",(e,t)=>{ut.init(e,t);const n=Ss(t.includes),s=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=s,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(s)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Hx=O("$ZodCheckStartsWith",(e,t)=>{ut.init(e,t);const n=new RegExp(`^${Ss(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=s=>{s.value.startsWith(t.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:s.value,inst:e,continue:!t.abort})}}),Wx=O("$ZodCheckEndsWith",(e,t)=>{ut.init(e,t);const n=new RegExp(`.*${Ss(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=s=>{s.value.endsWith(t.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:s.value,inst:e,continue:!t.abort})}}),Zx=O("$ZodCheckOverwrite",(e,t)=>{ut.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Kx{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const s=t.split(`
3
3
  `).filter(a=>a),o=Math.min(...s.map(a=>a.length-a.trimStart().length)),i=s.map(a=>a.slice(o)).map(a=>" ".repeat(this.indent*2)+a);for(const a of i)this.content.push(a)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,o.join(`
4
- `))}}const Gx={major:4,minor:4,patch:3},Le=O("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Gx;const s=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&s.unshift(e);for(const o of s)for(const i of o._zod.onattach)i(e);if(s.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,l,u)=>{let d=ms(a),f;for(const p of l){if(p._zod.def.when){if(Jg(a)||!p._zod.def.when(a))continue}else if(d)continue;const m=a.issues.length,h=p._zod.check(a);if(h instanceof Promise&&u?.async===!1)throw new xs;if(f||h instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await h,a.issues.length!==m&&(d||(d=ms(a,m)))});else{if(a.issues.length===m)continue;d||(d=ms(a,m))}}return f?f.then(()=>a):a},i=(a,l,u)=>{if(ms(a))return a.aborted=!0,a;const d=o(l,s,u);if(d instanceof Promise){if(u.async===!1)throw new xs;return d.then(f=>e._zod.parse(f,u))}return e._zod.parse(d,u)};e._zod.run=(a,l)=>{if(l.skipChecks)return e._zod.parse(a,l);if(l.direction==="backward"){const d=e._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(f=>i(f,a,l)):i(d,a,l)}const u=e._zod.parse(a,l);if(u instanceof Promise){if(l.async===!1)throw new xs;return u.then(d=>o(d,s,l))}return o(u,s,l)}}Ce(e,"~standard",()=>({validate:o=>{try{const i=Qg(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return ex(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),gl=O("$ZodString",(e,t)=>{Le.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Rx(e._zod.bag),e._zod.parse=(n,s)=>{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}}),De=O("$ZodStringFormat",(e,t)=>{Wo.init(e,t),gl.init(e,t)}),Jx=O("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=gx),De.init(e,t)}),Yx=O("$ZodUUID",(e,t)=>{if(t.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(s===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ac(s))}else t.pattern??(t.pattern=Ac());De.init(e,t)}),Xx=O("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=xx),De.init(e,t)}),Qx=O("$ZodURL",(e,t)=>{De.init(e,t),e._zod.check=n=>{try{const s=n.value.trim();if(!t.normalize&&t.protocol?.source===_x.source&&!/^https?:\/\//i.test(s)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const o=new URL(s);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.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(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=s;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),e1=O("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=vx()),De.init(e,t)}),t1=O("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=mx),De.init(e,t)}),n1=O("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=cx),De.init(e,t)}),s1=O("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ux),De.init(e,t)}),r1=O("$ZodULID",(e,t)=>{t.pattern??(t.pattern=dx),De.init(e,t)}),o1=O("$ZodXID",(e,t)=>{t.pattern??(t.pattern=fx),De.init(e,t)}),i1=O("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=px),De.init(e,t)}),a1=O("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ex(t)),De.init(e,t)}),l1=O("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Cx),De.init(e,t)}),c1=O("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Tx(t)),De.init(e,t)}),u1=O("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=hx),De.init(e,t)}),d1=O("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=yx),De.init(e,t),e._zod.bag.format="ipv4"}),f1=O("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=wx),De.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})}}}),p1=O("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=jx),De.init(e,t)}),m1=O("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=kx),De.init(e,t),e._zod.check=n=>{const s=n.value.split("/");try{if(s.length!==2)throw new Error;const[o,i]=s;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function vf(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const h1=O("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Sx),De.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{vf(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function g1(e){if(!ff.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return vf(n)}const x1=O("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ff),De.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{g1(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),b1=O("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Nx),De.init(e,t)});function v1(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[s]=n;if(!s)return!1;const o=JSON.parse(atob(s));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const y1=O("$ZodJWT",(e,t)=>{De.init(e,t),e._zod.check=n=>{v1(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),yf=O("$ZodNumber",(e,t)=>{Le.init(e,t),e._zod.pattern=e._zod.bag.pattern??hf,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),w1=O("$ZodNumberFormat",(e,t)=>{Lx.init(e,t),yf.init(e,t)}),j1=O("$ZodBoolean",(e,t)=>{Le.init(e,t),e._zod.pattern=Mx,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),k1=O("$ZodNull",(e,t)=>{Le.init(e,t),e._zod.pattern=Ix,e._zod.values=new Set([null]),e._zod.parse=(n,s)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),S1=O("$ZodUnknown",(e,t)=>{Le.init(e,t),e._zod.parse=n=>n}),_1=O("$ZodNever",(e,t)=>{Le.init(e,t),e._zod.parse=(n,s)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Oc(e,t,n){e.issues.length&&t.issues.push(...hs(n,e.issues)),t.value[n]=e.value}const N1=O("$ZodArray",(e,t)=>{Le.init(e,t),e._zod.parse=(n,s)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let a=0;a<o.length;a++){const l=o[a],u=t.element._zod.run({value:l,issues:[]},s);u instanceof Promise?i.push(u.then(d=>Oc(d,n,a))):Oc(u,n,a)}return i.length?Promise.all(i).then(()=>n):n}});function fo(e,t,n,s,o,i){const a=n in s;if(e.issues.length){if(o&&i&&!a)return;t.issues.push(...hs(n,e.issues))}if(!a&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?a&&(t.value[n]=void 0):t.value[n]=e.value}function wf(e){const t=Object.keys(e.shape);for(const s of t)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${s}": expected a Zod schema`);const n=Ug(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function jf(e,t,n,s,o,i){const a=[],l=o.keySet,u=o.catchall._zod,d=u.def.type,f=u.optin==="optional",p=u.optout==="optional";for(const m in t){if(m==="__proto__"||l.has(m))continue;if(d==="never"){a.push(m);continue}const h=u.run({value:t[m],issues:[]},s);h instanceof Promise?e.push(h.then(g=>fo(g,n,m,t,f,p))):fo(h,n,m,t,f,p)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const C1=O("$ZodObject",(e,t)=>{if(Le.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const u={...l};return Object.defineProperty(t,"shape",{value:u}),u}})}const s=Vo(()=>wf(t));Ce(e._zod,"propValues",()=>{const l=t.shape,u={};for(const d in l){const f=l[d]._zod;if(f.values){u[d]??(u[d]=new Set);for(const p of f.values)u[d].add(p)}}return u});const o=tr,i=t.catchall;let a;e._zod.parse=(l,u)=>{a??(a=s.value);const d=l.value;if(!o(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value={};const f=[],p=a.shape;for(const m of a.keys){const h=p[m],g=h._zod.optin==="optional",y=h._zod.optout==="optional",b=h._zod.run({value:d[m],issues:[]},u);b instanceof Promise?f.push(b.then(w=>fo(w,l,m,d,g,y))):fo(b,l,m,d,g,y)}return i?jf(f,d,l,u,s.value,e):f.length?Promise.all(f).then(()=>l):l}}),T1=O("$ZodObjectJIT",(e,t)=>{C1.init(e,t);const n=e._zod.parse,s=Vo(()=>wf(t)),o=m=>{const h=new Kx(["shape","payload","ctx"]),g=s.value,y=j=>{const S=Ic(j);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};h.write("const input = payload.value;");const b=Object.create(null);let w=0;for(const j of g.keys)b[j]=`key_${w++}`;h.write("const newResult = {};");for(const j of g.keys){const S=b[j],k=Ic(j),_=m[j],C=_?._zod?.optin==="optional",I=_?._zod?.optout==="optional";h.write(`const ${S} = ${y(j)};`),C&&I?h.write(`
5
- if (${S}.issues.length) {
4
+ `))}}const Gx={major:4,minor:4,patch:3},Le=O("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Gx;const s=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&s.unshift(e);for(const o of s)for(const i of o._zod.onattach)i(e);if(s.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,l,u)=>{let d=ms(a),p;for(const f of l){if(f._zod.def.when){if(Jg(a)||!f._zod.def.when(a))continue}else if(d)continue;const m=a.issues.length,h=f._zod.check(a);if(h instanceof Promise&&u?.async===!1)throw new xs;if(p||h instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await h,a.issues.length!==m&&(d||(d=ms(a,m)))});else{if(a.issues.length===m)continue;d||(d=ms(a,m))}}return p?p.then(()=>a):a},i=(a,l,u)=>{if(ms(a))return a.aborted=!0,a;const d=o(l,s,u);if(d instanceof Promise){if(u.async===!1)throw new xs;return d.then(p=>e._zod.parse(p,u))}return e._zod.parse(d,u)};e._zod.run=(a,l)=>{if(l.skipChecks)return e._zod.parse(a,l);if(l.direction==="backward"){const d=e._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(p=>i(p,a,l)):i(d,a,l)}const u=e._zod.parse(a,l);if(u instanceof Promise){if(l.async===!1)throw new xs;return u.then(d=>o(d,s,l))}return o(u,s,l)}}Ce(e,"~standard",()=>({validate:o=>{try{const i=Qg(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return ex(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),gl=O("$ZodString",(e,t)=>{Le.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Rx(e._zod.bag),e._zod.parse=(n,s)=>{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}}),De=O("$ZodStringFormat",(e,t)=>{Wo.init(e,t),gl.init(e,t)}),Jx=O("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=gx),De.init(e,t)}),Yx=O("$ZodUUID",(e,t)=>{if(t.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(s===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ac(s))}else t.pattern??(t.pattern=Ac());De.init(e,t)}),Xx=O("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=xx),De.init(e,t)}),Qx=O("$ZodURL",(e,t)=>{De.init(e,t),e._zod.check=n=>{try{const s=n.value.trim();if(!t.normalize&&t.protocol?.source===Sx.source&&!/^https?:\/\//i.test(s)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const o=new URL(s);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.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(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=s;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),e1=O("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=vx()),De.init(e,t)}),t1=O("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=mx),De.init(e,t)}),n1=O("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=cx),De.init(e,t)}),s1=O("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ux),De.init(e,t)}),r1=O("$ZodULID",(e,t)=>{t.pattern??(t.pattern=dx),De.init(e,t)}),o1=O("$ZodXID",(e,t)=>{t.pattern??(t.pattern=px),De.init(e,t)}),i1=O("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=fx),De.init(e,t)}),a1=O("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ex(t)),De.init(e,t)}),l1=O("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Cx),De.init(e,t)}),c1=O("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Tx(t)),De.init(e,t)}),u1=O("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=hx),De.init(e,t)}),d1=O("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=yx),De.init(e,t),e._zod.bag.format="ipv4"}),p1=O("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=wx),De.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})}}}),f1=O("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=jx),De.init(e,t)}),m1=O("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=kx),De.init(e,t),e._zod.check=n=>{const s=n.value.split("/");try{if(s.length!==2)throw new Error;const[o,i]=s;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function bp(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const h1=O("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=_x),De.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{bp(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function g1(e){if(!dp.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return bp(n)}const x1=O("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=dp),De.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{g1(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),b1=O("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Nx),De.init(e,t)});function v1(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[s]=n;if(!s)return!1;const o=JSON.parse(atob(s));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const y1=O("$ZodJWT",(e,t)=>{De.init(e,t),e._zod.check=n=>{v1(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),vp=O("$ZodNumber",(e,t)=>{Le.init(e,t),e._zod.pattern=e._zod.bag.pattern??mp,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),w1=O("$ZodNumberFormat",(e,t)=>{Lx.init(e,t),vp.init(e,t)}),j1=O("$ZodBoolean",(e,t)=>{Le.init(e,t),e._zod.pattern=Ix,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),k1=O("$ZodNull",(e,t)=>{Le.init(e,t),e._zod.pattern=Mx,e._zod.values=new Set([null]),e._zod.parse=(n,s)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),_1=O("$ZodUnknown",(e,t)=>{Le.init(e,t),e._zod.parse=n=>n}),S1=O("$ZodNever",(e,t)=>{Le.init(e,t),e._zod.parse=(n,s)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Oc(e,t,n){e.issues.length&&t.issues.push(...hs(n,e.issues)),t.value[n]=e.value}const N1=O("$ZodArray",(e,t)=>{Le.init(e,t),e._zod.parse=(n,s)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let a=0;a<o.length;a++){const l=o[a],u=t.element._zod.run({value:l,issues:[]},s);u instanceof Promise?i.push(u.then(d=>Oc(d,n,a))):Oc(u,n,a)}return i.length?Promise.all(i).then(()=>n):n}});function po(e,t,n,s,o,i){const a=n in s;if(e.issues.length){if(o&&i&&!a)return;t.issues.push(...hs(n,e.issues))}if(!a&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?a&&(t.value[n]=void 0):t.value[n]=e.value}function yp(e){const t=Object.keys(e.shape);for(const s of t)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${s}": expected a Zod schema`);const n=Ug(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function wp(e,t,n,s,o,i){const a=[],l=o.keySet,u=o.catchall._zod,d=u.def.type,p=u.optin==="optional",f=u.optout==="optional";for(const m in t){if(m==="__proto__"||l.has(m))continue;if(d==="never"){a.push(m);continue}const h=u.run({value:t[m],issues:[]},s);h instanceof Promise?e.push(h.then(g=>po(g,n,m,t,p,f))):po(h,n,m,t,p,f)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const C1=O("$ZodObject",(e,t)=>{if(Le.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const u={...l};return Object.defineProperty(t,"shape",{value:u}),u}})}const s=Vo(()=>yp(t));Ce(e._zod,"propValues",()=>{const l=t.shape,u={};for(const d in l){const p=l[d]._zod;if(p.values){u[d]??(u[d]=new Set);for(const f of p.values)u[d].add(f)}}return u});const o=tr,i=t.catchall;let a;e._zod.parse=(l,u)=>{a??(a=s.value);const d=l.value;if(!o(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value={};const p=[],f=a.shape;for(const m of a.keys){const h=f[m],g=h._zod.optin==="optional",y=h._zod.optout==="optional",b=h._zod.run({value:d[m],issues:[]},u);b instanceof Promise?p.push(b.then(w=>po(w,l,m,d,g,y))):po(b,l,m,d,g,y)}return i?wp(p,d,l,u,s.value,e):p.length?Promise.all(p).then(()=>l):l}}),T1=O("$ZodObjectJIT",(e,t)=>{C1.init(e,t);const n=e._zod.parse,s=Vo(()=>yp(t)),o=m=>{const h=new Kx(["shape","payload","ctx"]),g=s.value,y=j=>{const _=Mc(j);return`shape[${_}]._zod.run({ value: input[${_}], issues: [] }, ctx)`};h.write("const input = payload.value;");const b=Object.create(null);let w=0;for(const j of g.keys)b[j]=`key_${w++}`;h.write("const newResult = {};");for(const j of g.keys){const _=b[j],k=Mc(j),S=m[j],C=S?._zod?.optin==="optional",M=S?._zod?.optout==="optional";h.write(`const ${_} = ${y(j)};`),C&&M?h.write(`
5
+ if (${_}.issues.length) {
6
6
  if (${k} in input) {
7
- payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
7
+ payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
8
8
  ...iss,
9
9
  path: iss.path ? [${k}, ...iss.path] : [${k}]
10
10
  })));
11
11
  }
12
12
  }
13
13
 
14
- if (${S}.value === undefined) {
14
+ if (${_}.value === undefined) {
15
15
  if (${k} in input) {
16
16
  newResult[${k}] = undefined;
17
17
  }
18
18
  } else {
19
- newResult[${k}] = ${S}.value;
19
+ newResult[${k}] = ${_}.value;
20
20
  }
21
21
 
22
22
  `):C?h.write(`
23
- if (${S}.issues.length) {
24
- payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
23
+ if (${_}.issues.length) {
24
+ payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
25
25
  ...iss,
26
26
  path: iss.path ? [${k}, ...iss.path] : [${k}]
27
27
  })));
28
28
  }
29
29
 
30
- if (${S}.value === undefined) {
30
+ if (${_}.value === undefined) {
31
31
  if (${k} in input) {
32
32
  newResult[${k}] = undefined;
33
33
  }
34
34
  } else {
35
- newResult[${k}] = ${S}.value;
35
+ newResult[${k}] = ${_}.value;
36
36
  }
37
37
 
38
38
  `):h.write(`
39
- const ${S}_present = ${k} in input;
40
- if (${S}.issues.length) {
41
- payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
39
+ const ${_}_present = ${k} in input;
40
+ if (${_}.issues.length) {
41
+ payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
42
42
  ...iss,
43
43
  path: iss.path ? [${k}, ...iss.path] : [${k}]
44
44
  })));
45
45
  }
46
- if (!${S}_present && !${S}.issues.length) {
46
+ if (!${_}_present && !${_}.issues.length) {
47
47
  payload.issues.push({
48
48
  code: "invalid_type",
49
49
  expected: "nonoptional",
@@ -52,17 +52,17 @@ import{u as Bt,a as Xd,r as c,j as r,_ as Gt,b as Cg,c as Ti,p as Tg,T as Eg,n a
52
52
  });
53
53
  }
54
54
 
55
- if (${S}_present) {
56
- if (${S}.value === undefined) {
55
+ if (${_}_present) {
56
+ if (${_}.value === undefined) {
57
57
  newResult[${k}] = undefined;
58
58
  } else {
59
- newResult[${k}] = ${S}.value;
59
+ newResult[${k}] = ${_}.value;
60
60
  }
61
61
  }
62
62
 
63
- `)}h.write("payload.value = newResult;"),h.write("return payload;");const v=h.compile();return(j,S)=>v(m,j,S)};let i;const a=tr,l=!ul.jitless,d=l&&Dg.value,f=t.catchall;let p;e._zod.parse=(m,h)=>{p??(p=s.value);const g=m.value;return a(g)?l&&d&&h?.async===!1&&h.jitless!==!0?(i||(i=o(t.shape)),m=i(m,h),f?jf([],g,m,h,p,e):m):n(m,h):(m.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),m)}});function zc(e,t,n,s){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!ms(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(a=>an(a,s,on())))}),t)}const kf=O("$ZodUnion",(e,t)=>{Le.init(e,t),Ce(e._zod,"optin",()=>t.options.some(s=>s._zod.optin==="optional")?"optional":void 0),Ce(e._zod,"optout",()=>t.options.some(s=>s._zod.optout==="optional")?"optional":void 0),Ce(e._zod,"values",()=>{if(t.options.every(s=>s._zod.values))return new Set(t.options.flatMap(s=>Array.from(s._zod.values)))}),Ce(e._zod,"pattern",()=>{if(t.options.every(s=>s._zod.pattern)){const s=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${s.map(o=>fl(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(s,o)=>{if(n)return n(s,o);let i=!1;const a=[];for(const l of t.options){const u=l._zod.run({value:s.value,issues:[]},o);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(l=>zc(l,s,e,o)):zc(a,s,e,o)}}),E1=O("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,kf.init(e,t);const n=e._zod.parse;Ce(e._zod,"propValues",()=>{const o={};for(const i of t.options){const a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[l,u]of Object.entries(a)){o[l]||(o[l]=new Set);for(const d of u)o[l].add(d)}}return o});const s=Vo(()=>{const o=t.options,i=new Map;for(const a of o){const l=a._zod.propValues?.[t.discriminator];if(!l||l.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const u of l){if(i.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);i.set(u,a)}}return i});e._zod.parse=(o,i)=>{const a=o.value;if(!tr(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const l=s.value.get(a?.[t.discriminator]);return l?l._zod.run(o,i):t.unionFallback||i.direction==="backward"?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(s.value.keys()),input:a,path:[t.discriminator],inst:e}),o)}}),R1=O("$ZodIntersection",(e,t)=>{Le.init(e,t),e._zod.parse=(n,s)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},s),a=t.right._zod.run({value:o,issues:[]},s);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([u,d])=>Lc(n,u,d)):Lc(n,i,a)}});function ya(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ss(e)&&Ss(t)){const n=Object.keys(t),s=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of s){const a=ya(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let s=0;s<e.length;s++){const o=e[s],i=t[s],a=ya(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Lc(e,t,n){const s=new Map;let o;for(const l of t.issues)if(l.code==="unrecognized_keys"){o??(o=l);for(const u of l.keys)s.has(u)||s.set(u,{}),s.get(u).l=!0}else e.issues.push(l);for(const l of n.issues)if(l.code==="unrecognized_keys")for(const u of l.keys)s.has(u)||s.set(u,{}),s.get(u).r=!0;else e.issues.push(l);const i=[...s].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&o&&e.issues.push({...o,keys:i}),ms(e))return e;const a=ya(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}const P1=O("$ZodRecord",(e,t)=>{Le.init(e,t),e._zod.parse=(n,s)=>{const o=n.value;if(!Ss(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],a=t.keyType._zod.values;if(a){n.value={};const l=new Set;for(const d of a)if(typeof d=="string"||typeof d=="number"||typeof d=="symbol"){l.add(typeof d=="number"?d.toString():d);const f=t.keyType._zod.run({value:d,issues:[]},s);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(h=>an(h,s,on())),input:d,path:[d],inst:e});continue}const p=f.value,m=t.valueType._zod.run({value:o[d],issues:[]},s);m instanceof Promise?i.push(m.then(h=>{h.issues.length&&n.issues.push(...hs(d,h.issues)),n.value[p]=h.value})):(m.issues.length&&n.issues.push(...hs(d,m.issues)),n.value[p]=m.value)}let u;for(const d in o)l.has(d)||(u=u??[],u.push(d));u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:u})}else{n.value={};for(const l of Reflect.ownKeys(o)){if(l==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},s);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&hf.test(l)&&u.issues.length){const p=t.keyType._zod.run({value:Number(l),issues:[]},s);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(u=p)}if(u.issues.length){t.mode==="loose"?n.value[l]=o[l]:n.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(p=>an(p,s,on())),input:l,path:[l],inst:e});continue}const f=t.valueType._zod.run({value:o[l],issues:[]},s);f instanceof Promise?i.push(f.then(p=>{p.issues.length&&n.issues.push(...hs(l,p.issues)),n.value[u.value]=p.value})):(f.issues.length&&n.issues.push(...hs(l,f.issues)),n.value[u.value]=f.value)}}return i.length?Promise.all(i).then(()=>n):n}}),M1=O("$ZodEnum",(e,t)=>{Le.init(e,t);const n=of(t.entries),s=new Set(n);e._zod.values=s,e._zod.pattern=new RegExp(`^(${n.filter(o=>Fg.has(typeof o)).map(o=>typeof o=="string"?_s(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const a=o.value;return s.has(a)||o.issues.push({code:"invalid_value",values:n,input:a,inst:e}),o}}),I1=O("$ZodLiteral",(e,t)=>{if(Le.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(s=>typeof s=="string"?_s(s):s?_s(s.toString()):String(s)).join("|")})$`),e._zod.parse=(s,o)=>{const i=s.value;return n.has(i)||s.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),s}}),A1=O("$ZodTransform",(e,t)=>{Le.init(e,t),e._zod.optin="optional",e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new rf(e.constructor.name);const o=t.transform(n.value,n);if(s.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(n.value=a,n.fallback=!0,n));if(o instanceof Promise)throw new xs;return n.value=o,n.fallback=!0,n}});function $c(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Sf=O("$ZodOptional",(e,t)=>{Le.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ce(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ce(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${fl(n.source)})?$`):void 0}),e._zod.parse=(n,s)=>{if(t.innerType._zod.optin==="optional"){const o=n.value,i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(a=>$c(a,o)):$c(i,o)}return n.value===void 0?n:t.innerType._zod.run(n,s)}}),O1=O("$ZodExactOptional",(e,t)=>{Sf.init(e,t),Ce(e._zod,"values",()=>t.innerType._zod.values),Ce(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,s)=>t.innerType._zod.run(n,s)}),z1=O("$ZodNullable",(e,t)=>{Le.init(e,t),Ce(e._zod,"optin",()=>t.innerType._zod.optin),Ce(e._zod,"optout",()=>t.innerType._zod.optout),Ce(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${fl(n.source)}|null)$`):void 0}),Ce(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,s)=>n.value===null?n:t.innerType._zod.run(n,s)}),L1=O("$ZodDefault",(e,t)=>{Le.init(e,t),e._zod.optin="optional",Ce(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(i=>Dc(i,t)):Dc(o,t)}});function Dc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const $1=O("$ZodPrefault",(e,t)=>{Le.init(e,t),e._zod.optin="optional",Ce(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>(s.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,s))}),D1=O("$ZodNonOptional",(e,t)=>{Le.init(e,t),Ce(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(s=>s!==void 0)):void 0}),e._zod.parse=(n,s)=>{const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(i=>Fc(i,e)):Fc(o,e)}});function Fc(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const F1=O("$ZodCatch",(e,t)=>{Le.init(e,t),e._zod.optin="optional",Ce(e._zod,"optout",()=>t.innerType._zod.optout),Ce(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(a=>an(a,s,on()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>an(i,s,on()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),U1=O("$ZodPipe",(e,t)=>{Le.init(e,t),Ce(e._zod,"values",()=>t.in._zod.values),Ce(e._zod,"optin",()=>t.in._zod.optin),Ce(e._zod,"optout",()=>t.out._zod.optout),Ce(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,s)=>{if(s.direction==="backward"){const i=t.out._zod.run(n,s);return i instanceof Promise?i.then(a=>_r(a,t.in,s)):_r(i,t.in,s)}const o=t.in._zod.run(n,s);return o instanceof Promise?o.then(i=>_r(i,t.out,s)):_r(o,t.out,s)}});function _r(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const B1=O("$ZodReadonly",(e,t)=>{Le.init(e,t),Ce(e._zod,"propValues",()=>t.innerType._zod.propValues),Ce(e._zod,"values",()=>t.innerType._zod.values),Ce(e._zod,"optin",()=>t.innerType?._zod?.optin),Ce(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(Uc):Uc(o)}});function Uc(e){return e.value=Object.freeze(e.value),e}const V1=O("$ZodLazy",(e,t)=>{Le.init(e,t),Ce(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),Ce(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),Ce(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),Ce(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),Ce(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,s)=>e._zod.innerType._zod.run(n,s)}),q1=O("$ZodCustom",(e,t)=>{ut.init(e,t),Le.init(e,t),e._zod.parse=(n,s)=>n,e._zod.check=n=>{const s=n.value,o=t.fn(s);if(o instanceof Promise)return o.then(i=>Bc(i,n,s,e));Bc(o,n,s,e)}});function Bc(e,t,n,s){if(!e){const o={code:"custom",input:n,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(o.params=s._zod.def.params),t.issues.push(nr(o))}}var Vc;class H1{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const s=n[0];return this._map.set(t,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const s={...this.get(n)??{}};delete s.id;const o={...s,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function W1(){return new H1}(Vc=globalThis).__zod_globalRegistry??(Vc.__zod_globalRegistry=W1());const Ks=globalThis.__zod_globalRegistry;function Z1(e,t){return new e({type:"string",...re(t)})}function K1(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...re(t)})}function qc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...re(t)})}function G1(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...re(t)})}function J1(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...re(t)})}function Y1(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...re(t)})}function X1(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...re(t)})}function Q1(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...re(t)})}function eb(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...re(t)})}function tb(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...re(t)})}function nb(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...re(t)})}function sb(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...re(t)})}function rb(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...re(t)})}function ob(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...re(t)})}function ib(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...re(t)})}function ab(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...re(t)})}function lb(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...re(t)})}function cb(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...re(t)})}function ub(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...re(t)})}function db(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...re(t)})}function fb(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...re(t)})}function pb(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...re(t)})}function mb(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...re(t)})}function hb(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...re(t)})}function gb(e,t){return new e({type:"string",format:"date",check:"string_format",...re(t)})}function xb(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...re(t)})}function bb(e,t){return new e({type:"string",format:"duration",check:"string_format",...re(t)})}function vb(e,t){return new e({type:"number",checks:[],...re(t)})}function yb(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...re(t)})}function wb(e,t){return new e({type:"boolean",...re(t)})}function jb(e,t){return new e({type:"null",...re(t)})}function kb(e){return new e({type:"unknown"})}function Sb(e,t){return new e({type:"never",...re(t)})}function Hc(e,t){return new xf({check:"less_than",...re(t),value:e,inclusive:!1})}function Ri(e,t){return new xf({check:"less_than",...re(t),value:e,inclusive:!0})}function Wc(e,t){return new bf({check:"greater_than",...re(t),value:e,inclusive:!1})}function Pi(e,t){return new bf({check:"greater_than",...re(t),value:e,inclusive:!0})}function Zc(e,t){return new zx({check:"multiple_of",...re(t),value:e})}function _f(e,t){return new $x({check:"max_length",...re(t),maximum:e})}function po(e,t){return new Dx({check:"min_length",...re(t),minimum:e})}function Nf(e,t){return new Fx({check:"length_equals",...re(t),length:e})}function _b(e,t){return new Ux({check:"string_format",format:"regex",...re(t),pattern:e})}function Nb(e){return new Bx({check:"string_format",format:"lowercase",...re(e)})}function Cb(e){return new Vx({check:"string_format",format:"uppercase",...re(e)})}function Tb(e,t){return new qx({check:"string_format",format:"includes",...re(t),includes:e})}function Eb(e,t){return new Hx({check:"string_format",format:"starts_with",...re(t),prefix:e})}function Rb(e,t){return new Wx({check:"string_format",format:"ends_with",...re(t),suffix:e})}function zs(e){return new Zx({check:"overwrite",tx:e})}function Pb(e){return zs(t=>t.normalize(e))}function Mb(){return zs(e=>e.trim())}function Ib(){return zs(e=>e.toLowerCase())}function Ab(){return zs(e=>e.toUpperCase())}function Ob(){return zs(e=>$g(e))}function zb(e,t,n){return new e({type:"array",element:t,...re(n)})}function Lb(e,t,n){return new e({type:"custom",check:"custom",fn:t,...re(n)})}function $b(e,t){const n=Db(s=>(s.addIssue=o=>{if(typeof o=="string")s.issues.push(nr(o,s.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=s.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),s.issues.push(nr(i))}},e(s.value,s)),t);return n}function Db(e,t){const n=new ut({check:"custom",...re(t)});return n._zod.check=e,n}function Cf(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??Ks,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 He(e,t,n={path:[],schemaPath:[]}){var s;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const l=e._zod.toJSONSchema?.();if(l)a.schema=l;else{const f={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,f);else{const m=a.schema,h=t.processors[o.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);h(e,t,m,f)}const p=e._zod.parent;p&&(a.ref||(a.ref=p),He(p,t,f),t.seen.get(p).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&Object.assign(a.schema,u),t.io==="input"&&it(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((s=a.schema).default??(s.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Tf(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=new Map;for(const a of e.seen.entries()){const l=e.metadataRegistry.get(a[0])?.id;if(l){const u=s.get(l);if(u&&u!==a[0])throw new Error(`Duplicate schema id "${l}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(l,a[0])}}const o=a=>{const l=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const p=e.external.registry.get(a[0])?.id,m=e.external.uri??(g=>g);if(p)return{ref:m(p)};const h=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=h,{defId:h,ref:`${m("__shared")}#/${l}/${h}`}}if(a[1]===n)return{ref:"#"};const d=`#/${l}/`,f=a[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:d+f}},i=a=>{if(a[1].schema.$ref)return;const l=a[1],{ref:u,defId:d}=o(a);l.def={...l.schema},d&&(l.defId=d);const f=l.schema;for(const p in f)delete f[p];f.$ref=u};if(e.cycles==="throw")for(const a of e.seen.entries()){const l=a[1];if(l.cycle)throw new Error(`Cycle detected: #/${l.cycle?.join("/")}/<root>
63
+ `)}h.write("payload.value = newResult;"),h.write("return payload;");const v=h.compile();return(j,_)=>v(m,j,_)};let i;const a=tr,l=!ul.jitless,d=l&&Dg.value,p=t.catchall;let f;e._zod.parse=(m,h)=>{f??(f=s.value);const g=m.value;return a(g)?l&&d&&h?.async===!1&&h.jitless!==!0?(i||(i=o(t.shape)),m=i(m,h),p?wp([],g,m,h,f,e):m):n(m,h):(m.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),m)}});function zc(e,t,n,s){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!ms(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(a=>an(a,s,on())))}),t)}const jp=O("$ZodUnion",(e,t)=>{Le.init(e,t),Ce(e._zod,"optin",()=>t.options.some(s=>s._zod.optin==="optional")?"optional":void 0),Ce(e._zod,"optout",()=>t.options.some(s=>s._zod.optout==="optional")?"optional":void 0),Ce(e._zod,"values",()=>{if(t.options.every(s=>s._zod.values))return new Set(t.options.flatMap(s=>Array.from(s._zod.values)))}),Ce(e._zod,"pattern",()=>{if(t.options.every(s=>s._zod.pattern)){const s=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${s.map(o=>pl(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(s,o)=>{if(n)return n(s,o);let i=!1;const a=[];for(const l of t.options){const u=l._zod.run({value:s.value,issues:[]},o);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(l=>zc(l,s,e,o)):zc(a,s,e,o)}}),E1=O("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,jp.init(e,t);const n=e._zod.parse;Ce(e._zod,"propValues",()=>{const o={};for(const i of t.options){const a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[l,u]of Object.entries(a)){o[l]||(o[l]=new Set);for(const d of u)o[l].add(d)}}return o});const s=Vo(()=>{const o=t.options,i=new Map;for(const a of o){const l=a._zod.propValues?.[t.discriminator];if(!l||l.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const u of l){if(i.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);i.set(u,a)}}return i});e._zod.parse=(o,i)=>{const a=o.value;if(!tr(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const l=s.value.get(a?.[t.discriminator]);return l?l._zod.run(o,i):t.unionFallback||i.direction==="backward"?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(s.value.keys()),input:a,path:[t.discriminator],inst:e}),o)}}),R1=O("$ZodIntersection",(e,t)=>{Le.init(e,t),e._zod.parse=(n,s)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},s),a=t.right._zod.run({value:o,issues:[]},s);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([u,d])=>Lc(n,u,d)):Lc(n,i,a)}});function ya(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(_s(e)&&_s(t)){const n=Object.keys(t),s=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of s){const a=ya(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let s=0;s<e.length;s++){const o=e[s],i=t[s],a=ya(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Lc(e,t,n){const s=new Map;let o;for(const l of t.issues)if(l.code==="unrecognized_keys"){o??(o=l);for(const u of l.keys)s.has(u)||s.set(u,{}),s.get(u).l=!0}else e.issues.push(l);for(const l of n.issues)if(l.code==="unrecognized_keys")for(const u of l.keys)s.has(u)||s.set(u,{}),s.get(u).r=!0;else e.issues.push(l);const i=[...s].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&o&&e.issues.push({...o,keys:i}),ms(e))return e;const a=ya(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}const P1=O("$ZodRecord",(e,t)=>{Le.init(e,t),e._zod.parse=(n,s)=>{const o=n.value;if(!_s(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],a=t.keyType._zod.values;if(a){n.value={};const l=new Set;for(const d of a)if(typeof d=="string"||typeof d=="number"||typeof d=="symbol"){l.add(typeof d=="number"?d.toString():d);const p=t.keyType._zod.run({value:d,issues:[]},s);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(p.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(h=>an(h,s,on())),input:d,path:[d],inst:e});continue}const f=p.value,m=t.valueType._zod.run({value:o[d],issues:[]},s);m instanceof Promise?i.push(m.then(h=>{h.issues.length&&n.issues.push(...hs(d,h.issues)),n.value[f]=h.value})):(m.issues.length&&n.issues.push(...hs(d,m.issues)),n.value[f]=m.value)}let u;for(const d in o)l.has(d)||(u=u??[],u.push(d));u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:u})}else{n.value={};for(const l of Reflect.ownKeys(o)){if(l==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},s);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&mp.test(l)&&u.issues.length){const f=t.keyType._zod.run({value:Number(l),issues:[]},s);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(u=f)}if(u.issues.length){t.mode==="loose"?n.value[l]=o[l]:n.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(f=>an(f,s,on())),input:l,path:[l],inst:e});continue}const p=t.valueType._zod.run({value:o[l],issues:[]},s);p instanceof Promise?i.push(p.then(f=>{f.issues.length&&n.issues.push(...hs(l,f.issues)),n.value[u.value]=f.value})):(p.issues.length&&n.issues.push(...hs(l,p.issues)),n.value[u.value]=p.value)}}return i.length?Promise.all(i).then(()=>n):n}}),I1=O("$ZodEnum",(e,t)=>{Le.init(e,t);const n=op(t.entries),s=new Set(n);e._zod.values=s,e._zod.pattern=new RegExp(`^(${n.filter(o=>Fg.has(typeof o)).map(o=>typeof o=="string"?Ss(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const a=o.value;return s.has(a)||o.issues.push({code:"invalid_value",values:n,input:a,inst:e}),o}}),M1=O("$ZodLiteral",(e,t)=>{if(Le.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(s=>typeof s=="string"?Ss(s):s?Ss(s.toString()):String(s)).join("|")})$`),e._zod.parse=(s,o)=>{const i=s.value;return n.has(i)||s.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),s}}),A1=O("$ZodTransform",(e,t)=>{Le.init(e,t),e._zod.optin="optional",e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new rp(e.constructor.name);const o=t.transform(n.value,n);if(s.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(n.value=a,n.fallback=!0,n));if(o instanceof Promise)throw new xs;return n.value=o,n.fallback=!0,n}});function $c(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const kp=O("$ZodOptional",(e,t)=>{Le.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ce(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ce(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${pl(n.source)})?$`):void 0}),e._zod.parse=(n,s)=>{if(t.innerType._zod.optin==="optional"){const o=n.value,i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(a=>$c(a,o)):$c(i,o)}return n.value===void 0?n:t.innerType._zod.run(n,s)}}),O1=O("$ZodExactOptional",(e,t)=>{kp.init(e,t),Ce(e._zod,"values",()=>t.innerType._zod.values),Ce(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,s)=>t.innerType._zod.run(n,s)}),z1=O("$ZodNullable",(e,t)=>{Le.init(e,t),Ce(e._zod,"optin",()=>t.innerType._zod.optin),Ce(e._zod,"optout",()=>t.innerType._zod.optout),Ce(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${pl(n.source)}|null)$`):void 0}),Ce(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,s)=>n.value===null?n:t.innerType._zod.run(n,s)}),L1=O("$ZodDefault",(e,t)=>{Le.init(e,t),e._zod.optin="optional",Ce(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(i=>Dc(i,t)):Dc(o,t)}});function Dc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const $1=O("$ZodPrefault",(e,t)=>{Le.init(e,t),e._zod.optin="optional",Ce(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>(s.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,s))}),D1=O("$ZodNonOptional",(e,t)=>{Le.init(e,t),Ce(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(s=>s!==void 0)):void 0}),e._zod.parse=(n,s)=>{const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(i=>Fc(i,e)):Fc(o,e)}});function Fc(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const F1=O("$ZodCatch",(e,t)=>{Le.init(e,t),e._zod.optin="optional",Ce(e._zod,"optout",()=>t.innerType._zod.optout),Ce(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(a=>an(a,s,on()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>an(i,s,on()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),U1=O("$ZodPipe",(e,t)=>{Le.init(e,t),Ce(e._zod,"values",()=>t.in._zod.values),Ce(e._zod,"optin",()=>t.in._zod.optin),Ce(e._zod,"optout",()=>t.out._zod.optout),Ce(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,s)=>{if(s.direction==="backward"){const i=t.out._zod.run(n,s);return i instanceof Promise?i.then(a=>Sr(a,t.in,s)):Sr(i,t.in,s)}const o=t.in._zod.run(n,s);return o instanceof Promise?o.then(i=>Sr(i,t.out,s)):Sr(o,t.out,s)}});function Sr(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const B1=O("$ZodReadonly",(e,t)=>{Le.init(e,t),Ce(e._zod,"propValues",()=>t.innerType._zod.propValues),Ce(e._zod,"values",()=>t.innerType._zod.values),Ce(e._zod,"optin",()=>t.innerType?._zod?.optin),Ce(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(Uc):Uc(o)}});function Uc(e){return e.value=Object.freeze(e.value),e}const V1=O("$ZodLazy",(e,t)=>{Le.init(e,t),Ce(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),Ce(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),Ce(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),Ce(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),Ce(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,s)=>e._zod.innerType._zod.run(n,s)}),q1=O("$ZodCustom",(e,t)=>{ut.init(e,t),Le.init(e,t),e._zod.parse=(n,s)=>n,e._zod.check=n=>{const s=n.value,o=t.fn(s);if(o instanceof Promise)return o.then(i=>Bc(i,n,s,e));Bc(o,n,s,e)}});function Bc(e,t,n,s){if(!e){const o={code:"custom",input:n,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(o.params=s._zod.def.params),t.issues.push(nr(o))}}var Vc;class H1{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const s=n[0];return this._map.set(t,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const s={...this.get(n)??{}};delete s.id;const o={...s,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function W1(){return new H1}(Vc=globalThis).__zod_globalRegistry??(Vc.__zod_globalRegistry=W1());const Ks=globalThis.__zod_globalRegistry;function Z1(e,t){return new e({type:"string",...re(t)})}function K1(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...re(t)})}function qc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...re(t)})}function G1(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...re(t)})}function J1(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...re(t)})}function Y1(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...re(t)})}function X1(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...re(t)})}function Q1(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...re(t)})}function eb(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...re(t)})}function tb(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...re(t)})}function nb(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...re(t)})}function sb(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...re(t)})}function rb(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...re(t)})}function ob(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...re(t)})}function ib(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...re(t)})}function ab(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...re(t)})}function lb(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...re(t)})}function cb(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...re(t)})}function ub(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...re(t)})}function db(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...re(t)})}function pb(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...re(t)})}function fb(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...re(t)})}function mb(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...re(t)})}function hb(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...re(t)})}function gb(e,t){return new e({type:"string",format:"date",check:"string_format",...re(t)})}function xb(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...re(t)})}function bb(e,t){return new e({type:"string",format:"duration",check:"string_format",...re(t)})}function vb(e,t){return new e({type:"number",checks:[],...re(t)})}function yb(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...re(t)})}function wb(e,t){return new e({type:"boolean",...re(t)})}function jb(e,t){return new e({type:"null",...re(t)})}function kb(e){return new e({type:"unknown"})}function _b(e,t){return new e({type:"never",...re(t)})}function Hc(e,t){return new gp({check:"less_than",...re(t),value:e,inclusive:!1})}function Ri(e,t){return new gp({check:"less_than",...re(t),value:e,inclusive:!0})}function Wc(e,t){return new xp({check:"greater_than",...re(t),value:e,inclusive:!1})}function Pi(e,t){return new xp({check:"greater_than",...re(t),value:e,inclusive:!0})}function Zc(e,t){return new zx({check:"multiple_of",...re(t),value:e})}function _p(e,t){return new $x({check:"max_length",...re(t),maximum:e})}function fo(e,t){return new Dx({check:"min_length",...re(t),minimum:e})}function Sp(e,t){return new Fx({check:"length_equals",...re(t),length:e})}function Sb(e,t){return new Ux({check:"string_format",format:"regex",...re(t),pattern:e})}function Nb(e){return new Bx({check:"string_format",format:"lowercase",...re(e)})}function Cb(e){return new Vx({check:"string_format",format:"uppercase",...re(e)})}function Tb(e,t){return new qx({check:"string_format",format:"includes",...re(t),includes:e})}function Eb(e,t){return new Hx({check:"string_format",format:"starts_with",...re(t),prefix:e})}function Rb(e,t){return new Wx({check:"string_format",format:"ends_with",...re(t),suffix:e})}function zs(e){return new Zx({check:"overwrite",tx:e})}function Pb(e){return zs(t=>t.normalize(e))}function Ib(){return zs(e=>e.trim())}function Mb(){return zs(e=>e.toLowerCase())}function Ab(){return zs(e=>e.toUpperCase())}function Ob(){return zs(e=>$g(e))}function zb(e,t,n){return new e({type:"array",element:t,...re(n)})}function Lb(e,t,n){return new e({type:"custom",check:"custom",fn:t,...re(n)})}function $b(e,t){const n=Db(s=>(s.addIssue=o=>{if(typeof o=="string")s.issues.push(nr(o,s.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=s.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),s.issues.push(nr(i))}},e(s.value,s)),t);return n}function Db(e,t){const n=new ut({check:"custom",...re(t)});return n._zod.check=e,n}function Np(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??Ks,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 He(e,t,n={path:[],schemaPath:[]}){var s;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const l=e._zod.toJSONSchema?.();if(l)a.schema=l;else{const p={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,p);else{const m=a.schema,h=t.processors[o.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);h(e,t,m,p)}const f=e._zod.parent;f&&(a.ref||(a.ref=f),He(f,t,p),t.seen.get(f).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&Object.assign(a.schema,u),t.io==="input"&&it(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((s=a.schema).default??(s.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Cp(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=new Map;for(const a of e.seen.entries()){const l=e.metadataRegistry.get(a[0])?.id;if(l){const u=s.get(l);if(u&&u!==a[0])throw new Error(`Duplicate schema id "${l}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(l,a[0])}}const o=a=>{const l=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const f=e.external.registry.get(a[0])?.id,m=e.external.uri??(g=>g);if(f)return{ref:m(f)};const h=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=h,{defId:h,ref:`${m("__shared")}#/${l}/${h}`}}if(a[1]===n)return{ref:"#"};const d=`#/${l}/`,p=a[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:d+p}},i=a=>{if(a[1].schema.$ref)return;const l=a[1],{ref:u,defId:d}=o(a);l.def={...l.schema},d&&(l.defId=d);const p=l.schema;for(const f in p)delete p[f];p.$ref=u};if(e.cycles==="throw")for(const a of e.seen.entries()){const l=a[1];if(l.cycle)throw new Error(`Cycle detected: #/${l.cycle?.join("/")}/<root>
64
64
 
65
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const a of e.seen.entries()){const l=a[1];if(t===a[0]){i(a);continue}if(e.external){const d=e.external.registry.get(a[0])?.id;if(t!==a[0]&&d){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(l.cycle){i(a);continue}if(l.count>1&&e.reused==="ref"){i(a);continue}}}function Ef(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=l=>{const u=e.seen.get(l);if(u.ref===null)return;const d=u.def??u.schema,f={...d},p=u.ref;if(u.ref=null,p){s(p);const h=e.seen.get(p),g=h.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(g)):Object.assign(d,g),Object.assign(d,f),l._zod.parent===p)for(const b in d)b==="$ref"||b==="allOf"||b in f||delete d[b];if(g.$ref&&h.def)for(const b in d)b==="$ref"||b==="allOf"||b in h.def&&JSON.stringify(d[b])===JSON.stringify(h.def[b])&&delete d[b]}const m=l._zod.parent;if(m&&m!==p){s(m);const h=e.seen.get(m);if(h?.schema.$ref&&(d.$ref=h.schema.$ref,h.def))for(const g in d)g==="$ref"||g==="allOf"||g in h.def&&JSON.stringify(d[g])===JSON.stringify(h.def[g])&&delete d[g]}e.override({zodSchema:l,jsonSchema:d,path:u.path??[]})};for(const l of[...e.seen.entries()].reverse())s(l[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const l=e.external.registry.get(t)?.id;if(!l)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(l)}Object.assign(o,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;const a=e.external?.defs??{};for(const l of e.seen.entries()){const u=l[1];u.def&&u.defId&&(u.def.id===u.defId&&delete u.def.id,a[u.defId]=u.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?o.$defs=a:o.definitions=a);try{const l=JSON.parse(JSON.stringify(o));return Object.defineProperty(l,"~standard",{value:{...t["~standard"],jsonSchema:{input:mo(t,"input",e.processors),output:mo(t,"output",e.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function it(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const s=e._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return it(s.element,n);if(s.type==="set")return it(s.valueType,n);if(s.type==="lazy")return it(s.getter(),n);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault")return it(s.innerType,n);if(s.type==="intersection")return it(s.left,n)||it(s.right,n);if(s.type==="record"||s.type==="map")return it(s.keyType,n)||it(s.valueType,n);if(s.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:it(s.in,n)||it(s.out,n);if(s.type==="object"){for(const o in s.shape)if(it(s.shape[o],n))return!0;return!1}if(s.type==="union"){for(const o of s.options)if(it(o,n))return!0;return!1}if(s.type==="tuple"){for(const o of s.items)if(it(o,n))return!0;return!!(s.rest&&it(s.rest,n))}return!1}const Fb=(e,t={})=>n=>{const s=Cf({...n,processors:t});return He(e,s),Tf(s,e),Ef(s,e)},mo=(e,t,n={})=>s=>{const{libraryOptions:o,target:i}=s??{},a=Cf({...o??{},target:i,io:t,processors:n});return He(e,a),Tf(a,e),Ef(a,e)},Ub={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Bb=(e,t,n,s)=>{const o=n;o.type="string";const{minimum:i,maximum:a,format:l,patterns:u,contentEncoding:d}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),l&&(o.format=Ub[l]??l,o.format===""&&delete o.format,l==="time"&&delete o.format),d&&(o.contentEncoding=d),u&&u.size>0){const f=[...u];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},Vb=(e,t,n,s)=>{const o=n,{minimum:i,maximum:a,format:l,multipleOf:u,exclusiveMaximum:d,exclusiveMinimum:f}=e._zod.bag;typeof l=="string"&&l.includes("int")?o.type="integer":o.type="number";const p=typeof f=="number"&&f>=(i??Number.NEGATIVE_INFINITY),m=typeof d=="number"&&d<=(a??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";p?h?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f:typeof i=="number"&&(o.minimum=i),m?h?(o.maximum=d,o.exclusiveMaximum=!0):o.exclusiveMaximum=d:typeof a=="number"&&(o.maximum=a),typeof u=="number"&&(o.multipleOf=u)},qb=(e,t,n,s)=>{n.type="boolean"},Hb=(e,t,n,s)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},Wb=(e,t,n,s)=>{n.not={}},Zb=(e,t,n,s)=>{},Kb=(e,t,n,s)=>{const o=e._zod.def,i=of(o.entries);i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i},Gb=(e,t,n,s)=>{const o=e._zod.def,i=[];for(const a of o.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){const a=i[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),i.every(a=>typeof a=="boolean")&&(n.type="boolean"),i.every(a=>a===null)&&(n.type="null"),n.enum=i},Jb=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Yb=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Xb=(e,t,n,s)=>{const o=n,i=e._zod.def,{minimum:a,maximum:l}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof l=="number"&&(o.maxItems=l),o.type="array",o.items=He(i.element,t,{...s,path:[...s.path,"items"]})},Qb=(e,t,n,s)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const d in a)o.properties[d]=He(a[d],t,{...s,path:[...s.path,"properties",d]});const l=new Set(Object.keys(a)),u=new Set([...l].filter(d=>{const f=i.shape[d]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));u.size>0&&(o.required=Array.from(u)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=He(i.catchall,t,{...s,path:[...s.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},ev=(e,t,n,s)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((l,u)=>He(l,t,{...s,path:[...s.path,i?"oneOf":"anyOf",u]}));i?n.oneOf=a:n.anyOf=a},tv=(e,t,n,s)=>{const o=e._zod.def,i=He(o.left,t,{...s,path:[...s.path,"allOf",0]}),a=He(o.right,t,{...s,path:[...s.path,"allOf",1]}),l=d=>"allOf"in d&&Object.keys(d).length===1,u=[...l(i)?i.allOf:[i],...l(a)?a.allOf:[a]];n.allOf=u},nv=(e,t,n,s)=>{const o=n,i=e._zod.def;o.type="object";const a=i.keyType,u=a._zod.bag?.patterns;if(i.mode==="loose"&&u&&u.size>0){const f=He(i.valueType,t,{...s,path:[...s.path,"patternProperties","*"]});o.patternProperties={};for(const p of u)o.patternProperties[p.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=He(i.keyType,t,{...s,path:[...s.path,"propertyNames"]})),o.additionalProperties=He(i.valueType,t,{...s,path:[...s.path,"additionalProperties"]});const d=a._zod.values;if(d){const f=[...d].filter(p=>typeof p=="string"||typeof p=="number");f.length>0&&(o.required=f)}},sv=(e,t,n,s)=>{const o=e._zod.def,i=He(o.innerType,t,s),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},rv=(e,t,n,s)=>{const o=e._zod.def;He(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType},ov=(e,t,n,s)=>{const o=e._zod.def;He(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},iv=(e,t,n,s)=>{const o=e._zod.def;He(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},av=(e,t,n,s)=>{const o=e._zod.def;He(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},lv=(e,t,n,s)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?i?o.out:o.in:o.out;He(a,t,s);const l=t.seen.get(e);l.ref=a},cv=(e,t,n,s)=>{const o=e._zod.def;He(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Rf=(e,t,n,s)=>{const o=e._zod.def;He(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType},uv=(e,t,n,s)=>{const o=e._zod.innerType;He(o,t,s);const i=t.seen.get(e);i.ref=o},dv=O("ZodISODateTime",(e,t)=>{a1.init(e,t),Fe.init(e,t)});function fv(e){return hb(dv,e)}const pv=O("ZodISODate",(e,t)=>{l1.init(e,t),Fe.init(e,t)});function mv(e){return gb(pv,e)}const hv=O("ZodISOTime",(e,t)=>{c1.init(e,t),Fe.init(e,t)});function gv(e){return xb(hv,e)}const xv=O("ZodISODuration",(e,t)=>{u1.init(e,t),Fe.init(e,t)});function bv(e){return bb(xv,e)}const vv=(e,t)=>{uf.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Xg(e,n)},flatten:{value:n=>Yg(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,va,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,va,2)}},isEmpty:{get(){return e.issues.length===0}}})},St=O("ZodError",vv,{Parent:Error}),yv=ml(St),wv=hl(St),jv=qo(St),kv=Ho(St),Sv=tx(St),_v=nx(St),Nv=sx(St),Cv=rx(St),Tv=ox(St),Ev=ix(St),Rv=ax(St),Pv=lx(St),Kc=new WeakMap;function dr(e,t,n){const s=Object.getPrototypeOf(e);let o=Kc.get(s);if(o||(o=new Set,Kc.set(s,o)),!o.has(t)){o.add(t);for(const i in n){const a=n[i];Object.defineProperty(s,i,{configurable:!0,enumerable:!1,get(){const l=a.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l}),l},set(l){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l})}})}}}const $e=O("ZodType",(e,t)=>(Le.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:mo(e,"input"),output:mo(e,"output")}}),e.toJSONSchema=Fb(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,s)=>yv(e,n,s,{callee:e.parse}),e.safeParse=(n,s)=>jv(e,n,s),e.parseAsync=async(n,s)=>wv(e,n,s,{callee:e.parseAsync}),e.safeParseAsync=async(n,s)=>kv(e,n,s),e.spa=e.safeParseAsync,e.encode=(n,s)=>Sv(e,n,s),e.decode=(n,s)=>_v(e,n,s),e.encodeAsync=async(n,s)=>Nv(e,n,s),e.decodeAsync=async(n,s)=>Cv(e,n,s),e.safeEncode=(n,s)=>Tv(e,n,s),e.safeDecode=(n,s)=>Ev(e,n,s),e.safeEncodeAsync=async(n,s)=>Rv(e,n,s),e.safeDecodeAsync=async(n,s)=>Pv(e,n,s),dr(e,"ZodType",{check(...n){const s=this.def;return this.clone(Nn(s,{checks:[...s.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,s){return Cn(this,n,s)},brand(){return this},register(n,s){return n.add(this,s),this},refine(n,s){return this.check(N2(n,s))},superRefine(n,s){return this.check(C2(n,s))},overwrite(n){return this.check(zs(n))},optional(){return Xc(this)},exactOptional(){return d2(this)},nullable(){return Qc(this)},nullish(){return Xc(Qc(this))},nonoptional(n){return x2(this,n)},array(){return H(this)},or(n){return At([this,n])},and(n){return i2(this,n)},transform(n){return eu(this,c2(n))},default(n){return m2(this,n)},prefault(n){return g2(this,n)},catch(n){return v2(this,n)},pipe(n){return eu(this,n)},readonly(){return j2(this)},describe(n){const s=this.clone();return Ks.add(s,{description:n}),s},meta(...n){if(n.length===0)return Ks.get(this);const s=this.clone();return Ks.add(s,n[0]),s},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return Ks.get(e)?.description},configurable:!0}),e)),Pf=O("_ZodString",(e,t)=>{gl.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(s,o,i)=>Bb(e,s,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,dr(e,"_ZodString",{regex(...s){return this.check(_b(...s))},includes(...s){return this.check(Tb(...s))},startsWith(...s){return this.check(Eb(...s))},endsWith(...s){return this.check(Rb(...s))},min(...s){return this.check(po(...s))},max(...s){return this.check(_f(...s))},length(...s){return this.check(Nf(...s))},nonempty(...s){return this.check(po(1,...s))},lowercase(s){return this.check(Nb(s))},uppercase(s){return this.check(Cb(s))},trim(){return this.check(Mb())},normalize(...s){return this.check(Pb(...s))},toLowerCase(){return this.check(Ib())},toUpperCase(){return this.check(Ab())},slugify(){return this.check(Ob())}})}),Mv=O("ZodString",(e,t)=>{gl.init(e,t),Pf.init(e,t),e.email=n=>e.check(K1(Iv,n)),e.url=n=>e.check(Q1(Av,n)),e.jwt=n=>e.check(mb(Gv,n)),e.emoji=n=>e.check(eb(Ov,n)),e.guid=n=>e.check(qc(Gc,n)),e.uuid=n=>e.check(G1(Nr,n)),e.uuidv4=n=>e.check(J1(Nr,n)),e.uuidv6=n=>e.check(Y1(Nr,n)),e.uuidv7=n=>e.check(X1(Nr,n)),e.nanoid=n=>e.check(tb(zv,n)),e.guid=n=>e.check(qc(Gc,n)),e.cuid=n=>e.check(nb(Lv,n)),e.cuid2=n=>e.check(sb($v,n)),e.ulid=n=>e.check(rb(Dv,n)),e.base64=n=>e.check(db(Wv,n)),e.base64url=n=>e.check(fb(Zv,n)),e.xid=n=>e.check(ob(Fv,n)),e.ksuid=n=>e.check(ib(Uv,n)),e.ipv4=n=>e.check(ab(Bv,n)),e.ipv6=n=>e.check(lb(Vv,n)),e.cidrv4=n=>e.check(cb(qv,n)),e.cidrv6=n=>e.check(ub(Hv,n)),e.e164=n=>e.check(pb(Kv,n)),e.datetime=n=>e.check(fv(n)),e.date=n=>e.check(mv(n)),e.time=n=>e.check(gv(n)),e.duration=n=>e.check(bv(n))});function x(e){return Z1(Mv,e)}const Fe=O("ZodStringFormat",(e,t)=>{De.init(e,t),Pf.init(e,t)}),Iv=O("ZodEmail",(e,t)=>{Xx.init(e,t),Fe.init(e,t)}),Gc=O("ZodGUID",(e,t)=>{Jx.init(e,t),Fe.init(e,t)}),Nr=O("ZodUUID",(e,t)=>{Yx.init(e,t),Fe.init(e,t)}),Av=O("ZodURL",(e,t)=>{Qx.init(e,t),Fe.init(e,t)}),Ov=O("ZodEmoji",(e,t)=>{e1.init(e,t),Fe.init(e,t)}),zv=O("ZodNanoID",(e,t)=>{t1.init(e,t),Fe.init(e,t)}),Lv=O("ZodCUID",(e,t)=>{n1.init(e,t),Fe.init(e,t)}),$v=O("ZodCUID2",(e,t)=>{s1.init(e,t),Fe.init(e,t)}),Dv=O("ZodULID",(e,t)=>{r1.init(e,t),Fe.init(e,t)}),Fv=O("ZodXID",(e,t)=>{o1.init(e,t),Fe.init(e,t)}),Uv=O("ZodKSUID",(e,t)=>{i1.init(e,t),Fe.init(e,t)}),Bv=O("ZodIPv4",(e,t)=>{d1.init(e,t),Fe.init(e,t)}),Vv=O("ZodIPv6",(e,t)=>{f1.init(e,t),Fe.init(e,t)}),qv=O("ZodCIDRv4",(e,t)=>{p1.init(e,t),Fe.init(e,t)}),Hv=O("ZodCIDRv6",(e,t)=>{m1.init(e,t),Fe.init(e,t)}),Wv=O("ZodBase64",(e,t)=>{h1.init(e,t),Fe.init(e,t)}),Zv=O("ZodBase64URL",(e,t)=>{x1.init(e,t),Fe.init(e,t)}),Kv=O("ZodE164",(e,t)=>{b1.init(e,t),Fe.init(e,t)}),Gv=O("ZodJWT",(e,t)=>{y1.init(e,t),Fe.init(e,t)}),Mf=O("ZodNumber",(e,t)=>{yf.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(s,o,i)=>Vb(e,s,o),dr(e,"ZodNumber",{gt(s,o){return this.check(Wc(s,o))},gte(s,o){return this.check(Pi(s,o))},min(s,o){return this.check(Pi(s,o))},lt(s,o){return this.check(Hc(s,o))},lte(s,o){return this.check(Ri(s,o))},max(s,o){return this.check(Ri(s,o))},int(s){return this.check(Jc(s))},safe(s){return this.check(Jc(s))},positive(s){return this.check(Wc(0,s))},nonnegative(s){return this.check(Pi(0,s))},negative(s){return this.check(Hc(0,s))},nonpositive(s){return this.check(Ri(0,s))},multipleOf(s,o){return this.check(Zc(s,o))},step(s,o){return this.check(Zc(s,o))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function R(e){return vb(Mf,e)}const Jv=O("ZodNumberFormat",(e,t)=>{w1.init(e,t),Mf.init(e,t)});function Jc(e){return yb(Jv,e)}const Yv=O("ZodBoolean",(e,t)=>{j1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>qb(e,n,s)});function Te(e){return wb(Yv,e)}const Xv=O("ZodNull",(e,t)=>{k1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Hb(e,n,s)});function ho(e){return jb(Xv,e)}const Qv=O("ZodUnknown",(e,t)=>{S1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Zb()});function Fn(){return kb(Qv)}const e2=O("ZodNever",(e,t)=>{_1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Wb(e,n,s)});function t2(e){return Sb(e2,e)}const n2=O("ZodArray",(e,t)=>{N1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Xb(e,n,s,o),e.element=t.element,dr(e,"ZodArray",{min(n,s){return this.check(po(n,s))},nonempty(n){return this.check(po(1,n))},max(n,s){return this.check(_f(n,s))},length(n,s){return this.check(Nf(n,s))},unwrap(){return this.element}})});function H(e,t){return zb(n2,e,t)}const s2=O("ZodObject",(e,t)=>{T1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Qb(e,n,s,o),Ce(e,"shape",()=>t.shape),dr(e,"ZodObject",{keyof(){return pe(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:Fn()})},loose(){return this.clone({...this._zod.def,catchall:Fn()})},strict(){return this.clone({...this._zod.def,catchall:t2()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return Hg(this,n)},safeExtend(n){return Wg(this,n)},merge(n){return Zg(this,n)},pick(n){return Vg(this,n)},omit(n){return qg(this,n)},partial(...n){return Kg(Af,this,n[0])},required(...n){return Gg(Of,this,n[0])}})});function T(e,t){const n={type:"object",shape:e??{},...re(t)};return new s2(n)}const If=O("ZodUnion",(e,t)=>{kf.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>ev(e,n,s,o),e.options=t.options});function At(e,t){return new If({type:"union",options:e,...re(t)})}const r2=O("ZodDiscriminatedUnion",(e,t)=>{If.init(e,t),E1.init(e,t)});function Tn(e,t,n){return new r2({type:"union",options:t,discriminator:e,...re(n)})}const o2=O("ZodIntersection",(e,t)=>{R1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>tv(e,n,s,o)});function i2(e,t){return new o2({type:"intersection",left:e,right:t})}const Yc=O("ZodRecord",(e,t)=>{P1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>nv(e,n,s,o),e.keyType=t.keyType,e.valueType=t.valueType});function We(e,t,n){return!t||!t._zod?new Yc({type:"record",keyType:x(),valueType:e,...re(t)}):new Yc({type:"record",keyType:e,valueType:t,...re(n)})}const wa=O("ZodEnum",(e,t)=>{M1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(s,o,i)=>Kb(e,s,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(s,o)=>{const i={};for(const a of s)if(n.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new wa({...t,checks:[],...re(o),entries:i})},e.exclude=(s,o)=>{const i={...t.entries};for(const a of s)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new wa({...t,checks:[],...re(o),entries:i})}});function pe(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new wa({type:"enum",entries:n,...re(t)})}const a2=O("ZodLiteral",(e,t)=>{I1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Gb(e,n,s),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ae(e,t){return new a2({type:"literal",values:Array.isArray(e)?e:[e],...re(t)})}const l2=O("ZodTransform",(e,t)=>{A1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Yb(e,n),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new rf(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(nr(i,n.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(nr(a))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});function c2(e){return new l2({type:"transform",transform:e})}const Af=O("ZodOptional",(e,t)=>{Sf.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Rf(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function Xc(e){return new Af({type:"optional",innerType:e})}const u2=O("ZodExactOptional",(e,t)=>{O1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Rf(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function d2(e){return new u2({type:"optional",innerType:e})}const f2=O("ZodNullable",(e,t)=>{z1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>sv(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function Qc(e){return new f2({type:"nullable",innerType:e})}const p2=O("ZodDefault",(e,t)=>{L1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>ov(e,n,s,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function m2(e,t){return new p2({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():lf(t)}})}const h2=O("ZodPrefault",(e,t)=>{$1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>iv(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function g2(e,t){return new h2({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():lf(t)}})}const Of=O("ZodNonOptional",(e,t)=>{D1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>rv(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function x2(e,t){return new Of({type:"nonoptional",innerType:e,...re(t)})}const b2=O("ZodCatch",(e,t)=>{F1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>av(e,n,s,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function v2(e,t){return new b2({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const y2=O("ZodPipe",(e,t)=>{U1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>lv(e,n,s,o),e.in=t.in,e.out=t.out});function eu(e,t){return new y2({type:"pipe",in:e,out:t})}const w2=O("ZodReadonly",(e,t)=>{B1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>cv(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function j2(e){return new w2({type:"readonly",innerType:e})}const k2=O("ZodLazy",(e,t)=>{V1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>uv(e,n,s,o),e.unwrap=()=>e._zod.def.getter()});function S2(e){return new k2({type:"lazy",getter:e})}const _2=O("ZodCustom",(e,t)=>{q1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Jb(e,n)});function N2(e,t={}){return Lb(_2,e,t)}function C2(e,t){return $b(e,t)}const tt=S2(()=>At([x(),R(),Te(),ho(),H(tt),We(x(),tt)]));function zf(e){return e===void 0||typeof e=="bigint"||typeof e=="function"?null:e}const Lf=T({index:R(),timestamp:R(),type:x(),data:tt}),T2=T({chunks:H(Lf),truncated:Te().optional().default(!1)}),E2=pe(["request","response"]),R2=T({logId:R().int().positive(),part:E2,text:x(),offset:R().int().nonnegative(),limit:R().int().positive(),totalBytes:R().int().nonnegative(),textBytes:R().int().nonnegative(),nextOffset:R().int().nonnegative().nullable(),hasMore:Te(),contentMode:pe(["empty","partial","full"])}),sr=T({id:R(),timestamp:x(),method:x(),path:x(),model:x().nullable(),sessionId:x().nullable(),rawRequestBody:x().nullable(),responseStatus:R().nullable(),responseText:x().nullable(),inputTokens:R().nullable(),outputTokens:R().nullable(),cacheCreationInputTokens:R().nullable(),cacheReadInputTokens:R().nullable(),elapsedMs:R().nullable(),firstChunkMs:R().nullable().optional(),totalStreamMs:R().nullable().optional(),tokensPerSecond:R().nullable().optional(),streaming:Te(),userAgent:x().nullable(),origin:x().nullable(),rawHeaders:We(x(),x()).optional(),headers:We(x(),x()).optional(),apiFormat:pe(["anthropic","openai","unknown"]).default("unknown"),isTest:Te().optional().default(!1),replayOfLogId:R().nullable().optional(),providerName:x().nullable().optional(),clientPort:R().nullable().optional(),clientPid:R().nullable().optional(),clientCwd:x().nullable().optional(),clientProjectFolder:x().nullable().optional(),streamingChunks:T2.optional(),streamingChunksPath:x().nullable().optional(),rawRequestBodyBytes:R().int().nonnegative().nullable().optional(),responseTextBytes:R().int().nonnegative().nullable().optional(),bodyContentMode:pe(["full","compact","truncated"]).optional(),warnings:H(x()).optional(),error:x().nullable().optional()}),xl=T({type:x(),ttl:x().optional(),scope:x().optional()}),bl=T({type:ae("text"),text:x(),cache_control:xl.optional()}),$f=T({type:ae("thinking"),thinking:x(),signature:x().optional()}),P2=T({type:ae("think"),thinking:x(),signature:x().optional()}),M2=T({type:ae("base64"),media_type:x(),data:x()}),Df=T({type:ae("image"),source:M2}),Ff=T({type:ae("tool_use"),id:x(),name:x(),input:We(x(),tt)}),I2=Tn("type",[bl,Df]),A2=T({type:ae("tool_result"),tool_use_id:x().optional(),content:At([x(),H(I2)]),is_error:Te().optional()}),O2=Tn("type",[bl,$f,Df,Ff,A2]),z2=At([x(),H(O2)]),L2=T({role:pe(["user","assistant"]),content:z2}),$2=T({type:ae("text"),text:x(),cache_control:xl.optional()}),D2=T({type:x(),properties:We(x(),We(x(),tt)).optional(),required:H(x()).optional(),additionalProperties:Te().optional(),$schema:x().optional()}),F2=T({name:x(),description:x().optional(),input_schema:D2.optional(),cache_control:xl.optional()}),U2=Tn("type",[T({type:ae("enabled"),budget_tokens:R()}),T({type:ae("disabled")}),T({type:ae("adaptive")})]),Uf=T({model:x(),messages:H(L2),system:H($2).optional(),tools:H(F2).optional(),max_tokens:R().optional(),temperature:R().optional(),stream:Te().optional(),thinking:U2.optional(),metadata:T({user_id:x().optional()}).optional()}),vl=Tn("type",[bl,$f,P2,Ff]),B2=T({input_tokens:R().nullable().optional(),output_tokens:R().nullable().optional(),cache_creation_input_tokens:R().nullable().optional(),cache_read_input_tokens:R().nullable().optional()}).passthrough(),Bf=T({id:x(),type:ae("message"),model:x(),role:ae("assistant"),content:H(vl),stop_reason:x().nullable(),stop_sequence:x().nullable().optional(),usage:B2}).passthrough(),V2=T({type:ae("message_start"),message:T({id:x(),type:ae("message"),model:x(),role:ae("assistant"),content:H(vl),stop_reason:ho(),stop_sequence:ho(),usage:T({input_tokens:R(),cache_creation_input_tokens:R().optional(),cache_read_input_tokens:R().optional()}).passthrough()})}),q2=T({type:ae("content_block_start"),index:R(),content_block:vl}),H2=Tn("type",[T({type:ae("text_delta"),text:x()}),T({type:ae("input_json_delta"),partial_json:x()}),T({type:ae("thinking_delta"),thinking:x()}),T({type:ae("signature_delta"),signature:x()})]),W2=T({type:ae("content_block_delta"),index:R(),delta:H2}),Z2=T({type:ae("content_block_stop"),index:R()}),K2=T({type:ae("message_delta"),delta:T({stop_reason:x().nullable(),stop_sequence:x().nullable().optional()}),usage:T({output_tokens:R(),input_tokens:R().optional(),cache_creation_input_tokens:R().optional(),cache_read_input_tokens:R().optional()}).passthrough()}),G2=T({type:ae("message_stop")}),J2=T({type:ae("ping")}),Y2=T({type:ae("error"),error:T({type:x(),message:x()})}),X2=Tn("type",[V2,q2,W2,Z2,K2,G2,J2,Y2]),Q2=At([x(),H(Tn("type",[T({type:ae("text"),text:x()}),T({type:ae("image_url"),image_url:T({url:x(),detail:x().optional()})})]))]),Vf=T({role:pe(["system","user","assistant","tool"]),content:Q2,name:x().optional(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional()}),ey=T({name:x(),arguments:x()}),qf=T({index:R().optional(),id:x().optional(),type:ae("function").optional(),function:T({name:x().optional(),arguments:x().optional()})});Vf.extend({content:At([x(),H(T({type:ae("text"),text:x()}))]).optional(),function_call:ey.optional(),tool_calls:H(qf).optional()});const ty=T({type:ae("function"),function:T({name:x(),description:x().optional(),parameters:We(x(),tt)})}),Hf=T({model:x(),messages:H(Vf),temperature:R().optional(),max_tokens:R().optional(),stream:Te().optional(),tools:H(ty).optional(),tool_choice:At([pe(["auto","none","required"]),T({type:ae("auto")}),T({type:ae("none")}),T({type:ae("function"),function:T({name:x()})})]).optional(),user:x().optional()}),ny=T({type:x(),name:x().optional(),description:x().optional(),parameters:tt.optional(),function:T({name:x().optional(),description:x().optional(),parameters:tt.optional()}).optional()}).passthrough(),Wf=T({model:x(),input:Fn().optional(),instructions:At([x(),ho()]).optional(),stream:Te().optional(),tools:H(ny).optional(),tool_choice:Fn().optional(),max_output_tokens:R().optional(),temperature:R().optional(),user:x().optional(),metadata:We(x(),Fn()).optional()}).passthrough(),Zf=T({role:pe(["assistant"]).optional(),content:x().nullable().optional(),reasoning_content:x().nullable().optional(),thinking:x().nullable().optional(),think:x().nullable().optional(),function_call:T({name:x().optional(),arguments:x().optional()}).nullable().optional(),tool_calls:H(T({index:R(),id:x().optional(),type:ae("function").optional(),function:T({name:x().optional(),arguments:x().optional()})})).nullable().optional()}),sy=T({index:R(),message:T({role:pe(["assistant"]),content:x().nullable(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional(),function_call:T({name:x(),arguments:x()}).nullable().optional(),tool_calls:H(qf).optional()}).optional(),delta:Zf.optional(),finish_reason:x().nullable()}),ry=T({id:x(),object:ae("chat.completion"),created:R(),model:x(),choices:H(sy),usage:T({prompt_tokens:R().nullable().optional(),completion_tokens:R().nullable().optional(),total_tokens:R().nullable().optional()}).passthrough(),service_tier:x().nullable().optional(),system_fingerprint:x().nullable().optional()}).passthrough(),oy=T({id:x(),object:ae("chat.completion.chunk"),created:R(),model:x(),choices:H(T({index:R(),delta:Zf,finish_reason:x().nullable().optional()})),usage:T({prompt_tokens:R().nullable().optional(),completion_tokens:R().nullable().optional(),total_tokens:R().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),iy=T({input_tokens:R().nullable().optional(),output_tokens:R().nullable().optional(),total_tokens:R().nullable().optional(),input_tokens_details:T({cached_tokens:R().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:T({reasoning_tokens:R().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),ay=T({type:x()}).passthrough(),go=T({id:x(),object:ae("response").optional(),created_at:R().optional(),status:x().nullable().optional(),model:x().optional(),output:H(ay).optional(),output_text:x().optional(),usage:iy.nullable().optional(),error:Fn().optional()}).passthrough(),ly=T({type:x()}).passthrough();function Kf(e){try{const t=JSON.parse(e),n=ry.safeParse(t);return n.success?n.data:null}catch{return null}}function Gf(e){try{const t=JSON.parse(e),n=go.safeParse(t);return n.success?n.data:null}catch{return null}}const cy=T({error:x()}),uy=new Set(["POST","PUT","PATCH","DELETE"]);function Jf(e){const t=e?.method?.toUpperCase();if(t===void 0||!uy.has(t))return e;const n=new Headers(e?.headers);return n.has("x-agent-inspector-csrf")||n.set("x-agent-inspector-csrf","1"),{...e,headers:n}}async function yl(e,t){const n=await e.json();return t.parse(n)}async function wl(e,t){try{const n=await e.json(),s=cy.safeParse(n);return s.success?s.data.error:t}catch{return t}}async function ot(e,t,n,s){const o=await fetch(e,Jf(n));if(!o.ok){const i=s?.(o)??`Request failed with status ${o.status}`;throw new Error(await wl(o,i))}return yl(o,t)}function dy(e){return e<1e3?`${String(e)}ms`:`${String(Math.round(e/1e3))}s`}class Zo extends Error{constructor(t){super(`Request timed out after ${dy(t)}`),this.name="ApiTimeoutError"}}async function Un(e,t,n){const s=new AbortController;let o=!1;const i=setTimeout(()=>{o=!0,s.abort()},t),a=n?.signal??void 0,l=()=>s.abort();a!==void 0&&(a.aborted?s.abort():a.addEventListener("abort",l,{once:!0}));try{return await fetch(e,{...Jf(n),signal:s.signal})}catch(u){throw o&&u instanceof DOMException&&u.name==="AbortError"?new Zo(t):u}finally{clearTimeout(i),a?.removeEventListener("abort",l)}}async function qe(e,t,n,s,o){const i=await Un(e,n,s);if(!i.ok){const a=o?.(i)??`Request failed with status ${i.status}`;throw new Error(await wl(i,a))}return yl(i,t)}const Yf=T({input:R().int().nonnegative(),output:R().int().nonnegative(),cacheCreate:R().int().nonnegative(),cacheRead:R().int().nonnegative(),total:R().int().nonnegative()}),fy=T({id:R().int().positive(),sessionLogNumber:R().int().positive().optional(),timestamp:x(),provider:x().nullable(),model:x().nullable(),apiFormat:pe(["anthropic","openai","unknown"]),method:x(),path:x(),status:R().nullable(),isStreaming:Te(),hasError:Te(),error:x().nullable(),latencyMs:R().nullable(),firstChunkMs:R().nullable().optional(),totalStreamMs:R().nullable().optional(),tokensPerSecond:R().nullable().optional(),tokens:T({input:R().nullable(),output:R().nullable(),cacheCreate:R().nullable(),cacheRead:R().nullable()}),sessionId:x().nullable(),userAgent:x().nullable().optional(),clientPid:R().nullable().optional(),clientProjectFolder:x().nullable().optional()}),Xf=T({id:x(),status:pe(["active","failed","completed","empty"]),logCoverage:pe(["recent","history"]),source:pe(["explicit","client-process","client-connection","provider-test"]).nullable(),runtimeMode:pe(["in-process","worker-thread","child-process"]).nullable(),createdAt:x().nullable(),updatedAt:x().nullable(),requestCount:R().int().nonnegative(),activeRequests:R().int().nonnegative(),completedRequests:R().int().nonnegative(),failedRequests:R().int().nonnegative(),queuedTasks:R().int().nonnegative(),runningTasks:R().int().nonnegative(),lastTaskError:x().nullable(),logCount:R().int().nonnegative(),errorCount:R().int().nonnegative(),models:H(x()),providers:H(x()),tokenUsage:Yf,lastLogId:R().nullable(),lastModel:x().nullable(),clientUserAgent:x().nullable().optional(),clientPid:R().nullable(),clientProjectFolder:x().nullable(),inspectorPath:x(),inspectorUrl:x(),apiPath:x(),apiUrl:x(),compactLogsPath:x(),compactLogsUrl:x(),latestLogLimit:R().int().positive(),latestLogs:H(fy)}),fr=pe(["created","running","completed","failed","cancelled"]),jl=T({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),py=pe(["run-created","session-started","request","session-finished","evidence-exported"]),my=pe(["info","success","warning","error"]),hy=T({timestamp:x(),kind:py,severity:my,title:x(),details:x(),logId:R().int().positive().nullable(),status:R().nullable(),model:x().nullable(),provider:x().nullable(),latencyMs:R().nullable(),isStreaming:Te().nullable()}),gy=pe(["none","active","provider-timeout","provider-http-error","provider-auth-error","provider-rate-limit","network-or-container","streaming-mismatch","context-pressure","runtime-task-error","model-output-error","unknown-failure","no-session-data"]),Qf=T({outcome:pe(["success","failure","active","unknown"]),severity:pe(["none","low","medium","high"]),category:gy,summary:x(),evidenceLogIds:H(R().int().positive()),hints:H(x())}),kl=T({status:pe(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:x(),markdown:x()}),ep=kl,Sl=T({id:x(),sessionId:x(),groupId:x().nullable().default(null),title:x(),task:x().nullable(),project:x().nullable(),agent:x().nullable(),status:fr,tags:H(x()),metadata:We(x(),tt),evidence:jl.nullable(),createdAt:x(),updatedAt:x()});T({runId:x().min(1).optional(),sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:fr.optional(),tags:H(x()).optional(),metadata:We(x(),tt).optional()}).optional();T({sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:fr.optional(),tags:H(x()).optional(),metadata:We(x(),tt).optional()});T({includeHistory:Te().optional(),latestLogLimit:R().int().positive().max(50).optional()}).optional();T({run:Sl,evidence:jl,session:Xf.nullable(),timeline:H(hy),classification:Qf,jenkinsReport:kl});const xy=T({run:Sl,classification:Qf,evidence:jl.nullable(),jenkinsReport:kl.nullable(),sessionId:x(),inspectorUrl:x().nullable(),evidenceMarkdownPath:x().nullable(),updatedAt:x()});T({failures:H(xy),total:R().int().nonnegative(),limit:R().int().positive()});const _l=pe(["created","running","completed","failed","cancelled"]),Nl=pe(["evaluation","batch","manual"]),Cl=T({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),tp=T({id:x(),groupId:x(),sessionId:x(),runId:x().nullable(),label:x().nullable(),agent:x().nullable(),provider:x().nullable(),model:x().nullable(),status:fr.nullable(),metadata:We(x(),tt),addedAt:x(),updatedAt:x()}),Tl=T({id:x(),title:x(),kind:Nl,task:x().nullable(),project:x().nullable(),status:_l,tags:H(x()),metadata:We(x(),tt),evidence:Cl.nullable(),members:H(tp),createdAt:x(),updatedAt:x()});T({groupId:x().min(1).optional(),title:x().min(1).optional(),kind:Nl.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:_l.optional(),tags:H(x()).optional(),metadata:We(x(),tt).optional()}).optional();T({title:x().min(1).optional(),kind:Nl.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:_l.optional(),tags:H(x()).optional(),metadata:We(x(),tt).optional()});T({memberId:x().min(1).optional(),sessionId:x().min(1),runId:x().min(1).nullable().optional(),label:x().min(1).nullable().optional(),agent:x().min(1).nullable().optional(),provider:x().min(1).nullable().optional(),model:x().min(1).nullable().optional(),status:fr.nullable().optional(),metadata:We(x(),tt).optional()});T({includeHistory:Te().optional(),latestLogLimit:R().int().positive().max(50).optional()}).optional();T({deleteEvidence:Te().optional()});const np=T({groupId:x(),deleted:Te(),evidenceDeleted:Te(),evidencePath:x().nullable()}),sp=T({deleted:R().int().nonnegative(),groups:H(np)}),rp=T({member:tp,run:Sl.nullable(),session:Xf.nullable()}),op=T({memberCount:R().int().nonnegative(),sessionsWithData:R().int().nonnegative(),missingSessions:R().int().nonnegative(),requestCount:R().int().nonnegative(),errorCount:R().int().nonnegative(),tokenUsage:Yf,models:H(x()),providers:H(x()),completedMembers:R().int().nonnegative(),failedMembers:R().int().nonnegative(),runningMembers:R().int().nonnegative()}),by=T({group:Tl,evidence:Cl,members:H(rp).nullable(),markdown:x(),summary:op.nullable(),report:ep.nullable()}),vy=T({group:Tl,evidence:Cl,members:H(rp),summary:op,jenkinsReport:ep}),ip=T({groups:H(Tl)}),yy=T({sessionId:x(),imported:R().int().nonnegative(),skipped:R().int().nonnegative(),warnings:H(x()),logs:H(sr)}),xo=10,ja=600,bo=60,ka=600,vo="time",El="simple",ap=pe(["time","full"]),wy=pe(["simple","full"]),Ko=T({stripClaudeCodeBillingHeader:Te(),hasSeenOnboarding:Te().default(!1),slowResponseThresholdSeconds:R().int().min(0).max(ja).default(xo),providerTestTimeoutSeconds:R().int().min(1).max(ka).default(bo),timeDisplayFormat:ap.default(vo),captureMode:wy.default(El)}),ps="/api/config";async function jy(e){return ot(e,Ko,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function Cr(e){return ot(ps,Ko,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function Rl(){const e=Bt(ps,jy,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=Xd(),n=e.data?.stripClaudeCodeBillingHeader??!1,s=e.data?.captureMode??El,o=e.data?.slowResponseThresholdSeconds??xo,i=e.data?.providerTestTimeoutSeconds??bo,a=e.data?.timeDisplayFormat??vo,l=m=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??xo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??bo,timeDisplayFormat:e.data?.timeDisplayFormat??vo,captureMode:s,...m}),u=async m=>{await t(ps,Cr({stripClaudeCodeBillingHeader:m}),{optimisticData:l({stripClaudeCodeBillingHeader:m}),rollbackOnError:!0,revalidate:!1})},d=async m=>{await t(ps,Cr({slowResponseThresholdSeconds:m}),{optimisticData:l({slowResponseThresholdSeconds:m}),rollbackOnError:!0,revalidate:!1})},f=async m=>{await t(ps,Cr({timeDisplayFormat:m}),{optimisticData:l({timeDisplayFormat:m}),rollbackOnError:!0,revalidate:!1})},p=async m=>{await t(ps,Cr({providerTestTimeoutSeconds:m}),{optimisticData:l({providerTestTimeoutSeconds:m}),rollbackOnError:!0,revalidate:!1})};return{strip:n,captureMode:s,slowResponseThresholdSeconds:o,providerTestTimeoutSeconds:i,timeDisplayFormat:a,isLoading:e.isLoading,isError:e.error!==void 0,setStrip:u,setSlowResponseThresholdSeconds:d,setProviderTestTimeoutSeconds:p,setTimeDisplayFormat:f}}const lp=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();const ky=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Sy=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());const tu=e=>{const t=Sy(e);return t.charAt(0).toUpperCase()+t.slice(1)};var _y={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Ny=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const Cy=c.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:o="",children:i,iconNode:a,...l},u)=>c.createElement("svg",{ref:u,..._y,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:lp("lucide",o),...!i&&!Ny(l)&&{"aria-hidden":"true"},...l},[...a.map(([d,f])=>c.createElement(d,f)),...Array.isArray(i)?i:[i]]));const U=(e,t)=>{const n=c.forwardRef(({className:s,...o},i)=>c.createElement(Cy,{ref:i,iconNode:t,className:lp(`lucide-${ky(tu(e))}`,`lucide-${e}`,s),...o}));return n.displayName=tu(e),n};const Ty=[["path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16",key:"xik6mr"}],["path",{d:"M15.697 14h5.606",key:"1stdlc"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}]],Ey=U("a-large-small",Ty);const Ry=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Py=U("activity",Ry);const My=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],Iy=U("arrow-down-right",My);const Ay=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Oy=U("arrow-down",Ay);const zy=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Ly=U("arrow-left",zy);const $y=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],Dy=U("arrow-up-right",$y);const Fy=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Uy=U("arrow-up",Fy);const By=[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]],Pl=U("beaker",By);const Vy=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],qy=U("bell",Vy);const Hy=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]],Wy=U("blocks",Hy);const Zy=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]],Ky=U("brain-circuit",Zy);const Gy=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],cp=U("brain",Gy);const Jy=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ge=U("check",Jy);const Yy=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],nt=U("chevron-down",Yy);const Xy=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Qy=U("chevron-left",Xy);const ew=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],yt=U("chevron-right",ew);const tw=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Ml=U("chevron-up",tw);const nw=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],sw=U("chevrons-down",nw);const rw=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],ow=U("chevrons-left",rw);const iw=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],aw=U("chevrons-right",iw);const lw=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],cw=U("chevrons-up",lw);const uw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Ns=U("circle-alert",uw);const dw=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],pr=U("circle-check-big",dw);const fw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Sa=U("circle-check",fw);const pw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],mw=U("circle-question-mark",pw);const hw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],gw=U("circle-stop",hw);const xw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],up=U("circle-x",xw);const bw=[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]],vw=U("clapperboard",bw);const yw=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ww=U("clock-3",yw);const jw=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],rn=U("clock",jw);const kw=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],Sw=U("cloud-upload",kw);const _w=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],dp=U("code-xml",_w);const Nw=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Cw=U("columns-2",Nw);const Tw=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Ot=U("copy",Tw);const Ew=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Rw=U("cpu",Ew);const Pw=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],mr=U("download",Pw);const Mw=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Iw=U("ellipsis",Mw);const Aw=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Il=U("external-link",Aw);const Ow=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],zw=U("eye-off",Ow);const Lw=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],fp=U("eye",Lw);const $w=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],Dw=U("file-braces",$w);const Fw=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]],Uw=U("file-diff",Fw);const Bw=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],Vw=U("file-search",Bw);const qw=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m8 16 2-2-2-2",key:"10vzyd"}],["path",{d:"M12 18h4",key:"1wd2n7"}]],Hw=U("file-terminal",qw);const Ww=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Zw=U("file-text",Ww);const Kw=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],Gw=U("flag",Kw);const Jw=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],pp=U("flask-conical",Jw);const Yw=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Xw=U("folder-open",Yw);const Qw=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Al=U("gauge",Qw);const ej=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]],tj=U("git-compare-arrows",ej);const nj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],mp=U("globe",nj);const sj=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],hp=U("history",sj);const rj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],oj=U("info",rj);const ij=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],nu=U("layers",ij);const aj=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ue=U("loader-circle",aj);const lj=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],cj=U("lock",lj);const uj=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Go=U("message-square",uj);const dj=[["path",{d:"M5 12h14",key:"1ays0h"}]],gp=U("minus",dj);const fj=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],pj=U("monitor",fj);const mj=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],hj=U("moon",mj);const gj=[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]],xj=U("mouse-pointer-click",gj);const bj=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],vj=U("network",bj);const yj=[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],wj=U("octagon-alert",yj);const jj=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],kj=U("package-check",jj);const Sj=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],_j=U("panel-right-close",Sj);const Nj=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Cj=U("panel-right-open",Nj);const Tj=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],xp=U("pencil",Tj);const Ej=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],su=U("plus",Ej);const Rj=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],ru=U("radio",Rj);const Pj=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Vt=U("refresh-cw",Pj);const Mj=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],bp=U("rocket",Mj);const Ij=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],vp=U("rotate-ccw",Ij);const Aj=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],yo=U("rotate-cw",Aj);const Oj=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],zj=U("rows-3",Oj);const Lj=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],$j=U("save",Lj);const Dj=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],Fj=U("scan",Dj);const Uj=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],yp=U("search",Uj);const Bj=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Vj=U("send",Bj);const qj=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Hj=U("server",qj);const Wj=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Zj=U("settings",Wj);const Kj=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Gj=U("shield-alert",Kj);const Jj=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ou=U("shield-check",Jj);const Yj=[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]],_a=U("siren",Yj);const Xj=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Na=U("sparkles",Xj);const Qj=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],e5=U("sun",Qj);const t5=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Xn=U("terminal",t5);const n5=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],s5=U("timer",n5);const r5=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],jn=U("trash-2",r5);const o5=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],wn=U("triangle-alert",o5);const i5=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],wp=U("upload",i5);const a5=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],l5=U("wifi-off",a5);const c5=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],u5=U("wifi",c5);const d5=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],hr=U("wrench",d5);const f5=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],gr=U("x",f5);const p5=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],rr=U("zap",p5),Ca="/api/config";async function m5(e){return ot(e,Ko,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function h5(e){return ot(Ca,Ko,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function g5(){const e=Bt(Ca,m5,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=Xd(),n=e.data?.hasSeenOnboarding??!1,s=e.data?.captureMode??El,o=async()=>{await t(Ca,h5({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??xo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??bo,timeDisplayFormat:e.data?.timeDisplayFormat??vo,captureMode:s},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:n,captureMode:s,isLoading:e.isLoading,markSeen:o}}function x5({expanded:e,onToggle:t,onDismiss:n}){const s=e?"grid":"hidden sm:grid";return r.jsx("div",{role:"note","aria-label":"Onboarding tip",className:"mx-3 mt-2 mb-1 rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-sm shadow-sm sm:mx-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(oj,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":"true"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:"font-medium text-foreground",children:"Inspector ready"}),r.jsx("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:"Request, response, tool, timing, token, replay, and memory signals are active."})]}),r.jsx("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground sm:hidden",children:"Core capture is active."}),r.jsxs("div",{className:`${s} mt-2 gap-x-4 gap-y-1 text-xs leading-relaxed text-muted-foreground sm:grid-cols-2`,children:[r.jsxs("div",{children:[r.jsx("strong",{children:"Evidence"}),": logs, sessions, groups, and MCP exports are available."]}),r.jsxs("div",{children:[r.jsx("strong",{children:"Network"}),": replace ",r.jsx("code",{children:"localhost"})," if containers differ."]})]})]}),r.jsx("button",{type:"button",onClick:t,className:"inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-warning/35 px-2 text-xs font-medium text-foreground transition-colors hover:bg-warning/15 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:hidden","aria-expanded":e,"aria-label":e?"Hide onboarding details":"Show onboarding details",children:r.jsx(nt,{className:`size-3.5 transition-transform ${e?"rotate-180":""}`})}),r.jsxs("button",{type:"button",onClick:n,className:"hidden h-8 shrink-0 items-center gap-1.5 rounded-md border border-warning/40 px-3 text-xs font-medium text-foreground transition-colors hover:bg-warning/15 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:inline-flex","aria-label":"Dismiss onboarding tip",children:[r.jsx(Ge,{className:"size-3.5"}),"Got it"]}),r.jsx("button",{type:"button",onClick:n,className:"-m-1 shrink-0 rounded-sm p-1 text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Dismiss",children:r.jsx(gr,{className:"size-3.5"})})]})})}function b5(){const{hasSeenOnboarding:e,isLoading:t,markSeen:n}=g5(),[s,o]=c.useState(!1);return t||e?null:r.jsx(x5,{expanded:s,onToggle:()=>o(i=>!i),onDismiss:()=>{n()}})}const v5="3.0.31",jp={version:v5};function Gs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const kp="[REDACTED]",y5=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,w5=[/Bearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,/\bsk-[A-Za-z0-9_-]{12,}\b/g,/\bsk-ant-[A-Za-z0-9_-]{12,}\b/g,/\bghp_[A-Za-z0-9_]{12,}\b/g,/\bglpat-[A-Za-z0-9_-]{12,}\b/g],iu=200,j5=25e6,Sp=50,k5=1e4;function S5(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function _5(e){let t=0;for(const n of e)t+=n.rawRequestBody?.length??0,t+=n.responseText?.length??0;return t}function N5(e){if(e.length>iu)return`Export is limited to ${iu} logs at once. Narrow the filter and try again.`;const t=_5(e);return t>j5?`Export is too large (${S5(t)} of text). Narrow the filter and try again.`:null}function Tr(e){return e?.aborted===!0?{ok:!1,message:"Export canceled.",canceled:!0}:null}async function C5(e,t){try{const n=await Un(`/api/logs/${e}/chunks`,k5,{signal:t});if(!n.ok)return null;const s=await n.json();return JSON.stringify(s,null,2)}catch{return null}}function Ta(e){if(Array.isArray(e))return e.map(n=>Ta(n));if(!Gs(e))return e;const t={};for(const[n,s]of Object.entries(e))t[n]=y5.test(n)?kp:Ta(s);return t}function T5(e){const t=n=>{let s=n;for(const o of w5)s=s.replace(o,kp);return s};try{const n=JSON.parse(e);return t(JSON.stringify(Ta(n),null,2))}catch{return t(e)}}function Mi(e,t){return t==="redacted"?T5(e):e}function E5(e,t){return{...e,rawRequestBody:null,responseText:null,rawHeaders:t==="raw"?e.rawHeaders:void 0,headers:t==="raw"?e.headers:void 0,streamingChunks:void 0,bodyContentMode:"compact"}}function R5(e,t,n,s=new Date().toISOString()){return{version:jp.version,exportedAt:s,mode:t,redacted:t==="redacted",logCount:e.length,logIds:e.map(o=>o.id),streamingChunkExportLimit:Sp,streamingChunkLogIds:n.map(o=>o.id)}}async function P5(e,t="redacted",n={}){const s=Tr(n.signal);if(s!==null)return s;const o=N5(e);if(o!==null)return{ok:!1,message:o};const{default:i}=await Gt(async()=>{const{default:h}=await import("./jszip.min-DnSIoTix.js").then(g=>g.j);return{default:h}},__vite__mapDeps([0,1])),a=new i,l=t==="redacted"?"redacted":"raw",u=e.filter(h=>h.streaming).slice(0,Sp);a.file("manifest.json",JSON.stringify(R5(e,t,u),null,2)),a.file("logs.json",JSON.stringify(e.map(h=>E5(h,t)),null,2));for(const h of e){const g=Tr(n.signal);if(g!==null)return g;h.rawRequestBody!==null&&a.file(`#${h.id}.Request.json`,Mi(h.rawRequestBody,t)),h.responseText!==null&&a.file(`#${h.id}.Response.json`,Mi(h.responseText,t))}for(const h of u){const g=Tr(n.signal);if(g!==null)return g;const y=await C5(h.id,n.signal);y!==null&&a.file(`#${h.id}.SSE.Response.json`,Mi(y,t))}const d=await a.generateAsync({type:"blob"}),f=Tr(n.signal);if(f!==null)return f;const p=URL.createObjectURL(d),m=document.createElement("a");return m.href=p,m.download=`agent-inspector-export-${l}-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(p),{ok:!0}}function Ea(e,t){switch(t){case"full":return e;case"time":return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function Jo(e,t,n){return`${Ea(e,n)} - ${Ea(t,n)}`}function M5(){const[e,t]=c.useState(Cg),n=c.useCallback(s=>{t(s),Ti(s),Tg(s)},[]);return c.useEffect(()=>{Ti(e)},[e]),c.useEffect(()=>{function s(o){if(o.key!==Eg)return;const i=Rg(o.newValue);t(i),Ti(i)}return window.addEventListener("storage",s),()=>window.removeEventListener("storage",s)},[]),{themeMode:e,setThemeMode:n}}function I5(){const[e,t]=c.useState(Pg),[n,s]=c.useState(1),o=c.useCallback(i=>{t(i),Mg(i),s(Ei(i))},[]);return c.useEffect(()=>{const i=()=>{s(Ei(e))};if(i(),e==="auto")return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[e]),c.useEffect(()=>{const i=a=>{if(a.key!==Ig)return;const l=Qd(a.newValue);t(l),s(Ei(l))};return window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[]),{uiScalePreference:e,resolvedUiScale:n,setUiScalePreference:o}}const Bn=64,Ra=256,A5=64,O5=pe(["invalid-page-request","search-limit-exceeded","provider-model-limit-exceeded","sse-capacity-exceeded","provider-test-capacity-exceeded"]),z5=At([ae(400),ae(413),ae(429),ae(503)]);T({error:x().min(1).max(300),code:O5,status:z5,resource:x().min(1).max(80),limit:R().int().positive(),retryable:Te()});function Er(){return x().refine(e=>{if(e.length===0)return!0;try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}},"Must be a valid http(s) URL")}const Ol=x().max(Ra),L5=H(Ol).max(Bn),$5=T({model:Ol.min(1),contextWindow:R().int().positive().optional(),outputLimit:R().int().positive().optional(),source:pe(["manual","registry"]).optional(),sourceUrl:x().optional(),updatedAt:x().optional()}),D5=H($5).max(A5),F5=T({id:x(),name:x(),apiKey:x(),model:Ol.optional(),models:L5.optional().default([]),format:pe(["anthropic","openai"]).optional(),baseUrl:Er().optional(),anthropicBaseUrl:Er().optional(),openaiBaseUrl:Er().optional(),openaiResponsesBaseUrl:Er().optional(),authHeader:pe(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:x().optional(),modelMetadataUrl:x().optional(),modelMetadata:D5.optional(),source:pe(["company","personal"]).optional(),createdAt:x(),updatedAt:x()}),U5="configured",wo=F5.extend({apiKey:ae(U5)});async function B5(e){return ot(e,wo.array(),void 0,t=>`Failed to fetch ${e}: ${t.status}`)}function zl(){const e=Bt("/api/providers",B5,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function au(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function V5(...e){return t=>{let n=!1;const s=e.map(o=>{const i=au(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<s.length;o++){const i=s[o];typeof i=="function"?i():au(e[o],null)}}}}function Pe(...e){return c.useCallback(V5(...e),e)}function Cs(e){const t=c.forwardRef((n,s)=>{let{children:o,...i}=n,a=null,l=!1;const u=[];lu(o)&&typeof Rr=="function"&&(o=Rr(o._payload)),c.Children.forEach(o,m=>{if(G5(m)){l=!0;const h=m;let g="child"in h.props?h.props.child:h.props.children;lu(g)&&typeof Rr=="function"&&(g=Rr(g._payload)),a=W5(h,g),u.push(a?.props?.children)}else u.push(m)}),a?a=c.cloneElement(a,void 0,u):!l&&c.Children.count(o)===1&&c.isValidElement(o)&&(a=o);const d=a?K5(a):void 0,f=Pe(s,d);if(!a){if(o||o===0)throw new Error(l?Q5(e):X5(e));return o}const p=Z5(i,a.props??{});return a.type!==c.Fragment&&(p.ref=s?f:d),c.cloneElement(a,p)});return t.displayName=`${e}.Slot`,t}var q5=Cs("Slot"),_p=Symbol.for("radix.slottable");function H5(e){const t=n=>"child"in n?n.children(n.child):n.children;return t.displayName=`${e}.Slottable`,t.__radixId=_p,t}var W5=(e,t)=>{if("child"in e.props){const n=e.props.child;return c.isValidElement(n)?c.cloneElement(n,void 0,e.props.children(n.props.children)):null}return c.isValidElement(t)?t:null};function Z5(e,t){const n={...t};for(const s in t){const o=e[s],i=t[s];/^on[A-Z]/.test(s)?o&&i?n[s]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[s]=o):s==="style"?n[s]={...o,...i}:s==="className"&&(n[s]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function K5(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function G5(e){return c.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===_p}var J5=Symbol.for("react.lazy");function lu(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===J5&&"_payload"in e&&Y5(e._payload)}function Y5(e){return typeof e=="object"&&e!==null&&"then"in e}var X5=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,Q5=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,Rr=Bo[" use ".trim().toString()],ek=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ge=ek.reduce((e,t)=>{const n=Cs(`Primitive.${t}`),s=c.forwardRef((o,i)=>{const{asChild:a,...l}=o,u=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...l,ref:i})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function tk(e,t){e&&Os.flushSync(()=>e.dispatchEvent(t))}var Np=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),nk="VisuallyHidden",Cp=c.forwardRef((e,t)=>r.jsx(ge.span,{...e,ref:t,style:{...Np,...e.style}}));Cp.displayName=nk;var sk=Cp;function dn(e,t=[]){let n=[];function s(i,a){const l=c.createContext(a);l.displayName=i+"Context";const u=n.length;n=[...n,a];const d=p=>{const{scope:m,children:h,...g}=p,y=m?.[e]?.[u]||l,b=c.useMemo(()=>g,Object.values(g));return r.jsx(y.Provider,{value:b,children:h})};d.displayName=i+"Provider";function f(p,m,h={}){const{optional:g=!1}=h,y=m?.[e]?.[u]||l,b=c.useContext(y);if(b)return b;if(a!==void 0)return a;if(!g)throw new Error(`\`${p}\` must be used within \`${i}\``)}return[d,f]}const o=()=>{const i=n.map(a=>c.createContext(a));return function(l){const u=l?.[e]||i;return c.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return o.scopeName=e,[s,rk(o,...t)]}function rk(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const a=s.reduce((l,{useScope:u,scopeName:d})=>{const p=u(i)[`__scope${d}`];return{...l,...p}},{});return c.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}function Tp(e){const t=e+"CollectionProvider",[n,s]=dn(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=y=>{const{scope:b,children:w}=y,v=c.useRef(null),j=c.useRef(new Map).current;return r.jsx(o,{scope:b,itemMap:j,collectionRef:v,children:w})};a.displayName=t;const l=e+"CollectionSlot",u=Cs(l),d=c.forwardRef((y,b)=>{const{scope:w,children:v}=y,j=i(l,w),S=Pe(b,j.collectionRef);return r.jsx(u,{ref:S,children:v})});d.displayName=l;const f=e+"CollectionItemSlot",p="data-radix-collection-item",m=Cs(f),h=c.forwardRef((y,b)=>{const{scope:w,children:v,...j}=y,S=c.useRef(null),k=Pe(b,S),_=i(f,w);return c.useEffect(()=>(_.itemMap.set(S,{ref:S,...j}),()=>{_.itemMap.delete(S)})),r.jsx(m,{[p]:"",ref:k,children:v})});h.displayName=f;function g(y){const b=i(e+"CollectionConsumer",y);return c.useCallback(()=>{const v=b.collectionRef.current;if(!v)return[];const j=Array.from(v.querySelectorAll(`[${p}]`));return Array.from(b.itemMap.values()).sort((_,C)=>j.indexOf(_.ref.current)-j.indexOf(C.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:a,Slot:d,ItemSlot:h},g,s]}function fe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o||!o.defaultPrevented)return t?.(o)}}var Je=globalThis?.document?c.useLayoutEffect:()=>{},ok=Bo[" useInsertionEffect ".trim().toString()]||Je;function qn({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[o,i,a]=ik({defaultProp:t,onChange:n}),l=e!==void 0,u=l?e:o;{const f=c.useRef(e!==void 0);c.useEffect(()=>{const p=f.current;p!==l&&console.warn(`${s} is changing from ${p?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=l},[l,s])}const d=c.useCallback(f=>{if(l){const p=ak(f)?f(e):f;p!==e&&a.current?.(p)}else i(f)},[l,e,i,a]);return[u,d]}function ik({defaultProp:e,onChange:t}){const[n,s]=c.useState(e),o=c.useRef(n),i=c.useRef(t);return ok(()=>{i.current=t},[t]),c.useEffect(()=>{o.current!==n&&(i.current?.(n),o.current=n)},[n,o]),[n,s,i]}function ak(e){return typeof e=="function"}function lk(e,t){return c.useReducer((n,s)=>t[n][s]??n,e)}var wt=e=>{const{present:t,children:n}=e,s=ck(t),o=typeof n=="function"?n({present:s.isPresent}):c.Children.only(n),i=uk(s.ref,dk(o));return typeof n=="function"||s.isPresent?c.cloneElement(o,{ref:i}):null};wt.displayName="Presence";function ck(e){const[t,n]=c.useState(),s=c.useRef(null),o=c.useRef(e),i=c.useRef("none"),a=c.useRef(void 0),l=e?"mounted":"unmounted",[u,d]=lk(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return c.useEffect(()=>{u==="mounted"?(i.current=a.current??Us(s.current),a.current=void 0):i.current="none"},[u]),Je(()=>{const f=s.current,p=o.current;if(p!==e){const h=i.current,g=Us(f);e?(a.current=g,d("MOUNT")):g==="none"||f?.display==="none"?d("UNMOUNT"):d(p&&h!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),Je(()=>{if(t){let f;const p=t.ownerDocument.defaultView??window,m=g=>{const b=Us(s.current).includes(CSS.escape(g.animationName));if(g.target===t&&b&&(d("ANIMATION_END"),!o.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",f=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},h=g=>{g.target===t&&(i.current=Us(s.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{p.clearTimeout(f),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:c.useCallback(f=>{if(f){const p=getComputedStyle(f);s.current=p,a.current=Us(p)}else s.current=null;n(f)},[])}}function cu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function uk(...e){const t=c.useRef(e);return t.current=e,c.useCallback(n=>{const s=t.current;let o=!1;const i=s.map(a=>{const l=cu(a,n);return!o&&typeof l=="function"&&(o=!0),l});if(o)return()=>{for(let a=0;a<i.length;a++){const l=i[a];typeof l=="function"?l():cu(s[a],null)}}},[])}function Us(e){return e?.animationName||"none"}function dk(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var fk=Bo[" useId ".trim().toString()]||(()=>{}),pk=0;function qt(e){const[t,n]=c.useState(fk());return Je(()=>{n(s=>s??String(pk++))},[e]),t?`radix-${t}`:""}var Yo="Collapsible",[mk]=dn(Yo),[hk,Ll]=mk(Yo),Ep=c.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:s,defaultOpen:o,disabled:i,onOpenChange:a,...l}=e,[u,d]=qn({prop:s,defaultProp:o??!1,onChange:a,caller:Yo});return r.jsx(hk,{scope:n,disabled:i,contentId:qt(),open:u,onOpenToggle:c.useCallback(()=>d(f=>!f),[d]),children:r.jsx(ge.div,{"data-state":Dl(u),"data-disabled":i?"":void 0,...l,ref:t})})});Ep.displayName=Yo;var Rp="CollapsibleTrigger",Pp=c.forwardRef((e,t)=>{const{__scopeCollapsible:n,...s}=e,o=Ll(Rp,n);return r.jsx(ge.button,{type:"button","aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open||!1,"data-state":Dl(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...s,ref:t,onClick:fe(e.onClick,o.onOpenToggle)})});Pp.displayName=Rp;var $l="CollapsibleContent",Mp=c.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=Ll($l,e.__scopeCollapsible);return r.jsx(wt,{present:n||o.open,children:({present:i})=>r.jsx(gk,{...s,ref:t,present:i})})});Mp.displayName=$l;var gk=c.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:s,children:o,...i}=e,a=Ll($l,n),[l,u]=c.useState(s),d=c.useRef(null),f=Pe(t,d),p=c.useRef(0),m=p.current,h=c.useRef(0),g=h.current,y=a.open||l,b=c.useRef(y),w=c.useRef(void 0);return c.useEffect(()=>{const v=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(v)},[]),Je(()=>{const v=d.current;if(v){w.current=w.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const j=v.getBoundingClientRect();p.current=j.height,h.current=j.width,b.current||(v.style.transitionDuration=w.current.transitionDuration,v.style.animationName=w.current.animationName),u(s)}},[a.open,s]),r.jsx(ge.div,{"data-state":Dl(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!y,...i,ref:f,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:y&&o})});function Dl(e){return e?"open":"closed"}var xk=Ep,bk=c.createContext(void 0);function Xo(e){const t=c.useContext(bk);return e||t||"ltr"}function et(e){const t=c.useRef(e);return c.useEffect(()=>{t.current=e}),c.useMemo(()=>((...n)=>t.current?.(...n)),[])}var vk="DismissableLayer",Pa="dismissableLayer.update",yk="dismissableLayer.pointerDownOutside",wk="dismissableLayer.focusOutside",uu,Fl=c.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Qo=c.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:s=!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:l,onDismiss:u,...d}=e,f=c.useContext(Fl),[p,m]=c.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=c.useState({}),y=Pe(t,m),b=Array.from(f.layers),[w]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),v=w?b.indexOf(w):-1,j=p?b.indexOf(p):-1,S=f.layersWithOutsidePointerEventsDisabled.size>0,k=j>=v,_=c.useRef(!1),C=Nk(N=>{i?.(N),l?.(N),N.defaultPrevented||u?.()},{ownerDocument:h,deferPointerDownOutside:s,isDeferredPointerDownOutsideRef:_,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:c.useCallback(N=>{if(!(N instanceof Node))return!1;const M=[...f.branches].some(F=>F.contains(N));return k&&!M},[f.branches,k])}),I=Ck(N=>{if(s&&_.current)return;const M=N.target;[...f.branches].some(B=>B.contains(M))||(a?.(N),l?.(N),N.defaultPrevented||u?.())},h),A=p?j===b.length-1:!1,P=et(N=>{N.key==="Escape"&&(o?.(N),!N.defaultPrevented&&u&&(N.preventDefault(),u()))});return c.useEffect(()=>{if(A)return h.addEventListener("keydown",P,{capture:!0}),()=>h.removeEventListener("keydown",P,{capture:!0})},[h,A,P]),c.useEffect(()=>{if(p)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(uu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),du(),()=>{n&&(f.layersWithOutsidePointerEventsDisabled.delete(p),f.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=uu))}},[p,h,n,f]),c.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),du())},[p,f]),c.useEffect(()=>{const N=()=>g({});return document.addEventListener(Pa,N),()=>document.removeEventListener(Pa,N)},[]),r.jsx(ge.div,{...d,ref:y,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:fe(e.onFocusCapture,I.onFocusCapture),onBlurCapture:fe(e.onBlurCapture,I.onBlurCapture),onPointerDownCapture:fe(e.onPointerDownCapture,C.onPointerDownCapture)})});Qo.displayName=vk;var jk="DismissableLayerBranch",kk=c.forwardRef((e,t)=>{const n=c.useContext(Fl),s=c.useRef(null),o=Pe(t,s);return c.useEffect(()=>{const i=s.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),r.jsx(ge.div,{...e,ref:o})});kk.displayName=jk;function Sk(){const e=c.useContext(Fl),[t,n]=c.useState(null);return c.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}var _k=()=>!0;function Nk(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:s=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:i,shouldHandlePointerDownOutside:a=_k}=t,l=et(e),u=c.useRef(!1),d=c.useRef(!1),f=c.useRef(new Map),p=c.useRef(()=>{});return c.useEffect(()=>{function m(){d.current=!1,o.current=!1,f.current.clear()}function h(){return Array.from(f.current.values()).some(Boolean)}function g(j){if(!d.current)return;const S=j.target;S instanceof Node&&[...i].some(_=>_.contains(S))||f.current.set(j.type,!0),j.type==="click"&&window.setTimeout(()=>{d.current&&p.current()},0)}function y(j){d.current&&f.current.set(j.type,!1)}const b=j=>{if(j.target&&!u.current){let S=function(){n.removeEventListener("click",p.current);const _=h();m(),_||Ip(yk,l,k,{discrete:!0})};if(!a(j.target)){n.removeEventListener("click",p.current),m(),u.current=!1;return}const k={originalEvent:j};d.current=!0,o.current=s&&j.button===0,f.current.clear(),!s||j.button!==0?S():(n.removeEventListener("click",p.current),p.current=S,n.addEventListener("click",p.current,{once:!0}))}else n.removeEventListener("click",p.current),m();u.current=!1},w=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const j of w)n.addEventListener(j,g,!0),n.addEventListener(j,y);const v=window.setTimeout(()=>{n.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(v),n.removeEventListener("pointerdown",b),n.removeEventListener("click",p.current);for(const j of w)n.removeEventListener(j,g,!0),n.removeEventListener(j,y)}},[n,l,s,o,i,a]),{onPointerDownCapture:()=>u.current=!0}}function Ck(e,t=globalThis?.document){const n=et(e),s=c.useRef(!1);return c.useEffect(()=>{const o=i=>{i.target&&!s.current&&Ip(wk,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function du(){const e=new CustomEvent(Pa);document.dispatchEvent(e)}function Ip(e,t,n,{discrete:s}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),s?tk(o,i):o.dispatchEvent(i)}var Ii="focusScope.autoFocusOnMount",Ai="focusScope.autoFocusOnUnmount",fu={bubbles:!1,cancelable:!0},Tk="FocusScope",Ul=c.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...a}=e,[l,u]=c.useState(null),d=et(o),f=et(i),p=c.useRef(null),m=Pe(t,u),h=c.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;c.useEffect(()=>{if(s){let y=function(j){if(h.paused||!l)return;const S=j.target;l.contains(S)?p.current=S:gn(p.current,{select:!0})},b=function(j){if(h.paused||!l)return;const S=j.relatedTarget;S!==null&&(l.contains(S)||gn(p.current,{select:!0}))},w=function(j){if(document.activeElement===document.body)for(const k of j)k.removedNodes.length>0&&gn(l)};document.addEventListener("focusin",y),document.addEventListener("focusout",b);const v=new MutationObserver(w);return l&&v.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",b),v.disconnect()}}},[s,l,h.paused]),c.useEffect(()=>{if(l){mu.add(h);const y=document.activeElement;if(!l.contains(y)){const w=new CustomEvent(Ii,fu);l.addEventListener(Ii,d),l.dispatchEvent(w),w.defaultPrevented||(Ek(Ak(Ap(l)),{select:!0}),document.activeElement===y&&gn(l))}return()=>{l.removeEventListener(Ii,d),setTimeout(()=>{const w=new CustomEvent(Ai,fu);l.addEventListener(Ai,f),l.dispatchEvent(w),w.defaultPrevented||gn(y??document.body,{select:!0}),l.removeEventListener(Ai,f),mu.remove(h)},0)}}},[l,d,f,h]);const g=c.useCallback(y=>{if(!n&&!s||h.paused)return;const b=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,w=document.activeElement;if(b&&w){const v=y.currentTarget,[j,S]=Rk(v);j&&S?!y.shiftKey&&w===S?(y.preventDefault(),n&&gn(j,{select:!0})):y.shiftKey&&w===j&&(y.preventDefault(),n&&gn(S,{select:!0})):w===v&&y.preventDefault()}},[n,s,h.paused]);return r.jsx(ge.div,{tabIndex:-1,...a,ref:m,onKeyDown:g})});Ul.displayName=Tk;function Ek(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(gn(s,{select:t}),document.activeElement!==n)return}function Rk(e){const t=Ap(e),n=pu(t,e),s=pu(t.reverse(),e);return[n,s]}function Ap(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const o=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||o?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function pu(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const s of e)if(!(n?!s.checkVisibility({checkVisibilityCSS:!0}):Pk(s,{upTo:t})))return s}function Pk(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Mk(e){return e instanceof HTMLInputElement&&"select"in e}function gn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Mk(e)&&t&&e.select()}}var mu=Ik();function Ik(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=hu(e,t),e.unshift(t)},remove(t){e=hu(e,t),e[0]?.resume()}}}function hu(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function Ak(e){return e.filter(t=>t.tagName!=="A")}var Ok="Portal",ei=c.forwardRef((e,t)=>{const{container:n,...s}=e,[o,i]=c.useState(!1);Je(()=>i(!0),[]);const a=n||o&&globalThis?.document?.body;return a?Os.createPortal(r.jsx(ge.div,{...s,ref:t}),a):null});ei.displayName=Ok;var Pr=0,ns=null;function Op(){c.useEffect(()=>{ns||(ns={start:gu(),end:gu()});const{start:e,end:t}=ns;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Pr++,()=>{Pr===1&&(ns?.start.remove(),ns?.end.remove(),ns=null),Pr=Math.max(0,Pr-1)}},[])}function gu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Ft=function(){return Ft=Object.assign||function(t){for(var n,s=1,o=arguments.length;s<o;s++){n=arguments[s];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Ft.apply(this,arguments)};function zp(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(n[s[o]]=e[s[o]]);return n}function zk(e,t,n){if(n||arguments.length===2)for(var s=0,o=t.length,i;s<o;s++)(i||!(s in t))&&(i||(i=Array.prototype.slice.call(t,0,s)),i[s]=t[s]);return e.concat(i||Array.prototype.slice.call(t))}var no="right-scroll-bar-position",so="width-before-scroll-bar",Lk="with-scroll-bars-hidden",$k="--removed-body-scroll-bar-size";function Oi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Dk(e,t){var n=c.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(s){var o=n.value;o!==s&&(n.value=s,n.callback(s,o))}}}})[0];return n.callback=t,n.facade}var Fk=typeof window<"u"?c.useLayoutEffect:c.useEffect,xu=new WeakMap;function Uk(e,t){var n=Dk(null,function(s){return e.forEach(function(o){return Oi(o,s)})});return Fk(function(){var s=xu.get(n);if(s){var o=new Set(s),i=new Set(e),a=n.current;o.forEach(function(l){i.has(l)||Oi(l,null)}),i.forEach(function(l){o.has(l)||Oi(l,a)})}xu.set(n,e)},[e]),n}function Bk(e){return e}function Vk(e,t){t===void 0&&(t=Bk);var n=[],s=!1,o={read:function(){if(s)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var a=t(i,s);return n.push(a),function(){n=n.filter(function(l){return l!==a})}},assignSyncMedium:function(i){for(s=!0;n.length;){var a=n;n=[],a.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){s=!0;var a=[];if(n.length){var l=n;n=[],l.forEach(i),a=n}var u=function(){var f=a;a=[],f.forEach(i)},d=function(){return Promise.resolve().then(u)};d(),n={push:function(f){a.push(f),d()},filter:function(f){return a=a.filter(f),n}}}};return o}function qk(e){e===void 0&&(e={});var t=Vk(null);return t.options=Ft({async:!0,ssr:!1},e),t}var Lp=function(e){var t=e.sideCar,n=zp(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return c.createElement(s,Ft({},n))};Lp.isSideCarExport=!0;function Hk(e,t){return e.useMedium(t),Lp}var $p=qk(),zi=function(){},ti=c.forwardRef(function(e,t){var n=c.useRef(null),s=c.useState({onScrollCapture:zi,onWheelCapture:zi,onTouchMoveCapture:zi}),o=s[0],i=s[1],a=e.forwardProps,l=e.children,u=e.className,d=e.removeScrollBar,f=e.enabled,p=e.shards,m=e.sideCar,h=e.noRelative,g=e.noIsolation,y=e.inert,b=e.allowPinchZoom,w=e.as,v=w===void 0?"div":w,j=e.gapMode,S=zp(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=m,_=Uk([n,t]),C=Ft(Ft({},S),o);return c.createElement(c.Fragment,null,f&&c.createElement(k,{sideCar:$p,removeScrollBar:d,shards:p,noRelative:h,noIsolation:g,inert:y,setCallbacks:i,allowPinchZoom:!!b,lockRef:n,gapMode:j}),a?c.cloneElement(c.Children.only(l),Ft(Ft({},C),{ref:_})):c.createElement(v,Ft({},C,{className:u,ref:_}),l))});ti.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ti.classNames={fullWidth:so,zeroRight:no};var Wk=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Zk(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Wk();return t&&e.setAttribute("nonce",t),e}function Kk(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Gk(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Jk=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Zk())&&(Kk(t,n),Gk(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Yk=function(){var e=Jk();return function(t,n){c.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Dp=function(){var e=Yk(),t=function(n){var s=n.styles,o=n.dynamic;return e(s,o),null};return t},Xk={left:0,top:0,right:0,gap:0},Li=function(e){return parseInt(e||"",10)||0},Qk=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Li(n),Li(s),Li(o)]},eS=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Xk;var t=Qk(e),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-n+t[2]-t[0])}},tS=Dp(),bs="data-scroll-locked",nS=function(e,t,n,s){var o=e.left,i=e.top,a=e.right,l=e.gap;return n===void 0&&(n="margin"),`
65
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const a of e.seen.entries()){const l=a[1];if(t===a[0]){i(a);continue}if(e.external){const d=e.external.registry.get(a[0])?.id;if(t!==a[0]&&d){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(l.cycle){i(a);continue}if(l.count>1&&e.reused==="ref"){i(a);continue}}}function Tp(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=l=>{const u=e.seen.get(l);if(u.ref===null)return;const d=u.def??u.schema,p={...d},f=u.ref;if(u.ref=null,f){s(f);const h=e.seen.get(f),g=h.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(g)):Object.assign(d,g),Object.assign(d,p),l._zod.parent===f)for(const b in d)b==="$ref"||b==="allOf"||b in p||delete d[b];if(g.$ref&&h.def)for(const b in d)b==="$ref"||b==="allOf"||b in h.def&&JSON.stringify(d[b])===JSON.stringify(h.def[b])&&delete d[b]}const m=l._zod.parent;if(m&&m!==f){s(m);const h=e.seen.get(m);if(h?.schema.$ref&&(d.$ref=h.schema.$ref,h.def))for(const g in d)g==="$ref"||g==="allOf"||g in h.def&&JSON.stringify(d[g])===JSON.stringify(h.def[g])&&delete d[g]}e.override({zodSchema:l,jsonSchema:d,path:u.path??[]})};for(const l of[...e.seen.entries()].reverse())s(l[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const l=e.external.registry.get(t)?.id;if(!l)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(l)}Object.assign(o,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;const a=e.external?.defs??{};for(const l of e.seen.entries()){const u=l[1];u.def&&u.defId&&(u.def.id===u.defId&&delete u.def.id,a[u.defId]=u.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?o.$defs=a:o.definitions=a);try{const l=JSON.parse(JSON.stringify(o));return Object.defineProperty(l,"~standard",{value:{...t["~standard"],jsonSchema:{input:mo(t,"input",e.processors),output:mo(t,"output",e.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function it(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const s=e._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return it(s.element,n);if(s.type==="set")return it(s.valueType,n);if(s.type==="lazy")return it(s.getter(),n);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault")return it(s.innerType,n);if(s.type==="intersection")return it(s.left,n)||it(s.right,n);if(s.type==="record"||s.type==="map")return it(s.keyType,n)||it(s.valueType,n);if(s.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:it(s.in,n)||it(s.out,n);if(s.type==="object"){for(const o in s.shape)if(it(s.shape[o],n))return!0;return!1}if(s.type==="union"){for(const o of s.options)if(it(o,n))return!0;return!1}if(s.type==="tuple"){for(const o of s.items)if(it(o,n))return!0;return!!(s.rest&&it(s.rest,n))}return!1}const Fb=(e,t={})=>n=>{const s=Np({...n,processors:t});return He(e,s),Cp(s,e),Tp(s,e)},mo=(e,t,n={})=>s=>{const{libraryOptions:o,target:i}=s??{},a=Np({...o??{},target:i,io:t,processors:n});return He(e,a),Cp(a,e),Tp(a,e)},Ub={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Bb=(e,t,n,s)=>{const o=n;o.type="string";const{minimum:i,maximum:a,format:l,patterns:u,contentEncoding:d}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),l&&(o.format=Ub[l]??l,o.format===""&&delete o.format,l==="time"&&delete o.format),d&&(o.contentEncoding=d),u&&u.size>0){const p=[...u];p.length===1?o.pattern=p[0].source:p.length>1&&(o.allOf=[...p.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Vb=(e,t,n,s)=>{const o=n,{minimum:i,maximum:a,format:l,multipleOf:u,exclusiveMaximum:d,exclusiveMinimum:p}=e._zod.bag;typeof l=="string"&&l.includes("int")?o.type="integer":o.type="number";const f=typeof p=="number"&&p>=(i??Number.NEGATIVE_INFINITY),m=typeof d=="number"&&d<=(a??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";f?h?(o.minimum=p,o.exclusiveMinimum=!0):o.exclusiveMinimum=p:typeof i=="number"&&(o.minimum=i),m?h?(o.maximum=d,o.exclusiveMaximum=!0):o.exclusiveMaximum=d:typeof a=="number"&&(o.maximum=a),typeof u=="number"&&(o.multipleOf=u)},qb=(e,t,n,s)=>{n.type="boolean"},Hb=(e,t,n,s)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},Wb=(e,t,n,s)=>{n.not={}},Zb=(e,t,n,s)=>{},Kb=(e,t,n,s)=>{const o=e._zod.def,i=op(o.entries);i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i},Gb=(e,t,n,s)=>{const o=e._zod.def,i=[];for(const a of o.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){const a=i[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),i.every(a=>typeof a=="boolean")&&(n.type="boolean"),i.every(a=>a===null)&&(n.type="null"),n.enum=i},Jb=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Yb=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Xb=(e,t,n,s)=>{const o=n,i=e._zod.def,{minimum:a,maximum:l}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof l=="number"&&(o.maxItems=l),o.type="array",o.items=He(i.element,t,{...s,path:[...s.path,"items"]})},Qb=(e,t,n,s)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const d in a)o.properties[d]=He(a[d],t,{...s,path:[...s.path,"properties",d]});const l=new Set(Object.keys(a)),u=new Set([...l].filter(d=>{const p=i.shape[d]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));u.size>0&&(o.required=Array.from(u)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=He(i.catchall,t,{...s,path:[...s.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},ev=(e,t,n,s)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((l,u)=>He(l,t,{...s,path:[...s.path,i?"oneOf":"anyOf",u]}));i?n.oneOf=a:n.anyOf=a},tv=(e,t,n,s)=>{const o=e._zod.def,i=He(o.left,t,{...s,path:[...s.path,"allOf",0]}),a=He(o.right,t,{...s,path:[...s.path,"allOf",1]}),l=d=>"allOf"in d&&Object.keys(d).length===1,u=[...l(i)?i.allOf:[i],...l(a)?a.allOf:[a]];n.allOf=u},nv=(e,t,n,s)=>{const o=n,i=e._zod.def;o.type="object";const a=i.keyType,u=a._zod.bag?.patterns;if(i.mode==="loose"&&u&&u.size>0){const p=He(i.valueType,t,{...s,path:[...s.path,"patternProperties","*"]});o.patternProperties={};for(const f of u)o.patternProperties[f.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=He(i.keyType,t,{...s,path:[...s.path,"propertyNames"]})),o.additionalProperties=He(i.valueType,t,{...s,path:[...s.path,"additionalProperties"]});const d=a._zod.values;if(d){const p=[...d].filter(f=>typeof f=="string"||typeof f=="number");p.length>0&&(o.required=p)}},sv=(e,t,n,s)=>{const o=e._zod.def,i=He(o.innerType,t,s),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},rv=(e,t,n,s)=>{const o=e._zod.def;He(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType},ov=(e,t,n,s)=>{const o=e._zod.def;He(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},iv=(e,t,n,s)=>{const o=e._zod.def;He(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},av=(e,t,n,s)=>{const o=e._zod.def;He(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},lv=(e,t,n,s)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?i?o.out:o.in:o.out;He(a,t,s);const l=t.seen.get(e);l.ref=a},cv=(e,t,n,s)=>{const o=e._zod.def;He(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Ep=(e,t,n,s)=>{const o=e._zod.def;He(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType},uv=(e,t,n,s)=>{const o=e._zod.innerType;He(o,t,s);const i=t.seen.get(e);i.ref=o},dv=O("ZodISODateTime",(e,t)=>{a1.init(e,t),Fe.init(e,t)});function pv(e){return hb(dv,e)}const fv=O("ZodISODate",(e,t)=>{l1.init(e,t),Fe.init(e,t)});function mv(e){return gb(fv,e)}const hv=O("ZodISOTime",(e,t)=>{c1.init(e,t),Fe.init(e,t)});function gv(e){return xb(hv,e)}const xv=O("ZodISODuration",(e,t)=>{u1.init(e,t),Fe.init(e,t)});function bv(e){return bb(xv,e)}const vv=(e,t)=>{cp.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Xg(e,n)},flatten:{value:n=>Yg(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,va,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,va,2)}},isEmpty:{get(){return e.issues.length===0}}})},_t=O("ZodError",vv,{Parent:Error}),yv=ml(_t),wv=hl(_t),jv=qo(_t),kv=Ho(_t),_v=tx(_t),Sv=nx(_t),Nv=sx(_t),Cv=rx(_t),Tv=ox(_t),Ev=ix(_t),Rv=ax(_t),Pv=lx(_t),Kc=new WeakMap;function dr(e,t,n){const s=Object.getPrototypeOf(e);let o=Kc.get(s);if(o||(o=new Set,Kc.set(s,o)),!o.has(t)){o.add(t);for(const i in n){const a=n[i];Object.defineProperty(s,i,{configurable:!0,enumerable:!1,get(){const l=a.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l}),l},set(l){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l})}})}}}const $e=O("ZodType",(e,t)=>(Le.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:mo(e,"input"),output:mo(e,"output")}}),e.toJSONSchema=Fb(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,s)=>yv(e,n,s,{callee:e.parse}),e.safeParse=(n,s)=>jv(e,n,s),e.parseAsync=async(n,s)=>wv(e,n,s,{callee:e.parseAsync}),e.safeParseAsync=async(n,s)=>kv(e,n,s),e.spa=e.safeParseAsync,e.encode=(n,s)=>_v(e,n,s),e.decode=(n,s)=>Sv(e,n,s),e.encodeAsync=async(n,s)=>Nv(e,n,s),e.decodeAsync=async(n,s)=>Cv(e,n,s),e.safeEncode=(n,s)=>Tv(e,n,s),e.safeDecode=(n,s)=>Ev(e,n,s),e.safeEncodeAsync=async(n,s)=>Rv(e,n,s),e.safeDecodeAsync=async(n,s)=>Pv(e,n,s),dr(e,"ZodType",{check(...n){const s=this.def;return this.clone(Nn(s,{checks:[...s.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,s){return Cn(this,n,s)},brand(){return this},register(n,s){return n.add(this,s),this},refine(n,s){return this.check(N2(n,s))},superRefine(n,s){return this.check(C2(n,s))},overwrite(n){return this.check(zs(n))},optional(){return Xc(this)},exactOptional(){return d2(this)},nullable(){return Qc(this)},nullish(){return Xc(Qc(this))},nonoptional(n){return x2(this,n)},array(){return H(this)},or(n){return At([this,n])},and(n){return i2(this,n)},transform(n){return eu(this,c2(n))},default(n){return m2(this,n)},prefault(n){return g2(this,n)},catch(n){return v2(this,n)},pipe(n){return eu(this,n)},readonly(){return j2(this)},describe(n){const s=this.clone();return Ks.add(s,{description:n}),s},meta(...n){if(n.length===0)return Ks.get(this);const s=this.clone();return Ks.add(s,n[0]),s},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return Ks.get(e)?.description},configurable:!0}),e)),Rp=O("_ZodString",(e,t)=>{gl.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(s,o,i)=>Bb(e,s,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,dr(e,"_ZodString",{regex(...s){return this.check(Sb(...s))},includes(...s){return this.check(Tb(...s))},startsWith(...s){return this.check(Eb(...s))},endsWith(...s){return this.check(Rb(...s))},min(...s){return this.check(fo(...s))},max(...s){return this.check(_p(...s))},length(...s){return this.check(Sp(...s))},nonempty(...s){return this.check(fo(1,...s))},lowercase(s){return this.check(Nb(s))},uppercase(s){return this.check(Cb(s))},trim(){return this.check(Ib())},normalize(...s){return this.check(Pb(...s))},toLowerCase(){return this.check(Mb())},toUpperCase(){return this.check(Ab())},slugify(){return this.check(Ob())}})}),Iv=O("ZodString",(e,t)=>{gl.init(e,t),Rp.init(e,t),e.email=n=>e.check(K1(Mv,n)),e.url=n=>e.check(Q1(Av,n)),e.jwt=n=>e.check(mb(Gv,n)),e.emoji=n=>e.check(eb(Ov,n)),e.guid=n=>e.check(qc(Gc,n)),e.uuid=n=>e.check(G1(Nr,n)),e.uuidv4=n=>e.check(J1(Nr,n)),e.uuidv6=n=>e.check(Y1(Nr,n)),e.uuidv7=n=>e.check(X1(Nr,n)),e.nanoid=n=>e.check(tb(zv,n)),e.guid=n=>e.check(qc(Gc,n)),e.cuid=n=>e.check(nb(Lv,n)),e.cuid2=n=>e.check(sb($v,n)),e.ulid=n=>e.check(rb(Dv,n)),e.base64=n=>e.check(db(Wv,n)),e.base64url=n=>e.check(pb(Zv,n)),e.xid=n=>e.check(ob(Fv,n)),e.ksuid=n=>e.check(ib(Uv,n)),e.ipv4=n=>e.check(ab(Bv,n)),e.ipv6=n=>e.check(lb(Vv,n)),e.cidrv4=n=>e.check(cb(qv,n)),e.cidrv6=n=>e.check(ub(Hv,n)),e.e164=n=>e.check(fb(Kv,n)),e.datetime=n=>e.check(pv(n)),e.date=n=>e.check(mv(n)),e.time=n=>e.check(gv(n)),e.duration=n=>e.check(bv(n))});function x(e){return Z1(Iv,e)}const Fe=O("ZodStringFormat",(e,t)=>{De.init(e,t),Rp.init(e,t)}),Mv=O("ZodEmail",(e,t)=>{Xx.init(e,t),Fe.init(e,t)}),Gc=O("ZodGUID",(e,t)=>{Jx.init(e,t),Fe.init(e,t)}),Nr=O("ZodUUID",(e,t)=>{Yx.init(e,t),Fe.init(e,t)}),Av=O("ZodURL",(e,t)=>{Qx.init(e,t),Fe.init(e,t)}),Ov=O("ZodEmoji",(e,t)=>{e1.init(e,t),Fe.init(e,t)}),zv=O("ZodNanoID",(e,t)=>{t1.init(e,t),Fe.init(e,t)}),Lv=O("ZodCUID",(e,t)=>{n1.init(e,t),Fe.init(e,t)}),$v=O("ZodCUID2",(e,t)=>{s1.init(e,t),Fe.init(e,t)}),Dv=O("ZodULID",(e,t)=>{r1.init(e,t),Fe.init(e,t)}),Fv=O("ZodXID",(e,t)=>{o1.init(e,t),Fe.init(e,t)}),Uv=O("ZodKSUID",(e,t)=>{i1.init(e,t),Fe.init(e,t)}),Bv=O("ZodIPv4",(e,t)=>{d1.init(e,t),Fe.init(e,t)}),Vv=O("ZodIPv6",(e,t)=>{p1.init(e,t),Fe.init(e,t)}),qv=O("ZodCIDRv4",(e,t)=>{f1.init(e,t),Fe.init(e,t)}),Hv=O("ZodCIDRv6",(e,t)=>{m1.init(e,t),Fe.init(e,t)}),Wv=O("ZodBase64",(e,t)=>{h1.init(e,t),Fe.init(e,t)}),Zv=O("ZodBase64URL",(e,t)=>{x1.init(e,t),Fe.init(e,t)}),Kv=O("ZodE164",(e,t)=>{b1.init(e,t),Fe.init(e,t)}),Gv=O("ZodJWT",(e,t)=>{y1.init(e,t),Fe.init(e,t)}),Pp=O("ZodNumber",(e,t)=>{vp.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(s,o,i)=>Vb(e,s,o),dr(e,"ZodNumber",{gt(s,o){return this.check(Wc(s,o))},gte(s,o){return this.check(Pi(s,o))},min(s,o){return this.check(Pi(s,o))},lt(s,o){return this.check(Hc(s,o))},lte(s,o){return this.check(Ri(s,o))},max(s,o){return this.check(Ri(s,o))},int(s){return this.check(Jc(s))},safe(s){return this.check(Jc(s))},positive(s){return this.check(Wc(0,s))},nonnegative(s){return this.check(Pi(0,s))},negative(s){return this.check(Hc(0,s))},nonpositive(s){return this.check(Ri(0,s))},multipleOf(s,o){return this.check(Zc(s,o))},step(s,o){return this.check(Zc(s,o))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function R(e){return vb(Pp,e)}const Jv=O("ZodNumberFormat",(e,t)=>{w1.init(e,t),Pp.init(e,t)});function Jc(e){return yb(Jv,e)}const Yv=O("ZodBoolean",(e,t)=>{j1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>qb(e,n,s)});function Te(e){return wb(Yv,e)}const Xv=O("ZodNull",(e,t)=>{k1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Hb(e,n,s)});function ho(e){return jb(Xv,e)}const Qv=O("ZodUnknown",(e,t)=>{_1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Zb()});function Fn(){return kb(Qv)}const e2=O("ZodNever",(e,t)=>{S1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Wb(e,n,s)});function t2(e){return _b(e2,e)}const n2=O("ZodArray",(e,t)=>{N1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Xb(e,n,s,o),e.element=t.element,dr(e,"ZodArray",{min(n,s){return this.check(fo(n,s))},nonempty(n){return this.check(fo(1,n))},max(n,s){return this.check(_p(n,s))},length(n,s){return this.check(Sp(n,s))},unwrap(){return this.element}})});function H(e,t){return zb(n2,e,t)}const s2=O("ZodObject",(e,t)=>{T1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Qb(e,n,s,o),Ce(e,"shape",()=>t.shape),dr(e,"ZodObject",{keyof(){return fe(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:Fn()})},loose(){return this.clone({...this._zod.def,catchall:Fn()})},strict(){return this.clone({...this._zod.def,catchall:t2()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return Hg(this,n)},safeExtend(n){return Wg(this,n)},merge(n){return Zg(this,n)},pick(n){return Vg(this,n)},omit(n){return qg(this,n)},partial(...n){return Kg(Mp,this,n[0])},required(...n){return Gg(Ap,this,n[0])}})});function T(e,t){const n={type:"object",shape:e??{},...re(t)};return new s2(n)}const Ip=O("ZodUnion",(e,t)=>{jp.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>ev(e,n,s,o),e.options=t.options});function At(e,t){return new Ip({type:"union",options:e,...re(t)})}const r2=O("ZodDiscriminatedUnion",(e,t)=>{Ip.init(e,t),E1.init(e,t)});function Tn(e,t,n){return new r2({type:"union",options:t,discriminator:e,...re(n)})}const o2=O("ZodIntersection",(e,t)=>{R1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>tv(e,n,s,o)});function i2(e,t){return new o2({type:"intersection",left:e,right:t})}const Yc=O("ZodRecord",(e,t)=>{P1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>nv(e,n,s,o),e.keyType=t.keyType,e.valueType=t.valueType});function We(e,t,n){return!t||!t._zod?new Yc({type:"record",keyType:x(),valueType:e,...re(t)}):new Yc({type:"record",keyType:e,valueType:t,...re(n)})}const wa=O("ZodEnum",(e,t)=>{I1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(s,o,i)=>Kb(e,s,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(s,o)=>{const i={};for(const a of s)if(n.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new wa({...t,checks:[],...re(o),entries:i})},e.exclude=(s,o)=>{const i={...t.entries};for(const a of s)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new wa({...t,checks:[],...re(o),entries:i})}});function fe(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new wa({type:"enum",entries:n,...re(t)})}const a2=O("ZodLiteral",(e,t)=>{M1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Gb(e,n,s),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ae(e,t){return new a2({type:"literal",values:Array.isArray(e)?e:[e],...re(t)})}const l2=O("ZodTransform",(e,t)=>{A1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Yb(e,n),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new rp(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(nr(i,n.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(nr(a))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});function c2(e){return new l2({type:"transform",transform:e})}const Mp=O("ZodOptional",(e,t)=>{kp.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Ep(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function Xc(e){return new Mp({type:"optional",innerType:e})}const u2=O("ZodExactOptional",(e,t)=>{O1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Ep(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function d2(e){return new u2({type:"optional",innerType:e})}const p2=O("ZodNullable",(e,t)=>{z1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>sv(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function Qc(e){return new p2({type:"nullable",innerType:e})}const f2=O("ZodDefault",(e,t)=>{L1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>ov(e,n,s,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function m2(e,t){return new f2({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():ap(t)}})}const h2=O("ZodPrefault",(e,t)=>{$1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>iv(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function g2(e,t){return new h2({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():ap(t)}})}const Ap=O("ZodNonOptional",(e,t)=>{D1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>rv(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function x2(e,t){return new Ap({type:"nonoptional",innerType:e,...re(t)})}const b2=O("ZodCatch",(e,t)=>{F1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>av(e,n,s,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function v2(e,t){return new b2({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const y2=O("ZodPipe",(e,t)=>{U1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>lv(e,n,s,o),e.in=t.in,e.out=t.out});function eu(e,t){return new y2({type:"pipe",in:e,out:t})}const w2=O("ZodReadonly",(e,t)=>{B1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>cv(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function j2(e){return new w2({type:"readonly",innerType:e})}const k2=O("ZodLazy",(e,t)=>{V1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>uv(e,n,s,o),e.unwrap=()=>e._zod.def.getter()});function _2(e){return new k2({type:"lazy",getter:e})}const S2=O("ZodCustom",(e,t)=>{q1.init(e,t),$e.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Jb(e,n)});function N2(e,t={}){return Lb(S2,e,t)}function C2(e,t){return $b(e,t)}const tt=_2(()=>At([x(),R(),Te(),ho(),H(tt),We(x(),tt)]));function Op(e){return e===void 0||typeof e=="bigint"||typeof e=="function"?null:e}const zp=T({index:R(),timestamp:R(),type:x(),data:tt}),T2=T({chunks:H(zp),truncated:Te().optional().default(!1)}),E2=fe(["request","response"]),R2=T({logId:R().int().positive(),part:E2,text:x(),offset:R().int().nonnegative(),limit:R().int().positive(),totalBytes:R().int().nonnegative(),textBytes:R().int().nonnegative(),nextOffset:R().int().nonnegative().nullable(),hasMore:Te(),contentMode:fe(["empty","partial","full"])}),sr=T({id:R(),timestamp:x(),method:x(),path:x(),model:x().nullable(),sessionId:x().nullable(),rawRequestBody:x().nullable(),responseStatus:R().nullable(),responseText:x().nullable(),inputTokens:R().nullable(),outputTokens:R().nullable(),cacheCreationInputTokens:R().nullable(),cacheReadInputTokens:R().nullable(),elapsedMs:R().nullable(),firstChunkMs:R().nullable().optional(),totalStreamMs:R().nullable().optional(),tokensPerSecond:R().nullable().optional(),streaming:Te(),userAgent:x().nullable(),origin:x().nullable(),rawHeaders:We(x(),x()).optional(),headers:We(x(),x()).optional(),apiFormat:fe(["anthropic","openai","unknown"]).default("unknown"),isTest:Te().optional().default(!1),replayOfLogId:R().nullable().optional(),providerName:x().nullable().optional(),clientPort:R().nullable().optional(),clientPid:R().nullable().optional(),clientCwd:x().nullable().optional(),clientProjectFolder:x().nullable().optional(),streamingChunks:T2.optional(),streamingChunksPath:x().nullable().optional(),rawRequestBodyBytes:R().int().nonnegative().nullable().optional(),responseTextBytes:R().int().nonnegative().nullable().optional(),bodyContentMode:fe(["full","compact","truncated"]).optional(),warnings:H(x()).optional(),error:x().nullable().optional()}),xl=T({type:x(),ttl:x().optional(),scope:x().optional()}),bl=T({type:ae("text"),text:x(),cache_control:xl.optional()}),Lp=T({type:ae("thinking"),thinking:x(),signature:x().optional()}),P2=T({type:ae("think"),thinking:x(),signature:x().optional()}),I2=T({type:ae("base64"),media_type:x(),data:x()}),$p=T({type:ae("image"),source:I2}),Dp=T({type:ae("tool_use"),id:x(),name:x(),input:We(x(),tt)}),M2=Tn("type",[bl,$p]),A2=T({type:ae("tool_result"),tool_use_id:x().optional(),content:At([x(),H(M2)]),is_error:Te().optional()}),O2=Tn("type",[bl,Lp,$p,Dp,A2]),z2=At([x(),H(O2)]),L2=T({role:fe(["user","assistant"]),content:z2}),$2=T({type:ae("text"),text:x(),cache_control:xl.optional()}),D2=T({type:x(),properties:We(x(),We(x(),tt)).optional(),required:H(x()).optional(),additionalProperties:Te().optional(),$schema:x().optional()}),F2=T({name:x(),description:x().optional(),input_schema:D2.optional(),cache_control:xl.optional()}),U2=Tn("type",[T({type:ae("enabled"),budget_tokens:R()}),T({type:ae("disabled")}),T({type:ae("adaptive")})]),Fp=T({model:x(),messages:H(L2),system:H($2).optional(),tools:H(F2).optional(),max_tokens:R().optional(),temperature:R().optional(),stream:Te().optional(),thinking:U2.optional(),metadata:T({user_id:x().optional()}).optional()}),vl=Tn("type",[bl,Lp,P2,Dp]),B2=T({input_tokens:R().nullable().optional(),output_tokens:R().nullable().optional(),cache_creation_input_tokens:R().nullable().optional(),cache_read_input_tokens:R().nullable().optional()}).passthrough(),Up=T({id:x(),type:ae("message"),model:x(),role:ae("assistant"),content:H(vl),stop_reason:x().nullable(),stop_sequence:x().nullable().optional(),usage:B2}).passthrough(),V2=T({type:ae("message_start"),message:T({id:x(),type:ae("message"),model:x(),role:ae("assistant"),content:H(vl),stop_reason:ho(),stop_sequence:ho(),usage:T({input_tokens:R(),cache_creation_input_tokens:R().optional(),cache_read_input_tokens:R().optional()}).passthrough()})}),q2=T({type:ae("content_block_start"),index:R(),content_block:vl}),H2=Tn("type",[T({type:ae("text_delta"),text:x()}),T({type:ae("input_json_delta"),partial_json:x()}),T({type:ae("thinking_delta"),thinking:x()}),T({type:ae("signature_delta"),signature:x()})]),W2=T({type:ae("content_block_delta"),index:R(),delta:H2}),Z2=T({type:ae("content_block_stop"),index:R()}),K2=T({type:ae("message_delta"),delta:T({stop_reason:x().nullable(),stop_sequence:x().nullable().optional()}),usage:T({output_tokens:R(),input_tokens:R().optional(),cache_creation_input_tokens:R().optional(),cache_read_input_tokens:R().optional()}).passthrough()}),G2=T({type:ae("message_stop")}),J2=T({type:ae("ping")}),Y2=T({type:ae("error"),error:T({type:x(),message:x()})}),X2=Tn("type",[V2,q2,W2,Z2,K2,G2,J2,Y2]),Q2=At([x(),H(Tn("type",[T({type:ae("text"),text:x()}),T({type:ae("image_url"),image_url:T({url:x(),detail:x().optional()})})]))]),Bp=T({role:fe(["system","user","assistant","tool"]),content:Q2,name:x().optional(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional()}),ey=T({name:x(),arguments:x()}),Vp=T({index:R().optional(),id:x().optional(),type:ae("function").optional(),function:T({name:x().optional(),arguments:x().optional()})});Bp.extend({content:At([x(),H(T({type:ae("text"),text:x()}))]).optional(),function_call:ey.optional(),tool_calls:H(Vp).optional()});const ty=T({type:ae("function"),function:T({name:x(),description:x().optional(),parameters:We(x(),tt)})}),qp=T({model:x(),messages:H(Bp),temperature:R().optional(),max_tokens:R().optional(),stream:Te().optional(),tools:H(ty).optional(),tool_choice:At([fe(["auto","none","required"]),T({type:ae("auto")}),T({type:ae("none")}),T({type:ae("function"),function:T({name:x()})})]).optional(),user:x().optional()}),ny=T({type:x(),name:x().optional(),description:x().optional(),parameters:tt.optional(),function:T({name:x().optional(),description:x().optional(),parameters:tt.optional()}).optional()}).passthrough(),Hp=T({model:x(),input:Fn().optional(),instructions:At([x(),ho()]).optional(),stream:Te().optional(),tools:H(ny).optional(),tool_choice:Fn().optional(),max_output_tokens:R().optional(),temperature:R().optional(),user:x().optional(),metadata:We(x(),Fn()).optional()}).passthrough(),Wp=T({role:fe(["assistant"]).optional(),content:x().nullable().optional(),reasoning_content:x().nullable().optional(),thinking:x().nullable().optional(),think:x().nullable().optional(),function_call:T({name:x().optional(),arguments:x().optional()}).nullable().optional(),tool_calls:H(T({index:R(),id:x().optional(),type:ae("function").optional(),function:T({name:x().optional(),arguments:x().optional()})})).nullable().optional()}),sy=T({index:R(),message:T({role:fe(["assistant"]),content:x().nullable(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional(),function_call:T({name:x(),arguments:x()}).nullable().optional(),tool_calls:H(Vp).optional()}).optional(),delta:Wp.optional(),finish_reason:x().nullable()}),ry=T({id:x(),object:ae("chat.completion"),created:R(),model:x(),choices:H(sy),usage:T({prompt_tokens:R().nullable().optional(),completion_tokens:R().nullable().optional(),total_tokens:R().nullable().optional()}).passthrough(),service_tier:x().nullable().optional(),system_fingerprint:x().nullable().optional()}).passthrough(),oy=T({id:x(),object:ae("chat.completion.chunk"),created:R(),model:x(),choices:H(T({index:R(),delta:Wp,finish_reason:x().nullable().optional()})),usage:T({prompt_tokens:R().nullable().optional(),completion_tokens:R().nullable().optional(),total_tokens:R().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),iy=T({input_tokens:R().nullable().optional(),output_tokens:R().nullable().optional(),total_tokens:R().nullable().optional(),input_tokens_details:T({cached_tokens:R().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:T({reasoning_tokens:R().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),ay=T({type:x()}).passthrough(),go=T({id:x(),object:ae("response").optional(),created_at:R().optional(),status:x().nullable().optional(),model:x().optional(),output:H(ay).optional(),output_text:x().optional(),usage:iy.nullable().optional(),error:Fn().optional()}).passthrough(),ly=T({type:x()}).passthrough();function Zp(e){try{const t=JSON.parse(e),n=ry.safeParse(t);return n.success?n.data:null}catch{return null}}function Kp(e){try{const t=JSON.parse(e),n=go.safeParse(t);return n.success?n.data:null}catch{return null}}const cy=T({error:x()}),uy=new Set(["POST","PUT","PATCH","DELETE"]);function Gp(e){const t=e?.method?.toUpperCase();if(t===void 0||!uy.has(t))return e;const n=new Headers(e?.headers);return n.has("x-agent-inspector-csrf")||n.set("x-agent-inspector-csrf","1"),{...e,headers:n}}async function yl(e,t){const n=await e.json();return t.parse(n)}async function wl(e,t){try{const n=await e.json(),s=cy.safeParse(n);return s.success?s.data.error:t}catch{return t}}async function ot(e,t,n,s){const o=await fetch(e,Gp(n));if(!o.ok){const i=s?.(o)??`Request failed with status ${o.status}`;throw new Error(await wl(o,i))}return yl(o,t)}function dy(e){return e<1e3?`${String(e)}ms`:`${String(Math.round(e/1e3))}s`}class Zo extends Error{constructor(t){super(`Request timed out after ${dy(t)}`),this.name="ApiTimeoutError"}}async function Un(e,t,n){const s=new AbortController;let o=!1;const i=setTimeout(()=>{o=!0,s.abort()},t),a=n?.signal??void 0,l=()=>s.abort();a!==void 0&&(a.aborted?s.abort():a.addEventListener("abort",l,{once:!0}));try{return await fetch(e,{...Gp(n),signal:s.signal})}catch(u){throw o&&u instanceof DOMException&&u.name==="AbortError"?new Zo(t):u}finally{clearTimeout(i),a?.removeEventListener("abort",l)}}async function qe(e,t,n,s,o){const i=await Un(e,n,s);if(!i.ok){const a=o?.(i)??`Request failed with status ${i.status}`;throw new Error(await wl(i,a))}return yl(i,t)}const Jp=T({input:R().int().nonnegative(),output:R().int().nonnegative(),cacheCreate:R().int().nonnegative(),cacheRead:R().int().nonnegative(),total:R().int().nonnegative()}),py=T({id:R().int().positive(),sessionLogNumber:R().int().positive().optional(),timestamp:x(),provider:x().nullable(),model:x().nullable(),apiFormat:fe(["anthropic","openai","unknown"]),method:x(),path:x(),status:R().nullable(),isStreaming:Te(),hasError:Te(),error:x().nullable(),latencyMs:R().nullable(),firstChunkMs:R().nullable().optional(),totalStreamMs:R().nullable().optional(),tokensPerSecond:R().nullable().optional(),tokens:T({input:R().nullable(),output:R().nullable(),cacheCreate:R().nullable(),cacheRead:R().nullable()}),sessionId:x().nullable(),userAgent:x().nullable().optional(),clientPid:R().nullable().optional(),clientProjectFolder:x().nullable().optional()}),Yp=T({id:x(),status:fe(["active","failed","completed","empty"]),logCoverage:fe(["recent","history"]),source:fe(["explicit","client-process","client-connection","provider-test"]).nullable(),runtimeMode:fe(["in-process","worker-thread","child-process"]).nullable(),createdAt:x().nullable(),updatedAt:x().nullable(),requestCount:R().int().nonnegative(),activeRequests:R().int().nonnegative(),completedRequests:R().int().nonnegative(),failedRequests:R().int().nonnegative(),queuedTasks:R().int().nonnegative(),runningTasks:R().int().nonnegative(),lastTaskError:x().nullable(),logCount:R().int().nonnegative(),errorCount:R().int().nonnegative(),models:H(x()),providers:H(x()),tokenUsage:Jp,lastLogId:R().nullable(),lastModel:x().nullable(),clientUserAgent:x().nullable().optional(),clientPid:R().nullable(),clientProjectFolder:x().nullable(),inspectorPath:x(),inspectorUrl:x(),apiPath:x(),apiUrl:x(),compactLogsPath:x(),compactLogsUrl:x(),latestLogLimit:R().int().positive(),latestLogs:H(py)}),pr=fe(["created","running","completed","failed","cancelled"]),jl=T({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),fy=fe(["run-created","session-started","request","session-finished","evidence-exported"]),my=fe(["info","success","warning","error"]),hy=T({timestamp:x(),kind:fy,severity:my,title:x(),details:x(),logId:R().int().positive().nullable(),status:R().nullable(),model:x().nullable(),provider:x().nullable(),latencyMs:R().nullable(),isStreaming:Te().nullable()}),gy=fe(["none","active","provider-timeout","provider-http-error","provider-auth-error","provider-rate-limit","network-or-container","streaming-mismatch","context-pressure","runtime-task-error","model-output-error","unknown-failure","no-session-data"]),Xp=T({outcome:fe(["success","failure","active","unknown"]),severity:fe(["none","low","medium","high"]),category:gy,summary:x(),evidenceLogIds:H(R().int().positive()),hints:H(x())}),kl=T({status:fe(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:x(),markdown:x()}),Qp=kl,_l=T({id:x(),sessionId:x(),groupId:x().nullable().default(null),title:x(),task:x().nullable(),project:x().nullable(),agent:x().nullable(),status:pr,tags:H(x()),metadata:We(x(),tt),evidence:jl.nullable(),createdAt:x(),updatedAt:x()});T({runId:x().min(1).optional(),sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:pr.optional(),tags:H(x()).optional(),metadata:We(x(),tt).optional()}).optional();T({sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:pr.optional(),tags:H(x()).optional(),metadata:We(x(),tt).optional()});T({includeHistory:Te().optional(),latestLogLimit:R().int().positive().max(50).optional()}).optional();T({run:_l,evidence:jl,session:Yp.nullable(),timeline:H(hy),classification:Xp,jenkinsReport:kl});const xy=T({run:_l,classification:Xp,evidence:jl.nullable(),jenkinsReport:kl.nullable(),sessionId:x(),inspectorUrl:x().nullable(),evidenceMarkdownPath:x().nullable(),updatedAt:x()});T({failures:H(xy),total:R().int().nonnegative(),limit:R().int().positive()});const Sl=fe(["created","running","completed","failed","cancelled"]),Nl=fe(["evaluation","batch","manual"]),Cl=T({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),ef=T({id:x(),groupId:x(),sessionId:x(),runId:x().nullable(),label:x().nullable(),agent:x().nullable(),provider:x().nullable(),model:x().nullable(),status:pr.nullable(),metadata:We(x(),tt),addedAt:x(),updatedAt:x()}),Tl=T({id:x(),title:x(),kind:Nl,task:x().nullable(),project:x().nullable(),status:Sl,tags:H(x()),metadata:We(x(),tt),evidence:Cl.nullable(),members:H(ef),createdAt:x(),updatedAt:x()});T({groupId:x().min(1).optional(),title:x().min(1).optional(),kind:Nl.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Sl.optional(),tags:H(x()).optional(),metadata:We(x(),tt).optional()}).optional();T({title:x().min(1).optional(),kind:Nl.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Sl.optional(),tags:H(x()).optional(),metadata:We(x(),tt).optional()});T({memberId:x().min(1).optional(),sessionId:x().min(1),runId:x().min(1).nullable().optional(),label:x().min(1).nullable().optional(),agent:x().min(1).nullable().optional(),provider:x().min(1).nullable().optional(),model:x().min(1).nullable().optional(),status:pr.nullable().optional(),metadata:We(x(),tt).optional()});T({includeHistory:Te().optional(),latestLogLimit:R().int().positive().max(50).optional()}).optional();T({deleteEvidence:Te().optional()});const tf=T({groupId:x(),deleted:Te(),evidenceDeleted:Te(),evidencePath:x().nullable()}),nf=T({deleted:R().int().nonnegative(),groups:H(tf)}),sf=T({member:ef,run:_l.nullable(),session:Yp.nullable()}),rf=T({memberCount:R().int().nonnegative(),sessionsWithData:R().int().nonnegative(),missingSessions:R().int().nonnegative(),requestCount:R().int().nonnegative(),errorCount:R().int().nonnegative(),tokenUsage:Jp,models:H(x()),providers:H(x()),completedMembers:R().int().nonnegative(),failedMembers:R().int().nonnegative(),runningMembers:R().int().nonnegative()}),by=T({group:Tl,evidence:Cl,members:H(sf).nullable(),markdown:x(),summary:rf.nullable(),report:Qp.nullable()}),vy=T({group:Tl,evidence:Cl,members:H(sf),summary:rf,jenkinsReport:Qp}),of=T({groups:H(Tl)}),yy=T({sessionId:x(),imported:R().int().nonnegative(),skipped:R().int().nonnegative(),warnings:H(x()),logs:H(sr)}),xo=10,ja=600,bo=60,ka=600,vo="time",El="simple",af=fe(["time","full"]),wy=fe(["simple","full"]),Ko=T({stripClaudeCodeBillingHeader:Te(),hasSeenOnboarding:Te().default(!1),slowResponseThresholdSeconds:R().int().min(0).max(ja).default(xo),providerTestTimeoutSeconds:R().int().min(1).max(ka).default(bo),timeDisplayFormat:af.default(vo),captureMode:wy.default(El)}),fs="/api/config";async function jy(e){return ot(e,Ko,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function Cr(e){return ot(fs,Ko,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function Rl(){const e=Bt(fs,jy,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=Xd(),n=e.data?.stripClaudeCodeBillingHeader??!1,s=e.data?.captureMode??El,o=e.data?.slowResponseThresholdSeconds??xo,i=e.data?.providerTestTimeoutSeconds??bo,a=e.data?.timeDisplayFormat??vo,l=m=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??xo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??bo,timeDisplayFormat:e.data?.timeDisplayFormat??vo,captureMode:s,...m}),u=async m=>{await t(fs,Cr({stripClaudeCodeBillingHeader:m}),{optimisticData:l({stripClaudeCodeBillingHeader:m}),rollbackOnError:!0,revalidate:!1})},d=async m=>{await t(fs,Cr({slowResponseThresholdSeconds:m}),{optimisticData:l({slowResponseThresholdSeconds:m}),rollbackOnError:!0,revalidate:!1})},p=async m=>{await t(fs,Cr({timeDisplayFormat:m}),{optimisticData:l({timeDisplayFormat:m}),rollbackOnError:!0,revalidate:!1})},f=async m=>{await t(fs,Cr({providerTestTimeoutSeconds:m}),{optimisticData:l({providerTestTimeoutSeconds:m}),rollbackOnError:!0,revalidate:!1})};return{strip:n,captureMode:s,slowResponseThresholdSeconds:o,providerTestTimeoutSeconds:i,timeDisplayFormat:a,isLoading:e.isLoading,isError:e.error!==void 0,setStrip:u,setSlowResponseThresholdSeconds:d,setProviderTestTimeoutSeconds:f,setTimeDisplayFormat:p}}const lf=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();const ky=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const _y=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());const tu=e=>{const t=_y(e);return t.charAt(0).toUpperCase()+t.slice(1)};var Sy={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Ny=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const Cy=c.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:o="",children:i,iconNode:a,...l},u)=>c.createElement("svg",{ref:u,...Sy,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:lf("lucide",o),...!i&&!Ny(l)&&{"aria-hidden":"true"},...l},[...a.map(([d,p])=>c.createElement(d,p)),...Array.isArray(i)?i:[i]]));const U=(e,t)=>{const n=c.forwardRef(({className:s,...o},i)=>c.createElement(Cy,{ref:i,iconNode:t,className:lf(`lucide-${ky(tu(e))}`,`lucide-${e}`,s),...o}));return n.displayName=tu(e),n};const Ty=[["path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16",key:"xik6mr"}],["path",{d:"M15.697 14h5.606",key:"1stdlc"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}]],Ey=U("a-large-small",Ty);const Ry=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Py=U("activity",Ry);const Iy=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],My=U("arrow-down-right",Iy);const Ay=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Oy=U("arrow-down",Ay);const zy=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Ly=U("arrow-left",zy);const $y=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],Dy=U("arrow-up-right",$y);const Fy=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Uy=U("arrow-up",Fy);const By=[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]],Pl=U("beaker",By);const Vy=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],qy=U("bell",Vy);const Hy=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]],Wy=U("blocks",Hy);const Zy=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]],Ky=U("brain-circuit",Zy);const Gy=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],cf=U("brain",Gy);const Jy=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ge=U("check",Jy);const Yy=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],nt=U("chevron-down",Yy);const Xy=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Qy=U("chevron-left",Xy);const ew=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],yt=U("chevron-right",ew);const tw=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Il=U("chevron-up",tw);const nw=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],sw=U("chevrons-down",nw);const rw=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],ow=U("chevrons-left",rw);const iw=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],aw=U("chevrons-right",iw);const lw=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],cw=U("chevrons-up",lw);const uw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Ns=U("circle-alert",uw);const dw=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],fr=U("circle-check-big",dw);const pw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],_a=U("circle-check",pw);const fw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],mw=U("circle-question-mark",fw);const hw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],gw=U("circle-stop",hw);const xw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],uf=U("circle-x",xw);const bw=[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]],vw=U("clapperboard",bw);const yw=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ww=U("clock-3",yw);const jw=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],rn=U("clock",jw);const kw=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],_w=U("cloud-upload",kw);const Sw=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],df=U("code-xml",Sw);const Nw=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Cw=U("columns-2",Nw);const Tw=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Ot=U("copy",Tw);const Ew=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Rw=U("cpu",Ew);const Pw=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],mr=U("download",Pw);const Iw=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Mw=U("ellipsis",Iw);const Aw=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Ml=U("external-link",Aw);const Ow=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],zw=U("eye-off",Ow);const Lw=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],pf=U("eye",Lw);const $w=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],Dw=U("file-braces",$w);const Fw=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]],Uw=U("file-diff",Fw);const Bw=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],Vw=U("file-search",Bw);const qw=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m8 16 2-2-2-2",key:"10vzyd"}],["path",{d:"M12 18h4",key:"1wd2n7"}]],Hw=U("file-terminal",qw);const Ww=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Zw=U("file-text",Ww);const Kw=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],Gw=U("flag",Kw);const Jw=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],ff=U("flask-conical",Jw);const Yw=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Xw=U("folder-open",Yw);const Qw=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Al=U("gauge",Qw);const ej=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]],tj=U("git-compare-arrows",ej);const nj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],mf=U("globe",nj);const sj=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],hf=U("history",sj);const rj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],oj=U("info",rj);const ij=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],nu=U("layers",ij);const aj=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ue=U("loader-circle",aj);const lj=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],cj=U("lock",lj);const uj=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Go=U("message-square",uj);const dj=[["path",{d:"M5 12h14",key:"1ays0h"}]],gf=U("minus",dj);const pj=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],fj=U("monitor",pj);const mj=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],hj=U("moon",mj);const gj=[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]],xj=U("mouse-pointer-click",gj);const bj=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],vj=U("network",bj);const yj=[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],wj=U("octagon-alert",yj);const jj=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],kj=U("package-check",jj);const _j=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],Sj=U("panel-right-close",_j);const Nj=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Cj=U("panel-right-open",Nj);const Tj=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],xf=U("pencil",Tj);const Ej=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],su=U("plus",Ej);const Rj=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],ru=U("radio",Rj);const Pj=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Vt=U("refresh-cw",Pj);const Ij=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],bf=U("rocket",Ij);const Mj=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],vf=U("rotate-ccw",Mj);const Aj=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],yo=U("rotate-cw",Aj);const Oj=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],zj=U("rows-3",Oj);const Lj=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],$j=U("save",Lj);const Dj=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],Fj=U("scan",Dj);const Uj=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],yf=U("search",Uj);const Bj=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Vj=U("send",Bj);const qj=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Hj=U("server",qj);const Wj=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Zj=U("settings",Wj);const Kj=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Gj=U("shield-alert",Kj);const Jj=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ou=U("shield-check",Jj);const Yj=[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]],Sa=U("siren",Yj);const Xj=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Na=U("sparkles",Xj);const Qj=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],e5=U("sun",Qj);const t5=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Xn=U("terminal",t5);const n5=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],s5=U("timer",n5);const r5=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],jn=U("trash-2",r5);const o5=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],wn=U("triangle-alert",o5);const i5=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],wf=U("upload",i5);const a5=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],l5=U("wifi-off",a5);const c5=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],u5=U("wifi",c5);const d5=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],hr=U("wrench",d5);const p5=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],gr=U("x",p5);const f5=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],rr=U("zap",f5),Ca="/api/config";async function m5(e){return ot(e,Ko,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function h5(e){return ot(Ca,Ko,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function g5(){const e=Bt(Ca,m5,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=Xd(),n=e.data?.hasSeenOnboarding??!1,s=e.data?.captureMode??El,o=async()=>{await t(Ca,h5({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??xo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??bo,timeDisplayFormat:e.data?.timeDisplayFormat??vo,captureMode:s},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:n,captureMode:s,isLoading:e.isLoading,markSeen:o}}function x5({expanded:e,onToggle:t,onDismiss:n}){const s=e?"grid":"hidden sm:grid";return r.jsx("div",{role:"note","aria-label":"Onboarding tip",className:"mx-3 mt-2 mb-1 rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-sm shadow-sm sm:mx-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(oj,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":"true"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:"font-medium text-foreground",children:"Inspector ready"}),r.jsx("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:"Request, response, tool, timing, token, replay, and memory signals are active."})]}),r.jsx("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground sm:hidden",children:"Core capture is active."}),r.jsxs("div",{className:`${s} mt-2 gap-x-4 gap-y-1 text-xs leading-relaxed text-muted-foreground sm:grid-cols-2`,children:[r.jsxs("div",{children:[r.jsx("strong",{children:"Evidence"}),": logs, sessions, groups, and MCP exports are available."]}),r.jsxs("div",{children:[r.jsx("strong",{children:"Network"}),": replace ",r.jsx("code",{children:"localhost"})," if containers differ."]})]})]}),r.jsx("button",{type:"button",onClick:t,className:"inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-warning/35 px-2 text-xs font-medium text-foreground transition-colors hover:bg-warning/15 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:hidden","aria-expanded":e,"aria-label":e?"Hide onboarding details":"Show onboarding details",children:r.jsx(nt,{className:`size-3.5 transition-transform ${e?"rotate-180":""}`})}),r.jsxs("button",{type:"button",onClick:n,className:"hidden h-8 shrink-0 items-center gap-1.5 rounded-md border border-warning/40 px-3 text-xs font-medium text-foreground transition-colors hover:bg-warning/15 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:inline-flex","aria-label":"Dismiss onboarding tip",children:[r.jsx(Ge,{className:"size-3.5"}),"Got it"]}),r.jsx("button",{type:"button",onClick:n,className:"-m-1 shrink-0 rounded-sm p-1 text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Dismiss",children:r.jsx(gr,{className:"size-3.5"})})]})})}function b5(){const{hasSeenOnboarding:e,isLoading:t,markSeen:n}=g5(),[s,o]=c.useState(!1);return t||e?null:r.jsx(x5,{expanded:s,onToggle:()=>o(i=>!i),onDismiss:()=>{n()}})}const v5="3.0.33",jf={version:v5};function Gs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const kf="[REDACTED]",y5=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,w5=[/Bearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,/\bsk-[A-Za-z0-9_-]{12,}\b/g,/\bsk-ant-[A-Za-z0-9_-]{12,}\b/g,/\bghp_[A-Za-z0-9_]{12,}\b/g,/\bglpat-[A-Za-z0-9_-]{12,}\b/g],iu=200,j5=25e6,_f=50,k5=1e4;function _5(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function S5(e){let t=0;for(const n of e)t+=n.rawRequestBody?.length??0,t+=n.responseText?.length??0;return t}function N5(e){if(e.length>iu)return`Export is limited to ${iu} logs at once. Narrow the filter and try again.`;const t=S5(e);return t>j5?`Export is too large (${_5(t)} of text). Narrow the filter and try again.`:null}function Tr(e){return e?.aborted===!0?{ok:!1,message:"Export canceled.",canceled:!0}:null}async function C5(e,t){try{const n=await Un(`/api/logs/${e}/chunks`,k5,{signal:t});if(!n.ok)return null;const s=await n.json();return JSON.stringify(s,null,2)}catch{return null}}function Ta(e){if(Array.isArray(e))return e.map(n=>Ta(n));if(!Gs(e))return e;const t={};for(const[n,s]of Object.entries(e))t[n]=y5.test(n)?kf:Ta(s);return t}function T5(e){const t=n=>{let s=n;for(const o of w5)s=s.replace(o,kf);return s};try{const n=JSON.parse(e);return t(JSON.stringify(Ta(n),null,2))}catch{return t(e)}}function Ii(e,t){return t==="redacted"?T5(e):e}function E5(e,t){return{...e,rawRequestBody:null,responseText:null,rawHeaders:t==="raw"?e.rawHeaders:void 0,headers:t==="raw"?e.headers:void 0,streamingChunks:void 0,bodyContentMode:"compact"}}function R5(e,t,n,s=new Date().toISOString()){return{version:jf.version,exportedAt:s,mode:t,redacted:t==="redacted",logCount:e.length,logIds:e.map(o=>o.id),streamingChunkExportLimit:_f,streamingChunkLogIds:n.map(o=>o.id)}}async function P5(e,t="redacted",n={}){const s=Tr(n.signal);if(s!==null)return s;const o=N5(e);if(o!==null)return{ok:!1,message:o};const{default:i}=await Gt(async()=>{const{default:h}=await import("./jszip.min-D_dylbU1.js").then(g=>g.j);return{default:h}},__vite__mapDeps([0,1])),a=new i,l=t==="redacted"?"redacted":"raw",u=e.filter(h=>h.streaming).slice(0,_f);a.file("manifest.json",JSON.stringify(R5(e,t,u),null,2)),a.file("logs.json",JSON.stringify(e.map(h=>E5(h,t)),null,2));for(const h of e){const g=Tr(n.signal);if(g!==null)return g;h.rawRequestBody!==null&&a.file(`#${h.id}.Request.json`,Ii(h.rawRequestBody,t)),h.responseText!==null&&a.file(`#${h.id}.Response.json`,Ii(h.responseText,t))}for(const h of u){const g=Tr(n.signal);if(g!==null)return g;const y=await C5(h.id,n.signal);y!==null&&a.file(`#${h.id}.SSE.Response.json`,Ii(y,t))}const d=await a.generateAsync({type:"blob"}),p=Tr(n.signal);if(p!==null)return p;const f=URL.createObjectURL(d),m=document.createElement("a");return m.href=f,m.download=`agent-inspector-export-${l}-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(f),{ok:!0}}function Ea(e,t){switch(t){case"full":return e;case"time":return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function Jo(e,t,n){return`${Ea(e,n)} - ${Ea(t,n)}`}function I5(){const[e,t]=c.useState(Cg),n=c.useCallback(s=>{t(s),Ti(s),Tg(s)},[]);return c.useEffect(()=>{Ti(e)},[e]),c.useEffect(()=>{function s(o){if(o.key!==Eg)return;const i=Rg(o.newValue);t(i),Ti(i)}return window.addEventListener("storage",s),()=>window.removeEventListener("storage",s)},[]),{themeMode:e,setThemeMode:n}}function M5(){const[e,t]=c.useState(Pg),[n,s]=c.useState(1),o=c.useCallback(i=>{t(i),Ig(i),s(Ei(i))},[]);return c.useEffect(()=>{const i=()=>{s(Ei(e))};if(i(),e==="auto")return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[e]),c.useEffect(()=>{const i=a=>{if(a.key!==Mg)return;const l=Qd(a.newValue);t(l),s(Ei(l))};return window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[]),{uiScalePreference:e,resolvedUiScale:n,setUiScalePreference:o}}const Bn=64,Ra=256,A5=64,O5=fe(["invalid-page-request","search-limit-exceeded","provider-model-limit-exceeded","sse-capacity-exceeded","provider-test-capacity-exceeded"]),z5=At([ae(400),ae(413),ae(429),ae(503)]);T({error:x().min(1).max(300),code:O5,status:z5,resource:x().min(1).max(80),limit:R().int().positive(),retryable:Te()});function Er(){return x().refine(e=>{if(e.length===0)return!0;try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}},"Must be a valid http(s) URL")}const Ol=x().max(Ra),L5=H(Ol).max(Bn),$5=T({model:Ol.min(1),contextWindow:R().int().positive().optional(),outputLimit:R().int().positive().optional(),source:fe(["manual","registry"]).optional(),sourceUrl:x().optional(),updatedAt:x().optional()}),D5=H($5).max(A5),F5=T({id:x(),name:x(),apiKey:x(),model:Ol.optional(),models:L5.optional().default([]),format:fe(["anthropic","openai"]).optional(),baseUrl:Er().optional(),anthropicBaseUrl:Er().optional(),openaiBaseUrl:Er().optional(),openaiResponsesBaseUrl:Er().optional(),authHeader:fe(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:x().optional(),modelMetadataUrl:x().optional(),modelMetadata:D5.optional(),source:fe(["company","personal"]).optional(),createdAt:x(),updatedAt:x()}),U5="configured",wo=F5.extend({apiKey:ae(U5)});async function B5(e){return ot(e,wo.array(),void 0,t=>`Failed to fetch ${e}: ${t.status}`)}function zl(){const e=Bt("/api/providers",B5,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function au(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function V5(...e){return t=>{let n=!1;const s=e.map(o=>{const i=au(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<s.length;o++){const i=s[o];typeof i=="function"?i():au(e[o],null)}}}}function Pe(...e){return c.useCallback(V5(...e),e)}function Cs(e){const t=c.forwardRef((n,s)=>{let{children:o,...i}=n,a=null,l=!1;const u=[];lu(o)&&typeof Rr=="function"&&(o=Rr(o._payload)),c.Children.forEach(o,m=>{if(G5(m)){l=!0;const h=m;let g="child"in h.props?h.props.child:h.props.children;lu(g)&&typeof Rr=="function"&&(g=Rr(g._payload)),a=W5(h,g),u.push(a?.props?.children)}else u.push(m)}),a?a=c.cloneElement(a,void 0,u):!l&&c.Children.count(o)===1&&c.isValidElement(o)&&(a=o);const d=a?K5(a):void 0,p=Pe(s,d);if(!a){if(o||o===0)throw new Error(l?Q5(e):X5(e));return o}const f=Z5(i,a.props??{});return a.type!==c.Fragment&&(f.ref=s?p:d),c.cloneElement(a,f)});return t.displayName=`${e}.Slot`,t}var q5=Cs("Slot"),Sf=Symbol.for("radix.slottable");function H5(e){const t=n=>"child"in n?n.children(n.child):n.children;return t.displayName=`${e}.Slottable`,t.__radixId=Sf,t}var W5=(e,t)=>{if("child"in e.props){const n=e.props.child;return c.isValidElement(n)?c.cloneElement(n,void 0,e.props.children(n.props.children)):null}return c.isValidElement(t)?t:null};function Z5(e,t){const n={...t};for(const s in t){const o=e[s],i=t[s];/^on[A-Z]/.test(s)?o&&i?n[s]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[s]=o):s==="style"?n[s]={...o,...i}:s==="className"&&(n[s]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function K5(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function G5(e){return c.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Sf}var J5=Symbol.for("react.lazy");function lu(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===J5&&"_payload"in e&&Y5(e._payload)}function Y5(e){return typeof e=="object"&&e!==null&&"then"in e}var X5=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,Q5=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,Rr=Bo[" use ".trim().toString()],ek=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ge=ek.reduce((e,t)=>{const n=Cs(`Primitive.${t}`),s=c.forwardRef((o,i)=>{const{asChild:a,...l}=o,u=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...l,ref:i})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function tk(e,t){e&&Os.flushSync(()=>e.dispatchEvent(t))}var Nf=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),nk="VisuallyHidden",Cf=c.forwardRef((e,t)=>r.jsx(ge.span,{...e,ref:t,style:{...Nf,...e.style}}));Cf.displayName=nk;var sk=Cf;function dn(e,t=[]){let n=[];function s(i,a){const l=c.createContext(a);l.displayName=i+"Context";const u=n.length;n=[...n,a];const d=f=>{const{scope:m,children:h,...g}=f,y=m?.[e]?.[u]||l,b=c.useMemo(()=>g,Object.values(g));return r.jsx(y.Provider,{value:b,children:h})};d.displayName=i+"Provider";function p(f,m,h={}){const{optional:g=!1}=h,y=m?.[e]?.[u]||l,b=c.useContext(y);if(b)return b;if(a!==void 0)return a;if(!g)throw new Error(`\`${f}\` must be used within \`${i}\``)}return[d,p]}const o=()=>{const i=n.map(a=>c.createContext(a));return function(l){const u=l?.[e]||i;return c.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return o.scopeName=e,[s,rk(o,...t)]}function rk(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const a=s.reduce((l,{useScope:u,scopeName:d})=>{const f=u(i)[`__scope${d}`];return{...l,...f}},{});return c.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}function Tf(e){const t=e+"CollectionProvider",[n,s]=dn(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=y=>{const{scope:b,children:w}=y,v=c.useRef(null),j=c.useRef(new Map).current;return r.jsx(o,{scope:b,itemMap:j,collectionRef:v,children:w})};a.displayName=t;const l=e+"CollectionSlot",u=Cs(l),d=c.forwardRef((y,b)=>{const{scope:w,children:v}=y,j=i(l,w),_=Pe(b,j.collectionRef);return r.jsx(u,{ref:_,children:v})});d.displayName=l;const p=e+"CollectionItemSlot",f="data-radix-collection-item",m=Cs(p),h=c.forwardRef((y,b)=>{const{scope:w,children:v,...j}=y,_=c.useRef(null),k=Pe(b,_),S=i(p,w);return c.useEffect(()=>(S.itemMap.set(_,{ref:_,...j}),()=>{S.itemMap.delete(_)})),r.jsx(m,{[f]:"",ref:k,children:v})});h.displayName=p;function g(y){const b=i(e+"CollectionConsumer",y);return c.useCallback(()=>{const v=b.collectionRef.current;if(!v)return[];const j=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(b.itemMap.values()).sort((S,C)=>j.indexOf(S.ref.current)-j.indexOf(C.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:a,Slot:d,ItemSlot:h},g,s]}function pe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o||!o.defaultPrevented)return t?.(o)}}var Je=globalThis?.document?c.useLayoutEffect:()=>{},ok=Bo[" useInsertionEffect ".trim().toString()]||Je;function qn({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[o,i,a]=ik({defaultProp:t,onChange:n}),l=e!==void 0,u=l?e:o;{const p=c.useRef(e!==void 0);c.useEffect(()=>{const f=p.current;f!==l&&console.warn(`${s} is changing from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=l},[l,s])}const d=c.useCallback(p=>{if(l){const f=ak(p)?p(e):p;f!==e&&a.current?.(f)}else i(p)},[l,e,i,a]);return[u,d]}function ik({defaultProp:e,onChange:t}){const[n,s]=c.useState(e),o=c.useRef(n),i=c.useRef(t);return ok(()=>{i.current=t},[t]),c.useEffect(()=>{o.current!==n&&(i.current?.(n),o.current=n)},[n,o]),[n,s,i]}function ak(e){return typeof e=="function"}function lk(e,t){return c.useReducer((n,s)=>t[n][s]??n,e)}var wt=e=>{const{present:t,children:n}=e,s=ck(t),o=typeof n=="function"?n({present:s.isPresent}):c.Children.only(n),i=uk(s.ref,dk(o));return typeof n=="function"||s.isPresent?c.cloneElement(o,{ref:i}):null};wt.displayName="Presence";function ck(e){const[t,n]=c.useState(),s=c.useRef(null),o=c.useRef(e),i=c.useRef("none"),a=c.useRef(void 0),l=e?"mounted":"unmounted",[u,d]=lk(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return c.useEffect(()=>{u==="mounted"?(i.current=a.current??Us(s.current),a.current=void 0):i.current="none"},[u]),Je(()=>{const p=s.current,f=o.current;if(f!==e){const h=i.current,g=Us(p);e?(a.current=g,d("MOUNT")):g==="none"||p?.display==="none"?d("UNMOUNT"):d(f&&h!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),Je(()=>{if(t){let p;const f=t.ownerDocument.defaultView??window,m=g=>{const b=Us(s.current).includes(CSS.escape(g.animationName));if(g.target===t&&b&&(d("ANIMATION_END"),!o.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",p=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},h=g=>{g.target===t&&(i.current=Us(s.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{f.clearTimeout(p),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:c.useCallback(p=>{if(p){const f=getComputedStyle(p);s.current=f,a.current=Us(f)}else s.current=null;n(p)},[])}}function cu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function uk(...e){const t=c.useRef(e);return t.current=e,c.useCallback(n=>{const s=t.current;let o=!1;const i=s.map(a=>{const l=cu(a,n);return!o&&typeof l=="function"&&(o=!0),l});if(o)return()=>{for(let a=0;a<i.length;a++){const l=i[a];typeof l=="function"?l():cu(s[a],null)}}},[])}function Us(e){return e?.animationName||"none"}function dk(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var pk=Bo[" useId ".trim().toString()]||(()=>{}),fk=0;function qt(e){const[t,n]=c.useState(pk());return Je(()=>{n(s=>s??String(fk++))},[e]),t?`radix-${t}`:""}var Yo="Collapsible",[mk]=dn(Yo),[hk,Ll]=mk(Yo),Ef=c.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:s,defaultOpen:o,disabled:i,onOpenChange:a,...l}=e,[u,d]=qn({prop:s,defaultProp:o??!1,onChange:a,caller:Yo});return r.jsx(hk,{scope:n,disabled:i,contentId:qt(),open:u,onOpenToggle:c.useCallback(()=>d(p=>!p),[d]),children:r.jsx(ge.div,{"data-state":Dl(u),"data-disabled":i?"":void 0,...l,ref:t})})});Ef.displayName=Yo;var Rf="CollapsibleTrigger",Pf=c.forwardRef((e,t)=>{const{__scopeCollapsible:n,...s}=e,o=Ll(Rf,n);return r.jsx(ge.button,{type:"button","aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open||!1,"data-state":Dl(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...s,ref:t,onClick:pe(e.onClick,o.onOpenToggle)})});Pf.displayName=Rf;var $l="CollapsibleContent",If=c.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=Ll($l,e.__scopeCollapsible);return r.jsx(wt,{present:n||o.open,children:({present:i})=>r.jsx(gk,{...s,ref:t,present:i})})});If.displayName=$l;var gk=c.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:s,children:o,...i}=e,a=Ll($l,n),[l,u]=c.useState(s),d=c.useRef(null),p=Pe(t,d),f=c.useRef(0),m=f.current,h=c.useRef(0),g=h.current,y=a.open||l,b=c.useRef(y),w=c.useRef(void 0);return c.useEffect(()=>{const v=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(v)},[]),Je(()=>{const v=d.current;if(v){w.current=w.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const j=v.getBoundingClientRect();f.current=j.height,h.current=j.width,b.current||(v.style.transitionDuration=w.current.transitionDuration,v.style.animationName=w.current.animationName),u(s)}},[a.open,s]),r.jsx(ge.div,{"data-state":Dl(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!y,...i,ref:p,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:y&&o})});function Dl(e){return e?"open":"closed"}var xk=Ef,bk=c.createContext(void 0);function Xo(e){const t=c.useContext(bk);return e||t||"ltr"}function et(e){const t=c.useRef(e);return c.useEffect(()=>{t.current=e}),c.useMemo(()=>((...n)=>t.current?.(...n)),[])}var vk="DismissableLayer",Pa="dismissableLayer.update",yk="dismissableLayer.pointerDownOutside",wk="dismissableLayer.focusOutside",uu,Fl=c.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Qo=c.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:s=!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:l,onDismiss:u,...d}=e,p=c.useContext(Fl),[f,m]=c.useState(null),h=f?.ownerDocument??globalThis?.document,[,g]=c.useState({}),y=Pe(t,m),b=Array.from(p.layers),[w]=[...p.layersWithOutsidePointerEventsDisabled].slice(-1),v=w?b.indexOf(w):-1,j=f?b.indexOf(f):-1,_=p.layersWithOutsidePointerEventsDisabled.size>0,k=j>=v,S=c.useRef(!1),C=Nk(N=>{i?.(N),l?.(N),N.defaultPrevented||u?.()},{ownerDocument:h,deferPointerDownOutside:s,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:p.dismissableSurfaces,shouldHandlePointerDownOutside:c.useCallback(N=>{if(!(N instanceof Node))return!1;const I=[...p.branches].some(F=>F.contains(N));return k&&!I},[p.branches,k])}),M=Ck(N=>{if(s&&S.current)return;const I=N.target;[...p.branches].some(B=>B.contains(I))||(a?.(N),l?.(N),N.defaultPrevented||u?.())},h),A=f?j===b.length-1:!1,P=et(N=>{N.key==="Escape"&&(o?.(N),!N.defaultPrevented&&u&&(N.preventDefault(),u()))});return c.useEffect(()=>{if(A)return h.addEventListener("keydown",P,{capture:!0}),()=>h.removeEventListener("keydown",P,{capture:!0})},[h,A,P]),c.useEffect(()=>{if(f)return n&&(p.layersWithOutsidePointerEventsDisabled.size===0&&(uu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),p.layersWithOutsidePointerEventsDisabled.add(f)),p.layers.add(f),du(),()=>{n&&(p.layersWithOutsidePointerEventsDisabled.delete(f),p.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=uu))}},[f,h,n,p]),c.useEffect(()=>()=>{f&&(p.layers.delete(f),p.layersWithOutsidePointerEventsDisabled.delete(f),du())},[f,p]),c.useEffect(()=>{const N=()=>g({});return document.addEventListener(Pa,N),()=>document.removeEventListener(Pa,N)},[]),r.jsx(ge.div,{...d,ref:y,style:{pointerEvents:_?k?"auto":"none":void 0,...e.style},onFocusCapture:pe(e.onFocusCapture,M.onFocusCapture),onBlurCapture:pe(e.onBlurCapture,M.onBlurCapture),onPointerDownCapture:pe(e.onPointerDownCapture,C.onPointerDownCapture)})});Qo.displayName=vk;var jk="DismissableLayerBranch",kk=c.forwardRef((e,t)=>{const n=c.useContext(Fl),s=c.useRef(null),o=Pe(t,s);return c.useEffect(()=>{const i=s.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),r.jsx(ge.div,{...e,ref:o})});kk.displayName=jk;function _k(){const e=c.useContext(Fl),[t,n]=c.useState(null);return c.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}var Sk=()=>!0;function Nk(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:s=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:i,shouldHandlePointerDownOutside:a=Sk}=t,l=et(e),u=c.useRef(!1),d=c.useRef(!1),p=c.useRef(new Map),f=c.useRef(()=>{});return c.useEffect(()=>{function m(){d.current=!1,o.current=!1,p.current.clear()}function h(){return Array.from(p.current.values()).some(Boolean)}function g(j){if(!d.current)return;const _=j.target;_ instanceof Node&&[...i].some(S=>S.contains(_))||p.current.set(j.type,!0),j.type==="click"&&window.setTimeout(()=>{d.current&&f.current()},0)}function y(j){d.current&&p.current.set(j.type,!1)}const b=j=>{if(j.target&&!u.current){let _=function(){n.removeEventListener("click",f.current);const S=h();m(),S||Mf(yk,l,k,{discrete:!0})};if(!a(j.target)){n.removeEventListener("click",f.current),m(),u.current=!1;return}const k={originalEvent:j};d.current=!0,o.current=s&&j.button===0,p.current.clear(),!s||j.button!==0?_():(n.removeEventListener("click",f.current),f.current=_,n.addEventListener("click",f.current,{once:!0}))}else n.removeEventListener("click",f.current),m();u.current=!1},w=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const j of w)n.addEventListener(j,g,!0),n.addEventListener(j,y);const v=window.setTimeout(()=>{n.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(v),n.removeEventListener("pointerdown",b),n.removeEventListener("click",f.current);for(const j of w)n.removeEventListener(j,g,!0),n.removeEventListener(j,y)}},[n,l,s,o,i,a]),{onPointerDownCapture:()=>u.current=!0}}function Ck(e,t=globalThis?.document){const n=et(e),s=c.useRef(!1);return c.useEffect(()=>{const o=i=>{i.target&&!s.current&&Mf(wk,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function du(){const e=new CustomEvent(Pa);document.dispatchEvent(e)}function Mf(e,t,n,{discrete:s}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),s?tk(o,i):o.dispatchEvent(i)}var Mi="focusScope.autoFocusOnMount",Ai="focusScope.autoFocusOnUnmount",pu={bubbles:!1,cancelable:!0},Tk="FocusScope",Ul=c.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...a}=e,[l,u]=c.useState(null),d=et(o),p=et(i),f=c.useRef(null),m=Pe(t,u),h=c.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;c.useEffect(()=>{if(s){let y=function(j){if(h.paused||!l)return;const _=j.target;l.contains(_)?f.current=_:gn(f.current,{select:!0})},b=function(j){if(h.paused||!l)return;const _=j.relatedTarget;_!==null&&(l.contains(_)||gn(f.current,{select:!0}))},w=function(j){if(document.activeElement===document.body)for(const k of j)k.removedNodes.length>0&&gn(l)};document.addEventListener("focusin",y),document.addEventListener("focusout",b);const v=new MutationObserver(w);return l&&v.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",b),v.disconnect()}}},[s,l,h.paused]),c.useEffect(()=>{if(l){mu.add(h);const y=document.activeElement;if(!l.contains(y)){const w=new CustomEvent(Mi,pu);l.addEventListener(Mi,d),l.dispatchEvent(w),w.defaultPrevented||(Ek(Ak(Af(l)),{select:!0}),document.activeElement===y&&gn(l))}return()=>{l.removeEventListener(Mi,d),setTimeout(()=>{const w=new CustomEvent(Ai,pu);l.addEventListener(Ai,p),l.dispatchEvent(w),w.defaultPrevented||gn(y??document.body,{select:!0}),l.removeEventListener(Ai,p),mu.remove(h)},0)}}},[l,d,p,h]);const g=c.useCallback(y=>{if(!n&&!s||h.paused)return;const b=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,w=document.activeElement;if(b&&w){const v=y.currentTarget,[j,_]=Rk(v);j&&_?!y.shiftKey&&w===_?(y.preventDefault(),n&&gn(j,{select:!0})):y.shiftKey&&w===j&&(y.preventDefault(),n&&gn(_,{select:!0})):w===v&&y.preventDefault()}},[n,s,h.paused]);return r.jsx(ge.div,{tabIndex:-1,...a,ref:m,onKeyDown:g})});Ul.displayName=Tk;function Ek(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(gn(s,{select:t}),document.activeElement!==n)return}function Rk(e){const t=Af(e),n=fu(t,e),s=fu(t.reverse(),e);return[n,s]}function Af(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const o=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||o?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function fu(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const s of e)if(!(n?!s.checkVisibility({checkVisibilityCSS:!0}):Pk(s,{upTo:t})))return s}function Pk(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Ik(e){return e instanceof HTMLInputElement&&"select"in e}function gn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ik(e)&&t&&e.select()}}var mu=Mk();function Mk(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=hu(e,t),e.unshift(t)},remove(t){e=hu(e,t),e[0]?.resume()}}}function hu(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function Ak(e){return e.filter(t=>t.tagName!=="A")}var Ok="Portal",ei=c.forwardRef((e,t)=>{const{container:n,...s}=e,[o,i]=c.useState(!1);Je(()=>i(!0),[]);const a=n||o&&globalThis?.document?.body;return a?Os.createPortal(r.jsx(ge.div,{...s,ref:t}),a):null});ei.displayName=Ok;var Pr=0,ns=null;function Of(){c.useEffect(()=>{ns||(ns={start:gu(),end:gu()});const{start:e,end:t}=ns;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Pr++,()=>{Pr===1&&(ns?.start.remove(),ns?.end.remove(),ns=null),Pr=Math.max(0,Pr-1)}},[])}function gu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Ft=function(){return Ft=Object.assign||function(t){for(var n,s=1,o=arguments.length;s<o;s++){n=arguments[s];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Ft.apply(this,arguments)};function zf(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(n[s[o]]=e[s[o]]);return n}function zk(e,t,n){if(n||arguments.length===2)for(var s=0,o=t.length,i;s<o;s++)(i||!(s in t))&&(i||(i=Array.prototype.slice.call(t,0,s)),i[s]=t[s]);return e.concat(i||Array.prototype.slice.call(t))}var no="right-scroll-bar-position",so="width-before-scroll-bar",Lk="with-scroll-bars-hidden",$k="--removed-body-scroll-bar-size";function Oi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Dk(e,t){var n=c.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(s){var o=n.value;o!==s&&(n.value=s,n.callback(s,o))}}}})[0];return n.callback=t,n.facade}var Fk=typeof window<"u"?c.useLayoutEffect:c.useEffect,xu=new WeakMap;function Uk(e,t){var n=Dk(null,function(s){return e.forEach(function(o){return Oi(o,s)})});return Fk(function(){var s=xu.get(n);if(s){var o=new Set(s),i=new Set(e),a=n.current;o.forEach(function(l){i.has(l)||Oi(l,null)}),i.forEach(function(l){o.has(l)||Oi(l,a)})}xu.set(n,e)},[e]),n}function Bk(e){return e}function Vk(e,t){t===void 0&&(t=Bk);var n=[],s=!1,o={read:function(){if(s)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var a=t(i,s);return n.push(a),function(){n=n.filter(function(l){return l!==a})}},assignSyncMedium:function(i){for(s=!0;n.length;){var a=n;n=[],a.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){s=!0;var a=[];if(n.length){var l=n;n=[],l.forEach(i),a=n}var u=function(){var p=a;a=[],p.forEach(i)},d=function(){return Promise.resolve().then(u)};d(),n={push:function(p){a.push(p),d()},filter:function(p){return a=a.filter(p),n}}}};return o}function qk(e){e===void 0&&(e={});var t=Vk(null);return t.options=Ft({async:!0,ssr:!1},e),t}var Lf=function(e){var t=e.sideCar,n=zf(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return c.createElement(s,Ft({},n))};Lf.isSideCarExport=!0;function Hk(e,t){return e.useMedium(t),Lf}var $f=qk(),zi=function(){},ti=c.forwardRef(function(e,t){var n=c.useRef(null),s=c.useState({onScrollCapture:zi,onWheelCapture:zi,onTouchMoveCapture:zi}),o=s[0],i=s[1],a=e.forwardProps,l=e.children,u=e.className,d=e.removeScrollBar,p=e.enabled,f=e.shards,m=e.sideCar,h=e.noRelative,g=e.noIsolation,y=e.inert,b=e.allowPinchZoom,w=e.as,v=w===void 0?"div":w,j=e.gapMode,_=zf(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=m,S=Uk([n,t]),C=Ft(Ft({},_),o);return c.createElement(c.Fragment,null,p&&c.createElement(k,{sideCar:$f,removeScrollBar:d,shards:f,noRelative:h,noIsolation:g,inert:y,setCallbacks:i,allowPinchZoom:!!b,lockRef:n,gapMode:j}),a?c.cloneElement(c.Children.only(l),Ft(Ft({},C),{ref:S})):c.createElement(v,Ft({},C,{className:u,ref:S}),l))});ti.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ti.classNames={fullWidth:so,zeroRight:no};var Wk=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Zk(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Wk();return t&&e.setAttribute("nonce",t),e}function Kk(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Gk(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Jk=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Zk())&&(Kk(t,n),Gk(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Yk=function(){var e=Jk();return function(t,n){c.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Df=function(){var e=Yk(),t=function(n){var s=n.styles,o=n.dynamic;return e(s,o),null};return t},Xk={left:0,top:0,right:0,gap:0},Li=function(e){return parseInt(e||"",10)||0},Qk=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Li(n),Li(s),Li(o)]},e_=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Xk;var t=Qk(e),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-n+t[2]-t[0])}},t_=Df(),bs="data-scroll-locked",n_=function(e,t,n,s){var o=e.left,i=e.top,a=e.right,l=e.gap;return n===void 0&&(n="margin"),`
66
66
  .`.concat(Lk,` {
67
67
  overflow: hidden `).concat(s,`;
68
68
  padding-right: `).concat(l,"px ").concat(s,`;
@@ -99,28 +99,28 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
99
99
  body[`).concat(bs,`] {
100
100
  `).concat($k,": ").concat(l,`px;
101
101
  }
102
- `)},bu=function(){var e=parseInt(document.body.getAttribute(bs)||"0",10);return isFinite(e)?e:0},sS=function(){c.useEffect(function(){return document.body.setAttribute(bs,(bu()+1).toString()),function(){var e=bu()-1;e<=0?document.body.removeAttribute(bs):document.body.setAttribute(bs,e.toString())}},[])},rS=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,o=s===void 0?"margin":s;sS();var i=c.useMemo(function(){return eS(o)},[o]);return c.createElement(tS,{styles:nS(i,!t,o,n?"":"!important")})},Ma=!1;if(typeof window<"u")try{var Mr=Object.defineProperty({},"passive",{get:function(){return Ma=!0,!0}});window.addEventListener("test",Mr,Mr),window.removeEventListener("test",Mr,Mr)}catch{Ma=!1}var ss=Ma?{passive:!1}:!1,oS=function(e){return e.tagName==="TEXTAREA"},Fp=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!oS(e)&&n[t]==="visible")},iS=function(e){return Fp(e,"overflowY")},aS=function(e){return Fp(e,"overflowX")},vu=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var o=Up(e,s);if(o){var i=Bp(e,s),a=i[1],l=i[2];if(a>l)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},lS=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},cS=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},Up=function(e,t){return e==="v"?iS(t):aS(t)},Bp=function(e,t){return e==="v"?lS(t):cS(t)},uS=function(e,t){return e==="h"&&t==="rtl"?-1:1},dS=function(e,t,n,s,o){var i=uS(e,window.getComputedStyle(t).direction),a=i*s,l=n.target,u=t.contains(l),d=!1,f=a>0,p=0,m=0;do{if(!l)break;var h=Bp(e,l),g=h[0],y=h[1],b=h[2],w=y-b-i*g;(g||w)&&Up(e,l)&&(p+=w,m+=g);var v=l.parentNode;l=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!u&&l!==document.body||u&&(t.contains(l)||t===l));return(f&&Math.abs(p)<1||!f&&Math.abs(m)<1)&&(d=!0),d},Ir=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},yu=function(e){return[e.deltaX,e.deltaY]},wu=function(e){return e&&"current"in e?e.current:e},fS=function(e,t){return e[0]===t[0]&&e[1]===t[1]},pS=function(e){return`
102
+ `)},bu=function(){var e=parseInt(document.body.getAttribute(bs)||"0",10);return isFinite(e)?e:0},s_=function(){c.useEffect(function(){return document.body.setAttribute(bs,(bu()+1).toString()),function(){var e=bu()-1;e<=0?document.body.removeAttribute(bs):document.body.setAttribute(bs,e.toString())}},[])},r_=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,o=s===void 0?"margin":s;s_();var i=c.useMemo(function(){return e_(o)},[o]);return c.createElement(t_,{styles:n_(i,!t,o,n?"":"!important")})},Ia=!1;if(typeof window<"u")try{var Ir=Object.defineProperty({},"passive",{get:function(){return Ia=!0,!0}});window.addEventListener("test",Ir,Ir),window.removeEventListener("test",Ir,Ir)}catch{Ia=!1}var ss=Ia?{passive:!1}:!1,o_=function(e){return e.tagName==="TEXTAREA"},Ff=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!o_(e)&&n[t]==="visible")},i_=function(e){return Ff(e,"overflowY")},a_=function(e){return Ff(e,"overflowX")},vu=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var o=Uf(e,s);if(o){var i=Bf(e,s),a=i[1],l=i[2];if(a>l)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},l_=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},c_=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},Uf=function(e,t){return e==="v"?i_(t):a_(t)},Bf=function(e,t){return e==="v"?l_(t):c_(t)},u_=function(e,t){return e==="h"&&t==="rtl"?-1:1},d_=function(e,t,n,s,o){var i=u_(e,window.getComputedStyle(t).direction),a=i*s,l=n.target,u=t.contains(l),d=!1,p=a>0,f=0,m=0;do{if(!l)break;var h=Bf(e,l),g=h[0],y=h[1],b=h[2],w=y-b-i*g;(g||w)&&Uf(e,l)&&(f+=w,m+=g);var v=l.parentNode;l=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!u&&l!==document.body||u&&(t.contains(l)||t===l));return(p&&Math.abs(f)<1||!p&&Math.abs(m)<1)&&(d=!0),d},Mr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},yu=function(e){return[e.deltaX,e.deltaY]},wu=function(e){return e&&"current"in e?e.current:e},p_=function(e,t){return e[0]===t[0]&&e[1]===t[1]},f_=function(e){return`
103
103
  .block-interactivity-`.concat(e,` {pointer-events: none;}
104
104
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
105
- `)},mS=0,rs=[];function hS(e){var t=c.useRef([]),n=c.useRef([0,0]),s=c.useRef(),o=c.useState(mS++)[0],i=c.useState(Dp)[0],a=c.useRef(e);c.useEffect(function(){a.current=e},[e]),c.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var y=zk([e.lockRef.current],(e.shards||[]).map(wu),!0).filter(Boolean);return y.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),y.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=c.useCallback(function(y,b){if("touches"in y&&y.touches.length===2||y.type==="wheel"&&y.ctrlKey)return!a.current.allowPinchZoom;var w=Ir(y),v=n.current,j="deltaX"in y?y.deltaX:v[0]-w[0],S="deltaY"in y?y.deltaY:v[1]-w[1],k,_=y.target,C=Math.abs(j)>Math.abs(S)?"h":"v";if("touches"in y&&C==="h"&&_.type==="range")return!1;var I=window.getSelection(),A=I&&I.anchorNode,P=A?A===_||A.contains(_):!1;if(P)return!1;var N=vu(C,_);if(!N)return!0;if(N?k=C:(k=C==="v"?"h":"v",N=vu(C,_)),!N)return!1;if(!s.current&&"changedTouches"in y&&(j||S)&&(s.current=k),!k)return!0;var M=s.current||k;return dS(M,b,y,M==="h"?j:S)},[]),u=c.useCallback(function(y){var b=y;if(!(!rs.length||rs[rs.length-1]!==i)){var w="deltaY"in b?yu(b):Ir(b),v=t.current.filter(function(k){return k.name===b.type&&(k.target===b.target||b.target===k.shadowParent)&&fS(k.delta,w)})[0];if(v&&v.should){b.cancelable&&b.preventDefault();return}if(!v){var j=(a.current.shards||[]).map(wu).filter(Boolean).filter(function(k){return k.contains(b.target)}),S=j.length>0?l(b,j[0]):!a.current.noIsolation;S&&b.cancelable&&b.preventDefault()}}},[]),d=c.useCallback(function(y,b,w,v){var j={name:y,delta:b,target:w,should:v,shadowParent:gS(w)};t.current.push(j),setTimeout(function(){t.current=t.current.filter(function(S){return S!==j})},1)},[]),f=c.useCallback(function(y){n.current=Ir(y),s.current=void 0},[]),p=c.useCallback(function(y){d(y.type,yu(y),y.target,l(y,e.lockRef.current))},[]),m=c.useCallback(function(y){d(y.type,Ir(y),y.target,l(y,e.lockRef.current))},[]);c.useEffect(function(){return rs.push(i),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",u,ss),document.addEventListener("touchmove",u,ss),document.addEventListener("touchstart",f,ss),function(){rs=rs.filter(function(y){return y!==i}),document.removeEventListener("wheel",u,ss),document.removeEventListener("touchmove",u,ss),document.removeEventListener("touchstart",f,ss)}},[]);var h=e.removeScrollBar,g=e.inert;return c.createElement(c.Fragment,null,g?c.createElement(i,{styles:pS(o)}):null,h?c.createElement(rS,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function gS(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const xS=Hk($p,hS);var Bl=c.forwardRef(function(e,t){return c.createElement(ti,Ft({},e,{ref:t,sideCar:xS}))});Bl.classNames=ti.classNames;var bS=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},os=new WeakMap,Ar=new WeakMap,Or={},$i=0,Vp=function(e){return e&&(e.host||Vp(e.parentNode))},vS=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=Vp(n);return s&&e.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},yS=function(e,t,n,s){var o=vS(t,Array.isArray(e)?e:[e]);Or[n]||(Or[n]=new WeakMap);var i=Or[n],a=[],l=new Set,u=new Set(o),d=function(p){!p||l.has(p)||(l.add(p),d(p.parentNode))};o.forEach(d);var f=function(p){!p||u.has(p)||Array.prototype.forEach.call(p.children,function(m){if(l.has(m))f(m);else try{var h=m.getAttribute(s),g=h!==null&&h!=="false",y=(os.get(m)||0)+1,b=(i.get(m)||0)+1;os.set(m,y),i.set(m,b),a.push(m),y===1&&g&&Ar.set(m,!0),b===1&&m.setAttribute(n,"true"),g||m.setAttribute(s,"true")}catch(w){console.error("aria-hidden: cannot operate on ",m,w)}})};return f(t),l.clear(),$i++,function(){a.forEach(function(p){var m=os.get(p)-1,h=i.get(p)-1;os.set(p,m),i.set(p,h),m||(Ar.has(p)||p.removeAttribute(s),Ar.delete(p)),h||p.removeAttribute(n)}),$i--,$i||(os=new WeakMap,os=new WeakMap,Ar=new WeakMap,Or={})}},qp=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),o=bS(e);return o?(s.push.apply(s,Array.from(o.querySelectorAll("[aria-live], script"))),yS(s,o,n,"aria-hidden")):function(){return null}},ni="Dialog",[Hp]=dn(ni),[wS,zt]=Hp(ni),Wp=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:o,onOpenChange:i,modal:a=!0}=e,l=c.useRef(null),u=c.useRef(null),[d,f]=qn({prop:s,defaultProp:o??!1,onChange:i,caller:ni});return r.jsx(wS,{scope:t,triggerRef:l,contentRef:u,contentId:qt(),titleId:qt(),descriptionId:qt(),open:d,onOpenChange:f,onOpenToggle:c.useCallback(()=>f(p=>!p),[f]),modal:a,children:n})};Wp.displayName=ni;var Zp="DialogTrigger",Kp=c.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=zt(Zp,n),i=Pe(t,o.triggerRef);return r.jsx(ge.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":ql(o.open),...s,ref:i,onClick:fe(e.onClick,o.onOpenToggle)})});Kp.displayName=Zp;var Vl="DialogPortal",[jS,Gp]=Hp(Vl,{forceMount:void 0}),Jp=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:o}=e,i=zt(Vl,t);return r.jsx(jS,{scope:t,forceMount:n,children:c.Children.map(s,a=>r.jsx(wt,{present:n||i.open,children:r.jsx(ei,{asChild:!0,container:o,children:a})}))})};Jp.displayName=Vl;var jo="DialogOverlay",Yp=c.forwardRef((e,t)=>{const n=Gp(jo,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,i=zt(jo,e.__scopeDialog);return i.modal?r.jsx(wt,{present:s||i.open,children:r.jsx(SS,{...o,ref:t})}):null});Yp.displayName=jo;var kS=Cs("DialogOverlay.RemoveScroll"),SS=c.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=zt(jo,n),i=Sk(),a=Pe(t,i);return r.jsx(Bl,{as:kS,allowPinchZoom:!0,shards:[o.contentRef],children:r.jsx(ge.div,{"data-state":ql(o.open),...s,ref:a,style:{pointerEvents:"auto",...s.style}})})}),Ts="DialogContent",Xp=c.forwardRef((e,t)=>{const n=Gp(Ts,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,i=zt(Ts,e.__scopeDialog);return r.jsx(wt,{present:s||i.open,children:i.modal?r.jsx(_S,{...o,ref:t}):r.jsx(NS,{...o,ref:t})})});Xp.displayName=Ts;var _S=c.forwardRef((e,t)=>{const n=zt(Ts,e.__scopeDialog),s=c.useRef(null),o=Pe(t,n.contentRef,s);return c.useEffect(()=>{const i=s.current;if(i)return qp(i)},[]),r.jsx(Qp,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:fe(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:fe(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&i.preventDefault()}),onFocusOutside:fe(e.onFocusOutside,i=>i.preventDefault())})}),NS=c.forwardRef((e,t)=>{const n=zt(Ts,e.__scopeDialog),s=c.useRef(!1),o=c.useRef(!1);return r.jsx(Qp,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(s.current||n.triggerRef.current?.focus(),i.preventDefault()),s.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(s.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=i.target;n.triggerRef.current?.contains(a)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),Qp=c.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:i,...a}=e,l=zt(Ts,n);return Op(),r.jsx(r.Fragment,{children:r.jsx(Ul,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:i,children:r.jsx(Qo,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":ql(l.open),...a,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),em="DialogTitle",tm=c.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=zt(em,n);return r.jsx(ge.h2,{id:o.titleId,...s,ref:t})});tm.displayName=em;var nm="DialogDescription",sm=c.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=zt(nm,n);return r.jsx(ge.p,{id:o.descriptionId,...s,ref:t})});sm.displayName=nm;var rm="DialogClose",om=c.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=zt(rm,n);return r.jsx(ge.button,{type:"button",...s,ref:t,onClick:fe(e.onClick,()=>o.onOpenChange(!1))})});om.displayName=rm;function ql(e){return e?"open":"closed"}function CS(e){const t=c.useRef({value:e,previous:e});return c.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function TS(e){const[t,n]=c.useState(void 0);return Je(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let a,l;if("borderBoxSize"in i){const u=i.borderBoxSize,d=Array.isArray(u)?u[0]:u;a=d.inlineSize,l=d.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}const ES=["top","right","bottom","left"],kn=Math.min,gt=Math.max,ko=Math.round,zr=Math.floor,Ht=e=>({x:e,y:e}),RS={left:"right",right:"left",bottom:"top",top:"bottom"},PS={start:"end",end:"start"};function Ia(e,t,n){return gt(e,kn(t,n))}function ln(e,t){return typeof e=="function"?e(t):e}function cn(e){return e.split("-")[0]}function Ls(e){return e.split("-")[1]}function Hl(e){return e==="x"?"y":"x"}function Wl(e){return e==="y"?"height":"width"}const MS=new Set(["top","bottom"]);function Ut(e){return MS.has(cn(e))?"y":"x"}function Zl(e){return Hl(Ut(e))}function IS(e,t,n){n===void 0&&(n=!1);const s=Ls(e),o=Zl(e),i=Wl(o);let a=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=So(a)),[a,So(a)]}function AS(e){const t=So(e);return[Aa(e),t,Aa(t)]}function Aa(e){return e.replace(/start|end/g,t=>PS[t])}const ju=["left","right"],ku=["right","left"],OS=["top","bottom"],zS=["bottom","top"];function LS(e,t,n){switch(e){case"top":case"bottom":return n?t?ku:ju:t?ju:ku;case"left":case"right":return t?OS:zS;default:return[]}}function $S(e,t,n,s){const o=Ls(e);let i=LS(cn(e),n==="start",s);return o&&(i=i.map(a=>a+"-"+o),t&&(i=i.concat(i.map(Aa)))),i}function So(e){return e.replace(/left|right|bottom|top/g,t=>RS[t])}function DS(e){return{top:0,right:0,bottom:0,left:0,...e}}function im(e){return typeof e!="number"?DS(e):{top:e,right:e,bottom:e,left:e}}function _o(e){const{x:t,y:n,width:s,height:o}=e;return{width:s,height:o,top:n,left:t,right:t+s,bottom:n+o,x:t,y:n}}function Su(e,t,n){let{reference:s,floating:o}=e;const i=Ut(t),a=Zl(t),l=Wl(a),u=cn(t),d=i==="y",f=s.x+s.width/2-o.width/2,p=s.y+s.height/2-o.height/2,m=s[l]/2-o[l]/2;let h;switch(u){case"top":h={x:f,y:s.y-o.height};break;case"bottom":h={x:f,y:s.y+s.height};break;case"right":h={x:s.x+s.width,y:p};break;case"left":h={x:s.x-o.width,y:p};break;default:h={x:s.x,y:s.y}}switch(Ls(t)){case"start":h[a]-=m*(n&&d?-1:1);break;case"end":h[a]+=m*(n&&d?-1:1);break}return h}async function FS(e,t){var n;t===void 0&&(t={});const{x:s,y:o,platform:i,rects:a,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:p="floating",altBoundary:m=!1,padding:h=0}=ln(t,e),g=im(h),b=l[m?p==="floating"?"reference":"floating":p],w=_o(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:u})),v=p==="floating"?{x:s,y:o,width:a.floating.width,height:a.floating.height}:a.reference,j=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),S=await(i.isElement==null?void 0:i.isElement(j))?await(i.getScale==null?void 0:i.getScale(j))||{x:1,y:1}:{x:1,y:1},k=_o(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:j,strategy:u}):v);return{top:(w.top-k.top+g.top)/S.y,bottom:(k.bottom-w.bottom+g.bottom)/S.y,left:(w.left-k.left+g.left)/S.x,right:(k.right-w.right+g.right)/S.x}}const US=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:i=[],platform:a}=n,l=i.filter(Boolean),u=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:p}=Su(d,s,u),m=s,h={},g=0;for(let b=0;b<l.length;b++){var y;const{name:w,fn:v}=l[b],{x:j,y:S,data:k,reset:_}=await v({x:f,y:p,initialPlacement:s,placement:m,strategy:o,middlewareData:h,rects:d,platform:{...a,detectOverflow:(y=a.detectOverflow)!=null?y:FS},elements:{reference:e,floating:t}});f=j??f,p=S??p,h={...h,[w]:{...h[w],...k}},_&&g<=50&&(g++,typeof _=="object"&&(_.placement&&(m=_.placement),_.rects&&(d=_.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):_.rects),{x:f,y:p}=Su(d,m,u)),b=-1)}return{x:f,y:p,placement:m,strategy:o,middlewareData:h}},BS=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:o,rects:i,platform:a,elements:l,middlewareData:u}=t,{element:d,padding:f=0}=ln(e,t)||{};if(d==null)return{};const p=im(f),m={x:n,y:s},h=Zl(o),g=Wl(h),y=await a.getDimensions(d),b=h==="y",w=b?"top":"left",v=b?"bottom":"right",j=b?"clientHeight":"clientWidth",S=i.reference[g]+i.reference[h]-m[h]-i.floating[g],k=m[h]-i.reference[h],_=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let C=_?_[j]:0;(!C||!await(a.isElement==null?void 0:a.isElement(_)))&&(C=l.floating[j]||i.floating[g]);const I=S/2-k/2,A=C/2-y[g]/2-1,P=kn(p[w],A),N=kn(p[v],A),M=P,F=C-y[g]-N,B=C/2-y[g]/2+I,J=Ia(M,B,F),K=!u.arrow&&Ls(o)!=null&&B!==J&&i.reference[g]/2-(B<M?P:N)-y[g]/2<0,W=K?B<M?B-M:B-F:0;return{[h]:m[h]+W,data:{[h]:J,centerOffset:B-J-W,...K&&{alignmentOffset:W}},reset:K}}}),VS=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:o,middlewareData:i,rects:a,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:f=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...b}=ln(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=cn(o),v=Ut(l),j=cn(l)===l,S=await(u.isRTL==null?void 0:u.isRTL(d.floating)),k=m||(j||!y?[So(l)]:AS(l)),_=g!=="none";!m&&_&&k.push(...$S(l,y,g,S));const C=[l,...k],I=await u.detectOverflow(t,b),A=[];let P=((s=i.flip)==null?void 0:s.overflows)||[];if(f&&A.push(I[w]),p){const B=IS(o,a,S);A.push(I[B[0]],I[B[1]])}if(P=[...P,{placement:o,overflows:A}],!A.every(B=>B<=0)){var N,M;const B=(((N=i.flip)==null?void 0:N.index)||0)+1,J=C[B];if(J&&(!(p==="alignment"?v!==Ut(J):!1)||P.every(V=>Ut(V.placement)===v?V.overflows[0]>0:!0)))return{data:{index:B,overflows:P},reset:{placement:J}};let K=(M=P.filter(W=>W.overflows[0]<=0).sort((W,V)=>W.overflows[1]-V.overflows[1])[0])==null?void 0:M.placement;if(!K)switch(h){case"bestFit":{var F;const W=(F=P.filter(V=>{if(_){const z=Ut(V.placement);return z===v||z==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(z=>z>0).reduce((z,X)=>z+X,0)]).sort((V,z)=>V[1]-z[1])[0])==null?void 0:F[0];W&&(K=W);break}case"initialPlacement":K=l;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function _u(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Nu(e){return ES.some(t=>e[t]>=0)}const qS=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:o="referenceHidden",...i}=ln(e,t);switch(o){case"referenceHidden":{const a=await s.detectOverflow(t,{...i,elementContext:"reference"}),l=_u(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Nu(l)}}}case"escaped":{const a=await s.detectOverflow(t,{...i,altBoundary:!0}),l=_u(a,n.floating);return{data:{escapedOffsets:l,escaped:Nu(l)}}}default:return{}}}}},am=new Set(["left","top"]);async function HS(e,t){const{placement:n,platform:s,elements:o}=e,i=await(s.isRTL==null?void 0:s.isRTL(o.floating)),a=cn(n),l=Ls(n),u=Ut(n)==="y",d=am.has(a)?-1:1,f=i&&u?-1:1,p=ln(t,e);let{mainAxis:m,crossAxis:h,alignmentAxis:g}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof g=="number"&&(h=l==="end"?g*-1:g),u?{x:h*f,y:m*d}:{x:m*d,y:h*f}}const WS=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:o,y:i,placement:a,middlewareData:l}=t,u=await HS(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(s=l.arrow)!=null&&s.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:a}}}}},ZS=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:o,platform:i}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:u={fn:w=>{let{x:v,y:j}=w;return{x:v,y:j}}},...d}=ln(e,t),f={x:n,y:s},p=await i.detectOverflow(t,d),m=Ut(cn(o)),h=Hl(m);let g=f[h],y=f[m];if(a){const w=h==="y"?"top":"left",v=h==="y"?"bottom":"right",j=g+p[w],S=g-p[v];g=Ia(j,g,S)}if(l){const w=m==="y"?"top":"left",v=m==="y"?"bottom":"right",j=y+p[w],S=y-p[v];y=Ia(j,y,S)}const b=u.fn({...t,[h]:g,[m]:y});return{...b,data:{x:b.x-n,y:b.y-s,enabled:{[h]:a,[m]:l}}}}}},KS=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:o,rects:i,middlewareData:a}=t,{offset:l=0,mainAxis:u=!0,crossAxis:d=!0}=ln(e,t),f={x:n,y:s},p=Ut(o),m=Hl(p);let h=f[m],g=f[p];const y=ln(l,t),b=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(u){const j=m==="y"?"height":"width",S=i.reference[m]-i.floating[j]+b.mainAxis,k=i.reference[m]+i.reference[j]-b.mainAxis;h<S?h=S:h>k&&(h=k)}if(d){var w,v;const j=m==="y"?"width":"height",S=am.has(cn(o)),k=i.reference[p]-i.floating[j]+(S&&((w=a.offset)==null?void 0:w[p])||0)+(S?0:b.crossAxis),_=i.reference[p]+i.reference[j]+(S?0:((v=a.offset)==null?void 0:v[p])||0)-(S?b.crossAxis:0);g<k?g=k:g>_&&(g=_)}return{[m]:h,[p]:g}}}},GS=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:o,rects:i,platform:a,elements:l}=t,{apply:u=()=>{},...d}=ln(e,t),f=await a.detectOverflow(t,d),p=cn(o),m=Ls(o),h=Ut(o)==="y",{width:g,height:y}=i.floating;let b,w;p==="top"||p==="bottom"?(b=p,w=m===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(w=p,b=m==="end"?"top":"bottom");const v=y-f.top-f.bottom,j=g-f.left-f.right,S=kn(y-f[b],v),k=kn(g-f[w],j),_=!t.middlewareData.shift;let C=S,I=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(I=j),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(C=v),_&&!m){const P=gt(f.left,0),N=gt(f.right,0),M=gt(f.top,0),F=gt(f.bottom,0);h?I=g-2*(P!==0||N!==0?P+N:gt(f.left,f.right)):C=y-2*(M!==0||F!==0?M+F:gt(f.top,f.bottom))}await u({...t,availableWidth:I,availableHeight:C});const A=await a.getDimensions(l.floating);return g!==A.width||y!==A.height?{reset:{rects:!0}}:{}}}};function si(){return typeof window<"u"}function $s(e){return lm(e)?(e.nodeName||"").toLowerCase():"#document"}function vt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Jt(e){var t;return(t=(lm(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function lm(e){return si()?e instanceof Node||e instanceof vt(e).Node:!1}function Mt(e){return si()?e instanceof Element||e instanceof vt(e).Element:!1}function Wt(e){return si()?e instanceof HTMLElement||e instanceof vt(e).HTMLElement:!1}function Cu(e){return!si()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof vt(e).ShadowRoot}const JS=new Set(["inline","contents"]);function xr(e){const{overflow:t,overflowX:n,overflowY:s,display:o}=It(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!JS.has(o)}const YS=new Set(["table","td","th"]);function XS(e){return YS.has($s(e))}const QS=[":popover-open",":modal"];function ri(e){return QS.some(t=>{try{return e.matches(t)}catch{return!1}})}const e_=["transform","translate","scale","rotate","perspective"],t_=["transform","translate","scale","rotate","perspective","filter"],n_=["paint","layout","strict","content"];function Kl(e){const t=Gl(),n=Mt(e)?It(e):e;return e_.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||t_.some(s=>(n.willChange||"").includes(s))||n_.some(s=>(n.contain||"").includes(s))}function s_(e){let t=Sn(e);for(;Wt(t)&&!Es(t);){if(Kl(t))return t;if(ri(t))return null;t=Sn(t)}return null}function Gl(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const r_=new Set(["html","body","#document"]);function Es(e){return r_.has($s(e))}function It(e){return vt(e).getComputedStyle(e)}function oi(e){return Mt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Sn(e){if($s(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Cu(e)&&e.host||Jt(e);return Cu(t)?t.host:t}function cm(e){const t=Sn(e);return Es(t)?e.ownerDocument?e.ownerDocument.body:e.body:Wt(t)&&xr(t)?t:cm(t)}function or(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=cm(e),i=o===((s=e.ownerDocument)==null?void 0:s.body),a=vt(o);if(i){const l=Oa(a);return t.concat(a,a.visualViewport||[],xr(o)?o:[],l&&n?or(l):[])}return t.concat(o,or(o,[],n))}function Oa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function um(e){const t=It(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=Wt(e),i=o?e.offsetWidth:n,a=o?e.offsetHeight:s,l=ko(n)!==i||ko(s)!==a;return l&&(n=i,s=a),{width:n,height:s,$:l}}function Jl(e){return Mt(e)?e:e.contextElement}function vs(e){const t=Jl(e);if(!Wt(t))return Ht(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:i}=um(t);let a=(i?ko(n.width):n.width)/s,l=(i?ko(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const o_=Ht(0);function dm(e){const t=vt(e);return!Gl()||!t.visualViewport?o_:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function i_(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==vt(e)?!1:t}function Hn(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Jl(e);let a=Ht(1);t&&(s?Mt(s)&&(a=vs(s)):a=vs(e));const l=i_(i,n,s)?dm(i):Ht(0);let u=(o.left+l.x)/a.x,d=(o.top+l.y)/a.y,f=o.width/a.x,p=o.height/a.y;if(i){const m=vt(i),h=s&&Mt(s)?vt(s):s;let g=m,y=Oa(g);for(;y&&s&&h!==g;){const b=vs(y),w=y.getBoundingClientRect(),v=It(y),j=w.left+(y.clientLeft+parseFloat(v.paddingLeft))*b.x,S=w.top+(y.clientTop+parseFloat(v.paddingTop))*b.y;u*=b.x,d*=b.y,f*=b.x,p*=b.y,u+=j,d+=S,g=vt(y),y=Oa(g)}}return _o({width:f,height:p,x:u,y:d})}function ii(e,t){const n=oi(e).scrollLeft;return t?t.left+n:Hn(Jt(e)).left+n}function fm(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-ii(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function a_(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const i=o==="fixed",a=Jt(s),l=t?ri(t.floating):!1;if(s===a||l&&i)return n;let u={scrollLeft:0,scrollTop:0},d=Ht(1);const f=Ht(0),p=Wt(s);if((p||!p&&!i)&&(($s(s)!=="body"||xr(a))&&(u=oi(s)),Wt(s))){const h=Hn(s);d=vs(s),f.x=h.x+s.clientLeft,f.y=h.y+s.clientTop}const m=a&&!p&&!i?fm(a,u):Ht(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+f.x+m.x,y:n.y*d.y-u.scrollTop*d.y+f.y+m.y}}function l_(e){return Array.from(e.getClientRects())}function c_(e){const t=Jt(e),n=oi(e),s=e.ownerDocument.body,o=gt(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),i=gt(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let a=-n.scrollLeft+ii(e);const l=-n.scrollTop;return It(s).direction==="rtl"&&(a+=gt(t.clientWidth,s.clientWidth)-o),{width:o,height:i,x:a,y:l}}const Tu=25;function u_(e,t){const n=vt(e),s=Jt(e),o=n.visualViewport;let i=s.clientWidth,a=s.clientHeight,l=0,u=0;if(o){i=o.width,a=o.height;const f=Gl();(!f||f&&t==="fixed")&&(l=o.offsetLeft,u=o.offsetTop)}const d=ii(s);if(d<=0){const f=s.ownerDocument,p=f.body,m=getComputedStyle(p),h=f.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(s.clientWidth-p.clientWidth-h);g<=Tu&&(i-=g)}else d<=Tu&&(i+=d);return{width:i,height:a,x:l,y:u}}const d_=new Set(["absolute","fixed"]);function f_(e,t){const n=Hn(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,i=Wt(e)?vs(e):Ht(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,u=o*i.x,d=s*i.y;return{width:a,height:l,x:u,y:d}}function Eu(e,t,n){let s;if(t==="viewport")s=u_(e,n);else if(t==="document")s=c_(Jt(e));else if(Mt(t))s=f_(t,n);else{const o=dm(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return _o(s)}function pm(e,t){const n=Sn(e);return n===t||!Mt(n)||Es(n)?!1:It(n).position==="fixed"||pm(n,t)}function p_(e,t){const n=t.get(e);if(n)return n;let s=or(e,[],!1).filter(l=>Mt(l)&&$s(l)!=="body"),o=null;const i=It(e).position==="fixed";let a=i?Sn(e):e;for(;Mt(a)&&!Es(a);){const l=It(a),u=Kl(a);!u&&l.position==="fixed"&&(o=null),(i?!u&&!o:!u&&l.position==="static"&&!!o&&d_.has(o.position)||xr(a)&&!u&&pm(e,a))?s=s.filter(f=>f!==a):o=l,a=Sn(a)}return t.set(e,s),s}function m_(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const a=[...n==="clippingAncestors"?ri(t)?[]:p_(t,this._c):[].concat(n),s],l=a[0],u=a.reduce((d,f)=>{const p=Eu(t,f,o);return d.top=gt(p.top,d.top),d.right=kn(p.right,d.right),d.bottom=kn(p.bottom,d.bottom),d.left=gt(p.left,d.left),d},Eu(t,l,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function h_(e){const{width:t,height:n}=um(e);return{width:t,height:n}}function g_(e,t,n){const s=Wt(t),o=Jt(t),i=n==="fixed",a=Hn(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const u=Ht(0);function d(){u.x=ii(o)}if(s||!s&&!i)if(($s(t)!=="body"||xr(o))&&(l=oi(t)),s){const h=Hn(t,!0,i,t);u.x=h.x+t.clientLeft,u.y=h.y+t.clientTop}else o&&d();i&&!s&&o&&d();const f=o&&!s&&!i?fm(o,l):Ht(0),p=a.left+l.scrollLeft-u.x-f.x,m=a.top+l.scrollTop-u.y-f.y;return{x:p,y:m,width:a.width,height:a.height}}function Di(e){return It(e).position==="static"}function Ru(e,t){if(!Wt(e)||It(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Jt(e)===n&&(n=n.ownerDocument.body),n}function mm(e,t){const n=vt(e);if(ri(e))return n;if(!Wt(e)){let o=Sn(e);for(;o&&!Es(o);){if(Mt(o)&&!Di(o))return o;o=Sn(o)}return n}let s=Ru(e,t);for(;s&&XS(s)&&Di(s);)s=Ru(s,t);return s&&Es(s)&&Di(s)&&!Kl(s)?n:s||s_(e)||n}const x_=async function(e){const t=this.getOffsetParent||mm,n=this.getDimensions,s=await n(e.floating);return{reference:g_(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function b_(e){return It(e).direction==="rtl"}const v_={convertOffsetParentRelativeRectToViewportRelativeRect:a_,getDocumentElement:Jt,getClippingRect:m_,getOffsetParent:mm,getElementRects:x_,getClientRects:l_,getDimensions:h_,getScale:vs,isElement:Mt,isRTL:b_};function hm(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function y_(e,t){let n=null,s;const o=Jt(e);function i(){var l;clearTimeout(s),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),i();const d=e.getBoundingClientRect(),{left:f,top:p,width:m,height:h}=d;if(l||t(),!m||!h)return;const g=zr(p),y=zr(o.clientWidth-(f+m)),b=zr(o.clientHeight-(p+h)),w=zr(f),j={rootMargin:-g+"px "+-y+"px "+-b+"px "+-w+"px",threshold:gt(0,kn(1,u))||1};let S=!0;function k(_){const C=_[0].intersectionRatio;if(C!==u){if(!S)return a();C?a(!1,C):s=setTimeout(()=>{a(!1,1e-7)},1e3)}C===1&&!hm(d,e.getBoundingClientRect())&&a(),S=!1}try{n=new IntersectionObserver(k,{...j,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,j)}n.observe(e)}return a(!0),i}function w_(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=s,d=Jl(e),f=o||i?[...d?or(d):[],...or(t)]:[];f.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),i&&w.addEventListener("resize",n)});const p=d&&l?y_(d,n):null;let m=-1,h=null;a&&(h=new ResizeObserver(w=>{let[v]=w;v&&v.target===d&&h&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var j;(j=h)==null||j.observe(t)})),n()}),d&&!u&&h.observe(d),h.observe(t));let g,y=u?Hn(e):null;u&&b();function b(){const w=Hn(e);y&&!hm(y,w)&&n(),y=w,g=requestAnimationFrame(b)}return n(),()=>{var w;f.forEach(v=>{o&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),p?.(),(w=h)==null||w.disconnect(),h=null,u&&cancelAnimationFrame(g)}}const j_=WS,k_=ZS,S_=VS,__=GS,N_=qS,Pu=BS,C_=KS,T_=(e,t,n)=>{const s=new Map,o={platform:v_,...n},i={...o.platform,_c:s};return US(e,t,{...o,platform:i})};var E_=typeof document<"u",R_=function(){},ro=E_?c.useLayoutEffect:R_;function No(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!No(e[s],t[s]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,o[s]))return!1;for(s=n;s--!==0;){const i=o[s];if(!(i==="_owner"&&e.$$typeof)&&!No(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function gm(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Mu(e,t){const n=gm(e);return Math.round(t*n)/n}function Fi(e){const t=c.useRef(e);return ro(()=>{t.current=e}),t}function P_(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:o,elements:{reference:i,floating:a}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[f,p]=c.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=c.useState(s);No(m,s)||h(s);const[g,y]=c.useState(null),[b,w]=c.useState(null),v=c.useCallback(V=>{V!==_.current&&(_.current=V,y(V))},[]),j=c.useCallback(V=>{V!==C.current&&(C.current=V,w(V))},[]),S=i||g,k=a||b,_=c.useRef(null),C=c.useRef(null),I=c.useRef(f),A=u!=null,P=Fi(u),N=Fi(o),M=Fi(d),F=c.useCallback(()=>{if(!_.current||!C.current)return;const V={placement:t,strategy:n,middleware:m};N.current&&(V.platform=N.current),T_(_.current,C.current,V).then(z=>{const X={...z,isPositioned:M.current!==!1};B.current&&!No(I.current,X)&&(I.current=X,Os.flushSync(()=>{p(X)}))})},[m,t,n,N,M]);ro(()=>{d===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,p(V=>({...V,isPositioned:!1})))},[d]);const B=c.useRef(!1);ro(()=>(B.current=!0,()=>{B.current=!1}),[]),ro(()=>{if(S&&(_.current=S),k&&(C.current=k),S&&k){if(P.current)return P.current(S,k,F);F()}},[S,k,F,P,A]);const J=c.useMemo(()=>({reference:_,floating:C,setReference:v,setFloating:j}),[v,j]),K=c.useMemo(()=>({reference:S,floating:k}),[S,k]),W=c.useMemo(()=>{const V={position:n,left:0,top:0};if(!K.floating)return V;const z=Mu(K.floating,f.x),X=Mu(K.floating,f.y);return l?{...V,transform:"translate("+z+"px, "+X+"px)",...gm(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:X}},[n,l,K.floating,f.x,f.y]);return c.useMemo(()=>({...f,update:F,refs:J,elements:K,floatingStyles:W}),[f,F,J,K,W])}const M_=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:o}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?Pu({element:s.current,padding:o}).fn(n):{}:s?Pu({element:s,padding:o}).fn(n):{}}}},I_=(e,t)=>({...j_(e),options:[e,t]}),A_=(e,t)=>({...k_(e),options:[e,t]}),O_=(e,t)=>({...C_(e),options:[e,t]}),z_=(e,t)=>({...S_(e),options:[e,t]}),L_=(e,t)=>({...__(e),options:[e,t]}),$_=(e,t)=>({...N_(e),options:[e,t]}),D_=(e,t)=>({...M_(e),options:[e,t]});var F_="Arrow",xm=c.forwardRef((e,t)=>{const{children:n,width:s=10,height:o=5,...i}=e;return r.jsx(ge.svg,{...i,ref:t,width:s,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});xm.displayName=F_;var U_=xm,Yl="Popper",[bm,ai]=dn(Yl),[B_,vm]=bm(Yl),ym=e=>{const{__scopePopper:t,children:n}=e,[s,o]=c.useState(null),[i,a]=c.useState(void 0);return r.jsx(B_,{scope:t,anchor:s,onAnchorChange:o,placementState:i,setPlacementState:a,children:n})};ym.displayName=Yl;var wm="PopperAnchor",jm=c.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,i=vm(wm,n),a=c.useRef(null),l=i.onAnchorChange,u=c.useCallback(g=>{a.current=g,g&&l(g)},[l]),d=Pe(t,u),f=c.useRef(null);c.useEffect(()=>{if(!s)return;const g=f.current;f.current=s.current,g!==f.current&&l(f.current)});const p=i.placementState&&Ql(i.placementState),m=p?.[0],h=p?.[1];return s?null:r.jsx(ge.div,{"data-radix-popper-side":m,"data-radix-popper-align":h,...o,ref:d})});jm.displayName=wm;var Xl="PopperContent",[V_,q_]=bm(Xl),km=c.forwardRef((e,t)=>{const{__scopePopper:n,side:s="bottom",sideOffset:o=0,align:i="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:h="optimized",onPlaced:g,...y}=e,b=vm(Xl,n),[w,v]=c.useState(null),j=Pe(t,v),[S,k]=c.useState(null),_=TS(S),C=_?.width??0,I=_?.height??0,A=s+(i!=="center"?"-"+i:""),P=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},N=Array.isArray(d)?d:[d],M=N.length>0,F={padding:P,boundary:N.filter(W_),altBoundary:M},{refs:B,floatingStyles:J,placement:K,isPositioned:W,middlewareData:V}=P_({strategy:"fixed",placement:A,whileElementsMounted:(...je)=>w_(...je,{animationFrame:h==="always"}),elements:{reference:b.anchor},middleware:[I_({mainAxis:o+I,alignmentAxis:a}),u&&A_({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?O_():void 0,...F}),u&&z_({...F}),L_({...F,apply:({elements:je,rects:ke,availableWidth:ue,availableHeight:le})=>{const{width:xe,height:Se}=ke.reference,ve=je.floating.style;ve.setProperty("--radix-popper-available-width",`${ue}px`),ve.setProperty("--radix-popper-available-height",`${le}px`),ve.setProperty("--radix-popper-anchor-width",`${xe}px`),ve.setProperty("--radix-popper-anchor-height",`${Se}px`)}}),S&&D_({element:S,padding:l}),Z_({arrowWidth:C,arrowHeight:I}),m&&$_({strategy:"referenceHidden",...F,boundary:M?F.boundary:void 0})]}),z=b.setPlacementState;Je(()=>(z(K),()=>{z(void 0)}),[K,z]);const[X,Y]=Ql(K),we=et(g);Je(()=>{W&&we?.()},[W,we]);const he=V.arrow?.x,oe=V.arrow?.y,D=V.arrow?.centerOffset!==0,[Ne,te]=c.useState();return Je(()=>{w&&te(window.getComputedStyle(w).zIndex)},[w]),r.jsx("div",{ref:B.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:W?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ne,"--radix-popper-transform-origin":[V.transformOrigin?.x,V.transformOrigin?.y].join(" "),...V.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(V_,{scope:n,placedSide:X,placedAlign:Y,onArrowChange:k,arrowX:he,arrowY:oe,shouldHideArrow:D,children:r.jsx(ge.div,{"data-side":X,"data-align":Y,...y,ref:j,style:{...y.style,animation:W?void 0:"none"}})})})});km.displayName=Xl;var Sm="PopperArrow",H_={top:"bottom",right:"left",bottom:"top",left:"right"},_m=c.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,i=q_(Sm,s),a=H_[i.placedSide];return r.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:r.jsx(U_,{...o,ref:n,style:{...o.style,display:"block"}})})});_m.displayName=Sm;function W_(e){return e!==null}var Z_=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:s,middlewareData:o}=t,a=o.arrow?.centerOffset!==0,l=a?0:e.arrowWidth,u=a?0:e.arrowHeight,[d,f]=Ql(n),p={start:"0%",center:"50%",end:"100%"}[f],m=(o.arrow?.x??0)+l/2,h=(o.arrow?.y??0)+u/2;let g="",y="";return d==="bottom"?(g=a?p:`${m}px`,y=`${-u}px`):d==="top"?(g=a?p:`${m}px`,y=`${s.floating.height+u}px`):d==="right"?(g=`${-u}px`,y=a?p:`${h}px`):d==="left"&&(g=`${s.floating.width+u}px`,y=a?p:`${h}px`),{data:{x:g,y}}}});function Ql(e){const[t,n="center"]=e.split("-");return[t,n]}var Nm=ym,Cm=jm,Tm=km,Em=_m,Ui=!1;function K_(){const[e,t]=c.useState(Ui);return c.useEffect(()=>{Ui||(Ui=!0,t(!0))},[]),e}var Rm=Bo[" useSyncExternalStore ".trim().toString()];function G_(){return()=>{}}function J_(){return Rm(G_,()=>!0,()=>!1)}var Y_=typeof Rm=="function"?J_:K_,Bi="rovingFocusGroup.onEntryFocus",X_={bubbles:!1,cancelable:!0},br="RovingFocusGroup",[za,Pm,Q_]=Tp(br),[eN,Mm]=dn(br,[Q_]),[tN,nN]=eN(br),Im=c.forwardRef((e,t)=>r.jsx(za.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(za.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(sN,{...e,ref:t})})}));Im.displayName=br;var sN=c.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...p}=e,m=c.useRef(null),h=Pe(t,m),g=Xo(i),[y,b]=qn({prop:a,defaultProp:l??null,onChange:u,caller:br}),[w,v]=c.useState(!1),j=et(d),S=Pm(n),k=c.useRef(!1),[_,C]=c.useState(0);return c.useEffect(()=>{const I=m.current;if(I)return I.addEventListener(Bi,j),()=>I.removeEventListener(Bi,j)},[j]),r.jsx(tN,{scope:n,orientation:s,dir:g,loop:o,currentTabStopId:y,onItemFocus:c.useCallback(I=>b(I),[b]),onItemShiftTab:c.useCallback(()=>v(!0),[]),onFocusableItemAdd:c.useCallback(()=>C(I=>I+1),[]),onFocusableItemRemove:c.useCallback(()=>C(I=>I-1),[]),children:r.jsx(ge.div,{tabIndex:w||_===0?-1:0,"data-orientation":s,...p,ref:h,style:{outline:"none",...e.style},onMouseDown:fe(e.onMouseDown,()=>{k.current=!0}),onFocus:fe(e.onFocus,I=>{const A=!k.current;if(I.target===I.currentTarget&&A&&!w){const P=new CustomEvent(Bi,X_);if(I.currentTarget.dispatchEvent(P),!P.defaultPrevented){const N=S().filter(K=>K.focusable),M=N.find(K=>K.active),F=N.find(K=>K.id===y),J=[M,F,...N].filter(Boolean).map(K=>K.ref.current);zm(J,f)}}k.current=!1}),onBlur:fe(e.onBlur,()=>v(!1))})})}),Am="RovingFocusGroupItem",Om=c.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:i,children:a,...l}=e,u=qt(),d=i||u,f=nN(Am,n),p=f.currentTabStopId===d,m=Pm(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:y}=f,b=Y_();return Je(()=>{if(!(!b||!s))return h(),()=>g()},[b,s,h,g]),c.useEffect(()=>{if(!(b||!s))return h(),()=>g()},[b,s,h,g]),r.jsx(za.ItemSlot,{scope:n,id:d,focusable:s,active:o,children:r.jsx(ge.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:fe(e.onMouseDown,w=>{s?f.onItemFocus(d):w.preventDefault()}),onFocus:fe(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:fe(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){f.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const v=iN(w,f.orientation,f.dir);if(v!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(v==="last")S.reverse();else if(v==="prev"||v==="next"){v==="prev"&&S.reverse();const k=S.indexOf(w.currentTarget);S=f.loop?aN(S,k+1):S.slice(k+1)}setTimeout(()=>zm(S))}}),children:typeof a=="function"?a({isCurrentTabStop:p,hasTabStop:y!=null}):a})})});Om.displayName=Am;var rN={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function oN(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function iN(e,t,n){const s=oN(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return rN[s]}function zm(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function aN(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var lN=Im,cN=Om;function La(e,[t,n]){return Math.min(n,Math.max(t,e))}function uN(e,t){return c.useReducer((n,s)=>t[n][s]??n,e)}var ec="ScrollArea",[Lm]=dn(ec),[dN,_t]=Lm(ec),$m=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:s="hover",dir:o,scrollHideDelay:i=600,...a}=e,[l,u]=c.useState(null),[d,f]=c.useState(null),[p,m]=c.useState(null),[h,g]=c.useState(null),[y,b]=c.useState(null),[w,v]=c.useState(0),[j,S]=c.useState(0),[k,_]=c.useState(!1),[C,I]=c.useState(!1),A=Pe(t,u),P=Xo(o);return r.jsx(dN,{scope:n,type:s,dir:P,scrollHideDelay:i,scrollArea:l,viewport:d,onViewportChange:f,content:p,onContentChange:m,scrollbarX:h,onScrollbarXChange:g,scrollbarXEnabled:k,onScrollbarXEnabledChange:_,scrollbarY:y,onScrollbarYChange:b,scrollbarYEnabled:C,onScrollbarYEnabledChange:I,onCornerWidthChange:v,onCornerHeightChange:S,children:r.jsx(ge.div,{dir:P,...a,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":j+"px",...e.style}})})});$m.displayName=ec;var Dm="ScrollAreaViewport",Fm=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:s,nonce:o,...i}=e,a=_t(Dm,n),l=c.useRef(null),u=Pe(t,l,a.onViewportChange);return r.jsxs(r.Fragment,{children:[r.jsx(fN,{nonce:o}),r.jsx(ge.div,{"data-radix-scroll-area-viewport":"",...i,ref:u,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:r.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});Fm.displayName=Dm;var fN=c.memo(({nonce:e})=>r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:e}),(e,t)=>e.nonce===t.nonce),Yt="ScrollAreaScrollbar",Um=c.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=_t(Yt,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:a}=o,l=e.orientation==="horizontal";return c.useEffect(()=>(l?i(!0):a(!0),()=>{l?i(!1):a(!1)}),[l,i,a]),o.type==="hover"?r.jsx(pN,{...s,ref:t,forceMount:n}):o.type==="scroll"?r.jsx(mN,{...s,ref:t,forceMount:n}):o.type==="auto"?r.jsx(Bm,{...s,ref:t,forceMount:n}):o.type==="always"?r.jsx(tc,{...s,ref:t,"data-state":"visible"}):null});Um.displayName=Yt;var pN=c.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=_t(Yt,e.__scopeScrollArea),[i,a]=c.useState(!1);return c.useEffect(()=>{const l=o.scrollArea;let u=0;if(l){const d=()=>{window.clearTimeout(u),a(!0)},f=()=>{u=window.setTimeout(()=>a(!1),o.scrollHideDelay)};return l.addEventListener("pointerenter",d),l.addEventListener("pointerleave",f),()=>{window.clearTimeout(u),l.removeEventListener("pointerenter",d),l.removeEventListener("pointerleave",f)}}},[o.scrollArea,o.scrollHideDelay]),r.jsx(wt,{present:n||i,children:r.jsx(Bm,{"data-state":i?"visible":"hidden",...s,ref:t})})}),mN=c.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=_t(Yt,e.__scopeScrollArea),i=e.orientation==="horizontal",a=ci(()=>u("SCROLL_END"),100),[l,u]=uN("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return c.useEffect(()=>{if(l==="idle"){const d=window.setTimeout(()=>u("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(d)}},[l,o.scrollHideDelay,u]),c.useEffect(()=>{const d=o.viewport,f=i?"scrollLeft":"scrollTop";if(d){let p=d[f];const m=()=>{const h=d[f];p!==h&&(u("SCROLL"),a()),p=h};return d.addEventListener("scroll",m),()=>d.removeEventListener("scroll",m)}},[o.viewport,i,u,a]),r.jsx(wt,{present:n||l!=="hidden",children:r.jsx(tc,{"data-state":l==="hidden"?"hidden":"visible",...s,ref:t,onPointerEnter:fe(e.onPointerEnter,()=>u("POINTER_ENTER")),onPointerLeave:fe(e.onPointerLeave,()=>u("POINTER_LEAVE"))})})}),Bm=c.forwardRef((e,t)=>{const n=_t(Yt,e.__scopeScrollArea),{forceMount:s,...o}=e,[i,a]=c.useState(!1),l=e.orientation==="horizontal",u=ci(()=>{if(n.viewport){const d=n.viewport.offsetWidth<n.viewport.scrollWidth,f=n.viewport.offsetHeight<n.viewport.scrollHeight;a(l?d:f)}},10);return Rs(n.viewport,u),Rs(n.content,u),r.jsx(wt,{present:s||i,children:r.jsx(tc,{"data-state":i?"visible":"hidden",...o,ref:t})})}),tc=c.forwardRef((e,t)=>{const{orientation:n="vertical",...s}=e,o=_t(Yt,e.__scopeScrollArea),i=c.useRef(null),a=c.useRef(0),[l,u]=c.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=Zm(l.viewport,l.content),f={...s,sizes:l,onSizesChange:u,hasThumb:d>0&&d<1,onThumbChange:m=>i.current=m,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:m=>a.current=m};function p(m,h){return yN(m,a.current,l,h)}return n==="horizontal"?r.jsx(hN,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const m=o.viewport.scrollLeft,h=Iu(m,l,o.dir);i.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?r.jsx(gN,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const m=o.viewport.scrollTop,h=Iu(m,l);i.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),hN=c.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,i=_t(Yt,e.__scopeScrollArea),[a,l]=c.useState(),u=c.useRef(null),d=Pe(t,u,i.onScrollbarXChange);return c.useEffect(()=>{u.current&&l(getComputedStyle(u.current))},[u]),r.jsx(qm,{"data-orientation":"horizontal",...o,ref:d,sizes:n,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":li(n)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.x),onDragScroll:f=>e.onDragScroll(f.x),onWheelScroll:(f,p)=>{if(i.viewport){const m=i.viewport.scrollLeft+f.deltaX;e.onWheelScroll(m),Gm(m,p)&&f.preventDefault()}},onResize:()=>{u.current&&i.viewport&&a&&s({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:u.current.clientWidth,paddingStart:To(a.paddingLeft),paddingEnd:To(a.paddingRight)}})}})}),gN=c.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,i=_t(Yt,e.__scopeScrollArea),[a,l]=c.useState(),u=c.useRef(null),d=Pe(t,u,i.onScrollbarYChange);return c.useEffect(()=>{u.current&&l(getComputedStyle(u.current))},[u]),r.jsx(qm,{"data-orientation":"vertical",...o,ref:d,sizes:n,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":li(n)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.y),onDragScroll:f=>e.onDragScroll(f.y),onWheelScroll:(f,p)=>{if(i.viewport){const m=i.viewport.scrollTop+f.deltaY;e.onWheelScroll(m),Gm(m,p)&&f.preventDefault()}},onResize:()=>{u.current&&i.viewport&&a&&s({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:u.current.clientHeight,paddingStart:To(a.paddingTop),paddingEnd:To(a.paddingBottom)}})}})}),[xN,Vm]=Lm(Yt),qm=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:s,hasThumb:o,onThumbChange:i,onThumbPointerUp:a,onThumbPointerDown:l,onThumbPositionChange:u,onDragScroll:d,onWheelScroll:f,onResize:p,...m}=e,h=_t(Yt,n),[g,y]=c.useState(null),b=Pe(t,y),w=c.useRef(null),v=c.useRef(""),j=h.viewport,S=s.content-s.viewport,k=et(f),_=et(u),C=ci(p,10);function I(A){if(w.current){const P=A.clientX-w.current.left,N=A.clientY-w.current.top;d({x:P,y:N})}}return c.useEffect(()=>{const A=P=>{const N=P.target;g?.contains(N)&&k(P,S)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[j,g,S,k]),c.useEffect(_,[s,_]),Rs(g,C),Rs(h.content,C),r.jsx(xN,{scope:n,scrollbar:g,hasThumb:o,onThumbChange:et(i),onThumbPointerUp:et(a),onThumbPositionChange:_,onThumbPointerDown:et(l),children:r.jsx(ge.div,{...m,ref:b,style:{position:"absolute",...m.style},onPointerDown:fe(e.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),w.current=g.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),I(A))}),onPointerMove:fe(e.onPointerMove,I),onPointerUp:fe(e.onPointerUp,A=>{const P=A.target;P.hasPointerCapture(A.pointerId)&&P.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=v.current,h.viewport&&(h.viewport.style.scrollBehavior=""),w.current=null})})})}),Co="ScrollAreaThumb",Hm=c.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=Vm(Co,e.__scopeScrollArea);return r.jsx(wt,{present:n||o.hasThumb,children:r.jsx(bN,{ref:t,...s})})}),bN=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:s,...o}=e,i=_t(Co,n),a=Vm(Co,n),{onThumbPositionChange:l}=a,u=Pe(t,a.onThumbChange),d=c.useRef(void 0),f=ci(()=>{d.current&&(d.current(),d.current=void 0)},100);return c.useEffect(()=>{const p=i.viewport;if(p){const m=()=>{if(f(),!d.current){const h=wN(p,l);d.current=h,l()}};return l(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[i.viewport,f,l]),r.jsx(ge.div,{"data-state":a.hasThumb?"visible":"hidden",...o,ref:u,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:fe(e.onPointerDownCapture,p=>{const h=p.target.getBoundingClientRect(),g=p.clientX-h.left,y=p.clientY-h.top;a.onThumbPointerDown({x:g,y})}),onPointerUp:fe(e.onPointerUp,a.onThumbPointerUp)})});Hm.displayName=Co;var nc="ScrollAreaCorner",Wm=c.forwardRef((e,t)=>{const n=_t(nc,e.__scopeScrollArea),s=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&s?r.jsx(vN,{...e,ref:t}):null});Wm.displayName=nc;var vN=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,...s}=e,o=_t(nc,n),[i,a]=c.useState(0),[l,u]=c.useState(0),d=!!(i&&l),{onCornerWidthChange:f,onCornerHeightChange:p}=o;return Rs(o.scrollbarX,()=>{const m=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(m),u(m)}),Rs(o.scrollbarY,()=>{const m=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(m),a(m)}),c.useEffect(()=>()=>{f(0),p(0)},[f,p]),d?r.jsx(ge.div,{...s,ref:t,style:{width:i,height:l,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function To(e){return e?parseInt(e,10):0}function Zm(e,t){const n=e/t;return isNaN(n)?0:n}function li(e){const t=Zm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=(e.scrollbar.size-n)*t;return Math.max(s,18)}function yN(e,t,n,s="ltr"){const o=li(n),i=o/2,a=t||i,l=o-a,u=n.scrollbar.paddingStart+a,d=n.scrollbar.size-n.scrollbar.paddingEnd-l,f=n.content-n.viewport,p=s==="ltr"?[0,f]:[f*-1,0];return Km([u,d],p)(e)}function Iu(e,t,n="ltr"){const s=li(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,a=t.content-t.viewport,l=i-s,u=n==="ltr"?[0,a]:[a*-1,0],d=La(e,u);return Km([0,a],[0,l])(d)}function Km(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const s=(t[1]-t[0])/(e[1]-e[0]);return t[0]+s*(n-e[0])}}function Gm(e,t){return e>0&&e<t}var wN=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},s=0;return(function o(){const i={left:e.scrollLeft,top:e.scrollTop},a=n.left!==i.left,l=n.top!==i.top;(a||l)&&t(),n=i,s=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(s)};function ci(e,t){const n=et(e),s=c.useRef(0);return c.useEffect(()=>()=>window.clearTimeout(s.current),[]),c.useCallback(()=>{window.clearTimeout(s.current),s.current=window.setTimeout(n,t)},[n,t])}function Rs(e,t){const n=et(t);Je(()=>{let s=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(s),s=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(s),o.unobserve(e)}}},[e,n])}var jN=$m,kN=Fm,SN=Wm,_N=[" ","Enter","ArrowUp","ArrowDown"],NN=[" ","Enter"],Wn="Select",[ui,di,CN]=Tp(Wn),[Qn]=dn(Wn,[CN,ai]),fi=ai(),[TN,En]=Qn(Wn),[EN,RN]=Qn(Wn),PN="SelectProvider";function Jm(e){const{__scopeSelect:t,children:n,open:s,defaultOpen:o,onOpenChange:i,value:a,defaultValue:l,onValueChange:u,dir:d,name:f,autoComplete:p,disabled:m,required:h,form:g,internal_do_not_use_render:y}=e,b=fi(t),[w,v]=c.useState(null),[j,S]=c.useState(null),[k,_]=c.useState(!1),C=Xo(d),[I,A]=qn({prop:s,defaultProp:o??!1,onChange:i,caller:Wn}),[P,N]=qn({prop:a,defaultProp:l,onChange:u,caller:Wn}),M=c.useRef(null),F=c.useRef(P);c.useEffect(()=>{const we=g?w?.ownerDocument.getElementById(g):w?.form;if(we instanceof HTMLFormElement){const he=()=>N(F.current);return we.addEventListener("reset",he),()=>we.removeEventListener("reset",he)}},[g,w,N]);const B=w?!!g||!!w.closest("form"):!0,[J,K]=c.useState(new Set),W=qt(),V=Array.from(J).map(we=>we.props.value).join(";"),z=c.useCallback(we=>{K(he=>new Set(he).add(we))},[]),X=c.useCallback(we=>{K(he=>{const oe=new Set(he);return oe.delete(we),oe})},[]),Y={required:h,trigger:w,onTriggerChange:v,valueNode:j,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:_,contentId:W,value:P,onValueChange:N,open:I,onOpenChange:A,dir:C,triggerPointerDownPosRef:M,disabled:m,name:f,autoComplete:p,form:g,nativeOptions:J,nativeSelectKey:V,isFormControl:B};return r.jsx(Nm,{...b,children:r.jsx(TN,{scope:t,...Y,children:r.jsx(ui.Provider,{scope:t,children:r.jsx(EN,{scope:t,onNativeOptionAdd:z,onNativeOptionRemove:X,children:KN(y)?y(Y):n})})})})}Jm.displayName=PN;var Ym=e=>{const{__scopeSelect:t,children:n,...s}=e;return r.jsx(Jm,{__scopeSelect:t,...s,internal_do_not_use_render:({isFormControl:o})=>r.jsxs(r.Fragment,{children:[n,o?r.jsx(kh,{__scopeSelect:t}):null]})})};Ym.displayName=Wn;var Xm="SelectTrigger",Qm=c.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...o}=e,i=fi(n),a=En(Xm,n),l=a.disabled||s,u=Pe(t,a.onTriggerChange),d=di(n),f=c.useRef("touch"),[p,m,h]=Sh(y=>{const b=d().filter(j=>!j.disabled),w=b.find(j=>j.value===a.value),v=_h(b,y,w);v!==void 0&&a.onValueChange(v.value)}),g=y=>{l||(a.onOpenChange(!0),h()),y&&(a.triggerPointerDownPosRef.current={x:Math.round(y.pageX),y:Math.round(y.pageY)})};return r.jsx(Cm,{asChild:!0,...i,children:r.jsx(ge.button,{type:"button",role:"combobox","aria-controls":a.open?a.contentId:void 0,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":pi(a.value)?"":void 0,...o,ref:u,onClick:fe(o.onClick,y=>{y.currentTarget.focus(),f.current!=="mouse"&&g(y)}),onPointerDown:fe(o.onPointerDown,y=>{f.current=y.pointerType;const b=y.target;b.hasPointerCapture(y.pointerId)&&b.releasePointerCapture(y.pointerId),y.button===0&&y.ctrlKey===!1&&y.pointerType==="mouse"&&(g(y),y.preventDefault())}),onKeyDown:fe(o.onKeyDown,y=>{const b=p.current!=="";!(y.ctrlKey||y.altKey||y.metaKey)&&y.key.length===1&&m(y.key),!(b&&y.key===" ")&&_N.includes(y.key)&&(g(),y.preventDefault())})})})});Qm.displayName=Xm;var eh="SelectValue",th=c.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,children:i,placeholder:a="",...l}=e,u=En(eh,n),{onValueNodeHasChildrenChange:d}=u,f=i!==void 0,p=Pe(t,u.onValueNodeChange);Je(()=>{d(f)},[d,f]);const m=pi(u.value);return r.jsx(ge.span,{...l,asChild:m?!1:l.asChild,ref:p,style:{pointerEvents:"none"},children:r.jsx(c.Fragment,{children:m?a:i},m?"placeholder":"value")})});th.displayName=eh;var MN="SelectIcon",nh=c.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...o}=e;return r.jsx(ge.span,{"aria-hidden":!0,...o,ref:t,children:s||"▼"})});nh.displayName=MN;var sh="SelectPortal",[IN,AN]=Qn(sh,{forceMount:void 0}),rh=e=>{const{__scopeSelect:t,forceMount:n,...s}=e;return r.jsx(IN,{scope:e.__scopeSelect,forceMount:n,children:r.jsx(ei,{asChild:!0,...s})})};rh.displayName=sh;var _n="SelectContent",oh=c.forwardRef((e,t)=>{const n=AN(_n,e.__scopeSelect),{forceMount:s=n.forceMount,...o}=e,i=En(_n,e.__scopeSelect),[a,l]=c.useState();return Je(()=>{l(new DocumentFragment)},[]),r.jsx(wt,{present:s||i.open,children:({present:u})=>u?r.jsx(lh,{...o,ref:t}):r.jsx(ih,{...o,fragment:a})})});oh.displayName=_n;var ih=c.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,fragment:o}=e;return o?Os.createPortal(r.jsx(ah,{scope:n,children:r.jsx(ui.Slot,{scope:n,children:r.jsx("div",{ref:t,children:s})})}),o):null});ih.displayName="SelectContentFragment";var Rt=10,[ah,Rn]=Qn(_n),ON="SelectContentImpl",zN=Cs("SelectContent.RemoveScroll"),lh=c.forwardRef((e,t)=>{const{__scopeSelect:n}=e,{position:s="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:a,side:l,sideOffset:u,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:g,hideWhenDetached:y,avoidCollisions:b,...w}=e,v=En(_n,n),[j,S]=c.useState(null),[k,_]=c.useState(null),C=Pe(t,S),[I,A]=c.useState(null),[P,N]=c.useState(null),M=di(n),[F,B]=c.useState(!1),J=c.useRef(!1);c.useEffect(()=>{if(j)return qp(j)},[j]),Op();const K=c.useCallback(te=>{const[je,...ke]=M().map(xe=>xe.ref.current),[ue]=ke.slice(-1),le=document.activeElement;for(const xe of te)if(xe===le||(xe?.scrollIntoView({block:"nearest"}),xe===je&&k&&(k.scrollTop=0),xe===ue&&k&&(k.scrollTop=k.scrollHeight),xe?.focus(),document.activeElement!==le))return},[M,k]),W=c.useCallback(()=>K([I,j]),[K,I,j]);c.useEffect(()=>{F&&W()},[F,W]);const{onOpenChange:V,triggerPointerDownPosRef:z}=v;c.useEffect(()=>{if(j){let te={x:0,y:0};const je=ue=>{te={x:Math.abs(Math.round(ue.pageX)-(z.current?.x??0)),y:Math.abs(Math.round(ue.pageY)-(z.current?.y??0))}},ke=ue=>{te.x<=10&&te.y<=10?ue.preventDefault():ue.composedPath().includes(j)||V(!1),document.removeEventListener("pointermove",je),z.current=null};return z.current!==null&&(document.addEventListener("pointermove",je),document.addEventListener("pointerup",ke,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",je),document.removeEventListener("pointerup",ke,{capture:!0})}}},[j,V,z]),c.useEffect(()=>{const te=()=>V(!1);return window.addEventListener("blur",te),window.addEventListener("resize",te),()=>{window.removeEventListener("blur",te),window.removeEventListener("resize",te)}},[V]);const[X,Y]=Sh(te=>{const je=M().filter(le=>!le.disabled),ke=je.find(le=>le.ref.current===document.activeElement),ue=_h(je,te,ke);ue&&setTimeout(()=>ue.ref.current?.focus())}),we=c.useCallback((te,je,ke)=>{const ue=!J.current&&!ke;(v.value!==void 0&&v.value===je||ue)&&(A(te),ue&&(J.current=!0))},[v.value]),he=c.useCallback(()=>j?.focus(),[j]),oe=c.useCallback((te,je,ke)=>{const ue=!J.current&&!ke;(v.value!==void 0&&v.value===je||ue)&&N(te)},[v.value]),D=s==="popper"?$a:ch,Ne=D===$a?{side:l,sideOffset:u,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:g,hideWhenDetached:y,avoidCollisions:b}:{};return r.jsx(ah,{scope:n,content:j,viewport:k,onViewportChange:_,itemRefCallback:we,selectedItem:I,onItemLeave:he,itemTextRefCallback:oe,focusSelectedItem:W,selectedItemText:P,position:s,isPositioned:F,searchRef:X,children:r.jsx(Bl,{as:zN,allowPinchZoom:!0,children:r.jsx(Ul,{asChild:!0,trapped:v.open,onMountAutoFocus:te=>{te.preventDefault()},onUnmountAutoFocus:fe(o,te=>{v.trigger?.focus({preventScroll:!0}),te.preventDefault()}),children:r.jsx(Qo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:te=>te.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:r.jsx(D,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:te=>te.preventDefault(),...w,...Ne,onPlaced:()=>B(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:fe(w.onKeyDown,te=>{const je=te.ctrlKey||te.altKey||te.metaKey;if(te.key==="Tab"&&te.preventDefault(),!je&&te.key.length===1&&Y(te.key),["ArrowUp","ArrowDown","Home","End"].includes(te.key)){let ue=M().filter(le=>!le.disabled).map(le=>le.ref.current);if(["ArrowUp","End"].includes(te.key)&&(ue=ue.slice().reverse()),["ArrowUp","ArrowDown"].includes(te.key)){const le=te.target,xe=ue.indexOf(le);ue=ue.slice(xe+1)}setTimeout(()=>K(ue)),te.preventDefault()}})})})})})})});lh.displayName=ON;var LN="SelectItemAlignedPosition",ch=c.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...o}=e,i=En(_n,n),a=Rn(_n,n),[l,u]=c.useState(null),[d,f]=c.useState(null),p=Pe(t,f),m=di(n),h=c.useRef(!1),g=c.useRef(!0),{viewport:y,selectedItem:b,selectedItemText:w,focusSelectedItem:v}=a,j=c.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&d&&y&&b&&w){const C=i.trigger.getBoundingClientRect(),I=d.getBoundingClientRect(),A=i.valueNode.getBoundingClientRect(),P=w.getBoundingClientRect();if(i.dir!=="rtl"){const le=P.left-I.left,xe=A.left-le,Se=C.left-xe,ve=C.width+Se,Ze=Math.max(ve,I.width),Be=window.innerWidth-Rt,Ke=La(xe,[Rt,Math.max(Rt,Be-Ze)]);l.style.minWidth=ve+"px",l.style.left=Ke+"px"}else{const le=I.right-P.right,xe=window.innerWidth-A.right-le,Se=window.innerWidth-C.right-xe,ve=C.width+Se,Ze=Math.max(ve,I.width),Be=window.innerWidth-Rt,Ke=La(xe,[Rt,Math.max(Rt,Be-Ze)]);l.style.minWidth=ve+"px",l.style.right=Ke+"px"}const N=m(),M=window.innerHeight-Rt*2,F=y.scrollHeight,B=window.getComputedStyle(d),J=parseInt(B.borderTopWidth,10),K=parseInt(B.paddingTop,10),W=parseInt(B.borderBottomWidth,10),V=parseInt(B.paddingBottom,10),z=J+K+F+V+W,X=Math.min(b.offsetHeight*5,z),Y=window.getComputedStyle(y),we=parseInt(Y.paddingTop,10),he=parseInt(Y.paddingBottom,10),oe=C.top+C.height/2-Rt,D=M-oe,Ne=b.offsetHeight/2,te=b.offsetTop+Ne,je=J+K+te,ke=z-je;if(je<=oe){const le=N.length>0&&b===N[N.length-1].ref.current;l.style.bottom="0px";const xe=d.clientHeight-y.offsetTop-y.offsetHeight,Se=Math.max(D,Ne+(le?he:0)+xe+W),ve=je+Se;l.style.height=ve+"px"}else{const le=N.length>0&&b===N[0].ref.current;l.style.top="0px";const Se=Math.max(oe,J+y.offsetTop+(le?we:0)+Ne)+ke;l.style.height=Se+"px",y.scrollTop=je-oe+y.offsetTop}l.style.margin=`${Rt}px 0`,l.style.minHeight=X+"px",l.style.maxHeight=M+"px",s?.(),requestAnimationFrame(()=>h.current=!0)}},[m,i.trigger,i.valueNode,l,d,y,b,w,i.dir,s]);Je(()=>j(),[j]);const[S,k]=c.useState();Je(()=>{d&&k(window.getComputedStyle(d).zIndex)},[d]);const _=c.useCallback(C=>{C&&g.current===!0&&(j(),v?.(),g.current=!1)},[j,v]);return r.jsx(DN,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:h,onScrollButtonChange:_,children:r.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:r.jsx(ge.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});ch.displayName=LN;var $N="SelectPopperPosition",$a=c.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:o=Rt,...i}=e,a=fi(n);return r.jsx(Tm,{...a,...i,ref:t,align:s,collisionPadding:o,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});$a.displayName=$N;var[DN,sc]=Qn(_n,{}),Da="SelectViewport",uh=c.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...o}=e,i=Rn(Da,n),a=sc(Da,n),l=Pe(t,i.onViewportChange),u=c.useRef(0);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),r.jsx(ui.Slot,{scope:n,children:r.jsx(ge.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:fe(o.onScroll,d=>{const f=d.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=a;if(m?.current&&p){const h=Math.abs(u.current-f.scrollTop);if(h>0){const g=window.innerHeight-Rt*2,y=parseFloat(p.style.minHeight),b=parseFloat(p.style.height),w=Math.max(y,b);if(w<g){const v=w+h,j=Math.min(g,v),S=v-j;p.style.height=j+"px",p.style.bottom==="0px"&&(f.scrollTop=S>0?S:0,p.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});uh.displayName=Da;var dh="SelectGroup",[FN,UN]=Qn(dh),BN=c.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=qt();return r.jsx(FN,{scope:n,id:o,children:r.jsx(ge.div,{role:"group","aria-labelledby":o,...s,ref:t})})});BN.displayName=dh;var fh="SelectLabel",VN=c.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=UN(fh,n);return r.jsx(ge.div,{id:o.id,...s,ref:t})});VN.displayName=fh;var Eo="SelectItem",[qN,ph]=Qn(Eo),mh=c.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:o=!1,textValue:i,...a}=e,l=En(Eo,n),u=Rn(Eo,n),d=l.value===s,[f,p]=c.useState(i??""),[m,h]=c.useState(!1),g=et(j=>u.itemRefCallback?.(j,s,o)),y=Pe(t,g),b=qt(),w=c.useRef("touch"),v=()=>{o||(l.onValueChange(s),l.onOpenChange(!1))};return r.jsx(qN,{scope:n,value:s,disabled:o,textId:b,isSelected:d,onItemTextChange:c.useCallback(j=>{p(S=>S||(j?.textContent??"").trim())},[]),children:r.jsx(ui.ItemSlot,{scope:n,value:s,disabled:o,textValue:f,children:r.jsx(ge.div,{role:"option","aria-labelledby":b,"data-highlighted":m?"":void 0,"aria-selected":d&&m,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:y,onFocus:fe(a.onFocus,()=>h(!0)),onBlur:fe(a.onBlur,()=>h(!1)),onClick:fe(a.onClick,()=>{w.current!=="mouse"&&v()}),onPointerUp:fe(a.onPointerUp,()=>{w.current==="mouse"&&v()}),onPointerDown:fe(a.onPointerDown,j=>{w.current=j.pointerType}),onPointerMove:fe(a.onPointerMove,j=>{w.current=j.pointerType,o?u.onItemLeave?.():w.current==="mouse"&&j.currentTarget.focus({preventScroll:!0})}),onPointerLeave:fe(a.onPointerLeave,j=>{j.currentTarget===document.activeElement&&u.onItemLeave?.()}),onKeyDown:fe(a.onKeyDown,j=>{o||j.target!==j.currentTarget||u.searchRef?.current!==""&&j.key===" "||(NN.includes(j.key)&&v(),j.key===" "&&j.preventDefault())})})})})});mh.displayName=Eo;var Js="SelectItemText",hh=c.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,...i}=e,a=En(Js,n),l=Rn(Js,n),u=ph(Js,n),d=RN(Js,n),[f,p]=c.useState(null),m=et(v=>l.itemTextRefCallback?.(v,u.value,u.disabled)),h=Pe(t,p,u.onItemTextChange,m),g=f?.textContent,y=c.useMemo(()=>r.jsx("option",{value:u.value,disabled:u.disabled,children:g},u.value),[u.disabled,u.value,g]),{onNativeOptionAdd:b,onNativeOptionRemove:w}=d;return Je(()=>(b(y),()=>w(y)),[b,w,y]),r.jsxs(r.Fragment,{children:[r.jsx(ge.span,{id:u.textId,...i,ref:h}),u.isSelected&&a.valueNode&&!a.valueNodeHasChildren&&!pi(a.value)?Os.createPortal(i.children,a.valueNode):null]})});hh.displayName=Js;var gh="SelectItemIndicator",xh=c.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return ph(gh,n).isSelected?r.jsx(ge.span,{"aria-hidden":!0,...s,ref:t}):null});xh.displayName=gh;var Fa="SelectScrollUpButton",bh=c.forwardRef((e,t)=>{const n=Rn(Fa,e.__scopeSelect),s=sc(Fa,e.__scopeSelect),[o,i]=c.useState(!1),a=Pe(t,s.onScrollButtonChange);return Je(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollTop>0;i(d)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?r.jsx(yh,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});bh.displayName=Fa;var Ua="SelectScrollDownButton",vh=c.forwardRef((e,t)=>{const n=Rn(Ua,e.__scopeSelect),s=sc(Ua,e.__scopeSelect),[o,i]=c.useState(!1),a=Pe(t,s.onScrollButtonChange);return Je(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollHeight-u.clientHeight,f=Math.ceil(u.scrollTop)<d;i(f)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?r.jsx(yh,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});vh.displayName=Ua;var yh=c.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...o}=e,i=Rn("SelectScrollButton",n),a=c.useRef(null),l=di(n),u=c.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return c.useEffect(()=>()=>u(),[u]),Je(()=>{l().find(f=>f.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),r.jsx(ge.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:fe(o.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(s,50))}),onPointerMove:fe(o.onPointerMove,()=>{i.onItemLeave?.(),a.current===null&&(a.current=window.setInterval(s,50))}),onPointerLeave:fe(o.onPointerLeave,()=>{u()})})}),HN="SelectSeparator",WN=c.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(ge.div,{"aria-hidden":!0,...s,ref:t})});WN.displayName=HN;var wh="SelectArrow",ZN=c.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=fi(n);return Rn(wh,n).position==="popper"?r.jsx(Em,{...o,...s,ref:t}):null});ZN.displayName=wh;var jh="SelectBubbleInput",kh=c.forwardRef(({__scopeSelect:e,...t},n)=>{const s=En(jh,e),{value:o,onValueChange:i,required:a,disabled:l,name:u,autoComplete:d,form:f}=s,{nativeOptions:p,nativeSelectKey:m}=s,h=c.useRef(null),g=Pe(n,h),y=o??"",b=CS(y),w=Array.from(p).some(v=>(v.props.value??"")==="");return c.useEffect(()=>{const v=h.current;if(!v)return;const j=window.HTMLSelectElement.prototype,k=Object.getOwnPropertyDescriptor(j,"value").set;if(b!==y&&k){const _=new Event("change",{bubbles:!0});k.call(v,y),v.dispatchEvent(_)}},[b,y]),r.jsxs(ge.select,{"aria-hidden":!0,required:a,tabIndex:-1,name:u,autoComplete:d,disabled:l,form:f,onChange:v=>i(v.target.value),...t,style:{...Np,...t.style},ref:g,defaultValue:y,children:[pi(o)&&!w?r.jsx("option",{value:""}):null,Array.from(p)]},m)});kh.displayName=jh;function KN(e){return typeof e=="function"}function pi(e){return e===""||e===void 0}function Sh(e){const t=et(e),n=c.useRef(""),s=c.useRef(0),o=c.useCallback(a=>{const l=n.current+a;t(l),(function u(d){n.current=d,window.clearTimeout(s.current),d!==""&&(s.current=window.setTimeout(()=>u(""),1e3))})(l)},[t]),i=c.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return c.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,o,i]}function _h(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let a=GN(e,Math.max(i,0));o.length===1&&(a=a.filter(d=>d!==n));const u=a.find(d=>d.textValue.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}function GN(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var mi="Tabs",[JN]=dn(mi,[Mm]),Nh=Mm(),[YN,rc]=JN(mi),Ch=c.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:i,orientation:a="horizontal",dir:l,activationMode:u="automatic",...d}=e,f=Xo(l),[p,m]=qn({prop:s,onChange:o,defaultProp:i??"",caller:mi});return r.jsx(YN,{scope:n,baseId:qt(),value:p,onValueChange:m,orientation:a,dir:f,activationMode:u,children:r.jsx(ge.div,{dir:f,"data-orientation":a,...d,ref:t})})});Ch.displayName=mi;var Th="TabsList",Eh=c.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,i=rc(Th,n),a=Nh(n);return r.jsx(lN,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:s,children:r.jsx(ge.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});Eh.displayName=Th;var Rh="TabsTrigger",Ph=c.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...i}=e,a=rc(Rh,n),l=Nh(n),u=Ah(a.baseId,s),d=Oh(a.baseId,s),f=s===a.value;return r.jsx(cN,{asChild:!0,...l,focusable:!o,active:f,children:r.jsx(ge.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":d,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...i,ref:t,onMouseDown:fe(e.onMouseDown,p=>{!o&&p.button===0&&p.ctrlKey===!1?a.onValueChange(s):p.preventDefault()}),onKeyDown:fe(e.onKeyDown,p=>{o||p.target!==p.currentTarget||[" ","Enter"].includes(p.key)&&a.onValueChange(s)}),onFocus:fe(e.onFocus,()=>{const p=a.activationMode!=="manual";!f&&!o&&p&&a.onValueChange(s)})})})});Ph.displayName=Rh;var Mh="TabsContent",Ih=c.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:i,...a}=e,l=rc(Mh,n),u=Ah(l.baseId,s),d=Oh(l.baseId,s),f=s===l.value,p=c.useRef(f);return c.useEffect(()=>{const m=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(m)},[]),r.jsx(wt,{present:o||f,children:({present:m})=>r.jsx(ge.div,{"data-state":f?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":u,hidden:!m,id:d,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:m&&i})})});Ih.displayName=Mh;function Ah(e,t){return`${e}-trigger-${t}`}function Oh(e,t){return`${e}-content-${t}`}var XN=Ch,QN=Eh,eC=Ph,tC=Ih,[hi]=dn("Tooltip",[ai]),gi=ai(),zh="TooltipProvider",nC=700,Ba="tooltip.open",[sC,oc]=hi(zh),Lh=e=>{const{__scopeTooltip:t,delayDuration:n=nC,skipDelayDuration:s=300,disableHoverableContent:o=!1,children:i}=e,a=c.useRef(!0),l=c.useRef(!1),u=c.useRef(0);return c.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),r.jsx(sC,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:c.useCallback(()=>{s<=0||(window.clearTimeout(u.current),a.current=!1)},[s]),onClose:c.useCallback(()=>{s<=0||(window.clearTimeout(u.current),u.current=window.setTimeout(()=>a.current=!0,s))},[s]),isPointerInTransitRef:l,onPointerInTransitChange:c.useCallback(d=>{l.current=d},[]),disableHoverableContent:o,children:i})};Lh.displayName=zh;var ir="Tooltip",[rC,vr]=hi(ir),$h=e=>{const{__scopeTooltip:t,children:n,open:s,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:l}=e,u=oc(ir,e.__scopeTooltip),d=gi(t),[f,p]=c.useState(null),m=qt(),h=c.useRef(0),g=a??u.disableHoverableContent,y=l??u.delayDuration,b=c.useRef(!1),[w,v]=qn({prop:s,defaultProp:o??!1,onChange:C=>{C?(u.onOpen(),document.dispatchEvent(new CustomEvent(Ba))):u.onClose(),i?.(C)},caller:ir}),j=c.useMemo(()=>w?b.current?"delayed-open":"instant-open":"closed",[w]),S=c.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b.current=!1,v(!0)},[v]),k=c.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v(!1)},[v]),_=c.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{b.current=!0,v(!0),h.current=0},y)},[y,v]);return c.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),r.jsx(Nm,{...d,children:r.jsx(rC,{scope:t,contentId:m,open:w,stateAttribute:j,trigger:f,onTriggerChange:p,onTriggerEnter:c.useCallback(()=>{u.isOpenDelayedRef.current?_():S()},[u.isOpenDelayedRef,_,S]),onTriggerLeave:c.useCallback(()=>{g?k():(window.clearTimeout(h.current),h.current=0)},[k,g]),onOpen:S,onClose:k,disableHoverableContent:g,children:n})})};$h.displayName=ir;var Va="TooltipTrigger",Dh=c.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,o=vr(Va,n),i=oc(Va,n),a=gi(n),l=c.useRef(null),u=Pe(t,l,o.onTriggerChange),d=c.useRef(!1),f=c.useRef(!1),p=c.useCallback(()=>d.current=!1,[]);return c.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),r.jsx(Cm,{asChild:!0,...a,children:r.jsx(ge.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...s,ref:u,onPointerMove:fe(e.onPointerMove,m=>{m.pointerType!=="touch"&&!f.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:fe(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:fe(e.onPointerDown,()=>{o.open&&o.onClose(),d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:fe(e.onFocus,()=>{d.current||o.onOpen()}),onBlur:fe(e.onBlur,o.onClose),onClick:fe(e.onClick,o.onClose)})})});Dh.displayName=Va;var ic="TooltipPortal",[oC,iC]=hi(ic,{forceMount:void 0}),Fh=e=>{const{__scopeTooltip:t,forceMount:n,children:s,container:o}=e,i=vr(ic,t);return r.jsx(oC,{scope:t,forceMount:n,children:r.jsx(wt,{present:n||i.open,children:r.jsx(ei,{asChild:!0,container:o,children:s})})})};Fh.displayName=ic;var Ps="TooltipContent",Uh=c.forwardRef((e,t)=>{const n=iC(Ps,e.__scopeTooltip),{forceMount:s=n.forceMount,side:o="top",...i}=e,a=vr(Ps,e.__scopeTooltip);return r.jsx(wt,{present:s||a.open,children:a.disableHoverableContent?r.jsx(Bh,{side:o,...i,ref:t}):r.jsx(aC,{side:o,...i,ref:t})})}),aC=c.forwardRef((e,t)=>{const n=vr(Ps,e.__scopeTooltip),s=oc(Ps,e.__scopeTooltip),o=c.useRef(null),i=Pe(t,o),[a,l]=c.useState(null),{trigger:u,onClose:d}=n,f=o.current,{onPointerInTransitChange:p}=s,m=c.useCallback(()=>{l(null),p(!1)},[p]),h=c.useCallback((g,y)=>{const b=g.currentTarget,w={x:g.clientX,y:g.clientY},v=dC(w,b.getBoundingClientRect()),j=fC(w,v),S=pC(y.getBoundingClientRect()),k=hC([...j,...S]);l(k),p(!0)},[p]);return c.useEffect(()=>()=>m(),[m]),c.useEffect(()=>{if(u&&f){const g=b=>h(b,f),y=b=>h(b,u);return u.addEventListener("pointerleave",g),f.addEventListener("pointerleave",y),()=>{u.removeEventListener("pointerleave",g),f.removeEventListener("pointerleave",y)}}},[u,f,h,m]),c.useEffect(()=>{if(a){const g=y=>{const b=y.target,w={x:y.clientX,y:y.clientY},v=u?.contains(b)||f?.contains(b),j=!mC(w,a);v?m():j&&(m(),d())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[u,f,a,d,m]),r.jsx(Bh,{...e,ref:i})}),[lC,cC]=hi(ir,{isInside:!1}),uC=H5("TooltipContent"),Bh=c.forwardRef((e,t)=>{const{__scopeTooltip:n,children:s,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...l}=e,u=vr(Ps,n),d=gi(n),{onClose:f}=u;return c.useEffect(()=>(document.addEventListener(Ba,f),()=>document.removeEventListener(Ba,f)),[f]),c.useEffect(()=>{if(u.trigger){const p=m=>{m.target instanceof Node&&m.target.contains(u.trigger)&&f()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[u.trigger,f]),r.jsx(Qo,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:p=>p.preventDefault(),onDismiss:f,children:r.jsxs(Tm,{"data-state":u.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[r.jsx(uC,{children:s}),r.jsx(lC,{scope:n,isInside:!0,children:r.jsx(sk,{id:u.contentId,role:"tooltip",children:o||s})})]})})});Uh.displayName=Ps;var Vh="TooltipArrow",qh=c.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,o=gi(n);return cC(Vh,n).isInside?null:r.jsx(Em,{...o,...s,ref:t})});qh.displayName=Vh;function dC(e,t){const n=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,s,o,i)){case i:return"left";case o:return"right";case n:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function fC(e,t,n=5){const s=[];switch(t){case"top":s.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":s.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":s.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":s.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return s}function pC(e){const{top:t,right:n,bottom:s,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:s},{x:o,y:s}]}function mC(e,t){const{x:n,y:s}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const l=t[i],u=t[a],d=l.x,f=l.y,p=u.x,m=u.y;f>s!=m>s&&n<(p-d)*(s-f)/(m-f)+d&&(o=!o)}return o}function hC(e){const t=e.slice();return t.sort((n,s)=>n.x<s.x?-1:n.x>s.x?1:n.y<s.y?-1:n.y>s.y?1:0),gC(t)}function gC(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const o=e[s];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let s=e.length-1;s>=0;s--){const o=e[s];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var xC=Lh,bC=$h,vC=Dh,yC=Fh,wC=Uh,jC=qh;function Zt({...e}){return r.jsx(Wp,{"data-slot":"dialog",...e})}function yr({...e}){return r.jsx(Kp,{"data-slot":"dialog-trigger",...e})}function kC({...e}){return r.jsx(Jp,{"data-slot":"dialog-portal",...e})}function SC({className:e,...t}){return r.jsx(Yp,{"data-slot":"dialog-overlay",className:$("fixed inset-0 z-40 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t})}function Kt({className:e,children:t,...n}){return r.jsxs(kC,{children:[r.jsx(SC,{}),r.jsxs(Xp,{"data-slot":"dialog-content",className:$("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",e),...n,children:[t,r.jsxs(om,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[r.jsx(gr,{className:"size-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Xt({className:e,...t}){return r.jsx("div",{"data-slot":"dialog-header",className:$("flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function Qt({className:e,...t}){return r.jsx(tm,{"data-slot":"dialog-title",className:$("text-lg font-semibold leading-none tracking-tight",e),...t})}function wr({className:e,...t}){return r.jsx(sm,{"data-slot":"dialog-description",className:$("text-sm text-muted-foreground",e),...t})}function Hh({open:e,onOpenChange:t,title:n,description:s,confirmLabel:o="Confirm",variant:i="default",onConfirm:a}){return r.jsx(Zt,{open:e,onOpenChange:t,children:r.jsxs(Kt,{children:[r.jsx(Xt,{children:r.jsx(Qt,{children:n})}),r.jsx("p",{className:"text-sm text-muted-foreground",children:s}),r.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[r.jsx(ee,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),r.jsx(ee,{variant:i,size:"sm",onClick:()=>{a(),t(!1)},children:o})]})]})})}const _C="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eClaude%20Code%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M20.998%2010.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6%2010.949h1.488V8.102H6v2.847zm10.51%200H18V8.102h-1.49v2.847z'%20fill='%23D97757'%20fill-rule='evenodd'%3e%3c/path%3e%3c/svg%3e",NC="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20d='M19.503%200H4.496A4.496%204.496%200%20000%204.496v15.007A4.496%204.496%200%20004.496%2024h15.007A4.496%204.496%200%200024%2019.503V4.496A4.496%204.496%200%200019.503%200z'%20fill='%23fff'%3e%3c/path%3e%3cpath%20d='M9.064%203.344a4.578%204.578%200%20012.285-.312c1%20.115%201.891.54%202.673%201.275.01.01.024.017.037.021a.09.09%200%2000.043%200%204.55%204.55%200%20013.046.275l.047.022.116.057a4.581%204.581%200%20012.188%202.399c.209.51.313%201.041.315%201.595a4.24%204.24%200%2001-.134%201.223.123.123%200%2000.03.115c.594.607.988%201.33%201.183%202.17.289%201.425-.007%202.71-.887%203.854l-.136.166a4.548%204.548%200%2001-2.201%201.388.123.123%200%2000-.081.076c-.191.551-.383%201.023-.74%201.494-.9%201.187-2.222%201.846-3.711%201.838-1.187-.006-2.239-.44-3.157-1.302a.107.107%200%2000-.105-.024c-.388.125-.78.143-1.204.138a4.441%204.441%200%2001-1.945-.466%204.544%204.544%200%2001-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81%205.81%200%2001-.37-.961%204.582%204.582%200%2001-.014-2.298.124.124%200%2000.006-.056.085.085%200%2000-.027-.048%204.467%204.467%200%2001-1.034-1.651%203.896%203.896%200%2001-.251-1.192%205.189%205.189%200%2001.141-1.6c.337-1.112.982-1.985%201.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098%200%2000.065-.066%204.51%204.51%200%2001.829-1.615%204.535%204.535%200%20011.837-1.388zm3.482%2010.565a.637.637%200%20000%201.272h3.636a.637.637%200%20100-1.272h-3.636zM8.462%209.23a.637.637%200%2000-1.106.631l1.272%202.224-1.266%202.136a.636.636%200%20101.095.649l1.454-2.455a.636.636%200%2000.005-.64L8.462%209.23z'%20fill='url(%23lobe-icons-codex-_R_0_)'%3e%3c/path%3e%3cdefs%3e%3clinearGradient%20gradientUnits='userSpaceOnUse'%20id='lobe-icons-codex-_R_0_'%20x1='12'%20x2='12'%20y1='3'%20y2='21'%3e%3cstop%20stop-color='%23B1A7FF'%3e%3c/stop%3e%3cstop%20offset='.5'%20stop-color='%237A9DFF'%3e%3c/stop%3e%3cstop%20offset='1'%20stop-color='%233941FF'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",CC="data:image/svg+xml,%3csvg%20fill='%237dd3fc'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eOpenCode%3c/title%3e%3cpath%20d='M16%206H8v12h8V6zm4%2016H4V2h16v20z'%3e%3c/path%3e%3c/svg%3e",TC="data:image/svg+xml,%3csvg%20fill='%23ff6900'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eMiMo%20Code%3c/title%3e%3cpath%20d='M.958%2015.936a.459.459%200%2001.459.44v2.729a.46.46%200%2001-.918%200v-2.729a.459.459%200%2001.459-.44zm4.814-2.035a.46.46%200%2001.553.45v4.754a.458.458%200%2011-.918%200V15.48L3.74%2017.202a.462.462%200%2001-.655.016.462.462%200%2001-.065-.082L.628%2014.67a.459.459%200%2001.658-.637l2.124%202.187%202.127-2.188a.46.46%200%2001.235-.13zm2.068.004a.46.46%200%2001.458.445v4.755a.46.46%200%2001-.458.458.459.459%200%2001-.458-.458V14.35a.459.459%200%2001.458-.445zm1.973%202.014a.46.46%200%2001.46.457v2.729a.46.46%200%2001-.784.324.46.46%200%2001-.134-.324v-2.729a.46.46%200%2001.458-.458zm.002-2.045a.458.458%200%2001.328.157l2.127%202.19%202.125-2.19a.459.459%200%2001.784.318v4.756a.46.46%200%2001-.455.458.46.46%200%2001-.458-.458V15.48l-1.667%201.723a.46.46%200%2001-.65.008l-.005-.005c0-.002-.002-.002-.004-.003l-2.455-2.534a.46.46%200%2001-.008-.667.461.461%200%2001.338-.128zm6.797%201.206a.46.46%200%2001.53.651A1.966%201.966%200%200019.81%2018.4a.462.462%200%2001.623.18.46.46%200%2001-.181.624%202.863%202.863%200%2001-1.38.353l-.142-.004a2.88%202.88%200%2001-2.393-4.263.461.461%200%2001.274-.21zm.864-.931a2.884%202.884%200%20013.915%203.914.46.46%200%2001-.402.24l-.057-.004a.458.458%200%2001-.164-.055.46.46%200%2001-.182-.622%201.967%201.967%200%2000-2.669-2.67.459.459%200%2011-.441-.803zM9.59%206.368c1.481%200%201.696%201.202%201.696%201.654v2.648h-.917v-.432c-.26.346-.792.535-1.36.535-.133%200-1.289-.03-1.384-1.136-.082-.932.675-1.61%202.053-1.61h.691c0-.563-.367-.886-.983-.886-.44.013-.864.174-1.2.458l-.36-.664c.484-.379%201.012-.567%201.764-.567zm4.427.1c1.263%200%202.082.97%202.083%202.15%200%201.181-.824%202.154-2.083%202.154-1.26%200-2.084-.972-2.084-2.152%200-1.18.82-2.153%202.084-2.153zm6.801.015c.68%200%201.202.465%201.197%201.548v2.642H21.1V8.29c0-.312-.002-.98-.63-.98s-.628.667-.628.838v2.524h-.89V8.148c0-.17-.001-.838-.63-.838-.628%200-.628.668-.628.98v2.383h-.917v-4.03h.917V7a1.22%201.22%200%2001.947-.516c.398%200%20.76.193.982.686a1.321%201.321%200%20011.195-.686zm-18.093.872l1.457-1.772H5.32L3.311%208.07l2.14%202.602H4.24L2.725%208.796%201.21%2010.672H0L2.138%208.07.13%205.583h1.138l1.458%201.772zm4.149%203.317h-.916V6.644h.916v4.028zm16.99%200h-.916V6.644h.916v4.028zM9.925%208.71c-1.055%200-1.359.412-1.326.742.032.329.324.537.757.537a1.013%201.013%200%20001.014-.968l.002-.31h-.447zM14.018%207.3c-.663%200-1.184.487-1.184%201.32%200%20.832.52%201.32%201.184%201.32.662%200%201.182-.49%201.182-1.32%200-.832-.52-1.32-1.182-1.32zM6.417%205.001a.568.568%200%2001.587.582.588.588%200%2001-1.175%200A.57.57%200%20016.417%205zm16.991%200a.57.57%200%2001.592.582.588.588%200%2001-1.174%200%20.57.57%200%2001.357-.542.572.572%200%2001.225-.04z'%3e%3c/path%3e%3c/svg%3e",EC="/assets/agent-inspector-58K1_MsC.ico",RC={"agent-inspector":"Inspector",codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code","ai-sdk":"AI SDK"};function Lr(e){return e?.toLowerCase()??""}function is(e,t){for(const n of t)if(e.includes(n))return!0;return!1}function ac(e){const t=[Lr(e.userAgent),Lr(e.conversationId),Lr(e.clientProjectFolder)].join(" ");return is(t,["agent-inspector","agent inspector","provider-test"])?"agent-inspector":is(t,["mimocode","mimo-code","mimo code"])?"mimo-code":is(t,["opencode","open-code","open code"])?"opencode":is(t,["claude-code","claude code","claudecode","claude-cli","claude cli"])?"claude-code":is(t,["codex desktop","codex-cli","openai-codex","codex"])?"codex":is(Lr(e.userAgent),["ai-sdk","ai/"])?"ai-sdk":"unknown"}function xi(e){switch(e){case"agent-inspector":case"codex":case"opencode":case"mimo-code":case"claude-code":case"ai-sdk":return RC[e];case"unknown":return null}}function PC(e){switch(e){case"codex":case"opencode":case"mimo-code":case"claude-code":return"IDE";case"agent-inspector":case"ai-sdk":case"unknown":return"CLIENT"}}const MC={"agent-inspector":EC,codex:NC,opencode:CC,"mimo-code":TC,"claude-code":_C},IC={"agent-inspector":"border-orange-700/15 bg-orange-500/[0.08] dark:border-orange-200/25 dark:bg-orange-300/[0.12]",codex:"border-cyan-700/15 bg-cyan-500/[0.08] dark:border-cyan-200/20 dark:bg-cyan-300/[0.08]",opencode:"border-sky-700/15 bg-sky-500/[0.09] dark:border-sky-200/25 dark:bg-sky-300/[0.12]","mimo-code":"border-orange-700/15 bg-orange-500/[0.09] dark:border-orange-200/25 dark:bg-orange-400/[0.12]","claude-code":"border-amber-700/15 bg-amber-500/[0.08] dark:border-amber-100/20 dark:bg-amber-300/[0.09]"},AC={"agent-inspector":"p-0.5 drop-shadow-[0_0_8px_rgba(251,146,60,0.35)]",codex:"p-0.5",opencode:"p-1 drop-shadow-[0_0_8px_rgba(125,211,252,0.35)]","mimo-code":"p-0.5 drop-shadow-[0_0_8px_rgba(255,105,0,0.35)]","claude-code":"p-0.5"};function bi({client:e,className:t,decorative:n=!1}){if(e==="unknown")return null;const s=xi(e);if(s===null)return null;if(e==="ai-sdk")return r.jsx("span",{className:$("inline-flex size-6 shrink-0 items-center justify-center rounded-md border border-cyan-700/15 bg-cyan-500/[0.08] text-[var(--inspector-status-cool)] shadow-sm dark:border-cyan-200/20 dark:bg-cyan-300/[0.08]",t),"aria-label":n?void 0:s,"aria-hidden":n?!0:void 0,title:s,children:r.jsx(dp,{className:"size-1/2","aria-hidden":"true"})});const o=MC[e];return r.jsx("span",{className:$("inline-flex size-6 shrink-0 items-center justify-center rounded-md border p-0 shadow-sm",IC[e],t),"aria-label":n?void 0:s,"aria-hidden":n?!0:void 0,title:s,children:r.jsx("img",{src:o,alt:"",className:$("size-full object-contain",AC[e]),"aria-hidden":"true"})})}const OC="data:image/svg+xml,%3csvg%20height='2500'%20viewBox='0%206.603%201192.672%201193.397'%20width='2500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m233.96%20800.215%20234.684-131.678%203.947-11.436-3.947-6.363h-11.436l-39.221-2.416-134.094-3.624-116.296-4.832-112.67-6.04-28.35-6.04-26.577-35.035%202.738-17.477%2023.84-16.027%2034.147%202.98%2075.463%205.155%20113.235%207.812%2082.147%204.832%20121.692%2012.644h19.329l2.738-7.812-6.604-4.832-5.154-4.832-117.182-79.41-126.845-83.92-66.443-48.321-35.92-24.484-18.12-22.953-7.813-50.093%2032.618-35.92%2043.812%202.98%2011.195%202.98%2044.375%2034.147%2094.792%2073.37%20123.786%2091.167%2018.12%2015.06%207.249-5.154.886-3.624-8.135-13.61-67.329-121.692-71.838-123.785-31.974-51.302-8.456-30.765c-2.98-12.645-5.154-23.275-5.154-36.242l37.127-50.416%2020.537-6.604%2049.53%206.604%2020.86%2018.121%2030.765%2070.39%2049.852%20110.818%2077.315%20150.684%2022.631%2044.698%2012.08%2041.396%204.51%2012.645h7.813v-7.248l6.362-84.886%2011.759-104.215%2011.436-134.094%203.946-37.772%2018.685-45.262%2037.127-24.482%2028.994%2013.852%2023.839%2034.148-3.303%2022.067-14.174%2092.134-27.785%20144.323-18.121%2096.644h10.55l12.08-12.08%2048.887-64.913%2082.147-102.685%2036.242-40.752%2042.282-45.02%2027.14-21.423h51.303l37.772%2056.135-16.913%2057.986-52.832%2067.007-43.812%2056.779-62.82%2084.563-39.22%2067.651%203.623%205.396%209.343-.886%20141.906-30.201%2076.671-13.852%2091.49-15.705%2041.396%2019.329%204.51%2019.65-16.269%2040.189-97.852%2024.16-114.764%2022.954-170.9%2040.43-2.093%201.53%202.416%202.98%2076.993%207.248%2032.94%201.771h80.617l150.12%2011.195%2039.222%2025.933%2023.517%2031.732-3.946%2024.16-60.403%2030.766-81.503-19.33-190.228-45.26-65.235-16.27h-9.02v5.397l54.362%2053.154%2099.624%2089.96%20124.752%20115.973%206.362%2028.671-16.027%2022.63-16.912-2.415-109.611-82.47-42.282-37.127-95.758-80.618h-6.363v8.456l22.067%2032.296%20116.537%20175.167%206.04%2053.719-8.456%2017.476-30.201%2010.55-33.181-6.04-68.215-95.758-70.39-107.84-56.778-96.644-6.926%203.947-33.503%20360.886-15.705%2018.443-36.243%2013.852-30.201-22.953-16.027-37.127%2016.027-73.37%2019.329-95.758%2015.704-76.107%2014.175-94.55%208.456-31.41-.563-2.094-6.927.886-71.275%2097.852-108.402%20146.497-85.772%2091.812-20.537%208.134-35.597-18.443%203.301-32.94%2019.893-29.315%20118.712-151.007%2071.597-93.583%2046.228-54.04-.322-7.813h-2.738l-315.302%20204.725-56.135%207.248-24.16-22.63%202.98-37.128%2011.435-12.08%2094.792-65.236-.322.323z'%20fill='%23d97757'/%3e%3c/svg%3e",zC="data:image/svg+xml,%3csvg%20height='2500'%20viewBox='-1%20-.1%20949.1%20959.8'%20width='2474'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m925.8%20456.3c10.4%2023.2%2017%2048%2019.7%2073.3%202.6%2025.3%201.3%2050.9-4.1%2075.8-5.3%2024.9-14.5%2048.8-27.3%2070.8-8.4%2014.7-18.3%2028.5-29.7%2041.2-11.3%2012.6-23.9%2024-37.6%2034-13.8%2010-28.5%2018.4-44.1%2025.3-15.5%206.8-31.7%2012-48.3%2015.4-7.8%2024.2-19.4%2047.1-34.4%2067.7-14.9%2020.6-33%2038.7-53.6%2053.6-20.6%2015-43.4%2026.6-67.6%2034.4-24.2%207.9-49.5%2011.8-75%2011.8-16.9.1-33.9-1.7-50.5-5.1-16.5-3.5-32.7-8.8-48.2-15.7s-30.2-15.5-43.9-25.5c-13.6-10-26.2-21.5-37.4-34.2-25%205.4-50.6%206.7-75.9%204.1-25.3-2.7-50.1-9.3-73.4-19.7-23.2-10.3-44.7-24.3-63.6-41.4s-35-37.1-47.7-59.1c-8.5-14.7-15.5-30.2-20.8-46.3s-8.8-32.7-10.6-49.6c-1.8-16.8-1.7-33.8.1-50.7%201.8-16.8%205.5-33.4%2010.8-49.5-17-18.9-31-40.4-41.4-63.6-10.3-23.3-17-48-19.6-73.3-2.7-25.3-1.3-50.9%204-75.8s14.5-48.8%2027.3-70.8c8.4-14.7%2018.3-28.6%2029.6-41.2s24-24%2037.7-34%2028.5-18.5%2044-25.3c15.6-6.9%2031.8-12%2048.4-15.4%207.8-24.3%2019.4-47.1%2034.3-67.7%2015-20.6%2033.1-38.7%2053.7-53.7%2020.6-14.9%2043.4-26.5%2067.6-34.4%2024.2-7.8%2049.5-11.8%2075-11.7%2016.9-.1%2033.9%201.6%2050.5%205.1s32.8%208.7%2048.3%2015.6c15.5%207%2030.2%2015.5%2043.9%2025.5%2013.7%2010.1%2026.3%2021.5%2037.5%2034.2%2024.9-5.3%2050.5-6.6%2075.8-4s50%209.3%2073.3%2019.6c23.2%2010.4%2044.7%2024.3%2063.6%2041.4%2018.9%2017%2035%2036.9%2047.7%2059%208.5%2014.6%2015.5%2030.1%2020.8%2046.3%205.3%2016.1%208.9%2032.7%2010.6%2049.6%201.8%2016.9%201.8%2033.9-.1%2050.8-1.8%2016.9-5.5%2033.5-10.8%2049.6%2017.1%2018.9%2031%2040.3%2041.4%2063.6zm-333.2%20426.9c21.8-9%2041.6-22.3%2058.3-39s30-36.5%2039-58.4c9-21.8%2013.7-45.2%2013.7-68.8v-223q-.1-.3-.2-.7-.1-.3-.3-.6-.2-.3-.5-.5-.3-.3-.6-.4l-80.7-46.6v269.4c0%202.7-.4%205.5-1.1%208.1-.7%202.7-1.7%205.2-3.1%207.6s-3%204.6-5%206.5a32.1%2032.1%200%200%201%20-6.5%205l-191.1%20110.3c-1.6%201-4.3%202.4-5.7%203.2%207.9%206.7%2016.5%2012.6%2025.5%2017.8%209.1%205.2%2018.5%209.6%2028.3%2013.2%209.8%203.5%2019.9%206.2%2030.1%208%2010.3%201.8%2020.7%202.7%2031.1%202.7%2023.6%200%2047-4.7%2068.8-13.8zm-455.1-151.4c11.9%2020.5%2027.6%2038.3%2046.3%2052.7%2018.8%2014.4%2040.1%2024.9%2062.9%2031s46.6%207.7%2070%204.6%2045.9-10.7%2066.4-22.5l193.2-111.5.5-.5q.2-.2.3-.6.2-.3.3-.6v-94l-233.2%20134.9c-2.4%201.4-4.9%202.4-7.5%203.2-2.7.7-5.4%201-8.2%201-2.7%200-5.4-.3-8.1-1-2.6-.8-5.2-1.8-7.6-3.2l-191.1-110.4c-1.7-1-4.2-2.5-5.6-3.4-1.8%2010.3-2.7%2020.7-2.7%2031.1s1%2020.8%202.8%2031.1c1.8%2010.2%204.6%2020.3%208.1%2030.1%203.6%209.8%208%2019.2%2013.2%2028.2zm-50.2-417c-11.8%2020.5-19.4%2043.1-22.5%2066.5s-1.5%2047.1%204.6%2070c6.1%2022.8%2016.6%2044.1%2031%2062.9%2014.4%2018.7%2032.3%2034.4%2052.7%2046.2l193.1%20111.6q.3.1.7.2h.7q.4%200%20.7-.2.3-.1.6-.3l81-46.8-233.2-134.6c-2.3-1.4-4.5-3.1-6.5-5a32.1%2032.1%200%200%201%20-5-6.5c-1.3-2.4-2.4-4.9-3.1-7.6-.7-2.6-1.1-5.3-1-8.1v-227.1c-9.8%203.6-19.3%208-28.3%2013.2-9%205.3-17.5%2011.3-25.5%2018-7.9%206.7-15.3%2014.1-22%2022.1-6.7%207.9-12.6%2016.5-17.8%2025.5zm663.3%20154.4c2.4%201.4%204.6%203%206.6%205%201.9%201.9%203.6%204.1%205%206.5%201.3%202.4%202.4%205%203.1%207.6.6%202.7%201%205.4.9%208.2v227.1c32.1-11.8%2060.1-32.5%2080.8-59.7%2020.8-27.2%2033.3-59.7%2036.2-93.7s-3.9-68.2-19.7-98.5-39.9-55.5-69.5-72.5l-193.1-111.6q-.3-.1-.7-.2h-.7q-.3.1-.7.2-.3.1-.6.3l-80.6%2046.6%20233.2%20134.7zm80.5-121h-.1v.1zm-.1-.1c5.8-33.6%201.9-68.2-11.3-99.7-13.1-31.5-35-58.6-63-78.2-28-19.5-61-30.7-95.1-32.2-34.2-1.4-68%206.9-97.6%2023.9l-193.1%20111.5q-.3.2-.5.5l-.4.6q-.1.3-.2.7-.1.3-.1.7v93.2l233.2-134.7c2.4-1.4%205-2.4%207.6-3.2%202.7-.7%205.4-1%208.1-1%202.8%200%205.5.3%208.2%201%202.6.8%205.1%201.8%207.5%203.2l191.1%20110.4c1.7%201%204.2%202.4%205.6%203.3zm-505.3-103.2c0-2.7.4-5.4%201.1-8.1.7-2.6%201.7-5.2%203.1-7.6%201.4-2.3%203-4.5%205-6.5%201.9-1.9%204.1-3.6%206.5-4.9l191.1-110.3c1.8-1.1%204.3-2.5%205.7-3.2-26.2-21.9-58.2-35.9-92.1-40.2-33.9-4.4-68.3%201-99.2%2015.5-31%2014.5-57.2%2037.6-75.5%2066.4-18.3%2028.9-28%2062.3-28%2096.5v223q.1.4.2.7.1.3.3.6.2.3.5.6.2.2.6.4l80.7%2046.6zm43.8%20294.7%20103.9%2060%20103.9-60v-119.9l-103.8-60-103.9%2060z'/%3e%3c/svg%3e",LC="data:image/svg+xml,%3csvg%20fill='none'%20height='1320'%20viewBox='3.771%206.973%2023.993%2017.652'%20width='2500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m27.501%208.469c-.252-.123-.36.111-.508.23-.05.04-.093.09-.135.135-.368.395-.797.652-1.358.621-.821-.045-1.521.213-2.14.842-.132-.776-.57-1.238-1.235-1.535-.349-.155-.701-.309-.944-.645-.171-.238-.217-.504-.303-.765-.054-.159-.108-.32-.29-.348-.197-.031-.274.135-.352.273-.31.567-.43%201.192-.419%201.825.028%201.421.628%202.554%201.82%203.36.136.093.17.186.128.321-.081.278-.178.547-.264.824-.054.178-.135.217-.324.14a5.448%205.448%200%200%201%20-1.719-1.169c-.848-.82-1.614-1.726-2.57-2.435-.225-.166-.449-.32-.681-.467-.976-.95.128-1.729.383-1.82.267-.096.093-.428-.77-.424s-1.653.293-2.659.677a2.782%202.782%200%200%201%20-.46.135%209.554%209.554%200%200%200%20-2.853-.1c-1.866.21-3.356%201.092-4.452%202.6-1.315%201.81-1.625%203.87-1.246%206.018.399%202.261%201.552%204.136%203.326%205.601%201.837%201.518%203.955%202.262%206.37%202.12%201.466-.085%203.1-.282%204.942-1.842.465.23.952.322%201.762.392.623.059%201.223-.031%201.687-.127.728-.154.677-.828.414-.953-2.132-.994-1.665-.59-2.09-.916%201.084-1.285%202.717-2.619%203.356-6.94.05-.343.007-.558%200-.837-.004-.168.034-.235.228-.254a4.084%204.084%200%200%200%201.529-.47c1.382-.757%201.938-1.997%202.07-3.485.02-.227-.004-.463-.243-.582zm-12.041%2013.391c-2.067-1.627-3.07-2.162-3.483-2.138-.387.021-.318.465-.233.754.089.285.205.482.368.732.113.166.19.414-.112.598-.666.414-1.823-.139-1.878-.166-1.347-.793-2.473-1.842-3.267-3.276-.765-1.38-1.21-2.861-1.284-4.441-.02-.383.093-.518.472-.586a4.692%204.692%200%200%201%201.514-.04c2.109.31%203.905%201.255%205.41%202.749.86.853%201.51%201.871%202.18%202.865.711%201.057%201.478%202.063%202.454%202.887.343.289.619.51.881.672-.792.088-2.117.107-3.022-.61zm.99-6.38a.304.304%200%201%201%20.609%200c0%20.17-.136.304-.306.304a.3.3%200%200%201%20-.303-.305zm3.077%201.581c-.197.08-.394.15-.584.159a1.246%201.246%200%200%201%20-.79-.252c-.27-.227-.463-.354-.546-.752a1.752%201.752%200%200%201%20.016-.582c.07-.324-.008-.531-.235-.72-.187-.155-.422-.196-.682-.196a.551.551%200%200%201%20-.252-.078c-.108-.055-.197-.19-.112-.356.027-.053.159-.183.19-.207.352-.201.758-.135%201.134.016.349.142.611.404.99.773.388.448.457.573.678.906.174.264.333.534.441.842.066.192-.02.35-.248.448z'%20fill='%234d6bfe'/%3e%3c/svg%3e",$C="/assets/minimax-BPMzvuL-.jpeg",DC="/assets/alibaba-TTwafVwX.svg",FC="/assets/qwen-mMn3f5ul.webp",UC="/assets/zhipuai-BPNAnxo-.svg",BC={"claude-":"anthropic","gpt-":"openai","o1-":"openai","o3-":"openai","deepseek-":"deepseek",MiniMax:"minimax",qwen:"qwen"};function VC(e){return e.replace(/[_\s]+/g,"-").split(/[/:@]/).some(n=>n.startsWith("glm-"))}function qC(e){if(e===null)return"unknown";const t=e.toLowerCase();if(VC(t))return"zhipuai";for(const[n,s]of Object.entries(BC))if(t.startsWith(n.toLowerCase()))return s;return"unknown"}const es={width:24,height:24,objectFit:"contain"},HC=Jn.memo(({className:e})=>r.jsx("img",{src:OC,alt:"Anthropic",className:e,style:es})),WC=Jn.memo(({className:e})=>r.jsx("img",{src:zC,alt:"OpenAI",className:e,style:{...es,background:"white",borderRadius:"4px"}})),ZC=Jn.memo(({className:e})=>r.jsx("img",{src:LC,alt:"DeepSeek",className:e,style:es})),KC=Jn.memo(({className:e})=>r.jsx("img",{src:$C,alt:"MiniMax",className:e,style:es})),GC=Jn.memo(({className:e})=>r.jsx("img",{src:DC,alt:"Alibaba",className:e,style:es})),JC=Jn.memo(({className:e})=>r.jsx("img",{src:FC,alt:"Qwen",className:e,style:es})),YC=Jn.memo(({className:e})=>r.jsx("img",{src:UC,alt:"ZhipuAI",className:e,style:es}));function XC({provider:e,className:t}){switch(e){case"anthropic":return r.jsx(HC,{className:t});case"openai":return r.jsx(WC,{className:t});case"deepseek":return r.jsx(ZC,{className:t});case"minimax":return r.jsx(KC,{className:t});case"alibaba":return r.jsx(GC,{className:t});case"qwen":return r.jsx(JC,{className:t});case"zhipuai":return r.jsx(YC,{className:t});case"unknown":return null}}function Ds({delayDuration:e=600,...t}){return r.jsx(xC,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function pt({...e}){return r.jsx(bC,{"data-slot":"tooltip",...e})}function mt({...e}){return r.jsx(vC,{"data-slot":"tooltip-trigger",...e})}function ht({className:e,sideOffset:t=0,children:n,...s}){return r.jsx(yC,{children:r.jsxs(wC,{"data-slot":"tooltip-content",sideOffset:t,className:$("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...s,children:[n,r.jsx(jC,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const QC=3;function e3({items:e,ariaLabel:t,className:n}){if(e.length===0)return r.jsx("span",{className:$("flex h-8 w-12 shrink-0 items-center",n),"aria-hidden":"true"});const s=e.slice(0,QC),o=e.length-s.length;return r.jsx(Ds,{delayDuration:150,children:r.jsxs("span",{className:$("flex h-8 w-12 shrink-0 items-center",n),"aria-label":t,children:[s.map((i,a)=>r.jsxs(pt,{children:[r.jsx(mt,{asChild:!0,children:r.jsx("span",{className:$("border border-border bg-muted/40 inline-flex size-6 shrink-0 items-center justify-center rounded-md",a>0&&"-ml-2"),children:r.jsx(XC,{provider:i.provider,className:"size-4"})})}),r.jsx(ht,{children:i.tooltip})]},`${i.provider}-${String(a)}`)),o>0&&r.jsxs("span",{className:"border border-border bg-muted/40 -ml-2 inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md px-1 font-mono text-[10px] text-muted-foreground",children:["+",o]})]})})}const t3="/v1/chat/completions",n3="/chat/completions",s3="/v1/responses",r3="/responses",o3="/v1/messages";class i3{handlers=new Map;pathMap=new Map;register(t){this.handlers.set(t.format,t)}registerPath(t,n){this.pathMap.set(t,n)}get(t){return this.handlers.get(t)}getByPath(t){const n=t.split("?")[0]??"",s=this.pathMap.get(n);return s===void 0?void 0:this.handlers.get(s)}getApiFormatByPath(t){const n=t.split("?")[0]??"";return this.pathMap.get(n)}detectFormat(t){if(t===null)return"unknown";for(const n of this.handlers.values())if(n.detectFormat(t))return n.format;return"unknown"}}const Pn=new i3;function a3(e){return Pn.getApiFormatByPath(e)??"unknown"}Pn.registerPath(o3,"anthropic");Pn.registerPath(t3,"openai");Pn.registerPath(n3,"openai");Pn.registerPath(s3,"openai");Pn.registerPath(r3,"openai");function l3(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}catch{return{}}}function c3(e){switch(e.type){case"text":return{type:"text",text:e.text};case"thinking":{const t={type:"thinking",thinking:e.thinking};return e.signature!==""&&(t.signature=e.signature),t}case"think":{const t={type:"think",thinking:e.thinking};return e.signature!==""&&(t.signature=e.signature),t}case"tool_use":return{type:"tool_use",id:e.id,name:e.name,input:l3(e.inputJson)}}}function Wh(e,t,n,s){const o=new Map;let i="",a="",l=null,u=null,d=0,f=0;const p=1e3;let m=0,h=0;const g=[];for(const b of e.split(`
106
- `)){const w=b.trim();if(w.startsWith("data: "))try{const v=JSON.parse(w.slice(6)),j=X2.safeParse(v);if(!j.success)continue;const S=j.data;switch(m===0&&(h=Date.now()),s===!0&&g.length<p&&g.push({index:m,timestamp:Date.now()-h,type:S.type,data:zf(S)}),m++,S.type){case"message_start":i=S.message.id,a=S.message.model,d=S.message.usage.input_tokens,t.inputTokens=d,t.cacheCreationInputTokens=S.message.usage.cache_creation_input_tokens??null,t.cacheReadInputTokens=S.message.usage.cache_read_input_tokens??null,t.model===null&&(t.model=a);break;case"content_block_start":{const k=S.content_block;switch(k.type){case"text":o.set(S.index,{type:"text",text:k.text??""});break;case"thinking":o.set(S.index,{type:"thinking",thinking:k.thinking??"",signature:k.signature??""});break;case"think":o.set(S.index,{type:"think",thinking:k.thinking??"",signature:k.signature??""});break;case"tool_use":o.set(S.index,{type:"tool_use",id:k.id,name:k.name,inputJson:""});break}break}case"content_block_delta":{const k=o.get(S.index);if(k===void 0)break;const _=S.delta;_.type==="text_delta"&&k.type==="text"?k.text+=_.text:_.type==="thinking_delta"&&(k.type==="thinking"||k.type==="think")?k.thinking+=_.thinking:_.type==="signature_delta"&&(k.type==="thinking"||k.type==="think")?k.signature+=_.signature:_.type==="input_json_delta"&&k.type==="tool_use"&&(k.inputJson+=_.partial_json);break}case"message_delta":l=S.delta.stop_reason,u=S.delta.stop_sequence??null,f=S.usage.output_tokens,t.outputTokens=f,S.usage.cache_creation_input_tokens!==void 0&&(t.cacheCreationInputTokens=S.usage.cache_creation_input_tokens),S.usage.cache_read_input_tokens!==void 0&&(t.cacheReadInputTokens=S.usage.cache_read_input_tokens);break;case"error":t.error=S.error.message;break;case"content_block_stop":case"message_stop":case"ping":break}}catch{}}s===!0&&(t.streamingChunks={chunks:g,truncated:m>p});const y=[...o.entries()].sort(([b],[w])=>b-w).map(([,b])=>c3(b));return JSON.stringify({id:i,type:"message",model:a!==""?a:n??"",role:"assistant",content:y,stop_reason:l,stop_sequence:u,usage:{input_tokens:d,output_tokens:f}})}const u3={format:"anthropic",parseRequest(e,t){try{const n=JSON.parse(e),s=Uf.safeParse(n);return s.success?{model:s.data.model,sessionId:s.data.metadata?.user_id??t?.get("x-agent-inspector-session-id")??t?.get("x-session-affinity")??null}:null}catch{return null}},extractTokens(e){try{const t=JSON.parse(e),n=Bf.safeParse(t);if(n.success)return{inputTokens:n.data.usage.input_tokens??null,outputTokens:n.data.usage.output_tokens??null,cacheCreationInputTokens:n.data.usage.cache_creation_input_tokens??null,cacheReadInputTokens:n.data.usage.cache_read_input_tokens??null}}catch{}return{inputTokens:null,outputTokens:null,cacheCreationInputTokens:null,cacheReadInputTokens:null}},extractStream(e,t,n,s){return Wh(e,t,n,s)},detectFormat(e){if(e===null)return!1;try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const n=Object.keys(t);return n.includes("model")&&n.includes("messages")&&n.includes("system")}return!1}catch{return!1}}};Pn.register(u3);class d3{providers=[];register(t){this.providers.push(t)}findProvider(t){let n=null;for(const s of this.providers)if(s.matches(t)){if(s.name!=="anthropic")return s;n=s}return n}getAll(){return[...this.providers]}}const vi=new d3,f3="https://api.anthropic.com",p3={MiniMax:"https://api.minimaxi.com/anthropic"},m3={name:"anthropic",matches(e){const t=e.toLowerCase();if(t.startsWith("openai-"))return!1;if(t.includes("claude")||t.includes("anthropic"))return!0;for(const n of Object.keys(p3))if(t.startsWith(n.toLowerCase()))return!0;return!0},getUpstreamBase(e,t){return t?.baseUrl!==void 0?t.baseUrl:f3},extractStream(e,t,n,s){return Wh(e,t,n,s)}};vi.register(m3);const lc=1e3;function jr(e,t){if(!(e===null||typeof e!="object"||Array.isArray(e)))return Object.getOwnPropertyDescriptor(e,t)?.value}function rt(e,t){const n=jr(e,t);return typeof n=="string"?n:null}function Zh(e,t){const n=jr(e,t);return typeof n=="number"&&Number.isFinite(n)?n:null}function Ro(e,t){const n=jr(e,t);return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:null}function h3(e,t){const n=jr(e,t);return Array.isArray(n)?n:[]}function g3(e){const t=[];let n=null,s=[];const o=()=>{n===null&&s.length===0||(t.push({event:n,data:s.join(`
105
+ `)},m_=0,rs=[];function h_(e){var t=c.useRef([]),n=c.useRef([0,0]),s=c.useRef(),o=c.useState(m_++)[0],i=c.useState(Df)[0],a=c.useRef(e);c.useEffect(function(){a.current=e},[e]),c.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var y=zk([e.lockRef.current],(e.shards||[]).map(wu),!0).filter(Boolean);return y.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),y.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=c.useCallback(function(y,b){if("touches"in y&&y.touches.length===2||y.type==="wheel"&&y.ctrlKey)return!a.current.allowPinchZoom;var w=Mr(y),v=n.current,j="deltaX"in y?y.deltaX:v[0]-w[0],_="deltaY"in y?y.deltaY:v[1]-w[1],k,S=y.target,C=Math.abs(j)>Math.abs(_)?"h":"v";if("touches"in y&&C==="h"&&S.type==="range")return!1;var M=window.getSelection(),A=M&&M.anchorNode,P=A?A===S||A.contains(S):!1;if(P)return!1;var N=vu(C,S);if(!N)return!0;if(N?k=C:(k=C==="v"?"h":"v",N=vu(C,S)),!N)return!1;if(!s.current&&"changedTouches"in y&&(j||_)&&(s.current=k),!k)return!0;var I=s.current||k;return d_(I,b,y,I==="h"?j:_)},[]),u=c.useCallback(function(y){var b=y;if(!(!rs.length||rs[rs.length-1]!==i)){var w="deltaY"in b?yu(b):Mr(b),v=t.current.filter(function(k){return k.name===b.type&&(k.target===b.target||b.target===k.shadowParent)&&p_(k.delta,w)})[0];if(v&&v.should){b.cancelable&&b.preventDefault();return}if(!v){var j=(a.current.shards||[]).map(wu).filter(Boolean).filter(function(k){return k.contains(b.target)}),_=j.length>0?l(b,j[0]):!a.current.noIsolation;_&&b.cancelable&&b.preventDefault()}}},[]),d=c.useCallback(function(y,b,w,v){var j={name:y,delta:b,target:w,should:v,shadowParent:g_(w)};t.current.push(j),setTimeout(function(){t.current=t.current.filter(function(_){return _!==j})},1)},[]),p=c.useCallback(function(y){n.current=Mr(y),s.current=void 0},[]),f=c.useCallback(function(y){d(y.type,yu(y),y.target,l(y,e.lockRef.current))},[]),m=c.useCallback(function(y){d(y.type,Mr(y),y.target,l(y,e.lockRef.current))},[]);c.useEffect(function(){return rs.push(i),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",u,ss),document.addEventListener("touchmove",u,ss),document.addEventListener("touchstart",p,ss),function(){rs=rs.filter(function(y){return y!==i}),document.removeEventListener("wheel",u,ss),document.removeEventListener("touchmove",u,ss),document.removeEventListener("touchstart",p,ss)}},[]);var h=e.removeScrollBar,g=e.inert;return c.createElement(c.Fragment,null,g?c.createElement(i,{styles:f_(o)}):null,h?c.createElement(r_,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function g_(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const x_=Hk($f,h_);var Bl=c.forwardRef(function(e,t){return c.createElement(ti,Ft({},e,{ref:t,sideCar:x_}))});Bl.classNames=ti.classNames;var b_=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},os=new WeakMap,Ar=new WeakMap,Or={},$i=0,Vf=function(e){return e&&(e.host||Vf(e.parentNode))},v_=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=Vf(n);return s&&e.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},y_=function(e,t,n,s){var o=v_(t,Array.isArray(e)?e:[e]);Or[n]||(Or[n]=new WeakMap);var i=Or[n],a=[],l=new Set,u=new Set(o),d=function(f){!f||l.has(f)||(l.add(f),d(f.parentNode))};o.forEach(d);var p=function(f){!f||u.has(f)||Array.prototype.forEach.call(f.children,function(m){if(l.has(m))p(m);else try{var h=m.getAttribute(s),g=h!==null&&h!=="false",y=(os.get(m)||0)+1,b=(i.get(m)||0)+1;os.set(m,y),i.set(m,b),a.push(m),y===1&&g&&Ar.set(m,!0),b===1&&m.setAttribute(n,"true"),g||m.setAttribute(s,"true")}catch(w){console.error("aria-hidden: cannot operate on ",m,w)}})};return p(t),l.clear(),$i++,function(){a.forEach(function(f){var m=os.get(f)-1,h=i.get(f)-1;os.set(f,m),i.set(f,h),m||(Ar.has(f)||f.removeAttribute(s),Ar.delete(f)),h||f.removeAttribute(n)}),$i--,$i||(os=new WeakMap,os=new WeakMap,Ar=new WeakMap,Or={})}},qf=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),o=b_(e);return o?(s.push.apply(s,Array.from(o.querySelectorAll("[aria-live], script"))),y_(s,o,n,"aria-hidden")):function(){return null}},ni="Dialog",[Hf]=dn(ni),[w_,zt]=Hf(ni),Wf=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:o,onOpenChange:i,modal:a=!0}=e,l=c.useRef(null),u=c.useRef(null),[d,p]=qn({prop:s,defaultProp:o??!1,onChange:i,caller:ni});return r.jsx(w_,{scope:t,triggerRef:l,contentRef:u,contentId:qt(),titleId:qt(),descriptionId:qt(),open:d,onOpenChange:p,onOpenToggle:c.useCallback(()=>p(f=>!f),[p]),modal:a,children:n})};Wf.displayName=ni;var Zf="DialogTrigger",Kf=c.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=zt(Zf,n),i=Pe(t,o.triggerRef);return r.jsx(ge.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":ql(o.open),...s,ref:i,onClick:pe(e.onClick,o.onOpenToggle)})});Kf.displayName=Zf;var Vl="DialogPortal",[j_,Gf]=Hf(Vl,{forceMount:void 0}),Jf=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:o}=e,i=zt(Vl,t);return r.jsx(j_,{scope:t,forceMount:n,children:c.Children.map(s,a=>r.jsx(wt,{present:n||i.open,children:r.jsx(ei,{asChild:!0,container:o,children:a})}))})};Jf.displayName=Vl;var jo="DialogOverlay",Yf=c.forwardRef((e,t)=>{const n=Gf(jo,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,i=zt(jo,e.__scopeDialog);return i.modal?r.jsx(wt,{present:s||i.open,children:r.jsx(__,{...o,ref:t})}):null});Yf.displayName=jo;var k_=Cs("DialogOverlay.RemoveScroll"),__=c.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=zt(jo,n),i=_k(),a=Pe(t,i);return r.jsx(Bl,{as:k_,allowPinchZoom:!0,shards:[o.contentRef],children:r.jsx(ge.div,{"data-state":ql(o.open),...s,ref:a,style:{pointerEvents:"auto",...s.style}})})}),Ts="DialogContent",Xf=c.forwardRef((e,t)=>{const n=Gf(Ts,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,i=zt(Ts,e.__scopeDialog);return r.jsx(wt,{present:s||i.open,children:i.modal?r.jsx(S_,{...o,ref:t}):r.jsx(N_,{...o,ref:t})})});Xf.displayName=Ts;var S_=c.forwardRef((e,t)=>{const n=zt(Ts,e.__scopeDialog),s=c.useRef(null),o=Pe(t,n.contentRef,s);return c.useEffect(()=>{const i=s.current;if(i)return qf(i)},[]),r.jsx(Qf,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:pe(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:pe(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&i.preventDefault()}),onFocusOutside:pe(e.onFocusOutside,i=>i.preventDefault())})}),N_=c.forwardRef((e,t)=>{const n=zt(Ts,e.__scopeDialog),s=c.useRef(!1),o=c.useRef(!1);return r.jsx(Qf,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(s.current||n.triggerRef.current?.focus(),i.preventDefault()),s.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(s.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=i.target;n.triggerRef.current?.contains(a)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),Qf=c.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:i,...a}=e,l=zt(Ts,n);return Of(),r.jsx(r.Fragment,{children:r.jsx(Ul,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:i,children:r.jsx(Qo,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":ql(l.open),...a,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),em="DialogTitle",tm=c.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=zt(em,n);return r.jsx(ge.h2,{id:o.titleId,...s,ref:t})});tm.displayName=em;var nm="DialogDescription",sm=c.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=zt(nm,n);return r.jsx(ge.p,{id:o.descriptionId,...s,ref:t})});sm.displayName=nm;var rm="DialogClose",om=c.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=zt(rm,n);return r.jsx(ge.button,{type:"button",...s,ref:t,onClick:pe(e.onClick,()=>o.onOpenChange(!1))})});om.displayName=rm;function ql(e){return e?"open":"closed"}function C_(e){const t=c.useRef({value:e,previous:e});return c.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function T_(e){const[t,n]=c.useState(void 0);return Je(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let a,l;if("borderBoxSize"in i){const u=i.borderBoxSize,d=Array.isArray(u)?u[0]:u;a=d.inlineSize,l=d.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}const E_=["top","right","bottom","left"],kn=Math.min,gt=Math.max,ko=Math.round,zr=Math.floor,Ht=e=>({x:e,y:e}),R_={left:"right",right:"left",bottom:"top",top:"bottom"},P_={start:"end",end:"start"};function Ma(e,t,n){return gt(e,kn(t,n))}function ln(e,t){return typeof e=="function"?e(t):e}function cn(e){return e.split("-")[0]}function Ls(e){return e.split("-")[1]}function Hl(e){return e==="x"?"y":"x"}function Wl(e){return e==="y"?"height":"width"}const I_=new Set(["top","bottom"]);function Ut(e){return I_.has(cn(e))?"y":"x"}function Zl(e){return Hl(Ut(e))}function M_(e,t,n){n===void 0&&(n=!1);const s=Ls(e),o=Zl(e),i=Wl(o);let a=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=_o(a)),[a,_o(a)]}function A_(e){const t=_o(e);return[Aa(e),t,Aa(t)]}function Aa(e){return e.replace(/start|end/g,t=>P_[t])}const ju=["left","right"],ku=["right","left"],O_=["top","bottom"],z_=["bottom","top"];function L_(e,t,n){switch(e){case"top":case"bottom":return n?t?ku:ju:t?ju:ku;case"left":case"right":return t?O_:z_;default:return[]}}function $_(e,t,n,s){const o=Ls(e);let i=L_(cn(e),n==="start",s);return o&&(i=i.map(a=>a+"-"+o),t&&(i=i.concat(i.map(Aa)))),i}function _o(e){return e.replace(/left|right|bottom|top/g,t=>R_[t])}function D_(e){return{top:0,right:0,bottom:0,left:0,...e}}function im(e){return typeof e!="number"?D_(e):{top:e,right:e,bottom:e,left:e}}function So(e){const{x:t,y:n,width:s,height:o}=e;return{width:s,height:o,top:n,left:t,right:t+s,bottom:n+o,x:t,y:n}}function _u(e,t,n){let{reference:s,floating:o}=e;const i=Ut(t),a=Zl(t),l=Wl(a),u=cn(t),d=i==="y",p=s.x+s.width/2-o.width/2,f=s.y+s.height/2-o.height/2,m=s[l]/2-o[l]/2;let h;switch(u){case"top":h={x:p,y:s.y-o.height};break;case"bottom":h={x:p,y:s.y+s.height};break;case"right":h={x:s.x+s.width,y:f};break;case"left":h={x:s.x-o.width,y:f};break;default:h={x:s.x,y:s.y}}switch(Ls(t)){case"start":h[a]-=m*(n&&d?-1:1);break;case"end":h[a]+=m*(n&&d?-1:1);break}return h}async function F_(e,t){var n;t===void 0&&(t={});const{x:s,y:o,platform:i,rects:a,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:p="viewport",elementContext:f="floating",altBoundary:m=!1,padding:h=0}=ln(t,e),g=im(h),b=l[m?f==="floating"?"reference":"floating":f],w=So(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:p,strategy:u})),v=f==="floating"?{x:s,y:o,width:a.floating.width,height:a.floating.height}:a.reference,j=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),_=await(i.isElement==null?void 0:i.isElement(j))?await(i.getScale==null?void 0:i.getScale(j))||{x:1,y:1}:{x:1,y:1},k=So(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:j,strategy:u}):v);return{top:(w.top-k.top+g.top)/_.y,bottom:(k.bottom-w.bottom+g.bottom)/_.y,left:(w.left-k.left+g.left)/_.x,right:(k.right-w.right+g.right)/_.x}}const U_=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:i=[],platform:a}=n,l=i.filter(Boolean),u=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:p,y:f}=_u(d,s,u),m=s,h={},g=0;for(let b=0;b<l.length;b++){var y;const{name:w,fn:v}=l[b],{x:j,y:_,data:k,reset:S}=await v({x:p,y:f,initialPlacement:s,placement:m,strategy:o,middlewareData:h,rects:d,platform:{...a,detectOverflow:(y=a.detectOverflow)!=null?y:F_},elements:{reference:e,floating:t}});p=j??p,f=_??f,h={...h,[w]:{...h[w],...k}},S&&g<=50&&(g++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(d=S.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:p,y:f}=_u(d,m,u)),b=-1)}return{x:p,y:f,placement:m,strategy:o,middlewareData:h}},B_=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:o,rects:i,platform:a,elements:l,middlewareData:u}=t,{element:d,padding:p=0}=ln(e,t)||{};if(d==null)return{};const f=im(p),m={x:n,y:s},h=Zl(o),g=Wl(h),y=await a.getDimensions(d),b=h==="y",w=b?"top":"left",v=b?"bottom":"right",j=b?"clientHeight":"clientWidth",_=i.reference[g]+i.reference[h]-m[h]-i.floating[g],k=m[h]-i.reference[h],S=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let C=S?S[j]:0;(!C||!await(a.isElement==null?void 0:a.isElement(S)))&&(C=l.floating[j]||i.floating[g]);const M=_/2-k/2,A=C/2-y[g]/2-1,P=kn(f[w],A),N=kn(f[v],A),I=P,F=C-y[g]-N,B=C/2-y[g]/2+M,J=Ma(I,B,F),K=!u.arrow&&Ls(o)!=null&&B!==J&&i.reference[g]/2-(B<I?P:N)-y[g]/2<0,W=K?B<I?B-I:B-F:0;return{[h]:m[h]+W,data:{[h]:J,centerOffset:B-J-W,...K&&{alignmentOffset:W}},reset:K}}}),V_=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:o,middlewareData:i,rects:a,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:p=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...b}=ln(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=cn(o),v=Ut(l),j=cn(l)===l,_=await(u.isRTL==null?void 0:u.isRTL(d.floating)),k=m||(j||!y?[_o(l)]:A_(l)),S=g!=="none";!m&&S&&k.push(...$_(l,y,g,_));const C=[l,...k],M=await u.detectOverflow(t,b),A=[];let P=((s=i.flip)==null?void 0:s.overflows)||[];if(p&&A.push(M[w]),f){const B=M_(o,a,_);A.push(M[B[0]],M[B[1]])}if(P=[...P,{placement:o,overflows:A}],!A.every(B=>B<=0)){var N,I;const B=(((N=i.flip)==null?void 0:N.index)||0)+1,J=C[B];if(J&&(!(f==="alignment"?v!==Ut(J):!1)||P.every(V=>Ut(V.placement)===v?V.overflows[0]>0:!0)))return{data:{index:B,overflows:P},reset:{placement:J}};let K=(I=P.filter(W=>W.overflows[0]<=0).sort((W,V)=>W.overflows[1]-V.overflows[1])[0])==null?void 0:I.placement;if(!K)switch(h){case"bestFit":{var F;const W=(F=P.filter(V=>{if(S){const z=Ut(V.placement);return z===v||z==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(z=>z>0).reduce((z,X)=>z+X,0)]).sort((V,z)=>V[1]-z[1])[0])==null?void 0:F[0];W&&(K=W);break}case"initialPlacement":K=l;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function Su(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Nu(e){return E_.some(t=>e[t]>=0)}const q_=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:o="referenceHidden",...i}=ln(e,t);switch(o){case"referenceHidden":{const a=await s.detectOverflow(t,{...i,elementContext:"reference"}),l=Su(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Nu(l)}}}case"escaped":{const a=await s.detectOverflow(t,{...i,altBoundary:!0}),l=Su(a,n.floating);return{data:{escapedOffsets:l,escaped:Nu(l)}}}default:return{}}}}},am=new Set(["left","top"]);async function H_(e,t){const{placement:n,platform:s,elements:o}=e,i=await(s.isRTL==null?void 0:s.isRTL(o.floating)),a=cn(n),l=Ls(n),u=Ut(n)==="y",d=am.has(a)?-1:1,p=i&&u?-1:1,f=ln(t,e);let{mainAxis:m,crossAxis:h,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof g=="number"&&(h=l==="end"?g*-1:g),u?{x:h*p,y:m*d}:{x:m*d,y:h*p}}const W_=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:o,y:i,placement:a,middlewareData:l}=t,u=await H_(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(s=l.arrow)!=null&&s.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:a}}}}},Z_=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:o,platform:i}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:u={fn:w=>{let{x:v,y:j}=w;return{x:v,y:j}}},...d}=ln(e,t),p={x:n,y:s},f=await i.detectOverflow(t,d),m=Ut(cn(o)),h=Hl(m);let g=p[h],y=p[m];if(a){const w=h==="y"?"top":"left",v=h==="y"?"bottom":"right",j=g+f[w],_=g-f[v];g=Ma(j,g,_)}if(l){const w=m==="y"?"top":"left",v=m==="y"?"bottom":"right",j=y+f[w],_=y-f[v];y=Ma(j,y,_)}const b=u.fn({...t,[h]:g,[m]:y});return{...b,data:{x:b.x-n,y:b.y-s,enabled:{[h]:a,[m]:l}}}}}},K_=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:o,rects:i,middlewareData:a}=t,{offset:l=0,mainAxis:u=!0,crossAxis:d=!0}=ln(e,t),p={x:n,y:s},f=Ut(o),m=Hl(f);let h=p[m],g=p[f];const y=ln(l,t),b=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(u){const j=m==="y"?"height":"width",_=i.reference[m]-i.floating[j]+b.mainAxis,k=i.reference[m]+i.reference[j]-b.mainAxis;h<_?h=_:h>k&&(h=k)}if(d){var w,v;const j=m==="y"?"width":"height",_=am.has(cn(o)),k=i.reference[f]-i.floating[j]+(_&&((w=a.offset)==null?void 0:w[f])||0)+(_?0:b.crossAxis),S=i.reference[f]+i.reference[j]+(_?0:((v=a.offset)==null?void 0:v[f])||0)-(_?b.crossAxis:0);g<k?g=k:g>S&&(g=S)}return{[m]:h,[f]:g}}}},G_=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:o,rects:i,platform:a,elements:l}=t,{apply:u=()=>{},...d}=ln(e,t),p=await a.detectOverflow(t,d),f=cn(o),m=Ls(o),h=Ut(o)==="y",{width:g,height:y}=i.floating;let b,w;f==="top"||f==="bottom"?(b=f,w=m===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(w=f,b=m==="end"?"top":"bottom");const v=y-p.top-p.bottom,j=g-p.left-p.right,_=kn(y-p[b],v),k=kn(g-p[w],j),S=!t.middlewareData.shift;let C=_,M=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(M=j),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(C=v),S&&!m){const P=gt(p.left,0),N=gt(p.right,0),I=gt(p.top,0),F=gt(p.bottom,0);h?M=g-2*(P!==0||N!==0?P+N:gt(p.left,p.right)):C=y-2*(I!==0||F!==0?I+F:gt(p.top,p.bottom))}await u({...t,availableWidth:M,availableHeight:C});const A=await a.getDimensions(l.floating);return g!==A.width||y!==A.height?{reset:{rects:!0}}:{}}}};function si(){return typeof window<"u"}function $s(e){return lm(e)?(e.nodeName||"").toLowerCase():"#document"}function vt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Jt(e){var t;return(t=(lm(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function lm(e){return si()?e instanceof Node||e instanceof vt(e).Node:!1}function It(e){return si()?e instanceof Element||e instanceof vt(e).Element:!1}function Wt(e){return si()?e instanceof HTMLElement||e instanceof vt(e).HTMLElement:!1}function Cu(e){return!si()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof vt(e).ShadowRoot}const J_=new Set(["inline","contents"]);function xr(e){const{overflow:t,overflowX:n,overflowY:s,display:o}=Mt(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!J_.has(o)}const Y_=new Set(["table","td","th"]);function X_(e){return Y_.has($s(e))}const Q_=[":popover-open",":modal"];function ri(e){return Q_.some(t=>{try{return e.matches(t)}catch{return!1}})}const eS=["transform","translate","scale","rotate","perspective"],tS=["transform","translate","scale","rotate","perspective","filter"],nS=["paint","layout","strict","content"];function Kl(e){const t=Gl(),n=It(e)?Mt(e):e;return eS.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||tS.some(s=>(n.willChange||"").includes(s))||nS.some(s=>(n.contain||"").includes(s))}function sS(e){let t=_n(e);for(;Wt(t)&&!Es(t);){if(Kl(t))return t;if(ri(t))return null;t=_n(t)}return null}function Gl(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const rS=new Set(["html","body","#document"]);function Es(e){return rS.has($s(e))}function Mt(e){return vt(e).getComputedStyle(e)}function oi(e){return It(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function _n(e){if($s(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Cu(e)&&e.host||Jt(e);return Cu(t)?t.host:t}function cm(e){const t=_n(e);return Es(t)?e.ownerDocument?e.ownerDocument.body:e.body:Wt(t)&&xr(t)?t:cm(t)}function or(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=cm(e),i=o===((s=e.ownerDocument)==null?void 0:s.body),a=vt(o);if(i){const l=Oa(a);return t.concat(a,a.visualViewport||[],xr(o)?o:[],l&&n?or(l):[])}return t.concat(o,or(o,[],n))}function Oa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function um(e){const t=Mt(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=Wt(e),i=o?e.offsetWidth:n,a=o?e.offsetHeight:s,l=ko(n)!==i||ko(s)!==a;return l&&(n=i,s=a),{width:n,height:s,$:l}}function Jl(e){return It(e)?e:e.contextElement}function vs(e){const t=Jl(e);if(!Wt(t))return Ht(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:i}=um(t);let a=(i?ko(n.width):n.width)/s,l=(i?ko(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const oS=Ht(0);function dm(e){const t=vt(e);return!Gl()||!t.visualViewport?oS:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function iS(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==vt(e)?!1:t}function Hn(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Jl(e);let a=Ht(1);t&&(s?It(s)&&(a=vs(s)):a=vs(e));const l=iS(i,n,s)?dm(i):Ht(0);let u=(o.left+l.x)/a.x,d=(o.top+l.y)/a.y,p=o.width/a.x,f=o.height/a.y;if(i){const m=vt(i),h=s&&It(s)?vt(s):s;let g=m,y=Oa(g);for(;y&&s&&h!==g;){const b=vs(y),w=y.getBoundingClientRect(),v=Mt(y),j=w.left+(y.clientLeft+parseFloat(v.paddingLeft))*b.x,_=w.top+(y.clientTop+parseFloat(v.paddingTop))*b.y;u*=b.x,d*=b.y,p*=b.x,f*=b.y,u+=j,d+=_,g=vt(y),y=Oa(g)}}return So({width:p,height:f,x:u,y:d})}function ii(e,t){const n=oi(e).scrollLeft;return t?t.left+n:Hn(Jt(e)).left+n}function pm(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-ii(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function aS(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const i=o==="fixed",a=Jt(s),l=t?ri(t.floating):!1;if(s===a||l&&i)return n;let u={scrollLeft:0,scrollTop:0},d=Ht(1);const p=Ht(0),f=Wt(s);if((f||!f&&!i)&&(($s(s)!=="body"||xr(a))&&(u=oi(s)),Wt(s))){const h=Hn(s);d=vs(s),p.x=h.x+s.clientLeft,p.y=h.y+s.clientTop}const m=a&&!f&&!i?pm(a,u):Ht(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+p.x+m.x,y:n.y*d.y-u.scrollTop*d.y+p.y+m.y}}function lS(e){return Array.from(e.getClientRects())}function cS(e){const t=Jt(e),n=oi(e),s=e.ownerDocument.body,o=gt(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),i=gt(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let a=-n.scrollLeft+ii(e);const l=-n.scrollTop;return Mt(s).direction==="rtl"&&(a+=gt(t.clientWidth,s.clientWidth)-o),{width:o,height:i,x:a,y:l}}const Tu=25;function uS(e,t){const n=vt(e),s=Jt(e),o=n.visualViewport;let i=s.clientWidth,a=s.clientHeight,l=0,u=0;if(o){i=o.width,a=o.height;const p=Gl();(!p||p&&t==="fixed")&&(l=o.offsetLeft,u=o.offsetTop)}const d=ii(s);if(d<=0){const p=s.ownerDocument,f=p.body,m=getComputedStyle(f),h=p.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(s.clientWidth-f.clientWidth-h);g<=Tu&&(i-=g)}else d<=Tu&&(i+=d);return{width:i,height:a,x:l,y:u}}const dS=new Set(["absolute","fixed"]);function pS(e,t){const n=Hn(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,i=Wt(e)?vs(e):Ht(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,u=o*i.x,d=s*i.y;return{width:a,height:l,x:u,y:d}}function Eu(e,t,n){let s;if(t==="viewport")s=uS(e,n);else if(t==="document")s=cS(Jt(e));else if(It(t))s=pS(t,n);else{const o=dm(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return So(s)}function fm(e,t){const n=_n(e);return n===t||!It(n)||Es(n)?!1:Mt(n).position==="fixed"||fm(n,t)}function fS(e,t){const n=t.get(e);if(n)return n;let s=or(e,[],!1).filter(l=>It(l)&&$s(l)!=="body"),o=null;const i=Mt(e).position==="fixed";let a=i?_n(e):e;for(;It(a)&&!Es(a);){const l=Mt(a),u=Kl(a);!u&&l.position==="fixed"&&(o=null),(i?!u&&!o:!u&&l.position==="static"&&!!o&&dS.has(o.position)||xr(a)&&!u&&fm(e,a))?s=s.filter(p=>p!==a):o=l,a=_n(a)}return t.set(e,s),s}function mS(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const a=[...n==="clippingAncestors"?ri(t)?[]:fS(t,this._c):[].concat(n),s],l=a[0],u=a.reduce((d,p)=>{const f=Eu(t,p,o);return d.top=gt(f.top,d.top),d.right=kn(f.right,d.right),d.bottom=kn(f.bottom,d.bottom),d.left=gt(f.left,d.left),d},Eu(t,l,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function hS(e){const{width:t,height:n}=um(e);return{width:t,height:n}}function gS(e,t,n){const s=Wt(t),o=Jt(t),i=n==="fixed",a=Hn(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const u=Ht(0);function d(){u.x=ii(o)}if(s||!s&&!i)if(($s(t)!=="body"||xr(o))&&(l=oi(t)),s){const h=Hn(t,!0,i,t);u.x=h.x+t.clientLeft,u.y=h.y+t.clientTop}else o&&d();i&&!s&&o&&d();const p=o&&!s&&!i?pm(o,l):Ht(0),f=a.left+l.scrollLeft-u.x-p.x,m=a.top+l.scrollTop-u.y-p.y;return{x:f,y:m,width:a.width,height:a.height}}function Di(e){return Mt(e).position==="static"}function Ru(e,t){if(!Wt(e)||Mt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Jt(e)===n&&(n=n.ownerDocument.body),n}function mm(e,t){const n=vt(e);if(ri(e))return n;if(!Wt(e)){let o=_n(e);for(;o&&!Es(o);){if(It(o)&&!Di(o))return o;o=_n(o)}return n}let s=Ru(e,t);for(;s&&X_(s)&&Di(s);)s=Ru(s,t);return s&&Es(s)&&Di(s)&&!Kl(s)?n:s||sS(e)||n}const xS=async function(e){const t=this.getOffsetParent||mm,n=this.getDimensions,s=await n(e.floating);return{reference:gS(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function bS(e){return Mt(e).direction==="rtl"}const vS={convertOffsetParentRelativeRectToViewportRelativeRect:aS,getDocumentElement:Jt,getClippingRect:mS,getOffsetParent:mm,getElementRects:xS,getClientRects:lS,getDimensions:hS,getScale:vs,isElement:It,isRTL:bS};function hm(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function yS(e,t){let n=null,s;const o=Jt(e);function i(){var l;clearTimeout(s),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),i();const d=e.getBoundingClientRect(),{left:p,top:f,width:m,height:h}=d;if(l||t(),!m||!h)return;const g=zr(f),y=zr(o.clientWidth-(p+m)),b=zr(o.clientHeight-(f+h)),w=zr(p),j={rootMargin:-g+"px "+-y+"px "+-b+"px "+-w+"px",threshold:gt(0,kn(1,u))||1};let _=!0;function k(S){const C=S[0].intersectionRatio;if(C!==u){if(!_)return a();C?a(!1,C):s=setTimeout(()=>{a(!1,1e-7)},1e3)}C===1&&!hm(d,e.getBoundingClientRect())&&a(),_=!1}try{n=new IntersectionObserver(k,{...j,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,j)}n.observe(e)}return a(!0),i}function wS(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=s,d=Jl(e),p=o||i?[...d?or(d):[],...or(t)]:[];p.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),i&&w.addEventListener("resize",n)});const f=d&&l?yS(d,n):null;let m=-1,h=null;a&&(h=new ResizeObserver(w=>{let[v]=w;v&&v.target===d&&h&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var j;(j=h)==null||j.observe(t)})),n()}),d&&!u&&h.observe(d),h.observe(t));let g,y=u?Hn(e):null;u&&b();function b(){const w=Hn(e);y&&!hm(y,w)&&n(),y=w,g=requestAnimationFrame(b)}return n(),()=>{var w;p.forEach(v=>{o&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),f?.(),(w=h)==null||w.disconnect(),h=null,u&&cancelAnimationFrame(g)}}const jS=W_,kS=Z_,_S=V_,SS=G_,NS=q_,Pu=B_,CS=K_,TS=(e,t,n)=>{const s=new Map,o={platform:vS,...n},i={...o.platform,_c:s};return U_(e,t,{...o,platform:i})};var ES=typeof document<"u",RS=function(){},ro=ES?c.useLayoutEffect:RS;function No(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!No(e[s],t[s]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,o[s]))return!1;for(s=n;s--!==0;){const i=o[s];if(!(i==="_owner"&&e.$$typeof)&&!No(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function gm(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Iu(e,t){const n=gm(e);return Math.round(t*n)/n}function Fi(e){const t=c.useRef(e);return ro(()=>{t.current=e}),t}function PS(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:o,elements:{reference:i,floating:a}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[p,f]=c.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=c.useState(s);No(m,s)||h(s);const[g,y]=c.useState(null),[b,w]=c.useState(null),v=c.useCallback(V=>{V!==S.current&&(S.current=V,y(V))},[]),j=c.useCallback(V=>{V!==C.current&&(C.current=V,w(V))},[]),_=i||g,k=a||b,S=c.useRef(null),C=c.useRef(null),M=c.useRef(p),A=u!=null,P=Fi(u),N=Fi(o),I=Fi(d),F=c.useCallback(()=>{if(!S.current||!C.current)return;const V={placement:t,strategy:n,middleware:m};N.current&&(V.platform=N.current),TS(S.current,C.current,V).then(z=>{const X={...z,isPositioned:I.current!==!1};B.current&&!No(M.current,X)&&(M.current=X,Os.flushSync(()=>{f(X)}))})},[m,t,n,N,I]);ro(()=>{d===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,f(V=>({...V,isPositioned:!1})))},[d]);const B=c.useRef(!1);ro(()=>(B.current=!0,()=>{B.current=!1}),[]),ro(()=>{if(_&&(S.current=_),k&&(C.current=k),_&&k){if(P.current)return P.current(_,k,F);F()}},[_,k,F,P,A]);const J=c.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:j}),[v,j]),K=c.useMemo(()=>({reference:_,floating:k}),[_,k]),W=c.useMemo(()=>{const V={position:n,left:0,top:0};if(!K.floating)return V;const z=Iu(K.floating,p.x),X=Iu(K.floating,p.y);return l?{...V,transform:"translate("+z+"px, "+X+"px)",...gm(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:X}},[n,l,K.floating,p.x,p.y]);return c.useMemo(()=>({...p,update:F,refs:J,elements:K,floatingStyles:W}),[p,F,J,K,W])}const IS=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:o}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?Pu({element:s.current,padding:o}).fn(n):{}:s?Pu({element:s,padding:o}).fn(n):{}}}},MS=(e,t)=>({...jS(e),options:[e,t]}),AS=(e,t)=>({...kS(e),options:[e,t]}),OS=(e,t)=>({...CS(e),options:[e,t]}),zS=(e,t)=>({..._S(e),options:[e,t]}),LS=(e,t)=>({...SS(e),options:[e,t]}),$S=(e,t)=>({...NS(e),options:[e,t]}),DS=(e,t)=>({...IS(e),options:[e,t]});var FS="Arrow",xm=c.forwardRef((e,t)=>{const{children:n,width:s=10,height:o=5,...i}=e;return r.jsx(ge.svg,{...i,ref:t,width:s,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});xm.displayName=FS;var US=xm,Yl="Popper",[bm,ai]=dn(Yl),[BS,vm]=bm(Yl),ym=e=>{const{__scopePopper:t,children:n}=e,[s,o]=c.useState(null),[i,a]=c.useState(void 0);return r.jsx(BS,{scope:t,anchor:s,onAnchorChange:o,placementState:i,setPlacementState:a,children:n})};ym.displayName=Yl;var wm="PopperAnchor",jm=c.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,i=vm(wm,n),a=c.useRef(null),l=i.onAnchorChange,u=c.useCallback(g=>{a.current=g,g&&l(g)},[l]),d=Pe(t,u),p=c.useRef(null);c.useEffect(()=>{if(!s)return;const g=p.current;p.current=s.current,g!==p.current&&l(p.current)});const f=i.placementState&&Ql(i.placementState),m=f?.[0],h=f?.[1];return s?null:r.jsx(ge.div,{"data-radix-popper-side":m,"data-radix-popper-align":h,...o,ref:d})});jm.displayName=wm;var Xl="PopperContent",[VS,qS]=bm(Xl),km=c.forwardRef((e,t)=>{const{__scopePopper:n,side:s="bottom",sideOffset:o=0,align:i="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:p=0,sticky:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:h="optimized",onPlaced:g,...y}=e,b=vm(Xl,n),[w,v]=c.useState(null),j=Pe(t,v),[_,k]=c.useState(null),S=T_(_),C=S?.width??0,M=S?.height??0,A=s+(i!=="center"?"-"+i:""),P=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},N=Array.isArray(d)?d:[d],I=N.length>0,F={padding:P,boundary:N.filter(WS),altBoundary:I},{refs:B,floatingStyles:J,placement:K,isPositioned:W,middlewareData:V}=PS({strategy:"fixed",placement:A,whileElementsMounted:(...je)=>wS(...je,{animationFrame:h==="always"}),elements:{reference:b.anchor},middleware:[MS({mainAxis:o+M,alignmentAxis:a}),u&&AS({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?OS():void 0,...F}),u&&zS({...F}),LS({...F,apply:({elements:je,rects:ke,availableWidth:ue,availableHeight:le})=>{const{width:xe,height:_e}=ke.reference,ve=je.floating.style;ve.setProperty("--radix-popper-available-width",`${ue}px`),ve.setProperty("--radix-popper-available-height",`${le}px`),ve.setProperty("--radix-popper-anchor-width",`${xe}px`),ve.setProperty("--radix-popper-anchor-height",`${_e}px`)}}),_&&DS({element:_,padding:l}),ZS({arrowWidth:C,arrowHeight:M}),m&&$S({strategy:"referenceHidden",...F,boundary:I?F.boundary:void 0})]}),z=b.setPlacementState;Je(()=>(z(K),()=>{z(void 0)}),[K,z]);const[X,Y]=Ql(K),we=et(g);Je(()=>{W&&we?.()},[W,we]);const he=V.arrow?.x,oe=V.arrow?.y,D=V.arrow?.centerOffset!==0,[Ne,te]=c.useState();return Je(()=>{w&&te(window.getComputedStyle(w).zIndex)},[w]),r.jsx("div",{ref:B.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:W?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ne,"--radix-popper-transform-origin":[V.transformOrigin?.x,V.transformOrigin?.y].join(" "),...V.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(VS,{scope:n,placedSide:X,placedAlign:Y,onArrowChange:k,arrowX:he,arrowY:oe,shouldHideArrow:D,children:r.jsx(ge.div,{"data-side":X,"data-align":Y,...y,ref:j,style:{...y.style,animation:W?void 0:"none"}})})})});km.displayName=Xl;var _m="PopperArrow",HS={top:"bottom",right:"left",bottom:"top",left:"right"},Sm=c.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,i=qS(_m,s),a=HS[i.placedSide];return r.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:r.jsx(US,{...o,ref:n,style:{...o.style,display:"block"}})})});Sm.displayName=_m;function WS(e){return e!==null}var ZS=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:s,middlewareData:o}=t,a=o.arrow?.centerOffset!==0,l=a?0:e.arrowWidth,u=a?0:e.arrowHeight,[d,p]=Ql(n),f={start:"0%",center:"50%",end:"100%"}[p],m=(o.arrow?.x??0)+l/2,h=(o.arrow?.y??0)+u/2;let g="",y="";return d==="bottom"?(g=a?f:`${m}px`,y=`${-u}px`):d==="top"?(g=a?f:`${m}px`,y=`${s.floating.height+u}px`):d==="right"?(g=`${-u}px`,y=a?f:`${h}px`):d==="left"&&(g=`${s.floating.width+u}px`,y=a?f:`${h}px`),{data:{x:g,y}}}});function Ql(e){const[t,n="center"]=e.split("-");return[t,n]}var Nm=ym,Cm=jm,Tm=km,Em=Sm,Ui=!1;function KS(){const[e,t]=c.useState(Ui);return c.useEffect(()=>{Ui||(Ui=!0,t(!0))},[]),e}var Rm=Bo[" useSyncExternalStore ".trim().toString()];function GS(){return()=>{}}function JS(){return Rm(GS,()=>!0,()=>!1)}var YS=typeof Rm=="function"?JS:KS,Bi="rovingFocusGroup.onEntryFocus",XS={bubbles:!1,cancelable:!0},br="RovingFocusGroup",[za,Pm,QS]=Tf(br),[eN,Im]=dn(br,[QS]),[tN,nN]=eN(br),Mm=c.forwardRef((e,t)=>r.jsx(za.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(za.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(sN,{...e,ref:t})})}));Mm.displayName=br;var sN=c.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:p=!1,...f}=e,m=c.useRef(null),h=Pe(t,m),g=Xo(i),[y,b]=qn({prop:a,defaultProp:l??null,onChange:u,caller:br}),[w,v]=c.useState(!1),j=et(d),_=Pm(n),k=c.useRef(!1),[S,C]=c.useState(0);return c.useEffect(()=>{const M=m.current;if(M)return M.addEventListener(Bi,j),()=>M.removeEventListener(Bi,j)},[j]),r.jsx(tN,{scope:n,orientation:s,dir:g,loop:o,currentTabStopId:y,onItemFocus:c.useCallback(M=>b(M),[b]),onItemShiftTab:c.useCallback(()=>v(!0),[]),onFocusableItemAdd:c.useCallback(()=>C(M=>M+1),[]),onFocusableItemRemove:c.useCallback(()=>C(M=>M-1),[]),children:r.jsx(ge.div,{tabIndex:w||S===0?-1:0,"data-orientation":s,...f,ref:h,style:{outline:"none",...e.style},onMouseDown:pe(e.onMouseDown,()=>{k.current=!0}),onFocus:pe(e.onFocus,M=>{const A=!k.current;if(M.target===M.currentTarget&&A&&!w){const P=new CustomEvent(Bi,XS);if(M.currentTarget.dispatchEvent(P),!P.defaultPrevented){const N=_().filter(K=>K.focusable),I=N.find(K=>K.active),F=N.find(K=>K.id===y),J=[I,F,...N].filter(Boolean).map(K=>K.ref.current);zm(J,p)}}k.current=!1}),onBlur:pe(e.onBlur,()=>v(!1))})})}),Am="RovingFocusGroupItem",Om=c.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:i,children:a,...l}=e,u=qt(),d=i||u,p=nN(Am,n),f=p.currentTabStopId===d,m=Pm(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:y}=p,b=YS();return Je(()=>{if(!(!b||!s))return h(),()=>g()},[b,s,h,g]),c.useEffect(()=>{if(!(b||!s))return h(),()=>g()},[b,s,h,g]),r.jsx(za.ItemSlot,{scope:n,id:d,focusable:s,active:o,children:r.jsx(ge.span,{tabIndex:f?0:-1,"data-orientation":p.orientation,...l,ref:t,onMouseDown:pe(e.onMouseDown,w=>{s?p.onItemFocus(d):w.preventDefault()}),onFocus:pe(e.onFocus,()=>p.onItemFocus(d)),onKeyDown:pe(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const v=iN(w,p.orientation,p.dir);if(v!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let _=m().filter(k=>k.focusable).map(k=>k.ref.current);if(v==="last")_.reverse();else if(v==="prev"||v==="next"){v==="prev"&&_.reverse();const k=_.indexOf(w.currentTarget);_=p.loop?aN(_,k+1):_.slice(k+1)}setTimeout(()=>zm(_))}}),children:typeof a=="function"?a({isCurrentTabStop:f,hasTabStop:y!=null}):a})})});Om.displayName=Am;var rN={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function oN(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function iN(e,t,n){const s=oN(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return rN[s]}function zm(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function aN(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var lN=Mm,cN=Om;function La(e,[t,n]){return Math.min(n,Math.max(t,e))}function uN(e,t){return c.useReducer((n,s)=>t[n][s]??n,e)}var ec="ScrollArea",[Lm]=dn(ec),[dN,St]=Lm(ec),$m=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:s="hover",dir:o,scrollHideDelay:i=600,...a}=e,[l,u]=c.useState(null),[d,p]=c.useState(null),[f,m]=c.useState(null),[h,g]=c.useState(null),[y,b]=c.useState(null),[w,v]=c.useState(0),[j,_]=c.useState(0),[k,S]=c.useState(!1),[C,M]=c.useState(!1),A=Pe(t,u),P=Xo(o);return r.jsx(dN,{scope:n,type:s,dir:P,scrollHideDelay:i,scrollArea:l,viewport:d,onViewportChange:p,content:f,onContentChange:m,scrollbarX:h,onScrollbarXChange:g,scrollbarXEnabled:k,onScrollbarXEnabledChange:S,scrollbarY:y,onScrollbarYChange:b,scrollbarYEnabled:C,onScrollbarYEnabledChange:M,onCornerWidthChange:v,onCornerHeightChange:_,children:r.jsx(ge.div,{dir:P,...a,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":j+"px",...e.style}})})});$m.displayName=ec;var Dm="ScrollAreaViewport",Fm=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:s,nonce:o,...i}=e,a=St(Dm,n),l=c.useRef(null),u=Pe(t,l,a.onViewportChange);return r.jsxs(r.Fragment,{children:[r.jsx(pN,{nonce:o}),r.jsx(ge.div,{"data-radix-scroll-area-viewport":"",...i,ref:u,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:r.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});Fm.displayName=Dm;var pN=c.memo(({nonce:e})=>r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:e}),(e,t)=>e.nonce===t.nonce),Yt="ScrollAreaScrollbar",Um=c.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=St(Yt,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:a}=o,l=e.orientation==="horizontal";return c.useEffect(()=>(l?i(!0):a(!0),()=>{l?i(!1):a(!1)}),[l,i,a]),o.type==="hover"?r.jsx(fN,{...s,ref:t,forceMount:n}):o.type==="scroll"?r.jsx(mN,{...s,ref:t,forceMount:n}):o.type==="auto"?r.jsx(Bm,{...s,ref:t,forceMount:n}):o.type==="always"?r.jsx(tc,{...s,ref:t,"data-state":"visible"}):null});Um.displayName=Yt;var fN=c.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=St(Yt,e.__scopeScrollArea),[i,a]=c.useState(!1);return c.useEffect(()=>{const l=o.scrollArea;let u=0;if(l){const d=()=>{window.clearTimeout(u),a(!0)},p=()=>{u=window.setTimeout(()=>a(!1),o.scrollHideDelay)};return l.addEventListener("pointerenter",d),l.addEventListener("pointerleave",p),()=>{window.clearTimeout(u),l.removeEventListener("pointerenter",d),l.removeEventListener("pointerleave",p)}}},[o.scrollArea,o.scrollHideDelay]),r.jsx(wt,{present:n||i,children:r.jsx(Bm,{"data-state":i?"visible":"hidden",...s,ref:t})})}),mN=c.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=St(Yt,e.__scopeScrollArea),i=e.orientation==="horizontal",a=ci(()=>u("SCROLL_END"),100),[l,u]=uN("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return c.useEffect(()=>{if(l==="idle"){const d=window.setTimeout(()=>u("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(d)}},[l,o.scrollHideDelay,u]),c.useEffect(()=>{const d=o.viewport,p=i?"scrollLeft":"scrollTop";if(d){let f=d[p];const m=()=>{const h=d[p];f!==h&&(u("SCROLL"),a()),f=h};return d.addEventListener("scroll",m),()=>d.removeEventListener("scroll",m)}},[o.viewport,i,u,a]),r.jsx(wt,{present:n||l!=="hidden",children:r.jsx(tc,{"data-state":l==="hidden"?"hidden":"visible",...s,ref:t,onPointerEnter:pe(e.onPointerEnter,()=>u("POINTER_ENTER")),onPointerLeave:pe(e.onPointerLeave,()=>u("POINTER_LEAVE"))})})}),Bm=c.forwardRef((e,t)=>{const n=St(Yt,e.__scopeScrollArea),{forceMount:s,...o}=e,[i,a]=c.useState(!1),l=e.orientation==="horizontal",u=ci(()=>{if(n.viewport){const d=n.viewport.offsetWidth<n.viewport.scrollWidth,p=n.viewport.offsetHeight<n.viewport.scrollHeight;a(l?d:p)}},10);return Rs(n.viewport,u),Rs(n.content,u),r.jsx(wt,{present:s||i,children:r.jsx(tc,{"data-state":i?"visible":"hidden",...o,ref:t})})}),tc=c.forwardRef((e,t)=>{const{orientation:n="vertical",...s}=e,o=St(Yt,e.__scopeScrollArea),i=c.useRef(null),a=c.useRef(0),[l,u]=c.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=Zm(l.viewport,l.content),p={...s,sizes:l,onSizesChange:u,hasThumb:d>0&&d<1,onThumbChange:m=>i.current=m,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:m=>a.current=m};function f(m,h){return yN(m,a.current,l,h)}return n==="horizontal"?r.jsx(hN,{...p,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const m=o.viewport.scrollLeft,h=Mu(m,l,o.dir);i.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=f(m,o.dir))}}):n==="vertical"?r.jsx(gN,{...p,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const m=o.viewport.scrollTop,h=Mu(m,l);i.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=f(m))}}):null}),hN=c.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,i=St(Yt,e.__scopeScrollArea),[a,l]=c.useState(),u=c.useRef(null),d=Pe(t,u,i.onScrollbarXChange);return c.useEffect(()=>{u.current&&l(getComputedStyle(u.current))},[u]),r.jsx(qm,{"data-orientation":"horizontal",...o,ref:d,sizes:n,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":li(n)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.x),onDragScroll:p=>e.onDragScroll(p.x),onWheelScroll:(p,f)=>{if(i.viewport){const m=i.viewport.scrollLeft+p.deltaX;e.onWheelScroll(m),Gm(m,f)&&p.preventDefault()}},onResize:()=>{u.current&&i.viewport&&a&&s({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:u.current.clientWidth,paddingStart:To(a.paddingLeft),paddingEnd:To(a.paddingRight)}})}})}),gN=c.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,i=St(Yt,e.__scopeScrollArea),[a,l]=c.useState(),u=c.useRef(null),d=Pe(t,u,i.onScrollbarYChange);return c.useEffect(()=>{u.current&&l(getComputedStyle(u.current))},[u]),r.jsx(qm,{"data-orientation":"vertical",...o,ref:d,sizes:n,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":li(n)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.y),onDragScroll:p=>e.onDragScroll(p.y),onWheelScroll:(p,f)=>{if(i.viewport){const m=i.viewport.scrollTop+p.deltaY;e.onWheelScroll(m),Gm(m,f)&&p.preventDefault()}},onResize:()=>{u.current&&i.viewport&&a&&s({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:u.current.clientHeight,paddingStart:To(a.paddingTop),paddingEnd:To(a.paddingBottom)}})}})}),[xN,Vm]=Lm(Yt),qm=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:s,hasThumb:o,onThumbChange:i,onThumbPointerUp:a,onThumbPointerDown:l,onThumbPositionChange:u,onDragScroll:d,onWheelScroll:p,onResize:f,...m}=e,h=St(Yt,n),[g,y]=c.useState(null),b=Pe(t,y),w=c.useRef(null),v=c.useRef(""),j=h.viewport,_=s.content-s.viewport,k=et(p),S=et(u),C=ci(f,10);function M(A){if(w.current){const P=A.clientX-w.current.left,N=A.clientY-w.current.top;d({x:P,y:N})}}return c.useEffect(()=>{const A=P=>{const N=P.target;g?.contains(N)&&k(P,_)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[j,g,_,k]),c.useEffect(S,[s,S]),Rs(g,C),Rs(h.content,C),r.jsx(xN,{scope:n,scrollbar:g,hasThumb:o,onThumbChange:et(i),onThumbPointerUp:et(a),onThumbPositionChange:S,onThumbPointerDown:et(l),children:r.jsx(ge.div,{...m,ref:b,style:{position:"absolute",...m.style},onPointerDown:pe(e.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),w.current=g.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),M(A))}),onPointerMove:pe(e.onPointerMove,M),onPointerUp:pe(e.onPointerUp,A=>{const P=A.target;P.hasPointerCapture(A.pointerId)&&P.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=v.current,h.viewport&&(h.viewport.style.scrollBehavior=""),w.current=null})})})}),Co="ScrollAreaThumb",Hm=c.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=Vm(Co,e.__scopeScrollArea);return r.jsx(wt,{present:n||o.hasThumb,children:r.jsx(bN,{ref:t,...s})})}),bN=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:s,...o}=e,i=St(Co,n),a=Vm(Co,n),{onThumbPositionChange:l}=a,u=Pe(t,a.onThumbChange),d=c.useRef(void 0),p=ci(()=>{d.current&&(d.current(),d.current=void 0)},100);return c.useEffect(()=>{const f=i.viewport;if(f){const m=()=>{if(p(),!d.current){const h=wN(f,l);d.current=h,l()}};return l(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[i.viewport,p,l]),r.jsx(ge.div,{"data-state":a.hasThumb?"visible":"hidden",...o,ref:u,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:pe(e.onPointerDownCapture,f=>{const h=f.target.getBoundingClientRect(),g=f.clientX-h.left,y=f.clientY-h.top;a.onThumbPointerDown({x:g,y})}),onPointerUp:pe(e.onPointerUp,a.onThumbPointerUp)})});Hm.displayName=Co;var nc="ScrollAreaCorner",Wm=c.forwardRef((e,t)=>{const n=St(nc,e.__scopeScrollArea),s=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&s?r.jsx(vN,{...e,ref:t}):null});Wm.displayName=nc;var vN=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,...s}=e,o=St(nc,n),[i,a]=c.useState(0),[l,u]=c.useState(0),d=!!(i&&l),{onCornerWidthChange:p,onCornerHeightChange:f}=o;return Rs(o.scrollbarX,()=>{const m=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(m),u(m)}),Rs(o.scrollbarY,()=>{const m=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(m),a(m)}),c.useEffect(()=>()=>{p(0),f(0)},[p,f]),d?r.jsx(ge.div,{...s,ref:t,style:{width:i,height:l,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function To(e){return e?parseInt(e,10):0}function Zm(e,t){const n=e/t;return isNaN(n)?0:n}function li(e){const t=Zm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=(e.scrollbar.size-n)*t;return Math.max(s,18)}function yN(e,t,n,s="ltr"){const o=li(n),i=o/2,a=t||i,l=o-a,u=n.scrollbar.paddingStart+a,d=n.scrollbar.size-n.scrollbar.paddingEnd-l,p=n.content-n.viewport,f=s==="ltr"?[0,p]:[p*-1,0];return Km([u,d],f)(e)}function Mu(e,t,n="ltr"){const s=li(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,a=t.content-t.viewport,l=i-s,u=n==="ltr"?[0,a]:[a*-1,0],d=La(e,u);return Km([0,a],[0,l])(d)}function Km(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const s=(t[1]-t[0])/(e[1]-e[0]);return t[0]+s*(n-e[0])}}function Gm(e,t){return e>0&&e<t}var wN=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},s=0;return(function o(){const i={left:e.scrollLeft,top:e.scrollTop},a=n.left!==i.left,l=n.top!==i.top;(a||l)&&t(),n=i,s=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(s)};function ci(e,t){const n=et(e),s=c.useRef(0);return c.useEffect(()=>()=>window.clearTimeout(s.current),[]),c.useCallback(()=>{window.clearTimeout(s.current),s.current=window.setTimeout(n,t)},[n,t])}function Rs(e,t){const n=et(t);Je(()=>{let s=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(s),s=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(s),o.unobserve(e)}}},[e,n])}var jN=$m,kN=Fm,_N=Wm,SN=[" ","Enter","ArrowUp","ArrowDown"],NN=[" ","Enter"],Wn="Select",[ui,di,CN]=Tf(Wn),[Qn]=dn(Wn,[CN,ai]),pi=ai(),[TN,En]=Qn(Wn),[EN,RN]=Qn(Wn),PN="SelectProvider";function Jm(e){const{__scopeSelect:t,children:n,open:s,defaultOpen:o,onOpenChange:i,value:a,defaultValue:l,onValueChange:u,dir:d,name:p,autoComplete:f,disabled:m,required:h,form:g,internal_do_not_use_render:y}=e,b=pi(t),[w,v]=c.useState(null),[j,_]=c.useState(null),[k,S]=c.useState(!1),C=Xo(d),[M,A]=qn({prop:s,defaultProp:o??!1,onChange:i,caller:Wn}),[P,N]=qn({prop:a,defaultProp:l,onChange:u,caller:Wn}),I=c.useRef(null),F=c.useRef(P);c.useEffect(()=>{const we=g?w?.ownerDocument.getElementById(g):w?.form;if(we instanceof HTMLFormElement){const he=()=>N(F.current);return we.addEventListener("reset",he),()=>we.removeEventListener("reset",he)}},[g,w,N]);const B=w?!!g||!!w.closest("form"):!0,[J,K]=c.useState(new Set),W=qt(),V=Array.from(J).map(we=>we.props.value).join(";"),z=c.useCallback(we=>{K(he=>new Set(he).add(we))},[]),X=c.useCallback(we=>{K(he=>{const oe=new Set(he);return oe.delete(we),oe})},[]),Y={required:h,trigger:w,onTriggerChange:v,valueNode:j,onValueNodeChange:_,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:W,value:P,onValueChange:N,open:M,onOpenChange:A,dir:C,triggerPointerDownPosRef:I,disabled:m,name:p,autoComplete:f,form:g,nativeOptions:J,nativeSelectKey:V,isFormControl:B};return r.jsx(Nm,{...b,children:r.jsx(TN,{scope:t,...Y,children:r.jsx(ui.Provider,{scope:t,children:r.jsx(EN,{scope:t,onNativeOptionAdd:z,onNativeOptionRemove:X,children:KN(y)?y(Y):n})})})})}Jm.displayName=PN;var Ym=e=>{const{__scopeSelect:t,children:n,...s}=e;return r.jsx(Jm,{__scopeSelect:t,...s,internal_do_not_use_render:({isFormControl:o})=>r.jsxs(r.Fragment,{children:[n,o?r.jsx(kh,{__scopeSelect:t}):null]})})};Ym.displayName=Wn;var Xm="SelectTrigger",Qm=c.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...o}=e,i=pi(n),a=En(Xm,n),l=a.disabled||s,u=Pe(t,a.onTriggerChange),d=di(n),p=c.useRef("touch"),[f,m,h]=_h(y=>{const b=d().filter(j=>!j.disabled),w=b.find(j=>j.value===a.value),v=Sh(b,y,w);v!==void 0&&a.onValueChange(v.value)}),g=y=>{l||(a.onOpenChange(!0),h()),y&&(a.triggerPointerDownPosRef.current={x:Math.round(y.pageX),y:Math.round(y.pageY)})};return r.jsx(Cm,{asChild:!0,...i,children:r.jsx(ge.button,{type:"button",role:"combobox","aria-controls":a.open?a.contentId:void 0,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":fi(a.value)?"":void 0,...o,ref:u,onClick:pe(o.onClick,y=>{y.currentTarget.focus(),p.current!=="mouse"&&g(y)}),onPointerDown:pe(o.onPointerDown,y=>{p.current=y.pointerType;const b=y.target;b.hasPointerCapture(y.pointerId)&&b.releasePointerCapture(y.pointerId),y.button===0&&y.ctrlKey===!1&&y.pointerType==="mouse"&&(g(y),y.preventDefault())}),onKeyDown:pe(o.onKeyDown,y=>{const b=f.current!=="";!(y.ctrlKey||y.altKey||y.metaKey)&&y.key.length===1&&m(y.key),!(b&&y.key===" ")&&SN.includes(y.key)&&(g(),y.preventDefault())})})})});Qm.displayName=Xm;var eh="SelectValue",th=c.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,children:i,placeholder:a="",...l}=e,u=En(eh,n),{onValueNodeHasChildrenChange:d}=u,p=i!==void 0,f=Pe(t,u.onValueNodeChange);Je(()=>{d(p)},[d,p]);const m=fi(u.value);return r.jsx(ge.span,{...l,asChild:m?!1:l.asChild,ref:f,style:{pointerEvents:"none"},children:r.jsx(c.Fragment,{children:m?a:i},m?"placeholder":"value")})});th.displayName=eh;var IN="SelectIcon",nh=c.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...o}=e;return r.jsx(ge.span,{"aria-hidden":!0,...o,ref:t,children:s||"▼"})});nh.displayName=IN;var sh="SelectPortal",[MN,AN]=Qn(sh,{forceMount:void 0}),rh=e=>{const{__scopeSelect:t,forceMount:n,...s}=e;return r.jsx(MN,{scope:e.__scopeSelect,forceMount:n,children:r.jsx(ei,{asChild:!0,...s})})};rh.displayName=sh;var Sn="SelectContent",oh=c.forwardRef((e,t)=>{const n=AN(Sn,e.__scopeSelect),{forceMount:s=n.forceMount,...o}=e,i=En(Sn,e.__scopeSelect),[a,l]=c.useState();return Je(()=>{l(new DocumentFragment)},[]),r.jsx(wt,{present:s||i.open,children:({present:u})=>u?r.jsx(lh,{...o,ref:t}):r.jsx(ih,{...o,fragment:a})})});oh.displayName=Sn;var ih=c.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,fragment:o}=e;return o?Os.createPortal(r.jsx(ah,{scope:n,children:r.jsx(ui.Slot,{scope:n,children:r.jsx("div",{ref:t,children:s})})}),o):null});ih.displayName="SelectContentFragment";var Rt=10,[ah,Rn]=Qn(Sn),ON="SelectContentImpl",zN=Cs("SelectContent.RemoveScroll"),lh=c.forwardRef((e,t)=>{const{__scopeSelect:n}=e,{position:s="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:a,side:l,sideOffset:u,align:d,alignOffset:p,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:g,hideWhenDetached:y,avoidCollisions:b,...w}=e,v=En(Sn,n),[j,_]=c.useState(null),[k,S]=c.useState(null),C=Pe(t,_),[M,A]=c.useState(null),[P,N]=c.useState(null),I=di(n),[F,B]=c.useState(!1),J=c.useRef(!1);c.useEffect(()=>{if(j)return qf(j)},[j]),Of();const K=c.useCallback(te=>{const[je,...ke]=I().map(xe=>xe.ref.current),[ue]=ke.slice(-1),le=document.activeElement;for(const xe of te)if(xe===le||(xe?.scrollIntoView({block:"nearest"}),xe===je&&k&&(k.scrollTop=0),xe===ue&&k&&(k.scrollTop=k.scrollHeight),xe?.focus(),document.activeElement!==le))return},[I,k]),W=c.useCallback(()=>K([M,j]),[K,M,j]);c.useEffect(()=>{F&&W()},[F,W]);const{onOpenChange:V,triggerPointerDownPosRef:z}=v;c.useEffect(()=>{if(j){let te={x:0,y:0};const je=ue=>{te={x:Math.abs(Math.round(ue.pageX)-(z.current?.x??0)),y:Math.abs(Math.round(ue.pageY)-(z.current?.y??0))}},ke=ue=>{te.x<=10&&te.y<=10?ue.preventDefault():ue.composedPath().includes(j)||V(!1),document.removeEventListener("pointermove",je),z.current=null};return z.current!==null&&(document.addEventListener("pointermove",je),document.addEventListener("pointerup",ke,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",je),document.removeEventListener("pointerup",ke,{capture:!0})}}},[j,V,z]),c.useEffect(()=>{const te=()=>V(!1);return window.addEventListener("blur",te),window.addEventListener("resize",te),()=>{window.removeEventListener("blur",te),window.removeEventListener("resize",te)}},[V]);const[X,Y]=_h(te=>{const je=I().filter(le=>!le.disabled),ke=je.find(le=>le.ref.current===document.activeElement),ue=Sh(je,te,ke);ue&&setTimeout(()=>ue.ref.current?.focus())}),we=c.useCallback((te,je,ke)=>{const ue=!J.current&&!ke;(v.value!==void 0&&v.value===je||ue)&&(A(te),ue&&(J.current=!0))},[v.value]),he=c.useCallback(()=>j?.focus(),[j]),oe=c.useCallback((te,je,ke)=>{const ue=!J.current&&!ke;(v.value!==void 0&&v.value===je||ue)&&N(te)},[v.value]),D=s==="popper"?$a:ch,Ne=D===$a?{side:l,sideOffset:u,align:d,alignOffset:p,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:g,hideWhenDetached:y,avoidCollisions:b}:{};return r.jsx(ah,{scope:n,content:j,viewport:k,onViewportChange:S,itemRefCallback:we,selectedItem:M,onItemLeave:he,itemTextRefCallback:oe,focusSelectedItem:W,selectedItemText:P,position:s,isPositioned:F,searchRef:X,children:r.jsx(Bl,{as:zN,allowPinchZoom:!0,children:r.jsx(Ul,{asChild:!0,trapped:v.open,onMountAutoFocus:te=>{te.preventDefault()},onUnmountAutoFocus:pe(o,te=>{v.trigger?.focus({preventScroll:!0}),te.preventDefault()}),children:r.jsx(Qo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:te=>te.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:r.jsx(D,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:te=>te.preventDefault(),...w,...Ne,onPlaced:()=>B(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:pe(w.onKeyDown,te=>{const je=te.ctrlKey||te.altKey||te.metaKey;if(te.key==="Tab"&&te.preventDefault(),!je&&te.key.length===1&&Y(te.key),["ArrowUp","ArrowDown","Home","End"].includes(te.key)){let ue=I().filter(le=>!le.disabled).map(le=>le.ref.current);if(["ArrowUp","End"].includes(te.key)&&(ue=ue.slice().reverse()),["ArrowUp","ArrowDown"].includes(te.key)){const le=te.target,xe=ue.indexOf(le);ue=ue.slice(xe+1)}setTimeout(()=>K(ue)),te.preventDefault()}})})})})})})});lh.displayName=ON;var LN="SelectItemAlignedPosition",ch=c.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...o}=e,i=En(Sn,n),a=Rn(Sn,n),[l,u]=c.useState(null),[d,p]=c.useState(null),f=Pe(t,p),m=di(n),h=c.useRef(!1),g=c.useRef(!0),{viewport:y,selectedItem:b,selectedItemText:w,focusSelectedItem:v}=a,j=c.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&d&&y&&b&&w){const C=i.trigger.getBoundingClientRect(),M=d.getBoundingClientRect(),A=i.valueNode.getBoundingClientRect(),P=w.getBoundingClientRect();if(i.dir!=="rtl"){const le=P.left-M.left,xe=A.left-le,_e=C.left-xe,ve=C.width+_e,Ze=Math.max(ve,M.width),Be=window.innerWidth-Rt,Ke=La(xe,[Rt,Math.max(Rt,Be-Ze)]);l.style.minWidth=ve+"px",l.style.left=Ke+"px"}else{const le=M.right-P.right,xe=window.innerWidth-A.right-le,_e=window.innerWidth-C.right-xe,ve=C.width+_e,Ze=Math.max(ve,M.width),Be=window.innerWidth-Rt,Ke=La(xe,[Rt,Math.max(Rt,Be-Ze)]);l.style.minWidth=ve+"px",l.style.right=Ke+"px"}const N=m(),I=window.innerHeight-Rt*2,F=y.scrollHeight,B=window.getComputedStyle(d),J=parseInt(B.borderTopWidth,10),K=parseInt(B.paddingTop,10),W=parseInt(B.borderBottomWidth,10),V=parseInt(B.paddingBottom,10),z=J+K+F+V+W,X=Math.min(b.offsetHeight*5,z),Y=window.getComputedStyle(y),we=parseInt(Y.paddingTop,10),he=parseInt(Y.paddingBottom,10),oe=C.top+C.height/2-Rt,D=I-oe,Ne=b.offsetHeight/2,te=b.offsetTop+Ne,je=J+K+te,ke=z-je;if(je<=oe){const le=N.length>0&&b===N[N.length-1].ref.current;l.style.bottom="0px";const xe=d.clientHeight-y.offsetTop-y.offsetHeight,_e=Math.max(D,Ne+(le?he:0)+xe+W),ve=je+_e;l.style.height=ve+"px"}else{const le=N.length>0&&b===N[0].ref.current;l.style.top="0px";const _e=Math.max(oe,J+y.offsetTop+(le?we:0)+Ne)+ke;l.style.height=_e+"px",y.scrollTop=je-oe+y.offsetTop}l.style.margin=`${Rt}px 0`,l.style.minHeight=X+"px",l.style.maxHeight=I+"px",s?.(),requestAnimationFrame(()=>h.current=!0)}},[m,i.trigger,i.valueNode,l,d,y,b,w,i.dir,s]);Je(()=>j(),[j]);const[_,k]=c.useState();Je(()=>{d&&k(window.getComputedStyle(d).zIndex)},[d]);const S=c.useCallback(C=>{C&&g.current===!0&&(j(),v?.(),g.current=!1)},[j,v]);return r.jsx(DN,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:h,onScrollButtonChange:S,children:r.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:_},children:r.jsx(ge.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});ch.displayName=LN;var $N="SelectPopperPosition",$a=c.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:o=Rt,...i}=e,a=pi(n);return r.jsx(Tm,{...a,...i,ref:t,align:s,collisionPadding:o,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});$a.displayName=$N;var[DN,sc]=Qn(Sn,{}),Da="SelectViewport",uh=c.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...o}=e,i=Rn(Da,n),a=sc(Da,n),l=Pe(t,i.onViewportChange),u=c.useRef(0);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),r.jsx(ui.Slot,{scope:n,children:r.jsx(ge.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:pe(o.onScroll,d=>{const p=d.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=a;if(m?.current&&f){const h=Math.abs(u.current-p.scrollTop);if(h>0){const g=window.innerHeight-Rt*2,y=parseFloat(f.style.minHeight),b=parseFloat(f.style.height),w=Math.max(y,b);if(w<g){const v=w+h,j=Math.min(g,v),_=v-j;f.style.height=j+"px",f.style.bottom==="0px"&&(p.scrollTop=_>0?_:0,f.style.justifyContent="flex-end")}}}u.current=p.scrollTop})})})]})});uh.displayName=Da;var dh="SelectGroup",[FN,UN]=Qn(dh),BN=c.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=qt();return r.jsx(FN,{scope:n,id:o,children:r.jsx(ge.div,{role:"group","aria-labelledby":o,...s,ref:t})})});BN.displayName=dh;var ph="SelectLabel",VN=c.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=UN(ph,n);return r.jsx(ge.div,{id:o.id,...s,ref:t})});VN.displayName=ph;var Eo="SelectItem",[qN,fh]=Qn(Eo),mh=c.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:o=!1,textValue:i,...a}=e,l=En(Eo,n),u=Rn(Eo,n),d=l.value===s,[p,f]=c.useState(i??""),[m,h]=c.useState(!1),g=et(j=>u.itemRefCallback?.(j,s,o)),y=Pe(t,g),b=qt(),w=c.useRef("touch"),v=()=>{o||(l.onValueChange(s),l.onOpenChange(!1))};return r.jsx(qN,{scope:n,value:s,disabled:o,textId:b,isSelected:d,onItemTextChange:c.useCallback(j=>{f(_=>_||(j?.textContent??"").trim())},[]),children:r.jsx(ui.ItemSlot,{scope:n,value:s,disabled:o,textValue:p,children:r.jsx(ge.div,{role:"option","aria-labelledby":b,"data-highlighted":m?"":void 0,"aria-selected":d&&m,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:y,onFocus:pe(a.onFocus,()=>h(!0)),onBlur:pe(a.onBlur,()=>h(!1)),onClick:pe(a.onClick,()=>{w.current!=="mouse"&&v()}),onPointerUp:pe(a.onPointerUp,()=>{w.current==="mouse"&&v()}),onPointerDown:pe(a.onPointerDown,j=>{w.current=j.pointerType}),onPointerMove:pe(a.onPointerMove,j=>{w.current=j.pointerType,o?u.onItemLeave?.():w.current==="mouse"&&j.currentTarget.focus({preventScroll:!0})}),onPointerLeave:pe(a.onPointerLeave,j=>{j.currentTarget===document.activeElement&&u.onItemLeave?.()}),onKeyDown:pe(a.onKeyDown,j=>{o||j.target!==j.currentTarget||u.searchRef?.current!==""&&j.key===" "||(NN.includes(j.key)&&v(),j.key===" "&&j.preventDefault())})})})})});mh.displayName=Eo;var Js="SelectItemText",hh=c.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,...i}=e,a=En(Js,n),l=Rn(Js,n),u=fh(Js,n),d=RN(Js,n),[p,f]=c.useState(null),m=et(v=>l.itemTextRefCallback?.(v,u.value,u.disabled)),h=Pe(t,f,u.onItemTextChange,m),g=p?.textContent,y=c.useMemo(()=>r.jsx("option",{value:u.value,disabled:u.disabled,children:g},u.value),[u.disabled,u.value,g]),{onNativeOptionAdd:b,onNativeOptionRemove:w}=d;return Je(()=>(b(y),()=>w(y)),[b,w,y]),r.jsxs(r.Fragment,{children:[r.jsx(ge.span,{id:u.textId,...i,ref:h}),u.isSelected&&a.valueNode&&!a.valueNodeHasChildren&&!fi(a.value)?Os.createPortal(i.children,a.valueNode):null]})});hh.displayName=Js;var gh="SelectItemIndicator",xh=c.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return fh(gh,n).isSelected?r.jsx(ge.span,{"aria-hidden":!0,...s,ref:t}):null});xh.displayName=gh;var Fa="SelectScrollUpButton",bh=c.forwardRef((e,t)=>{const n=Rn(Fa,e.__scopeSelect),s=sc(Fa,e.__scopeSelect),[o,i]=c.useState(!1),a=Pe(t,s.onScrollButtonChange);return Je(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollTop>0;i(d)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?r.jsx(yh,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});bh.displayName=Fa;var Ua="SelectScrollDownButton",vh=c.forwardRef((e,t)=>{const n=Rn(Ua,e.__scopeSelect),s=sc(Ua,e.__scopeSelect),[o,i]=c.useState(!1),a=Pe(t,s.onScrollButtonChange);return Je(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollHeight-u.clientHeight,p=Math.ceil(u.scrollTop)<d;i(p)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?r.jsx(yh,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});vh.displayName=Ua;var yh=c.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...o}=e,i=Rn("SelectScrollButton",n),a=c.useRef(null),l=di(n),u=c.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return c.useEffect(()=>()=>u(),[u]),Je(()=>{l().find(p=>p.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),r.jsx(ge.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:pe(o.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(s,50))}),onPointerMove:pe(o.onPointerMove,()=>{i.onItemLeave?.(),a.current===null&&(a.current=window.setInterval(s,50))}),onPointerLeave:pe(o.onPointerLeave,()=>{u()})})}),HN="SelectSeparator",WN=c.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(ge.div,{"aria-hidden":!0,...s,ref:t})});WN.displayName=HN;var wh="SelectArrow",ZN=c.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=pi(n);return Rn(wh,n).position==="popper"?r.jsx(Em,{...o,...s,ref:t}):null});ZN.displayName=wh;var jh="SelectBubbleInput",kh=c.forwardRef(({__scopeSelect:e,...t},n)=>{const s=En(jh,e),{value:o,onValueChange:i,required:a,disabled:l,name:u,autoComplete:d,form:p}=s,{nativeOptions:f,nativeSelectKey:m}=s,h=c.useRef(null),g=Pe(n,h),y=o??"",b=C_(y),w=Array.from(f).some(v=>(v.props.value??"")==="");return c.useEffect(()=>{const v=h.current;if(!v)return;const j=window.HTMLSelectElement.prototype,k=Object.getOwnPropertyDescriptor(j,"value").set;if(b!==y&&k){const S=new Event("change",{bubbles:!0});k.call(v,y),v.dispatchEvent(S)}},[b,y]),r.jsxs(ge.select,{"aria-hidden":!0,required:a,tabIndex:-1,name:u,autoComplete:d,disabled:l,form:p,onChange:v=>i(v.target.value),...t,style:{...Nf,...t.style},ref:g,defaultValue:y,children:[fi(o)&&!w?r.jsx("option",{value:""}):null,Array.from(f)]},m)});kh.displayName=jh;function KN(e){return typeof e=="function"}function fi(e){return e===""||e===void 0}function _h(e){const t=et(e),n=c.useRef(""),s=c.useRef(0),o=c.useCallback(a=>{const l=n.current+a;t(l),(function u(d){n.current=d,window.clearTimeout(s.current),d!==""&&(s.current=window.setTimeout(()=>u(""),1e3))})(l)},[t]),i=c.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return c.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,o,i]}function Sh(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let a=GN(e,Math.max(i,0));o.length===1&&(a=a.filter(d=>d!==n));const u=a.find(d=>d.textValue.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}function GN(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var mi="Tabs",[JN]=dn(mi,[Im]),Nh=Im(),[YN,rc]=JN(mi),Ch=c.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:i,orientation:a="horizontal",dir:l,activationMode:u="automatic",...d}=e,p=Xo(l),[f,m]=qn({prop:s,onChange:o,defaultProp:i??"",caller:mi});return r.jsx(YN,{scope:n,baseId:qt(),value:f,onValueChange:m,orientation:a,dir:p,activationMode:u,children:r.jsx(ge.div,{dir:p,"data-orientation":a,...d,ref:t})})});Ch.displayName=mi;var Th="TabsList",Eh=c.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,i=rc(Th,n),a=Nh(n);return r.jsx(lN,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:s,children:r.jsx(ge.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});Eh.displayName=Th;var Rh="TabsTrigger",Ph=c.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...i}=e,a=rc(Rh,n),l=Nh(n),u=Ah(a.baseId,s),d=Oh(a.baseId,s),p=s===a.value;return r.jsx(cN,{asChild:!0,...l,focusable:!o,active:p,children:r.jsx(ge.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":d,"data-state":p?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...i,ref:t,onMouseDown:pe(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?a.onValueChange(s):f.preventDefault()}),onKeyDown:pe(e.onKeyDown,f=>{o||f.target!==f.currentTarget||[" ","Enter"].includes(f.key)&&a.onValueChange(s)}),onFocus:pe(e.onFocus,()=>{const f=a.activationMode!=="manual";!p&&!o&&f&&a.onValueChange(s)})})})});Ph.displayName=Rh;var Ih="TabsContent",Mh=c.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:i,...a}=e,l=rc(Ih,n),u=Ah(l.baseId,s),d=Oh(l.baseId,s),p=s===l.value,f=c.useRef(p);return c.useEffect(()=>{const m=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(m)},[]),r.jsx(wt,{present:o||p,children:({present:m})=>r.jsx(ge.div,{"data-state":p?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":u,hidden:!m,id:d,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:m&&i})})});Mh.displayName=Ih;function Ah(e,t){return`${e}-trigger-${t}`}function Oh(e,t){return`${e}-content-${t}`}var XN=Ch,QN=Eh,eC=Ph,tC=Mh,[hi]=dn("Tooltip",[ai]),gi=ai(),zh="TooltipProvider",nC=700,Ba="tooltip.open",[sC,oc]=hi(zh),Lh=e=>{const{__scopeTooltip:t,delayDuration:n=nC,skipDelayDuration:s=300,disableHoverableContent:o=!1,children:i}=e,a=c.useRef(!0),l=c.useRef(!1),u=c.useRef(0);return c.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),r.jsx(sC,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:c.useCallback(()=>{s<=0||(window.clearTimeout(u.current),a.current=!1)},[s]),onClose:c.useCallback(()=>{s<=0||(window.clearTimeout(u.current),u.current=window.setTimeout(()=>a.current=!0,s))},[s]),isPointerInTransitRef:l,onPointerInTransitChange:c.useCallback(d=>{l.current=d},[]),disableHoverableContent:o,children:i})};Lh.displayName=zh;var ir="Tooltip",[rC,vr]=hi(ir),$h=e=>{const{__scopeTooltip:t,children:n,open:s,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:l}=e,u=oc(ir,e.__scopeTooltip),d=gi(t),[p,f]=c.useState(null),m=qt(),h=c.useRef(0),g=a??u.disableHoverableContent,y=l??u.delayDuration,b=c.useRef(!1),[w,v]=qn({prop:s,defaultProp:o??!1,onChange:C=>{C?(u.onOpen(),document.dispatchEvent(new CustomEvent(Ba))):u.onClose(),i?.(C)},caller:ir}),j=c.useMemo(()=>w?b.current?"delayed-open":"instant-open":"closed",[w]),_=c.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b.current=!1,v(!0)},[v]),k=c.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v(!1)},[v]),S=c.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{b.current=!0,v(!0),h.current=0},y)},[y,v]);return c.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),r.jsx(Nm,{...d,children:r.jsx(rC,{scope:t,contentId:m,open:w,stateAttribute:j,trigger:p,onTriggerChange:f,onTriggerEnter:c.useCallback(()=>{u.isOpenDelayedRef.current?S():_()},[u.isOpenDelayedRef,S,_]),onTriggerLeave:c.useCallback(()=>{g?k():(window.clearTimeout(h.current),h.current=0)},[k,g]),onOpen:_,onClose:k,disableHoverableContent:g,children:n})})};$h.displayName=ir;var Va="TooltipTrigger",Dh=c.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,o=vr(Va,n),i=oc(Va,n),a=gi(n),l=c.useRef(null),u=Pe(t,l,o.onTriggerChange),d=c.useRef(!1),p=c.useRef(!1),f=c.useCallback(()=>d.current=!1,[]);return c.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),r.jsx(Cm,{asChild:!0,...a,children:r.jsx(ge.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...s,ref:u,onPointerMove:pe(e.onPointerMove,m=>{m.pointerType!=="touch"&&!p.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:pe(e.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:pe(e.onPointerDown,()=>{o.open&&o.onClose(),d.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:pe(e.onFocus,()=>{d.current||o.onOpen()}),onBlur:pe(e.onBlur,o.onClose),onClick:pe(e.onClick,o.onClose)})})});Dh.displayName=Va;var ic="TooltipPortal",[oC,iC]=hi(ic,{forceMount:void 0}),Fh=e=>{const{__scopeTooltip:t,forceMount:n,children:s,container:o}=e,i=vr(ic,t);return r.jsx(oC,{scope:t,forceMount:n,children:r.jsx(wt,{present:n||i.open,children:r.jsx(ei,{asChild:!0,container:o,children:s})})})};Fh.displayName=ic;var Ps="TooltipContent",Uh=c.forwardRef((e,t)=>{const n=iC(Ps,e.__scopeTooltip),{forceMount:s=n.forceMount,side:o="top",...i}=e,a=vr(Ps,e.__scopeTooltip);return r.jsx(wt,{present:s||a.open,children:a.disableHoverableContent?r.jsx(Bh,{side:o,...i,ref:t}):r.jsx(aC,{side:o,...i,ref:t})})}),aC=c.forwardRef((e,t)=>{const n=vr(Ps,e.__scopeTooltip),s=oc(Ps,e.__scopeTooltip),o=c.useRef(null),i=Pe(t,o),[a,l]=c.useState(null),{trigger:u,onClose:d}=n,p=o.current,{onPointerInTransitChange:f}=s,m=c.useCallback(()=>{l(null),f(!1)},[f]),h=c.useCallback((g,y)=>{const b=g.currentTarget,w={x:g.clientX,y:g.clientY},v=dC(w,b.getBoundingClientRect()),j=pC(w,v),_=fC(y.getBoundingClientRect()),k=hC([...j,..._]);l(k),f(!0)},[f]);return c.useEffect(()=>()=>m(),[m]),c.useEffect(()=>{if(u&&p){const g=b=>h(b,p),y=b=>h(b,u);return u.addEventListener("pointerleave",g),p.addEventListener("pointerleave",y),()=>{u.removeEventListener("pointerleave",g),p.removeEventListener("pointerleave",y)}}},[u,p,h,m]),c.useEffect(()=>{if(a){const g=y=>{const b=y.target,w={x:y.clientX,y:y.clientY},v=u?.contains(b)||p?.contains(b),j=!mC(w,a);v?m():j&&(m(),d())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[u,p,a,d,m]),r.jsx(Bh,{...e,ref:i})}),[lC,cC]=hi(ir,{isInside:!1}),uC=H5("TooltipContent"),Bh=c.forwardRef((e,t)=>{const{__scopeTooltip:n,children:s,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...l}=e,u=vr(Ps,n),d=gi(n),{onClose:p}=u;return c.useEffect(()=>(document.addEventListener(Ba,p),()=>document.removeEventListener(Ba,p)),[p]),c.useEffect(()=>{if(u.trigger){const f=m=>{m.target instanceof Node&&m.target.contains(u.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[u.trigger,p]),r.jsx(Qo,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:r.jsxs(Tm,{"data-state":u.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[r.jsx(uC,{children:s}),r.jsx(lC,{scope:n,isInside:!0,children:r.jsx(sk,{id:u.contentId,role:"tooltip",children:o||s})})]})})});Uh.displayName=Ps;var Vh="TooltipArrow",qh=c.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,o=gi(n);return cC(Vh,n).isInside?null:r.jsx(Em,{...o,...s,ref:t})});qh.displayName=Vh;function dC(e,t){const n=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,s,o,i)){case i:return"left";case o:return"right";case n:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function pC(e,t,n=5){const s=[];switch(t){case"top":s.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":s.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":s.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":s.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return s}function fC(e){const{top:t,right:n,bottom:s,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:s},{x:o,y:s}]}function mC(e,t){const{x:n,y:s}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const l=t[i],u=t[a],d=l.x,p=l.y,f=u.x,m=u.y;p>s!=m>s&&n<(f-d)*(s-p)/(m-p)+d&&(o=!o)}return o}function hC(e){const t=e.slice();return t.sort((n,s)=>n.x<s.x?-1:n.x>s.x?1:n.y<s.y?-1:n.y>s.y?1:0),gC(t)}function gC(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const o=e[s];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let s=e.length-1;s>=0;s--){const o=e[s];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var xC=Lh,bC=$h,vC=Dh,yC=Fh,wC=Uh,jC=qh;function Zt({...e}){return r.jsx(Wf,{"data-slot":"dialog",...e})}function yr({...e}){return r.jsx(Kf,{"data-slot":"dialog-trigger",...e})}function kC({...e}){return r.jsx(Jf,{"data-slot":"dialog-portal",...e})}function _C({className:e,...t}){return r.jsx(Yf,{"data-slot":"dialog-overlay",className:$("fixed inset-0 z-40 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t})}function Kt({className:e,children:t,...n}){return r.jsxs(kC,{children:[r.jsx(_C,{}),r.jsxs(Xf,{"data-slot":"dialog-content",className:$("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",e),...n,children:[t,r.jsxs(om,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[r.jsx(gr,{className:"size-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Xt({className:e,...t}){return r.jsx("div",{"data-slot":"dialog-header",className:$("flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function Qt({className:e,...t}){return r.jsx(tm,{"data-slot":"dialog-title",className:$("text-lg font-semibold leading-none tracking-tight",e),...t})}function wr({className:e,...t}){return r.jsx(sm,{"data-slot":"dialog-description",className:$("text-sm text-muted-foreground",e),...t})}function Hh({open:e,onOpenChange:t,title:n,description:s,confirmLabel:o="Confirm",variant:i="default",onConfirm:a}){return r.jsx(Zt,{open:e,onOpenChange:t,children:r.jsxs(Kt,{children:[r.jsx(Xt,{children:r.jsx(Qt,{children:n})}),r.jsx("p",{className:"text-sm text-muted-foreground",children:s}),r.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[r.jsx(ee,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),r.jsx(ee,{variant:i,size:"sm",onClick:()=>{a(),t(!1)},children:o})]})]})})}const SC="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eClaude%20Code%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M20.998%2010.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6%2010.949h1.488V8.102H6v2.847zm10.51%200H18V8.102h-1.49v2.847z'%20fill='%23D97757'%20fill-rule='evenodd'%3e%3c/path%3e%3c/svg%3e",NC="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20d='M19.503%200H4.496A4.496%204.496%200%20000%204.496v15.007A4.496%204.496%200%20004.496%2024h15.007A4.496%204.496%200%200024%2019.503V4.496A4.496%204.496%200%200019.503%200z'%20fill='%23fff'%3e%3c/path%3e%3cpath%20d='M9.064%203.344a4.578%204.578%200%20012.285-.312c1%20.115%201.891.54%202.673%201.275.01.01.024.017.037.021a.09.09%200%2000.043%200%204.55%204.55%200%20013.046.275l.047.022.116.057a4.581%204.581%200%20012.188%202.399c.209.51.313%201.041.315%201.595a4.24%204.24%200%2001-.134%201.223.123.123%200%2000.03.115c.594.607.988%201.33%201.183%202.17.289%201.425-.007%202.71-.887%203.854l-.136.166a4.548%204.548%200%2001-2.201%201.388.123.123%200%2000-.081.076c-.191.551-.383%201.023-.74%201.494-.9%201.187-2.222%201.846-3.711%201.838-1.187-.006-2.239-.44-3.157-1.302a.107.107%200%2000-.105-.024c-.388.125-.78.143-1.204.138a4.441%204.441%200%2001-1.945-.466%204.544%204.544%200%2001-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81%205.81%200%2001-.37-.961%204.582%204.582%200%2001-.014-2.298.124.124%200%2000.006-.056.085.085%200%2000-.027-.048%204.467%204.467%200%2001-1.034-1.651%203.896%203.896%200%2001-.251-1.192%205.189%205.189%200%2001.141-1.6c.337-1.112.982-1.985%201.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098%200%2000.065-.066%204.51%204.51%200%2001.829-1.615%204.535%204.535%200%20011.837-1.388zm3.482%2010.565a.637.637%200%20000%201.272h3.636a.637.637%200%20100-1.272h-3.636zM8.462%209.23a.637.637%200%2000-1.106.631l1.272%202.224-1.266%202.136a.636.636%200%20101.095.649l1.454-2.455a.636.636%200%2000.005-.64L8.462%209.23z'%20fill='url(%23lobe-icons-codex-_R_0_)'%3e%3c/path%3e%3cdefs%3e%3clinearGradient%20gradientUnits='userSpaceOnUse'%20id='lobe-icons-codex-_R_0_'%20x1='12'%20x2='12'%20y1='3'%20y2='21'%3e%3cstop%20stop-color='%23B1A7FF'%3e%3c/stop%3e%3cstop%20offset='.5'%20stop-color='%237A9DFF'%3e%3c/stop%3e%3cstop%20offset='1'%20stop-color='%233941FF'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",CC="data:image/svg+xml,%3csvg%20fill='%237dd3fc'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eOpenCode%3c/title%3e%3cpath%20d='M16%206H8v12h8V6zm4%2016H4V2h16v20z'%3e%3c/path%3e%3c/svg%3e",TC="data:image/svg+xml,%3csvg%20fill='%23ff6900'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eMiMo%20Code%3c/title%3e%3cpath%20d='M.958%2015.936a.459.459%200%2001.459.44v2.729a.46.46%200%2001-.918%200v-2.729a.459.459%200%2001.459-.44zm4.814-2.035a.46.46%200%2001.553.45v4.754a.458.458%200%2011-.918%200V15.48L3.74%2017.202a.462.462%200%2001-.655.016.462.462%200%2001-.065-.082L.628%2014.67a.459.459%200%2001.658-.637l2.124%202.187%202.127-2.188a.46.46%200%2001.235-.13zm2.068.004a.46.46%200%2001.458.445v4.755a.46.46%200%2001-.458.458.459.459%200%2001-.458-.458V14.35a.459.459%200%2001.458-.445zm1.973%202.014a.46.46%200%2001.46.457v2.729a.46.46%200%2001-.784.324.46.46%200%2001-.134-.324v-2.729a.46.46%200%2001.458-.458zm.002-2.045a.458.458%200%2001.328.157l2.127%202.19%202.125-2.19a.459.459%200%2001.784.318v4.756a.46.46%200%2001-.455.458.46.46%200%2001-.458-.458V15.48l-1.667%201.723a.46.46%200%2001-.65.008l-.005-.005c0-.002-.002-.002-.004-.003l-2.455-2.534a.46.46%200%2001-.008-.667.461.461%200%2001.338-.128zm6.797%201.206a.46.46%200%2001.53.651A1.966%201.966%200%200019.81%2018.4a.462.462%200%2001.623.18.46.46%200%2001-.181.624%202.863%202.863%200%2001-1.38.353l-.142-.004a2.88%202.88%200%2001-2.393-4.263.461.461%200%2001.274-.21zm.864-.931a2.884%202.884%200%20013.915%203.914.46.46%200%2001-.402.24l-.057-.004a.458.458%200%2001-.164-.055.46.46%200%2001-.182-.622%201.967%201.967%200%2000-2.669-2.67.459.459%200%2011-.441-.803zM9.59%206.368c1.481%200%201.696%201.202%201.696%201.654v2.648h-.917v-.432c-.26.346-.792.535-1.36.535-.133%200-1.289-.03-1.384-1.136-.082-.932.675-1.61%202.053-1.61h.691c0-.563-.367-.886-.983-.886-.44.013-.864.174-1.2.458l-.36-.664c.484-.379%201.012-.567%201.764-.567zm4.427.1c1.263%200%202.082.97%202.083%202.15%200%201.181-.824%202.154-2.083%202.154-1.26%200-2.084-.972-2.084-2.152%200-1.18.82-2.153%202.084-2.153zm6.801.015c.68%200%201.202.465%201.197%201.548v2.642H21.1V8.29c0-.312-.002-.98-.63-.98s-.628.667-.628.838v2.524h-.89V8.148c0-.17-.001-.838-.63-.838-.628%200-.628.668-.628.98v2.383h-.917v-4.03h.917V7a1.22%201.22%200%2001.947-.516c.398%200%20.76.193.982.686a1.321%201.321%200%20011.195-.686zm-18.093.872l1.457-1.772H5.32L3.311%208.07l2.14%202.602H4.24L2.725%208.796%201.21%2010.672H0L2.138%208.07.13%205.583h1.138l1.458%201.772zm4.149%203.317h-.916V6.644h.916v4.028zm16.99%200h-.916V6.644h.916v4.028zM9.925%208.71c-1.055%200-1.359.412-1.326.742.032.329.324.537.757.537a1.013%201.013%200%20001.014-.968l.002-.31h-.447zM14.018%207.3c-.663%200-1.184.487-1.184%201.32%200%20.832.52%201.32%201.184%201.32.662%200%201.182-.49%201.182-1.32%200-.832-.52-1.32-1.182-1.32zM6.417%205.001a.568.568%200%2001.587.582.588.588%200%2001-1.175%200A.57.57%200%20016.417%205zm16.991%200a.57.57%200%2001.592.582.588.588%200%2001-1.174%200%20.57.57%200%2001.357-.542.572.572%200%2001.225-.04z'%3e%3c/path%3e%3c/svg%3e",EC="/assets/agent-inspector-58K1_MsC.ico",RC={"agent-inspector":"Inspector",codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code","ai-sdk":"AI SDK"};function Lr(e){return e?.toLowerCase()??""}function is(e,t){for(const n of t)if(e.includes(n))return!0;return!1}function ac(e){const t=[Lr(e.userAgent),Lr(e.conversationId),Lr(e.clientProjectFolder)].join(" ");return is(t,["agent-inspector","agent inspector","provider-test"])?"agent-inspector":is(t,["mimocode","mimo-code","mimo code"])?"mimo-code":is(t,["opencode","open-code","open code"])?"opencode":is(t,["claude-code","claude code","claudecode","claude-cli","claude cli"])?"claude-code":is(t,["codex desktop","codex-cli","openai-codex","codex"])?"codex":is(Lr(e.userAgent),["ai-sdk","ai/"])?"ai-sdk":"unknown"}function xi(e){switch(e){case"agent-inspector":case"codex":case"opencode":case"mimo-code":case"claude-code":case"ai-sdk":return RC[e];case"unknown":return null}}function PC(e){switch(e){case"codex":case"opencode":case"mimo-code":case"claude-code":return"IDE";case"agent-inspector":case"ai-sdk":case"unknown":return"CLIENT"}}const IC={"agent-inspector":EC,codex:NC,opencode:CC,"mimo-code":TC,"claude-code":SC},MC={"agent-inspector":"border-orange-700/15 bg-orange-500/[0.08] dark:border-orange-200/25 dark:bg-orange-300/[0.12]",codex:"border-cyan-700/15 bg-cyan-500/[0.08] dark:border-cyan-200/20 dark:bg-cyan-300/[0.08]",opencode:"border-sky-700/15 bg-sky-500/[0.09] dark:border-sky-200/25 dark:bg-sky-300/[0.12]","mimo-code":"border-orange-700/15 bg-orange-500/[0.09] dark:border-orange-200/25 dark:bg-orange-400/[0.12]","claude-code":"border-amber-700/15 bg-amber-500/[0.08] dark:border-amber-100/20 dark:bg-amber-300/[0.09]"},AC={"agent-inspector":"p-0.5 drop-shadow-[0_0_8px_rgba(251,146,60,0.35)]",codex:"p-0.5",opencode:"p-1 drop-shadow-[0_0_8px_rgba(125,211,252,0.35)]","mimo-code":"p-0.5 drop-shadow-[0_0_8px_rgba(255,105,0,0.35)]","claude-code":"p-0.5"};function bi({client:e,className:t,decorative:n=!1}){if(e==="unknown")return null;const s=xi(e);if(s===null)return null;if(e==="ai-sdk")return r.jsx("span",{className:$("inline-flex size-6 shrink-0 items-center justify-center rounded-md border border-cyan-700/15 bg-cyan-500/[0.08] text-[var(--inspector-status-cool)] shadow-sm dark:border-cyan-200/20 dark:bg-cyan-300/[0.08]",t),"aria-label":n?void 0:s,"aria-hidden":n?!0:void 0,title:s,children:r.jsx(df,{className:"size-1/2","aria-hidden":"true"})});const o=IC[e];return r.jsx("span",{className:$("inline-flex size-6 shrink-0 items-center justify-center rounded-md border p-0 shadow-sm",MC[e],t),"aria-label":n?void 0:s,"aria-hidden":n?!0:void 0,title:s,children:r.jsx("img",{src:o,alt:"",className:$("size-full object-contain",AC[e]),"aria-hidden":"true"})})}const OC="data:image/svg+xml,%3csvg%20height='2500'%20viewBox='0%206.603%201192.672%201193.397'%20width='2500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m233.96%20800.215%20234.684-131.678%203.947-11.436-3.947-6.363h-11.436l-39.221-2.416-134.094-3.624-116.296-4.832-112.67-6.04-28.35-6.04-26.577-35.035%202.738-17.477%2023.84-16.027%2034.147%202.98%2075.463%205.155%20113.235%207.812%2082.147%204.832%20121.692%2012.644h19.329l2.738-7.812-6.604-4.832-5.154-4.832-117.182-79.41-126.845-83.92-66.443-48.321-35.92-24.484-18.12-22.953-7.813-50.093%2032.618-35.92%2043.812%202.98%2011.195%202.98%2044.375%2034.147%2094.792%2073.37%20123.786%2091.167%2018.12%2015.06%207.249-5.154.886-3.624-8.135-13.61-67.329-121.692-71.838-123.785-31.974-51.302-8.456-30.765c-2.98-12.645-5.154-23.275-5.154-36.242l37.127-50.416%2020.537-6.604%2049.53%206.604%2020.86%2018.121%2030.765%2070.39%2049.852%20110.818%2077.315%20150.684%2022.631%2044.698%2012.08%2041.396%204.51%2012.645h7.813v-7.248l6.362-84.886%2011.759-104.215%2011.436-134.094%203.946-37.772%2018.685-45.262%2037.127-24.482%2028.994%2013.852%2023.839%2034.148-3.303%2022.067-14.174%2092.134-27.785%20144.323-18.121%2096.644h10.55l12.08-12.08%2048.887-64.913%2082.147-102.685%2036.242-40.752%2042.282-45.02%2027.14-21.423h51.303l37.772%2056.135-16.913%2057.986-52.832%2067.007-43.812%2056.779-62.82%2084.563-39.22%2067.651%203.623%205.396%209.343-.886%20141.906-30.201%2076.671-13.852%2091.49-15.705%2041.396%2019.329%204.51%2019.65-16.269%2040.189-97.852%2024.16-114.764%2022.954-170.9%2040.43-2.093%201.53%202.416%202.98%2076.993%207.248%2032.94%201.771h80.617l150.12%2011.195%2039.222%2025.933%2023.517%2031.732-3.946%2024.16-60.403%2030.766-81.503-19.33-190.228-45.26-65.235-16.27h-9.02v5.397l54.362%2053.154%2099.624%2089.96%20124.752%20115.973%206.362%2028.671-16.027%2022.63-16.912-2.415-109.611-82.47-42.282-37.127-95.758-80.618h-6.363v8.456l22.067%2032.296%20116.537%20175.167%206.04%2053.719-8.456%2017.476-30.201%2010.55-33.181-6.04-68.215-95.758-70.39-107.84-56.778-96.644-6.926%203.947-33.503%20360.886-15.705%2018.443-36.243%2013.852-30.201-22.953-16.027-37.127%2016.027-73.37%2019.329-95.758%2015.704-76.107%2014.175-94.55%208.456-31.41-.563-2.094-6.927.886-71.275%2097.852-108.402%20146.497-85.772%2091.812-20.537%208.134-35.597-18.443%203.301-32.94%2019.893-29.315%20118.712-151.007%2071.597-93.583%2046.228-54.04-.322-7.813h-2.738l-315.302%20204.725-56.135%207.248-24.16-22.63%202.98-37.128%2011.435-12.08%2094.792-65.236-.322.323z'%20fill='%23d97757'/%3e%3c/svg%3e",zC="data:image/svg+xml,%3csvg%20height='2500'%20viewBox='-1%20-.1%20949.1%20959.8'%20width='2474'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m925.8%20456.3c10.4%2023.2%2017%2048%2019.7%2073.3%202.6%2025.3%201.3%2050.9-4.1%2075.8-5.3%2024.9-14.5%2048.8-27.3%2070.8-8.4%2014.7-18.3%2028.5-29.7%2041.2-11.3%2012.6-23.9%2024-37.6%2034-13.8%2010-28.5%2018.4-44.1%2025.3-15.5%206.8-31.7%2012-48.3%2015.4-7.8%2024.2-19.4%2047.1-34.4%2067.7-14.9%2020.6-33%2038.7-53.6%2053.6-20.6%2015-43.4%2026.6-67.6%2034.4-24.2%207.9-49.5%2011.8-75%2011.8-16.9.1-33.9-1.7-50.5-5.1-16.5-3.5-32.7-8.8-48.2-15.7s-30.2-15.5-43.9-25.5c-13.6-10-26.2-21.5-37.4-34.2-25%205.4-50.6%206.7-75.9%204.1-25.3-2.7-50.1-9.3-73.4-19.7-23.2-10.3-44.7-24.3-63.6-41.4s-35-37.1-47.7-59.1c-8.5-14.7-15.5-30.2-20.8-46.3s-8.8-32.7-10.6-49.6c-1.8-16.8-1.7-33.8.1-50.7%201.8-16.8%205.5-33.4%2010.8-49.5-17-18.9-31-40.4-41.4-63.6-10.3-23.3-17-48-19.6-73.3-2.7-25.3-1.3-50.9%204-75.8s14.5-48.8%2027.3-70.8c8.4-14.7%2018.3-28.6%2029.6-41.2s24-24%2037.7-34%2028.5-18.5%2044-25.3c15.6-6.9%2031.8-12%2048.4-15.4%207.8-24.3%2019.4-47.1%2034.3-67.7%2015-20.6%2033.1-38.7%2053.7-53.7%2020.6-14.9%2043.4-26.5%2067.6-34.4%2024.2-7.8%2049.5-11.8%2075-11.7%2016.9-.1%2033.9%201.6%2050.5%205.1s32.8%208.7%2048.3%2015.6c15.5%207%2030.2%2015.5%2043.9%2025.5%2013.7%2010.1%2026.3%2021.5%2037.5%2034.2%2024.9-5.3%2050.5-6.6%2075.8-4s50%209.3%2073.3%2019.6c23.2%2010.4%2044.7%2024.3%2063.6%2041.4%2018.9%2017%2035%2036.9%2047.7%2059%208.5%2014.6%2015.5%2030.1%2020.8%2046.3%205.3%2016.1%208.9%2032.7%2010.6%2049.6%201.8%2016.9%201.8%2033.9-.1%2050.8-1.8%2016.9-5.5%2033.5-10.8%2049.6%2017.1%2018.9%2031%2040.3%2041.4%2063.6zm-333.2%20426.9c21.8-9%2041.6-22.3%2058.3-39s30-36.5%2039-58.4c9-21.8%2013.7-45.2%2013.7-68.8v-223q-.1-.3-.2-.7-.1-.3-.3-.6-.2-.3-.5-.5-.3-.3-.6-.4l-80.7-46.6v269.4c0%202.7-.4%205.5-1.1%208.1-.7%202.7-1.7%205.2-3.1%207.6s-3%204.6-5%206.5a32.1%2032.1%200%200%201%20-6.5%205l-191.1%20110.3c-1.6%201-4.3%202.4-5.7%203.2%207.9%206.7%2016.5%2012.6%2025.5%2017.8%209.1%205.2%2018.5%209.6%2028.3%2013.2%209.8%203.5%2019.9%206.2%2030.1%208%2010.3%201.8%2020.7%202.7%2031.1%202.7%2023.6%200%2047-4.7%2068.8-13.8zm-455.1-151.4c11.9%2020.5%2027.6%2038.3%2046.3%2052.7%2018.8%2014.4%2040.1%2024.9%2062.9%2031s46.6%207.7%2070%204.6%2045.9-10.7%2066.4-22.5l193.2-111.5.5-.5q.2-.2.3-.6.2-.3.3-.6v-94l-233.2%20134.9c-2.4%201.4-4.9%202.4-7.5%203.2-2.7.7-5.4%201-8.2%201-2.7%200-5.4-.3-8.1-1-2.6-.8-5.2-1.8-7.6-3.2l-191.1-110.4c-1.7-1-4.2-2.5-5.6-3.4-1.8%2010.3-2.7%2020.7-2.7%2031.1s1%2020.8%202.8%2031.1c1.8%2010.2%204.6%2020.3%208.1%2030.1%203.6%209.8%208%2019.2%2013.2%2028.2zm-50.2-417c-11.8%2020.5-19.4%2043.1-22.5%2066.5s-1.5%2047.1%204.6%2070c6.1%2022.8%2016.6%2044.1%2031%2062.9%2014.4%2018.7%2032.3%2034.4%2052.7%2046.2l193.1%20111.6q.3.1.7.2h.7q.4%200%20.7-.2.3-.1.6-.3l81-46.8-233.2-134.6c-2.3-1.4-4.5-3.1-6.5-5a32.1%2032.1%200%200%201%20-5-6.5c-1.3-2.4-2.4-4.9-3.1-7.6-.7-2.6-1.1-5.3-1-8.1v-227.1c-9.8%203.6-19.3%208-28.3%2013.2-9%205.3-17.5%2011.3-25.5%2018-7.9%206.7-15.3%2014.1-22%2022.1-6.7%207.9-12.6%2016.5-17.8%2025.5zm663.3%20154.4c2.4%201.4%204.6%203%206.6%205%201.9%201.9%203.6%204.1%205%206.5%201.3%202.4%202.4%205%203.1%207.6.6%202.7%201%205.4.9%208.2v227.1c32.1-11.8%2060.1-32.5%2080.8-59.7%2020.8-27.2%2033.3-59.7%2036.2-93.7s-3.9-68.2-19.7-98.5-39.9-55.5-69.5-72.5l-193.1-111.6q-.3-.1-.7-.2h-.7q-.3.1-.7.2-.3.1-.6.3l-80.6%2046.6%20233.2%20134.7zm80.5-121h-.1v.1zm-.1-.1c5.8-33.6%201.9-68.2-11.3-99.7-13.1-31.5-35-58.6-63-78.2-28-19.5-61-30.7-95.1-32.2-34.2-1.4-68%206.9-97.6%2023.9l-193.1%20111.5q-.3.2-.5.5l-.4.6q-.1.3-.2.7-.1.3-.1.7v93.2l233.2-134.7c2.4-1.4%205-2.4%207.6-3.2%202.7-.7%205.4-1%208.1-1%202.8%200%205.5.3%208.2%201%202.6.8%205.1%201.8%207.5%203.2l191.1%20110.4c1.7%201%204.2%202.4%205.6%203.3zm-505.3-103.2c0-2.7.4-5.4%201.1-8.1.7-2.6%201.7-5.2%203.1-7.6%201.4-2.3%203-4.5%205-6.5%201.9-1.9%204.1-3.6%206.5-4.9l191.1-110.3c1.8-1.1%204.3-2.5%205.7-3.2-26.2-21.9-58.2-35.9-92.1-40.2-33.9-4.4-68.3%201-99.2%2015.5-31%2014.5-57.2%2037.6-75.5%2066.4-18.3%2028.9-28%2062.3-28%2096.5v223q.1.4.2.7.1.3.3.6.2.3.5.6.2.2.6.4l80.7%2046.6zm43.8%20294.7%20103.9%2060%20103.9-60v-119.9l-103.8-60-103.9%2060z'/%3e%3c/svg%3e",LC="data:image/svg+xml,%3csvg%20fill='none'%20height='1320'%20viewBox='3.771%206.973%2023.993%2017.652'%20width='2500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m27.501%208.469c-.252-.123-.36.111-.508.23-.05.04-.093.09-.135.135-.368.395-.797.652-1.358.621-.821-.045-1.521.213-2.14.842-.132-.776-.57-1.238-1.235-1.535-.349-.155-.701-.309-.944-.645-.171-.238-.217-.504-.303-.765-.054-.159-.108-.32-.29-.348-.197-.031-.274.135-.352.273-.31.567-.43%201.192-.419%201.825.028%201.421.628%202.554%201.82%203.36.136.093.17.186.128.321-.081.278-.178.547-.264.824-.054.178-.135.217-.324.14a5.448%205.448%200%200%201%20-1.719-1.169c-.848-.82-1.614-1.726-2.57-2.435-.225-.166-.449-.32-.681-.467-.976-.95.128-1.729.383-1.82.267-.096.093-.428-.77-.424s-1.653.293-2.659.677a2.782%202.782%200%200%201%20-.46.135%209.554%209.554%200%200%200%20-2.853-.1c-1.866.21-3.356%201.092-4.452%202.6-1.315%201.81-1.625%203.87-1.246%206.018.399%202.261%201.552%204.136%203.326%205.601%201.837%201.518%203.955%202.262%206.37%202.12%201.466-.085%203.1-.282%204.942-1.842.465.23.952.322%201.762.392.623.059%201.223-.031%201.687-.127.728-.154.677-.828.414-.953-2.132-.994-1.665-.59-2.09-.916%201.084-1.285%202.717-2.619%203.356-6.94.05-.343.007-.558%200-.837-.004-.168.034-.235.228-.254a4.084%204.084%200%200%200%201.529-.47c1.382-.757%201.938-1.997%202.07-3.485.02-.227-.004-.463-.243-.582zm-12.041%2013.391c-2.067-1.627-3.07-2.162-3.483-2.138-.387.021-.318.465-.233.754.089.285.205.482.368.732.113.166.19.414-.112.598-.666.414-1.823-.139-1.878-.166-1.347-.793-2.473-1.842-3.267-3.276-.765-1.38-1.21-2.861-1.284-4.441-.02-.383.093-.518.472-.586a4.692%204.692%200%200%201%201.514-.04c2.109.31%203.905%201.255%205.41%202.749.86.853%201.51%201.871%202.18%202.865.711%201.057%201.478%202.063%202.454%202.887.343.289.619.51.881.672-.792.088-2.117.107-3.022-.61zm.99-6.38a.304.304%200%201%201%20.609%200c0%20.17-.136.304-.306.304a.3.3%200%200%201%20-.303-.305zm3.077%201.581c-.197.08-.394.15-.584.159a1.246%201.246%200%200%201%20-.79-.252c-.27-.227-.463-.354-.546-.752a1.752%201.752%200%200%201%20.016-.582c.07-.324-.008-.531-.235-.72-.187-.155-.422-.196-.682-.196a.551.551%200%200%201%20-.252-.078c-.108-.055-.197-.19-.112-.356.027-.053.159-.183.19-.207.352-.201.758-.135%201.134.016.349.142.611.404.99.773.388.448.457.573.678.906.174.264.333.534.441.842.066.192-.02.35-.248.448z'%20fill='%234d6bfe'/%3e%3c/svg%3e",$C="/assets/minimax-BPMzvuL-.jpeg",DC="/assets/alibaba-TTwafVwX.svg",FC="/assets/qwen-mMn3f5ul.webp",UC="/assets/zhipuai-BPNAnxo-.svg",BC={"claude-":"anthropic","gpt-":"openai","o1-":"openai","o3-":"openai","deepseek-":"deepseek",MiniMax:"minimax",qwen:"qwen"};function VC(e){return e.replace(/[_\s]+/g,"-").split(/[/:@]/).some(n=>n.startsWith("glm-"))}function qC(e){if(e===null)return"unknown";const t=e.toLowerCase();if(VC(t))return"zhipuai";for(const[n,s]of Object.entries(BC))if(t.startsWith(n.toLowerCase()))return s;return"unknown"}const es={width:24,height:24,objectFit:"contain"},HC=Jn.memo(({className:e})=>r.jsx("img",{src:OC,alt:"Anthropic",className:e,style:es})),WC=Jn.memo(({className:e})=>r.jsx("img",{src:zC,alt:"OpenAI",className:e,style:{...es,background:"white",borderRadius:"4px"}})),ZC=Jn.memo(({className:e})=>r.jsx("img",{src:LC,alt:"DeepSeek",className:e,style:es})),KC=Jn.memo(({className:e})=>r.jsx("img",{src:$C,alt:"MiniMax",className:e,style:es})),GC=Jn.memo(({className:e})=>r.jsx("img",{src:DC,alt:"Alibaba",className:e,style:es})),JC=Jn.memo(({className:e})=>r.jsx("img",{src:FC,alt:"Qwen",className:e,style:es})),YC=Jn.memo(({className:e})=>r.jsx("img",{src:UC,alt:"ZhipuAI",className:e,style:es}));function XC({provider:e,className:t}){switch(e){case"anthropic":return r.jsx(HC,{className:t});case"openai":return r.jsx(WC,{className:t});case"deepseek":return r.jsx(ZC,{className:t});case"minimax":return r.jsx(KC,{className:t});case"alibaba":return r.jsx(GC,{className:t});case"qwen":return r.jsx(JC,{className:t});case"zhipuai":return r.jsx(YC,{className:t});case"unknown":return null}}function Ds({delayDuration:e=600,...t}){return r.jsx(xC,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ft({...e}){return r.jsx(bC,{"data-slot":"tooltip",...e})}function mt({...e}){return r.jsx(vC,{"data-slot":"tooltip-trigger",...e})}function ht({className:e,sideOffset:t=0,children:n,...s}){return r.jsx(yC,{children:r.jsxs(wC,{"data-slot":"tooltip-content",sideOffset:t,className:$("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...s,children:[n,r.jsx(jC,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const QC=3;function e3({items:e,ariaLabel:t,className:n}){if(e.length===0)return r.jsx("span",{className:$("flex h-8 w-12 shrink-0 items-center",n),"aria-hidden":"true"});const s=e.slice(0,QC),o=e.length-s.length;return r.jsx(Ds,{delayDuration:150,children:r.jsxs("span",{className:$("flex h-8 w-12 shrink-0 items-center",n),"aria-label":t,children:[s.map((i,a)=>r.jsxs(ft,{children:[r.jsx(mt,{asChild:!0,children:r.jsx("span",{className:$("border border-border bg-muted/40 inline-flex size-6 shrink-0 items-center justify-center rounded-md",a>0&&"-ml-2"),children:r.jsx(XC,{provider:i.provider,className:"size-4"})})}),r.jsx(ht,{children:i.tooltip})]},`${i.provider}-${String(a)}`)),o>0&&r.jsxs("span",{className:"border border-border bg-muted/40 -ml-2 inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md px-1 font-mono text-[10px] text-muted-foreground",children:["+",o]})]})})}const t3="/v1/chat/completions",n3="/chat/completions",s3="/v1/responses",r3="/responses",o3="/v1/messages";class i3{handlers=new Map;pathMap=new Map;register(t){this.handlers.set(t.format,t)}registerPath(t,n){this.pathMap.set(t,n)}get(t){return this.handlers.get(t)}getByPath(t){const n=t.split("?")[0]??"",s=this.pathMap.get(n);return s===void 0?void 0:this.handlers.get(s)}getApiFormatByPath(t){const n=t.split("?")[0]??"";return this.pathMap.get(n)}detectFormat(t){if(t===null)return"unknown";for(const n of this.handlers.values())if(n.detectFormat(t))return n.format;return"unknown"}}const Pn=new i3;function a3(e){return Pn.getApiFormatByPath(e)??"unknown"}Pn.registerPath(o3,"anthropic");Pn.registerPath(t3,"openai");Pn.registerPath(n3,"openai");Pn.registerPath(s3,"openai");Pn.registerPath(r3,"openai");function l3(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}catch{return{}}}function c3(e){switch(e.type){case"text":return{type:"text",text:e.text};case"thinking":{const t={type:"thinking",thinking:e.thinking};return e.signature!==""&&(t.signature=e.signature),t}case"think":{const t={type:"think",thinking:e.thinking};return e.signature!==""&&(t.signature=e.signature),t}case"tool_use":return{type:"tool_use",id:e.id,name:e.name,input:l3(e.inputJson)}}}function Wh(e,t,n,s){const o=new Map;let i="",a="",l=null,u=null,d=0,p=0;const f=1e3;let m=0,h=0;const g=[];for(const b of e.split(`
106
+ `)){const w=b.trim();if(w.startsWith("data: "))try{const v=JSON.parse(w.slice(6)),j=X2.safeParse(v);if(!j.success)continue;const _=j.data;switch(m===0&&(h=Date.now()),s===!0&&g.length<f&&g.push({index:m,timestamp:Date.now()-h,type:_.type,data:Op(_)}),m++,_.type){case"message_start":i=_.message.id,a=_.message.model,d=_.message.usage.input_tokens,t.inputTokens=d,t.cacheCreationInputTokens=_.message.usage.cache_creation_input_tokens??null,t.cacheReadInputTokens=_.message.usage.cache_read_input_tokens??null,t.model===null&&(t.model=a);break;case"content_block_start":{const k=_.content_block;switch(k.type){case"text":o.set(_.index,{type:"text",text:k.text??""});break;case"thinking":o.set(_.index,{type:"thinking",thinking:k.thinking??"",signature:k.signature??""});break;case"think":o.set(_.index,{type:"think",thinking:k.thinking??"",signature:k.signature??""});break;case"tool_use":o.set(_.index,{type:"tool_use",id:k.id,name:k.name,inputJson:""});break}break}case"content_block_delta":{const k=o.get(_.index);if(k===void 0)break;const S=_.delta;S.type==="text_delta"&&k.type==="text"?k.text+=S.text:S.type==="thinking_delta"&&(k.type==="thinking"||k.type==="think")?k.thinking+=S.thinking:S.type==="signature_delta"&&(k.type==="thinking"||k.type==="think")?k.signature+=S.signature:S.type==="input_json_delta"&&k.type==="tool_use"&&(k.inputJson+=S.partial_json);break}case"message_delta":l=_.delta.stop_reason,u=_.delta.stop_sequence??null,p=_.usage.output_tokens,t.outputTokens=p,_.usage.cache_creation_input_tokens!==void 0&&(t.cacheCreationInputTokens=_.usage.cache_creation_input_tokens),_.usage.cache_read_input_tokens!==void 0&&(t.cacheReadInputTokens=_.usage.cache_read_input_tokens);break;case"error":t.error=_.error.message;break;case"content_block_stop":case"message_stop":case"ping":break}}catch{}}s===!0&&(t.streamingChunks={chunks:g,truncated:m>f});const y=[...o.entries()].sort(([b],[w])=>b-w).map(([,b])=>c3(b));return JSON.stringify({id:i,type:"message",model:a!==""?a:n??"",role:"assistant",content:y,stop_reason:l,stop_sequence:u,usage:{input_tokens:d,output_tokens:p}})}const u3={format:"anthropic",parseRequest(e,t){try{const n=JSON.parse(e),s=Fp.safeParse(n);return s.success?{model:s.data.model,sessionId:s.data.metadata?.user_id??t?.get("x-agent-inspector-session-id")??t?.get("x-session-affinity")??null}:null}catch{return null}},extractTokens(e){try{const t=JSON.parse(e),n=Up.safeParse(t);if(n.success)return{inputTokens:n.data.usage.input_tokens??null,outputTokens:n.data.usage.output_tokens??null,cacheCreationInputTokens:n.data.usage.cache_creation_input_tokens??null,cacheReadInputTokens:n.data.usage.cache_read_input_tokens??null}}catch{}return{inputTokens:null,outputTokens:null,cacheCreationInputTokens:null,cacheReadInputTokens:null}},extractStream(e,t,n,s){return Wh(e,t,n,s)},detectFormat(e){if(e===null)return!1;try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const n=Object.keys(t);return n.includes("model")&&n.includes("messages")&&n.includes("system")}return!1}catch{return!1}}};Pn.register(u3);class d3{providers=[];register(t){this.providers.push(t)}findProvider(t){let n=null;for(const s of this.providers)if(s.matches(t)){if(s.name!=="anthropic")return s;n=s}return n}getAll(){return[...this.providers]}}const vi=new d3,p3="https://api.anthropic.com",f3={MiniMax:"https://api.minimaxi.com/anthropic"},m3={name:"anthropic",matches(e){const t=e.toLowerCase();if(t.startsWith("openai-"))return!1;if(t.includes("claude")||t.includes("anthropic"))return!0;for(const n of Object.keys(f3))if(t.startsWith(n.toLowerCase()))return!0;return!0},getUpstreamBase(e,t){return t?.baseUrl!==void 0?t.baseUrl:p3},extractStream(e,t,n,s){return Wh(e,t,n,s)}};vi.register(m3);const lc=1e3;function jr(e,t){if(!(e===null||typeof e!="object"||Array.isArray(e)))return Object.getOwnPropertyDescriptor(e,t)?.value}function rt(e,t){const n=jr(e,t);return typeof n=="string"?n:null}function Zh(e,t){const n=jr(e,t);return typeof n=="number"&&Number.isFinite(n)?n:null}function Ro(e,t){const n=jr(e,t);return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:null}function h3(e,t){const n=jr(e,t);return Array.isArray(n)?n:[]}function g3(e){const t=[];let n=null,s=[];const o=()=>{n===null&&s.length===0||(t.push({event:n,data:s.join(`
107
107
  `)}),n=null,s=[])};for(const i of e.split(`
108
- `)){const a=i.endsWith("\r")?i.slice(0,-1):i;if(a===""){o();continue}if(a.startsWith(":"))continue;const l=a.indexOf(":"),u=l===-1?a:a.slice(0,l),d=l===-1?"":a.slice(l+1),f=d.startsWith(" ")?d.slice(1):d;switch(u){case"event":n=f;break;case"data":n===null&&s.length>0&&(f.startsWith("{")||f==="[DONE]")&&o(),s.push(f);break}}return o(),t}function cc(e){try{return JSON.parse(e)}catch{return null}}function Kh(e,t){if(e.event!==null&&e.event!=="")return e.event;const n=ly.safeParse(t);return n.success?n.data.type:""}function x3(e){if(e.data==="[DONE]")return!1;const t=cc(e.data),n=Kh(e,t);return n.startsWith("response.")||n==="error"}function Gh(e,t,n,s,o){e.length>=lc||e.push({index:t,timestamp:Date.now()-n,type:s,data:zf(o)})}function qa(e,t){const n=Ro(t,"error"),s=rt(n,"message")??rt(t,"message")??rt(t,"error");s!==null&&s.length>0&&(e.error=s)}function b3(e,t,n,s){let o="",i="",a="",l="",u=null,d=0,f=0,p=!1,m=!1;const h=new Map;let g=0,y=0;const b=[];for(const v of e){if(v.data==="[DONE]")break;const j=cc(v.data);if(j===null)continue;qa(t,j);const S=oy.safeParse(j);if(!S.success)continue;const k=S.data;if(g===0&&(y=Date.now()),s&&Gh(b,g,y,"chat.completion.chunk",k),g++,m||(o=k.id,i=k.model,m=!0),!p&&k.usage!==void 0&&k.usage!==null){d=k.usage.prompt_tokens??0,f=k.usage.completion_tokens??0,t.inputTokens=d;const _=Ro(j,"usage"),C=Ro(_,"prompt_tokens_details"),I=Zh(C,"cached_tokens");I!==null&&(t.cacheReadInputTokens=I),p=!0}for(const _ of k.choices){const C=_.delta;C.content!==void 0&&C.content!==null&&(a+=C.content),C.reasoning_content!==void 0&&C.reasoning_content!==null&&(l+=C.reasoning_content),C.thinking!==void 0&&C.thinking!==null&&(l+=C.thinking);const I=C.think;if(I!=null&&(l+=I),_.finish_reason!==void 0&&_.finish_reason!==null&&(u=_.finish_reason),C.tool_calls!==void 0&&C.tool_calls!==null)for(const A of C.tool_calls){let P=h.get(A.index);P===void 0&&(P={index:A.index,type:"function",function:{name:"",arguments:""}},h.set(A.index,P)),A.id!==void 0&&(P.id=A.id),A.function?.name!==void 0&&(P.function.name+=A.function.name),A.function?.arguments!==void 0&&(P.function.arguments+=A.function.arguments)}}}s&&(t.streamingChunks={chunks:b,truncated:g>lc}),p||(f=Math.ceil(a.length/4)),t.outputTokens=f;const w={role:"assistant",content:a};return l.length>0&&(w.reasoning_content=l),h.size>0&&(w.tool_calls=[...h.values()]),JSON.stringify({id:o,object:"chat.completion",created:Math.floor(Date.now()/1e3),model:i!==""?i:n??"",choices:[{index:0,message:w,finish_reason:u}],usage:{prompt_tokens:d,completion_tokens:f,total_tokens:d+f}})}function v3(e){const t=go.safeParse(jr(e,"response"));if(t.success)return t.data;const n=go.safeParse(e);return n.success?n.data:null}function Jh(e){if(e.output_text!==void 0&&e.output_text.length>0)return e.output_text;const t=[];for(const n of e.output??[]){const s=h3(n,"content");for(const o of s){const i=rt(o,"type"),a=rt(o,"text");(i==="output_text"||i==="text")&&a!==null&&a.length>0&&t.push(a)}}return t.join(`
109
- `)}function Au(e,t){const n=e.usage,s=n?.input_tokens??null,o=n?.output_tokens??null;s!==null&&(t.inputTokens=s),o!==null&&(t.outputTokens=o);const i=n?.input_tokens_details?.cached_tokens??null;return i!==null&&(t.cacheReadInputTokens=i),{inputTokens:s,outputTokens:o}}function Vi(e,t){const n=rt(e,"item_id");if(n!==null&&n.length>0)return n;const s=Zh(e,"output_index");return s!==null?String(s):`function-${String(t)}`}function Ha(e,t){const n=e.get(t);if(n!==void 0)return n;const s={type:"function_call",arguments:""};return e.set(t,s),s}function y3(e,t,n){if(rt(n,"type")!=="function_call")return;const s=Ha(e,t),o=rt(n,"id"),i=rt(n,"call_id"),a=rt(n,"name"),l=rt(n,"arguments"),u=rt(n,"status");o!==null&&(s.id=o),i!==null&&(s.call_id=i),a!==null&&(s.name=a),l!==null&&(s.arguments=l),u!==null&&(s.status=u)}function w3(e,t){const n=[];e.length>0&&n.push({type:"message",role:"assistant",content:[{type:"output_text",text:e,annotations:[]}]});for(const s of t.values())n.push(s);return n}function j3(e,t,n){const s=t??Math.ceil(n.length/4);return{input_tokens:e,output_tokens:s,total_tokens:e===null?s:e+s}}function k3(e){const t=e.completedResponse===null?"":Jh(e.completedResponse),n=t.length>0?t:e.outputText,s=e.completedResponse?.output,o=s!==void 0&&s.length>0?s:w3(n,e.calls),i=e.completedResponse?.usage??j3(e.inputTokens,e.outputTokens,n);return{...e.completedResponse??{},id:e.completedResponse?.id??e.responseId,object:"response",created_at:e.completedResponse?.created_at??Math.floor(Date.now()/1e3),status:e.completedResponse?.status??e.status??"completed",model:e.completedResponse?.model??e.model,output:o,output_text:n,usage:i}}function S3(e,t,n,s){let o=null,i="",a=n??"",l=null,u="",d=null,f=null,p=0,m=0;const h=[],g=new Map;for(const w of e){if(w.data==="[DONE]")break;const v=cc(w.data);if(v===null)continue;const j=Kh(w,v);if(p===0&&(m=Date.now()),s&&Gh(h,p,m,j===""?"response.event":j,v),p++,qa(t,v),j==="error")continue;const S=v3(v);if(S!==null){o=S,i=S.id,a=S.model??a,l=S.status??l;const _=Au(S,t);d=_.inputTokens??d,f=_.outputTokens??f,qa(t,S)}const k=rt(v,"delta");switch(j){case"response.output_text.delta":k!==null&&(u+=k);break;case"response.output_text.done":{const _=rt(v,"text");u.length===0&&_!==null&&(u=_);break}case"response.function_call_arguments.delta":{if(k!==null){const _=Ha(g,Vi(v,g.size));_.arguments+=k}break}case"response.function_call_arguments.done":{const _=rt(v,"arguments");if(_!==null){const C=Ha(g,Vi(v,g.size));C.arguments=_}break}case"response.output_item.added":case"response.output_item.done":{const _=Ro(v,"item");y3(g,Vi(v,g.size),_);break}case"response.failed":case"response.incomplete":l=j.slice(9);break;case"response.completed":l="completed";break}}s&&(t.streamingChunks={chunks:h,truncated:p>lc});const y=k3({completedResponse:o,responseId:i,model:a,status:l,outputText:u,calls:g,inputTokens:d,outputTokens:f}),b=go.safeParse(y);if(b.success){if(Au(b.data,t).outputTokens===null){const v=Jh(b.data),j=Math.ceil(v.length/4);t.outputTokens=j}return JSON.stringify(b.data)}if(t.outputTokens===null){const w=rt(y,"output_text")??u,v=Math.ceil(w.length/4);t.outputTokens=v}return JSON.stringify(y)}function yi(e,t,n,s=!0){const o=g3(e);return o.some(x3)?S3(o,t,n,s):b3(o,t,n,s)}const _3={sessionId:null,threadId:null,turnId:null,installationId:null,windowId:null};function Wa(e,t){if(!(typeof e!="object"||e===null||Array.isArray(e)))return Object.getOwnPropertyDescriptor(e,t)?.value}function Dt(e,t){const n=Wa(e,t);return typeof n=="string"&&n.length>0?n:null}function N3(e){if(typeof e!="string"||e.length===0)return null;try{return JSON.parse(e)}catch{return null}}function C3(e){const t=Wa(e,"client_metadata");if(t===void 0)return _3;const n=N3(Wa(t,"x-codex-turn-metadata"));return{sessionId:Dt(t,"session_id")??Dt(n,"session_id"),threadId:Dt(t,"thread_id")??Dt(n,"thread_id"),turnId:Dt(t,"turn_id")??Dt(n,"turn_id"),installationId:Dt(t,"x-codex-installation-id")??Dt(n,"installation_id"),windowId:Dt(t,"x-codex-window-id")??Dt(n,"window_id")}}function Ou(e){return C3(e).sessionId}function T3(){return{inputTokens:null,outputTokens:null,cacheCreationInputTokens:null,cacheReadInputTokens:null}}function zu(e){return e===void 0?null:e.get("x-agent-inspector-session-id")??e.get("x-session-affinity")}const E3={format:"openai",parseRequest(e,t){try{const n=JSON.parse(e),s=Hf.safeParse(n);if(s.success)return{model:s.data.model,sessionId:Ou(n)??zu(t)};const o=Wf.safeParse(n);return o.success?{model:o.data.model,sessionId:Ou(n)??zu(t)}:null}catch{return null}},extractTokens(e){const t=Kf(e);if(t){let s=null;try{const o=JSON.parse(e);if(o!==null&&typeof o=="object"&&!Array.isArray(o)){const i=Object.getOwnPropertyDescriptor(o,"usage");if(i!==void 0&&typeof i.value=="object"&&i.value!==null){const a=Object.getOwnPropertyDescriptor(i.value,"prompt_tokens_details");if(a!==void 0&&typeof a.value=="object"&&a.value!==null){const l=Object.getOwnPropertyDescriptor(a.value,"cached_tokens");l!==void 0&&typeof l.value=="number"&&(s=l.value)}}}}catch{}return{inputTokens:t.usage.prompt_tokens??null,outputTokens:t.usage.completion_tokens??null,cacheCreationInputTokens:null,cacheReadInputTokens:s}}const n=Gf(e);if(n!==null){const s=n.usage;return{inputTokens:s?.input_tokens??null,outputTokens:s?.output_tokens??null,cacheCreationInputTokens:null,cacheReadInputTokens:s?.input_tokens_details?.cached_tokens??null}}return T3()},extractStream(e,t,n,s){return yi(e,t,n,s)},detectFormat(e){if(e===null)return!1;try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const n=Object.keys(t);return n.includes("model")&&(n.includes("messages")||n.includes("input"))&&!n.includes("system")}return!1}catch{return!1}}};Pn.register(E3);const R3="https://api.openai.com/v1",P3={name:"openai",matches(e){const t=e.toLowerCase();return!!(t.startsWith("openai-")||t.includes("gpt-")||t.includes("o1")||t.includes("o2")||t.includes("o3"))},getUpstreamBase(e,t){return t?.baseUrl!==void 0?t.baseUrl:R3},extractStream(e,t,n,s){return yi(e,t,n,s)}};vi.register(P3);const M3="https://open.bigmodel.cn/api/paas/v4",I3=["glm-","charglm-","cogview-","embedding-","rerank-"],A3={name:"zhipu",matches(e){const t=e.toLowerCase().replace(/\s+/g,"-");return I3.some(n=>t.startsWith(n))},getUpstreamBase(e,t){return t?.baseUrl??M3},extractStream(e,t,n,s){return yi(e,t,n,s)}};vi.register(A3);const O3="https://dashscope.aliyuncs.com/compatible-mode/v1",z3={name:"alibaba",matches(e){return!!e.toLowerCase().replace(/\s+/g,"-").startsWith("qwen")},getUpstreamBase(e,t){return O3},extractStream(e,t,n){return yi(e,t,n)}};vi.register(z3);function Yh(e,t){for(const n of Array.from(e))t(n)}const L3=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function uc(e){if(e.length===0)return 0;let t=0,n=0;return Yh(e,s=>{L3.test(s)?t+=1:n+=1}),Math.ceil(t*1)+Math.ceil(n/4)}function dc(e){if(e.length===0)return 0;let t=0;return Yh(e,()=>{t+=1}),t}function fc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Q(e,t){return e===null||typeof e!="object"||Array.isArray(e)?void 0:Object.getOwnPropertyDescriptor(e,t)?.value}const $3=["file","shell","browser","web","mcp","code","other"];function Za(e){const t=e.replace(/\s+/g," ").trim();return t.length<=120?t:`${t.slice(0,119)}...`}function Xh(e){if(e===null)return null;const t=e.replace(/\s+/g," ").trim();if(t.length===0)return null;const n=t.search(/[.!?。!?]/);return n>=24?Za(t.slice(0,n+1)):Za(t)}function D3(e,t){return`${e} ${t??""}`.toLowerCase()}function as(e,t){return t.some(n=>e.includes(n))}function Qh(e,t){const n=D3(e,t);return e.startsWith("mcp__")||e.startsWith("inspector_")||as(n,[" mcp","model context protocol"])?"mcp":as(n,["bash","shell","terminal","command","powershell","exec","process"])?"shell":as(n,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":as(n,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":as(n,["web","search","http","url","fetch"])?"web":as(n,["code","typescript","javascript","python","repl"])?"code":"other"}function e0(e){const t=Q(e,"properties");return t===null||typeof t!="object"||Array.isArray(t)?[]:Object.keys(t).sort((n,s)=>n.localeCompare(s))}function t0(e){const t=Q(e,"required");if(!Array.isArray(t))return[];const n=[];for(const s of t)typeof s=="string"&&s.length>0&&n.push(s);return n.sort((s,o)=>s.localeCompare(o))}function F3(e){const t=Q(e,"name");if(typeof t!="string"||t.length===0)return null;const n=Q(e,"description"),s=Q(e,"input_schema")??null,o=typeof n=="string"?n:null;return{name:t,description:o,descriptionPreview:Xh(o),category:Qh(t,o),parameterCount:e0(s).length,requiredParameters:t0(s),schema:s}}function U3(e){const t=Q(e,"function"),n=Q(e,"type");if(t===void 0&&typeof n!="string")return null;const s=Q(t,"name")??Q(e,"name")??(typeof n=="string"?n:void 0);if(typeof s!="string"||s.length===0)return null;const o=Q(t,"description")??Q(e,"description"),i=Q(t,"parameters")??Q(e,"parameters")??null,a=typeof o=="string"?o:null;return{name:s,description:a,descriptionPreview:Xh(a),category:Qh(s,a),parameterCount:e0(i).length,requiredParameters:t0(i),schema:i}}function B3(e){const t=U3(e);return t!==null?t:F3(e)}function V3(e){if(e==null)return null;if(typeof e=="string")return e;const t=Q(e,"type"),n=Q(e,"name"),s=Q(Q(e,"function"),"name");if(typeof t=="string"&&typeof s=="string"&&s.length>0)return`${t}: ${s}`;if(typeof t=="string"&&typeof n=="string"&&n.length>0)return`${t}: ${n}`;if(typeof t=="string")return t;const o=JSON.stringify(e);return o===void 0?null:Za(o)}function q3(e){const t=new Map;for(const n of e)t.set(n.category,(t.get(n.category)??0)+1);return $3.flatMap(n=>{const s=t.get(n)??0;return s>0?[{category:n,count:s}]:[]})}function pc(e){const t=Q(e,"tools");if(!Array.isArray(t)||t.length===0)return null;const n=[];for(const s of t){const o=B3(s);o!==null&&n.push(o)}return n.length===0?null:{tools:n,toolChoiceLabel:V3(Q(e,"tool_choice")),categories:q3(n)}}function Vn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const ys={parsed:null,toolNames:null};function H3(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const s=n;switch(s.type){case"text":typeof s.text=="string"&&t.push(s.text);break;case"thinking":case"think":typeof s.thinking=="string"&&t.push(s.thinking);break;case"tool_use":{const i=typeof s.name=="string"?s.name:"",a=s.input!==void 0?JSON.stringify(s.input):"";t.push(`${i} ${a}`.trim());break}case"tool_result":{const i=s.content;if(typeof i=="string")t.push(i);else if(Array.isArray(i)){for(const a of i)if(a!==null&&typeof a=="object"){const l=a.text;typeof l=="string"&&t.push(l)}}break}case"image":t.push("[image]");break}}return t.join(`
108
+ `)){const a=i.endsWith("\r")?i.slice(0,-1):i;if(a===""){o();continue}if(a.startsWith(":"))continue;const l=a.indexOf(":"),u=l===-1?a:a.slice(0,l),d=l===-1?"":a.slice(l+1),p=d.startsWith(" ")?d.slice(1):d;switch(u){case"event":n=p;break;case"data":n===null&&s.length>0&&(p.startsWith("{")||p==="[DONE]")&&o(),s.push(p);break}}return o(),t}function cc(e){try{return JSON.parse(e)}catch{return null}}function Kh(e,t){if(e.event!==null&&e.event!=="")return e.event;const n=ly.safeParse(t);return n.success?n.data.type:""}function x3(e){if(e.data==="[DONE]")return!1;const t=cc(e.data),n=Kh(e,t);return n.startsWith("response.")||n==="error"}function Gh(e,t,n,s,o){e.length>=lc||e.push({index:t,timestamp:Date.now()-n,type:s,data:Op(o)})}function qa(e,t){const n=Ro(t,"error"),s=rt(n,"message")??rt(t,"message")??rt(t,"error");s!==null&&s.length>0&&(e.error=s)}function b3(e,t,n,s){let o="",i="",a="",l="",u=null,d=0,p=0,f=!1,m=!1;const h=new Map;let g=0,y=0;const b=[];for(const v of e){if(v.data==="[DONE]")break;const j=cc(v.data);if(j===null)continue;qa(t,j);const _=oy.safeParse(j);if(!_.success)continue;const k=_.data;if(g===0&&(y=Date.now()),s&&Gh(b,g,y,"chat.completion.chunk",k),g++,m||(o=k.id,i=k.model,m=!0),!f&&k.usage!==void 0&&k.usage!==null){d=k.usage.prompt_tokens??0,p=k.usage.completion_tokens??0,t.inputTokens=d;const S=Ro(j,"usage"),C=Ro(S,"prompt_tokens_details"),M=Zh(C,"cached_tokens");M!==null&&(t.cacheReadInputTokens=M),f=!0}for(const S of k.choices){const C=S.delta;C.content!==void 0&&C.content!==null&&(a+=C.content),C.reasoning_content!==void 0&&C.reasoning_content!==null&&(l+=C.reasoning_content),C.thinking!==void 0&&C.thinking!==null&&(l+=C.thinking);const M=C.think;if(M!=null&&(l+=M),S.finish_reason!==void 0&&S.finish_reason!==null&&(u=S.finish_reason),C.tool_calls!==void 0&&C.tool_calls!==null)for(const A of C.tool_calls){let P=h.get(A.index);P===void 0&&(P={index:A.index,type:"function",function:{name:"",arguments:""}},h.set(A.index,P)),A.id!==void 0&&(P.id=A.id),A.function?.name!==void 0&&(P.function.name+=A.function.name),A.function?.arguments!==void 0&&(P.function.arguments+=A.function.arguments)}}}s&&(t.streamingChunks={chunks:b,truncated:g>lc}),f||(p=Math.ceil(a.length/4)),t.outputTokens=p;const w={role:"assistant",content:a};return l.length>0&&(w.reasoning_content=l),h.size>0&&(w.tool_calls=[...h.values()]),JSON.stringify({id:o,object:"chat.completion",created:Math.floor(Date.now()/1e3),model:i!==""?i:n??"",choices:[{index:0,message:w,finish_reason:u}],usage:{prompt_tokens:d,completion_tokens:p,total_tokens:d+p}})}function v3(e){const t=go.safeParse(jr(e,"response"));if(t.success)return t.data;const n=go.safeParse(e);return n.success?n.data:null}function Jh(e){if(e.output_text!==void 0&&e.output_text.length>0)return e.output_text;const t=[];for(const n of e.output??[]){const s=h3(n,"content");for(const o of s){const i=rt(o,"type"),a=rt(o,"text");(i==="output_text"||i==="text")&&a!==null&&a.length>0&&t.push(a)}}return t.join(`
109
+ `)}function Au(e,t){const n=e.usage,s=n?.input_tokens??null,o=n?.output_tokens??null;s!==null&&(t.inputTokens=s),o!==null&&(t.outputTokens=o);const i=n?.input_tokens_details?.cached_tokens??null;return i!==null&&(t.cacheReadInputTokens=i),{inputTokens:s,outputTokens:o}}function Vi(e,t){const n=rt(e,"item_id");if(n!==null&&n.length>0)return n;const s=Zh(e,"output_index");return s!==null?String(s):`function-${String(t)}`}function Ha(e,t){const n=e.get(t);if(n!==void 0)return n;const s={type:"function_call",arguments:""};return e.set(t,s),s}function y3(e,t,n){if(rt(n,"type")!=="function_call")return;const s=Ha(e,t),o=rt(n,"id"),i=rt(n,"call_id"),a=rt(n,"name"),l=rt(n,"arguments"),u=rt(n,"status");o!==null&&(s.id=o),i!==null&&(s.call_id=i),a!==null&&(s.name=a),l!==null&&(s.arguments=l),u!==null&&(s.status=u)}function w3(e,t){const n=[];e.length>0&&n.push({type:"message",role:"assistant",content:[{type:"output_text",text:e,annotations:[]}]});for(const s of t.values())n.push(s);return n}function j3(e,t,n){const s=t??Math.ceil(n.length/4);return{input_tokens:e,output_tokens:s,total_tokens:e===null?s:e+s}}function k3(e){const t=e.completedResponse===null?"":Jh(e.completedResponse),n=t.length>0?t:e.outputText,s=e.completedResponse?.output,o=s!==void 0&&s.length>0?s:w3(n,e.calls),i=e.completedResponse?.usage??j3(e.inputTokens,e.outputTokens,n);return{...e.completedResponse??{},id:e.completedResponse?.id??e.responseId,object:"response",created_at:e.completedResponse?.created_at??Math.floor(Date.now()/1e3),status:e.completedResponse?.status??e.status??"completed",model:e.completedResponse?.model??e.model,output:o,output_text:n,usage:i}}function _3(e,t,n,s){let o=null,i="",a=n??"",l=null,u="",d=null,p=null,f=0,m=0;const h=[],g=new Map;for(const w of e){if(w.data==="[DONE]")break;const v=cc(w.data);if(v===null)continue;const j=Kh(w,v);if(f===0&&(m=Date.now()),s&&Gh(h,f,m,j===""?"response.event":j,v),f++,qa(t,v),j==="error")continue;const _=v3(v);if(_!==null){o=_,i=_.id,a=_.model??a,l=_.status??l;const S=Au(_,t);d=S.inputTokens??d,p=S.outputTokens??p,qa(t,_)}const k=rt(v,"delta");switch(j){case"response.output_text.delta":k!==null&&(u+=k);break;case"response.output_text.done":{const S=rt(v,"text");u.length===0&&S!==null&&(u=S);break}case"response.function_call_arguments.delta":{if(k!==null){const S=Ha(g,Vi(v,g.size));S.arguments+=k}break}case"response.function_call_arguments.done":{const S=rt(v,"arguments");if(S!==null){const C=Ha(g,Vi(v,g.size));C.arguments=S}break}case"response.output_item.added":case"response.output_item.done":{const S=Ro(v,"item");y3(g,Vi(v,g.size),S);break}case"response.failed":case"response.incomplete":l=j.slice(9);break;case"response.completed":l="completed";break}}s&&(t.streamingChunks={chunks:h,truncated:f>lc});const y=k3({completedResponse:o,responseId:i,model:a,status:l,outputText:u,calls:g,inputTokens:d,outputTokens:p}),b=go.safeParse(y);if(b.success){if(Au(b.data,t).outputTokens===null){const v=Jh(b.data),j=Math.ceil(v.length/4);t.outputTokens=j}return JSON.stringify(b.data)}if(t.outputTokens===null){const w=rt(y,"output_text")??u,v=Math.ceil(w.length/4);t.outputTokens=v}return JSON.stringify(y)}function yi(e,t,n,s=!0){const o=g3(e);return o.some(x3)?_3(o,t,n,s):b3(o,t,n,s)}const S3={sessionId:null,threadId:null,turnId:null,installationId:null,windowId:null};function Wa(e,t){if(!(typeof e!="object"||e===null||Array.isArray(e)))return Object.getOwnPropertyDescriptor(e,t)?.value}function Dt(e,t){const n=Wa(e,t);return typeof n=="string"&&n.length>0?n:null}function N3(e){if(typeof e!="string"||e.length===0)return null;try{return JSON.parse(e)}catch{return null}}function C3(e){const t=Wa(e,"client_metadata");if(t===void 0)return S3;const n=N3(Wa(t,"x-codex-turn-metadata"));return{sessionId:Dt(t,"session_id")??Dt(n,"session_id"),threadId:Dt(t,"thread_id")??Dt(n,"thread_id"),turnId:Dt(t,"turn_id")??Dt(n,"turn_id"),installationId:Dt(t,"x-codex-installation-id")??Dt(n,"installation_id"),windowId:Dt(t,"x-codex-window-id")??Dt(n,"window_id")}}function Ou(e){return C3(e).sessionId}function T3(){return{inputTokens:null,outputTokens:null,cacheCreationInputTokens:null,cacheReadInputTokens:null}}function zu(e){return e===void 0?null:e.get("x-agent-inspector-session-id")??e.get("x-session-affinity")}const E3={format:"openai",parseRequest(e,t){try{const n=JSON.parse(e),s=qp.safeParse(n);if(s.success)return{model:s.data.model,sessionId:Ou(n)??zu(t)};const o=Hp.safeParse(n);return o.success?{model:o.data.model,sessionId:Ou(n)??zu(t)}:null}catch{return null}},extractTokens(e){const t=Zp(e);if(t){let s=null;try{const o=JSON.parse(e);if(o!==null&&typeof o=="object"&&!Array.isArray(o)){const i=Object.getOwnPropertyDescriptor(o,"usage");if(i!==void 0&&typeof i.value=="object"&&i.value!==null){const a=Object.getOwnPropertyDescriptor(i.value,"prompt_tokens_details");if(a!==void 0&&typeof a.value=="object"&&a.value!==null){const l=Object.getOwnPropertyDescriptor(a.value,"cached_tokens");l!==void 0&&typeof l.value=="number"&&(s=l.value)}}}}catch{}return{inputTokens:t.usage.prompt_tokens??null,outputTokens:t.usage.completion_tokens??null,cacheCreationInputTokens:null,cacheReadInputTokens:s}}const n=Kp(e);if(n!==null){const s=n.usage;return{inputTokens:s?.input_tokens??null,outputTokens:s?.output_tokens??null,cacheCreationInputTokens:null,cacheReadInputTokens:s?.input_tokens_details?.cached_tokens??null}}return T3()},extractStream(e,t,n,s){return yi(e,t,n,s)},detectFormat(e){if(e===null)return!1;try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const n=Object.keys(t);return n.includes("model")&&(n.includes("messages")||n.includes("input"))&&!n.includes("system")}return!1}catch{return!1}}};Pn.register(E3);const R3="https://api.openai.com/v1",P3={name:"openai",matches(e){const t=e.toLowerCase();return!!(t.startsWith("openai-")||t.includes("gpt-")||t.includes("o1")||t.includes("o2")||t.includes("o3"))},getUpstreamBase(e,t){return t?.baseUrl!==void 0?t.baseUrl:R3},extractStream(e,t,n,s){return yi(e,t,n,s)}};vi.register(P3);const I3="https://open.bigmodel.cn/api/paas/v4",M3=["glm-","charglm-","cogview-","embedding-","rerank-"],A3={name:"zhipu",matches(e){const t=e.toLowerCase().replace(/\s+/g,"-");return M3.some(n=>t.startsWith(n))},getUpstreamBase(e,t){return t?.baseUrl??I3},extractStream(e,t,n,s){return yi(e,t,n,s)}};vi.register(A3);const O3="https://dashscope.aliyuncs.com/compatible-mode/v1",z3={name:"alibaba",matches(e){return!!e.toLowerCase().replace(/\s+/g,"-").startsWith("qwen")},getUpstreamBase(e,t){return O3},extractStream(e,t,n){return yi(e,t,n)}};vi.register(z3);function Yh(e,t){for(const n of Array.from(e))t(n)}const L3=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function uc(e){if(e.length===0)return 0;let t=0,n=0;return Yh(e,s=>{L3.test(s)?t+=1:n+=1}),Math.ceil(t*1)+Math.ceil(n/4)}function dc(e){if(e.length===0)return 0;let t=0;return Yh(e,()=>{t+=1}),t}function pc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Q(e,t){return e===null||typeof e!="object"||Array.isArray(e)?void 0:Object.getOwnPropertyDescriptor(e,t)?.value}const $3=["file","shell","browser","web","mcp","code","other"];function Za(e){const t=e.replace(/\s+/g," ").trim();return t.length<=120?t:`${t.slice(0,119)}...`}function Xh(e){if(e===null)return null;const t=e.replace(/\s+/g," ").trim();if(t.length===0)return null;const n=t.search(/[.!?。!?]/);return n>=24?Za(t.slice(0,n+1)):Za(t)}function D3(e,t){return`${e} ${t??""}`.toLowerCase()}function as(e,t){return t.some(n=>e.includes(n))}function Qh(e,t){const n=D3(e,t);return e.startsWith("mcp__")||e.startsWith("inspector_")||as(n,[" mcp","model context protocol"])?"mcp":as(n,["bash","shell","terminal","command","powershell","exec","process"])?"shell":as(n,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":as(n,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":as(n,["web","search","http","url","fetch"])?"web":as(n,["code","typescript","javascript","python","repl"])?"code":"other"}function e0(e){const t=Q(e,"properties");return t===null||typeof t!="object"||Array.isArray(t)?[]:Object.keys(t).sort((n,s)=>n.localeCompare(s))}function t0(e){const t=Q(e,"required");if(!Array.isArray(t))return[];const n=[];for(const s of t)typeof s=="string"&&s.length>0&&n.push(s);return n.sort((s,o)=>s.localeCompare(o))}function F3(e){const t=Q(e,"name");if(typeof t!="string"||t.length===0)return null;const n=Q(e,"description"),s=Q(e,"input_schema")??null,o=typeof n=="string"?n:null;return{name:t,description:o,descriptionPreview:Xh(o),category:Qh(t,o),parameterCount:e0(s).length,requiredParameters:t0(s),schema:s}}function U3(e){const t=Q(e,"function"),n=Q(e,"type");if(t===void 0&&typeof n!="string")return null;const s=Q(t,"name")??Q(e,"name")??(typeof n=="string"?n:void 0);if(typeof s!="string"||s.length===0)return null;const o=Q(t,"description")??Q(e,"description"),i=Q(t,"parameters")??Q(e,"parameters")??null,a=typeof o=="string"?o:null;return{name:s,description:a,descriptionPreview:Xh(a),category:Qh(s,a),parameterCount:e0(i).length,requiredParameters:t0(i),schema:i}}function B3(e){const t=U3(e);return t!==null?t:F3(e)}function V3(e){if(e==null)return null;if(typeof e=="string")return e;const t=Q(e,"type"),n=Q(e,"name"),s=Q(Q(e,"function"),"name");if(typeof t=="string"&&typeof s=="string"&&s.length>0)return`${t}: ${s}`;if(typeof t=="string"&&typeof n=="string"&&n.length>0)return`${t}: ${n}`;if(typeof t=="string")return t;const o=JSON.stringify(e);return o===void 0?null:Za(o)}function q3(e){const t=new Map;for(const n of e)t.set(n.category,(t.get(n.category)??0)+1);return $3.flatMap(n=>{const s=t.get(n)??0;return s>0?[{category:n,count:s}]:[]})}function fc(e){const t=Q(e,"tools");if(!Array.isArray(t)||t.length===0)return null;const n=[];for(const s of t){const o=B3(s);o!==null&&n.push(o)}return n.length===0?null:{tools:n,toolChoiceLabel:V3(Q(e,"tool_choice")),categories:q3(n)}}function Vn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const ys={parsed:null,toolNames:null};function H3(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const s=n;switch(s.type){case"text":typeof s.text=="string"&&t.push(s.text);break;case"thinking":case"think":typeof s.thinking=="string"&&t.push(s.thinking);break;case"tool_use":{const i=typeof s.name=="string"?s.name:"",a=s.input!==void 0?JSON.stringify(s.input):"";t.push(`${i} ${a}`.trim());break}case"tool_result":{const i=s.content;if(typeof i=="string")t.push(i);else if(Array.isArray(i)){for(const a of i)if(a!==null&&typeof a=="object"){const l=a.text;typeof l=="string"&&t.push(l)}}break}case"image":t.push("[image]");break}}return t.join(`
110
110
  `)}function W3(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];for(const n of e)if(n!==null&&typeof n=="object"){const s=n.text;n.type==="text"&&typeof s=="string"&&t.push(s)}return t.join(`
111
111
  `)}function Z3(e){if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const s=n;typeof s.name=="string"&&t.push(s.name),typeof s.description=="string"&&t.push(s.description),s.input_schema!==void 0&&t.push(JSON.stringify(s.input_schema))}return t.join(`
112
- `)}function qi(e,t,n,s){return{role:e,label:t,text:n,size:uc(n),characters:dc(n),path:s}}const K3={format:"anthropic",analyzeRequest(e){if(e===null)return Vn(e);try{const t=JSON.parse(e),n=pc(t)?.tools.length??null,s=Uf.safeParse(t);return s.success?{parsed:s.data,comparisonValue:s.data,messageCount:s.data.messages.length,toolCount:n}:Vn(e)}catch{return Vn(e)}},analyzeResponse(e){if(e===null)return ys;try{let t=JSON.parse(e);typeof t=="string"&&(t=JSON.parse(t));const n=Bf.safeParse(t);if(!n.success)return ys;const s=n.data.content.filter(o=>o.type==="tool_use").map(o=>o.name);return{parsed:n.data,toolNames:s.length>0?s:null}}catch{return ys}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,n=[];if(t.system!==void 0){const s=W3(t.system);s.length>0&&n.push(qi("system","system",s,"/system"))}if(Array.isArray(t.messages)&&t.messages.forEach((s,o)=>{if(s===null||typeof s!="object")return;const i=s,a=i.role==="user"||i.role==="assistant"?i.role:"user",l=H3(i.content);n.push(qi(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.tools)&&t.tools.length>0){const s=Z3(t.tools);n.push(qi("tools","tools",s,"/tools"))}return n.length>0?n:null}};function Ka(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const s=n,o=s.type;(o==="text"||o==="input_text"||o==="output_text")&&typeof s.text=="string"?t.push(s.text):(o==="image_url"||o==="input_image")&&t.push("[image]")}return t.join(`
112
+ `)}function qi(e,t,n,s){return{role:e,label:t,text:n,size:uc(n),characters:dc(n),path:s}}const K3={format:"anthropic",analyzeRequest(e){if(e===null)return Vn(e);try{const t=JSON.parse(e),n=fc(t)?.tools.length??null,s=Fp.safeParse(t);return s.success?{parsed:s.data,comparisonValue:s.data,messageCount:s.data.messages.length,toolCount:n}:Vn(e)}catch{return Vn(e)}},analyzeResponse(e){if(e===null)return ys;try{let t=JSON.parse(e);typeof t=="string"&&(t=JSON.parse(t));const n=Up.safeParse(t);if(!n.success)return ys;const s=n.data.content.filter(o=>o.type==="tool_use").map(o=>o.name);return{parsed:n.data,toolNames:s.length>0?s:null}}catch{return ys}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,n=[];if(t.system!==void 0){const s=W3(t.system);s.length>0&&n.push(qi("system","system",s,"/system"))}if(Array.isArray(t.messages)&&t.messages.forEach((s,o)=>{if(s===null||typeof s!="object")return;const i=s,a=i.role==="user"||i.role==="assistant"?i.role:"user",l=H3(i.content);n.push(qi(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.tools)&&t.tools.length>0){const s=Z3(t.tools);n.push(qi("tools","tools",s,"/tools"))}return n.length>0?n:null}};function Ka(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const s=n,o=s.type;(o==="text"||o==="input_text"||o==="output_text")&&typeof s.text=="string"?t.push(s.text):(o==="image_url"||o==="input_image")&&t.push("[image]")}return t.join(`
113
113
  `)}function G3(e){const t=[],n=Ka(e.content);n.length>0&&t.push(n);const s=typeof e.reasoning_content=="string"?e.reasoning_content:typeof e.thinking=="string"?e.thinking:typeof e.think=="string"?e.think:"";s.length>0&&t.push(s);const o=e.tool_calls;if(Array.isArray(o))for(const i of o){if(i===null||typeof i!="object")continue;const a=i.function;if(a===void 0)continue;const l=typeof a.name=="string"?a.name:"",u=typeof a.arguments=="string"?a.arguments:"";t.push(`${l} ${u}`.trim())}return t.join(`
114
114
  `)}function J3(e){if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const s=Q(n,"function"),o=Q(s,"name")??Q(n,"name"),i=Q(s,"description")??Q(n,"description"),a=Q(s,"parameters")??Q(n,"parameters");typeof o=="string"&&t.push(o),typeof i=="string"&&t.push(i),a!==void 0&&t.push(JSON.stringify(a))}return t.join(`
115
- `)}function Y3(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function X3(e){if(typeof e=="string")return e;const t=Q(e,"text");if(typeof t=="string")return t;const n=Ka(Q(e,"content"));if(n.length>0)return n;const s=Ka(Q(e,"output"));if(s.length>0)return s;const o=Q(e,"arguments");return typeof o=="string"?o:""}function Q3(e){const t=Q(e,"role");if(t==="system"||t==="user"||t==="assistant"||t==="tool")return t;const n=Q(e,"type");return n==="function_call_output"?"tool":"user"}function eT(e){const t=Q(e,"output");if(!Array.isArray(t))return[];const n=[];for(const s of t){if(Q(s,"type")!=="function_call")continue;const o=Q(s,"name");typeof o=="string"&&o.length>0&&n.push(o)}return n}function Bs(e,t,n,s){return{role:e,label:t,text:n,size:uc(n),characters:dc(n),path:s}}const tT={format:"openai",analyzeRequest(e){if(e===null)return Vn(e);try{const t=JSON.parse(e),n=pc(t)?.tools.length??null,s=Hf.safeParse(t);if(!s.success){const o=Wf.safeParse(t);return o.success?{parsed:o.data,comparisonValue:o.data,messageCount:Y3(o.data.input),toolCount:n}:Vn(e)}return{parsed:s.data,comparisonValue:s.data,messageCount:s.data.messages.length,toolCount:n}}catch{return Vn(e)}},analyzeResponse(e){if(e===null)return ys;const t=Kf(e);if(t===null){const s=Gf(e);if(s===null)return ys;const o=eT(s);return{parsed:s,toolNames:o.length>0?o:null}}const n=t.choices[0]?.message?.tool_calls?.map(s=>s.function?.name??"").filter(s=>s!=="")??[];return{parsed:t,toolNames:n.length>0?n:null}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,n=[];if(typeof t.instructions=="string"&&t.instructions.length>0&&n.push(Bs("system","instructions",t.instructions,"/instructions")),Array.isArray(t.messages)&&t.messages.forEach((s,o)=>{if(s===null||typeof s!="object")return;const i=s,a=i.role==="user"||i.role==="assistant"||i.role==="system"||i.role==="tool"?i.role:"user",l=G3(i);n.push(Bs(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.messages)||(typeof t.input=="string"&&t.input.length>0?n.push(Bs("user","input",t.input,"/input")):Array.isArray(t.input)&&t.input.forEach((s,o)=>{const i=Q3(s),a=X3(s);n.push(Bs(i,`[${o}] ${i}`,a,`/input/${o}`))})),Array.isArray(t.tools)&&t.tools.length>0){const s=J3(t.tools);n.push(Bs("tools","tools",s,"/tools"))}return n.length>0?n:null}},nT={format:"unknown",analyzeRequest(e){return Vn(e)},analyzeResponse(){return ys},anatomySegments(){return null}},sT={anthropic:K3,openai:tT,unknown:nT};function n0(e){return sT[e]}function ar(e){const t=a3(e.path);return t==="unknown"?e.apiFormat:t}const Lu="inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)] hover:text-foreground";function s0(e){return e.startsWith("PID:")||e.startsWith("process:")||e.startsWith("connection:")||e.includes("|")}function rT(e){return s0(e)?"No session ID":e.length>24?`${e.slice(0,12)}...${e.slice(-12)}`:e}function Hi({icon:e,children:t,title:n,className:s}){return r.jsxs("span",{className:$("inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",s),title:n,children:[e,r.jsx("span",{className:"min-w-0 font-mono tabular-nums",children:t})]})}function oT(){return r.jsxs("span",{className:"inline-flex h-6 shrink-0 items-center gap-1.5 rounded-md bg-[var(--inspector-surface-medium)] px-1.5 font-mono text-[10px] uppercase text-[var(--inspector-status-watch)] ring-1 ring-border/50",title:"This session has a turn that has not finished yet",children:[r.jsx(Ue,{className:"size-3 animate-spin"}),"Turn open"]})}function iT({conversationId:e,startTime:t,endTime:n,totalCalls:s,totalInputTokens:o,totalOutputTokens:i,expanded:a,onToggle:l,providers:u,isLoading:d=!1,userAgent:f,clientPid:p,clientProjectFolder:m,showClientIdentity:h=!0,showProcessMetadata:g=!0,timeDisplayFormat:y,onClear:b}){const[w,v]=c.useState(!1),j=J=>{J.stopPropagation(),b!==void 0&&v(!0)},S=c.useCallback(J=>{J.stopPropagation(),window.open(ef(e),"_blank","noopener,noreferrer")},[e]),k=u?.map(({provider:J,models:K})=>({provider:J,tooltip:K.length===1?K[0]??J:K.join(", ")}))??[],_=ac({userAgent:f,conversationId:e,clientProjectFolder:m}),C=xi(_),I=f!=null&&f!=="",A=C??f??null,P=C!==null&&I?`${C} - ${f}`:null,N=s0(e),M=rT(e),F=Jo(t,n,y),B=`${s} call${s!==1?"s":""}`;return r.jsxs("div",{role:"button",tabIndex:0,"data-nav-id":`conv-${e}`,"data-nav-action":a?"collapse":"expand",className:$("relative flex cursor-pointer items-start gap-2.5 overflow-hidden rounded-md bg-[var(--inspector-surface-low)] px-3 py-2.5 transition-colors","hover:bg-[var(--inspector-surface-medium)]","select-none","sticky top-0 z-10 mb-2","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none"),onClick:l,onKeyDown:J=>{J.target===J.currentTarget&&(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),l())},children:[r.jsx(e3,{items:k,ariaLabel:"Models used in this session",className:"mt-0.5"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:"shrink-0 rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:"Session"}),N&&g?p!=null?r.jsxs("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:`PID ${p}`,children:["PID ",p]}):r.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:e}):r.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:M}),!N&&g&&p!==null&&p!==void 0&&r.jsxs("span",{className:"shrink-0 rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-xs tabular-nums text-muted-foreground",title:`Client process ID ${p}`,children:["PID ",p]}),N&&g&&m!==null&&m!==void 0&&m!==""&&r.jsx("span",{className:"min-w-0 max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:m,children:m}),h&&A!==null&&A!==""&&r.jsxs("span",{className:"inline-flex min-h-6 shrink-0 flex-wrap items-center gap-1 rounded-md bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 text-xs text-muted-foreground",title:P??A,children:[r.jsx(bi,{client:_,className:"size-4 shrink-0",decorative:!0}),r.jsx("span",{className:"font-mono leading-snug tabular-nums",children:A})]}),d&&r.jsx(oT,{})]}),r.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[r.jsx(Hi,{icon:r.jsx(rn,{className:"size-3 shrink-0"}),title:F,children:F}),r.jsx(Hi,{icon:r.jsx(Go,{className:"size-3 shrink-0"}),children:B}),r.jsxs(Hi,{icon:r.jsx(rr,{className:"size-3 shrink-0"}),className:"max-w-full",children:[r.jsx("span",{className:"text-[var(--inspector-status-info)]",children:Me(o)})," / ",r.jsx("span",{className:"text-[var(--inspector-status-watch)]",children:Me(i)})]})]})]}),r.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[r.jsx("button",{type:"button",onClick:S,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&S(J)},"aria-label":`Open session ${e} in a new tab`,title:"Open this session in a new tab",className:Lu,children:r.jsx(Il,{className:"size-3.5"})}),b!==void 0&&r.jsx("button",{type:"button",onClick:j,"aria-label":`Clear group (${s} request${s!==1?"s":""})`,title:"Clear this group from the current view",className:Lu,children:r.jsx(jn,{className:"size-3.5"})}),r.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)] hover:text-foreground","aria-hidden":"true",children:a?r.jsx(nt,{className:"size-4 shrink-0"}):d?r.jsx(Ue,{className:"size-4 shrink-0 animate-spin"}):r.jsx(yt,{className:"size-4 shrink-0"})})]}),d&&r.jsx("span",{className:"pointer-events-none absolute inset-x-3 bottom-0 h-px overflow-hidden rounded-full bg-[var(--inspector-surface-medium)]","aria-hidden":"true",children:r.jsx("span",{className:"absolute inset-y-0 left-0 w-1/3 animate-pulse rounded-full bg-[var(--inspector-status-watch)] opacity-70"})}),r.jsx(Hh,{open:w,onOpenChange:v,title:"Clear this group from the current view?",description:`This will hide ${s} request${s!==1?"s":""} from the current view. Stored logs remain reloadable.`,confirmLabel:"Clear",variant:"destructive",onConfirm:()=>{b?.()}})]})}function aT(e){if(e.sessionId!==null&&e.sessionId!==""&&e.sessionId!==void 0)return e.sessionId;if(e.isTest===!0)return"provider-test";const t=e.clientPid!==null&&e.clientPid!==void 0,n=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0;if(!t&&!n)return"default";const s=t?`PID:${e.clientPid}`:"unknown",o=n?e.clientProjectFolder:"no-folder";return`${s}|${o}`}function lT(e){const t=new Map;for(const s of e){const o=aT(s),i=t.get(o);i!==void 0?i.push(s):t.set(o,[s])}const n=[];for(const[s,o]of t){const i=[...o].sort((a,l)=>a.timestamp.localeCompare(l.timestamp));n.push({id:s,conversationId:s,logs:i})}return n.sort((s,o)=>(s.logs[0]?.timestamp??"").localeCompare(o.logs[0]?.timestamp??"")),n}function cT(e,t,n){const s=new Array(e);return new Proxy(s,{get(o,i,a){if(typeof i=="string"){const l=i.charCodeAt(0);if(l>=48&&l<=57){const u=+i;if(Number.isInteger(u)&&u>=0&&u<e){let d=o[u];if(!d){const f=t[u*2];d=o[u]={index:u,key:n(u),start:f,size:t[u*2+1],end:f+t[u*2+1],lane:0}}return d}}if(i==="length")return e}return Reflect.get(o,i,a)}})}function ls(e,t,n){let s=n.initialDeps??[],o,i=!0;function a(){const l=e();return(l.length!==s.length||l.some((d,f)=>s[f]!==d))&&(s=l,o=t(...l),n?.onChange&&!(i&&n.skipInitialOnChange)&&n.onChange(o),i=!1),o}return a.updateDeps=l=>{s=l},a}function $u(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const uT=(e,t)=>Math.abs(e-t)<1.01,dT=(e,t,n)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>t.apply(this,o),n)}};let Vs;const Wi=()=>{if(Vs!==void 0)return Vs;if(typeof navigator>"u")return Vs=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Vs=!0;const e=navigator.maxTouchPoints;return Vs=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Du=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},fT=e=>e,pT=e=>{const t=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,o=new Array(s);for(let i=0;i<s;i++)o[i]=t+i;return o},mT=(e,t)=>{const n=e.scrollElement;if(!n)return;const s=e.targetWindow;if(!s)return;const o=a=>{const{width:l,height:u}=a;t({width:Math.round(l),height:Math.round(u)})};if(o(Du(n)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(a=>{const l=()=>{const u=a[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){o({width:d.inlineSize,height:d.blockSize});return}}o(Du(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},lr={passive:!0},hT=(e,t)=>{const n=e.scrollElement;if(!n)return;const s=()=>{t({width:n.innerWidth,height:n.innerHeight})};return s(),n.addEventListener("resize",s,lr),()=>{n.removeEventListener("resize",s)}},gT=typeof window>"u"?!0:"onscrollend"in window,r0=(e,t,n)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&gT;let a=0;const l=i?null:dT(o,()=>t(a,!1),e.options.isScrollingResetDelay),u=p=>()=>{a=n(s),l?.(),t(a,p)},d=u(!0),f=u(!1);return s.addEventListener("scroll",d,lr),i&&s.addEventListener("scrollend",f,lr),()=>{s.removeEventListener("scroll",d),i&&s.removeEventListener("scrollend",f)}},xT=(e,t)=>r0(e,t,n=>{const{horizontal:s,isRtl:o}=e.options;return s?n.scrollLeft*(o&&-1||1):n.scrollTop}),bT=(e,t)=>r0(e,t,n=>e.options.horizontal?n.scrollX:n.scrollY),vT=(e,t,n)=>{if(n.options.useCachedMeasurements){const s=n.indexFromElement(e),o=n.options.getItemKey(s);return n.itemSizeCache.get(o)??n.options.estimateSize(s)}if(t?.borderBoxSize){const s=t.borderBoxSize[0];if(s)return Math.round(s[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const s=n.indexFromElement(e),o=n.options.getItemKey(s),i=n.itemSizeCache.get(o);if(i!==void 0)return i}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},o0=(e,{adjustments:t=0,behavior:n},s)=>{var o,i;(i=(o=s.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[s.options.horizontal?"left":"top"]:e+t,behavior:n})},yT=o0,wT=o0;class jT{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var n,s,o;return((o=(s=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:s.now)==null?void 0:o.call(s))??Date.now()},this.observer=(()=>{let n=null;const s=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const a=()=>{const l=i.target,u=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);for(const[d,f]of this.elementsCache)if(f===l){this.elementsCache.delete(d);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(l,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var o;(o=s())==null||o.disconnect(),n=null},observe:o=>{var i;return(i=s())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=s())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=n=>{var s,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:fT,rangeExtractor:pT,onChange:()=>{},measureElement:vT,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in n){const h=n[m];h!==void 0&&(i[m]=h)}const a=this.options;let l=null,u=null,d=!1;if(a!==void 0&&a.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=a.count,h=i.count,g=this.getMeasurements(),y=m>0?((s=g[0])==null?void 0:s.key)??a.getItemKey(0):null,b=m>0?((o=g[m-1])==null?void 0:o.key)??a.getItemKey(m-1):null;if(h!==m||m>0&&h>0&&(i.getItemKey(0)!==y||i.getItemKey(h-1)!==b)){d=!0;const j=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??g[0]:null;j&&(l=[j.key,this.getScrollOffset()-j.start]);const S=i.followOnAppend===!0?"auto":i.followOnAppend||null;S&&h>m&&this.isAtEnd(a.scrollEndThreshold)&&(m===0||i.getItemKey(h-1)!==b)&&(u=S)}}this.options=i,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,p=0;if(l&&this.scrollOffset!==null){const[m,h]=l,g=this.getMeasurements(),{count:y,getItemKey:b}=this.options;let w=0;for(;w<y&&b(w)!==m;)w++;if(w<y){const v=g[w];if(v){const j=v.start+h;j!==this.scrollOffset&&(p=j-this.scrollOffset,this.scrollOffset=j,f=!0)}}}(f||u)&&(this.pendingScrollAnchor=[f?l[0]:null,f?l[1]:0,u,p])},this.notify=n=>{var s,o;(o=(s=this.options).onChange)==null||o.call(s,this,n)},this.maybeNotify=ls(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,a)=>{if(a&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const l=this.getScrollOffset();this.scrollDirection=a?l===i?this.scrollDirection:l<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=a,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,a=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},l=()=>{this._iosTouching=!1,!(!Wi()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",a,lr),i.addEventListener("touchend",l,lr),this.unsubs.push(()=>{i.removeEventListener("touchstart",a),i.removeEventListener("touchend",l),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[i,a,l,u]=o;i!==null&&!l&&(Wi()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),l&&this.scrollToEnd({behavior:l})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),s=this.getMaxScrollOffset();if(n<0||n>s)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=o,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,s)=>{const o=new Map,i=new Map;for(let a=s-1;a>=0;a--){const l=n[a];if(o.has(l.lane))continue;const u=i.get(l.lane);if(u==null||l.end>u.end?i.set(l.lane,l):l.end<u.end&&o.set(l.lane,!0),o.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((a,l)=>a.end===l.end?a.index-l.index:a.end-l.end)[0]:void 0},this.getMeasurementOptions=ls(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(n,s,o,i,a,l,u)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMin=null,{count:n,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:a,lanes:l,laneAssignmentMode:u}),{key:!1}),this.getMeasurements=ls(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:a,lanes:l,laneAssignmentMode:u},d)=>{const f=this.itemSizeCache;if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const g of this.laneAssignments.keys())g>=n&&this.laneAssignments.delete(g);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(g=>{this.itemSizeCache.set(g.key,g.size)}));const p=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),l===1){const g=this.options.gap,y=n*2;let b=this._flatMeasurements;if(!b||b.length<y){const j=new Float64Array(y);b&&p>0&&j.set(b.subarray(0,p*2)),b=j,this._flatMeasurements=b}let w;if(p===0)w=s+o;else{const j=p-1;w=b[j*2]+b[j*2+1]+g}for(let j=p;j<n;j++){const S=i(j),k=f.get(S),_=typeof k=="number"?k:this.options.estimateSize(j);b[j*2]=w,b[j*2+1]=_,w+=_+g}const v=cT(n,b,i);return this.measurementsCache=v,v}const m=this.measurementsCache.slice(0,p),h=new Array(l).fill(void 0);for(let g=0;g<p;g++){const y=m[g];y&&(h[y.lane]=g)}for(let g=p;g<n;g++){const y=i(g),b=this.laneAssignments.get(g);let w,v;const j=u==="estimate"||f.has(y);if(b!==void 0&&this.options.lanes>1){w=b;const C=h[w],I=C!==void 0?m[C]:void 0;v=I?I.end+this.options.gap:s+o}else{const C=this.options.lanes===1?m[g-1]:this.getFurthestMeasurement(m,g);v=C?C.end+this.options.gap:s+o,w=C?C.lane:g%this.options.lanes,this.options.lanes>1&&j&&this.laneAssignments.set(g,w)}const S=f.get(y),k=typeof S=="number"?S:this.options.estimateSize(g),_=v+k;m[g]={index:g,start:v,size:k,end:_,key:y,lane:w},h[w]=g}return this.measurementsCache=m,m},{key:!1,debug:()=>this.options.debug}),this.calculateRange=ls(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,s,o,i)=>n.length===0||s===0?(this.range=null,null):(this.range=ST(n,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ls(()=>{let n=null,s=null;const o=this.calculateRange();return o&&(n=o.startIndex,s=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,s]},(n,s,o,i,a)=>i===null||a===null?[]:n({startIndex:i,endIndex:a,overscan:s,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const s=this.options.indexAttribute,o=n.getAttribute(s);return o?parseInt(o,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(o!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,o-i),l=Math.min(this.options.count-1,o+i);return n>=a&&n<=l}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((a,l)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(l))});return}const s=this.indexFromElement(n),o=this.options.getItemKey(s),i=this.elementsCache.get(o);i!==n&&(i&&this.observer.unobserve(i),this.observer.observe(n),this.elementsCache.set(o,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,s)=>{var o,i;if(n<0||n>=this.options.count)return;let a,l,u;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)u=this.options.getItemKey(n),l=d[n*2],a=d[n*2+1];else{const m=this.measurementsCache[n];if(!m)return;u=m.key,l=m.start,a=m.size}const f=this.itemSizeCache.get(u)??a,p=s-f;if(p!==0){const m=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,h=m?this.getTotalSize():0,g=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:u,start:l,size:a,end:l+a,lane:0},p,this):l<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(u)||this.scrollDirection!=="backward"));(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(u,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-h):g&&this.applyScrollAdjustment(p),this.notify(!1)}},this.getVirtualItems=ls(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,s)=>{const o=[];for(let i=0,a=n.length;i<a;i++){const l=n[i],u=s[l];o.push(u)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const s=this.getMeasurements();if(s.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,a=i0(0,s.length-1,i?l=>o[l*2]:l=>$u(s[l]).start,n);return $u(s[a])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,s,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),a=this.getScrollOffset();s==="auto"&&(s=n>=a+i?"end":"start"),s==="center"?n+=(o-i)/2:s==="end"&&(n-=i);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,s="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const o=this.getSize(),i=this.getScrollOffset(),a=this.measurementsCache[n];if(!a)return;if(s==="auto")if(a.end>=i+o-this.options.scrollPaddingEnd)s="end";else if(a.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),s];const l=s==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,s,a.size),s]},this.scrollToOffset=(n,{align:s="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(n,s),a=this.now();this.scrollState={index:null,align:s,behavior:o,startedAt:a,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:s="auto",behavior:o="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getOffsetForIndex(n,s);if(!i)return;const[a,l]=i,u=this.now();this.scrollState={index:n,align:l,behavior:o,startedAt:u,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:s="auto"}={})=>{const o=this.getScrollOffset()+n,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n;const s=this.getMeasurements();let o;if(s.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,a=this._flatMeasurements;a!=null?o=a[i*2]+a[i*2+1]:o=((n=s[i])==null?void 0:n.end)??0}else{const i=Array(this.options.lanes).fill(null);let a=s.length-1;for(;a>=0&&i.some(l=>l===null);){const l=s[a];i[l.lane]===null&&(i[l.lane]=l.end),a--}o=Math.max(...i.filter(l=>l!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const s=this.getMeasurements();for(const o of s)o&&this.itemSizeCache.has(o.key)&&n.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return n},this._scrollToOffset=(n,{adjustments:s,behavior:o})=>{this._intendedScrollOffset=n+(s??0),this.options.scrollToFn(n,{behavior:o,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){t!==0&&(Wi()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=s?s[0]:this.scrollState.lastTargetOffset,i=1,a=o!==this.scrollState.lastTargetOffset;if(!a&&uT(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,a){const l=this.getSize()||600,u=Math.abs(o-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&u>l;this.scrollState.lastTargetOffset=o,d||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const i0=(e,t,n,s)=>{for(;e<=t;){const o=(e+t)/2|0,i=n(o);if(i<s)e=o+1;else if(i>s)t=o-1;else return o}return e>0?e-1:0};function kT(e,t,n){let s=0;for(;s<=t;){const o=(s+t)/2|0,i=e[o*2];if(i<n)s=o+1;else if(i>n)t=o-1;else return o}return s>0?s-1:0}function ST(e,t,n,s,o){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&o!==null){const d=kT(o,i,n);let f=d;const p=n+t;for(;f<i&&o[f*2]+o[f*2+1]<p;)f++;return{startIndex:d,endIndex:f}}let l=i0(0,i,d=>e[d].start,n),u=l;if(s===1)for(;u<i&&e[u].end<n+t;)u++;else if(s>1){const d=Array(s).fill(0);for(;u<i&&d.some(p=>p<n+t);){const p=e[u];d[p.lane]=p.end,u++}const f=Array(s).fill(n+t);for(;l>=0&&f.some(p=>p>=n);){const p=e[l];f[p.lane]=p.start,l--}l=Math.max(0,l-l%s),u=Math.min(i,u+(s-1-u%s))}return{startIndex:l,endIndex:u}}const Zi=typeof document<"u"?c.useLayoutEffect:c.useEffect;function a0({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...s}){const o=c.useReducer(d=>d+1,0)[1],i=c.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=t,i.current.mode=n;const a=d=>{const f=i.current;if(!f.enabled||!f.container)return;const p=d.getTotalSize();if(p!==f.lastSize){f.lastSize=p;const w=d.options.horizontal?"width":"height";f.container.style[w]=`${p}px`}const m=!!d.options.horizontal,h=f.mode==="transform",g=m?"left":"top",y=d.options.scrollMargin,b=d.getVirtualItems();for(const w of b){const v=w.start-y,j=d.elementsCache.get(w.key);j&&f.lastPositions.get(j)!==v&&(f.lastPositions.set(j,v),h?j.style.transform=m?`translate3d(${v}px, 0, 0)`:`translate3d(0, ${v}px, 0)`:j.style[g]=`${v}px`)}},l={...s,onChange:(d,f)=>{var p;const m=i.current;let h=!0;if(m.enabled){a(d);const g=d.range,y=m.prevRange;h=!y||y.isScrolling!==d.isScrolling||y.startIndex!==g?.startIndex||y.endIndex!==g?.endIndex,h&&(m.prevRange=g?{startIndex:g.startIndex,endIndex:g.endIndex,isScrolling:d.isScrolling}:null)}h&&(e&&f?Os.flushSync(o):o()),(p=s.onChange)==null||p.call(s,d,f)}},[u]=c.useState(()=>{const d=new jT(l);return Object.assign(d,{containerRef:f=>{const p=i.current;if(p.container=f,p.lastSize=null,f&&p.enabled){const m=d.getTotalSize();p.lastSize=m;const h=d.options.horizontal?"width":"height";f.style[h]=`${m}px`}}})});return u.setOptions(l),Zi(()=>u._didMount(),[]),Zi(()=>u._willUpdate()),Zi(()=>{a(u)}),u}function _T(e){return a0({observeElementRect:mT,observeElementOffset:xT,scrollToFn:wT,...e})}function NT(e){return a0({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:hT,observeElementOffset:bT,scrollToFn:yT,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const un="agent-inspector:focus-log";function Ms(e){window.dispatchEvent(new CustomEvent(un,{detail:e}))}function wi(e){if(typeof CustomEvent>"u"||!(e instanceof CustomEvent))return null;const t=e.detail,n=Q(t,"logId");if(typeof n!="number"||!Number.isInteger(n)||n<0)return null;const s=Q(t,"tab");switch(s){case"anatomy":case"request":case"response":break;case void 0:break;default:return null}const o=Q(t,"source"),i=Q(t,"toolCallIndex"),a=typeof i=="number"&&Number.isInteger(i)&&i>=0?{logId:n,tab:s??"request",toolCallIndex:i}:{logId:n,tab:s??"request"};switch(o){case"virtualizer":return{...a,source:o};case void 0:return a;default:return null}}function CT(e){switch(e){case"end_turn":case"tool_use":return e;case"max_tokens":return"length";default:return null}}function TT(e){switch(e){case"stop":case"length":return e;case"max_tokens":return"length";default:return null}}function ET(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function l0(e){if(e.responseText===null)return null;try{let t=JSON.parse(e.responseText);if(typeof t=="string"&&(t=JSON.parse(t)),!Gs(t))return null;if(typeof t.stop_reason=="string")return CT(t.stop_reason);if(Array.isArray(t.choices))for(const n of t.choices){if(!Gs(n)||typeof n.finish_reason!="string")continue;const s=TT(n.finish_reason);if(s!==null)return s}if(Array.isArray(t.output)){for(const n of t.output)if(Gs(n)&&n.type==="function_call")return"tool_use";if(t.status==="completed")return"stop"}if(t.status==="incomplete"&&Gs(t.incomplete_details)){const n=t.incomplete_details.reason;if(typeof n=="string"&&ET(n))return"length"}return null}catch{return null}}function mc(e){return e==="end_turn"||e==="stop"||e==="length"}function Nt({className:e,style:t,d:n,eyeStalks:s,eyes:o,legs:i,extras:a}){return r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:t,className:$("inline-block size-5",e),children:[r.jsx("path",{d:n}),s,o,i,a]})}const Mn=r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),r.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),r.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),r.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]}),c0=r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"7",y1:"16",x2:"5.5",y2:"18.5"}),r.jsx("line",{x1:"9.5",y1:"17",x2:"8.5",y2:"19.5"}),r.jsx("line",{x1:"14.5",y1:"17",x2:"15.5",y2:"19.5"}),r.jsx("line",{x1:"17",y1:"16",x2:"18.5",y2:"18.5"})]});function u0({className:e}){return r.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),r.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"})]}),legs:Mn,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),r.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function RT({className:e}){return r.jsx(Nt,{className:e,d:"M4 13 C4 7 7.5 5.5 12 5.5 C16.5 5.5 20 7 20 13 C20 17.5 16.5 19 12 19 C7.5 19 4 17.5 4 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"9.5",y1:"6.5",x2:"9.5",y2:"4.5"}),r.jsx("line",{x1:"14.5",y1:"6.5",x2:"14.5",y2:"4.5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"14.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"})]}),legs:c0,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12"}),r.jsx("path",{d:"M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12"})]})})}function PT({className:e}){return r.jsx(Nt,{className:e,d:"M3 13.5 C3 8 7 6 12 6 C17 6 21 8 21 13.5 C21 17 17 19 12 19 C7 19 3 17 3 13.5 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"7",y1:"7",x2:"6.5",y2:"4.5"}),r.jsx("line",{x1:"17",y1:"7",x2:"17.5",y2:"4.5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"6.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"17.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:Mn,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13"}),r.jsx("path",{d:"M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13"})]})})}function MT({className:e}){return r.jsx(Nt,{className:e,d:"M6 14 C6 8 9 5.5 12 5.5 C15 5.5 18 8 18 14 C18 18 15 20 12 20 C9 20 6 18 6 14 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"6.5",x2:"10",y2:"3.5"}),r.jsx("line",{x1:"14",y1:"6.5",x2:"14",y2:"3.5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"10",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"14",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"7",y1:"17",x2:"5",y2:"20.5"}),r.jsx("line",{x1:"9.5",y1:"18.5",x2:"8.5",y2:"21.5"}),r.jsx("line",{x1:"14.5",y1:"18.5",x2:"15.5",y2:"21.5"}),r.jsx("line",{x1:"17",y1:"17",x2:"19",y2:"20.5"})]}),extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12"}),r.jsx("path",{d:"M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12"})]})})}function IT({className:e}){return r.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 L13 4 L14 7 C16 7 19 9 19 13 C19 16 16 18 13 18 L12 21 L11 18 C8 18 5 16 5 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),r.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:Mn,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),r.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function AT({className:e}){return r.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),r.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),r.jsx("line",{x1:"13.5",y1:"4",x2:"15.5",y2:"5"})]}),legs:Mn,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),r.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function OT({className:e}){return r.jsx(Nt,{className:e,d:"M5.5 13.5 C5.5 10 8.5 8 12 8 C15.5 8 18.5 10 18.5 13.5 C18.5 16 15.5 17.5 12 17.5 C8.5 17.5 5.5 16 5.5 13.5 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"6"}),r.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"6"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"9",y1:"6",x2:"11",y2:"6.5"}),r.jsx("line",{x1:"13",y1:"6",x2:"15",y2:"6.5"})]}),legs:c0,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M6 11.5 C4.5 10.5 3 11 3.5 12.5 C4 13.5 5 13 5.5 12.5"}),r.jsx("path",{d:"M18 11.5 C19.5 10.5 21 11 20.5 12.5 C20 13.5 19 13 18.5 12.5"})]})})}function zT({className:e}){return r.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),r.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:Mn,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),r.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),r.jsx("line",{x1:"8.5",y1:"4",x2:"10.5",y2:"4.5"}),r.jsx("line",{x1:"15.5",y1:"4",x2:"13.5",y2:"4.5"}),r.jsx("path",{d:"M9 15.5 C10 14.5 14 14.5 15 15.5"})]})})}function LT({className:e}){return r.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),r.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"}),r.jsx("circle",{cx:"14.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"})]}),legs:Mn,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),r.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),r.jsx("ellipse",{cx:"12",cy:"15",rx:"2",ry:"1.5",fill:"currentColor",stroke:"none"})]})})}function $T({className:e}){return r.jsx(Nt,{className:e,d:"M4.5 13 C4.5 8 7.5 6 12 6 C16.5 6 19.5 8 19.5 13 C19.5 17 16.5 18.5 12 18.5 C7.5 18.5 4.5 17 4.5 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"9.5",y1:"7",x2:"9",y2:"5"}),r.jsx("line",{x1:"14.5",y1:"7",x2:"15",y2:"5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"15",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"})]}),legs:Mn,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12"}),r.jsx("path",{d:"M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12"}),r.jsx("path",{d:"M9 14.5 C10 16 14 16 15 14.5"}),r.jsx("circle",{cx:"7",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"}),r.jsx("circle",{cx:"17",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"})]})})}function DT({className:e}){return r.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5.5"}),r.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5.5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"7.5",y1:"5.5",x2:"16.5",y2:"5.5"}),r.jsx("rect",{x:"7",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"}),r.jsx("rect",{x:"13",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"})]}),legs:Mn,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),r.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),r.jsx("path",{d:"M9.5 15 C10.5 16 13.5 16 14.5 15"})]})})}function FT({className:e}){return r.jsx(Nt,{className:e,d:"M7 13.5 C7 10.5 9.5 9 12 9 C14.5 9 17 10.5 17 13.5 C17 16 14.5 17.5 12 17.5 C9.5 17.5 7 16 7 13.5 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10.5",y1:"9.5",x2:"10.5",y2:"8"}),r.jsx("line",{x1:"13.5",y1:"9.5",x2:"13.5",y2:"8"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"10.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"13.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"8",y1:"16",x2:"6.5",y2:"18"}),r.jsx("line",{x1:"10",y1:"17",x2:"9.5",y2:"19"}),r.jsx("line",{x1:"14",y1:"17",x2:"14.5",y2:"19"}),r.jsx("line",{x1:"16",y1:"16",x2:"17.5",y2:"18"})]}),extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13"}),r.jsx("path",{d:"M16.5 12 C17.5 11 18.5 11.5 18 13 C17.5 14 17 13.5 16.5 13"})]})})}const Ga=[u0,RT,PT,MT,IT,AT,OT,zT,LT,$T,DT,FT];function hc(e){return Ga[Math.abs(e)%Ga.length]??u0}function UT(e){const t=Ga.length-2;return t<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%t+t)%t}function BT(e){return hc(UT(e))}const VT="x-anthropic-billing-header:";function qT(e){return e.trimStart().toLowerCase().startsWith(VT)}function HT(e){return fc(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function WT(e){if(!fc(e))return!1;const t=Q(e,"type"),n=Q(e,"text");return typeof t!="string"||t!=="text"||typeof n!="string"?!1:qT(n)}function ZT(e){let t;try{t=JSON.parse(e)}catch{return{body:e,removed:0}}if(!HT(t))return{body:e,removed:0};const n=t.system;if(!Array.isArray(n)||n.length===0)return{body:e,removed:0};const s=[];let o=0;for(const i of n){if(WT(i)){o+=1;continue}s.push(i)}return o===0?{body:e,removed:0}:(s.length===0?delete t.system:t.system=s,{body:JSON.stringify(t),removed:o})}const KT=400,Fu=2e3;function GT(e){return Array.isArray(e)}function JT(e,t){const n=[e];let s=0;for(;n.length>0;){const o=n.pop();if(o!==void 0){if(s+=1,s>t)return s;if(!(o===null||typeof o!="object")){if(GT(o)){for(const i of o)n.push(i);continue}for(const i of Object.keys(o)){const a=o[i];a!==void 0&&n.push(a)}}}}return s}function YT(e){const t=JT(e,Fu+1);return t<=KT?{depth:Number.POSITIVE_INFINITY}:t<=Fu?{depth:3}:{depth:2}}function XT(e){try{const t=JSON.parse(e);return{kind:"json",data:Po(t)}}catch{return{kind:"text"}}}function Ki(e){const t=c.useMemo(()=>e===null?null:XT(e),[e]),n=t?.kind==="json"?t.data:null,s=c.useMemo(()=>n===null?null:YT(n),[n]),[o,i]=c.useState(!1),[a,l]=c.useState(0),[u,d]=c.useState(0),[f,p]=c.useTransition(),m=c.useCallback(()=>{const h=!o,g=h&&s!==null?s.depth:0;p(()=>{i(h),l(g),d(y=>y+1)})},[o,s]);return{parsedData:n,policy:s,isExpanded:o,toggle:m,isPending:f,bulkDepth:a,bulkRevision:u}}function Po(e){if(e==null)return null;switch(typeof e){case"string":return e;case"number":return e;case"boolean":return e;case"object":{if(Array.isArray(e))return e.map(n=>Po(n));const t={};for(const n of Object.keys(e)){const s=Object.getOwnPropertyDescriptor(e,n);t[n]=Po(s?.value)}return t}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function d0({className:e,orientation:t="horizontal",...n}){return r.jsx(XN,{"data-slot":"tabs","data-orientation":t,orientation:t,className:$("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...n})}const QT=tf("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function f0({className:e,variant:t="default",...n}){return r.jsx(QN,{"data-slot":"tabs-list","data-variant":t,className:$(QT({variant:t}),e),...n})}function xn({className:e,...t}){return r.jsx(eC,{"data-slot":"tabs-trigger",className:$("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-muted-foreground hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:border-border data-[state=active]:bg-background data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",e),...t})}function jt({className:e,...t}){return r.jsx(tC,{"data-slot":"tabs-content",className:$("flex-1 outline-none",e),...t})}function vn(e){const[t,n]=c.useState(!1),s=c.useRef(null);c.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]);const o=c.useCallback(i=>{i.stopPropagation(),e!==null&&Pt(e).then(a=>{a&&(n(!0),s.current!==null&&clearTimeout(s.current),s.current=setTimeout(()=>n(!1),2e3))})},[e]);return{copied:t,copy:o}}const e4=c.lazy(()=>Gt(()=>import("./CompareDrawer-DB2KggLE.js"),__vite__mapDeps([2,1])).then(e=>({default:e.CompareDrawer}))),t4=c.lazy(()=>Gt(()=>import("./InspectorPet-CfwDw6kD.js"),__vite__mapDeps([3,1])).then(e=>({default:e.InspectorPet}))),n4=c.lazy(()=>Gt(()=>import("./ReplayDialog-3Pl7EKjp.js"),__vite__mapDeps([4,1,5])).then(e=>({default:e.ReplayDialog}))),s4=c.lazy(()=>Gt(()=>import("./RequestAnatomy-BcPjcHLX.js"),__vite__mapDeps([6,1])).then(e=>({default:e.RequestAnatomy}))),r4=c.lazy(()=>Gt(()=>import("./ResponseView-DOx51wV3.js"),__vite__mapDeps([5,1])).then(e=>({default:e.ResponseView}))),o4=c.lazy(()=>Gt(()=>import("./StreamingChunkSequence-LkYJWM1A.js"),__vite__mapDeps([7,1])).then(e=>({default:e.StreamingChunkSequence}))),Ja=c.lazy(()=>Gt(()=>import("./json-viewer-WctIbAh_.js"),__vite__mapDeps([8,1])).then(e=>({default:e.JsonViewer}))),i4=c.lazy(()=>Gt(()=>import("./json-viewer-WctIbAh_.js"),__vite__mapDeps([8,1])).then(e=>({default:e.JsonViewerFromString}))),a4=1200,l4=12;function c4(e){const{containerRef:t,setExpandToPath:n,ensureTabActive:s,highlightMs:o}=e,i=c.useRef(null);return c.useCallback(a=>{s?.(),n(a.path);const l=p=>{p.scrollIntoView({behavior:"smooth",block:"center"}),p.classList.add("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{p.classList.remove("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),n(null)},o??a4)},d=`[data-anatomy-path="${(p=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(p):p.replace(/(["'\\[\](){}])/g,"\\$1"))(a.path)}"]`,f=p=>{const m=t.current;if(m!==null){const h=m.querySelector(d);if(h!==null){l(h);return}}p>0?window.requestAnimationFrame(()=>f(p-1)):n(null)};window.requestAnimationFrame(()=>f(l4))},[t,s,o,n])}const Uu="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.";function gs(e){return e<1024?`${e.toLocaleString()} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(1)} GiB`}function u4(e,t){const n=[];return e!=null&&n.push(`Request ${gs(e)}`),t!=null&&n.push(`Response ${gs(t)}`),n.length===0?null:n.join(" · ")}function d4(e){if(e instanceof Zo)return{title:"Full bodies timed out",detail:"The log store did not answer before the UI timeout. Compact metadata is still available; retry loading the bodies."};if(e instanceof Error){const t=e.message.trim();return{title:"Full bodies could not be loaded",detail:t===""?Uu:t}}return{title:"Full bodies could not be loaded",detail:Uu}}class p0{diff(t,n,s={}){let o;typeof s=="function"?(o=s,s={}):"callback"in s&&(o=s.callback);const i=this.castInput(t,s),a=this.castInput(n,s),l=this.removeEmpty(this.tokenize(i,s)),u=this.removeEmpty(this.tokenize(a,s));return this.diffWithOptionsObj(l,u,s,o)}diffWithOptionsObj(t,n,s,o){var i;const a=v=>{if(v=this.postProcess(v,s),o){setTimeout(function(){o(v)},0);return}else return v},l=n.length,u=t.length;let d=1,f=l+u;s.maxEditLength!=null&&(f=Math.min(f,s.maxEditLength));const p=(i=s.timeout)!==null&&i!==void 0?i:1/0,m=Date.now()+p,h=[{oldPos:-1,lastComponent:void 0}];let g=this.extractCommon(h[0],n,t,0,s);if(h[0].oldPos+1>=u&&g+1>=l)return a(this.buildValues(h[0].lastComponent,n,t));let y=-1/0,b=1/0;const w=()=>{for(let v=Math.max(y,-d);v<=Math.min(b,d);v+=2){let j;const S=h[v-1],k=h[v+1];S&&(h[v-1]=void 0);let _=!1;if(k){const I=k.oldPos-v;_=k&&0<=I&&I<l}const C=S&&S.oldPos+1<u;if(!_&&!C){h[v]=void 0;continue}if(!C||_&&S.oldPos<k.oldPos?j=this.addToPath(k,!0,!1,0,s):j=this.addToPath(S,!1,!0,1,s),g=this.extractCommon(j,n,t,v,s),j.oldPos+1>=u&&g+1>=l)return a(this.buildValues(j.lastComponent,n,t))||!0;h[v]=j,j.oldPos+1>=u&&(b=Math.min(b,v-1)),g+1>=l&&(y=Math.max(y,v+1))}d++};if(o)(function v(){setTimeout(function(){if(d>f||Date.now()>m)return o(void 0);w()||v()},0)})();else for(;d<=f&&Date.now()<=m;){const v=w();if(v)return v}}addToPath(t,n,s,o,i){const a=t.lastComponent;return a&&!i.oneChangePerToken&&a.added===n&&a.removed===s?{oldPos:t.oldPos+o,lastComponent:{count:a.count+1,added:n,removed:s,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+o,lastComponent:{count:1,added:n,removed:s,previousComponent:a}}}extractCommon(t,n,s,o,i){const a=n.length,l=s.length;let u=t.oldPos,d=u-o,f=0;for(;d+1<a&&u+1<l&&this.equals(s[u+1],n[d+1],i);)d++,u++,f++,i.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return f&&!i.oneChangePerToken&&(t.lastComponent={count:f,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=u,d}equals(t,n,s){return s.comparator?s.comparator(t,n):t===n||!!s.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let s=0;s<t.length;s++)t[s]&&n.push(t[s]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,s){const o=[];let i;for(;t;)o.push(t),i=t.previousComponent,delete t.previousComponent,t=i;o.reverse();const a=o.length;let l=0,u=0,d=0;for(;l<a;l++){const f=o[l];if(f.removed)f.value=this.join(s.slice(d,d+f.count)),d+=f.count;else{if(!f.added&&this.useLongestToken){let p=n.slice(u,u+f.count);p=p.map(function(m,h){const g=s[d+h];return g.length>m.length?g:m}),f.value=this.join(p)}else f.value=this.join(n.slice(u,u+f.count));u+=f.count,f.added||(d+=f.count)}}return o}}class f4 extends p0{constructor(){super(...arguments),this.tokenize=h0}equals(t,n,s){return s.ignoreWhitespace?((!s.newlineIsToken||!t.includes(`
115
+ `)}function Y3(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function X3(e){if(typeof e=="string")return e;const t=Q(e,"text");if(typeof t=="string")return t;const n=Ka(Q(e,"content"));if(n.length>0)return n;const s=Ka(Q(e,"output"));if(s.length>0)return s;const o=Q(e,"arguments");return typeof o=="string"?o:""}function Q3(e){const t=Q(e,"role");if(t==="system"||t==="user"||t==="assistant"||t==="tool")return t;const n=Q(e,"type");return n==="function_call_output"?"tool":"user"}function eT(e){const t=Q(e,"output");if(!Array.isArray(t))return[];const n=[];for(const s of t){if(Q(s,"type")!=="function_call")continue;const o=Q(s,"name");typeof o=="string"&&o.length>0&&n.push(o)}return n}function Bs(e,t,n,s){return{role:e,label:t,text:n,size:uc(n),characters:dc(n),path:s}}const tT={format:"openai",analyzeRequest(e){if(e===null)return Vn(e);try{const t=JSON.parse(e),n=fc(t)?.tools.length??null,s=qp.safeParse(t);if(!s.success){const o=Hp.safeParse(t);return o.success?{parsed:o.data,comparisonValue:o.data,messageCount:Y3(o.data.input),toolCount:n}:Vn(e)}return{parsed:s.data,comparisonValue:s.data,messageCount:s.data.messages.length,toolCount:n}}catch{return Vn(e)}},analyzeResponse(e){if(e===null)return ys;const t=Zp(e);if(t===null){const s=Kp(e);if(s===null)return ys;const o=eT(s);return{parsed:s,toolNames:o.length>0?o:null}}const n=t.choices[0]?.message?.tool_calls?.map(s=>s.function?.name??"").filter(s=>s!=="")??[];return{parsed:t,toolNames:n.length>0?n:null}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,n=[];if(typeof t.instructions=="string"&&t.instructions.length>0&&n.push(Bs("system","instructions",t.instructions,"/instructions")),Array.isArray(t.messages)&&t.messages.forEach((s,o)=>{if(s===null||typeof s!="object")return;const i=s,a=i.role==="user"||i.role==="assistant"||i.role==="system"||i.role==="tool"?i.role:"user",l=G3(i);n.push(Bs(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.messages)||(typeof t.input=="string"&&t.input.length>0?n.push(Bs("user","input",t.input,"/input")):Array.isArray(t.input)&&t.input.forEach((s,o)=>{const i=Q3(s),a=X3(s);n.push(Bs(i,`[${o}] ${i}`,a,`/input/${o}`))})),Array.isArray(t.tools)&&t.tools.length>0){const s=J3(t.tools);n.push(Bs("tools","tools",s,"/tools"))}return n.length>0?n:null}},nT={format:"unknown",analyzeRequest(e){return Vn(e)},analyzeResponse(){return ys},anatomySegments(){return null}},sT={anthropic:K3,openai:tT,unknown:nT};function n0(e){return sT[e]}function ar(e){const t=a3(e.path);return t==="unknown"?e.apiFormat:t}const Lu="inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)] hover:text-foreground";function s0(e){return e.startsWith("PID:")||e.startsWith("process:")||e.startsWith("connection:")||e.includes("|")}function rT(e){return s0(e)?"No session ID":e.length>24?`${e.slice(0,12)}...${e.slice(-12)}`:e}function Hi({icon:e,children:t,title:n,className:s}){return r.jsxs("span",{className:$("inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",s),title:n,children:[e,r.jsx("span",{className:"min-w-0 font-mono tabular-nums",children:t})]})}function oT(){return r.jsxs("span",{className:"inline-flex h-6 shrink-0 items-center gap-1.5 rounded-md bg-[var(--inspector-surface-medium)] px-1.5 font-mono text-[10px] uppercase text-[var(--inspector-status-watch)] ring-1 ring-border/50",title:"This session has a turn that has not finished yet",children:[r.jsx(Ue,{className:"size-3 animate-spin"}),"Turn open"]})}function iT({conversationId:e,startTime:t,endTime:n,totalCalls:s,totalInputTokens:o,totalOutputTokens:i,expanded:a,onToggle:l,providers:u,isLoading:d=!1,userAgent:p,clientPid:f,clientProjectFolder:m,showClientIdentity:h=!0,showProcessMetadata:g=!0,timeDisplayFormat:y,onClear:b}){const[w,v]=c.useState(!1),j=J=>{J.stopPropagation(),b!==void 0&&v(!0)},_=c.useCallback(J=>{J.stopPropagation(),window.open(ep(e),"_blank","noopener,noreferrer")},[e]),k=u?.map(({provider:J,models:K})=>({provider:J,tooltip:K.length===1?K[0]??J:K.join(", ")}))??[],S=ac({userAgent:p,conversationId:e,clientProjectFolder:m}),C=xi(S),M=p!=null&&p!=="",A=C??p??null,P=C!==null&&M?`${C} - ${p}`:null,N=s0(e),I=rT(e),F=Jo(t,n,y),B=`${s} call${s!==1?"s":""}`;return r.jsxs("div",{role:"button",tabIndex:0,"data-nav-id":`conv-${e}`,"data-nav-action":a?"collapse":"expand",className:$("relative flex cursor-pointer items-start gap-2.5 overflow-hidden rounded-md bg-[var(--inspector-surface-low)] px-3 py-2.5 transition-colors","hover:bg-[var(--inspector-surface-medium)]","select-none","sticky top-0 z-10 mb-2","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none"),onClick:l,onKeyDown:J=>{J.target===J.currentTarget&&(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),l())},children:[r.jsx(e3,{items:k,ariaLabel:"Models used in this session",className:"mt-0.5"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:"shrink-0 rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:"Session"}),N&&g?f!=null?r.jsxs("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:`PID ${f}`,children:["PID ",f]}):r.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:e}):r.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:I}),!N&&g&&f!==null&&f!==void 0&&r.jsxs("span",{className:"shrink-0 rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-xs tabular-nums text-muted-foreground",title:`Client process ID ${f}`,children:["PID ",f]}),N&&g&&m!==null&&m!==void 0&&m!==""&&r.jsx("span",{className:"min-w-0 max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:m,children:m}),h&&A!==null&&A!==""&&r.jsxs("span",{className:"inline-flex min-h-6 shrink-0 flex-wrap items-center gap-1 rounded-md bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 text-xs text-muted-foreground",title:P??A,children:[r.jsx(bi,{client:S,className:"size-4 shrink-0",decorative:!0}),r.jsx("span",{className:"font-mono leading-snug tabular-nums",children:A})]}),d&&r.jsx(oT,{})]}),r.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[r.jsx(Hi,{icon:r.jsx(rn,{className:"size-3 shrink-0"}),title:F,children:F}),r.jsx(Hi,{icon:r.jsx(Go,{className:"size-3 shrink-0"}),children:B}),r.jsxs(Hi,{icon:r.jsx(rr,{className:"size-3 shrink-0"}),className:"max-w-full",children:[r.jsx("span",{className:"text-[var(--inspector-status-info)]",children:Ie(o)})," / ",r.jsx("span",{className:"text-[var(--inspector-status-watch)]",children:Ie(i)})]})]})]}),r.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[r.jsx("button",{type:"button",onClick:_,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&_(J)},"aria-label":`Open session ${e} in a new tab`,title:"Open this session in a new tab",className:Lu,children:r.jsx(Ml,{className:"size-3.5"})}),b!==void 0&&r.jsx("button",{type:"button",onClick:j,"aria-label":`Clear group (${s} request${s!==1?"s":""})`,title:"Clear this group from the current view",className:Lu,children:r.jsx(jn,{className:"size-3.5"})}),r.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)] hover:text-foreground","aria-hidden":"true",children:a?r.jsx(nt,{className:"size-4 shrink-0"}):d?r.jsx(Ue,{className:"size-4 shrink-0 animate-spin"}):r.jsx(yt,{className:"size-4 shrink-0"})})]}),d&&r.jsx("span",{className:"pointer-events-none absolute inset-x-3 bottom-0 h-px overflow-hidden rounded-full bg-[var(--inspector-surface-medium)]","aria-hidden":"true",children:r.jsx("span",{className:"absolute inset-y-0 left-0 w-1/3 animate-pulse rounded-full bg-[var(--inspector-status-watch)] opacity-70"})}),r.jsx(Hh,{open:w,onOpenChange:v,title:"Clear this group from the current view?",description:`This will hide ${s} request${s!==1?"s":""} from the current view. Stored logs remain reloadable.`,confirmLabel:"Clear",variant:"destructive",onConfirm:()=>{b?.()}})]})}function aT(e){if(e.sessionId!==null&&e.sessionId!==""&&e.sessionId!==void 0)return e.sessionId;if(e.isTest===!0)return"provider-test";const t=e.clientPid!==null&&e.clientPid!==void 0,n=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0;if(!t&&!n)return"default";const s=t?`PID:${e.clientPid}`:"unknown",o=n?e.clientProjectFolder:"no-folder";return`${s}|${o}`}function lT(e){const t=new Map;for(const s of e){const o=aT(s),i=t.get(o);i!==void 0?i.push(s):t.set(o,[s])}const n=[];for(const[s,o]of t){const i=[...o].sort((a,l)=>a.timestamp.localeCompare(l.timestamp));n.push({id:s,conversationId:s,logs:i})}return n.sort((s,o)=>(s.logs[0]?.timestamp??"").localeCompare(o.logs[0]?.timestamp??"")),n}function cT(e,t,n){const s=new Array(e);return new Proxy(s,{get(o,i,a){if(typeof i=="string"){const l=i.charCodeAt(0);if(l>=48&&l<=57){const u=+i;if(Number.isInteger(u)&&u>=0&&u<e){let d=o[u];if(!d){const p=t[u*2];d=o[u]={index:u,key:n(u),start:p,size:t[u*2+1],end:p+t[u*2+1],lane:0}}return d}}if(i==="length")return e}return Reflect.get(o,i,a)}})}function ls(e,t,n){let s=n.initialDeps??[],o,i=!0;function a(){const l=e();return(l.length!==s.length||l.some((d,p)=>s[p]!==d))&&(s=l,o=t(...l),n?.onChange&&!(i&&n.skipInitialOnChange)&&n.onChange(o),i=!1),o}return a.updateDeps=l=>{s=l},a}function $u(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const uT=(e,t)=>Math.abs(e-t)<1.01,dT=(e,t,n)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>t.apply(this,o),n)}};let Vs;const Wi=()=>{if(Vs!==void 0)return Vs;if(typeof navigator>"u")return Vs=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Vs=!0;const e=navigator.maxTouchPoints;return Vs=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Du=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},pT=e=>e,fT=e=>{const t=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,o=new Array(s);for(let i=0;i<s;i++)o[i]=t+i;return o},mT=(e,t)=>{const n=e.scrollElement;if(!n)return;const s=e.targetWindow;if(!s)return;const o=a=>{const{width:l,height:u}=a;t({width:Math.round(l),height:Math.round(u)})};if(o(Du(n)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(a=>{const l=()=>{const u=a[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){o({width:d.inlineSize,height:d.blockSize});return}}o(Du(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},lr={passive:!0},hT=(e,t)=>{const n=e.scrollElement;if(!n)return;const s=()=>{t({width:n.innerWidth,height:n.innerHeight})};return s(),n.addEventListener("resize",s,lr),()=>{n.removeEventListener("resize",s)}},gT=typeof window>"u"?!0:"onscrollend"in window,r0=(e,t,n)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&gT;let a=0;const l=i?null:dT(o,()=>t(a,!1),e.options.isScrollingResetDelay),u=f=>()=>{a=n(s),l?.(),t(a,f)},d=u(!0),p=u(!1);return s.addEventListener("scroll",d,lr),i&&s.addEventListener("scrollend",p,lr),()=>{s.removeEventListener("scroll",d),i&&s.removeEventListener("scrollend",p)}},xT=(e,t)=>r0(e,t,n=>{const{horizontal:s,isRtl:o}=e.options;return s?n.scrollLeft*(o&&-1||1):n.scrollTop}),bT=(e,t)=>r0(e,t,n=>e.options.horizontal?n.scrollX:n.scrollY),vT=(e,t,n)=>{if(n.options.useCachedMeasurements){const s=n.indexFromElement(e),o=n.options.getItemKey(s);return n.itemSizeCache.get(o)??n.options.estimateSize(s)}if(t?.borderBoxSize){const s=t.borderBoxSize[0];if(s)return Math.round(s[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const s=n.indexFromElement(e),o=n.options.getItemKey(s),i=n.itemSizeCache.get(o);if(i!==void 0)return i}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},o0=(e,{adjustments:t=0,behavior:n},s)=>{var o,i;(i=(o=s.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[s.options.horizontal?"left":"top"]:e+t,behavior:n})},yT=o0,wT=o0;class jT{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var n,s,o;return((o=(s=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:s.now)==null?void 0:o.call(s))??Date.now()},this.observer=(()=>{let n=null;const s=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const a=()=>{const l=i.target,u=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);for(const[d,p]of this.elementsCache)if(p===l){this.elementsCache.delete(d);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(l,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var o;(o=s())==null||o.disconnect(),n=null},observe:o=>{var i;return(i=s())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=s())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=n=>{var s,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:pT,rangeExtractor:fT,onChange:()=>{},measureElement:vT,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in n){const h=n[m];h!==void 0&&(i[m]=h)}const a=this.options;let l=null,u=null,d=!1;if(a!==void 0&&a.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=a.count,h=i.count,g=this.getMeasurements(),y=m>0?((s=g[0])==null?void 0:s.key)??a.getItemKey(0):null,b=m>0?((o=g[m-1])==null?void 0:o.key)??a.getItemKey(m-1):null;if(h!==m||m>0&&h>0&&(i.getItemKey(0)!==y||i.getItemKey(h-1)!==b)){d=!0;const j=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??g[0]:null;j&&(l=[j.key,this.getScrollOffset()-j.start]);const _=i.followOnAppend===!0?"auto":i.followOnAppend||null;_&&h>m&&this.isAtEnd(a.scrollEndThreshold)&&(m===0||i.getItemKey(h-1)!==b)&&(u=_)}}this.options=i,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let p=!1,f=0;if(l&&this.scrollOffset!==null){const[m,h]=l,g=this.getMeasurements(),{count:y,getItemKey:b}=this.options;let w=0;for(;w<y&&b(w)!==m;)w++;if(w<y){const v=g[w];if(v){const j=v.start+h;j!==this.scrollOffset&&(f=j-this.scrollOffset,this.scrollOffset=j,p=!0)}}}(p||u)&&(this.pendingScrollAnchor=[p?l[0]:null,p?l[1]:0,u,f])},this.notify=n=>{var s,o;(o=(s=this.options).onChange)==null||o.call(s,this,n)},this.maybeNotify=ls(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,a)=>{if(a&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const l=this.getScrollOffset();this.scrollDirection=a?l===i?this.scrollDirection:l<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=a,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,a=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},l=()=>{this._iosTouching=!1,!(!Wi()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",a,lr),i.addEventListener("touchend",l,lr),this.unsubs.push(()=>{i.removeEventListener("touchstart",a),i.removeEventListener("touchend",l),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[i,a,l,u]=o;i!==null&&!l&&(Wi()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),l&&this.scrollToEnd({behavior:l})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),s=this.getMaxScrollOffset();if(n<0||n>s)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=o,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,s)=>{const o=new Map,i=new Map;for(let a=s-1;a>=0;a--){const l=n[a];if(o.has(l.lane))continue;const u=i.get(l.lane);if(u==null||l.end>u.end?i.set(l.lane,l):l.end<u.end&&o.set(l.lane,!0),o.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((a,l)=>a.end===l.end?a.index-l.index:a.end-l.end)[0]:void 0},this.getMeasurementOptions=ls(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(n,s,o,i,a,l,u)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMin=null,{count:n,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:a,lanes:l,laneAssignmentMode:u}),{key:!1}),this.getMeasurements=ls(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:a,lanes:l,laneAssignmentMode:u},d)=>{const p=this.itemSizeCache;if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const g of this.laneAssignments.keys())g>=n&&this.laneAssignments.delete(g);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(g=>{this.itemSizeCache.set(g.key,g.size)}));const f=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),l===1){const g=this.options.gap,y=n*2;let b=this._flatMeasurements;if(!b||b.length<y){const j=new Float64Array(y);b&&f>0&&j.set(b.subarray(0,f*2)),b=j,this._flatMeasurements=b}let w;if(f===0)w=s+o;else{const j=f-1;w=b[j*2]+b[j*2+1]+g}for(let j=f;j<n;j++){const _=i(j),k=p.get(_),S=typeof k=="number"?k:this.options.estimateSize(j);b[j*2]=w,b[j*2+1]=S,w+=S+g}const v=cT(n,b,i);return this.measurementsCache=v,v}const m=this.measurementsCache.slice(0,f),h=new Array(l).fill(void 0);for(let g=0;g<f;g++){const y=m[g];y&&(h[y.lane]=g)}for(let g=f;g<n;g++){const y=i(g),b=this.laneAssignments.get(g);let w,v;const j=u==="estimate"||p.has(y);if(b!==void 0&&this.options.lanes>1){w=b;const C=h[w],M=C!==void 0?m[C]:void 0;v=M?M.end+this.options.gap:s+o}else{const C=this.options.lanes===1?m[g-1]:this.getFurthestMeasurement(m,g);v=C?C.end+this.options.gap:s+o,w=C?C.lane:g%this.options.lanes,this.options.lanes>1&&j&&this.laneAssignments.set(g,w)}const _=p.get(y),k=typeof _=="number"?_:this.options.estimateSize(g),S=v+k;m[g]={index:g,start:v,size:k,end:S,key:y,lane:w},h[w]=g}return this.measurementsCache=m,m},{key:!1,debug:()=>this.options.debug}),this.calculateRange=ls(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,s,o,i)=>n.length===0||s===0?(this.range=null,null):(this.range=_T(n,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ls(()=>{let n=null,s=null;const o=this.calculateRange();return o&&(n=o.startIndex,s=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,s]},(n,s,o,i,a)=>i===null||a===null?[]:n({startIndex:i,endIndex:a,overscan:s,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const s=this.options.indexAttribute,o=n.getAttribute(s);return o?parseInt(o,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(o!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,o-i),l=Math.min(this.options.count-1,o+i);return n>=a&&n<=l}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((a,l)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(l))});return}const s=this.indexFromElement(n),o=this.options.getItemKey(s),i=this.elementsCache.get(o);i!==n&&(i&&this.observer.unobserve(i),this.observer.observe(n),this.elementsCache.set(o,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,s)=>{var o,i;if(n<0||n>=this.options.count)return;let a,l,u;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)u=this.options.getItemKey(n),l=d[n*2],a=d[n*2+1];else{const m=this.measurementsCache[n];if(!m)return;u=m.key,l=m.start,a=m.size}const p=this.itemSizeCache.get(u)??a,f=s-p;if(f!==0){const m=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,h=m?this.getTotalSize():0,g=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:u,start:l,size:a,end:l+a,lane:0},f,this):l<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(u)||this.scrollDirection!=="backward"));(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(u,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-h):g&&this.applyScrollAdjustment(f),this.notify(!1)}},this.getVirtualItems=ls(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,s)=>{const o=[];for(let i=0,a=n.length;i<a;i++){const l=n[i],u=s[l];o.push(u)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const s=this.getMeasurements();if(s.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,a=i0(0,s.length-1,i?l=>o[l*2]:l=>$u(s[l]).start,n);return $u(s[a])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,s,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),a=this.getScrollOffset();s==="auto"&&(s=n>=a+i?"end":"start"),s==="center"?n+=(o-i)/2:s==="end"&&(n-=i);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,s="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const o=this.getSize(),i=this.getScrollOffset(),a=this.measurementsCache[n];if(!a)return;if(s==="auto")if(a.end>=i+o-this.options.scrollPaddingEnd)s="end";else if(a.start<=i+this.options.scrollPaddingStart)s="start";else return[i,s];if(s==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),s];const l=s==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,s,a.size),s]},this.scrollToOffset=(n,{align:s="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(n,s),a=this.now();this.scrollState={index:null,align:s,behavior:o,startedAt:a,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:s="auto",behavior:o="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getOffsetForIndex(n,s);if(!i)return;const[a,l]=i,u=this.now();this.scrollState={index:n,align:l,behavior:o,startedAt:u,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:s="auto"}={})=>{const o=this.getScrollOffset()+n,i=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n;const s=this.getMeasurements();let o;if(s.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=s.length-1,a=this._flatMeasurements;a!=null?o=a[i*2]+a[i*2+1]:o=((n=s[i])==null?void 0:n.end)??0}else{const i=Array(this.options.lanes).fill(null);let a=s.length-1;for(;a>=0&&i.some(l=>l===null);){const l=s[a];i[l.lane]===null&&(i[l.lane]=l.end),a--}o=Math.max(...i.filter(l=>l!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const s=this.getMeasurements();for(const o of s)o&&this.itemSizeCache.has(o.key)&&n.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return n},this._scrollToOffset=(n,{adjustments:s,behavior:o})=>{this._intendedScrollOffset=n+(s??0),this.options.scrollToFn(n,{behavior:o,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){t!==0&&(Wi()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=s?s[0]:this.scrollState.lastTargetOffset,i=1,a=o!==this.scrollState.lastTargetOffset;if(!a&&uT(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,a){const l=this.getSize()||600,u=Math.abs(o-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&u>l;this.scrollState.lastTargetOffset=o,d||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const i0=(e,t,n,s)=>{for(;e<=t;){const o=(e+t)/2|0,i=n(o);if(i<s)e=o+1;else if(i>s)t=o-1;else return o}return e>0?e-1:0};function kT(e,t,n){let s=0;for(;s<=t;){const o=(s+t)/2|0,i=e[o*2];if(i<n)s=o+1;else if(i>n)t=o-1;else return o}return s>0?s-1:0}function _T(e,t,n,s,o){const i=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:i};if(s===1&&o!==null){const d=kT(o,i,n);let p=d;const f=n+t;for(;p<i&&o[p*2]+o[p*2+1]<f;)p++;return{startIndex:d,endIndex:p}}let l=i0(0,i,d=>e[d].start,n),u=l;if(s===1)for(;u<i&&e[u].end<n+t;)u++;else if(s>1){const d=Array(s).fill(0);for(;u<i&&d.some(f=>f<n+t);){const f=e[u];d[f.lane]=f.end,u++}const p=Array(s).fill(n+t);for(;l>=0&&p.some(f=>f>=n);){const f=e[l];p[f.lane]=f.start,l--}l=Math.max(0,l-l%s),u=Math.min(i,u+(s-1-u%s))}return{startIndex:l,endIndex:u}}const Zi=typeof document<"u"?c.useLayoutEffect:c.useEffect;function a0({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...s}){const o=c.useReducer(d=>d+1,0)[1],i=c.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=t,i.current.mode=n;const a=d=>{const p=i.current;if(!p.enabled||!p.container)return;const f=d.getTotalSize();if(f!==p.lastSize){p.lastSize=f;const w=d.options.horizontal?"width":"height";p.container.style[w]=`${f}px`}const m=!!d.options.horizontal,h=p.mode==="transform",g=m?"left":"top",y=d.options.scrollMargin,b=d.getVirtualItems();for(const w of b){const v=w.start-y,j=d.elementsCache.get(w.key);j&&p.lastPositions.get(j)!==v&&(p.lastPositions.set(j,v),h?j.style.transform=m?`translate3d(${v}px, 0, 0)`:`translate3d(0, ${v}px, 0)`:j.style[g]=`${v}px`)}},l={...s,onChange:(d,p)=>{var f;const m=i.current;let h=!0;if(m.enabled){a(d);const g=d.range,y=m.prevRange;h=!y||y.isScrolling!==d.isScrolling||y.startIndex!==g?.startIndex||y.endIndex!==g?.endIndex,h&&(m.prevRange=g?{startIndex:g.startIndex,endIndex:g.endIndex,isScrolling:d.isScrolling}:null)}h&&(e&&p?Os.flushSync(o):o()),(f=s.onChange)==null||f.call(s,d,p)}},[u]=c.useState(()=>{const d=new jT(l);return Object.assign(d,{containerRef:p=>{const f=i.current;if(f.container=p,f.lastSize=null,p&&f.enabled){const m=d.getTotalSize();f.lastSize=m;const h=d.options.horizontal?"width":"height";p.style[h]=`${m}px`}}})});return u.setOptions(l),Zi(()=>u._didMount(),[]),Zi(()=>u._willUpdate()),Zi(()=>{a(u)}),u}function ST(e){return a0({observeElementRect:mT,observeElementOffset:xT,scrollToFn:wT,...e})}function NT(e){return a0({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:hT,observeElementOffset:bT,scrollToFn:yT,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const un="agent-inspector:focus-log";function Is(e){window.dispatchEvent(new CustomEvent(un,{detail:e}))}function wi(e){if(typeof CustomEvent>"u"||!(e instanceof CustomEvent))return null;const t=e.detail,n=Q(t,"logId");if(typeof n!="number"||!Number.isInteger(n)||n<0)return null;const s=Q(t,"tab");switch(s){case"anatomy":case"request":case"response":break;case void 0:break;default:return null}const o=Q(t,"source"),i=Q(t,"toolCallIndex"),a=typeof i=="number"&&Number.isInteger(i)&&i>=0?{logId:n,tab:s??"request",toolCallIndex:i}:{logId:n,tab:s??"request"};switch(o){case"virtualizer":return{...a,source:o};case void 0:return a;default:return null}}function CT(e){switch(e){case"end_turn":case"tool_use":return e;case"max_tokens":return"length";default:return null}}function TT(e){switch(e){case"stop":case"length":return e;case"max_tokens":return"length";default:return null}}function ET(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function l0(e){if(e.responseText===null)return null;try{let t=JSON.parse(e.responseText);if(typeof t=="string"&&(t=JSON.parse(t)),!Gs(t))return null;if(typeof t.stop_reason=="string")return CT(t.stop_reason);if(Array.isArray(t.choices))for(const n of t.choices){if(!Gs(n)||typeof n.finish_reason!="string")continue;const s=TT(n.finish_reason);if(s!==null)return s}if(Array.isArray(t.output)){for(const n of t.output)if(Gs(n)&&n.type==="function_call")return"tool_use";if(t.status==="completed")return"stop"}if(t.status==="incomplete"&&Gs(t.incomplete_details)){const n=t.incomplete_details.reason;if(typeof n=="string"&&ET(n))return"length"}return null}catch{return null}}function mc(e){return e==="end_turn"||e==="stop"||e==="length"}function Nt({className:e,style:t,d:n,eyeStalks:s,eyes:o,legs:i,extras:a}){return r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:t,className:$("inline-block size-5",e),children:[r.jsx("path",{d:n}),s,o,i,a]})}const In=r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),r.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),r.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),r.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]}),c0=r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"7",y1:"16",x2:"5.5",y2:"18.5"}),r.jsx("line",{x1:"9.5",y1:"17",x2:"8.5",y2:"19.5"}),r.jsx("line",{x1:"14.5",y1:"17",x2:"15.5",y2:"19.5"}),r.jsx("line",{x1:"17",y1:"16",x2:"18.5",y2:"18.5"})]});function u0({className:e}){return r.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),r.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"})]}),legs:In,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),r.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function RT({className:e}){return r.jsx(Nt,{className:e,d:"M4 13 C4 7 7.5 5.5 12 5.5 C16.5 5.5 20 7 20 13 C20 17.5 16.5 19 12 19 C7.5 19 4 17.5 4 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"9.5",y1:"6.5",x2:"9.5",y2:"4.5"}),r.jsx("line",{x1:"14.5",y1:"6.5",x2:"14.5",y2:"4.5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"14.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"})]}),legs:c0,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12"}),r.jsx("path",{d:"M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12"})]})})}function PT({className:e}){return r.jsx(Nt,{className:e,d:"M3 13.5 C3 8 7 6 12 6 C17 6 21 8 21 13.5 C21 17 17 19 12 19 C7 19 3 17 3 13.5 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"7",y1:"7",x2:"6.5",y2:"4.5"}),r.jsx("line",{x1:"17",y1:"7",x2:"17.5",y2:"4.5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"6.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"17.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:In,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13"}),r.jsx("path",{d:"M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13"})]})})}function IT({className:e}){return r.jsx(Nt,{className:e,d:"M6 14 C6 8 9 5.5 12 5.5 C15 5.5 18 8 18 14 C18 18 15 20 12 20 C9 20 6 18 6 14 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"6.5",x2:"10",y2:"3.5"}),r.jsx("line",{x1:"14",y1:"6.5",x2:"14",y2:"3.5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"10",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"14",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"7",y1:"17",x2:"5",y2:"20.5"}),r.jsx("line",{x1:"9.5",y1:"18.5",x2:"8.5",y2:"21.5"}),r.jsx("line",{x1:"14.5",y1:"18.5",x2:"15.5",y2:"21.5"}),r.jsx("line",{x1:"17",y1:"17",x2:"19",y2:"20.5"})]}),extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12"}),r.jsx("path",{d:"M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12"})]})})}function MT({className:e}){return r.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 L13 4 L14 7 C16 7 19 9 19 13 C19 16 16 18 13 18 L12 21 L11 18 C8 18 5 16 5 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),r.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:In,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),r.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function AT({className:e}){return r.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),r.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),r.jsx("line",{x1:"13.5",y1:"4",x2:"15.5",y2:"5"})]}),legs:In,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),r.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function OT({className:e}){return r.jsx(Nt,{className:e,d:"M5.5 13.5 C5.5 10 8.5 8 12 8 C15.5 8 18.5 10 18.5 13.5 C18.5 16 15.5 17.5 12 17.5 C8.5 17.5 5.5 16 5.5 13.5 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"6"}),r.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"6"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"9",y1:"6",x2:"11",y2:"6.5"}),r.jsx("line",{x1:"13",y1:"6",x2:"15",y2:"6.5"})]}),legs:c0,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M6 11.5 C4.5 10.5 3 11 3.5 12.5 C4 13.5 5 13 5.5 12.5"}),r.jsx("path",{d:"M18 11.5 C19.5 10.5 21 11 20.5 12.5 C20 13.5 19 13 18.5 12.5"})]})})}function zT({className:e}){return r.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),r.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:In,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),r.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),r.jsx("line",{x1:"8.5",y1:"4",x2:"10.5",y2:"4.5"}),r.jsx("line",{x1:"15.5",y1:"4",x2:"13.5",y2:"4.5"}),r.jsx("path",{d:"M9 15.5 C10 14.5 14 14.5 15 15.5"})]})})}function LT({className:e}){return r.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),r.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"}),r.jsx("circle",{cx:"14.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"})]}),legs:In,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),r.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),r.jsx("ellipse",{cx:"12",cy:"15",rx:"2",ry:"1.5",fill:"currentColor",stroke:"none"})]})})}function $T({className:e}){return r.jsx(Nt,{className:e,d:"M4.5 13 C4.5 8 7.5 6 12 6 C16.5 6 19.5 8 19.5 13 C19.5 17 16.5 18.5 12 18.5 C7.5 18.5 4.5 17 4.5 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"9.5",y1:"7",x2:"9",y2:"5"}),r.jsx("line",{x1:"14.5",y1:"7",x2:"15",y2:"5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"9",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"15",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"})]}),legs:In,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12"}),r.jsx("path",{d:"M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12"}),r.jsx("path",{d:"M9 14.5 C10 16 14 16 15 14.5"}),r.jsx("circle",{cx:"7",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"}),r.jsx("circle",{cx:"17",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"})]})})}function DT({className:e}){return r.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5.5"}),r.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5.5"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"7.5",y1:"5.5",x2:"16.5",y2:"5.5"}),r.jsx("rect",{x:"7",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"}),r.jsx("rect",{x:"13",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"})]}),legs:In,extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),r.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),r.jsx("path",{d:"M9.5 15 C10.5 16 13.5 16 14.5 15"})]})})}function FT({className:e}){return r.jsx(Nt,{className:e,d:"M7 13.5 C7 10.5 9.5 9 12 9 C14.5 9 17 10.5 17 13.5 C17 16 14.5 17.5 12 17.5 C9.5 17.5 7 16 7 13.5 Z",eyeStalks:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"10.5",y1:"9.5",x2:"10.5",y2:"8"}),r.jsx("line",{x1:"13.5",y1:"9.5",x2:"13.5",y2:"8"})]}),eyes:r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"10.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"13.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"8",y1:"16",x2:"6.5",y2:"18"}),r.jsx("line",{x1:"10",y1:"17",x2:"9.5",y2:"19"}),r.jsx("line",{x1:"14",y1:"17",x2:"14.5",y2:"19"}),r.jsx("line",{x1:"16",y1:"16",x2:"17.5",y2:"18"})]}),extras:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13"}),r.jsx("path",{d:"M16.5 12 C17.5 11 18.5 11.5 18 13 C17.5 14 17 13.5 16.5 13"})]})})}const Ga=[u0,RT,PT,IT,MT,AT,OT,zT,LT,$T,DT,FT];function hc(e){return Ga[Math.abs(e)%Ga.length]??u0}function UT(e){const t=Ga.length-2;return t<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%t+t)%t}function BT(e){return hc(UT(e))}const VT="x-anthropic-billing-header:";function qT(e){return e.trimStart().toLowerCase().startsWith(VT)}function HT(e){return pc(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function WT(e){if(!pc(e))return!1;const t=Q(e,"type"),n=Q(e,"text");return typeof t!="string"||t!=="text"||typeof n!="string"?!1:qT(n)}function ZT(e){let t;try{t=JSON.parse(e)}catch{return{body:e,removed:0}}if(!HT(t))return{body:e,removed:0};const n=t.system;if(!Array.isArray(n)||n.length===0)return{body:e,removed:0};const s=[];let o=0;for(const i of n){if(WT(i)){o+=1;continue}s.push(i)}return o===0?{body:e,removed:0}:(s.length===0?delete t.system:t.system=s,{body:JSON.stringify(t),removed:o})}const KT=400,Fu=2e3;function GT(e){return Array.isArray(e)}function JT(e,t){const n=[e];let s=0;for(;n.length>0;){const o=n.pop();if(o!==void 0){if(s+=1,s>t)return s;if(!(o===null||typeof o!="object")){if(GT(o)){for(const i of o)n.push(i);continue}for(const i of Object.keys(o)){const a=o[i];a!==void 0&&n.push(a)}}}}return s}function YT(e){const t=JT(e,Fu+1);return t<=KT?{depth:Number.POSITIVE_INFINITY}:t<=Fu?{depth:3}:{depth:2}}function XT(e){try{const t=JSON.parse(e);return{kind:"json",data:Po(t)}}catch{return{kind:"text"}}}function Ki(e){const t=c.useMemo(()=>e===null?null:XT(e),[e]),n=t?.kind==="json"?t.data:null,s=c.useMemo(()=>n===null?null:YT(n),[n]),[o,i]=c.useState(!1),[a,l]=c.useState(0),[u,d]=c.useState(0),[p,f]=c.useTransition(),m=c.useCallback(()=>{const h=!o,g=h&&s!==null?s.depth:0;f(()=>{i(h),l(g),d(y=>y+1)})},[o,s]);return{parsedData:n,policy:s,isExpanded:o,toggle:m,isPending:p,bulkDepth:a,bulkRevision:u}}function Po(e){if(e==null)return null;switch(typeof e){case"string":return e;case"number":return e;case"boolean":return e;case"object":{if(Array.isArray(e))return e.map(n=>Po(n));const t={};for(const n of Object.keys(e)){const s=Object.getOwnPropertyDescriptor(e,n);t[n]=Po(s?.value)}return t}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function d0({className:e,orientation:t="horizontal",...n}){return r.jsx(XN,{"data-slot":"tabs","data-orientation":t,orientation:t,className:$("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...n})}const QT=tp("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function p0({className:e,variant:t="default",...n}){return r.jsx(QN,{"data-slot":"tabs-list","data-variant":t,className:$(QT({variant:t}),e),...n})}function xn({className:e,...t}){return r.jsx(eC,{"data-slot":"tabs-trigger",className:$("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-muted-foreground hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:border-border data-[state=active]:bg-background data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",e),...t})}function jt({className:e,...t}){return r.jsx(tC,{"data-slot":"tabs-content",className:$("flex-1 outline-none",e),...t})}function vn(e){const[t,n]=c.useState(!1),s=c.useRef(null);c.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]);const o=c.useCallback(i=>{i.stopPropagation(),e!==null&&Pt(e).then(a=>{a&&(n(!0),s.current!==null&&clearTimeout(s.current),s.current=setTimeout(()=>n(!1),2e3))})},[e]);return{copied:t,copy:o}}const e4=c.lazy(()=>Gt(()=>import("./CompareDrawer-DZHbDuyp.js"),__vite__mapDeps([2,1])).then(e=>({default:e.CompareDrawer}))),t4=c.lazy(()=>Gt(()=>import("./InspectorPet-CcB16ERo.js"),__vite__mapDeps([3,1])).then(e=>({default:e.InspectorPet}))),n4=c.lazy(()=>Gt(()=>import("./ReplayDialog-C9QR9m_y.js"),__vite__mapDeps([4,1,5])).then(e=>({default:e.ReplayDialog}))),s4=c.lazy(()=>Gt(()=>import("./RequestAnatomy-CUY83fwY.js"),__vite__mapDeps([6,1])).then(e=>({default:e.RequestAnatomy}))),r4=c.lazy(()=>Gt(()=>import("./ResponseView-B_9r-cyE.js"),__vite__mapDeps([5,1])).then(e=>({default:e.ResponseView}))),o4=c.lazy(()=>Gt(()=>import("./StreamingChunkSequence--jQP7nh3.js"),__vite__mapDeps([7,1])).then(e=>({default:e.StreamingChunkSequence}))),Ja=c.lazy(()=>Gt(()=>import("./json-viewer-CeXNLNRL.js"),__vite__mapDeps([8,1])).then(e=>({default:e.JsonViewer}))),i4=c.lazy(()=>Gt(()=>import("./json-viewer-CeXNLNRL.js"),__vite__mapDeps([8,1])).then(e=>({default:e.JsonViewerFromString}))),a4=1200,l4=12;function c4(e){const{containerRef:t,setExpandToPath:n,ensureTabActive:s,highlightMs:o}=e,i=c.useRef(null);return c.useCallback(a=>{s?.(),n(a.path);const l=f=>{f.scrollIntoView({behavior:"smooth",block:"center"}),f.classList.add("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{f.classList.remove("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),n(null)},o??a4)},d=`[data-anatomy-path="${(f=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(f):f.replace(/(["'\\[\](){}])/g,"\\$1"))(a.path)}"]`,p=f=>{const m=t.current;if(m!==null){const h=m.querySelector(d);if(h!==null){l(h);return}}f>0?window.requestAnimationFrame(()=>p(f-1)):n(null)};window.requestAnimationFrame(()=>p(l4))},[t,s,o,n])}const Uu="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.";function gs(e){return e<1024?`${e.toLocaleString()} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(1)} GiB`}function u4(e,t){const n=[];return e!=null&&n.push(`Request ${gs(e)}`),t!=null&&n.push(`Response ${gs(t)}`),n.length===0?null:n.join(" · ")}function d4(e){if(e instanceof Zo)return{title:"Full bodies timed out",detail:"The log store did not answer before the UI timeout. Compact metadata is still available; retry loading the bodies."};if(e instanceof Error){const t=e.message.trim();return{title:"Full bodies could not be loaded",detail:t===""?Uu:t}}return{title:"Full bodies could not be loaded",detail:Uu}}class f0{diff(t,n,s={}){let o;typeof s=="function"?(o=s,s={}):"callback"in s&&(o=s.callback);const i=this.castInput(t,s),a=this.castInput(n,s),l=this.removeEmpty(this.tokenize(i,s)),u=this.removeEmpty(this.tokenize(a,s));return this.diffWithOptionsObj(l,u,s,o)}diffWithOptionsObj(t,n,s,o){var i;const a=v=>{if(v=this.postProcess(v,s),o){setTimeout(function(){o(v)},0);return}else return v},l=n.length,u=t.length;let d=1,p=l+u;s.maxEditLength!=null&&(p=Math.min(p,s.maxEditLength));const f=(i=s.timeout)!==null&&i!==void 0?i:1/0,m=Date.now()+f,h=[{oldPos:-1,lastComponent:void 0}];let g=this.extractCommon(h[0],n,t,0,s);if(h[0].oldPos+1>=u&&g+1>=l)return a(this.buildValues(h[0].lastComponent,n,t));let y=-1/0,b=1/0;const w=()=>{for(let v=Math.max(y,-d);v<=Math.min(b,d);v+=2){let j;const _=h[v-1],k=h[v+1];_&&(h[v-1]=void 0);let S=!1;if(k){const M=k.oldPos-v;S=k&&0<=M&&M<l}const C=_&&_.oldPos+1<u;if(!S&&!C){h[v]=void 0;continue}if(!C||S&&_.oldPos<k.oldPos?j=this.addToPath(k,!0,!1,0,s):j=this.addToPath(_,!1,!0,1,s),g=this.extractCommon(j,n,t,v,s),j.oldPos+1>=u&&g+1>=l)return a(this.buildValues(j.lastComponent,n,t))||!0;h[v]=j,j.oldPos+1>=u&&(b=Math.min(b,v-1)),g+1>=l&&(y=Math.max(y,v+1))}d++};if(o)(function v(){setTimeout(function(){if(d>p||Date.now()>m)return o(void 0);w()||v()},0)})();else for(;d<=p&&Date.now()<=m;){const v=w();if(v)return v}}addToPath(t,n,s,o,i){const a=t.lastComponent;return a&&!i.oneChangePerToken&&a.added===n&&a.removed===s?{oldPos:t.oldPos+o,lastComponent:{count:a.count+1,added:n,removed:s,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+o,lastComponent:{count:1,added:n,removed:s,previousComponent:a}}}extractCommon(t,n,s,o,i){const a=n.length,l=s.length;let u=t.oldPos,d=u-o,p=0;for(;d+1<a&&u+1<l&&this.equals(s[u+1],n[d+1],i);)d++,u++,p++,i.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return p&&!i.oneChangePerToken&&(t.lastComponent={count:p,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=u,d}equals(t,n,s){return s.comparator?s.comparator(t,n):t===n||!!s.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let s=0;s<t.length;s++)t[s]&&n.push(t[s]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,s){const o=[];let i;for(;t;)o.push(t),i=t.previousComponent,delete t.previousComponent,t=i;o.reverse();const a=o.length;let l=0,u=0,d=0;for(;l<a;l++){const p=o[l];if(p.removed)p.value=this.join(s.slice(d,d+p.count)),d+=p.count;else{if(!p.added&&this.useLongestToken){let f=n.slice(u,u+p.count);f=f.map(function(m,h){const g=s[d+h];return g.length>m.length?g:m}),p.value=this.join(f)}else p.value=this.join(n.slice(u,u+p.count));u+=p.count,p.added||(d+=p.count)}}return o}}class p4 extends f0{constructor(){super(...arguments),this.tokenize=h0}equals(t,n,s){return s.ignoreWhitespace?((!s.newlineIsToken||!t.includes(`
116
116
  `))&&(t=t.trim()),(!s.newlineIsToken||!n.includes(`
117
117
  `))&&(n=n.trim())):s.ignoreNewlineAtEof&&!s.newlineIsToken&&(t.endsWith(`
118
118
  `)&&(t=t.slice(0,-1)),n.endsWith(`
119
- `)&&(n=n.slice(0,-1))),super.equals(t,n,s)}}const p4=new f4;function m0(e,t,n){return p4.diff(e,t,n)}function h0(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
120
- `));const n=[],s=e.split(/(\n|\r\n)/);s[s.length-1]||s.pop();for(let o=0;o<s.length;o++){const i=s[o];o%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}class m4 extends p0{constructor(){super(...arguments),this.tokenize=h0}get useLongestToken(){return!0}castInput(t,n){const{undefinedReplacement:s,stringifyReplacer:o=(i,a)=>typeof a>"u"?s:a}=n;return typeof t=="string"?t:JSON.stringify(Ya(t,null,null,o),null," ")}equals(t,n,s){return super.equals(t.replace(/,([\r\n])/g,"$1"),n.replace(/,([\r\n])/g,"$1"),s)}}const h4=new m4;function g4(e,t,n){return h4.diff(e,t,n)}function Ya(e,t,n,s,o){t=t||[],n=n||[],s&&(e=s(o===void 0?"":o,e));let i;for(i=0;i<t.length;i+=1)if(t[i]===e)return n[i];let a;if(Object.prototype.toString.call(e)==="[object Array]"){for(t.push(e),a=new Array(e.length),n.push(a),i=0;i<e.length;i+=1)a[i]=Ya(e[i],t,n,s,String(i));return t.pop(),n.pop(),a}if(e&&e.toJSON&&(e=e.toJSON()),typeof e=="object"&&e!==null){t.push(e),a={},n.push(a);const l=[];let u;for(u in e)Object.prototype.hasOwnProperty.call(e,u)&&l.push(u);for(l.sort(),i=0;i<l.length;i+=1)u=l[i],a[u]=Ya(e[u],t,n,s,u);t.pop(),n.pop()}else a=e;return a}function Bu(e){return e===void 0?[]:Object.entries(e).map(t=>[t[0].toLowerCase(),t[1]]).sort(([t],[n])=>t.localeCompare(n))}function Vu([e,t]){return`${e}: ${t}`}function Xa(e){const t=[];let n=0,s=0;for(const o of e){const i=o.value.split(`
119
+ `)&&(n=n.slice(0,-1))),super.equals(t,n,s)}}const f4=new p4;function m0(e,t,n){return f4.diff(e,t,n)}function h0(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
120
+ `));const n=[],s=e.split(/(\n|\r\n)/);s[s.length-1]||s.pop();for(let o=0;o<s.length;o++){const i=s[o];o%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}class m4 extends f0{constructor(){super(...arguments),this.tokenize=h0}get useLongestToken(){return!0}castInput(t,n){const{undefinedReplacement:s,stringifyReplacer:o=(i,a)=>typeof a>"u"?s:a}=n;return typeof t=="string"?t:JSON.stringify(Ya(t,null,null,o),null," ")}equals(t,n,s){return super.equals(t.replace(/,([\r\n])/g,"$1"),n.replace(/,([\r\n])/g,"$1"),s)}}const h4=new m4;function g4(e,t,n){return h4.diff(e,t,n)}function Ya(e,t,n,s,o){t=t||[],n=n||[],s&&(e=s(o===void 0?"":o,e));let i;for(i=0;i<t.length;i+=1)if(t[i]===e)return n[i];let a;if(Object.prototype.toString.call(e)==="[object Array]"){for(t.push(e),a=new Array(e.length),n.push(a),i=0;i<e.length;i+=1)a[i]=Ya(e[i],t,n,s,String(i));return t.pop(),n.pop(),a}if(e&&e.toJSON&&(e=e.toJSON()),typeof e=="object"&&e!==null){t.push(e),a={},n.push(a);const l=[];let u;for(u in e)Object.prototype.hasOwnProperty.call(e,u)&&l.push(u);for(l.sort(),i=0;i<l.length;i+=1)u=l[i],a[u]=Ya(e[u],t,n,s,u);t.pop(),n.pop()}else a=e;return a}function Bu(e){return e===void 0?[]:Object.entries(e).map(t=>[t[0].toLowerCase(),t[1]]).sort(([t],[n])=>t.localeCompare(n))}function Vu([e,t]){return`${e}: ${t}`}function Xa(e){const t=[];let n=0,s=0;for(const o of e){const i=o.value.split(`
121
121
  `);i.length>0&&i[i.length-1]===""&&i.pop();for(const a of i)o.added?(s+=1,t.push({kind:"added",text:a,oldLineNumber:null,newLineNumber:s})):o.removed?(n+=1,t.push({kind:"removed",text:a,oldLineNumber:n,newLineNumber:null})):(n+=1,s+=1,t.push({kind:"context",text:a,oldLineNumber:n,newLineNumber:s}))}return t}function x4(e,t){const n=Bu(e).map(Vu).join(`
122
122
  `),s=Bu(t).map(Vu).join(`
123
- `);if(n===s)return{lines:[],isEmpty:!0};const o=m0(n,s);return{lines:Xa(o),isEmpty:!1}}function qu(e){try{const t=JSON.parse(e);return t===null||typeof t=="string"||typeof t=="object"?t:null}catch{return null}}function b4(e,t){const n=e??"",s=t??"";if(n===s)return{lines:[],isEmpty:!0};const o=qu(n),i=qu(s);if(o!==null&&i!==null){const l=g4(o,i)??[];if(l.length===1){const u=l[0];if(u!==void 0&&!u.added&&!u.removed)return{lines:[],isEmpty:!0}}return{lines:Xa(l),isEmpty:!1}}const a=m0(n,s);return{lines:Xa(a),isEmpty:!1}}const v4=22,Gi=1e4;function y4(e){return e==="added"?"+":e==="removed"?"-":" "}function w4(e){return e==="added"?"bg-green-500/10 text-green-700 dark:text-green-300":e==="removed"?"bg-red-500/10 text-red-700 dark:text-red-300":"text-foreground/80"}const j4=function({result:t,emptyLabel:n}){const[s,o]=c.useState("unified"),i=c.useRef(null),a=_T({count:t.lines.length,getScrollElement:()=>i.current,estimateSize:()=>v4,overscan:10});if(t.isEmpty)return r.jsx("div",{className:"rounded border border-dashed border-border bg-muted/30 px-4 py-6 text-center text-xs text-muted-foreground","data-testid":"diff-empty",children:n??"No transformation applied — raw and processed are identical."});const l=t.lines.length,u=l>Gi,d=u?t.lines.slice(0,Gi):t.lines;return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[r.jsxs("span",{children:[l.toLocaleString()," line",l===1?"":"s",u&&` (showing first ${Gi.toLocaleString()})`]}),r.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>o("unified"),"aria-pressed":s==="unified",className:$("flex items-center gap-1 px-2 py-1 transition-colors",s==="unified"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Unified diff (single column)",children:[r.jsx(zj,{className:"size-3"}),"Unified"]}),r.jsxs("button",{type:"button",onClick:()=>o("split"),"aria-pressed":s==="split",className:$("flex items-center gap-1 px-2 py-1 transition-colors border-l border-border",s==="split"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Split diff (side by side)",children:[r.jsx(Cw,{className:"size-3"}),"Split"]})]})]}),r.jsx("div",{ref:i,className:"max-h-[60vh] overflow-auto rounded border border-border bg-background font-mono text-xs","data-testid":"diff-viewport",children:s==="unified"?r.jsx(k4,{virtualizer:a,lines:d}):r.jsx(N4,{lines:d})})]})};function k4({virtualizer:e,lines:t}){return r.jsx("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:e.getVirtualItems().map(n=>{const s=t[n.index];return s===void 0?null:r.jsxs("div",{"data-index":n.index,ref:e.measureElement,className:$("flex items-start gap-3 px-2",w4(s.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${n.start}px)`},children:[r.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:s.oldLineNumber??""}),r.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:s.newLineNumber??""}),r.jsx("span",{className:$("select-none w-3 text-right font-bold",s.kind==="added"&&"text-green-600 dark:text-green-400",s.kind==="removed"&&"text-red-600 dark:text-red-400"),children:y4(s.kind)}),r.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.text})]},n.key)})})}function S4(e){const t=[];let n=0;for(;n<e.length;){const s=e[n];if(s===void 0)break;if(s.kind==="context"){t.push({left:{text:s.text,lineNumber:s.oldLineNumber},right:{text:s.text,lineNumber:s.newLineNumber},kind:"equal"}),n+=1;continue}const o=[],i=[];for(;n<e.length&&e[n]?.kind==="removed";){const l=e[n];l!==void 0&&o.push(l),n+=1}for(;n<e.length&&e[n]?.kind==="added";){const l=e[n];l!==void 0&&i.push(l),n+=1}const a=Math.max(o.length,i.length);for(let l=0;l<a;l+=1){const u=o[l],d=i[l];u!==void 0&&d!==void 0?t.push({left:{text:u.text,lineNumber:u.oldLineNumber},right:{text:d.text,lineNumber:d.newLineNumber},kind:"changed"}):u!==void 0?t.push({left:{text:u.text,lineNumber:u.oldLineNumber},right:null,kind:"removed"}):d!==void 0&&t.push({left:null,right:{text:d.text,lineNumber:d.newLineNumber},kind:"added"})}}return t}function _4(e){switch(e){case"changed":return"bg-amber-500/10";case"removed":return"bg-red-500/10";case"added":return"bg-green-500/10";case"equal":return""}}function N4({lines:e}){const t=S4(e);return r.jsx("div",{"data-testid":"diff-split",children:t.map((n,s)=>r.jsxs("div",{className:$("grid grid-cols-2 font-mono text-xs",_4(n.kind)),children:[r.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[r.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.left?.lineNumber??""}),r.jsx("span",{className:$("select-none w-3 text-right font-bold",(n.kind==="removed"||n.kind==="changed")&&"text-red-600 dark:text-red-400"),children:n.left!==null?"-":" "}),r.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.left?.text??""})]}),r.jsxs("div",{className:"flex items-start gap-2 px-2",children:[r.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.right?.lineNumber??""}),r.jsx("span",{className:$("select-none w-3 text-right font-bold",(n.kind==="added"||n.kind==="changed")&&"text-green-600 dark:text-green-400"),children:n.right!==null?"+":" "}),r.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.right?.text??""})]})]},s))})}const g0=c.memo(j4),C4=tf("inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function _e({className:e,variant:t="default",asChild:n=!1,...s}){const o=n?q5:"span";return r.jsx(o,{"data-slot":"badge","data-variant":t,className:$(C4({variant:t}),e),...s})}const T4=3;function E4({event:e}){const t=n=>{n.stopPropagation(),Ms({logId:e.logId,tab:"response",toolCallIndex:e.index})};return r.jsx("button",{type:"button",className:"inline-flex h-5 min-w-0 max-w-[8.5rem] items-center rounded px-1.5 text-[10px] text-muted-foreground transition-colors hover:bg-background/65 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:t,onKeyDown:n=>n.stopPropagation(),"aria-label":`Open response tool call ${e.name}`,title:e.name,children:r.jsx("span",{className:"min-w-0 truncate font-mono font-semibold",children:e.name})})}function R4({events:e}){if(e.length===0)return null;const t=e.slice(0,T4),n=Math.max(0,e.length-t.length);return r.jsxs("span",{className:"inline-flex h-7 min-w-0 max-w-full items-center gap-1 overflow-hidden rounded-md border border-cyan-300/10 bg-cyan-300/[0.055] px-1 sm:max-w-[26rem]",role:"group","aria-label":`${e.length} response tool ${e.length===1?"call":"calls"}`,onClick:s=>s.stopPropagation(),onKeyDown:s=>s.stopPropagation(),children:[r.jsxs("span",{className:"inline-flex h-5 shrink-0 items-center gap-1 px-1 font-mono text-[9px] font-semibold uppercase text-cyan-300",children:[r.jsx(hr,{className:"size-3"}),"Call ",e.length]}),r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden",children:[t.map(s=>r.jsx(E4,{event:s},s.id)),n>0&&r.jsxs("span",{className:"inline-flex h-5 shrink-0 items-center rounded px-1 font-mono text-[10px] font-semibold text-muted-foreground",children:["+",n]})]})]})}const P4={success:"bg-slate-300/[0.08] text-slate-100 border-transparent",client_error:"bg-amber-300/[0.10] text-amber-100 border-transparent",server_error:"bg-rose-400/[0.10] text-rose-100 border-transparent",pending:"bg-cyan-300/[0.08] text-cyan-100 border-transparent"},M4={success:{frame:"border-cyan-200/15 bg-white/[0.04] text-slate-100"},client_error:{frame:"border-amber-300/25 bg-amber-300/[0.08] text-amber-100"},server_error:{frame:"border-rose-300/25 bg-rose-300/[0.08] text-rose-100"},pending:{frame:"border-cyan-300/25 bg-cyan-300/[0.08] text-cyan-100"}},qs="border border-transparent bg-white/[0.045] hover:bg-white/[0.075] size-8 text-muted-foreground shadow-none hover:text-cyan-100",Et="bg-white/[0.045] flex h-7 items-center gap-1 rounded-md px-2 text-xs";function Hs(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function I4(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function A4(e,t){switch(e){case"success":return t===null?"OK":String(t);case"client_error":return t===null?"WARN":String(t);case"server_error":return t===null?"FAIL":String(t);case"pending":return"ROLL"}}function Hu({trend:e}){if(e===null)return null;const t=e.direction==="up",n=t?Uy:Oy,s=t?"+":"-";return r.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[r.jsx(n,{className:t?"size-3 text-cyan-300":"size-3 text-rose-400"}),r.jsxs("span",{className:"font-mono",children:[s,Me(e.delta)]})]})}const O4=c.memo(function({log:e,displayNumber:t,messageCount:n=null,toolCount:s=null,toolEvents:o=[],expanded:i,onToggle:a,cacheTrend:l=null,activeTab:u,tabActions:d,onReplay:f,slowResponseThresholdSeconds:p=0,showClientMetadata:m=!0,timeDisplayFormat:h}){const g=Ag(e.responseStatus),y=e.elapsedMs!==null&&p>0&&e.elapsedMs>p*1e3,b=e.inputTokens!==null||e.outputTokens!==null,w=e.firstChunkMs??null,v=e.tokensPerSecond??null,j=w===null?null:Hs(w),S=v===null||v<=0?null:I4(v),k=e.warnings?.length??0,_=e.clientPid!==null&&e.clientPid!==void 0,C=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="";e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd;const I=M4[g],A=A4(g,e.responseStatus),P=g!=="success"||e.responseStatus!==200,N=e.streaming&&j===null&&S===null;return r.jsx(Ds,{children:r.jsxs("div",{id:`log-${e.id}`,role:"button",tabIndex:0,"data-nav-id":`log-${e.id}`,"data-nav-action":i?"collapse":"expand",className:$("group/header relative isolate flex min-w-0 cursor-pointer items-start gap-2 overflow-hidden px-3 py-2 transition-[background-color,border-color,box-shadow]",i?"bg-white/[0.04]":"bg-transparent hover:bg-white/[0.035]","select-none","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),onClick:a,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),a())},children:[r.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:$("inline-flex h-8 shrink-0 items-center rounded-md px-2 font-mono",I.frame),children:r.jsxs("span",{className:"text-xs font-semibold tabular-nums",title:`Log ID ${String(e.id)}`,children:["#",t]})}),r.jsxs("span",{className:"bg-white/[0.045] flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-xs text-muted-foreground",children:[r.jsx(rn,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:Ea(e.timestamp,h)})]}),P&&r.jsxs(_e,{variant:"outline",className:$("h-6 gap-1 rounded-md px-2 py-0 font-mono text-[10px] font-semibold uppercase tabular-nums shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]",P4[g]),children:[g==="success"?r.jsx(Ge,{className:"size-3","aria-label":"Success"}):g==="server_error"?r.jsx(wj,{className:"size-3","aria-label":"Server error"}):g==="client_error"?r.jsx(wn,{className:"size-3","aria-label":"Client error"}):r.jsx(Ue,{className:"size-3 animate-spin","aria-label":"Pending"}),A]}),k>0&&r.jsxs(pt,{children:[r.jsx(mt,{asChild:!0,children:r.jsxs(_e,{variant:"outline",className:"h-6 gap-1 rounded-md border-amber-300/30 bg-amber-300/[0.10] px-2 py-0 font-mono text-[10px] tabular-nums text-amber-100",children:[r.jsx(wn,{className:"size-3","aria-label":"Tool schema warnings"}),k]})}),r.jsx(ht,{children:k===1?"1 tool schema warning":`${k} tool schema warnings`})]}),e.elapsedMs!==null&&(y?r.jsxs(pt,{children:[r.jsx(mt,{asChild:!0,children:r.jsxs("span",{className:$(Et,"shrink-0 border-amber-300/25 text-amber-200"),children:[r.jsx(rn,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:Hs(e.elapsedMs)}),r.jsx(wn,{className:"size-3","aria-label":"Slow response"})]})}),r.jsxs(ht,{children:["Slow response: ",Hs(e.elapsedMs)," exceeds"," ",Hs(p*1e3)]})]}):r.jsxs("span",{className:$(Et,"shrink-0 text-muted-foreground"),children:[r.jsx(rn,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:Hs(e.elapsedMs)})]})),e.streaming&&j!==null&&r.jsxs("span",{className:$(Et,"shrink-0 text-cyan-300"),children:[r.jsx(ru,{className:"size-3"}),r.jsxs("span",{className:"font-mono tabular-nums",children:["first ",j]})]}),e.streaming&&S!==null&&r.jsxs("span",{className:$(Et,"shrink-0 text-cyan-300"),children:[r.jsx(Al,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:S})]}),b&&r.jsxs("span",{className:$(Et,"min-w-0 sm:shrink-0"),children:[r.jsx(rr,{className:"size-3 text-muted-foreground"}),r.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 font-mono tabular-nums",children:[r.jsxs("span",{className:$("whitespace-nowrap",e.inputTokens!==null?"text-blue-400":"text-muted-foreground"),children:["IN ",e.inputTokens!==null?Me(e.inputTokens):"n/a"]}),r.jsx("span",{className:"text-muted-foreground",children:"/"}),r.jsxs("span",{className:$("whitespace-nowrap",e.outputTokens!==null?"text-amber-400":"text-muted-foreground"),children:["OUT ",e.outputTokens!==null?Me(e.outputTokens):"n/a"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&r.jsxs("span",{className:$(Et,"shrink-0"),children:[r.jsx(Hu,{trend:l?.creation??null}),r.jsxs("span",{className:"font-mono tabular-nums text-cyan-300",children:["KV Cache +",Me(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&r.jsxs("span",{className:$(Et,"shrink-0"),children:[r.jsx(Hu,{trend:l?.read??null}),r.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",Me(e.cacheReadInputTokens)]})]}),n!==null&&r.jsxs("span",{className:$(Et,"shrink-0 text-muted-foreground"),children:[r.jsx(Go,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:n})]}),s!==null&&r.jsxs("span",{className:$(Et,"shrink-0 text-muted-foreground"),children:[r.jsx(hr,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:s})]}),r.jsx(R4,{events:o}),e.origin!==null&&r.jsxs("span",{className:$(Et,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[r.jsx(mp,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),m&&(_||C)&&r.jsxs("span",{className:$(Et,"hidden shrink-0 text-purple-300 xl:flex"),children:[r.jsx(Hw,{className:"size-3"}),C?r.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):r.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]}),N&&r.jsx(ru,{className:"size-3 shrink-0 text-muted-foreground/60"})]}),r.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[i&&r.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",onClick:M=>M.stopPropagation(),onKeyDown:M=>M.stopPropagation(),children:[d!==void 0&&u!==void 0&&(()=>{const M=d[u];return M===void 0?null:r.jsxs(r.Fragment,{children:[M.expansion!==null&&r.jsxs(pt,{children:[r.jsx(mt,{asChild:!0,children:r.jsx(ee,{variant:"outline",size:"icon",className:qs,onClick:M.expansion.onToggle,disabled:M.expansion.isPending,"aria-pressed":M.expansion.isExpanded,"aria-label":M.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:M.expansion.isExpanded?r.jsx(cw,{className:"size-3.5"}):r.jsx(sw,{className:"size-3.5"})})}),r.jsx(ht,{children:M.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),M.diffWithRaw!==void 0&&r.jsxs(pt,{children:[r.jsx(mt,{asChild:!0,children:r.jsx(ee,{variant:"outline",size:"icon",className:$(qs,M.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:M.diffWithRaw.onToggle,"aria-pressed":M.diffWithRaw.active,"aria-label":M.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:r.jsx(Uw,{className:"size-3.5"})})}),r.jsx(ht,{children:M.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),M.diffWithPrevious!==void 0&&r.jsxs(pt,{children:[r.jsx(mt,{asChild:!0,children:r.jsx(ee,{variant:"outline",size:"icon",className:qs,onClick:M.diffWithPrevious,"aria-label":"Diff with previous",children:r.jsx(hp,{className:"size-3.5"})})}),r.jsx(ht,{children:"Compare this request with the immediately preceding one"})]}),M.copyText!==null&&r.jsxs(pt,{children:[r.jsx(mt,{asChild:!0,children:r.jsx(ee,{variant:"outline",size:"icon",className:qs,onClick:M.onCopy,"aria-label":M.copyCopied?"Copied":M.copyLabel,children:M.copyCopied?r.jsx(Ge,{className:"size-3.5 text-cyan-300"}):r.jsx(Ot,{className:"size-3.5"})})}),r.jsx(ht,{children:M.copyCopied?"Copied to clipboard":M.copyLabel})]})]})})(),f!==void 0&&r.jsxs(pt,{children:[r.jsx(mt,{asChild:!0,children:r.jsx(ee,{variant:"outline",size:"icon",className:qs,onClick:f,"aria-label":"Replay request",children:r.jsx(vp,{className:"size-3.5"})})}),r.jsx(ht,{children:"Re-send this request to the provider"})]})]}),r.jsx("span",{className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-slate-200","aria-hidden":"true",children:i?r.jsx(nt,{className:"size-4 shrink-0"}):r.jsx(yt,{className:"size-4 shrink-0"})})]})]})})});function z4({...e}){return r.jsx(xk,{"data-slot":"collapsible",...e})}function t6({...e}){return r.jsx(Pp,{"data-slot":"collapsible-trigger",...e})}function L4({...e}){return r.jsx(Mp,{"data-slot":"collapsible-content",...e})}function $4({className:e,children:t,...n}){return r.jsxs(jN,{"data-slot":"scroll-area",className:$("relative overflow-hidden",e),...n,children:[r.jsx(kN,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full max-h-[inherit] rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),r.jsx(D4,{}),r.jsx(SN,{})]})}function D4({className:e,orientation:t="vertical",...n}){return r.jsx(Um,{"data-slot":"scroll-area-scrollbar",orientation:t,className:$("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...n,children:r.jsx(Hm,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const x0={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},F4={file:"border-transparent bg-blue-400/5 text-blue-300",shell:"border-transparent bg-teal-400/5 text-teal-300",browser:"border-transparent bg-cyan-400/5 text-cyan-300",web:"border-transparent bg-sky-400/5 text-sky-300",mcp:"border-transparent bg-violet-400/5 text-violet-300",code:"border-transparent bg-emerald-400/5 text-emerald-300",other:"border-transparent bg-muted/30 text-muted-foreground"};function U4({category:e}){switch(e){case"file":return r.jsx(Zw,{className:"size-3.5"});case"shell":return r.jsx(Xn,{className:"size-3.5"});case"browser":return r.jsx(xj,{className:"size-3.5"});case"web":return r.jsx(mp,{className:"size-3.5"});case"mcp":return r.jsx(Wy,{className:"size-3.5"});case"code":return r.jsx(dp,{className:"size-3.5"});case"other":return r.jsx(Iw,{className:"size-3.5"})}}function B4({names:e}){return e.length===0?null:r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[r.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"required"}),e.slice(0,4).map(t=>r.jsx(_e,{variant:"outline",className:"h-5 max-w-36 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",children:t},t)),e.length>4&&r.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e.length-4]})]})}function V4({tool:e,called:t}){const[n,s]=c.useState(!1),o=vn(e.name),i=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return r.jsx(z4,{open:n,onOpenChange:s,children:r.jsxs("div",{className:"bg-white/[0.035] rounded-[8px]",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",children:[r.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>s(a=>!a),"aria-expanded":n,disabled:!i,children:[r.jsx(U4,{category:e.category}),r.jsx("span",{className:"min-w-0 truncate font-mono text-xs font-semibold text-foreground/90",children:e.name}),t&&r.jsx(_e,{variant:"outline",className:"h-5 rounded-md border-emerald-400/20 bg-emerald-400/5 px-1.5 py-0 text-[10px] text-emerald-300",children:"called"}),r.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:[e.parameterCount," params"]}),e.descriptionPreview!==null&&r.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground md:inline",children:e.descriptionPreview}),r.jsx("span",{className:"flex-1"}),i&&(n?r.jsx(nt,{className:"size-3.5 shrink-0 text-muted-foreground"}):r.jsx(yt,{className:"size-3.5 shrink-0 text-muted-foreground"}))]}),r.jsx("button",{type:"button",className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:o.copy,"aria-label":o.copied?"Copied tool name":"Copy tool name",children:o.copied?r.jsx(Ge,{className:"size-3.5 text-emerald-400"}):r.jsx(Ot,{className:"size-3.5"})})]}),r.jsx(L4,{children:n&&r.jsxs("div",{className:"space-y-2 bg-white/[0.025] px-2.5 py-2",children:[e.description!==null&&r.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e.description}),r.jsx(B4,{names:e.requiredParameters}),e.schema!==null&&r.jsx($4,{className:"bg-black/[0.16] max-h-64 rounded-[8px] p-2",children:r.jsx(c.Suspense,{fallback:r.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:r.jsx(Ja,{data:Po(e.schema),defaultExpandDepth:0})})})]})})]})})}function q4(e,t){return t.length===0?!0:`${e.name} ${e.description??""} ${x0[e.category]}`.toLowerCase().trim().includes(t)}const H4=c.memo(function({summary:t,calledToolNames:n}){const[s,o]=c.useState(!1),[i,a]=c.useState(""),l=c.useMemo(()=>new Set(n),[n]),u=i.trim().toLowerCase(),d=c.useMemo(()=>t===null?[]:t.tools.filter(m=>q4(m,u)),[u,t]);if(t===null)return null;const f=t.tools.slice(0,6),p=t.tools.length-f.length;return r.jsxs("section",{className:"bg-black/[0.10] mb-3 overflow-hidden rounded-[8px]",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 px-3 py-2",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[r.jsx(hr,{className:"size-4 shrink-0 text-sky-300/80"}),r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[r.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Request Tools"}),r.jsx(_e,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",children:t.tools.length}),t.toolChoiceLabel!==null&&r.jsxs(_e,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px] text-muted-foreground",children:["tool_choice: ",t.toolChoiceLabel]})]}),r.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap gap-1",children:t.categories.map(m=>r.jsxs(_e,{variant:"outline",className:$("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",F4[m.category]),children:[m.count," ",x0[m.category]]},m.category))})]})]}),r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-cyan-100",onClick:()=>o(m=>!m),"aria-expanded":s,children:[s?r.jsx(nt,{className:"size-3.5"}):r.jsx(yt,{className:"size-3.5"}),s?"Hide":"Show"]})]}),r.jsxs("div",{className:"flex min-w-0 flex-wrap gap-1.5 bg-white/[0.025] px-3 py-2",children:[f.map(m=>r.jsx(_e,{variant:"outline",className:$("h-5 max-w-44 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",l.has(m.name)&&"border-emerald-400/20 text-emerald-300"),children:m.name},m.name)),p>0&&r.jsxs("span",{className:"font-mono text-[10px] leading-5 text-muted-foreground",children:["+",p]})]}),s&&r.jsxs("div",{className:"space-y-2 bg-black/10 px-3 py-3",children:[r.jsxs("label",{className:"bg-white/[0.045] hover:bg-white/[0.075] flex h-8 items-center gap-2 rounded-md px-2 text-xs",children:[r.jsx(yp,{className:"size-3.5 shrink-0 text-muted-foreground"}),r.jsx("input",{value:i,onChange:m=>a(m.target.value),placeholder:"Filter tools",className:"min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:text-muted-foreground/70"})]}),r.jsx("div",{className:"grid gap-1.5",children:d.length>0?d.map(m=>r.jsx(V4,{tool:m,called:l.has(m.name)},m.name)):r.jsx("p",{className:"py-2 text-xs text-muted-foreground",children:"No matching tools"})})]})]})});function Wu(e,t,n){return e==="anthropic"&&t==="full"&&n}function W4(e,t){return e==="full"&&t}function Ji(e,t){return e==="full"&&t}function Yi(e,t){return e==="full"&&t}function Z4(e,t,n,s){return e==="anthropic"&&t==="full"&&n&&s}function cs(){return r.jsx("div",{className:"h-1","aria-hidden":"true"})}function K4(e,t){switch(e){case"anatomy":return t===null?"request":"anatomy";case"request":return"request";case"response":return"parsed"}}const G4=15e3,J4=15e3,Y4=256*1024,Mo=1024*1024,An="h-9 flex-none rounded-md border border-transparent bg-transparent px-3 text-xs font-semibold text-muted-foreground shadow-none transition-colors hover:bg-white/[0.045] hover:text-foreground data-[state=active]:bg-cyan-300/[0.08] data-[state=active]:text-cyan-100 data-[state=active]:shadow-none";function $r(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function Io(e){return e??0}function b0(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function v0(e){return b0(e)?Io(e.rawRequestBodyBytes)>Mo||Io(e.responseTextBytes)>Mo:!1}function X4(e){return b0(e)&&!v0(e)}function Q4(e){return e instanceof Zo?"Body preview timed out. The log is still available on disk; try loading again.":e instanceof Error?e.message:"Body preview could not be loaded."}function Dr({status:e,error:t,footprint:n,onRetry:s}){switch(e){case"idle":return null;case"loading":return r.jsx(cr,{tone:"loading",title:"Loading full bodies",children:r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(Ue,{className:"size-3.5 shrink-0 animate-spin text-cyan-200"}),r.jsx("span",{children:"Loading full request and response bodies from the log store."})]}),n!==null&&r.jsx("span",{className:"rounded border border-cyan-300/15 bg-cyan-300/[0.06] px-2 py-0.5 font-mono text-[11px] text-cyan-100",children:n})]})});case"failed":return r.jsx(cr,{tone:"warning",title:t?.title??"Full bodies could not be loaded",children:r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r.jsx("span",{children:t?.detail??"Compact metadata is still available."}),r.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 gap-1.5 text-xs text-amber-100",onClick:s,children:[r.jsx(Vt,{className:"size-3"}),"Retry"]})]})})}}function Zu(e,t){return e?t.text!==""?t.text:t.status==="success"?"":null:null}function On({children:e,className:t}){return r.jsx("div",{className:$("bg-black/[0.14] inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",t),children:e})}function oo({children:e}){return r.jsx("div",{className:"bg-white/[0.035] rounded-md px-3 py-5 text-center text-xs italic text-muted-foreground",children:e})}function Fr({children:e}){return r.jsx("pre",{className:"bg-black/[0.18] inspector-scrollbar max-h-[64vh] overflow-auto whitespace-pre-wrap break-words rounded-[8px] p-3 font-mono text-xs leading-relaxed text-muted-foreground",children:e})}const eE={loading:"border-transparent bg-cyan-400/[0.06] text-cyan-100",warning:"border-transparent bg-amber-400/[0.08] text-amber-100",danger:"border-transparent bg-rose-400/[0.08] text-rose-100"};function cr({tone:e,title:t,children:n}){return r.jsxs("div",{className:$("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",eE[e]),children:[t!==void 0&&r.jsx("div",{className:"mb-1 font-semibold",children:t}),r.jsx("div",{className:"leading-relaxed text-muted-foreground",children:n})]})}function Ur({label:e,state:t,expectedBytes:n,onLoadMore:s}){const o=t.totalBytes??n,i=o===null?gs(t.offset):`${gs(t.offset)} / ${gs(o)}`,a=t.status!=="loading"&&t.hasMore,l=t.status==="failed"?"Retry":"Load more";return r.jsx(cr,{tone:t.status==="failed"?"warning":"loading",title:`${e} body preview`,children:r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r.jsxs("span",{children:[t.status==="idle"&&o!==null?`${e} body is ${gs(o)}. Loading the first preview chunk.`:`Loaded ${i}.`,t.status==="failed"&&t.error!==null&&` ${t.error}`]}),a&&r.jsx(ee,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 text-xs text-cyan-100",onClick:s,children:l})]})})}function Ku({headers:e,emptyLabel:t}){const n=e===void 0?[]:Object.entries(e).sort(([s],[o])=>s.localeCompare(o));return n.length===0?r.jsx(oo,{children:t}):r.jsx("div",{className:"bg-black/[0.14] overflow-hidden rounded-[8px] font-mono text-xs",children:n.map(([s,o])=>r.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(140px,0.32fr)_minmax(0,1fr)] border-b border-white/[0.055] last:border-b-0",children:[r.jsx("div",{className:"min-w-0 truncate bg-white/[0.035] px-2.5 py-2 font-semibold text-cyan-200",children:s}),r.jsx("div",{className:"min-w-0 truncate px-2.5 py-2 text-muted-foreground",title:o,children:o})]},s))})}function tE({active:e,onClick:t}){return r.jsxs(pt,{children:[r.jsx(mt,{asChild:!0,children:r.jsxs(ee,{variant:e?"default":"outline",size:"sm",className:$("h-8 border-white/10 text-xs shadow-none",e?"bg-cyan-300 text-black hover:bg-cyan-200":"border border-input bg-background hover:bg-accent hover:text-accent-foreground text-muted-foreground hover:text-cyan-100"),onClick:t,"aria-pressed":e,children:[r.jsx(tj,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),r.jsx(ht,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const nE=c.memo(function({rawBody:e,displayedBody:t,emptyLabel:n}){const s=c.useMemo(()=>b4(e,t),[e,t]);return r.jsx(g0,{result:s,emptyLabel:n})}),sE=c.memo(function({rawHeaders:e,headers:t,emptyLabel:n}){const s=c.useMemo(()=>x4(e,t),[e,t]);return r.jsx(g0,{result:s,emptyLabel:n})}),rE=c.memo(function({log:e,displayNumber:t,viewMode:n="simple",strip:s,slowResponseThresholdSeconds:o,timeDisplayFormat:i,cacheTrend:a=null,onCompareWithPrevious:l,showClientMetadata:u=!0,toolEvents:d=[]}){const[f,p]=c.useState(!1),[m,h]=c.useState(!1),[g,y]=c.useState(!1),[b,w]=c.useState(!1),[v,j]=c.useState("request"),[S,k]=c.useState(null),[_,C]=c.useState(0),[I,A]=c.useState(null),[P,N]=c.useState(null),[M,F]=c.useState("idle"),[B,J]=c.useState(null),[K,W]=c.useState(0),[V,z]=c.useState(()=>$r(e.rawRequestBodyBytes??null)),[X,Y]=c.useState(()=>$r(e.responseTextBytes??null)),we=c.useRef(null),he=c.useRef(e.id),oe=c.useRef(!1),D=P??e,Ne=P===null&&v0(e),te=c.useMemo(()=>u4(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),je=Zu(Ne,V),ke=Zu(Ne,X),ue=D.rawRequestBody??je,le=D.responseText??ke,xe=D.rawRequestBody===null&&je!==null,Se=D.responseText===null&&ke!==null,ve=!xe||V.hasMore===!1&&Io(V.totalBytes)<=Mo,Ze=!Se||X.hasMore===!1&&Io(X.totalBytes)<=Mo,Be=ar(D),Ke=n0(Be),dt=c.useMemo(()=>Ke.analyzeRequest(D.rawRequestBody),[Ke,D.rawRequestBody]),Lt=c.useMemo(()=>Ke.analyzeResponse(D.responseText),[Ke,D.responseText]),Ye=c.useMemo(()=>!s||Be!=="anthropic"||D.rawRequestBody===null?null:ZT(D.rawRequestBody).body,[D.rawRequestBody,Be,s])??ue,Ie=Ki(ve?Ye:null),Oe=Ki(v==="raw-request"&&ve?ue:null),q=Ki(v==="raw"&&Ze?le:null),ne=c.useMemo(()=>D.headers&&Object.keys(D.headers).length>0?JSON.stringify(D.headers,null,2):null,[D.headers]),Ee=c.useMemo(()=>D.rawHeaders&&Object.keys(D.rawHeaders).length>0?JSON.stringify(D.rawHeaders,null,2):null,[D.rawHeaders]),me=vn(Ye),be=vn(ue),ze=vn(ne),G=vn(Ee),E=vn(le),L=c.useMemo(()=>({request:{copyLabel:xe?"Copy loaded request preview":"Copy request body",copyText:Ye,copyCopied:me.copied,onCopy:me.copy,expansion:ve?{isExpanded:Ie.isExpanded,isPending:Ie.isPending,onToggle:Ie.toggle}:null,diffWithRaw:Z4(Be,n,s,D.rawRequestBody!==null)?{active:b,onToggle:()=>w(!b)}:void 0,diffWithPrevious:l===void 0?void 0:()=>{l(D)}},"raw-request":{copyLabel:xe?"Copy loaded raw request preview":"Copy raw request",copyText:ue,copyCopied:be.copied,onCopy:be.copy,expansion:ve?{isExpanded:Oe.isExpanded,isPending:Oe.isPending,onToggle:Oe.toggle}:null},...Yi(n,D.headers!==void 0&&Object.keys(D.headers).length>0)?{headers:{copyLabel:"Copy headers",copyText:ne,copyCopied:ze.copied,onCopy:ze.copy,expansion:null}}:{},...Ji(n,D.rawHeaders!==void 0&&Object.keys(D.rawHeaders).length>0)?{"raw-headers":{copyLabel:"Copy raw headers",copyText:Ee,copyCopied:G.copied,onCopy:G.copy,expansion:null}}:{},raw:{copyLabel:Se?"Copy loaded response preview":"Copy response",copyText:le,copyCopied:E.copied,onCopy:E.copy,expansion:Ze?{isExpanded:q.isExpanded,isPending:q.isPending,onToggle:q.toggle}:null}}),[Ye,xe,ve,me,Ie,b,D,D.rawRequestBody,ue,be,Oe,ne,ze,Ee,G,D.responseText,Se,Ze,le,E,q,Be,n,s,l]),Z=c.useMemo(()=>Ie.parsedData!==null?Ke.anatomySegments(Ie.parsedData):null,[Ke,Ie.parsedData]),ie=c.useMemo(()=>pc(Ie.parsedData),[Ie.parsedData]),de=D.warnings??[],se=c.useMemo(()=>{if(Z!==null)return new Set(Z.map(Ae=>Ae.path))},[Z]),ye=c4({containerRef:we,setExpandToPath:A,ensureTabActive:()=>{v!=="request"&&j("request")}}),ce=c.useCallback((Ae,en)=>{const Ve=Ae==="request"?z:Y;Ve(Xe=>({...Xe,status:"loading",error:null}));const ts=new URLSearchParams({part:Ae,offset:String(en),limit:String(Y4)});qe(`/api/logs/${String(e.id)}/body?${ts.toString()}`,R2,J4).then(Xe=>{he.current===e.id&&Ve($t=>({status:"success",text:Xe.offset===0?Xe.text:`${$t.text}${Xe.text}`,offset:Xe.nextOffset??Xe.totalBytes,totalBytes:Xe.totalBytes,hasMore:Xe.hasMore,error:null}))}).catch(Xe=>{he.current===e.id&&Ve($t=>({...$t,status:"failed",error:Q4(Xe)}))})},[e.id]),ft=c.useCallback(()=>{oe.current||(N(null),F("idle"),J(null),W(Ae=>Ae+1))},[]),In=c.useCallback(()=>{const Ae=!f;Ae&&j(Z!==null?"anatomy":"request"),p(Ae)},[Z,f]);return c.useEffect(()=>{he.current=e.id,oe.current=!1,N(null),F("idle"),J(null),W(0),z($r(e.rawRequestBodyBytes??null)),Y($r(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),c.useEffect(()=>{if(!f||!X4(e)||P!==null||oe.current)return;let Ae=!1;return oe.current=!0,F("loading"),J(null),qe(`/api/logs/${String(e.id)}`,sr,G4).then(en=>{Ae||(oe.current=!1,N(en),F("idle"),J(null))}).catch(en=>{Ae||(oe.current=!1,F("failed"),J(d4(en)))}),()=>{Ae=!0,oe.current=!1}},[f,P,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,K]),c.useEffect(()=>{f&&Ne&&V.status==="idle"&&(v!=="request"&&v!=="raw-request"&&v!=="anatomy"||ce("request",0))},[v,f,ce,V.status,Ne]),c.useEffect(()=>{f&&Ne&&X.status==="idle"&&(v!=="parsed"&&v!=="raw"||ce("response",0))},[v,f,ce,X.status,Ne]),c.useEffect(()=>{const Ae=en=>{const Ve=wi(en);Ve!==null&&Ve.logId===e.id&&(p(!0),j(K4(Ve.tab,Z)),Ve.tab==="response"&&Ve.toolCallIndex!==void 0&&(k(Ve.toolCallIndex),C(ts=>ts+1)))};return window.addEventListener(un,Ae),()=>{window.removeEventListener(un,Ae)}},[Z,e.id]),r.jsxs(Ds,{children:[r.jsxs("div",{className:$("bg-card/80 relative mb-1.5 overflow-hidden rounded-[8px] transition-[background-color,box-shadow]",f?"bg-card shadow-[0_18px_60px_rgba(0,0,0,0.30),0_0_0_1px_rgba(103,232,249,0.08)]":"hover:bg-card"),children:[r.jsx(O4,{log:D,displayNumber:t,messageCount:dt.messageCount,toolCount:dt.toolCount,toolEvents:d,expanded:f,onToggle:In,cacheTrend:a,slowResponseThresholdSeconds:o,showClientMetadata:u,timeDisplayFormat:i,activeTab:v,tabActions:L,onReplay:l===void 0?void 0:()=>{h(!0)}}),f&&r.jsxs("div",{className:"relative bg-black/[0.14] pt-2",onClick:Ae=>Ae.stopPropagation(),onKeyDown:Ae=>Ae.stopPropagation(),children:[r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-12 bg-gradient-to-b from-white/[0.05] to-transparent","aria-hidden":"true"}),r.jsx(co,{feature:"Log details",children:r.jsxs(d0,{value:v,onValueChange:j,className:"gap-2",children:[r.jsxs(f0,{variant:"line",className:"bg-white/[0.04] inspector-scrollbar relative mx-3 h-auto w-[calc(100%-1.5rem)] justify-start overflow-x-auto rounded-[8px] p-1",children:[Ji(n,D.rawHeaders!==void 0&&Object.keys(D.rawHeaders).length>0)&&r.jsx(xn,{className:An,value:"raw-headers",children:"Raw Headers"}),Yi(n,D.headers!==void 0&&Object.keys(D.headers).length>0)&&r.jsx(xn,{className:An,value:"headers",children:"Headers"}),Z!==null&&r.jsx(xn,{className:An,value:"anatomy",children:"Context"}),Wu(Be,n,s)&&r.jsx(xn,{className:An,value:"raw-request",children:"Raw Request"}),r.jsx(xn,{className:An,value:"request",children:"Request"}),n==="full"&&r.jsx(xn,{className:An,value:"raw",children:"Raw Response"}),r.jsx(xn,{className:An,value:"parsed",children:"Response"})]}),Wu(Be,n,s)&&r.jsx(jt,{value:"raw-request",children:v==="raw-request"&&r.jsxs(On,{children:[r.jsx(Dr,{status:M,error:B,footprint:te,onRetry:ft}),Ne&&r.jsx(Ur,{label:"Request",state:V,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ce("request",V.offset)}),ue===null?r.jsx(oo,{children:Ne?"Request preview is loading":"No request body"}):Oe.parsedData!==null?r.jsx(c.Suspense,{fallback:r.jsx(cs,{}),children:r.jsx(Ja,{data:Oe.parsedData,bulkDepth:Oe.bulkDepth,bulkRevision:Oe.bulkRevision})}):r.jsx(Fr,{children:ue})]})}),r.jsx(jt,{value:"request",children:v==="request"&&r.jsxs(On,{children:[r.jsx(Dr,{status:M,error:B,footprint:te,onRetry:ft}),Ne&&r.jsx(Ur,{label:"Request",state:V,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ce("request",V.offset)}),de.length>0&&r.jsxs(cr,{tone:"warning",children:[r.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[r.jsx(wn,{className:"size-3.5"}),"Tool schema warnings"]}),r.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:de.map(Ae=>r.jsx("li",{children:Ae},Ae))})]}),r.jsx(H4,{summary:ie,calledToolNames:Lt.toolNames??[]}),b?r.jsx(nE,{rawBody:D.rawRequestBody,displayedBody:Ye,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):r.jsx("div",{ref:we,children:Ye===null?r.jsx(oo,{children:Ne?"Request preview is loading":"No request body"}):Ie.parsedData!==null?r.jsx(c.Suspense,{fallback:r.jsx(cs,{}),children:r.jsx(Ja,{data:Ie.parsedData,bulkDepth:Ie.bulkDepth,bulkRevision:Ie.bulkRevision,anatomyPaths:se,expandToPath:I})}):r.jsx(Fr,{children:Ye})})]})}),Z!==null&&r.jsx(jt,{value:"anatomy",children:v==="anatomy"&&r.jsx(On,{className:"p-0",children:r.jsx(c.Suspense,{fallback:r.jsx(cs,{}),children:r.jsx(s4,{parsed:Ie.parsedData,inputTokens:D.inputTokens??null,model:D.model,segments:Z,onSegmentActivate:ye})})})}),Yi(n,D.headers!==void 0&&Object.keys(D.headers).length>0)&&r.jsx(jt,{value:"headers",children:v==="headers"&&r.jsxs(On,{children:[r.jsx("div",{className:"flex justify-end gap-2 mb-2",children:W4(n,D.rawHeaders!==void 0&&Object.keys(D.rawHeaders).length>0)&&r.jsx(tE,{active:g,onClick:Ae=>{Ae.stopPropagation(),y(!g)}})}),g?r.jsx(sE,{rawHeaders:D.rawHeaders,headers:D.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):r.jsx(Ku,{headers:D.headers,emptyLabel:"No headers captured"})]})}),Ji(n,D.rawHeaders!==void 0&&Object.keys(D.rawHeaders).length>0)&&r.jsx(jt,{value:"raw-headers",children:v==="raw-headers"&&r.jsx(On,{children:r.jsx(Ku,{headers:D.rawHeaders,emptyLabel:"No raw headers captured"})})}),r.jsx(jt,{value:"raw",children:v==="raw"&&r.jsxs(On,{className:"space-y-3",children:[r.jsx(Dr,{status:M,error:B,footprint:te,onRetry:ft}),Ne&&r.jsx(Ur,{label:"Response",state:X,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ce("response",X.offset)}),D.error!==void 0&&D.error!==null&&r.jsx(cr,{tone:"danger",title:"SSE Error",children:r.jsx("span",{className:"font-mono",children:D.error})}),le!==null&&Ze?r.jsx(c.Suspense,{fallback:r.jsx(cs,{}),children:r.jsx(i4,{text:le,defaultExpandDepth:0,bulkDepth:q.bulkDepth,bulkRevision:q.bulkRevision})}):le!==null?r.jsx(Fr,{children:le}):r.jsx(oo,{children:Ne?"Response preview is loading":"No response"}),D.streaming===!0&&r.jsx(c.Suspense,{fallback:r.jsx(cs,{}),children:r.jsx(o4,{logId:D.id,truncated:D.streamingChunksPath!==null})})]})}),r.jsx(jt,{value:"parsed",children:v==="parsed"&&r.jsxs(On,{children:[r.jsx(Dr,{status:M,error:B,footprint:te,onRetry:ft}),Ne&&r.jsx(Ur,{label:"Response",state:X,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ce("response",X.offset)}),Se&&!Ze?r.jsx(Fr,{children:le}):r.jsx(c.Suspense,{fallback:r.jsx(cs,{}),children:r.jsx(r4,{responseText:le,responseStatus:D.responseStatus,streaming:D.streaming,inputTokens:D.inputTokens,outputTokens:D.outputTokens,cacheCreationInputTokens:D.cacheCreationInputTokens,cacheReadInputTokens:D.cacheReadInputTokens,apiFormat:Be,error:D.error,focusedToolIndex:S,toolFocusNonce:_})})]})})]})})]})]}),r.jsx(co,{feature:"Replay",children:r.jsx(c.Suspense,{fallback:null,children:r.jsx(n4,{log:D,displayNumber:t,open:m,onOpenChange:h})})})]})});function oE(e){switch(e){case"end_turn":return"End of Turn (Anthropic)";case"stop":return"End of Turn (OpenAI)";case"length":return"End of Turn (length limit)";case"tool_use":case null:return"End of Turn"}}function Xi(e){return e?"cursor-pointer transition-transform hover:scale-110":""}function iE({stopReason:e,isPending:t,isFirst:n,isTurnStart:s,isOnlyEntry:o=!1,isOpenTurnTail:i=!1,crabIndex:a=0,collapsible:l=!1,onToggle:u}){const d=mc(e),f=o&&s&&d,p=t&&!d,m=l&&u!==void 0,h=c.useMemo(()=>hc(a),[a]),g=c.useMemo(()=>BT(a),[a]),y=w=>{!m||u===void 0||(w.stopPropagation(),u())},b=w=>{!m||u===void 0||w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),u())};return r.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[r.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!n&&r.jsx("div",{className:"w-px bg-muted-foreground/18 h-full"})}),f?r.jsx("span",{role:m?"button":void 0,tabIndex:m?0:void 0,title:"Single-request turn",className:Xi(m),onClick:y,onKeyDown:b,children:r.jsx(g,{className:$("size-3.5 text-[#80FF00]","animate-crab-settle","drop-shadow-[0_0_4px_rgba(128,255,0,0.5)]")})}):d?r.jsx("span",{role:m?"button":void 0,tabIndex:m?0:void 0,title:oE(e),className:Xi(m),onClick:y,onKeyDown:b,children:r.jsx(h,{className:$("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})}):s?r.jsx("span",{role:m?"button":void 0,tabIndex:m?0:void 0,title:"Start of turn",className:Xi(m),onClick:y,onKeyDown:b,children:r.jsx(h,{className:$("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):i?r.jsx("span",{title:t?"Current end of open turn (processing)":"Current end of open turn",children:r.jsx(h,{className:$("size-3.5 text-cyan-300/85",p?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})}):p?r.jsx("span",{title:"Processing",children:r.jsx(h,{className:$("size-3.5 text-amber-300/80","animate-crab-crawl")})}):r.jsx("span",{title:"Request in turn",children:r.jsx(h,{className:"size-3.5 text-muted-foreground/40"})}),r.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!d&&!i&&r.jsx("div",{className:$("w-0.5 h-full",t?"border-dashed bg-transparent border-l border-muted-foreground/14":"bg-muted-foreground/18")})})]})}const Gu=180,Qi=new WeakMap;function aE(e,t){const n=e.responseText;if(n===null)return!1;switch(t){case"anthropic":return n.includes("tool_use");case"openai":return n.includes("tool_calls")||n.includes("function_call");case"unknown":return!1}}function lE(e){return e>1}function Qa(e){const t=[];let n=[],s=0;for(let o=0;o<e.length;o+=1){const i=e[o];if(i===void 0)continue;n.push({log:i,stopReason:l0(i),sessionLogNumber:o+1});const a=n[n.length-1];a!==void 0&&mc(a.stopReason)&&(t.push({entries:n,turnIndex:s}),n=[],s+=1)}return n.length>0&&t.push({entries:n,turnIndex:s}),t}function cE(e){const t=new Map;for(const n of e)for(let s=1;s<n.logs.length;s+=1){const o=n.logs[s],i=n.logs[s-1];if(o===void 0||i===void 0)continue;const a=ar(o),l=ar(i);a==="unknown"||a!==l||t.set(o.id,i)}return t}function y0(e){if(e===null)return null;try{const t=JSON.parse(e);return typeof t=="string"?JSON.parse(t):t}catch{return null}}function io(e){if(e==null)return null;const t=typeof e=="string"?e:JSON.stringify(e);if(t===void 0)return null;const n=t.replace(/\s+/g," ").trim();return n.length===0?null:n.length>Gu?`${n.slice(0,Gu-1)}...`:n}function ao(e){if(e==null)return null;if(typeof e=="string")return e.length>0?e:null;const t=JSON.stringify(e,null,2);return t===void 0||t.length===0?null:t}function uE(e){const t=y0(e.responseText),n=Q(t,"content");if(!Array.isArray(n))return[];const s=[];for(const o of n){if(Q(o,"type")!=="tool_use")continue;const a=Q(o,"name");if(typeof a!="string"||a.length===0)continue;const l=Q(o,"input");s.push({id:`${String(e.id)}-anthropic-tool-${String(s.length)}`,logId:e.id,index:s.length,provider:"anthropic",name:a,argumentsText:ao(l),argumentsPreview:io(l)})}return s}function dE(e){const t=y0(e.responseText),n=Q(t,"choices");if(!Array.isArray(n))return[];const s=[];for(const i of n){const a=Q(i,"message"),l=Q(a,"tool_calls");if(Array.isArray(l))for(const f of l){const p=Q(f,"function"),m=Q(p,"name");if(typeof m!="string"||m.length===0)continue;const h=Q(p,"arguments");s.push({id:`${String(e.id)}-openai-tool-${String(s.length)}`,logId:e.id,index:s.length,provider:"openai",name:m,argumentsText:ao(h),argumentsPreview:io(h)})}const u=Q(a,"function_call"),d=Q(u,"name");if(typeof d=="string"&&d.length>0){const f=Q(u,"arguments");s.push({id:`${String(e.id)}-openai-tool-${String(s.length)}`,logId:e.id,index:s.length,provider:"openai",name:d,argumentsText:ao(f),argumentsPreview:io(f)})}}const o=Q(t,"output");if(Array.isArray(o))for(const i of o){if(Q(i,"type")!=="function_call")continue;const a=Q(i,"name");if(typeof a!="string"||a.length===0)continue;const l=Q(i,"arguments");s.push({id:`${String(e.id)}-openai-tool-${String(s.length)}`,logId:e.id,index:s.length,provider:"openai",name:a,argumentsText:ao(l),argumentsPreview:io(l)})}return s}function gc(e){const t=Qi.get(e);if(t!==void 0&&t.apiFormat===e.apiFormat&&t.responseText===e.responseText)return t.events;const n=ar(e);if(!aE(e,n)){const o=[];return Qi.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:o}),o}let s;switch(n){case"anthropic":s=uE(e);break;case"openai":s=dE(e);break;case"unknown":s=[];break}return Qi.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:s}),s}function fE(e,t,n=0){let s=0,o=0,i=0,a=0,l=0,u=0,d=0,f=0,p=null,m=0;for(const h of e)h.responseStatus===null?o+=1:h.responseStatus>=400&&(s+=1),h.elapsedMs!==null&&t>0&&h.elapsedMs>t*1e3&&(i+=1),h.inputTokens!==null&&(a+=h.inputTokens),h.outputTokens!==null&&(l+=h.outputTokens),h.cacheCreationInputTokens!==null&&(u+=h.cacheCreationInputTokens),h.cacheReadInputTokens!==null&&(d+=h.cacheReadInputTokens),h.elapsedMs!==null&&(f+=h.elapsedMs,p=p===null?h.elapsedMs:Math.max(p,h.elapsedMs)),m+=gc(h).length;return{llmCallCount:e.length,toolCallCount:m,failedCallCount:s,pendingCallCount:o,slowCallCount:i,totalInputTokens:a,totalOutputTokens:l,totalCacheCreationInputTokens:u,totalCacheReadInputTokens:d,totalElapsedMs:f,maxElapsedMs:p,startedAt:e[0]?.timestamp??null,endedAt:e[e.length-1]?.timestamp??null,knowledgeCandidateCount:n}}function ea(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const pE=c.memo(function({entries:t,viewMode:n,strip:s,slowResponseThresholdSeconds:o,cacheTrends:i,onCompareWithPrevious:a,comparisonPredecessors:l,turnIndex:u=0,timeDisplayFormat:d,pendingFocusRequest:f,showLogClientMetadata:p=!0}){const m=t.length-1,h=t[m]?.stopReason??null,g=h!==null?mc(h):!1,y=t[m]?.log.responseStatus===null,b=t.length===1,w=lE(t.length),[v,j]=c.useState(!1),S=c.useRef(!1);c.useEffect(()=>{w?g&&!S.current&&j(!0):j(!1),S.current=g},[w,g]),c.useEffect(()=>{const W=V=>{const z=wi(V);z!==null&&t.some(X=>X.log.id===z.logId)&&w&&j(!1)};return window.addEventListener(un,W),()=>{window.removeEventListener(un,W)}},[w,t]),c.useEffect(()=>{if(f===void 0||!t.some(V=>V.log.id===f.logId))return;w&&j(!1);const W=window.setTimeout(()=>{Ms({logId:f.logId,tab:f.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(W)},[w,t,f]);const k=c.useCallback(()=>{w&&j(W=>!W)},[w]),_=c.useMemo(()=>{let W=0,V=0,z=null,X=!1;for(const Y of t)Y.log.inputTokens!==null&&(W+=Y.log.inputTokens,X=!0),Y.log.outputTokens!==null&&(V+=Y.log.outputTokens,X=!0),Y.log.elapsedMs!==null&&(z=z===null?Y.log.elapsedMs:Math.max(z,Y.log.elapsedMs));return{totalInput:W,totalOutput:V,hasTokens:X,maxElapsed:z}},[t,m]),C=u%2===0?"bg-white/[0.008]":"bg-cyan-300/[0.008]",I=_.maxElapsed!==null&&o>0&&_.maxElapsed>o*1e3,A=c.useMemo(()=>{const W=new Map;for(const V of t){const z=gc(V.log);z.length>0&&W.set(V.log.id,z)}return W},[t]),[P,N]=c.useState(0),M=c.useRef(null);c.useEffect(()=>{const W=M.current;if(!W)return;let V=0;const z=new ResizeObserver(()=>{window.cancelAnimationFrame(V),V=window.requestAnimationFrame(()=>N(X=>X+1))});return z.observe(W),()=>{z.disconnect(),window.cancelAnimationFrame(V)}},[]);const F=t[0]?.log.id??u,B=`Turn ${String(u+1)}`,J=c.useMemo(()=>hc(F%12),[F]),K=c.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:v?"48px":"160px"}),[v]);return r.jsx("div",{ref:M,style:K,tabIndex:v?void 0:0,role:v?void 0:"group","aria-label":v?void 0:B,"data-nav-id":v?void 0:`turn-${String(F)}`,className:$("rounded-[8px] transition-[background-color,box-shadow]",y?"bg-amber-300/[0.018] shadow-[0_0_0_1px_rgba(252,211,77,0.035)]":"",!v&&"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),children:v?r.jsxs("div",{"data-nav-id":`turn-collapsed-${String(F)}`,"data-nav-action":"expand",role:"button",tabIndex:0,className:"flex items-stretch cursor-pointer focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none rounded-lg",onClick:k,onKeyDown:W=>{(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),k())},children:[r.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-1.5 pb-1.5",children:[r.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),r.jsx(J,{className:$("size-3.5",y?"animate-crab-crawl text-amber-300/80":"animate-crab-appear text-emerald-400",y?"drop-shadow-[0_0_4px_rgba(252,211,77,0.42)]":"drop-shadow-[0_0_4px_rgba(52,211,153,0.45)]")}),r.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:r.jsx("div",{className:"w-px bg-muted-foreground/14 h-full"})}),g?r.jsx(J,{className:$("size-3.5 animate-crab-settle text-amber-400","drop-shadow-[0_0_4px_rgba(251,191,36,0.45)]")}):r.jsx("span",{title:"Current end of open turn","aria-label":"Current end of open turn",children:r.jsx(J,{className:$("size-3.5 text-cyan-300/85",y?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})})]}),t.length>1&&r.jsxs("div",{className:$("flex-1 min-w-0 mb-0.5 rounded-[8px] py-1.5 px-3 flex items-center gap-3 text-xs","bg-card/80 transition-colors hover:bg-card",C),children:[r.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:B}),r.jsxs("span",{className:"text-blue-300/85 font-mono font-semibold tabular-nums shrink-0",title:`Log IDs ${String(t[0]?.log.id??"?")} ~ ${String(t[m]?.log.id??"?")}`,children:["#",t[0]?.sessionLogNumber??"?"," ~ #",t[m]?.sessionLogNumber??"?"]}),r.jsxs("span",{className:"text-muted-foreground shrink-0",children:[t.length," request",t.length>1?"s":""]}),_.maxElapsed!==null&&r.jsx(Ds,{children:r.jsxs(pt,{children:[r.jsx(mt,{asChild:!0,children:r.jsxs("span",{className:$("flex items-center gap-1 shrink-0",I?"text-amber-400":"text-muted-foreground"),children:[r.jsx(rn,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:ea(_.maxElapsed)}),I&&r.jsx(wn,{className:"size-3","aria-label":"Slow response"})]})}),r.jsx(ht,{children:I?`Slow response: ${ea(_.maxElapsed)} exceeds ${ea(o*1e3)}`:"Slowest request in this turn"})]})}),_.hasTokens&&r.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[r.jsx(rr,{className:"size-3 text-muted-foreground"}),r.jsxs("span",{className:"font-mono tabular-nums",children:[r.jsxs("span",{className:"text-blue-400",children:["IN ",Me(_.totalInput)]})," / ",r.jsxs("span",{className:"text-amber-400",children:["OUT ",Me(_.totalOutput)]})]})]}),r.jsx("span",{className:"flex-1 min-w-0"}),r.jsx("span",{className:"bg-white/[0.045] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-slate-200","aria-hidden":"true",children:r.jsx(yt,{className:"size-4 shrink-0"})})]})]}):t.map((W,V)=>{const{log:z,stopReason:X}=W,Y=V===0;return r.jsxs("div",{className:"flex items-stretch",children:[r.jsx(iE,{stopReason:X,isPending:z.responseStatus===null,isFirst:V===0,isTurnStart:Y,isOnlyEntry:b,isOpenTurnTail:V===m&&!g,crabIndex:z.id%12,collapsible:w&&Y,onToggle:k}),r.jsx("div",{className:$("flex-1 min-w-0 mb-0.5 rounded-[8px]",C),children:r.jsx(rE,{log:z,displayNumber:W.sessionLogNumber,viewMode:n,strip:s,slowResponseThresholdSeconds:o,timeDisplayFormat:d,cacheTrend:i?.get(z.id)??null,showClientMetadata:p,toolEvents:A.get(z.id),onCompareWithPrevious:l.has(z.id)?a:void 0})})]},z.id)})})}),mE=24,hE=132,gE=8;function xE(e){return e>mE}function bE(e){const t=new Map;for(let n=0;n<e.length;n++){const s=e[n];if(s!==void 0)for(const o of s.entries)t.set(o.log.id,n)}return t}function w0(e,t,n){return r.jsx(pE,{entries:e.entries,viewMode:t.viewMode,strip:t.strip,slowResponseThresholdSeconds:t.slowResponseThresholdSeconds,timeDisplayFormat:t.timeDisplayFormat,cacheTrends:t.cacheTrends,onCompareWithPrevious:t.onCompareWithPrevious,comparisonPredecessors:t.comparisonPredecessors,turnIndex:e.turnIndex,pendingFocusRequest:n,showLogClientMetadata:t.showLogClientMetadata},e.turnIndex)}function vE(e){return xE(e.turnGroups.length)?r.jsx(yE,{...e}):r.jsx(r.Fragment,{children:e.turnGroups.map(t=>w0(t,e))})}function yE(e){const{turnGroups:t}=e,[n,s]=c.useState(null),o=NT({count:t.length,estimateSize:()=>hE,overscan:gE,getItemKey:a=>t[a]?.turnIndex??a}),i=c.useMemo(()=>bE(t),[t]);return c.useEffect(()=>{const a=l=>{const u=wi(l);if(u===null||u.source==="virtualizer")return;const d=i.get(u.logId);d!==void 0&&(o.scrollToIndex(d,{align:"center"}),s(f=>({...u,turnIndex:d,nonce:f===null?1:f.nonce+1})))};return window.addEventListener(un,a),()=>{window.removeEventListener(un,a)}},[i,o]),r.jsx("div",{className:"relative w-full",style:{height:`${o.getTotalSize()}px`},"data-virtualized-turn-list":"true",children:o.getVirtualItems().map(a=>{const l=t[a.index];if(l===void 0)return null;const u=n!==null&&n.turnIndex===a.index?n:void 0;return r.jsx("div",{"data-index":a.index,ref:o.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${a.start}px)`},children:w0(l,e,u)},a.key)})})}const xc=pe(["episode","procedure","preference","project-fact"]),wE=pe(["draft","promoted","failed"]),j0=T({source:ae("agent-inspector"),sessionId:x(),logIds:H(R().int().positive()),project:x().nullable(),models:H(x())}),jE=T({redacted:Te(),patterns:H(x())}),kr=T({id:x(),type:xc,title:x(),content:x(),tags:H(x()),source:ae("agent-inspector"),sessionId:x(),logIds:H(R().int().positive()),evidence:j0,status:wE,createdAt:x(),updatedAt:x(),openClawMemoryId:x().nullable(),error:x().nullable(),redaction:jE});T({idempotencyKey:x(),type:xc,title:x(),content:x(),tags:H(x()),source:ae("agent-inspector"),project:x().nullable(),evidence:j0});const kE=T({id:x(),type:xc.or(x()),title:x(),content:x(),score:R().nullable(),source:x().nullable(),project:x().nullable(),evidence:Fn().optional()});T({results:H(kE),warning:x().nullable()});const SE=T({candidates:H(kr)}),_E=T({candidate:kr}),NE=T({error:x().optional(),candidate:kr.optional()}),CE=T({candidate:kr}),TE=3e4,EE=15e3,RE=15e3,PE={draft:"border-amber-500/30 bg-amber-500/10 text-amber-500",promoted:"border-emerald-500/30 bg-emerald-500/10 text-emerald-500",failed:"border-destructive/30 bg-destructive/10 text-destructive"};function el(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function ME(e,t,n){return e===null||t===null?null:Jo(e,t,n)}function IE(e){return`${String(e)} candidate${e===1?"":"s"}`}function k0(e){return`log-${String(e)}`}function S0(e){const t=k0(e),n=document.getElementById(t);window.history.replaceState(null,"",`#${t}`),n instanceof HTMLElement&&(n.scrollIntoView({block:"center",behavior:"smooth"}),n.focus({preventScroll:!0}))}function AE(e){for(const t of e)if(t.responseStatus!==null&&t.responseStatus>=400)return t;return null}function OE(e){let t=null,n=-1;for(const s of e)s.elapsedMs!==null&&s.elapsedMs>n&&(t=s,n=s.elapsedMs);return t}function zE(e){for(const t of e)if(gc(t).length>0)return t;return null}function LE(e){const t=new Map;for(let n=0;n<e.length;n+=1){const s=e[n];s!==void 0&&t.set(s.id,n+1)}return t}function ws(e,t){return String(t.get(e)??e)}function $E(e){const t=[{kind:"session",title:`${String(e.summary.llmCallCount)} LLM call${e.summary.llmCallCount===1?"":"s"}`,detail:`Scope ${e.scopeId}`,logId:e.logs[0]?.id??null}],n=zE(e.logs);e.summary.toolCallCount>0&&n!==null&&t.push({kind:"tool",title:`${String(e.summary.toolCallCount)} tool call${e.summary.toolCallCount===1?"":"s"}`,detail:`First tool evidence at #${ws(n.id,e.displayNumberByLogId)}`,logId:n.id});const s=AE(e.logs);s!==null&&t.push({kind:"failure",title:`Failure #${String(s.responseStatus)}`,detail:`First failed request is #${ws(s.id,e.displayNumberByLogId)}`,logId:s.id});const o=OE(e.logs);if(o!==null&&e.summary.maxElapsedMs!==null&&t.push({kind:"slow",title:`Slowest ${el(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${ws(o.id,e.displayNumberByLogId)}`,logId:o.id}),e.candidates.length>0){const i=e.candidates.filter(l=>l.status==="draft").length,a=e.candidates.filter(l=>l.status==="promoted").length;t.push({kind:"candidate",title:`${String(e.candidates.length)} memory candidate${e.candidates.length===1?"":"s"}`,detail:`${String(i)} draft / ${String(a)} promoted`,logId:e.candidates[0]?.logIds[0]??null})}return t}function DE(e){switch(e){case"session":return r.jsx(Go,{className:"size-3.5 text-blue-400"});case"tool":return r.jsx(hr,{className:"size-3.5 text-sky-400/70"});case"slow":return r.jsx(rn,{className:"size-3.5 text-amber-400"});case"failure":return r.jsx(up,{className:"size-3.5 text-destructive"});case"candidate":return r.jsx(cp,{className:"size-3.5 text-emerald-400"})}}function FE({insights:e}){return e.length===0?null:r.jsx("div",{className:"mt-2 grid gap-1.5 border-t border-border/70 pt-2 md:grid-cols-2 xl:grid-cols-3",children:e.map(t=>r.jsxs("button",{type:"button",className:$("flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs","text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),onClick:()=>{t.logId!==null&&S0(t.logId)},disabled:t.logId===null,children:[DE(t.kind),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block truncate font-medium text-foreground/90",children:t.title}),r.jsx("span",{className:"block truncate font-mono text-[10px]",children:t.detail})]})]},`${t.kind}-${t.title}`))})}function UE(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function BE(e,t){if(t)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function VE(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function qE(e,t){const n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,t-3)}...`}function HE(e,t){const n=e[0],s=e[e.length-1];if(n===void 0)return"No evidence logs";const o=ws(n,t);return s===void 0||n===s?`#${o}`:`#${o}-#${ws(s,t)}`}function Ju(e){return e.join(", ")}function WE(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function ZE({candidate:e,isPromoting:t,isUpdating:n,onPromoteCandidate:s,onUpdateCandidate:o,displayNumberByLogId:i}){const[a,l]=c.useState(!1),[u,d]=c.useState(e.type),[f,p]=c.useState(e.title),[m,h]=c.useState(e.content),[g,y]=c.useState(Ju(e.tags)),[b,w]=c.useState(null),v=e.status!=="promoted",j=e.status!=="promoted",S=c.useCallback(()=>{d(e.type),p(e.title),h(e.content),y(Ju(e.tags)),w(null)},[e.content,e.tags,e.title,e.type]),k=c.useCallback(async()=>{const _=f.trim(),C=m.trim(),I=WE(g);if(_.length===0){w("Title is required.");return}if(C.length===0){w("Content is required.");return}if(I.length===0){w("At least one tag is required.");return}w(null),await o(e.id,{type:u,title:_,content:C,tags:I})&&l(!1)},[e.id,m,g,f,u,o]);return a?r.jsx("div",{className:"border border-border bg-card shadow-sm rounded-[8px] px-2.5 py-2",children:r.jsxs("div",{className:"grid gap-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs("select",{value:u,disabled:n,onChange:_=>{const C=kr.shape.type.safeParse(_.currentTarget.value);C.success&&d(C.data)},className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 rounded-md px-2 text-xs","aria-label":"Candidate type",children:[r.jsx("option",{value:"episode",children:"episode"}),r.jsx("option",{value:"procedure",children:"procedure"}),r.jsx("option",{value:"preference",children:"preference"}),r.jsx("option",{value:"project-fact",children:"project-fact"})]}),r.jsx("input",{value:f,disabled:n,onChange:_=>p(_.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 min-w-[220px] flex-1 rounded-md px-2 text-xs","aria-label":"Candidate title"})]}),r.jsx("textarea",{value:m,disabled:n,onChange:_=>h(_.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground min-h-28 rounded-md px-2 py-1.5 font-mono text-[11px] leading-relaxed","aria-label":"Candidate content"}),r.jsx("input",{value:g,disabled:n,onChange:_=>y(_.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 rounded-md px-2 text-xs","aria-label":"Candidate tags"}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground",children:[r.jsx(ou,{className:"size-3"}),"Saving reruns Inspector redaction before promotion."]}),r.jsx("span",{className:"flex-1"}),b!==null&&r.jsx("span",{className:"text-[10px] text-destructive",children:b}),r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{S(),l(!1)},children:[r.jsx(gr,{className:"size-3.5"}),"Cancel"]}),r.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{k()},children:[n?r.jsx(Vt,{className:"size-3.5 animate-spin"}):r.jsx($j,{className:"size-3.5"}),"Save"]})]})]})}):r.jsxs("div",{className:"rounded-md border border-border/80 bg-background/60 px-2.5 py-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(_e,{variant:"outline",className:"h-5 px-1.5 text-[10px] font-mono",children:e.type}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",title:e.title,children:e.title}),r.jsx(_e,{variant:"outline",className:$("h-5 shrink-0 px-1.5 text-[10px] font-mono",PE[e.status]),children:UE(e.status)})]}),r.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:qE(e.content,360)}),r.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground",children:[r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(Vw,{className:"size-3"}),HE(e.logIds,i)]}),r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(ou,{className:"size-3"}),VE(e)]}),e.status==="promoted"&&r.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[r.jsx(Sa,{className:"size-3"}),e.openClawMemoryId??"OpenClaw"]}),e.status==="failed"&&e.error!==null&&r.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[r.jsx(up,{className:"size-3"}),e.error]})]}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.logIds.map(_=>{const C=ws(_,i);return r.jsxs("a",{href:`#${k0(_)}`,onClick:I=>{I.preventDefault(),S0(_)},className:"rounded border border-blue-400/25 px-1.5 py-0.5 font-mono text-[10px] text-blue-400 underline-offset-2 transition-colors hover:bg-blue-400/10 hover:text-blue-300 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":`Jump to evidence log ${C}`,title:`Log ID ${String(_)}`,children:["#",C]},_)}),r.jsx("span",{className:"flex-1"}),j&&r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",disabled:n||t,onClick:()=>l(!0),children:[r.jsx(xp,{className:"size-3"}),"Review"]}),r.jsxs(ee,{type:"button",variant:v?"outline":"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",onClick:()=>s(e.id),disabled:!v||t||n,children:[t?r.jsx(Vt,{className:"size-3 animate-spin"}):v?r.jsx(Sw,{className:"size-3"}):r.jsx(Sa,{className:"size-3"}),BE(e,t)]})]})]})}function KE({candidates:e,promotingCandidateIds:t,updatingCandidateIds:n,onPromoteCandidate:s,onUpdateCandidate:o,displayNumberByLogId:i}){return e.length===0?null:r.jsx("div",{className:"mt-2 grid gap-1.5",children:e.map(a=>r.jsx(ZE,{candidate:a,isPromoting:t.has(a.id),isUpdating:n.has(a.id),onPromoteCandidate:s,onUpdateCandidate:o,displayNumberByLogId:i},a.id))})}function GE({logs:e,scopeId:t,slowResponseThresholdSeconds:n,showRollupMetrics:s,timeDisplayFormat:o}){const[i,a]=c.useState([]),[l,u]=c.useState(!0),[d,f]=c.useState({status:"idle",error:null}),[p,m]=c.useState(()=>new Set),[h,g]=c.useState(()=>new Set),y=i.length>0,b=c.useMemo(()=>fE(e,n,i.length),[i.length,e,n]),w=c.useMemo(()=>LE(e),[e]),v=c.useMemo(()=>$E({logs:e,scopeId:t,summary:b,candidates:i,displayNumberByLogId:w}),[i,w,e,t,b]),j=s||b.maxElapsedMs!==null,S=c.useMemo(()=>ME(b.startedAt,b.endedAt,o),[b.endedAt,b.startedAt,o]),k=c.useCallback(()=>{e.length===0||d.status==="loading"||(f({status:"loading",error:null}),(async()=>{try{const I=await qe(`/api/knowledge/sessions/${encodeURIComponent(t)}/candidates`,SE,TE,{method:"POST"},A=>`Candidate generation failed with ${String(A.status)}`);a(I.candidates),u(I.candidates.length>0),f(I.candidates.length>0?{status:"ready",error:null}:{status:"failed",error:"No candidate was generated for this trace scope."})}catch(I){f({status:"failed",error:I instanceof Error?I.message:"Candidate response was invalid"})}})())},[d.status,e.length,t]),_=c.useCallback(I=>{m(A=>{if(A.has(I))return A;const P=new Set(A);return P.add(I),P}),(async()=>{try{const A=await Un(`/api/knowledge/candidates/${encodeURIComponent(I)}/promote`,EE,{method:"POST"}),P=await A.json().catch(()=>null),N=_E.safeParse(P);if(A.ok&&N.success){a(F=>F.map(B=>B.id===N.data.candidate.id?N.data.candidate:B)),f({status:"ready",error:null});return}const M=NE.safeParse(P);M.success&&M.data.candidate!==void 0&&a(F=>F.map(B=>B.id===M.data.candidate?.id?M.data.candidate:B)),f({status:"failed",error:M.success?M.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(A.status)}`})}catch(A){f({status:"failed",error:A instanceof Error?A.message:"Candidate promotion failed"})}finally{m(A=>{const P=new Set(A);return P.delete(I),P})}})()},[]),C=c.useCallback(async(I,A)=>{g(P=>{if(P.has(I))return P;const N=new Set(P);return N.add(I),N});try{const P=await qe(`/api/knowledge/candidates/${encodeURIComponent(I)}`,CE,RE,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)},N=>`Candidate update failed with ${String(N.status)}`);return a(N=>N.map(M=>M.id===P.candidate.id?P.candidate:M)),f({status:"ready",error:null}),!0}catch(P){return f({status:"failed",error:P instanceof Error?P.message:"Candidate update failed"}),!1}finally{g(P=>{const N=new Set(P);return N.delete(I),N})}},[]);return e.length===0?null:r.jsxs("section",{className:"border border-border bg-card shadow-sm mb-2 rounded-[8px] px-3 py-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[s&&r.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold text-foreground",children:[r.jsx(Go,{className:"size-3.5 text-blue-400"}),b.llmCallCount," LLM"]}),r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[r.jsx(hr,{className:"size-3.5 text-sky-400/70"}),b.toolCallCount," tools"]}),s&&r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[r.jsx(rr,{className:"size-3.5 text-emerald-400"}),r.jsxs("span",{className:"font-mono",children:[Me(b.totalInputTokens)," / ",Me(b.totalOutputTokens)]})]}),(b.totalCacheCreationInputTokens>0||b.totalCacheReadInputTokens>0)&&r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[r.jsx(rr,{className:"size-3.5 text-purple-400"}),r.jsxs("span",{className:"font-mono",children:["KV Cache +",Me(b.totalCacheCreationInputTokens)," / ~",Me(b.totalCacheReadInputTokens)]})]}),j&&r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[r.jsx(rn,{className:"size-3.5"}),s&&r.jsx("span",{className:"font-mono",children:el(b.totalElapsedMs)}),b.maxElapsedMs!==null&&r.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",el(b.maxElapsedMs)]})]}),s&&S!==null&&r.jsx("span",{className:"font-mono text-muted-foreground/70",children:S}),(b.failedCallCount>0||b.pendingCallCount>0||b.slowCallCount>0)&&r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-amber-400",children:[r.jsx(wn,{className:"size-3.5"}),r.jsxs("span",{className:"font-mono",children:[b.failedCallCount," fail / ",b.pendingCallCount," pending /"," ",b.slowCallCount," slow"]})]}),r.jsx("span",{className:"flex-1"}),y&&r.jsx(_e,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:IE(b.knowledgeCandidateCount)}),r.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:k,disabled:d.status==="loading",children:[d.status==="loading"?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(cp,{className:"size-3.5"}),"Candidate"]}),y&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onClick:()=>u(I=>!I),"aria-expanded":l,"aria-label":l?"Collapse memory candidates":"Expand memory candidates",children:l?r.jsx(nt,{className:"size-3.5"}):r.jsx(yt,{className:"size-3.5"})})]}),d.status==="failed"&&r.jsx("p",{className:"mt-2 text-xs text-destructive",children:d.error}),r.jsx(FE,{insights:v}),l&&r.jsx(KE,{candidates:i,promotingCandidateIds:p,updatingCandidateIds:h,onPromoteCandidate:_,onUpdateCandidate:C,displayNumberByLogId:w})]})}function JE(e){let t=0,n=0;for(const s of e)s.inputTokens!==null&&(t+=s.inputTokens),s.outputTokens!==null&&(n+=s.outputTokens);return{totalInputTokens:t,totalOutputTokens:n}}function YE(e){const t=new Map;for(const n of e){if(n.model===null)continue;const s=qC(n.model);if(s==="unknown")continue;let o=t.get(s);o===void 0&&(o=new Set,t.set(s,o)),o.add(n.model)}return[...t.entries()].map(([n,s])=>({provider:n,models:[...s]}))}function XE(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function QE(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}const eR=c.memo(function({group:e,viewMode:t="simple",strip:n,slowResponseThresholdSeconds:s,cacheTrends:o,onCompareWithPrevious:i,comparisonPredecessors:a,onClearGroup:l,showClientIdentity:u=!0,showProcessMetadata:d=!0,showLogClientMetadata:f=!0,defaultExpanded:p=!1,timeDisplayFormat:m,expanded:h,onExpandedChange:g}){const[y,b]=c.useState(p),w=h??y,v=c.useCallback(N=>{if(g!==void 0){g(N);return}b(N)},[g]);c.useEffect(()=>{!p||h!==void 0||b(!0)},[h,p]);const j=c.useMemo(()=>JE(e.logs),[e.logs]),S=c.useMemo(()=>YE(e.logs),[e.logs]),k=e.logs[0]?.timestamp??new Date().toISOString(),_=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),C=e.logs.some(N=>N.responseStatus===null),I=c.useMemo(()=>XE(e.logs),[e.logs]),A=c.useMemo(()=>QE(e.logs),[e.logs]),P=c.useMemo(()=>Qa(e.logs),[e.logs]);return c.useEffect(()=>{const N=M=>{const F=wi(M);F!==null&&e.logs.some(B=>B.id===F.logId)&&v(!0)};return window.addEventListener(un,N),()=>{window.removeEventListener(un,N)}},[e.logs,v]),r.jsxs("div",{className:"mb-1.5",children:[r.jsx(iT,{conversationId:e.conversationId,startTime:k,endTime:_,totalCalls:e.logs.length,totalInputTokens:j.totalInputTokens,totalOutputTokens:j.totalOutputTokens,expanded:w,onToggle:()=>v(!w),providers:S,isLoading:C,userAgent:e.logs[0]?.userAgent??null,clientPid:I,clientProjectFolder:A,showClientIdentity:u,showProcessMetadata:d,timeDisplayFormat:m,onClear:()=>l(e.logs.map(N=>N.id))}),w&&r.jsxs("div",{children:[r.jsx(GE,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:s,showRollupMetrics:!1,timeDisplayFormat:m}),r.jsx(vE,{turnGroups:P,viewMode:t,strip:n,slowResponseThresholdSeconds:s,timeDisplayFormat:m,cacheTrends:o,onCompareWithPrevious:i,comparisonPredecessors:a,showLogClientMetadata:f})]})]})}),tR="flex w-full min-w-0 items-center gap-2 rounded-md border border-border/70 bg-muted/35 px-3 py-2 sm:w-auto sm:max-w-full",nR="m-0 min-w-0 flex-1 overflow-x-auto font-mono text-xs text-foreground sm:text-sm";function sR(e){return e==="full"}function rR(e){return e==="raw"}function oR(e,t){const n=t>0;return{redacted:n,raw:n&&sR(e)}}function iR(e,t){const n=e[0],s=e[e.length-1];return n===void 0||s===void 0?null:Jo(n.timestamp,s.timestamp,t)}function aR(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function lR(e){const t=new Set;for(const s of e)s.model!==null&&s.model.length>0&&t.add(s.model);const n=[...t].sort();return n.length===0?"Model unknown":n.length===1?n[0]??"Model unknown":`${n.length} models`}function cR(e){const t=new Set;for(const s of e)s.providerName!==null&&s.providerName!==void 0&&s.providerName.length>0&&t.add(s.providerName);const n=[...t].sort();return n.length===0?"Provider unknown":n.length===1?n[0]??"Provider unknown":`${n.length} providers`}function uR(e){if(e<1e3)return`${e}ms`;if(e<6e4){const o=e/1e3;return`${o<10?o.toFixed(1):o.toFixed(0)}s`}const t=Math.round(e/1e3),n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function dR(e,t){return`${Me(e)} in / ${Me(t)} out`}function fR(e,t){if(e.length===0)return 0;if(t.length===0)return Qa(e).length;let n=0;for(const s of t)n+=Qa(s.logs).length;return n}function pR({stopReason:e,pending:t,lastFailureLogNumber:n}){if(t>0)return{label:"In flight",detail:`${t} request${t===1?"":"s"} pending`,tone:"cool"};if(n!==null&&e===null)return{label:"Error",detail:`Last failed request #${n}`,tone:"danger"};switch(e){case"end_turn":return{label:"End turn",detail:"Assistant completed the turn",tone:"neutral"};case"stop":return{label:"Stop",detail:"Model reached a stop condition",tone:"neutral"};case"length":return{label:"Output limit",detail:"Turn ended at max output tokens",tone:"watch"};case"tool_use":return{label:"Tool call",detail:"Assistant requested a tool",tone:"cool"};case null:return{label:"Unknown",detail:"No finish reason captured",tone:"neutral"}}}function mR(e){if(e===null)return!1;const t=e.toLowerCase();return t.includes("abort")||t.includes("cancel")||t.includes("client disconnected")||t.includes("stream disconnected")||t.includes("connection closed")}function hR({pending:e,failures:t,lengthStops:n,stopReason:s,lastFailure:o}){if(o!==null&&(o.status===499||mR(o.error)))return{label:"Client aborted",detail:`Request #${o.logNumber} ended before completion`,tone:"watch"};if(e>0)return{label:"In flight",detail:`${e} request${e===1?"":"s"} still running`,tone:"cool"};if(o!==null&&o.status!==null&&o.status>=500)return{label:"Provider error",detail:`Request #${o.logNumber} returned HTTP ${o.status}`,tone:"danger"};if(t>0&&o!==null)return{label:"Failed",detail:`Request #${o.logNumber} needs attention`,tone:"danger"};if(n>0||s==="length")return{label:"Output limited",detail:"Model stopped at the output token limit",tone:"watch"};switch(s){case"end_turn":case"stop":return{label:"Completed",detail:"Assistant completed normally",tone:"neutral"};case"tool_use":return{label:"Tool requested",detail:"Assistant handed off to a tool",tone:"cool"};case null:return{label:"Unknown",detail:"No terminal signal captured",tone:"neutral"}}}function gR({logs:e,conversationGroups:t,isLoading:n,timeDisplayFormat:s,slowResponseThresholdSeconds:o}){let i=0,a=0,l=0,u=0,d=0,f=0,p=null,m=null,h=null,g=null,y=null,b=0,w=0,v=0,j=null;const S=o*1e3;for(let A=0;A<e.length;A+=1){const P=e[A];if(P===void 0)continue;const N=A+1,M=l0(P);M!==null&&(p=M),M==="length"&&(u+=1),aR(P)&&(i+=1,m=N,h={logNumber:N,status:P.responseStatus,error:P.error??null}),P.responseStatus===null&&(a+=1),o>0&&P.elapsedMs!==null&&P.elapsedMs>=S&&(l+=1),P.inputTokens!==null&&(d+=P.inputTokens),P.outputTokens!==null&&(f+=P.outputTokens),P.elapsedMs!==null&&(g===null||P.elapsedMs>g)&&(g=P.elapsedMs,y=N);const F=P.inputTokens??0,B=P.outputTokens??0,J=F+B;J>b&&(b=J,w=F,v=B,j=N)}const k=n||a>0&&i===0?"rolling":i>0?"failed":l>0||u>0?"watch":"clear",_=k==="rolling"?"Rolling":k==="failed"?"Failure":k==="watch"?"Watch":"Clear",C=pR({stopReason:p,pending:a,lastFailureLogNumber:m}),I=hR({pending:a,failures:i,lengthStops:u,stopReason:p,lastFailure:h});return{status:k,statusLabel:_,modelLabel:lR(e),providerLabel:cR(e),requests:e.length,turns:fR(e,t),failures:i,pending:a,slow:l,lengthStops:u,timeRange:iR(e,s),tokenLabel:`${Me(d)} in / ${Me(f)} out`,finishLabel:C.label,finishDetail:C.detail,finishTone:C.tone,outcomeLabel:I.label,outcomeDetail:I.detail,outcomeTone:I.tone,slowestLabel:g===null?"n/a":uR(g),slowestDetail:y===null?"Latency pending":`Request #${y}`,heaviestDetail:j===null?"Tokens pending":`#${j} ${dR(w,v)}`}}function xR({pinnedSessionId:e,selectedSession:t,sessions:n,logs:s}){if(e!==void 0){const a=s.filter(l=>l.sessionId===e);return a.length===0?null:{label:e,logs:a,showBackLink:!0}}if(t!=="__all__"){const a=s.filter(l=>l.sessionId===t);return a.length===0?null:{label:t,logs:a,showBackLink:!0}}const o=n.length===1?n[0]??null:null;return o!==null&&s.every(l=>l.sessionId===o)?{label:o,logs:[...s],showBackLink:!1}:n.length===0&&s.length>0&&s.every(a=>a.sessionId===null)?{label:"Visible requests",logs:[...s],showBackLink:!1}:null}function bR({logs:e,pagination:t}){if(t.isLoading&&e.length===0)return"Loading logs...";if(e.length===0)return"No logs on this page";const n=e[0],s=e[e.length-1],o=n===void 0||s===void 0?"Current page":`#${n.id}-#${s.id}`;return t.total===null?`Showing ${e.length} logs (${o})`:t.total<=e.length?`Showing all ${t.total} logs`:`Showing ${e.length} of ${t.total} logs (${o})`}function Zn({...e}){return r.jsx(Ym,{"data-slot":"select",...e})}function Is({...e}){return r.jsx(th,{"data-slot":"select-value",...e})}function Kn({className:e,size:t="default",children:n,...s}){return r.jsxs(Qm,{"data-slot":"select-trigger","data-size":t,className:$("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...s,children:[n,r.jsx(nh,{asChild:!0,children:r.jsx(nt,{className:"size-4 opacity-50"})})]})}function Gn({className:e,children:t,position:n="popper",align:s="center",...o}){return r.jsx(rh,{children:r.jsxs(oh,{"data-slot":"select-content",className:$("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,align:s,...o,children:[r.jsx(vR,{}),r.jsx(uh,{className:$("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),r.jsx(yR,{})]})})}function Qe({className:e,children:t,...n}){return r.jsxs(mh,{"data-slot":"select-item",className:$("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[r.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:r.jsx(xh,{children:r.jsx(Ge,{className:"size-4"})})}),r.jsx(hh,{children:t})]})}function vR({className:e,...t}){return r.jsx(bh,{"data-slot":"select-scroll-up-button",className:$("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Ml,{className:"size-4"})})}function yR({className:e,...t}){return r.jsx(vh,{"data-slot":"select-scroll-down-button",className:$("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(nt,{className:"size-4"})})}const wR=pe(["critical","warning","notice"]),jR=pe(["open"]),kR=pe(["proxy","tool-schema","run","group"]),_0=pe(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),SR=pe(["log","session","run","group"]),_R=pe(["anthropic","openai","unknown"]),NR=T({kind:SR,id:x(),label:x(),href:x().nullable()}),CR=T({id:x(),fingerprint:x(),severity:wR,category:_0,source:kR,status:jR,title:x(),message:x(),count:R().int().positive(),firstSeenAt:x(),lastSeenAt:x(),logIds:H(R().int().positive()),sessionIds:H(x()),runIds:H(x()),groupIds:H(x()),provider:x().nullable(),model:x().nullable(),apiFormat:_R.nullable(),evidence:H(NR),metadata:We(x(),tt)}),TR=T({category:_0,count:R().int().nonnegative()}),N0=T({total:R().int().nonnegative(),open:R().int().nonnegative(),critical:R().int().nonnegative(),warning:R().int().nonnegative(),notice:R().int().nonnegative(),byCategory:H(TR)}),ER=T({alerts:H(CR),total:R().int().nonnegative(),limit:R().int().positive(),summary:N0}),RR=8e3,PR=1e4;function MR(e){const t=new URLSearchParams;e.severity!==void 0&&t.set("severity",e.severity),e.category!==void 0&&t.set("category",e.category),e.source!==void 0&&t.set("source",e.source),e.limit!==void 0&&t.set("limit",String(e.limit));const n=t.toString();return n.length>0?`/api/alerts?${n}`:"/api/alerts"}function IR(e,t){const n=Bt(t?MR(e):null,s=>qe(s,ER,PR));return{alerts:n.data?.alerts??[],total:n.data?.total??0,summary:n.data?.summary??null,isLoading:n.isLoading,error:n.error,mutate:n.mutate}}function AR(){const e=Bt("/api/alerts/summary",t=>qe(t,N0,RR),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const ji="relative size-8 rounded-md border-0 bg-white/[0.035] text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:bg-white/[0.065] hover:text-accent-foreground focus-visible:ring-ring/50",OR=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function C0(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function zR(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function bc(e){switch(e){case"request-failure":return"Request failure";case"request-timeout":return"Timeout";case"slow-response":return"Slow response";case"tool-schema":return"Tool calling";case"run-failure":return"Run failure";case"group-failure":return"Group failure";case"group-incomplete":return"Group incomplete"}}function LR(e){switch(e){case"critical":return"border-red-400/40 bg-red-500/12 text-red-100";case"warning":return"border-amber-300/35 bg-amber-400/12 text-amber-100";case"notice":return"border-sky-300/35 bg-sky-400/12 text-sky-100"}}function $R(e){switch(e){case"critical":return"bg-red-400";case"warning":return"bg-amber-300";case"notice":return"bg-sky-300"}}function DR(e){switch(e){case"critical":return"text-red-200";case"warning":return"text-amber-100";case"notice":return"text-sky-100"}}function FR(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return r.jsx(Gj,{className:"size-3.5"});case"request-timeout":case"slow-response":return r.jsx(ww,{className:"size-3.5"});case"tool-schema":return r.jsx(wn,{className:"size-3.5"});case"group-incomplete":return r.jsx(qy,{className:"size-3.5"})}}function tl(e){const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):e}function bt(e){return e.toLocaleString()}function T0(e){return e.provider!==null&&e.model!==null?`${e.provider} / ${e.model}`:e.provider!==null?e.provider:e.model!==null?e.model:"Unknown target"}function UR(e,t){const n={limit:100};return e!=="all"&&(n.severity=e),t!=="all"&&(n.category=t),n}function BR(e,t){if(t!==null){const n=e.find(s=>s.id===t);if(n!==void 0)return n}return e[0]??null}function Br({label:e,count:t,tone:n}){const s=n==="critical"?"border-red-400/30 bg-red-500/10 text-red-100":n==="warning"?"border-amber-300/30 bg-amber-400/10 text-amber-100":n==="notice"?"border-sky-300/30 bg-sky-400/10 text-sky-100":"border-border bg-muted/40 text-foreground";return r.jsxs("div",{className:$("rounded-md border px-3 py-2",s),children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase opacity-75",children:e}),r.jsx("div",{className:"mt-1 text-lg font-semibold leading-none",children:bt(t)})]})}function Vr({value:e,active:t,label:n,count:s,onClick:o}){return r.jsxs(ee,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>o(e),className:"h-7 px-2",children:[n,s!==null?r.jsx(_e,{variant:"outline",children:bt(s)}):null]})}function VR({category:e,active:t,count:n,onClick:s}){return r.jsxs(ee,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>s(e),className:"h-7 px-2",children:[FR(e),bc(e),r.jsx(_e,{variant:"outline",children:bt(n)})]})}function qR({alerts:e,selectedAlertId:t,isLoading:n,error:s,onSelect:o}){return n?r.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:[r.jsx(Ue,{className:"mr-2 size-3.5 animate-spin"}),"Loading alerts..."]}):s!==void 0?r.jsx("div",{className:"rounded-md border border-red-300/30 bg-red-500/10 px-3 py-2 text-xs text-red-100",children:s.message}):e.length===0?r.jsx("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground",children:"No alerts match the current filters."}):r.jsx("div",{className:"min-h-0 space-y-2 overflow-y-auto pr-1",children:e.map(i=>{const a=i.id===t;return r.jsxs("button",{type:"button",onClick:()=>o(i.id),className:$("w-full rounded-md border px-3 py-3 text-left transition-colors",a?"border-primary/60 bg-primary/12":"border-border bg-background/70 hover:border-primary/30 hover:bg-muted/60"),children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:$("size-2 rounded-full",$R(i.severity))}),r.jsx("span",{className:$("text-xs font-semibold",DR(i.severity)),children:C0(i.severity)}),r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:bc(i.category)})]}),r.jsx("div",{className:"mt-1 text-sm font-semibold leading-snug",children:i.title}),r.jsx("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:i.message})]}),i.count>1?r.jsxs(_e,{variant:"outline",className:"shrink-0",children:["x",bt(i.count)]}):null]}),r.jsxs("div",{className:"mt-2 flex min-w-0 items-start justify-between gap-2 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"min-w-0 leading-snug",children:T0(i)}),r.jsx("span",{className:"shrink-0",children:tl(i.lastSeenAt)})]})]},i.id)})})}function HR({alert:e,onNavigate:t}){return e.evidence.length===0?r.jsx("span",{className:"text-xs text-muted-foreground",children:"No linked evidence"}):r.jsx("div",{className:"flex flex-wrap gap-2",children:e.evidence.map(n=>n.href===null?r.jsx(_e,{variant:"outline",children:n.label},`${n.kind}:${n.id}`):r.jsx(_e,{variant:"outline",asChild:!0,children:r.jsx("a",{href:n.href,onClick:t,children:n.label})},`${n.kind}:${n.id}`))})}function WR({alert:e,onNavigate:t}){return e===null?r.jsx("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground",children:"Select an alert to inspect its evidence."}):r.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-border bg-background/70",children:[r.jsx("div",{className:$("border-b px-4 py-3",LR(e.severity)),children:r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx(_e,{variant:"outline",children:C0(e.severity)}),r.jsx(_e,{variant:"outline",children:zR(e.source)}),r.jsx(_e,{variant:"outline",children:bc(e.category)})]}),r.jsx("h3",{className:"mt-3 text-base font-semibold",children:e.title}),r.jsx("p",{className:"mt-1 text-sm opacity-85",children:e.message})]}),e.count>1?r.jsxs(_e,{variant:"outline",className:"shrink-0",children:[bt(e.count)," hits"]}):null]})}),r.jsxs("div",{className:"space-y-4 p-4",children:[r.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[r.jsx(fn,{label:"Target",value:T0(e)}),r.jsx(fn,{label:"Last seen",value:tl(e.lastSeenAt)}),r.jsx(fn,{label:"First seen",value:tl(e.firstSeenAt)}),r.jsx(fn,{label:"Protocol",value:e.apiFormat??"n/a"})]}),r.jsxs("div",{children:[r.jsx("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Evidence"}),r.jsx(HR,{alert:e,onNavigate:t})]}),r.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[r.jsx(fn,{label:"Logs",value:e.logIds.length===0?"n/a":bt(e.logIds.length)}),r.jsx(fn,{label:"Sessions",value:e.sessionIds.length===0?"n/a":bt(e.sessionIds.length)}),r.jsx(fn,{label:"Runs",value:e.runIds.length===0?"n/a":bt(e.runIds.length)}),r.jsx(fn,{label:"Groups",value:e.groupIds.length===0?"n/a":bt(e.groupIds.length)})]})]})]})}function fn({label:e,value:t}){return r.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2",children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground",children:e}),r.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-foreground",children:t})]})}function ZR(){const[e,t]=c.useState(!1),[n,s]=c.useState("all"),[o,i]=c.useState("all"),[a,l]=c.useState(null),{summary:u,isLoading:d}=AR(),f=c.useMemo(()=>UR(n,o),[o,n]),{alerts:p,total:m,isLoading:h,error:g,mutate:y}=IR(f,e),b=c.useMemo(()=>BR(p,a),[p,a]);c.useEffect(()=>{!e||a!==null&&p.some(C=>C.id===a)||l(p[0]?.id??null)},[p,e,a]);const w=u?.total??0,v=u?.critical??0,j=u?.warning??0,S=u?.notice??0,k=v>0?"bg-red-600 text-white":j>0?"bg-amber-400 text-zinc-950":"bg-sky-400 text-zinc-950";return r.jsxs(Zt,{open:e,onOpenChange:t,children:[r.jsx(yr,{asChild:!0,children:r.jsxs(ee,{type:"button",variant:"ghost",size:"icon",className:ji,"aria-label":"Alerts",title:"Alerts",children:[r.jsx(_a,{className:"size-4"}),d?r.jsx(Ue,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):w>0?r.jsx("span",{className:$("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4",k),children:bt(w)}):null,r.jsx("span",{className:"sr-only",children:"Alerts"})]})}),r.jsxs(Kt,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[r.jsxs(Xt,{children:[r.jsxs(Qt,{className:"flex items-center gap-2 pr-8",children:[r.jsx(_a,{className:"size-5 text-red-300"}),r.jsx("span",{children:"Alerts"}),r.jsx(_e,{variant:"outline",children:bt(w)})]}),r.jsx(wr,{className:"sr-only",children:"Local alert board for captured Inspector evidence."})]}),r.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[r.jsx(Br,{label:"Open",count:u?.open??0,tone:"neutral"}),r.jsx(Br,{label:"Critical",count:v,tone:"critical"}),r.jsx(Br,{label:"Warning",count:j,tone:"warning"}),r.jsx(Br,{label:"Notice",count:S,tone:"notice"})]}),r.jsxs("div",{className:"flex min-h-0 flex-wrap items-center justify-between gap-2 border-y border-border py-3",children:[r.jsxs("div",{className:"flex flex-wrap gap-1",children:[r.jsx(Vr,{value:"all",active:n==="all",label:"All",count:u?.total??null,onClick:s}),r.jsx(Vr,{value:"critical",active:n==="critical",label:"Critical",count:v,onClick:s}),r.jsx(Vr,{value:"warning",active:n==="warning",label:"Warning",count:j,onClick:s}),r.jsx(Vr,{value:"notice",active:n==="notice",label:"Notice",count:S,onClick:s})]}),r.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{y()},children:[r.jsx(Vt,{className:"size-3.5"}),"Refresh"]})]}),r.jsxs("div",{className:"flex flex-wrap gap-1",children:[r.jsx(ee,{type:"button",variant:o==="all"?"secondary":"ghost",size:"sm","aria-pressed":o==="all",onClick:()=>i("all"),className:"h-7 px-2",children:"All categories"}),OR.map(_=>{const C=u?.byCategory.find(I=>I.category===_)?.count??0;return C===0?null:r.jsx(VR,{category:_,active:o===_,count:C,onClick:i},_)})]}),r.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[360px_minmax(0,1fr)]",children:[r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[r.jsxs("span",{children:[bt(m)," matched"]}),r.jsx("span",{children:p.length<m?`${bt(p.length)} shown`:"Latest"})]}),r.jsx(qR,{alerts:p,selectedAlertId:b?.id??null,isLoading:h,error:g,onSelect:l})]}),r.jsx(WR,{alert:b,onNavigate:()=>t(!1)})]})]})]})}const KR=12e3;function GR(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function JR(e){const t=Bt(GR(e),n=>qe(n,by,KR));return{evidenceResponse:t.data??null,isLoading:t.isLoading,error:t.error,mutate:t.mutate}}const YR=8e3;function XR(){const e=Bt("/api/groups",t=>qe(t,ip,YR));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const QR=3e3;function eP(e,t){return{id:(e?.id??0)+1,message:t.message,tone:t.tone??"error"}}function E0(){const[e,t]=c.useState(null),n=c.useCallback(o=>{t(i=>eP(i,o))},[]),s=c.useCallback(()=>{t(null)},[]);return c.useEffect(()=>{if(e===null)return;const o=window.setTimeout(()=>{t(null)},QR);return()=>{window.clearTimeout(o)}},[e]),{notice:e,showToast:n,dismissToast:s}}function R0({notice:e,onDismiss:t}){if(e===null)return null;const n=e.tone==="error",s=n?wn:Sa;return r.jsx("div",{"aria-atomic":"true","aria-live":"polite",className:"pointer-events-none fixed top-4 right-4 z-[100] w-[min(calc(100vw-2rem),26rem)]",role:"status",children:r.jsxs("div",{className:$("pointer-events-auto flex items-start gap-2 rounded-md border bg-popover/95 px-3 py-2 text-sm text-popover-foreground shadow-[0_18px_50px_color-mix(in_oklch,var(--foreground)_16%,transparent)] backdrop-blur",n?"border-status-danger/35":"border-status-success/35"),children:[r.jsx(s,{className:$("mt-0.5 size-4 shrink-0",n?"text-status-danger":"text-status-success")}),r.jsx("div",{className:"min-w-0 flex-1 break-words leading-5",children:e.message}),r.jsx("button",{type:"button",className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-current/70 transition-colors hover:bg-white/10 hover:text-current focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none","aria-label":"Dismiss notification",onClick:t,children:r.jsx(gr,{className:"size-3.5"})})]},e.id)})}const ta=2e4;function tP(e,t){const n=`/api/groups/${encodeURIComponent(e)}`;return t?`${n}?deleteEvidence=1`:n}function nP(e){return"/api/groups"}function P0(e){let t=0,n=0,s=0,o=0;for(const i of e.members)switch(i.status){case"completed":t+=1;break;case"failed":case"cancelled":n+=1;break;case"running":s+=1;break;case"created":break;case null:o+=1;break}return{memberCount:e.members.length,completedMembers:t,failedMembers:n,runningMembers:s,missingStatusMembers:o}}function sP(e,t,n=null){return t!==null&&t.group.id===e.id?t.members.map(s=>({member:s.member,exportMember:s,source:"export"})):n!==null&&n.group.id===e.id&&n.members!==null?n.members.map(s=>({member:s.member,exportMember:s,source:"evidence"})):e.members.map(s=>({member:s,exportMember:null,source:"group"}))}function vc(e){switch(e){case"completed":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"failed":case"cancelled":return"border-red-200 bg-red-50 text-red-700";case"running":return"border-sky-200 bg-sky-50 text-sky-700";case"created":return"border-zinc-200 bg-zinc-50 text-zinc-600";case null:return"border-zinc-200 bg-zinc-50 text-zinc-500"}}function yc(e){return e??"unknown"}function rP(e){switch(e){case"PASS":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"FAIL":return"border-red-200 bg-red-50 text-red-700";case"RUNNING":return"border-sky-200 bg-sky-50 text-sky-700";case"UNKNOWN":return"border-zinc-200 bg-zinc-50 text-zinc-600"}}function ki(e){return e===null||e.trim().length===0?"-":e}function xt(e){return e.toLocaleString()}function nl(e){return e==null?"-":e<1e3?`${xt(e)} ms`:`${(e/1e3).toFixed(1)} s`}function As(e){const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):e}function Yu(e){return e===null?"-":As(e)}function oP(e){const t=JSON.stringify(e),n=t===void 0?String(e):t;return n.length<=160?n:`${n.slice(0,157)}...`}function M0(...e){for(const t of e)if(t!==null&&t.trim().length>0)return t;return"-"}function iP(...e){for(const t of e)if(t!=null&&t.trim().length>0)return t;return null}function aP(e){const t=e.provider,n=e.model;return t!==null&&t.length>0&&n!==null&&n.length>0?`${t} / ${n}`:M0(t,n)}function lP(e,t){if(t!==null){const n=e.find(s=>s.id===t);if(n!==void 0)return n}return e[0]??null}function cP(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function uP(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function dP(e,t){return t!==null&&t.group.id===e.id?t.evidence:e.evidence}function fP(e,t,n){return t!==null&&t.group.id===e.id?t.summary:n!==null&&n.group.id===e.id?n.summary:null}function pP(e,t,n){return t!==null&&t.group.id===e.id?t.jenkinsReport:n!==null&&n.group.id===e.id?n.report:null}function mP(){const[e,t]=c.useState(!1),[n,s]=c.useState(null),[o,i]=c.useState(null),[a,l]=c.useState(null),[u,d]=c.useState(null),[f,p]=c.useState(null),[m,h]=c.useState(!1),[g,y]=c.useState(null),[b,w]=c.useState(null),[v,j]=c.useState(!1),{notice:S,showToast:k,dismissToast:_}=E0(),{groups:C,isLoading:I,error:A,mutate:P}=XR(),N=c.useMemo(()=>lP(C,n),[C,n]);c.useEffect(()=>{!e||n!==null&&C.some(D=>D.id===n)||s(C[0]?.id??null)},[C,e,n]);const M=N!==null&&u!==null&&u.group.id===N.id?u:null,{evidenceResponse:F,isLoading:B,error:J,mutate:K}=JR(N),W=c.useCallback(()=>{P()},[P]),V=c.useCallback(async()=>{if(!(C.length===0||v)){j(!0),p(null),h(!1),w(null),l(null);try{const oe=await qe(nP(!1),sp,ta,{method:"DELETE"},D=>`Clear failed with status ${String(D.status)}`);d(null),s(null),await P(),await K(),k({message:`Cleared ${xt(oe.deleted)} group${oe.deleted===1?"":"s"}.`,tone:"success"})}catch(oe){k({message:oe instanceof Error?oe.message:"Unknown error clearing groups",tone:"error"})}finally{j(!1)}}},[v,C.length,P,K,k]),z=c.useCallback(async oe=>{i(oe.id),l(null);try{const D=await qe(`/api/groups/${encodeURIComponent(oe.id)}/evidence`,vy,ta,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})},Ne=>`Export failed with status ${String(Ne.status)}`);d(D),await P(),await K()}catch(D){l(D instanceof Error?D.message:String(D))}finally{i(null)}},[P,K]),X=c.useCallback(oe=>{p(oe),h(!1),w(null)},[]),Y=c.useCallback(()=>{g===null&&(p(null),h(!1),w(null))},[g]),we=c.useCallback(oe=>{s(oe),p(null),h(!1),w(null)},[]),he=c.useCallback(async()=>{const oe=f;if(oe!==null){y(oe.id),w(null);try{await qe(tP(oe.id,m),np,ta,{method:"DELETE"},D=>`Delete failed with status ${String(D.status)}`),d(D=>D!==null&&D.group.id===oe.id?null:D),s(D=>D===oe.id?null:D),p(null),h(!1),await P(),await K()}catch(D){w(D instanceof Error?D.message:String(D))}finally{y(null)}}},[m,f,P,K]);return r.jsxs(Zt,{open:e,onOpenChange:t,children:[r.jsx(R0,{notice:S,onDismiss:_}),r.jsx(yr,{asChild:!0,children:r.jsxs(ee,{type:"button",variant:"ghost",size:"icon",className:ji,"aria-label":"Evaluation groups",title:"Evaluation groups",children:[r.jsx(nu,{className:"size-4"}),I?r.jsx(Ue,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):C.length>0?r.jsx("span",{className:"absolute -right-1 -top-1 min-w-4 rounded-full bg-primary px-1 text-[10px] leading-4 text-primary-foreground",children:C.length}):null,r.jsx("span",{className:"sr-only",children:"Evaluation groups"})]})}),r.jsxs(Kt,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[r.jsx(Xt,{children:r.jsxs(Qt,{className:"flex items-center gap-2 pr-8",children:[r.jsx(nu,{className:"size-5 text-muted-foreground"}),r.jsx("span",{children:"Groups"}),r.jsx(_e,{variant:"outline",children:xt(C.length)})]})}),r.jsxs("div",{className:"flex min-h-0 items-center justify-between gap-3 border-b border-border pb-3",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"Evaluation batches, model runs, and exported evidence packs."}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsxs(ee,{type:"button",variant:"outline",size:"sm",disabled:C.length===0||v,onClick:()=>{V()},title:"Clear all groups. Session logs and run records stay intact.",children:[v?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(jn,{className:"size-3.5"}),"Clear"]}),r.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:W,children:[r.jsx(Vt,{className:"size-3.5"}),"Refresh"]})]})]}),r.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[260px_minmax(0,1fr)]",children:[r.jsx(hP,{groups:C,selectedGroupId:N?.id??null,isLoading:I,error:A,onSelect:we}),r.jsx(gP,{group:N,deleteTarget:f,deleteEvidence:m,exportResult:M,evidenceResponse:F,evidenceLoading:B,evidenceError:J,exportError:a,deleteError:b,exportingGroupId:o,deletingGroupId:g,onDeleteEvidenceChange:h,onExport:z,onRequestDelete:X,onCancelDelete:Y,onConfirmDelete:()=>{he()}})]})]})]})}function hP({groups:e,selectedGroupId:t,isLoading:n,error:s,onSelect:o}){return n?r.jsx("div",{className:"flex min-h-48 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:"Loading groups..."}):s!==void 0?r.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:s.message}):e.length===0?r.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-8 text-center text-xs text-muted-foreground",children:"No groups yet."}):r.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:r.jsx("div",{className:"space-y-2",children:e.map(i=>{const a=P0(i),l=t===i.id;return r.jsxs("button",{type:"button",onClick:()=>o(i.id),className:$("w-full rounded-md border px-3 py-2 text-left text-xs transition-colors",l?"border-primary bg-primary/5":"border-border bg-background hover:bg-muted/50"),children:[r.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[r.jsx("span",{className:"min-w-0 text-sm font-medium leading-snug",children:i.title}),r.jsx(_e,{variant:"outline",className:vc(i.status),children:yc(i.status)})]}),r.jsxs("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[r.jsxs("span",{children:[a.memberCount," sessions"]}),r.jsx("span",{children:As(i.updatedAt)})]})]},i.id)})})})}function gP({group:e,deleteTarget:t,deleteEvidence:n,exportResult:s,evidenceResponse:o,evidenceLoading:i,evidenceError:a,exportError:l,deleteError:u,exportingGroupId:d,deletingGroupId:f,onDeleteEvidenceChange:p,onExport:m,onRequestDelete:h,onCancelDelete:g,onConfirmDelete:y}){if(e===null)return r.jsx("div",{className:"flex min-h-48 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:"Select a group to inspect."});const b=P0(e),w=fP(e,s,o),v=pP(e,s,o),j=dP(e,s),S=sP(e,s,o),k=d===e.id,_=f===e.id,C=t?.id===e.id;return r.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[r.jsxs("div",{className:"min-w-0 space-y-1",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[r.jsx("h3",{className:"min-w-0 text-base font-semibold leading-snug",children:e.title}),r.jsx(_e,{variant:"outline",className:vc(e.status),children:yc(e.status)}),r.jsx(_e,{variant:"outline",children:e.kind})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:ki(e.project)}),r.jsxs("span",{children:["updated ",As(e.updatedAt)]})]})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(ee,{type:"button",variant:"outline",size:"icon",className:"size-8 text-red-600 hover:text-red-700","aria-label":"Delete group",title:"Delete group",disabled:_,onClick:()=>h(e),children:_?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(jn,{className:"size-3.5"})}),r.jsxs(ee,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:k||_,onClick:()=>{m(e)},children:[k?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(mr,{className:"size-3.5"}),"Export evidence"]})]})]}),e.task!==null&&e.task.trim().length>0&&r.jsx("p",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:e.task}),C&&r.jsx(xP,{group:e,deleteEvidence:n,isDeleting:_,error:u,onDeleteEvidenceChange:p,onCancel:g,onConfirm:y}),r.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[r.jsx(pn,{label:"Members",value:b.memberCount}),r.jsx(pn,{label:"Done",value:b.completedMembers}),r.jsx(pn,{label:"Failed",value:b.failedMembers}),r.jsx(pn,{label:"Running",value:b.runningMembers})]}),w!==null&&r.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[r.jsx(pn,{label:"Requests",value:w.requestCount}),r.jsx(pn,{label:"Errors",value:w.errorCount}),r.jsx(pn,{label:"Tokens",value:w.tokenUsage.total}),r.jsx(pn,{label:"Missing",value:w.missingSessions})]}),r.jsx(bP,{report:v,loading:i,error:a,hasEvidence:j!==null}),r.jsx(vP,{evidence:j}),l!==null&&r.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:l}),u!==null&&!C&&r.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:u}),r.jsx(yP,{rows:S})]})})}function xP({group:e,deleteEvidence:t,isDeleting:n,error:s,onDeleteEvidenceChange:o,onCancel:i,onConfirm:a}){const l=e.evidence!==null,u=e.evidence?.markdownPath??"No evidence pack exported.";return r.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-3 text-red-900",children:r.jsxs("div",{className:"flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[r.jsxs("div",{className:"min-w-0 space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[r.jsx(jn,{className:"size-4 text-red-600"}),r.jsx("span",{children:"Delete group?"})]}),r.jsxs("p",{className:"text-xs text-red-800",children:["Delete ",r.jsx("span",{className:"font-medium",children:e.title}),". Session logs and run records stay intact."]}),r.jsxs("label",{className:$("flex min-w-0 items-start gap-2 text-xs",l?"cursor-pointer":"opacity-60"),children:[r.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0",checked:t,disabled:!l||n,onChange:d=>o(d.currentTarget.checked)}),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block font-medium",children:"Also delete exported evidence files"}),r.jsx("code",{className:"mt-1 block truncate font-mono text-[11px] text-red-700",children:u})]})]}),s!==null&&r.jsx("div",{className:"rounded-md border border-red-200 bg-white px-2 py-1.5 text-xs text-red-700",children:s})]}),r.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[r.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:n,onClick:i,children:"Cancel"}),r.jsxs(ee,{type:"button",variant:"destructive",size:"sm",disabled:n,onClick:a,children:[n?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(jn,{className:"size-3.5"}),"Delete"]})]})]})})}function pn({label:e,value:t}){return r.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:e}),r.jsx("div",{className:"mt-1 font-mono text-sm font-semibold",children:xt(t)})]})}function bP({report:e,loading:t,error:n,hasEvidence:s}){const{copied:o,copy:i}=vn(e?.markdown??null);return e===null&&!t&&n===void 0?null:t?r.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:[r.jsx(Ue,{className:"size-3.5 animate-spin"}),"Loading evidence report..."]}):n!==void 0&&s?r.jsxs("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:["Failed to load evidence report: ",n.message]}):e===null?null:r.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"text-xs font-semibold",children:"Evidence report"}),r.jsx(_e,{variant:"outline",className:rP(e.status),children:e.status})]}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":o?"Copied evidence report":"Copy evidence report",onClick:i,children:o?r.jsx(Ge,{className:"size-3.5 text-emerald-500"}):r.jsx(Ot,{className:"size-3.5"})})]}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function vP({evidence:e}){return e===null?r.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No evidence pack exported yet."}):r.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("span",{className:"text-xs font-semibold",children:"Evidence paths"}),r.jsx("span",{className:"text-[11px] text-muted-foreground",children:As(e.exportedAt)})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx(na,{label:"JSON",value:e.jsonPath}),r.jsx(na,{label:"Markdown",value:e.markdownPath}),r.jsx(na,{label:"HTML",value:e.htmlPath})]})]})}function na({label:e,value:t}){const{copied:n,copy:s}=vn(t);return r.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border bg-background px-2 py-1.5",children:[r.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground",children:e}),r.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":n?`Copied ${e} path`:`Copy ${e} path`,onClick:s,children:n?r.jsx(Ge,{className:"size-3.5 text-emerald-500"}):r.jsx(Ot,{className:"size-3.5"})})]})}function yP({rows:e}){const[t,n]=c.useState(null),s=c.useCallback(o=>{n(i=>i===o?null:o)},[]);return e.length===0?r.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-8 text-center text-xs text-muted-foreground",children:"No sessions attached."}):r.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[r.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-xs font-semibold",children:"Members"}),r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[760px] text-left text-xs",children:[r.jsx("thead",{className:"border-b border-border bg-muted/20 text-muted-foreground",children:r.jsxs("tr",{children:[r.jsx("th",{className:"px-3 py-2 font-medium",children:"Session"}),r.jsx("th",{className:"px-3 py-2 font-medium",children:"Provider / Model"}),r.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),r.jsx("th",{className:"px-3 py-2 font-medium",children:"Requests"}),r.jsx("th",{className:"px-3 py-2 font-medium",children:"Errors"}),r.jsx("th",{className:"px-3 py-2 font-medium",children:"First chunk"}),r.jsx("th",{className:"px-3 py-2 font-medium",children:"Tokens"})]})}),r.jsx("tbody",{children:e.map(o=>{const i=t===o.member.id;return r.jsxs(c.Fragment,{children:[r.jsx(wP,{row:o,isExpanded:i,onToggleDetails:s}),r.jsx(jP,{row:o,isExpanded:i})]},o.member.id)})})]})})]})}function wP({row:e,isExpanded:t,onToggleDetails:n}){const s=e.member,o=e.exportMember?.session??null,i=cP(e),a=o?.inspectorPath??ef(s.sessionId),l=e.source!=="evidence",u=o?.requestCount??null,d=o?.errorCount??null,f=o?.tokenUsage.total??null,p=i?.firstChunkMs??null,m=M0(s.label,s.sessionId),h=iP(o?.clientUserAgent,i?.userAgent,s.agent),g=o?.clientProjectFolder??null,y=ac({userAgent:h,conversationId:s.sessionId,clientProjectFolder:g}),b=xi(y);return r.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/20",children:[r.jsxs("td",{className:"max-w-56 px-3 py-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground","aria-label":t?`Hide member ${m}`:`Show member ${m}`,title:t?"Hide member details":"Show member details",onClick:()=>{n(s.id)},children:t?r.jsx(nt,{className:"size-3.5"}):r.jsx(yt,{className:"size-3.5"})}),b!==null&&r.jsx(bi,{client:y,className:"size-5"}),l?r.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",className:"inline-flex max-w-full min-w-0 items-center gap-2 rounded-sm font-mono text-xs text-primary outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","aria-label":`Open session ${m}`,title:`Open session ${m}`,children:[r.jsx("span",{className:"min-w-0 truncate",children:m}),r.jsx(Il,{className:"size-3 shrink-0 text-muted-foreground"})]}):r.jsxs("button",{type:"button",className:"inline-flex max-w-full min-w-0 items-center gap-2 rounded-sm font-mono text-xs text-foreground outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",title:`Show evidence snapshot for ${m}`,"aria-label":`Show evidence snapshot for ${m}`,onClick:()=>{n(s.id)},children:[r.jsx("span",{className:"min-w-0 truncate",children:m}),r.jsx(_e,{variant:"outline",className:"shrink-0 border-zinc-200 bg-zinc-50 text-zinc-600",children:"evidence"})]})]}),r.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:ki(s.agent)})]}),r.jsx("td",{className:"max-w-52 px-3 py-2",children:r.jsx("span",{className:"block whitespace-normal leading-snug",children:aP(s)})}),r.jsx("td",{className:"px-3 py-2",children:r.jsx(_e,{variant:"outline",className:vc(s.status),children:yc(s.status)})}),r.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":xt(u)}),r.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":xt(d)}),r.jsx("td",{className:"px-3 py-2 font-mono",children:nl(p)}),r.jsx("td",{className:"px-3 py-2 font-mono",children:f===null?"-":xt(f)})]})}function jP({row:e,isExpanded:t}){if(!t)return null;const n=e.member,s=e.exportMember,o=s?.session??null,i=s?.run??null,a=Object.entries(n.metadata);return r.jsx("tr",{className:"border-b border-border bg-muted/10",children:r.jsx("td",{colSpan:7,className:"px-3 pb-4 pt-2",children:r.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-background p-3",children:[r.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[r.jsx(st,{label:"Source",value:uP(e.source)}),r.jsx(st,{label:"Member ID",value:n.id,mono:!0}),r.jsx(st,{label:"Session ID",value:n.sessionId,mono:!0}),r.jsx(st,{label:"Run ID",value:i?.id??n.runId??"-",mono:!0}),r.jsx(st,{label:"Created",value:As(n.addedAt)}),r.jsx(st,{label:"Updated",value:As(n.updatedAt)}),r.jsx(st,{label:"Session created",value:Yu(o?.createdAt??null)}),r.jsx(st,{label:"Session updated",value:Yu(o?.updatedAt??null)})]}),o===null?r.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No session snapshot is available for this member."}):r.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[r.jsx(st,{label:"Log coverage",value:o.logCoverage}),r.jsx(st,{label:"Runtime",value:ki(o.runtimeMode)}),r.jsx(st,{label:"Requests",value:xt(o.requestCount),mono:!0}),r.jsx(st,{label:"Errors",value:xt(o.errorCount),mono:!0}),r.jsx(st,{label:"Input tokens",value:xt(o.tokenUsage.input),mono:!0}),r.jsx(st,{label:"Output tokens",value:xt(o.tokenUsage.output),mono:!0}),r.jsx(st,{label:"Cache read",value:xt(o.tokenUsage.cacheRead),mono:!0}),r.jsx(st,{label:"Total tokens",value:xt(o.tokenUsage.total),mono:!0})]}),r.jsx(kP,{logs:o?.latestLogs??[]}),r.jsx(SP,{entries:a})]})})})}function st({label:e,value:t,mono:n=!1}){return r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),r.jsx("div",{className:$("truncate text-xs text-foreground",n?"font-mono":""),title:t,children:t})]})}function kP({logs:e}){const t=e.slice(0,5);return t.length===0?r.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No latest logs in this snapshot."}):r.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[r.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Latest logs"}),r.jsx("div",{className:"divide-y divide-border",children:t.map(n=>{const s=n.sessionLogNumber??n.id;return r.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs sm:grid-cols-[72px_1fr_88px_88px]",children:[r.jsxs("span",{className:"font-mono text-muted-foreground",title:`Log ID ${String(n.id)}`,children:["#",s]}),r.jsxs("span",{className:"min-w-0 truncate",children:[ki(n.model)," · ",n.apiFormat," · ",n.path]}),r.jsx("span",{className:"font-mono text-muted-foreground",children:nl(n.firstChunkMs)}),r.jsx("span",{className:"font-mono text-muted-foreground",children:nl(n.latencyMs)})]},n.id)})})]})}function SP({entries:e}){return e.length===0?null:r.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[r.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Metadata"}),r.jsx("div",{className:"grid gap-x-3 gap-y-2 p-3 text-xs sm:grid-cols-2",children:e.map(([t,n])=>{const s=oP(n);return r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"mr-2 text-muted-foreground",children:t}),r.jsx("span",{className:"font-mono text-foreground",title:s,children:s})]},t)})})]})}const _P=T({selectionId:x().uuid(),name:x(),apiKeyHint:x(),format:pe(["anthropic","openai"]),anthropicBaseUrl:x(),openaiBaseUrl:x(),openaiResponsesBaseUrl:x().optional().default(""),models:H(x()),sourceTool:pe(["claude-code","opencode","mimo-code"]),alreadyExists:Te()}),NP=T({scanId:x().uuid(),providers:H(_P),warnings:H(x()).optional()});T({scanId:x().uuid(),selectionIds:H(x().uuid()).min(1).max(100)});const CP=T({success:Te().optional(),imported:R().optional(),message:x().optional(),errors:H(x()).optional()}),Xu=2e4;function TP({open:e,onOpenChange:t,onImportComplete:n}){const[s,o]=c.useState(!1),[i,a]=c.useState(null),[l,u]=c.useState(null),[d,f]=c.useState([]),[p,m]=c.useState([]),[h,g]=c.useState(new Set),[y,b]=c.useState(!1),[w,v]=c.useState(null),[j,S]=c.useState(null),k=c.useRef(0),_=c.useRef(0),C=c.useCallback(()=>{const N=k.current+1;k.current=N,o(!0),a(null),m([]),u(null),f([]),g(new Set),v(null),S(null),qe("/api/providers/scan",NP,Xu,{method:"POST"},M=>`Scan failed (${String(M.status)})`).then(M=>{if(k.current!==N)return;u(M.scanId),f(M.providers),m(M.warnings??[]);const F=new Set;M.providers.forEach((B,J)=>{B.alreadyExists||F.add(J)}),g(F)}).catch(M=>{k.current===N&&a(M instanceof Error?M.message:String(M))}).finally(()=>{k.current===N&&o(!1)})},[]);c.useEffect(()=>{e&&C()},[e,C]),c.useEffect(()=>{e||(k.current+=1,_.current+=1,o(!1),b(!1))},[e]);const I=c.useCallback(N=>{g(M=>{const F=new Set(M);return F.has(N)?F.delete(N):F.add(N),F})},[]),A=c.useCallback(()=>{const N=d.filter((F,B)=>h.has(B));if(N.length===0||l===null)return;const M=_.current+1;_.current=M,b(!0),S(null),v(null),qe("/api/providers/import",CP,Xu,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scanId:l,selectionIds:N.map(F=>F.selectionId)})},F=>`Import failed (${String(F.status)})`).then(F=>{_.current===M&&(f(B=>B.map((J,K)=>h.has(K)?{...J,alreadyExists:!0}:J)),g(new Set),F.errors!==void 0&&F.errors.length>0&&F.message!==void 0?v(F.message):v(`Imported ${F.imported??N.length} provider(s)`),n())}).catch(F=>{_.current===M&&S(F instanceof Error?F.message:String(F))}).finally(()=>{_.current===M&&b(!1)})},[d,l,h,n]),P=d.some(N=>!N.alreadyExists);return r.jsx(Zt,{open:e,onOpenChange:t,children:r.jsxs(Kt,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[r.jsxs(Xt,{children:[r.jsx(Qt,{children:"Import from External Tools"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[s&&r.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[r.jsx(Ue,{className:"size-4 animate-spin"}),r.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),i!==null&&r.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[r.jsx(Ns,{className:"size-4"}),i]}),!s&&i===null&&d.length===0&&r.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",r.jsx("br",{}),r.jsx("span",{className:"text-xs",children:"Supported tools: Claude Code (~/.claude/settings.json), OpenCode (~/.config/opencode/opencode.json), MiMo Code (~/.config/mimocode/mimocode.jsonc)"})]}),!s&&d.map((N,M)=>r.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${N.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!N.alreadyExists&&r.jsx("input",{type:"checkbox",checked:h.has(M),disabled:y,onChange:()=>I(M),className:"mt-0.5 size-4"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(bi,{client:N.sourceTool,className:"size-7 rounded-[8px]"}),N.alreadyExists&&r.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),r.jsxs("div",{className:"mt-1 text-xs leading-snug text-muted-foreground",children:[N.models.slice(0,4).join(", "),N.models.length>4?` +${N.models.length-4} more`:""]}),r.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:N.format==="anthropic"?N.anthropicBaseUrl:N.openaiResponsesBaseUrl!==""?N.openaiResponsesBaseUrl:N.openaiBaseUrl}),r.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:N.apiKeyHint})]})]},N.selectionId)),p.length>0&&r.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:p.map((N,M)=>r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(Ns,{className:"size-3"}),N]},M))}),w!==null&&r.jsx("div",{className:"text-sm text-green-500 border-t pt-2",children:w}),j!==null&&r.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:j})]}),r.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[r.jsxs(ee,{variant:"outline",size:"sm",onClick:C,disabled:s,children:[r.jsx(Ue,{className:`size-3 mr-1 ${s?"animate-spin":""}`}),"Rescan"]}),r.jsxs(ee,{size:"sm",onClick:A,disabled:!P||h.size===0||y,children:[r.jsx(mr,{className:"size-3 mr-1"}),y?"Importing...":`Import Selected (${h.size})`]})]})]})})}const I0=T({id:x().min(1).max(Ra),aliases:H(x().max(Ra)).max(Bn).optional().default([]),contextWindow:R().int().positive().optional(),outputLimit:R().int().positive().optional(),sourceUrl:x().optional()}),EP=T({name:x().min(1).optional(),aliases:H(x()).max(Bn).optional().default([]),baseUrls:H(x()).max(Bn).optional().default([]),models:H(I0).min(1).max(Bn)});T({version:R().int().positive().optional(),updatedAt:x().optional(),providers:H(EP).max(Bn).optional().default([]),models:H(I0).max(Bn).optional().default([])});function Qu(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function RP(e){const t=e.models.filter(n=>n.trim()!=="");return t.length>0?t:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function wc(e,t){const n=Qu(t);return(e.modelMetadata??[]).find(o=>Qu(o.model)===n)??null}function PP(e){const t=RP(e);return t.length===0?!1:t.every(n=>{const s=wc(e,n);return s!==null&&s.contextWindow!==void 0})}function MP(e,t){if(e===null)return null;for(const n of t){const s=wc(n,e);if(s!==null&&s.contextWindow!==void 0)return{providerName:n.name,model:s.model,tokens:s.contextWindow,sourceUrl:s.sourceUrl}}return null}function ur(e){return Object.prototype.hasOwnProperty.call(e,"success")}function Si(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function kt(e){return e!==void 0&&e!==""}function at(e){return e!==void 0&&e.trim()!==""}function js(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function A0(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function O0(e){switch(e){case"timeout":return"Timeout";case"network_unreachable":return"Offline";case"connection_refused":return"Refused";case"auth_failed":return"Auth";case"rate_limited":return"Rate limit";case"server_error":return"Server";case"invalid_response":return"Invalid";case"unknown":return"Failed"}}function IP(e){return e.firstChunkMs!==void 0&&e.firstChunkMs!==null?js(e.firstChunkMs):e.latencyMs!==void 0?js(e.latencyMs):e.totalStreamMs!==void 0&&e.totalStreamMs!==null?js(e.totalStreamMs):e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?A0(e.tokensPerSecond):null}function AP(e){return Si(e)?{tone:"quiet",label:"N/A",metric:null,hasDetails:!1}:ur(e)?e.success?{tone:"success",label:"Pass",metric:IP(e),hasDetails:!0}:{tone:"failure",label:O0(e.error?.type??"unknown"),metric:null,hasDetails:!0}:{tone:"pending",label:"Running",metric:null,hasDetails:!1}}function OP(e,t){if(t===void 0)return[];const n=[];return kt(e.anthropicBaseUrl)&&n.push(t.anthropic),kt(e.openaiBaseUrl)&&n.push(t.openaiChat),kt(e.openaiResponsesBaseUrl)&&n.push(t.openaiResponses),n}function zP(e,t){const n={total:0,passed:0,failed:0,testing:0};for(const s of OP(e,t))for(const o of[s.nonStreaming,s.streaming])Si(o)||(n.total+=1,ur(o)?o.success?n.passed+=1:n.failed+=1:n.testing+=1);return n}function ed(e){if(e===void 0)return;const t=Object.entries(e).map(([n,s])=>`${n}: ${s}`);return t.length===0?void 0:t.join(`
124
- `)}function mn({title:e,children:t}){return r.jsxs("section",{className:"space-y-1.5",children:[r.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:e}),t]})}function zn({value:e}){return r.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/40 p-3 font-mono text-[11px] leading-relaxed text-foreground/80",children:e})}function Ln({label:e,value:t}){return r.jsxs("div",{className:"min-w-0 rounded-md bg-muted/35 px-3 py-2",children:[r.jsx("dt",{className:"text-[10px] text-muted-foreground",children:e}),r.jsx("dd",{className:"mt-1 truncate font-mono text-xs font-semibold text-foreground",title:t,children:t})]})}function LP({result:e}){const t=e.inputTokens!==void 0||e.outputTokens!==void 0,n=e.cacheCreationInputTokens!==void 0||e.cacheReadInputTokens!==void 0;return at(e.model)||t||n||e.latencyMs!==void 0||e.firstChunkMs!==void 0&&e.firstChunkMs!==null||e.totalStreamMs!==void 0&&e.totalStreamMs!==null||e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?r.jsxs("dl",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:[at(e.model)&&r.jsx(Ln,{label:"Model",value:e.model}),e.latencyMs!==void 0&&r.jsx(Ln,{label:"Latency",value:js(e.latencyMs)}),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&r.jsx(Ln,{label:"First chunk",value:js(e.firstChunkMs)}),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&r.jsx(Ln,{label:"Stream total",value:js(e.totalStreamMs)}),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&r.jsx(Ln,{label:"Token rate",value:`${A0(e.tokensPerSecond)} tok`}),t&&r.jsx(Ln,{label:"Tokens in / out",value:`${String(e.inputTokens??0)} / ${String(e.outputTokens??0)}`}),n&&r.jsx(Ln,{label:"Cache create / read",value:`${String(e.cacheCreationInputTokens??0)} / ${String(e.cacheReadInputTokens??0)}`})]}):null}function $P({result:e}){const t=e.debug,n=t?.requestUrl,s=t?.requestMethod??"POST",o=ed(t?.requestHeaders),i=ed(t?.responseHeaders),a=t?.responseStatus===void 0?void 0:`${String(t.responseStatus)}${at(t.responseStatusText)?` ${t.responseStatusText}`:""}`,l=t?.responseBody??e.rawResponse;return at(e.error?.hint)||at(e.error?.details)||at(n)||o!==void 0||at(t?.requestBody)||at(a)||i!==void 0||at(l)?r.jsxs("div",{className:"space-y-4 border-t border-border/70 pt-4 text-xs text-muted-foreground",children:[at(e.error?.hint)&&r.jsx(mn,{title:"Hint",children:r.jsx("p",{className:"break-words text-foreground/80",children:e.error.hint})}),at(e.error?.details)&&r.jsx(mn,{title:"Error details",children:r.jsx(zn,{value:e.error.details})}),at(n)&&r.jsx(mn,{title:"Request",children:r.jsx(zn,{value:`${s} ${n}`})}),o!==void 0&&r.jsx(mn,{title:"Request headers",children:r.jsx(zn,{value:o})}),at(t?.requestBody)&&r.jsx(mn,{title:"Request body",children:r.jsx(zn,{value:t.requestBody})}),at(a)&&r.jsx(mn,{title:"Response status",children:r.jsx(zn,{value:a})}),i!==void 0&&r.jsx(mn,{title:"Response headers",children:r.jsx(zn,{value:i})}),at(l)&&r.jsx(mn,{title:"Response body",children:r.jsx(zn,{value:l})})]}):null}function DP({result:e,probeLabel:t,children:n}){const s=e.error?.message??"Connection failed";return r.jsxs(Zt,{children:[r.jsx(yr,{asChild:!0,children:n}),r.jsxs(Kt,{className:"max-h-[82vh] max-w-2xl gap-0 overflow-hidden p-0",children:[r.jsxs(Xt,{className:"border-b border-border/70 px-5 py-4 pr-12",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[e.success?r.jsx(pr,{className:"size-4 text-cyan-300"}):r.jsx(Ns,{className:"size-4 text-red-300"}),r.jsx(Qt,{className:"text-base",children:t})]}),r.jsx(wr,{children:e.success?"Connection probe passed.":s})]}),r.jsxs("div",{className:"space-y-4 overflow-y-auto p-5",children:[!e.success&&r.jsxs("div",{className:"rounded-md border border-red-400/20 bg-red-400/[0.06] px-3 py-2 text-sm text-red-200",children:[r.jsx("div",{className:"font-medium",children:O0(e.error?.type??"unknown")}),r.jsx("div",{className:"mt-1 break-words text-xs text-muted-foreground",children:s})]}),r.jsx(LP,{result:e}),r.jsx($P,{result:e})]})]})]})}function FP(e){const t="size-3 shrink-0";switch(e){case"timeout":return r.jsx(rn,{className:t});case"network_unreachable":return r.jsx(l5,{className:t});case"connection_refused":return r.jsx(u5,{className:t});case"auth_failed":return r.jsx(cj,{className:t});case"rate_limited":return r.jsx(Al,{className:t});case"server_error":return r.jsx(Hj,{className:t});case"invalid_response":return r.jsx(mw,{className:t});case"unknown":return r.jsx(Ns,{className:t})}}const UP={success:"bg-cyan-300/[0.07] text-cyan-100 hover:bg-cyan-300/[0.11]",failure:"bg-red-400/[0.07] text-red-200 hover:bg-red-400/[0.11]",pending:"bg-muted/40 text-foreground/80",quiet:"bg-transparent text-muted-foreground/70"};function td({result:e,probeLabel:t}){const n=AP(e),s=Si(e)?r.jsx(gp,{className:"size-3 shrink-0"}):ur(e)?e.success?r.jsx(pr,{className:"size-3 shrink-0"}):FP(e.error?.type??"unknown"):r.jsx(yo,{className:"size-3 shrink-0 animate-spin"}),o=r.jsxs(r.Fragment,{children:[s,r.jsx("span",{className:"min-w-0 truncate",children:n.label}),n.metric!==null&&r.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] opacity-75",children:n.metric})]}),i=$("inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors",UP[n.tone]);return ur(e)&&n.hasDetails?r.jsx(DP,{result:e,probeLabel:t,children:r.jsx("button",{type:"button",className:i,"aria-label":`Open ${t} result: ${n.label}`,children:o})}):r.jsx("div",{className:i,children:o})}function nd({label:e}){return r.jsxs("div",{className:"inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground/70",children:[r.jsx(gp,{className:"size-3 shrink-0"}),r.jsx("span",{className:"truncate",children:e})]})}function sa({label:e,results:t,configured:n=!0}){return r.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(6.5rem,1fr)_minmax(6rem,0.9fr)_minmax(6rem,0.9fr)] items-center gap-2 border-t border-border/60 px-2 py-2",children:[r.jsx("div",{className:"min-w-0 truncate text-xs font-medium text-foreground/85",title:e,children:e}),n&&t!==void 0?r.jsx(td,{result:t.nonStreaming,probeLabel:`${e} non-stream`}):r.jsx(nd,{label:n?"Not tested":"Off"}),n&&t!==void 0?r.jsx(td,{result:t.streaming,probeLabel:`${e} stream`}):r.jsx(nd,{label:n?"Not tested":"Off"})]})}function z0({provider:e,results:t}){const n=kt(e.anthropicBaseUrl),s=kt(e.openaiBaseUrl),o=kt(e.openaiResponsesBaseUrl);return!n&&!s&&!o?r.jsx("div",{className:"text-xs text-muted-foreground",children:"No testable endpoint configured."}):r.jsx("div",{className:"min-w-0 overflow-x-auto rounded-md border border-border/70",children:r.jsxs("div",{className:"min-w-[20rem]",children:[r.jsxs("div",{className:"grid grid-cols-[minmax(6.5rem,1fr)_minmax(6rem,0.9fr)_minmax(6rem,0.9fr)] gap-2 bg-muted/25 px-2 py-1.5 text-[10px] text-muted-foreground",children:[r.jsx("span",{children:"Protocol"}),r.jsx("span",{children:"Non-stream"}),r.jsx("span",{children:"Stream"})]}),n&&r.jsx(sa,{label:"Anthropic",results:t?.anthropic}),s&&r.jsx(sa,{label:"OpenAI Chat",results:t?.openaiChat}),r.jsx(sa,{label:"OpenAI Responses",results:t?.openaiResponses,configured:o})]})})}function BP(e){const t={total:0,passed:0,failed:0,testing:0};for(const n of[e.nonStreaming,e.streaming])Si(n)||(t.total+=1,ur(n)?n.success?t.passed+=1:t.failed+=1:t.testing+=1);return t}function ra({label:e,results:t}){const n=BP(t),s=n.failed>0?"border-red-400/20 bg-red-400/[0.06] text-red-200":n.testing>0?"border-amber-300/20 bg-amber-300/[0.06] text-amber-100":n.total>0&&n.passed===n.total?"border-cyan-300/20 bg-cyan-300/[0.06] text-cyan-100":"border-border/60 bg-transparent text-muted-foreground",o=n.failed>0?`${n.failed} fail`:n.testing>0?"running":n.total===0?"off":`${n.passed}/${n.total}`;return r.jsxs("span",{className:$("rounded border px-1.5 py-0.5 text-[10px]",s),children:[e," ",o]})}function VP({provider:e,modelName:t,results:n,expanded:s,onToggle:o}){return r.jsxs("div",{className:"min-w-0",children:[r.jsxs("button",{type:"button",onClick:o,className:"flex w-full min-w-0 flex-wrap items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-muted/20","aria-expanded":s,children:[s?r.jsx(nt,{className:"size-3.5 shrink-0 text-muted-foreground"}):r.jsx(yt,{className:"size-3.5 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-[8rem] flex-1 truncate text-xs font-medium",title:t,children:t}),r.jsxs("span",{className:"flex flex-wrap items-center justify-end gap-1",children:[kt(e.anthropicBaseUrl)&&r.jsx(ra,{label:"A",results:n.anthropic}),kt(e.openaiBaseUrl)&&r.jsx(ra,{label:"Chat",results:n.openaiChat}),kt(e.openaiResponsesBaseUrl)&&r.jsx(ra,{label:"Resp",results:n.openaiResponses})]})]}),s&&r.jsx("div",{className:"px-2 pb-3",children:r.jsx(z0,{provider:e,results:n})})]})}function qP({provider:e,testResults:t}){const n=Object.entries(t.models??{}),[s,o]=c.useState(!1),[i,a]=c.useState(null);return n.length===0?null:r.jsxs("section",{className:"space-y-2",children:[r.jsxs("button",{type:"button",onClick:()=>o(l=>!l),className:"flex w-full items-center gap-1.5 text-left text-xs font-medium text-foreground/80 transition-colors hover:text-foreground","aria-expanded":s,children:[s?r.jsx(nt,{className:"size-3.5"}):r.jsx(yt,{className:"size-3.5"}),"Model probes",r.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:n.length})]}),s&&r.jsx("div",{className:"min-w-0 divide-y divide-border/60 rounded-md border border-border/70",children:n.map(([l,u])=>r.jsx(VP,{provider:e,modelName:l,results:u,expanded:i===l,onToggle:()=>a(d=>d===l?null:l)},l))})]})}function HP({provider:e,testResults:t,isTesting:n}){const s=kt(e.anthropicBaseUrl)||kt(e.openaiBaseUrl)||kt(e.openaiResponsesBaseUrl),o=zP(e,t);return n?r.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-cyan-300/25 bg-cyan-300/[0.08] px-2 py-1 text-xs text-cyan-100",children:[r.jsx(yo,{className:"size-3 animate-spin"}),"Testing"]}):s?t===void 0||o.total===0?r.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"Not tested"}):o.failed>0?r.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-red-400/25 bg-red-500/[0.08] px-2 py-1 text-xs text-red-200",children:[r.jsx(Ns,{className:"size-3"}),o.failed," failed"]}):o.testing>0||o.passed<o.total?r.jsxs("span",{className:"rounded border border-amber-300/25 bg-amber-400/[0.08] px-2 py-1 text-xs text-amber-100",children:[o.passed,"/",o.total]}):r.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-cyan-300/25 bg-cyan-300/[0.08] px-2 py-1 text-xs text-cyan-100",children:[r.jsx(pr,{className:"size-3"}),o.passed,"/",o.total]}):r.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"No endpoint"})}const WP={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function oa(e){return e!==void 0&&e!==""}function ia({label:e}){return r.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border/70 bg-muted/25 px-1.5 py-0.5 text-foreground/80",children:[r.jsx(pr,{className:"size-3"}),e]})}function ZP({provider:e}){const t=oa(e.anthropicBaseUrl),n=oa(e.openaiBaseUrl),s=oa(e.openaiResponsesBaseUrl);return!t&&!n&&!s?r.jsx("div",{className:"text-xs text-muted-foreground",children:"Test requires at least one configured endpoint."}):r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[t&&r.jsx(ia,{label:"Anthropic"}),n&&r.jsx(ia,{label:"OpenAI Chat"}),s&&r.jsx(ia,{label:"OpenAI Responses"})]})}function KP(e){const t=e.models??[];if(t.length===0)return"No models configured";const n=t.slice(0,2).join(", "),s=t.length-2;return s>0?`${n} +${s} more`:n}function GP({provider:e,model:t}){const n=wc(e,t),s=YP(n?.sourceUrl);return r.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[r.jsx("span",{children:t}),n!==null&&n.contextWindow!==void 0&&r.jsx("span",{className:"font-mono text-foreground/80",children:nf(n.contextWindow)}),s!==null&&r.jsx(Ds,{children:r.jsxs(pt,{children:[r.jsx(mt,{asChild:!0,children:r.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 rounded border border-border/70 bg-background/70 px-1 font-mono text-[10px] leading-4 text-muted-foreground transition-colors hover:text-foreground","aria-label":s.title,children:s.label})}),r.jsx(ht,{children:s.title})]})})]})}function JP(e){const t=Date.now(),n=new Date(e).getTime(),s=t-n,o=Math.floor(s/1e3);if(o<60)return"just now";const i=Math.floor(o/60);if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function YP(e){if(e===void 0||e.trim()==="")return null;try{const t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;const n=t.hostname.toLowerCase(),s=n==="huggingface.co"||n.endsWith(".huggingface.co");return{label:s?"HF":"Source",title:s?"Open Hugging Face model source":"Open model metadata source",url:e}}catch{return null}}function XP({provider:e,testResults:t,isTesting:n,testingTimeLeft:s,isHighlighted:o,onEdit:i,onDelete:a,onTest:l,onRefreshMetadata:u,isRefreshingMetadata:d=!1}){const[f,p]=c.useState(!1),m=e.apiDocsUrl??Object.entries(WP).find(([v])=>e.name.toLowerCase().includes(v))?.[1],h=PP(e),g=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",y=g?"Refresh":"Import defaults",b=n??!1,w=e.source==="company"?r.jsx("span",{className:"shrink-0 rounded border border-cyan-300/20 bg-cyan-300/[0.08] px-1.5 py-0.5 text-xs text-cyan-100",children:"Company"}):e.source==="personal"?r.jsx("span",{className:"shrink-0 rounded border border-violet-300/20 bg-violet-300/[0.08] px-1.5 py-0.5 text-xs text-violet-100",children:"Personal"}):null;return r.jsxs("div",{"data-provider-id":e.id,className:`flex flex-col gap-3 rounded-[8px] border border-border bg-card p-4 shadow-sm transition-all duration-500 ${o===!0?"ring-2 ring-primary shadow-md":""}`,children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 space-y-1",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[r.jsx("span",{className:"font-medium leading-snug",children:e.name}),w]}),r.jsx("div",{className:"text-xs leading-snug text-muted-foreground",children:KP(e)})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(HP,{provider:e,testResults:t,isTesting:b}),m!==void 0&&r.jsxs("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",title:"View API documentation",children:[r.jsx(Il,{className:"size-3"}),r.jsx("span",{className:"sr-only",children:"Docs"})]})]})]}),r.jsxs("div",{className:"flex flex-col gap-2 text-xs text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[r.jsx(ZP,{provider:e}),t?.testedAt!==void 0&&r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(rn,{className:"size-3"}),JP(t.testedAt)]})]}),!h&&r.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-amber-500/25 bg-amber-500/6 px-2 py-1.5 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Context window metadata missing"}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[r.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>u?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:d,children:[r.jsx(yo,{className:`size-3 ${d?"animate-spin":""}`}),y]}),!g&&r.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),f&&r.jsxs("div",{className:"space-y-3 border-t border-border/60 pt-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx(pr,{className:"size-3.5 text-emerald-500"}),r.jsx("span",{children:"API key configured"})]}),e.models!==void 0&&e.models.length>0&&r.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(v=>r.jsx(GP,{provider:e,model:v},v))}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:"Connection probes"}),r.jsx(z0,{provider:e,results:t})]}),t!==void 0&&r.jsx(qP,{provider:e,testResults:t})]}),r.jsxs("div",{className:"flex flex-col gap-2 border-t pt-1 sm:flex-row sm:items-center sm:justify-between",children:[r.jsxs("button",{type:"button",onClick:()=>p(v=>!v),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":f,children:[f?r.jsx(nt,{className:"size-3"}):r.jsx(yt,{className:"size-3"}),"Details"]}),r.jsxs("div",{className:"flex gap-2",children:[l!==void 0&&r.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>l(e.id),className:"text-xs h-7 gap-1",disabled:b,children:[r.jsx(yo,{className:`size-3 ${b?"animate-spin":""}`}),b?s!==void 0?`Testing (${s}s)`:"Testing...":"Test"]}),r.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>i(e),className:"text-xs h-7 gap-1",disabled:b,children:[r.jsx(xp,{className:"size-3"}),"Edit"]}),r.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>a(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:b,children:[r.jsx(jn,{className:"size-3"}),"Delete"]})]})]})]})}const ks="/v1/chat/completions",sl="/v1/responses",QP="/v1/messages";function eM(e,t){const n=e.endsWith("/")?e.slice(0,-1):e,s=L0(t),o=t.indexOf("?"),i=o>=0?t.slice(o):"";return s!==""&&n.endsWith(s)?n+i:D0(n)&&$0(t)||n.endsWith("/v1")&&t.startsWith("/v1/")?n+t.slice(3):n+t}function tM(e,t,n={}){const s=e.trim().replace(/\/+$/,""),o=L0(t),i=eM(s,t),a=[];return o!==""&&s.endsWith(o)?a.push({severity:"info",message:"This already includes the exact endpoint; no duplicate suffix will be appended."}):D0(s)&&$0(t)?a.push({severity:"info",message:"Zhipu bases already include the API version; only /chat/completions is appended."}):s.endsWith("/v1")&&t.startsWith("/v1/")&&a.push({severity:"info",message:"Base URL already ends with /v1; the suffix will not repeat /v1."}),sd(o)&&sM(s)&&a.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),nM(o)&&rM(s)&&a.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),sd(o)&&oM(s,n.providerName)&&a.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:i,diagnostics:a}}function L0(e){return e.split("?")[0]??e}function $0(e){return e===ks||e.startsWith(`${ks}?`)||e.startsWith(`${ks}/`)}function nM(e){return e===ks||e.startsWith(`${ks}/`)}function sd(e){return e===sl||e.startsWith(`${sl}/`)}function sM(e){return e.toLowerCase().endsWith("/chat/completions")}function rM(e){return e.toLowerCase().endsWith("/responses")}function oM(e,t){const n=t?.toLowerCase();if(n!==void 0&&n.includes("deepseek"))return!0;try{return new URL(e).hostname.toLowerCase().includes("deepseek")}catch{return e.toLowerCase().includes("deepseek")}}function D0(e){try{const t=new URL(e),n=t.pathname.replace(/\/+$/,"");return t.hostname==="open.bigmodel.cn"&&(n==="/api/paas/v4"||n==="/api/coding/paas/v4")}catch{return!1}}function aa(e){return e!==void 0&&e.trim()!==""}function rd(e){const t=aa(e?.anthropicBaseUrl),n=aa(e?.openaiBaseUrl),s=aa(e?.openaiResponsesBaseUrl);return{anthropic:t,openai:n||s,openaiChat:n,openaiResponses:s}}function la(e,t,n){if(!e)return n?"":void 0;const s=t.trim();return s===""?void 0:s}const od=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],id=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],qr=QP,Hr=ks,Wr=sl,iM={deepseek:{openaiBaseUrl:"https://api.deepseek.com"},minimax:{anthropicBaseUrl:"https://api.minimaxi.com/anthropic",openaiBaseUrl:"https://api.minimaxi.com",openaiResponsesBaseUrl:"https://api.minimaxi.com",apiDocsUrl:"https://platform.minimaxi.com/docs/api-reference/api-overview"},"zhipu coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"glm coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"bigmodel coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"z.ai coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"zai coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},zhipu:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},zhipuai:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},bigmodel:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},"z.ai":{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},zai:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},glm:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},alibaba:{openaiBaseUrl:"https://dashscope.aliyuncs.com/compatible-mode"}},ad=["MiniMax M3","MiniMax M2.7","MiniMax M2.7-highspeed","MiniMax M2.5","MiniMax M2.5-highspeed","MiniMax M2.1","MiniMax M2.1-highspeed","MiniMax M2"],ld=["qwen3.6-plus","qwen3.7-max"],cd=["glm-5.2","glm-5.1","glm-5","glm-5-turbo","glm-4.7","glm-4.7-flashx","glm-4.6","glm-4.5","glm-4.5-air","glm-4.5-x","glm-4.5-airx","glm-4.5-flash"],rl="__unset__",Ao="__custom__",F0=[{value:"32K",label:"Small"},{value:"64K",label:"Standard"},{value:"128K",label:"Medium"},{value:"200K",label:"Long"},{value:"256K",label:"Extended"},{value:"512K",label:"Large"},{value:"1M",label:"Max"}];function $n(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function ud(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function U0(e,t){const n=ud(t);return e?.modelMetadata?.find(s=>ud(s.model)===n)??null}function B0(e){const t=uo(e);if(t===null)return null;for(const n of F0)if(uo(n.value)===t)return n.value;return null}function aM(e){return e.trim()===""?"unset":B0(e)!==null?"preset":"custom"}function lM(e){switch(e.contextWindowMode){case"unset":return rl;case"custom":return Ao;case"preset":return B0(e.contextWindow)??Ao}}function ca(e){const t=e.trim().replaceAll(",","");if(t==="")return{amount:"",unit:"K"};const n=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(t);if(n===null)return{amount:t,unit:"K"};const s=n[1];if(s===void 0)return{amount:t,unit:"K"};const o=n[2];if(o===void 0||o==="")return{amount:s,unit:"tokens"};switch(o.toLowerCase()){case"k":return{amount:s,unit:"K"};case"m":return{amount:s,unit:"M"};default:return{amount:t,unit:"K"}}}function dd(e,t){const n=e.trim();if(n==="")return"";switch(t){case"K":return`${n}K`;case"M":return`${n}M`;case"tokens":return n}}function fd(e,t){return t.map(n=>{const s=U0(e,n),o=s?.contextWindow!==void 0?Og(s.contextWindow):"";return{contextWindow:o,contextWindowMode:aM(o),outputLimit:s?.outputLimit?.toString()??""}})}function pd(e){const t=e.trim();if(t==="")return null;const n=Number(t);return!Number.isInteger(n)||n<=0?null:n}function us(e,t){if(e===void 0)return"";const n=e.trim(),s=n.replace(/\/+$/,"");return s.endsWith(t)?s.slice(0,-t.length).replace(/\/+$/,""):n}function cM(e,t,n){const s=e.trim();return s===""?null:tM(s,t,{providerName:n})}function ua({baseUrl:e,endpoint:t,providerName:n}){const s=cM(e,t,n);return s===null?null:r.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs",children:[r.jsx("div",{className:"text-muted-foreground",children:"Final URL"}),r.jsx("div",{className:"break-all font-mono text-foreground",children:s.finalUrl}),s.diagnostics.length>0&&r.jsx("div",{className:"mt-2 space-y-1",children:s.diagnostics.map(o=>r.jsx("div",{className:o.severity==="warning"?"text-amber-200":"text-muted-foreground",children:o.message},`${o.severity}:${o.message}`))})]})}function uM({provider:e,onSubmit:t,onCancel:n}){const s=rd(e),[o,i]=c.useState(e?.name??""),[a,l]=c.useState(""),[u,d]=c.useState(!1),[f,p]=c.useState(!1),m=e?.models,[h,g]=c.useState(m!==void 0&&m.length>0?m:[""]),[y,b]=c.useState(()=>fd(e,m!==void 0&&m.length>0?m:[""])),[w,v]=c.useState(s.anthropic),[j,S]=c.useState(s.openai),[k,_]=c.useState(s.openaiChat),[C,I]=c.useState(s.openaiResponses),[A,P]=c.useState(us(e?.anthropicBaseUrl,qr)),[N,M]=c.useState(us(e?.openaiBaseUrl,Hr)),[F,B]=c.useState(us(e?.openaiResponsesBaseUrl,Wr)),[J,K]=c.useState(e?.apiDocsUrl??""),[W,V]=c.useState(e?.modelMetadataUrl??""),[z,X]=c.useState(e?.source),[Y,we]=c.useState({}),[he,oe]=c.useState(!1),[D,Ne]=c.useState(null),te=c.useRef([]);c.useEffect(()=>{if(D===null)return;const E=D;function L(Z){if(!(Z.target instanceof Node))return;const ie=te.current[E];ie!=null&&!ie.contains(Z.target)&&Ne(null)}return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[D]);const[je,ke]=c.useState(!1),[ue,le]=c.useState(!1),[xe,Se]=c.useState(!1),ve=o.toLowerCase().includes("minimax"),Ze=o.toLowerCase().includes("alibaba"),Be=[...od,...id].some(E=>o.toLowerCase().includes(E)),Ke=ve?ad:Be?cd:Ze?ld:[],dt=e?.modelMetadata?.some(E=>E.contextWindow!==void 0)??!1;function Lt(){Pt(a).then(E=>{E&&(p(!0),setTimeout(()=>p(!1),2e3))})}c.useEffect(()=>{if(e){i(e.name),l(""),d(!1);const E=(e.models?.length??0)>0?e.models:[""];g(E),b(fd(e,E));const L=rd(e);v(L.anthropic),S(L.openai),_(L.openaiChat),I(L.openaiResponses),P(us(e.anthropicBaseUrl,qr)),M(us(e.openaiBaseUrl,Hr)),B(us(e.openaiResponsesBaseUrl,Wr)),K(e.apiDocsUrl??""),V(e.modelMetadataUrl??""),X(e.source),ke(!1),le(!1),Se(!1)}},[e]),c.useEffect(()=>{const E=o.toLowerCase();for(const[L,Z]of Object.entries(iM))if(E.includes(L)){Z.anthropicBaseUrl!==void 0&&!je&&P(Z.anthropicBaseUrl),Z.openaiBaseUrl!==void 0&&!ue&&M(Z.openaiBaseUrl),Z.openaiResponsesBaseUrl!==void 0&&!xe&&B(Z.openaiResponsesBaseUrl),Z.apiDocsUrl!==void 0&&!J&&K(Z.apiDocsUrl),L==="minimax"&&h.length===1&&h[0]===""&&g([ad[0]??""]),L==="alibaba"&&h.length===1&&h[0]===""&&g([ld[0]??""]),(od.includes(L)||id.includes(L))&&h.length===1&&h[0]===""&&g([cd[0]??""]);break}},[o]);function Ct(){const E={};return o.trim()||(E.name="Name is required"),e===void 0&&!a.trim()&&(E.apiKey="API key is required"),(h.length===0||h.every(L=>!L.trim()))&&(E.models="At least one model is required"),!w&&!j&&(E.capabilities="Select at least one API capability"),j&&!k&&!C&&(E.openaiCapabilities="Select Chat Completions, Responses, or both"),w&&(A.trim()===""?E.anthropicBaseUrl="Anthropic base URL is required":Ye(A.trim())||(E.anthropicBaseUrl="Invalid URL format")),j&&k&&(N.trim()===""?E.openaiBaseUrl="OpenAI Chat base URL is required":Ye(N.trim())||(E.openaiBaseUrl="Invalid URL format")),j&&C&&(F.trim()===""?E.openaiResponsesBaseUrl="OpenAI Responses base URL is required":Ye(F.trim())||(E.openaiResponsesBaseUrl="Invalid URL format")),W.trim()&&!Ye(W.trim())&&(E.modelMetadataUrl="Invalid URL format"),y.forEach((L,Z)=>{const ie=uo(L.contextWindow),de=pd(L.outputLimit);L.contextWindow.trim()!==""&&ie===null&&(E[`modelMetadata.${Z}.contextWindow`]="Context window must be a positive number, optionally using K or M"),L.outputLimit.trim()!==""&&de===null&&(E[`modelMetadata.${Z}.outputLimit`]="Output limit must be a positive integer"),ie!==null&&de!==null&&de>ie&&(E[`modelMetadata.${Z}.outputLimit`]="Output limit should not exceed context window")}),we(E),Object.keys(E).length===0}function Ye(E){try{return new URL(E),!0}catch{return!1}}function Ie(E,L){g(Z=>{const ie=[...Z];return ie[E]=L,ie})}function Oe(E,L){b(Z=>{const ie=[...Z];return ie[E]={...ie[E]??$n(),...L},ie})}function q(E,L){switch(L){case rl:Oe(E,{contextWindow:"",contextWindowMode:"unset"});return;case Ao:{const Z=y[E]??$n();Oe(E,{contextWindow:Z.contextWindow,contextWindowMode:"custom"});return}default:Oe(E,{contextWindow:L,contextWindowMode:"preset"});return}}function ne(E,L){const Z=y[E]??$n(),ie=ca(Z.contextWindow);Oe(E,{contextWindow:dd(L,ie.unit),contextWindowMode:"custom"})}function Ee(E,L){const Z=y[E]??$n(),ie=ca(Z.contextWindow);switch(L){case"K":case"M":case"tokens":Oe(E,{contextWindow:dd(ie.amount,L),contextWindowMode:"custom"});return;default:return}}function me(E){g(L=>L.filter((Z,ie)=>ie!==E)),b(L=>L.filter((Z,ie)=>ie!==E))}function be(){g(E=>[...E,""]),b(E=>[...E,$n()])}function ze(){const E=new Date().toISOString(),L=[];return h.forEach((Z,ie)=>{const de=Z.trim();if(de==="")return;const se=y[ie]??$n(),ye=uo(se.contextWindow),ce=pd(se.outputLimit);if(ye===null&&ce===null)return;const ft=U0(e,de);if(ft!==null&&ft.contextWindow===(ye??void 0)&&ft.outputLimit===(ce??void 0)){L.push({...ft,model:de});return}const In={model:de,source:"manual",updatedAt:E};ye!==null&&(In.contextWindow=ye),ce!==null&&(In.outputLimit=ce),L.push(In)}),L.length>0?L:e?.modelMetadata!==void 0?[]:void 0}function G(E){if(E.preventDefault(),!Ct())return;oe(!0);const L=e!==void 0;try{t({name:o.trim(),apiKey:a.trim(),models:h.map(Z=>Z.trim()).filter(Z=>Z!==""),anthropicBaseUrl:la(w,A,L),openaiBaseUrl:la(j&&k,N,L),openaiResponsesBaseUrl:la(j&&C,F,L),apiDocsUrl:J.trim()||void 0,modelMetadataUrl:W.trim()||void 0,modelMetadata:ze(),source:z})}finally{oe(!1)}}return r.jsxs("form",{onSubmit:G,className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",r.jsx("span",{className:"text-destructive",children:"*"})]}),r.jsx("input",{id:"provider-name",type:"text",value:o,onChange:E=>i(E.target.value),placeholder:"Provider Name",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),Y.name!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.name})]}),r.jsxs("fieldset",{className:"space-y-3",children:[r.jsxs("legend",{className:"text-sm font-medium",children:["Capabilities ",r.jsx("span",{className:"text-destructive",children:"*"})]}),r.jsxs("div",{className:"divide-y divide-border overflow-hidden rounded-md border border-border",children:[r.jsxs("div",{className:j?"bg-primary/[0.04] px-3 py-3":"px-3 py-3",children:[r.jsxs("label",{htmlFor:"provider-capability-openai",className:"flex cursor-pointer items-start gap-3",children:[r.jsx("input",{id:"provider-capability-openai",type:"checkbox",checked:j,onChange:E=>S(E.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block text-sm font-medium",children:"OpenAI"}),r.jsx("span",{className:"block text-xs text-muted-foreground",children:"Chat Completions and Responses"})]})]}),j&&r.jsxs("div",{className:"ml-7 mt-3 flex flex-wrap gap-x-5 gap-y-2 border-t border-border/70 pt-3",children:[r.jsxs("label",{htmlFor:"provider-capability-openai-chat",className:"flex cursor-pointer items-center gap-2 text-sm",children:[r.jsx("input",{id:"provider-capability-openai-chat",type:"checkbox",checked:k,onChange:E=>_(E.target.checked),className:"size-4 shrink-0 accent-primary"}),"Chat Completions"]}),r.jsxs("label",{htmlFor:"provider-capability-openai-responses",className:"flex cursor-pointer items-center gap-2 text-sm",children:[r.jsx("input",{id:"provider-capability-openai-responses",type:"checkbox",checked:C,onChange:E=>I(E.target.checked),className:"size-4 shrink-0 accent-primary"}),"Responses"]})]}),Y.openaiCapabilities!==void 0&&j&&r.jsx("p",{className:"ml-7 mt-2 text-xs text-destructive",children:Y.openaiCapabilities})]}),r.jsxs("label",{htmlFor:"provider-capability-anthropic",className:`flex cursor-pointer items-start gap-3 px-3 py-3 ${w?"bg-primary/[0.04]":""}`,children:[r.jsx("input",{id:"provider-capability-anthropic",type:"checkbox",checked:w,onChange:E=>v(E.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block text-sm font-medium",children:"Anthropic"}),r.jsx("span",{className:"block text-xs text-muted-foreground",children:"Messages"})]})]})]}),Y.capabilities!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.capabilities})]}),(w||j&&(k||C))&&r.jsxs("section",{className:"space-y-5 border-l border-border pl-4","aria-label":"API endpoints",children:[r.jsx("h3",{className:"text-sm font-medium",children:"Endpoint Configuration"}),w&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:["Anthropic Messages Base URL ",r.jsx("span",{className:"text-destructive",children:"*"})]}),r.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[r.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:A,onChange:E=>{ke(!0),P(E.target.value)},placeholder:"https://api.anthropic.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("span",{className:"shrink-0 select-none border-l border-white/10 bg-white/[0.04] px-3 py-2 font-mono text-xs text-muted-foreground",children:qr})]}),Y.anthropicBaseUrl!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.anthropicBaseUrl}),r.jsx(ua,{baseUrl:A,endpoint:qr,providerName:o})]}),j&&k&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:["OpenAI Chat Base URL ",r.jsx("span",{className:"text-destructive",children:"*"})]}),r.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[r.jsx("input",{id:"provider-openai-base-url",type:"text",value:N,onChange:E=>{le(!0),M(E.target.value)},placeholder:"https://api.openai.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("span",{className:"shrink-0 select-none border-l border-white/10 bg-white/[0.04] px-3 py-2 font-mono text-xs text-muted-foreground",children:Hr})]}),Y.openaiBaseUrl!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.openaiBaseUrl}),r.jsx(ua,{baseUrl:N,endpoint:Hr,providerName:o})]}),j&&C&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{htmlFor:"provider-openai-responses-base-url",className:"text-sm font-medium",children:["OpenAI Responses Base URL ",r.jsx("span",{className:"text-destructive",children:"*"})]}),r.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[r.jsx("input",{id:"provider-openai-responses-base-url",type:"text",value:F,onChange:E=>{Se(!0),B(E.target.value)},placeholder:"https://api.openai.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("span",{className:"shrink-0 select-none border-l border-white/10 bg-white/[0.04] px-3 py-2 font-mono text-xs text-muted-foreground",children:Wr})]}),Y.openaiResponsesBaseUrl!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.openaiResponsesBaseUrl}),r.jsx(ua,{baseUrl:F,endpoint:Wr,providerName:o})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),r.jsxs("select",{id:"provider-source",value:z??"",onChange:E=>X(E.target.value==="company"||E.target.value==="personal"?E.target.value:void 0),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",children:[r.jsx("option",{value:"",children:"Unspecified"}),r.jsx("option",{value:"personal",children:"个人 (Personal)"}),r.jsx("option",{value:"company",children:"公司 (Company)"})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{htmlFor:"provider-model-metadata-url",className:"text-sm font-medium",children:"Model Metadata URL"}),r.jsx("input",{id:"provider-model-metadata-url",type:"text",value:W,onChange:E=>V(E.target.value),placeholder:"https://example.com/agent-inspector-models.json",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),Y.modelMetadataUrl!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.modelMetadataUrl}),W.trim()===""&&r.jsx("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs text-muted-foreground",children:"Built-in limits cover DeepSeek v4 pro/flash, MiniMax M3/M2.7/M2.5/M2.1, and GLM coding models. Use a registry URL for private or custom model limits."}),e!==void 0&&!dt&&W.trim()===""&&r.jsx("p",{className:"text-xs text-amber-400",children:"This provider has no matching context metadata yet."}),W.trim()!==""&&r.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent Inspector will refresh model limits from this JSON registry after save."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",e===void 0&&r.jsx("span",{className:"text-destructive",children:"*"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{id:"provider-apikey",type:u?"text":"password",value:a,onChange:E=>l(E.target.value),placeholder:e===void 0?"sk-ant-...":"Leave blank to keep current key",className:"flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("button",{type:"button",onClick:()=>d(E=>!E),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":u?"Hide API key":"Show API key",children:u?r.jsx(zw,{className:"size-4"}):r.jsx(fp,{className:"size-4"})}),r.jsx("button",{type:"button",onClick:Lt,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:f?r.jsx(Ge,{className:"size-4 text-cyan-300"}):r.jsx(Ot,{className:"size-4"})})]}),e!==void 0&&a.trim()===""&&r.jsx("p",{className:"text-xs text-muted-foreground",children:"A key is configured. Enter a new value only to rotate it."}),Y.apiKey!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.apiKey})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{className:"text-sm font-medium",children:["Models ",r.jsx("span",{className:"text-destructive",children:"*"})]}),h.map((E,L)=>{const Z=y[L]??$n(),ie=Y[`modelMetadata.${L}.contextWindow`],de=Y[`modelMetadata.${L}.outputLimit`],se=lM(Z),ye=ca(Z.contextWindow);return r.jsxs("div",{ref:ce=>{te.current[L]=ce},className:"border border-border bg-card shadow-sm space-y-2 rounded-[8px] p-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("input",{type:"text",value:E,onChange:ce=>Ie(L,ce.target.value),placeholder:Ke.length>0?"Type or select a model...":"Model name",className:"w-full rounded-md border border-input bg-background px-4 py-3 pr-8 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),Ke.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>Ne(D===L?null:L),className:"absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors p-1 z-10","aria-label":"Show model suggestions",children:r.jsx(nt,{className:"size-4"})}),D===L&&r.jsx("div",{className:"bg-popover text-popover-foreground absolute left-0 right-0 top-full z-50 mt-1 max-h-48 overflow-y-auto rounded-md border shadow-md",children:Ke.map(ce=>r.jsx("button",{type:"button",onClick:()=>{Ie(L,ce),Ne(null)},className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-white/[0.06]",children:ce},ce))})]})]}),h.length>1&&r.jsx("button",{type:"button",onClick:()=>me(L),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M3 6h18"}),r.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),r.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]}),r.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[r.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Context Window"}),r.jsxs(Zn,{value:se,onValueChange:ce=>q(L,ce),children:[r.jsx(Kn,{size:"sm",className:"w-full bg-background font-mono text-xs",children:r.jsx(Is,{})}),r.jsxs(Gn,{className:"max-h-64",children:[r.jsx(Qe,{value:rl,children:"Not set"}),F0.map(ce=>r.jsxs(Qe,{value:ce.value,children:[ce.label," · ",ce.value]},ce.value)),r.jsx(Qe,{value:Ao,children:"Custom"})]})]}),Z.contextWindowMode==="custom"&&r.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_5.75rem] gap-1.5",children:[r.jsx("input",{type:"text",inputMode:"decimal",value:ye.amount,onChange:ce=>ne(L,ce.target.value),placeholder:"128",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),r.jsxs(Zn,{value:ye.unit,onValueChange:ce=>Ee(L,ce),children:[r.jsx(Kn,{size:"sm",className:"w-full bg-background font-mono text-xs",children:r.jsx(Is,{})}),r.jsxs(Gn,{children:[r.jsx(Qe,{value:"K",children:"K"}),r.jsx(Qe,{value:"M",children:"M"}),r.jsx(Qe,{value:"tokens",children:"tokens"})]})]})]}),ie!==void 0&&r.jsx("span",{className:"block text-destructive",children:ie})]}),r.jsxs("label",{className:"space-y-1 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Output Limit"}),r.jsx("input",{type:"number",min:1,step:1e3,value:Z.outputLimit,onChange:ce=>Oe(L,{outputLimit:ce.target.value}),placeholder:"e.g. 8192",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),de!==void 0&&r.jsx("span",{className:"block text-destructive",children:de})]})]})]},L)}),r.jsx("button",{type:"button",onClick:be,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),Y.models!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.models})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),r.jsx("input",{id:"provider-api-docs-url",type:"text",value:J,onChange:E=>K(E.target.value),placeholder:"https://api.example.com/docs",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),r.jsxs("div",{className:"border border-border bg-background/95 shadow-sm sticky bottom-0 flex justify-end gap-2 rounded-[8px] px-3 py-2",children:[r.jsx(ee,{type:"button",variant:"outline",onClick:n,disabled:he,children:"Cancel"}),r.jsx(ee,{type:"submit",disabled:he,children:he?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const dM=pe(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),fM=T({message:x(),type:dM,details:x().optional(),hint:x().optional()}),pM=T({type:pe(["text","thinking"]),text:x().optional(),thinking:x().optional()}),mM=T({requestUrl:x().optional(),requestMethod:x().optional(),requestHeaders:We(x(),x()).optional(),requestBody:x().optional(),responseStatus:R().optional(),responseStatusText:x().optional(),responseHeaders:We(x(),x()).optional(),responseBody:x().optional()}),hM=T({success:Te(),error:fM.optional(),model:x().optional(),inputTokens:R().optional(),outputTokens:R().optional(),cacheCreationInputTokens:R().optional(),cacheReadInputTokens:R().optional(),latencyMs:R().optional(),firstChunkMs:R().nullable().optional(),totalStreamMs:R().nullable().optional(),tokensPerSecond:R().nullable().optional(),content:H(pM).optional(),rawResponse:x().optional(),streaming:Te().optional(),streamingChunks:T({chunks:H(Lf),truncated:Te().default(!1)}).optional(),requestHeaders:We(x(),x()).optional(),debug:mM.optional()}),md=At([hM,T({notConfigured:ae(!0)}),T({testing:ae(!0)})]),yn=T({nonStreaming:md,streaming:md});function Oo(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const gM=T({anthropic:yn,openai:yn.optional(),openaiChat:yn.optional(),openaiResponses:yn.optional()}).transform(e=>{const t=e.openaiChat??e.openai??Oo();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??Oo()}}),xM=T({anthropic:yn,openai:yn.optional(),openaiChat:yn.optional(),openaiResponses:yn.optional(),models:We(x(),gM).optional(),testedAt:x().optional()}).transform(e=>{const t=e.openaiChat??e.openai??Oo();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??Oo()}});function bM(){return{anthropic:{nonStreaming:{testing:!0},streaming:{testing:!0}},openai:{nonStreaming:{testing:!0},streaming:{testing:!0}},openaiChat:{nonStreaming:{testing:!0},streaming:{testing:!0}},openaiResponses:{nonStreaming:{testing:!0},streaming:{testing:!0}}}}function hd(e,t){const n=()=>({nonStreaming:{success:!1,error:{message:e,type:t}},streaming:{notConfigured:!0}});return{anthropic:n(),openai:n(),openaiChat:n(),openaiResponses:n()}}const vM=T({providerConfig:x()}),yM=T({success:Te().optional(),imported:R().optional(),message:x().optional(),errors:H(x()).optional()}),wM=T({provider:wo,imported:R(),matchedModels:H(x()),missingModels:H(x()),sourceUrl:x()}),Zr="Network error: could not reach the server. Is the proxy running?",jM=5e3,kM=5e3,gd=15e3,SM=1e4,_M=2e4,NM=2e4,CM=3e4;function da(e,t){return(e?.length??0)>0?e:t&&e!==void 0?"":void 0}function xd(e,t=!1){return{name:e.name,...e.apiKey.trim()===""?{}:{apiKey:e.apiKey},models:e.models,anthropicBaseUrl:da(e.anthropicBaseUrl,t),openaiBaseUrl:da(e.openaiBaseUrl,t),openaiResponsesBaseUrl:da(e.openaiResponsesBaseUrl,t),apiDocsUrl:(e.apiDocsUrl?.length??0)>0?e.apiDocsUrl:void 0,modelMetadataUrl:(e.modelMetadataUrl?.length??0)>0?e.modelMetadataUrl:void 0,modelMetadata:e.modelMetadata,source:e.source}}function TM(e,t){const n=e?.models?.map(s=>s.trim()).filter(s=>s!=="").length??0;return Math.max(1,n)*t}async function EM(e,t){if(t.models!==void 0)try{await Un(`/api/providers/${e}/test/log`,kM,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function RM({externalProviders:e,isLoading:t=!1,externalTestResults:n,externalTestingProviders:s,externalTestingTimeLeft:o,onProvidersMutate:i,onTestResultsChange:a,onTestingProvidersChange:l,onTestingTimeLeftChange:u}){const[d,f]=c.useState(!1),[p,m]=c.useState(),[h,g]=c.useState(null),[y,b]=c.useState({}),[w,v]=c.useState(new Set),[j,S]=c.useState({}),[k,_]=c.useState(null),[C,I]=c.useState(!1),[A,P]=c.useState(null),[N,M]=c.useState(!1),[F,B]=c.useState(!1),[J,K]=c.useState(null),[W,V]=c.useState("all"),[z,X]=c.useState(new Set),{providerTestTimeoutSeconds:Y}=Rl(),we=c.useRef(null),he=c.useRef(null),oe=e??[],D=c.useMemo(()=>{const q=W==="all"?oe:oe.filter(ne=>ne.source===W);return W==="all"?[...q].sort((ne,Ee)=>{const me={personal:0,company:1};return(me[ne.source??""]??2)-(me[Ee.source??""]??2)}):q},[oe,W]),Ne=n??y,te=s??w,je=o??j,ke=u?(q,ne)=>u(q,ne):(q,ne)=>{S(ne===void 0?Ee=>{const me={...Ee};return delete me[q],me}:Ee=>({...Ee,[q]:ne}))};c.useEffect(()=>{(async()=>{try{const q=await qe("/api/config/paths",vM,jM);_(q.providerConfig)}catch{}})()},[]);const ue=c.useCallback(q=>{he.current!==null&&clearTimeout(he.current),P(q),we.current?.scrollTo({top:we.current.scrollHeight,behavior:"smooth"}),he.current=setTimeout(()=>{P(null),he.current=null},2e3)},[]);c.useEffect(()=>()=>{he.current!==null&&clearTimeout(he.current)},[]);const le=c.useCallback(()=>{i?.().catch(()=>{})},[i]),xe=c.useCallback((q,ne)=>{a?a(q,ne):b(Ee=>({...Ee,[q]:ne}))},[a]),Se=c.useCallback((q,ne)=>{if(l){l(q,ne);return}v(Ee=>{const me=new Set(Ee);return ne?me.add(q):me.delete(q),me})},[l]),ve=c.useCallback(async q=>{xe(q,bM()),Se(q,!0);const ne=new AbortController,Ee=oe.find(G=>G.id===q),me=TM(Ee,Y);let be=me;ke(q,be);const ze=setInterval(()=>{be--,ke(q,be),be<=0&&(clearInterval(ze),ne.abort())},1e3);try{const G=await qe(`/api/providers/${q}/test`,xM,me*1e3+1e3,{method:"POST",signal:ne.signal},E=>`HTTP ${E.status}: ${E.statusText}`);xe(q,G),await EM(q,G)}catch(G){const E=G instanceof Error&&G.name==="AbortError",L=G instanceof Zo;E||L?xe(q,hd("Request timed out","timeout")):G instanceof Error&&xe(q,hd(G.message,"server_error"))}finally{clearInterval(ze),ke(q,void 0),Se(q,!1)}},[Y,oe,ke,xe,Se]),Ze=c.useCallback(async(q,ne,Ee=!0)=>{X(me=>{const be=new Set(me);return be.add(q),be});try{const me=ne!==void 0&&ne.trim()!==""?{url:ne}:{},be=await qe(`/api/providers/${q}/model-metadata`,wM,CM,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(me)},()=>"Failed to refresh model metadata");return be.imported===0&&Ee?g("No matching model metadata found for this provider."):g(null),ue(be.provider.id),le(),be.imported>0}catch(me){return Ee&&g(me instanceof Error?me.message:Zr),!1}finally{X(me=>{const be=new Set(me);return be.delete(q),be})}},[le,ue]);function Be(q){(async()=>{try{const ne=await qe("/api/providers",wo,gd,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(xd(q))},()=>"Failed to add provider");f(!1),ue(ne.id),q.modelMetadataUrl!==void 0&&q.modelMetadataUrl.trim()!==""&&await Ze(ne.id,q.modelMetadataUrl,!1),le(),await ve(ne.id)}catch(ne){g(ne instanceof Error?ne.message:Zr)}})()}function Ke(q){p&&(async()=>{try{const ne=await qe(`/api/providers/${p.id}`,wo,gd,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(xd(q,!0))},()=>"Failed to update provider");m(void 0),ue(ne.id),q.modelMetadataUrl!==void 0&&q.modelMetadataUrl.trim()!==""&&await Ze(ne.id,q.modelMetadataUrl,!1),le(),(q.apiKey.trim()!==""||JSON.stringify(q.models)!==JSON.stringify(p.models)||(q.anthropicBaseUrl??"")!==(p.anthropicBaseUrl??"")||(q.openaiBaseUrl??"")!==(p.openaiBaseUrl??"")||(q.openaiResponsesBaseUrl??"")!==(p.openaiResponsesBaseUrl??""))&&await ve(ne.id)}catch(ne){g(ne instanceof Error?ne.message:Zr)}})()}function dt(q){K(q),B(!0)}function Lt(){const q=J;q!==null&&(async()=>{let ne;try{ne=await Un(`/api/providers/${q}`,SM,{method:"DELETE"})}catch{g(Zr);return}if(!ne.ok){g(await wl(ne,"Failed to delete provider"));return}le()})()}const Ct=c.useRef(null);function Ye(q){const ne="/api/providers/export";(async()=>{try{const Ee=await Un(ne,_M);if(!Ee.ok){g("Failed to export providers");return}const me=await Ee.blob(),be=URL.createObjectURL(me),ze=document.createElement("a");ze.href=be,ze.download=Ee.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(ze),ze.click(),document.body.removeChild(ze),URL.revokeObjectURL(be)}catch{g("Failed to export providers")}})()}function Ie(){Ct.current?.click()}function Oe(q){const ne=q.target.files?.[0];ne&&(async()=>{try{const Ee=await ne.text(),me=await Un("/api/providers/import",NM,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ee)}),be=await yl(me,yM);me.ok&&be.imported!==void 0&&be.imported>0?(le(),g(null)):be.errors&&be.errors.length>0?g(be.errors.join("; ")):g(be.message??"Import failed")}catch{g("Failed to import providers")}q.target.value=""})()}return t?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):d||p?r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-3 rounded-[8px] bg-background/95 px-1 py-1 backdrop-blur",children:r.jsx("h3",{className:"text-lg font-medium",children:p?"Edit Provider":"Add New Provider"})}),r.jsx(uM,{provider:p,onSubmit:p?Ke:Be,onCancel:()=>{f(!1),m(void 0)}})]}):r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{"data-provider-toolbar":"true",className:"sticky top-0 z-10 flex min-w-0 flex-wrap items-center justify-start gap-2 rounded-[8px] bg-background/95 px-1 py-1 backdrop-blur sm:justify-end",children:[r.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>Ye(),className:"gap-1 hover:bg-muted",children:[r.jsx(mr,{className:"size-3"}),"Export"]}),r.jsxs(ee,{variant:"outline",size:"sm",onClick:Ie,className:"gap-1 hover:bg-muted",children:[r.jsx(wp,{className:"size-3"}),"Import"]}),r.jsx("input",{type:"file",ref:Ct,accept:".json",onChange:Oe,style:{display:"none"}}),r.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>M(!0),className:"gap-1",children:[r.jsx(Fj,{className:"size-3"}),"Scan"]}),r.jsxs(ee,{onClick:()=>f(!0),size:"sm",className:"gap-1",children:[r.jsx(su,{className:"size-4"}),"Add Provider"]})]}),k!==null&&r.jsxs("div",{className:"flex items-center gap-2 rounded-[8px] bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[r.jsx("span",{className:"font-mono truncate",title:k,children:k}),r.jsx("button",{type:"button",onClick:()=>{Pt(k).then(q=>{q&&(I(!0),setTimeout(()=>I(!1),2e3))})},className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-foreground","aria-label":C?"Copied config file path":"Copy config file path",children:C?r.jsx(Ge,{className:"size-3 text-cyan-300"}):r.jsx(Ot,{className:"size-3"})})]}),h!==null&&r.jsxs("div",{className:"border border-border bg-card shadow-sm flex items-center gap-2 rounded-[8px] px-3 py-2 text-sm text-destructive",children:[r.jsx(Ns,{className:"size-4 shrink-0"}),h]}),oe.length===0?r.jsxs("div",{className:"border border-border bg-card shadow-sm space-y-3 rounded-[8px] py-12 text-center",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),r.jsxs(ee,{onClick:()=>f(!0),variant:"outline",size:"sm",children:[r.jsx(su,{className:"size-4"}),"Add Your First Provider"]})]}):r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"inline-flex w-fit gap-1 rounded-[8px] bg-muted/20 p-1",children:["all","personal","company"].map(q=>r.jsx("button",{type:"button",onClick:()=>V(q),className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${W===q?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:q==="all"?"All":q==="personal"?"Personal":"Company"},q))}),r.jsx("div",{ref:we,className:"space-y-3",children:D.map(q=>r.jsx(XP,{provider:q,testResults:Ne[q.id],isTesting:te.has(q.id),testingTimeLeft:je[q.id],isHighlighted:q.id===A,onEdit:ne=>m(ne),onDelete:dt,onRefreshMetadata:ne=>{Ze(ne)},isRefreshingMetadata:z.has(q.id),onTest:ne=>{ve(ne)}},q.id))})]}),r.jsx(TP,{open:N,onOpenChange:M,onImportComplete:()=>{i!==void 0&&i()}}),r.jsx(Hh,{open:F,onOpenChange:B,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:Lt})]})}const PM=[{value:"providers",label:"Providers"},{value:"proxy",label:"Proxy"},{value:"storage",label:"Storage"},{value:"mcp",label:"MCP"},{value:"onboarding",label:"Onboarding"}];function MM(){return r.jsx(f0,{"aria-label":"Settings sections",className:"grid w-full grid-cols-3 justify-stretch gap-1 bg-muted/35 p-1 group-data-[orientation=horizontal]/tabs:h-auto sm:grid-cols-5",children:PM.map(e=>r.jsx(xn,{value:e.value,className:"min-w-0 w-full",children:e.label},e.value))})}function IM(){const[e,t]=c.useState(!1),[n,s]=c.useState("providers"),{providers:o,isLoading:i,mutate:a}=zl(),[l,u]=c.useState({}),[d,f]=c.useState(new Set),[p,m]=c.useState({}),h=c.useCallback((b,w)=>{u(v=>({...v,[b]:w}))},[]),g=c.useCallback((b,w)=>{f(v=>{const j=new Set(v);return w?j.add(b):j.delete(b),j})},[]),y=c.useCallback((b,w)=>{m(v=>{if(w===void 0){const j={...v};return delete j[b],j}return{...v,[b]:w}})},[]);return r.jsxs(Zt,{open:e,onOpenChange:t,children:[r.jsx(yr,{asChild:!0,children:r.jsxs(ee,{variant:"ghost",size:"icon",className:ji,"aria-label":"Settings",title:"Settings",children:[r.jsx(Zj,{className:"size-4"}),r.jsx("span",{className:"sr-only",children:"Settings"})]})}),r.jsxs(Kt,{className:"flex max-h-[calc(100vh-1rem)] w-[calc(100%-1rem)] max-w-2xl flex-col overflow-hidden p-4 sm:max-h-[80vh] sm:p-6",children:[r.jsx(Xt,{children:r.jsx(Qt,{children:"Settings"})}),r.jsxs(d0,{value:n,onValueChange:s,className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:[r.jsx(MM,{}),r.jsxs("div",{className:"mt-4 min-w-0 flex-1 overflow-x-hidden overflow-y-auto pr-1 sm:pr-2",children:[r.jsx(jt,{value:"providers",children:r.jsx(RM,{externalProviders:o,isLoading:i,externalTestResults:l,externalTestingProviders:d,externalTestingTimeLeft:p,onProvidersMutate:()=>a(),onTestResultsChange:h,onTestingProvidersChange:g,onTestingTimeLeftChange:y})}),r.jsx(jt,{value:"proxy",children:r.jsx(DM,{})}),r.jsx(jt,{value:"storage",children:r.jsx(zM,{})}),r.jsx(jt,{value:"mcp",children:r.jsx($M,{})}),r.jsx(jt,{value:"onboarding",children:r.jsx(LM,{})})]})]})]})]})}const AM=T({memoryCount:R(),logDir:x(),logFileCount:R(),logBytes:R(),chunkDir:x(),chunkFileCount:R(),chunkBytes:R(),sessionArchiveDir:x(),sessionArchiveFileCount:R(),sessionArchiveBytes:R()}),OM=1e4;function fa(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(1)} GiB`}function zM(){const[e,t]=c.useState(null),[n,s]=c.useState(null),[o,i]=c.useState(!1),[a,l]=c.useState(null),u=c.useCallback(async()=>{i(!0),s(null);try{const f=await qe("/api/logs?stats=1",AM,OM,void 0,p=>`Failed to load storage stats: HTTP ${String(p.status)}`);t(f)}catch(f){s(f instanceof Error?f.message:String(f))}finally{i(!1)}},[]);c.useEffect(()=>{u()},[u]);const d=c.useCallback((f,p)=>{Pt(p).then(m=>{m&&(l(f),setTimeout(()=>l(null),1600))})},[]);return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Log storage"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Inspect local log and streaming chunk footprint before exporting or clearing sessions."})]}),r.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>{u()},children:o?"Refreshing...":"Refresh"})]}),e!==null&&r.jsxs("div",{className:"grid gap-2 text-xs",children:[r.jsx(Ys,{id:"log-dir",label:"Log storage path",value:e.logDir,copiedId:a,onCopy:d}),r.jsx(Ys,{id:"chunk-dir",label:"Streaming chunks storage path",value:e.chunkDir,copiedId:a,onCopy:d}),r.jsx(Ys,{id:"session-archive-dir",label:"Session archive storage path",value:e.sessionArchiveDir,copiedId:a,onCopy:d}),r.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[r.jsx("div",{className:"font-medium",children:"In-memory logs"}),r.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.memoryCount.toLocaleString()," loaded"]})]}),r.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[r.jsx("div",{className:"font-medium",children:"Log files"}),r.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.logFileCount.toLocaleString()," files / ",fa(e.logBytes)]})]}),r.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[r.jsx("div",{className:"font-medium",children:"Streaming chunks"}),r.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.chunkFileCount.toLocaleString()," files / ",fa(e.chunkBytes)]})]}),r.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[r.jsx("div",{className:"font-medium",children:"Session archives"}),r.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.sessionArchiveFileCount.toLocaleString()," files /"," ",fa(e.sessionArchiveBytes)]})]})]}),n!==null&&r.jsx("p",{className:"text-xs text-destructive",children:n})]})}function Ys({id:e,label:t,value:n,copiedId:s,onCopy:o}){const i=s===e;return r.jsxs("div",{className:"min-w-0 rounded-md border border-border/45 bg-muted/15 px-3 py-2 transition-colors hover:bg-muted/25",children:[r.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:t}),r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",title:n,children:n}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>o(e,n),"aria-label":i?`Copied ${t}`:`Copy ${t}`,children:i?r.jsx(Ge,{className:"size-3.5 text-emerald-500"}):r.jsx(Ot,{className:"size-3.5"})})]})]})}function LM(){const[e,t]=c.useState(null),n=c.useMemo(()=>typeof window>"u"?"http://localhost:9527":window.location.origin,[]),s=c.useMemo(()=>[{id:"status",label:"Check onboarding",value:"agent-inspector onboard --status"},{id:"status-json",label:"Check onboarding JSON",value:"agent-inspector onboard --status --json"},{id:"refresh",label:"Refresh generated files",value:"agent-inspector onboard --force"},{id:"uninstall",label:"Remove matching generated files",value:"agent-inspector onboard --uninstall"},{id:"claude",label:"Claude Code command",value:"/agent-inspector:onboard"},{id:"codex",label:"Codex prompt",value:"Use the agent-inspector-onboard skill"},{id:"opencode-config",label:"OpenCode config",value:"agent-inspector onboard --opencode-only"},{id:"opencode-status",label:"OpenCode status",value:"agent-inspector onboard --status --opencode-only"},{id:"opencode-verify",label:"OpenCode verify",value:"opencode mcp list"},{id:"opencode-proxy",label:"OpenCode proxy",value:`LLM_BASE_URL=${n}/proxy`},{id:"mimo-config",label:"MiMo Code config",value:"agent-inspector onboard --mimo-only"},{id:"mimo-status",label:"MiMo Code status",value:"agent-inspector onboard --status --mimo-only"},{id:"mimo-verify",label:"MiMo Code verify",value:"mimo mcp list"},{id:"mimo-proxy",label:"MiMo Code proxy",value:`OPENAI_BASE_URL=${n}/proxy`},{id:"mcp",label:"MCP URL",value:`${n}/api/mcp`},{id:"proxy",label:"Proxy URL",value:`${n}/proxy`},{id:"anthropic",label:"Anthropic base",value:`ANTHROPIC_BASE_URL=${n}/proxy`},{id:"openai",label:"OpenAI base",value:`OPENAI_BASE_URL=${n}/proxy`}],[n]),o=c.useCallback((i,a)=>{Pt(a).then(l=>{l&&(t(i),setTimeout(()=>t(null),1600))})},[]);return r.jsxs("div",{className:"min-w-0 space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Xn,{className:"size-4 text-muted-foreground"}),r.jsx("h3",{className:"text-sm font-semibold",children:"Agent onboarding"})]}),r.jsx("div",{className:"grid gap-2",children:s.map(i=>r.jsx(Ys,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:o},i.id))}),r.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ge,{className:"size-3.5 text-emerald-500"}),r.jsx("span",{children:"Provider test creates a traceable memory probe session."})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ge,{className:"size-3.5 text-emerald-500"}),r.jsx("span",{children:"Captured sessions can produce reviewable memory candidates."})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),r.jsxs("span",{children:["Streamable HTTP clients should use the MCP URL directly. Stdio-only clients should use",r.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"agent-inspector-mcp stdio"}),"instead. Configure only one entry for the same Inspector."]})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),r.jsxs("span",{children:["OpenCode onboarding safely merges"," ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode.json"}),", then verify with"," ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode mcp list"}),"."]})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),r.jsxs("span",{children:["MiMo Code onboarding safely merges"," ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mimocode.jsonc"}),", then route OpenAI-format traffic with"," ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"OPENAI_BASE_URL"}),"."]})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),r.jsx("span",{children:"If your AI tool runs in another container or host, replace localhost with an address reachable from that tool and verify the network/firewall path."})]})]})]})}function $M(){const[e,t]=c.useState(null),s=`${c.useMemo(()=>typeof window>"u"?"http://localhost:9527":window.location.origin,[])}/api/mcp`,o=c.useMemo(()=>[{id:"mcp-url",label:"Streamable HTTP MCP URL",value:s},{id:"stdio",label:"Stdio bridge command",value:`agent-inspector-mcp stdio --url ${s}`},{id:"doctor",label:"Bridge doctor",value:`agent-inspector-mcp doctor --url ${s}`},{id:"writes",label:"Enable write tools",value:"AGENT_INSPECTOR_MCP_WRITES=1 agent-inspector"},{id:"capabilities",label:"Capabilities resource",value:"inspector://mcp/capabilities"},{id:"context",label:"Current context resource",value:"inspector://context/current"},{id:"streamable-json",label:"Streamable HTTP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{type:"streamableHttp",url:s}}},null,2)},{id:"stdio-json",label:"Stdio MCP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{command:"agent-inspector-mcp",args:["stdio","--url",s]}}},null,2)},{id:"opencode-local",label:"OpenCode local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",s],enabled:!0}}},null,2)},{id:"mimo-local",label:"MiMo Code local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",s],enabled:!0}}},null,2)},{id:"codex-toml",label:"Codex TOML",value:`[mcp_servers.agent-inspector]
123
+ `);if(n===s)return{lines:[],isEmpty:!0};const o=m0(n,s);return{lines:Xa(o),isEmpty:!1}}function qu(e){try{const t=JSON.parse(e);return t===null||typeof t=="string"||typeof t=="object"?t:null}catch{return null}}function b4(e,t){const n=e??"",s=t??"";if(n===s)return{lines:[],isEmpty:!0};const o=qu(n),i=qu(s);if(o!==null&&i!==null){const l=g4(o,i)??[];if(l.length===1){const u=l[0];if(u!==void 0&&!u.added&&!u.removed)return{lines:[],isEmpty:!0}}return{lines:Xa(l),isEmpty:!1}}const a=m0(n,s);return{lines:Xa(a),isEmpty:!1}}const v4=22,Gi=1e4;function y4(e){return e==="added"?"+":e==="removed"?"-":" "}function w4(e){return e==="added"?"bg-green-500/10 text-green-700 dark:text-green-300":e==="removed"?"bg-red-500/10 text-red-700 dark:text-red-300":"text-foreground/80"}const j4=function({result:t,emptyLabel:n}){const[s,o]=c.useState("unified"),i=c.useRef(null),a=ST({count:t.lines.length,getScrollElement:()=>i.current,estimateSize:()=>v4,overscan:10});if(t.isEmpty)return r.jsx("div",{className:"rounded border border-dashed border-border bg-muted/30 px-4 py-6 text-center text-xs text-muted-foreground","data-testid":"diff-empty",children:n??"No transformation applied — raw and processed are identical."});const l=t.lines.length,u=l>Gi,d=u?t.lines.slice(0,Gi):t.lines;return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[r.jsxs("span",{children:[l.toLocaleString()," line",l===1?"":"s",u&&` (showing first ${Gi.toLocaleString()})`]}),r.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>o("unified"),"aria-pressed":s==="unified",className:$("flex items-center gap-1 px-2 py-1 transition-colors",s==="unified"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Unified diff (single column)",children:[r.jsx(zj,{className:"size-3"}),"Unified"]}),r.jsxs("button",{type:"button",onClick:()=>o("split"),"aria-pressed":s==="split",className:$("flex items-center gap-1 px-2 py-1 transition-colors border-l border-border",s==="split"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Split diff (side by side)",children:[r.jsx(Cw,{className:"size-3"}),"Split"]})]})]}),r.jsx("div",{ref:i,className:"max-h-[60vh] overflow-auto rounded border border-border bg-background font-mono text-xs","data-testid":"diff-viewport",children:s==="unified"?r.jsx(k4,{virtualizer:a,lines:d}):r.jsx(N4,{lines:d})})]})};function k4({virtualizer:e,lines:t}){return r.jsx("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:e.getVirtualItems().map(n=>{const s=t[n.index];return s===void 0?null:r.jsxs("div",{"data-index":n.index,ref:e.measureElement,className:$("flex items-start gap-3 px-2",w4(s.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${n.start}px)`},children:[r.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:s.oldLineNumber??""}),r.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:s.newLineNumber??""}),r.jsx("span",{className:$("select-none w-3 text-right font-bold",s.kind==="added"&&"text-green-600 dark:text-green-400",s.kind==="removed"&&"text-red-600 dark:text-red-400"),children:y4(s.kind)}),r.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.text})]},n.key)})})}function _4(e){const t=[];let n=0;for(;n<e.length;){const s=e[n];if(s===void 0)break;if(s.kind==="context"){t.push({left:{text:s.text,lineNumber:s.oldLineNumber},right:{text:s.text,lineNumber:s.newLineNumber},kind:"equal"}),n+=1;continue}const o=[],i=[];for(;n<e.length&&e[n]?.kind==="removed";){const l=e[n];l!==void 0&&o.push(l),n+=1}for(;n<e.length&&e[n]?.kind==="added";){const l=e[n];l!==void 0&&i.push(l),n+=1}const a=Math.max(o.length,i.length);for(let l=0;l<a;l+=1){const u=o[l],d=i[l];u!==void 0&&d!==void 0?t.push({left:{text:u.text,lineNumber:u.oldLineNumber},right:{text:d.text,lineNumber:d.newLineNumber},kind:"changed"}):u!==void 0?t.push({left:{text:u.text,lineNumber:u.oldLineNumber},right:null,kind:"removed"}):d!==void 0&&t.push({left:null,right:{text:d.text,lineNumber:d.newLineNumber},kind:"added"})}}return t}function S4(e){switch(e){case"changed":return"bg-amber-500/10";case"removed":return"bg-red-500/10";case"added":return"bg-green-500/10";case"equal":return""}}function N4({lines:e}){const t=_4(e);return r.jsx("div",{"data-testid":"diff-split",children:t.map((n,s)=>r.jsxs("div",{className:$("grid grid-cols-2 font-mono text-xs",S4(n.kind)),children:[r.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[r.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.left?.lineNumber??""}),r.jsx("span",{className:$("select-none w-3 text-right font-bold",(n.kind==="removed"||n.kind==="changed")&&"text-red-600 dark:text-red-400"),children:n.left!==null?"-":" "}),r.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.left?.text??""})]}),r.jsxs("div",{className:"flex items-start gap-2 px-2",children:[r.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.right?.lineNumber??""}),r.jsx("span",{className:$("select-none w-3 text-right font-bold",(n.kind==="added"||n.kind==="changed")&&"text-green-600 dark:text-green-400"),children:n.right!==null?"+":" "}),r.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.right?.text??""})]})]},s))})}const g0=c.memo(j4),C4=tp("inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function Se({className:e,variant:t="default",asChild:n=!1,...s}){const o=n?q5:"span";return r.jsx(o,{"data-slot":"badge","data-variant":t,className:$(C4({variant:t}),e),...s})}const T4=3;function E4({event:e}){const t=n=>{n.stopPropagation(),Is({logId:e.logId,tab:"response",toolCallIndex:e.index})};return r.jsx("button",{type:"button",className:"inline-flex h-5 min-w-0 max-w-[8.5rem] items-center rounded px-1.5 text-[10px] text-muted-foreground transition-colors hover:bg-background/65 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:t,onKeyDown:n=>n.stopPropagation(),"aria-label":`Open response tool call ${e.name}`,title:e.name,children:r.jsx("span",{className:"min-w-0 truncate font-mono font-semibold",children:e.name})})}function R4({events:e}){if(e.length===0)return null;const t=e.slice(0,T4),n=Math.max(0,e.length-t.length);return r.jsxs("span",{className:"inline-flex h-7 min-w-0 max-w-full items-center gap-1 overflow-hidden rounded-md border border-cyan-300/10 bg-cyan-300/[0.055] px-1 sm:max-w-[26rem]",role:"group","aria-label":`${e.length} response tool ${e.length===1?"call":"calls"}`,onClick:s=>s.stopPropagation(),onKeyDown:s=>s.stopPropagation(),children:[r.jsxs("span",{className:"inline-flex h-5 shrink-0 items-center gap-1 px-1 font-mono text-[9px] font-semibold uppercase text-cyan-300",children:[r.jsx(hr,{className:"size-3"}),"Call ",e.length]}),r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden",children:[t.map(s=>r.jsx(E4,{event:s},s.id)),n>0&&r.jsxs("span",{className:"inline-flex h-5 shrink-0 items-center rounded px-1 font-mono text-[10px] font-semibold text-muted-foreground",children:["+",n]})]})]})}const P4={success:"bg-slate-300/[0.08] text-slate-100 border-transparent",client_error:"bg-amber-300/[0.10] text-amber-100 border-transparent",server_error:"bg-rose-400/[0.10] text-rose-100 border-transparent",pending:"bg-cyan-300/[0.08] text-cyan-100 border-transparent"},I4={success:{frame:"border-cyan-200/15 bg-white/[0.04] text-slate-100"},client_error:{frame:"border-amber-300/25 bg-amber-300/[0.08] text-amber-100"},server_error:{frame:"border-rose-300/25 bg-rose-300/[0.08] text-rose-100"},pending:{frame:"border-cyan-300/25 bg-cyan-300/[0.08] text-cyan-100"}},qs="border border-transparent bg-white/[0.045] hover:bg-white/[0.075] size-8 text-muted-foreground shadow-none hover:text-cyan-100",Et="bg-white/[0.045] flex h-7 items-center gap-1 rounded-md px-2 text-xs";function Hs(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function M4(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function A4(e,t){switch(e){case"success":return t===null?"OK":String(t);case"client_error":return t===null?"WARN":String(t);case"server_error":return t===null?"FAIL":String(t);case"pending":return"ROLL"}}function Hu({trend:e}){if(e===null)return null;const t=e.direction==="up",n=t?Uy:Oy,s=t?"+":"-";return r.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[r.jsx(n,{className:t?"size-3 text-cyan-300":"size-3 text-rose-400"}),r.jsxs("span",{className:"font-mono",children:[s,Ie(e.delta)]})]})}const O4=c.memo(function({log:e,displayNumber:t,messageCount:n=null,toolCount:s=null,toolEvents:o=[],expanded:i,onToggle:a,cacheTrend:l=null,activeTab:u,tabActions:d,onReplay:p,slowResponseThresholdSeconds:f=0,showClientMetadata:m=!0,timeDisplayFormat:h}){const g=Ag(e.responseStatus),y=e.elapsedMs!==null&&f>0&&e.elapsedMs>f*1e3,b=e.inputTokens!==null||e.outputTokens!==null,w=e.firstChunkMs??null,v=e.tokensPerSecond??null,j=w===null?null:Hs(w),_=v===null||v<=0?null:M4(v),k=e.warnings?.length??0,S=e.clientPid!==null&&e.clientPid!==void 0,C=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="";e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd;const M=I4[g],A=A4(g,e.responseStatus),P=g!=="success"||e.responseStatus!==200,N=e.streaming&&j===null&&_===null;return r.jsx(Ds,{children:r.jsxs("div",{id:`log-${e.id}`,role:"button",tabIndex:0,"data-nav-id":`log-${e.id}`,"data-nav-action":i?"collapse":"expand",className:$("group/header relative isolate flex min-w-0 cursor-pointer items-start gap-2 overflow-hidden px-3 py-2 transition-[background-color,border-color,box-shadow]",i?"bg-white/[0.04]":"bg-transparent hover:bg-white/[0.035]","select-none","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),onClick:a,onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),a())},children:[r.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:$("inline-flex h-8 shrink-0 items-center rounded-md px-2 font-mono",M.frame),children:r.jsxs("span",{className:"text-xs font-semibold tabular-nums",title:`Log ID ${String(e.id)}`,children:["#",t]})}),r.jsxs("span",{className:"bg-white/[0.045] flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-xs text-muted-foreground",children:[r.jsx(rn,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:Ea(e.timestamp,h)})]}),P&&r.jsxs(Se,{variant:"outline",className:$("h-6 gap-1 rounded-md px-2 py-0 font-mono text-[10px] font-semibold uppercase tabular-nums shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]",P4[g]),children:[g==="success"?r.jsx(Ge,{className:"size-3","aria-label":"Success"}):g==="server_error"?r.jsx(wj,{className:"size-3","aria-label":"Server error"}):g==="client_error"?r.jsx(wn,{className:"size-3","aria-label":"Client error"}):r.jsx(Ue,{className:"size-3 animate-spin","aria-label":"Pending"}),A]}),k>0&&r.jsxs(ft,{children:[r.jsx(mt,{asChild:!0,children:r.jsxs(Se,{variant:"outline",className:"h-6 gap-1 rounded-md border-amber-300/30 bg-amber-300/[0.10] px-2 py-0 font-mono text-[10px] tabular-nums text-amber-100",children:[r.jsx(wn,{className:"size-3","aria-label":"Tool schema warnings"}),k]})}),r.jsx(ht,{children:k===1?"1 tool schema warning":`${k} tool schema warnings`})]}),e.elapsedMs!==null&&(y?r.jsxs(ft,{children:[r.jsx(mt,{asChild:!0,children:r.jsxs("span",{className:$(Et,"shrink-0 border-amber-300/25 text-amber-200"),children:[r.jsx(rn,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:Hs(e.elapsedMs)}),r.jsx(wn,{className:"size-3","aria-label":"Slow response"})]})}),r.jsxs(ht,{children:["Slow response: ",Hs(e.elapsedMs)," exceeds"," ",Hs(f*1e3)]})]}):r.jsxs("span",{className:$(Et,"shrink-0 text-muted-foreground"),children:[r.jsx(rn,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:Hs(e.elapsedMs)})]})),e.streaming&&j!==null&&r.jsxs("span",{className:$(Et,"shrink-0 text-cyan-300"),children:[r.jsx(ru,{className:"size-3"}),r.jsxs("span",{className:"font-mono tabular-nums",children:["first ",j]})]}),e.streaming&&_!==null&&r.jsxs("span",{className:$(Et,"shrink-0 text-cyan-300"),children:[r.jsx(Al,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:_})]}),b&&r.jsxs("span",{className:$(Et,"min-w-0 sm:shrink-0"),children:[r.jsx(rr,{className:"size-3 text-muted-foreground"}),r.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 font-mono tabular-nums",children:[r.jsxs("span",{className:$("whitespace-nowrap",e.inputTokens!==null?"text-blue-400":"text-muted-foreground"),children:["IN ",e.inputTokens!==null?Ie(e.inputTokens):"n/a"]}),r.jsx("span",{className:"text-muted-foreground",children:"/"}),r.jsxs("span",{className:$("whitespace-nowrap",e.outputTokens!==null?"text-amber-400":"text-muted-foreground"),children:["OUT ",e.outputTokens!==null?Ie(e.outputTokens):"n/a"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&r.jsxs("span",{className:$(Et,"shrink-0"),children:[r.jsx(Hu,{trend:l?.creation??null}),r.jsxs("span",{className:"font-mono tabular-nums text-cyan-300",children:["KV Cache +",Ie(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&r.jsxs("span",{className:$(Et,"shrink-0"),children:[r.jsx(Hu,{trend:l?.read??null}),r.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",Ie(e.cacheReadInputTokens)]})]}),n!==null&&r.jsxs("span",{className:$(Et,"shrink-0 text-muted-foreground"),children:[r.jsx(Go,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:n})]}),s!==null&&r.jsxs("span",{className:$(Et,"shrink-0 text-muted-foreground"),children:[r.jsx(hr,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:s})]}),r.jsx(R4,{events:o}),e.origin!==null&&r.jsxs("span",{className:$(Et,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[r.jsx(mf,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),m&&(S||C)&&r.jsxs("span",{className:$(Et,"hidden shrink-0 text-purple-300 xl:flex"),children:[r.jsx(Hw,{className:"size-3"}),C?r.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):r.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]}),N&&r.jsx(ru,{className:"size-3 shrink-0 text-muted-foreground/60"})]}),r.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[i&&r.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",onClick:I=>I.stopPropagation(),onKeyDown:I=>I.stopPropagation(),children:[d!==void 0&&u!==void 0&&(()=>{const I=d[u];return I===void 0?null:r.jsxs(r.Fragment,{children:[I.expansion!==null&&r.jsxs(ft,{children:[r.jsx(mt,{asChild:!0,children:r.jsx(ee,{variant:"outline",size:"icon",className:qs,onClick:I.expansion.onToggle,disabled:I.expansion.isPending,"aria-pressed":I.expansion.isExpanded,"aria-label":I.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:I.expansion.isExpanded?r.jsx(cw,{className:"size-3.5"}):r.jsx(sw,{className:"size-3.5"})})}),r.jsx(ht,{children:I.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),I.diffWithRaw!==void 0&&r.jsxs(ft,{children:[r.jsx(mt,{asChild:!0,children:r.jsx(ee,{variant:"outline",size:"icon",className:$(qs,I.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:I.diffWithRaw.onToggle,"aria-pressed":I.diffWithRaw.active,"aria-label":I.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:r.jsx(Uw,{className:"size-3.5"})})}),r.jsx(ht,{children:I.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),I.diffWithPrevious!==void 0&&r.jsxs(ft,{children:[r.jsx(mt,{asChild:!0,children:r.jsx(ee,{variant:"outline",size:"icon",className:qs,onClick:I.diffWithPrevious,"aria-label":"Diff with previous",children:r.jsx(hf,{className:"size-3.5"})})}),r.jsx(ht,{children:"Compare this request with the immediately preceding one"})]}),I.copyText!==null&&r.jsxs(ft,{children:[r.jsx(mt,{asChild:!0,children:r.jsx(ee,{variant:"outline",size:"icon",className:qs,onClick:I.onCopy,"aria-label":I.copyCopied?"Copied":I.copyLabel,children:I.copyCopied?r.jsx(Ge,{className:"size-3.5 text-cyan-300"}):r.jsx(Ot,{className:"size-3.5"})})}),r.jsx(ht,{children:I.copyCopied?"Copied to clipboard":I.copyLabel})]})]})})(),p!==void 0&&r.jsxs(ft,{children:[r.jsx(mt,{asChild:!0,children:r.jsx(ee,{variant:"outline",size:"icon",className:qs,onClick:p,"aria-label":"Replay request",children:r.jsx(vf,{className:"size-3.5"})})}),r.jsx(ht,{children:"Re-send this request to the provider"})]})]}),r.jsx("span",{className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-slate-200","aria-hidden":"true",children:i?r.jsx(nt,{className:"size-4 shrink-0"}):r.jsx(yt,{className:"size-4 shrink-0"})})]})]})})});function z4({...e}){return r.jsx(xk,{"data-slot":"collapsible",...e})}function n6({...e}){return r.jsx(Pf,{"data-slot":"collapsible-trigger",...e})}function L4({...e}){return r.jsx(If,{"data-slot":"collapsible-content",...e})}function $4({className:e,children:t,...n}){return r.jsxs(jN,{"data-slot":"scroll-area",className:$("relative overflow-hidden",e),...n,children:[r.jsx(kN,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full max-h-[inherit] rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),r.jsx(D4,{}),r.jsx(_N,{})]})}function D4({className:e,orientation:t="vertical",...n}){return r.jsx(Um,{"data-slot":"scroll-area-scrollbar",orientation:t,className:$("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...n,children:r.jsx(Hm,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const x0={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},F4={file:"border-transparent bg-blue-400/5 text-blue-300",shell:"border-transparent bg-teal-400/5 text-teal-300",browser:"border-transparent bg-cyan-400/5 text-cyan-300",web:"border-transparent bg-sky-400/5 text-sky-300",mcp:"border-transparent bg-violet-400/5 text-violet-300",code:"border-transparent bg-emerald-400/5 text-emerald-300",other:"border-transparent bg-muted/30 text-muted-foreground"};function U4({category:e}){switch(e){case"file":return r.jsx(Zw,{className:"size-3.5"});case"shell":return r.jsx(Xn,{className:"size-3.5"});case"browser":return r.jsx(xj,{className:"size-3.5"});case"web":return r.jsx(mf,{className:"size-3.5"});case"mcp":return r.jsx(Wy,{className:"size-3.5"});case"code":return r.jsx(df,{className:"size-3.5"});case"other":return r.jsx(Mw,{className:"size-3.5"})}}function B4({names:e}){return e.length===0?null:r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[r.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"required"}),e.slice(0,4).map(t=>r.jsx(Se,{variant:"outline",className:"h-5 max-w-36 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",children:t},t)),e.length>4&&r.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e.length-4]})]})}function V4({tool:e,called:t}){const[n,s]=c.useState(!1),o=vn(e.name),i=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return r.jsx(z4,{open:n,onOpenChange:s,children:r.jsxs("div",{className:"bg-white/[0.035] rounded-[8px]",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",children:[r.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>s(a=>!a),"aria-expanded":n,disabled:!i,children:[r.jsx(U4,{category:e.category}),r.jsx("span",{className:"min-w-0 truncate font-mono text-xs font-semibold text-foreground/90",children:e.name}),t&&r.jsx(Se,{variant:"outline",className:"h-5 rounded-md border-emerald-400/20 bg-emerald-400/5 px-1.5 py-0 text-[10px] text-emerald-300",children:"called"}),r.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:[e.parameterCount," params"]}),e.descriptionPreview!==null&&r.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground md:inline",children:e.descriptionPreview}),r.jsx("span",{className:"flex-1"}),i&&(n?r.jsx(nt,{className:"size-3.5 shrink-0 text-muted-foreground"}):r.jsx(yt,{className:"size-3.5 shrink-0 text-muted-foreground"}))]}),r.jsx("button",{type:"button",className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:o.copy,"aria-label":o.copied?"Copied tool name":"Copy tool name",children:o.copied?r.jsx(Ge,{className:"size-3.5 text-emerald-400"}):r.jsx(Ot,{className:"size-3.5"})})]}),r.jsx(L4,{children:n&&r.jsxs("div",{className:"space-y-2 bg-white/[0.025] px-2.5 py-2",children:[e.description!==null&&r.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e.description}),r.jsx(B4,{names:e.requiredParameters}),e.schema!==null&&r.jsx($4,{className:"bg-black/[0.16] max-h-64 rounded-[8px] p-2",children:r.jsx(c.Suspense,{fallback:r.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:r.jsx(Ja,{data:Po(e.schema),defaultExpandDepth:0})})})]})})]})})}function q4(e,t){return t.length===0?!0:`${e.name} ${e.description??""} ${x0[e.category]}`.toLowerCase().trim().includes(t)}const H4=c.memo(function({summary:t,calledToolNames:n}){const[s,o]=c.useState(!1),[i,a]=c.useState(""),l=c.useMemo(()=>new Set(n),[n]),u=i.trim().toLowerCase(),d=c.useMemo(()=>t===null?[]:t.tools.filter(m=>q4(m,u)),[u,t]);if(t===null)return null;const p=t.tools.slice(0,6),f=t.tools.length-p.length;return r.jsxs("section",{className:"bg-black/[0.10] mb-3 overflow-hidden rounded-[8px]",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 px-3 py-2",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[r.jsx(hr,{className:"size-4 shrink-0 text-sky-300/80"}),r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[r.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Request Tools"}),r.jsx(Se,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",children:t.tools.length}),t.toolChoiceLabel!==null&&r.jsxs(Se,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px] text-muted-foreground",children:["tool_choice: ",t.toolChoiceLabel]})]}),r.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap gap-1",children:t.categories.map(m=>r.jsxs(Se,{variant:"outline",className:$("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",F4[m.category]),children:[m.count," ",x0[m.category]]},m.category))})]})]}),r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-cyan-100",onClick:()=>o(m=>!m),"aria-expanded":s,children:[s?r.jsx(nt,{className:"size-3.5"}):r.jsx(yt,{className:"size-3.5"}),s?"Hide":"Show"]})]}),r.jsxs("div",{className:"flex min-w-0 flex-wrap gap-1.5 bg-white/[0.025] px-3 py-2",children:[p.map(m=>r.jsx(Se,{variant:"outline",className:$("h-5 max-w-44 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",l.has(m.name)&&"border-emerald-400/20 text-emerald-300"),children:m.name},m.name)),f>0&&r.jsxs("span",{className:"font-mono text-[10px] leading-5 text-muted-foreground",children:["+",f]})]}),s&&r.jsxs("div",{className:"space-y-2 bg-black/10 px-3 py-3",children:[r.jsxs("label",{className:"bg-white/[0.045] hover:bg-white/[0.075] flex h-8 items-center gap-2 rounded-md px-2 text-xs",children:[r.jsx(yf,{className:"size-3.5 shrink-0 text-muted-foreground"}),r.jsx("input",{value:i,onChange:m=>a(m.target.value),placeholder:"Filter tools",className:"min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:text-muted-foreground/70"})]}),r.jsx("div",{className:"grid gap-1.5",children:d.length>0?d.map(m=>r.jsx(V4,{tool:m,called:l.has(m.name)},m.name)):r.jsx("p",{className:"py-2 text-xs text-muted-foreground",children:"No matching tools"})})]})]})});function Wu(e,t,n){return e==="anthropic"&&t==="full"&&n}function W4(e,t){return e==="full"&&t}function Ji(e,t){return e==="full"&&t}function Yi(e,t){return e==="full"&&t}function Z4(e,t,n,s){return e==="anthropic"&&t==="full"&&n&&s}function cs(){return r.jsx("div",{className:"h-1","aria-hidden":"true"})}function K4(e,t){switch(e){case"anatomy":return t===null?"request":"anatomy";case"request":return"request";case"response":return"parsed"}}const G4=15e3,J4=15e3,Y4=256*1024,Io=1024*1024,An="h-9 flex-none rounded-md border border-transparent bg-transparent px-3 text-xs font-semibold text-muted-foreground shadow-none transition-colors hover:bg-white/[0.045] hover:text-foreground data-[state=active]:bg-cyan-300/[0.08] data-[state=active]:text-cyan-100 data-[state=active]:shadow-none";function $r(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function Mo(e){return e??0}function b0(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function v0(e){return b0(e)?Mo(e.rawRequestBodyBytes)>Io||Mo(e.responseTextBytes)>Io:!1}function X4(e){return b0(e)&&!v0(e)}function Q4(e){return e instanceof Zo?"Body preview timed out. The log is still available on disk; try loading again.":e instanceof Error?e.message:"Body preview could not be loaded."}function Dr({status:e,error:t,footprint:n,onRetry:s}){switch(e){case"idle":return null;case"loading":return r.jsx(cr,{tone:"loading",title:"Loading full bodies",children:r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(Ue,{className:"size-3.5 shrink-0 animate-spin text-cyan-200"}),r.jsx("span",{children:"Loading full request and response bodies from the log store."})]}),n!==null&&r.jsx("span",{className:"rounded border border-cyan-300/15 bg-cyan-300/[0.06] px-2 py-0.5 font-mono text-[11px] text-cyan-100",children:n})]})});case"failed":return r.jsx(cr,{tone:"warning",title:t?.title??"Full bodies could not be loaded",children:r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r.jsx("span",{children:t?.detail??"Compact metadata is still available."}),r.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 gap-1.5 text-xs text-amber-100",onClick:s,children:[r.jsx(Vt,{className:"size-3"}),"Retry"]})]})})}}function Zu(e,t){return e?t.text!==""?t.text:t.status==="success"?"":null:null}function On({children:e,className:t}){return r.jsx("div",{className:$("bg-black/[0.14] inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",t),children:e})}function oo({children:e}){return r.jsx("div",{className:"bg-white/[0.035] rounded-md px-3 py-5 text-center text-xs italic text-muted-foreground",children:e})}function Fr({children:e}){return r.jsx("pre",{className:"bg-black/[0.18] inspector-scrollbar max-h-[64vh] overflow-auto whitespace-pre-wrap break-words rounded-[8px] p-3 font-mono text-xs leading-relaxed text-muted-foreground",children:e})}const eE={loading:"border-transparent bg-cyan-400/[0.06] text-cyan-100",warning:"border-transparent bg-amber-400/[0.08] text-amber-100",danger:"border-transparent bg-rose-400/[0.08] text-rose-100"};function cr({tone:e,title:t,children:n}){return r.jsxs("div",{className:$("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",eE[e]),children:[t!==void 0&&r.jsx("div",{className:"mb-1 font-semibold",children:t}),r.jsx("div",{className:"leading-relaxed text-muted-foreground",children:n})]})}function Ur({label:e,state:t,expectedBytes:n,onLoadMore:s}){const o=t.totalBytes??n,i=o===null?gs(t.offset):`${gs(t.offset)} / ${gs(o)}`,a=t.status!=="loading"&&t.hasMore,l=t.status==="failed"?"Retry":"Load more";return r.jsx(cr,{tone:t.status==="failed"?"warning":"loading",title:`${e} body preview`,children:r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r.jsxs("span",{children:[t.status==="idle"&&o!==null?`${e} body is ${gs(o)}. Loading the first preview chunk.`:`Loaded ${i}.`,t.status==="failed"&&t.error!==null&&` ${t.error}`]}),a&&r.jsx(ee,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 text-xs text-cyan-100",onClick:s,children:l})]})})}function Ku({headers:e,emptyLabel:t}){const n=e===void 0?[]:Object.entries(e).sort(([s],[o])=>s.localeCompare(o));return n.length===0?r.jsx(oo,{children:t}):r.jsx("div",{className:"bg-black/[0.14] overflow-hidden rounded-[8px] font-mono text-xs",children:n.map(([s,o])=>r.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(140px,0.32fr)_minmax(0,1fr)] border-b border-white/[0.055] last:border-b-0",children:[r.jsx("div",{className:"min-w-0 truncate bg-white/[0.035] px-2.5 py-2 font-semibold text-cyan-200",children:s}),r.jsx("div",{className:"min-w-0 truncate px-2.5 py-2 text-muted-foreground",title:o,children:o})]},s))})}function tE({active:e,onClick:t}){return r.jsxs(ft,{children:[r.jsx(mt,{asChild:!0,children:r.jsxs(ee,{variant:e?"default":"outline",size:"sm",className:$("h-8 border-white/10 text-xs shadow-none",e?"bg-cyan-300 text-black hover:bg-cyan-200":"border border-input bg-background hover:bg-accent hover:text-accent-foreground text-muted-foreground hover:text-cyan-100"),onClick:t,"aria-pressed":e,children:[r.jsx(tj,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),r.jsx(ht,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const nE=c.memo(function({rawBody:e,displayedBody:t,emptyLabel:n}){const s=c.useMemo(()=>b4(e,t),[e,t]);return r.jsx(g0,{result:s,emptyLabel:n})}),sE=c.memo(function({rawHeaders:e,headers:t,emptyLabel:n}){const s=c.useMemo(()=>x4(e,t),[e,t]);return r.jsx(g0,{result:s,emptyLabel:n})}),rE=c.memo(function({log:e,displayNumber:t,viewMode:n="simple",strip:s,slowResponseThresholdSeconds:o,timeDisplayFormat:i,cacheTrend:a=null,onCompareWithPrevious:l,showClientMetadata:u=!0,toolEvents:d=[]}){const[p,f]=c.useState(!1),[m,h]=c.useState(!1),[g,y]=c.useState(!1),[b,w]=c.useState(!1),[v,j]=c.useState("request"),[_,k]=c.useState(null),[S,C]=c.useState(0),[M,A]=c.useState(null),[P,N]=c.useState(null),[I,F]=c.useState("idle"),[B,J]=c.useState(null),[K,W]=c.useState(0),[V,z]=c.useState(()=>$r(e.rawRequestBodyBytes??null)),[X,Y]=c.useState(()=>$r(e.responseTextBytes??null)),we=c.useRef(null),he=c.useRef(e.id),oe=c.useRef(!1),D=P??e,Ne=P===null&&v0(e),te=c.useMemo(()=>u4(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),je=Zu(Ne,V),ke=Zu(Ne,X),ue=D.rawRequestBody??je,le=D.responseText??ke,xe=D.rawRequestBody===null&&je!==null,_e=D.responseText===null&&ke!==null,ve=!xe||V.hasMore===!1&&Mo(V.totalBytes)<=Io,Ze=!_e||X.hasMore===!1&&Mo(X.totalBytes)<=Io,Be=ar(D),Ke=n0(Be),dt=c.useMemo(()=>Ke.analyzeRequest(D.rawRequestBody),[Ke,D.rawRequestBody]),Lt=c.useMemo(()=>Ke.analyzeResponse(D.responseText),[Ke,D.responseText]),Ye=c.useMemo(()=>!s||Be!=="anthropic"||D.rawRequestBody===null?null:ZT(D.rawRequestBody).body,[D.rawRequestBody,Be,s])??ue,Me=Ki(ve?Ye:null),Oe=Ki(v==="raw-request"&&ve?ue:null),q=Ki(v==="raw"&&Ze?le:null),ne=c.useMemo(()=>D.headers&&Object.keys(D.headers).length>0?JSON.stringify(D.headers,null,2):null,[D.headers]),Ee=c.useMemo(()=>D.rawHeaders&&Object.keys(D.rawHeaders).length>0?JSON.stringify(D.rawHeaders,null,2):null,[D.rawHeaders]),me=vn(Ye),be=vn(ue),ze=vn(ne),G=vn(Ee),E=vn(le),L=c.useMemo(()=>({request:{copyLabel:xe?"Copy loaded request preview":"Copy request body",copyText:Ye,copyCopied:me.copied,onCopy:me.copy,expansion:ve?{isExpanded:Me.isExpanded,isPending:Me.isPending,onToggle:Me.toggle}:null,diffWithRaw:Z4(Be,n,s,D.rawRequestBody!==null)?{active:b,onToggle:()=>w(!b)}:void 0,diffWithPrevious:l===void 0?void 0:()=>{l(D)}},"raw-request":{copyLabel:xe?"Copy loaded raw request preview":"Copy raw request",copyText:ue,copyCopied:be.copied,onCopy:be.copy,expansion:ve?{isExpanded:Oe.isExpanded,isPending:Oe.isPending,onToggle:Oe.toggle}:null},...Yi(n,D.headers!==void 0&&Object.keys(D.headers).length>0)?{headers:{copyLabel:"Copy headers",copyText:ne,copyCopied:ze.copied,onCopy:ze.copy,expansion:null}}:{},...Ji(n,D.rawHeaders!==void 0&&Object.keys(D.rawHeaders).length>0)?{"raw-headers":{copyLabel:"Copy raw headers",copyText:Ee,copyCopied:G.copied,onCopy:G.copy,expansion:null}}:{},raw:{copyLabel:_e?"Copy loaded response preview":"Copy response",copyText:le,copyCopied:E.copied,onCopy:E.copy,expansion:Ze?{isExpanded:q.isExpanded,isPending:q.isPending,onToggle:q.toggle}:null}}),[Ye,xe,ve,me,Me,b,D,D.rawRequestBody,ue,be,Oe,ne,ze,Ee,G,D.responseText,_e,Ze,le,E,q,Be,n,s,l]),Z=c.useMemo(()=>Me.parsedData!==null?Ke.anatomySegments(Me.parsedData):null,[Ke,Me.parsedData]),ie=c.useMemo(()=>fc(Me.parsedData),[Me.parsedData]),de=D.warnings??[],se=c.useMemo(()=>{if(Z!==null)return new Set(Z.map(Ae=>Ae.path))},[Z]),ye=c4({containerRef:we,setExpandToPath:A,ensureTabActive:()=>{v!=="request"&&j("request")}}),ce=c.useCallback((Ae,en)=>{const Ve=Ae==="request"?z:Y;Ve(Xe=>({...Xe,status:"loading",error:null}));const ts=new URLSearchParams({part:Ae,offset:String(en),limit:String(Y4)});qe(`/api/logs/${String(e.id)}/body?${ts.toString()}`,R2,J4).then(Xe=>{he.current===e.id&&Ve($t=>({status:"success",text:Xe.offset===0?Xe.text:`${$t.text}${Xe.text}`,offset:Xe.nextOffset??Xe.totalBytes,totalBytes:Xe.totalBytes,hasMore:Xe.hasMore,error:null}))}).catch(Xe=>{he.current===e.id&&Ve($t=>({...$t,status:"failed",error:Q4(Xe)}))})},[e.id]),pt=c.useCallback(()=>{oe.current||(N(null),F("idle"),J(null),W(Ae=>Ae+1))},[]),Mn=c.useCallback(()=>{const Ae=!p;Ae&&j(Z!==null?"anatomy":"request"),f(Ae)},[Z,p]);return c.useEffect(()=>{he.current=e.id,oe.current=!1,N(null),F("idle"),J(null),W(0),z($r(e.rawRequestBodyBytes??null)),Y($r(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),c.useEffect(()=>{if(!p||!X4(e)||P!==null||oe.current)return;let Ae=!1;return oe.current=!0,F("loading"),J(null),qe(`/api/logs/${String(e.id)}`,sr,G4).then(en=>{Ae||(oe.current=!1,N(en),F("idle"),J(null))}).catch(en=>{Ae||(oe.current=!1,F("failed"),J(d4(en)))}),()=>{Ae=!0,oe.current=!1}},[p,P,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,K]),c.useEffect(()=>{p&&Ne&&V.status==="idle"&&(v!=="request"&&v!=="raw-request"&&v!=="anatomy"||ce("request",0))},[v,p,ce,V.status,Ne]),c.useEffect(()=>{p&&Ne&&X.status==="idle"&&(v!=="parsed"&&v!=="raw"||ce("response",0))},[v,p,ce,X.status,Ne]),c.useEffect(()=>{const Ae=en=>{const Ve=wi(en);Ve!==null&&Ve.logId===e.id&&(f(!0),j(K4(Ve.tab,Z)),Ve.tab==="response"&&Ve.toolCallIndex!==void 0&&(k(Ve.toolCallIndex),C(ts=>ts+1)))};return window.addEventListener(un,Ae),()=>{window.removeEventListener(un,Ae)}},[Z,e.id]),r.jsxs(Ds,{children:[r.jsxs("div",{className:$("bg-card/80 relative mb-1.5 overflow-hidden rounded-[8px] transition-[background-color,box-shadow]",p?"bg-card shadow-[0_18px_60px_rgba(0,0,0,0.30),0_0_0_1px_rgba(103,232,249,0.08)]":"hover:bg-card"),children:[r.jsx(O4,{log:D,displayNumber:t,messageCount:dt.messageCount,toolCount:dt.toolCount,toolEvents:d,expanded:p,onToggle:Mn,cacheTrend:a,slowResponseThresholdSeconds:o,showClientMetadata:u,timeDisplayFormat:i,activeTab:v,tabActions:L,onReplay:l===void 0?void 0:()=>{h(!0)}}),p&&r.jsxs("div",{className:"relative bg-black/[0.14] pt-2",onClick:Ae=>Ae.stopPropagation(),onKeyDown:Ae=>Ae.stopPropagation(),children:[r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-12 bg-gradient-to-b from-white/[0.05] to-transparent","aria-hidden":"true"}),r.jsx(co,{feature:"Log details",children:r.jsxs(d0,{value:v,onValueChange:j,className:"gap-2",children:[r.jsxs(p0,{variant:"line",className:"bg-white/[0.04] inspector-scrollbar relative mx-3 h-auto w-[calc(100%-1.5rem)] justify-start overflow-x-auto rounded-[8px] p-1",children:[Ji(n,D.rawHeaders!==void 0&&Object.keys(D.rawHeaders).length>0)&&r.jsx(xn,{className:An,value:"raw-headers",children:"Raw Headers"}),Yi(n,D.headers!==void 0&&Object.keys(D.headers).length>0)&&r.jsx(xn,{className:An,value:"headers",children:"Headers"}),Z!==null&&r.jsx(xn,{className:An,value:"anatomy",children:"Context"}),Wu(Be,n,s)&&r.jsx(xn,{className:An,value:"raw-request",children:"Raw Request"}),r.jsx(xn,{className:An,value:"request",children:"Request"}),n==="full"&&r.jsx(xn,{className:An,value:"raw",children:"Raw Response"}),r.jsx(xn,{className:An,value:"parsed",children:"Response"})]}),Wu(Be,n,s)&&r.jsx(jt,{value:"raw-request",children:v==="raw-request"&&r.jsxs(On,{children:[r.jsx(Dr,{status:I,error:B,footprint:te,onRetry:pt}),Ne&&r.jsx(Ur,{label:"Request",state:V,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ce("request",V.offset)}),ue===null?r.jsx(oo,{children:Ne?"Request preview is loading":"No request body"}):Oe.parsedData!==null?r.jsx(c.Suspense,{fallback:r.jsx(cs,{}),children:r.jsx(Ja,{data:Oe.parsedData,bulkDepth:Oe.bulkDepth,bulkRevision:Oe.bulkRevision})}):r.jsx(Fr,{children:ue})]})}),r.jsx(jt,{value:"request",children:v==="request"&&r.jsxs(On,{children:[r.jsx(Dr,{status:I,error:B,footprint:te,onRetry:pt}),Ne&&r.jsx(Ur,{label:"Request",state:V,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ce("request",V.offset)}),de.length>0&&r.jsxs(cr,{tone:"warning",children:[r.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[r.jsx(wn,{className:"size-3.5"}),"Tool schema warnings"]}),r.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:de.map(Ae=>r.jsx("li",{children:Ae},Ae))})]}),r.jsx(H4,{summary:ie,calledToolNames:Lt.toolNames??[]}),b?r.jsx(nE,{rawBody:D.rawRequestBody,displayedBody:Ye,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):r.jsx("div",{ref:we,children:Ye===null?r.jsx(oo,{children:Ne?"Request preview is loading":"No request body"}):Me.parsedData!==null?r.jsx(c.Suspense,{fallback:r.jsx(cs,{}),children:r.jsx(Ja,{data:Me.parsedData,bulkDepth:Me.bulkDepth,bulkRevision:Me.bulkRevision,anatomyPaths:se,expandToPath:M})}):r.jsx(Fr,{children:Ye})})]})}),Z!==null&&r.jsx(jt,{value:"anatomy",children:v==="anatomy"&&r.jsx(On,{className:"p-0",children:r.jsx(c.Suspense,{fallback:r.jsx(cs,{}),children:r.jsx(s4,{parsed:Me.parsedData,inputTokens:D.inputTokens??null,model:D.model,segments:Z,onSegmentActivate:ye})})})}),Yi(n,D.headers!==void 0&&Object.keys(D.headers).length>0)&&r.jsx(jt,{value:"headers",children:v==="headers"&&r.jsxs(On,{children:[r.jsx("div",{className:"flex justify-end gap-2 mb-2",children:W4(n,D.rawHeaders!==void 0&&Object.keys(D.rawHeaders).length>0)&&r.jsx(tE,{active:g,onClick:Ae=>{Ae.stopPropagation(),y(!g)}})}),g?r.jsx(sE,{rawHeaders:D.rawHeaders,headers:D.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):r.jsx(Ku,{headers:D.headers,emptyLabel:"No headers captured"})]})}),Ji(n,D.rawHeaders!==void 0&&Object.keys(D.rawHeaders).length>0)&&r.jsx(jt,{value:"raw-headers",children:v==="raw-headers"&&r.jsx(On,{children:r.jsx(Ku,{headers:D.rawHeaders,emptyLabel:"No raw headers captured"})})}),r.jsx(jt,{value:"raw",children:v==="raw"&&r.jsxs(On,{className:"space-y-3",children:[r.jsx(Dr,{status:I,error:B,footprint:te,onRetry:pt}),Ne&&r.jsx(Ur,{label:"Response",state:X,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ce("response",X.offset)}),D.error!==void 0&&D.error!==null&&r.jsx(cr,{tone:"danger",title:"SSE Error",children:r.jsx("span",{className:"font-mono",children:D.error})}),le!==null&&Ze?r.jsx(c.Suspense,{fallback:r.jsx(cs,{}),children:r.jsx(i4,{text:le,defaultExpandDepth:0,bulkDepth:q.bulkDepth,bulkRevision:q.bulkRevision})}):le!==null?r.jsx(Fr,{children:le}):r.jsx(oo,{children:Ne?"Response preview is loading":"No response"}),D.streaming===!0&&r.jsx(c.Suspense,{fallback:r.jsx(cs,{}),children:r.jsx(o4,{logId:D.id,truncated:D.streamingChunksPath!==null})})]})}),r.jsx(jt,{value:"parsed",children:v==="parsed"&&r.jsxs(On,{children:[r.jsx(Dr,{status:I,error:B,footprint:te,onRetry:pt}),Ne&&r.jsx(Ur,{label:"Response",state:X,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ce("response",X.offset)}),_e&&!Ze?r.jsx(Fr,{children:le}):r.jsx(c.Suspense,{fallback:r.jsx(cs,{}),children:r.jsx(r4,{responseText:le,responseStatus:D.responseStatus,streaming:D.streaming,inputTokens:D.inputTokens,outputTokens:D.outputTokens,cacheCreationInputTokens:D.cacheCreationInputTokens,cacheReadInputTokens:D.cacheReadInputTokens,apiFormat:Be,error:D.error,focusedToolIndex:_,toolFocusNonce:S})})]})})]})})]})]}),r.jsx(co,{feature:"Replay",children:r.jsx(c.Suspense,{fallback:null,children:r.jsx(n4,{log:D,displayNumber:t,open:m,onOpenChange:h})})})]})});function oE(e){switch(e){case"end_turn":return"End of Turn (Anthropic)";case"stop":return"End of Turn (OpenAI)";case"length":return"End of Turn (length limit)";case"tool_use":case null:return"End of Turn"}}function Xi(e){return e?"cursor-pointer transition-transform hover:scale-110":""}function iE({stopReason:e,isPending:t,isFirst:n,isTurnStart:s,isOnlyEntry:o=!1,isOpenTurnTail:i=!1,crabIndex:a=0,collapsible:l=!1,onToggle:u}){const d=mc(e),p=o&&s&&d,f=t&&!d,m=l&&u!==void 0,h=c.useMemo(()=>hc(a),[a]),g=c.useMemo(()=>BT(a),[a]),y=w=>{!m||u===void 0||(w.stopPropagation(),u())},b=w=>{!m||u===void 0||w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),u())};return r.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[r.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!n&&r.jsx("div",{className:"w-px bg-muted-foreground/18 h-full"})}),p?r.jsx("span",{role:m?"button":void 0,tabIndex:m?0:void 0,title:"Single-request turn",className:Xi(m),onClick:y,onKeyDown:b,children:r.jsx(g,{className:$("size-3.5 text-[#80FF00]","animate-crab-settle","drop-shadow-[0_0_4px_rgba(128,255,0,0.5)]")})}):d?r.jsx("span",{role:m?"button":void 0,tabIndex:m?0:void 0,title:oE(e),className:Xi(m),onClick:y,onKeyDown:b,children:r.jsx(h,{className:$("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})}):s?r.jsx("span",{role:m?"button":void 0,tabIndex:m?0:void 0,title:"Start of turn",className:Xi(m),onClick:y,onKeyDown:b,children:r.jsx(h,{className:$("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):i?r.jsx("span",{title:t?"Current end of open turn (processing)":"Current end of open turn",children:r.jsx(h,{className:$("size-3.5 text-cyan-300/85",f?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})}):f?r.jsx("span",{title:"Processing",children:r.jsx(h,{className:$("size-3.5 text-amber-300/80","animate-crab-crawl")})}):r.jsx("span",{title:"Request in turn",children:r.jsx(h,{className:"size-3.5 text-muted-foreground/40"})}),r.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!d&&!i&&r.jsx("div",{className:$("w-0.5 h-full",t?"border-dashed bg-transparent border-l border-muted-foreground/14":"bg-muted-foreground/18")})})]})}const Gu=180,Qi=new WeakMap;function aE(e,t){const n=e.responseText;if(n===null)return!1;switch(t){case"anthropic":return n.includes("tool_use");case"openai":return n.includes("tool_calls")||n.includes("function_call");case"unknown":return!1}}function lE(e){return e>1}function Qa(e){const t=[];let n=[],s=0;for(let o=0;o<e.length;o+=1){const i=e[o];if(i===void 0)continue;n.push({log:i,stopReason:l0(i),sessionLogNumber:o+1});const a=n[n.length-1];a!==void 0&&mc(a.stopReason)&&(t.push({entries:n,turnIndex:s}),n=[],s+=1)}return n.length>0&&t.push({entries:n,turnIndex:s}),t}function cE(e){const t=new Map;for(const n of e)for(let s=1;s<n.logs.length;s+=1){const o=n.logs[s],i=n.logs[s-1];if(o===void 0||i===void 0)continue;const a=ar(o),l=ar(i);a==="unknown"||a!==l||t.set(o.id,i)}return t}function y0(e){if(e===null)return null;try{const t=JSON.parse(e);return typeof t=="string"?JSON.parse(t):t}catch{return null}}function io(e){if(e==null)return null;const t=typeof e=="string"?e:JSON.stringify(e);if(t===void 0)return null;const n=t.replace(/\s+/g," ").trim();return n.length===0?null:n.length>Gu?`${n.slice(0,Gu-1)}...`:n}function ao(e){if(e==null)return null;if(typeof e=="string")return e.length>0?e:null;const t=JSON.stringify(e,null,2);return t===void 0||t.length===0?null:t}function uE(e){const t=y0(e.responseText),n=Q(t,"content");if(!Array.isArray(n))return[];const s=[];for(const o of n){if(Q(o,"type")!=="tool_use")continue;const a=Q(o,"name");if(typeof a!="string"||a.length===0)continue;const l=Q(o,"input");s.push({id:`${String(e.id)}-anthropic-tool-${String(s.length)}`,logId:e.id,index:s.length,provider:"anthropic",name:a,argumentsText:ao(l),argumentsPreview:io(l)})}return s}function dE(e){const t=y0(e.responseText),n=Q(t,"choices");if(!Array.isArray(n))return[];const s=[];for(const i of n){const a=Q(i,"message"),l=Q(a,"tool_calls");if(Array.isArray(l))for(const p of l){const f=Q(p,"function"),m=Q(f,"name");if(typeof m!="string"||m.length===0)continue;const h=Q(f,"arguments");s.push({id:`${String(e.id)}-openai-tool-${String(s.length)}`,logId:e.id,index:s.length,provider:"openai",name:m,argumentsText:ao(h),argumentsPreview:io(h)})}const u=Q(a,"function_call"),d=Q(u,"name");if(typeof d=="string"&&d.length>0){const p=Q(u,"arguments");s.push({id:`${String(e.id)}-openai-tool-${String(s.length)}`,logId:e.id,index:s.length,provider:"openai",name:d,argumentsText:ao(p),argumentsPreview:io(p)})}}const o=Q(t,"output");if(Array.isArray(o))for(const i of o){if(Q(i,"type")!=="function_call")continue;const a=Q(i,"name");if(typeof a!="string"||a.length===0)continue;const l=Q(i,"arguments");s.push({id:`${String(e.id)}-openai-tool-${String(s.length)}`,logId:e.id,index:s.length,provider:"openai",name:a,argumentsText:ao(l),argumentsPreview:io(l)})}return s}function gc(e){const t=Qi.get(e);if(t!==void 0&&t.apiFormat===e.apiFormat&&t.responseText===e.responseText)return t.events;const n=ar(e);if(!aE(e,n)){const o=[];return Qi.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:o}),o}let s;switch(n){case"anthropic":s=uE(e);break;case"openai":s=dE(e);break;case"unknown":s=[];break}return Qi.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:s}),s}function pE(e,t,n=0){let s=0,o=0,i=0,a=0,l=0,u=0,d=0,p=0,f=null,m=0;for(const h of e)h.responseStatus===null?o+=1:h.responseStatus>=400&&(s+=1),h.elapsedMs!==null&&t>0&&h.elapsedMs>t*1e3&&(i+=1),h.inputTokens!==null&&(a+=h.inputTokens),h.outputTokens!==null&&(l+=h.outputTokens),h.cacheCreationInputTokens!==null&&(u+=h.cacheCreationInputTokens),h.cacheReadInputTokens!==null&&(d+=h.cacheReadInputTokens),h.elapsedMs!==null&&(p+=h.elapsedMs,f=f===null?h.elapsedMs:Math.max(f,h.elapsedMs)),m+=gc(h).length;return{llmCallCount:e.length,toolCallCount:m,failedCallCount:s,pendingCallCount:o,slowCallCount:i,totalInputTokens:a,totalOutputTokens:l,totalCacheCreationInputTokens:u,totalCacheReadInputTokens:d,totalElapsedMs:p,maxElapsedMs:f,startedAt:e[0]?.timestamp??null,endedAt:e[e.length-1]?.timestamp??null,knowledgeCandidateCount:n}}function ea(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const fE=c.memo(function({entries:t,viewMode:n,strip:s,slowResponseThresholdSeconds:o,cacheTrends:i,onCompareWithPrevious:a,comparisonPredecessors:l,turnIndex:u=0,timeDisplayFormat:d,pendingFocusRequest:p,showLogClientMetadata:f=!0}){const m=t.length-1,h=t[m]?.stopReason??null,g=h!==null?mc(h):!1,y=t[m]?.log.responseStatus===null,b=t.length===1,w=lE(t.length),[v,j]=c.useState(!1),_=c.useRef(!1);c.useEffect(()=>{w?g&&!_.current&&j(!0):j(!1),_.current=g},[w,g]),c.useEffect(()=>{const W=V=>{const z=wi(V);z!==null&&t.some(X=>X.log.id===z.logId)&&w&&j(!1)};return window.addEventListener(un,W),()=>{window.removeEventListener(un,W)}},[w,t]),c.useEffect(()=>{if(p===void 0||!t.some(V=>V.log.id===p.logId))return;w&&j(!1);const W=window.setTimeout(()=>{Is({logId:p.logId,tab:p.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(W)},[w,t,p]);const k=c.useCallback(()=>{w&&j(W=>!W)},[w]),S=c.useMemo(()=>{let W=0,V=0,z=null,X=!1;for(const Y of t)Y.log.inputTokens!==null&&(W+=Y.log.inputTokens,X=!0),Y.log.outputTokens!==null&&(V+=Y.log.outputTokens,X=!0),Y.log.elapsedMs!==null&&(z=z===null?Y.log.elapsedMs:Math.max(z,Y.log.elapsedMs));return{totalInput:W,totalOutput:V,hasTokens:X,maxElapsed:z}},[t,m]),C=u%2===0?"bg-white/[0.008]":"bg-cyan-300/[0.008]",M=S.maxElapsed!==null&&o>0&&S.maxElapsed>o*1e3,A=c.useMemo(()=>{const W=new Map;for(const V of t){const z=gc(V.log);z.length>0&&W.set(V.log.id,z)}return W},[t]),[P,N]=c.useState(0),I=c.useRef(null);c.useEffect(()=>{const W=I.current;if(!W)return;let V=0;const z=new ResizeObserver(()=>{window.cancelAnimationFrame(V),V=window.requestAnimationFrame(()=>N(X=>X+1))});return z.observe(W),()=>{z.disconnect(),window.cancelAnimationFrame(V)}},[]);const F=t[0]?.log.id??u,B=`Turn ${String(u+1)}`,J=c.useMemo(()=>hc(F%12),[F]),K=c.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:v?"48px":"160px"}),[v]);return r.jsx("div",{ref:I,style:K,tabIndex:v?void 0:0,role:v?void 0:"group","aria-label":v?void 0:B,"data-nav-id":v?void 0:`turn-${String(F)}`,className:$("rounded-[8px] transition-[background-color,box-shadow]",y?"bg-amber-300/[0.018] shadow-[0_0_0_1px_rgba(252,211,77,0.035)]":"",!v&&"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),children:v?r.jsxs("div",{"data-nav-id":`turn-collapsed-${String(F)}`,"data-nav-action":"expand",role:"button",tabIndex:0,className:"flex items-stretch cursor-pointer focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none rounded-lg",onClick:k,onKeyDown:W=>{(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),k())},children:[r.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-1.5 pb-1.5",children:[r.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),r.jsx(J,{className:$("size-3.5",y?"animate-crab-crawl text-amber-300/80":"animate-crab-appear text-emerald-400",y?"drop-shadow-[0_0_4px_rgba(252,211,77,0.42)]":"drop-shadow-[0_0_4px_rgba(52,211,153,0.45)]")}),r.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:r.jsx("div",{className:"w-px bg-muted-foreground/14 h-full"})}),g?r.jsx(J,{className:$("size-3.5 animate-crab-settle text-amber-400","drop-shadow-[0_0_4px_rgba(251,191,36,0.45)]")}):r.jsx("span",{title:"Current end of open turn","aria-label":"Current end of open turn",children:r.jsx(J,{className:$("size-3.5 text-cyan-300/85",y?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})})]}),t.length>1&&r.jsxs("div",{className:$("flex-1 min-w-0 mb-0.5 rounded-[8px] py-1.5 px-3 flex items-center gap-3 text-xs","bg-card/80 transition-colors hover:bg-card",C),children:[r.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:B}),r.jsxs("span",{className:"text-blue-300/85 font-mono font-semibold tabular-nums shrink-0",title:`Log IDs ${String(t[0]?.log.id??"?")} ~ ${String(t[m]?.log.id??"?")}`,children:["#",t[0]?.sessionLogNumber??"?"," ~ #",t[m]?.sessionLogNumber??"?"]}),r.jsxs("span",{className:"text-muted-foreground shrink-0",children:[t.length," request",t.length>1?"s":""]}),S.maxElapsed!==null&&r.jsx(Ds,{children:r.jsxs(ft,{children:[r.jsx(mt,{asChild:!0,children:r.jsxs("span",{className:$("flex items-center gap-1 shrink-0",M?"text-amber-400":"text-muted-foreground"),children:[r.jsx(rn,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:ea(S.maxElapsed)}),M&&r.jsx(wn,{className:"size-3","aria-label":"Slow response"})]})}),r.jsx(ht,{children:M?`Slow response: ${ea(S.maxElapsed)} exceeds ${ea(o*1e3)}`:"Slowest request in this turn"})]})}),S.hasTokens&&r.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[r.jsx(rr,{className:"size-3 text-muted-foreground"}),r.jsxs("span",{className:"font-mono tabular-nums",children:[r.jsxs("span",{className:"text-blue-400",children:["IN ",Ie(S.totalInput)]})," / ",r.jsxs("span",{className:"text-amber-400",children:["OUT ",Ie(S.totalOutput)]})]})]}),r.jsx("span",{className:"flex-1 min-w-0"}),r.jsx("span",{className:"bg-white/[0.045] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-slate-200","aria-hidden":"true",children:r.jsx(yt,{className:"size-4 shrink-0"})})]})]}):t.map((W,V)=>{const{log:z,stopReason:X}=W,Y=V===0;return r.jsxs("div",{className:"flex items-stretch",children:[r.jsx(iE,{stopReason:X,isPending:z.responseStatus===null,isFirst:V===0,isTurnStart:Y,isOnlyEntry:b,isOpenTurnTail:V===m&&!g,crabIndex:z.id%12,collapsible:w&&Y,onToggle:k}),r.jsx("div",{className:$("flex-1 min-w-0 mb-0.5 rounded-[8px]",C),children:r.jsx(rE,{log:z,displayNumber:W.sessionLogNumber,viewMode:n,strip:s,slowResponseThresholdSeconds:o,timeDisplayFormat:d,cacheTrend:i?.get(z.id)??null,showClientMetadata:f,toolEvents:A.get(z.id),onCompareWithPrevious:l.has(z.id)?a:void 0})})]},z.id)})})}),mE=24,hE=132,gE=8;function xE(e){return e>mE}function bE(e){const t=new Map;for(let n=0;n<e.length;n++){const s=e[n];if(s!==void 0)for(const o of s.entries)t.set(o.log.id,n)}return t}function w0(e,t,n){return r.jsx(fE,{entries:e.entries,viewMode:t.viewMode,strip:t.strip,slowResponseThresholdSeconds:t.slowResponseThresholdSeconds,timeDisplayFormat:t.timeDisplayFormat,cacheTrends:t.cacheTrends,onCompareWithPrevious:t.onCompareWithPrevious,comparisonPredecessors:t.comparisonPredecessors,turnIndex:e.turnIndex,pendingFocusRequest:n,showLogClientMetadata:t.showLogClientMetadata},e.turnIndex)}function vE(e){return xE(e.turnGroups.length)?r.jsx(yE,{...e}):r.jsx(r.Fragment,{children:e.turnGroups.map(t=>w0(t,e))})}function yE(e){const{turnGroups:t}=e,[n,s]=c.useState(null),o=NT({count:t.length,estimateSize:()=>hE,overscan:gE,getItemKey:a=>t[a]?.turnIndex??a}),i=c.useMemo(()=>bE(t),[t]);return c.useEffect(()=>{const a=l=>{const u=wi(l);if(u===null||u.source==="virtualizer")return;const d=i.get(u.logId);d!==void 0&&(o.scrollToIndex(d,{align:"center"}),s(p=>({...u,turnIndex:d,nonce:p===null?1:p.nonce+1})))};return window.addEventListener(un,a),()=>{window.removeEventListener(un,a)}},[i,o]),r.jsx("div",{className:"relative w-full",style:{height:`${o.getTotalSize()}px`},"data-virtualized-turn-list":"true",children:o.getVirtualItems().map(a=>{const l=t[a.index];if(l===void 0)return null;const u=n!==null&&n.turnIndex===a.index?n:void 0;return r.jsx("div",{"data-index":a.index,ref:o.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${a.start}px)`},children:w0(l,e,u)},a.key)})})}const xc=fe(["episode","procedure","preference","project-fact"]),wE=fe(["draft","promoted","failed"]),j0=T({source:ae("agent-inspector"),sessionId:x(),logIds:H(R().int().positive()),project:x().nullable(),models:H(x())}),jE=T({redacted:Te(),patterns:H(x())}),kr=T({id:x(),type:xc,title:x(),content:x(),tags:H(x()),source:ae("agent-inspector"),sessionId:x(),logIds:H(R().int().positive()),evidence:j0,status:wE,createdAt:x(),updatedAt:x(),openClawMemoryId:x().nullable(),error:x().nullable(),redaction:jE});T({idempotencyKey:x(),type:xc,title:x(),content:x(),tags:H(x()),source:ae("agent-inspector"),project:x().nullable(),evidence:j0});const kE=T({id:x(),type:xc.or(x()),title:x(),content:x(),score:R().nullable(),source:x().nullable(),project:x().nullable(),evidence:Fn().optional()});T({results:H(kE),warning:x().nullable()});const _E=T({candidates:H(kr)}),SE=T({candidate:kr}),NE=T({error:x().optional(),candidate:kr.optional()}),CE=T({candidate:kr}),TE=3e4,EE=15e3,RE=15e3,PE={draft:"border-amber-500/30 bg-amber-500/10 text-amber-500",promoted:"border-emerald-500/30 bg-emerald-500/10 text-emerald-500",failed:"border-destructive/30 bg-destructive/10 text-destructive"};function el(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function IE(e,t,n){return e===null||t===null?null:Jo(e,t,n)}function ME(e){return`${String(e)} candidate${e===1?"":"s"}`}function k0(e){return`log-${String(e)}`}function _0(e){const t=k0(e),n=document.getElementById(t);window.history.replaceState(null,"",`#${t}`),n instanceof HTMLElement&&(n.scrollIntoView({block:"center",behavior:"smooth"}),n.focus({preventScroll:!0}))}function AE(e){for(const t of e)if(t.responseStatus!==null&&t.responseStatus>=400)return t;return null}function OE(e){let t=null,n=-1;for(const s of e)s.elapsedMs!==null&&s.elapsedMs>n&&(t=s,n=s.elapsedMs);return t}function zE(e){for(const t of e)if(gc(t).length>0)return t;return null}function LE(e){const t=new Map;for(let n=0;n<e.length;n+=1){const s=e[n];s!==void 0&&t.set(s.id,n+1)}return t}function ws(e,t){return String(t.get(e)??e)}function $E(e){const t=[{kind:"session",title:`${String(e.summary.llmCallCount)} LLM call${e.summary.llmCallCount===1?"":"s"}`,detail:`Scope ${e.scopeId}`,logId:e.logs[0]?.id??null}],n=zE(e.logs);e.summary.toolCallCount>0&&n!==null&&t.push({kind:"tool",title:`${String(e.summary.toolCallCount)} tool call${e.summary.toolCallCount===1?"":"s"}`,detail:`First tool evidence at #${ws(n.id,e.displayNumberByLogId)}`,logId:n.id});const s=AE(e.logs);s!==null&&t.push({kind:"failure",title:`Failure #${String(s.responseStatus)}`,detail:`First failed request is #${ws(s.id,e.displayNumberByLogId)}`,logId:s.id});const o=OE(e.logs);if(o!==null&&e.summary.maxElapsedMs!==null&&t.push({kind:"slow",title:`Slowest ${el(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${ws(o.id,e.displayNumberByLogId)}`,logId:o.id}),e.candidates.length>0){const i=e.candidates.filter(l=>l.status==="draft").length,a=e.candidates.filter(l=>l.status==="promoted").length;t.push({kind:"candidate",title:`${String(e.candidates.length)} memory candidate${e.candidates.length===1?"":"s"}`,detail:`${String(i)} draft / ${String(a)} promoted`,logId:e.candidates[0]?.logIds[0]??null})}return t}function DE(e){switch(e){case"session":return r.jsx(Go,{className:"size-3.5 text-blue-400"});case"tool":return r.jsx(hr,{className:"size-3.5 text-sky-400/70"});case"slow":return r.jsx(rn,{className:"size-3.5 text-amber-400"});case"failure":return r.jsx(uf,{className:"size-3.5 text-destructive"});case"candidate":return r.jsx(cf,{className:"size-3.5 text-emerald-400"})}}function FE({insights:e}){return e.length===0?null:r.jsx("div",{className:"mt-2 grid gap-1.5 border-t border-border/70 pt-2 md:grid-cols-2 xl:grid-cols-3",children:e.map(t=>r.jsxs("button",{type:"button",className:$("flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs","text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),onClick:()=>{t.logId!==null&&_0(t.logId)},disabled:t.logId===null,children:[DE(t.kind),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block truncate font-medium text-foreground/90",children:t.title}),r.jsx("span",{className:"block truncate font-mono text-[10px]",children:t.detail})]})]},`${t.kind}-${t.title}`))})}function UE(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function BE(e,t){if(t)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function VE(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function qE(e,t){const n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,t-3)}...`}function HE(e,t){const n=e[0],s=e[e.length-1];if(n===void 0)return"No evidence logs";const o=ws(n,t);return s===void 0||n===s?`#${o}`:`#${o}-#${ws(s,t)}`}function Ju(e){return e.join(", ")}function WE(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function ZE({candidate:e,isPromoting:t,isUpdating:n,onPromoteCandidate:s,onUpdateCandidate:o,displayNumberByLogId:i}){const[a,l]=c.useState(!1),[u,d]=c.useState(e.type),[p,f]=c.useState(e.title),[m,h]=c.useState(e.content),[g,y]=c.useState(Ju(e.tags)),[b,w]=c.useState(null),v=e.status!=="promoted",j=e.status!=="promoted",_=c.useCallback(()=>{d(e.type),f(e.title),h(e.content),y(Ju(e.tags)),w(null)},[e.content,e.tags,e.title,e.type]),k=c.useCallback(async()=>{const S=p.trim(),C=m.trim(),M=WE(g);if(S.length===0){w("Title is required.");return}if(C.length===0){w("Content is required.");return}if(M.length===0){w("At least one tag is required.");return}w(null),await o(e.id,{type:u,title:S,content:C,tags:M})&&l(!1)},[e.id,m,g,p,u,o]);return a?r.jsx("div",{className:"border border-border bg-card shadow-sm rounded-[8px] px-2.5 py-2",children:r.jsxs("div",{className:"grid gap-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs("select",{value:u,disabled:n,onChange:S=>{const C=kr.shape.type.safeParse(S.currentTarget.value);C.success&&d(C.data)},className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 rounded-md px-2 text-xs","aria-label":"Candidate type",children:[r.jsx("option",{value:"episode",children:"episode"}),r.jsx("option",{value:"procedure",children:"procedure"}),r.jsx("option",{value:"preference",children:"preference"}),r.jsx("option",{value:"project-fact",children:"project-fact"})]}),r.jsx("input",{value:p,disabled:n,onChange:S=>f(S.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 min-w-[220px] flex-1 rounded-md px-2 text-xs","aria-label":"Candidate title"})]}),r.jsx("textarea",{value:m,disabled:n,onChange:S=>h(S.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground min-h-28 rounded-md px-2 py-1.5 font-mono text-[11px] leading-relaxed","aria-label":"Candidate content"}),r.jsx("input",{value:g,disabled:n,onChange:S=>y(S.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 rounded-md px-2 text-xs","aria-label":"Candidate tags"}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground",children:[r.jsx(ou,{className:"size-3"}),"Saving reruns Inspector redaction before promotion."]}),r.jsx("span",{className:"flex-1"}),b!==null&&r.jsx("span",{className:"text-[10px] text-destructive",children:b}),r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{_(),l(!1)},children:[r.jsx(gr,{className:"size-3.5"}),"Cancel"]}),r.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{k()},children:[n?r.jsx(Vt,{className:"size-3.5 animate-spin"}):r.jsx($j,{className:"size-3.5"}),"Save"]})]})]})}):r.jsxs("div",{className:"rounded-md border border-border/80 bg-background/60 px-2.5 py-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(Se,{variant:"outline",className:"h-5 px-1.5 text-[10px] font-mono",children:e.type}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",title:e.title,children:e.title}),r.jsx(Se,{variant:"outline",className:$("h-5 shrink-0 px-1.5 text-[10px] font-mono",PE[e.status]),children:UE(e.status)})]}),r.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:qE(e.content,360)}),r.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground",children:[r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(Vw,{className:"size-3"}),HE(e.logIds,i)]}),r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(ou,{className:"size-3"}),VE(e)]}),e.status==="promoted"&&r.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[r.jsx(_a,{className:"size-3"}),e.openClawMemoryId??"OpenClaw"]}),e.status==="failed"&&e.error!==null&&r.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[r.jsx(uf,{className:"size-3"}),e.error]})]}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.logIds.map(S=>{const C=ws(S,i);return r.jsxs("a",{href:`#${k0(S)}`,onClick:M=>{M.preventDefault(),_0(S)},className:"rounded border border-blue-400/25 px-1.5 py-0.5 font-mono text-[10px] text-blue-400 underline-offset-2 transition-colors hover:bg-blue-400/10 hover:text-blue-300 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":`Jump to evidence log ${C}`,title:`Log ID ${String(S)}`,children:["#",C]},S)}),r.jsx("span",{className:"flex-1"}),j&&r.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",disabled:n||t,onClick:()=>l(!0),children:[r.jsx(xf,{className:"size-3"}),"Review"]}),r.jsxs(ee,{type:"button",variant:v?"outline":"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",onClick:()=>s(e.id),disabled:!v||t||n,children:[t?r.jsx(Vt,{className:"size-3 animate-spin"}):v?r.jsx(_w,{className:"size-3"}):r.jsx(_a,{className:"size-3"}),BE(e,t)]})]})]})}function KE({candidates:e,promotingCandidateIds:t,updatingCandidateIds:n,onPromoteCandidate:s,onUpdateCandidate:o,displayNumberByLogId:i}){return e.length===0?null:r.jsx("div",{className:"mt-2 grid gap-1.5",children:e.map(a=>r.jsx(ZE,{candidate:a,isPromoting:t.has(a.id),isUpdating:n.has(a.id),onPromoteCandidate:s,onUpdateCandidate:o,displayNumberByLogId:i},a.id))})}function GE({logs:e,scopeId:t,slowResponseThresholdSeconds:n,showRollupMetrics:s,timeDisplayFormat:o}){const[i,a]=c.useState([]),[l,u]=c.useState(!0),[d,p]=c.useState({status:"idle",error:null}),[f,m]=c.useState(()=>new Set),[h,g]=c.useState(()=>new Set),y=i.length>0,b=c.useMemo(()=>pE(e,n,i.length),[i.length,e,n]),w=c.useMemo(()=>LE(e),[e]),v=c.useMemo(()=>$E({logs:e,scopeId:t,summary:b,candidates:i,displayNumberByLogId:w}),[i,w,e,t,b]),j=s||b.maxElapsedMs!==null,_=c.useMemo(()=>IE(b.startedAt,b.endedAt,o),[b.endedAt,b.startedAt,o]),k=c.useCallback(()=>{e.length===0||d.status==="loading"||(p({status:"loading",error:null}),(async()=>{try{const M=await qe(`/api/knowledge/sessions/${encodeURIComponent(t)}/candidates`,_E,TE,{method:"POST"},A=>`Candidate generation failed with ${String(A.status)}`);a(M.candidates),u(M.candidates.length>0),p(M.candidates.length>0?{status:"ready",error:null}:{status:"failed",error:"No candidate was generated for this trace scope."})}catch(M){p({status:"failed",error:M instanceof Error?M.message:"Candidate response was invalid"})}})())},[d.status,e.length,t]),S=c.useCallback(M=>{m(A=>{if(A.has(M))return A;const P=new Set(A);return P.add(M),P}),(async()=>{try{const A=await Un(`/api/knowledge/candidates/${encodeURIComponent(M)}/promote`,EE,{method:"POST"}),P=await A.json().catch(()=>null),N=SE.safeParse(P);if(A.ok&&N.success){a(F=>F.map(B=>B.id===N.data.candidate.id?N.data.candidate:B)),p({status:"ready",error:null});return}const I=NE.safeParse(P);I.success&&I.data.candidate!==void 0&&a(F=>F.map(B=>B.id===I.data.candidate?.id?I.data.candidate:B)),p({status:"failed",error:I.success?I.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(A.status)}`})}catch(A){p({status:"failed",error:A instanceof Error?A.message:"Candidate promotion failed"})}finally{m(A=>{const P=new Set(A);return P.delete(M),P})}})()},[]),C=c.useCallback(async(M,A)=>{g(P=>{if(P.has(M))return P;const N=new Set(P);return N.add(M),N});try{const P=await qe(`/api/knowledge/candidates/${encodeURIComponent(M)}`,CE,RE,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)},N=>`Candidate update failed with ${String(N.status)}`);return a(N=>N.map(I=>I.id===P.candidate.id?P.candidate:I)),p({status:"ready",error:null}),!0}catch(P){return p({status:"failed",error:P instanceof Error?P.message:"Candidate update failed"}),!1}finally{g(P=>{const N=new Set(P);return N.delete(M),N})}},[]);return e.length===0?null:r.jsxs("section",{className:"border border-border bg-card shadow-sm mb-2 rounded-[8px] px-3 py-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[s&&r.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold text-foreground",children:[r.jsx(Go,{className:"size-3.5 text-blue-400"}),b.llmCallCount," LLM"]}),r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[r.jsx(hr,{className:"size-3.5 text-sky-400/70"}),b.toolCallCount," tools"]}),s&&r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[r.jsx(rr,{className:"size-3.5 text-emerald-400"}),r.jsxs("span",{className:"font-mono",children:[Ie(b.totalInputTokens)," / ",Ie(b.totalOutputTokens)]})]}),(b.totalCacheCreationInputTokens>0||b.totalCacheReadInputTokens>0)&&r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[r.jsx(rr,{className:"size-3.5 text-purple-400"}),r.jsxs("span",{className:"font-mono",children:["KV Cache +",Ie(b.totalCacheCreationInputTokens)," / ~",Ie(b.totalCacheReadInputTokens)]})]}),j&&r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[r.jsx(rn,{className:"size-3.5"}),s&&r.jsx("span",{className:"font-mono",children:el(b.totalElapsedMs)}),b.maxElapsedMs!==null&&r.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",el(b.maxElapsedMs)]})]}),s&&_!==null&&r.jsx("span",{className:"font-mono text-muted-foreground/70",children:_}),(b.failedCallCount>0||b.pendingCallCount>0||b.slowCallCount>0)&&r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-amber-400",children:[r.jsx(wn,{className:"size-3.5"}),r.jsxs("span",{className:"font-mono",children:[b.failedCallCount," fail / ",b.pendingCallCount," pending /"," ",b.slowCallCount," slow"]})]}),r.jsx("span",{className:"flex-1"}),y&&r.jsx(Se,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:ME(b.knowledgeCandidateCount)}),r.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:k,disabled:d.status==="loading",children:[d.status==="loading"?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(cf,{className:"size-3.5"}),"Candidate"]}),y&&r.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onClick:()=>u(M=>!M),"aria-expanded":l,"aria-label":l?"Collapse memory candidates":"Expand memory candidates",children:l?r.jsx(nt,{className:"size-3.5"}):r.jsx(yt,{className:"size-3.5"})})]}),d.status==="failed"&&r.jsx("p",{className:"mt-2 text-xs text-destructive",children:d.error}),r.jsx(FE,{insights:v}),l&&r.jsx(KE,{candidates:i,promotingCandidateIds:f,updatingCandidateIds:h,onPromoteCandidate:S,onUpdateCandidate:C,displayNumberByLogId:w})]})}function JE(e){let t=0,n=0;for(const s of e)s.inputTokens!==null&&(t+=s.inputTokens),s.outputTokens!==null&&(n+=s.outputTokens);return{totalInputTokens:t,totalOutputTokens:n}}function YE(e){const t=new Map;for(const n of e){if(n.model===null)continue;const s=qC(n.model);if(s==="unknown")continue;let o=t.get(s);o===void 0&&(o=new Set,t.set(s,o)),o.add(n.model)}return[...t.entries()].map(([n,s])=>({provider:n,models:[...s]}))}function XE(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function QE(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}const eR=c.memo(function({group:e,viewMode:t="simple",strip:n,slowResponseThresholdSeconds:s,cacheTrends:o,onCompareWithPrevious:i,comparisonPredecessors:a,onClearGroup:l,showClientIdentity:u=!0,showProcessMetadata:d=!0,showLogClientMetadata:p=!0,defaultExpanded:f=!1,timeDisplayFormat:m,expanded:h,onExpandedChange:g}){const[y,b]=c.useState(f),w=h??y,v=c.useCallback(N=>{if(g!==void 0){g(N);return}b(N)},[g]);c.useEffect(()=>{!f||h!==void 0||b(!0)},[h,f]);const j=c.useMemo(()=>JE(e.logs),[e.logs]),_=c.useMemo(()=>YE(e.logs),[e.logs]),k=e.logs[0]?.timestamp??new Date().toISOString(),S=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),C=e.logs.some(N=>N.responseStatus===null),M=c.useMemo(()=>XE(e.logs),[e.logs]),A=c.useMemo(()=>QE(e.logs),[e.logs]),P=c.useMemo(()=>Qa(e.logs),[e.logs]);return c.useEffect(()=>{const N=I=>{const F=wi(I);F!==null&&e.logs.some(B=>B.id===F.logId)&&v(!0)};return window.addEventListener(un,N),()=>{window.removeEventListener(un,N)}},[e.logs,v]),r.jsxs("div",{className:"mb-1.5",children:[r.jsx(iT,{conversationId:e.conversationId,startTime:k,endTime:S,totalCalls:e.logs.length,totalInputTokens:j.totalInputTokens,totalOutputTokens:j.totalOutputTokens,expanded:w,onToggle:()=>v(!w),providers:_,isLoading:C,userAgent:e.logs[0]?.userAgent??null,clientPid:M,clientProjectFolder:A,showClientIdentity:u,showProcessMetadata:d,timeDisplayFormat:m,onClear:()=>l(e.logs.map(N=>N.id))}),w&&r.jsxs("div",{children:[r.jsx(GE,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:s,showRollupMetrics:!1,timeDisplayFormat:m}),r.jsx(vE,{turnGroups:P,viewMode:t,strip:n,slowResponseThresholdSeconds:s,timeDisplayFormat:m,cacheTrends:o,onCompareWithPrevious:i,comparisonPredecessors:a,showLogClientMetadata:p})]})]})}),tR="flex w-full min-w-0 items-center gap-2 rounded-md border border-border/70 bg-muted/35 px-3 py-2 sm:w-auto sm:max-w-full",nR="m-0 min-w-0 flex-1 overflow-x-auto font-mono text-xs text-foreground sm:text-sm";function sR(e){return e==="full"}function rR(e){return e==="raw"}function oR(e,t){const n=t>0;return{redacted:n,raw:n&&sR(e)}}function iR(e,t){const n=e[0],s=e[e.length-1];return n===void 0||s===void 0?null:Jo(n.timestamp,s.timestamp,t)}function aR(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function lR(e){const t=new Set;for(const s of e)s.model!==null&&s.model.length>0&&t.add(s.model);const n=[...t].sort();return n.length===0?"Model unknown":n.length===1?n[0]??"Model unknown":`${n.length} models`}function cR(e){const t=new Set;for(const s of e)s.providerName!==null&&s.providerName!==void 0&&s.providerName.length>0&&t.add(s.providerName);const n=[...t].sort();return n.length===0?"Provider unknown":n.length===1?n[0]??"Provider unknown":`${n.length} providers`}function uR(e){if(e<1e3)return`${e}ms`;if(e<6e4){const o=e/1e3;return`${o<10?o.toFixed(1):o.toFixed(0)}s`}const t=Math.round(e/1e3),n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function dR(e,t){return`${Ie(e)} in / ${Ie(t)} out`}function pR(e,t){if(e.length===0)return 0;if(t.length===0)return Qa(e).length;let n=0;for(const s of t)n+=Qa(s.logs).length;return n}function fR({stopReason:e,pending:t,lastFailureLogNumber:n}){if(t>0)return{label:"In flight",detail:`${t} request${t===1?"":"s"} pending`,tone:"cool"};if(n!==null&&e===null)return{label:"Error",detail:`Last failed request #${n}`,tone:"danger"};switch(e){case"end_turn":return{label:"End turn",detail:"Assistant completed the turn",tone:"neutral"};case"stop":return{label:"Stop",detail:"Model reached a stop condition",tone:"neutral"};case"length":return{label:"Output limit",detail:"Turn ended at max output tokens",tone:"watch"};case"tool_use":return{label:"Tool call",detail:"Assistant requested a tool",tone:"cool"};case null:return{label:"Unknown",detail:"No finish reason captured",tone:"neutral"}}}function mR(e){if(e===null)return!1;const t=e.toLowerCase();return t.includes("abort")||t.includes("cancel")||t.includes("client disconnected")||t.includes("stream disconnected")||t.includes("connection closed")}function hR({pending:e,failures:t,lengthStops:n,stopReason:s,lastFailure:o}){if(o!==null&&(o.status===499||mR(o.error)))return{label:"Client aborted",detail:`Request #${o.logNumber} ended before completion`,tone:"watch"};if(e>0)return{label:"In flight",detail:`${e} request${e===1?"":"s"} still running`,tone:"cool"};if(o!==null&&o.status!==null&&o.status>=500)return{label:"Provider error",detail:`Request #${o.logNumber} returned HTTP ${o.status}`,tone:"danger"};if(t>0&&o!==null)return{label:"Failed",detail:`Request #${o.logNumber} needs attention`,tone:"danger"};if(n>0||s==="length")return{label:"Output limited",detail:"Model stopped at the output token limit",tone:"watch"};switch(s){case"end_turn":case"stop":return{label:"Completed",detail:"Assistant completed normally",tone:"neutral"};case"tool_use":return{label:"Tool requested",detail:"Assistant handed off to a tool",tone:"cool"};case null:return{label:"Unknown",detail:"No terminal signal captured",tone:"neutral"}}}function gR({logs:e,conversationGroups:t,isLoading:n,timeDisplayFormat:s,slowResponseThresholdSeconds:o}){let i=0,a=0,l=0,u=0,d=0,p=0,f=null,m=null,h=null,g=null,y=null,b=0,w=0,v=0,j=null;const _=o*1e3;for(let A=0;A<e.length;A+=1){const P=e[A];if(P===void 0)continue;const N=A+1,I=l0(P);I!==null&&(f=I),I==="length"&&(u+=1),aR(P)&&(i+=1,m=N,h={logNumber:N,status:P.responseStatus,error:P.error??null}),P.responseStatus===null&&(a+=1),o>0&&P.elapsedMs!==null&&P.elapsedMs>=_&&(l+=1),P.inputTokens!==null&&(d+=P.inputTokens),P.outputTokens!==null&&(p+=P.outputTokens),P.elapsedMs!==null&&(g===null||P.elapsedMs>g)&&(g=P.elapsedMs,y=N);const F=P.inputTokens??0,B=P.outputTokens??0,J=F+B;J>b&&(b=J,w=F,v=B,j=N)}const k=n||a>0&&i===0?"rolling":i>0?"failed":l>0||u>0?"watch":"clear",S=k==="rolling"?"Rolling":k==="failed"?"Failure":k==="watch"?"Watch":"Clear",C=fR({stopReason:f,pending:a,lastFailureLogNumber:m}),M=hR({pending:a,failures:i,lengthStops:u,stopReason:f,lastFailure:h});return{status:k,statusLabel:S,modelLabel:lR(e),providerLabel:cR(e),requests:e.length,turns:pR(e,t),failures:i,pending:a,slow:l,lengthStops:u,timeRange:iR(e,s),tokenLabel:`${Ie(d)} in / ${Ie(p)} out`,finishLabel:C.label,finishDetail:C.detail,finishTone:C.tone,outcomeLabel:M.label,outcomeDetail:M.detail,outcomeTone:M.tone,slowestLabel:g===null?"n/a":uR(g),slowestDetail:y===null?"Latency pending":`Request #${y}`,heaviestDetail:j===null?"Tokens pending":`#${j} ${dR(w,v)}`}}function xR({pinnedSessionId:e,selectedSession:t,sessions:n,logs:s}){if(e!==void 0){const a=s.filter(l=>l.sessionId===e);return a.length===0?null:{label:e,logs:a,showBackLink:!0}}if(t!=="__all__"){const a=s.filter(l=>l.sessionId===t);return a.length===0?null:{label:t,logs:a,showBackLink:!0}}const o=n.length===1?n[0]??null:null;return o!==null&&s.every(l=>l.sessionId===o)?{label:o,logs:[...s],showBackLink:!1}:n.length===0&&s.length>0&&s.every(a=>a.sessionId===null)?{label:"Visible requests",logs:[...s],showBackLink:!1}:null}function bR({logs:e,pagination:t}){if(t.isLoading&&e.length===0)return"Loading logs...";if(e.length===0)return"No logs on this page";const n=e[0],s=e[e.length-1],o=n===void 0||s===void 0?"Current page":`#${n.id}-#${s.id}`;return t.total===null?`Showing ${e.length} logs (${o})`:t.total<=e.length?`Showing all ${t.total} logs`:`Showing ${e.length} of ${t.total} logs (${o})`}function Zn({...e}){return r.jsx(Ym,{"data-slot":"select",...e})}function Ms({...e}){return r.jsx(th,{"data-slot":"select-value",...e})}function Kn({className:e,size:t="default",children:n,...s}){return r.jsxs(Qm,{"data-slot":"select-trigger","data-size":t,className:$("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...s,children:[n,r.jsx(nh,{asChild:!0,children:r.jsx(nt,{className:"size-4 opacity-50"})})]})}function Gn({className:e,children:t,position:n="popper",align:s="center",...o}){return r.jsx(rh,{children:r.jsxs(oh,{"data-slot":"select-content",className:$("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,align:s,...o,children:[r.jsx(vR,{}),r.jsx(uh,{className:$("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),r.jsx(yR,{})]})})}function Qe({className:e,children:t,...n}){return r.jsxs(mh,{"data-slot":"select-item",className:$("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[r.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:r.jsx(xh,{children:r.jsx(Ge,{className:"size-4"})})}),r.jsx(hh,{children:t})]})}function vR({className:e,...t}){return r.jsx(bh,{"data-slot":"select-scroll-up-button",className:$("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Il,{className:"size-4"})})}function yR({className:e,...t}){return r.jsx(vh,{"data-slot":"select-scroll-down-button",className:$("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(nt,{className:"size-4"})})}const wR=fe(["critical","warning","notice"]),jR=fe(["open"]),kR=fe(["proxy","tool-schema","run","group"]),S0=fe(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),_R=fe(["log","session","run","group"]),SR=fe(["anthropic","openai","unknown"]),NR=T({kind:_R,id:x(),label:x(),href:x().nullable()}),CR=T({id:x(),fingerprint:x(),severity:wR,category:S0,source:kR,status:jR,title:x(),message:x(),count:R().int().positive(),firstSeenAt:x(),lastSeenAt:x(),logIds:H(R().int().positive()),sessionIds:H(x()),runIds:H(x()),groupIds:H(x()),provider:x().nullable(),model:x().nullable(),apiFormat:SR.nullable(),evidence:H(NR),metadata:We(x(),tt)}),TR=T({category:S0,count:R().int().nonnegative()}),N0=T({total:R().int().nonnegative(),open:R().int().nonnegative(),critical:R().int().nonnegative(),warning:R().int().nonnegative(),notice:R().int().nonnegative(),byCategory:H(TR)}),ER=T({alerts:H(CR),total:R().int().nonnegative(),limit:R().int().positive(),summary:N0}),RR=8e3,PR=1e4;function IR(e){const t=new URLSearchParams;e.severity!==void 0&&t.set("severity",e.severity),e.category!==void 0&&t.set("category",e.category),e.source!==void 0&&t.set("source",e.source),e.limit!==void 0&&t.set("limit",String(e.limit));const n=t.toString();return n.length>0?`/api/alerts?${n}`:"/api/alerts"}function MR(e,t){const n=Bt(t?IR(e):null,s=>qe(s,ER,PR));return{alerts:n.data?.alerts??[],total:n.data?.total??0,summary:n.data?.summary??null,isLoading:n.isLoading,error:n.error,mutate:n.mutate}}function AR(){const e=Bt("/api/alerts/summary",t=>qe(t,N0,RR),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const ji="relative size-8 rounded-md border-0 bg-white/[0.035] text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:bg-white/[0.065] hover:text-accent-foreground focus-visible:ring-ring/50",OR=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function C0(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function zR(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function bc(e){switch(e){case"request-failure":return"Request failure";case"request-timeout":return"Timeout";case"slow-response":return"Slow response";case"tool-schema":return"Tool calling";case"run-failure":return"Run failure";case"group-failure":return"Group failure";case"group-incomplete":return"Group incomplete"}}function LR(e){switch(e){case"critical":return"border-red-400/40 bg-red-500/12 text-red-100";case"warning":return"border-amber-300/35 bg-amber-400/12 text-amber-100";case"notice":return"border-sky-300/35 bg-sky-400/12 text-sky-100"}}function $R(e){switch(e){case"critical":return"bg-red-400";case"warning":return"bg-amber-300";case"notice":return"bg-sky-300"}}function DR(e){switch(e){case"critical":return"text-red-200";case"warning":return"text-amber-100";case"notice":return"text-sky-100"}}function FR(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return r.jsx(Gj,{className:"size-3.5"});case"request-timeout":case"slow-response":return r.jsx(ww,{className:"size-3.5"});case"tool-schema":return r.jsx(wn,{className:"size-3.5"});case"group-incomplete":return r.jsx(qy,{className:"size-3.5"})}}function tl(e){const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):e}function bt(e){return e.toLocaleString()}function T0(e){return e.provider!==null&&e.model!==null?`${e.provider} / ${e.model}`:e.provider!==null?e.provider:e.model!==null?e.model:"Unknown target"}function UR(e,t){const n={limit:100};return e!=="all"&&(n.severity=e),t!=="all"&&(n.category=t),n}function BR(e,t){if(t!==null){const n=e.find(s=>s.id===t);if(n!==void 0)return n}return e[0]??null}function Br({label:e,count:t,tone:n}){const s=n==="critical"?"border-red-400/30 bg-red-500/10 text-red-100":n==="warning"?"border-amber-300/30 bg-amber-400/10 text-amber-100":n==="notice"?"border-sky-300/30 bg-sky-400/10 text-sky-100":"border-border bg-muted/40 text-foreground";return r.jsxs("div",{className:$("rounded-md border px-3 py-2",s),children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase opacity-75",children:e}),r.jsx("div",{className:"mt-1 text-lg font-semibold leading-none",children:bt(t)})]})}function Vr({value:e,active:t,label:n,count:s,onClick:o}){return r.jsxs(ee,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>o(e),className:"h-7 px-2",children:[n,s!==null?r.jsx(Se,{variant:"outline",children:bt(s)}):null]})}function VR({category:e,active:t,count:n,onClick:s}){return r.jsxs(ee,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>s(e),className:"h-7 px-2",children:[FR(e),bc(e),r.jsx(Se,{variant:"outline",children:bt(n)})]})}function qR({alerts:e,selectedAlertId:t,isLoading:n,error:s,onSelect:o}){return n?r.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:[r.jsx(Ue,{className:"mr-2 size-3.5 animate-spin"}),"Loading alerts..."]}):s!==void 0?r.jsx("div",{className:"rounded-md border border-red-300/30 bg-red-500/10 px-3 py-2 text-xs text-red-100",children:s.message}):e.length===0?r.jsx("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground",children:"No alerts match the current filters."}):r.jsx("div",{className:"min-h-0 space-y-2 overflow-y-auto pr-1",children:e.map(i=>{const a=i.id===t;return r.jsxs("button",{type:"button",onClick:()=>o(i.id),className:$("w-full rounded-md border px-3 py-3 text-left transition-colors",a?"border-primary/60 bg-primary/12":"border-border bg-background/70 hover:border-primary/30 hover:bg-muted/60"),children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:$("size-2 rounded-full",$R(i.severity))}),r.jsx("span",{className:$("text-xs font-semibold",DR(i.severity)),children:C0(i.severity)}),r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:bc(i.category)})]}),r.jsx("div",{className:"mt-1 text-sm font-semibold leading-snug",children:i.title}),r.jsx("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:i.message})]}),i.count>1?r.jsxs(Se,{variant:"outline",className:"shrink-0",children:["x",bt(i.count)]}):null]}),r.jsxs("div",{className:"mt-2 flex min-w-0 items-start justify-between gap-2 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"min-w-0 leading-snug",children:T0(i)}),r.jsx("span",{className:"shrink-0",children:tl(i.lastSeenAt)})]})]},i.id)})})}function HR({alert:e,onNavigate:t}){return e.evidence.length===0?r.jsx("span",{className:"text-xs text-muted-foreground",children:"No linked evidence"}):r.jsx("div",{className:"flex flex-wrap gap-2",children:e.evidence.map(n=>n.href===null?r.jsx(Se,{variant:"outline",children:n.label},`${n.kind}:${n.id}`):r.jsx(Se,{variant:"outline",asChild:!0,children:r.jsx("a",{href:n.href,onClick:t,children:n.label})},`${n.kind}:${n.id}`))})}function WR({alert:e,onNavigate:t}){return e===null?r.jsx("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground",children:"Select an alert to inspect its evidence."}):r.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-border bg-background/70",children:[r.jsx("div",{className:$("border-b px-4 py-3",LR(e.severity)),children:r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx(Se,{variant:"outline",children:C0(e.severity)}),r.jsx(Se,{variant:"outline",children:zR(e.source)}),r.jsx(Se,{variant:"outline",children:bc(e.category)})]}),r.jsx("h3",{className:"mt-3 text-base font-semibold",children:e.title}),r.jsx("p",{className:"mt-1 text-sm opacity-85",children:e.message})]}),e.count>1?r.jsxs(Se,{variant:"outline",className:"shrink-0",children:[bt(e.count)," hits"]}):null]})}),r.jsxs("div",{className:"space-y-4 p-4",children:[r.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[r.jsx(pn,{label:"Target",value:T0(e)}),r.jsx(pn,{label:"Last seen",value:tl(e.lastSeenAt)}),r.jsx(pn,{label:"First seen",value:tl(e.firstSeenAt)}),r.jsx(pn,{label:"Protocol",value:e.apiFormat??"n/a"})]}),r.jsxs("div",{children:[r.jsx("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Evidence"}),r.jsx(HR,{alert:e,onNavigate:t})]}),r.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[r.jsx(pn,{label:"Logs",value:e.logIds.length===0?"n/a":bt(e.logIds.length)}),r.jsx(pn,{label:"Sessions",value:e.sessionIds.length===0?"n/a":bt(e.sessionIds.length)}),r.jsx(pn,{label:"Runs",value:e.runIds.length===0?"n/a":bt(e.runIds.length)}),r.jsx(pn,{label:"Groups",value:e.groupIds.length===0?"n/a":bt(e.groupIds.length)})]})]})]})}function pn({label:e,value:t}){return r.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2",children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground",children:e}),r.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-foreground",children:t})]})}function ZR(){const[e,t]=c.useState(!1),[n,s]=c.useState("all"),[o,i]=c.useState("all"),[a,l]=c.useState(null),{summary:u,isLoading:d}=AR(),p=c.useMemo(()=>UR(n,o),[o,n]),{alerts:f,total:m,isLoading:h,error:g,mutate:y}=MR(p,e),b=c.useMemo(()=>BR(f,a),[f,a]);c.useEffect(()=>{!e||a!==null&&f.some(C=>C.id===a)||l(f[0]?.id??null)},[f,e,a]);const w=u?.total??0,v=u?.critical??0,j=u?.warning??0,_=u?.notice??0,k=v>0?"bg-red-600 text-white":j>0?"bg-amber-400 text-zinc-950":"bg-sky-400 text-zinc-950";return r.jsxs(Zt,{open:e,onOpenChange:t,children:[r.jsx(yr,{asChild:!0,children:r.jsxs(ee,{type:"button",variant:"ghost",size:"icon",className:ji,"aria-label":"Alerts",title:"Alerts",children:[r.jsx(Sa,{className:"size-4"}),d?r.jsx(Ue,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):w>0?r.jsx("span",{className:$("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4",k),children:bt(w)}):null,r.jsx("span",{className:"sr-only",children:"Alerts"})]})}),r.jsxs(Kt,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[r.jsxs(Xt,{children:[r.jsxs(Qt,{className:"flex items-center gap-2 pr-8",children:[r.jsx(Sa,{className:"size-5 text-red-300"}),r.jsx("span",{children:"Alerts"}),r.jsx(Se,{variant:"outline",children:bt(w)})]}),r.jsx(wr,{className:"sr-only",children:"Local alert board for captured Inspector evidence."})]}),r.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[r.jsx(Br,{label:"Open",count:u?.open??0,tone:"neutral"}),r.jsx(Br,{label:"Critical",count:v,tone:"critical"}),r.jsx(Br,{label:"Warning",count:j,tone:"warning"}),r.jsx(Br,{label:"Notice",count:_,tone:"notice"})]}),r.jsxs("div",{className:"flex min-h-0 flex-wrap items-center justify-between gap-2 border-y border-border py-3",children:[r.jsxs("div",{className:"flex flex-wrap gap-1",children:[r.jsx(Vr,{value:"all",active:n==="all",label:"All",count:u?.total??null,onClick:s}),r.jsx(Vr,{value:"critical",active:n==="critical",label:"Critical",count:v,onClick:s}),r.jsx(Vr,{value:"warning",active:n==="warning",label:"Warning",count:j,onClick:s}),r.jsx(Vr,{value:"notice",active:n==="notice",label:"Notice",count:_,onClick:s})]}),r.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{y()},children:[r.jsx(Vt,{className:"size-3.5"}),"Refresh"]})]}),r.jsxs("div",{className:"flex flex-wrap gap-1",children:[r.jsx(ee,{type:"button",variant:o==="all"?"secondary":"ghost",size:"sm","aria-pressed":o==="all",onClick:()=>i("all"),className:"h-7 px-2",children:"All categories"}),OR.map(S=>{const C=u?.byCategory.find(M=>M.category===S)?.count??0;return C===0?null:r.jsx(VR,{category:S,active:o===S,count:C,onClick:i},S)})]}),r.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[360px_minmax(0,1fr)]",children:[r.jsxs("div",{className:"flex min-h-0 flex-col",children:[r.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[r.jsxs("span",{children:[bt(m)," matched"]}),r.jsx("span",{children:f.length<m?`${bt(f.length)} shown`:"Latest"})]}),r.jsx(qR,{alerts:f,selectedAlertId:b?.id??null,isLoading:h,error:g,onSelect:l})]}),r.jsx(WR,{alert:b,onNavigate:()=>t(!1)})]})]})]})}const KR=12e3;function GR(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function JR(e){const t=Bt(GR(e),n=>qe(n,by,KR));return{evidenceResponse:t.data??null,isLoading:t.isLoading,error:t.error,mutate:t.mutate}}const YR=8e3;function XR(){const e=Bt("/api/groups",t=>qe(t,of,YR));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const QR=3e3;function eP(e,t){return{id:(e?.id??0)+1,message:t.message,tone:t.tone??"error"}}function E0(){const[e,t]=c.useState(null),n=c.useCallback(o=>{t(i=>eP(i,o))},[]),s=c.useCallback(()=>{t(null)},[]);return c.useEffect(()=>{if(e===null)return;const o=window.setTimeout(()=>{t(null)},QR);return()=>{window.clearTimeout(o)}},[e]),{notice:e,showToast:n,dismissToast:s}}function R0({notice:e,onDismiss:t}){if(e===null)return null;const n=e.tone==="error",s=n?wn:_a;return r.jsx("div",{"aria-atomic":"true","aria-live":"polite",className:"pointer-events-none fixed top-4 right-4 z-[100] w-[min(calc(100vw-2rem),26rem)]",role:"status",children:r.jsxs("div",{className:$("pointer-events-auto flex items-start gap-2 rounded-md border bg-popover/95 px-3 py-2 text-sm text-popover-foreground shadow-[0_18px_50px_color-mix(in_oklch,var(--foreground)_16%,transparent)] backdrop-blur",n?"border-status-danger/35":"border-status-success/35"),children:[r.jsx(s,{className:$("mt-0.5 size-4 shrink-0",n?"text-status-danger":"text-status-success")}),r.jsx("div",{className:"min-w-0 flex-1 break-words leading-5",children:e.message}),r.jsx("button",{type:"button",className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-current/70 transition-colors hover:bg-white/10 hover:text-current focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none","aria-label":"Dismiss notification",onClick:t,children:r.jsx(gr,{className:"size-3.5"})})]},e.id)})}const ta=2e4;function tP(e,t){const n=`/api/groups/${encodeURIComponent(e)}`;return t?`${n}?deleteEvidence=1`:n}function nP(e){return"/api/groups"}function P0(e){let t=0,n=0,s=0,o=0;for(const i of e.members)switch(i.status){case"completed":t+=1;break;case"failed":case"cancelled":n+=1;break;case"running":s+=1;break;case"created":break;case null:o+=1;break}return{memberCount:e.members.length,completedMembers:t,failedMembers:n,runningMembers:s,missingStatusMembers:o}}function sP(e,t,n=null){return t!==null&&t.group.id===e.id?t.members.map(s=>({member:s.member,exportMember:s,source:"export"})):n!==null&&n.group.id===e.id&&n.members!==null?n.members.map(s=>({member:s.member,exportMember:s,source:"evidence"})):e.members.map(s=>({member:s,exportMember:null,source:"group"}))}function vc(e){switch(e){case"completed":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"failed":case"cancelled":return"border-red-200 bg-red-50 text-red-700";case"running":return"border-sky-200 bg-sky-50 text-sky-700";case"created":return"border-zinc-200 bg-zinc-50 text-zinc-600";case null:return"border-zinc-200 bg-zinc-50 text-zinc-500"}}function yc(e){return e??"unknown"}function rP(e){switch(e){case"PASS":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"FAIL":return"border-red-200 bg-red-50 text-red-700";case"RUNNING":return"border-sky-200 bg-sky-50 text-sky-700";case"UNKNOWN":return"border-zinc-200 bg-zinc-50 text-zinc-600"}}function ki(e){return e===null||e.trim().length===0?"-":e}function xt(e){return e.toLocaleString()}function nl(e){return e==null?"-":e<1e3?`${xt(e)} ms`:`${(e/1e3).toFixed(1)} s`}function As(e){const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):e}function Yu(e){return e===null?"-":As(e)}function oP(e){const t=JSON.stringify(e),n=t===void 0?String(e):t;return n.length<=160?n:`${n.slice(0,157)}...`}function I0(...e){for(const t of e)if(t!==null&&t.trim().length>0)return t;return"-"}function iP(...e){for(const t of e)if(t!=null&&t.trim().length>0)return t;return null}function aP(e){const t=e.provider,n=e.model;return t!==null&&t.length>0&&n!==null&&n.length>0?`${t} / ${n}`:I0(t,n)}function lP(e,t){if(t!==null){const n=e.find(s=>s.id===t);if(n!==void 0)return n}return e[0]??null}function cP(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function uP(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function dP(e,t){return t!==null&&t.group.id===e.id?t.evidence:e.evidence}function pP(e,t,n){return t!==null&&t.group.id===e.id?t.summary:n!==null&&n.group.id===e.id?n.summary:null}function fP(e,t,n){return t!==null&&t.group.id===e.id?t.jenkinsReport:n!==null&&n.group.id===e.id?n.report:null}function mP(){const[e,t]=c.useState(!1),[n,s]=c.useState(null),[o,i]=c.useState(null),[a,l]=c.useState(null),[u,d]=c.useState(null),[p,f]=c.useState(null),[m,h]=c.useState(!1),[g,y]=c.useState(null),[b,w]=c.useState(null),[v,j]=c.useState(!1),{notice:_,showToast:k,dismissToast:S}=E0(),{groups:C,isLoading:M,error:A,mutate:P}=XR(),N=c.useMemo(()=>lP(C,n),[C,n]);c.useEffect(()=>{!e||n!==null&&C.some(D=>D.id===n)||s(C[0]?.id??null)},[C,e,n]);const I=N!==null&&u!==null&&u.group.id===N.id?u:null,{evidenceResponse:F,isLoading:B,error:J,mutate:K}=JR(N),W=c.useCallback(()=>{P()},[P]),V=c.useCallback(async()=>{if(!(C.length===0||v)){j(!0),f(null),h(!1),w(null),l(null);try{const oe=await qe(nP(!1),nf,ta,{method:"DELETE"},D=>`Clear failed with status ${String(D.status)}`);d(null),s(null),await P(),await K(),k({message:`Cleared ${xt(oe.deleted)} group${oe.deleted===1?"":"s"}.`,tone:"success"})}catch(oe){k({message:oe instanceof Error?oe.message:"Unknown error clearing groups",tone:"error"})}finally{j(!1)}}},[v,C.length,P,K,k]),z=c.useCallback(async oe=>{i(oe.id),l(null);try{const D=await qe(`/api/groups/${encodeURIComponent(oe.id)}/evidence`,vy,ta,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})},Ne=>`Export failed with status ${String(Ne.status)}`);d(D),await P(),await K()}catch(D){l(D instanceof Error?D.message:String(D))}finally{i(null)}},[P,K]),X=c.useCallback(oe=>{f(oe),h(!1),w(null)},[]),Y=c.useCallback(()=>{g===null&&(f(null),h(!1),w(null))},[g]),we=c.useCallback(oe=>{s(oe),f(null),h(!1),w(null)},[]),he=c.useCallback(async()=>{const oe=p;if(oe!==null){y(oe.id),w(null);try{await qe(tP(oe.id,m),tf,ta,{method:"DELETE"},D=>`Delete failed with status ${String(D.status)}`),d(D=>D!==null&&D.group.id===oe.id?null:D),s(D=>D===oe.id?null:D),f(null),h(!1),await P(),await K()}catch(D){w(D instanceof Error?D.message:String(D))}finally{y(null)}}},[m,p,P,K]);return r.jsxs(Zt,{open:e,onOpenChange:t,children:[r.jsx(R0,{notice:_,onDismiss:S}),r.jsx(yr,{asChild:!0,children:r.jsxs(ee,{type:"button",variant:"ghost",size:"icon",className:ji,"aria-label":"Evaluation groups",title:"Evaluation groups",children:[r.jsx(nu,{className:"size-4"}),M?r.jsx(Ue,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):C.length>0?r.jsx("span",{className:"absolute -right-1 -top-1 min-w-4 rounded-full bg-primary px-1 text-[10px] leading-4 text-primary-foreground",children:C.length}):null,r.jsx("span",{className:"sr-only",children:"Evaluation groups"})]})}),r.jsxs(Kt,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[r.jsx(Xt,{children:r.jsxs(Qt,{className:"flex items-center gap-2 pr-8",children:[r.jsx(nu,{className:"size-5 text-muted-foreground"}),r.jsx("span",{children:"Groups"}),r.jsx(Se,{variant:"outline",children:xt(C.length)})]})}),r.jsxs("div",{className:"flex min-h-0 items-center justify-between gap-3 border-b border-border pb-3",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"Evaluation batches, model runs, and exported evidence packs."}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsxs(ee,{type:"button",variant:"outline",size:"sm",disabled:C.length===0||v,onClick:()=>{V()},title:"Clear all groups. Session logs and run records stay intact.",children:[v?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(jn,{className:"size-3.5"}),"Clear"]}),r.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:W,children:[r.jsx(Vt,{className:"size-3.5"}),"Refresh"]})]})]}),r.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[260px_minmax(0,1fr)]",children:[r.jsx(hP,{groups:C,selectedGroupId:N?.id??null,isLoading:M,error:A,onSelect:we}),r.jsx(gP,{group:N,deleteTarget:p,deleteEvidence:m,exportResult:I,evidenceResponse:F,evidenceLoading:B,evidenceError:J,exportError:a,deleteError:b,exportingGroupId:o,deletingGroupId:g,onDeleteEvidenceChange:h,onExport:z,onRequestDelete:X,onCancelDelete:Y,onConfirmDelete:()=>{he()}})]})]})]})}function hP({groups:e,selectedGroupId:t,isLoading:n,error:s,onSelect:o}){return n?r.jsx("div",{className:"flex min-h-48 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:"Loading groups..."}):s!==void 0?r.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:s.message}):e.length===0?r.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-8 text-center text-xs text-muted-foreground",children:"No groups yet."}):r.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:r.jsx("div",{className:"space-y-2",children:e.map(i=>{const a=P0(i),l=t===i.id;return r.jsxs("button",{type:"button",onClick:()=>o(i.id),className:$("w-full rounded-md border px-3 py-2 text-left text-xs transition-colors",l?"border-primary bg-primary/5":"border-border bg-background hover:bg-muted/50"),children:[r.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[r.jsx("span",{className:"min-w-0 text-sm font-medium leading-snug",children:i.title}),r.jsx(Se,{variant:"outline",className:vc(i.status),children:yc(i.status)})]}),r.jsxs("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[r.jsxs("span",{children:[a.memberCount," sessions"]}),r.jsx("span",{children:As(i.updatedAt)})]})]},i.id)})})})}function gP({group:e,deleteTarget:t,deleteEvidence:n,exportResult:s,evidenceResponse:o,evidenceLoading:i,evidenceError:a,exportError:l,deleteError:u,exportingGroupId:d,deletingGroupId:p,onDeleteEvidenceChange:f,onExport:m,onRequestDelete:h,onCancelDelete:g,onConfirmDelete:y}){if(e===null)return r.jsx("div",{className:"flex min-h-48 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:"Select a group to inspect."});const b=P0(e),w=pP(e,s,o),v=fP(e,s,o),j=dP(e,s),_=sP(e,s,o),k=d===e.id,S=p===e.id,C=t?.id===e.id;return r.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[r.jsxs("div",{className:"min-w-0 space-y-1",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[r.jsx("h3",{className:"min-w-0 text-base font-semibold leading-snug",children:e.title}),r.jsx(Se,{variant:"outline",className:vc(e.status),children:yc(e.status)}),r.jsx(Se,{variant:"outline",children:e.kind})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:ki(e.project)}),r.jsxs("span",{children:["updated ",As(e.updatedAt)]})]})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(ee,{type:"button",variant:"outline",size:"icon",className:"size-8 text-red-600 hover:text-red-700","aria-label":"Delete group",title:"Delete group",disabled:S,onClick:()=>h(e),children:S?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(jn,{className:"size-3.5"})}),r.jsxs(ee,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:k||S,onClick:()=>{m(e)},children:[k?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(mr,{className:"size-3.5"}),"Export evidence"]})]})]}),e.task!==null&&e.task.trim().length>0&&r.jsx("p",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:e.task}),C&&r.jsx(xP,{group:e,deleteEvidence:n,isDeleting:S,error:u,onDeleteEvidenceChange:f,onCancel:g,onConfirm:y}),r.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[r.jsx(fn,{label:"Members",value:b.memberCount}),r.jsx(fn,{label:"Done",value:b.completedMembers}),r.jsx(fn,{label:"Failed",value:b.failedMembers}),r.jsx(fn,{label:"Running",value:b.runningMembers})]}),w!==null&&r.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[r.jsx(fn,{label:"Requests",value:w.requestCount}),r.jsx(fn,{label:"Errors",value:w.errorCount}),r.jsx(fn,{label:"Tokens",value:w.tokenUsage.total}),r.jsx(fn,{label:"Missing",value:w.missingSessions})]}),r.jsx(bP,{report:v,loading:i,error:a,hasEvidence:j!==null}),r.jsx(vP,{evidence:j}),l!==null&&r.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:l}),u!==null&&!C&&r.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:u}),r.jsx(yP,{rows:_})]})})}function xP({group:e,deleteEvidence:t,isDeleting:n,error:s,onDeleteEvidenceChange:o,onCancel:i,onConfirm:a}){const l=e.evidence!==null,u=e.evidence?.markdownPath??"No evidence pack exported.";return r.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-3 text-red-900",children:r.jsxs("div",{className:"flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[r.jsxs("div",{className:"min-w-0 space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[r.jsx(jn,{className:"size-4 text-red-600"}),r.jsx("span",{children:"Delete group?"})]}),r.jsxs("p",{className:"text-xs text-red-800",children:["Delete ",r.jsx("span",{className:"font-medium",children:e.title}),". Session logs and run records stay intact."]}),r.jsxs("label",{className:$("flex min-w-0 items-start gap-2 text-xs",l?"cursor-pointer":"opacity-60"),children:[r.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0",checked:t,disabled:!l||n,onChange:d=>o(d.currentTarget.checked)}),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block font-medium",children:"Also delete exported evidence files"}),r.jsx("code",{className:"mt-1 block truncate font-mono text-[11px] text-red-700",children:u})]})]}),s!==null&&r.jsx("div",{className:"rounded-md border border-red-200 bg-white px-2 py-1.5 text-xs text-red-700",children:s})]}),r.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[r.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:n,onClick:i,children:"Cancel"}),r.jsxs(ee,{type:"button",variant:"destructive",size:"sm",disabled:n,onClick:a,children:[n?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(jn,{className:"size-3.5"}),"Delete"]})]})]})})}function fn({label:e,value:t}){return r.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:e}),r.jsx("div",{className:"mt-1 font-mono text-sm font-semibold",children:xt(t)})]})}function bP({report:e,loading:t,error:n,hasEvidence:s}){const{copied:o,copy:i}=vn(e?.markdown??null);return e===null&&!t&&n===void 0?null:t?r.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:[r.jsx(Ue,{className:"size-3.5 animate-spin"}),"Loading evidence report..."]}):n!==void 0&&s?r.jsxs("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:["Failed to load evidence report: ",n.message]}):e===null?null:r.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"text-xs font-semibold",children:"Evidence report"}),r.jsx(Se,{variant:"outline",className:rP(e.status),children:e.status})]}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":o?"Copied evidence report":"Copy evidence report",onClick:i,children:o?r.jsx(Ge,{className:"size-3.5 text-emerald-500"}):r.jsx(Ot,{className:"size-3.5"})})]}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function vP({evidence:e}){return e===null?r.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No evidence pack exported yet."}):r.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("span",{className:"text-xs font-semibold",children:"Evidence paths"}),r.jsx("span",{className:"text-[11px] text-muted-foreground",children:As(e.exportedAt)})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx(na,{label:"JSON",value:e.jsonPath}),r.jsx(na,{label:"Markdown",value:e.markdownPath}),r.jsx(na,{label:"HTML",value:e.htmlPath})]})]})}function na({label:e,value:t}){const{copied:n,copy:s}=vn(t);return r.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border bg-background px-2 py-1.5",children:[r.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground",children:e}),r.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":n?`Copied ${e} path`:`Copy ${e} path`,onClick:s,children:n?r.jsx(Ge,{className:"size-3.5 text-emerald-500"}):r.jsx(Ot,{className:"size-3.5"})})]})}function yP({rows:e}){const[t,n]=c.useState(null),s=c.useCallback(o=>{n(i=>i===o?null:o)},[]);return e.length===0?r.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-8 text-center text-xs text-muted-foreground",children:"No sessions attached."}):r.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[r.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-xs font-semibold",children:"Members"}),r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[760px] text-left text-xs",children:[r.jsx("thead",{className:"border-b border-border bg-muted/20 text-muted-foreground",children:r.jsxs("tr",{children:[r.jsx("th",{className:"px-3 py-2 font-medium",children:"Session"}),r.jsx("th",{className:"px-3 py-2 font-medium",children:"Provider / Model"}),r.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),r.jsx("th",{className:"px-3 py-2 font-medium",children:"Requests"}),r.jsx("th",{className:"px-3 py-2 font-medium",children:"Errors"}),r.jsx("th",{className:"px-3 py-2 font-medium",children:"First chunk"}),r.jsx("th",{className:"px-3 py-2 font-medium",children:"Tokens"})]})}),r.jsx("tbody",{children:e.map(o=>{const i=t===o.member.id;return r.jsxs(c.Fragment,{children:[r.jsx(wP,{row:o,isExpanded:i,onToggleDetails:s}),r.jsx(jP,{row:o,isExpanded:i})]},o.member.id)})})]})})]})}function wP({row:e,isExpanded:t,onToggleDetails:n}){const s=e.member,o=e.exportMember?.session??null,i=cP(e),a=o?.inspectorPath??ep(s.sessionId),l=e.source!=="evidence",u=o?.requestCount??null,d=o?.errorCount??null,p=o?.tokenUsage.total??null,f=i?.firstChunkMs??null,m=I0(s.label,s.sessionId),h=iP(o?.clientUserAgent,i?.userAgent,s.agent),g=o?.clientProjectFolder??null,y=ac({userAgent:h,conversationId:s.sessionId,clientProjectFolder:g}),b=xi(y);return r.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/20",children:[r.jsxs("td",{className:"max-w-56 px-3 py-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground","aria-label":t?`Hide member ${m}`:`Show member ${m}`,title:t?"Hide member details":"Show member details",onClick:()=>{n(s.id)},children:t?r.jsx(nt,{className:"size-3.5"}):r.jsx(yt,{className:"size-3.5"})}),b!==null&&r.jsx(bi,{client:y,className:"size-5"}),l?r.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",className:"inline-flex max-w-full min-w-0 items-center gap-2 rounded-sm font-mono text-xs text-primary outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","aria-label":`Open session ${m}`,title:`Open session ${m}`,children:[r.jsx("span",{className:"min-w-0 truncate",children:m}),r.jsx(Ml,{className:"size-3 shrink-0 text-muted-foreground"})]}):r.jsxs("button",{type:"button",className:"inline-flex max-w-full min-w-0 items-center gap-2 rounded-sm font-mono text-xs text-foreground outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",title:`Show evidence snapshot for ${m}`,"aria-label":`Show evidence snapshot for ${m}`,onClick:()=>{n(s.id)},children:[r.jsx("span",{className:"min-w-0 truncate",children:m}),r.jsx(Se,{variant:"outline",className:"shrink-0 border-zinc-200 bg-zinc-50 text-zinc-600",children:"evidence"})]})]}),r.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:ki(s.agent)})]}),r.jsx("td",{className:"max-w-52 px-3 py-2",children:r.jsx("span",{className:"block whitespace-normal leading-snug",children:aP(s)})}),r.jsx("td",{className:"px-3 py-2",children:r.jsx(Se,{variant:"outline",className:vc(s.status),children:yc(s.status)})}),r.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":xt(u)}),r.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":xt(d)}),r.jsx("td",{className:"px-3 py-2 font-mono",children:nl(f)}),r.jsx("td",{className:"px-3 py-2 font-mono",children:p===null?"-":xt(p)})]})}function jP({row:e,isExpanded:t}){if(!t)return null;const n=e.member,s=e.exportMember,o=s?.session??null,i=s?.run??null,a=Object.entries(n.metadata);return r.jsx("tr",{className:"border-b border-border bg-muted/10",children:r.jsx("td",{colSpan:7,className:"px-3 pb-4 pt-2",children:r.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-background p-3",children:[r.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[r.jsx(st,{label:"Source",value:uP(e.source)}),r.jsx(st,{label:"Member ID",value:n.id,mono:!0}),r.jsx(st,{label:"Session ID",value:n.sessionId,mono:!0}),r.jsx(st,{label:"Run ID",value:i?.id??n.runId??"-",mono:!0}),r.jsx(st,{label:"Created",value:As(n.addedAt)}),r.jsx(st,{label:"Updated",value:As(n.updatedAt)}),r.jsx(st,{label:"Session created",value:Yu(o?.createdAt??null)}),r.jsx(st,{label:"Session updated",value:Yu(o?.updatedAt??null)})]}),o===null?r.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No session snapshot is available for this member."}):r.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[r.jsx(st,{label:"Log coverage",value:o.logCoverage}),r.jsx(st,{label:"Runtime",value:ki(o.runtimeMode)}),r.jsx(st,{label:"Requests",value:xt(o.requestCount),mono:!0}),r.jsx(st,{label:"Errors",value:xt(o.errorCount),mono:!0}),r.jsx(st,{label:"Input tokens",value:xt(o.tokenUsage.input),mono:!0}),r.jsx(st,{label:"Output tokens",value:xt(o.tokenUsage.output),mono:!0}),r.jsx(st,{label:"Cache read",value:xt(o.tokenUsage.cacheRead),mono:!0}),r.jsx(st,{label:"Total tokens",value:xt(o.tokenUsage.total),mono:!0})]}),r.jsx(kP,{logs:o?.latestLogs??[]}),r.jsx(_P,{entries:a})]})})})}function st({label:e,value:t,mono:n=!1}){return r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),r.jsx("div",{className:$("truncate text-xs text-foreground",n?"font-mono":""),title:t,children:t})]})}function kP({logs:e}){const t=e.slice(0,5);return t.length===0?r.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No latest logs in this snapshot."}):r.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[r.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Latest logs"}),r.jsx("div",{className:"divide-y divide-border",children:t.map(n=>{const s=n.sessionLogNumber??n.id;return r.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs sm:grid-cols-[72px_1fr_88px_88px]",children:[r.jsxs("span",{className:"font-mono text-muted-foreground",title:`Log ID ${String(n.id)}`,children:["#",s]}),r.jsxs("span",{className:"min-w-0 truncate",children:[ki(n.model)," · ",n.apiFormat," · ",n.path]}),r.jsx("span",{className:"font-mono text-muted-foreground",children:nl(n.firstChunkMs)}),r.jsx("span",{className:"font-mono text-muted-foreground",children:nl(n.latencyMs)})]},n.id)})})]})}function _P({entries:e}){return e.length===0?null:r.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[r.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Metadata"}),r.jsx("div",{className:"grid gap-x-3 gap-y-2 p-3 text-xs sm:grid-cols-2",children:e.map(([t,n])=>{const s=oP(n);return r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"mr-2 text-muted-foreground",children:t}),r.jsx("span",{className:"font-mono text-foreground",title:s,children:s})]},t)})})]})}const SP=T({selectionId:x().uuid(),name:x(),apiKeyHint:x(),format:fe(["anthropic","openai"]),anthropicBaseUrl:x(),openaiBaseUrl:x(),openaiResponsesBaseUrl:x().optional().default(""),models:H(x()),sourceTool:fe(["claude-code","opencode","mimo-code"]),alreadyExists:Te()}),NP=T({scanId:x().uuid(),providers:H(SP),warnings:H(x()).optional()});T({scanId:x().uuid(),selectionIds:H(x().uuid()).min(1).max(100)});const CP=T({success:Te().optional(),imported:R().optional(),message:x().optional(),errors:H(x()).optional()}),Xu=2e4;function TP({open:e,onOpenChange:t,onImportComplete:n}){const[s,o]=c.useState(!1),[i,a]=c.useState(null),[l,u]=c.useState(null),[d,p]=c.useState([]),[f,m]=c.useState([]),[h,g]=c.useState(new Set),[y,b]=c.useState(!1),[w,v]=c.useState(null),[j,_]=c.useState(null),k=c.useRef(0),S=c.useRef(0),C=c.useCallback(()=>{const N=k.current+1;k.current=N,o(!0),a(null),m([]),u(null),p([]),g(new Set),v(null),_(null),qe("/api/providers/scan",NP,Xu,{method:"POST"},I=>`Scan failed (${String(I.status)})`).then(I=>{if(k.current!==N)return;u(I.scanId),p(I.providers),m(I.warnings??[]);const F=new Set;I.providers.forEach((B,J)=>{B.alreadyExists||F.add(J)}),g(F)}).catch(I=>{k.current===N&&a(I instanceof Error?I.message:String(I))}).finally(()=>{k.current===N&&o(!1)})},[]);c.useEffect(()=>{e&&C()},[e,C]),c.useEffect(()=>{e||(k.current+=1,S.current+=1,o(!1),b(!1))},[e]);const M=c.useCallback(N=>{g(I=>{const F=new Set(I);return F.has(N)?F.delete(N):F.add(N),F})},[]),A=c.useCallback(()=>{const N=d.filter((F,B)=>h.has(B));if(N.length===0||l===null)return;const I=S.current+1;S.current=I,b(!0),_(null),v(null),qe("/api/providers/import",CP,Xu,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scanId:l,selectionIds:N.map(F=>F.selectionId)})},F=>`Import failed (${String(F.status)})`).then(F=>{S.current===I&&(p(B=>B.map((J,K)=>h.has(K)?{...J,alreadyExists:!0}:J)),g(new Set),F.errors!==void 0&&F.errors.length>0&&F.message!==void 0?v(F.message):v(`Imported ${F.imported??N.length} provider(s)`),n())}).catch(F=>{S.current===I&&_(F instanceof Error?F.message:String(F))}).finally(()=>{S.current===I&&b(!1)})},[d,l,h,n]),P=d.some(N=>!N.alreadyExists);return r.jsx(Zt,{open:e,onOpenChange:t,children:r.jsxs(Kt,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[r.jsxs(Xt,{children:[r.jsx(Qt,{children:"Import from External Tools"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[s&&r.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[r.jsx(Ue,{className:"size-4 animate-spin"}),r.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),i!==null&&r.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[r.jsx(Ns,{className:"size-4"}),i]}),!s&&i===null&&d.length===0&&r.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",r.jsx("br",{}),r.jsx("span",{className:"text-xs",children:"Supported tools: Claude Code (~/.claude/settings.json), OpenCode (~/.config/opencode/opencode.json), MiMo Code (~/.config/mimocode/mimocode.jsonc)"})]}),!s&&d.map((N,I)=>r.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${N.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!N.alreadyExists&&r.jsx("input",{type:"checkbox",checked:h.has(I),disabled:y,onChange:()=>M(I),className:"mt-0.5 size-4"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(bi,{client:N.sourceTool,className:"size-7 rounded-[8px]"}),N.alreadyExists&&r.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),r.jsxs("div",{className:"mt-1 text-xs leading-snug text-muted-foreground",children:[N.models.slice(0,4).join(", "),N.models.length>4?` +${N.models.length-4} more`:""]}),r.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:N.format==="anthropic"?N.anthropicBaseUrl:N.openaiResponsesBaseUrl!==""?N.openaiResponsesBaseUrl:N.openaiBaseUrl}),r.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:N.apiKeyHint})]})]},N.selectionId)),f.length>0&&r.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:f.map((N,I)=>r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(Ns,{className:"size-3"}),N]},I))}),w!==null&&r.jsx("div",{className:"text-sm text-green-500 border-t pt-2",children:w}),j!==null&&r.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:j})]}),r.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[r.jsxs(ee,{variant:"outline",size:"sm",onClick:C,disabled:s,children:[r.jsx(Ue,{className:`size-3 mr-1 ${s?"animate-spin":""}`}),"Rescan"]}),r.jsxs(ee,{size:"sm",onClick:A,disabled:!P||h.size===0||y,children:[r.jsx(mr,{className:"size-3 mr-1"}),y?"Importing...":`Import Selected (${h.size})`]})]})]})})}const M0=T({id:x().min(1).max(Ra),aliases:H(x().max(Ra)).max(Bn).optional().default([]),contextWindow:R().int().positive().optional(),outputLimit:R().int().positive().optional(),sourceUrl:x().optional()}),EP=T({name:x().min(1).optional(),aliases:H(x()).max(Bn).optional().default([]),baseUrls:H(x()).max(Bn).optional().default([]),models:H(M0).min(1).max(Bn)});T({version:R().int().positive().optional(),updatedAt:x().optional(),providers:H(EP).max(Bn).optional().default([]),models:H(M0).max(Bn).optional().default([])});function Qu(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function RP(e){const t=e.models.filter(n=>n.trim()!=="");return t.length>0?t:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function wc(e,t){const n=Qu(t);return(e.modelMetadata??[]).find(o=>Qu(o.model)===n)??null}function PP(e){const t=RP(e);return t.length===0?!1:t.every(n=>{const s=wc(e,n);return s!==null&&s.contextWindow!==void 0})}function IP(e,t){if(e===null)return null;for(const n of t){const s=wc(n,e);if(s!==null&&s.contextWindow!==void 0)return{providerName:n.name,model:s.model,tokens:s.contextWindow,sourceUrl:s.sourceUrl}}return null}function ur(e){return Object.prototype.hasOwnProperty.call(e,"success")}function _i(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function kt(e){return e!==void 0&&e!==""}function at(e){return e!==void 0&&e.trim()!==""}function js(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function A0(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function O0(e){switch(e){case"timeout":return"Timeout";case"network_unreachable":return"Offline";case"connection_refused":return"Refused";case"auth_failed":return"Auth";case"rate_limited":return"Rate limit";case"server_error":return"Server";case"invalid_response":return"Invalid";case"unknown":return"Failed"}}function MP(e){return e.firstChunkMs!==void 0&&e.firstChunkMs!==null?js(e.firstChunkMs):e.latencyMs!==void 0?js(e.latencyMs):e.totalStreamMs!==void 0&&e.totalStreamMs!==null?js(e.totalStreamMs):e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?A0(e.tokensPerSecond):null}function AP(e){return _i(e)?{tone:"quiet",label:"N/A",metric:null,hasDetails:!1}:ur(e)?e.success?{tone:"success",label:"Pass",metric:MP(e),hasDetails:!0}:{tone:"failure",label:O0(e.error?.type??"unknown"),metric:null,hasDetails:!0}:{tone:"pending",label:"Running",metric:null,hasDetails:!1}}function OP(e,t){if(t===void 0)return[];const n=[];return kt(e.anthropicBaseUrl)&&n.push(t.anthropic),kt(e.openaiBaseUrl)&&n.push(t.openaiChat),kt(e.openaiResponsesBaseUrl)&&n.push(t.openaiResponses),n}function zP(e,t){const n={total:0,passed:0,failed:0,testing:0};for(const s of OP(e,t))for(const o of[s.nonStreaming,s.streaming])_i(o)||(n.total+=1,ur(o)?o.success?n.passed+=1:n.failed+=1:n.testing+=1);return n}function ed(e){if(e===void 0)return;const t=Object.entries(e).map(([n,s])=>`${n}: ${s}`);return t.length===0?void 0:t.join(`
124
+ `)}function mn({title:e,children:t}){return r.jsxs("section",{className:"space-y-1.5",children:[r.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:e}),t]})}function zn({value:e}){return r.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/40 p-3 font-mono text-[11px] leading-relaxed text-foreground/80",children:e})}function Ln({label:e,value:t}){return r.jsxs("div",{className:"min-w-0 rounded-md bg-muted/35 px-3 py-2",children:[r.jsx("dt",{className:"text-[10px] text-muted-foreground",children:e}),r.jsx("dd",{className:"mt-1 truncate font-mono text-xs font-semibold text-foreground",title:t,children:t})]})}function LP({result:e}){const t=e.inputTokens!==void 0||e.outputTokens!==void 0,n=e.cacheCreationInputTokens!==void 0||e.cacheReadInputTokens!==void 0;return at(e.model)||t||n||e.latencyMs!==void 0||e.firstChunkMs!==void 0&&e.firstChunkMs!==null||e.totalStreamMs!==void 0&&e.totalStreamMs!==null||e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?r.jsxs("dl",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:[at(e.model)&&r.jsx(Ln,{label:"Model",value:e.model}),e.latencyMs!==void 0&&r.jsx(Ln,{label:"Latency",value:js(e.latencyMs)}),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&r.jsx(Ln,{label:"First chunk",value:js(e.firstChunkMs)}),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&r.jsx(Ln,{label:"Stream total",value:js(e.totalStreamMs)}),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&r.jsx(Ln,{label:"Token rate",value:`${A0(e.tokensPerSecond)} tok`}),t&&r.jsx(Ln,{label:"Tokens in / out",value:`${String(e.inputTokens??0)} / ${String(e.outputTokens??0)}`}),n&&r.jsx(Ln,{label:"Cache create / read",value:`${String(e.cacheCreationInputTokens??0)} / ${String(e.cacheReadInputTokens??0)}`})]}):null}function $P({result:e}){const t=e.debug,n=t?.requestUrl,s=t?.requestMethod??"POST",o=ed(t?.requestHeaders),i=ed(t?.responseHeaders),a=t?.responseStatus===void 0?void 0:`${String(t.responseStatus)}${at(t.responseStatusText)?` ${t.responseStatusText}`:""}`,l=t?.responseBody??e.rawResponse;return at(e.error?.hint)||at(e.error?.details)||at(n)||o!==void 0||at(t?.requestBody)||at(a)||i!==void 0||at(l)?r.jsxs("div",{className:"space-y-4 border-t border-border/70 pt-4 text-xs text-muted-foreground",children:[at(e.error?.hint)&&r.jsx(mn,{title:"Hint",children:r.jsx("p",{className:"break-words text-foreground/80",children:e.error.hint})}),at(e.error?.details)&&r.jsx(mn,{title:"Error details",children:r.jsx(zn,{value:e.error.details})}),at(n)&&r.jsx(mn,{title:"Request",children:r.jsx(zn,{value:`${s} ${n}`})}),o!==void 0&&r.jsx(mn,{title:"Request headers",children:r.jsx(zn,{value:o})}),at(t?.requestBody)&&r.jsx(mn,{title:"Request body",children:r.jsx(zn,{value:t.requestBody})}),at(a)&&r.jsx(mn,{title:"Response status",children:r.jsx(zn,{value:a})}),i!==void 0&&r.jsx(mn,{title:"Response headers",children:r.jsx(zn,{value:i})}),at(l)&&r.jsx(mn,{title:"Response body",children:r.jsx(zn,{value:l})})]}):null}function DP({result:e,probeLabel:t,children:n}){const s=e.error?.message??"Connection failed";return r.jsxs(Zt,{children:[r.jsx(yr,{asChild:!0,children:n}),r.jsxs(Kt,{className:"max-h-[82vh] max-w-2xl gap-0 overflow-hidden p-0",children:[r.jsxs(Xt,{className:"border-b border-border/70 px-5 py-4 pr-12",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[e.success?r.jsx(fr,{className:"size-4 text-cyan-300"}):r.jsx(Ns,{className:"size-4 text-red-300"}),r.jsx(Qt,{className:"text-base",children:t})]}),r.jsx(wr,{children:e.success?"Connection probe passed.":s})]}),r.jsxs("div",{className:"space-y-4 overflow-y-auto p-5",children:[!e.success&&r.jsxs("div",{className:"rounded-md border border-red-400/20 bg-red-400/[0.06] px-3 py-2 text-sm text-red-200",children:[r.jsx("div",{className:"font-medium",children:O0(e.error?.type??"unknown")}),r.jsx("div",{className:"mt-1 break-words text-xs text-muted-foreground",children:s})]}),r.jsx(LP,{result:e}),r.jsx($P,{result:e})]})]})]})}function FP(e){const t="size-3 shrink-0";switch(e){case"timeout":return r.jsx(rn,{className:t});case"network_unreachable":return r.jsx(l5,{className:t});case"connection_refused":return r.jsx(u5,{className:t});case"auth_failed":return r.jsx(cj,{className:t});case"rate_limited":return r.jsx(Al,{className:t});case"server_error":return r.jsx(Hj,{className:t});case"invalid_response":return r.jsx(mw,{className:t});case"unknown":return r.jsx(Ns,{className:t})}}const UP={success:"bg-cyan-300/[0.07] text-cyan-100 hover:bg-cyan-300/[0.11]",failure:"bg-red-400/[0.07] text-red-200 hover:bg-red-400/[0.11]",pending:"bg-muted/40 text-foreground/80",quiet:"bg-transparent text-muted-foreground/70"};function td({result:e,probeLabel:t}){const n=AP(e),s=_i(e)?r.jsx(gf,{className:"size-3 shrink-0"}):ur(e)?e.success?r.jsx(fr,{className:"size-3 shrink-0"}):FP(e.error?.type??"unknown"):r.jsx(yo,{className:"size-3 shrink-0 animate-spin"}),o=r.jsxs(r.Fragment,{children:[s,r.jsx("span",{className:"min-w-0 truncate",children:n.label}),n.metric!==null&&r.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] opacity-75",children:n.metric})]}),i=$("inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors",UP[n.tone]);return ur(e)&&n.hasDetails?r.jsx(DP,{result:e,probeLabel:t,children:r.jsx("button",{type:"button",className:i,"aria-label":`Open ${t} result: ${n.label}`,children:o})}):r.jsx("div",{className:i,children:o})}function nd({label:e}){return r.jsxs("div",{className:"inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground/70",children:[r.jsx(gf,{className:"size-3 shrink-0"}),r.jsx("span",{className:"truncate",children:e})]})}function sa({label:e,results:t,configured:n=!0}){return r.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(6.5rem,1fr)_minmax(6rem,0.9fr)_minmax(6rem,0.9fr)] items-center gap-2 border-t border-border/60 px-2 py-2",children:[r.jsx("div",{className:"min-w-0 truncate text-xs font-medium text-foreground/85",title:e,children:e}),n&&t!==void 0?r.jsx(td,{result:t.nonStreaming,probeLabel:`${e} non-stream`}):r.jsx(nd,{label:n?"Not tested":"Off"}),n&&t!==void 0?r.jsx(td,{result:t.streaming,probeLabel:`${e} stream`}):r.jsx(nd,{label:n?"Not tested":"Off"})]})}function z0({provider:e,results:t}){const n=kt(e.anthropicBaseUrl),s=kt(e.openaiBaseUrl),o=kt(e.openaiResponsesBaseUrl);return!n&&!s&&!o?r.jsx("div",{className:"text-xs text-muted-foreground",children:"No testable endpoint configured."}):r.jsx("div",{className:"min-w-0 overflow-x-auto rounded-md border border-border/70",children:r.jsxs("div",{className:"min-w-[20rem]",children:[r.jsxs("div",{className:"grid grid-cols-[minmax(6.5rem,1fr)_minmax(6rem,0.9fr)_minmax(6rem,0.9fr)] gap-2 bg-muted/25 px-2 py-1.5 text-[10px] text-muted-foreground",children:[r.jsx("span",{children:"Protocol"}),r.jsx("span",{children:"Non-stream"}),r.jsx("span",{children:"Stream"})]}),n&&r.jsx(sa,{label:"Anthropic",results:t?.anthropic}),s&&r.jsx(sa,{label:"OpenAI Chat",results:t?.openaiChat}),r.jsx(sa,{label:"OpenAI Responses",results:t?.openaiResponses,configured:o})]})})}function BP(e){const t={total:0,passed:0,failed:0,testing:0};for(const n of[e.nonStreaming,e.streaming])_i(n)||(t.total+=1,ur(n)?n.success?t.passed+=1:t.failed+=1:t.testing+=1);return t}function ra({label:e,results:t}){const n=BP(t),s=n.failed>0?"border-red-400/20 bg-red-400/[0.06] text-red-200":n.testing>0?"border-amber-300/20 bg-amber-300/[0.06] text-amber-100":n.total>0&&n.passed===n.total?"border-cyan-300/20 bg-cyan-300/[0.06] text-cyan-100":"border-border/60 bg-transparent text-muted-foreground",o=n.failed>0?`${n.failed} fail`:n.testing>0?"running":n.total===0?"off":`${n.passed}/${n.total}`;return r.jsxs("span",{className:$("rounded border px-1.5 py-0.5 text-[10px]",s),children:[e," ",o]})}function VP({provider:e,modelName:t,results:n,expanded:s,onToggle:o}){return r.jsxs("div",{className:"min-w-0",children:[r.jsxs("button",{type:"button",onClick:o,className:"flex w-full min-w-0 flex-wrap items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-muted/20","aria-expanded":s,children:[s?r.jsx(nt,{className:"size-3.5 shrink-0 text-muted-foreground"}):r.jsx(yt,{className:"size-3.5 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-[8rem] flex-1 truncate text-xs font-medium",title:t,children:t}),r.jsxs("span",{className:"flex flex-wrap items-center justify-end gap-1",children:[kt(e.anthropicBaseUrl)&&r.jsx(ra,{label:"A",results:n.anthropic}),kt(e.openaiBaseUrl)&&r.jsx(ra,{label:"Chat",results:n.openaiChat}),kt(e.openaiResponsesBaseUrl)&&r.jsx(ra,{label:"Resp",results:n.openaiResponses})]})]}),s&&r.jsx("div",{className:"px-2 pb-3",children:r.jsx(z0,{provider:e,results:n})})]})}function qP({provider:e,testResults:t}){const n=Object.entries(t.models??{}),[s,o]=c.useState(!1),[i,a]=c.useState(null);return n.length===0?null:r.jsxs("section",{className:"space-y-2",children:[r.jsxs("button",{type:"button",onClick:()=>o(l=>!l),className:"flex w-full items-center gap-1.5 text-left text-xs font-medium text-foreground/80 transition-colors hover:text-foreground","aria-expanded":s,children:[s?r.jsx(nt,{className:"size-3.5"}):r.jsx(yt,{className:"size-3.5"}),"Model probes",r.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:n.length})]}),s&&r.jsx("div",{className:"min-w-0 divide-y divide-border/60 rounded-md border border-border/70",children:n.map(([l,u])=>r.jsx(VP,{provider:e,modelName:l,results:u,expanded:i===l,onToggle:()=>a(d=>d===l?null:l)},l))})]})}function HP({provider:e,testResults:t,isTesting:n}){const s=kt(e.anthropicBaseUrl)||kt(e.openaiBaseUrl)||kt(e.openaiResponsesBaseUrl),o=zP(e,t);return n?r.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-cyan-300/25 bg-cyan-300/[0.08] px-2 py-1 text-xs text-cyan-100",children:[r.jsx(yo,{className:"size-3 animate-spin"}),"Testing"]}):s?t===void 0||o.total===0?r.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"Not tested"}):o.failed>0?r.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-red-400/25 bg-red-500/[0.08] px-2 py-1 text-xs text-red-200",children:[r.jsx(Ns,{className:"size-3"}),o.failed," failed"]}):o.testing>0||o.passed<o.total?r.jsxs("span",{className:"rounded border border-amber-300/25 bg-amber-400/[0.08] px-2 py-1 text-xs text-amber-100",children:[o.passed,"/",o.total]}):r.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-cyan-300/25 bg-cyan-300/[0.08] px-2 py-1 text-xs text-cyan-100",children:[r.jsx(fr,{className:"size-3"}),o.passed,"/",o.total]}):r.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"No endpoint"})}const WP={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function oa(e){return e!==void 0&&e!==""}function ia({label:e}){return r.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border/70 bg-muted/25 px-1.5 py-0.5 text-foreground/80",children:[r.jsx(fr,{className:"size-3"}),e]})}function ZP({provider:e}){const t=oa(e.anthropicBaseUrl),n=oa(e.openaiBaseUrl),s=oa(e.openaiResponsesBaseUrl);return!t&&!n&&!s?r.jsx("div",{className:"text-xs text-muted-foreground",children:"Test requires at least one configured endpoint."}):r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[t&&r.jsx(ia,{label:"Anthropic"}),n&&r.jsx(ia,{label:"OpenAI Chat"}),s&&r.jsx(ia,{label:"OpenAI Responses"})]})}function KP(e){const t=e.models??[];if(t.length===0)return"No models configured";const n=t.slice(0,2).join(", "),s=t.length-2;return s>0?`${n} +${s} more`:n}function GP({provider:e,model:t}){const n=wc(e,t),s=YP(n?.sourceUrl);return r.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[r.jsx("span",{children:t}),n!==null&&n.contextWindow!==void 0&&r.jsx("span",{className:"font-mono text-foreground/80",children:np(n.contextWindow)}),s!==null&&r.jsx(Ds,{children:r.jsxs(ft,{children:[r.jsx(mt,{asChild:!0,children:r.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 rounded border border-border/70 bg-background/70 px-1 font-mono text-[10px] leading-4 text-muted-foreground transition-colors hover:text-foreground","aria-label":s.title,children:s.label})}),r.jsx(ht,{children:s.title})]})})]})}function JP(e){const t=Date.now(),n=new Date(e).getTime(),s=t-n,o=Math.floor(s/1e3);if(o<60)return"just now";const i=Math.floor(o/60);if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function YP(e){if(e===void 0||e.trim()==="")return null;try{const t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;const n=t.hostname.toLowerCase(),s=n==="huggingface.co"||n.endsWith(".huggingface.co");return{label:s?"HF":"Source",title:s?"Open Hugging Face model source":"Open model metadata source",url:e}}catch{return null}}function XP({provider:e,testResults:t,isTesting:n,testingTimeLeft:s,isHighlighted:o,onEdit:i,onDelete:a,onTest:l,onRefreshMetadata:u,isRefreshingMetadata:d=!1}){const[p,f]=c.useState(!1),m=e.apiDocsUrl??Object.entries(WP).find(([v])=>e.name.toLowerCase().includes(v))?.[1],h=PP(e),g=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",y=g?"Refresh":"Import defaults",b=n??!1,w=e.source==="company"?r.jsx("span",{className:"shrink-0 rounded border border-cyan-300/20 bg-cyan-300/[0.08] px-1.5 py-0.5 text-xs text-cyan-100",children:"Company"}):e.source==="personal"?r.jsx("span",{className:"shrink-0 rounded border border-violet-300/20 bg-violet-300/[0.08] px-1.5 py-0.5 text-xs text-violet-100",children:"Personal"}):null;return r.jsxs("div",{"data-provider-id":e.id,className:`flex flex-col gap-3 rounded-[8px] border border-border bg-card p-4 shadow-sm transition-all duration-500 ${o===!0?"ring-2 ring-primary shadow-md":""}`,children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 space-y-1",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[r.jsx("span",{className:"font-medium leading-snug",children:e.name}),w]}),r.jsx("div",{className:"text-xs leading-snug text-muted-foreground",children:KP(e)})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(HP,{provider:e,testResults:t,isTesting:b}),m!==void 0&&r.jsxs("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",title:"View API documentation",children:[r.jsx(Ml,{className:"size-3"}),r.jsx("span",{className:"sr-only",children:"Docs"})]})]})]}),r.jsxs("div",{className:"flex flex-col gap-2 text-xs text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[r.jsx(ZP,{provider:e}),t?.testedAt!==void 0&&r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(rn,{className:"size-3"}),JP(t.testedAt)]})]}),!h&&r.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-amber-500/25 bg-amber-500/6 px-2 py-1.5 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Context window metadata missing"}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[r.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>u?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:d,children:[r.jsx(yo,{className:`size-3 ${d?"animate-spin":""}`}),y]}),!g&&r.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),p&&r.jsxs("div",{className:"space-y-3 border-t border-border/60 pt-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx(fr,{className:"size-3.5 text-emerald-500"}),r.jsx("span",{children:"API key configured"})]}),e.models!==void 0&&e.models.length>0&&r.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(v=>r.jsx(GP,{provider:e,model:v},v))}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:"Connection probes"}),r.jsx(z0,{provider:e,results:t})]}),t!==void 0&&r.jsx(qP,{provider:e,testResults:t})]}),r.jsxs("div",{className:"flex flex-col gap-2 border-t pt-1 sm:flex-row sm:items-center sm:justify-between",children:[r.jsxs("button",{type:"button",onClick:()=>f(v=>!v),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":p,children:[p?r.jsx(nt,{className:"size-3"}):r.jsx(yt,{className:"size-3"}),"Details"]}),r.jsxs("div",{className:"flex gap-2",children:[l!==void 0&&r.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>l(e.id),className:"text-xs h-7 gap-1",disabled:b,children:[r.jsx(yo,{className:`size-3 ${b?"animate-spin":""}`}),b?s!==void 0?`Testing (${s}s)`:"Testing...":"Test"]}),r.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>i(e),className:"text-xs h-7 gap-1",disabled:b,children:[r.jsx(xf,{className:"size-3"}),"Edit"]}),r.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>a(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:b,children:[r.jsx(jn,{className:"size-3"}),"Delete"]})]})]})]})}const ks="/v1/chat/completions",sl="/v1/responses",QP="/v1/messages";function eI(e,t){const n=e.endsWith("/")?e.slice(0,-1):e,s=L0(t),o=t.indexOf("?"),i=o>=0?t.slice(o):"";return s!==""&&n.endsWith(s)?n+i:D0(n)&&$0(t)||n.endsWith("/v1")&&t.startsWith("/v1/")?n+t.slice(3):n+t}function tI(e,t,n={}){const s=e.trim().replace(/\/+$/,""),o=L0(t),i=eI(s,t),a=[];return o!==""&&s.endsWith(o)?a.push({severity:"info",message:"This already includes the exact endpoint; no duplicate suffix will be appended."}):D0(s)&&$0(t)?a.push({severity:"info",message:"Zhipu bases already include the API version; only /chat/completions is appended."}):s.endsWith("/v1")&&t.startsWith("/v1/")&&a.push({severity:"info",message:"Base URL already ends with /v1; the suffix will not repeat /v1."}),sd(o)&&sI(s)&&a.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),nI(o)&&rI(s)&&a.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),sd(o)&&oI(s,n.providerName)&&a.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:i,diagnostics:a}}function L0(e){return e.split("?")[0]??e}function $0(e){return e===ks||e.startsWith(`${ks}?`)||e.startsWith(`${ks}/`)}function nI(e){return e===ks||e.startsWith(`${ks}/`)}function sd(e){return e===sl||e.startsWith(`${sl}/`)}function sI(e){return e.toLowerCase().endsWith("/chat/completions")}function rI(e){return e.toLowerCase().endsWith("/responses")}function oI(e,t){const n=t?.toLowerCase();if(n!==void 0&&n.includes("deepseek"))return!0;try{return new URL(e).hostname.toLowerCase().includes("deepseek")}catch{return e.toLowerCase().includes("deepseek")}}function D0(e){try{const t=new URL(e),n=t.pathname.replace(/\/+$/,"");return t.hostname==="open.bigmodel.cn"&&(n==="/api/paas/v4"||n==="/api/coding/paas/v4")}catch{return!1}}function aa(e){return e!==void 0&&e.trim()!==""}function rd(e){const t=aa(e?.anthropicBaseUrl),n=aa(e?.openaiBaseUrl),s=aa(e?.openaiResponsesBaseUrl);return{anthropic:t,openai:n||s,openaiChat:n,openaiResponses:s}}function la(e,t,n){if(!e)return n?"":void 0;const s=t.trim();return s===""?void 0:s}const od=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],id=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],qr=QP,Hr=ks,Wr=sl,iI={deepseek:{openaiBaseUrl:"https://api.deepseek.com"},minimax:{anthropicBaseUrl:"https://api.minimaxi.com/anthropic",openaiBaseUrl:"https://api.minimaxi.com",openaiResponsesBaseUrl:"https://api.minimaxi.com",apiDocsUrl:"https://platform.minimaxi.com/docs/api-reference/api-overview"},"zhipu coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"glm coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"bigmodel coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"z.ai coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"zai coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},zhipu:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},zhipuai:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},bigmodel:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},"z.ai":{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},zai:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},glm:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},alibaba:{openaiBaseUrl:"https://dashscope.aliyuncs.com/compatible-mode"}},ad=["MiniMax M3","MiniMax M2.7","MiniMax M2.7-highspeed","MiniMax M2.5","MiniMax M2.5-highspeed","MiniMax M2.1","MiniMax M2.1-highspeed","MiniMax M2"],ld=["qwen3.6-plus","qwen3.7-max"],cd=["glm-5.2","glm-5.1","glm-5","glm-5-turbo","glm-4.7","glm-4.7-flashx","glm-4.6","glm-4.5","glm-4.5-air","glm-4.5-x","glm-4.5-airx","glm-4.5-flash"],rl="__unset__",Ao="__custom__",F0=[{value:"32K",label:"Small"},{value:"64K",label:"Standard"},{value:"128K",label:"Medium"},{value:"200K",label:"Long"},{value:"256K",label:"Extended"},{value:"512K",label:"Large"},{value:"1M",label:"Max"}];function $n(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function ud(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function U0(e,t){const n=ud(t);return e?.modelMetadata?.find(s=>ud(s.model)===n)??null}function B0(e){const t=uo(e);if(t===null)return null;for(const n of F0)if(uo(n.value)===t)return n.value;return null}function aI(e){return e.trim()===""?"unset":B0(e)!==null?"preset":"custom"}function lI(e){switch(e.contextWindowMode){case"unset":return rl;case"custom":return Ao;case"preset":return B0(e.contextWindow)??Ao}}function ca(e){const t=e.trim().replaceAll(",","");if(t==="")return{amount:"",unit:"K"};const n=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(t);if(n===null)return{amount:t,unit:"K"};const s=n[1];if(s===void 0)return{amount:t,unit:"K"};const o=n[2];if(o===void 0||o==="")return{amount:s,unit:"tokens"};switch(o.toLowerCase()){case"k":return{amount:s,unit:"K"};case"m":return{amount:s,unit:"M"};default:return{amount:t,unit:"K"}}}function dd(e,t){const n=e.trim();if(n==="")return"";switch(t){case"K":return`${n}K`;case"M":return`${n}M`;case"tokens":return n}}function pd(e,t){return t.map(n=>{const s=U0(e,n),o=s?.contextWindow!==void 0?Og(s.contextWindow):"";return{contextWindow:o,contextWindowMode:aI(o),outputLimit:s?.outputLimit?.toString()??""}})}function fd(e){const t=e.trim();if(t==="")return null;const n=Number(t);return!Number.isInteger(n)||n<=0?null:n}function us(e,t){if(e===void 0)return"";const n=e.trim(),s=n.replace(/\/+$/,"");return s.endsWith(t)?s.slice(0,-t.length).replace(/\/+$/,""):n}function cI(e,t,n){const s=e.trim();return s===""?null:tI(s,t,{providerName:n})}function ua({baseUrl:e,endpoint:t,providerName:n}){const s=cI(e,t,n);return s===null?null:r.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs",children:[r.jsx("div",{className:"text-muted-foreground",children:"Final URL"}),r.jsx("div",{className:"break-all font-mono text-foreground",children:s.finalUrl}),s.diagnostics.length>0&&r.jsx("div",{className:"mt-2 space-y-1",children:s.diagnostics.map(o=>r.jsx("div",{className:o.severity==="warning"?"text-amber-200":"text-muted-foreground",children:o.message},`${o.severity}:${o.message}`))})]})}function uI({provider:e,onSubmit:t,onCancel:n}){const s=rd(e),[o,i]=c.useState(e?.name??""),[a,l]=c.useState(""),[u,d]=c.useState(!1),[p,f]=c.useState(!1),m=e?.models,[h,g]=c.useState(m!==void 0&&m.length>0?m:[""]),[y,b]=c.useState(()=>pd(e,m!==void 0&&m.length>0?m:[""])),[w,v]=c.useState(s.anthropic),[j,_]=c.useState(s.openai),[k,S]=c.useState(s.openaiChat),[C,M]=c.useState(s.openaiResponses),[A,P]=c.useState(us(e?.anthropicBaseUrl,qr)),[N,I]=c.useState(us(e?.openaiBaseUrl,Hr)),[F,B]=c.useState(us(e?.openaiResponsesBaseUrl,Wr)),[J,K]=c.useState(e?.apiDocsUrl??""),[W,V]=c.useState(e?.modelMetadataUrl??""),[z,X]=c.useState(e?.source),[Y,we]=c.useState({}),[he,oe]=c.useState(!1),[D,Ne]=c.useState(null),te=c.useRef([]);c.useEffect(()=>{if(D===null)return;const E=D;function L(Z){if(!(Z.target instanceof Node))return;const ie=te.current[E];ie!=null&&!ie.contains(Z.target)&&Ne(null)}return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[D]);const[je,ke]=c.useState(!1),[ue,le]=c.useState(!1),[xe,_e]=c.useState(!1),ve=o.toLowerCase().includes("minimax"),Ze=o.toLowerCase().includes("alibaba"),Be=[...od,...id].some(E=>o.toLowerCase().includes(E)),Ke=ve?ad:Be?cd:Ze?ld:[],dt=e?.modelMetadata?.some(E=>E.contextWindow!==void 0)??!1;function Lt(){Pt(a).then(E=>{E&&(f(!0),setTimeout(()=>f(!1),2e3))})}c.useEffect(()=>{if(e){i(e.name),l(""),d(!1);const E=(e.models?.length??0)>0?e.models:[""];g(E),b(pd(e,E));const L=rd(e);v(L.anthropic),_(L.openai),S(L.openaiChat),M(L.openaiResponses),P(us(e.anthropicBaseUrl,qr)),I(us(e.openaiBaseUrl,Hr)),B(us(e.openaiResponsesBaseUrl,Wr)),K(e.apiDocsUrl??""),V(e.modelMetadataUrl??""),X(e.source),ke(!1),le(!1),_e(!1)}},[e]),c.useEffect(()=>{const E=o.toLowerCase();for(const[L,Z]of Object.entries(iI))if(E.includes(L)){Z.anthropicBaseUrl!==void 0&&!je&&P(Z.anthropicBaseUrl),Z.openaiBaseUrl!==void 0&&!ue&&I(Z.openaiBaseUrl),Z.openaiResponsesBaseUrl!==void 0&&!xe&&B(Z.openaiResponsesBaseUrl),Z.apiDocsUrl!==void 0&&!J&&K(Z.apiDocsUrl),L==="minimax"&&h.length===1&&h[0]===""&&g([ad[0]??""]),L==="alibaba"&&h.length===1&&h[0]===""&&g([ld[0]??""]),(od.includes(L)||id.includes(L))&&h.length===1&&h[0]===""&&g([cd[0]??""]);break}},[o]);function Ct(){const E={};return o.trim()||(E.name="Name is required"),e===void 0&&!a.trim()&&(E.apiKey="API key is required"),(h.length===0||h.every(L=>!L.trim()))&&(E.models="At least one model is required"),!w&&!j&&(E.capabilities="Select at least one API capability"),j&&!k&&!C&&(E.openaiCapabilities="Select Chat Completions, Responses, or both"),w&&(A.trim()===""?E.anthropicBaseUrl="Anthropic base URL is required":Ye(A.trim())||(E.anthropicBaseUrl="Invalid URL format")),j&&k&&(N.trim()===""?E.openaiBaseUrl="OpenAI Chat base URL is required":Ye(N.trim())||(E.openaiBaseUrl="Invalid URL format")),j&&C&&(F.trim()===""?E.openaiResponsesBaseUrl="OpenAI Responses base URL is required":Ye(F.trim())||(E.openaiResponsesBaseUrl="Invalid URL format")),W.trim()&&!Ye(W.trim())&&(E.modelMetadataUrl="Invalid URL format"),y.forEach((L,Z)=>{const ie=uo(L.contextWindow),de=fd(L.outputLimit);L.contextWindow.trim()!==""&&ie===null&&(E[`modelMetadata.${Z}.contextWindow`]="Context window must be a positive number, optionally using K or M"),L.outputLimit.trim()!==""&&de===null&&(E[`modelMetadata.${Z}.outputLimit`]="Output limit must be a positive integer"),ie!==null&&de!==null&&de>ie&&(E[`modelMetadata.${Z}.outputLimit`]="Output limit should not exceed context window")}),we(E),Object.keys(E).length===0}function Ye(E){try{return new URL(E),!0}catch{return!1}}function Me(E,L){g(Z=>{const ie=[...Z];return ie[E]=L,ie})}function Oe(E,L){b(Z=>{const ie=[...Z];return ie[E]={...ie[E]??$n(),...L},ie})}function q(E,L){switch(L){case rl:Oe(E,{contextWindow:"",contextWindowMode:"unset"});return;case Ao:{const Z=y[E]??$n();Oe(E,{contextWindow:Z.contextWindow,contextWindowMode:"custom"});return}default:Oe(E,{contextWindow:L,contextWindowMode:"preset"});return}}function ne(E,L){const Z=y[E]??$n(),ie=ca(Z.contextWindow);Oe(E,{contextWindow:dd(L,ie.unit),contextWindowMode:"custom"})}function Ee(E,L){const Z=y[E]??$n(),ie=ca(Z.contextWindow);switch(L){case"K":case"M":case"tokens":Oe(E,{contextWindow:dd(ie.amount,L),contextWindowMode:"custom"});return;default:return}}function me(E){g(L=>L.filter((Z,ie)=>ie!==E)),b(L=>L.filter((Z,ie)=>ie!==E))}function be(){g(E=>[...E,""]),b(E=>[...E,$n()])}function ze(){const E=new Date().toISOString(),L=[];return h.forEach((Z,ie)=>{const de=Z.trim();if(de==="")return;const se=y[ie]??$n(),ye=uo(se.contextWindow),ce=fd(se.outputLimit);if(ye===null&&ce===null)return;const pt=U0(e,de);if(pt!==null&&pt.contextWindow===(ye??void 0)&&pt.outputLimit===(ce??void 0)){L.push({...pt,model:de});return}const Mn={model:de,source:"manual",updatedAt:E};ye!==null&&(Mn.contextWindow=ye),ce!==null&&(Mn.outputLimit=ce),L.push(Mn)}),L.length>0?L:e?.modelMetadata!==void 0?[]:void 0}function G(E){if(E.preventDefault(),!Ct())return;oe(!0);const L=e!==void 0;try{t({name:o.trim(),apiKey:a.trim(),models:h.map(Z=>Z.trim()).filter(Z=>Z!==""),anthropicBaseUrl:la(w,A,L),openaiBaseUrl:la(j&&k,N,L),openaiResponsesBaseUrl:la(j&&C,F,L),apiDocsUrl:J.trim()||void 0,modelMetadataUrl:W.trim()||void 0,modelMetadata:ze(),source:z})}finally{oe(!1)}}return r.jsxs("form",{onSubmit:G,className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",r.jsx("span",{className:"text-destructive",children:"*"})]}),r.jsx("input",{id:"provider-name",type:"text",value:o,onChange:E=>i(E.target.value),placeholder:"Provider Name",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),Y.name!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.name})]}),r.jsxs("fieldset",{className:"space-y-3",children:[r.jsxs("legend",{className:"text-sm font-medium",children:["Capabilities ",r.jsx("span",{className:"text-destructive",children:"*"})]}),r.jsxs("div",{className:"divide-y divide-border overflow-hidden rounded-md border border-border",children:[r.jsxs("div",{className:j?"bg-primary/[0.04] px-3 py-3":"px-3 py-3",children:[r.jsxs("label",{htmlFor:"provider-capability-openai",className:"flex cursor-pointer items-start gap-3",children:[r.jsx("input",{id:"provider-capability-openai",type:"checkbox",checked:j,onChange:E=>_(E.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block text-sm font-medium",children:"OpenAI"}),r.jsx("span",{className:"block text-xs text-muted-foreground",children:"Chat Completions and Responses"})]})]}),j&&r.jsxs("div",{className:"ml-7 mt-3 flex flex-wrap gap-x-5 gap-y-2 border-t border-border/70 pt-3",children:[r.jsxs("label",{htmlFor:"provider-capability-openai-chat",className:"flex cursor-pointer items-center gap-2 text-sm",children:[r.jsx("input",{id:"provider-capability-openai-chat",type:"checkbox",checked:k,onChange:E=>S(E.target.checked),className:"size-4 shrink-0 accent-primary"}),"Chat Completions"]}),r.jsxs("label",{htmlFor:"provider-capability-openai-responses",className:"flex cursor-pointer items-center gap-2 text-sm",children:[r.jsx("input",{id:"provider-capability-openai-responses",type:"checkbox",checked:C,onChange:E=>M(E.target.checked),className:"size-4 shrink-0 accent-primary"}),"Responses"]})]}),Y.openaiCapabilities!==void 0&&j&&r.jsx("p",{className:"ml-7 mt-2 text-xs text-destructive",children:Y.openaiCapabilities})]}),r.jsxs("label",{htmlFor:"provider-capability-anthropic",className:`flex cursor-pointer items-start gap-3 px-3 py-3 ${w?"bg-primary/[0.04]":""}`,children:[r.jsx("input",{id:"provider-capability-anthropic",type:"checkbox",checked:w,onChange:E=>v(E.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block text-sm font-medium",children:"Anthropic"}),r.jsx("span",{className:"block text-xs text-muted-foreground",children:"Messages"})]})]})]}),Y.capabilities!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.capabilities})]}),(w||j&&(k||C))&&r.jsxs("section",{className:"space-y-5 border-l border-border pl-4","aria-label":"API endpoints",children:[r.jsx("h3",{className:"text-sm font-medium",children:"Endpoint Configuration"}),w&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:["Anthropic Messages Base URL ",r.jsx("span",{className:"text-destructive",children:"*"})]}),r.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[r.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:A,onChange:E=>{ke(!0),P(E.target.value)},placeholder:"https://api.anthropic.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("span",{className:"shrink-0 select-none border-l border-white/10 bg-white/[0.04] px-3 py-2 font-mono text-xs text-muted-foreground",children:qr})]}),Y.anthropicBaseUrl!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.anthropicBaseUrl}),r.jsx(ua,{baseUrl:A,endpoint:qr,providerName:o})]}),j&&k&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:["OpenAI Chat Base URL ",r.jsx("span",{className:"text-destructive",children:"*"})]}),r.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[r.jsx("input",{id:"provider-openai-base-url",type:"text",value:N,onChange:E=>{le(!0),I(E.target.value)},placeholder:"https://api.openai.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("span",{className:"shrink-0 select-none border-l border-white/10 bg-white/[0.04] px-3 py-2 font-mono text-xs text-muted-foreground",children:Hr})]}),Y.openaiBaseUrl!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.openaiBaseUrl}),r.jsx(ua,{baseUrl:N,endpoint:Hr,providerName:o})]}),j&&C&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{htmlFor:"provider-openai-responses-base-url",className:"text-sm font-medium",children:["OpenAI Responses Base URL ",r.jsx("span",{className:"text-destructive",children:"*"})]}),r.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[r.jsx("input",{id:"provider-openai-responses-base-url",type:"text",value:F,onChange:E=>{_e(!0),B(E.target.value)},placeholder:"https://api.openai.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("span",{className:"shrink-0 select-none border-l border-white/10 bg-white/[0.04] px-3 py-2 font-mono text-xs text-muted-foreground",children:Wr})]}),Y.openaiResponsesBaseUrl!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.openaiResponsesBaseUrl}),r.jsx(ua,{baseUrl:F,endpoint:Wr,providerName:o})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),r.jsxs("select",{id:"provider-source",value:z??"",onChange:E=>X(E.target.value==="company"||E.target.value==="personal"?E.target.value:void 0),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",children:[r.jsx("option",{value:"",children:"Unspecified"}),r.jsx("option",{value:"personal",children:"个人 (Personal)"}),r.jsx("option",{value:"company",children:"公司 (Company)"})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{htmlFor:"provider-model-metadata-url",className:"text-sm font-medium",children:"Model Metadata URL"}),r.jsx("input",{id:"provider-model-metadata-url",type:"text",value:W,onChange:E=>V(E.target.value),placeholder:"https://example.com/agent-inspector-models.json",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),Y.modelMetadataUrl!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.modelMetadataUrl}),W.trim()===""&&r.jsx("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs text-muted-foreground",children:"Built-in limits cover DeepSeek v4 pro/flash, MiniMax M3/M2.7/M2.5/M2.1, and GLM coding models. Use a registry URL for private or custom model limits."}),e!==void 0&&!dt&&W.trim()===""&&r.jsx("p",{className:"text-xs text-amber-400",children:"This provider has no matching context metadata yet."}),W.trim()!==""&&r.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent Inspector will refresh model limits from this JSON registry after save."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",e===void 0&&r.jsx("span",{className:"text-destructive",children:"*"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{id:"provider-apikey",type:u?"text":"password",value:a,onChange:E=>l(E.target.value),placeholder:e===void 0?"sk-ant-...":"Leave blank to keep current key",className:"flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("button",{type:"button",onClick:()=>d(E=>!E),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":u?"Hide API key":"Show API key",children:u?r.jsx(zw,{className:"size-4"}):r.jsx(pf,{className:"size-4"})}),r.jsx("button",{type:"button",onClick:Lt,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:p?r.jsx(Ge,{className:"size-4 text-cyan-300"}):r.jsx(Ot,{className:"size-4"})})]}),e!==void 0&&a.trim()===""&&r.jsx("p",{className:"text-xs text-muted-foreground",children:"A key is configured. Enter a new value only to rotate it."}),Y.apiKey!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.apiKey})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{className:"text-sm font-medium",children:["Models ",r.jsx("span",{className:"text-destructive",children:"*"})]}),h.map((E,L)=>{const Z=y[L]??$n(),ie=Y[`modelMetadata.${L}.contextWindow`],de=Y[`modelMetadata.${L}.outputLimit`],se=lI(Z),ye=ca(Z.contextWindow);return r.jsxs("div",{ref:ce=>{te.current[L]=ce},className:"border border-border bg-card shadow-sm space-y-2 rounded-[8px] p-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("input",{type:"text",value:E,onChange:ce=>Me(L,ce.target.value),placeholder:Ke.length>0?"Type or select a model...":"Model name",className:"w-full rounded-md border border-input bg-background px-4 py-3 pr-8 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),Ke.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>Ne(D===L?null:L),className:"absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors p-1 z-10","aria-label":"Show model suggestions",children:r.jsx(nt,{className:"size-4"})}),D===L&&r.jsx("div",{className:"bg-popover text-popover-foreground absolute left-0 right-0 top-full z-50 mt-1 max-h-48 overflow-y-auto rounded-md border shadow-md",children:Ke.map(ce=>r.jsx("button",{type:"button",onClick:()=>{Me(L,ce),Ne(null)},className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-white/[0.06]",children:ce},ce))})]})]}),h.length>1&&r.jsx("button",{type:"button",onClick:()=>me(L),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M3 6h18"}),r.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),r.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]}),r.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[r.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Context Window"}),r.jsxs(Zn,{value:se,onValueChange:ce=>q(L,ce),children:[r.jsx(Kn,{size:"sm",className:"w-full bg-background font-mono text-xs",children:r.jsx(Ms,{})}),r.jsxs(Gn,{className:"max-h-64",children:[r.jsx(Qe,{value:rl,children:"Not set"}),F0.map(ce=>r.jsxs(Qe,{value:ce.value,children:[ce.label," · ",ce.value]},ce.value)),r.jsx(Qe,{value:Ao,children:"Custom"})]})]}),Z.contextWindowMode==="custom"&&r.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_5.75rem] gap-1.5",children:[r.jsx("input",{type:"text",inputMode:"decimal",value:ye.amount,onChange:ce=>ne(L,ce.target.value),placeholder:"128",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),r.jsxs(Zn,{value:ye.unit,onValueChange:ce=>Ee(L,ce),children:[r.jsx(Kn,{size:"sm",className:"w-full bg-background font-mono text-xs",children:r.jsx(Ms,{})}),r.jsxs(Gn,{children:[r.jsx(Qe,{value:"K",children:"K"}),r.jsx(Qe,{value:"M",children:"M"}),r.jsx(Qe,{value:"tokens",children:"tokens"})]})]})]}),ie!==void 0&&r.jsx("span",{className:"block text-destructive",children:ie})]}),r.jsxs("label",{className:"space-y-1 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Output Limit"}),r.jsx("input",{type:"number",min:1,step:1e3,value:Z.outputLimit,onChange:ce=>Oe(L,{outputLimit:ce.target.value}),placeholder:"e.g. 8192",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),de!==void 0&&r.jsx("span",{className:"block text-destructive",children:de})]})]})]},L)}),r.jsx("button",{type:"button",onClick:be,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),Y.models!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:Y.models})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),r.jsx("input",{id:"provider-api-docs-url",type:"text",value:J,onChange:E=>K(E.target.value),placeholder:"https://api.example.com/docs",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),r.jsxs("div",{className:"border border-border bg-background/95 shadow-sm sticky bottom-0 flex justify-end gap-2 rounded-[8px] px-3 py-2",children:[r.jsx(ee,{type:"button",variant:"outline",onClick:n,disabled:he,children:"Cancel"}),r.jsx(ee,{type:"submit",disabled:he,children:he?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const dI=fe(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),pI=T({message:x(),type:dI,details:x().optional(),hint:x().optional()}),fI=T({type:fe(["text","thinking"]),text:x().optional(),thinking:x().optional()}),mI=T({requestUrl:x().optional(),requestMethod:x().optional(),requestHeaders:We(x(),x()).optional(),requestBody:x().optional(),responseStatus:R().optional(),responseStatusText:x().optional(),responseHeaders:We(x(),x()).optional(),responseBody:x().optional()}),hI=T({success:Te(),error:pI.optional(),model:x().optional(),inputTokens:R().optional(),outputTokens:R().optional(),cacheCreationInputTokens:R().optional(),cacheReadInputTokens:R().optional(),latencyMs:R().optional(),firstChunkMs:R().nullable().optional(),totalStreamMs:R().nullable().optional(),tokensPerSecond:R().nullable().optional(),content:H(fI).optional(),rawResponse:x().optional(),streaming:Te().optional(),streamingChunks:T({chunks:H(zp),truncated:Te().default(!1)}).optional(),requestHeaders:We(x(),x()).optional(),debug:mI.optional()}),md=At([hI,T({notConfigured:ae(!0)}),T({testing:ae(!0)})]),yn=T({nonStreaming:md,streaming:md});function Oo(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const gI=T({anthropic:yn,openai:yn.optional(),openaiChat:yn.optional(),openaiResponses:yn.optional()}).transform(e=>{const t=e.openaiChat??e.openai??Oo();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??Oo()}}),xI=T({anthropic:yn,openai:yn.optional(),openaiChat:yn.optional(),openaiResponses:yn.optional(),models:We(x(),gI).optional(),testedAt:x().optional()}).transform(e=>{const t=e.openaiChat??e.openai??Oo();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??Oo()}});function bI(){return{anthropic:{nonStreaming:{testing:!0},streaming:{testing:!0}},openai:{nonStreaming:{testing:!0},streaming:{testing:!0}},openaiChat:{nonStreaming:{testing:!0},streaming:{testing:!0}},openaiResponses:{nonStreaming:{testing:!0},streaming:{testing:!0}}}}function hd(e,t){const n=()=>({nonStreaming:{success:!1,error:{message:e,type:t}},streaming:{notConfigured:!0}});return{anthropic:n(),openai:n(),openaiChat:n(),openaiResponses:n()}}const vI=T({providerConfig:x()}),yI=T({success:Te().optional(),imported:R().optional(),message:x().optional(),errors:H(x()).optional()}),wI=T({provider:wo,imported:R(),matchedModels:H(x()),missingModels:H(x()),sourceUrl:x()}),Zr="Network error: could not reach the server. Is the proxy running?",jI=5e3,kI=5e3,gd=15e3,_I=1e4,SI=2e4,NI=2e4,CI=3e4;function da(e,t){return(e?.length??0)>0?e:t&&e!==void 0?"":void 0}function xd(e,t=!1){return{name:e.name,...e.apiKey.trim()===""?{}:{apiKey:e.apiKey},models:e.models,anthropicBaseUrl:da(e.anthropicBaseUrl,t),openaiBaseUrl:da(e.openaiBaseUrl,t),openaiResponsesBaseUrl:da(e.openaiResponsesBaseUrl,t),apiDocsUrl:(e.apiDocsUrl?.length??0)>0?e.apiDocsUrl:void 0,modelMetadataUrl:(e.modelMetadataUrl?.length??0)>0?e.modelMetadataUrl:void 0,modelMetadata:e.modelMetadata,source:e.source}}function TI(e,t){const n=e?.models?.map(s=>s.trim()).filter(s=>s!=="").length??0;return Math.max(1,n)*t}async function EI(e,t){if(t.models!==void 0)try{await Un(`/api/providers/${e}/test/log`,kI,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function RI({externalProviders:e,isLoading:t=!1,externalTestResults:n,externalTestingProviders:s,externalTestingTimeLeft:o,onProvidersMutate:i,onTestResultsChange:a,onTestingProvidersChange:l,onTestingTimeLeftChange:u}){const[d,p]=c.useState(!1),[f,m]=c.useState(),[h,g]=c.useState(null),[y,b]=c.useState({}),[w,v]=c.useState(new Set),[j,_]=c.useState({}),[k,S]=c.useState(null),[C,M]=c.useState(!1),[A,P]=c.useState(null),[N,I]=c.useState(!1),[F,B]=c.useState(!1),[J,K]=c.useState(null),[W,V]=c.useState("all"),[z,X]=c.useState(new Set),{providerTestTimeoutSeconds:Y}=Rl(),we=c.useRef(null),he=c.useRef(null),oe=e??[],D=c.useMemo(()=>{const q=W==="all"?oe:oe.filter(ne=>ne.source===W);return W==="all"?[...q].sort((ne,Ee)=>{const me={personal:0,company:1};return(me[ne.source??""]??2)-(me[Ee.source??""]??2)}):q},[oe,W]),Ne=n??y,te=s??w,je=o??j,ke=u?(q,ne)=>u(q,ne):(q,ne)=>{_(ne===void 0?Ee=>{const me={...Ee};return delete me[q],me}:Ee=>({...Ee,[q]:ne}))};c.useEffect(()=>{(async()=>{try{const q=await qe("/api/config/paths",vI,jI);S(q.providerConfig)}catch{}})()},[]);const ue=c.useCallback(q=>{he.current!==null&&clearTimeout(he.current),P(q),we.current?.scrollTo({top:we.current.scrollHeight,behavior:"smooth"}),he.current=setTimeout(()=>{P(null),he.current=null},2e3)},[]);c.useEffect(()=>()=>{he.current!==null&&clearTimeout(he.current)},[]);const le=c.useCallback(()=>{i?.().catch(()=>{})},[i]),xe=c.useCallback((q,ne)=>{a?a(q,ne):b(Ee=>({...Ee,[q]:ne}))},[a]),_e=c.useCallback((q,ne)=>{if(l){l(q,ne);return}v(Ee=>{const me=new Set(Ee);return ne?me.add(q):me.delete(q),me})},[l]),ve=c.useCallback(async q=>{xe(q,bI()),_e(q,!0);const ne=new AbortController,Ee=oe.find(G=>G.id===q),me=TI(Ee,Y);let be=me;ke(q,be);const ze=setInterval(()=>{be--,ke(q,be),be<=0&&(clearInterval(ze),ne.abort())},1e3);try{const G=await qe(`/api/providers/${q}/test`,xI,me*1e3+1e3,{method:"POST",signal:ne.signal},E=>`HTTP ${E.status}: ${E.statusText}`);xe(q,G),await EI(q,G)}catch(G){const E=G instanceof Error&&G.name==="AbortError",L=G instanceof Zo;E||L?xe(q,hd("Request timed out","timeout")):G instanceof Error&&xe(q,hd(G.message,"server_error"))}finally{clearInterval(ze),ke(q,void 0),_e(q,!1)}},[Y,oe,ke,xe,_e]),Ze=c.useCallback(async(q,ne,Ee=!0)=>{X(me=>{const be=new Set(me);return be.add(q),be});try{const me=ne!==void 0&&ne.trim()!==""?{url:ne}:{},be=await qe(`/api/providers/${q}/model-metadata`,wI,CI,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(me)},()=>"Failed to refresh model metadata");return be.imported===0&&Ee?g("No matching model metadata found for this provider."):g(null),ue(be.provider.id),le(),be.imported>0}catch(me){return Ee&&g(me instanceof Error?me.message:Zr),!1}finally{X(me=>{const be=new Set(me);return be.delete(q),be})}},[le,ue]);function Be(q){(async()=>{try{const ne=await qe("/api/providers",wo,gd,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(xd(q))},()=>"Failed to add provider");p(!1),ue(ne.id),q.modelMetadataUrl!==void 0&&q.modelMetadataUrl.trim()!==""&&await Ze(ne.id,q.modelMetadataUrl,!1),le(),await ve(ne.id)}catch(ne){g(ne instanceof Error?ne.message:Zr)}})()}function Ke(q){f&&(async()=>{try{const ne=await qe(`/api/providers/${f.id}`,wo,gd,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(xd(q,!0))},()=>"Failed to update provider");m(void 0),ue(ne.id),q.modelMetadataUrl!==void 0&&q.modelMetadataUrl.trim()!==""&&await Ze(ne.id,q.modelMetadataUrl,!1),le(),(q.apiKey.trim()!==""||JSON.stringify(q.models)!==JSON.stringify(f.models)||(q.anthropicBaseUrl??"")!==(f.anthropicBaseUrl??"")||(q.openaiBaseUrl??"")!==(f.openaiBaseUrl??"")||(q.openaiResponsesBaseUrl??"")!==(f.openaiResponsesBaseUrl??""))&&await ve(ne.id)}catch(ne){g(ne instanceof Error?ne.message:Zr)}})()}function dt(q){K(q),B(!0)}function Lt(){const q=J;q!==null&&(async()=>{let ne;try{ne=await Un(`/api/providers/${q}`,_I,{method:"DELETE"})}catch{g(Zr);return}if(!ne.ok){g(await wl(ne,"Failed to delete provider"));return}le()})()}const Ct=c.useRef(null);function Ye(q){const ne="/api/providers/export";(async()=>{try{const Ee=await Un(ne,SI);if(!Ee.ok){g("Failed to export providers");return}const me=await Ee.blob(),be=URL.createObjectURL(me),ze=document.createElement("a");ze.href=be,ze.download=Ee.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(ze),ze.click(),document.body.removeChild(ze),URL.revokeObjectURL(be)}catch{g("Failed to export providers")}})()}function Me(){Ct.current?.click()}function Oe(q){const ne=q.target.files?.[0];ne&&(async()=>{try{const Ee=await ne.text(),me=await Un("/api/providers/import",NI,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ee)}),be=await yl(me,yI);me.ok&&be.imported!==void 0&&be.imported>0?(le(),g(null)):be.errors&&be.errors.length>0?g(be.errors.join("; ")):g(be.message??"Import failed")}catch{g("Failed to import providers")}q.target.value=""})()}return t?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):d||f?r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-3 rounded-[8px] bg-background/95 px-1 py-1 backdrop-blur",children:r.jsx("h3",{className:"text-lg font-medium",children:f?"Edit Provider":"Add New Provider"})}),r.jsx(uI,{provider:f,onSubmit:f?Ke:Be,onCancel:()=>{p(!1),m(void 0)}})]}):r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{"data-provider-toolbar":"true",className:"sticky top-0 z-10 flex min-w-0 flex-wrap items-center justify-start gap-2 rounded-[8px] bg-background/95 px-1 py-1 backdrop-blur sm:justify-end",children:[r.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>Ye(),className:"gap-1 hover:bg-muted",children:[r.jsx(mr,{className:"size-3"}),"Export"]}),r.jsxs(ee,{variant:"outline",size:"sm",onClick:Me,className:"gap-1 hover:bg-muted",children:[r.jsx(wf,{className:"size-3"}),"Import"]}),r.jsx("input",{type:"file",ref:Ct,accept:".json",onChange:Oe,style:{display:"none"}}),r.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>I(!0),className:"gap-1",children:[r.jsx(Fj,{className:"size-3"}),"Scan"]}),r.jsxs(ee,{onClick:()=>p(!0),size:"sm",className:"gap-1",children:[r.jsx(su,{className:"size-4"}),"Add Provider"]})]}),k!==null&&r.jsxs("div",{className:"flex items-center gap-2 rounded-[8px] bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[r.jsx("span",{className:"font-mono truncate",title:k,children:k}),r.jsx("button",{type:"button",onClick:()=>{Pt(k).then(q=>{q&&(M(!0),setTimeout(()=>M(!1),2e3))})},className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-foreground","aria-label":C?"Copied config file path":"Copy config file path",children:C?r.jsx(Ge,{className:"size-3 text-cyan-300"}):r.jsx(Ot,{className:"size-3"})})]}),h!==null&&r.jsxs("div",{className:"border border-border bg-card shadow-sm flex items-center gap-2 rounded-[8px] px-3 py-2 text-sm text-destructive",children:[r.jsx(Ns,{className:"size-4 shrink-0"}),h]}),oe.length===0?r.jsxs("div",{className:"border border-border bg-card shadow-sm space-y-3 rounded-[8px] py-12 text-center",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),r.jsxs(ee,{onClick:()=>p(!0),variant:"outline",size:"sm",children:[r.jsx(su,{className:"size-4"}),"Add Your First Provider"]})]}):r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"inline-flex w-fit gap-1 rounded-[8px] bg-muted/20 p-1",children:["all","personal","company"].map(q=>r.jsx("button",{type:"button",onClick:()=>V(q),className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${W===q?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:q==="all"?"All":q==="personal"?"Personal":"Company"},q))}),r.jsx("div",{ref:we,className:"space-y-3",children:D.map(q=>r.jsx(XP,{provider:q,testResults:Ne[q.id],isTesting:te.has(q.id),testingTimeLeft:je[q.id],isHighlighted:q.id===A,onEdit:ne=>m(ne),onDelete:dt,onRefreshMetadata:ne=>{Ze(ne)},isRefreshingMetadata:z.has(q.id),onTest:ne=>{ve(ne)}},q.id))})]}),r.jsx(TP,{open:N,onOpenChange:I,onImportComplete:()=>{i!==void 0&&i()}}),r.jsx(Hh,{open:F,onOpenChange:B,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:Lt})]})}const PI=[{value:"providers",label:"Providers"},{value:"proxy",label:"Proxy"},{value:"storage",label:"Storage"},{value:"mcp",label:"MCP"},{value:"onboarding",label:"Onboarding"}];function II(){return r.jsx(p0,{"aria-label":"Settings sections",className:"grid w-full grid-cols-3 justify-stretch gap-1 bg-muted/35 p-1 group-data-[orientation=horizontal]/tabs:h-auto sm:grid-cols-5",children:PI.map(e=>r.jsx(xn,{value:e.value,className:"min-w-0 w-full",children:e.label},e.value))})}function MI(){const[e,t]=c.useState(!1),[n,s]=c.useState("providers"),{providers:o,isLoading:i,mutate:a}=zl(),[l,u]=c.useState({}),[d,p]=c.useState(new Set),[f,m]=c.useState({}),h=c.useCallback((b,w)=>{u(v=>({...v,[b]:w}))},[]),g=c.useCallback((b,w)=>{p(v=>{const j=new Set(v);return w?j.add(b):j.delete(b),j})},[]),y=c.useCallback((b,w)=>{m(v=>{if(w===void 0){const j={...v};return delete j[b],j}return{...v,[b]:w}})},[]);return r.jsxs(Zt,{open:e,onOpenChange:t,children:[r.jsx(yr,{asChild:!0,children:r.jsxs(ee,{variant:"ghost",size:"icon",className:ji,"aria-label":"Settings",title:"Settings",children:[r.jsx(Zj,{className:"size-4"}),r.jsx("span",{className:"sr-only",children:"Settings"})]})}),r.jsxs(Kt,{className:"flex max-h-[calc(100vh-1rem)] w-[calc(100%-1rem)] max-w-2xl flex-col overflow-hidden p-4 sm:max-h-[80vh] sm:p-6",children:[r.jsx(Xt,{children:r.jsx(Qt,{children:"Settings"})}),r.jsxs(d0,{value:n,onValueChange:s,className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:[r.jsx(II,{}),r.jsxs("div",{className:"mt-4 min-w-0 flex-1 overflow-x-hidden overflow-y-auto pr-1 sm:pr-2",children:[r.jsx(jt,{value:"providers",children:r.jsx(RI,{externalProviders:o,isLoading:i,externalTestResults:l,externalTestingProviders:d,externalTestingTimeLeft:f,onProvidersMutate:()=>a(),onTestResultsChange:h,onTestingProvidersChange:g,onTestingTimeLeftChange:y})}),r.jsx(jt,{value:"proxy",children:r.jsx(DI,{})}),r.jsx(jt,{value:"storage",children:r.jsx(zI,{})}),r.jsx(jt,{value:"mcp",children:r.jsx($I,{})}),r.jsx(jt,{value:"onboarding",children:r.jsx(LI,{})})]})]})]})]})}const AI=T({memoryCount:R(),logDir:x(),logFileCount:R(),logBytes:R(),chunkDir:x(),chunkFileCount:R(),chunkBytes:R(),sessionArchiveDir:x(),sessionArchiveFileCount:R(),sessionArchiveBytes:R()}),OI=1e4;function pa(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(1)} GiB`}function zI(){const[e,t]=c.useState(null),[n,s]=c.useState(null),[o,i]=c.useState(!1),[a,l]=c.useState(null),u=c.useCallback(async()=>{i(!0),s(null);try{const p=await qe("/api/logs?stats=1",AI,OI,void 0,f=>`Failed to load storage stats: HTTP ${String(f.status)}`);t(p)}catch(p){s(p instanceof Error?p.message:String(p))}finally{i(!1)}},[]);c.useEffect(()=>{u()},[u]);const d=c.useCallback((p,f)=>{Pt(f).then(m=>{m&&(l(p),setTimeout(()=>l(null),1600))})},[]);return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Log storage"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Inspect local log and streaming chunk footprint before exporting or clearing sessions."})]}),r.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>{u()},children:o?"Refreshing...":"Refresh"})]}),e!==null&&r.jsxs("div",{className:"grid gap-2 text-xs",children:[r.jsx(Ys,{id:"log-dir",label:"Log storage path",value:e.logDir,copiedId:a,onCopy:d}),r.jsx(Ys,{id:"chunk-dir",label:"Streaming chunks storage path",value:e.chunkDir,copiedId:a,onCopy:d}),r.jsx(Ys,{id:"session-archive-dir",label:"Session archive storage path",value:e.sessionArchiveDir,copiedId:a,onCopy:d}),r.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[r.jsx("div",{className:"font-medium",children:"In-memory logs"}),r.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.memoryCount.toLocaleString()," loaded"]})]}),r.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[r.jsx("div",{className:"font-medium",children:"Log files"}),r.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.logFileCount.toLocaleString()," files / ",pa(e.logBytes)]})]}),r.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[r.jsx("div",{className:"font-medium",children:"Streaming chunks"}),r.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.chunkFileCount.toLocaleString()," files / ",pa(e.chunkBytes)]})]}),r.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[r.jsx("div",{className:"font-medium",children:"Session archives"}),r.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.sessionArchiveFileCount.toLocaleString()," files /"," ",pa(e.sessionArchiveBytes)]})]})]}),n!==null&&r.jsx("p",{className:"text-xs text-destructive",children:n})]})}function Ys({id:e,label:t,value:n,copiedId:s,onCopy:o}){const i=s===e;return r.jsxs("div",{className:"min-w-0 rounded-md border border-border/45 bg-muted/15 px-3 py-2 transition-colors hover:bg-muted/25",children:[r.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:t}),r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",title:n,children:n}),r.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>o(e,n),"aria-label":i?`Copied ${t}`:`Copy ${t}`,children:i?r.jsx(Ge,{className:"size-3.5 text-emerald-500"}):r.jsx(Ot,{className:"size-3.5"})})]})]})}function LI(){const[e,t]=c.useState(null),n=c.useMemo(()=>typeof window>"u"?"http://localhost:9527":window.location.origin,[]),s=c.useMemo(()=>[{id:"status",label:"Check onboarding",value:"agent-inspector onboard --status"},{id:"status-json",label:"Check onboarding JSON",value:"agent-inspector onboard --status --json"},{id:"refresh",label:"Refresh generated files",value:"agent-inspector onboard --force"},{id:"uninstall",label:"Remove matching generated files",value:"agent-inspector onboard --uninstall"},{id:"claude",label:"Claude Code command",value:"/agent-inspector:onboard"},{id:"codex",label:"Codex prompt",value:"Use the agent-inspector-onboard skill"},{id:"opencode-config",label:"OpenCode config",value:"agent-inspector onboard --opencode-only"},{id:"opencode-status",label:"OpenCode status",value:"agent-inspector onboard --status --opencode-only"},{id:"opencode-verify",label:"OpenCode verify",value:"opencode mcp list"},{id:"opencode-proxy",label:"OpenCode proxy",value:`LLM_BASE_URL=${n}/proxy`},{id:"mimo-config",label:"MiMo Code config",value:"agent-inspector onboard --mimo-only"},{id:"mimo-status",label:"MiMo Code status",value:"agent-inspector onboard --status --mimo-only"},{id:"mimo-verify",label:"MiMo Code verify",value:"mimo mcp list"},{id:"mimo-proxy",label:"MiMo Code proxy",value:`OPENAI_BASE_URL=${n}/proxy`},{id:"mcp",label:"MCP URL",value:`${n}/api/mcp`},{id:"proxy",label:"Proxy URL",value:`${n}/proxy`},{id:"anthropic",label:"Anthropic base",value:`ANTHROPIC_BASE_URL=${n}/proxy`},{id:"openai",label:"OpenAI base",value:`OPENAI_BASE_URL=${n}/proxy`}],[n]),o=c.useCallback((i,a)=>{Pt(a).then(l=>{l&&(t(i),setTimeout(()=>t(null),1600))})},[]);return r.jsxs("div",{className:"min-w-0 space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Xn,{className:"size-4 text-muted-foreground"}),r.jsx("h3",{className:"text-sm font-semibold",children:"Agent onboarding"})]}),r.jsx("div",{className:"grid gap-2",children:s.map(i=>r.jsx(Ys,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:o},i.id))}),r.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ge,{className:"size-3.5 text-emerald-500"}),r.jsx("span",{children:"Provider test creates a traceable memory probe session."})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ge,{className:"size-3.5 text-emerald-500"}),r.jsx("span",{children:"Captured sessions can produce reviewable memory candidates."})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),r.jsxs("span",{children:["Streamable HTTP clients should use the MCP URL directly. Stdio-only clients should use",r.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"agent-inspector-mcp stdio"}),"instead. Configure only one entry for the same Inspector."]})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),r.jsxs("span",{children:["OpenCode onboarding safely merges"," ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode.json"}),", then verify with"," ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode mcp list"}),"."]})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),r.jsxs("span",{children:["MiMo Code onboarding safely merges"," ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mimocode.jsonc"}),", then route OpenAI-format traffic with"," ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"OPENAI_BASE_URL"}),"."]})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),r.jsx("span",{children:"If your AI tool runs in another container or host, replace localhost with an address reachable from that tool and verify the network/firewall path."})]})]})]})}function $I(){const[e,t]=c.useState(null),s=`${c.useMemo(()=>typeof window>"u"?"http://localhost:9527":window.location.origin,[])}/api/mcp`,o=c.useMemo(()=>[{id:"mcp-url",label:"Streamable HTTP MCP URL",value:s},{id:"stdio",label:"Stdio bridge command",value:`agent-inspector-mcp stdio --url ${s}`},{id:"doctor",label:"Bridge doctor",value:`agent-inspector-mcp doctor --url ${s}`},{id:"writes",label:"Enable write tools",value:"AGENT_INSPECTOR_MCP_WRITES=1 agent-inspector"},{id:"capabilities",label:"Capabilities resource",value:"inspector://mcp/capabilities"},{id:"context",label:"Current context resource",value:"inspector://context/current"},{id:"streamable-json",label:"Streamable HTTP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{type:"streamableHttp",url:s}}},null,2)},{id:"stdio-json",label:"Stdio MCP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{command:"agent-inspector-mcp",args:["stdio","--url",s]}}},null,2)},{id:"opencode-local",label:"OpenCode local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",s],enabled:!0}}},null,2)},{id:"mimo-local",label:"MiMo Code local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",s],enabled:!0}}},null,2)},{id:"codex-toml",label:"Codex TOML",value:`[mcp_servers.agent-inspector]
125
125
  command = "agent-inspector-mcp"
126
- args = ["stdio", "--url", "${s}"]`}],[s]),i=c.useCallback((a,l)=>{Pt(l).then(u=>{u&&(t(a),setTimeout(()=>t(null),1600))})},[]);return r.jsxs("div",{className:"min-w-0 space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Xn,{className:"size-4 text-muted-foreground"}),r.jsx("h3",{className:"text-sm font-semibold",children:"MCP access"})]}),r.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[r.jsx("div",{children:"Use Streamable HTTP when the client supports URL-based MCP. Use the stdio bridge only for stdio-only clients. Configure one entry for the same Inspector instance."}),r.jsx("div",{children:"If the MCP client runs in another container or host, replace localhost with a reachable host/IP and verify the network path."})]}),r.jsx("div",{className:"grid gap-2",children:o.map(a=>r.jsx(Ys,{id:a.id,label:a.label,value:a.value,copiedId:e,onCopy:i},a.id))})]})}function DM(){const{strip:e,slowResponseThresholdSeconds:t,providerTestTimeoutSeconds:n,timeDisplayFormat:s,isLoading:o,setStrip:i,setSlowResponseThresholdSeconds:a,setProviderTestTimeoutSeconds:l,setTimeDisplayFormat:u}=Rl(),[d,f]=c.useState(null),[p,m]=c.useState(!1),h=c.useCallback(async w=>{f(null),m(!0);try{await i(w)}catch(v){f(v instanceof Error?v.message:String(v))}finally{m(!1)}},[i]),g=c.useCallback(async w=>{f(null),m(!0);try{await a(w)}catch(v){f(v instanceof Error?v.message:String(v))}finally{m(!1)}},[a]),y=c.useCallback(async w=>{f(null),m(!0);try{await l(w)}catch(v){f(v instanceof Error?v.message:String(v))}finally{m(!1)}},[l]),b=c.useCallback(async w=>{f(null),m(!0);try{await u(w)}catch(v){f(v instanceof Error?v.message:String(v))}finally{m(!1)}},[u]);return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Strip Claude Code's synthetic billing block before upstream forwarding. This can improve prefix-cache hits with third-party providers and is persisted to ",r.jsx("code",{children:"config.json"}),"."]})]}),r.jsxs("label",{className:"flex items-center gap-3",children:[r.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:o||p,onChange:w=>{h(w.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("span",{className:"text-sm",children:o?"Loading...":e?"Stripping enabled":"Stripping disabled"})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"slow-response-threshold",className:"text-sm font-semibold",children:"Slow response threshold"}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Show a slow marker when elapsed time exceeds this many seconds. Use ",r.jsx("code",{children:"0"})," to disable it."]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{id:"slow-response-threshold",type:"number",min:0,max:ja,step:1,value:t,disabled:o||p,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<0||v>ja||g(v))},className:"h-8 w-24 rounded-md border border-input bg-transparent px-2 text-sm font-mono disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds"})]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"provider-test-timeout",className:"text-sm font-semibold",children:"Provider test timeout"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Abort slow Provider Test probes after this many seconds per model."}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{id:"provider-test-timeout",type:"number",min:1,max:ka,step:1,value:n,disabled:o||p,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<1||v>ka||y(v))},className:"h-8 w-24 rounded-md border border-input bg-transparent px-2 text-sm font-mono disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds / model"})]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"time-display-format",className:"text-sm font-semibold",children:"Time display"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls timestamps in session summaries, headers, and log rows."}),r.jsxs("select",{id:"time-display-format",value:s,disabled:o||p,onChange:w=>{const v=ap.safeParse(w.currentTarget.value);v.success&&b(v.data)},className:"h-8 rounded-md border border-input bg-background px-2 text-sm disabled:cursor-not-allowed disabled:opacity-50",children:[r.jsx("option",{value:"time",children:"Time only"}),r.jsx("option",{value:"full",children:"Full ISO"})]})]}),d!==null&&r.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",d]})]})}const FM=pe(["installed","update-available","available","planned","unknown"]),UM=T({id:x(),name:x(),npmName:x(),capability:x(),description:x(),workflow:x(),installCommand:x(),state:FM,installedVersion:x().nullable(),latestVersion:x().nullable(),primary:Te()}),BM=T({id:x(),name:x(),validatedVersion:x(),binary:x(),modelFlag:x(),variantFlag:x().nullable(),tools:H(x()),logDir:x(),skillsDir:x(),agentsDir:x()}),VM=T({id:x(),title:x(),stage:x(),packageId:x(),description:x(),command:x(),requiresSession:Te(),runnable:Te()}),qM=T({checkedAt:x(),packages:H(UM),runnerPresets:H(BM),recipes:H(VM)}),V0=pe(["install","upgrade","help","runner-presets","recipe"]),q0="RUN_LOCAL_COMMAND",HM=T({action:V0,targetId:x(),targetName:x(),command:x(),source:x(),timeoutMs:R().int().positive(),scope:x()}),WM=T({nonce:x().uuid(),phrase:ae(q0),expiresAt:x().datetime(),plan:HM}),H0=T({confirmation:WM});Tn("intent",[T({intent:ae("prepare")}),T({intent:ae("confirm"),nonce:x().uuid(),confirmation:ae(q0)})]);const ZM=pe(["queued","running","succeeded","failed"]),W0=T({id:x(),packageId:x(),npmName:x(),recipeId:x().nullable().default(null),action:V0,status:ZM,command:x(),output:x(),createdAt:x(),startedAt:x().nullable(),finishedAt:x().nullable(),exitCode:R().nullable(),error:x().nullable()}),Z0=T({task:W0}),KM=T({tasks:H(W0)}),GM=[{id:"observe",title:"Observe",label:"Live",description:"Capture IDE, process, session, turn, request, response, tools, and providers.",metric:"Inspector core",icon:Py},{id:"replay",title:"Replay",label:"Ready",description:"Promote real logs into repeatable replay evidence without losing the raw context.",metric:"Session asset",icon:Vt},{id:"evaluate",title:"Evaluate",label:"Next",description:"Use eval-harness to turn sessions into regression cases and provider bakeoffs.",metric:"Eval loop",icon:Pl},{id:"connect",title:"Connect",label:"MCP",description:"Expose Inspector state to coding agents as queryable context and durable evidence.",metric:"/api/mcp",icon:vj}];async function JM(e){return ot(e,qM,void 0,t=>`Failed to load ecosystem packages: ${String(t.status)}`)}async function YM(e){return ot(e,Z0,void 0,t=>`Failed to load ecosystem task: ${String(t.status)}`)}async function XM(e){return ot(e,KM,void 0,t=>`Failed to load ecosystem tasks: ${String(t.status)}`)}async function QM(e,t){const n=`/api/ecosystem/packages/${encodeURIComponent(e)}/${t}`,s=await ot(n,H0,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},o=>`Failed to prepare ecosystem task: ${String(o.status)}`);return{endpoint:n,confirmation:s.confirmation}}async function eI(e){const t=`/api/ecosystem/recipes/${encodeURIComponent(e)}/run`,n=await ot(t,H0,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},s=>`Failed to prepare ecosystem recipe: ${String(s.status)}`);return{endpoint:t,confirmation:n.confirmation}}async function tI(e){return(await ot(e.endpoint,Z0,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"confirm",nonce:e.confirmation.nonce,confirmation:e.confirmation.phrase})},n=>`Failed to start ecosystem task: ${String(n.status)}`)).task}function nI(e){switch(e){case"installed":return"Installed";case"update-available":return"Update";case"available":return"Available";case"planned":return"Planned";case"unknown":return"Unknown"}}function sI(e){switch(e){case"installed":return"border-emerald-400/20 bg-emerald-400/8 text-emerald-200";case"update-available":return"border-amber-400/20 bg-amber-400/8 text-amber-200";case"available":return"border-sky-400/20 bg-sky-400/8 text-sky-200";case"planned":return"border-white/10 bg-white/[0.04] text-white/55";case"unknown":return"border-white/10 bg-white/[0.04] text-white/45"}}function rI(e){return e.installedVersion!==null&&e.latestVersion!==null?e.installedVersion===e.latestVersion?`v${e.installedVersion}`:`v${e.installedVersion} -> v${e.latestVersion}`:e.installedVersion!==null?`v${e.installedVersion}`:e.latestVersion!==null?`latest v${e.latestVersion}`:"not published"}function Xs(e){switch(e){case"install":return"Install";case"upgrade":return"Upgrade";case"help":return"Help";case"runner-presets":return"Presets";case"recipe":return"Recipe"}}function oI(e){switch(e.status){case"queued":return"Queued";case"running":return`${Xs(e.action)} running`;case"succeeded":return`${Xs(e.action)} complete`;case"failed":return`${Xs(e.action)} failed`}}function K0(e){switch(e){case"queued":case"running":return"border-cyan-300/20 bg-cyan-300/8 text-cyan-100";case"succeeded":return"border-emerald-400/20 bg-emerald-400/8 text-emerald-100";case"failed":return"border-red-400/20 bg-red-400/8 text-red-100"}}function iI(e){switch(e.state){case"available":return"install";case"update-available":return"upgrade";case"installed":case"planned":case"unknown":return null}}function aI({pkg:e,activeTask:t,onStartTask:n}){const s=iI(e),o=t!==null&&t.packageId===e.id&&t.status==="running";return r.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[r.jsx(kj,{className:"size-4 shrink-0 text-white/55"}),r.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),r.jsx("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:e.npmName})]}),r.jsx(_e,{className:$("shrink-0",sI(e.state)),variant:"outline",children:nI(e.state)})]}),r.jsx("div",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:e.description}),r.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[r.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/50",children:rI(e)}),r.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 text-white/45",children:e.capability}),r.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/35",children:e.installCommand})]}),r.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[s!==null&&r.jsxs(ee,{type:"button",size:"sm",variant:"secondary",disabled:o,onClick:()=>n(e.id,s),children:[o?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(mr,{className:"size-3.5"}),Xs(s)]}),r.jsxs(ee,{type:"button",size:"sm",variant:"outline",disabled:o||e.state==="planned",onClick:()=>n(e.id,"help"),children:[r.jsx(Xn,{className:"size-3.5"}),"Help"]}),e.id==="eval-harness"&&r.jsxs(ee,{type:"button",size:"sm",variant:"ghost",disabled:o||e.state==="planned",onClick:()=>n(e.id,"runner-presets"),children:[r.jsx(Pl,{className:"size-3.5"}),"Presets"]})]})]})}function lI({task:e}){if(e===null)return null;const t=e.status==="queued"||e.status==="running";return r.jsxs("section",{className:"mt-3 rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t?r.jsx(Ue,{className:"size-4 animate-spin text-cyan-200/75"}):r.jsx(Xn,{className:"size-4 text-white/55"}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-semibold",children:oI(e)}),r.jsx("div",{className:"break-all font-mono text-[11px] text-white/35",children:e.command})]})]}),r.jsx(_e,{variant:"outline",className:$("shrink-0",K0(e.status)),children:e.status})]}),r.jsx("pre",{className:"mt-3 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-black/30 p-3 font-mono text-[11px] leading-5 text-white/60 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.output.trim().length>0?e.output:"Waiting for npm output..."}),e.error!==null&&r.jsx("div",{className:"mt-2 text-xs text-red-100",children:e.error})]})}function cI({workflow:e}){const t=e.icon;return r.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(t,{className:"size-4 shrink-0 text-cyan-200/75"}),r.jsx("div",{className:"text-sm font-semibold",children:e.title})]}),r.jsx("span",{className:"rounded bg-white/[0.04] px-2 py-0.5 font-mono text-[10px] text-white/45",children:e.label})]}),r.jsx("div",{className:"mt-2 min-h-10 text-xs leading-5 text-muted-foreground",children:e.description}),r.jsx("div",{className:"mt-3 font-mono text-[11px] text-white/35",children:e.metric})]})}function uI(e){return e===null?'npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke" --latest-log-limit 5':`npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke ${e}" --latest-log-limit 5`}function dI({preset:e}){return r.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[r.jsx(bp,{className:"size-4 shrink-0 text-cyan-200/75"}),r.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),r.jsxs("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:[e.binary," ",e.modelFlag,e.variantFlag!==null?` ${e.variantFlag}`:""]})]}),r.jsxs(_e,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:["v",e.validatedVersion]})]}),r.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px]",children:[r.jsxs("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:["logs/",e.logDir]}),r.jsx("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:e.tools.join(", ")}),r.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.skillsDir}),r.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.agentsDir})]})]})}function fI({recipe:e,copied:t,running:n,onCopy:s,onRun:o}){return r.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[r.jsx(pp,{className:"size-4 shrink-0 text-cyan-200/75"}),r.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.title})]}),r.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:e.description})]}),r.jsx(_e,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:e.runnable?e.stage:"Template"})]}),r.jsx("div",{className:"mt-3 rounded-md bg-black/20 p-2 font-mono text-[11px] leading-5 text-white/50 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.command}),r.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2",children:[r.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-[11px] text-white/35",children:e.packageId}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(ee,{type:"button",size:"sm",variant:"outline",onClick:()=>s(e),children:[t?r.jsx(Ge,{className:"size-3.5"}):r.jsx(Ot,{className:"size-3.5"}),t?"Copied":"Copy"]}),e.runnable&&r.jsxs(ee,{type:"button",size:"sm",variant:"secondary",disabled:n,onClick:()=>o(e),children:[n?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(bp,{className:"size-3.5"}),n?"Running":"Run"]})]})]})]})}function pI({task:e,selected:t,onSelect:n}){const s=e.recipeId??Xs(e.action);return r.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-white/[0.025] px-3 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(hp,{className:"size-3.5 shrink-0 text-white/40"}),r.jsx("div",{className:"truncate text-xs font-semibold text-white/75",children:s}),r.jsx(_e,{variant:"outline",className:$("shrink-0",K0(e.status)),children:e.status})]}),r.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-[10px] text-white/35",children:[r.jsx("span",{children:e.packageId}),r.jsx("span",{children:new Date(e.createdAt).toLocaleTimeString()}),e.exitCode!==null&&r.jsxs("span",{children:["exit ",String(e.exitCode)]})]})]}),r.jsx(ee,{type:"button",size:"sm",variant:t?"secondary":"outline",onClick:()=>n(e),children:t?"Open":"View"})]})}function mI({pending:e,busy:t,onOpenChange:n,onConfirm:s}){const o=e?.confirmation.plan??null;return r.jsx(Zt,{open:e!==null,onOpenChange:n,children:r.jsxs(Kt,{className:"max-w-xl",children:[r.jsxs(Xt,{children:[r.jsx(Qt,{children:"Confirm local command"}),r.jsx(wr,{children:"Review the exact allowlisted action Agent Inspector will run on this machine."})]}),o!==null&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[r.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[r.jsx("div",{className:"text-muted-foreground",children:"Source"}),r.jsx("div",{className:"mt-1 break-words font-medium",children:o.source})]}),r.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[r.jsx("div",{className:"text-muted-foreground",children:"Timeout"}),r.jsxs("div",{className:"mt-1 font-medium",children:[String(o.timeoutMs/1e3)," seconds"]})]}),r.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 sm:col-span-2",children:[r.jsx("div",{className:"text-muted-foreground",children:"Affected scope"}),r.jsx("div",{className:"mt-1 font-medium",children:o.scope})]})]}),r.jsxs("div",{children:[r.jsx("div",{className:"mb-1 text-xs font-medium",children:"Resolved command"}),r.jsx("pre",{className:"max-h-32 overflow-auto whitespace-pre-wrap break-all rounded-md bg-black/80 p-3 font-mono text-xs leading-5 text-white/80",children:o.command})]}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Confirmation phrase: ",r.jsx("code",{children:e?.confirmation.phrase}),". The one-time confirmation expires at"," ",new Date(e?.confirmation.expiresAt??"").toLocaleTimeString(),"."]})]}),r.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[r.jsx(ee,{type:"button",variant:"outline",disabled:t,onClick:()=>n(!1),children:"Cancel"}),r.jsxs(ee,{type:"button",variant:"secondary",disabled:t||o===null,onClick:s,children:[t?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(Xn,{className:"size-3.5"}),t?"Starting":"Confirm & Run"]})]})]})})}function hI({currentSessionId:e,logCount:t}){const[n,s]=c.useState(!1),[o,i]=c.useState(!1),[a,l]=c.useState(!1),[u,d]=c.useState(null),[f,p]=c.useState(null),[m,h]=c.useState(null),[g,y]=c.useState(null),[b,w]=c.useState(!1),v=Bt("/api/ecosystem/packages",JM,{revalidateOnFocus:!1,revalidateIfStale:!1}),j=Bt(f===null?null:`/api/ecosystem/tasks/${f}`,YM,{refreshInterval:z=>{const X=z?.task;return X!==void 0&&(X.status==="queued"||X.status==="running")?900:0},revalidateOnFocus:!1}),S=Bt(n?"/api/ecosystem/tasks":null,XM,{refreshInterval:2500,revalidateOnFocus:!1}),k=v.data?.packages??[],_=v.data?.runnerPresets??[],C=v.data?.recipes??[],I=(S.data?.tasks??[]).slice(0,6),A=c.useMemo(()=>k.filter(z=>z.state==="installed"||z.state==="update-available").length,[k]),P=uI(e),N="npx @tonyclaw/eval-harness runner-presets",M=()=>{Pt(P).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)})},F=()=>{Pt(N).then(()=>{l(!0),window.setTimeout(()=>l(!1),1200)})},B=z=>{Pt(z.command).then(()=>{d(z.id),window.setTimeout(()=>d(null),1200)})},J=z=>{h(null),eI(z.id).then(X=>{y(X)}).catch(X=>{h(X instanceof Error?X.message:"Failed to prepare ecosystem recipe")})},K=j.data?.task??null;c.useEffect(()=>{K!==null&&(S.mutate(),K.status==="succeeded"&&v.mutate())},[K,v,S]);const W=(z,X)=>{h(null),QM(z,X).then(Y=>{y(Y)}).catch(Y=>{h(Y instanceof Error?Y.message:"Failed to prepare ecosystem task")})},V=()=>{g!==null&&(h(null),w(!0),tI(g).then(z=>{p(z.id),y(null),j.mutate({task:z},{revalidate:!0}),S.mutate()}).catch(z=>{h(z instanceof Error?z.message:"Failed to start ecosystem task")}).finally(()=>{w(!1)}))};return r.jsxs(Zt,{open:n,onOpenChange:s,children:[r.jsx(yr,{asChild:!0,children:r.jsxs(ee,{variant:"ghost",size:"icon",className:ji,"aria-label":"TonyClaw Lab",title:"TonyClaw Lab",children:[r.jsx(pp,{className:"size-4"}),r.jsx("span",{className:"sr-only",children:"TonyClaw Lab"})]})}),r.jsxs(Kt,{className:"flex max-h-[84vh] max-w-5xl flex-col overflow-hidden",children:[r.jsx(Xt,{children:r.jsxs(Qt,{className:"flex items-center gap-2",children:[r.jsx(Na,{className:"size-4 text-cyan-200/80"}),"TonyClaw Lab"]})}),r.jsxs("div",{className:"overflow-y-auto pr-2",children:[r.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.1fr_0.9fr]",children:[r.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-semibold",children:"Session asset pipeline"}),r.jsx("div",{className:"mt-1 max-w-2xl text-xs leading-5 text-muted-foreground",children:"Treat captured traffic as durable assets: observe it, replay it, evaluate it, and expose it back to agents through MCP."})]}),r.jsxs(_e,{variant:"outline",className:"border-cyan-300/20 bg-cyan-300/8 text-cyan-100",children:[String(A),"/",String(k.length)," packages"]})]}),r.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:GM.map(z=>r.jsx(cI,{workflow:z},z.id))})]}),r.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-semibold",children:"Current session"}),r.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:e===null?"MCP smoke command":e})]}),r.jsxs(_e,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:[String(t)," logs"]})]}),r.jsx("div",{className:"mt-4 rounded-md bg-black/20 p-3 font-mono text-[11px] leading-5 text-white/55 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:P}),r.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[r.jsxs(ee,{size:"sm",variant:"secondary",onClick:M,children:[o?r.jsx(Ge,{className:"size-3.5"}):r.jsx(Ot,{className:"size-3.5"}),o?"Copied":"Copy"]}),r.jsxs(ee,{size:"sm",variant:"outline",onClick:F,children:[r.jsx(Pl,{className:"size-3.5"}),a?"Presets copied":"Runner Presets"]})]})]})]}),r.jsxs("section",{className:"mt-3",children:[r.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[r.jsx("div",{className:"text-sm font-semibold",children:"Lab recipes"}),r.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[r.jsx(Na,{className:"size-3.5"}),"copy-ready workflows"]})]}),r.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[C.map(z=>r.jsx(fI,{recipe:z,copied:u===z.id,running:K!==null&&K.recipeId===z.id&&(K.status==="queued"||K.status==="running"),onCopy:B,onRun:J},z.id)),v.isLoading&&C.length===0&&[0,1].map(z=>r.jsx("div",{className:"h-40 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},z))]})]}),r.jsxs("section",{className:"mt-3",children:[r.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[r.jsx("div",{className:"text-sm font-semibold",children:"Runner presets"}),r.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[r.jsx(Xn,{className:"size-3.5"}),N]})]}),r.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[_.map(z=>r.jsx(dI,{preset:z},z.id)),v.isLoading&&_.length===0&&[0,1,2,3].map(z=>r.jsx("div",{className:"h-32 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},z))]})]}),r.jsxs("section",{className:"mt-3",children:[r.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[r.jsx("div",{className:"text-sm font-semibold",children:"TonyClaw packages"}),v.isLoading&&r.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"checking npm..."})]}),v.error!==void 0&&r.jsx("div",{className:"rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:"Package status is temporarily unavailable."}),r.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[k.map(z=>r.jsx(aI,{pkg:z,activeTask:K,onStartTask:W},z.id)),v.isLoading&&k.length===0&&[0,1,2].map(z=>r.jsx("div",{className:"h-36 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},z))]})]}),m!==null&&r.jsx("div",{className:"mt-3 rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:m}),I.length>0&&r.jsxs("section",{className:"mt-3",children:[r.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[r.jsx("div",{className:"text-sm font-semibold",children:"Recent Lab runs"}),r.jsxs("div",{className:"hidden font-mono text-[11px] text-muted-foreground sm:block",children:["last ",String(I.length)]})]}),r.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:I.map(z=>r.jsx(pI,{task:z,selected:f===z.id,onSelect:X=>{p(X.id),j.mutate({task:X},{revalidate:!0})}},z.id))})]}),r.jsx(lI,{task:K})]})]}),r.jsx(mI,{pending:g,busy:b,onOpenChange:z=>{!z&&!b&&y(null)},onConfirm:V})]})}const gI=[{id:"reliability",label:"Reliability",question:"Which requests failed, stalled, or look most likely to hang, and why?"},{id:"performance",label:"Performance",question:"Summarize latency and identify the slowest requests with supporting evidence."},{id:"tokens",label:"Token usage",question:"Where are tokens being spent, and which requests have unusually high usage?"},{id:"providers",label:"Providers",question:"Compare Provider and model reliability, latency, and token usage in this scope."},{id:"tools",label:"Tool activity",question:"Which tools were used most, and where did tool calls fail or produce warnings?"}],xI=4e3,pa=12;function bd(){return{messages:[],question:"",error:null}}function bI(e){return e.filter(t=>t.content.trim().length>0).slice(-10).map(t=>({role:t.role,content:t.content.trim().slice(0,xI)}))}function ct(e,...t){for(const n of t){const s=Q(e,n);if(typeof s=="string"&&s.trim().length>0)return s}return null}function bn(e,...t){for(const n of t){const s=Q(e,n);if(typeof s=="number"&&Number.isFinite(s))return s}return null}function vI(e,t){const n=Q(e,t);return Array.isArray(n)?n.filter(s=>typeof s=="string").slice(0,8):[]}function yI(e){const t=ct(e,"source")??"log",n=ct(e,"id")??"",s=bn(e,"logId","id");if(n===""&&s===null||s!==null&&(!Number.isInteger(s)||s<0))return null;const o=bn(e,"inputTokens"),i=bn(e,"outputTokens"),a=bn(e,"totalTokens","tokenCount"),l=bn(e,"responseStatus","status"),u=ct(e,"responseStatus","status");return{source:t,id:n!==""?n:String(s),logId:s,sessionId:ct(e,"sessionId"),timestamp:ct(e,"timestamp"),model:ct(e,"model"),providerName:ct(e,"providerName","provider"),path:ct(e,"path"),status:l??u,elapsedMs:bn(e,"elapsedMs","latencyMs"),inputTokens:o,outputTokens:i,totalTokens:a??(o===null&&i===null?null:(o??0)+(i??0)),score:bn(e,"score","relevanceScore"),matchedFields:vI(e,"matchedFields"),excerpt:ct(e,"excerpt","snippet")??"No excerpt available."}}function ma(e){const t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return t.length===0?"Metric":`${t[0]?.toUpperCase()??""}${t.slice(1)}`}function vd(e){if(typeof e=="number"&&Number.isFinite(e))return e.toLocaleString();if(typeof e=="string"&&e.trim().length>0)return e;if(typeof e=="boolean")return e?"Yes":"No";if(Array.isArray(e)){const t=e.filter(n=>typeof n=="string"||typeof n=="number"&&Number.isFinite(n)).slice(0,6);return t.length>0?t.join(", "):null}return null}function yd(e){return Object.getOwnPropertyNames(e).map(t=>[t,Q(e,t)])}function wd(e){if(e===null||typeof e!="object"||Array.isArray(e))return[];const t=[];for(const[n,s]of yd(e)){const o=vd(s);if(o!==null){if(t.push({key:n,label:ma(n),value:o}),t.length>=pa)break;continue}if(!(s===null||typeof s!="object"||Array.isArray(s))){for(const[i,a]of yd(s)){const l=vd(a);if(l===null)continue;const u=`${n}.${i}`;if(t.push({key:u,label:`${ma(n)} ${ma(i).toLowerCase()}`,value:l}),t.length>=pa)break}if(t.length>=pa)break}}return t}function wI(e){const t=ct(e,"answer"),n=ct(e,"providerId"),s=ct(e,"providerName"),o=ct(e,"model"),i=ct(e,"protocol"),a=bn(e,"logCount");if(t===null||n===null||s===null||o===null||i===null||a===null)return null;const l=Q(e,"evidence"),u=Array.isArray(l)?l.map(yI).filter(d=>d!==null).slice(0,12):[];return{answer:t,providerId:n,providerName:s,model:o,protocol:i,logCount:a,evidence:u,summaryMetrics:wd(Q(e,"summary")),queryMetrics:wd(Q(e,"queryStats"))}}const jI=c.lazy(()=>Gt(()=>import("./index-FV5sxqx3.js"),__vite__mapDeps([9,1]))),kI="prose prose-sm dark:prose-invert max-w-none text-[13px] leading-[1.65] [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_p]:leading-[1.65] [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5 [&_li]:leading-[1.6]";function SI({text:e}){return r.jsx("div",{className:kI,children:r.jsx(c.Suspense,{fallback:r.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading Markdown..."}),children:r.jsx(jI,{children:e})})})}const jd="Analyze the current Inspector session. What looks abnormal, slow, or likely to hang?";function _I(e){return e.openaiResponsesBaseUrl!==void 0||e.openaiBaseUrl!==void 0||e.anthropicBaseUrl!==void 0}function NI(e){return e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""?"Responses":e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""?"Chat":"Anthropic"}function CI(e){return e.toSorted((t,n)=>{const s=t.source==="company"?0:1,o=n.source==="company"?0:1;return s!==o?s-o:t.name.localeCompare(n.name)})}function kd(e){return`${e}-${String(Date.now())}-${String(Math.random()).slice(2)}`}function Sd({metrics:e}){return e.length===0?null:r.jsx("div",{className:"mt-2 grid grid-cols-2 gap-1.5",children:e.slice(0,8).map(t=>r.jsxs("div",{className:"rounded-sm bg-black/20 px-2 py-1",children:[r.jsx("div",{className:"truncate text-[9px] uppercase text-muted-foreground",children:t.label}),r.jsx("div",{className:"truncate font-mono text-[11px] text-cyan-50",children:t.value})]},t.key))})}function TI({evidence:e}){const t=()=>{e.logId!==null&&Ms({logId:e.logId,tab:"anatomy"})},n=e.logId===null?`${e.source}:${e.id}`:`${e.source}:log #${String(e.logId)}`;return r.jsxs("button",{type:"button",onClick:t,disabled:e.logId===null,className:"w-full rounded-sm bg-black/20 px-2 py-2 text-left shadow-[inset_0_0_0_1px_rgba(255,255,255,0.05)] transition-colors hover:bg-black/30 disabled:cursor-default disabled:hover:bg-black/20",children:[r.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[r.jsx("span",{className:"truncate font-mono text-[10px] text-cyan-100",children:n}),e.score!==null&&r.jsx("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:e.score.toFixed(1)})]}),r.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-1 text-[10px] text-muted-foreground",children:[e.providerName!==null&&r.jsx("span",{children:e.providerName}),e.model!==null&&r.jsx("span",{children:e.model}),e.status!==null&&r.jsxs("span",{children:["status ",String(e.status)]}),e.elapsedMs!==null&&r.jsxs("span",{children:[String(e.elapsedMs)," ms"]})]}),r.jsx("p",{className:"mt-1 line-clamp-3 text-[11px] leading-4 text-foreground/85",children:e.excerpt})]})}function EI({response:e}){return r.jsxs("div",{className:"rounded-md bg-black/25 p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.05)]",children:[r.jsx(SI,{text:e.answer}),r.jsxs("div",{className:"mt-2 break-words font-mono text-[10px] text-cyan-100/70",children:[e.providerName," / ",e.model," / ",e.protocol," /"," ",String(e.logCount)," matched logs"]}),r.jsx(Sd,{metrics:e.summaryMetrics}),r.jsx(Sd,{metrics:e.queryMetrics}),e.evidence.length>0&&r.jsx("div",{className:"mt-2 space-y-1.5",children:e.evidence.slice(0,6).map(t=>r.jsx(TI,{evidence:t},`${t.source}-${t.id}`))})]})}function RI({message:e}){return e.role==="assistant"&&e.response!==null?r.jsx(EI,{response:e.response}):r.jsx("div",{className:"rounded-md bg-cyan-400/10 px-3 py-2 text-xs leading-5 text-cyan-50",children:e.content})}function PI({currentSessionId:e,logCount:t}){const{providers:n}=zl(),s=c.useMemo(()=>CI(n.filter(_I)),[n]),[o,i]=c.useState(()=>({...bd(),question:jd})),[a,l]=c.useState("__auto__"),[u,d]=c.useState("__auto__"),[f,p]=c.useState(!1),h=s.find(k=>k.id===a)?.models??[],g=o.question,y=g.trim()!==""&&s.length>0&&!f,b=k=>{i(_=>({..._,question:k.currentTarget.value}))},w=k=>{l(k),d("__auto__")},v=()=>{i({...bd(),question:jd})},j=k=>{i(_=>({..._,question:k,error:null}))},S=()=>{if(!y)return;const k=g.trim(),_=bI(o.messages),C={id:kd("user"),role:"user",content:k,response:null};p(!0),i(A=>({...A,messages:[...A.messages,C],question:"",error:null}));const I={question:k,history:_,...e!==null?{sessionId:e}:{},...a!=="__auto__"?{providerId:a}:{},...u!=="__auto__"?{model:u}:{},logLimit:16};fetch("/api/pi-agent",{method:"POST",headers:{"content-type":"application/json","x-agent-inspector-csrf":"1"},body:JSON.stringify(I)}).then(async A=>{const P=await A.text();if(!A.ok){i(F=>({...F,error:`Pi Agent failed: HTTP ${String(A.status)} ${P}`}));return}const N=JSON.parse(P),M=wI(N);if(M===null){i(F=>({...F,error:"Pi Agent returned an unexpected response."}));return}i(F=>({...F,messages:[...F.messages,{id:kd("assistant"),role:"assistant",content:M.answer,response:M}]}))}).catch(A=>{i(P=>({...P,error:A instanceof Error?A.message:"Pi Agent request failed."}))}).finally(()=>{p(!1)})};return r.jsxs("section",{className:"rounded-md bg-black/20 px-3 py-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ky,{className:"size-4 text-cyan-200"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Pi Agent"}),r.jsx("div",{className:"text-[11px] text-muted-foreground",children:e===null?"Inspector-wide ChatBI":"Session ChatBI"})]}),r.jsx("button",{type:"button",onClick:v,className:"inline-flex size-7 items-center justify-center rounded-md bg-black/25 text-muted-foreground transition-colors hover:text-foreground",title:"Reset conversation",children:r.jsx(vp,{className:"size-3.5"})})]}),r.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[r.jsxs(Zn,{value:a,onValueChange:w,children:[r.jsx(Kn,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:r.jsx(Is,{placeholder:"Provider"})}),r.jsxs(Gn,{children:[r.jsx(Qe,{value:"__auto__",children:"Auto provider"}),s.map(k=>r.jsxs(Qe,{value:k.id,children:[k.name," / ",NI(k)]},k.id))]})]}),r.jsxs(Zn,{value:u,onValueChange:d,children:[r.jsx(Kn,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:r.jsx(Is,{placeholder:"Model"})}),r.jsxs(Gn,{children:[r.jsx(Qe,{value:"__auto__",children:"Auto model"}),h.map(k=>r.jsx(Qe,{value:k,children:k},k))]})]})]}),o.messages.length===0&&r.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:gI.map(k=>r.jsxs("button",{type:"button",onClick:()=>{j(k.question)},className:"inline-flex h-7 items-center gap-1.5 rounded-sm bg-black/25 px-2 text-[11px] text-cyan-50 transition-colors hover:bg-cyan-400/12",children:[r.jsx(Na,{className:"size-3"}),r.jsx("span",{children:k.label})]},k.id))}),o.messages.length>0&&r.jsxs("div",{className:"mt-3 max-h-96 space-y-2 overflow-y-auto pr-1",children:[o.messages.map(k=>r.jsx(RI,{message:k},k.id)),f&&r.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md bg-black/25 px-3 py-2 text-xs text-muted-foreground",children:[r.jsx(Ue,{className:"size-3.5 animate-spin"}),r.jsx("span",{children:"Searching Inspector..."})]})]}),r.jsx("textarea",{value:g,onChange:b,className:"mt-3 min-h-20 w-full resize-y rounded-md bg-black/25 px-3 py-2 text-xs leading-5 text-foreground outline-none shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring",placeholder:"Ask Pi Agent across saved Inspector data..."}),r.jsxs("button",{type:"button",onClick:S,disabled:!y,className:"mt-2 inline-flex h-8 w-full items-center justify-center gap-2 rounded-md bg-cyan-400/12 px-3 text-xs font-medium text-cyan-100 shadow-[inset_0_0_0_1px_rgba(103,232,249,0.18)] transition-colors hover:bg-cyan-400/18 disabled:cursor-not-allowed disabled:opacity-50",children:[f?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(Vj,{className:"size-3.5"}),r.jsx("span",{children:f?"Thinking...":"Ask Pi"})]}),o.error!==null&&r.jsx("p",{className:"mt-2 break-words text-[11px] leading-5 text-red-200",children:o.error}),s.length===0&&r.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"Configure a Provider with Responses, Chat, or Anthropic URL to enable Pi Agent."}),t===0&&r.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"No logs are visible in this scope yet; Pi Agent can still answer Provider setup questions."})]})}function MI(e){const t=new Map;for(const n of e){const s=n.logs;for(let o=1;o<s.length;o++){const i=s[o-1],a=s[o];i===void 0||a===void 0||t.set(a.id,{creation:_d(i.cacheCreationInputTokens,a.cacheCreationInputTokens),read:_d(i.cacheReadInputTokens,a.cacheReadInputTokens)})}}return t}function _d(e,t){return t===null||e===null?null:t>e?{direction:"up",delta:t-e}:t<e?{direction:"down",delta:e-t}:null}function G0(e){return e===null?null:new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ds(e,t,n){const s=G0(e.lastSuccessAt),o=e.retryCount>0?` Retry ${e.retryCount.toString()}.`:"",i=n?" Captured logs remain visible.":"",a=s===null?"":` Last update ${s}.`;return`${t}${a}${o}${i}`}function J0(e,t,n){switch(e){case"connecting":return{label:"Connecting",description:ds(t,"Waiting for the first live update.",n),toneClass:"border-cyan-400/20 bg-cyan-500/8 text-cyan-100",dotClass:"bg-cyan-300 animate-pulse motion-reduce:animate-none",canRetry:!1,canStop:!1};case"live":return{label:"Live",description:ds(t,"Live updates are current.",n),toneClass:"border-emerald-400/20 bg-emerald-500/8 text-emerald-100",dotClass:"bg-emerald-300",canRetry:!1,canStop:!1};case"reconnecting":return{label:"Reconnecting",description:ds(t,"Live updates were interrupted.",n),toneClass:"border-amber-400/20 bg-amber-500/8 text-amber-100",dotClass:"bg-amber-300 animate-pulse motion-reduce:animate-none",canRetry:!0,canStop:!0};case"stale":return{label:"Stale data",description:ds(t,"Live updates have not resumed.",n),toneClass:"border-orange-400/25 bg-orange-500/10 text-orange-100",dotClass:"bg-orange-300",canRetry:!0,canStop:!0};case"offline":return{label:"Offline",description:ds(t,t.errorMessage??"Live updates are paused.",n),toneClass:"border-slate-400/20 bg-slate-500/10 text-slate-200",dotClass:"bg-slate-400",canRetry:!0,canStop:!1};case"error":return{label:"Connection error",description:ds(t,t.errorMessage??"The live stream reported a recoverable error.",n),toneClass:"border-red-400/25 bg-red-500/10 text-red-100",dotClass:"bg-red-300",canRetry:!0,canStop:!0}}}function II({state:e}){const t=J0(e.status,e,!1),n=G0(e.lastSuccessAt),s=e.retryCount>0?`Retry ${e.retryCount.toString()}`:null;return r.jsxs("span",{role:"status","aria-label":t.description,"data-connection-state":e.status,className:$("inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium",t.toneClass),children:[r.jsx("span",{className:$("size-1.5 shrink-0 rounded-full",t.dotClass)}),r.jsx("span",{className:"shrink-0",children:t.label}),s!==null&&r.jsx("span",{className:"hidden truncate text-current/70 sm:inline",children:s}),n!==null&&r.jsxs("span",{className:"hidden truncate font-mono text-[10px] text-current/65 md:inline",children:["Last ",n]})]})}function AI({state:e,hasLogs:t,onRetry:n,onStop:s}){const o=J0(e.status,e,t);return r.jsxs("div",{role:"status","aria-live":"polite","data-connection-state":e.status,className:$("mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md border px-3 py-2 text-xs",o.toneClass),children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[r.jsx("span",{className:$("size-2 shrink-0 rounded-full",o.dotClass)}),r.jsx("span",{className:"shrink-0 font-semibold",children:o.label}),r.jsx("span",{className:"min-w-0 text-current/75",children:o.description})]}),(o.canRetry||o.canStop)&&r.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[o.canRetry&&r.jsxs("button",{type:"button",onClick:n,className:"inline-flex h-7 items-center gap-1 rounded-md bg-black/15 px-2 font-medium transition-colors hover:bg-black/25 focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[r.jsx(Vt,{className:"size-3"}),"Retry now"]}),o.canStop&&r.jsxs("button",{type:"button",onClick:s,className:"inline-flex h-7 items-center gap-1 rounded-md px-2 text-current/70 transition-colors hover:bg-black/15 hover:text-current focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[r.jsx(gw,{className:"size-3"}),"Stop retrying"]})]})]})}function OI({liveConnection:e,alertsAction:t,settingsAction:n}){return r.jsx("header",{"data-application-bar":"true",className:"border-border/70 bg-background/95 sticky top-0 z-50 shrink-0 border-b px-3 py-2 shadow-[0_10px_30px_rgba(0,0,0,0.14)] backdrop-blur lg:px-4",children:r.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-2 sm:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]",children:[r.jsxs("a",{href:"/","aria-label":"Agent Inspector home",className:"flex min-w-0 items-center gap-2 rounded-md focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[r.jsx(sf,{className:"size-7 shrink-0 text-amber-500"}),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block truncate text-sm font-bold leading-4",children:"Agent Inspector"}),r.jsx("span",{className:"hidden truncate text-[10px] font-medium text-muted-foreground md:block",children:"Local First. Evidence First."})]}),r.jsxs("span",{className:"hidden shrink-0 font-mono text-[10px] text-muted-foreground lg:inline",children:["v",jp.version]})]}),r.jsx("div",{className:"order-3 col-span-2 flex min-w-0 justify-start sm:order-2 sm:col-span-1 sm:justify-center",children:e===void 0?r.jsxs("span",{"data-connection-state":"stored",className:"border-border/70 bg-muted/50 inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium text-muted-foreground",children:[r.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-slate-400"}),"Stored session"]}):r.jsx(II,{state:e})}),r.jsxs("nav",{"aria-label":"Application actions",className:"order-2 flex shrink-0 items-center justify-end gap-1 sm:order-3",children:[t,n]})]})})}function zI(e){return`${Math.max(0,Math.ceil(e/1e3)).toString()}s`}function lo({progress:e}){const t=Math.min(1,e.elapsedMs/e.timeoutMs),n=Math.max(4,Math.round(t*100)),s=Math.max(0,e.timeoutMs-e.elapsedMs),o=t>=.75,i=[e.loadedLogs>0?`${e.loadedLogs.toString()} logs`:null,e.loadedPages>0?`${e.loadedPages.toString()} page${e.loadedPages===1?"":"s"}`:null,`${zI(s)} before timeout`].filter(l=>l!==null),a=`${e.label}: ${i.join(", ")}`;return r.jsxs("div",{className:"min-w-0 space-y-1 px-1 pb-1",children:[r.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 font-mono text-[10px] text-muted-foreground",children:[r.jsx("span",{className:"min-w-0 truncate",children:e.label}),r.jsx("span",{className:$("shrink-0 tabular-nums",o&&"text-amber-300"),children:i.join(" / ")})]}),r.jsx("div",{role:"progressbar","aria-label":e.label,"aria-valuemin":0,"aria-valuemax":e.timeoutMs,"aria-valuenow":Math.min(e.elapsedMs,e.timeoutMs),"aria-valuetext":a,className:"h-1.5 overflow-hidden rounded-full bg-white/[0.06]",children:r.jsx("div",{className:$("h-full rounded-full transition-all duration-300 motion-reduce:transition-none",o?"bg-amber-300/80":"bg-cyan-300/70"),style:{width:`${n.toString()}%`}})})]})}function Y0(e){return e?"auto":"smooth"}function X0(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function LI(){return{status:"connecting",lastSuccessAt:null,retryCount:0,errorMessage:null}}function nn(e,t){switch(t.type){case"connect-requested":return{...e,status:e.lastSuccessAt===null?"connecting":e.status==="stale"?"stale":"reconnecting",errorMessage:null};case"message-received":return{status:"live",lastSuccessAt:t.at,retryCount:0,errorMessage:null};case"connection-lost":{const n=e.retryCount+1;return t.online?{...e,status:e.lastSuccessAt===null?"error":"reconnecting",retryCount:n,errorMessage:t.message}:{...e,status:"offline",retryCount:n,errorMessage:"Browser is offline."}}case"stale-timeout":return e.lastSuccessAt===null||e.status==="live"||e.status==="offline"?e:{...e,status:"stale"};case"browser-offline":return{...e,status:"offline",errorMessage:"Browser is offline."};case"stop-retrying":return{...e,status:"offline",errorMessage:"Automatic live updates are paused."};case"recoverable-error":return{...e,status:"error",errorMessage:t.message}}}function $I(e){return e===void 0||e.status==="live"?"empty":e.status}function DI(e){switch(e){case"connecting":return{title:"Connecting to the live stream...",description:"Waiting for the first successful initialization before checking for logs.",showConnectionCommands:!1};case"empty":return{title:"No logs captured yet.",description:"Connect an AI coding tool to capture its first request.",showConnectionCommands:!0};case"reconnecting":return{title:"Reconnecting to live updates...",description:"The stream was interrupted. Agent Inspector is retrying automatically.",showConnectionCommands:!1};case"stale":return{title:"Live data is stale.",description:"No logs are hidden; retry the connection to resume live updates.",showConnectionCommands:!1};case"offline":return{title:"Live updates are offline.",description:"Check the browser and Inspector connection, then retry.",showConnectionCommands:!1};case"error":return{title:"Live updates could not initialize.",description:"The error is recoverable. Retry without reloading the page.",showConnectionCommands:!1}}}const Nd="agent-inspector.hierarchy.collapsedClients",Cd="agent-inspector.hierarchy.collapsedProcesses";function zo(e){return e.some(t=>t.responseStatus===null)}function Q0(e){return e.filter(t=>t.responseStatus===null).length}function eg(e){for(const t of e){const n=t.userAgent;if(n!=null&&n!=="")return n}return null}function FI(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function tg(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}function UI(e){return ac({userAgent:eg(e.logs),conversationId:e.conversationId,clientProjectFolder:tg(e.logs)})}function BI(e){if(e===null||e==="")return"Unknown client";const t=e.split(/[ /;]/)[0]??"";return t===""?"Unknown client":t}function VI(e,t){const n=xi(e);return n!==null?n:BI(t)}function Lo(e){return e===null||e===""?"unknown":String(e)}function qI(e,t,n){return e!=="unknown"?e:`unknown:${Lo(t)}:${Lo(n)}`}function HI(e,t){return`${Lo(e)}:${Lo(t)}`}function Td(e){return[...e].sort((t,n)=>t.timestamp.localeCompare(n.timestamp))}function Ed(e){let t="";for(const n of e)n.timestamp>t&&(t=n.timestamp);return t}function Rd(e){return zo(e)?0:e.some(t=>t.error!==null&&t.error!==void 0||t.responseStatus!==null&&t.responseStatus!==void 0&&t.responseStatus>=400)?1:2}function ha(e){return[...e].sort((t,n)=>{const s=Rd(t.logs)-Rd(n.logs);if(s!==0)return s;const o=Ed(n.logs).localeCompare(Ed(t.logs));return o!==0?o:t.id.localeCompare(n.id)})}function WI(e){const t=new Map;for(const s of e){const o=eg(s.logs),i=tg(s.logs),a=UI(s),l=qI(a,o,i);let u=t.get(l);u===void 0&&(u={id:l,client:a,label:VI(a,o),userAgent:o,processes:new Map,logs:[]},t.set(l,u)),u.logs.push(...s.logs);const d=FI(s.logs),f=`${l}:${HI(d,i)}`;let p=u.processes.get(f);p===void 0&&(p={id:f,clientPid:d,clientProjectFolder:i,sessions:[],logs:[]},u.processes.set(f,p)),p.sessions.push(s),p.logs.push(...s.logs)}const n=[];for(const s of t.values()){const o=ha([...s.processes.values()].map(i=>({id:i.id,clientPid:i.clientPid,clientProjectFolder:i.clientProjectFolder,sessions:ha(i.sessions),logs:Td(i.logs)})));n.push({id:s.id,client:s.client,label:s.label,userAgent:s.userAgent,processes:o,logs:Td(s.logs)})}return ha(n)}function $o(e){return e<=0?"0":Me(e)}function ng(e){let t=0,n=0;for(const s of e)s.inputTokens!==null&&s.inputTokens!==void 0&&(t+=s.inputTokens),s.outputTokens!==null&&s.outputTokens!==void 0&&(n+=s.outputTokens);return{inputTokens:t,outputTokens:n}}function ZI(e){let t=0;for(const n of e)t+=n.sessions.length;return t}function Pd(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(t===null)return null;const n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(s=>typeof s=="string")):null}catch{return null}}function Md(e,t){try{window.localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function Id(e,t){let n=!1;const s=new Set(e);for(const o of t)s.delete(o)&&(n=!0);return n?s:e}function KI(e){const t=new Set;for(const n of e)for(let s=1;s<n.processes.length;s++){const o=n.processes[s];o!==void 0&&!zo(o.logs)&&t.add(o.id)}return t}function GI(e){if(e===null||e==="")return null;const t=e.replaceAll("\\","/").split("/").filter(o=>o!==""),n=t[t.length-1];if(n===void 0)return e;const s=t[t.length-2];return s===void 0?n:`${s}/${n}`}function Do({label:e,value:t,className:n}){return r.jsxs("span",{className:$("inline-flex h-7 items-center gap-1 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",n),children:[r.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:e}),r.jsx("span",{className:"font-mono tabular-nums text-foreground",children:t})]})}function sg({count:e}){const t=`${e} open turn${e===1?"":"s"}`;return r.jsxs("span",{className:"relative inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-medium)] text-[var(--inspector-status-watch)] ring-1 ring-border/50","aria-label":t,title:t,children:[r.jsx(Ue,{className:"size-3 animate-spin"}),e>1&&r.jsx("span",{className:"absolute translate-x-2 -translate-y-2 rounded bg-card px-0.5 font-mono text-[8px] tabular-nums text-[var(--inspector-status-watch)]",children:e})]})}function JI({groups:e,...t}){const n=c.useMemo(()=>WI(e),[e]),[s,o]=c.useState(()=>new Set),[i,a]=c.useState(()=>KI(n)),[l,u]=c.useState(!1);c.useEffect(()=>{const p=Pd(Nd),m=Pd(Cd);p!==null&&o(p),m!==null&&a(m),u(!0)},[]),c.useEffect(()=>{l&&(Md(Nd,s),Md(Cd,i))},[s,i,l]),c.useEffect(()=>{const p=new Set(n.filter(h=>zo(h.logs)).map(h=>h.id)),m=new Set(n.flatMap(h=>h.processes.filter(g=>zo(g.logs)).map(g=>g.id)));o(h=>Id(h,p)),a(h=>Id(h,m))},[n]);const d=c.useCallback(p=>{o(m=>{const h=new Set(m);return h.has(p)?h.delete(p):h.add(p),h})},[]),f=c.useCallback(p=>{a(m=>{const h=new Set(m);return h.has(p)?h.delete(p):h.add(p),h})},[]);return r.jsx("div",{className:"space-y-2",children:n.map(p=>r.jsx(YI,{group:p,collapsed:s.has(p.id),collapsedProcessIds:i,onToggleClient:()=>d(p.id),onToggleProcess:f,conversationProps:t},p.id))})}function YI({group:e,collapsed:t,collapsedProcessIds:n,onToggleClient:s,onToggleProcess:o,conversationProps:i}){const a=ng(e.logs),l=ZI(e.processes),u=e.logs.length,d=Q0(e.logs),f=d>0;return r.jsxs("section",{className:$("relative isolate overflow-hidden rounded-[8px] bg-card/65",f&&"bg-card/80"),"data-ide-group":e.id,children:[r.jsxs("button",{type:"button",className:"grid w-full min-w-0 grid-cols-[2.25rem_minmax(0,1fr)_auto] items-center gap-2.5 px-3 py-2.5 text-left transition-colors hover:bg-[var(--inspector-surface-low)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:s,"aria-expanded":!t,children:[e.client==="unknown"?r.jsx("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground",children:r.jsx(pj,{className:"size-4"})}):r.jsx(bi,{client:e.client,className:"size-9 rounded-md",decorative:!0}),r.jsxs("span",{className:"min-w-0",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"truncate text-sm font-semibold text-foreground",title:e.userAgent??e.label,children:e.label}),r.jsx("span",{className:"rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:PC(e.client)}),f&&r.jsx(sg,{count:d})]}),r.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[r.jsxs("span",{children:[e.processes.length," process",e.processes.length!==1?"es":""]}),r.jsxs("span",{children:[l," session",l!==1?"s":""]}),r.jsxs("span",{children:[u," req"]})]})]}),r.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t&&r.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[r.jsx(Do,{label:"IN",value:$o(a.inputTokens)}),r.jsx(Do,{label:"OUT",value:$o(a.outputTokens)})]}),r.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors group-hover:bg-[var(--inspector-surface-medium)]",children:t?r.jsx(yt,{className:"size-4"}):r.jsx(nt,{className:"size-4"})})]})]}),!t&&r.jsx("div",{className:"space-y-0.5 px-2 pb-2 pt-0.5",children:e.processes.map(p=>r.jsx(XI,{group:p,collapsed:n.has(p.id),onToggle:()=>o(p.id),conversationProps:i},p.id))})]})}function XI({group:e,collapsed:t,onToggle:n,conversationProps:s}){const o=ng(e.logs),i=GI(e.clientProjectFolder),a=e.sessions.length,l=e.logs.length,u=Q0(e.logs),d=u>0,f=e.clientPid!==null&&e.clientPid!==void 0?`PID ${e.clientPid}`:"Process unavailable";return r.jsxs("section",{className:"relative pl-3",children:[r.jsxs("button",{type:"button",className:"grid w-full min-w-0 grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-2.5 rounded-md bg-[var(--inspector-surface-low)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--inspector-surface-medium)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:n,"aria-expanded":!t,children:[r.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center text-[var(--inspector-status-watch)]",children:r.jsx(Rw,{className:"size-4"})}),r.jsxs("span",{className:"min-w-0",children:[r.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:"font-mono text-xs font-semibold tabular-nums text-foreground",children:f}),d&&r.jsx(sg,{count:u}),i!==null&&r.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:e.clientProjectFolder??i,children:[r.jsx(Xw,{className:"size-3 shrink-0"}),r.jsx("span",{className:"truncate font-mono",children:i})]})]}),r.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[r.jsxs("span",{children:[a," session",a!==1?"s":""]}),r.jsxs("span",{children:[l," req"]})]})]}),r.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t&&r.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[r.jsx(Do,{label:"IN",value:$o(o.inputTokens)}),r.jsx(Do,{label:"OUT",value:$o(o.outputTokens)})]}),r.jsx("span",{className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)]",children:t?r.jsx(yt,{className:"size-4"}):r.jsx(nt,{className:"size-4"})})]})]}),!t&&r.jsx("div",{className:"space-y-1 pb-1 pl-3 pr-1 pt-1",children:e.sessions.map(p=>r.jsx(eR,{group:p,...s,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},p.id))})]})}const QI="w-[calc(100%-1rem)] border-warning/30 bg-popover text-popover-foreground sm:max-w-lg",eA=[{label:"Headers",detail:"request and response headers, including authorization or cookie values"},{label:"Prompts",detail:"system instructions, user prompts, model responses, and conversation history"},{label:"Source content",detail:"source code, file contents, tool inputs, and tool output"},{label:"Secrets",detail:"API keys, access tokens, credentials, and other sensitive values"}];function tA({onCancel:e,onExportRedacted:t,onConfirmRaw:n}){return r.jsxs(r.Fragment,{children:[r.jsxs(Xt,{children:[r.jsx(Qt,{children:"Export unredacted logs?"}),r.jsx(wr,{children:"Raw exports bypass Agent Inspector redaction and may expose sensitive captured data."})]}),r.jsxs("div",{role:"alert",className:"rounded-md border border-warning/35 bg-warning/10 px-3 py-3 text-sm text-foreground",children:[r.jsx("p",{className:"font-medium",children:"The raw archive may include:"}),r.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs leading-relaxed text-muted-foreground",children:eA.map(s=>r.jsxs("li",{children:[r.jsxs("span",{className:"font-semibold text-foreground",children:[s.label,":"]})," ",s.detail]},s.label))}),r.jsx("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:"Only continue if you trust where this file will be stored and everyone it may be shared with."})]}),r.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[r.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:e,children:"Cancel"}),r.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:t,children:"Export redacted instead"}),r.jsx(ee,{type:"button",variant:"destructive",size:"sm",onClick:n,children:"Export raw data"})]})]})}const Fo="data-nav-id",nA="data-nav-action";function Ad(e){return Array.from(e.querySelectorAll(`[${Fo}]`))}function Od(e){return e instanceof HTMLElement}function sA(e,t){let n=e;for(;n!==null&&n!==t;){if(n.hasAttribute(Fo))return n;n=n.parentElement}return e.hasAttribute(Fo)?e:null}function ga(e){const t=e.getAttribute(nA);return t==="toggle"||t==="expand"||t==="collapse"?t:null}function Ws(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Zs(e,t){return e[t]??null}function rg(e){const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function zd(e){const t=e.tagName;return t==="BUTTON"||t==="A"||rg(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function rA(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function oA(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function Kr(e,t){return e.key===t&&e.shiftKey}function iA(e,t,n={}){const s=t??e,o=n.pageWide===!0,i=c.useCallback(a=>{const l=e.current,u=s.current;if(!l||!u)return;const d=a.target;if(!Od(d)||d!==u)return;const f=Ad(l),p=Zs(f,0);p!==null&&Ws(p)},[e,s]);c.useEffect(()=>{const a=l=>{if(l.altKey||l.ctrlKey||l.metaKey)return;const u=e.current;if(!u)return;const d=l.target;if(!Od(d)||rg(d)||oA())return;const f=u.contains(d);if(f&&zd(d)&&!d.hasAttribute(Fo)||!f&&(!o||zd(d)||rA(d)))return;const p=Ad(u);if(p.length===0)return;const m=sA(d,u),h=m!==null?p.indexOf(m):-1;let g=!1;switch(l.key){case"ArrowUp":case"W":{if(l.shiftKey&&l.key==="ArrowUp"||l.key==="W"&&!Kr(l,"W"))break;l.preventDefault();const y=h>0?h-1:h===-1?p.length-1:-1;if(y!==-1){const b=Zs(p,y);b!==null&&Ws(b)}g=!0;break}case"ArrowDown":case"S":{if(l.shiftKey&&l.key==="ArrowDown"||l.key==="S"&&!Kr(l,"S"))break;l.preventDefault();const y=h<p.length-1?h+1:h===-1?0:-1;if(y!==-1){const b=Zs(p,y);b!==null&&Ws(b)}g=!0;break}case"ArrowLeft":case"A":{if(l.shiftKey&&l.key==="ArrowLeft"||l.key==="A"&&!Kr(l,"A")||m===null)break;if(l.preventDefault(),ga(m)==="collapse")m.click();else if(h>0){const b=Zs(p,h-1);b!==null&&Ws(b)}g=!0;break}case"ArrowRight":case"D":{if(l.shiftKey&&l.key==="ArrowRight"||l.key==="D"&&!Kr(l,"D")||m===null)break;if(l.preventDefault(),ga(m)==="expand")m.click();else if(h<p.length-1){const b=Zs(p,h+1);b!==null&&Ws(b)}g=!0;break}case" ":{if(m===null)break;l.preventDefault(),ga(m)!==null&&m.click(),g=!0;break}}g&&l.stopPropagation()};return document.addEventListener("keydown",a,{capture:!0}),()=>document.removeEventListener("keydown",a,{capture:!0})},[e,o,s]),c.useEffect(()=>(document.addEventListener("focusin",i),()=>document.removeEventListener("focusin",i)),[i])}const aA={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},lA={system:"bg-sky-500/70",user:"bg-emerald-500/70",assistant:"bg-violet-500/70",tool:"bg-sky-400/55",tools:"bg-slate-500/70"},cA={system:"focus-visible:ring-sky-300",user:"focus-visible:ring-emerald-300",assistant:"focus-visible:ring-violet-300",tool:"focus-visible:ring-sky-300",tools:"focus-visible:ring-slate-300"},xa=12,Gr=1,Ld=80,$d=24;function uA(e){return e.length<=$d?e:`${e.slice(0,$d-3)}...`}function dA(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Ld?t:`${t.slice(0,Ld)}...`}function Jr(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const fA=c.memo(function({segments:t,totalTokens:n,showLabels:s=!0,onActivate:o}){const i=c.useMemo(()=>n>0?n:t.reduce((b,w)=>b+w.size,0),[t,n]),a=t.slice(0,xa),l=t.slice(xa),u=l.reduce((b,w)=>b+w.size,0),d=l.length,f=xa,p=f+d-1,m=d>0,h=o!==void 0,g=c.useMemo(()=>a.reduce((b,w)=>b+w.size,0),[a]),y=c.useMemo(()=>`Request context: ~${Me(i)} tokens across ${t.length} segment${t.length===1?"":"s"}`,[t.length,i]);return t.length===0||i<=0?r.jsx("div",{role:"img","aria-label":y,className:"h-6"}):r.jsx(Ds,{delayDuration:150,children:r.jsxs("div",{role:"img","aria-label":y,className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"relative flex h-6 w-full overflow-hidden rounded border border-border/40 bg-muted/30","data-testid":"anatomy-segment-bar",children:[a.map((b,w)=>{const v=i>0?b.size/i*100:0,j=Math.max(Gr,v),S=$("h-full border-r border-background/80 last:border-r-0",h?"opacity-90 hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background":"opacity-90",lA[b.role],h?cA[b.role]:""),k={width:`${j}%`},_=`${b.label}, ${Jr(v)}, ~${Me(b.size)} tokens`;return r.jsxs(pt,{children:[r.jsx(mt,{asChild:!0,children:h?r.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>o(b),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),o(b))},"data-anatomy-path":b.path,"aria-label":_,className:S,style:k}):r.jsx("span",{"aria-label":_,className:S,style:k})}),r.jsxs(ht,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[r.jsxs("div",{className:"font-semibold",children:[b.label," - ",Jr(v)," - ~",Me(b.size)," ","tokens"]}),r.jsx("div",{className:"text-muted-foreground",children:aA[b.role]}),r.jsxs("div",{className:"text-muted-foreground",children:[b.characters.toLocaleString()," chars"]}),b.text.length>0&&r.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:dA(b.text)})]})]},`${b.path}-${w}`)}),m&&r.jsxs(pt,{children:[r.jsx(mt,{asChild:!0,children:r.jsxs("div",{role:"img","aria-label":`${d} additional segments`,className:"flex h-full items-center justify-center bg-muted-foreground/30 px-1.5 text-[10px] font-mono text-background",style:{width:`${Math.max(Gr,u/i*100)}%`},children:["... +",d]})}),r.jsxs(ht,{side:"bottom",className:"text-xs",children:[d," more segment",d===1?"":"s"," (indices"," ",f,"-",p,")"]})]})]}),s&&r.jsxs("div",{className:"flex w-full gap-1 text-[10px] text-muted-foreground",children:[a.map((b,w)=>{const v=i>0?b.size/i*100:0,j=Math.max(Gr,v);return r.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${j}%`},title:`${b.label} - ${Jr(v)} - ~${Me(b.size)} tokens`,children:[r.jsx("span",{className:"truncate font-mono text-foreground/80",children:uA(b.label)}),r.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[Jr(v)," - ~",Me(b.size)]})]},`label-${b.path}-${w}`)}),m&&r.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(Gr,u/i*100)}%`},children:[r.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",d]}),r.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",Me(u)]})]})]}),g<i*.1&&r.jsx("div",{className:"h-0"})]})})}),og=.75,ig=.9,ol=8e3,pA=.35,ag=40,lg=160,mA=5,hA=8,gA=18,xA=6e4,bA=.7,Dd=3e3,vA=.3,Fd=160,yA=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),wA=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],jA=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],kA=[{family:"OpenAI GPT-4.1",tokens:1047576,mode:"prefix",patterns:["gpt-4.1"]},{family:"OpenAI GPT-4o",tokens:128e3,mode:"prefix",patterns:["gpt-4o"]},{family:"OpenAI o-series",tokens:128e3,mode:"prefix",patterns:["o1","o3","o4"]},{family:"Anthropic Claude",tokens:2e5,mode:"prefix",patterns:["claude-"]},{family:"DeepSeek V4",tokens:1048576,mode:"prefix",patterns:["deepseek-v4-pro","deepseek-v4-flash"]},{family:"DeepSeek",tokens:64e3,mode:"prefix",patterns:["deepseek-"]},{family:"MiniMax M3",tokens:1048576,mode:"includes",patterns:["minimax-m3"]},{family:"MiniMax M2.7",tokens:204800,mode:"includes",patterns:["minimax-m2.7"]},{family:"MiniMax M2.5/M2.1",tokens:196608,mode:"includes",patterns:["minimax-m2.5","minimax-m2.1"]},{family:"GLM-5.2",tokens:1048576,mode:"prefix",patterns:["glm-5.2"]},{family:"GLM-5",tokens:202752,mode:"prefix",patterns:["glm-5","glm-5.1"]}],SA={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function _A(e){if(typeof e=="number")return Number.isFinite(e)&&e>0?Math.floor(e):null;if(typeof e=="string"){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}return null}function cg(e,t){for(const n of t){const s=_A(Q(e,n));if(s!==null)return s}return null}function NA(e){const t=Q(e,"model");if(typeof t!="string")return null;const n=t.trim();return n===""?null:n}function CA(e,t){switch(t.mode){case"prefix":return t.patterns.some(n=>e.startsWith(n));case"includes":return t.patterns.some(n=>e.includes(n))}}function TA(e,t,n=[]){const s=cg(t,wA);if(s!==null)return{tokens:s,label:"Request metadata",source:"request"};const o=MP(e,n);if(o!==null)return{tokens:o.tokens,label:`${o.providerName} config`,source:"provider"};if(e===null)return{tokens:null,label:"Unknown model",source:"unknown"};const i=e.trim().toLowerCase().replace(/\s+/g,"-");for(const a of kA)if(CA(i,a))return{tokens:a.tokens,label:`${a.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function EA(e){return e<0?0:e>1?1:e}function RA(e){return e===null?"unknown":e>=ig?"danger":e>=og?"watch":"ok"}function PA(e,t){return e.filter(n=>n.role===t).reduce((n,s)=>n+s.size,0)}function MA(e,t){return["system","user","assistant","tool","tools"].map(s=>{const o=PA(e,s);return{role:s,label:SA[s],tokens:o,percent:t>0?o/t:0}}).filter(s=>s.tokens>0).sort((s,o)=>o.tokens-s.tokens)}function il(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function IA(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Fd?t:`${t.slice(0,Fd-3)}...`}function AA(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function OA(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function zA(e){const t=e.trim();return t.startsWith("{")||t.startsWith("[")}function LA(e){if(!zA(e))return null;try{return JSON.parse(e)}catch{return null}}function $A(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function DA(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t]??"";if(!(n.startsWith("[")&&n.endsWith("]")))return n}return null}function FA(e){const t=DA(e);return t===null?!1:yA.has($A(t))}function UA(e){return e.map(t=>t.startsWith("[")?t:`.${t}`).join("").replace(/^\./,"")}function BA(e,t,n){const s=dc(t);if(s<lg)return null;const o=uc(t);return o<ag?null:{role:e.role,label:`${e.label} ${UA(n)}`,path:e.path,tokens:o,characters:s,text:t}}function al({value:e,segment:t,path:n,depth:s,candidates:o}){if(!(o.length>=hA)&&!(s>mA)){if(typeof e=="string"){if(!FA(n))return;const i=BA(t,e,n);i!==null&&o.push(i);return}if(Array.isArray(e)){e.forEach((i,a)=>al({value:i,segment:t,path:[...n,`[${String(a)}]`],depth:s+1,candidates:o}));return}fc(e)&&Object.entries(e).forEach(([i,a])=>al({value:a,segment:t,path:[...n,i],depth:s+1,candidates:o}))}}function VA(e){const t=OA(e),n=LA(e.text);if(n===null)return[t];const s=[];al({value:n,segment:e,path:[],depth:0,candidates:s});const o=il(e.text),i=new Set([o]),a=s.filter(l=>{const u=il(l.text);return u===""||i.has(u)?!1:(i.add(u),!0)});return[t,...a]}function qA(e){const t=new Map;for(const s of e){const o=VA(s);for(const i of o){if(i.tokens<ag||i.characters<lg)continue;const a=il(i.text);if(a==="")continue;const l=t.get(a);if(l===void 0){t.set(a,{tokens:i.tokens,candidates:[i]});continue}t.set(a,{tokens:l.tokens+i.tokens,candidates:[...l.candidates,i]})}}const n=[];for(const s of t.values()){if(s.candidates.length<2)continue;const o=s.candidates[0]??null;if(o===null)continue;const i=s.tokens-o.tokens;n.push({key:`${o.path}:${o.label}:${String(s.candidates.length)}:${String(s.tokens)}`,count:s.candidates.length,totalTokens:s.tokens,repeatedTokens:i,preview:IA(o.text),firstLabel:o.label,segments:s.candidates.map(AA)})}return n.sort((s,o)=>o.repeatedTokens-s.repeatedTokens||o.totalTokens-s.totalTokens)}function HA(e){if(e.length===0)return null;const t=e.length,n=e.reduce((o,i)=>o+i.count,0),s=e.reduce((o,i)=>o+i.repeatedTokens,0);return{kind:"duplicate",severity:s>=ol?"danger":"watch",title:"Duplicate context",detail:`${String(n)} repeated blocks across ${String(t)} group${t===1?"":"s"}, ~${String(s)} repeated tokens.`}}function WA(e){return e.reduce((t,n)=>t+n.repeatedTokens,0)}function ZA(e,t,n){const s=[],o=e.find(u=>u.role==="tools")??null;o!==null&&(o.tokens>=ol||o.percent>=pA&&o.tokens>=Dd)&&s.push({kind:"tool-schema",severity:o.tokens>=ol?"danger":"watch",title:"Large tool schema",detail:`Tool definitions take ${Math.round(o.percent*100)}% of request context.`});const i=e.find(u=>u.role==="system")??null;i!==null&&i.tokens>=Dd&&i.percent>=vA&&s.push({kind:"system-heavy",severity:"watch",title:"Large system prompt",detail:`System instructions take ${Math.round(i.percent*100)}% of request context.`});const a=e.filter(u=>u.role==="user"||u.role==="assistant"||u.role==="tool").reduce((u,d)=>u+d.tokens,0),l=t>0?a/t:0;return n>=gA&&(a>=xA||l>=bA)&&s.push({kind:"history-bloat",severity:l>=.85?"danger":"watch",title:"Conversation history growth",detail:`${String(n)} message blocks take ${Math.round(l*100)}% of request context.`}),s}function KA({risk:e,contextWindow:t,diagnostics:n,duplicateGroups:s}){let i=new Set(n.map(u=>u.kind)).size;(e==="watch"||e==="danger")&&(i+=1),t.source==="unknown"&&(i+=1);const a=n.some(u=>u.severity==="danger");return{level:e==="danger"||a?"risk":i>0?"optimizable":"ok",opportunityCount:i,reclaimableTokens:WA(s)}}function GA({segments:e,inputTokens:t,parsed:n,model:s,providers:o=[]}){const i=e.reduce((_,C)=>_+C.size,0),a=s??NA(n),l=t??i,u=cg(n,jA),d=TA(a,n,o),f=u??0,p=d.tokens===null?null:l+f,m=d.tokens===null?null:d.tokens-l,h=d.tokens===null?null:d.tokens-l-f,g=d.tokens===null||p===null?null:EA(p/d.tokens),y=MA(e,i),b=y[0]??null,w=e.filter(_=>_.role!=="tools").length,v=qA(e),j=HA(v),S=ZA(y,i,w);j!==null&&S.unshift(j);const k=RA(g);return{model:a,contextWindow:d,estimatedInputTokens:l,outputReserveTokens:u,windowUsedTokens:p,remainingInputTokens:m,remainingAfterReserveTokens:h,usagePercent:g,riskLevel:k,roleUsages:y,largestRole:b,diagnostics:S,duplicateGroups:v,health:KA({risk:k,contextWindow:d,diagnostics:S,duplicateGroups:v})}}const n6={watch:og,danger:ig},Ud=new WeakMap;function JA(e){return e.map(t=>{const n=t.modelMetadata?.map(s=>`${s.model}:${String(s.contextWindow??"")}`).join(",")??"";return`${t.id}:${t.updatedAt}:${t.models.join(",")}:${n}`}).join("|")}function YA(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function XA(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function QA(e,t){const n=YA(e.rawRequestBody);if(n===null)return null;const o=n0(ar(e)).anatomySegments(n);if(o===null)return null;const i=GA({segments:o,inputTokens:e.inputTokens??null,parsed:n,model:e.model,providers:t}),a=i.model??e.model??"Unknown model",l=i.roleUsages.map(XA);return{logId:e.id,model:a,timestamp:e.timestamp,contextWindow:i.contextWindow,estimatedInputTokens:i.estimatedInputTokens,windowUsedTokens:i.windowUsedTokens,usagePercent:i.usagePercent,riskLevel:i.riskLevel,health:i.health,diagnostics:i.diagnostics.map(u=>u.title),roleSegments:l,roleTotalTokens:l.reduce((u,d)=>u+d.size,0)}}function eO(e,t,n){const s=Ud.get(e);if(s!==void 0&&s.id===e.id&&s.rawRequestBody===e.rawRequestBody&&s.inputTokens===e.inputTokens&&s.model===e.model&&s.path===e.path&&s.apiFormat===e.apiFormat&&s.timestamp===e.timestamp&&s.providersSignature===n)return s.snapshot;const o=QA(e,t);return Ud.set(e,{id:e.id,rawRequestBody:e.rawRequestBody,inputTokens:e.inputTokens,model:e.model,path:e.path,apiFormat:e.apiFormat,timestamp:e.timestamp,providersSignature:n,snapshot:o}),o}function tO(e,t){return e.usagePercent!==null&&t.usagePercent!==null?e.usagePercent>t.usagePercent:e.usagePercent!==null&&t.usagePercent===null?!0:e.usagePercent===null&&t.usagePercent!==null?!1:e.estimatedInputTokens>t.estimatedInputTokens}function Bd(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function nO(e,t){const n=Bd(t.latest.riskLevel)-Bd(e.latest.riskLevel);if(n!==0)return n;const s=e.peak.usagePercent??-1,i=(t.peak.usagePercent??-1)-s;return i!==0?i:t.latest.logId-e.latest.logId}function sO(e,t){return e.usagePercent===null||t.usagePercent===null?null:(t.usagePercent-e.usagePercent)*100}function rO(e){for(let t=1;t<e.length;t++){const n=e[t-1],s=e[t];if(!(n===void 0||s===void 0)&&n.id>s.id)return[...e].sort((o,i)=>o.id-i.id)}return e}function oO(e,t=[]){const n=rO(e),s=JA(t),o=new Map;for(const a of n){const l=eO(a,t,s);if(l===null)continue;const u=o.get(l.model);if(u===void 0){o.set(l.model,{model:l.model,requestCount:1,first:l,latest:l,peak:l});continue}o.set(l.model,{model:u.model,requestCount:u.requestCount+1,first:u.first,latest:l,peak:tO(l,u.peak)?l:u.peak})}return{models:[...o.values()].map(a=>({model:a.model,requestCount:a.requestCount,first:a.first,latest:a.latest,peak:a.peak,trendPercent:sO(a.first,a.latest)})).sort(nO)}}function sn(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function iO(e){const t=new Map;for(const n of e)for(let s=0;s<n.logs.length;s+=1){const o=n.logs[s];o!==void 0&&t.set(o.id,s+1)}return t}function Vd(e,t){return t.get(e.id)??e.id}function qd(e){let t=0,n=0;for(const s of e)s.inputTokens!==null&&(t+=s.inputTokens),s.outputTokens!==null&&(n+=s.outputTokens);return{totalIn:t,totalOut:n}}function aO(e){for(const t of e)if(t.userAgent!==null&&t.userAgent!==void 0&&t.userAgent!=="")return t.userAgent;return null}function lO(e,t){const n=e[0],s=e[e.length-1];return n===void 0||s===void 0?null:Jo(n.timestamp,s.timestamp,t)}function cO(e){switch(e){case"cool":return"text-cyan-100";case"danger":return"text-red-100";case"watch":return"text-amber-100";case"neutral":return"text-foreground"}}function uO(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function dO(e){return e.pending>0?`${e.pending} pending / ${e.failures} failed`:e.lengthStops>0?`${e.lengthStops} output limit / ${e.failures} failed`:`${e.failures} failed / ${e.slow} slow`}function fs({label:e,value:t,detail:n,icon:s,tone:o="neutral"}){return r.jsxs("div",{className:"min-w-0 border-t border-white/10 px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[s,e]}),r.jsx("div",{className:$("mt-2 font-mono text-sm font-semibold",cO(o)),children:t}),r.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:n})]})}function fO({stats:e}){return e.requests===0?null:r.jsxs("div",{className:"border border-border bg-card shadow-sm mb-4 overflow-hidden rounded-[8px]",children:[r.jsx("div",{className:"px-4 py-3",children:r.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-semibold uppercase text-muted-foreground",children:[r.jsx(vw,{className:"size-3.5 text-slate-300"}),"Flight Recorder"]}),r.jsx("div",{className:"mt-2 min-w-0 font-mono text-sm font-semibold text-foreground",children:e.modelLabel})]}),r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"min-w-0 font-mono",children:e.providerLabel}),r.jsx("span",{className:"min-w-0 font-mono",children:e.timeRange??"Timeline pending"})]})]})}),r.jsxs("div",{className:"grid grid-cols-2 border-t border-white/10 md:grid-cols-3 2xl:grid-cols-6",children:[r.jsx(fs,{label:"Status",value:e.statusLabel,detail:dO(e),tone:uO(e.status)}),r.jsx(fs,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:r.jsx(Gw,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),r.jsx(fs,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:r.jsx(_a,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),r.jsx(fs,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:r.jsx(s5,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),r.jsx(fs,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:r.jsx(Al,{className:"size-3 text-muted-foreground"})}),r.jsx(fs,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function Qs(e){if(e===null)return"Unknown";const t=e*100;return t>=10?`${t.toFixed(0)}%`:t>=1?`${t.toFixed(1)}%`:t>0?"<1%":"0%"}function pO(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function ll(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function mO(e,t){if(t===null)return null;const n=ll(e),s=ll(t);return s<=0||Math.abs(s-n)<.5?null:s}function hO(e){switch(e){case"danger":return"bg-red-400";case"watch":return"bg-amber-300";case"unknown":return"bg-muted-foreground/50";case"ok":return"bg-cyan-300"}}function gO(e){const t=e.latest.contextWindow.tokens;return t===null?"Context window unknown":`Context window ${nf(t)}`}const xO=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function ug(e){return typeof e=="string"?e.length>0?e:null:typeof e=="number"||typeof e=="boolean"?String(e):e===null?null:JSON.stringify(e)}function ba(e,t){if(e===null)return null;const n=e.metadata[t];return n===void 0?null:ug(n)}function bO(e){const t=e.toLowerCase();return t.includes("reject")||t.includes("fail")||t.includes("error")?"border-red-400/35 bg-red-500/10 text-red-100":t.includes("partial")||t.includes("pending")||t.includes("slow")?"border-amber-300/35 bg-amber-400/10 text-amber-100":t.includes("pass")||t.includes("complete")||t.includes("accept")?"border-cyan-300/25 bg-cyan-400/10 text-cyan-100":"border-border/70 bg-background/70 text-muted-foreground"}function vO(e){const t=[];for(const n of xO){const s=e.metadata[n];if(s===void 0)continue;const o=ug(s);o!==null&&t.push({key:n,value:o})}return t}function Hd({memberships:e,defaultOpen:t=!1}){const[n,s]=c.useState(t);if(e.length===0)return null;const o=e[0],i=o?.member??null,a=ba(i,"score"),l=ba(i,"decision"),u=ba(i,"final_status"),d=[a===null?null:{label:`score ${a}`,value:a},l===null?null:{label:l,value:l},u===null?null:{label:u,value:u},i?.model===null||i?.model===void 0?null:{label:i.model,value:i.model}].filter(f=>f!==null&&f.label.length>0&&f.value.length>0);return r.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] text-xs",children:[r.jsxs("button",{type:"button",onClick:()=>s(f=>!f),className:"flex w-full items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-white/[0.04]","aria-expanded":n,children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:"font-semibold text-foreground",children:"Case File"}),o!==void 0&&r.jsx("span",{className:"truncate text-muted-foreground",title:o.groupTitle,children:o.groupTitle}),r.jsxs("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:[e.length," group",e.length===1?"":"s"]})]}),d.length>0&&r.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:d.slice(0,4).map(f=>r.jsx("span",{className:$("rounded border px-1.5 py-0.5 font-mono text-[10px]",bO(f.value)),children:f.label},f.label))})]}),n?r.jsx(Ml,{className:"size-4 shrink-0 text-muted-foreground"}):r.jsx(nt,{className:"size-4 shrink-0 text-muted-foreground"})]}),n&&r.jsx("div",{className:"space-y-2 border-t border-white/10 px-3 py-2",children:e.map(f=>{const p=f.member,m=vO(p);return r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:"truncate font-medium text-foreground",title:f.groupTitle,children:f.groupTitle}),r.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:f.groupStatus}),p.status!==null&&r.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["member ",p.status]})]}),r.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[r.jsx("span",{className:"font-mono",title:p.sessionId,children:sn(p.sessionId)}),p.label!==null&&r.jsx("span",{children:p.label}),p.provider!==null&&r.jsx("span",{children:p.provider}),p.model!==null&&r.jsx("span",{className:"font-mono",children:p.model}),p.runId!==null&&r.jsxs("span",{className:"font-mono",title:p.runId,children:["run ",sn(p.runId)]})]}),m.length>0&&r.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:m.map(h=>r.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-1",children:[r.jsx("div",{className:"font-mono text-[10px] text-muted-foreground",children:h.key}),r.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:h.value,children:h.value})]},h.key))})]},`${f.groupId}:${p.id}`)})})]})}function Yr({label:e,title:t,icon:n,disabled:s,onClick:o}){return r.jsxs("button",{type:"button",onClick:o,disabled:s,className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45",title:t,children:[n,r.jsx("span",{children:e})]})}function Wd({logs:e,pagination:t,embedded:n=!1}){if(t===void 0)return null;const s=t.isLoading;return r.jsxs("nav",{"aria-label":"Session log pagination",className:$("flex min-h-9 flex-col gap-2 px-1 py-1 sm:flex-row sm:items-center",n?"border-t border-white/10 pt-2":"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-2"),children:[r.jsxs("div",{className:"w-full min-w-0 px-1 font-mono text-[11px] text-muted-foreground sm:flex-1",children:[r.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",children:[bR({logs:e,pagination:t}),t.isLoading&&e.length>0&&r.jsx("span",{className:"ml-2",children:"Loading..."})]}),t.loadProgress!==void 0&&r.jsx(lo,{progress:t.loadProgress})]}),r.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[r.jsx(Yr,{label:"Oldest",title:"Load the oldest logs in this session",icon:r.jsx(ow,{className:"size-3.5"}),disabled:s||!t.hasOlder,onClick:t.onOldest}),r.jsx(Yr,{label:"Older",title:"Load older logs",icon:r.jsx(Qy,{className:"size-3.5"}),disabled:s||!t.hasOlder,onClick:t.onOlder}),r.jsx(Yr,{label:"Newer",title:"Load newer logs",icon:r.jsx(yt,{className:"size-3.5"}),disabled:s||!t.hasNewer,onClick:t.onNewer}),r.jsx(Yr,{label:"Newest",title:"Load the newest logs in this session",icon:r.jsx(aw,{className:"size-3.5"}),disabled:s||!t.hasNewer,onClick:t.onNewest})]})]})}function yO(e){return`${e} ${e===1?"request":"requests"}`}function Zd(e){return`#${String(e)}`}function Kd(e){switch(e){case"danger":return"text-red-300";case"watch":return"text-amber-200";case"unknown":return"text-muted-foreground";case"ok":return"text-cyan-200"}}function wO(e){switch(e){case"risk":return"border-red-400/30 bg-red-500/10 text-red-100";case"optimizable":return"border-amber-400/25 bg-amber-400/8 text-amber-100";case"ok":return"border-cyan-300/25 bg-cyan-400/8 text-cyan-100"}}function jO(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const kO=10,SO=80;function _O(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function NO(e){const t=document.getElementById(`log-${String(e)}`);return t instanceof HTMLElement?(t.scrollIntoView({block:"center",behavior:Y0(X0())}),t.focus({preventScroll:!0}),_O(t),!0):!1}function dg(e){Ms({logId:e,tab:"anatomy"});let t=0;const n=()=>{Ms({logId:e,tab:"anatomy"}),!NO(e)&&(t+=1,t<kO&&window.setTimeout(n,SO))};window.setTimeout(n,0)}function Gd({command:e}){const[t,n]=c.useState(!1),s=c.useCallback(()=>{Pt(e).then(o=>{o&&(n(!0),setTimeout(()=>n(!1),2e3))})},[e]);return r.jsxs("div",{"data-command-example":"true",className:tR,children:[r.jsx("pre",{className:nR,children:e}),r.jsx("button",{type:"button",onClick:s,className:"shrink-0 cursor-pointer rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Copy command",children:t?r.jsx(Ge,{className:"size-4"}):r.jsx(Ot,{className:"size-4"})})]})}function Xr({label:e,children:t,className:n}){return r.jsxs("section",{className:$("bg-white/[0.028] shadow-[inset_0_1px_0_rgba(255,255,255,0.035)] rounded-[8px]",n),children:[r.jsx("div",{className:"px-3 pt-3",children:r.jsx("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-white/35",children:e})}),r.jsx("div",{className:"p-3 pt-2",children:t})]})}function Qr({label:e,value:t}){return r.jsxs("div",{className:"bg-black/20 min-w-0 rounded-md px-2 py-2 shadow-[inset_0_1px_0_rgba(255,255,255,0.035)]",children:[r.jsx("div",{className:"truncate font-mono text-lg font-semibold leading-6 text-slate-100",children:t}),r.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] uppercase tracking-[0.12em] text-white/35",children:e})]})}function CO(){const{themeMode:e,setThemeMode:t}=M5();return r.jsxs("div",{className:"border-border/70 bg-muted/70 inline-flex h-8 items-center rounded-md border p-0.5 shadow-sm","aria-label":"Theme mode",role:"group",children:[r.jsx("button",{type:"button",onClick:()=>t("light"),className:$("inline-flex size-7 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",e==="light"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use light mode","aria-pressed":e==="light",title:"Light mode",children:r.jsx(e5,{className:"size-3.5"})}),r.jsx("button",{type:"button",onClick:()=>t("eye-care"),className:$("inline-flex size-7 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",e==="eye-care"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use eye care mode","aria-pressed":e==="eye-care",title:"Eye care mode",children:r.jsx(fp,{className:"size-3.5"})}),r.jsx("button",{type:"button",onClick:()=>t("dark"),className:$("inline-flex size-7 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",e==="dark"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use dark mode","aria-pressed":e==="dark",title:"Dark mode",children:r.jsx(hj,{className:"size-3.5"})})]})}function TO({visible:e,onToggle:t}){const n=e?"Hide Inspector pet":"Summon Inspector pet";return r.jsx("button",{type:"button",onClick:t,className:$("border-border/70 bg-muted/70 inline-flex size-8 shrink-0 items-center justify-center rounded-md border text-muted-foreground shadow-sm transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",e&&"bg-background text-amber-500 shadow-sm"),"aria-label":n,"aria-pressed":e,title:n,children:r.jsx(sf,{className:$("size-4 transition-opacity",!e&&"opacity-45")})})}function EO({preference:e,resolvedScale:t,onChange:n}){const s=zg(t),o=e==="auto"?`Auto (${s})`:`${e}%`;return r.jsxs(Zn,{value:e,onValueChange:i=>n(Qd(i)),children:[r.jsxs(Kn,{size:"sm",className:"bg-white/[0.035] hover:bg-white/[0.065] h-8 min-w-[4rem] justify-center gap-1 border-0 px-2 py-0 text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] [&>svg:last-child]:hidden","aria-label":`Interface size: ${o}`,children:[r.jsx(Ey,{className:"size-3.5"}),r.jsx("span",{className:"font-mono text-[10px] font-semibold tabular-nums",children:s})]}),r.jsxs(Gn,{align:"end",children:[r.jsx(Qe,{value:"auto",children:"Auto"}),r.jsx(Qe,{value:"100",children:"100%"}),r.jsx(Qe,{value:"125",children:"125%"}),r.jsx(Qe,{value:"150",children:"150%"})]})]})}const fg="agent-inspector.detailsPanelCollapsed",pg="agent-inspector.pet.visible";function RO(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(fg);return e===null||e==="1"}function PO(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(pg)!=="0"}catch{return!0}}function Jd({label:e,logId:t}){return r.jsxs("button",{type:"button",onClick:()=>dg(t),className:"inline-flex h-5 items-center rounded px-1 font-mono text-[10px] text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",title:`Open Context for ${Zd(t)}`,children:[e," ",Zd(t)]})}function MO({latestPercent:e,peakPercent:t,risk:n,onOpenContext:s}){const o=ll(e),i=mO(e,t),a=t===null?`Latest context window usage ${Qs(e)}`:`Latest context window usage ${Qs(e)}, peak ${Qs(t)}`;return r.jsx("button",{type:"button",onClick:s,className:"group block w-full rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1","aria-label":`${a}. Open latest Context details`,title:"Open latest Context details",children:r.jsxs("span",{className:"relative block h-2.5 overflow-hidden rounded-full border border-white/10 bg-black/25 transition-colors group-hover:border-cyan-200/35",role:"meter","aria-label":a,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o),children:[r.jsx("span",{className:$("block h-full rounded-full transition-[width]",hO(n)),style:{width:`${o}%`}}),i!==null&&r.jsx("span",{className:"absolute top-0 h-full w-0.5 rounded-full bg-amber-100/75 shadow-[0_0_0_1px_rgba(0,0,0,0.25)]",style:{left:`calc(${i}% - 0.5px)`},"aria-hidden":"true"})]})})}function IO({summary:e}){const t=e.trendPercent,n=t===null||Math.abs(t)<.1?null:t>0?Dy:Iy,s=e.latest.diagnostics[0]??null,o=Qs(e.latest.usagePercent),i=Qs(e.peak.usagePercent),a=()=>{dg(e.latest.logId)};return r.jsxs("div",{className:"grid gap-x-4 gap-y-2 border-t border-white/10 py-2 first:border-t-0 lg:grid-cols-[minmax(180px,1fr)_minmax(260px,1fr)_minmax(260px,1.4fr)]",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("button",{type:"button",onClick:a,className:"min-w-0 truncate rounded-sm text-left font-mono font-semibold text-foreground transition-colors hover:text-cyan-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",title:`Open latest Context for ${e.model}`,children:e.model}),r.jsx("span",{className:$("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",wO(e.latest.health.level)),children:jO(e.latest.health.level)})]}),r.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[r.jsx("span",{children:yO(e.requestCount)}),r.jsx("span",{children:gO(e)})]})]}),r.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[r.jsx(MO,{latestPercent:e.latest.usagePercent,peakPercent:e.peak.usagePercent,risk:e.latest.riskLevel,onOpenContext:a}),r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Latest"}),r.jsx("div",{className:$("mt-0.5 font-mono",Kd(e.latest.riskLevel)),children:o}),r.jsx(Jd,{label:"Log",logId:e.latest.logId})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Peak"}),r.jsx("div",{className:$("mt-0.5 font-mono",Kd(e.peak.riskLevel)),children:i}),r.jsx(Jd,{label:"Log",logId:e.peak.logId})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Trend"}),r.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-foreground",children:[n!==null&&r.jsx(n,{className:$("size-3",t!==null&&t>0?"text-amber-300":"text-cyan-300")}),pO(t)]}),r.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),r.jsxs("div",{className:"min-w-0 space-y-1.5",children:[r.jsx(fA,{segments:e.latest.roleSegments,totalTokens:e.latest.roleTotalTokens,showLabels:!1}),r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[r.jsxs("span",{className:"font-mono",children:["~",Me(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&r.jsxs("span",{className:"font-mono",children:["~",Me(e.latest.windowUsedTokens)," used"]}),s!==null&&r.jsx("span",{className:"truncate",children:s})]})]})]})}function AO({summary:e}){return e.models.length===0?null:r.jsxs("div",{className:"mt-3 border-t border-white/10 pt-2",children:[r.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Session Context"}),r.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:[e.models.length," model",e.models.length===1?"":"s"]})]}),r.jsx("div",{className:"max-h-52 overflow-y-auto pr-1",children:e.models.map(t=>r.jsx(IO,{summary:t},t.model))})]})}function OO(e){const t=e.models.filter(s=>s.latest.health.level==="risk").length;if(t>0)return`${t} risk`;const n=e.models.filter(s=>s.latest.health.level==="optimizable").length;return n>0?`${n} optimizable`:`${e.models.length} model${e.models.length===1?"":"s"}`}function zO({label:e,logs:t,totalIn:n,totalOut:s,timeDisplayFormat:o,contextSummary:i,showBackLink:a}){const[l,u]=c.useState(!1),[d,f]=c.useState(!1),p=c.useMemo(()=>lO(t,o),[t,o]),m=c.useMemo(()=>aO(t),[t]),h=c.useMemo(()=>OO(i),[i]),g=c.useCallback(()=>{Pt(window.location.href).then(y=>{y&&(u(!0),setTimeout(()=>u(!1),2e3))})},[]);return r.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-3 py-2 text-xs",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a&&r.jsx("a",{href:"/",className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":"Back to all sessions",title:"Back to all sessions",children:r.jsx(Ly,{className:"size-3.5"})}),r.jsxs("div",{className:"min-w-[180px] flex-1",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"font-mono font-semibold text-purple-400/90 truncate",title:e,children:sn(e)}),m!==null&&r.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:m,children:m})]}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[r.jsxs("span",{children:[t.length," request",t.length!==1?"s":""]}),p!==null&&r.jsx("span",{children:p}),(n>0||s>0)&&r.jsxs("span",{className:"font-mono",children:[Me(n)," in / ",Me(s)," out"]})]})]}),i.models.length>0&&r.jsxs("button",{type:"button",onClick:()=>f(y=>!y),className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 font-mono text-[11px] text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-expanded":d,title:d?"Hide context details":"Show context details",children:[r.jsx("span",{children:h}),d?r.jsx(Ml,{className:"size-3.5"}):r.jsx(nt,{className:"size-3.5"})]}),r.jsx("button",{type:"button",onClick:g,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":l?"Copied session link":"Copy session link",title:l?"Copied session link":"Copy session link",children:l?r.jsx(Ge,{className:"size-3.5"}):r.jsx(Ot,{className:"size-3.5"})})]}),d&&r.jsx(AO,{summary:i})]})}function LO({logs:e,sessions:t,models:n,selectedSession:s,selectedModel:o,onSessionChange:i,onModelChange:a,onClearAll:l,onDeleteCurrentView:u,onReloadSession:d,onClearGroup:f,onNotify:p,onImportLogs:m,viewMode:h,captureMode:g,strip:y,slowResponseThresholdSeconds:b,timeDisplayFormat:w,isLoading:v=!1,liveConnection:j,onRetryLiveConnection:S,onStopLiveConnection:k,pagination:_,sessionLoadProgress:C,sessionLoadError:I,sessionMemberships:A=[],hideSessionFilter:P=!1,pinnedSessionId:N}){const{totalIn:M,totalOut:F}=c.useMemo(()=>qd(e),[e]),{providers:B}=zl(),{uiScalePreference:J,resolvedUiScale:K,setUiScalePreference:W}=I5(),[V,z]=c.useState(null),[X,Y]=c.useState(null),[we,he]=c.useState(!1),[oe,D]=c.useState(!1),[Ne,te]=c.useState(null),[je,ke]=c.useState(null),[ue,le]=c.useState(!1),[xe,Se]=c.useState(!1),[ve,Ze]=c.useState(!0),[Be,Ke]=c.useState(!1),[dt,Lt]=c.useState(!0),[Ct,Ye]=c.useState(!1),[Ie,Oe]=c.useState(null),q=c.useRef(null),ne=c.useRef(null),Ee=c.useRef(null),me=c.useRef(null),be=c.useRef(0);iA(q,ne,{pageWide:!0});const ze=c.useCallback(()=>{be.current+=1,me.current?.abort(),me.current=null,z(null),Y(null)},[]);c.useEffect(()=>()=>{be.current+=1,me.current?.abort(),me.current=null},[]),c.useEffect(()=>{Ze(RO()),Ke(!0)},[]),c.useEffect(()=>{Be&&window.localStorage.setItem(fg,ve?"1":"0")},[ve,Be]),c.useEffect(()=>{Lt(PO()),Ye(!0)},[]),c.useEffect(()=>{if(Ct)try{window.localStorage.setItem(pg,dt?"1":"0")}catch{}},[Ct,dt]),c.useEffect(()=>{if(N===void 0){document.title="Agent Inspector";return}const Re=e.length===1?"1 req":`${e.length} req`;document.title=`${sn(N)} - ${Re} - Agent Inspector`},[e.length,N]);const G=c.useCallback(async Re=>{me.current?.abort();const lt=new AbortController;me.current=lt;const Tt=be.current+1;be.current=Tt,z(Re),Y(null);try{const tn=await P5(e,Re,{signal:lt.signal});if(be.current!==Tt)return;if(!tn.ok){if(tn.canceled===!0)return;p!==void 0?p({message:tn.message,tone:"error"}):Y(tn.message)}}finally{be.current===Tt&&(me.current=null,z(null))}},[e,p]),E=c.useCallback(Re=>{if(rR(Re)){he(!0);return}G(Re)},[G]),L=c.useCallback(()=>{he(!1),G("redacted")},[G]),Z=c.useCallback(()=>{he(!1),G("raw")},[G]),ie=c.useCallback(()=>{Ee.current?.click()},[]),de=c.useCallback(Re=>{const lt=Re.currentTarget.files?.[0];Re.currentTarget.value="",!(lt===void 0||m===void 0)&&(D(!0),ke(null),te(null),m(lt).then(Tt=>{const tn=Tt.skipped>0?`, skipped ${String(Tt.skipped)}`:"",Rc=`Imported ${String(Tt.imported)} logs as ${Tt.sessionId}${tn}.`;p!==void 0?p({message:Rc,tone:"success"}):te(Rc)}).catch(Tt=>{const tn=Tt instanceof Error?Tt.message:"Failed to import logs";p!==void 0?p({message:tn,tone:"error"}):ke(tn)}).finally(()=>{D(!1)}))},[m,p]);c.useEffect(()=>{ze(),Oe(null)},[ze,s,o]);const se=c.useCallback(()=>{ze(),te(null),ke(null),Oe(null),l()},[ze,l]),ye=c.useCallback(()=>{le(!0)},[]),ce=c.useCallback(()=>{ze(),te(null),ke(null),Oe(null),u!==void 0&&(Se(!0),u().then(()=>{le(!1)}).catch(Re=>{const lt=Re instanceof Error?Re.message:"Failed to delete stored logs";p!==void 0?p({message:lt,tone:"error"}):ke(lt)}).finally(()=>{Se(!1)}))},[ze,u,p]),ft=c.useCallback(()=>{d!==void 0&&(ze(),te(null),ke(null),Oe(null),d())},[ze,d]),In=c.useCallback(()=>{Oe(null)},[]),Ae=c.useCallback(()=>{Ze(Re=>!Re)},[]),en=c.useCallback(()=>{Lt(Re=>!Re)},[]),Ve=c.useMemo(()=>lT(e),[e]),ts=c.useMemo(()=>iO(Ve),[Ve]),Xe=c.useMemo(()=>xR({pinnedSessionId:N,selectedSession:s,sessions:t,logs:e}),[e,N,s,t]),$t=Xe?.logs??[],Fs=Xe!==null&&$t.length>0,{totalIn:kc,totalOut:Sc}=c.useMemo(()=>qd($t),[$t]),hg=c.useMemo(()=>oO($t,B),[$t,B]),gg=c.useMemo(()=>MI(Ve),[Ve]),_i=c.useMemo(()=>cE(Ve),[Ve]),_c=oR(g,e.length),xg=N!==void 0,bg=e.length>0,vg=u!==void 0&&(e.length>0||s!=="__all__"),yg=s==="__all__"?"all sessions":"this session",wg=s==="__all__"?"Deletes every stored log, streaming chunk, and session archive entry across all sessions.":"Deletes every stored log, streaming chunk, and session archive entry for this session, including history that is not currently loaded.",jg=e.length===0?"Load":"Reload",Nc=s==="__all__"?"":s,Cc=s==="__all__"||t.includes(s)?s:"__typed__",Ni=Fs&&Xe!==null?sn(Xe.label):s==="__all__"?"All sessions":sn(s),Tc=$I(j),Ci=DI(Tc),kg=c.useMemo(()=>gR({logs:e,conversationGroups:Ve,isLoading:v,timeDisplayFormat:w,slowResponseThresholdSeconds:b}),[Ve,v,e,b,w]),Sg=c.useCallback(Re=>{const lt=_i.get(Re.id);lt!==void 0&&Oe([lt,Re])},[_i]),_g=c.useCallback(Re=>{const lt=Re.currentTarget.value.trim();i(lt===""?"__all__":lt)},[i]),Ng=c.useCallback(Re=>{Re!=="__typed__"&&i(Re)},[i]),Ec=N!==void 0?N:s==="__all__"?null:s;return r.jsxs("div",{className:"bg-background min-h-screen w-full overflow-x-clip text-foreground lg:h-screen lg:flex lg:flex-col lg:overflow-hidden",children:[r.jsx(OI,{liveConnection:j,alertsAction:r.jsx(ZR,{}),settingsAction:r.jsx(IM,{})}),r.jsxs("button",{type:"button",onClick:Ae,className:$("group fixed top-1/2 right-3 z-40 inline-flex h-14 w-7 -translate-y-1/2 items-center justify-center rounded-l-md border border-white/[0.08] bg-background/90 text-muted-foreground shadow-[0_12px_34px_rgba(0,0,0,0.26),inset_0_1px_0_rgba(255,255,255,0.06)] backdrop-blur transition-[right,background-color,color,border-color] duration-200 motion-reduce:transition-none hover:border-white/[0.16] hover:bg-white/[0.07] hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",ve?"right-3":"lg:right-[calc(21.25rem-0.875rem)] xl:right-[calc(22.5rem-0.875rem)]"),"aria-label":ve?"Show details panel":"Hide details panel",title:ve?"Show details panel":"Hide details panel",children:[r.jsx("span",{className:"absolute left-1 top-2 bottom-2 w-px rounded-full bg-white/[0.16] transition-colors group-hover:bg-white/[0.28]"}),ve?r.jsx(Cj,{className:"size-3.5"}):r.jsx(_j,{className:"size-3.5"})]}),Ct&&dt&&r.jsx(co,{feature:"Inspector Pet",children:r.jsx(c.Suspense,{fallback:null,children:r.jsx(t4,{logs:e})})}),r.jsxs("div",{className:$("grid w-full min-w-0 grid-cols-1 lg:min-h-0 lg:flex-1 lg:overflow-hidden",ve?"lg:grid-cols-[minmax(0,1fr)]":"lg:grid-cols-[minmax(0,1fr)_21.25rem] xl:grid-cols-[minmax(0,1fr)_22.5rem]"),children:[!ve&&r.jsx("aside",{className:"bg-background/95 order-1 border-b border-white/[0.045] lg:order-2 lg:h-full lg:overflow-y-auto lg:border-b-0 lg:border-l lg:border-white/[0.055] inspector-scrollbar",children:r.jsxs("div",{className:"space-y-4 p-4",children:[r.jsx(Xr,{label:"Tools",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[r.jsx(CO,{}),r.jsx(EO,{preference:J,resolvedScale:K,onChange:W}),r.jsx(mP,{}),r.jsx(hI,{currentSessionId:Ec,logCount:e.length})]})}),r.jsxs(Xr,{label:"Session",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsx(Qr,{label:"Requests",value:e.length}),r.jsx(Qr,{label:"Sessions",value:t.length}),r.jsx(Qr,{label:"Input",value:Me(Fs?kc:M)}),r.jsx(Qr,{label:"Output",value:Me(Fs?Sc:F)})]}),C!==void 0&&r.jsx("div",{className:"mt-2 rounded-md bg-black/20 px-2 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:r.jsx(lo,{progress:C})})]}),r.jsx(Xr,{label:"Workspace",children:r.jsxs("div",{className:"bg-black/20 rounded-md px-3 py-2 shadow-[inset_0_1px_0_rgba(255,255,255,0.035)]",children:[r.jsx("div",{className:"truncate font-mono text-xs font-semibold text-cyan-100",title:Ni,children:Ni}),r.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:xg?"Session workspace":"Live workspace"})]})}),r.jsx(PI,{currentSessionId:Ec,logCount:e.length}),Fs&&Xe!==null&&r.jsx(zO,{label:Xe.label,logs:$t,totalIn:kc,totalOut:Sc,timeDisplayFormat:w,contextSummary:hg,showBackLink:Xe.showBackLink}),Fs&&N!==void 0&&A.length>0&&r.jsx(Hd,{memberships:A}),r.jsx(Xr,{label:"Filters",children:r.jsxs("div",{className:"space-y-2",children:[!P&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative",children:[r.jsx(yp,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),r.jsx("input",{type:"search",value:Nc,onChange:_g,placeholder:"Paste session ID",className:"bg-black/25 hover:bg-white/[0.045] focus-visible:ring-ring h-9 w-full rounded-md px-8 font-mono text-xs text-foreground outline-none shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors placeholder:font-sans placeholder:text-muted-foreground focus-visible:ring-1","aria-label":"Filter by session ID",title:"Filter by exact session ID"}),Nc!==""&&r.jsx("button",{type:"button",onClick:()=>i("__all__"),className:"absolute right-1.5 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Clear session filter",title:"Clear session filter",children:r.jsx(gr,{className:"size-3.5"})})]}),r.jsxs(Zn,{value:Cc,onValueChange:Ng,children:[r.jsx(Kn,{"aria-label":"Select a session",className:"bg-black/25 hover:bg-white/[0.045] h-9 w-full border-0 text-xs text-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:r.jsx(Is,{placeholder:"All sessions"})}),r.jsxs(Gn,{children:[r.jsx(Qe,{value:"__all__",children:"All sessions"}),Cc==="__typed__"&&r.jsxs(Qe,{value:"__typed__",children:["Typed: ",sn(s)]}),t.map(Re=>r.jsx(Qe,{value:Re,children:sn(Re)},Re))]})]})]}),r.jsxs(Zn,{value:o,onValueChange:a,children:[r.jsx(Kn,{"aria-label":"Select a model",className:"bg-black/25 hover:bg-white/[0.045] h-9 w-full border-0 text-xs text-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:r.jsx(Is,{placeholder:"All models"})}),r.jsxs(Gn,{children:[r.jsx(Qe,{value:"__all__",children:"All models"}),n.map(Re=>r.jsx(Qe,{value:Re,children:Re},Re))]})]})]})})]})}),r.jsxs("main",{className:"order-2 min-w-0 lg:order-1 lg:h-full lg:overflow-y-auto inspector-scrollbar",children:[r.jsxs("div",{className:"bg-background/95 shadow-[0_12px_36px_rgba(0,0,0,0.18),inset_0_-1px_0_rgba(255,255,255,0.045)] sticky top-0 z-30 px-4 py-3 lg:px-5",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs("div",{className:"min-w-[180px] flex-1",children:[r.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Logs"}),r.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:Ni})]}),r.jsx(TO,{visible:dt,onToggle:en}),m!==void 0&&r.jsxs(r.Fragment,{children:[r.jsx("input",{ref:Ee,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:de}),r.jsx("button",{type:"button",onClick:ie,disabled:oe,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Import Agent Inspector export",children:oe?r.jsx("span",{children:"Importing..."}):r.jsxs(r.Fragment,{children:[r.jsx(wp,{className:"size-3.5"}),r.jsx("span",{children:"Import"})]})})]}),_c.redacted&&r.jsx("button",{type:"button",onClick:()=>{E("redacted")},disabled:V!==null,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Export redacted logs as JSON ZIP",children:V==="redacted"?r.jsx("span",{children:"Exporting..."}):r.jsxs(r.Fragment,{children:[r.jsx(mr,{className:"size-3.5"}),r.jsx("span",{children:"Export"})]})}),_c.raw&&r.jsx("button",{type:"button",onClick:()=>{E("raw")},disabled:V!==null,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Export raw logs without redaction",children:V==="raw"?r.jsx("span",{children:"Exporting..."}):r.jsxs(r.Fragment,{children:[r.jsx(Dw,{className:"size-3.5"}),r.jsx("span",{children:"Raw"})]})}),d!==void 0&&r.jsxs("button",{type:"button",onClick:ft,disabled:v,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Reload this session from stored logs",children:[r.jsx(Vt,{className:$("size-3.5",v&&"animate-spin motion-reduce:animate-none")}),r.jsx("span",{children:jg})]}),r.jsxs("button",{type:"button",onClick:se,disabled:!bg,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Clear the current view. Stored logs remain reloadable.",children:[r.jsx(jn,{className:"size-3.5"}),r.jsx("span",{children:"Clear"})]}),u!==void 0&&r.jsxs("button",{type:"button",onClick:ye,disabled:!vg||xe,className:"bg-red-500/[0.07] hover:bg-red-500/[0.12] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-red-200 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.14)] transition-colors hover:text-red-100 focus-visible:ring-1 focus-visible:ring-red-300 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Delete persisted history for the selected session.",children:[r.jsx(jn,{className:"size-3.5"}),r.jsx("span",{children:"Delete"})]})]}),_===void 0&&C!==void 0&&r.jsx("div",{className:"mt-2 rounded-md bg-black/20 px-2 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:r.jsx(lo,{progress:C})}),I!==void 0&&r.jsxs("div",{role:"alert",className:"mt-2 flex flex-wrap items-center gap-2 rounded-md border border-red-400/25 bg-red-500/10 px-3 py-2 text-xs text-red-100",children:[r.jsxs("span",{className:"min-w-0 flex-1",children:["Session logs could not be loaded. ",I," Existing logs remain visible."]}),d!==void 0&&r.jsxs("button",{type:"button",onClick:ft,className:"inline-flex h-7 items-center gap-1 rounded-md bg-black/15 px-2 font-medium transition-colors hover:bg-black/25 focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[r.jsx(Vt,{className:"size-3"}),"Retry"]})]}),r.jsx(Wd,{logs:e,pagination:_,embedded:!0}),p===void 0&&X!==null&&r.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:X}),p===void 0&&je!==null&&r.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:je}),p===void 0&&Ne!==null&&je===null&&r.jsx("div",{className:"mt-2 rounded-md border border-cyan-400/25 bg-cyan-500/10 px-3 py-2 text-xs text-cyan-100",children:Ne}),j!==void 0&&j.status!=="live"&&S!==void 0&&k!==void 0&&r.jsx(AI,{state:j,hasLogs:e.length>0,onRetry:S,onStop:k})]}),r.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[r.jsx(fO,{stats:kg}),e.length===0?s!=="__all__"?r.jsx("div",{className:"py-16 text-center text-muted-foreground",children:r.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-xl space-y-4 rounded-[8px] px-4 py-8",children:[r.jsx("p",{className:"text-sm font-medium",children:v?"Loading session data...":I===void 0?"No logs loaded for this session":"Session logs could not be loaded"}),r.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:sn(s)}),C!==void 0&&r.jsx("div",{className:"mx-auto max-w-md rounded-md bg-black/20 px-2 py-2 text-left shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:r.jsx(lo,{progress:C})}),A.length>0&&r.jsx("div",{className:"text-left",children:r.jsx(Hd,{memberships:A})}),!v&&r.jsxs("div",{className:"flex flex-col items-center gap-3 text-xs",children:[r.jsx("p",{children:"Stored logs may still be available."}),r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[d!==void 0&&r.jsxs("button",{type:"button",onClick:ft,className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[r.jsx(Vt,{className:"size-3.5"}),r.jsx("span",{children:"Load session"})]}),P?r.jsx("a",{href:"/",className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:"Back to all sessions"}):r.jsx("button",{type:"button",onClick:()=>i("__all__"),className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:"Show all sessions"})]})]})]})}):r.jsx("div",{className:"py-16 text-center text-muted-foreground",children:r.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-2xl space-y-4 rounded-[8px] px-4 py-8",children:[r.jsx("p",{className:"text-sm font-medium",children:Ci.title}),r.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:Ci.description}),Tc==="empty"&&t.length>0&&r.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Pick a session from the filter panel to load stored logs on demand."}),Ci.showConnectionCommands&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(Gd,{command:"ANTHROPIC_BASE_URL=http://localhost:9527/proxy <your-tool>"}),r.jsx(Gd,{command:"OPENAI_BASE_URL=http://localhost:9527/proxy <your-tool>"})]}),r.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Container note: if your AI tool runs in a different container or host than Agent Inspector, replace localhost with an address reachable from that tool and verify the network/firewall path."})]})]})}):r.jsxs("div",{ref:ne,tabIndex:0,"aria-label":"Captured logs",className:"flex flex-col gap-2 rounded-md focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none",children:[r.jsx("div",{ref:q,children:r.jsx(JI,{groups:Ve,viewMode:h,strip:y,slowResponseThresholdSeconds:b,cacheTrends:gg,onCompareWithPrevious:Sg,comparisonPredecessors:_i,onClearGroup:f,defaultExpanded:Ve.length===1,timeDisplayFormat:w})}),r.jsx("div",{className:"mt-3",children:r.jsx(Wd,{logs:e,pagination:_})})]})]})]})]}),r.jsx(Zt,{open:we,onOpenChange:he,children:r.jsx(Kt,{className:QI,children:r.jsx(tA,{onCancel:()=>he(!1),onExportRedacted:L,onConfirmRaw:Z})})}),r.jsx(Zt,{open:ue,onOpenChange:le,children:r.jsxs(Kt,{className:"border-red-500/20 bg-zinc-950 text-zinc-100 sm:max-w-md",children:[r.jsxs(Xt,{children:[r.jsxs(Qt,{children:["Delete ",yg," history?"]}),r.jsx(wr,{children:"Clear only hides logs from the UI. Delete removes stored history from disk."})]}),r.jsxs("div",{className:"rounded-md bg-red-500/[0.08] px-3 py-3 text-sm text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:[r.jsx("span",{className:"block font-medium",children:"This is a full history delete."}),r.jsx("span",{className:"mt-1 block text-xs text-red-200/80",children:wg})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:xe,onClick:()=>le(!1),children:"Cancel"}),r.jsx(ee,{type:"button",variant:"destructive",size:"sm",disabled:xe,onClick:ce,children:xe?"Deleting...":"Delete history"})]})]})}),Ie!==null&&r.jsx(co,{feature:"Compare",children:r.jsx(c.Suspense,{fallback:null,children:r.jsx(e4,{left:Ie[0],right:Ie[1],leftDisplayNumber:Vd(Ie[0],ts),rightDisplayNumber:Vd(Ie[1],ts),onClose:In})})})]})}function $O(e,t,n){return t==="__all__"&&n==="__all__"?e:e.filter(s=>!(t!=="__all__"&&s.sessionId!==t||n!=="__all__"&&s.model!==n))}function eo(e,t){if(e.length===0)return[...t];if(t.length===0)return[...e];const n=new Map;for(const s of e)n.set(s.id,s);for(const s of t)n.set(s.id,s);return[...n.values()].toSorted((s,o)=>s.id-o.id)}function Dn(e,t){const n=new Set;for(const s of e)s!==""&&n.add(s);for(const s of t)s!==""&&n.add(s);return[...n].sort()}const DO=At([T({type:ae("init"),logs:H(sr)}),T({type:ae("update"),log:sr})]),FO=T({logs:H(sr),total:R().int().nonnegative(),limit:R().int().positive(),hasOlder:Te(),hasNewer:Te(),oldestLogId:R().int().positive().nullable(),newestLogId:R().int().positive().nullable()}),UO=H(x()),Yd=T({success:Te(),cleared:R().int().nonnegative(),logFilesRewritten:R().int().nonnegative().optional(),chunkFilesDeleted:R().int().nonnegative(),sessionArchiveLogsDeleted:R().int().nonnegative().optional()});function BO(e,t){const n=[];for(const s of e)for(const o of s.members)o.sessionId===t&&n.push({groupId:s.id,groupTitle:s.title,groupKind:s.kind,groupStatus:s.status,groupTask:s.task,groupProject:s.project,groupEvidence:s.evidence,member:o});return n}function to(e){const t=new Set;for(const n of e)n.sessionId!==null&&n.sessionId!==""&&t.add(n.sessionId);return[...t]}function VO(e){const t=new Set;for(const n of e)n.model!==null&&n.model!==""&&t.add(n.model);return[...t]}const qO=100,HO=12,WO=1800,jc=100,Uo=500,mg=200,cl=2e4,ZO=1e4,KO=3e3,GO=1e4;function JO(e){const t=new URLSearchParams({compact:"1"});e!==void 0&&t.set("sessionId",e);const n=t.toString();return n.length>0?`/api/logs/stream?${n}`:"/api/logs/stream"}function YO(e,t,n=jc){const s=new URLSearchParams({cursor:"1",compact:"1",limit:String(n),sessionId:e});switch(t.kind){case"oldest":s.set("anchor","oldest");break;case"older":s.set("beforeLogId",String(t.beforeLogId));break;case"newer":s.set("afterLogId",String(t.afterLogId));break}return`/api/logs?${s.toString()}`}function hn(e){const t=new Map;for(let n=0;n<e.length;n++){const s=e[n];s!==void 0&&t.set(s.id,n)}return t}function er(e,t,n=jc){return qe(YO(e,t,n),FO,cl)}async function XO(e,t){const n=new Set;let s=await er(e,{kind:"oldest"},Uo);for(const i of s.logs)n.add(i.id);t(n.size,1);let o=1;for(;s.hasNewer&&s.newestLogId!==null&&o<mg;){s=await er(e,{kind:"newer",afterLogId:s.newestLogId},Uo);for(const i of s.logs)n.add(i.id);o+=1,t(n.size,o)}return{ids:[...n],truncated:s.hasNewer}}async function QO(){try{return{deleted:(await ot("/api/groups",sp,{method:"DELETE"})).deleted,ok:!0}}catch{return{deleted:0,ok:!1}}}function s6({initialSessionId:e}={}){const[t,n]=c.useState([]),[s,o]=c.useState(e??"__all__"),[i,a]=c.useState("__all__"),[l,u]=c.useState([]),{notice:d,showToast:f,dismissToast:p}=E0(),[m,h]=c.useState(LI),[g,y]=c.useState(null),[b,w]=c.useState(e!==void 0),[v,j]=c.useState(null),[S,k]=c.useState(void 0),[_,C]=c.useState([]),[,I]=c.useTransition(),A=c.useRef(null),P=c.useRef(null),N=c.useRef(null),M=c.useRef(!0),F=c.useRef(null),B=c.useRef(0),J=c.useRef(null),K=c.useRef(null),W=c.useRef(new Map),V=c.useRef([]),z=c.useRef(null),X=c.useCallback(G=>{f({message:G,tone:"error"})},[f]),Y=c.useCallback(()=>{K.current!==null&&(clearInterval(K.current),K.current=null),J.current=null,k(void 0)},[]),we=c.useCallback((G,E,L=0,Z=0)=>{K.current!==null&&clearInterval(K.current);const ie=Date.now();J.current=ie;const de=()=>{B.current===E&&k({label:G,elapsedMs:Date.now()-ie,timeoutMs:cl,loadedLogs:L,loadedPages:Z})};de(),K.current=setInterval(de,250)},[]),he=c.useCallback((G,E,L,Z)=>{const ie=J.current;ie===null||B.current!==E||k({label:G,elapsedMs:Date.now()-ie,timeoutMs:cl,loadedLogs:L,loadedPages:Z})},[]),oe=c.useMemo(()=>$O(t,s,i),[t,s,i]),D=c.useMemo(()=>Dn(l,to(t)),[t,l]),Ne=c.useMemo(()=>VO(t),[t]),te=c.useCallback(()=>{ot("/api/sessions",UO).then(G=>{u(E=>Dn(E,G))}).catch(()=>{})},[]),je=c.useCallback(()=>{z.current=null;const G=V.current;V.current=[],G.length!==0&&I(()=>{n(E=>{const L=eo(E,G);return W.current=hn(L),L})})},[I]),ke=c.useCallback(G=>{V.current.push(G),z.current===null&&(z.current=setTimeout(je,qO))},[je]),ue=c.useCallback(()=>{A.current&&A.current.close(),P.current!==null&&(clearTimeout(P.current),P.current=null),h(E=>nn(E,{type:"connect-requested"}));const G=new EventSource(JO(e));A.current=G,G.onmessage=E=>{try{const L=String(E.data),Z=JSON.parse(L),ie=DO.safeParse(Z);if(!ie.success){h(se=>nn(se,{type:"recoverable-error",message:"The live stream returned invalid data."})),X("Failed to parse SSE data");return}const de=ie.data;de.type==="init"?(z.current!==null&&(clearTimeout(z.current),z.current=null),V.current=[],n(se=>{const ye=eo(se,de.logs);return W.current=hn(ye),ye}),u(se=>Dn(se,to(de.logs))),N.current!==null&&(clearTimeout(N.current),N.current=null),h(se=>nn(se,{type:"message-received",at:Date.now()})),p()):de.type==="update"&&(u(se=>de.log.sessionId===null||de.log.sessionId===""?se:Dn(se,[de.log.sessionId])),ke(de.log),N.current!==null&&(clearTimeout(N.current),N.current=null),h(se=>nn(se,{type:"message-received",at:Date.now()})))}catch{h(L=>nn(L,{type:"recoverable-error",message:"The live stream returned malformed JSON."})),X("Failed to parse SSE data")}},G.onerror=()=>{const E=navigator.onLine;h(L=>nn(L,{type:"connection-lost",online:E,message:"The live stream disconnected."})),G.close(),!(!E||!M.current)&&(N.current===null&&(N.current=setTimeout(()=>{N.current=null,h(L=>nn(L,{type:"stale-timeout"}))},GO)),P.current=setTimeout(ue,KO))}},[p,e,ke,X]),le=c.useCallback(()=>{M.current=!0,P.current!==null&&(clearTimeout(P.current),P.current=null),ue()},[ue]),xe=c.useCallback(()=>{M.current=!1,A.current?.close(),A.current=null,P.current!==null&&(clearTimeout(P.current),P.current=null),N.current!==null&&(clearTimeout(N.current),N.current=null),h(G=>nn(G,{type:"stop-retrying"}))},[]),Se=c.useCallback(G=>{if(e===void 0)return;const E=B.current+1;B.current=E,w(!0),j(null),we("Loading session logs",E),p(),er(e,G).then(L=>{if(B.current!==E)return;const Z=L.logs;W.current=hn(Z),n(Z),y(L),o(e),w(!1),j(null),Y(),p()}).catch(L=>{if(B.current!==E)return;w(!1),Y();const Z=L instanceof Error?L.message:"Failed to load session logs";j(Z),X(Z)})},[p,e,X,we,Y]),ve=c.useCallback(G=>{const E=B.current+1;B.current=E,w(!0),j(null),we("Reloading full session",E),p(),(async()=>{const L=[];let Z=await er(G,{kind:"oldest"},Uo);L.push(...Z.logs),he("Reloading full session",E,L.length,1);let ie=1;for(;Z.hasNewer&&Z.newestLogId!==null&&ie<mg;)Z=await er(G,{kind:"newer",afterLogId:Z.newestLogId},Uo),L.push(...Z.logs),ie+=1,he("Reloading full session",E,L.length,ie);B.current===E&&(n(de=>{const se=eo(de,L);return W.current=hn(se),se}),u(de=>Dn(de,[G])),w(!1),j(null),Y(),Z.hasNewer?f({message:`Loaded ${String(L.length)} logs for this session. More history is available.`,tone:"success"}):p())})().catch(L=>{if(B.current!==E)return;w(!1),Y();const Z=L instanceof Error?L.message:"Failed to reload session logs";j(Z),X(Z)})},[p,X,f,we,Y,he]);c.useEffect(()=>{if(e===void 0){C([]);return}let G=!1;return qe("/api/groups",ip,ZO).then(E=>E.groups).then(E=>{G||E===null||C(BO(E,e))}).catch(()=>{G||C([])}),()=>{G=!0}},[e]),c.useEffect(()=>{te()},[te]),c.useEffect(()=>()=>{Y()},[Y]),c.useEffect(()=>{e!==void 0&&Se({kind:"newest"})},[e,Se]),c.useEffect(()=>{e===void 0&&s!=="__all__"&&ve(s)},[e,ve,s]),c.useEffect(()=>{if(e!==void 0)return;ue();const G=()=>{A.current?.close(),A.current=null,P.current!==null&&(clearTimeout(P.current),P.current=null),N.current!==null&&(clearTimeout(N.current),N.current=null),h(L=>nn(L,{type:"browser-offline"}))},E=()=>{M.current&&ue()};return window.addEventListener("offline",G),window.addEventListener("online",E),()=>{window.removeEventListener("offline",G),window.removeEventListener("online",E),A.current&&(A.current.close(),A.current=null),P.current!==null&&(clearTimeout(P.current),P.current=null),N.current!==null&&(clearTimeout(N.current),N.current=null),z.current!==null&&(clearTimeout(z.current),z.current=null)}},[ue,e]),c.useEffect(()=>{const G=window.location.hash;if(!G.startsWith("#log-")||F.current===G)return;const E=G.slice(1),L=Number(E.replace(/^log-/,""));Number.isInteger(L)&&L>0&&Ms({logId:L,tab:"request"});let Z=!1,ie=0,de=null,se=null;const ye=()=>{if(Z)return;const ce=document.getElementById(E);if(ce!==null){F.current=G,ce.scrollIntoView({block:"center",behavior:Y0(X0())}),ce instanceof HTMLElement&&(de=ce,ce.setAttribute("data-deep-link-highlight","true"),se=window.setTimeout(()=>{ce.removeAttribute("data-deep-link-highlight")},WO),ce.focus({preventScroll:!0}),ce.getAttribute("data-nav-action")==="expand"&&ce.click());return}ie+=1,ie<HO&&window.setTimeout(ye,100)};return ye(),()=>{Z=!0,se!==null&&window.clearTimeout(se),de!==null&&de.removeAttribute("data-deep-link-highlight")}},[oe.length]);const Ze=c.useCallback(()=>{const G=to(t);Y(),w(!1),W.current.clear(),n([]),y(null),u(E=>Dn(E,G)),f({message:"Cleared the current view. Stored logs are still reloadable.",tone:"success"})},[t,f,Y]),Be=c.useCallback(G=>{if(G.length===0)return;const E=new Set(G);n(L=>{const Z=L.filter(de=>E.has(de.id)),ie=L.filter(de=>!E.has(de.id));return u(de=>Dn(de,to(Z))),W.current=hn(ie),ie}),f({message:"Cleared this group from the current view.",tone:"success"})},[f]),Ke=c.useCallback(async()=>{const G=B.current+1;B.current=G,w(!0),Y(),p();try{if(s==="__all__"){we("Deleting stored history",G);const se=await ot("/api/logs",Yd,{method:"DELETE"}),ye=await QO();if(B.current!==G)return;n([]),W.current.clear(),y(null),u([]),C([]),w(!1),Y();const ce=ye.ok?` Cleared ${ye.deleted.toString()} group${ye.deleted===1?"":"s"}.`:" Group cleanup failed; open Groups to retry Clear.";f({message:`Deleted ${se.cleared.toString()} stored log${se.cleared===1?"":"s"} across all sessions.${ce}`,tone:ye.ok?"success":"error"});return}const E=s;we("Deleting session history",G);const L=await XO(E,(se,ye)=>{he("Deleting session history",G,se,ye)}),Z=new Set(L.ids);for(const se of t)se.sessionId===E&&Z.add(se.id);const ie=[...Z].filter(se=>Number.isInteger(se)&&se>=0);if(ie.length===0){if(B.current!==G)return;n(se=>{const ye=se.filter(ce=>ce.sessionId!==E);return W.current=hn(ye),ye}),y(se=>se===null?null:{...se,logs:se.logs.filter(ye=>ye.sessionId!==E)}),u(se=>se.filter(ye=>ye!==E)),w(!1),Y(),f({message:"No stored log records were found for this session.",tone:"success"});return}const de=await ot("/api/logs",Yd,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({ids:ie})});if(B.current!==G)return;n(se=>{const ye=se.filter(ce=>ce.sessionId!==E);return W.current=hn(ye),ye}),y(se=>se===null?null:{...se,logs:se.logs.filter(ye=>ye.sessionId!==E)}),u(se=>se.filter(ye=>ye!==E)),w(!1),Y(),f({message:`Deleted ${de.cleared.toString()} stored log${de.cleared===1?"":"s"} for this session${L.truncated?". More history may remain.":"."}`,tone:L.truncated?"error":"success"})}finally{B.current===G&&(w(!1),Y())}},[t,p,s,f,we,Y,he]),dt=c.useCallback(()=>{if(e!==void 0){Se({kind:"newest"});return}if(s==="__all__"){te();return}ve(s)},[e,Se,te,ve,s]),Lt=c.useCallback(async G=>{const E=new FormData;E.set("file",G);const L=await ot("/api/logs/import",yy,{method:"POST",body:E});return n(Z=>{const ie=new Set(L.logs.map(se=>se.id)),de=eo(Z.filter(se=>!ie.has(se.id)),L.logs);return W.current=hn(de),de}),o(L.sessionId),a("__all__"),y(null),p(),L},[p]),{strip:Ct,captureMode:Ye,slowResponseThresholdSeconds:Ie,timeDisplayFormat:Oe}=Rl(),q=Ye,ne=c.useCallback(()=>{Se({kind:"oldest"})},[Se]),Ee=c.useCallback(()=>{Se({kind:"newest"})},[Se]),me=c.useCallback(()=>{const G=t[0],E=g?.oldestLogId??G?.id??null;E!==null&&Se({kind:"older",beforeLogId:E})},[t,Se,g]),be=c.useCallback(()=>{const G=t[t.length-1],E=g?.newestLogId??G?.id??null;E!==null&&Se({kind:"newer",afterLogId:E})},[t,Se,g]),ze=c.useMemo(()=>{if(e!==void 0)return{isLoading:b,loadProgress:S,total:g?.total??null,pageSize:g?.limit??jc,hasOlder:g?.hasOlder??!1,hasNewer:g?.hasNewer??!1,oldestLogId:g?.oldestLogId??null,newestLogId:g?.newestLogId??null,onOldest:ne,onOlder:me,onNewer:be,onNewest:Ee}},[e,Ee,be,me,ne,g,S,b]);return r.jsxs(r.Fragment,{children:[r.jsx(R0,{notice:d,onDismiss:p}),r.jsx(b5,{}),r.jsx(LO,{logs:oe,sessions:D,models:Ne,selectedSession:s,selectedModel:i,onSessionChange:o,onModelChange:a,onClearAll:Ze,onDeleteCurrentView:Ke,onReloadSession:e!==void 0||s!=="__all__"?dt:void 0,onClearGroup:Be,onNotify:f,onImportLogs:e===void 0?Lt:void 0,isLoading:e===void 0&&m.status==="connecting"&&m.lastSuccessAt===null||b,liveConnection:e===void 0?m:void 0,onRetryLiveConnection:le,onStopLiveConnection:xe,pagination:ze,sessionLoadProgress:S,sessionLoadError:v??void 0,sessionMemberships:_,viewMode:q,captureMode:Ye,strip:Ct,slowResponseThresholdSeconds:Ie,timeDisplayFormat:Oe,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{Ja as $,Zo as A,_e as B,Cw as C,Zt as D,Te as E,x as F,sr as G,GA as H,oj as I,lA as J,aA as K,i4 as L,gp as M,n6 as N,nt as O,s6 as P,ge as Q,zj as R,fA as S,d0 as T,z4 as U,t6 as V,cp as W,gr as X,L4 as Y,$4 as Z,Xn as _,aT as a,Po as a0,SI as a1,gw as a2,rr as a3,Q as a4,wn as a5,Ue as a6,Lf as a7,XT as a8,sw as a9,su as b,U as c,xp as d,yt as e,Ge as f,n0 as g,Ot as h,qe as i,Kt as j,Xt as k,Qt as l,vp as m,f0 as n,xn as o,jt as p,Ds as q,ar as r,pt as s,mt as t,zl as u,ht as v,T as w,R as x,H as y,Ms as z};
126
+ args = ["stdio", "--url", "${s}"]`}],[s]),i=c.useCallback((a,l)=>{Pt(l).then(u=>{u&&(t(a),setTimeout(()=>t(null),1600))})},[]);return r.jsxs("div",{className:"min-w-0 space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Xn,{className:"size-4 text-muted-foreground"}),r.jsx("h3",{className:"text-sm font-semibold",children:"MCP access"})]}),r.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[r.jsx("div",{children:"Use Streamable HTTP when the client supports URL-based MCP. Use the stdio bridge only for stdio-only clients. Configure one entry for the same Inspector instance."}),r.jsx("div",{children:"If the MCP client runs in another container or host, replace localhost with a reachable host/IP and verify the network path."})]}),r.jsx("div",{className:"grid gap-2",children:o.map(a=>r.jsx(Ys,{id:a.id,label:a.label,value:a.value,copiedId:e,onCopy:i},a.id))})]})}function DI(){const{strip:e,slowResponseThresholdSeconds:t,providerTestTimeoutSeconds:n,timeDisplayFormat:s,isLoading:o,setStrip:i,setSlowResponseThresholdSeconds:a,setProviderTestTimeoutSeconds:l,setTimeDisplayFormat:u}=Rl(),[d,p]=c.useState(null),[f,m]=c.useState(!1),h=c.useCallback(async w=>{p(null),m(!0);try{await i(w)}catch(v){p(v instanceof Error?v.message:String(v))}finally{m(!1)}},[i]),g=c.useCallback(async w=>{p(null),m(!0);try{await a(w)}catch(v){p(v instanceof Error?v.message:String(v))}finally{m(!1)}},[a]),y=c.useCallback(async w=>{p(null),m(!0);try{await l(w)}catch(v){p(v instanceof Error?v.message:String(v))}finally{m(!1)}},[l]),b=c.useCallback(async w=>{p(null),m(!0);try{await u(w)}catch(v){p(v instanceof Error?v.message:String(v))}finally{m(!1)}},[u]);return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Strip Claude Code's synthetic billing block before upstream forwarding. This can improve prefix-cache hits with third-party providers and is persisted to ",r.jsx("code",{children:"config.json"}),"."]})]}),r.jsxs("label",{className:"flex items-center gap-3",children:[r.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:o||f,onChange:w=>{h(w.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("span",{className:"text-sm",children:o?"Loading...":e?"Stripping enabled":"Stripping disabled"})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"slow-response-threshold",className:"text-sm font-semibold",children:"Slow response threshold"}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Show a slow marker when elapsed time exceeds this many seconds. Use ",r.jsx("code",{children:"0"})," to disable it."]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{id:"slow-response-threshold",type:"number",min:0,max:ja,step:1,value:t,disabled:o||f,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<0||v>ja||g(v))},className:"h-8 w-24 rounded-md border border-input bg-transparent px-2 text-sm font-mono disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds"})]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"provider-test-timeout",className:"text-sm font-semibold",children:"Provider test timeout"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Abort slow Provider Test probes after this many seconds per model."}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{id:"provider-test-timeout",type:"number",min:1,max:ka,step:1,value:n,disabled:o||f,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<1||v>ka||y(v))},className:"h-8 w-24 rounded-md border border-input bg-transparent px-2 text-sm font-mono disabled:cursor-not-allowed disabled:opacity-50"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds / model"})]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"time-display-format",className:"text-sm font-semibold",children:"Time display"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls timestamps in session summaries, headers, and log rows."}),r.jsxs("select",{id:"time-display-format",value:s,disabled:o||f,onChange:w=>{const v=af.safeParse(w.currentTarget.value);v.success&&b(v.data)},className:"h-8 rounded-md border border-input bg-background px-2 text-sm disabled:cursor-not-allowed disabled:opacity-50",children:[r.jsx("option",{value:"time",children:"Time only"}),r.jsx("option",{value:"full",children:"Full ISO"})]})]}),d!==null&&r.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",d]})]})}const FI=fe(["installed","update-available","available","planned","unknown"]),UI=T({id:x(),name:x(),npmName:x(),capability:x(),description:x(),workflow:x(),installCommand:x(),state:FI,installedVersion:x().nullable(),latestVersion:x().nullable(),primary:Te()}),BI=T({id:x(),name:x(),validatedVersion:x(),binary:x(),modelFlag:x(),variantFlag:x().nullable(),tools:H(x()),logDir:x(),skillsDir:x(),agentsDir:x()}),VI=T({id:x(),title:x(),stage:x(),packageId:x(),description:x(),command:x(),requiresSession:Te(),runnable:Te()}),qI=T({checkedAt:x(),packages:H(UI),runnerPresets:H(BI),recipes:H(VI)}),V0=fe(["install","upgrade","help","runner-presets","recipe"]),q0="RUN_LOCAL_COMMAND",HI=T({action:V0,targetId:x(),targetName:x(),command:x(),source:x(),timeoutMs:R().int().positive(),scope:x()}),WI=T({nonce:x().uuid(),phrase:ae(q0),expiresAt:x().datetime(),plan:HI}),H0=T({confirmation:WI});Tn("intent",[T({intent:ae("prepare")}),T({intent:ae("confirm"),nonce:x().uuid(),confirmation:ae(q0)})]);const ZI=fe(["queued","running","succeeded","failed"]),W0=T({id:x(),packageId:x(),npmName:x(),recipeId:x().nullable().default(null),action:V0,status:ZI,command:x(),output:x(),createdAt:x(),startedAt:x().nullable(),finishedAt:x().nullable(),exitCode:R().nullable(),error:x().nullable()}),Z0=T({task:W0}),KI=T({tasks:H(W0)}),GI=[{id:"observe",title:"Observe",label:"Live",description:"Capture IDE, process, session, turn, request, response, tools, and providers.",metric:"Inspector core",icon:Py},{id:"replay",title:"Replay",label:"Ready",description:"Promote real logs into repeatable replay evidence without losing the raw context.",metric:"Session asset",icon:Vt},{id:"evaluate",title:"Evaluate",label:"Next",description:"Use eval-harness to turn sessions into regression cases and provider bakeoffs.",metric:"Eval loop",icon:Pl},{id:"connect",title:"Connect",label:"MCP",description:"Expose Inspector state to coding agents as queryable context and durable evidence.",metric:"/api/mcp",icon:vj}];async function JI(e){return ot(e,qI,void 0,t=>`Failed to load ecosystem packages: ${String(t.status)}`)}async function YI(e){return ot(e,Z0,void 0,t=>`Failed to load ecosystem task: ${String(t.status)}`)}async function XI(e){return ot(e,KI,void 0,t=>`Failed to load ecosystem tasks: ${String(t.status)}`)}async function QI(e,t){const n=`/api/ecosystem/packages/${encodeURIComponent(e)}/${t}`,s=await ot(n,H0,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},o=>`Failed to prepare ecosystem task: ${String(o.status)}`);return{endpoint:n,confirmation:s.confirmation}}async function eM(e){const t=`/api/ecosystem/recipes/${encodeURIComponent(e)}/run`,n=await ot(t,H0,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},s=>`Failed to prepare ecosystem recipe: ${String(s.status)}`);return{endpoint:t,confirmation:n.confirmation}}async function tM(e){return(await ot(e.endpoint,Z0,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"confirm",nonce:e.confirmation.nonce,confirmation:e.confirmation.phrase})},n=>`Failed to start ecosystem task: ${String(n.status)}`)).task}function nM(e){switch(e){case"installed":return"Installed";case"update-available":return"Update";case"available":return"Available";case"planned":return"Planned";case"unknown":return"Unknown"}}function sM(e){switch(e){case"installed":return"border-emerald-400/20 bg-emerald-400/8 text-emerald-200";case"update-available":return"border-amber-400/20 bg-amber-400/8 text-amber-200";case"available":return"border-sky-400/20 bg-sky-400/8 text-sky-200";case"planned":return"border-white/10 bg-white/[0.04] text-white/55";case"unknown":return"border-white/10 bg-white/[0.04] text-white/45"}}function rM(e){return e.installedVersion!==null&&e.latestVersion!==null?e.installedVersion===e.latestVersion?`v${e.installedVersion}`:`v${e.installedVersion} -> v${e.latestVersion}`:e.installedVersion!==null?`v${e.installedVersion}`:e.latestVersion!==null?`latest v${e.latestVersion}`:"not published"}function Xs(e){switch(e){case"install":return"Install";case"upgrade":return"Upgrade";case"help":return"Help";case"runner-presets":return"Presets";case"recipe":return"Recipe"}}function oM(e){switch(e.status){case"queued":return"Queued";case"running":return`${Xs(e.action)} running`;case"succeeded":return`${Xs(e.action)} complete`;case"failed":return`${Xs(e.action)} failed`}}function K0(e){switch(e){case"queued":case"running":return"border-cyan-300/20 bg-cyan-300/8 text-cyan-100";case"succeeded":return"border-emerald-400/20 bg-emerald-400/8 text-emerald-100";case"failed":return"border-red-400/20 bg-red-400/8 text-red-100"}}function iM(e){switch(e.state){case"available":return"install";case"update-available":return"upgrade";case"installed":case"planned":case"unknown":return null}}function aM({pkg:e,activeTask:t,onStartTask:n}){const s=iM(e),o=t!==null&&t.packageId===e.id&&t.status==="running";return r.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[r.jsx(kj,{className:"size-4 shrink-0 text-white/55"}),r.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),r.jsx("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:e.npmName})]}),r.jsx(Se,{className:$("shrink-0",sM(e.state)),variant:"outline",children:nM(e.state)})]}),r.jsx("div",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:e.description}),r.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[r.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/50",children:rM(e)}),r.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 text-white/45",children:e.capability}),r.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/35",children:e.installCommand})]}),r.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[s!==null&&r.jsxs(ee,{type:"button",size:"sm",variant:"secondary",disabled:o,onClick:()=>n(e.id,s),children:[o?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(mr,{className:"size-3.5"}),Xs(s)]}),r.jsxs(ee,{type:"button",size:"sm",variant:"outline",disabled:o||e.state==="planned",onClick:()=>n(e.id,"help"),children:[r.jsx(Xn,{className:"size-3.5"}),"Help"]}),e.id==="eval-harness"&&r.jsxs(ee,{type:"button",size:"sm",variant:"ghost",disabled:o||e.state==="planned",onClick:()=>n(e.id,"runner-presets"),children:[r.jsx(Pl,{className:"size-3.5"}),"Presets"]})]})]})}function lM({task:e}){if(e===null)return null;const t=e.status==="queued"||e.status==="running";return r.jsxs("section",{className:"mt-3 rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t?r.jsx(Ue,{className:"size-4 animate-spin text-cyan-200/75"}):r.jsx(Xn,{className:"size-4 text-white/55"}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-semibold",children:oM(e)}),r.jsx("div",{className:"break-all font-mono text-[11px] text-white/35",children:e.command})]})]}),r.jsx(Se,{variant:"outline",className:$("shrink-0",K0(e.status)),children:e.status})]}),r.jsx("pre",{className:"mt-3 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-black/30 p-3 font-mono text-[11px] leading-5 text-white/60 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.output.trim().length>0?e.output:"Waiting for npm output..."}),e.error!==null&&r.jsx("div",{className:"mt-2 text-xs text-red-100",children:e.error})]})}function cM({workflow:e}){const t=e.icon;return r.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(t,{className:"size-4 shrink-0 text-cyan-200/75"}),r.jsx("div",{className:"text-sm font-semibold",children:e.title})]}),r.jsx("span",{className:"rounded bg-white/[0.04] px-2 py-0.5 font-mono text-[10px] text-white/45",children:e.label})]}),r.jsx("div",{className:"mt-2 min-h-10 text-xs leading-5 text-muted-foreground",children:e.description}),r.jsx("div",{className:"mt-3 font-mono text-[11px] text-white/35",children:e.metric})]})}function uM(e){return e===null?'npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke" --latest-log-limit 5':`npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke ${e}" --latest-log-limit 5`}function dM({preset:e}){return r.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[r.jsx(bf,{className:"size-4 shrink-0 text-cyan-200/75"}),r.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),r.jsxs("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:[e.binary," ",e.modelFlag,e.variantFlag!==null?` ${e.variantFlag}`:""]})]}),r.jsxs(Se,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:["v",e.validatedVersion]})]}),r.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px]",children:[r.jsxs("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:["logs/",e.logDir]}),r.jsx("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:e.tools.join(", ")}),r.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.skillsDir}),r.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.agentsDir})]})]})}function pM({recipe:e,copied:t,running:n,onCopy:s,onRun:o}){return r.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[r.jsx(ff,{className:"size-4 shrink-0 text-cyan-200/75"}),r.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.title})]}),r.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:e.description})]}),r.jsx(Se,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:e.runnable?e.stage:"Template"})]}),r.jsx("div",{className:"mt-3 rounded-md bg-black/20 p-2 font-mono text-[11px] leading-5 text-white/50 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.command}),r.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2",children:[r.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-[11px] text-white/35",children:e.packageId}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(ee,{type:"button",size:"sm",variant:"outline",onClick:()=>s(e),children:[t?r.jsx(Ge,{className:"size-3.5"}):r.jsx(Ot,{className:"size-3.5"}),t?"Copied":"Copy"]}),e.runnable&&r.jsxs(ee,{type:"button",size:"sm",variant:"secondary",disabled:n,onClick:()=>o(e),children:[n?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(bf,{className:"size-3.5"}),n?"Running":"Run"]})]})]})]})}function fM({task:e,selected:t,onSelect:n}){const s=e.recipeId??Xs(e.action);return r.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-white/[0.025] px-3 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(hf,{className:"size-3.5 shrink-0 text-white/40"}),r.jsx("div",{className:"truncate text-xs font-semibold text-white/75",children:s}),r.jsx(Se,{variant:"outline",className:$("shrink-0",K0(e.status)),children:e.status})]}),r.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-[10px] text-white/35",children:[r.jsx("span",{children:e.packageId}),r.jsx("span",{children:new Date(e.createdAt).toLocaleTimeString()}),e.exitCode!==null&&r.jsxs("span",{children:["exit ",String(e.exitCode)]})]})]}),r.jsx(ee,{type:"button",size:"sm",variant:t?"secondary":"outline",onClick:()=>n(e),children:t?"Open":"View"})]})}function mM({pending:e,busy:t,onOpenChange:n,onConfirm:s}){const o=e?.confirmation.plan??null;return r.jsx(Zt,{open:e!==null,onOpenChange:n,children:r.jsxs(Kt,{className:"max-w-xl",children:[r.jsxs(Xt,{children:[r.jsx(Qt,{children:"Confirm local command"}),r.jsx(wr,{children:"Review the exact allowlisted action Agent Inspector will run on this machine."})]}),o!==null&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[r.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[r.jsx("div",{className:"text-muted-foreground",children:"Source"}),r.jsx("div",{className:"mt-1 break-words font-medium",children:o.source})]}),r.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[r.jsx("div",{className:"text-muted-foreground",children:"Timeout"}),r.jsxs("div",{className:"mt-1 font-medium",children:[String(o.timeoutMs/1e3)," seconds"]})]}),r.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 sm:col-span-2",children:[r.jsx("div",{className:"text-muted-foreground",children:"Affected scope"}),r.jsx("div",{className:"mt-1 font-medium",children:o.scope})]})]}),r.jsxs("div",{children:[r.jsx("div",{className:"mb-1 text-xs font-medium",children:"Resolved command"}),r.jsx("pre",{className:"max-h-32 overflow-auto whitespace-pre-wrap break-all rounded-md bg-black/80 p-3 font-mono text-xs leading-5 text-white/80",children:o.command})]}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Confirmation phrase: ",r.jsx("code",{children:e?.confirmation.phrase}),". The one-time confirmation expires at"," ",new Date(e?.confirmation.expiresAt??"").toLocaleTimeString(),"."]})]}),r.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[r.jsx(ee,{type:"button",variant:"outline",disabled:t,onClick:()=>n(!1),children:"Cancel"}),r.jsxs(ee,{type:"button",variant:"secondary",disabled:t||o===null,onClick:s,children:[t?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(Xn,{className:"size-3.5"}),t?"Starting":"Confirm & Run"]})]})]})})}function hM({currentSessionId:e,logCount:t}){const[n,s]=c.useState(!1),[o,i]=c.useState(!1),[a,l]=c.useState(!1),[u,d]=c.useState(null),[p,f]=c.useState(null),[m,h]=c.useState(null),[g,y]=c.useState(null),[b,w]=c.useState(!1),v=Bt("/api/ecosystem/packages",JI,{revalidateOnFocus:!1,revalidateIfStale:!1}),j=Bt(p===null?null:`/api/ecosystem/tasks/${p}`,YI,{refreshInterval:z=>{const X=z?.task;return X!==void 0&&(X.status==="queued"||X.status==="running")?900:0},revalidateOnFocus:!1}),_=Bt(n?"/api/ecosystem/tasks":null,XI,{refreshInterval:2500,revalidateOnFocus:!1}),k=v.data?.packages??[],S=v.data?.runnerPresets??[],C=v.data?.recipes??[],M=(_.data?.tasks??[]).slice(0,6),A=c.useMemo(()=>k.filter(z=>z.state==="installed"||z.state==="update-available").length,[k]),P=uM(e),N="npx @tonyclaw/eval-harness runner-presets",I=()=>{Pt(P).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)})},F=()=>{Pt(N).then(()=>{l(!0),window.setTimeout(()=>l(!1),1200)})},B=z=>{Pt(z.command).then(()=>{d(z.id),window.setTimeout(()=>d(null),1200)})},J=z=>{h(null),eM(z.id).then(X=>{y(X)}).catch(X=>{h(X instanceof Error?X.message:"Failed to prepare ecosystem recipe")})},K=j.data?.task??null;c.useEffect(()=>{K!==null&&(_.mutate(),K.status==="succeeded"&&v.mutate())},[K,v,_]);const W=(z,X)=>{h(null),QI(z,X).then(Y=>{y(Y)}).catch(Y=>{h(Y instanceof Error?Y.message:"Failed to prepare ecosystem task")})},V=()=>{g!==null&&(h(null),w(!0),tM(g).then(z=>{f(z.id),y(null),j.mutate({task:z},{revalidate:!0}),_.mutate()}).catch(z=>{h(z instanceof Error?z.message:"Failed to start ecosystem task")}).finally(()=>{w(!1)}))};return r.jsxs(Zt,{open:n,onOpenChange:s,children:[r.jsx(yr,{asChild:!0,children:r.jsxs(ee,{variant:"ghost",size:"icon",className:ji,"aria-label":"TonyClaw Lab",title:"TonyClaw Lab",children:[r.jsx(ff,{className:"size-4"}),r.jsx("span",{className:"sr-only",children:"TonyClaw Lab"})]})}),r.jsxs(Kt,{className:"flex max-h-[84vh] max-w-5xl flex-col overflow-hidden",children:[r.jsx(Xt,{children:r.jsxs(Qt,{className:"flex items-center gap-2",children:[r.jsx(Na,{className:"size-4 text-cyan-200/80"}),"TonyClaw Lab"]})}),r.jsxs("div",{className:"overflow-y-auto pr-2",children:[r.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.1fr_0.9fr]",children:[r.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-semibold",children:"Session asset pipeline"}),r.jsx("div",{className:"mt-1 max-w-2xl text-xs leading-5 text-muted-foreground",children:"Treat captured traffic as durable assets: observe it, replay it, evaluate it, and expose it back to agents through MCP."})]}),r.jsxs(Se,{variant:"outline",className:"border-cyan-300/20 bg-cyan-300/8 text-cyan-100",children:[String(A),"/",String(k.length)," packages"]})]}),r.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:GI.map(z=>r.jsx(cM,{workflow:z},z.id))})]}),r.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-semibold",children:"Current session"}),r.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:e===null?"MCP smoke command":e})]}),r.jsxs(Se,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:[String(t)," logs"]})]}),r.jsx("div",{className:"mt-4 rounded-md bg-black/20 p-3 font-mono text-[11px] leading-5 text-white/55 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:P}),r.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[r.jsxs(ee,{size:"sm",variant:"secondary",onClick:I,children:[o?r.jsx(Ge,{className:"size-3.5"}):r.jsx(Ot,{className:"size-3.5"}),o?"Copied":"Copy"]}),r.jsxs(ee,{size:"sm",variant:"outline",onClick:F,children:[r.jsx(Pl,{className:"size-3.5"}),a?"Presets copied":"Runner Presets"]})]})]})]}),r.jsxs("section",{className:"mt-3",children:[r.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[r.jsx("div",{className:"text-sm font-semibold",children:"Lab recipes"}),r.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[r.jsx(Na,{className:"size-3.5"}),"copy-ready workflows"]})]}),r.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[C.map(z=>r.jsx(pM,{recipe:z,copied:u===z.id,running:K!==null&&K.recipeId===z.id&&(K.status==="queued"||K.status==="running"),onCopy:B,onRun:J},z.id)),v.isLoading&&C.length===0&&[0,1].map(z=>r.jsx("div",{className:"h-40 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},z))]})]}),r.jsxs("section",{className:"mt-3",children:[r.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[r.jsx("div",{className:"text-sm font-semibold",children:"Runner presets"}),r.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[r.jsx(Xn,{className:"size-3.5"}),N]})]}),r.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[S.map(z=>r.jsx(dM,{preset:z},z.id)),v.isLoading&&S.length===0&&[0,1,2,3].map(z=>r.jsx("div",{className:"h-32 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},z))]})]}),r.jsxs("section",{className:"mt-3",children:[r.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[r.jsx("div",{className:"text-sm font-semibold",children:"TonyClaw packages"}),v.isLoading&&r.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"checking npm..."})]}),v.error!==void 0&&r.jsx("div",{className:"rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:"Package status is temporarily unavailable."}),r.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[k.map(z=>r.jsx(aM,{pkg:z,activeTask:K,onStartTask:W},z.id)),v.isLoading&&k.length===0&&[0,1,2].map(z=>r.jsx("div",{className:"h-36 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},z))]})]}),m!==null&&r.jsx("div",{className:"mt-3 rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:m}),M.length>0&&r.jsxs("section",{className:"mt-3",children:[r.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[r.jsx("div",{className:"text-sm font-semibold",children:"Recent Lab runs"}),r.jsxs("div",{className:"hidden font-mono text-[11px] text-muted-foreground sm:block",children:["last ",String(M.length)]})]}),r.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:M.map(z=>r.jsx(fM,{task:z,selected:p===z.id,onSelect:X=>{f(X.id),j.mutate({task:X},{revalidate:!0})}},z.id))})]}),r.jsx(lM,{task:K})]})]}),r.jsx(mM,{pending:g,busy:b,onOpenChange:z=>{!z&&!b&&y(null)},onConfirm:V})]})}const gM=[{id:"saved-data",label:"Saved Inspector data",description:"requests, responses, sessions, tools, alerts, runs, groups, and knowledge"},{id:"root-cause",label:"Root-cause hints",description:"failures, hangs, slow paths, token spikes, and provider drift"},{id:"evidence",label:"Evidence links",description:"matched logs and metrics you can jump back into"}],xM=[{id:"reliability",label:"Reliability",question:"Which requests failed, stalled, or look most likely to hang, and why?"},{id:"performance",label:"Performance",question:"Summarize latency and identify the slowest requests with supporting evidence."},{id:"tokens",label:"Token usage",question:"Where are tokens being spent, and which requests have unusually high usage?"},{id:"providers",label:"Providers",question:"Compare Provider and model reliability, latency, and token usage in this scope."},{id:"tools",label:"Tool activity",question:"Which tools were used most, and where did tool calls fail or produce warnings?"}],bM=4e3,fa=12;function bd(){return{messages:[],question:"",error:null}}function vM(e){return e.filter(t=>t.content.trim().length>0).slice(-10).map(t=>({role:t.role,content:t.content.trim().slice(0,bM)}))}function ct(e,...t){for(const n of t){const s=Q(e,n);if(typeof s=="string"&&s.trim().length>0)return s}return null}function bn(e,...t){for(const n of t){const s=Q(e,n);if(typeof s=="number"&&Number.isFinite(s))return s}return null}function yM(e,t){const n=Q(e,t);return Array.isArray(n)?n.filter(s=>typeof s=="string").slice(0,8):[]}function wM(e){const t=ct(e,"source")??"log",n=ct(e,"id")??"",s=bn(e,"logId","id");if(n===""&&s===null||s!==null&&(!Number.isInteger(s)||s<0))return null;const o=bn(e,"inputTokens"),i=bn(e,"outputTokens"),a=bn(e,"totalTokens","tokenCount"),l=bn(e,"responseStatus","status"),u=ct(e,"responseStatus","status");return{source:t,id:n!==""?n:String(s),logId:s,sessionId:ct(e,"sessionId"),timestamp:ct(e,"timestamp"),model:ct(e,"model"),providerName:ct(e,"providerName","provider"),path:ct(e,"path"),status:l??u,elapsedMs:bn(e,"elapsedMs","latencyMs"),inputTokens:o,outputTokens:i,totalTokens:a??(o===null&&i===null?null:(o??0)+(i??0)),score:bn(e,"score","relevanceScore"),matchedFields:yM(e,"matchedFields"),excerpt:ct(e,"excerpt","snippet")??"No excerpt available."}}function ma(e){const t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return t.length===0?"Metric":`${t[0]?.toUpperCase()??""}${t.slice(1)}`}function vd(e){if(typeof e=="number"&&Number.isFinite(e))return e.toLocaleString();if(typeof e=="string"&&e.trim().length>0)return e;if(typeof e=="boolean")return e?"Yes":"No";if(Array.isArray(e)){const t=e.filter(n=>typeof n=="string"||typeof n=="number"&&Number.isFinite(n)).slice(0,6);return t.length>0?t.join(", "):null}return null}function yd(e){return Object.getOwnPropertyNames(e).map(t=>[t,Q(e,t)])}function wd(e){if(e===null||typeof e!="object"||Array.isArray(e))return[];const t=[];for(const[n,s]of yd(e)){const o=vd(s);if(o!==null){if(t.push({key:n,label:ma(n),value:o}),t.length>=fa)break;continue}if(!(s===null||typeof s!="object"||Array.isArray(s))){for(const[i,a]of yd(s)){const l=vd(a);if(l===null)continue;const u=`${n}.${i}`;if(t.push({key:u,label:`${ma(n)} ${ma(i).toLowerCase()}`,value:l}),t.length>=fa)break}if(t.length>=fa)break}}return t}function jM(e){const t=ct(e,"answer"),n=ct(e,"providerId"),s=ct(e,"providerName"),o=ct(e,"model"),i=ct(e,"protocol"),a=bn(e,"logCount");if(t===null||n===null||s===null||o===null||i===null||a===null)return null;const l=Q(e,"evidence"),u=Array.isArray(l)?l.map(wM).filter(d=>d!==null).slice(0,12):[];return{answer:t,providerId:n,providerName:s,model:o,protocol:i,logCount:a,evidence:u,summaryMetrics:wd(Q(e,"summary")),queryMetrics:wd(Q(e,"queryStats"))}}const kM=c.lazy(()=>Gt(()=>import("./index-BLp02enl.js"),__vite__mapDeps([9,1]))),_M="prose prose-sm dark:prose-invert max-w-none text-[13px] leading-[1.65] [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_p]:leading-[1.65] [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5 [&_li]:leading-[1.6]";function SM({text:e}){return r.jsx("div",{className:_M,children:r.jsx(c.Suspense,{fallback:r.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading Markdown..."}),children:r.jsx(kM,{children:e})})})}const jd="Analyze the current Inspector session. What looks abnormal, slow, or likely to hang?";function NM(e){return e.openaiResponsesBaseUrl!==void 0||e.openaiBaseUrl!==void 0||e.anthropicBaseUrl!==void 0}function CM(e){return e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""?"Responses":e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""?"Chat":"Anthropic"}function TM(e){return e.toSorted((t,n)=>{const s=t.source==="company"?0:1,o=n.source==="company"?0:1;return s!==o?s-o:t.name.localeCompare(n.name)})}function kd(e){return`${e}-${String(Date.now())}-${String(Math.random()).slice(2)}`}function _d({metrics:e}){return e.length===0?null:r.jsx("div",{className:"mt-2 grid grid-cols-2 gap-1.5",children:e.slice(0,8).map(t=>r.jsxs("div",{className:"rounded-sm bg-black/20 px-2 py-1",children:[r.jsx("div",{className:"truncate text-[9px] uppercase text-muted-foreground",children:t.label}),r.jsx("div",{className:"truncate font-mono text-[11px] text-cyan-50",children:t.value})]},t.key))})}function EM({evidence:e}){const t=()=>{e.logId!==null&&Is({logId:e.logId,tab:"anatomy"})},n=e.logId===null?`${e.source}:${e.id}`:`${e.source}:log #${String(e.logId)}`;return r.jsxs("button",{type:"button",onClick:t,disabled:e.logId===null,className:"w-full rounded-sm bg-black/20 px-2 py-2 text-left shadow-[inset_0_0_0_1px_rgba(255,255,255,0.05)] transition-colors hover:bg-black/30 disabled:cursor-default disabled:hover:bg-black/20",children:[r.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[r.jsx("span",{className:"truncate font-mono text-[10px] text-cyan-100",children:n}),e.score!==null&&r.jsx("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:e.score.toFixed(1)})]}),r.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-1 text-[10px] text-muted-foreground",children:[e.providerName!==null&&r.jsx("span",{children:e.providerName}),e.model!==null&&r.jsx("span",{children:e.model}),e.status!==null&&r.jsxs("span",{children:["status ",String(e.status)]}),e.elapsedMs!==null&&r.jsxs("span",{children:[String(e.elapsedMs)," ms"]})]}),r.jsx("p",{className:"mt-1 line-clamp-3 text-[11px] leading-4 text-foreground/85",children:e.excerpt})]})}function RM({response:e}){return r.jsxs("div",{className:"rounded-md bg-black/25 p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.05)]",children:[r.jsx(SM,{text:e.answer}),r.jsxs("div",{className:"mt-2 break-words font-mono text-[10px] text-cyan-100/70",children:[e.providerName," / ",e.model," / ",e.protocol," /"," ",String(e.logCount)," matched logs"]}),r.jsx(_d,{metrics:e.summaryMetrics}),r.jsx(_d,{metrics:e.queryMetrics}),e.evidence.length>0&&r.jsx("div",{className:"mt-2 space-y-1.5",children:e.evidence.slice(0,6).map(t=>r.jsx(EM,{evidence:t},`${t.source}-${t.id}`))})]})}function PM({message:e}){return e.role==="assistant"&&e.response!==null?r.jsx(RM,{response:e.response}):r.jsx("div",{className:"rounded-md bg-cyan-400/10 px-3 py-2 text-xs leading-5 text-cyan-50",children:e.content})}function IM({currentSessionId:e,logCount:t}){const{providers:n}=zl(),s=c.useMemo(()=>TM(n.filter(NM)),[n]),[o,i]=c.useState(()=>({...bd(),question:jd})),[a,l]=c.useState("__auto__"),[u,d]=c.useState("__auto__"),[p,f]=c.useState(!1),h=s.find(k=>k.id===a)?.models??[],g=o.question,y=g.trim()!==""&&s.length>0&&!p,b=k=>{i(S=>({...S,question:k.currentTarget.value}))},w=k=>{l(k),d("__auto__")},v=()=>{i({...bd(),question:jd})},j=k=>{i(S=>({...S,question:k,error:null}))},_=()=>{if(!y)return;const k=g.trim(),S=vM(o.messages),C={id:kd("user"),role:"user",content:k,response:null};f(!0),i(A=>({...A,messages:[...A.messages,C],question:"",error:null}));const M={question:k,history:S,...e!==null?{sessionId:e}:{},...a!=="__auto__"?{providerId:a}:{},...u!=="__auto__"?{model:u}:{},logLimit:16};fetch("/api/pi-agent",{method:"POST",headers:{"content-type":"application/json","x-agent-inspector-csrf":"1"},body:JSON.stringify(M)}).then(async A=>{const P=await A.text();if(!A.ok){i(F=>({...F,error:`Pi Agent failed: HTTP ${String(A.status)} ${P}`}));return}const N=JSON.parse(P),I=jM(N);if(I===null){i(F=>({...F,error:"Pi Agent returned an unexpected response."}));return}i(F=>({...F,messages:[...F.messages,{id:kd("assistant"),role:"assistant",content:I.answer,response:I}]}))}).catch(A=>{i(P=>({...P,error:A instanceof Error?A.message:"Pi Agent request failed."}))}).finally(()=>{f(!1)})};return r.jsxs("section",{className:"rounded-md bg-black/20 px-3 py-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ky,{className:"size-4 text-cyan-200"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Pi Agent"}),r.jsx("div",{className:"text-[11px] text-muted-foreground",children:e===null?"Ask saved Inspector data":"Ask this session"})]}),r.jsx("button",{type:"button",onClick:v,className:"inline-flex size-7 items-center justify-center rounded-md bg-black/25 text-muted-foreground transition-colors hover:text-foreground",title:"Reset conversation",children:r.jsx(vf,{className:"size-3.5"})})]}),o.messages.length===0&&r.jsxs("div",{className:"mt-3 rounded-md bg-black/[0.18] px-3 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[r.jsx("p",{className:"text-[11px] leading-5 text-muted-foreground",children:"ChatBI for Inspector memory: Pi searches saved traffic, sessions, tools, Provider signals, alerts, runs, groups, and knowledge candidates, then answers with linked evidence."}),r.jsx("div",{className:"mt-2 grid gap-1.5",children:gM.map(k=>r.jsxs("div",{className:"rounded-sm bg-cyan-400/[0.06] px-2 py-1.5 shadow-[inset_0_0_0_1px_rgba(103,232,249,0.08)]",children:[r.jsx("div",{className:"text-[10px] font-medium text-cyan-50",children:k.label}),r.jsx("div",{className:"mt-0.5 text-[9px] leading-4 text-muted-foreground",children:k.description})]},k.id))})]}),r.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[r.jsxs(Zn,{value:a,onValueChange:w,children:[r.jsx(Kn,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:r.jsx(Ms,{placeholder:"Provider"})}),r.jsxs(Gn,{children:[r.jsx(Qe,{value:"__auto__",children:"Auto provider"}),s.map(k=>r.jsxs(Qe,{value:k.id,children:[k.name," / ",CM(k)]},k.id))]})]}),r.jsxs(Zn,{value:u,onValueChange:d,children:[r.jsx(Kn,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:r.jsx(Ms,{placeholder:"Model"})}),r.jsxs(Gn,{children:[r.jsx(Qe,{value:"__auto__",children:"Auto model"}),h.map(k=>r.jsx(Qe,{value:k,children:k},k))]})]})]}),o.messages.length===0&&r.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:xM.map(k=>r.jsxs("button",{type:"button",onClick:()=>{j(k.question)},className:"inline-flex h-7 items-center gap-1.5 rounded-sm bg-black/25 px-2 text-[11px] text-cyan-50 transition-colors hover:bg-cyan-400/12",children:[r.jsx(Na,{className:"size-3"}),r.jsx("span",{children:k.label})]},k.id))}),o.messages.length>0&&r.jsxs("div",{className:"mt-3 max-h-96 space-y-2 overflow-y-auto pr-1",children:[o.messages.map(k=>r.jsx(PM,{message:k},k.id)),p&&r.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md bg-black/25 px-3 py-2 text-xs text-muted-foreground",children:[r.jsx(Ue,{className:"size-3.5 animate-spin"}),r.jsx("span",{children:"Searching Inspector..."})]})]}),r.jsx("textarea",{value:g,onChange:b,className:"mt-3 min-h-20 w-full resize-y rounded-md bg-black/25 px-3 py-2 text-xs leading-5 text-foreground outline-none shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring",placeholder:"Ask Pi Agent across saved Inspector data..."}),r.jsxs("button",{type:"button",onClick:_,disabled:!y,className:"mt-2 inline-flex h-8 w-full items-center justify-center gap-2 rounded-md bg-cyan-400/12 px-3 text-xs font-medium text-cyan-100 shadow-[inset_0_0_0_1px_rgba(103,232,249,0.18)] transition-colors hover:bg-cyan-400/18 disabled:cursor-not-allowed disabled:opacity-50",children:[p?r.jsx(Ue,{className:"size-3.5 animate-spin"}):r.jsx(Vj,{className:"size-3.5"}),r.jsx("span",{children:p?"Thinking...":"Ask Pi"})]}),o.error!==null&&r.jsx("p",{className:"mt-2 break-words text-[11px] leading-5 text-red-200",children:o.error}),s.length===0&&r.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"Configure a Provider with Responses, Chat, or Anthropic URL to enable Pi Agent."}),t===0&&r.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"No logs are visible in this scope yet; Pi Agent can still answer Provider setup questions."})]})}function MM(e){const t=new Map;for(const n of e){const s=n.logs;for(let o=1;o<s.length;o++){const i=s[o-1],a=s[o];i===void 0||a===void 0||t.set(a.id,{creation:Sd(i.cacheCreationInputTokens,a.cacheCreationInputTokens),read:Sd(i.cacheReadInputTokens,a.cacheReadInputTokens)})}}return t}function Sd(e,t){return t===null||e===null?null:t>e?{direction:"up",delta:t-e}:t<e?{direction:"down",delta:e-t}:null}function G0(e){return e===null?null:new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ds(e,t,n){const s=G0(e.lastSuccessAt),o=e.retryCount>0?` Retry ${e.retryCount.toString()}.`:"",i=n?" Captured logs remain visible.":"",a=s===null?"":` Last update ${s}.`;return`${t}${a}${o}${i}`}function J0(e,t,n){switch(e){case"connecting":return{label:"Connecting",description:ds(t,"Waiting for the first live update.",n),toneClass:"border-cyan-400/20 bg-cyan-500/8 text-cyan-100",dotClass:"bg-cyan-300 animate-pulse motion-reduce:animate-none",canRetry:!1,canStop:!1};case"live":return{label:"Live",description:ds(t,"Live updates are current.",n),toneClass:"border-emerald-400/20 bg-emerald-500/8 text-emerald-100",dotClass:"bg-emerald-300",canRetry:!1,canStop:!1};case"reconnecting":return{label:"Reconnecting",description:ds(t,"Live updates were interrupted.",n),toneClass:"border-amber-400/20 bg-amber-500/8 text-amber-100",dotClass:"bg-amber-300 animate-pulse motion-reduce:animate-none",canRetry:!0,canStop:!0};case"stale":return{label:"Stale data",description:ds(t,"Live updates have not resumed.",n),toneClass:"border-orange-400/25 bg-orange-500/10 text-orange-100",dotClass:"bg-orange-300",canRetry:!0,canStop:!0};case"offline":return{label:"Offline",description:ds(t,t.errorMessage??"Live updates are paused.",n),toneClass:"border-slate-400/20 bg-slate-500/10 text-slate-200",dotClass:"bg-slate-400",canRetry:!0,canStop:!1};case"error":return{label:"Connection error",description:ds(t,t.errorMessage??"The live stream reported a recoverable error.",n),toneClass:"border-red-400/25 bg-red-500/10 text-red-100",dotClass:"bg-red-300",canRetry:!0,canStop:!0}}}function AM({state:e}){const t=J0(e.status,e,!1),n=G0(e.lastSuccessAt),s=e.retryCount>0?`Retry ${e.retryCount.toString()}`:null;return r.jsxs("span",{role:"status","aria-label":t.description,"data-connection-state":e.status,className:$("inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium",t.toneClass),children:[r.jsx("span",{className:$("size-1.5 shrink-0 rounded-full",t.dotClass)}),r.jsx("span",{className:"shrink-0",children:t.label}),s!==null&&r.jsx("span",{className:"hidden truncate text-current/70 sm:inline",children:s}),n!==null&&r.jsxs("span",{className:"hidden truncate font-mono text-[10px] text-current/65 md:inline",children:["Last ",n]})]})}function OM({state:e,hasLogs:t,onRetry:n,onStop:s}){const o=J0(e.status,e,t);return r.jsxs("div",{role:"status","aria-live":"polite","data-connection-state":e.status,className:$("mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md border px-3 py-2 text-xs",o.toneClass),children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[r.jsx("span",{className:$("size-2 shrink-0 rounded-full",o.dotClass)}),r.jsx("span",{className:"shrink-0 font-semibold",children:o.label}),r.jsx("span",{className:"min-w-0 text-current/75",children:o.description})]}),(o.canRetry||o.canStop)&&r.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[o.canRetry&&r.jsxs("button",{type:"button",onClick:n,className:"inline-flex h-7 items-center gap-1 rounded-md bg-black/15 px-2 font-medium transition-colors hover:bg-black/25 focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[r.jsx(Vt,{className:"size-3"}),"Retry now"]}),o.canStop&&r.jsxs("button",{type:"button",onClick:s,className:"inline-flex h-7 items-center gap-1 rounded-md px-2 text-current/70 transition-colors hover:bg-black/15 hover:text-current focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[r.jsx(gw,{className:"size-3"}),"Stop retrying"]})]})]})}function zM({liveConnection:e,alertsAction:t,settingsAction:n}){return r.jsx("header",{"data-application-bar":"true",className:"border-border/70 bg-background/95 sticky top-0 z-50 shrink-0 border-b px-3 py-2 shadow-[0_10px_30px_rgba(0,0,0,0.14)] backdrop-blur lg:px-4",children:r.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-2 sm:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]",children:[r.jsxs("a",{href:"/","aria-label":"Agent Inspector home",className:"flex min-w-0 items-center gap-2 rounded-md focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[r.jsx(sp,{className:"size-7 shrink-0 text-amber-500"}),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block truncate text-sm font-bold leading-4",children:"Agent Inspector"}),r.jsx("span",{className:"hidden truncate text-[10px] font-medium text-muted-foreground md:block",children:"Local First. Evidence First."})]}),r.jsxs("span",{className:"hidden shrink-0 font-mono text-[10px] text-muted-foreground lg:inline",children:["v",jf.version]})]}),r.jsx("div",{className:"order-3 col-span-2 flex min-w-0 justify-start sm:order-2 sm:col-span-1 sm:justify-center",children:e===void 0?r.jsxs("span",{"data-connection-state":"stored",className:"border-border/70 bg-muted/50 inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium text-muted-foreground",children:[r.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-slate-400"}),"Stored session"]}):r.jsx(AM,{state:e})}),r.jsxs("nav",{"aria-label":"Application actions",className:"order-2 flex shrink-0 items-center justify-end gap-1 sm:order-3",children:[t,n]})]})})}function LM(e){return`${Math.max(0,Math.ceil(e/1e3)).toString()}s`}function lo({progress:e}){const t=Math.min(1,e.elapsedMs/e.timeoutMs),n=Math.max(4,Math.round(t*100)),s=Math.max(0,e.timeoutMs-e.elapsedMs),o=t>=.75,i=[e.loadedLogs>0?`${e.loadedLogs.toString()} logs`:null,e.loadedPages>0?`${e.loadedPages.toString()} page${e.loadedPages===1?"":"s"}`:null,`${LM(s)} before timeout`].filter(l=>l!==null),a=`${e.label}: ${i.join(", ")}`;return r.jsxs("div",{className:"min-w-0 space-y-1 px-1 pb-1",children:[r.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 font-mono text-[10px] text-muted-foreground",children:[r.jsx("span",{className:"min-w-0 truncate",children:e.label}),r.jsx("span",{className:$("shrink-0 tabular-nums",o&&"text-amber-300"),children:i.join(" / ")})]}),r.jsx("div",{role:"progressbar","aria-label":e.label,"aria-valuemin":0,"aria-valuemax":e.timeoutMs,"aria-valuenow":Math.min(e.elapsedMs,e.timeoutMs),"aria-valuetext":a,className:"h-1.5 overflow-hidden rounded-full bg-white/[0.06]",children:r.jsx("div",{className:$("h-full rounded-full transition-all duration-300 motion-reduce:transition-none",o?"bg-amber-300/80":"bg-cyan-300/70"),style:{width:`${n.toString()}%`}})})]})}function Y0(e){return e?"auto":"smooth"}function X0(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function $M(){return{status:"connecting",lastSuccessAt:null,retryCount:0,errorMessage:null}}function nn(e,t){switch(t.type){case"connect-requested":return{...e,status:e.lastSuccessAt===null?"connecting":e.status==="stale"?"stale":"reconnecting",errorMessage:null};case"message-received":return{status:"live",lastSuccessAt:t.at,retryCount:0,errorMessage:null};case"connection-lost":{const n=e.retryCount+1;return t.online?{...e,status:e.lastSuccessAt===null?"error":"reconnecting",retryCount:n,errorMessage:t.message}:{...e,status:"offline",retryCount:n,errorMessage:"Browser is offline."}}case"stale-timeout":return e.lastSuccessAt===null||e.status==="live"||e.status==="offline"?e:{...e,status:"stale"};case"browser-offline":return{...e,status:"offline",errorMessage:"Browser is offline."};case"stop-retrying":return{...e,status:"offline",errorMessage:"Automatic live updates are paused."};case"recoverable-error":return{...e,status:"error",errorMessage:t.message}}}function DM(e){return e===void 0||e.status==="live"?"empty":e.status}function FM(e){switch(e){case"connecting":return{title:"Connecting to the live stream...",description:"Waiting for the first successful initialization before checking for logs.",showConnectionCommands:!1};case"empty":return{title:"No logs captured yet.",description:"Connect an AI coding tool to capture its first request.",showConnectionCommands:!0};case"reconnecting":return{title:"Reconnecting to live updates...",description:"The stream was interrupted. Agent Inspector is retrying automatically.",showConnectionCommands:!1};case"stale":return{title:"Live data is stale.",description:"No logs are hidden; retry the connection to resume live updates.",showConnectionCommands:!1};case"offline":return{title:"Live updates are offline.",description:"Check the browser and Inspector connection, then retry.",showConnectionCommands:!1};case"error":return{title:"Live updates could not initialize.",description:"The error is recoverable. Retry without reloading the page.",showConnectionCommands:!1}}}const Nd="agent-inspector.hierarchy.collapsedClients",Cd="agent-inspector.hierarchy.collapsedProcesses";function zo(e){return e.some(t=>t.responseStatus===null)}function Q0(e){return e.filter(t=>t.responseStatus===null).length}function eg(e){for(const t of e){const n=t.userAgent;if(n!=null&&n!=="")return n}return null}function UM(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function tg(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}function BM(e){return ac({userAgent:eg(e.logs),conversationId:e.conversationId,clientProjectFolder:tg(e.logs)})}function VM(e){if(e===null||e==="")return"Unknown client";const t=e.split(/[ /;]/)[0]??"";return t===""?"Unknown client":t}function qM(e,t){const n=xi(e);return n!==null?n:VM(t)}function Lo(e){return e===null||e===""?"unknown":String(e)}function HM(e,t,n){return e!=="unknown"?e:`unknown:${Lo(t)}:${Lo(n)}`}function WM(e,t){return`${Lo(e)}:${Lo(t)}`}function Td(e){return[...e].sort((t,n)=>t.timestamp.localeCompare(n.timestamp))}function Ed(e){let t="";for(const n of e)n.timestamp>t&&(t=n.timestamp);return t}function Rd(e){return zo(e)?0:e.some(t=>t.error!==null&&t.error!==void 0||t.responseStatus!==null&&t.responseStatus!==void 0&&t.responseStatus>=400)?1:2}function ha(e){return[...e].sort((t,n)=>{const s=Rd(t.logs)-Rd(n.logs);if(s!==0)return s;const o=Ed(n.logs).localeCompare(Ed(t.logs));return o!==0?o:t.id.localeCompare(n.id)})}function ZM(e){const t=new Map;for(const s of e){const o=eg(s.logs),i=tg(s.logs),a=BM(s),l=HM(a,o,i);let u=t.get(l);u===void 0&&(u={id:l,client:a,label:qM(a,o),userAgent:o,processes:new Map,logs:[]},t.set(l,u)),u.logs.push(...s.logs);const d=UM(s.logs),p=`${l}:${WM(d,i)}`;let f=u.processes.get(p);f===void 0&&(f={id:p,clientPid:d,clientProjectFolder:i,sessions:[],logs:[]},u.processes.set(p,f)),f.sessions.push(s),f.logs.push(...s.logs)}const n=[];for(const s of t.values()){const o=ha([...s.processes.values()].map(i=>({id:i.id,clientPid:i.clientPid,clientProjectFolder:i.clientProjectFolder,sessions:ha(i.sessions),logs:Td(i.logs)})));n.push({id:s.id,client:s.client,label:s.label,userAgent:s.userAgent,processes:o,logs:Td(s.logs)})}return ha(n)}function $o(e){return e<=0?"0":Ie(e)}function ng(e){let t=0,n=0;for(const s of e)s.inputTokens!==null&&s.inputTokens!==void 0&&(t+=s.inputTokens),s.outputTokens!==null&&s.outputTokens!==void 0&&(n+=s.outputTokens);return{inputTokens:t,outputTokens:n}}function KM(e){let t=0;for(const n of e)t+=n.sessions.length;return t}function Pd(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(t===null)return null;const n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(s=>typeof s=="string")):null}catch{return null}}function Id(e,t){try{window.localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function Md(e,t){let n=!1;const s=new Set(e);for(const o of t)s.delete(o)&&(n=!0);return n?s:e}function GM(e){const t=new Set;for(const n of e)for(let s=1;s<n.processes.length;s++){const o=n.processes[s];o!==void 0&&!zo(o.logs)&&t.add(o.id)}return t}function JM(e){if(e===null||e==="")return null;const t=e.replaceAll("\\","/").split("/").filter(o=>o!==""),n=t[t.length-1];if(n===void 0)return e;const s=t[t.length-2];return s===void 0?n:`${s}/${n}`}function Do({label:e,value:t,className:n}){return r.jsxs("span",{className:$("inline-flex h-7 items-center gap-1 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",n),children:[r.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:e}),r.jsx("span",{className:"font-mono tabular-nums text-foreground",children:t})]})}function sg({count:e}){const t=`${e} open turn${e===1?"":"s"}`;return r.jsxs("span",{className:"relative inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-medium)] text-[var(--inspector-status-watch)] ring-1 ring-border/50","aria-label":t,title:t,children:[r.jsx(Ue,{className:"size-3 animate-spin"}),e>1&&r.jsx("span",{className:"absolute translate-x-2 -translate-y-2 rounded bg-card px-0.5 font-mono text-[8px] tabular-nums text-[var(--inspector-status-watch)]",children:e})]})}function YM({groups:e,...t}){const n=c.useMemo(()=>ZM(e),[e]),[s,o]=c.useState(()=>new Set),[i,a]=c.useState(()=>GM(n)),[l,u]=c.useState(!1);c.useEffect(()=>{const f=Pd(Nd),m=Pd(Cd);f!==null&&o(f),m!==null&&a(m),u(!0)},[]),c.useEffect(()=>{l&&(Id(Nd,s),Id(Cd,i))},[s,i,l]),c.useEffect(()=>{const f=new Set(n.filter(h=>zo(h.logs)).map(h=>h.id)),m=new Set(n.flatMap(h=>h.processes.filter(g=>zo(g.logs)).map(g=>g.id)));o(h=>Md(h,f)),a(h=>Md(h,m))},[n]);const d=c.useCallback(f=>{o(m=>{const h=new Set(m);return h.has(f)?h.delete(f):h.add(f),h})},[]),p=c.useCallback(f=>{a(m=>{const h=new Set(m);return h.has(f)?h.delete(f):h.add(f),h})},[]);return r.jsx("div",{className:"space-y-2",children:n.map(f=>r.jsx(XM,{group:f,collapsed:s.has(f.id),collapsedProcessIds:i,onToggleClient:()=>d(f.id),onToggleProcess:p,conversationProps:t},f.id))})}function XM({group:e,collapsed:t,collapsedProcessIds:n,onToggleClient:s,onToggleProcess:o,conversationProps:i}){const a=ng(e.logs),l=KM(e.processes),u=e.logs.length,d=Q0(e.logs),p=d>0;return r.jsxs("section",{className:$("relative isolate overflow-hidden rounded-[8px] bg-card/65",p&&"bg-card/80"),"data-ide-group":e.id,children:[r.jsxs("button",{type:"button",className:"grid w-full min-w-0 grid-cols-[2.25rem_minmax(0,1fr)_auto] items-center gap-2.5 px-3 py-2.5 text-left transition-colors hover:bg-[var(--inspector-surface-low)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:s,"aria-expanded":!t,children:[e.client==="unknown"?r.jsx("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground",children:r.jsx(fj,{className:"size-4"})}):r.jsx(bi,{client:e.client,className:"size-9 rounded-md",decorative:!0}),r.jsxs("span",{className:"min-w-0",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"truncate text-sm font-semibold text-foreground",title:e.userAgent??e.label,children:e.label}),r.jsx("span",{className:"rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:PC(e.client)}),p&&r.jsx(sg,{count:d})]}),r.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[r.jsxs("span",{children:[e.processes.length," process",e.processes.length!==1?"es":""]}),r.jsxs("span",{children:[l," session",l!==1?"s":""]}),r.jsxs("span",{children:[u," req"]})]})]}),r.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t&&r.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[r.jsx(Do,{label:"IN",value:$o(a.inputTokens)}),r.jsx(Do,{label:"OUT",value:$o(a.outputTokens)})]}),r.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors group-hover:bg-[var(--inspector-surface-medium)]",children:t?r.jsx(yt,{className:"size-4"}):r.jsx(nt,{className:"size-4"})})]})]}),!t&&r.jsx("div",{className:"space-y-0.5 px-2 pb-2 pt-0.5",children:e.processes.map(f=>r.jsx(QM,{group:f,collapsed:n.has(f.id),onToggle:()=>o(f.id),conversationProps:i},f.id))})]})}function QM({group:e,collapsed:t,onToggle:n,conversationProps:s}){const o=ng(e.logs),i=JM(e.clientProjectFolder),a=e.sessions.length,l=e.logs.length,u=Q0(e.logs),d=u>0,p=e.clientPid!==null&&e.clientPid!==void 0?`PID ${e.clientPid}`:"Process unavailable";return r.jsxs("section",{className:"relative pl-3",children:[r.jsxs("button",{type:"button",className:"grid w-full min-w-0 grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-2.5 rounded-md bg-[var(--inspector-surface-low)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--inspector-surface-medium)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:n,"aria-expanded":!t,children:[r.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center text-[var(--inspector-status-watch)]",children:r.jsx(Rw,{className:"size-4"})}),r.jsxs("span",{className:"min-w-0",children:[r.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:"font-mono text-xs font-semibold tabular-nums text-foreground",children:p}),d&&r.jsx(sg,{count:u}),i!==null&&r.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:e.clientProjectFolder??i,children:[r.jsx(Xw,{className:"size-3 shrink-0"}),r.jsx("span",{className:"truncate font-mono",children:i})]})]}),r.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[r.jsxs("span",{children:[a," session",a!==1?"s":""]}),r.jsxs("span",{children:[l," req"]})]})]}),r.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t&&r.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[r.jsx(Do,{label:"IN",value:$o(o.inputTokens)}),r.jsx(Do,{label:"OUT",value:$o(o.outputTokens)})]}),r.jsx("span",{className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)]",children:t?r.jsx(yt,{className:"size-4"}):r.jsx(nt,{className:"size-4"})})]})]}),!t&&r.jsx("div",{className:"space-y-1 pb-1 pl-3 pr-1 pt-1",children:e.sessions.map(f=>r.jsx(eR,{group:f,...s,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},f.id))})]})}const eA="w-[calc(100%-1rem)] border-warning/30 bg-popover text-popover-foreground sm:max-w-lg",tA=[{label:"Headers",detail:"request and response headers, including authorization or cookie values"},{label:"Prompts",detail:"system instructions, user prompts, model responses, and conversation history"},{label:"Source content",detail:"source code, file contents, tool inputs, and tool output"},{label:"Secrets",detail:"API keys, access tokens, credentials, and other sensitive values"}];function nA({onCancel:e,onExportRedacted:t,onConfirmRaw:n}){return r.jsxs(r.Fragment,{children:[r.jsxs(Xt,{children:[r.jsx(Qt,{children:"Export unredacted logs?"}),r.jsx(wr,{children:"Raw exports bypass Agent Inspector redaction and may expose sensitive captured data."})]}),r.jsxs("div",{role:"alert",className:"rounded-md border border-warning/35 bg-warning/10 px-3 py-3 text-sm text-foreground",children:[r.jsx("p",{className:"font-medium",children:"The raw archive may include:"}),r.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs leading-relaxed text-muted-foreground",children:tA.map(s=>r.jsxs("li",{children:[r.jsxs("span",{className:"font-semibold text-foreground",children:[s.label,":"]})," ",s.detail]},s.label))}),r.jsx("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:"Only continue if you trust where this file will be stored and everyone it may be shared with."})]}),r.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[r.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:e,children:"Cancel"}),r.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:t,children:"Export redacted instead"}),r.jsx(ee,{type:"button",variant:"destructive",size:"sm",onClick:n,children:"Export raw data"})]})]})}const Fo="data-nav-id",sA="data-nav-action";function Ad(e){return Array.from(e.querySelectorAll(`[${Fo}]`))}function Od(e){return e instanceof HTMLElement}function rA(e,t){let n=e;for(;n!==null&&n!==t;){if(n.hasAttribute(Fo))return n;n=n.parentElement}return e.hasAttribute(Fo)?e:null}function ga(e){const t=e.getAttribute(sA);return t==="toggle"||t==="expand"||t==="collapse"?t:null}function Ws(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Zs(e,t){return e[t]??null}function rg(e){const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function zd(e){const t=e.tagName;return t==="BUTTON"||t==="A"||rg(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function oA(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function iA(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function Kr(e,t){return e.key===t&&e.shiftKey}function aA(e,t,n={}){const s=t??e,o=n.pageWide===!0,i=c.useCallback(a=>{const l=e.current,u=s.current;if(!l||!u)return;const d=a.target;if(!Od(d)||d!==u)return;const p=Ad(l),f=Zs(p,0);f!==null&&Ws(f)},[e,s]);c.useEffect(()=>{const a=l=>{if(l.altKey||l.ctrlKey||l.metaKey)return;const u=e.current;if(!u)return;const d=l.target;if(!Od(d)||rg(d)||iA())return;const p=u.contains(d);if(p&&zd(d)&&!d.hasAttribute(Fo)||!p&&(!o||zd(d)||oA(d)))return;const f=Ad(u);if(f.length===0)return;const m=rA(d,u),h=m!==null?f.indexOf(m):-1;let g=!1;switch(l.key){case"ArrowUp":case"W":{if(l.shiftKey&&l.key==="ArrowUp"||l.key==="W"&&!Kr(l,"W"))break;l.preventDefault();const y=h>0?h-1:h===-1?f.length-1:-1;if(y!==-1){const b=Zs(f,y);b!==null&&Ws(b)}g=!0;break}case"ArrowDown":case"S":{if(l.shiftKey&&l.key==="ArrowDown"||l.key==="S"&&!Kr(l,"S"))break;l.preventDefault();const y=h<f.length-1?h+1:h===-1?0:-1;if(y!==-1){const b=Zs(f,y);b!==null&&Ws(b)}g=!0;break}case"ArrowLeft":case"A":{if(l.shiftKey&&l.key==="ArrowLeft"||l.key==="A"&&!Kr(l,"A")||m===null)break;if(l.preventDefault(),ga(m)==="collapse")m.click();else if(h>0){const b=Zs(f,h-1);b!==null&&Ws(b)}g=!0;break}case"ArrowRight":case"D":{if(l.shiftKey&&l.key==="ArrowRight"||l.key==="D"&&!Kr(l,"D")||m===null)break;if(l.preventDefault(),ga(m)==="expand")m.click();else if(h<f.length-1){const b=Zs(f,h+1);b!==null&&Ws(b)}g=!0;break}case" ":{if(m===null)break;l.preventDefault(),ga(m)!==null&&m.click(),g=!0;break}}g&&l.stopPropagation()};return document.addEventListener("keydown",a,{capture:!0}),()=>document.removeEventListener("keydown",a,{capture:!0})},[e,o,s]),c.useEffect(()=>(document.addEventListener("focusin",i),()=>document.removeEventListener("focusin",i)),[i])}const lA={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},cA={system:"bg-sky-500/70",user:"bg-emerald-500/70",assistant:"bg-violet-500/70",tool:"bg-sky-400/55",tools:"bg-slate-500/70"},uA={system:"focus-visible:ring-sky-300",user:"focus-visible:ring-emerald-300",assistant:"focus-visible:ring-violet-300",tool:"focus-visible:ring-sky-300",tools:"focus-visible:ring-slate-300"},xa=12,Gr=1,Ld=80,$d=24;function dA(e){return e.length<=$d?e:`${e.slice(0,$d-3)}...`}function pA(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Ld?t:`${t.slice(0,Ld)}...`}function Jr(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const fA=c.memo(function({segments:t,totalTokens:n,showLabels:s=!0,onActivate:o}){const i=c.useMemo(()=>n>0?n:t.reduce((b,w)=>b+w.size,0),[t,n]),a=t.slice(0,xa),l=t.slice(xa),u=l.reduce((b,w)=>b+w.size,0),d=l.length,p=xa,f=p+d-1,m=d>0,h=o!==void 0,g=c.useMemo(()=>a.reduce((b,w)=>b+w.size,0),[a]),y=c.useMemo(()=>`Request context: ~${Ie(i)} tokens across ${t.length} segment${t.length===1?"":"s"}`,[t.length,i]);return t.length===0||i<=0?r.jsx("div",{role:"img","aria-label":y,className:"h-6"}):r.jsx(Ds,{delayDuration:150,children:r.jsxs("div",{role:"img","aria-label":y,className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"relative flex h-6 w-full overflow-hidden rounded border border-border/40 bg-muted/30","data-testid":"anatomy-segment-bar",children:[a.map((b,w)=>{const v=i>0?b.size/i*100:0,j=Math.max(Gr,v),_=$("h-full border-r border-background/80 last:border-r-0",h?"opacity-90 hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background":"opacity-90",cA[b.role],h?uA[b.role]:""),k={width:`${j}%`},S=`${b.label}, ${Jr(v)}, ~${Ie(b.size)} tokens`;return r.jsxs(ft,{children:[r.jsx(mt,{asChild:!0,children:h?r.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>o(b),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),o(b))},"data-anatomy-path":b.path,"aria-label":S,className:_,style:k}):r.jsx("span",{"aria-label":S,className:_,style:k})}),r.jsxs(ht,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[r.jsxs("div",{className:"font-semibold",children:[b.label," - ",Jr(v)," - ~",Ie(b.size)," ","tokens"]}),r.jsx("div",{className:"text-muted-foreground",children:lA[b.role]}),r.jsxs("div",{className:"text-muted-foreground",children:[b.characters.toLocaleString()," chars"]}),b.text.length>0&&r.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:pA(b.text)})]})]},`${b.path}-${w}`)}),m&&r.jsxs(ft,{children:[r.jsx(mt,{asChild:!0,children:r.jsxs("div",{role:"img","aria-label":`${d} additional segments`,className:"flex h-full items-center justify-center bg-muted-foreground/30 px-1.5 text-[10px] font-mono text-background",style:{width:`${Math.max(Gr,u/i*100)}%`},children:["... +",d]})}),r.jsxs(ht,{side:"bottom",className:"text-xs",children:[d," more segment",d===1?"":"s"," (indices"," ",p,"-",f,")"]})]})]}),s&&r.jsxs("div",{className:"flex w-full gap-1 text-[10px] text-muted-foreground",children:[a.map((b,w)=>{const v=i>0?b.size/i*100:0,j=Math.max(Gr,v);return r.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${j}%`},title:`${b.label} - ${Jr(v)} - ~${Ie(b.size)} tokens`,children:[r.jsx("span",{className:"truncate font-mono text-foreground/80",children:dA(b.label)}),r.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[Jr(v)," - ~",Ie(b.size)]})]},`label-${b.path}-${w}`)}),m&&r.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(Gr,u/i*100)}%`},children:[r.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",d]}),r.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",Ie(u)]})]})]}),g<i*.1&&r.jsx("div",{className:"h-0"})]})})}),og=.75,ig=.9,ol=8e3,mA=.35,ag=40,lg=160,hA=5,gA=8,xA=18,bA=6e4,vA=.7,Dd=3e3,yA=.3,Fd=160,wA=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),jA=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],kA=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],_A=[{family:"OpenAI GPT-4.1",tokens:1047576,mode:"prefix",patterns:["gpt-4.1"]},{family:"OpenAI GPT-4o",tokens:128e3,mode:"prefix",patterns:["gpt-4o"]},{family:"OpenAI o-series",tokens:128e3,mode:"prefix",patterns:["o1","o3","o4"]},{family:"Anthropic Claude",tokens:2e5,mode:"prefix",patterns:["claude-"]},{family:"DeepSeek V4",tokens:1048576,mode:"prefix",patterns:["deepseek-v4-pro","deepseek-v4-flash"]},{family:"DeepSeek",tokens:64e3,mode:"prefix",patterns:["deepseek-"]},{family:"MiniMax M3",tokens:1048576,mode:"includes",patterns:["minimax-m3"]},{family:"MiniMax M2.7",tokens:204800,mode:"includes",patterns:["minimax-m2.7"]},{family:"MiniMax M2.5/M2.1",tokens:196608,mode:"includes",patterns:["minimax-m2.5","minimax-m2.1"]},{family:"GLM-5.2",tokens:1048576,mode:"prefix",patterns:["glm-5.2"]},{family:"GLM-5",tokens:202752,mode:"prefix",patterns:["glm-5","glm-5.1"]}],SA={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function NA(e){if(typeof e=="number")return Number.isFinite(e)&&e>0?Math.floor(e):null;if(typeof e=="string"){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}return null}function cg(e,t){for(const n of t){const s=NA(Q(e,n));if(s!==null)return s}return null}function CA(e){const t=Q(e,"model");if(typeof t!="string")return null;const n=t.trim();return n===""?null:n}function TA(e,t){switch(t.mode){case"prefix":return t.patterns.some(n=>e.startsWith(n));case"includes":return t.patterns.some(n=>e.includes(n))}}function EA(e,t,n=[]){const s=cg(t,jA);if(s!==null)return{tokens:s,label:"Request metadata",source:"request"};const o=IP(e,n);if(o!==null)return{tokens:o.tokens,label:`${o.providerName} config`,source:"provider"};if(e===null)return{tokens:null,label:"Unknown model",source:"unknown"};const i=e.trim().toLowerCase().replace(/\s+/g,"-");for(const a of _A)if(TA(i,a))return{tokens:a.tokens,label:`${a.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function RA(e){return e<0?0:e>1?1:e}function PA(e){return e===null?"unknown":e>=ig?"danger":e>=og?"watch":"ok"}function IA(e,t){return e.filter(n=>n.role===t).reduce((n,s)=>n+s.size,0)}function MA(e,t){return["system","user","assistant","tool","tools"].map(s=>{const o=IA(e,s);return{role:s,label:SA[s],tokens:o,percent:t>0?o/t:0}}).filter(s=>s.tokens>0).sort((s,o)=>o.tokens-s.tokens)}function il(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function AA(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Fd?t:`${t.slice(0,Fd-3)}...`}function OA(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function zA(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function LA(e){const t=e.trim();return t.startsWith("{")||t.startsWith("[")}function $A(e){if(!LA(e))return null;try{return JSON.parse(e)}catch{return null}}function DA(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function FA(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t]??"";if(!(n.startsWith("[")&&n.endsWith("]")))return n}return null}function UA(e){const t=FA(e);return t===null?!1:wA.has(DA(t))}function BA(e){return e.map(t=>t.startsWith("[")?t:`.${t}`).join("").replace(/^\./,"")}function VA(e,t,n){const s=dc(t);if(s<lg)return null;const o=uc(t);return o<ag?null:{role:e.role,label:`${e.label} ${BA(n)}`,path:e.path,tokens:o,characters:s,text:t}}function al({value:e,segment:t,path:n,depth:s,candidates:o}){if(!(o.length>=gA)&&!(s>hA)){if(typeof e=="string"){if(!UA(n))return;const i=VA(t,e,n);i!==null&&o.push(i);return}if(Array.isArray(e)){e.forEach((i,a)=>al({value:i,segment:t,path:[...n,`[${String(a)}]`],depth:s+1,candidates:o}));return}pc(e)&&Object.entries(e).forEach(([i,a])=>al({value:a,segment:t,path:[...n,i],depth:s+1,candidates:o}))}}function qA(e){const t=zA(e),n=$A(e.text);if(n===null)return[t];const s=[];al({value:n,segment:e,path:[],depth:0,candidates:s});const o=il(e.text),i=new Set([o]),a=s.filter(l=>{const u=il(l.text);return u===""||i.has(u)?!1:(i.add(u),!0)});return[t,...a]}function HA(e){const t=new Map;for(const s of e){const o=qA(s);for(const i of o){if(i.tokens<ag||i.characters<lg)continue;const a=il(i.text);if(a==="")continue;const l=t.get(a);if(l===void 0){t.set(a,{tokens:i.tokens,candidates:[i]});continue}t.set(a,{tokens:l.tokens+i.tokens,candidates:[...l.candidates,i]})}}const n=[];for(const s of t.values()){if(s.candidates.length<2)continue;const o=s.candidates[0]??null;if(o===null)continue;const i=s.tokens-o.tokens;n.push({key:`${o.path}:${o.label}:${String(s.candidates.length)}:${String(s.tokens)}`,count:s.candidates.length,totalTokens:s.tokens,repeatedTokens:i,preview:AA(o.text),firstLabel:o.label,segments:s.candidates.map(OA)})}return n.sort((s,o)=>o.repeatedTokens-s.repeatedTokens||o.totalTokens-s.totalTokens)}function WA(e){if(e.length===0)return null;const t=e.length,n=e.reduce((o,i)=>o+i.count,0),s=e.reduce((o,i)=>o+i.repeatedTokens,0);return{kind:"duplicate",severity:s>=ol?"danger":"watch",title:"Duplicate context",detail:`${String(n)} repeated blocks across ${String(t)} group${t===1?"":"s"}, ~${String(s)} repeated tokens.`}}function ZA(e){return e.reduce((t,n)=>t+n.repeatedTokens,0)}function KA(e,t,n){const s=[],o=e.find(u=>u.role==="tools")??null;o!==null&&(o.tokens>=ol||o.percent>=mA&&o.tokens>=Dd)&&s.push({kind:"tool-schema",severity:o.tokens>=ol?"danger":"watch",title:"Large tool schema",detail:`Tool definitions take ${Math.round(o.percent*100)}% of request context.`});const i=e.find(u=>u.role==="system")??null;i!==null&&i.tokens>=Dd&&i.percent>=yA&&s.push({kind:"system-heavy",severity:"watch",title:"Large system prompt",detail:`System instructions take ${Math.round(i.percent*100)}% of request context.`});const a=e.filter(u=>u.role==="user"||u.role==="assistant"||u.role==="tool").reduce((u,d)=>u+d.tokens,0),l=t>0?a/t:0;return n>=xA&&(a>=bA||l>=vA)&&s.push({kind:"history-bloat",severity:l>=.85?"danger":"watch",title:"Conversation history growth",detail:`${String(n)} message blocks take ${Math.round(l*100)}% of request context.`}),s}function GA({risk:e,contextWindow:t,diagnostics:n,duplicateGroups:s}){let i=new Set(n.map(u=>u.kind)).size;(e==="watch"||e==="danger")&&(i+=1),t.source==="unknown"&&(i+=1);const a=n.some(u=>u.severity==="danger");return{level:e==="danger"||a?"risk":i>0?"optimizable":"ok",opportunityCount:i,reclaimableTokens:ZA(s)}}function JA({segments:e,inputTokens:t,parsed:n,model:s,providers:o=[]}){const i=e.reduce((S,C)=>S+C.size,0),a=s??CA(n),l=t??i,u=cg(n,kA),d=EA(a,n,o),p=u??0,f=d.tokens===null?null:l+p,m=d.tokens===null?null:d.tokens-l,h=d.tokens===null?null:d.tokens-l-p,g=d.tokens===null||f===null?null:RA(f/d.tokens),y=MA(e,i),b=y[0]??null,w=e.filter(S=>S.role!=="tools").length,v=HA(e),j=WA(v),_=KA(y,i,w);j!==null&&_.unshift(j);const k=PA(g);return{model:a,contextWindow:d,estimatedInputTokens:l,outputReserveTokens:u,windowUsedTokens:f,remainingInputTokens:m,remainingAfterReserveTokens:h,usagePercent:g,riskLevel:k,roleUsages:y,largestRole:b,diagnostics:_,duplicateGroups:v,health:GA({risk:k,contextWindow:d,diagnostics:_,duplicateGroups:v})}}const s6={watch:og,danger:ig},Ud=new WeakMap;function YA(e){return e.map(t=>{const n=t.modelMetadata?.map(s=>`${s.model}:${String(s.contextWindow??"")}`).join(",")??"";return`${t.id}:${t.updatedAt}:${t.models.join(",")}:${n}`}).join("|")}function XA(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function QA(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function eO(e,t){const n=XA(e.rawRequestBody);if(n===null)return null;const o=n0(ar(e)).anatomySegments(n);if(o===null)return null;const i=JA({segments:o,inputTokens:e.inputTokens??null,parsed:n,model:e.model,providers:t}),a=i.model??e.model??"Unknown model",l=i.roleUsages.map(QA);return{logId:e.id,model:a,timestamp:e.timestamp,contextWindow:i.contextWindow,estimatedInputTokens:i.estimatedInputTokens,windowUsedTokens:i.windowUsedTokens,usagePercent:i.usagePercent,riskLevel:i.riskLevel,health:i.health,diagnostics:i.diagnostics.map(u=>u.title),roleSegments:l,roleTotalTokens:l.reduce((u,d)=>u+d.size,0)}}function tO(e,t,n){const s=Ud.get(e);if(s!==void 0&&s.id===e.id&&s.rawRequestBody===e.rawRequestBody&&s.inputTokens===e.inputTokens&&s.model===e.model&&s.path===e.path&&s.apiFormat===e.apiFormat&&s.timestamp===e.timestamp&&s.providersSignature===n)return s.snapshot;const o=eO(e,t);return Ud.set(e,{id:e.id,rawRequestBody:e.rawRequestBody,inputTokens:e.inputTokens,model:e.model,path:e.path,apiFormat:e.apiFormat,timestamp:e.timestamp,providersSignature:n,snapshot:o}),o}function nO(e,t){return e.usagePercent!==null&&t.usagePercent!==null?e.usagePercent>t.usagePercent:e.usagePercent!==null&&t.usagePercent===null?!0:e.usagePercent===null&&t.usagePercent!==null?!1:e.estimatedInputTokens>t.estimatedInputTokens}function Bd(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function sO(e,t){const n=Bd(t.latest.riskLevel)-Bd(e.latest.riskLevel);if(n!==0)return n;const s=e.peak.usagePercent??-1,i=(t.peak.usagePercent??-1)-s;return i!==0?i:t.latest.logId-e.latest.logId}function rO(e,t){return e.usagePercent===null||t.usagePercent===null?null:(t.usagePercent-e.usagePercent)*100}function oO(e){for(let t=1;t<e.length;t++){const n=e[t-1],s=e[t];if(!(n===void 0||s===void 0)&&n.id>s.id)return[...e].sort((o,i)=>o.id-i.id)}return e}function iO(e,t=[]){const n=oO(e),s=YA(t),o=new Map;for(const a of n){const l=tO(a,t,s);if(l===null)continue;const u=o.get(l.model);if(u===void 0){o.set(l.model,{model:l.model,requestCount:1,first:l,latest:l,peak:l});continue}o.set(l.model,{model:u.model,requestCount:u.requestCount+1,first:u.first,latest:l,peak:nO(l,u.peak)?l:u.peak})}return{models:[...o.values()].map(a=>({model:a.model,requestCount:a.requestCount,first:a.first,latest:a.latest,peak:a.peak,trendPercent:rO(a.first,a.latest)})).sort(sO)}}function sn(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function aO(e){const t=new Map;for(const n of e)for(let s=0;s<n.logs.length;s+=1){const o=n.logs[s];o!==void 0&&t.set(o.id,s+1)}return t}function Vd(e,t){return t.get(e.id)??e.id}function qd(e){let t=0,n=0;for(const s of e)s.inputTokens!==null&&(t+=s.inputTokens),s.outputTokens!==null&&(n+=s.outputTokens);return{totalIn:t,totalOut:n}}function lO(e){for(const t of e)if(t.userAgent!==null&&t.userAgent!==void 0&&t.userAgent!=="")return t.userAgent;return null}function cO(e,t){const n=e[0],s=e[e.length-1];return n===void 0||s===void 0?null:Jo(n.timestamp,s.timestamp,t)}function uO(e){switch(e){case"cool":return"text-cyan-100";case"danger":return"text-red-100";case"watch":return"text-amber-100";case"neutral":return"text-foreground"}}function dO(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function pO(e){return e.pending>0?`${e.pending} pending / ${e.failures} failed`:e.lengthStops>0?`${e.lengthStops} output limit / ${e.failures} failed`:`${e.failures} failed / ${e.slow} slow`}function ps({label:e,value:t,detail:n,icon:s,tone:o="neutral"}){return r.jsxs("div",{className:"min-w-0 border-t border-white/10 px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[s,e]}),r.jsx("div",{className:$("mt-2 font-mono text-sm font-semibold",uO(o)),children:t}),r.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:n})]})}function fO({stats:e}){return e.requests===0?null:r.jsxs("div",{className:"border border-border bg-card shadow-sm mb-4 overflow-hidden rounded-[8px]",children:[r.jsx("div",{className:"px-4 py-3",children:r.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-semibold uppercase text-muted-foreground",children:[r.jsx(vw,{className:"size-3.5 text-slate-300"}),"Flight Recorder"]}),r.jsx("div",{className:"mt-2 min-w-0 font-mono text-sm font-semibold text-foreground",children:e.modelLabel})]}),r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"min-w-0 font-mono",children:e.providerLabel}),r.jsx("span",{className:"min-w-0 font-mono",children:e.timeRange??"Timeline pending"})]})]})}),r.jsxs("div",{className:"grid grid-cols-2 border-t border-white/10 md:grid-cols-3 2xl:grid-cols-6",children:[r.jsx(ps,{label:"Status",value:e.statusLabel,detail:pO(e),tone:dO(e.status)}),r.jsx(ps,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:r.jsx(Gw,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),r.jsx(ps,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:r.jsx(Sa,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),r.jsx(ps,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:r.jsx(s5,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),r.jsx(ps,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:r.jsx(Al,{className:"size-3 text-muted-foreground"})}),r.jsx(ps,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function Qs(e){if(e===null)return"Unknown";const t=e*100;return t>=10?`${t.toFixed(0)}%`:t>=1?`${t.toFixed(1)}%`:t>0?"<1%":"0%"}function mO(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function ll(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function hO(e,t){if(t===null)return null;const n=ll(e),s=ll(t);return s<=0||Math.abs(s-n)<.5?null:s}function gO(e){switch(e){case"danger":return"bg-red-400";case"watch":return"bg-amber-300";case"unknown":return"bg-muted-foreground/50";case"ok":return"bg-cyan-300"}}function xO(e){const t=e.latest.contextWindow.tokens;return t===null?"Context window unknown":`Context window ${np(t)}`}const bO=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function ug(e){return typeof e=="string"?e.length>0?e:null:typeof e=="number"||typeof e=="boolean"?String(e):e===null?null:JSON.stringify(e)}function ba(e,t){if(e===null)return null;const n=e.metadata[t];return n===void 0?null:ug(n)}function vO(e){const t=e.toLowerCase();return t.includes("reject")||t.includes("fail")||t.includes("error")?"border-red-400/35 bg-red-500/10 text-red-100":t.includes("partial")||t.includes("pending")||t.includes("slow")?"border-amber-300/35 bg-amber-400/10 text-amber-100":t.includes("pass")||t.includes("complete")||t.includes("accept")?"border-cyan-300/25 bg-cyan-400/10 text-cyan-100":"border-border/70 bg-background/70 text-muted-foreground"}function yO(e){const t=[];for(const n of bO){const s=e.metadata[n];if(s===void 0)continue;const o=ug(s);o!==null&&t.push({key:n,value:o})}return t}function Hd({memberships:e,defaultOpen:t=!1}){const[n,s]=c.useState(t);if(e.length===0)return null;const o=e[0],i=o?.member??null,a=ba(i,"score"),l=ba(i,"decision"),u=ba(i,"final_status"),d=[a===null?null:{label:`score ${a}`,value:a},l===null?null:{label:l,value:l},u===null?null:{label:u,value:u},i?.model===null||i?.model===void 0?null:{label:i.model,value:i.model}].filter(p=>p!==null&&p.label.length>0&&p.value.length>0);return r.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] text-xs",children:[r.jsxs("button",{type:"button",onClick:()=>s(p=>!p),className:"flex w-full items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-white/[0.04]","aria-expanded":n,children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:"font-semibold text-foreground",children:"Case File"}),o!==void 0&&r.jsx("span",{className:"truncate text-muted-foreground",title:o.groupTitle,children:o.groupTitle}),r.jsxs("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:[e.length," group",e.length===1?"":"s"]})]}),d.length>0&&r.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:d.slice(0,4).map(p=>r.jsx("span",{className:$("rounded border px-1.5 py-0.5 font-mono text-[10px]",vO(p.value)),children:p.label},p.label))})]}),n?r.jsx(Il,{className:"size-4 shrink-0 text-muted-foreground"}):r.jsx(nt,{className:"size-4 shrink-0 text-muted-foreground"})]}),n&&r.jsx("div",{className:"space-y-2 border-t border-white/10 px-3 py-2",children:e.map(p=>{const f=p.member,m=yO(f);return r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:"truncate font-medium text-foreground",title:p.groupTitle,children:p.groupTitle}),r.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:p.groupStatus}),f.status!==null&&r.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["member ",f.status]})]}),r.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[r.jsx("span",{className:"font-mono",title:f.sessionId,children:sn(f.sessionId)}),f.label!==null&&r.jsx("span",{children:f.label}),f.provider!==null&&r.jsx("span",{children:f.provider}),f.model!==null&&r.jsx("span",{className:"font-mono",children:f.model}),f.runId!==null&&r.jsxs("span",{className:"font-mono",title:f.runId,children:["run ",sn(f.runId)]})]}),m.length>0&&r.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:m.map(h=>r.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-1",children:[r.jsx("div",{className:"font-mono text-[10px] text-muted-foreground",children:h.key}),r.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:h.value,children:h.value})]},h.key))})]},`${p.groupId}:${f.id}`)})})]})}function Yr({label:e,title:t,icon:n,disabled:s,onClick:o}){return r.jsxs("button",{type:"button",onClick:o,disabled:s,className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45",title:t,children:[n,r.jsx("span",{children:e})]})}function Wd({logs:e,pagination:t,embedded:n=!1}){if(t===void 0)return null;const s=t.isLoading;return r.jsxs("nav",{"aria-label":"Session log pagination",className:$("flex min-h-9 flex-col gap-2 px-1 py-1 sm:flex-row sm:items-center",n?"border-t border-white/10 pt-2":"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-2"),children:[r.jsxs("div",{className:"w-full min-w-0 px-1 font-mono text-[11px] text-muted-foreground sm:flex-1",children:[r.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",children:[bR({logs:e,pagination:t}),t.isLoading&&e.length>0&&r.jsx("span",{className:"ml-2",children:"Loading..."})]}),t.loadProgress!==void 0&&r.jsx(lo,{progress:t.loadProgress})]}),r.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[r.jsx(Yr,{label:"Oldest",title:"Load the oldest logs in this session",icon:r.jsx(ow,{className:"size-3.5"}),disabled:s||!t.hasOlder,onClick:t.onOldest}),r.jsx(Yr,{label:"Older",title:"Load older logs",icon:r.jsx(Qy,{className:"size-3.5"}),disabled:s||!t.hasOlder,onClick:t.onOlder}),r.jsx(Yr,{label:"Newer",title:"Load newer logs",icon:r.jsx(yt,{className:"size-3.5"}),disabled:s||!t.hasNewer,onClick:t.onNewer}),r.jsx(Yr,{label:"Newest",title:"Load the newest logs in this session",icon:r.jsx(aw,{className:"size-3.5"}),disabled:s||!t.hasNewer,onClick:t.onNewest})]})]})}function wO(e){return`${e} ${e===1?"request":"requests"}`}function Zd(e){return`#${String(e)}`}function Kd(e){switch(e){case"danger":return"text-red-300";case"watch":return"text-amber-200";case"unknown":return"text-muted-foreground";case"ok":return"text-cyan-200"}}function jO(e){switch(e){case"risk":return"border-red-400/30 bg-red-500/10 text-red-100";case"optimizable":return"border-amber-400/25 bg-amber-400/8 text-amber-100";case"ok":return"border-cyan-300/25 bg-cyan-400/8 text-cyan-100"}}function kO(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const _O=10,SO=80;function NO(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function CO(e){const t=document.getElementById(`log-${String(e)}`);return t instanceof HTMLElement?(t.scrollIntoView({block:"center",behavior:Y0(X0())}),t.focus({preventScroll:!0}),NO(t),!0):!1}function dg(e){Is({logId:e,tab:"anatomy"});let t=0;const n=()=>{Is({logId:e,tab:"anatomy"}),!CO(e)&&(t+=1,t<_O&&window.setTimeout(n,SO))};window.setTimeout(n,0)}function Gd({command:e}){const[t,n]=c.useState(!1),s=c.useCallback(()=>{Pt(e).then(o=>{o&&(n(!0),setTimeout(()=>n(!1),2e3))})},[e]);return r.jsxs("div",{"data-command-example":"true",className:tR,children:[r.jsx("pre",{className:nR,children:e}),r.jsx("button",{type:"button",onClick:s,className:"shrink-0 cursor-pointer rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Copy command",children:t?r.jsx(Ge,{className:"size-4"}):r.jsx(Ot,{className:"size-4"})})]})}function Xr({label:e,children:t,className:n}){return r.jsxs("section",{className:$("bg-white/[0.028] shadow-[inset_0_1px_0_rgba(255,255,255,0.035)] rounded-[8px]",n),children:[r.jsx("div",{className:"px-3 pt-3",children:r.jsx("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-white/35",children:e})}),r.jsx("div",{className:"p-3 pt-2",children:t})]})}function Qr({label:e,value:t}){return r.jsxs("div",{className:"bg-black/20 min-w-0 rounded-md px-2 py-2 shadow-[inset_0_1px_0_rgba(255,255,255,0.035)]",children:[r.jsx("div",{className:"truncate font-mono text-lg font-semibold leading-6 text-slate-100",children:t}),r.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] uppercase tracking-[0.12em] text-white/35",children:e})]})}function TO(){const{themeMode:e,setThemeMode:t}=I5();return r.jsxs("div",{className:"border-border/70 bg-muted/70 inline-flex h-8 items-center rounded-md border p-0.5 shadow-sm","aria-label":"Theme mode",role:"group",children:[r.jsx("button",{type:"button",onClick:()=>t("light"),className:$("inline-flex size-7 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",e==="light"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use light mode","aria-pressed":e==="light",title:"Light mode",children:r.jsx(e5,{className:"size-3.5"})}),r.jsx("button",{type:"button",onClick:()=>t("eye-care"),className:$("inline-flex size-7 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",e==="eye-care"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use eye care mode","aria-pressed":e==="eye-care",title:"Eye care mode",children:r.jsx(pf,{className:"size-3.5"})}),r.jsx("button",{type:"button",onClick:()=>t("dark"),className:$("inline-flex size-7 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",e==="dark"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use dark mode","aria-pressed":e==="dark",title:"Dark mode",children:r.jsx(hj,{className:"size-3.5"})})]})}function EO({visible:e,onToggle:t}){const n=e?"Hide Inspector pet":"Summon Inspector pet";return r.jsx("button",{type:"button",onClick:t,className:$("border-border/70 bg-muted/70 inline-flex size-8 shrink-0 items-center justify-center rounded-md border text-muted-foreground shadow-sm transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",e&&"bg-background text-amber-500 shadow-sm"),"aria-label":n,"aria-pressed":e,title:n,children:r.jsx(sp,{className:$("size-4 transition-opacity",!e&&"opacity-45")})})}function RO({preference:e,resolvedScale:t,onChange:n}){const s=zg(t),o=e==="auto"?`Auto (${s})`:`${e}%`;return r.jsxs(Zn,{value:e,onValueChange:i=>n(Qd(i)),children:[r.jsxs(Kn,{size:"sm",className:"bg-white/[0.035] hover:bg-white/[0.065] h-8 min-w-[4rem] justify-center gap-1 border-0 px-2 py-0 text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] [&>svg:last-child]:hidden","aria-label":`Interface size: ${o}`,children:[r.jsx(Ey,{className:"size-3.5"}),r.jsx("span",{className:"font-mono text-[10px] font-semibold tabular-nums",children:s})]}),r.jsxs(Gn,{align:"end",children:[r.jsx(Qe,{value:"auto",children:"Auto"}),r.jsx(Qe,{value:"100",children:"100%"}),r.jsx(Qe,{value:"125",children:"125%"}),r.jsx(Qe,{value:"150",children:"150%"})]})]})}const pg="agent-inspector.detailsPanelCollapsed",fg="agent-inspector.pet.visible";function PO(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(pg);return e===null||e==="1"}function IO(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(fg)!=="0"}catch{return!0}}function Jd({label:e,logId:t}){return r.jsxs("button",{type:"button",onClick:()=>dg(t),className:"inline-flex h-5 items-center rounded px-1 font-mono text-[10px] text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",title:`Open Context for ${Zd(t)}`,children:[e," ",Zd(t)]})}function MO({latestPercent:e,peakPercent:t,risk:n,onOpenContext:s}){const o=ll(e),i=hO(e,t),a=t===null?`Latest context window usage ${Qs(e)}`:`Latest context window usage ${Qs(e)}, peak ${Qs(t)}`;return r.jsx("button",{type:"button",onClick:s,className:"group block w-full rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1","aria-label":`${a}. Open latest Context details`,title:"Open latest Context details",children:r.jsxs("span",{className:"relative block h-2.5 overflow-hidden rounded-full border border-white/10 bg-black/25 transition-colors group-hover:border-cyan-200/35",role:"meter","aria-label":a,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o),children:[r.jsx("span",{className:$("block h-full rounded-full transition-[width]",gO(n)),style:{width:`${o}%`}}),i!==null&&r.jsx("span",{className:"absolute top-0 h-full w-0.5 rounded-full bg-amber-100/75 shadow-[0_0_0_1px_rgba(0,0,0,0.25)]",style:{left:`calc(${i}% - 0.5px)`},"aria-hidden":"true"})]})})}function AO({summary:e}){const t=e.trendPercent,n=t===null||Math.abs(t)<.1?null:t>0?Dy:My,s=e.latest.diagnostics[0]??null,o=Qs(e.latest.usagePercent),i=Qs(e.peak.usagePercent),a=()=>{dg(e.latest.logId)};return r.jsxs("div",{className:"grid gap-x-4 gap-y-2 border-t border-white/10 py-2 first:border-t-0 lg:grid-cols-[minmax(180px,1fr)_minmax(260px,1fr)_minmax(260px,1.4fr)]",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("button",{type:"button",onClick:a,className:"min-w-0 truncate rounded-sm text-left font-mono font-semibold text-foreground transition-colors hover:text-cyan-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",title:`Open latest Context for ${e.model}`,children:e.model}),r.jsx("span",{className:$("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",jO(e.latest.health.level)),children:kO(e.latest.health.level)})]}),r.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[r.jsx("span",{children:wO(e.requestCount)}),r.jsx("span",{children:xO(e)})]})]}),r.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[r.jsx(MO,{latestPercent:e.latest.usagePercent,peakPercent:e.peak.usagePercent,risk:e.latest.riskLevel,onOpenContext:a}),r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Latest"}),r.jsx("div",{className:$("mt-0.5 font-mono",Kd(e.latest.riskLevel)),children:o}),r.jsx(Jd,{label:"Log",logId:e.latest.logId})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Peak"}),r.jsx("div",{className:$("mt-0.5 font-mono",Kd(e.peak.riskLevel)),children:i}),r.jsx(Jd,{label:"Log",logId:e.peak.logId})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Trend"}),r.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-foreground",children:[n!==null&&r.jsx(n,{className:$("size-3",t!==null&&t>0?"text-amber-300":"text-cyan-300")}),mO(t)]}),r.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),r.jsxs("div",{className:"min-w-0 space-y-1.5",children:[r.jsx(fA,{segments:e.latest.roleSegments,totalTokens:e.latest.roleTotalTokens,showLabels:!1}),r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[r.jsxs("span",{className:"font-mono",children:["~",Ie(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&r.jsxs("span",{className:"font-mono",children:["~",Ie(e.latest.windowUsedTokens)," used"]}),s!==null&&r.jsx("span",{className:"truncate",children:s})]})]})]})}function OO({summary:e}){return e.models.length===0?null:r.jsxs("div",{className:"mt-3 border-t border-white/10 pt-2",children:[r.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Session Context"}),r.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:[e.models.length," model",e.models.length===1?"":"s"]})]}),r.jsx("div",{className:"max-h-52 overflow-y-auto pr-1",children:e.models.map(t=>r.jsx(AO,{summary:t},t.model))})]})}function zO(e){const t=e.models.filter(s=>s.latest.health.level==="risk").length;if(t>0)return`${t} risk`;const n=e.models.filter(s=>s.latest.health.level==="optimizable").length;return n>0?`${n} optimizable`:`${e.models.length} model${e.models.length===1?"":"s"}`}function LO({label:e,logs:t,totalIn:n,totalOut:s,timeDisplayFormat:o,contextSummary:i,showBackLink:a}){const[l,u]=c.useState(!1),[d,p]=c.useState(!1),f=c.useMemo(()=>cO(t,o),[t,o]),m=c.useMemo(()=>lO(t),[t]),h=c.useMemo(()=>zO(i),[i]),g=c.useCallback(()=>{Pt(window.location.href).then(y=>{y&&(u(!0),setTimeout(()=>u(!1),2e3))})},[]);return r.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-3 py-2 text-xs",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a&&r.jsx("a",{href:"/",className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":"Back to all sessions",title:"Back to all sessions",children:r.jsx(Ly,{className:"size-3.5"})}),r.jsxs("div",{className:"min-w-[180px] flex-1",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"font-mono font-semibold text-purple-400/90 truncate",title:e,children:sn(e)}),m!==null&&r.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:m,children:m})]}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[r.jsxs("span",{children:[t.length," request",t.length!==1?"s":""]}),f!==null&&r.jsx("span",{children:f}),(n>0||s>0)&&r.jsxs("span",{className:"font-mono",children:[Ie(n)," in / ",Ie(s)," out"]})]})]}),i.models.length>0&&r.jsxs("button",{type:"button",onClick:()=>p(y=>!y),className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 font-mono text-[11px] text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-expanded":d,title:d?"Hide context details":"Show context details",children:[r.jsx("span",{children:h}),d?r.jsx(Il,{className:"size-3.5"}):r.jsx(nt,{className:"size-3.5"})]}),r.jsx("button",{type:"button",onClick:g,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":l?"Copied session link":"Copy session link",title:l?"Copied session link":"Copy session link",children:l?r.jsx(Ge,{className:"size-3.5"}):r.jsx(Ot,{className:"size-3.5"})})]}),d&&r.jsx(OO,{summary:i})]})}function $O({logs:e,sessions:t,models:n,selectedSession:s,selectedModel:o,onSessionChange:i,onModelChange:a,onClearAll:l,onDeleteCurrentView:u,onReloadSession:d,onClearGroup:p,onNotify:f,onImportLogs:m,viewMode:h,captureMode:g,strip:y,slowResponseThresholdSeconds:b,timeDisplayFormat:w,isLoading:v=!1,liveConnection:j,onRetryLiveConnection:_,onStopLiveConnection:k,pagination:S,sessionLoadProgress:C,sessionLoadError:M,sessionMemberships:A=[],hideSessionFilter:P=!1,pinnedSessionId:N}){const{totalIn:I,totalOut:F}=c.useMemo(()=>qd(e),[e]),{providers:B}=zl(),{uiScalePreference:J,resolvedUiScale:K,setUiScalePreference:W}=M5(),[V,z]=c.useState(null),[X,Y]=c.useState(null),[we,he]=c.useState(!1),[oe,D]=c.useState(!1),[Ne,te]=c.useState(null),[je,ke]=c.useState(null),[ue,le]=c.useState(!1),[xe,_e]=c.useState(!1),[ve,Ze]=c.useState(!0),[Be,Ke]=c.useState(!1),[dt,Lt]=c.useState(!0),[Ct,Ye]=c.useState(!1),[Me,Oe]=c.useState(null),q=c.useRef(null),ne=c.useRef(null),Ee=c.useRef(null),me=c.useRef(null),be=c.useRef(0);aA(q,ne,{pageWide:!0});const ze=c.useCallback(()=>{be.current+=1,me.current?.abort(),me.current=null,z(null),Y(null)},[]);c.useEffect(()=>()=>{be.current+=1,me.current?.abort(),me.current=null},[]),c.useEffect(()=>{Ze(PO()),Ke(!0)},[]),c.useEffect(()=>{Be&&window.localStorage.setItem(pg,ve?"1":"0")},[ve,Be]),c.useEffect(()=>{Lt(IO()),Ye(!0)},[]),c.useEffect(()=>{if(Ct)try{window.localStorage.setItem(fg,dt?"1":"0")}catch{}},[Ct,dt]),c.useEffect(()=>{if(N===void 0){document.title="Agent Inspector";return}const Re=e.length===1?"1 req":`${e.length} req`;document.title=`${sn(N)} - ${Re} - Agent Inspector`},[e.length,N]);const G=c.useCallback(async Re=>{me.current?.abort();const lt=new AbortController;me.current=lt;const Tt=be.current+1;be.current=Tt,z(Re),Y(null);try{const tn=await P5(e,Re,{signal:lt.signal});if(be.current!==Tt)return;if(!tn.ok){if(tn.canceled===!0)return;f!==void 0?f({message:tn.message,tone:"error"}):Y(tn.message)}}finally{be.current===Tt&&(me.current=null,z(null))}},[e,f]),E=c.useCallback(Re=>{if(rR(Re)){he(!0);return}G(Re)},[G]),L=c.useCallback(()=>{he(!1),G("redacted")},[G]),Z=c.useCallback(()=>{he(!1),G("raw")},[G]),ie=c.useCallback(()=>{Ee.current?.click()},[]),de=c.useCallback(Re=>{const lt=Re.currentTarget.files?.[0];Re.currentTarget.value="",!(lt===void 0||m===void 0)&&(D(!0),ke(null),te(null),m(lt).then(Tt=>{const tn=Tt.skipped>0?`, skipped ${String(Tt.skipped)}`:"",Rc=`Imported ${String(Tt.imported)} logs as ${Tt.sessionId}${tn}.`;f!==void 0?f({message:Rc,tone:"success"}):te(Rc)}).catch(Tt=>{const tn=Tt instanceof Error?Tt.message:"Failed to import logs";f!==void 0?f({message:tn,tone:"error"}):ke(tn)}).finally(()=>{D(!1)}))},[m,f]);c.useEffect(()=>{ze(),Oe(null)},[ze,s,o]);const se=c.useCallback(()=>{ze(),te(null),ke(null),Oe(null),l()},[ze,l]),ye=c.useCallback(()=>{le(!0)},[]),ce=c.useCallback(()=>{ze(),te(null),ke(null),Oe(null),u!==void 0&&(_e(!0),u().then(()=>{le(!1)}).catch(Re=>{const lt=Re instanceof Error?Re.message:"Failed to delete stored logs";f!==void 0?f({message:lt,tone:"error"}):ke(lt)}).finally(()=>{_e(!1)}))},[ze,u,f]),pt=c.useCallback(()=>{d!==void 0&&(ze(),te(null),ke(null),Oe(null),d())},[ze,d]),Mn=c.useCallback(()=>{Oe(null)},[]),Ae=c.useCallback(()=>{Ze(Re=>!Re)},[]),en=c.useCallback(()=>{Lt(Re=>!Re)},[]),Ve=c.useMemo(()=>lT(e),[e]),ts=c.useMemo(()=>aO(Ve),[Ve]),Xe=c.useMemo(()=>xR({pinnedSessionId:N,selectedSession:s,sessions:t,logs:e}),[e,N,s,t]),$t=Xe?.logs??[],Fs=Xe!==null&&$t.length>0,{totalIn:kc,totalOut:_c}=c.useMemo(()=>qd($t),[$t]),hg=c.useMemo(()=>iO($t,B),[$t,B]),gg=c.useMemo(()=>MM(Ve),[Ve]),Si=c.useMemo(()=>cE(Ve),[Ve]),Sc=oR(g,e.length),xg=N!==void 0,bg=e.length>0,vg=u!==void 0&&(e.length>0||s!=="__all__"),yg=s==="__all__"?"all sessions":"this session",wg=s==="__all__"?"Deletes every stored log, streaming chunk, and session archive entry across all sessions.":"Deletes every stored log, streaming chunk, and session archive entry for this session, including history that is not currently loaded.",jg=e.length===0?"Load":"Reload",Nc=s==="__all__"?"":s,Cc=s==="__all__"||t.includes(s)?s:"__typed__",Ni=Fs&&Xe!==null?sn(Xe.label):s==="__all__"?"All sessions":sn(s),Tc=DM(j),Ci=FM(Tc),kg=c.useMemo(()=>gR({logs:e,conversationGroups:Ve,isLoading:v,timeDisplayFormat:w,slowResponseThresholdSeconds:b}),[Ve,v,e,b,w]),_g=c.useCallback(Re=>{const lt=Si.get(Re.id);lt!==void 0&&Oe([lt,Re])},[Si]),Sg=c.useCallback(Re=>{const lt=Re.currentTarget.value.trim();i(lt===""?"__all__":lt)},[i]),Ng=c.useCallback(Re=>{Re!=="__typed__"&&i(Re)},[i]),Ec=N!==void 0?N:s==="__all__"?null:s;return r.jsxs("div",{className:"bg-background min-h-screen w-full overflow-x-clip text-foreground lg:h-screen lg:flex lg:flex-col lg:overflow-hidden",children:[r.jsx(zM,{liveConnection:j,alertsAction:r.jsx(ZR,{}),settingsAction:r.jsx(MI,{})}),r.jsxs("button",{type:"button",onClick:Ae,className:$("group fixed top-1/2 right-3 z-40 inline-flex h-14 w-7 -translate-y-1/2 items-center justify-center rounded-l-md border border-white/[0.08] bg-background/90 text-muted-foreground shadow-[0_12px_34px_rgba(0,0,0,0.26),inset_0_1px_0_rgba(255,255,255,0.06)] backdrop-blur transition-[right,background-color,color,border-color] duration-200 motion-reduce:transition-none hover:border-white/[0.16] hover:bg-white/[0.07] hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",ve?"right-3":"lg:right-[calc(21.25rem-0.875rem)] xl:right-[calc(22.5rem-0.875rem)]"),"aria-label":ve?"Show details panel":"Hide details panel",title:ve?"Show details panel":"Hide details panel",children:[r.jsx("span",{className:"absolute left-1 top-2 bottom-2 w-px rounded-full bg-white/[0.16] transition-colors group-hover:bg-white/[0.28]"}),ve?r.jsx(Cj,{className:"size-3.5"}):r.jsx(Sj,{className:"size-3.5"})]}),Ct&&dt&&r.jsx(co,{feature:"Inspector Pet",children:r.jsx(c.Suspense,{fallback:null,children:r.jsx(t4,{logs:e})})}),r.jsxs("div",{className:$("grid w-full min-w-0 grid-cols-1 lg:min-h-0 lg:flex-1 lg:overflow-hidden",ve?"lg:grid-cols-[minmax(0,1fr)]":"lg:grid-cols-[minmax(0,1fr)_21.25rem] xl:grid-cols-[minmax(0,1fr)_22.5rem]"),children:[!ve&&r.jsx("aside",{className:"bg-background/95 order-1 border-b border-white/[0.045] lg:order-2 lg:h-full lg:overflow-y-auto lg:border-b-0 lg:border-l lg:border-white/[0.055] inspector-scrollbar",children:r.jsxs("div",{className:"space-y-4 p-4",children:[r.jsx(Xr,{label:"Tools",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[r.jsx(TO,{}),r.jsx(RO,{preference:J,resolvedScale:K,onChange:W}),r.jsx(mP,{}),r.jsx(hM,{currentSessionId:Ec,logCount:e.length})]})}),r.jsxs(Xr,{label:"Session",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsx(Qr,{label:"Requests",value:e.length}),r.jsx(Qr,{label:"Sessions",value:t.length}),r.jsx(Qr,{label:"Input",value:Ie(Fs?kc:I)}),r.jsx(Qr,{label:"Output",value:Ie(Fs?_c:F)})]}),C!==void 0&&r.jsx("div",{className:"mt-2 rounded-md bg-black/20 px-2 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:r.jsx(lo,{progress:C})})]}),r.jsx(Xr,{label:"Workspace",children:r.jsxs("div",{className:"bg-black/20 rounded-md px-3 py-2 shadow-[inset_0_1px_0_rgba(255,255,255,0.035)]",children:[r.jsx("div",{className:"truncate font-mono text-xs font-semibold text-cyan-100",title:Ni,children:Ni}),r.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:xg?"Session workspace":"Live workspace"})]})}),r.jsx(IM,{currentSessionId:Ec,logCount:e.length}),Fs&&Xe!==null&&r.jsx(LO,{label:Xe.label,logs:$t,totalIn:kc,totalOut:_c,timeDisplayFormat:w,contextSummary:hg,showBackLink:Xe.showBackLink}),Fs&&N!==void 0&&A.length>0&&r.jsx(Hd,{memberships:A}),r.jsx(Xr,{label:"Filters",children:r.jsxs("div",{className:"space-y-2",children:[!P&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative",children:[r.jsx(yf,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),r.jsx("input",{type:"search",value:Nc,onChange:Sg,placeholder:"Paste session ID",className:"bg-black/25 hover:bg-white/[0.045] focus-visible:ring-ring h-9 w-full rounded-md px-8 font-mono text-xs text-foreground outline-none shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors placeholder:font-sans placeholder:text-muted-foreground focus-visible:ring-1","aria-label":"Filter by session ID",title:"Filter by exact session ID"}),Nc!==""&&r.jsx("button",{type:"button",onClick:()=>i("__all__"),className:"absolute right-1.5 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Clear session filter",title:"Clear session filter",children:r.jsx(gr,{className:"size-3.5"})})]}),r.jsxs(Zn,{value:Cc,onValueChange:Ng,children:[r.jsx(Kn,{"aria-label":"Select a session",className:"bg-black/25 hover:bg-white/[0.045] h-9 w-full border-0 text-xs text-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:r.jsx(Ms,{placeholder:"All sessions"})}),r.jsxs(Gn,{children:[r.jsx(Qe,{value:"__all__",children:"All sessions"}),Cc==="__typed__"&&r.jsxs(Qe,{value:"__typed__",children:["Typed: ",sn(s)]}),t.map(Re=>r.jsx(Qe,{value:Re,children:sn(Re)},Re))]})]})]}),r.jsxs(Zn,{value:o,onValueChange:a,children:[r.jsx(Kn,{"aria-label":"Select a model",className:"bg-black/25 hover:bg-white/[0.045] h-9 w-full border-0 text-xs text-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:r.jsx(Ms,{placeholder:"All models"})}),r.jsxs(Gn,{children:[r.jsx(Qe,{value:"__all__",children:"All models"}),n.map(Re=>r.jsx(Qe,{value:Re,children:Re},Re))]})]})]})})]})}),r.jsxs("main",{className:"order-2 min-w-0 lg:order-1 lg:h-full lg:overflow-y-auto inspector-scrollbar",children:[r.jsxs("div",{className:"bg-background/95 shadow-[0_12px_36px_rgba(0,0,0,0.18),inset_0_-1px_0_rgba(255,255,255,0.045)] sticky top-0 z-30 px-4 py-3 lg:px-5",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs("div",{className:"min-w-[180px] flex-1",children:[r.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Logs"}),r.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:Ni})]}),r.jsx(EO,{visible:dt,onToggle:en}),m!==void 0&&r.jsxs(r.Fragment,{children:[r.jsx("input",{ref:Ee,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:de}),r.jsx("button",{type:"button",onClick:ie,disabled:oe,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Import Agent Inspector export",children:oe?r.jsx("span",{children:"Importing..."}):r.jsxs(r.Fragment,{children:[r.jsx(wf,{className:"size-3.5"}),r.jsx("span",{children:"Import"})]})})]}),Sc.redacted&&r.jsx("button",{type:"button",onClick:()=>{E("redacted")},disabled:V!==null,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Export redacted logs as JSON ZIP",children:V==="redacted"?r.jsx("span",{children:"Exporting..."}):r.jsxs(r.Fragment,{children:[r.jsx(mr,{className:"size-3.5"}),r.jsx("span",{children:"Export"})]})}),Sc.raw&&r.jsx("button",{type:"button",onClick:()=>{E("raw")},disabled:V!==null,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Export raw logs without redaction",children:V==="raw"?r.jsx("span",{children:"Exporting..."}):r.jsxs(r.Fragment,{children:[r.jsx(Dw,{className:"size-3.5"}),r.jsx("span",{children:"Raw"})]})}),d!==void 0&&r.jsxs("button",{type:"button",onClick:pt,disabled:v,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Reload this session from stored logs",children:[r.jsx(Vt,{className:$("size-3.5",v&&"animate-spin motion-reduce:animate-none")}),r.jsx("span",{children:jg})]}),r.jsxs("button",{type:"button",onClick:se,disabled:!bg,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Clear the current view. Stored logs remain reloadable.",children:[r.jsx(jn,{className:"size-3.5"}),r.jsx("span",{children:"Clear"})]}),u!==void 0&&r.jsxs("button",{type:"button",onClick:ye,disabled:!vg||xe,className:"bg-red-500/[0.07] hover:bg-red-500/[0.12] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-red-200 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.14)] transition-colors hover:text-red-100 focus-visible:ring-1 focus-visible:ring-red-300 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Delete persisted history for the selected session.",children:[r.jsx(jn,{className:"size-3.5"}),r.jsx("span",{children:"Delete"})]})]}),S===void 0&&C!==void 0&&r.jsx("div",{className:"mt-2 rounded-md bg-black/20 px-2 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:r.jsx(lo,{progress:C})}),M!==void 0&&r.jsxs("div",{role:"alert",className:"mt-2 flex flex-wrap items-center gap-2 rounded-md border border-red-400/25 bg-red-500/10 px-3 py-2 text-xs text-red-100",children:[r.jsxs("span",{className:"min-w-0 flex-1",children:["Session logs could not be loaded. ",M," Existing logs remain visible."]}),d!==void 0&&r.jsxs("button",{type:"button",onClick:pt,className:"inline-flex h-7 items-center gap-1 rounded-md bg-black/15 px-2 font-medium transition-colors hover:bg-black/25 focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[r.jsx(Vt,{className:"size-3"}),"Retry"]})]}),r.jsx(Wd,{logs:e,pagination:S,embedded:!0}),f===void 0&&X!==null&&r.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:X}),f===void 0&&je!==null&&r.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:je}),f===void 0&&Ne!==null&&je===null&&r.jsx("div",{className:"mt-2 rounded-md border border-cyan-400/25 bg-cyan-500/10 px-3 py-2 text-xs text-cyan-100",children:Ne}),j!==void 0&&j.status!=="live"&&_!==void 0&&k!==void 0&&r.jsx(OM,{state:j,hasLogs:e.length>0,onRetry:_,onStop:k})]}),r.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[r.jsx(fO,{stats:kg}),e.length===0?s!=="__all__"?r.jsx("div",{className:"py-16 text-center text-muted-foreground",children:r.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-xl space-y-4 rounded-[8px] px-4 py-8",children:[r.jsx("p",{className:"text-sm font-medium",children:v?"Loading session data...":M===void 0?"No logs loaded for this session":"Session logs could not be loaded"}),r.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:sn(s)}),C!==void 0&&r.jsx("div",{className:"mx-auto max-w-md rounded-md bg-black/20 px-2 py-2 text-left shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:r.jsx(lo,{progress:C})}),A.length>0&&r.jsx("div",{className:"text-left",children:r.jsx(Hd,{memberships:A})}),!v&&r.jsxs("div",{className:"flex flex-col items-center gap-3 text-xs",children:[r.jsx("p",{children:"Stored logs may still be available."}),r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[d!==void 0&&r.jsxs("button",{type:"button",onClick:pt,className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[r.jsx(Vt,{className:"size-3.5"}),r.jsx("span",{children:"Load session"})]}),P?r.jsx("a",{href:"/",className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:"Back to all sessions"}):r.jsx("button",{type:"button",onClick:()=>i("__all__"),className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:"Show all sessions"})]})]})]})}):r.jsx("div",{className:"py-16 text-center text-muted-foreground",children:r.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-2xl space-y-4 rounded-[8px] px-4 py-8",children:[r.jsx("p",{className:"text-sm font-medium",children:Ci.title}),r.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:Ci.description}),Tc==="empty"&&t.length>0&&r.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Pick a session from the filter panel to load stored logs on demand."}),Ci.showConnectionCommands&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(Gd,{command:"ANTHROPIC_BASE_URL=http://localhost:9527/proxy <your-tool>"}),r.jsx(Gd,{command:"OPENAI_BASE_URL=http://localhost:9527/proxy <your-tool>"})]}),r.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Container note: if your AI tool runs in a different container or host than Agent Inspector, replace localhost with an address reachable from that tool and verify the network/firewall path."})]})]})}):r.jsxs("div",{ref:ne,tabIndex:0,"aria-label":"Captured logs",className:"flex flex-col gap-2 rounded-md focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none",children:[r.jsx("div",{ref:q,children:r.jsx(YM,{groups:Ve,viewMode:h,strip:y,slowResponseThresholdSeconds:b,cacheTrends:gg,onCompareWithPrevious:_g,comparisonPredecessors:Si,onClearGroup:p,defaultExpanded:Ve.length===1,timeDisplayFormat:w})}),r.jsx("div",{className:"mt-3",children:r.jsx(Wd,{logs:e,pagination:S})})]})]})]})]}),r.jsx(Zt,{open:we,onOpenChange:he,children:r.jsx(Kt,{className:eA,children:r.jsx(nA,{onCancel:()=>he(!1),onExportRedacted:L,onConfirmRaw:Z})})}),r.jsx(Zt,{open:ue,onOpenChange:le,children:r.jsxs(Kt,{className:"border-red-500/20 bg-zinc-950 text-zinc-100 sm:max-w-md",children:[r.jsxs(Xt,{children:[r.jsxs(Qt,{children:["Delete ",yg," history?"]}),r.jsx(wr,{children:"Clear only hides logs from the UI. Delete removes stored history from disk."})]}),r.jsxs("div",{className:"rounded-md bg-red-500/[0.08] px-3 py-3 text-sm text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:[r.jsx("span",{className:"block font-medium",children:"This is a full history delete."}),r.jsx("span",{className:"mt-1 block text-xs text-red-200/80",children:wg})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:xe,onClick:()=>le(!1),children:"Cancel"}),r.jsx(ee,{type:"button",variant:"destructive",size:"sm",disabled:xe,onClick:ce,children:xe?"Deleting...":"Delete history"})]})]})}),Me!==null&&r.jsx(co,{feature:"Compare",children:r.jsx(c.Suspense,{fallback:null,children:r.jsx(e4,{left:Me[0],right:Me[1],leftDisplayNumber:Vd(Me[0],ts),rightDisplayNumber:Vd(Me[1],ts),onClose:Mn})})})]})}function DO(e,t,n){return t==="__all__"&&n==="__all__"?e:e.filter(s=>!(t!=="__all__"&&s.sessionId!==t||n!=="__all__"&&s.model!==n))}function eo(e,t){if(e.length===0)return[...t];if(t.length===0)return[...e];const n=new Map;for(const s of e)n.set(s.id,s);for(const s of t)n.set(s.id,s);return[...n.values()].toSorted((s,o)=>s.id-o.id)}function Dn(e,t){const n=new Set;for(const s of e)s!==""&&n.add(s);for(const s of t)s!==""&&n.add(s);return[...n].sort()}const FO=At([T({type:ae("init"),logs:H(sr)}),T({type:ae("update"),log:sr})]),UO=T({logs:H(sr),total:R().int().nonnegative(),limit:R().int().positive(),hasOlder:Te(),hasNewer:Te(),oldestLogId:R().int().positive().nullable(),newestLogId:R().int().positive().nullable()}),BO=H(x()),Yd=T({success:Te(),cleared:R().int().nonnegative(),logFilesRewritten:R().int().nonnegative().optional(),chunkFilesDeleted:R().int().nonnegative(),sessionArchiveLogsDeleted:R().int().nonnegative().optional()});function VO(e,t){const n=[];for(const s of e)for(const o of s.members)o.sessionId===t&&n.push({groupId:s.id,groupTitle:s.title,groupKind:s.kind,groupStatus:s.status,groupTask:s.task,groupProject:s.project,groupEvidence:s.evidence,member:o});return n}function to(e){const t=new Set;for(const n of e)n.sessionId!==null&&n.sessionId!==""&&t.add(n.sessionId);return[...t]}function qO(e){const t=new Set;for(const n of e)n.model!==null&&n.model!==""&&t.add(n.model);return[...t]}const HO=100,WO=12,ZO=1800,jc=100,Uo=500,mg=200,cl=2e4,KO=1e4,GO=3e3,JO=1e4;function YO(e){const t=new URLSearchParams({compact:"1"});e!==void 0&&t.set("sessionId",e);const n=t.toString();return n.length>0?`/api/logs/stream?${n}`:"/api/logs/stream"}function XO(e,t,n=jc){const s=new URLSearchParams({cursor:"1",compact:"1",limit:String(n),sessionId:e});switch(t.kind){case"oldest":s.set("anchor","oldest");break;case"older":s.set("beforeLogId",String(t.beforeLogId));break;case"newer":s.set("afterLogId",String(t.afterLogId));break}return`/api/logs?${s.toString()}`}function hn(e){const t=new Map;for(let n=0;n<e.length;n++){const s=e[n];s!==void 0&&t.set(s.id,n)}return t}function er(e,t,n=jc){return qe(XO(e,t,n),UO,cl)}async function QO(e,t){const n=new Set;let s=await er(e,{kind:"oldest"},Uo);for(const i of s.logs)n.add(i.id);t(n.size,1);let o=1;for(;s.hasNewer&&s.newestLogId!==null&&o<mg;){s=await er(e,{kind:"newer",afterLogId:s.newestLogId},Uo);for(const i of s.logs)n.add(i.id);o+=1,t(n.size,o)}return{ids:[...n],truncated:s.hasNewer}}async function e6(){try{return{deleted:(await ot("/api/groups",nf,{method:"DELETE"})).deleted,ok:!0}}catch{return{deleted:0,ok:!1}}}function r6({initialSessionId:e}={}){const[t,n]=c.useState([]),[s,o]=c.useState(e??"__all__"),[i,a]=c.useState("__all__"),[l,u]=c.useState([]),{notice:d,showToast:p,dismissToast:f}=E0(),[m,h]=c.useState($M),[g,y]=c.useState(null),[b,w]=c.useState(e!==void 0),[v,j]=c.useState(null),[_,k]=c.useState(void 0),[S,C]=c.useState([]),[,M]=c.useTransition(),A=c.useRef(null),P=c.useRef(null),N=c.useRef(null),I=c.useRef(!0),F=c.useRef(null),B=c.useRef(0),J=c.useRef(null),K=c.useRef(null),W=c.useRef(new Map),V=c.useRef([]),z=c.useRef(null),X=c.useCallback(G=>{p({message:G,tone:"error"})},[p]),Y=c.useCallback(()=>{K.current!==null&&(clearInterval(K.current),K.current=null),J.current=null,k(void 0)},[]),we=c.useCallback((G,E,L=0,Z=0)=>{K.current!==null&&clearInterval(K.current);const ie=Date.now();J.current=ie;const de=()=>{B.current===E&&k({label:G,elapsedMs:Date.now()-ie,timeoutMs:cl,loadedLogs:L,loadedPages:Z})};de(),K.current=setInterval(de,250)},[]),he=c.useCallback((G,E,L,Z)=>{const ie=J.current;ie===null||B.current!==E||k({label:G,elapsedMs:Date.now()-ie,timeoutMs:cl,loadedLogs:L,loadedPages:Z})},[]),oe=c.useMemo(()=>DO(t,s,i),[t,s,i]),D=c.useMemo(()=>Dn(l,to(t)),[t,l]),Ne=c.useMemo(()=>qO(t),[t]),te=c.useCallback(()=>{ot("/api/sessions",BO).then(G=>{u(E=>Dn(E,G))}).catch(()=>{})},[]),je=c.useCallback(()=>{z.current=null;const G=V.current;V.current=[],G.length!==0&&M(()=>{n(E=>{const L=eo(E,G);return W.current=hn(L),L})})},[M]),ke=c.useCallback(G=>{V.current.push(G),z.current===null&&(z.current=setTimeout(je,HO))},[je]),ue=c.useCallback(()=>{A.current&&A.current.close(),P.current!==null&&(clearTimeout(P.current),P.current=null),h(E=>nn(E,{type:"connect-requested"}));const G=new EventSource(YO(e));A.current=G,G.onmessage=E=>{try{const L=String(E.data),Z=JSON.parse(L),ie=FO.safeParse(Z);if(!ie.success){h(se=>nn(se,{type:"recoverable-error",message:"The live stream returned invalid data."})),X("Failed to parse SSE data");return}const de=ie.data;de.type==="init"?(z.current!==null&&(clearTimeout(z.current),z.current=null),V.current=[],n(se=>{const ye=eo(se,de.logs);return W.current=hn(ye),ye}),u(se=>Dn(se,to(de.logs))),N.current!==null&&(clearTimeout(N.current),N.current=null),h(se=>nn(se,{type:"message-received",at:Date.now()})),f()):de.type==="update"&&(u(se=>de.log.sessionId===null||de.log.sessionId===""?se:Dn(se,[de.log.sessionId])),ke(de.log),N.current!==null&&(clearTimeout(N.current),N.current=null),h(se=>nn(se,{type:"message-received",at:Date.now()})))}catch{h(L=>nn(L,{type:"recoverable-error",message:"The live stream returned malformed JSON."})),X("Failed to parse SSE data")}},G.onerror=()=>{const E=navigator.onLine;h(L=>nn(L,{type:"connection-lost",online:E,message:"The live stream disconnected."})),G.close(),!(!E||!I.current)&&(N.current===null&&(N.current=setTimeout(()=>{N.current=null,h(L=>nn(L,{type:"stale-timeout"}))},JO)),P.current=setTimeout(ue,GO))}},[f,e,ke,X]),le=c.useCallback(()=>{I.current=!0,P.current!==null&&(clearTimeout(P.current),P.current=null),ue()},[ue]),xe=c.useCallback(()=>{I.current=!1,A.current?.close(),A.current=null,P.current!==null&&(clearTimeout(P.current),P.current=null),N.current!==null&&(clearTimeout(N.current),N.current=null),h(G=>nn(G,{type:"stop-retrying"}))},[]),_e=c.useCallback(G=>{if(e===void 0)return;const E=B.current+1;B.current=E,w(!0),j(null),we("Loading session logs",E),f(),er(e,G).then(L=>{if(B.current!==E)return;const Z=L.logs;W.current=hn(Z),n(Z),y(L),o(e),w(!1),j(null),Y(),f()}).catch(L=>{if(B.current!==E)return;w(!1),Y();const Z=L instanceof Error?L.message:"Failed to load session logs";j(Z),X(Z)})},[f,e,X,we,Y]),ve=c.useCallback(G=>{const E=B.current+1;B.current=E,w(!0),j(null),we("Reloading full session",E),f(),(async()=>{const L=[];let Z=await er(G,{kind:"oldest"},Uo);L.push(...Z.logs),he("Reloading full session",E,L.length,1);let ie=1;for(;Z.hasNewer&&Z.newestLogId!==null&&ie<mg;)Z=await er(G,{kind:"newer",afterLogId:Z.newestLogId},Uo),L.push(...Z.logs),ie+=1,he("Reloading full session",E,L.length,ie);B.current===E&&(n(de=>{const se=eo(de,L);return W.current=hn(se),se}),u(de=>Dn(de,[G])),w(!1),j(null),Y(),Z.hasNewer?p({message:`Loaded ${String(L.length)} logs for this session. More history is available.`,tone:"success"}):f())})().catch(L=>{if(B.current!==E)return;w(!1),Y();const Z=L instanceof Error?L.message:"Failed to reload session logs";j(Z),X(Z)})},[f,X,p,we,Y,he]);c.useEffect(()=>{if(e===void 0){C([]);return}let G=!1;return qe("/api/groups",of,KO).then(E=>E.groups).then(E=>{G||E===null||C(VO(E,e))}).catch(()=>{G||C([])}),()=>{G=!0}},[e]),c.useEffect(()=>{te()},[te]),c.useEffect(()=>()=>{Y()},[Y]),c.useEffect(()=>{e!==void 0&&_e({kind:"newest"})},[e,_e]),c.useEffect(()=>{e===void 0&&s!=="__all__"&&ve(s)},[e,ve,s]),c.useEffect(()=>{if(e!==void 0)return;ue();const G=()=>{A.current?.close(),A.current=null,P.current!==null&&(clearTimeout(P.current),P.current=null),N.current!==null&&(clearTimeout(N.current),N.current=null),h(L=>nn(L,{type:"browser-offline"}))},E=()=>{I.current&&ue()};return window.addEventListener("offline",G),window.addEventListener("online",E),()=>{window.removeEventListener("offline",G),window.removeEventListener("online",E),A.current&&(A.current.close(),A.current=null),P.current!==null&&(clearTimeout(P.current),P.current=null),N.current!==null&&(clearTimeout(N.current),N.current=null),z.current!==null&&(clearTimeout(z.current),z.current=null)}},[ue,e]),c.useEffect(()=>{const G=window.location.hash;if(!G.startsWith("#log-")||F.current===G)return;const E=G.slice(1),L=Number(E.replace(/^log-/,""));Number.isInteger(L)&&L>0&&Is({logId:L,tab:"request"});let Z=!1,ie=0,de=null,se=null;const ye=()=>{if(Z)return;const ce=document.getElementById(E);if(ce!==null){F.current=G,ce.scrollIntoView({block:"center",behavior:Y0(X0())}),ce instanceof HTMLElement&&(de=ce,ce.setAttribute("data-deep-link-highlight","true"),se=window.setTimeout(()=>{ce.removeAttribute("data-deep-link-highlight")},ZO),ce.focus({preventScroll:!0}),ce.getAttribute("data-nav-action")==="expand"&&ce.click());return}ie+=1,ie<WO&&window.setTimeout(ye,100)};return ye(),()=>{Z=!0,se!==null&&window.clearTimeout(se),de!==null&&de.removeAttribute("data-deep-link-highlight")}},[oe.length]);const Ze=c.useCallback(()=>{const G=to(t);Y(),w(!1),W.current.clear(),n([]),y(null),u(E=>Dn(E,G)),p({message:"Cleared the current view. Stored logs are still reloadable.",tone:"success"})},[t,p,Y]),Be=c.useCallback(G=>{if(G.length===0)return;const E=new Set(G);n(L=>{const Z=L.filter(de=>E.has(de.id)),ie=L.filter(de=>!E.has(de.id));return u(de=>Dn(de,to(Z))),W.current=hn(ie),ie}),p({message:"Cleared this group from the current view.",tone:"success"})},[p]),Ke=c.useCallback(async()=>{const G=B.current+1;B.current=G,w(!0),Y(),f();try{if(s==="__all__"){we("Deleting stored history",G);const se=await ot("/api/logs",Yd,{method:"DELETE"}),ye=await e6();if(B.current!==G)return;n([]),W.current.clear(),y(null),u([]),C([]),w(!1),Y();const ce=ye.ok?` Cleared ${ye.deleted.toString()} group${ye.deleted===1?"":"s"}.`:" Group cleanup failed; open Groups to retry Clear.";p({message:`Deleted ${se.cleared.toString()} stored log${se.cleared===1?"":"s"} across all sessions.${ce}`,tone:ye.ok?"success":"error"});return}const E=s;we("Deleting session history",G);const L=await QO(E,(se,ye)=>{he("Deleting session history",G,se,ye)}),Z=new Set(L.ids);for(const se of t)se.sessionId===E&&Z.add(se.id);const ie=[...Z].filter(se=>Number.isInteger(se)&&se>=0);if(ie.length===0){if(B.current!==G)return;n(se=>{const ye=se.filter(ce=>ce.sessionId!==E);return W.current=hn(ye),ye}),y(se=>se===null?null:{...se,logs:se.logs.filter(ye=>ye.sessionId!==E)}),u(se=>se.filter(ye=>ye!==E)),w(!1),Y(),p({message:"No stored log records were found for this session.",tone:"success"});return}const de=await ot("/api/logs",Yd,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({ids:ie})});if(B.current!==G)return;n(se=>{const ye=se.filter(ce=>ce.sessionId!==E);return W.current=hn(ye),ye}),y(se=>se===null?null:{...se,logs:se.logs.filter(ye=>ye.sessionId!==E)}),u(se=>se.filter(ye=>ye!==E)),w(!1),Y(),p({message:`Deleted ${de.cleared.toString()} stored log${de.cleared===1?"":"s"} for this session${L.truncated?". More history may remain.":"."}`,tone:L.truncated?"error":"success"})}finally{B.current===G&&(w(!1),Y())}},[t,f,s,p,we,Y,he]),dt=c.useCallback(()=>{if(e!==void 0){_e({kind:"newest"});return}if(s==="__all__"){te();return}ve(s)},[e,_e,te,ve,s]),Lt=c.useCallback(async G=>{const E=new FormData;E.set("file",G);const L=await ot("/api/logs/import",yy,{method:"POST",body:E});return n(Z=>{const ie=new Set(L.logs.map(se=>se.id)),de=eo(Z.filter(se=>!ie.has(se.id)),L.logs);return W.current=hn(de),de}),o(L.sessionId),a("__all__"),y(null),f(),L},[f]),{strip:Ct,captureMode:Ye,slowResponseThresholdSeconds:Me,timeDisplayFormat:Oe}=Rl(),q=Ye,ne=c.useCallback(()=>{_e({kind:"oldest"})},[_e]),Ee=c.useCallback(()=>{_e({kind:"newest"})},[_e]),me=c.useCallback(()=>{const G=t[0],E=g?.oldestLogId??G?.id??null;E!==null&&_e({kind:"older",beforeLogId:E})},[t,_e,g]),be=c.useCallback(()=>{const G=t[t.length-1],E=g?.newestLogId??G?.id??null;E!==null&&_e({kind:"newer",afterLogId:E})},[t,_e,g]),ze=c.useMemo(()=>{if(e!==void 0)return{isLoading:b,loadProgress:_,total:g?.total??null,pageSize:g?.limit??jc,hasOlder:g?.hasOlder??!1,hasNewer:g?.hasNewer??!1,oldestLogId:g?.oldestLogId??null,newestLogId:g?.newestLogId??null,onOldest:ne,onOlder:me,onNewer:be,onNewest:Ee}},[e,Ee,be,me,ne,g,_,b]);return r.jsxs(r.Fragment,{children:[r.jsx(R0,{notice:d,onDismiss:f}),r.jsx(b5,{}),r.jsx($O,{logs:oe,sessions:D,models:Ne,selectedSession:s,selectedModel:i,onSessionChange:o,onModelChange:a,onClearAll:Ze,onDeleteCurrentView:Ke,onReloadSession:e!==void 0||s!=="__all__"?dt:void 0,onClearGroup:Be,onNotify:p,onImportLogs:e===void 0?Lt:void 0,isLoading:e===void 0&&m.status==="connecting"&&m.lastSuccessAt===null||b,liveConnection:e===void 0?m:void 0,onRetryLiveConnection:le,onStopLiveConnection:xe,pagination:ze,sessionLoadProgress:_,sessionLoadError:v??void 0,sessionMemberships:S,viewMode:q,captureMode:Ye,strip:Ct,slowResponseThresholdSeconds:Me,timeDisplayFormat:Oe,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{Ja as $,Zo as A,Se as B,Cw as C,Zt as D,Te as E,x as F,sr as G,JA as H,oj as I,cA as J,lA as K,i4 as L,gf as M,s6 as N,nt as O,r6 as P,ge as Q,zj as R,fA as S,d0 as T,z4 as U,n6 as V,cf as W,gr as X,L4 as Y,$4 as Z,Xn as _,aT as a,Po as a0,SM as a1,gw as a2,rr as a3,Q as a4,wn as a5,Ue as a6,zp as a7,XT as a8,sw as a9,su as b,U as c,xf as d,yt as e,Ge as f,n0 as g,Ot as h,qe as i,Kt as j,Xt as k,Qt as l,vf as m,p0 as n,xn as o,jt as p,Ds as q,ar as r,ft as s,mt as t,zl as u,ht as v,T as w,R as x,H as y,Is as z};