@tonyclaw/agent-inspector 3.0.25 → 3.0.26

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 (37) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/{CompareDrawer-BnvOPwpe.js → CompareDrawer-SZRUDQc9.js} +1 -1
  3. package/.output/public/assets/ProxyViewerContainer-BJvwOrSi.js +4234 -0
  4. package/.output/public/assets/{ReplayDialog-BJgoQWdW.js → ReplayDialog-DgfmqiM3.js} +1 -1
  5. package/.output/public/assets/{RequestAnatomy-CpBZEHnM.js → RequestAnatomy-CS6c7Qfn.js} +1 -1
  6. package/.output/public/assets/{ResponseView-CWmyRb2M.js → ResponseView-C0Ri_5gm.js} +2 -2
  7. package/.output/public/assets/{StreamingChunkSequence-BWhC8bwx.js → StreamingChunkSequence-7dYcHWyZ.js} +1 -1
  8. package/.output/public/assets/{_sessionId-Cq-2OqUU.js → _sessionId-D-V84cgw.js} +1 -1
  9. package/.output/public/assets/{index-BKi9IRtV.js → index-CSIL7-MK.js} +3 -3
  10. package/.output/public/assets/index-CmeF5XXS.css +1 -0
  11. package/.output/public/assets/{index-Cf8O0Oos.js → index-DgFWCxOs.js} +1 -1
  12. package/.output/public/assets/{index-DdgTJ4QJ.js → index-DrVJsks2.js} +1 -1
  13. package/.output/public/assets/{json-viewer-Bqu_4hmm.js → json-viewer-C9Ji3gYN.js} +1 -1
  14. package/.output/server/_libs/three.mjs +26016 -0
  15. package/.output/server/{_sessionId-Ba7H3Gjw.mjs → _sessionId-BQ6YQOO1.mjs} +7 -6
  16. package/.output/server/_ssr/{CompareDrawer-aH59Ab6x.mjs → CompareDrawer-CqNzIeMR.mjs} +7 -6
  17. package/.output/server/_ssr/{ProxyViewerContainer-By-I0tJv.mjs → ProxyViewerContainer-CMC7Vsbw.mjs} +785 -311
  18. package/.output/server/_ssr/{ReplayDialog-BO4Vy0et.mjs → ReplayDialog-D9p_LaTr.mjs} +8 -7
  19. package/.output/server/_ssr/{RequestAnatomy-FtOr7vSS.mjs → RequestAnatomy-B4ge3qNZ.mjs} +7 -6
  20. package/.output/server/_ssr/{ResponseView-cvw6ajue.mjs → ResponseView-BCqMKApI.mjs} +7 -6
  21. package/.output/server/_ssr/{StreamingChunkSequence-Oc8S2kD6.mjs → StreamingChunkSequence-BA4zTLE4.mjs} +7 -6
  22. package/.output/server/_ssr/{index-BDRlQheR.mjs → index-CzxhDjlq.mjs} +7 -6
  23. package/.output/server/_ssr/index.mjs +2 -2
  24. package/.output/server/_ssr/{json-viewer-Cd6trhQr.mjs → json-viewer-B3qV6iEJ.mjs} +7 -6
  25. package/.output/server/_ssr/{router-bofP-Ekl.mjs → router-CZe_R31M.mjs} +4 -4
  26. package/.output/server/{_tanstack-start-manifest_v-BPuf86qB.mjs → _tanstack-start-manifest_v-B50VTLrH.mjs} +1 -1
  27. package/.output/server/index.mjs +68 -68
  28. package/package.json +3 -1
  29. package/src/components/inspector-pet/InspectorPet.tsx +66 -51
  30. package/src/components/inspector-pet/InspectorPetCrab3D.tsx +455 -0
  31. package/src/components/inspector-pet/inspectorPetLogic.ts +28 -43
  32. package/src/components/providers/ProviderForm.tsx +238 -163
  33. package/src/components/providers/ProvidersPanel.tsx +16 -6
  34. package/src/components/providers/providerFormCapabilities.ts +36 -0
  35. package/styles/globals.css +0 -61
  36. package/.output/public/assets/ProxyViewerContainer-DcqFqo1m.js +0 -127
  37. package/.output/public/assets/index-BMYuDL5X.css +0 -1
@@ -1,127 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CompareDrawer-BnvOPwpe.js","assets/index-BKi9IRtV.js","assets/ReplayDialog-BJgoQWdW.js","assets/ResponseView-CWmyRb2M.js","assets/RequestAnatomy-CpBZEHnM.js","assets/StreamingChunkSequence-BWhC8bwx.js","assets/json-viewer-Bqu_4hmm.js"])))=>i.map(i=>d[i]);
2
- import{u as qt,a as wf,r as p,j as r,c as Pr,g as qg,b as Zg,d as Di,p as Gg,T as Kg,n as Jg,e as Yg,f as Xg,h as $i,U as Qg,i as _f,k as Qo,l as Ds,m as ts,o as kf,_ as ns,q as ex}from"./index-BKi9IRtV.js";var Gc;function ne(e,t,n){function s(l,c){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,c);const u=a.prototype,d=Object.keys(u);for(let f=0;f<d.length;f++){const m=d[f];m in l||(l[m]=u[m].bind(l))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(l){var c;const u=n?.Parent?new i:this;s(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}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 ws extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class jf extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Gc=globalThis).__zod_globalConfig??(Gc.__zod_globalConfig={});const jl=globalThis.__zod_globalConfig;function nn(e){return jl}function Sf(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 Ea(e,t){return typeof t=="bigint"?t.toString():t}function ei(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Sl(e){return e==null}function Cl(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function tx(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 Kc=Symbol("evaluating");function Me(e,t,n){let s;Object.defineProperty(e,t,{get(){if(s!==Kc)return s===void 0&&(s=Kc,s=n()),s},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function ss(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Cn(...e){const t={};for(const n of e){const s=Object.getOwnPropertyDescriptors(n);Object.assign(t,s)}return Object.defineProperties({},t)}function Jc(e){return JSON.stringify(e)}function nx(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Cf="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ir(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const sx=ei(()=>{if(jl.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Ts(e){if(ir(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ir(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Nf(e){return Ts(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const rx=new Set(["string","number","symbol"]);function Es(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Nn(e,t,n){const s=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(s._zod.parent=e),s}function Se(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 ox(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const ix={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 ax(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=Cn(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 ss(this,"shape",a),a},checks:[]});return Nn(e,i)}function lx(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=Cn(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 ss(this,"shape",a),a},checks:[]});return Nn(e,i)}function cx(e,t){if(!Ts(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=Cn(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return ss(this,"shape",i),i}});return Nn(e,o)}function ux(e,t){if(!Ts(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Cn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return ss(this,"shape",s),s}});return Nn(e,n)}function dx(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=Cn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return ss(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Nn(e,n)}function fx(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=Cn(t._zod.def,{get shape(){const l=t._zod.def.shape,c={...l};if(n)for(const u in n){if(!(u in l))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=e?new e({type:"optional",innerType:l[u]}):l[u])}else for(const u in l)c[u]=e?new e({type:"optional",innerType:l[u]}):l[u];return ss(this,"shape",c),c},checks:[]});return Nn(t,a)}function px(e,t,n){const s=Cn(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 ss(this,"shape",i),i}});return Nn(t,s)}function bs(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 hx(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 vs(e,t){return t.map(n=>{var s;return(s=n).path??(s.path=[]),n.path.unshift(e),n})}function zr(e){return typeof e=="string"?e:e?.message}function sn(e,t,n){const s=e.message?e.message:zr(e.inst?._zod.def?.error?.(e))??zr(t?.error?.(e))??zr(n.customError?.(e))??zr(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 Nl(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ar(...e){const[t,n,s]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:s}:{...t}}const Tf=(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,Ea,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ef=ne("$ZodError",Tf),Af=ne("$ZodError",Tf,{Parent:Error});function mx(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 gx(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 c=n,u=0;for(;u<l.length;){const d=l[u];u===l.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(a))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}}};return s(e),n}const Tl=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 ws;if(a.issues.length){const l=new(o?.Err??e)(a.issues.map(c=>sn(c,i,nn())));throw Cf(l,o?.callee),l}return a.value},El=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(c=>sn(c,i,nn())));throw Cf(l,o?.callee),l}return a.value},ti=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 ws;return i.issues.length?{success:!1,error:new(e??Ef)(i.issues.map(a=>sn(a,o,nn())))}:{success:!0,data:i.value}},xx=ti(Af),ni=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=>sn(a,o,nn())))}:{success:!0,data:i.value}},bx=ni(Af),vx=e=>(t,n,s)=>{const o=s?{...s,direction:"backward"}:{direction:"backward"};return Tl(e)(t,n,o)},yx=e=>(t,n,s)=>Tl(e)(t,n,s),wx=e=>async(t,n,s)=>{const o=s?{...s,direction:"backward"}:{direction:"backward"};return El(e)(t,n,o)},_x=e=>async(t,n,s)=>El(e)(t,n,s),kx=e=>(t,n,s)=>{const o=s?{...s,direction:"backward"}:{direction:"backward"};return ti(e)(t,n,o)},jx=e=>(t,n,s)=>ti(e)(t,n,s),Sx=e=>async(t,n,s)=>{const o=s?{...s,direction:"backward"}:{direction:"backward"};return ni(e)(t,n,o)},Cx=e=>async(t,n,s)=>ni(e)(t,n,s),Nx=/^[cC][0-9a-z]{6,}$/,Tx=/^[0-9a-z]+$/,Ex=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ax=/^[0-9a-vA-V]{20}$/,Rx=/^[A-Za-z0-9]{27}$/,Ix=/^[a-zA-Z0-9_-]{21}$/,Px=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,zx=/^([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})$/,Yc=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)$/,Mx=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ox="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Lx(){return new RegExp(Ox,"u")}const Dx=/^(?:(?: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])$/,$x=/^(([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}|:))$/,Fx=/^((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])$/,Ux=/^(([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])$/,Bx=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Rf=/^[A-Za-z0-9_-]*$/,Wx=/^https?$/,Hx=/^\+[1-9]\d{6,14}$/,If="(?:(?:\\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])))",Vx=new RegExp(`^${If}$`);function Pf(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 qx(e){return new RegExp(`^${Pf(e)}$`)}function Zx(e){const t=Pf({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(`^${If}T(?:${s})$`)}const Gx=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Kx=/^-?\d+$/,zf=/^-?\d+(?:\.\d+)?$/,Jx=/^(?:true|false)$/i,Yx=/^null$/i,Xx=/^[^A-Z]*$/,Qx=/^[^a-z]*$/,gt=ne("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Mf={number:"number",bigint:"bigint",object:"date"},Of=ne("$ZodCheckLessThan",(e,t)=>{gt.init(e,t);const n=Mf[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})}}),Lf=ne("$ZodCheckGreaterThan",(e,t)=>{gt.init(e,t);const n=Mf[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})}}),e1=ne("$ZodCheckMultipleOf",(e,t)=>{gt.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):tx(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})}}),t1=ne("$ZodCheckNumberFormat",(e,t)=>{gt.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),s=n?"int":"number",[o,i]=ix[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=Kx)}),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})}}),n1=ne("$ZodCheckMaxLength",(e,t)=>{var n;gt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!Sl(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=Nl(o);s.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),s1=ne("$ZodCheckMinLength",(e,t)=>{var n;gt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!Sl(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=Nl(o);s.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),r1=ne("$ZodCheckLengthEquals",(e,t)=>{var n;gt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!Sl(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=Nl(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})}}),si=ne("$ZodCheckStringFormat",(e,t)=>{var n,s;gt.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=()=>{})}),o1=ne("$ZodCheckRegex",(e,t)=>{si.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})}}),i1=ne("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Xx),si.init(e,t)}),a1=ne("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Qx),si.init(e,t)}),l1=ne("$ZodCheckIncludes",(e,t)=>{gt.init(e,t);const n=Es(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})}}),c1=ne("$ZodCheckStartsWith",(e,t)=>{gt.init(e,t);const n=new RegExp(`^${Es(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})}}),u1=ne("$ZodCheckEndsWith",(e,t)=>{gt.init(e,t);const n=new RegExp(`.*${Es(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})}}),d1=ne("$ZodCheckOverwrite",(e,t)=>{gt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class f1{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
- `).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 p1={major:4,minor:4,patch:3},Be=ne("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=p1;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,c)=>{let u=bs(a),d;for(const f of l){if(f._zod.def.when){if(hx(a)||!f._zod.def.when(a))continue}else if(u)continue;const m=a.issues.length,h=f._zod.check(a);if(h instanceof Promise&&c?.async===!1)throw new ws;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,a.issues.length!==m&&(u||(u=bs(a,m)))});else{if(a.issues.length===m)continue;u||(u=bs(a,m))}}return d?d.then(()=>a):a},i=(a,l,c)=>{if(bs(a))return a.aborted=!0,a;const u=o(l,s,c);if(u instanceof Promise){if(c.async===!1)throw new ws;return u.then(d=>e._zod.parse(d,c))}return e._zod.parse(u,c)};e._zod.run=(a,l)=>{if(l.skipChecks)return e._zod.parse(a,l);if(l.direction==="backward"){const u=e._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return u instanceof Promise?u.then(d=>i(d,a,l)):i(u,a,l)}const c=e._zod.parse(a,l);if(c instanceof Promise){if(l.async===!1)throw new ws;return c.then(u=>o(u,s,l))}return o(c,s,l)}}Me(e,"~standard",()=>({validate:o=>{try{const i=xx(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return bx(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Al=ne("$ZodString",(e,t)=>{Be.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Gx(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}}),He=ne("$ZodStringFormat",(e,t)=>{si.init(e,t),Al.init(e,t)}),h1=ne("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=zx),He.init(e,t)}),m1=ne("$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=Yc(s))}else t.pattern??(t.pattern=Yc());He.init(e,t)}),g1=ne("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Mx),He.init(e,t)}),x1=ne("$ZodURL",(e,t)=>{He.init(e,t),e._zod.check=n=>{try{const s=n.value.trim();if(!t.normalize&&t.protocol?.source===Wx.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})}}}),b1=ne("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Lx()),He.init(e,t)}),v1=ne("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ix),He.init(e,t)}),y1=ne("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Nx),He.init(e,t)}),w1=ne("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Tx),He.init(e,t)}),_1=ne("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ex),He.init(e,t)}),k1=ne("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ax),He.init(e,t)}),j1=ne("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Rx),He.init(e,t)}),S1=ne("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Zx(t)),He.init(e,t)}),C1=ne("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Vx),He.init(e,t)}),N1=ne("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=qx(t)),He.init(e,t)}),T1=ne("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Px),He.init(e,t)}),E1=ne("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Dx),He.init(e,t),e._zod.bag.format="ipv4"}),A1=ne("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=$x),He.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})}}}),R1=ne("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Fx),He.init(e,t)}),I1=ne("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ux),He.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 Df(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const P1=ne("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Bx),He.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Df(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function z1(e){if(!Rf.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Df(n)}const M1=ne("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Rf),He.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{z1(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),O1=ne("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Hx),He.init(e,t)});function L1(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 D1=ne("$ZodJWT",(e,t)=>{He.init(e,t),e._zod.check=n=>{L1(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),$f=ne("$ZodNumber",(e,t)=>{Be.init(e,t),e._zod.pattern=e._zod.bag.pattern??zf,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}}),$1=ne("$ZodNumberFormat",(e,t)=>{t1.init(e,t),$f.init(e,t)}),F1=ne("$ZodBoolean",(e,t)=>{Be.init(e,t),e._zod.pattern=Jx,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}}),U1=ne("$ZodNull",(e,t)=>{Be.init(e,t),e._zod.pattern=Yx,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}}),B1=ne("$ZodUnknown",(e,t)=>{Be.init(e,t),e._zod.parse=n=>n}),W1=ne("$ZodNever",(e,t)=>{Be.init(e,t),e._zod.parse=(n,s)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Xc(e,t,n){e.issues.length&&t.issues.push(...vs(n,e.issues)),t.value[n]=e.value}const H1=ne("$ZodArray",(e,t)=>{Be.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],c=t.element._zod.run({value:l,issues:[]},s);c instanceof Promise?i.push(c.then(u=>Xc(u,n,a))):Xc(c,n,a)}return i.length?Promise.all(i).then(()=>n):n}});function _o(e,t,n,s,o,i){const a=n in s;if(e.issues.length){if(o&&i&&!a)return;t.issues.push(...vs(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 Ff(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=ox(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Uf(e,t,n,s,o,i){const a=[],l=o.keySet,c=o.catchall._zod,u=c.def.type,d=c.optin==="optional",f=c.optout==="optional";for(const m in t){if(m==="__proto__"||l.has(m))continue;if(u==="never"){a.push(m);continue}const h=c.run({value:t[m],issues:[]},s);h instanceof Promise?e.push(h.then(x=>_o(x,n,m,t,d,f))):_o(h,n,m,t,d,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 V1=ne("$ZodObject",(e,t)=>{if(Be.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...l};return Object.defineProperty(t,"shape",{value:c}),c}})}const s=ei(()=>Ff(t));Me(e._zod,"propValues",()=>{const l=t.shape,c={};for(const u in l){const d=l[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const f of d.values)c[u].add(f)}}return c});const o=ir,i=t.catchall;let a;e._zod.parse=(l,c)=>{a??(a=s.value);const u=l.value;if(!o(u))return l.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),l;l.value={};const d=[],f=a.shape;for(const m of a.keys){const h=f[m],x=h._zod.optin==="optional",g=h._zod.optout==="optional",b=h._zod.run({value:u[m],issues:[]},c);b instanceof Promise?d.push(b.then(v=>_o(v,l,m,u,x,g))):_o(b,l,m,u,x,g)}return i?Uf(d,u,l,c,s.value,e):d.length?Promise.all(d).then(()=>l):l}}),q1=ne("$ZodObjectJIT",(e,t)=>{V1.init(e,t);const n=e._zod.parse,s=ei(()=>Ff(t)),o=m=>{const h=new f1(["shape","payload","ctx"]),x=s.value,g=_=>{const j=Jc(_);return`shape[${j}]._zod.run({ value: input[${j}], issues: [] }, ctx)`};h.write("const input = payload.value;");const b=Object.create(null);let v=0;for(const _ of x.keys)b[_]=`key_${v++}`;h.write("const newResult = {};");for(const _ of x.keys){const j=b[_],S=Jc(_),E=m[_],T=E?._zod?.optin==="optional",R=E?._zod?.optout==="optional";h.write(`const ${j} = ${g(_)};`),T&&R?h.write(`
5
- if (${j}.issues.length) {
6
- if (${S} in input) {
7
- payload.issues = payload.issues.concat(${j}.issues.map(iss => ({
8
- ...iss,
9
- path: iss.path ? [${S}, ...iss.path] : [${S}]
10
- })));
11
- }
12
- }
13
-
14
- if (${j}.value === undefined) {
15
- if (${S} in input) {
16
- newResult[${S}] = undefined;
17
- }
18
- } else {
19
- newResult[${S}] = ${j}.value;
20
- }
21
-
22
- `):T?h.write(`
23
- if (${j}.issues.length) {
24
- payload.issues = payload.issues.concat(${j}.issues.map(iss => ({
25
- ...iss,
26
- path: iss.path ? [${S}, ...iss.path] : [${S}]
27
- })));
28
- }
29
-
30
- if (${j}.value === undefined) {
31
- if (${S} in input) {
32
- newResult[${S}] = undefined;
33
- }
34
- } else {
35
- newResult[${S}] = ${j}.value;
36
- }
37
-
38
- `):h.write(`
39
- const ${j}_present = ${S} in input;
40
- if (${j}.issues.length) {
41
- payload.issues = payload.issues.concat(${j}.issues.map(iss => ({
42
- ...iss,
43
- path: iss.path ? [${S}, ...iss.path] : [${S}]
44
- })));
45
- }
46
- if (!${j}_present && !${j}.issues.length) {
47
- payload.issues.push({
48
- code: "invalid_type",
49
- expected: "nonoptional",
50
- input: undefined,
51
- path: [${S}]
52
- });
53
- }
54
-
55
- if (${j}_present) {
56
- if (${j}.value === undefined) {
57
- newResult[${S}] = undefined;
58
- } else {
59
- newResult[${S}] = ${j}.value;
60
- }
61
- }
62
-
63
- `)}h.write("payload.value = newResult;"),h.write("return payload;");const y=h.compile();return(_,j)=>y(m,_,j)};let i;const a=ir,l=!jl.jitless,u=l&&sx.value,d=t.catchall;let f;e._zod.parse=(m,h)=>{f??(f=s.value);const x=m.value;return a(x)?l&&u&&h?.async===!1&&h.jitless!==!0?(i||(i=o(t.shape)),m=i(m,h),d?Uf([],x,m,h,f,e):m):n(m,h):(m.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),m)}});function Qc(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=>!bs(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=>sn(a,s,nn())))}),t)}const Bf=ne("$ZodUnion",(e,t)=>{Be.init(e,t),Me(e._zod,"optin",()=>t.options.some(s=>s._zod.optin==="optional")?"optional":void 0),Me(e._zod,"optout",()=>t.options.some(s=>s._zod.optout==="optional")?"optional":void 0),Me(e._zod,"values",()=>{if(t.options.every(s=>s._zod.values))return new Set(t.options.flatMap(s=>Array.from(s._zod.values)))}),Me(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=>Cl(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 c=l._zod.run({value:s.value,issues:[]},o);if(c instanceof Promise)a.push(c),i=!0;else{if(c.issues.length===0)return c;a.push(c)}}return i?Promise.all(a).then(l=>Qc(l,s,e,o)):Qc(a,s,e,o)}}),Z1=ne("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Bf.init(e,t);const n=e._zod.parse;Me(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,c]of Object.entries(a)){o[l]||(o[l]=new Set);for(const u of c)o[l].add(u)}}return o});const s=ei(()=>{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 c of l){if(i.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,a)}}return i});e._zod.parse=(o,i)=>{const a=o.value;if(!ir(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)}}),G1=ne("$ZodIntersection",(e,t)=>{Be.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(([c,u])=>eu(n,c,u)):eu(n,i,a)}});function Aa(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(Ts(e)&&Ts(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=Aa(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=Aa(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 eu(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 c of l.keys)s.has(c)||s.set(c,{}),s.get(c).l=!0}else e.issues.push(l);for(const l of n.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)s.has(c)||s.set(c,{}),s.get(c).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}),bs(e))return e;const a=Aa(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 K1=ne("$ZodRecord",(e,t)=>{Be.init(e,t),e._zod.parse=(n,s)=>{const o=n.value;if(!Ts(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 u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){l.add(typeof u=="number"?u.toString():u);const d=t.keyType._zod.run({value:u,issues:[]},s);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(h=>sn(h,s,nn())),input:u,path:[u],inst:e});continue}const f=d.value,m=t.valueType._zod.run({value:o[u],issues:[]},s);m instanceof Promise?i.push(m.then(h=>{h.issues.length&&n.issues.push(...vs(u,h.issues)),n.value[f]=h.value})):(m.issues.length&&n.issues.push(...vs(u,m.issues)),n.value[f]=m.value)}let c;for(const u in o)l.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const l of Reflect.ownKeys(o)){if(l==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,l))continue;let c=t.keyType._zod.run({value:l,issues:[]},s);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&zf.test(l)&&c.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&&(c=f)}if(c.issues.length){t.mode==="loose"?n.value[l]=o[l]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>sn(f,s,nn())),input:l,path:[l],inst:e});continue}const d=t.valueType._zod.run({value:o[l],issues:[]},s);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&n.issues.push(...vs(l,f.issues)),n.value[c.value]=f.value})):(d.issues.length&&n.issues.push(...vs(l,d.issues)),n.value[c.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),J1=ne("$ZodEnum",(e,t)=>{Be.init(e,t);const n=Sf(t.entries),s=new Set(n);e._zod.values=s,e._zod.pattern=new RegExp(`^(${n.filter(o=>rx.has(typeof o)).map(o=>typeof o=="string"?Es(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}}),Y1=ne("$ZodLiteral",(e,t)=>{if(Be.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"?Es(s):s?Es(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}}),X1=ne("$ZodTransform",(e,t)=>{Be.init(e,t),e._zod.optin="optional",e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new jf(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 ws;return n.value=o,n.fallback=!0,n}});function tu(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Wf=ne("$ZodOptional",(e,t)=>{Be.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Me(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Me(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Cl(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=>tu(a,o)):tu(i,o)}return n.value===void 0?n:t.innerType._zod.run(n,s)}}),Q1=ne("$ZodExactOptional",(e,t)=>{Wf.init(e,t),Me(e._zod,"values",()=>t.innerType._zod.values),Me(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,s)=>t.innerType._zod.run(n,s)}),eb=ne("$ZodNullable",(e,t)=>{Be.init(e,t),Me(e._zod,"optin",()=>t.innerType._zod.optin),Me(e._zod,"optout",()=>t.innerType._zod.optout),Me(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Cl(n.source)}|null)$`):void 0}),Me(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)}),tb=ne("$ZodDefault",(e,t)=>{Be.init(e,t),e._zod.optin="optional",Me(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=>nu(i,t)):nu(o,t)}});function nu(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const nb=ne("$ZodPrefault",(e,t)=>{Be.init(e,t),e._zod.optin="optional",Me(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))}),sb=ne("$ZodNonOptional",(e,t)=>{Be.init(e,t),Me(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=>su(i,e)):su(o,e)}});function su(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 rb=ne("$ZodCatch",(e,t)=>{Be.init(e,t),e._zod.optin="optional",Me(e._zod,"optout",()=>t.innerType._zod.optout),Me(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=>sn(a,s,nn()))},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=>sn(i,s,nn()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),ob=ne("$ZodPipe",(e,t)=>{Be.init(e,t),Me(e._zod,"values",()=>t.in._zod.values),Me(e._zod,"optin",()=>t.in._zod.optin),Me(e._zod,"optout",()=>t.out._zod.optout),Me(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=>Mr(a,t.in,s)):Mr(i,t.in,s)}const o=t.in._zod.run(n,s);return o instanceof Promise?o.then(i=>Mr(i,t.out,s)):Mr(o,t.out,s)}});function Mr(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 ib=ne("$ZodReadonly",(e,t)=>{Be.init(e,t),Me(e._zod,"propValues",()=>t.innerType._zod.propValues),Me(e._zod,"values",()=>t.innerType._zod.values),Me(e._zod,"optin",()=>t.innerType?._zod?.optin),Me(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(ru):ru(o)}});function ru(e){return e.value=Object.freeze(e.value),e}const ab=ne("$ZodLazy",(e,t)=>{Be.init(e,t),Me(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),Me(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),Me(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),Me(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),Me(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,s)=>e._zod.innerType._zod.run(n,s)}),lb=ne("$ZodCustom",(e,t)=>{gt.init(e,t),Be.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=>ou(i,n,s,e));ou(o,n,s,e)}});function ou(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(ar(o))}}var iu;class cb{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 ub(){return new cb}(iu=globalThis).__zod_globalRegistry??(iu.__zod_globalRegistry=ub());const er=globalThis.__zod_globalRegistry;function db(e,t){return new e({type:"string",...Se(t)})}function fb(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Se(t)})}function au(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Se(t)})}function pb(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Se(t)})}function hb(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Se(t)})}function mb(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Se(t)})}function gb(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Se(t)})}function xb(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Se(t)})}function bb(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Se(t)})}function vb(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Se(t)})}function yb(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Se(t)})}function wb(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Se(t)})}function _b(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Se(t)})}function kb(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Se(t)})}function jb(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Se(t)})}function Sb(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Se(t)})}function Cb(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Se(t)})}function Nb(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Se(t)})}function Tb(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Se(t)})}function Eb(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Se(t)})}function Ab(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Se(t)})}function Rb(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Se(t)})}function Ib(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Se(t)})}function Pb(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Se(t)})}function zb(e,t){return new e({type:"string",format:"date",check:"string_format",...Se(t)})}function Mb(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Se(t)})}function Ob(e,t){return new e({type:"string",format:"duration",check:"string_format",...Se(t)})}function Lb(e,t){return new e({type:"number",checks:[],...Se(t)})}function Db(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Se(t)})}function $b(e,t){return new e({type:"boolean",...Se(t)})}function Fb(e,t){return new e({type:"null",...Se(t)})}function Ub(e){return new e({type:"unknown"})}function Bb(e,t){return new e({type:"never",...Se(t)})}function lu(e,t){return new Of({check:"less_than",...Se(t),value:e,inclusive:!1})}function Fi(e,t){return new Of({check:"less_than",...Se(t),value:e,inclusive:!0})}function cu(e,t){return new Lf({check:"greater_than",...Se(t),value:e,inclusive:!1})}function Ui(e,t){return new Lf({check:"greater_than",...Se(t),value:e,inclusive:!0})}function uu(e,t){return new e1({check:"multiple_of",...Se(t),value:e})}function Hf(e,t){return new n1({check:"max_length",...Se(t),maximum:e})}function ko(e,t){return new s1({check:"min_length",...Se(t),minimum:e})}function Vf(e,t){return new r1({check:"length_equals",...Se(t),length:e})}function Wb(e,t){return new o1({check:"string_format",format:"regex",...Se(t),pattern:e})}function Hb(e){return new i1({check:"string_format",format:"lowercase",...Se(e)})}function Vb(e){return new a1({check:"string_format",format:"uppercase",...Se(e)})}function qb(e,t){return new l1({check:"string_format",format:"includes",...Se(t),includes:e})}function Zb(e,t){return new c1({check:"string_format",format:"starts_with",...Se(t),prefix:e})}function Gb(e,t){return new u1({check:"string_format",format:"ends_with",...Se(t),suffix:e})}function $s(e){return new d1({check:"overwrite",tx:e})}function Kb(e){return $s(t=>t.normalize(e))}function Jb(){return $s(e=>e.trim())}function Yb(){return $s(e=>e.toLowerCase())}function Xb(){return $s(e=>e.toUpperCase())}function Qb(){return $s(e=>nx(e))}function ev(e,t,n){return new e({type:"array",element:t,...Se(n)})}function tv(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Se(n)})}function nv(e,t){const n=sv(s=>(s.addIssue=o=>{if(typeof o=="string")s.issues.push(ar(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(ar(i))}},e(s.value,s)),t);return n}function sv(e,t){const n=new gt({check:"custom",...Se(t)});return n._zod.check=e,n}function qf(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??er,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Ge(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 d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,d);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,d)}const f=e._zod.parent;f&&(a.ref||(a.ref=f),Ge(f,t,d),t.seen.get(f).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),t.io==="input"&&ct(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 Zf(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 c=s.get(l);if(c&&c!==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??(x=>x);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 u=`#/${l}/`,d=a[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},i=a=>{if(a[1].schema.$ref)return;const l=a[1],{ref:c,defId:u}=o(a);l.def={...l.schema},u&&(l.defId=u);const d=l.schema;for(const f in d)delete d[f];d.$ref=c};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
-
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 u=e.external.registry.get(a[0])?.id;if(t!==a[0]&&u){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 Gf(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 c=e.seen.get(l);if(c.ref===null)return;const u=c.def??c.schema,d={...u},f=c.ref;if(c.ref=null,f){s(f);const h=e.seen.get(f),x=h.schema;if(x.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(x)):Object.assign(u,x),Object.assign(u,d),l._zod.parent===f)for(const b in u)b==="$ref"||b==="allOf"||b in d||delete u[b];if(x.$ref&&h.def)for(const b in u)b==="$ref"||b==="allOf"||b in h.def&&JSON.stringify(u[b])===JSON.stringify(h.def[b])&&delete u[b]}const m=l._zod.parent;if(m&&m!==f){s(m);const h=e.seen.get(m);if(h?.schema.$ref&&(u.$ref=h.schema.$ref,h.def))for(const x in u)x==="$ref"||x==="allOf"||x in h.def&&JSON.stringify(u[x])===JSON.stringify(h.def[x])&&delete u[x]}e.override({zodSchema:l,jsonSchema:u,path:c.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 c=l[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,a[c.defId]=c.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:jo(t,"input",e.processors),output:jo(t,"output",e.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function ct(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 ct(s.element,n);if(s.type==="set")return ct(s.valueType,n);if(s.type==="lazy")return ct(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 ct(s.innerType,n);if(s.type==="intersection")return ct(s.left,n)||ct(s.right,n);if(s.type==="record"||s.type==="map")return ct(s.keyType,n)||ct(s.valueType,n);if(s.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ct(s.in,n)||ct(s.out,n);if(s.type==="object"){for(const o in s.shape)if(ct(s.shape[o],n))return!0;return!1}if(s.type==="union"){for(const o of s.options)if(ct(o,n))return!0;return!1}if(s.type==="tuple"){for(const o of s.items)if(ct(o,n))return!0;return!!(s.rest&&ct(s.rest,n))}return!1}const rv=(e,t={})=>n=>{const s=qf({...n,processors:t});return Ge(e,s),Zf(s,e),Gf(s,e)},jo=(e,t,n={})=>s=>{const{libraryOptions:o,target:i}=s??{},a=qf({...o??{},target:i,io:t,processors:n});return Ge(e,a),Zf(a,e),Gf(a,e)},ov={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},iv=(e,t,n,s)=>{const o=n;o.type="string";const{minimum:i,maximum:a,format:l,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),l&&(o.format=ov[l]??l,o.format===""&&delete o.format,l==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},av=(e,t,n,s)=>{const o=n,{minimum:i,maximum:a,format:l,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof l=="string"&&l.includes("int")?o.type="integer":o.type="number";const f=typeof d=="number"&&d>=(i??Number.NEGATIVE_INFINITY),m=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";f?h?(o.minimum=d,o.exclusiveMinimum=!0):o.exclusiveMinimum=d:typeof i=="number"&&(o.minimum=i),m?h?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof a=="number"&&(o.maximum=a),typeof c=="number"&&(o.multipleOf=c)},lv=(e,t,n,s)=>{n.type="boolean"},cv=(e,t,n,s)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},uv=(e,t,n,s)=>{n.not={}},dv=(e,t,n,s)=>{},fv=(e,t,n,s)=>{const o=e._zod.def,i=Sf(o.entries);i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i},pv=(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},hv=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},mv=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},gv=(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=Ge(i.element,t,{...s,path:[...s.path,"items"]})},xv=(e,t,n,s)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const u in a)o.properties[u]=Ge(a[u],t,{...s,path:[...s.path,"properties",u]});const l=new Set(Object.keys(a)),c=new Set([...l].filter(u=>{const d=i.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=Ge(i.catchall,t,{...s,path:[...s.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},bv=(e,t,n,s)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((l,c)=>Ge(l,t,{...s,path:[...s.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=a:n.anyOf=a},vv=(e,t,n,s)=>{const o=e._zod.def,i=Ge(o.left,t,{...s,path:[...s.path,"allOf",0]}),a=Ge(o.right,t,{...s,path:[...s.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(i)?i.allOf:[i],...l(a)?a.allOf:[a]];n.allOf=c},yv=(e,t,n,s)=>{const o=n,i=e._zod.def;o.type="object";const a=i.keyType,c=a._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){const d=Ge(i.valueType,t,{...s,path:[...s.path,"patternProperties","*"]});o.patternProperties={};for(const f of c)o.patternProperties[f.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=Ge(i.keyType,t,{...s,path:[...s.path,"propertyNames"]})),o.additionalProperties=Ge(i.valueType,t,{...s,path:[...s.path,"additionalProperties"]});const u=a._zod.values;if(u){const d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(o.required=d)}},wv=(e,t,n,s)=>{const o=e._zod.def,i=Ge(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"}]},_v=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType},kv=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},jv=(e,t,n,s)=>{const o=e._zod.def;Ge(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)))},Sv=(e,t,n,s)=>{const o=e._zod.def;Ge(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},Cv=(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;Ge(a,t,s);const l=t.seen.get(e);l.ref=a},Nv=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Kf=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const i=t.seen.get(e);i.ref=o.innerType},Tv=(e,t,n,s)=>{const o=e._zod.innerType;Ge(o,t,s);const i=t.seen.get(e);i.ref=o},Ev=ne("ZodISODateTime",(e,t)=>{S1.init(e,t),Ve.init(e,t)});function Av(e){return Pb(Ev,e)}const Rv=ne("ZodISODate",(e,t)=>{C1.init(e,t),Ve.init(e,t)});function Iv(e){return zb(Rv,e)}const Pv=ne("ZodISOTime",(e,t)=>{N1.init(e,t),Ve.init(e,t)});function zv(e){return Mb(Pv,e)}const Mv=ne("ZodISODuration",(e,t)=>{T1.init(e,t),Ve.init(e,t)});function Ov(e){return Ob(Mv,e)}const Lv=(e,t)=>{Ef.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>gx(e,n)},flatten:{value:n=>mx(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ea,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ea,2)}},isEmpty:{get(){return e.issues.length===0}}})},It=ne("ZodError",Lv,{Parent:Error}),Dv=Tl(It),$v=El(It),Fv=ti(It),Uv=ni(It),Bv=vx(It),Wv=yx(It),Hv=wx(It),Vv=_x(It),qv=kx(It),Zv=jx(It),Gv=Sx(It),Kv=Cx(It),du=new WeakMap;function vr(e,t,n){const s=Object.getPrototypeOf(e);let o=du.get(s);if(o||(o=new Set,du.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 We=ne("ZodType",(e,t)=>(Be.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:jo(e,"input"),output:jo(e,"output")}}),e.toJSONSchema=rv(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,s)=>Dv(e,n,s,{callee:e.parse}),e.safeParse=(n,s)=>Fv(e,n,s),e.parseAsync=async(n,s)=>$v(e,n,s,{callee:e.parseAsync}),e.safeParseAsync=async(n,s)=>Uv(e,n,s),e.spa=e.safeParseAsync,e.encode=(n,s)=>Bv(e,n,s),e.decode=(n,s)=>Wv(e,n,s),e.encodeAsync=async(n,s)=>Hv(e,n,s),e.decodeAsync=async(n,s)=>Vv(e,n,s),e.safeEncode=(n,s)=>qv(e,n,s),e.safeDecode=(n,s)=>Zv(e,n,s),e.safeEncodeAsync=async(n,s)=>Gv(e,n,s),e.safeDecodeAsync=async(n,s)=>Kv(e,n,s),vr(e,"ZodType",{check(...n){const s=this.def;return this.clone(Cn(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 Nn(this,n,s)},brand(){return this},register(n,s){return n.add(this,s),this},refine(n,s){return this.check(H2(n,s))},superRefine(n,s){return this.check(V2(n,s))},overwrite(n){return this.check($s(n))},optional(){return mu(this)},exactOptional(){return E2(this)},nullable(){return gu(this)},nullish(){return mu(gu(this))},nonoptional(n){return M2(this,n)},array(){return fe(this)},or(n){return Jt([this,n])},and(n){return j2(this,n)},transform(n){return xu(this,N2(n))},default(n){return I2(this,n)},prefault(n){return z2(this,n)},catch(n){return L2(this,n)},pipe(n){return xu(this,n)},readonly(){return F2(this)},describe(n){const s=this.clone();return er.add(s,{description:n}),s},meta(...n){if(n.length===0)return er.get(this);const s=this.clone();return er.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 er.get(e)?.description},configurable:!0}),e)),Jf=ne("_ZodString",(e,t)=>{Al.init(e,t),We.init(e,t),e._zod.processJSONSchema=(s,o,i)=>iv(e,s,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,vr(e,"_ZodString",{regex(...s){return this.check(Wb(...s))},includes(...s){return this.check(qb(...s))},startsWith(...s){return this.check(Zb(...s))},endsWith(...s){return this.check(Gb(...s))},min(...s){return this.check(ko(...s))},max(...s){return this.check(Hf(...s))},length(...s){return this.check(Vf(...s))},nonempty(...s){return this.check(ko(1,...s))},lowercase(s){return this.check(Hb(s))},uppercase(s){return this.check(Vb(s))},trim(){return this.check(Jb())},normalize(...s){return this.check(Kb(...s))},toLowerCase(){return this.check(Yb())},toUpperCase(){return this.check(Xb())},slugify(){return this.check(Qb())}})}),Jv=ne("ZodString",(e,t)=>{Al.init(e,t),Jf.init(e,t),e.email=n=>e.check(fb(Yv,n)),e.url=n=>e.check(xb(Xv,n)),e.jwt=n=>e.check(Ib(p2,n)),e.emoji=n=>e.check(bb(Qv,n)),e.guid=n=>e.check(au(fu,n)),e.uuid=n=>e.check(pb(Or,n)),e.uuidv4=n=>e.check(hb(Or,n)),e.uuidv6=n=>e.check(mb(Or,n)),e.uuidv7=n=>e.check(gb(Or,n)),e.nanoid=n=>e.check(vb(e2,n)),e.guid=n=>e.check(au(fu,n)),e.cuid=n=>e.check(yb(t2,n)),e.cuid2=n=>e.check(wb(n2,n)),e.ulid=n=>e.check(_b(s2,n)),e.base64=n=>e.check(Eb(u2,n)),e.base64url=n=>e.check(Ab(d2,n)),e.xid=n=>e.check(kb(r2,n)),e.ksuid=n=>e.check(jb(o2,n)),e.ipv4=n=>e.check(Sb(i2,n)),e.ipv6=n=>e.check(Cb(a2,n)),e.cidrv4=n=>e.check(Nb(l2,n)),e.cidrv6=n=>e.check(Tb(c2,n)),e.e164=n=>e.check(Rb(f2,n)),e.datetime=n=>e.check(Av(n)),e.date=n=>e.check(Iv(n)),e.time=n=>e.check(zv(n)),e.duration=n=>e.check(Ov(n))});function C(e){return db(Jv,e)}const Ve=ne("ZodStringFormat",(e,t)=>{He.init(e,t),Jf.init(e,t)}),Yv=ne("ZodEmail",(e,t)=>{g1.init(e,t),Ve.init(e,t)}),fu=ne("ZodGUID",(e,t)=>{h1.init(e,t),Ve.init(e,t)}),Or=ne("ZodUUID",(e,t)=>{m1.init(e,t),Ve.init(e,t)}),Xv=ne("ZodURL",(e,t)=>{x1.init(e,t),Ve.init(e,t)}),Qv=ne("ZodEmoji",(e,t)=>{b1.init(e,t),Ve.init(e,t)}),e2=ne("ZodNanoID",(e,t)=>{v1.init(e,t),Ve.init(e,t)}),t2=ne("ZodCUID",(e,t)=>{y1.init(e,t),Ve.init(e,t)}),n2=ne("ZodCUID2",(e,t)=>{w1.init(e,t),Ve.init(e,t)}),s2=ne("ZodULID",(e,t)=>{_1.init(e,t),Ve.init(e,t)}),r2=ne("ZodXID",(e,t)=>{k1.init(e,t),Ve.init(e,t)}),o2=ne("ZodKSUID",(e,t)=>{j1.init(e,t),Ve.init(e,t)}),i2=ne("ZodIPv4",(e,t)=>{E1.init(e,t),Ve.init(e,t)}),a2=ne("ZodIPv6",(e,t)=>{A1.init(e,t),Ve.init(e,t)}),l2=ne("ZodCIDRv4",(e,t)=>{R1.init(e,t),Ve.init(e,t)}),c2=ne("ZodCIDRv6",(e,t)=>{I1.init(e,t),Ve.init(e,t)}),u2=ne("ZodBase64",(e,t)=>{P1.init(e,t),Ve.init(e,t)}),d2=ne("ZodBase64URL",(e,t)=>{M1.init(e,t),Ve.init(e,t)}),f2=ne("ZodE164",(e,t)=>{O1.init(e,t),Ve.init(e,t)}),p2=ne("ZodJWT",(e,t)=>{D1.init(e,t),Ve.init(e,t)}),Yf=ne("ZodNumber",(e,t)=>{$f.init(e,t),We.init(e,t),e._zod.processJSONSchema=(s,o,i)=>av(e,s,o),vr(e,"ZodNumber",{gt(s,o){return this.check(cu(s,o))},gte(s,o){return this.check(Ui(s,o))},min(s,o){return this.check(Ui(s,o))},lt(s,o){return this.check(lu(s,o))},lte(s,o){return this.check(Fi(s,o))},max(s,o){return this.check(Fi(s,o))},int(s){return this.check(pu(s))},safe(s){return this.check(pu(s))},positive(s){return this.check(cu(0,s))},nonnegative(s){return this.check(Ui(0,s))},negative(s){return this.check(lu(0,s))},nonpositive(s){return this.check(Fi(0,s))},multipleOf(s,o){return this.check(uu(s,o))},step(s,o){return this.check(uu(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 G(e){return Lb(Yf,e)}const h2=ne("ZodNumberFormat",(e,t)=>{$1.init(e,t),Yf.init(e,t)});function pu(e){return Db(h2,e)}const m2=ne("ZodBoolean",(e,t)=>{F1.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>lv(e,n,s)});function Le(e){return $b(m2,e)}const g2=ne("ZodNull",(e,t)=>{U1.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>cv(e,n,s)});function So(e){return Fb(g2,e)}const x2=ne("ZodUnknown",(e,t)=>{B1.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>dv()});function qn(){return Ub(x2)}const b2=ne("ZodNever",(e,t)=>{W1.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>uv(e,n,s)});function v2(e){return Bb(b2,e)}const y2=ne("ZodArray",(e,t)=>{H1.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>gv(e,n,s,o),e.element=t.element,vr(e,"ZodArray",{min(n,s){return this.check(ko(n,s))},nonempty(n){return this.check(ko(1,n))},max(n,s){return this.check(Hf(n,s))},length(n,s){return this.check(Vf(n,s))},unwrap(){return this.element}})});function fe(e,t){return ev(y2,e,t)}const w2=ne("ZodObject",(e,t)=>{q1.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>xv(e,n,s,o),Me(e,"shape",()=>t.shape),vr(e,"ZodObject",{keyof(){return Te(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:qn()})},loose(){return this.clone({...this._zod.def,catchall:qn()})},strict(){return this.clone({...this._zod.def,catchall:v2()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return cx(this,n)},safeExtend(n){return ux(this,n)},merge(n){return dx(this,n)},pick(n){return ax(this,n)},omit(n){return lx(this,n)},partial(...n){return fx(Qf,this,n[0])},required(...n){return px(ep,this,n[0])}})});function J(e,t){const n={type:"object",shape:e??{},...Se(t)};return new w2(n)}const Xf=ne("ZodUnion",(e,t)=>{Bf.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>bv(e,n,s,o),e.options=t.options});function Jt(e,t){return new Xf({type:"union",options:e,...Se(t)})}const _2=ne("ZodDiscriminatedUnion",(e,t)=>{Xf.init(e,t),Z1.init(e,t)});function rs(e,t,n){return new _2({type:"union",options:t,discriminator:e,...Se(n)})}const k2=ne("ZodIntersection",(e,t)=>{G1.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>vv(e,n,s,o)});function j2(e,t){return new k2({type:"intersection",left:e,right:t})}const hu=ne("ZodRecord",(e,t)=>{K1.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>yv(e,n,s,o),e.keyType=t.keyType,e.valueType=t.valueType});function Ke(e,t,n){return!t||!t._zod?new hu({type:"record",keyType:C(),valueType:e,...Se(t)}):new hu({type:"record",keyType:e,valueType:t,...Se(n)})}const Ra=ne("ZodEnum",(e,t)=>{J1.init(e,t),We.init(e,t),e._zod.processJSONSchema=(s,o,i)=>fv(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 Ra({...t,checks:[],...Se(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 Ra({...t,checks:[],...Se(o),entries:i})}});function Te(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new Ra({type:"enum",entries:n,...Se(t)})}const S2=ne("ZodLiteral",(e,t)=>{Y1.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>pv(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 Ee(e,t){return new S2({type:"literal",values:Array.isArray(e)?e:[e],...Se(t)})}const C2=ne("ZodTransform",(e,t)=>{X1.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>mv(e,n),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new jf(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(ar(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(ar(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 N2(e){return new C2({type:"transform",transform:e})}const Qf=ne("ZodOptional",(e,t)=>{Wf.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Kf(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function mu(e){return new Qf({type:"optional",innerType:e})}const T2=ne("ZodExactOptional",(e,t)=>{Q1.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Kf(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function E2(e){return new T2({type:"optional",innerType:e})}const A2=ne("ZodNullable",(e,t)=>{eb.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>wv(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function gu(e){return new A2({type:"nullable",innerType:e})}const R2=ne("ZodDefault",(e,t)=>{tb.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>kv(e,n,s,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function I2(e,t){return new R2({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Nf(t)}})}const P2=ne("ZodPrefault",(e,t)=>{nb.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>jv(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function z2(e,t){return new P2({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Nf(t)}})}const ep=ne("ZodNonOptional",(e,t)=>{sb.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>_v(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function M2(e,t){return new ep({type:"nonoptional",innerType:e,...Se(t)})}const O2=ne("ZodCatch",(e,t)=>{rb.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Sv(e,n,s,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function L2(e,t){return new O2({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const D2=ne("ZodPipe",(e,t)=>{ob.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Cv(e,n,s,o),e.in=t.in,e.out=t.out});function xu(e,t){return new D2({type:"pipe",in:e,out:t})}const $2=ne("ZodReadonly",(e,t)=>{ib.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Nv(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function F2(e){return new $2({type:"readonly",innerType:e})}const U2=ne("ZodLazy",(e,t)=>{ab.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Tv(e,n,s,o),e.unwrap=()=>e._zod.def.getter()});function B2(e){return new U2({type:"lazy",getter:e})}const W2=ne("ZodCustom",(e,t)=>{lb.init(e,t),We.init(e,t),e._zod.processJSONSchema=(n,s,o)=>hv(e,n)});function H2(e,t={}){return tv(W2,e,t)}function V2(e,t){return nv(e,t)}const st=B2(()=>Jt([C(),G(),Le(),So(),fe(st),Ke(C(),st)]));function tp(e){return e===void 0||typeof e=="bigint"||typeof e=="function"?null:e}const np=J({index:G(),timestamp:G(),type:C(),data:st}),q2=J({chunks:fe(np),truncated:Le().optional().default(!1)}),Z2=Te(["request","response"]),G2=J({logId:G().int().positive(),part:Z2,text:C(),offset:G().int().nonnegative(),limit:G().int().positive(),totalBytes:G().int().nonnegative(),textBytes:G().int().nonnegative(),nextOffset:G().int().nonnegative().nullable(),hasMore:Le(),contentMode:Te(["empty","partial","full"])}),lr=J({id:G(),timestamp:C(),method:C(),path:C(),model:C().nullable(),sessionId:C().nullable(),rawRequestBody:C().nullable(),responseStatus:G().nullable(),responseText:C().nullable(),inputTokens:G().nullable(),outputTokens:G().nullable(),cacheCreationInputTokens:G().nullable(),cacheReadInputTokens:G().nullable(),elapsedMs:G().nullable(),firstChunkMs:G().nullable().optional(),totalStreamMs:G().nullable().optional(),tokensPerSecond:G().nullable().optional(),streaming:Le(),userAgent:C().nullable(),origin:C().nullable(),rawHeaders:Ke(C(),C()).optional(),headers:Ke(C(),C()).optional(),apiFormat:Te(["anthropic","openai","unknown"]).default("unknown"),isTest:Le().optional().default(!1),replayOfLogId:G().nullable().optional(),providerName:C().nullable().optional(),clientPort:G().nullable().optional(),clientPid:G().nullable().optional(),clientCwd:C().nullable().optional(),clientProjectFolder:C().nullable().optional(),streamingChunks:q2.optional(),streamingChunksPath:C().nullable().optional(),rawRequestBodyBytes:G().int().nonnegative().nullable().optional(),responseTextBytes:G().int().nonnegative().nullable().optional(),bodyContentMode:Te(["full","compact","truncated"]).optional(),warnings:fe(C()).optional(),error:C().nullable().optional()}),Rl=J({type:C(),ttl:C().optional(),scope:C().optional()}),Il=J({type:Ee("text"),text:C(),cache_control:Rl.optional()}),sp=J({type:Ee("thinking"),thinking:C(),signature:C().optional()}),K2=J({type:Ee("think"),thinking:C(),signature:C().optional()}),J2=J({type:Ee("base64"),media_type:C(),data:C()}),rp=J({type:Ee("image"),source:J2}),op=J({type:Ee("tool_use"),id:C(),name:C(),input:Ke(C(),st)}),Y2=rs("type",[Il,rp]),X2=J({type:Ee("tool_result"),tool_use_id:C().optional(),content:Jt([C(),fe(Y2)]),is_error:Le().optional()}),Q2=rs("type",[Il,sp,rp,op,X2]),ey=Jt([C(),fe(Q2)]),ty=J({role:Te(["user","assistant"]),content:ey}),ny=J({type:Ee("text"),text:C(),cache_control:Rl.optional()}),sy=J({type:C(),properties:Ke(C(),Ke(C(),st)).optional(),required:fe(C()).optional(),additionalProperties:Le().optional(),$schema:C().optional()}),ry=J({name:C(),description:C().optional(),input_schema:sy.optional(),cache_control:Rl.optional()}),oy=rs("type",[J({type:Ee("enabled"),budget_tokens:G()}),J({type:Ee("disabled")}),J({type:Ee("adaptive")})]),ip=J({model:C(),messages:fe(ty),system:fe(ny).optional(),tools:fe(ry).optional(),max_tokens:G().optional(),temperature:G().optional(),stream:Le().optional(),thinking:oy.optional(),metadata:J({user_id:C().optional()}).optional()}),Pl=rs("type",[Il,sp,K2,op]),iy=J({input_tokens:G().nullable().optional(),output_tokens:G().nullable().optional(),cache_creation_input_tokens:G().nullable().optional(),cache_read_input_tokens:G().nullable().optional()}).passthrough(),ap=J({id:C(),type:Ee("message"),model:C(),role:Ee("assistant"),content:fe(Pl),stop_reason:C().nullable(),stop_sequence:C().nullable().optional(),usage:iy}).passthrough(),ay=J({type:Ee("message_start"),message:J({id:C(),type:Ee("message"),model:C(),role:Ee("assistant"),content:fe(Pl),stop_reason:So(),stop_sequence:So(),usage:J({input_tokens:G(),cache_creation_input_tokens:G().optional(),cache_read_input_tokens:G().optional()}).passthrough()})}),ly=J({type:Ee("content_block_start"),index:G(),content_block:Pl}),cy=rs("type",[J({type:Ee("text_delta"),text:C()}),J({type:Ee("input_json_delta"),partial_json:C()}),J({type:Ee("thinking_delta"),thinking:C()}),J({type:Ee("signature_delta"),signature:C()})]),uy=J({type:Ee("content_block_delta"),index:G(),delta:cy}),dy=J({type:Ee("content_block_stop"),index:G()}),fy=J({type:Ee("message_delta"),delta:J({stop_reason:C().nullable(),stop_sequence:C().nullable().optional()}),usage:J({output_tokens:G(),input_tokens:G().optional(),cache_creation_input_tokens:G().optional(),cache_read_input_tokens:G().optional()}).passthrough()}),py=J({type:Ee("message_stop")}),hy=J({type:Ee("ping")}),my=J({type:Ee("error"),error:J({type:C(),message:C()})}),gy=rs("type",[ay,ly,uy,dy,fy,py,hy,my]),xy=Jt([C(),fe(rs("type",[J({type:Ee("text"),text:C()}),J({type:Ee("image_url"),image_url:J({url:C(),detail:C().optional()})})]))]),lp=J({role:Te(["system","user","assistant","tool"]),content:xy,name:C().optional(),reasoning_content:C().optional(),thinking:C().optional(),think:C().optional()}),by=J({name:C(),arguments:C()}),cp=J({index:G().optional(),id:C().optional(),type:Ee("function").optional(),function:J({name:C().optional(),arguments:C().optional()})});lp.extend({content:Jt([C(),fe(J({type:Ee("text"),text:C()}))]).optional(),function_call:by.optional(),tool_calls:fe(cp).optional()});const vy=J({type:Ee("function"),function:J({name:C(),description:C().optional(),parameters:Ke(C(),st)})}),up=J({model:C(),messages:fe(lp),temperature:G().optional(),max_tokens:G().optional(),stream:Le().optional(),tools:fe(vy).optional(),tool_choice:Jt([Te(["auto","none","required"]),J({type:Ee("auto")}),J({type:Ee("none")}),J({type:Ee("function"),function:J({name:C()})})]).optional(),user:C().optional()}),yy=J({type:C(),name:C().optional(),description:C().optional(),parameters:st.optional(),function:J({name:C().optional(),description:C().optional(),parameters:st.optional()}).optional()}).passthrough(),dp=J({model:C(),input:qn().optional(),instructions:Jt([C(),So()]).optional(),stream:Le().optional(),tools:fe(yy).optional(),tool_choice:qn().optional(),max_output_tokens:G().optional(),temperature:G().optional(),user:C().optional(),metadata:Ke(C(),qn()).optional()}).passthrough(),fp=J({role:Te(["assistant"]).optional(),content:C().nullable().optional(),reasoning_content:C().nullable().optional(),thinking:C().nullable().optional(),think:C().nullable().optional(),function_call:J({name:C().optional(),arguments:C().optional()}).nullable().optional(),tool_calls:fe(J({index:G(),id:C().optional(),type:Ee("function").optional(),function:J({name:C().optional(),arguments:C().optional()})})).nullable().optional()}),wy=J({index:G(),message:J({role:Te(["assistant"]),content:C().nullable(),reasoning_content:C().optional(),thinking:C().optional(),think:C().optional(),function_call:J({name:C(),arguments:C()}).nullable().optional(),tool_calls:fe(cp).optional()}).optional(),delta:fp.optional(),finish_reason:C().nullable()}),_y=J({id:C(),object:Ee("chat.completion"),created:G(),model:C(),choices:fe(wy),usage:J({prompt_tokens:G().nullable().optional(),completion_tokens:G().nullable().optional(),total_tokens:G().nullable().optional()}).passthrough(),service_tier:C().nullable().optional(),system_fingerprint:C().nullable().optional()}).passthrough(),ky=J({id:C(),object:Ee("chat.completion.chunk"),created:G(),model:C(),choices:fe(J({index:G(),delta:fp,finish_reason:C().nullable().optional()})),usage:J({prompt_tokens:G().nullable().optional(),completion_tokens:G().nullable().optional(),total_tokens:G().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),jy=J({input_tokens:G().nullable().optional(),output_tokens:G().nullable().optional(),total_tokens:G().nullable().optional(),input_tokens_details:J({cached_tokens:G().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:J({reasoning_tokens:G().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),Sy=J({type:C()}).passthrough(),Co=J({id:C(),object:Ee("response").optional(),created_at:G().optional(),status:C().nullable().optional(),model:C().optional(),output:fe(Sy).optional(),output_text:C().optional(),usage:jy.nullable().optional(),error:qn().optional()}).passthrough(),Cy=J({type:C()}).passthrough();function pp(e){try{const t=JSON.parse(e),n=_y.safeParse(t);return n.success?n.data:null}catch{return null}}function hp(e){try{const t=JSON.parse(e),n=Co.safeParse(t);return n.success?n.data:null}catch{return null}}const Ny=J({error:C()});async function zl(e,t){const n=await e.json();return t.parse(n)}async function Ml(e,t){try{const n=await e.json(),s=Ny.safeParse(n);return s.success?s.data.error:t}catch{return t}}async function ht(e,t,n,s){const o=await fetch(e,n);if(!o.ok){const i=s?.(o)??`Request failed with status ${o.status}`;throw new Error(await Ml(o,i))}return zl(o,t)}function Ty(e){return e<1e3?`${String(e)}ms`:`${String(Math.round(e/1e3))}s`}class ri extends Error{constructor(t){super(`Request timed out after ${Ty(t)}`),this.name="ApiTimeoutError"}}async function Zn(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,{...n,signal:s.signal})}catch(c){throw o&&c instanceof DOMException&&c.name==="AbortError"?new ri(t):c}finally{clearTimeout(i),a?.removeEventListener("abort",l)}}async function Ze(e,t,n,s,o){const i=await Zn(e,n,s);if(!i.ok){const a=o?.(i)??`Request failed with status ${i.status}`;throw new Error(await Ml(i,a))}return zl(i,t)}const mp=J({input:G().int().nonnegative(),output:G().int().nonnegative(),cacheCreate:G().int().nonnegative(),cacheRead:G().int().nonnegative(),total:G().int().nonnegative()}),Ey=J({id:G().int().positive(),sessionLogNumber:G().int().positive().optional(),timestamp:C(),provider:C().nullable(),model:C().nullable(),apiFormat:Te(["anthropic","openai","unknown"]),method:C(),path:C(),status:G().nullable(),isStreaming:Le(),hasError:Le(),error:C().nullable(),latencyMs:G().nullable(),firstChunkMs:G().nullable().optional(),totalStreamMs:G().nullable().optional(),tokensPerSecond:G().nullable().optional(),tokens:J({input:G().nullable(),output:G().nullable(),cacheCreate:G().nullable(),cacheRead:G().nullable()}),sessionId:C().nullable(),userAgent:C().nullable().optional(),clientPid:G().nullable().optional(),clientProjectFolder:C().nullable().optional()}),gp=J({id:C(),status:Te(["active","failed","completed","empty"]),logCoverage:Te(["recent","history"]),source:Te(["explicit","client-process","client-connection","provider-test"]).nullable(),runtimeMode:Te(["in-process","worker-thread","child-process"]).nullable(),createdAt:C().nullable(),updatedAt:C().nullable(),requestCount:G().int().nonnegative(),activeRequests:G().int().nonnegative(),completedRequests:G().int().nonnegative(),failedRequests:G().int().nonnegative(),queuedTasks:G().int().nonnegative(),runningTasks:G().int().nonnegative(),lastTaskError:C().nullable(),logCount:G().int().nonnegative(),errorCount:G().int().nonnegative(),models:fe(C()),providers:fe(C()),tokenUsage:mp,lastLogId:G().nullable(),lastModel:C().nullable(),clientUserAgent:C().nullable().optional(),clientPid:G().nullable(),clientProjectFolder:C().nullable(),inspectorPath:C(),inspectorUrl:C(),apiPath:C(),apiUrl:C(),compactLogsPath:C(),compactLogsUrl:C(),latestLogLimit:G().int().positive(),latestLogs:fe(Ey)}),yr=Te(["created","running","completed","failed","cancelled"]),Ol=J({jsonPath:C(),markdownPath:C(),htmlPath:C(),exportedAt:C()}),Ay=Te(["run-created","session-started","request","session-finished","evidence-exported"]),Ry=Te(["info","success","warning","error"]),Iy=J({timestamp:C(),kind:Ay,severity:Ry,title:C(),details:C(),logId:G().int().positive().nullable(),status:G().nullable(),model:C().nullable(),provider:C().nullable(),latencyMs:G().nullable(),isStreaming:Le().nullable()}),Py=Te(["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=J({outcome:Te(["success","failure","active","unknown"]),severity:Te(["none","low","medium","high"]),category:Py,summary:C(),evidenceLogIds:fe(G().int().positive()),hints:fe(C())}),Ll=J({status:Te(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:C(),markdown:C()}),bp=Ll,Dl=J({id:C(),sessionId:C(),groupId:C().nullable().default(null),title:C(),task:C().nullable(),project:C().nullable(),agent:C().nullable(),status:yr,tags:fe(C()),metadata:Ke(C(),st),evidence:Ol.nullable(),createdAt:C(),updatedAt:C()});J({runId:C().min(1).optional(),sessionId:C().min(1).optional(),groupId:C().min(1).nullable().optional(),title:C().min(1).optional(),task:C().nullable().optional(),project:C().nullable().optional(),agent:C().nullable().optional(),status:yr.optional(),tags:fe(C()).optional(),metadata:Ke(C(),st).optional()}).optional();J({sessionId:C().min(1).optional(),groupId:C().min(1).nullable().optional(),title:C().min(1).optional(),task:C().nullable().optional(),project:C().nullable().optional(),agent:C().nullable().optional(),status:yr.optional(),tags:fe(C()).optional(),metadata:Ke(C(),st).optional()});J({includeHistory:Le().optional(),latestLogLimit:G().int().positive().max(50).optional()}).optional();J({run:Dl,evidence:Ol,session:gp.nullable(),timeline:fe(Iy),classification:xp,jenkinsReport:Ll});const zy=J({run:Dl,classification:xp,evidence:Ol.nullable(),jenkinsReport:Ll.nullable(),sessionId:C(),inspectorUrl:C().nullable(),evidenceMarkdownPath:C().nullable(),updatedAt:C()});J({failures:fe(zy),total:G().int().nonnegative(),limit:G().int().positive()});const $l=Te(["created","running","completed","failed","cancelled"]),Fl=Te(["evaluation","batch","manual"]),Ul=J({jsonPath:C(),markdownPath:C(),htmlPath:C(),exportedAt:C()}),vp=J({id:C(),groupId:C(),sessionId:C(),runId:C().nullable(),label:C().nullable(),agent:C().nullable(),provider:C().nullable(),model:C().nullable(),status:yr.nullable(),metadata:Ke(C(),st),addedAt:C(),updatedAt:C()}),Bl=J({id:C(),title:C(),kind:Fl,task:C().nullable(),project:C().nullable(),status:$l,tags:fe(C()),metadata:Ke(C(),st),evidence:Ul.nullable(),members:fe(vp),createdAt:C(),updatedAt:C()});J({groupId:C().min(1).optional(),title:C().min(1).optional(),kind:Fl.optional(),task:C().nullable().optional(),project:C().nullable().optional(),status:$l.optional(),tags:fe(C()).optional(),metadata:Ke(C(),st).optional()}).optional();J({title:C().min(1).optional(),kind:Fl.optional(),task:C().nullable().optional(),project:C().nullable().optional(),status:$l.optional(),tags:fe(C()).optional(),metadata:Ke(C(),st).optional()});J({memberId:C().min(1).optional(),sessionId:C().min(1),runId:C().min(1).nullable().optional(),label:C().min(1).nullable().optional(),agent:C().min(1).nullable().optional(),provider:C().min(1).nullable().optional(),model:C().min(1).nullable().optional(),status:yr.nullable().optional(),metadata:Ke(C(),st).optional()});J({includeHistory:Le().optional(),latestLogLimit:G().int().positive().max(50).optional()}).optional();J({deleteEvidence:Le().optional()});const yp=J({groupId:C(),deleted:Le(),evidenceDeleted:Le(),evidencePath:C().nullable()}),wp=J({deleted:G().int().nonnegative(),groups:fe(yp)}),_p=J({member:vp,run:Dl.nullable(),session:gp.nullable()}),kp=J({memberCount:G().int().nonnegative(),sessionsWithData:G().int().nonnegative(),missingSessions:G().int().nonnegative(),requestCount:G().int().nonnegative(),errorCount:G().int().nonnegative(),tokenUsage:mp,models:fe(C()),providers:fe(C()),completedMembers:G().int().nonnegative(),failedMembers:G().int().nonnegative(),runningMembers:G().int().nonnegative()}),My=J({group:Bl,evidence:Ul,members:fe(_p).nullable(),markdown:C(),summary:kp.nullable(),report:bp.nullable()}),Oy=J({group:Bl,evidence:Ul,members:fe(_p),summary:kp,jenkinsReport:bp}),jp=J({groups:fe(Bl)}),Ly=J({sessionId:C(),imported:G().int().nonnegative(),skipped:G().int().nonnegative(),warnings:fe(C()),logs:fe(lr)}),No=10,Ia=600,To=60,Pa=600,Eo="time",Wl="simple",Sp=Te(["time","full"]),Dy=Te(["simple","full"]),oi=J({stripClaudeCodeBillingHeader:Le(),hasSeenOnboarding:Le().default(!1),slowResponseThresholdSeconds:G().int().min(0).max(Ia).default(No),providerTestTimeoutSeconds:G().int().min(1).max(Pa).default(To),timeDisplayFormat:Sp.default(Eo),captureMode:Dy.default(Wl)}),xs="/api/config";async function $y(e){return ht(e,oi,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function Lr(e){return ht(xs,oi,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function Hl(){const e=qt(xs,$y,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=wf(),n=e.data?.stripClaudeCodeBillingHeader??!1,s=e.data?.captureMode??Wl,o=e.data?.slowResponseThresholdSeconds??No,i=e.data?.providerTestTimeoutSeconds??To,a=e.data?.timeDisplayFormat??Eo,l=m=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??No,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??To,timeDisplayFormat:e.data?.timeDisplayFormat??Eo,captureMode:s,...m}),c=async m=>{await t(xs,Lr({stripClaudeCodeBillingHeader:m}),{optimisticData:l({stripClaudeCodeBillingHeader:m}),rollbackOnError:!0,revalidate:!1})},u=async m=>{await t(xs,Lr({slowResponseThresholdSeconds:m}),{optimisticData:l({slowResponseThresholdSeconds:m}),rollbackOnError:!0,revalidate:!1})},d=async m=>{await t(xs,Lr({timeDisplayFormat:m}),{optimisticData:l({timeDisplayFormat:m}),rollbackOnError:!0,revalidate:!1})},f=async m=>{await t(xs,Lr({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:c,setSlowResponseThresholdSeconds:u,setProviderTestTimeoutSeconds:f,setTimeDisplayFormat:d}}const Cp=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();const Fy=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Uy=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());const bu=e=>{const t=Uy(e);return t.charAt(0).toUpperCase()+t.slice(1)};var By={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 Wy=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const Hy=p.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:o="",children:i,iconNode:a,...l},c)=>p.createElement("svg",{ref:c,...By,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:Cp("lucide",o),...!i&&!Wy(l)&&{"aria-hidden":"true"},...l},[...a.map(([u,d])=>p.createElement(u,d)),...Array.isArray(i)?i:[i]]));const ce=(e,t)=>{const n=p.forwardRef(({className:s,...o},i)=>p.createElement(Hy,{ref:i,iconNode:t,className:Cp(`lucide-${Fy(bu(e))}`,`lucide-${e}`,s),...o}));return n.displayName=bu(e),n};const Vy=[["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"}]],qy=ce("a-large-small",Vy);const Zy=[["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"}]],Gy=ce("activity",Zy);const Ky=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],Jy=ce("arrow-down-right",Ky);const Yy=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Xy=ce("arrow-down",Yy);const Qy=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],ew=ce("arrow-left",Qy);const tw=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],nw=ce("arrow-up-right",tw);const sw=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],rw=ce("arrow-up",sw);const ow=[["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"}]],Vl=ce("beaker",ow);const iw=[["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"}]],aw=ce("bell",iw);const lw=[["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"}]],cw=ce("blocks",lw);const uw=[["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"}]],dw=ce("brain-circuit",uw);const fw=[["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"}]],Np=ce("brain",fw);const pw=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],qe=ce("check",pw);const hw=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],rt=ce("chevron-down",hw);const mw=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],gw=ce("chevron-left",mw);const xw=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],jt=ce("chevron-right",xw);const bw=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],ql=ce("chevron-up",bw);const vw=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],yw=ce("chevrons-down",vw);const ww=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],_w=ce("chevrons-left",ww);const kw=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],jw=ce("chevrons-right",kw);const Sw=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Cw=ce("chevrons-up",Sw);const Nw=[["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"}]],As=ce("circle-alert",Nw);const Tw=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ii=ce("circle-check-big",Tw);const Ew=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],za=ce("circle-check",Ew);const Aw=[["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"}]],Rw=ce("circle-question-mark",Aw);const Iw=[["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"}]],Tp=ce("circle-x",Iw);const Pw=[["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"}]],zw=ce("clapperboard",Pw);const Mw=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ow=ce("clock-3",Mw);const Lw=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],tn=ce("clock",Lw);const Dw=[["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=ce("cloud-upload",Dw);const Fw=[["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"}]],Uw=ce("code-xml",Fw);const Bw=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Ww=ce("columns-2",Bw);const Hw=[["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"}]],Pt=ce("copy",Hw);const Vw=[["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"}]],qw=ce("cpu",Vw);const Zw=[["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"}]],wr=ce("download",Zw);const Gw=[["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"}]],Kw=ce("ellipsis",Gw);const Jw=[["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"}]],Zl=ce("external-link",Jw);const Yw=[["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"}]],Ep=ce("eye-off",Yw);const Xw=[["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"}]],Gl=ce("eye",Xw);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:"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"}]],e_=ce("file-braces",Qw);const t_=[["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"}]],n_=ce("file-diff",t_);const s_=[["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"}]],r_=ce("file-search",s_);const o_=[["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"}]],i_=ce("file-terminal",o_);const a_=[["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"}]],l_=ce("file-text",a_);const c_=[["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"}]],u_=ce("flag",c_);const d_=[["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"}]],Ap=ce("flask-conical",d_);const f_=[["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"}]],p_=ce("folder-open",f_);const h_=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Kl=ce("gauge",h_);const m_=[["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"}]],g_=ce("git-compare-arrows",m_);const x_=[["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"}]],Rp=ce("globe",x_);const b_=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],v_=ce("heart",b_);const y_=[["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"}]],Ip=ce("history",y_);const w_=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],__=ce("info",w_);const k_=[["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"}]],vu=ce("layers",k_);const j_=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ye=ce("loader-circle",j_);const S_=[["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"}]],C_=ce("lock",S_);const N_=[["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"}]],ai=ce("message-square",N_);const T_=[["path",{d:"M5 12h14",key:"1ays0h"}]],Pp=ce("minus",T_);const E_=[["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"}]],A_=ce("monitor",E_);const R_=[["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"}]],I_=ce("moon",R_);const P_=[["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"}]],z_=ce("mouse-pointer-click",P_);const M_=[["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"}]],O_=ce("network",M_);const L_=[["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"}]],D_=ce("octagon-alert",L_);const $_=[["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"}]],F_=ce("package-check",$_);const U_=[["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"}]],B_=ce("panel-right-close",U_);const W_=[["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"}]],H_=ce("panel-right-open",W_);const V_=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],q_=ce("pause",V_);const Z_=[["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"}]],zp=ce("pencil",Z_);const G_=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],K_=ce("play",G_);const J_=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ma=ce("plus",J_);const Y_=[["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"}]],yu=ce("radio",Y_);const X_=[["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"}]],vn=ce("refresh-cw",X_);const Q_=[["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"}]],Mp=ce("rocket",Q_);const e5=[["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"}]],t5=ce("rotate-ccw",e5);const n5=[["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"}]],Ao=ce("rotate-cw",n5);const s5=[["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"}]],r5=ce("rows-3",s5);const o5=[["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"}]],i5=ce("save",o5);const a5=[["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"}]],l5=ce("scan",a5);const c5=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Op=ce("search",c5);const u5=[["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"}]],d5=ce("send",u5);const f5=[["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"}]],p5=ce("server",f5);const h5=[["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"}]],m5=ce("settings",h5);const g5=[["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"}]],x5=ce("shield-alert",g5);const b5=[["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"}]],wu=ce("shield-check",b5);const v5=[["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"}]],Oa=ce("siren",v5);const y5=[["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"}]],_u=ce("sparkles",y5);const w5=[["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"}]],_5=ce("sun",w5);const k5=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Fs=ce("terminal",k5);const j5=[["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=ce("timer",j5);const C5=[["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"}]],yn=ce("trash-2",C5);const N5=[["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"}]],bn=ce("triangle-alert",N5);const T5=[["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"}]],Lp=ce("upload",T5);const E5=[["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"}]],A5=ce("wifi-off",E5);const R5=[["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"}]],I5=ce("wifi",R5);const P5=[["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"}]],_r=ce("wrench",P5);const z5=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],kr=ce("x",z5);const M5=[["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"}]],cr=ce("zap",M5),La="/api/config";async function O5(e){return ht(e,oi,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function L5(e){return ht(La,oi,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function D5(){const e=qt(La,O5,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=wf(),n=e.data?.hasSeenOnboarding??!1,s=e.data?.captureMode??Wl,o=async()=>{await t(La,L5({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??No,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??To,timeDisplayFormat:e.data?.timeDisplayFormat??Eo,captureMode:s},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:n,captureMode:s,isLoading:e.isLoading,markSeen:o}}function $5(){const{hasSeenOnboarding:e,isLoading:t,markSeen:n}=D5(),[s,o]=p.useState(!1);if(t||e)return null;const i=s?"grid":"hidden sm:grid";return r.jsx("div",{role:"note","aria-label":"Onboarding tip",className:"mx-4 mt-2 mb-1 rounded-md border border-amber-500/30 bg-[#130d04] px-3 py-2 text-sm shadow-[0_12px_40px_rgba(0,0,0,0.16)]",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(__,{className:"mt-0.5 size-4 shrink-0 text-amber-300","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-amber-200",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:`${i} 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:()=>o(a=>!a),className:"inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-amber-500/30 px-2 text-xs text-amber-200 transition-colors hover:bg-amber-500/10 sm:hidden","aria-expanded":s,"aria-label":s?"Hide onboarding details":"Show onboarding details",children:r.jsx(rt,{className:`size-3.5 transition-transform ${s?"rotate-180":""}`})}),r.jsxs("button",{type:"button",onClick:()=>{n()},className:"hidden h-8 shrink-0 items-center gap-1.5 rounded-md border border-amber-500/40 px-3 text-xs text-amber-200 transition-colors hover:bg-amber-500/10 sm:inline-flex","aria-label":"Dismiss onboarding tip",children:[r.jsx(qe,{className:"size-3.5"}),"Got it"]}),r.jsx("button",{type:"button",onClick:()=>{n()},className:"-m-1 shrink-0 p-1 text-muted-foreground transition-colors hover:text-foreground","aria-label":"Dismiss",children:r.jsx(kr,{className:"size-3.5"})})]})})}function Dr(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Bi={exports:{}};var ku;function F5(){return ku||(ku=1,(function(e,t){(function(n){e.exports=n()})(function(){return(function n(s,o,i){function a(u,d){if(!o[u]){if(!s[u]){var f=typeof Dr=="function"&&Dr;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var m=new Error("Cannot find module '"+u+"'");throw m.code="MODULE_NOT_FOUND",m}var h=o[u]={exports:{}};s[u][0].call(h.exports,function(x){var g=s[u][1][x];return a(g||x)},h,h.exports,n,s,o,i)}return o[u].exports}for(var l=typeof Dr=="function"&&Dr,c=0;c<i.length;c++)a(i[c]);return a})({1:[function(n,s,o){var i=n("./utils"),a=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(c){for(var u,d,f,m,h,x,g,b=[],v=0,y=c.length,_=y,j=i.getTypeOf(c)!=="string";v<c.length;)_=y-v,f=j?(u=c[v++],d=v<y?c[v++]:0,v<y?c[v++]:0):(u=c.charCodeAt(v++),d=v<y?c.charCodeAt(v++):0,v<y?c.charCodeAt(v++):0),m=u>>2,h=(3&u)<<4|d>>4,x=1<_?(15&d)<<2|f>>6:64,g=2<_?63&f:64,b.push(l.charAt(m)+l.charAt(h)+l.charAt(x)+l.charAt(g));return b.join("")},o.decode=function(c){var u,d,f,m,h,x,g=0,b=0,v="data:";if(c.substr(0,v.length)===v)throw new Error("Invalid base64 input, it looks like a data url.");var y,_=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&_--,c.charAt(c.length-2)===l.charAt(64)&&_--,_%1!=0)throw new Error("Invalid base64 input, bad content length.");for(y=a.uint8array?new Uint8Array(0|_):new Array(0|_);g<c.length;)u=l.indexOf(c.charAt(g++))<<2|(m=l.indexOf(c.charAt(g++)))>>4,d=(15&m)<<4|(h=l.indexOf(c.charAt(g++)))>>2,f=(3&h)<<6|(x=l.indexOf(c.charAt(g++))),y[b++]=u,h!==64&&(y[b++]=d),x!==64&&(y[b++]=f);return y}},{"./support":30,"./utils":32}],2:[function(n,s,o){var i=n("./external"),a=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,m,h,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=m,this.compression=h,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new a(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new a(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,m){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(m)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},s.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,s,o){var i=n("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},o.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,s,o){var i=n("./utils"),a=(function(){for(var l,c=[],u=0;u<256;u++){l=u;for(var d=0;d<8;d++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c})();s.exports=function(l,c){return l!==void 0&&l.length?i.getTypeOf(l)!=="string"?(function(u,d,f,m){var h=a,x=m+f;u^=-1;for(var g=m;g<x;g++)u=u>>>8^h[255&(u^d[g])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,m){var h=a,x=m+f;u^=-1;for(var g=m;g<x;g++)u=u>>>8^h[255&(u^d.charCodeAt(g))];return-1^u})(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,s,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(n,s,o){var i=null;i=typeof Promise<"u"?Promise:n("lie"),s.exports={Promise:i}},{lie:37}],7:[function(n,s,o){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=i?"uint8array":"array";function d(f,m){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=m,this.meta={}}o.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,f.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(m){f.push({data:m,meta:f.meta})}},o.compressWorker=function(f){return new d("Deflate",f)},o.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,s,o){function i(h,x){var g,b="";for(g=0;g<x;g++)b+=String.fromCharCode(255&h),h>>>=8;return b}function a(h,x,g,b,v,y){var _,j,S=h.file,E=h.compression,T=y!==u.utf8encode,R=l.transformTo("string",y(S.name)),A=l.transformTo("string",u.utf8encode(S.name)),z=S.comment,H=l.transformTo("string",y(z)),N=l.transformTo("string",u.utf8encode(z)),L=A.length!==S.name.length,w=N.length!==z.length,$="",X="",B="",Q=S.dir,D=S.date,Z={crc32:0,compressedSize:0,uncompressedSize:0};x&&!g||(Z.crc32=h.crc32,Z.compressedSize=h.compressedSize,Z.uncompressedSize=h.uncompressedSize);var W=0;x&&(W|=8),T||!L&&!w||(W|=2048);var V=0,ue=0;Q&&(V|=16),v==="UNIX"?(ue=798,V|=(function(F,ge){var de=F;return F||(de=ge?16893:33204),(65535&de)<<16})(S.unixPermissions,Q)):(ue=20,V|=(function(F){return 63&(F||0)})(S.dosPermissions)),_=D.getUTCHours(),_<<=6,_|=D.getUTCMinutes(),_<<=5,_|=D.getUTCSeconds()/2,j=D.getUTCFullYear()-1980,j<<=4,j|=D.getUTCMonth()+1,j<<=5,j|=D.getUTCDate(),L&&(X=i(1,1)+i(d(R),4)+A,$+="up"+i(X.length,2)+X),w&&(B=i(1,1)+i(d(H),4)+N,$+="uc"+i(B.length,2)+B);var te="";return te+=`
66
- \0`,te+=i(W,2),te+=E.magic,te+=i(_,2),te+=i(j,2),te+=i(Z.crc32,4),te+=i(Z.compressedSize,4),te+=i(Z.uncompressedSize,4),te+=i(R.length,2),te+=i($.length,2),{fileRecord:f.LOCAL_FILE_HEADER+te+R+$,dirRecord:f.CENTRAL_FILE_HEADER+i(ue,2)+te+i(H.length,2)+"\0\0\0\0"+i(V,4)+i(b,4)+R+$+H}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function m(h,x,g,b){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=g,this.encodeFileName=b,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(m,c),m.prototype.push=function(h){var x=h.meta.percent||0,g=this.entriesCount,b=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,c.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:g?(x+100*(g-b-1))/g:100}}))},m.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var x=this.streamFiles&&!h.file.dir;if(x){var g=a(h,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(h){this.accumulate=!1;var x=this.streamFiles&&!h.file.dir,g=a(h,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),x)this.push({data:(function(b){return f.DATA_DESCRIPTOR+i(b.crc32,4)+i(b.compressedSize,4)+i(b.uncompressedSize,4)})(h),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var h=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var g=this.bytesWritten-h,b=(function(v,y,_,j,S){var E=l.transformTo("string",S(j));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(v,2)+i(v,2)+i(y,4)+i(_,4)+i(E.length,2)+E})(this.dirRecords.length,g,h,this.zipComment,this.encodeFileName);this.push({data:b,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(h){this._sources.push(h);var x=this;return h.on("data",function(g){x.processChunk(g)}),h.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),h.on("error",function(g){x.error(g)}),this},m.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},m.prototype.error=function(h){var x=this._sources;if(!c.prototype.error.call(this,h))return!1;for(var g=0;g<x.length;g++)try{x[g].error(h)}catch{}return!0},m.prototype.lock=function(){c.prototype.lock.call(this);for(var h=this._sources,x=0;x<h.length;x++)h[x].lock()},s.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,s,o){var i=n("../compressions"),a=n("./ZipFileWorker");o.generateWorker=function(l,c,u){var d=new a(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{l.forEach(function(m,h){f++;var x=(function(y,_){var j=y||_,S=i[j];if(!S)throw new Error(j+" is not a valid compression method !");return S})(h.options.compression,c.compression),g=h.options.compressionOptions||c.compressionOptions||{},b=h.dir,v=h.date;h._compressWorker(x,g).withStreamInfo("file",{name:m,dir:b,date:v,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(m){d.error(m)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,s,o){function i(){if(!(this instanceof i))return new i;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new i;for(var l in this)typeof this[l]!="function"&&(a[l]=this[l]);return a}}(i.prototype=n("./object")).loadAsync=n("./load"),i.support=n("./support"),i.defaults=n("./defaults"),i.version="3.10.1",i.loadAsync=function(a,l){return new i().loadAsync(a,l)},i.external=n("./external"),s.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,s,o){var i=n("./utils"),a=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(m){return new a.Promise(function(h,x){var g=m.decompressed.getContentWorker().pipe(new u);g.on("error",function(b){x(b)}).on("end",function(){g.streamInfo.crc32!==m.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}s.exports=function(m,h){var x=this;return h=i.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(m)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip file",m,!0,h.optimizedBinaryString,h.base64).then(function(g){var b=new c(h);return b.load(g),b}).then(function(g){var b=[a.Promise.resolve(g)],v=g.files;if(h.checkCRC32)for(var y=0;y<v.length;y++)b.push(f(v[y]));return a.Promise.all(b)}).then(function(g){for(var b=g.shift(),v=b.files,y=0;y<v.length;y++){var _=v[y],j=_.fileNameStr,S=i.resolve(_.fileNameStr);x.file(S,_.decompressed,{binary:!0,optimizedBinaryString:!0,date:_.date,dir:_.dir,comment:_.fileCommentStr.length?_.fileCommentStr:null,unixPermissions:_.unixPermissions,dosPermissions:_.dosPermissions,createFolders:h.createFolders}),_.dir||(x.file(S).unsafeOriginalName=j)}return b.zipComment.length&&(x.comment=b.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,s,o){var i=n("../utils"),a=n("../stream/GenericWorker");function l(c,u){a.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}i.inherits(l,a),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},s.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,s,o){var i=n("readable-stream").Readable;function a(l,c,u){i.call(this,c),this._helper=l;var d=this;l.on("data",function(f,m){d.push(f)||d._helper.pause(),u&&u(m)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(a,i),a.prototype._read=function(){this._helper.resume()},s.exports=a},{"../utils":32,"readable-stream":16}],14:[function(n,s,o){s.exports={isNode:typeof Buffer<"u",newBufferFrom:function(i,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(i,a);if(typeof i=="number")throw new Error('The "data" argument must not be a number');return new Buffer(i,a)},allocBuffer:function(i){if(Buffer.alloc)return Buffer.alloc(i);var a=new Buffer(i);return a.fill(0),a},isBuffer:function(i){return Buffer.isBuffer(i)},isStream:function(i){return i&&typeof i.on=="function"&&typeof i.pause=="function"&&typeof i.resume=="function"}}},{}],15:[function(n,s,o){function i(S,E,T){var R,A=l.getTypeOf(E),z=l.extend(T||{},d);z.date=z.date||new Date,z.compression!==null&&(z.compression=z.compression.toUpperCase()),typeof z.unixPermissions=="string"&&(z.unixPermissions=parseInt(z.unixPermissions,8)),z.unixPermissions&&16384&z.unixPermissions&&(z.dir=!0),z.dosPermissions&&16&z.dosPermissions&&(z.dir=!0),z.dir&&(S=v(S)),z.createFolders&&(R=b(S))&&y.call(this,R,!0);var H=A==="string"&&z.binary===!1&&z.base64===!1;T&&T.binary!==void 0||(z.binary=!H),(E instanceof f&&E.uncompressedSize===0||z.dir||!E||E.length===0)&&(z.base64=!1,z.binary=!0,E="",z.compression="STORE",A="string");var N=null;N=E instanceof f||E instanceof c?E:x.isNode&&x.isStream(E)?new g(S,E):l.prepareContent(S,E,z.binary,z.optimizedBinaryString,z.base64);var L=new m(S,N,z);this.files[S]=L}var a=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),m=n("./zipObject"),h=n("./generate"),x=n("./nodejsUtils"),g=n("./nodejs/NodejsStreamInputAdapter"),b=function(S){S.slice(-1)==="/"&&(S=S.substring(0,S.length-1));var E=S.lastIndexOf("/");return 0<E?S.substring(0,E):""},v=function(S){return S.slice(-1)!=="/"&&(S+="/"),S},y=function(S,E){return E=E!==void 0?E:d.createFolders,S=v(S),this.files[S]||i.call(this,S,null,{dir:!0,createFolders:E}),this.files[S]};function _(S){return Object.prototype.toString.call(S)==="[object RegExp]"}var j={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(S){var E,T,R;for(E in this.files)R=this.files[E],(T=E.slice(this.root.length,E.length))&&E.slice(0,this.root.length)===this.root&&S(T,R)},filter:function(S){var E=[];return this.forEach(function(T,R){S(T,R)&&E.push(R)}),E},file:function(S,E,T){if(arguments.length!==1)return S=this.root+S,i.call(this,S,E,T),this;if(_(S)){var R=S;return this.filter(function(z,H){return!H.dir&&R.test(z)})}var A=this.files[this.root+S];return A&&!A.dir?A:null},folder:function(S){if(!S)return this;if(_(S))return this.filter(function(A,z){return z.dir&&S.test(A)});var E=this.root+S,T=y.call(this,E),R=this.clone();return R.root=T.name,R},remove:function(S){S=this.root+S;var E=this.files[S];if(E||(S.slice(-1)!=="/"&&(S+="/"),E=this.files[S]),E&&!E.dir)delete this.files[S];else for(var T=this.filter(function(A,z){return z.name.slice(0,S.length)===S}),R=0;R<T.length;R++)delete this.files[T[R].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(S){var E,T={};try{if((T=l.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=T.type.toLowerCase(),T.compression=T.compression.toUpperCase(),T.type==="binarystring"&&(T.type="string"),!T.type)throw new Error("No output type specified.");l.checkSupport(T.type),T.platform!=="darwin"&&T.platform!=="freebsd"&&T.platform!=="linux"&&T.platform!=="sunos"||(T.platform="UNIX"),T.platform==="win32"&&(T.platform="DOS");var R=T.comment||this.comment||"";E=h.generateWorker(this,T,R)}catch(A){(E=new c("error")).error(A)}return new u(E,T.type||"string",T.mimeType)},generateAsync:function(S,E){return this.generateInternalStream(S).accumulate(E)},generateNodeStream:function(S,E){return(S=S||{}).type||(S.type="nodebuffer"),this.generateInternalStream(S).toNodejsStream(E)}};s.exports=j},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,s,o){s.exports=n("stream")},{stream:void 0}],17:[function(n,s,o){var i=n("./DataReader");function a(l){i.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(a,i),a.prototype.byteAt=function(l){return this.data[this.zero+l]},a.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),m=this.length-4;0<=m;--m)if(this.data[m]===c&&this.data[m+1]===u&&this.data[m+2]===d&&this.data[m+3]===f)return m-this.zero;return-1},a.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),m=this.readData(4);return c===m[0]&&u===m[1]&&d===m[2]&&f===m[3]},a.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},s.exports=a},{"../utils":32,"./DataReader":18}],18:[function(n,s,o){var i=n("../utils");function a(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return i.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},s.exports=a},{"../utils":32}],19:[function(n,s,o){var i=n("./Uint8ArrayReader");function a(l){i.call(this,l)}n("../utils").inherits(a,i),a.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},s.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,s,o){var i=n("./DataReader");function a(l){i.call(this,l)}n("../utils").inherits(a,i),a.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},a.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},a.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},a.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},s.exports=a},{"../utils":32,"./DataReader":18}],21:[function(n,s,o){var i=n("./ArrayReader");function a(l){i.call(this,l)}n("../utils").inherits(a,i),a.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},s.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(n,s,o){var i=n("../utils"),a=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");s.exports=function(f){var m=i.getTypeOf(f);return i.checkSupport(m),m!=="string"||a.uint8array?m==="nodebuffer"?new u(f):a.uint8array?new d(i.transformTo("uint8array",f)):new l(i.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,s,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,s,o){var i=n("./GenericWorker"),a=n("../utils");function l(c){i.call(this,"ConvertWorker to "+c),this.destType=c}a.inherits(l,i),l.prototype.processChunk=function(c){this.push({data:a.transformTo(this.destType,c.data),meta:c.meta})},s.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,s,o){var i=n("./GenericWorker"),a=n("../crc32");function l(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,i),l.prototype.processChunk=function(c){this.streamInfo.crc32=a(c.data,this.streamInfo.crc32||0),this.push(c)},s.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,s,o){var i=n("../utils"),a=n("./GenericWorker");function l(c){a.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}i.inherits(l,a),l.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}a.prototype.processChunk.call(this,c)},s.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,s,o){var i=n("../utils"),a=n("./GenericWorker");function l(c){a.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=i.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}i.inherits(l,a),l.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},s.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,s,o){function i(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,l){return this._listeners[a].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,l){if(this._listeners[a])for(var c=0;c<this._listeners[a].length;c++)this._listeners[a][c].call(this,l)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var l=this;return a.on("data",function(c){l.processChunk(c)}),a.on("end",function(){l.end()}),a.on("error",function(c){l.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,l){return this.extraStreamInfo[a]=l,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},s.exports=i},{}],29:[function(n,s,o){var i=n("../utils"),a=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function m(x,g){return new d.Promise(function(b,v){var y=[],_=x._internalType,j=x._outputType,S=x._mimeType;x.on("data",function(E,T){y.push(E),g&&g(T)}).on("error",function(E){y=[],v(E)}).on("end",function(){try{var E=(function(T,R,A){switch(T){case"blob":return i.newBlob(i.transformTo("arraybuffer",R),A);case"base64":return c.encode(R);default:return i.transformTo(T,R)}})(j,(function(T,R){var A,z=0,H=null,N=0;for(A=0;A<R.length;A++)N+=R[A].length;switch(T){case"string":return R.join("");case"array":return Array.prototype.concat.apply([],R);case"uint8array":for(H=new Uint8Array(N),A=0;A<R.length;A++)H.set(R[A],z),z+=R[A].length;return H;case"nodebuffer":return Buffer.concat(R);default:throw new Error("concat : unsupported type '"+T+"'")}})(_,y),S);b(E)}catch(T){v(T)}y=[]}).resume()})}function h(x,g,b){var v=g;switch(g){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=g,this._mimeType=b,i.checkSupport(v),this._worker=x.pipe(new a(v)),x.lock()}catch(y){this._worker=new l("error"),this._worker.error(y)}}h.prototype={accumulate:function(x){return m(this,x)},on:function(x,g){var b=this;return x==="data"?this._worker.on(x,function(v){g.call(b,v.data,v.meta)}):this._worker.on(x,function(){i.delay(g,arguments,b)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(i.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},x)}},s.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,s,o){if(o.base64=!0,o.array=!0,o.string=!0,o.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",o.nodebuffer=typeof Buffer<"u",o.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")o.blob=!1;else{var i=new ArrayBuffer(0);try{o.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(i),o.blob=a.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!n("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(n,s,o){for(var i=n("./utils"),a=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function m(){c.call(this,"utf-8 encode")}o.utf8encode=function(h){return a.nodebuffer?l.newBufferFrom(h,"utf-8"):(function(x){var g,b,v,y,_,j=x.length,S=0;for(y=0;y<j;y++)(64512&(b=x.charCodeAt(y)))==55296&&y+1<j&&(64512&(v=x.charCodeAt(y+1)))==56320&&(b=65536+(b-55296<<10)+(v-56320),y++),S+=b<128?1:b<2048?2:b<65536?3:4;for(g=a.uint8array?new Uint8Array(S):new Array(S),y=_=0;_<S;y++)(64512&(b=x.charCodeAt(y)))==55296&&y+1<j&&(64512&(v=x.charCodeAt(y+1)))==56320&&(b=65536+(b-55296<<10)+(v-56320),y++),b<128?g[_++]=b:(b<2048?g[_++]=192|b>>>6:(b<65536?g[_++]=224|b>>>12:(g[_++]=240|b>>>18,g[_++]=128|b>>>12&63),g[_++]=128|b>>>6&63),g[_++]=128|63&b);return g})(h)},o.utf8decode=function(h){return a.nodebuffer?i.transformTo("nodebuffer",h).toString("utf-8"):(function(x){var g,b,v,y,_=x.length,j=new Array(2*_);for(g=b=0;g<_;)if((v=x[g++])<128)j[b++]=v;else if(4<(y=u[v]))j[b++]=65533,g+=y-1;else{for(v&=y===2?31:y===3?15:7;1<y&&g<_;)v=v<<6|63&x[g++],y--;1<y?j[b++]=65533:v<65536?j[b++]=v:(v-=65536,j[b++]=55296|v>>10&1023,j[b++]=56320|1023&v)}return j.length!==b&&(j.subarray?j=j.subarray(0,b):j.length=b),i.applyFromCharCode(j)})(h=i.transformTo(a.uint8array?"uint8array":"array",h))},i.inherits(f,c),f.prototype.processChunk=function(h){var x=i.transformTo(a.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var g=x;(x=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),x.set(g,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var b=(function(y,_){var j;for((_=_||y.length)>y.length&&(_=y.length),j=_-1;0<=j&&(192&y[j])==128;)j--;return j<0||j===0?_:j+u[y[j]]>_?j:_})(x),v=x;b!==x.length&&(a.uint8array?(v=x.subarray(0,b),this.leftOver=x.subarray(b,x.length)):(v=x.slice(0,b),this.leftOver=x.slice(b,x.length))),this.push({data:o.utf8decode(v),meta:h.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=f,i.inherits(m,c),m.prototype.processChunk=function(h){this.push({data:o.utf8encode(h.data),meta:h.meta})},o.Utf8EncodeWorker=m},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,s,o){var i=n("./support"),a=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(g){return g}function d(g,b){for(var v=0;v<g.length;++v)b[v]=255&g.charCodeAt(v);return b}n("setimmediate"),o.newBlob=function(g,b){o.checkSupport("blob");try{return new Blob([g],{type:b})}catch{try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(g),v.getBlob(b)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(g,b,v){var y=[],_=0,j=g.length;if(j<=v)return String.fromCharCode.apply(null,g);for(;_<j;)b==="array"||b==="nodebuffer"?y.push(String.fromCharCode.apply(null,g.slice(_,Math.min(_+v,j)))):y.push(String.fromCharCode.apply(null,g.subarray(_,Math.min(_+v,j)))),_+=v;return y.join("")},stringifyByChar:function(g){for(var b="",v=0;v<g.length;v++)b+=String.fromCharCode(g[v]);return b},applyCanBeUsed:{uint8array:(function(){try{return i.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return i.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}})()}};function m(g){var b=65536,v=o.getTypeOf(g),y=!0;if(v==="uint8array"?y=f.applyCanBeUsed.uint8array:v==="nodebuffer"&&(y=f.applyCanBeUsed.nodebuffer),y)for(;1<b;)try{return f.stringifyByChunk(g,v,b)}catch{b=Math.floor(b/2)}return f.stringifyByChar(g)}function h(g,b){for(var v=0;v<g.length;v++)b[v]=g[v];return b}o.applyFromCharCode=m;var x={};x.string={string:u,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return x.string.uint8array(g).buffer},uint8array:function(g){return d(g,new Uint8Array(g.length))},nodebuffer:function(g){return d(g,l.allocBuffer(g.length))}},x.array={string:m,array:u,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return l.newBufferFrom(g)}},x.arraybuffer={string:function(g){return m(new Uint8Array(g))},array:function(g){return h(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:u,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return l.newBufferFrom(new Uint8Array(g))}},x.uint8array={string:m,array:function(g){return h(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:u,nodebuffer:function(g){return l.newBufferFrom(g)}},x.nodebuffer={string:m,array:function(g){return h(g,new Array(g.length))},arraybuffer:function(g){return x.nodebuffer.uint8array(g).buffer},uint8array:function(g){return h(g,new Uint8Array(g.length))},nodebuffer:u},o.transformTo=function(g,b){if(b=b||"",!g)return b;o.checkSupport(g);var v=o.getTypeOf(b);return x[v][g](b)},o.resolve=function(g){for(var b=g.split("/"),v=[],y=0;y<b.length;y++){var _=b[y];_==="."||_===""&&y!==0&&y!==b.length-1||(_===".."?v.pop():v.push(_))}return v.join("/")},o.getTypeOf=function(g){return typeof g=="string"?"string":Object.prototype.toString.call(g)==="[object Array]"?"array":i.nodebuffer&&l.isBuffer(g)?"nodebuffer":i.uint8array&&g instanceof Uint8Array?"uint8array":i.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},o.checkSupport=function(g){if(!i[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},o.MAX_VALUE_16BITS=65535,o.MAX_VALUE_32BITS=-1,o.pretty=function(g){var b,v,y="";for(v=0;v<(g||"").length;v++)y+="\\x"+((b=g.charCodeAt(v))<16?"0":"")+b.toString(16).toUpperCase();return y},o.delay=function(g,b,v){setImmediate(function(){g.apply(v||null,b||[])})},o.inherits=function(g,b){function v(){}v.prototype=b.prototype,g.prototype=new v},o.extend=function(){var g,b,v={};for(g=0;g<arguments.length;g++)for(b in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],b)&&v[b]===void 0&&(v[b]=arguments[g][b]);return v},o.prepareContent=function(g,b,v,y,_){return c.Promise.resolve(b).then(function(j){return i.blob&&(j instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(j))!==-1)&&typeof FileReader<"u"?new c.Promise(function(S,E){var T=new FileReader;T.onload=function(R){S(R.target.result)},T.onerror=function(R){E(R.target.error)},T.readAsArrayBuffer(j)}):j}).then(function(j){var S=o.getTypeOf(j);return S?(S==="arraybuffer"?j=o.transformTo("uint8array",j):S==="string"&&(_?j=a.decode(j):v&&y!==!0&&(j=(function(E){return d(E,i.uint8array?new Uint8Array(E.length):new Array(E.length))})(j))),j):c.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,s,o){var i=n("./reader/readerFor"),a=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(m)+", expected "+a.pretty(f)+")")}},isSignature:function(f,m){var h=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===m;return this.reader.setIndex(h),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),m=u.uint8array?"uint8array":"array",h=a.transformTo(m,f);this.zipComment=this.loadOptions.decodeFileName(h)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,m,h,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),m=this.reader.readInt(4),h=this.reader.readData(m),this.zip64ExtensibleData[f]={id:f,length:m,value:h}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,m;for(f=0;f<this.files.length;f++)m=this.files[f],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(f=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,l.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var m=f;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var x=m-h;if(0<x)this.isSignature(m,l.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(f){this.reader=i(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},s.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,s,o){var i=n("./reader/readerFor"),a=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function m(h,x){this.options=h,this.loadOptions=x}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var x,g;if(h.skip(22),this.fileNameLength=h.readInt(2),g=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(g),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(b){for(var v in d)if(Object.prototype.hasOwnProperty.call(d,v)&&d[v].magic===b)return d[v];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,x,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var x=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(x),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=i(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var x,g,b,v=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<v;)x=h.readInt(2),g=h.readInt(2),b=h.readData(g),this.extraFields[x]={id:x,length:g,value:b};h.setIndex(v)},handleUTF8:function(){var h=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var g=a.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var b=this.findExtraFieldUnicodeComment();if(b!==null)this.fileCommentStr=b;else{var v=a.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var x=i(h.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var x=i(h.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(h.length-5))}return null}},s.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,s,o){function i(x,g,b){this.name=x,this.dir=b.dir,this.date=b.date,this.comment=b.comment,this.unixPermissions=b.unixPermissions,this.dosPermissions=b.dosPermissions,this._data=g,this._dataBinary=b.binary,this.options={compression:b.compression,compressionOptions:b.compressionOptions}}var a=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");i.prototype={internalStream:function(x){var g=null,b="string";try{if(!x)throw new Error("No output type specified.");var v=(b=x.toLowerCase())==="string"||b==="text";b!=="binarystring"&&b!=="text"||(b="string"),g=this._decompressWorker();var y=!this._dataBinary;y&&!v&&(g=g.pipe(new c.Utf8EncodeWorker)),!y&&v&&(g=g.pipe(new c.Utf8DecodeWorker))}catch(_){(g=new d("error")).error(_)}return new a(g,b,"")},async:function(x,g){return this.internalStream(x).accumulate(g)},nodeStream:function(x,g){return this.internalStream(x||"nodebuffer").toNodejsStream(g)},_compressWorker:function(x,g){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var b=this._decompressWorker();return this._dataBinary||(b=b.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(b,x,g)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<f.length;h++)i.prototype[f[h]]=m;s.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,s,o){(function(i){var a,l,c=i.MutationObserver||i.WebKitMutationObserver;if(c){var u=0,d=new c(x),f=i.document.createTextNode("");d.observe(f,{characterData:!0}),a=function(){f.data=u=++u%2}}else if(i.setImmediate||i.MessageChannel===void 0)a="document"in i&&"onreadystatechange"in i.document.createElement("script")?function(){var g=i.document.createElement("script");g.onreadystatechange=function(){x(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},i.document.documentElement.appendChild(g)}:function(){setTimeout(x,0)};else{var m=new i.MessageChannel;m.port1.onmessage=x,a=function(){m.port2.postMessage(0)}}var h=[];function x(){var g,b;l=!0;for(var v=h.length;v;){for(b=h,h=[],g=-1;++g<v;)b[g]();v=h.length}l=!1}s.exports=function(g){h.push(g)!==1||l||a()}}).call(this,typeof Pr<"u"?Pr:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,s,o){var i=n("immediate");function a(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,v!==a&&g(this,v)}function m(v,y,_){this.promise=v,typeof y=="function"&&(this.onFulfilled=y,this.callFulfilled=this.otherCallFulfilled),typeof _=="function"&&(this.onRejected=_,this.callRejected=this.otherCallRejected)}function h(v,y,_){i(function(){var j;try{j=y(_)}catch(S){return l.reject(v,S)}j===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,j)})}function x(v){var y=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof y=="function")return function(){y.apply(v,arguments)}}function g(v,y){var _=!1;function j(T){_||(_=!0,l.reject(v,T))}function S(T){_||(_=!0,l.resolve(v,T))}var E=b(function(){y(S,j)});E.status==="error"&&j(E.value)}function b(v,y){var _={};try{_.value=v(y),_.status="success"}catch(j){_.status="error",_.value=j}return _}(s.exports=f).prototype.finally=function(v){if(typeof v!="function")return this;var y=this.constructor;return this.then(function(_){return y.resolve(v()).then(function(){return _})},function(_){return y.resolve(v()).then(function(){throw _})})},f.prototype.catch=function(v){return this.then(null,v)},f.prototype.then=function(v,y){if(typeof v!="function"&&this.state===u||typeof y!="function"&&this.state===c)return this;var _=new this.constructor(a);return this.state!==d?h(_,this.state===u?v:y,this.outcome):this.queue.push(new m(_,v,y)),_},m.prototype.callFulfilled=function(v){l.resolve(this.promise,v)},m.prototype.otherCallFulfilled=function(v){h(this.promise,this.onFulfilled,v)},m.prototype.callRejected=function(v){l.reject(this.promise,v)},m.prototype.otherCallRejected=function(v){h(this.promise,this.onRejected,v)},l.resolve=function(v,y){var _=b(x,y);if(_.status==="error")return l.reject(v,_.value);var j=_.value;if(j)g(v,j);else{v.state=u,v.outcome=y;for(var S=-1,E=v.queue.length;++S<E;)v.queue[S].callFulfilled(y)}return v},l.reject=function(v,y){v.state=c,v.outcome=y;for(var _=-1,j=v.queue.length;++_<j;)v.queue[_].callRejected(y);return v},f.resolve=function(v){return v instanceof this?v:l.resolve(new this(a),v)},f.reject=function(v){var y=new this(a);return l.reject(y,v)},f.all=function(v){var y=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var _=v.length,j=!1;if(!_)return this.resolve([]);for(var S=new Array(_),E=0,T=-1,R=new this(a);++T<_;)A(v[T],T);return R;function A(z,H){y.resolve(z).then(function(N){S[H]=N,++E!==_||j||(j=!0,l.resolve(R,S))},function(N){j||(j=!0,l.reject(R,N))})}},f.race=function(v){var y=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var _=v.length,j=!1;if(!_)return this.resolve([]);for(var S=-1,E=new this(a);++S<_;)T=v[S],y.resolve(T).then(function(R){j||(j=!0,l.resolve(E,R))},function(R){j||(j=!0,l.reject(E,R))});var T;return E}},{immediate:36}],38:[function(n,s,o){var i={};(0,n("./lib/utils/common").assign)(i,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),s.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,s,o){var i=n("./zlib/deflate"),a=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,m=-1,h=0,x=8;function g(v){if(!(this instanceof g))return new g(v);this.options=a.assign({level:m,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},v||{});var y=this.options;y.raw&&0<y.windowBits?y.windowBits=-y.windowBits:y.gzip&&0<y.windowBits&&y.windowBits<16&&(y.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var _=i.deflateInit2(this.strm,y.level,y.method,y.windowBits,y.memLevel,y.strategy);if(_!==f)throw new Error(c[_]);if(y.header&&i.deflateSetHeader(this.strm,y.header),y.dictionary){var j;if(j=typeof y.dictionary=="string"?l.string2buf(y.dictionary):d.call(y.dictionary)==="[object ArrayBuffer]"?new Uint8Array(y.dictionary):y.dictionary,(_=i.deflateSetDictionary(this.strm,j))!==f)throw new Error(c[_]);this._dict_set=!0}}function b(v,y){var _=new g(y);if(_.push(v,!0),_.err)throw _.msg||c[_.err];return _.result}g.prototype.push=function(v,y){var _,j,S=this.strm,E=this.options.chunkSize;if(this.ended)return!1;j=y===~~y?y:y===!0?4:0,typeof v=="string"?S.input=l.string2buf(v):d.call(v)==="[object ArrayBuffer]"?S.input=new Uint8Array(v):S.input=v,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new a.Buf8(E),S.next_out=0,S.avail_out=E),(_=i.deflate(S,j))!==1&&_!==f)return this.onEnd(_),!(this.ended=!0);S.avail_out!==0&&(S.avail_in!==0||j!==4&&j!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(a.shrinkBuf(S.output,S.next_out))):this.onData(a.shrinkBuf(S.output,S.next_out)))}while((0<S.avail_in||S.avail_out===0)&&_!==1);return j===4?(_=i.deflateEnd(this.strm),this.onEnd(_),this.ended=!0,_===f):j!==2||(this.onEnd(f),!(S.avail_out=0))},g.prototype.onData=function(v){this.chunks.push(v)},g.prototype.onEnd=function(v){v===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},o.Deflate=g,o.deflate=b,o.deflateRaw=function(v,y){return(y=y||{}).raw=!0,b(v,y)},o.gzip=function(v,y){return(y=y||{}).gzip=!0,b(v,y)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,s,o){var i=n("./zlib/inflate"),a=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),m=Object.prototype.toString;function h(g){if(!(this instanceof h))return new h(g);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},g||{});var b=this.options;b.raw&&0<=b.windowBits&&b.windowBits<16&&(b.windowBits=-b.windowBits,b.windowBits===0&&(b.windowBits=-15)),!(0<=b.windowBits&&b.windowBits<16)||g&&g.windowBits||(b.windowBits+=32),15<b.windowBits&&b.windowBits<48&&(15&b.windowBits)==0&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var v=i.inflateInit2(this.strm,b.windowBits);if(v!==c.Z_OK)throw new Error(u[v]);this.header=new f,i.inflateGetHeader(this.strm,this.header)}function x(g,b){var v=new h(b);if(v.push(g,!0),v.err)throw v.msg||u[v.err];return v.result}h.prototype.push=function(g,b){var v,y,_,j,S,E,T=this.strm,R=this.options.chunkSize,A=this.options.dictionary,z=!1;if(this.ended)return!1;y=b===~~b?b:b===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof g=="string"?T.input=l.binstring2buf(g):m.call(g)==="[object ArrayBuffer]"?T.input=new Uint8Array(g):T.input=g,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new a.Buf8(R),T.next_out=0,T.avail_out=R),(v=i.inflate(T,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&A&&(E=typeof A=="string"?l.string2buf(A):m.call(A)==="[object ArrayBuffer]"?new Uint8Array(A):A,v=i.inflateSetDictionary(this.strm,E)),v===c.Z_BUF_ERROR&&z===!0&&(v=c.Z_OK,z=!1),v!==c.Z_STREAM_END&&v!==c.Z_OK)return this.onEnd(v),!(this.ended=!0);T.next_out&&(T.avail_out!==0&&v!==c.Z_STREAM_END&&(T.avail_in!==0||y!==c.Z_FINISH&&y!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(_=l.utf8border(T.output,T.next_out),j=T.next_out-_,S=l.buf2string(T.output,_),T.next_out=j,T.avail_out=R-j,j&&a.arraySet(T.output,T.output,_,j,0),this.onData(S)):this.onData(a.shrinkBuf(T.output,T.next_out)))),T.avail_in===0&&T.avail_out===0&&(z=!0)}while((0<T.avail_in||T.avail_out===0)&&v!==c.Z_STREAM_END);return v===c.Z_STREAM_END&&(y=c.Z_FINISH),y===c.Z_FINISH?(v=i.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===c.Z_OK):y!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(T.avail_out=0))},h.prototype.onData=function(g){this.chunks.push(g)},h.prototype.onEnd=function(g){g===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},o.Inflate=h,o.inflate=x,o.inflateRaw=function(g,b){return(b=b||{}).raw=!0,x(g,b)},o.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,s,o){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";o.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},o.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var a={arraySet:function(c,u,d,f,m){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),m);else for(var h=0;h<f;h++)c[m+h]=u[d+h]},flattenChunks:function(c){var u,d,f,m,h,x;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(x=new Uint8Array(f),u=m=0,d=c.length;u<d;u++)h=c[u],x.set(h,m),m+=h.length;return x}},l={arraySet:function(c,u,d,f,m){for(var h=0;h<f;h++)c[m+h]=u[d+h]},flattenChunks:function(c){return[].concat.apply([],c)}};o.setTyped=function(c){c?(o.Buf8=Uint8Array,o.Buf16=Uint16Array,o.Buf32=Int32Array,o.assign(o,a)):(o.Buf8=Array,o.Buf16=Array,o.Buf32=Array,o.assign(o,l))},o.setTyped(i)},{}],42:[function(n,s,o){var i=n("./common"),a=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new i.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,m){if(m<65537&&(f.subarray&&l||!f.subarray&&a))return String.fromCharCode.apply(null,i.shrinkBuf(f,m));for(var h="",x=0;x<m;x++)h+=String.fromCharCode(f[x]);return h}c[254]=c[254]=1,o.string2buf=function(f){var m,h,x,g,b,v=f.length,y=0;for(g=0;g<v;g++)(64512&(h=f.charCodeAt(g)))==55296&&g+1<v&&(64512&(x=f.charCodeAt(g+1)))==56320&&(h=65536+(h-55296<<10)+(x-56320),g++),y+=h<128?1:h<2048?2:h<65536?3:4;for(m=new i.Buf8(y),g=b=0;b<y;g++)(64512&(h=f.charCodeAt(g)))==55296&&g+1<v&&(64512&(x=f.charCodeAt(g+1)))==56320&&(h=65536+(h-55296<<10)+(x-56320),g++),h<128?m[b++]=h:(h<2048?m[b++]=192|h>>>6:(h<65536?m[b++]=224|h>>>12:(m[b++]=240|h>>>18,m[b++]=128|h>>>12&63),m[b++]=128|h>>>6&63),m[b++]=128|63&h);return m},o.buf2binstring=function(f){return d(f,f.length)},o.binstring2buf=function(f){for(var m=new i.Buf8(f.length),h=0,x=m.length;h<x;h++)m[h]=f.charCodeAt(h);return m},o.buf2string=function(f,m){var h,x,g,b,v=m||f.length,y=new Array(2*v);for(h=x=0;h<v;)if((g=f[h++])<128)y[x++]=g;else if(4<(b=c[g]))y[x++]=65533,h+=b-1;else{for(g&=b===2?31:b===3?15:7;1<b&&h<v;)g=g<<6|63&f[h++],b--;1<b?y[x++]=65533:g<65536?y[x++]=g:(g-=65536,y[x++]=55296|g>>10&1023,y[x++]=56320|1023&g)}return d(y,x)},o.utf8border=function(f,m){var h;for((m=m||f.length)>f.length&&(m=f.length),h=m-1;0<=h&&(192&f[h])==128;)h--;return h<0||h===0?m:h+c[f[h]]>m?h:m}},{"./common":41}],43:[function(n,s,o){s.exports=function(i,a,l,c){for(var u=65535&i|0,d=i>>>16&65535|0,f=0;l!==0;){for(l-=f=2e3<l?2e3:l;d=d+(u=u+a[c++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,s,o){s.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,s,o){var i=(function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l})();s.exports=function(a,l,c,u){var d=i,f=u+c;a^=-1;for(var m=u;m<f;m++)a=a>>>8^d[255&(a^l[m])];return-1^a}},{}],46:[function(n,s,o){var i,a=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,m=4,h=0,x=-2,g=-1,b=4,v=2,y=8,_=9,j=286,S=30,E=19,T=2*j+1,R=15,A=3,z=258,H=z+A+1,N=42,L=113,w=1,$=2,X=3,B=4;function Q(k,ee){return k.msg=d[ee],ee}function D(k){return(k<<1)-(4<k?9:0)}function Z(k){for(var ee=k.length;0<=--ee;)k[ee]=0}function W(k){var ee=k.state,K=ee.pending;K>k.avail_out&&(K=k.avail_out),K!==0&&(a.arraySet(k.output,ee.pending_buf,ee.pending_out,K,k.next_out),k.next_out+=K,ee.pending_out+=K,k.total_out+=K,k.avail_out-=K,ee.pending-=K,ee.pending===0&&(ee.pending_out=0))}function V(k,ee){l._tr_flush_block(k,0<=k.block_start?k.block_start:-1,k.strstart-k.block_start,ee),k.block_start=k.strstart,W(k.strm)}function ue(k,ee){k.pending_buf[k.pending++]=ee}function te(k,ee){k.pending_buf[k.pending++]=ee>>>8&255,k.pending_buf[k.pending++]=255&ee}function F(k,ee){var K,M,P=k.max_chain_length,U=k.strstart,re=k.prev_length,se=k.nice_match,q=k.strstart>k.w_size-H?k.strstart-(k.w_size-H):0,ae=k.window,I=k.w_mask,O=k.prev,Y=k.strstart+z,ie=ae[U+re-1],le=ae[U+re];k.prev_length>=k.good_match&&(P>>=2),se>k.lookahead&&(se=k.lookahead);do if(ae[(K=ee)+re]===le&&ae[K+re-1]===ie&&ae[K]===ae[U]&&ae[++K]===ae[U+1]){U+=2,K++;do;while(ae[++U]===ae[++K]&&ae[++U]===ae[++K]&&ae[++U]===ae[++K]&&ae[++U]===ae[++K]&&ae[++U]===ae[++K]&&ae[++U]===ae[++K]&&ae[++U]===ae[++K]&&ae[++U]===ae[++K]&&U<Y);if(M=z-(Y-U),U=Y-z,re<M){if(k.match_start=ee,se<=(re=M))break;ie=ae[U+re-1],le=ae[U+re]}}while((ee=O[ee&I])>q&&--P!=0);return re<=k.lookahead?re:k.lookahead}function ge(k){var ee,K,M,P,U,re,se,q,ae,I,O=k.w_size;do{if(P=k.window_size-k.lookahead-k.strstart,k.strstart>=O+(O-H)){for(a.arraySet(k.window,k.window,O,O,0),k.match_start-=O,k.strstart-=O,k.block_start-=O,ee=K=k.hash_size;M=k.head[--ee],k.head[ee]=O<=M?M-O:0,--K;);for(ee=K=O;M=k.prev[--ee],k.prev[ee]=O<=M?M-O:0,--K;);P+=O}if(k.strm.avail_in===0)break;if(re=k.strm,se=k.window,q=k.strstart+k.lookahead,ae=P,I=void 0,I=re.avail_in,ae<I&&(I=ae),K=I===0?0:(re.avail_in-=I,a.arraySet(se,re.input,re.next_in,I,q),re.state.wrap===1?re.adler=c(re.adler,se,I,q):re.state.wrap===2&&(re.adler=u(re.adler,se,I,q)),re.next_in+=I,re.total_in+=I,I),k.lookahead+=K,k.lookahead+k.insert>=A)for(U=k.strstart-k.insert,k.ins_h=k.window[U],k.ins_h=(k.ins_h<<k.hash_shift^k.window[U+1])&k.hash_mask;k.insert&&(k.ins_h=(k.ins_h<<k.hash_shift^k.window[U+A-1])&k.hash_mask,k.prev[U&k.w_mask]=k.head[k.ins_h],k.head[k.ins_h]=U,U++,k.insert--,!(k.lookahead+k.insert<A)););}while(k.lookahead<H&&k.strm.avail_in!==0)}function de(k,ee){for(var K,M;;){if(k.lookahead<H){if(ge(k),k.lookahead<H&&ee===f)return w;if(k.lookahead===0)break}if(K=0,k.lookahead>=A&&(k.ins_h=(k.ins_h<<k.hash_shift^k.window[k.strstart+A-1])&k.hash_mask,K=k.prev[k.strstart&k.w_mask]=k.head[k.ins_h],k.head[k.ins_h]=k.strstart),K!==0&&k.strstart-K<=k.w_size-H&&(k.match_length=F(k,K)),k.match_length>=A)if(M=l._tr_tally(k,k.strstart-k.match_start,k.match_length-A),k.lookahead-=k.match_length,k.match_length<=k.max_lazy_match&&k.lookahead>=A){for(k.match_length--;k.strstart++,k.ins_h=(k.ins_h<<k.hash_shift^k.window[k.strstart+A-1])&k.hash_mask,K=k.prev[k.strstart&k.w_mask]=k.head[k.ins_h],k.head[k.ins_h]=k.strstart,--k.match_length!=0;);k.strstart++}else k.strstart+=k.match_length,k.match_length=0,k.ins_h=k.window[k.strstart],k.ins_h=(k.ins_h<<k.hash_shift^k.window[k.strstart+1])&k.hash_mask;else M=l._tr_tally(k,0,k.window[k.strstart]),k.lookahead--,k.strstart++;if(M&&(V(k,!1),k.strm.avail_out===0))return w}return k.insert=k.strstart<A-1?k.strstart:A-1,ee===m?(V(k,!0),k.strm.avail_out===0?X:B):k.last_lit&&(V(k,!1),k.strm.avail_out===0)?w:$}function pe(k,ee){for(var K,M,P;;){if(k.lookahead<H){if(ge(k),k.lookahead<H&&ee===f)return w;if(k.lookahead===0)break}if(K=0,k.lookahead>=A&&(k.ins_h=(k.ins_h<<k.hash_shift^k.window[k.strstart+A-1])&k.hash_mask,K=k.prev[k.strstart&k.w_mask]=k.head[k.ins_h],k.head[k.ins_h]=k.strstart),k.prev_length=k.match_length,k.prev_match=k.match_start,k.match_length=A-1,K!==0&&k.prev_length<k.max_lazy_match&&k.strstart-K<=k.w_size-H&&(k.match_length=F(k,K),k.match_length<=5&&(k.strategy===1||k.match_length===A&&4096<k.strstart-k.match_start)&&(k.match_length=A-1)),k.prev_length>=A&&k.match_length<=k.prev_length){for(P=k.strstart+k.lookahead-A,M=l._tr_tally(k,k.strstart-1-k.prev_match,k.prev_length-A),k.lookahead-=k.prev_length-1,k.prev_length-=2;++k.strstart<=P&&(k.ins_h=(k.ins_h<<k.hash_shift^k.window[k.strstart+A-1])&k.hash_mask,K=k.prev[k.strstart&k.w_mask]=k.head[k.ins_h],k.head[k.ins_h]=k.strstart),--k.prev_length!=0;);if(k.match_available=0,k.match_length=A-1,k.strstart++,M&&(V(k,!1),k.strm.avail_out===0))return w}else if(k.match_available){if((M=l._tr_tally(k,0,k.window[k.strstart-1]))&&V(k,!1),k.strstart++,k.lookahead--,k.strm.avail_out===0)return w}else k.match_available=1,k.strstart++,k.lookahead--}return k.match_available&&(M=l._tr_tally(k,0,k.window[k.strstart-1]),k.match_available=0),k.insert=k.strstart<A-1?k.strstart:A-1,ee===m?(V(k,!0),k.strm.avail_out===0?X:B):k.last_lit&&(V(k,!1),k.strm.avail_out===0)?w:$}function me(k,ee,K,M,P){this.good_length=k,this.max_lazy=ee,this.nice_length=K,this.max_chain=M,this.func=P}function ve(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=y,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*T),this.dyn_dtree=new a.Buf16(2*(2*S+1)),this.bl_tree=new a.Buf16(2*(2*E+1)),Z(this.dyn_ltree),Z(this.dyn_dtree),Z(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(R+1),this.heap=new a.Buf16(2*j+1),Z(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*j+1),Z(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function xe(k){var ee;return k&&k.state?(k.total_in=k.total_out=0,k.data_type=v,(ee=k.state).pending=0,ee.pending_out=0,ee.wrap<0&&(ee.wrap=-ee.wrap),ee.status=ee.wrap?N:L,k.adler=ee.wrap===2?0:1,ee.last_flush=f,l._tr_init(ee),h):Q(k,x)}function Ce(k){var ee=xe(k);return ee===h&&(function(K){K.window_size=2*K.w_size,Z(K.head),K.max_lazy_match=i[K.level].max_lazy,K.good_match=i[K.level].good_length,K.nice_match=i[K.level].nice_length,K.max_chain_length=i[K.level].max_chain,K.strstart=0,K.block_start=0,K.lookahead=0,K.insert=0,K.match_length=K.prev_length=A-1,K.match_available=0,K.ins_h=0})(k.state),ee}function Ae(k,ee,K,M,P,U){if(!k)return x;var re=1;if(ee===g&&(ee=6),M<0?(re=0,M=-M):15<M&&(re=2,M-=16),P<1||_<P||K!==y||M<8||15<M||ee<0||9<ee||U<0||b<U)return Q(k,x);M===8&&(M=9);var se=new ve;return(k.state=se).strm=k,se.wrap=re,se.gzhead=null,se.w_bits=M,se.w_size=1<<se.w_bits,se.w_mask=se.w_size-1,se.hash_bits=P+7,se.hash_size=1<<se.hash_bits,se.hash_mask=se.hash_size-1,se.hash_shift=~~((se.hash_bits+A-1)/A),se.window=new a.Buf8(2*se.w_size),se.head=new a.Buf16(se.hash_size),se.prev=new a.Buf16(se.w_size),se.lit_bufsize=1<<P+6,se.pending_buf_size=4*se.lit_bufsize,se.pending_buf=new a.Buf8(se.pending_buf_size),se.d_buf=1*se.lit_bufsize,se.l_buf=3*se.lit_bufsize,se.level=ee,se.strategy=U,se.method=K,Ce(k)}i=[new me(0,0,0,0,function(k,ee){var K=65535;for(K>k.pending_buf_size-5&&(K=k.pending_buf_size-5);;){if(k.lookahead<=1){if(ge(k),k.lookahead===0&&ee===f)return w;if(k.lookahead===0)break}k.strstart+=k.lookahead,k.lookahead=0;var M=k.block_start+K;if((k.strstart===0||k.strstart>=M)&&(k.lookahead=k.strstart-M,k.strstart=M,V(k,!1),k.strm.avail_out===0)||k.strstart-k.block_start>=k.w_size-H&&(V(k,!1),k.strm.avail_out===0))return w}return k.insert=0,ee===m?(V(k,!0),k.strm.avail_out===0?X:B):(k.strstart>k.block_start&&(V(k,!1),k.strm.avail_out),w)}),new me(4,4,8,4,de),new me(4,5,16,8,de),new me(4,6,32,32,de),new me(4,4,16,16,pe),new me(8,16,32,32,pe),new me(8,16,128,128,pe),new me(8,32,128,256,pe),new me(32,128,258,1024,pe),new me(32,258,258,4096,pe)],o.deflateInit=function(k,ee){return Ae(k,ee,y,15,8,0)},o.deflateInit2=Ae,o.deflateReset=Ce,o.deflateResetKeep=xe,o.deflateSetHeader=function(k,ee){return k&&k.state?k.state.wrap!==2?x:(k.state.gzhead=ee,h):x},o.deflate=function(k,ee){var K,M,P,U;if(!k||!k.state||5<ee||ee<0)return k?Q(k,x):x;if(M=k.state,!k.output||!k.input&&k.avail_in!==0||M.status===666&&ee!==m)return Q(k,k.avail_out===0?-5:x);if(M.strm=k,K=M.last_flush,M.last_flush=ee,M.status===N)if(M.wrap===2)k.adler=0,ue(M,31),ue(M,139),ue(M,8),M.gzhead?(ue(M,(M.gzhead.text?1:0)+(M.gzhead.hcrc?2:0)+(M.gzhead.extra?4:0)+(M.gzhead.name?8:0)+(M.gzhead.comment?16:0)),ue(M,255&M.gzhead.time),ue(M,M.gzhead.time>>8&255),ue(M,M.gzhead.time>>16&255),ue(M,M.gzhead.time>>24&255),ue(M,M.level===9?2:2<=M.strategy||M.level<2?4:0),ue(M,255&M.gzhead.os),M.gzhead.extra&&M.gzhead.extra.length&&(ue(M,255&M.gzhead.extra.length),ue(M,M.gzhead.extra.length>>8&255)),M.gzhead.hcrc&&(k.adler=u(k.adler,M.pending_buf,M.pending,0)),M.gzindex=0,M.status=69):(ue(M,0),ue(M,0),ue(M,0),ue(M,0),ue(M,0),ue(M,M.level===9?2:2<=M.strategy||M.level<2?4:0),ue(M,3),M.status=L);else{var re=y+(M.w_bits-8<<4)<<8;re|=(2<=M.strategy||M.level<2?0:M.level<6?1:M.level===6?2:3)<<6,M.strstart!==0&&(re|=32),re+=31-re%31,M.status=L,te(M,re),M.strstart!==0&&(te(M,k.adler>>>16),te(M,65535&k.adler)),k.adler=1}if(M.status===69)if(M.gzhead.extra){for(P=M.pending;M.gzindex<(65535&M.gzhead.extra.length)&&(M.pending!==M.pending_buf_size||(M.gzhead.hcrc&&M.pending>P&&(k.adler=u(k.adler,M.pending_buf,M.pending-P,P)),W(k),P=M.pending,M.pending!==M.pending_buf_size));)ue(M,255&M.gzhead.extra[M.gzindex]),M.gzindex++;M.gzhead.hcrc&&M.pending>P&&(k.adler=u(k.adler,M.pending_buf,M.pending-P,P)),M.gzindex===M.gzhead.extra.length&&(M.gzindex=0,M.status=73)}else M.status=73;if(M.status===73)if(M.gzhead.name){P=M.pending;do{if(M.pending===M.pending_buf_size&&(M.gzhead.hcrc&&M.pending>P&&(k.adler=u(k.adler,M.pending_buf,M.pending-P,P)),W(k),P=M.pending,M.pending===M.pending_buf_size)){U=1;break}U=M.gzindex<M.gzhead.name.length?255&M.gzhead.name.charCodeAt(M.gzindex++):0,ue(M,U)}while(U!==0);M.gzhead.hcrc&&M.pending>P&&(k.adler=u(k.adler,M.pending_buf,M.pending-P,P)),U===0&&(M.gzindex=0,M.status=91)}else M.status=91;if(M.status===91)if(M.gzhead.comment){P=M.pending;do{if(M.pending===M.pending_buf_size&&(M.gzhead.hcrc&&M.pending>P&&(k.adler=u(k.adler,M.pending_buf,M.pending-P,P)),W(k),P=M.pending,M.pending===M.pending_buf_size)){U=1;break}U=M.gzindex<M.gzhead.comment.length?255&M.gzhead.comment.charCodeAt(M.gzindex++):0,ue(M,U)}while(U!==0);M.gzhead.hcrc&&M.pending>P&&(k.adler=u(k.adler,M.pending_buf,M.pending-P,P)),U===0&&(M.status=103)}else M.status=103;if(M.status===103&&(M.gzhead.hcrc?(M.pending+2>M.pending_buf_size&&W(k),M.pending+2<=M.pending_buf_size&&(ue(M,255&k.adler),ue(M,k.adler>>8&255),k.adler=0,M.status=L)):M.status=L),M.pending!==0){if(W(k),k.avail_out===0)return M.last_flush=-1,h}else if(k.avail_in===0&&D(ee)<=D(K)&&ee!==m)return Q(k,-5);if(M.status===666&&k.avail_in!==0)return Q(k,-5);if(k.avail_in!==0||M.lookahead!==0||ee!==f&&M.status!==666){var se=M.strategy===2?(function(q,ae){for(var I;;){if(q.lookahead===0&&(ge(q),q.lookahead===0)){if(ae===f)return w;break}if(q.match_length=0,I=l._tr_tally(q,0,q.window[q.strstart]),q.lookahead--,q.strstart++,I&&(V(q,!1),q.strm.avail_out===0))return w}return q.insert=0,ae===m?(V(q,!0),q.strm.avail_out===0?X:B):q.last_lit&&(V(q,!1),q.strm.avail_out===0)?w:$})(M,ee):M.strategy===3?(function(q,ae){for(var I,O,Y,ie,le=q.window;;){if(q.lookahead<=z){if(ge(q),q.lookahead<=z&&ae===f)return w;if(q.lookahead===0)break}if(q.match_length=0,q.lookahead>=A&&0<q.strstart&&(O=le[Y=q.strstart-1])===le[++Y]&&O===le[++Y]&&O===le[++Y]){ie=q.strstart+z;do;while(O===le[++Y]&&O===le[++Y]&&O===le[++Y]&&O===le[++Y]&&O===le[++Y]&&O===le[++Y]&&O===le[++Y]&&O===le[++Y]&&Y<ie);q.match_length=z-(ie-Y),q.match_length>q.lookahead&&(q.match_length=q.lookahead)}if(q.match_length>=A?(I=l._tr_tally(q,1,q.match_length-A),q.lookahead-=q.match_length,q.strstart+=q.match_length,q.match_length=0):(I=l._tr_tally(q,0,q.window[q.strstart]),q.lookahead--,q.strstart++),I&&(V(q,!1),q.strm.avail_out===0))return w}return q.insert=0,ae===m?(V(q,!0),q.strm.avail_out===0?X:B):q.last_lit&&(V(q,!1),q.strm.avail_out===0)?w:$})(M,ee):i[M.level].func(M,ee);if(se!==X&&se!==B||(M.status=666),se===w||se===X)return k.avail_out===0&&(M.last_flush=-1),h;if(se===$&&(ee===1?l._tr_align(M):ee!==5&&(l._tr_stored_block(M,0,0,!1),ee===3&&(Z(M.head),M.lookahead===0&&(M.strstart=0,M.block_start=0,M.insert=0))),W(k),k.avail_out===0))return M.last_flush=-1,h}return ee!==m?h:M.wrap<=0?1:(M.wrap===2?(ue(M,255&k.adler),ue(M,k.adler>>8&255),ue(M,k.adler>>16&255),ue(M,k.adler>>24&255),ue(M,255&k.total_in),ue(M,k.total_in>>8&255),ue(M,k.total_in>>16&255),ue(M,k.total_in>>24&255)):(te(M,k.adler>>>16),te(M,65535&k.adler)),W(k),0<M.wrap&&(M.wrap=-M.wrap),M.pending!==0?h:1)},o.deflateEnd=function(k){var ee;return k&&k.state?(ee=k.state.status)!==N&&ee!==69&&ee!==73&&ee!==91&&ee!==103&&ee!==L&&ee!==666?Q(k,x):(k.state=null,ee===L?Q(k,-3):h):x},o.deflateSetDictionary=function(k,ee){var K,M,P,U,re,se,q,ae,I=ee.length;if(!k||!k.state||(U=(K=k.state).wrap)===2||U===1&&K.status!==N||K.lookahead)return x;for(U===1&&(k.adler=c(k.adler,ee,I,0)),K.wrap=0,I>=K.w_size&&(U===0&&(Z(K.head),K.strstart=0,K.block_start=0,K.insert=0),ae=new a.Buf8(K.w_size),a.arraySet(ae,ee,I-K.w_size,K.w_size,0),ee=ae,I=K.w_size),re=k.avail_in,se=k.next_in,q=k.input,k.avail_in=I,k.next_in=0,k.input=ee,ge(K);K.lookahead>=A;){for(M=K.strstart,P=K.lookahead-(A-1);K.ins_h=(K.ins_h<<K.hash_shift^K.window[M+A-1])&K.hash_mask,K.prev[M&K.w_mask]=K.head[K.ins_h],K.head[K.ins_h]=M,M++,--P;);K.strstart=M,K.lookahead=A-1,ge(K)}return K.strstart+=K.lookahead,K.block_start=K.strstart,K.insert=K.lookahead,K.lookahead=0,K.match_length=K.prev_length=A-1,K.match_available=0,k.next_in=se,k.input=q,k.avail_in=re,K.wrap=U,h},o.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,s,o){s.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,s,o){s.exports=function(i,a){var l,c,u,d,f,m,h,x,g,b,v,y,_,j,S,E,T,R,A,z,H,N,L,w,$;l=i.state,c=i.next_in,w=i.input,u=c+(i.avail_in-5),d=i.next_out,$=i.output,f=d-(a-i.avail_out),m=d+(i.avail_out-257),h=l.dmax,x=l.wsize,g=l.whave,b=l.wnext,v=l.window,y=l.hold,_=l.bits,j=l.lencode,S=l.distcode,E=(1<<l.lenbits)-1,T=(1<<l.distbits)-1;e:do{_<15&&(y+=w[c++]<<_,_+=8,y+=w[c++]<<_,_+=8),R=j[y&E];t:for(;;){if(y>>>=A=R>>>24,_-=A,(A=R>>>16&255)===0)$[d++]=65535&R;else{if(!(16&A)){if((64&A)==0){R=j[(65535&R)+(y&(1<<A)-1)];continue t}if(32&A){l.mode=12;break e}i.msg="invalid literal/length code",l.mode=30;break e}z=65535&R,(A&=15)&&(_<A&&(y+=w[c++]<<_,_+=8),z+=y&(1<<A)-1,y>>>=A,_-=A),_<15&&(y+=w[c++]<<_,_+=8,y+=w[c++]<<_,_+=8),R=S[y&T];n:for(;;){if(y>>>=A=R>>>24,_-=A,!(16&(A=R>>>16&255))){if((64&A)==0){R=S[(65535&R)+(y&(1<<A)-1)];continue n}i.msg="invalid distance code",l.mode=30;break e}if(H=65535&R,_<(A&=15)&&(y+=w[c++]<<_,(_+=8)<A&&(y+=w[c++]<<_,_+=8)),h<(H+=y&(1<<A)-1)){i.msg="invalid distance too far back",l.mode=30;break e}if(y>>>=A,_-=A,(A=d-f)<H){if(g<(A=H-A)&&l.sane){i.msg="invalid distance too far back",l.mode=30;break e}if(L=v,(N=0)===b){if(N+=x-A,A<z){for(z-=A;$[d++]=v[N++],--A;);N=d-H,L=$}}else if(b<A){if(N+=x+b-A,(A-=b)<z){for(z-=A;$[d++]=v[N++],--A;);if(N=0,b<z){for(z-=A=b;$[d++]=v[N++],--A;);N=d-H,L=$}}}else if(N+=b-A,A<z){for(z-=A;$[d++]=v[N++],--A;);N=d-H,L=$}for(;2<z;)$[d++]=L[N++],$[d++]=L[N++],$[d++]=L[N++],z-=3;z&&($[d++]=L[N++],1<z&&($[d++]=L[N++]))}else{for(N=d-H;$[d++]=$[N++],$[d++]=$[N++],$[d++]=$[N++],2<(z-=3););z&&($[d++]=$[N++],1<z&&($[d++]=$[N++]))}break}}break}}while(c<u&&d<m);c-=z=_>>3,y&=(1<<(_-=z<<3))-1,i.next_in=c,i.next_out=d,i.avail_in=c<u?u-c+5:5-(c-u),i.avail_out=d<m?m-d+257:257-(d-m),l.hold=y,l.bits=_}},{}],49:[function(n,s,o){var i=n("../utils/common"),a=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,m=0,h=-2,x=1,g=852,b=592;function v(N){return(N>>>24&255)+(N>>>8&65280)+((65280&N)<<8)+((255&N)<<24)}function y(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(N){var L;return N&&N.state?(L=N.state,N.total_in=N.total_out=L.total=0,N.msg="",L.wrap&&(N.adler=1&L.wrap),L.mode=x,L.last=0,L.havedict=0,L.dmax=32768,L.head=null,L.hold=0,L.bits=0,L.lencode=L.lendyn=new i.Buf32(g),L.distcode=L.distdyn=new i.Buf32(b),L.sane=1,L.back=-1,m):h}function j(N){var L;return N&&N.state?((L=N.state).wsize=0,L.whave=0,L.wnext=0,_(N)):h}function S(N,L){var w,$;return N&&N.state?($=N.state,L<0?(w=0,L=-L):(w=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15<L)?h:($.window!==null&&$.wbits!==L&&($.window=null),$.wrap=w,$.wbits=L,j(N))):h}function E(N,L){var w,$;return N?($=new y,(N.state=$).window=null,(w=S(N,L))!==m&&(N.state=null),w):h}var T,R,A=!0;function z(N){if(A){var L;for(T=new i.Buf32(512),R=new i.Buf32(32),L=0;L<144;)N.lens[L++]=8;for(;L<256;)N.lens[L++]=9;for(;L<280;)N.lens[L++]=7;for(;L<288;)N.lens[L++]=8;for(u(d,N.lens,0,288,T,0,N.work,{bits:9}),L=0;L<32;)N.lens[L++]=5;u(f,N.lens,0,32,R,0,N.work,{bits:5}),A=!1}N.lencode=T,N.lenbits=9,N.distcode=R,N.distbits=5}function H(N,L,w,$){var X,B=N.state;return B.window===null&&(B.wsize=1<<B.wbits,B.wnext=0,B.whave=0,B.window=new i.Buf8(B.wsize)),$>=B.wsize?(i.arraySet(B.window,L,w-B.wsize,B.wsize,0),B.wnext=0,B.whave=B.wsize):($<(X=B.wsize-B.wnext)&&(X=$),i.arraySet(B.window,L,w-$,X,B.wnext),($-=X)?(i.arraySet(B.window,L,w-$,$,0),B.wnext=$,B.whave=B.wsize):(B.wnext+=X,B.wnext===B.wsize&&(B.wnext=0),B.whave<B.wsize&&(B.whave+=X))),0}o.inflateReset=j,o.inflateReset2=S,o.inflateResetKeep=_,o.inflateInit=function(N){return E(N,15)},o.inflateInit2=E,o.inflate=function(N,L){var w,$,X,B,Q,D,Z,W,V,ue,te,F,ge,de,pe,me,ve,xe,Ce,Ae,k,ee,K,M,P=0,U=new i.Buf8(4),re=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!N||!N.state||!N.output||!N.input&&N.avail_in!==0)return h;(w=N.state).mode===12&&(w.mode=13),Q=N.next_out,X=N.output,Z=N.avail_out,B=N.next_in,$=N.input,D=N.avail_in,W=w.hold,V=w.bits,ue=D,te=Z,ee=m;e:for(;;)switch(w.mode){case x:if(w.wrap===0){w.mode=13;break}for(;V<16;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}if(2&w.wrap&&W===35615){U[w.check=0]=255&W,U[1]=W>>>8&255,w.check=l(w.check,U,2,0),V=W=0,w.mode=2;break}if(w.flags=0,w.head&&(w.head.done=!1),!(1&w.wrap)||(((255&W)<<8)+(W>>8))%31){N.msg="incorrect header check",w.mode=30;break}if((15&W)!=8){N.msg="unknown compression method",w.mode=30;break}if(V-=4,k=8+(15&(W>>>=4)),w.wbits===0)w.wbits=k;else if(k>w.wbits){N.msg="invalid window size",w.mode=30;break}w.dmax=1<<k,N.adler=w.check=1,w.mode=512&W?10:12,V=W=0;break;case 2:for(;V<16;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}if(w.flags=W,(255&w.flags)!=8){N.msg="unknown compression method",w.mode=30;break}if(57344&w.flags){N.msg="unknown header flags set",w.mode=30;break}w.head&&(w.head.text=W>>8&1),512&w.flags&&(U[0]=255&W,U[1]=W>>>8&255,w.check=l(w.check,U,2,0)),V=W=0,w.mode=3;case 3:for(;V<32;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}w.head&&(w.head.time=W),512&w.flags&&(U[0]=255&W,U[1]=W>>>8&255,U[2]=W>>>16&255,U[3]=W>>>24&255,w.check=l(w.check,U,4,0)),V=W=0,w.mode=4;case 4:for(;V<16;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}w.head&&(w.head.xflags=255&W,w.head.os=W>>8),512&w.flags&&(U[0]=255&W,U[1]=W>>>8&255,w.check=l(w.check,U,2,0)),V=W=0,w.mode=5;case 5:if(1024&w.flags){for(;V<16;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}w.length=W,w.head&&(w.head.extra_len=W),512&w.flags&&(U[0]=255&W,U[1]=W>>>8&255,w.check=l(w.check,U,2,0)),V=W=0}else w.head&&(w.head.extra=null);w.mode=6;case 6:if(1024&w.flags&&(D<(F=w.length)&&(F=D),F&&(w.head&&(k=w.head.extra_len-w.length,w.head.extra||(w.head.extra=new Array(w.head.extra_len)),i.arraySet(w.head.extra,$,B,F,k)),512&w.flags&&(w.check=l(w.check,$,F,B)),D-=F,B+=F,w.length-=F),w.length))break e;w.length=0,w.mode=7;case 7:if(2048&w.flags){if(D===0)break e;for(F=0;k=$[B+F++],w.head&&k&&w.length<65536&&(w.head.name+=String.fromCharCode(k)),k&&F<D;);if(512&w.flags&&(w.check=l(w.check,$,F,B)),D-=F,B+=F,k)break e}else w.head&&(w.head.name=null);w.length=0,w.mode=8;case 8:if(4096&w.flags){if(D===0)break e;for(F=0;k=$[B+F++],w.head&&k&&w.length<65536&&(w.head.comment+=String.fromCharCode(k)),k&&F<D;);if(512&w.flags&&(w.check=l(w.check,$,F,B)),D-=F,B+=F,k)break e}else w.head&&(w.head.comment=null);w.mode=9;case 9:if(512&w.flags){for(;V<16;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}if(W!==(65535&w.check)){N.msg="header crc mismatch",w.mode=30;break}V=W=0}w.head&&(w.head.hcrc=w.flags>>9&1,w.head.done=!0),N.adler=w.check=0,w.mode=12;break;case 10:for(;V<32;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}N.adler=w.check=v(W),V=W=0,w.mode=11;case 11:if(w.havedict===0)return N.next_out=Q,N.avail_out=Z,N.next_in=B,N.avail_in=D,w.hold=W,w.bits=V,2;N.adler=w.check=1,w.mode=12;case 12:if(L===5||L===6)break e;case 13:if(w.last){W>>>=7&V,V-=7&V,w.mode=27;break}for(;V<3;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}switch(w.last=1&W,V-=1,3&(W>>>=1)){case 0:w.mode=14;break;case 1:if(z(w),w.mode=20,L!==6)break;W>>>=2,V-=2;break e;case 2:w.mode=17;break;case 3:N.msg="invalid block type",w.mode=30}W>>>=2,V-=2;break;case 14:for(W>>>=7&V,V-=7&V;V<32;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}if((65535&W)!=(W>>>16^65535)){N.msg="invalid stored block lengths",w.mode=30;break}if(w.length=65535&W,V=W=0,w.mode=15,L===6)break e;case 15:w.mode=16;case 16:if(F=w.length){if(D<F&&(F=D),Z<F&&(F=Z),F===0)break e;i.arraySet(X,$,B,F,Q),D-=F,B+=F,Z-=F,Q+=F,w.length-=F;break}w.mode=12;break;case 17:for(;V<14;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}if(w.nlen=257+(31&W),W>>>=5,V-=5,w.ndist=1+(31&W),W>>>=5,V-=5,w.ncode=4+(15&W),W>>>=4,V-=4,286<w.nlen||30<w.ndist){N.msg="too many length or distance symbols",w.mode=30;break}w.have=0,w.mode=18;case 18:for(;w.have<w.ncode;){for(;V<3;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}w.lens[re[w.have++]]=7&W,W>>>=3,V-=3}for(;w.have<19;)w.lens[re[w.have++]]=0;if(w.lencode=w.lendyn,w.lenbits=7,K={bits:w.lenbits},ee=u(0,w.lens,0,19,w.lencode,0,w.work,K),w.lenbits=K.bits,ee){N.msg="invalid code lengths set",w.mode=30;break}w.have=0,w.mode=19;case 19:for(;w.have<w.nlen+w.ndist;){for(;me=(P=w.lencode[W&(1<<w.lenbits)-1])>>>16&255,ve=65535&P,!((pe=P>>>24)<=V);){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}if(ve<16)W>>>=pe,V-=pe,w.lens[w.have++]=ve;else{if(ve===16){for(M=pe+2;V<M;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}if(W>>>=pe,V-=pe,w.have===0){N.msg="invalid bit length repeat",w.mode=30;break}k=w.lens[w.have-1],F=3+(3&W),W>>>=2,V-=2}else if(ve===17){for(M=pe+3;V<M;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}V-=pe,k=0,F=3+(7&(W>>>=pe)),W>>>=3,V-=3}else{for(M=pe+7;V<M;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}V-=pe,k=0,F=11+(127&(W>>>=pe)),W>>>=7,V-=7}if(w.have+F>w.nlen+w.ndist){N.msg="invalid bit length repeat",w.mode=30;break}for(;F--;)w.lens[w.have++]=k}}if(w.mode===30)break;if(w.lens[256]===0){N.msg="invalid code -- missing end-of-block",w.mode=30;break}if(w.lenbits=9,K={bits:w.lenbits},ee=u(d,w.lens,0,w.nlen,w.lencode,0,w.work,K),w.lenbits=K.bits,ee){N.msg="invalid literal/lengths set",w.mode=30;break}if(w.distbits=6,w.distcode=w.distdyn,K={bits:w.distbits},ee=u(f,w.lens,w.nlen,w.ndist,w.distcode,0,w.work,K),w.distbits=K.bits,ee){N.msg="invalid distances set",w.mode=30;break}if(w.mode=20,L===6)break e;case 20:w.mode=21;case 21:if(6<=D&&258<=Z){N.next_out=Q,N.avail_out=Z,N.next_in=B,N.avail_in=D,w.hold=W,w.bits=V,c(N,te),Q=N.next_out,X=N.output,Z=N.avail_out,B=N.next_in,$=N.input,D=N.avail_in,W=w.hold,V=w.bits,w.mode===12&&(w.back=-1);break}for(w.back=0;me=(P=w.lencode[W&(1<<w.lenbits)-1])>>>16&255,ve=65535&P,!((pe=P>>>24)<=V);){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}if(me&&(240&me)==0){for(xe=pe,Ce=me,Ae=ve;me=(P=w.lencode[Ae+((W&(1<<xe+Ce)-1)>>xe)])>>>16&255,ve=65535&P,!(xe+(pe=P>>>24)<=V);){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}W>>>=xe,V-=xe,w.back+=xe}if(W>>>=pe,V-=pe,w.back+=pe,w.length=ve,me===0){w.mode=26;break}if(32&me){w.back=-1,w.mode=12;break}if(64&me){N.msg="invalid literal/length code",w.mode=30;break}w.extra=15&me,w.mode=22;case 22:if(w.extra){for(M=w.extra;V<M;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}w.length+=W&(1<<w.extra)-1,W>>>=w.extra,V-=w.extra,w.back+=w.extra}w.was=w.length,w.mode=23;case 23:for(;me=(P=w.distcode[W&(1<<w.distbits)-1])>>>16&255,ve=65535&P,!((pe=P>>>24)<=V);){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}if((240&me)==0){for(xe=pe,Ce=me,Ae=ve;me=(P=w.distcode[Ae+((W&(1<<xe+Ce)-1)>>xe)])>>>16&255,ve=65535&P,!(xe+(pe=P>>>24)<=V);){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}W>>>=xe,V-=xe,w.back+=xe}if(W>>>=pe,V-=pe,w.back+=pe,64&me){N.msg="invalid distance code",w.mode=30;break}w.offset=ve,w.extra=15&me,w.mode=24;case 24:if(w.extra){for(M=w.extra;V<M;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}w.offset+=W&(1<<w.extra)-1,W>>>=w.extra,V-=w.extra,w.back+=w.extra}if(w.offset>w.dmax){N.msg="invalid distance too far back",w.mode=30;break}w.mode=25;case 25:if(Z===0)break e;if(F=te-Z,w.offset>F){if((F=w.offset-F)>w.whave&&w.sane){N.msg="invalid distance too far back",w.mode=30;break}ge=F>w.wnext?(F-=w.wnext,w.wsize-F):w.wnext-F,F>w.length&&(F=w.length),de=w.window}else de=X,ge=Q-w.offset,F=w.length;for(Z<F&&(F=Z),Z-=F,w.length-=F;X[Q++]=de[ge++],--F;);w.length===0&&(w.mode=21);break;case 26:if(Z===0)break e;X[Q++]=w.length,Z--,w.mode=21;break;case 27:if(w.wrap){for(;V<32;){if(D===0)break e;D--,W|=$[B++]<<V,V+=8}if(te-=Z,N.total_out+=te,w.total+=te,te&&(N.adler=w.check=w.flags?l(w.check,X,te,Q-te):a(w.check,X,te,Q-te)),te=Z,(w.flags?W:v(W))!==w.check){N.msg="incorrect data check",w.mode=30;break}V=W=0}w.mode=28;case 28:if(w.wrap&&w.flags){for(;V<32;){if(D===0)break e;D--,W+=$[B++]<<V,V+=8}if(W!==(4294967295&w.total)){N.msg="incorrect length check",w.mode=30;break}V=W=0}w.mode=29;case 29:ee=1;break e;case 30:ee=-3;break e;case 31:return-4;default:return h}return N.next_out=Q,N.avail_out=Z,N.next_in=B,N.avail_in=D,w.hold=W,w.bits=V,(w.wsize||te!==N.avail_out&&w.mode<30&&(w.mode<27||L!==4))&&H(N,N.output,N.next_out,te-N.avail_out)?(w.mode=31,-4):(ue-=N.avail_in,te-=N.avail_out,N.total_in+=ue,N.total_out+=te,w.total+=te,w.wrap&&te&&(N.adler=w.check=w.flags?l(w.check,X,te,N.next_out-te):a(w.check,X,te,N.next_out-te)),N.data_type=w.bits+(w.last?64:0)+(w.mode===12?128:0)+(w.mode===20||w.mode===15?256:0),(ue==0&&te===0||L===4)&&ee===m&&(ee=-5),ee)},o.inflateEnd=function(N){if(!N||!N.state)return h;var L=N.state;return L.window&&(L.window=null),N.state=null,m},o.inflateGetHeader=function(N,L){var w;return N&&N.state?(2&(w=N.state).wrap)==0?h:((w.head=L).done=!1,m):h},o.inflateSetDictionary=function(N,L){var w,$=L.length;return N&&N.state?(w=N.state).wrap!==0&&w.mode!==11?h:w.mode===11&&a(1,L,$,0)!==w.check?-3:H(N,L,$,$)?(w.mode=31,-4):(w.havedict=1,m):h},o.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,s,o){var i=n("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];s.exports=function(d,f,m,h,x,g,b,v){var y,_,j,S,E,T,R,A,z,H=v.bits,N=0,L=0,w=0,$=0,X=0,B=0,Q=0,D=0,Z=0,W=0,V=null,ue=0,te=new i.Buf16(16),F=new i.Buf16(16),ge=null,de=0;for(N=0;N<=15;N++)te[N]=0;for(L=0;L<h;L++)te[f[m+L]]++;for(X=H,$=15;1<=$&&te[$]===0;$--);if($<X&&(X=$),$===0)return x[g++]=20971520,x[g++]=20971520,v.bits=1,0;for(w=1;w<$&&te[w]===0;w++);for(X<w&&(X=w),N=D=1;N<=15;N++)if(D<<=1,(D-=te[N])<0)return-1;if(0<D&&(d===0||$!==1))return-1;for(F[1]=0,N=1;N<15;N++)F[N+1]=F[N]+te[N];for(L=0;L<h;L++)f[m+L]!==0&&(b[F[f[m+L]]++]=L);if(T=d===0?(V=ge=b,19):d===1?(V=a,ue-=257,ge=l,de-=257,256):(V=c,ge=u,-1),N=w,E=g,Q=L=W=0,j=-1,S=(Z=1<<(B=X))-1,d===1&&852<Z||d===2&&592<Z)return 1;for(;;){for(R=N-Q,z=b[L]<T?(A=0,b[L]):b[L]>T?(A=ge[de+b[L]],V[ue+b[L]]):(A=96,0),y=1<<N-Q,w=_=1<<B;x[E+(W>>Q)+(_-=y)]=R<<24|A<<16|z|0,_!==0;);for(y=1<<N-1;W&y;)y>>=1;if(y!==0?(W&=y-1,W+=y):W=0,L++,--te[N]==0){if(N===$)break;N=f[m+b[L]]}if(X<N&&(W&S)!==j){for(Q===0&&(Q=X),E+=w,D=1<<(B=N-Q);B+Q<$&&!((D-=te[B+Q])<=0);)B++,D<<=1;if(Z+=1<<B,d===1&&852<Z||d===2&&592<Z)return 1;x[j=W&S]=X<<24|B<<16|E-g|0}}return W!==0&&(x[E+W]=N-Q<<24|64<<16|0),v.bits=X,0}},{"../utils/common":41}],51:[function(n,s,o){s.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,s,o){var i=n("../utils/common"),a=0,l=1;function c(P){for(var U=P.length;0<=--U;)P[U]=0}var u=0,d=29,f=256,m=f+1+d,h=30,x=19,g=2*m+1,b=15,v=16,y=7,_=256,j=16,S=17,E=18,T=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],R=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],z=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],H=new Array(2*(m+2));c(H);var N=new Array(2*h);c(N);var L=new Array(512);c(L);var w=new Array(256);c(w);var $=new Array(d);c($);var X,B,Q,D=new Array(h);function Z(P,U,re,se,q){this.static_tree=P,this.extra_bits=U,this.extra_base=re,this.elems=se,this.max_length=q,this.has_stree=P&&P.length}function W(P,U){this.dyn_tree=P,this.max_code=0,this.stat_desc=U}function V(P){return P<256?L[P]:L[256+(P>>>7)]}function ue(P,U){P.pending_buf[P.pending++]=255&U,P.pending_buf[P.pending++]=U>>>8&255}function te(P,U,re){P.bi_valid>v-re?(P.bi_buf|=U<<P.bi_valid&65535,ue(P,P.bi_buf),P.bi_buf=U>>v-P.bi_valid,P.bi_valid+=re-v):(P.bi_buf|=U<<P.bi_valid&65535,P.bi_valid+=re)}function F(P,U,re){te(P,re[2*U],re[2*U+1])}function ge(P,U){for(var re=0;re|=1&P,P>>>=1,re<<=1,0<--U;);return re>>>1}function de(P,U,re){var se,q,ae=new Array(b+1),I=0;for(se=1;se<=b;se++)ae[se]=I=I+re[se-1]<<1;for(q=0;q<=U;q++){var O=P[2*q+1];O!==0&&(P[2*q]=ge(ae[O]++,O))}}function pe(P){var U;for(U=0;U<m;U++)P.dyn_ltree[2*U]=0;for(U=0;U<h;U++)P.dyn_dtree[2*U]=0;for(U=0;U<x;U++)P.bl_tree[2*U]=0;P.dyn_ltree[2*_]=1,P.opt_len=P.static_len=0,P.last_lit=P.matches=0}function me(P){8<P.bi_valid?ue(P,P.bi_buf):0<P.bi_valid&&(P.pending_buf[P.pending++]=P.bi_buf),P.bi_buf=0,P.bi_valid=0}function ve(P,U,re,se){var q=2*U,ae=2*re;return P[q]<P[ae]||P[q]===P[ae]&&se[U]<=se[re]}function xe(P,U,re){for(var se=P.heap[re],q=re<<1;q<=P.heap_len&&(q<P.heap_len&&ve(U,P.heap[q+1],P.heap[q],P.depth)&&q++,!ve(U,se,P.heap[q],P.depth));)P.heap[re]=P.heap[q],re=q,q<<=1;P.heap[re]=se}function Ce(P,U,re){var se,q,ae,I,O=0;if(P.last_lit!==0)for(;se=P.pending_buf[P.d_buf+2*O]<<8|P.pending_buf[P.d_buf+2*O+1],q=P.pending_buf[P.l_buf+O],O++,se===0?F(P,q,U):(F(P,(ae=w[q])+f+1,U),(I=T[ae])!==0&&te(P,q-=$[ae],I),F(P,ae=V(--se),re),(I=R[ae])!==0&&te(P,se-=D[ae],I)),O<P.last_lit;);F(P,_,U)}function Ae(P,U){var re,se,q,ae=U.dyn_tree,I=U.stat_desc.static_tree,O=U.stat_desc.has_stree,Y=U.stat_desc.elems,ie=-1;for(P.heap_len=0,P.heap_max=g,re=0;re<Y;re++)ae[2*re]!==0?(P.heap[++P.heap_len]=ie=re,P.depth[re]=0):ae[2*re+1]=0;for(;P.heap_len<2;)ae[2*(q=P.heap[++P.heap_len]=ie<2?++ie:0)]=1,P.depth[q]=0,P.opt_len--,O&&(P.static_len-=I[2*q+1]);for(U.max_code=ie,re=P.heap_len>>1;1<=re;re--)xe(P,ae,re);for(q=Y;re=P.heap[1],P.heap[1]=P.heap[P.heap_len--],xe(P,ae,1),se=P.heap[1],P.heap[--P.heap_max]=re,P.heap[--P.heap_max]=se,ae[2*q]=ae[2*re]+ae[2*se],P.depth[q]=(P.depth[re]>=P.depth[se]?P.depth[re]:P.depth[se])+1,ae[2*re+1]=ae[2*se+1]=q,P.heap[1]=q++,xe(P,ae,1),2<=P.heap_len;);P.heap[--P.heap_max]=P.heap[1],(function(le,_e){var be,he,Oe,Re,xt,Ct,mt=_e.dyn_tree,Ln=_e.max_code,Nt=_e.stat_desc.static_tree,cn=_e.stat_desc.has_stree,Dn=_e.stat_desc.extra_bits,De=_e.stat_desc.extra_base,at=_e.stat_desc.max_length,tt=0;for(Re=0;Re<=b;Re++)le.bl_count[Re]=0;for(mt[2*le.heap[le.heap_max]+1]=0,be=le.heap_max+1;be<g;be++)at<(Re=mt[2*mt[2*(he=le.heap[be])+1]+1]+1)&&(Re=at,tt++),mt[2*he+1]=Re,Ln<he||(le.bl_count[Re]++,xt=0,De<=he&&(xt=Dn[he-De]),Ct=mt[2*he],le.opt_len+=Ct*(Re+xt),cn&&(le.static_len+=Ct*(Nt[2*he+1]+xt)));if(tt!==0){do{for(Re=at-1;le.bl_count[Re]===0;)Re--;le.bl_count[Re]--,le.bl_count[Re+1]+=2,le.bl_count[at]--,tt-=2}while(0<tt);for(Re=at;Re!==0;Re--)for(he=le.bl_count[Re];he!==0;)Ln<(Oe=le.heap[--be])||(mt[2*Oe+1]!==Re&&(le.opt_len+=(Re-mt[2*Oe+1])*mt[2*Oe],mt[2*Oe+1]=Re),he--)}})(P,U),de(ae,ie,P.bl_count)}function k(P,U,re){var se,q,ae=-1,I=U[1],O=0,Y=7,ie=4;for(I===0&&(Y=138,ie=3),U[2*(re+1)+1]=65535,se=0;se<=re;se++)q=I,I=U[2*(se+1)+1],++O<Y&&q===I||(O<ie?P.bl_tree[2*q]+=O:q!==0?(q!==ae&&P.bl_tree[2*q]++,P.bl_tree[2*j]++):O<=10?P.bl_tree[2*S]++:P.bl_tree[2*E]++,ae=q,ie=(O=0)===I?(Y=138,3):q===I?(Y=6,3):(Y=7,4))}function ee(P,U,re){var se,q,ae=-1,I=U[1],O=0,Y=7,ie=4;for(I===0&&(Y=138,ie=3),se=0;se<=re;se++)if(q=I,I=U[2*(se+1)+1],!(++O<Y&&q===I)){if(O<ie)for(;F(P,q,P.bl_tree),--O!=0;);else q!==0?(q!==ae&&(F(P,q,P.bl_tree),O--),F(P,j,P.bl_tree),te(P,O-3,2)):O<=10?(F(P,S,P.bl_tree),te(P,O-3,3)):(F(P,E,P.bl_tree),te(P,O-11,7));ae=q,ie=(O=0)===I?(Y=138,3):q===I?(Y=6,3):(Y=7,4)}}c(D);var K=!1;function M(P,U,re,se){te(P,(u<<1)+(se?1:0),3),(function(q,ae,I,O){me(q),ue(q,I),ue(q,~I),i.arraySet(q.pending_buf,q.window,ae,I,q.pending),q.pending+=I})(P,U,re)}o._tr_init=function(P){K||((function(){var U,re,se,q,ae,I=new Array(b+1);for(q=se=0;q<d-1;q++)for($[q]=se,U=0;U<1<<T[q];U++)w[se++]=q;for(w[se-1]=q,q=ae=0;q<16;q++)for(D[q]=ae,U=0;U<1<<R[q];U++)L[ae++]=q;for(ae>>=7;q<h;q++)for(D[q]=ae<<7,U=0;U<1<<R[q]-7;U++)L[256+ae++]=q;for(re=0;re<=b;re++)I[re]=0;for(U=0;U<=143;)H[2*U+1]=8,U++,I[8]++;for(;U<=255;)H[2*U+1]=9,U++,I[9]++;for(;U<=279;)H[2*U+1]=7,U++,I[7]++;for(;U<=287;)H[2*U+1]=8,U++,I[8]++;for(de(H,m+1,I),U=0;U<h;U++)N[2*U+1]=5,N[2*U]=ge(U,5);X=new Z(H,T,f+1,m,b),B=new Z(N,R,0,h,b),Q=new Z(new Array(0),A,0,x,y)})(),K=!0),P.l_desc=new W(P.dyn_ltree,X),P.d_desc=new W(P.dyn_dtree,B),P.bl_desc=new W(P.bl_tree,Q),P.bi_buf=0,P.bi_valid=0,pe(P)},o._tr_stored_block=M,o._tr_flush_block=function(P,U,re,se){var q,ae,I=0;0<P.level?(P.strm.data_type===2&&(P.strm.data_type=(function(O){var Y,ie=4093624447;for(Y=0;Y<=31;Y++,ie>>>=1)if(1&ie&&O.dyn_ltree[2*Y]!==0)return a;if(O.dyn_ltree[18]!==0||O.dyn_ltree[20]!==0||O.dyn_ltree[26]!==0)return l;for(Y=32;Y<f;Y++)if(O.dyn_ltree[2*Y]!==0)return l;return a})(P)),Ae(P,P.l_desc),Ae(P,P.d_desc),I=(function(O){var Y;for(k(O,O.dyn_ltree,O.l_desc.max_code),k(O,O.dyn_dtree,O.d_desc.max_code),Ae(O,O.bl_desc),Y=x-1;3<=Y&&O.bl_tree[2*z[Y]+1]===0;Y--);return O.opt_len+=3*(Y+1)+5+5+4,Y})(P),q=P.opt_len+3+7>>>3,(ae=P.static_len+3+7>>>3)<=q&&(q=ae)):q=ae=re+5,re+4<=q&&U!==-1?M(P,U,re,se):P.strategy===4||ae===q?(te(P,2+(se?1:0),3),Ce(P,H,N)):(te(P,4+(se?1:0),3),(function(O,Y,ie,le){var _e;for(te(O,Y-257,5),te(O,ie-1,5),te(O,le-4,4),_e=0;_e<le;_e++)te(O,O.bl_tree[2*z[_e]+1],3);ee(O,O.dyn_ltree,Y-1),ee(O,O.dyn_dtree,ie-1)})(P,P.l_desc.max_code+1,P.d_desc.max_code+1,I+1),Ce(P,P.dyn_ltree,P.dyn_dtree)),pe(P),se&&me(P)},o._tr_tally=function(P,U,re){return P.pending_buf[P.d_buf+2*P.last_lit]=U>>>8&255,P.pending_buf[P.d_buf+2*P.last_lit+1]=255&U,P.pending_buf[P.l_buf+P.last_lit]=255&re,P.last_lit++,U===0?P.dyn_ltree[2*re]++:(P.matches++,U--,P.dyn_ltree[2*(w[re]+f+1)]++,P.dyn_dtree[2*V(U)]++),P.last_lit===P.lit_bufsize-1},o._tr_align=function(P){te(P,2,3),F(P,_,H),(function(U){U.bi_valid===16?(ue(U,U.bi_buf),U.bi_buf=0,U.bi_valid=0):8<=U.bi_valid&&(U.pending_buf[U.pending++]=255&U.bi_buf,U.bi_buf>>=8,U.bi_valid-=8)})(P)}},{"../utils/common":41}],53:[function(n,s,o){s.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,s,o){(function(i){(function(a,l){if(!a.setImmediate){var c,u,d,f,m=1,h={},x=!1,g=a.document,b=Object.getPrototypeOf&&Object.getPrototypeOf(a);b=b&&b.setTimeout?b:a,c={}.toString.call(a.process)==="[object process]"?function(j){process.nextTick(function(){y(j)})}:(function(){if(a.postMessage&&!a.importScripts){var j=!0,S=a.onmessage;return a.onmessage=function(){j=!1},a.postMessage("","*"),a.onmessage=S,j}})()?(f="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",_,!1):a.attachEvent("onmessage",_),function(j){a.postMessage(f+j,"*")}):a.MessageChannel?((d=new MessageChannel).port1.onmessage=function(j){y(j.data)},function(j){d.port2.postMessage(j)}):g&&"onreadystatechange"in g.createElement("script")?(u=g.documentElement,function(j){var S=g.createElement("script");S.onreadystatechange=function(){y(j),S.onreadystatechange=null,u.removeChild(S),S=null},u.appendChild(S)}):function(j){setTimeout(y,0,j)},b.setImmediate=function(j){typeof j!="function"&&(j=new Function(""+j));for(var S=new Array(arguments.length-1),E=0;E<S.length;E++)S[E]=arguments[E+1];var T={callback:j,args:S};return h[m]=T,c(m),m++},b.clearImmediate=v}function v(j){delete h[j]}function y(j){if(x)setTimeout(y,0,j);else{var S=h[j];if(S){x=!0;try{(function(E){var T=E.callback,R=E.args;switch(R.length){case 0:T();break;case 1:T(R[0]);break;case 2:T(R[0],R[1]);break;case 3:T(R[0],R[1],R[2]);break;default:T.apply(l,R)}})(S)}finally{v(j),x=!1}}}}function _(j){j.source===a&&typeof j.data=="string"&&j.data.indexOf(f)===0&&y(+j.data.slice(f.length))}})(typeof self>"u"?i===void 0?this:i:self)}).call(this,typeof Pr<"u"?Pr:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Bi)),Bi.exports}var U5=F5();const B5=qg(U5),W5="3.0.25",Da={version:W5},Dp="[REDACTED]",H5=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,V5=[/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],ju=200,q5=25e6,$p=50,Z5=1e4;function G5(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function K5(e){let t=0;for(const n of e)t+=n.rawRequestBody?.length??0,t+=n.responseText?.length??0;return t}function J5(e){if(e.length>ju)return`Export is limited to ${ju} logs at once. Narrow the filter and try again.`;const t=K5(e);return t>q5?`Export is too large (${G5(t)} of text). Narrow the filter and try again.`:null}function $r(e){return e?.aborted===!0?{ok:!1,message:"Export canceled.",canceled:!0}:null}async function Y5(e,t){try{const n=await Zn(`/api/logs/${e}/chunks`,Z5,{signal:t});if(!n.ok)return null;const s=await n.json();return JSON.stringify(s,null,2)}catch{return null}}function X5(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $a(e){if(Array.isArray(e))return e.map(n=>$a(n));if(!X5(e))return e;const t={};for(const[n,s]of Object.entries(e))t[n]=H5.test(n)?Dp:$a(s);return t}function Q5(e){const t=n=>{let s=n;for(const o of V5)s=s.replace(o,Dp);return s};try{const n=JSON.parse(e);return t(JSON.stringify($a(n),null,2))}catch{return t(e)}}function Wi(e,t){return t==="redacted"?Q5(e):e}function ek(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 tk(e,t,n,s=new Date().toISOString()){return{version:Da.version,exportedAt:s,mode:t,redacted:t==="redacted",logCount:e.length,logIds:e.map(o=>o.id),streamingChunkExportLimit:$p,streamingChunkLogIds:n.map(o=>o.id)}}async function nk(e,t="redacted",n={}){const s=$r(n.signal);if(s!==null)return s;const o=J5(e);if(o!==null)return{ok:!1,message:o};const i=new B5,a=t==="redacted"?"redacted":"raw",l=e.filter(m=>m.streaming).slice(0,$p);i.file("manifest.json",JSON.stringify(tk(e,t,l),null,2)),i.file("logs.json",JSON.stringify(e.map(m=>ek(m,t)),null,2));for(const m of e){const h=$r(n.signal);if(h!==null)return h;m.rawRequestBody!==null&&i.file(`#${m.id}.Request.json`,Wi(m.rawRequestBody,t)),m.responseText!==null&&i.file(`#${m.id}.Response.json`,Wi(m.responseText,t))}for(const m of l){const h=$r(n.signal);if(h!==null)return h;const x=await Y5(m.id,n.signal);x!==null&&i.file(`#${m.id}.SSE.Response.json`,Wi(x,t))}const c=await i.generateAsync({type:"blob"}),u=$r(n.signal);if(u!==null)return u;const d=URL.createObjectURL(c),f=document.createElement("a");return f.href=d,f.download=`agent-inspector-export-${a}-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(d),{ok:!0}}function sk(e,t){if(e!==null){e.removeAllRanges();for(const n of t)e.addRange(n)}}function rk(e){if(e===null)return[];const t=[];for(let n=0;n<e.rangeCount;n++)t.push(e.getRangeAt(n));return t}function ok(e){if(typeof document>"u")return!1;const t=document.activeElement,n=document.getSelection(),s=rk(n),o=document.createElement("textarea");o.value=e,o.setAttribute("readonly",""),o.style.position="fixed",o.style.top="0",o.style.left="-9999px",o.style.opacity="0",document.body.appendChild(o),o.focus(),o.select(),o.setSelectionRange(0,e.length);let i=!1;try{i=document.execCommand("copy")}catch{}finally{document.body.removeChild(o),sk(n,s),typeof HTMLElement<"u"&&t instanceof HTMLElement&&t.focus({preventScroll:!0})}return i}async function At(e){const t=globalThis.navigator?.clipboard;if(t!==void 0)try{return await t.writeText(e),!0}catch{}return ok(e)}function Fa(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 li(e,t,n){return`${Fa(e,n)} - ${Fa(t,n)}`}function Fp(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Fp(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function Up(){for(var e,t,n=0,s="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Fp(e))&&(s&&(s+=" "),s+=t);return s}const ik=(e,t)=>{const n=new Array(e.length+t.length);for(let s=0;s<e.length;s++)n[s]=e[s];for(let s=0;s<t.length;s++)n[e.length+s]=t[s];return n},ak=(e,t)=>({classGroupId:e,validator:t}),Bp=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Ro="-",Su=[],lk="arbitrary..",ck=e=>{const t=dk(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return uk(a);const l=a.split(Ro),c=l[0]===""&&l.length>1?1:0;return Wp(l,c,t)},getConflictingClassGroupIds:(a,l)=>{if(l){const c=s[a],u=n[a];return c?u?ik(u,c):c:u||Su}return n[a]||Su}}},Wp=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],i=n.nextPart.get(o);if(i){const u=Wp(e,t+1,i);if(u)return u}const a=n.validators;if(a===null)return;const l=t===0?e.join(Ro):e.slice(t).join(Ro),c=a.length;for(let u=0;u<c;u++){const d=a[u];if(d.validator(l))return d.classGroupId}},uk=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),s=t.slice(0,n);return s?lk+s:void 0})(),dk=e=>{const{theme:t,classGroups:n}=e;return fk(n,t)},fk=(e,t)=>{const n=Bp();for(const s in e){const o=e[s];Jl(o,n,s,t)}return n},Jl=(e,t,n,s)=>{const o=e.length;for(let i=0;i<o;i++){const a=e[i];pk(a,t,n,s)}},pk=(e,t,n,s)=>{if(typeof e=="string"){hk(e,t,n);return}if(typeof e=="function"){mk(e,t,n,s);return}gk(e,t,n,s)},hk=(e,t,n)=>{const s=e===""?t:Hp(t,e);s.classGroupId=n},mk=(e,t,n,s)=>{if(xk(e)){Jl(e(s),t,n,s);return}t.validators===null&&(t.validators=[]),t.validators.push(ak(n,e))},gk=(e,t,n,s)=>{const o=Object.entries(e),i=o.length;for(let a=0;a<i;a++){const[l,c]=o[a];Jl(c,Hp(t,l),n,s)}},Hp=(e,t)=>{let n=e;const s=t.split(Ro),o=s.length;for(let i=0;i<o;i++){const a=s[i];let l=n.nextPart.get(a);l||(l=Bp(),n.nextPart.set(a,l)),n=l}return n},xk=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,bk=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),s=Object.create(null);const o=(i,a)=>{n[i]=a,t++,t>e&&(t=0,s=n,n=Object.create(null))};return{get(i){let a=n[i];if(a!==void 0)return a;if((a=s[i])!==void 0)return o(i,a),a},set(i,a){i in n?n[i]=a:o(i,a)}}},Ua="!",Cu=":",vk=[],Nu=(e,t,n,s,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:s,isExternal:o}),yk=e=>{const{prefix:t,experimentalParseClassName:n}=e;let s=o=>{const i=[];let a=0,l=0,c=0,u;const d=o.length;for(let g=0;g<d;g++){const b=o[g];if(a===0&&l===0){if(b===Cu){i.push(o.slice(c,g)),c=g+1;continue}if(b==="/"){u=g;continue}}b==="["?a++:b==="]"?a--:b==="("?l++:b===")"&&l--}const f=i.length===0?o:o.slice(c);let m=f,h=!1;f.endsWith(Ua)?(m=f.slice(0,-1),h=!0):f.startsWith(Ua)&&(m=f.slice(1),h=!0);const x=u&&u>c?u-c:void 0;return Nu(i,h,m,x)};if(t){const o=t+Cu,i=s;s=a=>a.startsWith(o)?i(a.slice(o.length)):Nu(vk,!1,a,void 0,!0)}if(n){const o=s;s=i=>n({className:i,parseClassName:o})}return s},wk=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,s)=>{t.set(n,1e6+s)}),n=>{const s=[];let o=[];for(let i=0;i<n.length;i++){const a=n[i],l=a[0]==="[",c=t.has(a);l||c?(o.length>0&&(o.sort(),s.push(...o),o=[]),s.push(a)):o.push(a)}return o.length>0&&(o.sort(),s.push(...o)),s}},_k=e=>({cache:bk(e.cacheSize),parseClassName:yk(e),sortModifiers:wk(e),postfixLookupClassGroupIds:kk(e),...ck(e)}),kk=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let s=0;s<n.length;s++)t[n[s]]=!0;return t},jk=/\s+/,Sk=(e,t)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:o,sortModifiers:i,postfixLookupClassGroupIds:a}=t,l=[],c=e.trim().split(jk);let u="";for(let d=c.length-1;d>=0;d-=1){const f=c[d],{isExternal:m,modifiers:h,hasImportantModifier:x,baseClassName:g,maybePostfixModifierPosition:b}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let v=!!b,y;if(v){const T=g.substring(0,b);y=s(T);const R=y&&a[y]?s(g):void 0;R&&R!==y&&(y=R,v=!1)}else y=s(g);if(!y){if(!v){u=f+(u.length>0?" "+u:u);continue}if(y=s(g),!y){u=f+(u.length>0?" "+u:u);continue}v=!1}const _=h.length===0?"":h.length===1?h[0]:i(h).join(":"),j=x?_+Ua:_,S=j+y;if(l.indexOf(S)>-1)continue;l.push(S);const E=o(y,v);for(let T=0;T<E.length;++T){const R=E[T];l.push(j+R)}u=f+(u.length>0?" "+u:u)}return u},Ck=(...e)=>{let t=0,n,s,o="";for(;t<e.length;)(n=e[t++])&&(s=Vp(n))&&(o&&(o+=" "),o+=s);return o},Vp=e=>{if(typeof e=="string")return e;let t,n="";for(let s=0;s<e.length;s++)e[s]&&(t=Vp(e[s]))&&(n&&(n+=" "),n+=t);return n},Nk=(e,...t)=>{let n,s,o,i;const a=c=>{const u=t.reduce((d,f)=>f(d),e());return n=_k(u),s=n.cache.get,o=n.cache.set,i=l,l(c)},l=c=>{const u=s(c);if(u)return u;const d=Sk(c,n);return o(c,d),d};return i=a,(...c)=>i(Ck(...c))},Tk=[],Xe=e=>{const t=n=>n[e]||Tk;return t.isThemeGetter=!0,t},qp=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Zp=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ek=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Ak=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Rk=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Ik=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Pk=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,zk=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,un=e=>Ek.test(e),Pe=e=>!!e&&!Number.isNaN(Number(e)),Bt=e=>!!e&&Number.isInteger(Number(e)),Hi=e=>e.endsWith("%")&&Pe(e.slice(0,-1)),Qt=e=>Ak.test(e),Gp=()=>!0,Mk=e=>Rk.test(e)&&!Ik.test(e),Yl=()=>!1,Ok=e=>Pk.test(e),Lk=e=>zk.test(e),Dk=e=>!ye(e)&&!we(e),$k=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),Fk=e=>Tn(e,Yp,Yl),ye=e=>qp.test(e),$n=e=>Tn(e,Xp,Mk),Tu=e=>Tn(e,Gk,Pe),Uk=e=>Tn(e,eh,Gp),Bk=e=>Tn(e,Qp,Yl),Eu=e=>Tn(e,Kp,Yl),Wk=e=>Tn(e,Jp,Lk),Fr=e=>Tn(e,th,Ok),we=e=>Zp.test(e),Vs=e=>os(e,Xp),Hk=e=>os(e,Qp),Au=e=>os(e,Kp),Vk=e=>os(e,Yp),qk=e=>os(e,Jp),Ur=e=>os(e,th,!0),Zk=e=>os(e,eh,!0),Tn=(e,t,n)=>{const s=qp.exec(e);return s?s[1]?t(s[1]):n(s[2]):!1},os=(e,t,n=!1)=>{const s=Zp.exec(e);return s?s[1]?t(s[1]):n:!1},Kp=e=>e==="position"||e==="percentage",Jp=e=>e==="image"||e==="url",Yp=e=>e==="length"||e==="size"||e==="bg-size",Xp=e=>e==="length",Gk=e=>e==="number",Qp=e=>e==="family-name",eh=e=>e==="number"||e==="weight",th=e=>e==="shadow",Kk=()=>{const e=Xe("color"),t=Xe("font"),n=Xe("text"),s=Xe("font-weight"),o=Xe("tracking"),i=Xe("leading"),a=Xe("breakpoint"),l=Xe("container"),c=Xe("spacing"),u=Xe("radius"),d=Xe("shadow"),f=Xe("inset-shadow"),m=Xe("text-shadow"),h=Xe("drop-shadow"),x=Xe("blur"),g=Xe("perspective"),b=Xe("aspect"),v=Xe("ease"),y=Xe("animate"),_=()=>["auto","avoid","all","avoid-page","page","left","right","column"],j=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],S=()=>[...j(),we,ye],E=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto","contain","none"],R=()=>[we,ye,c],A=()=>[un,"full","auto",...R()],z=()=>[Bt,"none","subgrid",we,ye],H=()=>["auto",{span:["full",Bt,we,ye]},Bt,we,ye],N=()=>[Bt,"auto",we,ye],L=()=>["auto","min","max","fr",we,ye],w=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],$=()=>["start","end","center","stretch","center-safe","end-safe"],X=()=>["auto",...R()],B=()=>[un,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],Q=()=>[un,"screen","full","dvw","lvw","svw","min","max","fit",...R()],D=()=>[un,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],Z=()=>[e,we,ye],W=()=>[...j(),Au,Eu,{position:[we,ye]}],V=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ue=()=>["auto","cover","contain",Vk,Fk,{size:[we,ye]}],te=()=>[Hi,Vs,$n],F=()=>["","none","full",u,we,ye],ge=()=>["",Pe,Vs,$n],de=()=>["solid","dashed","dotted","double"],pe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>[Pe,Hi,Au,Eu],ve=()=>["","none",x,we,ye],xe=()=>["none",Pe,we,ye],Ce=()=>["none",Pe,we,ye],Ae=()=>[Pe,we,ye],k=()=>[un,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Qt],breakpoint:[Qt],color:[Gp],container:[Qt],"drop-shadow":[Qt],ease:["in","out","in-out"],font:[Dk],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Qt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Qt],shadow:[Qt],spacing:["px",Pe],text:[Qt],"text-shadow":[Qt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",un,ye,we,b]}],container:["container"],"container-type":[{"@container":["","normal","size",we,ye]}],"container-named":[$k],columns:[{columns:[Pe,ye,we,l]}],"break-after":[{"break-after":_()}],"break-before":[{"break-before":_()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:S()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{"inset-s":A(),start:A()}],end:[{"inset-e":A(),end:A()}],"inset-bs":[{"inset-bs":A()}],"inset-be":[{"inset-be":A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[Bt,"auto",we,ye]}],basis:[{basis:[un,"full","auto",l,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Pe,un,"auto","initial","none",ye]}],grow:[{grow:["",Pe,we,ye]}],shrink:[{shrink:["",Pe,we,ye]}],order:[{order:[Bt,"first","last","none",we,ye]}],"grid-cols":[{"grid-cols":z()}],"col-start-end":[{col:H()}],"col-start":[{"col-start":N()}],"col-end":[{"col-end":N()}],"grid-rows":[{"grid-rows":z()}],"row-start-end":[{row:H()}],"row-start":[{"row-start":N()}],"row-end":[{"row-end":N()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":L()}],"auto-rows":[{"auto-rows":L()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...w(),"normal"]}],"justify-items":[{"justify-items":[...$(),"normal"]}],"justify-self":[{"justify-self":["auto",...$()]}],"align-content":[{content:["normal",...w()]}],"align-items":[{items:[...$(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...$(),{baseline:["","last"]}]}],"place-content":[{"place-content":w()}],"place-items":[{"place-items":[...$(),"baseline"]}],"place-self":[{"place-self":["auto",...$()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:X()}],mx:[{mx:X()}],my:[{my:X()}],ms:[{ms:X()}],me:[{me:X()}],mbs:[{mbs:X()}],mbe:[{mbe:X()}],mt:[{mt:X()}],mr:[{mr:X()}],mb:[{mb:X()}],ml:[{ml:X()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:B()}],"inline-size":[{inline:["auto",...Q()]}],"min-inline-size":[{"min-inline":["auto",...Q()]}],"max-inline-size":[{"max-inline":["none",...Q()]}],"block-size":[{block:["auto",...D()]}],"min-block-size":[{"min-block":["auto",...D()]}],"max-block-size":[{"max-block":["none",...D()]}],w:[{w:[l,"screen",...B()]}],"min-w":[{"min-w":[l,"screen","none",...B()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[a]},...B()]}],h:[{h:["screen","lh",...B()]}],"min-h":[{"min-h":["screen","lh","none",...B()]}],"max-h":[{"max-h":["screen","lh",...B()]}],"font-size":[{text:["base",n,Vs,$n]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,Zk,Uk]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Hi,ye]}],"font-family":[{font:[Hk,Bk,t]}],"font-features":[{"font-features":[ye]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,we,ye]}],"line-clamp":[{"line-clamp":[Pe,"none",we,Tu]}],leading:[{leading:[i,...R()]}],"list-image":[{"list-image":["none",we,ye]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",we,ye]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:Z()}],"text-color":[{text:Z()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...de(),"wavy"]}],"text-decoration-thickness":[{decoration:[Pe,"from-font","auto",we,$n]}],"text-decoration-color":[{decoration:Z()}],"underline-offset":[{"underline-offset":[Pe,"auto",we,ye]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"tab-size":[{tab:[Bt,we,ye]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",we,ye]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",we,ye]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:W()}],"bg-repeat":[{bg:V()}],"bg-size":[{bg:ue()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Bt,we,ye],radial:["",we,ye],conic:[Bt,we,ye]},qk,Wk]}],"bg-color":[{bg:Z()}],"gradient-from-pos":[{from:te()}],"gradient-via-pos":[{via:te()}],"gradient-to-pos":[{to:te()}],"gradient-from":[{from:Z()}],"gradient-via":[{via:Z()}],"gradient-to":[{to:Z()}],rounded:[{rounded:F()}],"rounded-s":[{"rounded-s":F()}],"rounded-e":[{"rounded-e":F()}],"rounded-t":[{"rounded-t":F()}],"rounded-r":[{"rounded-r":F()}],"rounded-b":[{"rounded-b":F()}],"rounded-l":[{"rounded-l":F()}],"rounded-ss":[{"rounded-ss":F()}],"rounded-se":[{"rounded-se":F()}],"rounded-ee":[{"rounded-ee":F()}],"rounded-es":[{"rounded-es":F()}],"rounded-tl":[{"rounded-tl":F()}],"rounded-tr":[{"rounded-tr":F()}],"rounded-br":[{"rounded-br":F()}],"rounded-bl":[{"rounded-bl":F()}],"border-w":[{border:ge()}],"border-w-x":[{"border-x":ge()}],"border-w-y":[{"border-y":ge()}],"border-w-s":[{"border-s":ge()}],"border-w-e":[{"border-e":ge()}],"border-w-bs":[{"border-bs":ge()}],"border-w-be":[{"border-be":ge()}],"border-w-t":[{"border-t":ge()}],"border-w-r":[{"border-r":ge()}],"border-w-b":[{"border-b":ge()}],"border-w-l":[{"border-l":ge()}],"divide-x":[{"divide-x":ge()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ge()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...de(),"hidden","none"]}],"divide-style":[{divide:[...de(),"hidden","none"]}],"border-color":[{border:Z()}],"border-color-x":[{"border-x":Z()}],"border-color-y":[{"border-y":Z()}],"border-color-s":[{"border-s":Z()}],"border-color-e":[{"border-e":Z()}],"border-color-bs":[{"border-bs":Z()}],"border-color-be":[{"border-be":Z()}],"border-color-t":[{"border-t":Z()}],"border-color-r":[{"border-r":Z()}],"border-color-b":[{"border-b":Z()}],"border-color-l":[{"border-l":Z()}],"divide-color":[{divide:Z()}],"outline-style":[{outline:[...de(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Pe,we,ye]}],"outline-w":[{outline:["",Pe,Vs,$n]}],"outline-color":[{outline:Z()}],shadow:[{shadow:["","none",d,Ur,Fr]}],"shadow-color":[{shadow:Z()}],"inset-shadow":[{"inset-shadow":["none",f,Ur,Fr]}],"inset-shadow-color":[{"inset-shadow":Z()}],"ring-w":[{ring:ge()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:Z()}],"ring-offset-w":[{"ring-offset":[Pe,$n]}],"ring-offset-color":[{"ring-offset":Z()}],"inset-ring-w":[{"inset-ring":ge()}],"inset-ring-color":[{"inset-ring":Z()}],"text-shadow":[{"text-shadow":["none",m,Ur,Fr]}],"text-shadow-color":[{"text-shadow":Z()}],opacity:[{opacity:[Pe,we,ye]}],"mix-blend":[{"mix-blend":[...pe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":pe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Pe]}],"mask-image-linear-from-pos":[{"mask-linear-from":me()}],"mask-image-linear-to-pos":[{"mask-linear-to":me()}],"mask-image-linear-from-color":[{"mask-linear-from":Z()}],"mask-image-linear-to-color":[{"mask-linear-to":Z()}],"mask-image-t-from-pos":[{"mask-t-from":me()}],"mask-image-t-to-pos":[{"mask-t-to":me()}],"mask-image-t-from-color":[{"mask-t-from":Z()}],"mask-image-t-to-color":[{"mask-t-to":Z()}],"mask-image-r-from-pos":[{"mask-r-from":me()}],"mask-image-r-to-pos":[{"mask-r-to":me()}],"mask-image-r-from-color":[{"mask-r-from":Z()}],"mask-image-r-to-color":[{"mask-r-to":Z()}],"mask-image-b-from-pos":[{"mask-b-from":me()}],"mask-image-b-to-pos":[{"mask-b-to":me()}],"mask-image-b-from-color":[{"mask-b-from":Z()}],"mask-image-b-to-color":[{"mask-b-to":Z()}],"mask-image-l-from-pos":[{"mask-l-from":me()}],"mask-image-l-to-pos":[{"mask-l-to":me()}],"mask-image-l-from-color":[{"mask-l-from":Z()}],"mask-image-l-to-color":[{"mask-l-to":Z()}],"mask-image-x-from-pos":[{"mask-x-from":me()}],"mask-image-x-to-pos":[{"mask-x-to":me()}],"mask-image-x-from-color":[{"mask-x-from":Z()}],"mask-image-x-to-color":[{"mask-x-to":Z()}],"mask-image-y-from-pos":[{"mask-y-from":me()}],"mask-image-y-to-pos":[{"mask-y-to":me()}],"mask-image-y-from-color":[{"mask-y-from":Z()}],"mask-image-y-to-color":[{"mask-y-to":Z()}],"mask-image-radial":[{"mask-radial":[we,ye]}],"mask-image-radial-from-pos":[{"mask-radial-from":me()}],"mask-image-radial-to-pos":[{"mask-radial-to":me()}],"mask-image-radial-from-color":[{"mask-radial-from":Z()}],"mask-image-radial-to-color":[{"mask-radial-to":Z()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":j()}],"mask-image-conic-pos":[{"mask-conic":[Pe]}],"mask-image-conic-from-pos":[{"mask-conic-from":me()}],"mask-image-conic-to-pos":[{"mask-conic-to":me()}],"mask-image-conic-from-color":[{"mask-conic-from":Z()}],"mask-image-conic-to-color":[{"mask-conic-to":Z()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:W()}],"mask-repeat":[{mask:V()}],"mask-size":[{mask:ue()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",we,ye]}],filter:[{filter:["","none",we,ye]}],blur:[{blur:ve()}],brightness:[{brightness:[Pe,we,ye]}],contrast:[{contrast:[Pe,we,ye]}],"drop-shadow":[{"drop-shadow":["","none",h,Ur,Fr]}],"drop-shadow-color":[{"drop-shadow":Z()}],grayscale:[{grayscale:["",Pe,we,ye]}],"hue-rotate":[{"hue-rotate":[Pe,we,ye]}],invert:[{invert:["",Pe,we,ye]}],saturate:[{saturate:[Pe,we,ye]}],sepia:[{sepia:["",Pe,we,ye]}],"backdrop-filter":[{"backdrop-filter":["","none",we,ye]}],"backdrop-blur":[{"backdrop-blur":ve()}],"backdrop-brightness":[{"backdrop-brightness":[Pe,we,ye]}],"backdrop-contrast":[{"backdrop-contrast":[Pe,we,ye]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Pe,we,ye]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Pe,we,ye]}],"backdrop-invert":[{"backdrop-invert":["",Pe,we,ye]}],"backdrop-opacity":[{"backdrop-opacity":[Pe,we,ye]}],"backdrop-saturate":[{"backdrop-saturate":[Pe,we,ye]}],"backdrop-sepia":[{"backdrop-sepia":["",Pe,we,ye]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",we,ye]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Pe,"initial",we,ye]}],ease:[{ease:["linear","initial",v,we,ye]}],delay:[{delay:[Pe,we,ye]}],animate:[{animate:["none",y,we,ye]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,we,ye]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:xe()}],"rotate-x":[{"rotate-x":xe()}],"rotate-y":[{"rotate-y":xe()}],"rotate-z":[{"rotate-z":xe()}],scale:[{scale:Ce()}],"scale-x":[{"scale-x":Ce()}],"scale-y":[{"scale-y":Ce()}],"scale-z":[{"scale-z":Ce()}],"scale-3d":["scale-3d"],skew:[{skew:Ae()}],"skew-x":[{"skew-x":Ae()}],"skew-y":[{"skew-y":Ae()}],transform:[{transform:[we,ye,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:k()}],"translate-x":[{"translate-x":k()}],"translate-y":[{"translate-y":k()}],"translate-z":[{"translate-z":k()}],"translate-none":["translate-none"],zoom:[{zoom:[Bt,we,ye]}],accent:[{accent:Z()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:Z()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",we,ye]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":Z()}],"scrollbar-track-color":[{"scrollbar-track":Z()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",we,ye]}],fill:[{fill:["none",...Z()]}],"stroke-w":[{stroke:[Pe,Vs,$n,Tu]}],stroke:[{stroke:["none",...Z()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Jk=Nk(Kk);function oe(...e){return Jk(Up(e))}function Fe(e){return e>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+"M":(e/1e3).toFixed(1).replace(/\.0$/,"")+"K"}function nh(e){return e>=1024*1024?(e/(1024*1024)).toFixed(1).replace(/\.0$/,"")+"M":(e/1024).toFixed(1).replace(/\.0$/,"")+"K"}function Ru(e,t,n){const s=e*10;return!Number.isSafeInteger(s)||s%t!==0?null:(s/t/10).toFixed(1).replace(/\.0$/,"")+n}function Yk(e){if(!Number.isSafeInteger(e)||e<=0)return e.toString();if(e>=1024*1024){const n=Ru(e,1048576,"M");if(n!==null)return n}const t=Ru(e,1024,"K");return t!==null?t:e.toString()}function Xk(e){if(e===void 0||e==="")return 1;switch(e.toLowerCase()){case"k":return 1024;case"m":return 1024*1024;default:return null}}function Io(e){const t=e.trim().replaceAll(",","");if(t==="")return null;const n=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(t);if(n===null)return null;const s=n[1];if(s===void 0)return null;const o=Number(s),i=n[2],a=Xk(i);if(!Number.isFinite(o)||o<=0||a===null||(i===void 0||i==="")&&!Number.isInteger(o))return null;const l=Math.round(o*a);return!Number.isSafeInteger(l)||l<=0?null:l}function Qk(e){return e===null?"pending":e>=200&&e<300?"success":e>=400&&e<500?"client_error":e>=500?"server_error":"pending"}function ej(){const[e,t]=p.useState(Zg),n=p.useCallback(s=>{t(s),Di(s),Gg(s)},[]);return p.useEffect(()=>{Di(e)},[e]),p.useEffect(()=>{function s(o){if(o.key!==Kg)return;const i=Jg(o.newValue);t(i),Di(i)}return window.addEventListener("storage",s),()=>window.removeEventListener("storage",s)},[]),{themeMode:e,setThemeMode:n}}function tj(){const[e,t]=p.useState(Yg),[n,s]=p.useState(1),o=p.useCallback(i=>{t(i),Xg(i),s($i(i))},[]);return p.useEffect(()=>{const i=()=>{s($i(e))};if(i(),e==="auto")return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[e]),p.useEffect(()=>{const i=a=>{if(a.key!==Qg)return;const l=_f(a.newValue);t(l),s($i(l))};return window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[]),{uiScalePreference:e,resolvedUiScale:n,setUiScalePreference:o}}function Br(){return C().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 nj=J({model:C().min(1),contextWindow:G().int().positive().optional(),outputLimit:G().int().positive().optional(),source:Te(["manual","registry"]).optional(),sourceUrl:C().optional(),updatedAt:C().optional()}),Po=J({id:C(),name:C(),apiKey:C(),model:C().optional(),models:fe(C()).optional().default([]),format:Te(["anthropic","openai"]).optional(),baseUrl:Br().optional(),anthropicBaseUrl:Br().optional(),openaiBaseUrl:Br().optional(),openaiResponsesBaseUrl:Br().optional(),authHeader:Te(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:C().optional(),modelMetadataUrl:C().optional(),modelMetadata:fe(nj).optional(),source:Te(["company","personal"]).optional(),createdAt:C(),updatedAt:C()});async function sj(e){return ht(e,Po.array(),void 0,t=>`Failed to fetch ${e}: ${t.status}`)}function Xl(){const e=qt("/api/providers?includeSecrets=1",sj,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function Iu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function rj(...e){return t=>{let n=!1;const s=e.map(o=>{const i=Iu(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():Iu(e[o],null)}}}}function $e(...e){return p.useCallback(rj(...e),e)}function Rs(e){const t=p.forwardRef((n,s)=>{let{children:o,...i}=n,a=null,l=!1;const c=[];Pu(o)&&typeof Wr=="function"&&(o=Wr(o._payload)),p.Children.forEach(o,m=>{if(uj(m)){l=!0;const h=m;let x="child"in h.props?h.props.child:h.props.children;Pu(x)&&typeof Wr=="function"&&(x=Wr(x._payload)),a=aj(h,x),c.push(a?.props?.children)}else c.push(m)}),a?a=p.cloneElement(a,void 0,c):!l&&p.Children.count(o)===1&&p.isValidElement(o)&&(a=o);const u=a?cj(a):void 0,d=$e(s,u);if(!a){if(o||o===0)throw new Error(l?hj(e):pj(e));return o}const f=lj(i,a.props??{});return a.type!==p.Fragment&&(f.ref=s?d:u),p.cloneElement(a,f)});return t.displayName=`${e}.Slot`,t}var oj=Rs("Slot"),sh=Symbol.for("radix.slottable");function ij(e){const t=n=>"child"in n?n.children(n.child):n.children;return t.displayName=`${e}.Slottable`,t.__radixId=sh,t}var aj=(e,t)=>{if("child"in e.props){const n=e.props.child;return p.isValidElement(n)?p.cloneElement(n,void 0,e.props.children(n.props.children)):null}return p.isValidElement(t)?t:null};function lj(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 c=i(...l);return o(...l),c}:o&&(n[s]=o):s==="style"?n[s]={...o,...i}:s==="className"&&(n[s]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function cj(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 uj(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===sh}var dj=Symbol.for("react.lazy");function Pu(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===dj&&"_payload"in e&&fj(e._payload)}function fj(e){return typeof e=="object"&&e!==null&&"then"in e}var pj=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,hj=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,Wr=Qo[" use ".trim().toString()],mj=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=mj.reduce((e,t)=>{const n=Rs(`Primitive.${t}`),s=p.forwardRef((o,i)=>{const{asChild:a,...l}=o,c=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(c,{...l,ref:i})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function gj(e,t){e&&Ds.flushSync(()=>e.dispatchEvent(t))}var rh=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"}),xj="VisuallyHidden",oh=p.forwardRef((e,t)=>r.jsx(Ie.span,{...e,ref:t,style:{...rh,...e.style}}));oh.displayName=xj;var bj=oh;function ln(e,t=[]){let n=[];function s(i,a){const l=p.createContext(a);l.displayName=i+"Context";const c=n.length;n=[...n,a];const u=f=>{const{scope:m,children:h,...x}=f,g=m?.[e]?.[c]||l,b=p.useMemo(()=>x,Object.values(x));return r.jsx(g.Provider,{value:b,children:h})};u.displayName=i+"Provider";function d(f,m,h={}){const{optional:x=!1}=h,g=m?.[e]?.[c]||l,b=p.useContext(g);if(b)return b;if(a!==void 0)return a;if(!x)throw new Error(`\`${f}\` must be used within \`${i}\``)}return[u,d]}const o=()=>{const i=n.map(a=>p.createContext(a));return function(l){const c=l?.[e]||i;return p.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return o.scopeName=e,[s,vj(o,...t)]}function vj(...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:c,scopeName:u})=>{const f=c(i)[`__scope${u}`];return{...l,...f}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}function ih(e){const t=e+"CollectionProvider",[n,s]=ln(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=g=>{const{scope:b,children:v}=g,y=p.useRef(null),_=p.useRef(new Map).current;return r.jsx(o,{scope:b,itemMap:_,collectionRef:y,children:v})};a.displayName=t;const l=e+"CollectionSlot",c=Rs(l),u=p.forwardRef((g,b)=>{const{scope:v,children:y}=g,_=i(l,v),j=$e(b,_.collectionRef);return r.jsx(c,{ref:j,children:y})});u.displayName=l;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=Rs(d),h=p.forwardRef((g,b)=>{const{scope:v,children:y,..._}=g,j=p.useRef(null),S=$e(b,j),E=i(d,v);return p.useEffect(()=>(E.itemMap.set(j,{ref:j,..._}),()=>{E.itemMap.delete(j)})),r.jsx(m,{[f]:"",ref:S,children:y})});h.displayName=d;function x(g){const b=i(e+"CollectionConsumer",g);return p.useCallback(()=>{const y=b.collectionRef.current;if(!y)return[];const _=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(b.itemMap.values()).sort((E,T)=>_.indexOf(E.ref.current)-_.indexOf(T.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:a,Slot:u,ItemSlot:h},x,s]}function Ne(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o||!o.defaultPrevented)return t?.(o)}}var Je=globalThis?.document?p.useLayoutEffect:()=>{},yj=Qo[" useInsertionEffect ".trim().toString()]||Je;function Kn({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[o,i,a]=wj({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const f=d.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.`),d.current=l},[l,s])}const u=p.useCallback(d=>{if(l){const f=_j(d)?d(e):d;f!==e&&a.current?.(f)}else i(d)},[l,e,i,a]);return[c,u]}function wj({defaultProp:e,onChange:t}){const[n,s]=p.useState(e),o=p.useRef(n),i=p.useRef(t);return yj(()=>{i.current=t},[t]),p.useEffect(()=>{o.current!==n&&(i.current?.(n),o.current=n)},[n,o]),[n,s,i]}function _j(e){return typeof e=="function"}function kj(e,t){return p.useReducer((n,s)=>t[n][s]??n,e)}var St=e=>{const{present:t,children:n}=e,s=jj(t),o=typeof n=="function"?n({present:s.isPresent}):p.Children.only(n),i=Sj(s.ref,Cj(o));return typeof n=="function"||s.isPresent?p.cloneElement(o,{ref:i}):null};St.displayName="Presence";function jj(e){const[t,n]=p.useState(),s=p.useRef(null),o=p.useRef(e),i=p.useRef("none"),a=p.useRef(void 0),l=e?"mounted":"unmounted",[c,u]=kj(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{c==="mounted"?(i.current=a.current??qs(s.current),a.current=void 0):i.current="none"},[c]),Je(()=>{const d=s.current,f=o.current;if(f!==e){const h=i.current,x=qs(d);e?(a.current=x,u("MOUNT")):x==="none"||d?.display==="none"?u("UNMOUNT"):u(f&&h!==x?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),Je(()=>{if(t){let d;const f=t.ownerDocument.defaultView??window,m=x=>{const b=qs(s.current).includes(CSS.escape(x.animationName));if(x.target===t&&b&&(u("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",d=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},h=x=>{x.target===t&&(i.current=qs(s.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{f.clearTimeout(d),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:p.useCallback(d=>{if(d){const f=getComputedStyle(d);s.current=f,a.current=qs(f)}else s.current=null;n(d)},[])}}function zu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Sj(...e){const t=p.useRef(e);return t.current=e,p.useCallback(n=>{const s=t.current;let o=!1;const i=s.map(a=>{const l=zu(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():zu(s[a],null)}}},[])}function qs(e){return e?.animationName||"none"}function Cj(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 Nj=Qo[" useId ".trim().toString()]||(()=>{}),Tj=0;function Zt(e){const[t,n]=p.useState(Nj());return Je(()=>{n(s=>s??String(Tj++))},[e]),t?`radix-${t}`:""}var ci="Collapsible",[Ej]=ln(ci),[Aj,Ql]=Ej(ci),ah=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:s,defaultOpen:o,disabled:i,onOpenChange:a,...l}=e,[c,u]=Kn({prop:s,defaultProp:o??!1,onChange:a,caller:ci});return r.jsx(Aj,{scope:n,disabled:i,contentId:Zt(),open:c,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),children:r.jsx(Ie.div,{"data-state":tc(c),"data-disabled":i?"":void 0,...l,ref:t})})});ah.displayName=ci;var lh="CollapsibleTrigger",ch=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,...s}=e,o=Ql(lh,n);return r.jsx(Ie.button,{type:"button","aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open||!1,"data-state":tc(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...s,ref:t,onClick:Ne(e.onClick,o.onOpenToggle)})});ch.displayName=lh;var ec="CollapsibleContent",uh=p.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=Ql(ec,e.__scopeCollapsible);return r.jsx(St,{present:n||o.open,children:({present:i})=>r.jsx(Rj,{...s,ref:t,present:i})})});uh.displayName=ec;var Rj=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:s,children:o,...i}=e,a=Ql(ec,n),[l,c]=p.useState(s),u=p.useRef(null),d=$e(t,u),f=p.useRef(0),m=f.current,h=p.useRef(0),x=h.current,g=a.open||l,b=p.useRef(g),v=p.useRef(void 0);return p.useEffect(()=>{const y=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(y)},[]),Je(()=>{const y=u.current;if(y){v.current=v.current||{transitionDuration:y.style.transitionDuration,animationName:y.style.animationName},y.style.transitionDuration="0s",y.style.animationName="none";const _=y.getBoundingClientRect();f.current=_.height,h.current=_.width,b.current||(y.style.transitionDuration=v.current.transitionDuration,y.style.animationName=v.current.animationName),c(s)}},[a.open,s]),r.jsx(Ie.div,{"data-state":tc(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!g,...i,ref:d,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":x?`${x}px`:void 0,...e.style},children:g&&o})});function tc(e){return e?"open":"closed"}var Ij=ah,Pj=p.createContext(void 0);function ui(e){const t=p.useContext(Pj);return e||t||"ltr"}function nt(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>((...n)=>t.current?.(...n)),[])}var zj="DismissableLayer",Ba="dismissableLayer.update",Mj="dismissableLayer.pointerDownOutside",Oj="dismissableLayer.focusOutside",Mu,nc=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),di=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:s=!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...u}=e,d=p.useContext(nc),[f,m]=p.useState(null),h=f?.ownerDocument??globalThis?.document,[,x]=p.useState({}),g=$e(t,m),b=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=v?b.indexOf(v):-1,_=f?b.indexOf(f):-1,j=d.layersWithOutsidePointerEventsDisabled.size>0,S=_>=y,E=p.useRef(!1),T=Uj(H=>{i?.(H),l?.(H),H.defaultPrevented||c?.()},{ownerDocument:h,deferPointerDownOutside:s,isDeferredPointerDownOutsideRef:E,dismissableSurfaces:d.dismissableSurfaces,shouldHandlePointerDownOutside:p.useCallback(H=>{if(!(H instanceof Node))return!1;const N=[...d.branches].some(L=>L.contains(H));return S&&!N},[d.branches,S])}),R=Bj(H=>{if(s&&E.current)return;const N=H.target;[...d.branches].some(w=>w.contains(N))||(a?.(H),l?.(H),H.defaultPrevented||c?.())},h),A=f?_===b.length-1:!1,z=nt(H=>{H.key==="Escape"&&(o?.(H),!H.defaultPrevented&&c&&(H.preventDefault(),c()))});return p.useEffect(()=>{if(A)return h.addEventListener("keydown",z,{capture:!0}),()=>h.removeEventListener("keydown",z,{capture:!0})},[h,A,z]),p.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(Mu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),Ou(),()=>{n&&(d.layersWithOutsidePointerEventsDisabled.delete(f),d.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=Mu))}},[f,h,n,d]),p.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),Ou())},[f,d]),p.useEffect(()=>{const H=()=>x({});return document.addEventListener(Ba,H),()=>document.removeEventListener(Ba,H)},[]),r.jsx(Ie.div,{...u,ref:g,style:{pointerEvents:j?S?"auto":"none":void 0,...e.style},onFocusCapture:Ne(e.onFocusCapture,R.onFocusCapture),onBlurCapture:Ne(e.onBlurCapture,R.onBlurCapture),onPointerDownCapture:Ne(e.onPointerDownCapture,T.onPointerDownCapture)})});di.displayName=zj;var Lj="DismissableLayerBranch",Dj=p.forwardRef((e,t)=>{const n=p.useContext(nc),s=p.useRef(null),o=$e(t,s);return p.useEffect(()=>{const i=s.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),r.jsx(Ie.div,{...e,ref:o})});Dj.displayName=Lj;function $j(){const e=p.useContext(nc),[t,n]=p.useState(null);return p.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}var Fj=()=>!0;function Uj(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:s=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:i,shouldHandlePointerDownOutside:a=Fj}=t,l=nt(e),c=p.useRef(!1),u=p.useRef(!1),d=p.useRef(new Map),f=p.useRef(()=>{});return p.useEffect(()=>{function m(){u.current=!1,o.current=!1,d.current.clear()}function h(){return Array.from(d.current.values()).some(Boolean)}function x(_){if(!u.current)return;const j=_.target;j instanceof Node&&[...i].some(E=>E.contains(j))||d.current.set(_.type,!0),_.type==="click"&&window.setTimeout(()=>{u.current&&f.current()},0)}function g(_){u.current&&d.current.set(_.type,!1)}const b=_=>{if(_.target&&!c.current){let j=function(){n.removeEventListener("click",f.current);const E=h();m(),E||dh(Mj,l,S,{discrete:!0})};if(!a(_.target)){n.removeEventListener("click",f.current),m(),c.current=!1;return}const S={originalEvent:_};u.current=!0,o.current=s&&_.button===0,d.current.clear(),!s||_.button!==0?j():(n.removeEventListener("click",f.current),f.current=j,n.addEventListener("click",f.current,{once:!0}))}else n.removeEventListener("click",f.current),m();c.current=!1},v=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const _ of v)n.addEventListener(_,x,!0),n.addEventListener(_,g);const y=window.setTimeout(()=>{n.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(y),n.removeEventListener("pointerdown",b),n.removeEventListener("click",f.current);for(const _ of v)n.removeEventListener(_,x,!0),n.removeEventListener(_,g)}},[n,l,s,o,i,a]),{onPointerDownCapture:()=>c.current=!0}}function Bj(e,t=globalThis?.document){const n=nt(e),s=p.useRef(!1);return p.useEffect(()=>{const o=i=>{i.target&&!s.current&&dh(Oj,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 Ou(){const e=new CustomEvent(Ba);document.dispatchEvent(e)}function dh(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?gj(o,i):o.dispatchEvent(i)}var Vi="focusScope.autoFocusOnMount",qi="focusScope.autoFocusOnUnmount",Lu={bubbles:!1,cancelable:!0},Wj="FocusScope",sc=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...a}=e,[l,c]=p.useState(null),u=nt(o),d=nt(i),f=p.useRef(null),m=$e(t,c),h=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(s){let g=function(_){if(h.paused||!l)return;const j=_.target;l.contains(j)?f.current=j:mn(f.current,{select:!0})},b=function(_){if(h.paused||!l)return;const j=_.relatedTarget;j!==null&&(l.contains(j)||mn(f.current,{select:!0}))},v=function(_){if(document.activeElement===document.body)for(const S of _)S.removedNodes.length>0&&mn(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",b);const y=new MutationObserver(v);return l&&y.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",b),y.disconnect()}}},[s,l,h.paused]),p.useEffect(()=>{if(l){$u.add(h);const g=document.activeElement;if(!l.contains(g)){const v=new CustomEvent(Vi,Lu);l.addEventListener(Vi,u),l.dispatchEvent(v),v.defaultPrevented||(Hj(Kj(fh(l)),{select:!0}),document.activeElement===g&&mn(l))}return()=>{l.removeEventListener(Vi,u),setTimeout(()=>{const v=new CustomEvent(qi,Lu);l.addEventListener(qi,d),l.dispatchEvent(v),v.defaultPrevented||mn(g??document.body,{select:!0}),l.removeEventListener(qi,d),$u.remove(h)},0)}}},[l,u,d,h]);const x=p.useCallback(g=>{if(!n&&!s||h.paused)return;const b=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,v=document.activeElement;if(b&&v){const y=g.currentTarget,[_,j]=Vj(y);_&&j?!g.shiftKey&&v===j?(g.preventDefault(),n&&mn(_,{select:!0})):g.shiftKey&&v===_&&(g.preventDefault(),n&&mn(j,{select:!0})):v===y&&g.preventDefault()}},[n,s,h.paused]);return r.jsx(Ie.div,{tabIndex:-1,...a,ref:m,onKeyDown:x})});sc.displayName=Wj;function Hj(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(mn(s,{select:t}),document.activeElement!==n)return}function Vj(e){const t=fh(e),n=Du(t,e),s=Du(t.reverse(),e);return[n,s]}function fh(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 Du(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const s of e)if(!(n?!s.checkVisibility({checkVisibilityCSS:!0}):qj(s,{upTo:t})))return s}function qj(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 Zj(e){return e instanceof HTMLInputElement&&"select"in e}function mn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Zj(e)&&t&&e.select()}}var $u=Gj();function Gj(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Fu(e,t),e.unshift(t)},remove(t){e=Fu(e,t),e[0]?.resume()}}}function Fu(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function Kj(e){return e.filter(t=>t.tagName!=="A")}var Jj="Portal",fi=p.forwardRef((e,t)=>{const{container:n,...s}=e,[o,i]=p.useState(!1);Je(()=>i(!0),[]);const a=n||o&&globalThis?.document?.body;return a?Ds.createPortal(r.jsx(Ie.div,{...s,ref:t}),a):null});fi.displayName=Jj;var Hr=0,ls=null;function ph(){p.useEffect(()=>{ls||(ls={start:Uu(),end:Uu()});const{start:e,end:t}=ls;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Hr++,()=>{Hr===1&&(ls?.start.remove(),ls?.end.remove(),ls=null),Hr=Math.max(0,Hr-1)}},[])}function Uu(){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 Ht=function(){return Ht=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},Ht.apply(this,arguments)};function hh(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 Yj(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 mo="right-scroll-bar-position",go="width-before-scroll-bar",Xj="with-scroll-bars-hidden",Qj="--removed-body-scroll-bar-size";function Zi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function eS(e,t){var n=p.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 tS=typeof window<"u"?p.useLayoutEffect:p.useEffect,Bu=new WeakMap;function nS(e,t){var n=eS(null,function(s){return e.forEach(function(o){return Zi(o,s)})});return tS(function(){var s=Bu.get(n);if(s){var o=new Set(s),i=new Set(e),a=n.current;o.forEach(function(l){i.has(l)||Zi(l,null)}),i.forEach(function(l){o.has(l)||Zi(l,a)})}Bu.set(n,e)},[e]),n}function sS(e){return e}function rS(e,t){t===void 0&&(t=sS);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 c=function(){var d=a;a=[],d.forEach(i)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){a.push(d),u()},filter:function(d){return a=a.filter(d),n}}}};return o}function oS(e){e===void 0&&(e={});var t=rS(null);return t.options=Ht({async:!0,ssr:!1},e),t}var mh=function(e){var t=e.sideCar,n=hh(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 p.createElement(s,Ht({},n))};mh.isSideCarExport=!0;function iS(e,t){return e.useMedium(t),mh}var gh=oS(),Gi=function(){},pi=p.forwardRef(function(e,t){var n=p.useRef(null),s=p.useState({onScrollCapture:Gi,onWheelCapture:Gi,onTouchMoveCapture:Gi}),o=s[0],i=s[1],a=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,m=e.sideCar,h=e.noRelative,x=e.noIsolation,g=e.inert,b=e.allowPinchZoom,v=e.as,y=v===void 0?"div":v,_=e.gapMode,j=hh(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,E=nS([n,t]),T=Ht(Ht({},j),o);return p.createElement(p.Fragment,null,d&&p.createElement(S,{sideCar:gh,removeScrollBar:u,shards:f,noRelative:h,noIsolation:x,inert:g,setCallbacks:i,allowPinchZoom:!!b,lockRef:n,gapMode:_}),a?p.cloneElement(p.Children.only(l),Ht(Ht({},T),{ref:E})):p.createElement(y,Ht({},T,{className:c,ref:E}),l))});pi.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};pi.classNames={fullWidth:go,zeroRight:mo};var aS=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function lS(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=aS();return t&&e.setAttribute("nonce",t),e}function cS(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function uS(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var dS=function(){var e=0,t=null;return{add:function(n){e==0&&(t=lS())&&(cS(t,n),uS(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},fS=function(){var e=dS();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},xh=function(){var e=fS(),t=function(n){var s=n.styles,o=n.dynamic;return e(s,o),null};return t},pS={left:0,top:0,right:0,gap:0},Ki=function(e){return parseInt(e||"",10)||0},hS=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[Ki(n),Ki(s),Ki(o)]},mS=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return pS;var t=hS(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])}},gS=xh(),_s="data-scroll-locked",xS=function(e,t,n,s){var o=e.left,i=e.top,a=e.right,l=e.gap;return n===void 0&&(n="margin"),`
67
- .`.concat(Xj,` {
68
- overflow: hidden `).concat(s,`;
69
- padding-right: `).concat(l,"px ").concat(s,`;
70
- }
71
- body[`).concat(_s,`] {
72
- overflow: hidden `).concat(s,`;
73
- overscroll-behavior: contain;
74
- `).concat([t&&"position: relative ".concat(s,";"),n==="margin"&&`
75
- padding-left: `.concat(o,`px;
76
- padding-top: `).concat(i,`px;
77
- padding-right: `).concat(a,`px;
78
- margin-left:0;
79
- margin-top:0;
80
- margin-right: `).concat(l,"px ").concat(s,`;
81
- `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(s,";")].filter(Boolean).join(""),`
82
- }
83
-
84
- .`).concat(mo,` {
85
- right: `).concat(l,"px ").concat(s,`;
86
- }
87
-
88
- .`).concat(go,` {
89
- margin-right: `).concat(l,"px ").concat(s,`;
90
- }
91
-
92
- .`).concat(mo," .").concat(mo,` {
93
- right: 0 `).concat(s,`;
94
- }
95
-
96
- .`).concat(go," .").concat(go,` {
97
- margin-right: 0 `).concat(s,`;
98
- }
99
-
100
- body[`).concat(_s,`] {
101
- `).concat(Qj,": ").concat(l,`px;
102
- }
103
- `)},Wu=function(){var e=parseInt(document.body.getAttribute(_s)||"0",10);return isFinite(e)?e:0},bS=function(){p.useEffect(function(){return document.body.setAttribute(_s,(Wu()+1).toString()),function(){var e=Wu()-1;e<=0?document.body.removeAttribute(_s):document.body.setAttribute(_s,e.toString())}},[])},vS=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,o=s===void 0?"margin":s;bS();var i=p.useMemo(function(){return mS(o)},[o]);return p.createElement(gS,{styles:xS(i,!t,o,n?"":"!important")})},Wa=!1;if(typeof window<"u")try{var Vr=Object.defineProperty({},"passive",{get:function(){return Wa=!0,!0}});window.addEventListener("test",Vr,Vr),window.removeEventListener("test",Vr,Vr)}catch{Wa=!1}var cs=Wa?{passive:!1}:!1,yS=function(e){return e.tagName==="TEXTAREA"},bh=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!yS(e)&&n[t]==="visible")},wS=function(e){return bh(e,"overflowY")},_S=function(e){return bh(e,"overflowX")},Hu=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var o=vh(e,s);if(o){var i=yh(e,s),a=i[1],l=i[2];if(a>l)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},kS=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},jS=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},vh=function(e,t){return e==="v"?wS(t):_S(t)},yh=function(e,t){return e==="v"?kS(t):jS(t)},SS=function(e,t){return e==="h"&&t==="rtl"?-1:1},CS=function(e,t,n,s,o){var i=SS(e,window.getComputedStyle(t).direction),a=i*s,l=n.target,c=t.contains(l),u=!1,d=a>0,f=0,m=0;do{if(!l)break;var h=yh(e,l),x=h[0],g=h[1],b=h[2],v=g-b-i*x;(x||v)&&vh(e,l)&&(f+=v,m+=x);var y=l.parentNode;l=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(d&&Math.abs(f)<1||!d&&Math.abs(m)<1)&&(u=!0),u},qr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Vu=function(e){return[e.deltaX,e.deltaY]},qu=function(e){return e&&"current"in e?e.current:e},NS=function(e,t){return e[0]===t[0]&&e[1]===t[1]},TS=function(e){return`
104
- .block-interactivity-`.concat(e,` {pointer-events: none;}
105
- .allow-interactivity-`).concat(e,` {pointer-events: all;}
106
- `)},ES=0,us=[];function AS(e){var t=p.useRef([]),n=p.useRef([0,0]),s=p.useRef(),o=p.useState(ES++)[0],i=p.useState(xh)[0],a=p.useRef(e);p.useEffect(function(){a.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=Yj([e.lockRef.current],(e.shards||[]).map(qu),!0).filter(Boolean);return g.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=p.useCallback(function(g,b){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!a.current.allowPinchZoom;var v=qr(g),y=n.current,_="deltaX"in g?g.deltaX:y[0]-v[0],j="deltaY"in g?g.deltaY:y[1]-v[1],S,E=g.target,T=Math.abs(_)>Math.abs(j)?"h":"v";if("touches"in g&&T==="h"&&E.type==="range")return!1;var R=window.getSelection(),A=R&&R.anchorNode,z=A?A===E||A.contains(E):!1;if(z)return!1;var H=Hu(T,E);if(!H)return!0;if(H?S=T:(S=T==="v"?"h":"v",H=Hu(T,E)),!H)return!1;if(!s.current&&"changedTouches"in g&&(_||j)&&(s.current=S),!S)return!0;var N=s.current||S;return CS(N,b,g,N==="h"?_:j)},[]),c=p.useCallback(function(g){var b=g;if(!(!us.length||us[us.length-1]!==i)){var v="deltaY"in b?Vu(b):qr(b),y=t.current.filter(function(S){return S.name===b.type&&(S.target===b.target||b.target===S.shadowParent)&&NS(S.delta,v)})[0];if(y&&y.should){b.cancelable&&b.preventDefault();return}if(!y){var _=(a.current.shards||[]).map(qu).filter(Boolean).filter(function(S){return S.contains(b.target)}),j=_.length>0?l(b,_[0]):!a.current.noIsolation;j&&b.cancelable&&b.preventDefault()}}},[]),u=p.useCallback(function(g,b,v,y){var _={name:g,delta:b,target:v,should:y,shadowParent:RS(v)};t.current.push(_),setTimeout(function(){t.current=t.current.filter(function(j){return j!==_})},1)},[]),d=p.useCallback(function(g){n.current=qr(g),s.current=void 0},[]),f=p.useCallback(function(g){u(g.type,Vu(g),g.target,l(g,e.lockRef.current))},[]),m=p.useCallback(function(g){u(g.type,qr(g),g.target,l(g,e.lockRef.current))},[]);p.useEffect(function(){return us.push(i),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",c,cs),document.addEventListener("touchmove",c,cs),document.addEventListener("touchstart",d,cs),function(){us=us.filter(function(g){return g!==i}),document.removeEventListener("wheel",c,cs),document.removeEventListener("touchmove",c,cs),document.removeEventListener("touchstart",d,cs)}},[]);var h=e.removeScrollBar,x=e.inert;return p.createElement(p.Fragment,null,x?p.createElement(i,{styles:TS(o)}):null,h?p.createElement(vS,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function RS(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const IS=iS(gh,AS);var rc=p.forwardRef(function(e,t){return p.createElement(pi,Ht({},e,{ref:t,sideCar:IS}))});rc.classNames=pi.classNames;var PS=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ds=new WeakMap,Zr=new WeakMap,Gr={},Ji=0,wh=function(e){return e&&(e.host||wh(e.parentNode))},zS=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=wh(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})},MS=function(e,t,n,s){var o=zS(t,Array.isArray(e)?e:[e]);Gr[n]||(Gr[n]=new WeakMap);var i=Gr[n],a=[],l=new Set,c=new Set(o),u=function(f){!f||l.has(f)||(l.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(m){if(l.has(m))d(m);else try{var h=m.getAttribute(s),x=h!==null&&h!=="false",g=(ds.get(m)||0)+1,b=(i.get(m)||0)+1;ds.set(m,g),i.set(m,b),a.push(m),g===1&&x&&Zr.set(m,!0),b===1&&m.setAttribute(n,"true"),x||m.setAttribute(s,"true")}catch(v){console.error("aria-hidden: cannot operate on ",m,v)}})};return d(t),l.clear(),Ji++,function(){a.forEach(function(f){var m=ds.get(f)-1,h=i.get(f)-1;ds.set(f,m),i.set(f,h),m||(Zr.has(f)||f.removeAttribute(s),Zr.delete(f)),h||f.removeAttribute(n)}),Ji--,Ji||(ds=new WeakMap,ds=new WeakMap,Zr=new WeakMap,Gr={})}},_h=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),o=PS(e);return o?(s.push.apply(s,Array.from(o.querySelectorAll("[aria-live], script"))),MS(s,o,n,"aria-hidden")):function(){return null}},hi="Dialog",[kh]=ln(hi),[OS,Ut]=kh(hi),jh=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:o,onOpenChange:i,modal:a=!0}=e,l=p.useRef(null),c=p.useRef(null),[u,d]=Kn({prop:s,defaultProp:o??!1,onChange:i,caller:hi});return r.jsx(OS,{scope:t,triggerRef:l,contentRef:c,contentId:Zt(),titleId:Zt(),descriptionId:Zt(),open:u,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(f=>!f),[d]),modal:a,children:n})};jh.displayName=hi;var Sh="DialogTrigger",Ch=p.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Ut(Sh,n),i=$e(t,o.triggerRef);return r.jsx(Ie.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":ic(o.open),...s,ref:i,onClick:Ne(e.onClick,o.onOpenToggle)})});Ch.displayName=Sh;var oc="DialogPortal",[LS,Nh]=kh(oc,{forceMount:void 0}),Th=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:o}=e,i=Ut(oc,t);return r.jsx(LS,{scope:t,forceMount:n,children:p.Children.map(s,a=>r.jsx(St,{present:n||i.open,children:r.jsx(fi,{asChild:!0,container:o,children:a})}))})};Th.displayName=oc;var zo="DialogOverlay",Eh=p.forwardRef((e,t)=>{const n=Nh(zo,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,i=Ut(zo,e.__scopeDialog);return i.modal?r.jsx(St,{present:s||i.open,children:r.jsx($S,{...o,ref:t})}):null});Eh.displayName=zo;var DS=Rs("DialogOverlay.RemoveScroll"),$S=p.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Ut(zo,n),i=$j(),a=$e(t,i);return r.jsx(rc,{as:DS,allowPinchZoom:!0,shards:[o.contentRef],children:r.jsx(Ie.div,{"data-state":ic(o.open),...s,ref:a,style:{pointerEvents:"auto",...s.style}})})}),Is="DialogContent",Ah=p.forwardRef((e,t)=>{const n=Nh(Is,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,i=Ut(Is,e.__scopeDialog);return r.jsx(St,{present:s||i.open,children:i.modal?r.jsx(FS,{...o,ref:t}):r.jsx(US,{...o,ref:t})})});Ah.displayName=Is;var FS=p.forwardRef((e,t)=>{const n=Ut(Is,e.__scopeDialog),s=p.useRef(null),o=$e(t,n.contentRef,s);return p.useEffect(()=>{const i=s.current;if(i)return _h(i)},[]),r.jsx(Rh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Ne(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ne(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&i.preventDefault()}),onFocusOutside:Ne(e.onFocusOutside,i=>i.preventDefault())})}),US=p.forwardRef((e,t)=>{const n=Ut(Is,e.__scopeDialog),s=p.useRef(!1),o=p.useRef(!1);return r.jsx(Rh,{...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()}})}),Rh=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:i,...a}=e,l=Ut(Is,n);return ph(),r.jsx(r.Fragment,{children:r.jsx(sc,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:i,children:r.jsx(di,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":ic(l.open),...a,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),Ih="DialogTitle",Ph=p.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Ut(Ih,n);return r.jsx(Ie.h2,{id:o.titleId,...s,ref:t})});Ph.displayName=Ih;var zh="DialogDescription",Mh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Ut(zh,n);return r.jsx(Ie.p,{id:o.descriptionId,...s,ref:t})});Mh.displayName=zh;var Oh="DialogClose",Lh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Ut(Oh,n);return r.jsx(Ie.button,{type:"button",...s,ref:t,onClick:Ne(e.onClick,()=>o.onOpenChange(!1))})});Lh.displayName=Oh;function ic(e){return e?"open":"closed"}function BS(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function WS(e){const[t,n]=p.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 c=i.borderBoxSize,u=Array.isArray(c)?c[0]:c;a=u.inlineSize,l=u.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 HS=["top","right","bottom","left"],wn=Math.min,yt=Math.max,Mo=Math.round,Kr=Math.floor,Gt=e=>({x:e,y:e}),VS={left:"right",right:"left",bottom:"top",top:"bottom"},qS={start:"end",end:"start"};function Ha(e,t,n){return yt(e,wn(t,n))}function rn(e,t){return typeof e=="function"?e(t):e}function on(e){return e.split("-")[0]}function Us(e){return e.split("-")[1]}function ac(e){return e==="x"?"y":"x"}function lc(e){return e==="y"?"height":"width"}const ZS=new Set(["top","bottom"]);function Vt(e){return ZS.has(on(e))?"y":"x"}function cc(e){return ac(Vt(e))}function GS(e,t,n){n===void 0&&(n=!1);const s=Us(e),o=cc(e),i=lc(o);let a=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Oo(a)),[a,Oo(a)]}function KS(e){const t=Oo(e);return[Va(e),t,Va(t)]}function Va(e){return e.replace(/start|end/g,t=>qS[t])}const Zu=["left","right"],Gu=["right","left"],JS=["top","bottom"],YS=["bottom","top"];function XS(e,t,n){switch(e){case"top":case"bottom":return n?t?Gu:Zu:t?Zu:Gu;case"left":case"right":return t?JS:YS;default:return[]}}function QS(e,t,n,s){const o=Us(e);let i=XS(on(e),n==="start",s);return o&&(i=i.map(a=>a+"-"+o),t&&(i=i.concat(i.map(Va)))),i}function Oo(e){return e.replace(/left|right|bottom|top/g,t=>VS[t])}function eC(e){return{top:0,right:0,bottom:0,left:0,...e}}function Dh(e){return typeof e!="number"?eC(e):{top:e,right:e,bottom:e,left:e}}function Lo(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 Ku(e,t,n){let{reference:s,floating:o}=e;const i=Vt(t),a=cc(t),l=lc(a),c=on(t),u=i==="y",d=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(c){case"top":h={x:d,y:s.y-o.height};break;case"bottom":h={x:d,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(Us(t)){case"start":h[a]-=m*(n&&u?-1:1);break;case"end":h[a]+=m*(n&&u?-1:1);break}return h}async function tC(e,t){var n;t===void 0&&(t={});const{x:s,y:o,platform:i,rects:a,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:m=!1,padding:h=0}=rn(t,e),x=Dh(h),b=l[m?f==="floating"?"reference":"floating":f],v=Lo(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:u,rootBoundary:d,strategy:c})),y=f==="floating"?{x:s,y:o,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),j=await(i.isElement==null?void 0:i.isElement(_))?await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1}:{x:1,y:1},S=Lo(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:_,strategy:c}):y);return{top:(v.top-S.top+x.top)/j.y,bottom:(S.bottom-v.bottom+x.bottom)/j.y,left:(v.left-S.left+x.left)/j.x,right:(S.right-v.right+x.right)/j.x}}const nC=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:i=[],platform:a}=n,l=i.filter(Boolean),c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=Ku(u,s,c),m=s,h={},x=0;for(let b=0;b<l.length;b++){var g;const{name:v,fn:y}=l[b],{x:_,y:j,data:S,reset:E}=await y({x:d,y:f,initialPlacement:s,placement:m,strategy:o,middlewareData:h,rects:u,platform:{...a,detectOverflow:(g=a.detectOverflow)!=null?g:tC},elements:{reference:e,floating:t}});d=_??d,f=j??f,h={...h,[v]:{...h[v],...S}},E&&x<=50&&(x++,typeof E=="object"&&(E.placement&&(m=E.placement),E.rects&&(u=E.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):E.rects),{x:d,y:f}=Ku(u,m,c)),b=-1)}return{x:d,y:f,placement:m,strategy:o,middlewareData:h}},sC=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:o,rects:i,platform:a,elements:l,middlewareData:c}=t,{element:u,padding:d=0}=rn(e,t)||{};if(u==null)return{};const f=Dh(d),m={x:n,y:s},h=cc(o),x=lc(h),g=await a.getDimensions(u),b=h==="y",v=b?"top":"left",y=b?"bottom":"right",_=b?"clientHeight":"clientWidth",j=i.reference[x]+i.reference[h]-m[h]-i.floating[x],S=m[h]-i.reference[h],E=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let T=E?E[_]:0;(!T||!await(a.isElement==null?void 0:a.isElement(E)))&&(T=l.floating[_]||i.floating[x]);const R=j/2-S/2,A=T/2-g[x]/2-1,z=wn(f[v],A),H=wn(f[y],A),N=z,L=T-g[x]-H,w=T/2-g[x]/2+R,$=Ha(N,w,L),X=!c.arrow&&Us(o)!=null&&w!==$&&i.reference[x]/2-(w<N?z:H)-g[x]/2<0,B=X?w<N?w-N:w-L:0;return{[h]:m[h]+B,data:{[h]:$,centerOffset:w-$-B,...X&&{alignmentOffset:B}},reset:X}}}),rC=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:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:g=!0,...b}=rn(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const v=on(o),y=Vt(l),_=on(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=m||(_||!g?[Oo(l)]:KS(l)),E=x!=="none";!m&&E&&S.push(...QS(l,g,x,j));const T=[l,...S],R=await c.detectOverflow(t,b),A=[];let z=((s=i.flip)==null?void 0:s.overflows)||[];if(d&&A.push(R[v]),f){const w=GS(o,a,j);A.push(R[w[0]],R[w[1]])}if(z=[...z,{placement:o,overflows:A}],!A.every(w=>w<=0)){var H,N;const w=(((H=i.flip)==null?void 0:H.index)||0)+1,$=T[w];if($&&(!(f==="alignment"?y!==Vt($):!1)||z.every(Q=>Vt(Q.placement)===y?Q.overflows[0]>0:!0)))return{data:{index:w,overflows:z},reset:{placement:$}};let X=(N=z.filter(B=>B.overflows[0]<=0).sort((B,Q)=>B.overflows[1]-Q.overflows[1])[0])==null?void 0:N.placement;if(!X)switch(h){case"bestFit":{var L;const B=(L=z.filter(Q=>{if(E){const D=Vt(Q.placement);return D===y||D==="y"}return!0}).map(Q=>[Q.placement,Q.overflows.filter(D=>D>0).reduce((D,Z)=>D+Z,0)]).sort((Q,D)=>Q[1]-D[1])[0])==null?void 0:L[0];B&&(X=B);break}case"initialPlacement":X=l;break}if(o!==X)return{reset:{placement:X}}}return{}}}};function Ju(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Yu(e){return HS.some(t=>e[t]>=0)}const oC=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:o="referenceHidden",...i}=rn(e,t);switch(o){case"referenceHidden":{const a=await s.detectOverflow(t,{...i,elementContext:"reference"}),l=Ju(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Yu(l)}}}case"escaped":{const a=await s.detectOverflow(t,{...i,altBoundary:!0}),l=Ju(a,n.floating);return{data:{escapedOffsets:l,escaped:Yu(l)}}}default:return{}}}}},$h=new Set(["left","top"]);async function iC(e,t){const{placement:n,platform:s,elements:o}=e,i=await(s.isRTL==null?void 0:s.isRTL(o.floating)),a=on(n),l=Us(n),c=Vt(n)==="y",u=$h.has(a)?-1:1,d=i&&c?-1:1,f=rn(t,e);let{mainAxis:m,crossAxis:h,alignmentAxis:x}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof x=="number"&&(h=l==="end"?x*-1:x),c?{x:h*d,y:m*u}:{x:m*u,y:h*d}}const aC=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,c=await iC(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(s=l.arrow)!=null&&s.alignmentOffset?{}:{x:o+c.x,y:i+c.y,data:{...c,placement:a}}}}},lC=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:c={fn:v=>{let{x:y,y:_}=v;return{x:y,y:_}}},...u}=rn(e,t),d={x:n,y:s},f=await i.detectOverflow(t,u),m=Vt(on(o)),h=ac(m);let x=d[h],g=d[m];if(a){const v=h==="y"?"top":"left",y=h==="y"?"bottom":"right",_=x+f[v],j=x-f[y];x=Ha(_,x,j)}if(l){const v=m==="y"?"top":"left",y=m==="y"?"bottom":"right",_=g+f[v],j=g-f[y];g=Ha(_,g,j)}const b=c.fn({...t,[h]:x,[m]:g});return{...b,data:{x:b.x-n,y:b.y-s,enabled:{[h]:a,[m]:l}}}}}},cC=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:c=!0,crossAxis:u=!0}=rn(e,t),d={x:n,y:s},f=Vt(o),m=ac(f);let h=d[m],x=d[f];const g=rn(l,t),b=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const _=m==="y"?"height":"width",j=i.reference[m]-i.floating[_]+b.mainAxis,S=i.reference[m]+i.reference[_]-b.mainAxis;h<j?h=j:h>S&&(h=S)}if(u){var v,y;const _=m==="y"?"width":"height",j=$h.has(on(o)),S=i.reference[f]-i.floating[_]+(j&&((v=a.offset)==null?void 0:v[f])||0)+(j?0:b.crossAxis),E=i.reference[f]+i.reference[_]+(j?0:((y=a.offset)==null?void 0:y[f])||0)-(j?b.crossAxis:0);x<S?x=S:x>E&&(x=E)}return{[m]:h,[f]:x}}}},uC=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:c=()=>{},...u}=rn(e,t),d=await a.detectOverflow(t,u),f=on(o),m=Us(o),h=Vt(o)==="y",{width:x,height:g}=i.floating;let b,v;f==="top"||f==="bottom"?(b=f,v=m===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(v=f,b=m==="end"?"top":"bottom");const y=g-d.top-d.bottom,_=x-d.left-d.right,j=wn(g-d[b],y),S=wn(x-d[v],_),E=!t.middlewareData.shift;let T=j,R=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(R=_),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(T=y),E&&!m){const z=yt(d.left,0),H=yt(d.right,0),N=yt(d.top,0),L=yt(d.bottom,0);h?R=x-2*(z!==0||H!==0?z+H:yt(d.left,d.right)):T=g-2*(N!==0||L!==0?N+L:yt(d.top,d.bottom))}await c({...t,availableWidth:R,availableHeight:T});const A=await a.getDimensions(l.floating);return x!==A.width||g!==A.height?{reset:{rects:!0}}:{}}}};function mi(){return typeof window<"u"}function Bs(e){return Fh(e)?(e.nodeName||"").toLowerCase():"#document"}function kt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Yt(e){var t;return(t=(Fh(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Fh(e){return mi()?e instanceof Node||e instanceof kt(e).Node:!1}function $t(e){return mi()?e instanceof Element||e instanceof kt(e).Element:!1}function Kt(e){return mi()?e instanceof HTMLElement||e instanceof kt(e).HTMLElement:!1}function Xu(e){return!mi()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof kt(e).ShadowRoot}const dC=new Set(["inline","contents"]);function jr(e){const{overflow:t,overflowX:n,overflowY:s,display:o}=Ft(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!dC.has(o)}const fC=new Set(["table","td","th"]);function pC(e){return fC.has(Bs(e))}const hC=[":popover-open",":modal"];function gi(e){return hC.some(t=>{try{return e.matches(t)}catch{return!1}})}const mC=["transform","translate","scale","rotate","perspective"],gC=["transform","translate","scale","rotate","perspective","filter"],xC=["paint","layout","strict","content"];function uc(e){const t=dc(),n=$t(e)?Ft(e):e;return mC.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)||gC.some(s=>(n.willChange||"").includes(s))||xC.some(s=>(n.contain||"").includes(s))}function bC(e){let t=_n(e);for(;Kt(t)&&!Ps(t);){if(uc(t))return t;if(gi(t))return null;t=_n(t)}return null}function dc(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const vC=new Set(["html","body","#document"]);function Ps(e){return vC.has(Bs(e))}function Ft(e){return kt(e).getComputedStyle(e)}function xi(e){return $t(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function _n(e){if(Bs(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Xu(e)&&e.host||Yt(e);return Xu(t)?t.host:t}function Uh(e){const t=_n(e);return Ps(t)?e.ownerDocument?e.ownerDocument.body:e.body:Kt(t)&&jr(t)?t:Uh(t)}function ur(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Uh(e),i=o===((s=e.ownerDocument)==null?void 0:s.body),a=kt(o);if(i){const l=qa(a);return t.concat(a,a.visualViewport||[],jr(o)?o:[],l&&n?ur(l):[])}return t.concat(o,ur(o,[],n))}function qa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Bh(e){const t=Ft(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=Kt(e),i=o?e.offsetWidth:n,a=o?e.offsetHeight:s,l=Mo(n)!==i||Mo(s)!==a;return l&&(n=i,s=a),{width:n,height:s,$:l}}function fc(e){return $t(e)?e:e.contextElement}function ks(e){const t=fc(e);if(!Kt(t))return Gt(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:i}=Bh(t);let a=(i?Mo(n.width):n.width)/s,l=(i?Mo(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const yC=Gt(0);function Wh(e){const t=kt(e);return!dc()||!t.visualViewport?yC:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function wC(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==kt(e)?!1:t}function Jn(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=fc(e);let a=Gt(1);t&&(s?$t(s)&&(a=ks(s)):a=ks(e));const l=wC(i,n,s)?Wh(i):Gt(0);let c=(o.left+l.x)/a.x,u=(o.top+l.y)/a.y,d=o.width/a.x,f=o.height/a.y;if(i){const m=kt(i),h=s&&$t(s)?kt(s):s;let x=m,g=qa(x);for(;g&&s&&h!==x;){const b=ks(g),v=g.getBoundingClientRect(),y=Ft(g),_=v.left+(g.clientLeft+parseFloat(y.paddingLeft))*b.x,j=v.top+(g.clientTop+parseFloat(y.paddingTop))*b.y;c*=b.x,u*=b.y,d*=b.x,f*=b.y,c+=_,u+=j,x=kt(g),g=qa(x)}}return Lo({width:d,height:f,x:c,y:u})}function bi(e,t){const n=xi(e).scrollLeft;return t?t.left+n:Jn(Yt(e)).left+n}function Hh(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-bi(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function _C(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const i=o==="fixed",a=Yt(s),l=t?gi(t.floating):!1;if(s===a||l&&i)return n;let c={scrollLeft:0,scrollTop:0},u=Gt(1);const d=Gt(0),f=Kt(s);if((f||!f&&!i)&&((Bs(s)!=="body"||jr(a))&&(c=xi(s)),Kt(s))){const h=Jn(s);u=ks(s),d.x=h.x+s.clientLeft,d.y=h.y+s.clientTop}const m=a&&!f&&!i?Hh(a,c):Gt(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+m.x,y:n.y*u.y-c.scrollTop*u.y+d.y+m.y}}function kC(e){return Array.from(e.getClientRects())}function jC(e){const t=Yt(e),n=xi(e),s=e.ownerDocument.body,o=yt(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),i=yt(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let a=-n.scrollLeft+bi(e);const l=-n.scrollTop;return Ft(s).direction==="rtl"&&(a+=yt(t.clientWidth,s.clientWidth)-o),{width:o,height:i,x:a,y:l}}const Qu=25;function SC(e,t){const n=kt(e),s=Yt(e),o=n.visualViewport;let i=s.clientWidth,a=s.clientHeight,l=0,c=0;if(o){i=o.width,a=o.height;const d=dc();(!d||d&&t==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}const u=bi(s);if(u<=0){const d=s.ownerDocument,f=d.body,m=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,x=Math.abs(s.clientWidth-f.clientWidth-h);x<=Qu&&(i-=x)}else u<=Qu&&(i+=u);return{width:i,height:a,x:l,y:c}}const CC=new Set(["absolute","fixed"]);function NC(e,t){const n=Jn(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,i=Kt(e)?ks(e):Gt(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,c=o*i.x,u=s*i.y;return{width:a,height:l,x:c,y:u}}function ed(e,t,n){let s;if(t==="viewport")s=SC(e,n);else if(t==="document")s=jC(Yt(e));else if($t(t))s=NC(t,n);else{const o=Wh(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Lo(s)}function Vh(e,t){const n=_n(e);return n===t||!$t(n)||Ps(n)?!1:Ft(n).position==="fixed"||Vh(n,t)}function TC(e,t){const n=t.get(e);if(n)return n;let s=ur(e,[],!1).filter(l=>$t(l)&&Bs(l)!=="body"),o=null;const i=Ft(e).position==="fixed";let a=i?_n(e):e;for(;$t(a)&&!Ps(a);){const l=Ft(a),c=uc(a);!c&&l.position==="fixed"&&(o=null),(i?!c&&!o:!c&&l.position==="static"&&!!o&&CC.has(o.position)||jr(a)&&!c&&Vh(e,a))?s=s.filter(d=>d!==a):o=l,a=_n(a)}return t.set(e,s),s}function EC(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const a=[...n==="clippingAncestors"?gi(t)?[]:TC(t,this._c):[].concat(n),s],l=a[0],c=a.reduce((u,d)=>{const f=ed(t,d,o);return u.top=yt(f.top,u.top),u.right=wn(f.right,u.right),u.bottom=wn(f.bottom,u.bottom),u.left=yt(f.left,u.left),u},ed(t,l,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function AC(e){const{width:t,height:n}=Bh(e);return{width:t,height:n}}function RC(e,t,n){const s=Kt(t),o=Yt(t),i=n==="fixed",a=Jn(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=Gt(0);function u(){c.x=bi(o)}if(s||!s&&!i)if((Bs(t)!=="body"||jr(o))&&(l=xi(t)),s){const h=Jn(t,!0,i,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else o&&u();i&&!s&&o&&u();const d=o&&!s&&!i?Hh(o,l):Gt(0),f=a.left+l.scrollLeft-c.x-d.x,m=a.top+l.scrollTop-c.y-d.y;return{x:f,y:m,width:a.width,height:a.height}}function Yi(e){return Ft(e).position==="static"}function td(e,t){if(!Kt(e)||Ft(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Yt(e)===n&&(n=n.ownerDocument.body),n}function qh(e,t){const n=kt(e);if(gi(e))return n;if(!Kt(e)){let o=_n(e);for(;o&&!Ps(o);){if($t(o)&&!Yi(o))return o;o=_n(o)}return n}let s=td(e,t);for(;s&&pC(s)&&Yi(s);)s=td(s,t);return s&&Ps(s)&&Yi(s)&&!uc(s)?n:s||bC(e)||n}const IC=async function(e){const t=this.getOffsetParent||qh,n=this.getDimensions,s=await n(e.floating);return{reference:RC(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function PC(e){return Ft(e).direction==="rtl"}const zC={convertOffsetParentRelativeRectToViewportRelativeRect:_C,getDocumentElement:Yt,getClippingRect:EC,getOffsetParent:qh,getElementRects:IC,getClientRects:kC,getDimensions:AC,getScale:ks,isElement:$t,isRTL:PC};function Zh(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function MC(e,t){let n=null,s;const o=Yt(e);function i(){var l;clearTimeout(s),(l=n)==null||l.disconnect(),n=null}function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),i();const u=e.getBoundingClientRect(),{left:d,top:f,width:m,height:h}=u;if(l||t(),!m||!h)return;const x=Kr(f),g=Kr(o.clientWidth-(d+m)),b=Kr(o.clientHeight-(f+h)),v=Kr(d),_={rootMargin:-x+"px "+-g+"px "+-b+"px "+-v+"px",threshold:yt(0,wn(1,c))||1};let j=!0;function S(E){const T=E[0].intersectionRatio;if(T!==c){if(!j)return a();T?a(!1,T):s=setTimeout(()=>{a(!1,1e-7)},1e3)}T===1&&!Zh(u,e.getBoundingClientRect())&&a(),j=!1}try{n=new IntersectionObserver(S,{..._,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,_)}n.observe(e)}return a(!0),i}function OC(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:c=!1}=s,u=fc(e),d=o||i?[...u?ur(u):[],...ur(t)]:[];d.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),i&&v.addEventListener("resize",n)});const f=u&&l?MC(u,n):null;let m=-1,h=null;a&&(h=new ResizeObserver(v=>{let[y]=v;y&&y.target===u&&h&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var _;(_=h)==null||_.observe(t)})),n()}),u&&!c&&h.observe(u),h.observe(t));let x,g=c?Jn(e):null;c&&b();function b(){const v=Jn(e);g&&!Zh(g,v)&&n(),g=v,x=requestAnimationFrame(b)}return n(),()=>{var v;d.forEach(y=>{o&&y.removeEventListener("scroll",n),i&&y.removeEventListener("resize",n)}),f?.(),(v=h)==null||v.disconnect(),h=null,c&&cancelAnimationFrame(x)}}const LC=aC,DC=lC,$C=rC,FC=uC,UC=oC,nd=sC,BC=cC,WC=(e,t,n)=>{const s=new Map,o={platform:zC,...n},i={...o.platform,_c:s};return nC(e,t,{...o,platform:i})};var HC=typeof document<"u",VC=function(){},xo=HC?p.useLayoutEffect:VC;function Do(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(!Do(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)&&!Do(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function Gh(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function sd(e,t){const n=Gh(e);return Math.round(t*n)/n}function Xi(e){const t=p.useRef(e);return xo(()=>{t.current=e}),t}function qC(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:c,open:u}=e,[d,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=p.useState(s);Do(m,s)||h(s);const[x,g]=p.useState(null),[b,v]=p.useState(null),y=p.useCallback(Q=>{Q!==E.current&&(E.current=Q,g(Q))},[]),_=p.useCallback(Q=>{Q!==T.current&&(T.current=Q,v(Q))},[]),j=i||x,S=a||b,E=p.useRef(null),T=p.useRef(null),R=p.useRef(d),A=c!=null,z=Xi(c),H=Xi(o),N=Xi(u),L=p.useCallback(()=>{if(!E.current||!T.current)return;const Q={placement:t,strategy:n,middleware:m};H.current&&(Q.platform=H.current),WC(E.current,T.current,Q).then(D=>{const Z={...D,isPositioned:N.current!==!1};w.current&&!Do(R.current,Z)&&(R.current=Z,Ds.flushSync(()=>{f(Z)}))})},[m,t,n,H,N]);xo(()=>{u===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,f(Q=>({...Q,isPositioned:!1})))},[u]);const w=p.useRef(!1);xo(()=>(w.current=!0,()=>{w.current=!1}),[]),xo(()=>{if(j&&(E.current=j),S&&(T.current=S),j&&S){if(z.current)return z.current(j,S,L);L()}},[j,S,L,z,A]);const $=p.useMemo(()=>({reference:E,floating:T,setReference:y,setFloating:_}),[y,_]),X=p.useMemo(()=>({reference:j,floating:S}),[j,S]),B=p.useMemo(()=>{const Q={position:n,left:0,top:0};if(!X.floating)return Q;const D=sd(X.floating,d.x),Z=sd(X.floating,d.y);return l?{...Q,transform:"translate("+D+"px, "+Z+"px)",...Gh(X.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:D,top:Z}},[n,l,X.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:L,refs:$,elements:X,floatingStyles:B}),[d,L,$,X,B])}const ZC=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?nd({element:s.current,padding:o}).fn(n):{}:s?nd({element:s,padding:o}).fn(n):{}}}},GC=(e,t)=>({...LC(e),options:[e,t]}),KC=(e,t)=>({...DC(e),options:[e,t]}),JC=(e,t)=>({...BC(e),options:[e,t]}),YC=(e,t)=>({...$C(e),options:[e,t]}),XC=(e,t)=>({...FC(e),options:[e,t]}),QC=(e,t)=>({...UC(e),options:[e,t]}),e3=(e,t)=>({...ZC(e),options:[e,t]});var t3="Arrow",Kh=p.forwardRef((e,t)=>{const{children:n,width:s=10,height:o=5,...i}=e;return r.jsx(Ie.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"})})});Kh.displayName=t3;var n3=Kh,pc="Popper",[Jh,vi]=ln(pc),[s3,Yh]=Jh(pc),Xh=e=>{const{__scopePopper:t,children:n}=e,[s,o]=p.useState(null),[i,a]=p.useState(void 0);return r.jsx(s3,{scope:t,anchor:s,onAnchorChange:o,placementState:i,setPlacementState:a,children:n})};Xh.displayName=pc;var Qh="PopperAnchor",em=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,i=Yh(Qh,n),a=p.useRef(null),l=i.onAnchorChange,c=p.useCallback(x=>{a.current=x,x&&l(x)},[l]),u=$e(t,c),d=p.useRef(null);p.useEffect(()=>{if(!s)return;const x=d.current;d.current=s.current,x!==d.current&&l(d.current)});const f=i.placementState&&mc(i.placementState),m=f?.[0],h=f?.[1];return s?null:r.jsx(Ie.div,{"data-radix-popper-side":m,"data-radix-popper-align":h,...o,ref:u})});em.displayName=Qh;var hc="PopperContent",[r3,o3]=Jh(hc),tm=p.forwardRef((e,t)=>{const{__scopePopper:n,side:s="bottom",sideOffset:o=0,align:i="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:h="optimized",onPlaced:x,...g}=e,b=Yh(hc,n),[v,y]=p.useState(null),_=$e(t,y),[j,S]=p.useState(null),E=WS(j),T=E?.width??0,R=E?.height??0,A=s+(i!=="center"?"-"+i:""),z=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},H=Array.isArray(u)?u:[u],N=H.length>0,L={padding:z,boundary:H.filter(a3),altBoundary:N},{refs:w,floatingStyles:$,placement:X,isPositioned:B,middlewareData:Q}=qC({strategy:"fixed",placement:A,whileElementsMounted:(...pe)=>OC(...pe,{animationFrame:h==="always"}),elements:{reference:b.anchor},middleware:[GC({mainAxis:o+R,alignmentAxis:a}),c&&KC({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?JC():void 0,...L}),c&&YC({...L}),XC({...L,apply:({elements:pe,rects:me,availableWidth:ve,availableHeight:xe})=>{const{width:Ce,height:Ae}=me.reference,k=pe.floating.style;k.setProperty("--radix-popper-available-width",`${ve}px`),k.setProperty("--radix-popper-available-height",`${xe}px`),k.setProperty("--radix-popper-anchor-width",`${Ce}px`),k.setProperty("--radix-popper-anchor-height",`${Ae}px`)}}),j&&e3({element:j,padding:l}),l3({arrowWidth:T,arrowHeight:R}),m&&QC({strategy:"referenceHidden",...L,boundary:N?L.boundary:void 0})]}),D=b.setPlacementState;Je(()=>(D(X),()=>{D(void 0)}),[X,D]);const[Z,W]=mc(X),V=nt(x);Je(()=>{B&&V?.()},[B,V]);const ue=Q.arrow?.x,te=Q.arrow?.y,F=Q.arrow?.centerOffset!==0,[ge,de]=p.useState();return Je(()=>{v&&de(window.getComputedStyle(v).zIndex)},[v]),r.jsx("div",{ref:w.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:B?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ge,"--radix-popper-transform-origin":[Q.transformOrigin?.x,Q.transformOrigin?.y].join(" "),...Q.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(r3,{scope:n,placedSide:Z,placedAlign:W,onArrowChange:S,arrowX:ue,arrowY:te,shouldHideArrow:F,children:r.jsx(Ie.div,{"data-side":Z,"data-align":W,...g,ref:_,style:{...g.style,animation:B?void 0:"none"}})})})});tm.displayName=hc;var nm="PopperArrow",i3={top:"bottom",right:"left",bottom:"top",left:"right"},sm=p.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,i=o3(nm,s),a=i3[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(n3,{...o,ref:n,style:{...o.style,display:"block"}})})});sm.displayName=nm;function a3(e){return e!==null}var l3=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,c=a?0:e.arrowHeight,[u,d]=mc(n),f={start:"0%",center:"50%",end:"100%"}[d],m=(o.arrow?.x??0)+l/2,h=(o.arrow?.y??0)+c/2;let x="",g="";return u==="bottom"?(x=a?f:`${m}px`,g=`${-c}px`):u==="top"?(x=a?f:`${m}px`,g=`${s.floating.height+c}px`):u==="right"?(x=`${-c}px`,g=a?f:`${h}px`):u==="left"&&(x=`${s.floating.width+c}px`,g=a?f:`${h}px`),{data:{x,y:g}}}});function mc(e){const[t,n="center"]=e.split("-");return[t,n]}var rm=Xh,om=em,im=tm,am=sm,Qi=!1;function c3(){const[e,t]=p.useState(Qi);return p.useEffect(()=>{Qi||(Qi=!0,t(!0))},[]),e}var lm=Qo[" useSyncExternalStore ".trim().toString()];function u3(){return()=>{}}function d3(){return lm(u3,()=>!0,()=>!1)}var f3=typeof lm=="function"?d3:c3,ea="rovingFocusGroup.onEntryFocus",p3={bubbles:!1,cancelable:!0},Sr="RovingFocusGroup",[Za,cm,h3]=ih(Sr),[m3,um]=ln(Sr,[h3]),[g3,x3]=m3(Sr),dm=p.forwardRef((e,t)=>r.jsx(Za.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Za.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(b3,{...e,ref:t})})}));dm.displayName=Sr;var b3=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,m=p.useRef(null),h=$e(t,m),x=ui(i),[g,b]=Kn({prop:a,defaultProp:l??null,onChange:c,caller:Sr}),[v,y]=p.useState(!1),_=nt(u),j=cm(n),S=p.useRef(!1),[E,T]=p.useState(0);return p.useEffect(()=>{const R=m.current;if(R)return R.addEventListener(ea,_),()=>R.removeEventListener(ea,_)},[_]),r.jsx(g3,{scope:n,orientation:s,dir:x,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(R=>b(R),[b]),onItemShiftTab:p.useCallback(()=>y(!0),[]),onFocusableItemAdd:p.useCallback(()=>T(R=>R+1),[]),onFocusableItemRemove:p.useCallback(()=>T(R=>R-1),[]),children:r.jsx(Ie.div,{tabIndex:v||E===0?-1:0,"data-orientation":s,...f,ref:h,style:{outline:"none",...e.style},onMouseDown:Ne(e.onMouseDown,()=>{S.current=!0}),onFocus:Ne(e.onFocus,R=>{const A=!S.current;if(R.target===R.currentTarget&&A&&!v){const z=new CustomEvent(ea,p3);if(R.currentTarget.dispatchEvent(z),!z.defaultPrevented){const H=j().filter(X=>X.focusable),N=H.find(X=>X.active),L=H.find(X=>X.id===g),$=[N,L,...H].filter(Boolean).map(X=>X.ref.current);hm($,d)}}S.current=!1}),onBlur:Ne(e.onBlur,()=>y(!1))})})}),fm="RovingFocusGroupItem",pm=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:i,children:a,...l}=e,c=Zt(),u=i||c,d=x3(fm,n),f=d.currentTabStopId===u,m=cm(n),{onFocusableItemAdd:h,onFocusableItemRemove:x,currentTabStopId:g}=d,b=f3();return Je(()=>{if(!(!b||!s))return h(),()=>x()},[b,s,h,x]),p.useEffect(()=>{if(!(b||!s))return h(),()=>x()},[b,s,h,x]),r.jsx(Za.ItemSlot,{scope:n,id:u,focusable:s,active:o,children:r.jsx(Ie.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...l,ref:t,onMouseDown:Ne(e.onMouseDown,v=>{s?d.onItemFocus(u):v.preventDefault()}),onFocus:Ne(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:Ne(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const y=w3(v,d.orientation,d.dir);if(y!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let j=m().filter(S=>S.focusable).map(S=>S.ref.current);if(y==="last")j.reverse();else if(y==="prev"||y==="next"){y==="prev"&&j.reverse();const S=j.indexOf(v.currentTarget);j=d.loop?_3(j,S+1):j.slice(S+1)}setTimeout(()=>hm(j))}}),children:typeof a=="function"?a({isCurrentTabStop:f,hasTabStop:g!=null}):a})})});pm.displayName=fm;var v3={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function y3(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function w3(e,t,n){const s=y3(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return v3[s]}function hm(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function _3(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var k3=dm,j3=pm;function Ga(e,[t,n]){return Math.min(n,Math.max(t,e))}function S3(e,t){return p.useReducer((n,s)=>t[n][s]??n,e)}var gc="ScrollArea",[mm]=ln(gc),[C3,zt]=mm(gc),gm=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:s="hover",dir:o,scrollHideDelay:i=600,...a}=e,[l,c]=p.useState(null),[u,d]=p.useState(null),[f,m]=p.useState(null),[h,x]=p.useState(null),[g,b]=p.useState(null),[v,y]=p.useState(0),[_,j]=p.useState(0),[S,E]=p.useState(!1),[T,R]=p.useState(!1),A=$e(t,c),z=ui(o);return r.jsx(C3,{scope:n,type:s,dir:z,scrollHideDelay:i,scrollArea:l,viewport:u,onViewportChange:d,content:f,onContentChange:m,scrollbarX:h,onScrollbarXChange:x,scrollbarXEnabled:S,onScrollbarXEnabledChange:E,scrollbarY:g,onScrollbarYChange:b,scrollbarYEnabled:T,onScrollbarYEnabledChange:R,onCornerWidthChange:y,onCornerHeightChange:j,children:r.jsx(Ie.div,{dir:z,...a,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":_+"px",...e.style}})})});gm.displayName=gc;var xm="ScrollAreaViewport",bm=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:s,nonce:o,...i}=e,a=zt(xm,n),l=p.useRef(null),c=$e(t,l,a.onViewportChange);return r.jsxs(r.Fragment,{children:[r.jsx(N3,{nonce:o}),r.jsx(Ie.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,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})})]})});bm.displayName=xm;var N3=p.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),Xt="ScrollAreaScrollbar",vm=p.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=zt(Xt,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:a}=o,l=e.orientation==="horizontal";return p.useEffect(()=>(l?i(!0):a(!0),()=>{l?i(!1):a(!1)}),[l,i,a]),o.type==="hover"?r.jsx(T3,{...s,ref:t,forceMount:n}):o.type==="scroll"?r.jsx(E3,{...s,ref:t,forceMount:n}):o.type==="auto"?r.jsx(ym,{...s,ref:t,forceMount:n}):o.type==="always"?r.jsx(xc,{...s,ref:t,"data-state":"visible"}):null});vm.displayName=Xt;var T3=p.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=zt(Xt,e.__scopeScrollArea),[i,a]=p.useState(!1);return p.useEffect(()=>{const l=o.scrollArea;let c=0;if(l){const u=()=>{window.clearTimeout(c),a(!0)},d=()=>{c=window.setTimeout(()=>a(!1),o.scrollHideDelay)};return l.addEventListener("pointerenter",u),l.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),l.removeEventListener("pointerenter",u),l.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),r.jsx(St,{present:n||i,children:r.jsx(ym,{"data-state":i?"visible":"hidden",...s,ref:t})})}),E3=p.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=zt(Xt,e.__scopeScrollArea),i=e.orientation==="horizontal",a=wi(()=>c("SCROLL_END"),100),[l,c]=S3("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 p.useEffect(()=>{if(l==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[l,o.scrollHideDelay,c]),p.useEffect(()=>{const u=o.viewport,d=i?"scrollLeft":"scrollTop";if(u){let f=u[d];const m=()=>{const h=u[d];f!==h&&(c("SCROLL"),a()),f=h};return u.addEventListener("scroll",m),()=>u.removeEventListener("scroll",m)}},[o.viewport,i,c,a]),r.jsx(St,{present:n||l!=="hidden",children:r.jsx(xc,{"data-state":l==="hidden"?"hidden":"visible",...s,ref:t,onPointerEnter:Ne(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Ne(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),ym=p.forwardRef((e,t)=>{const n=zt(Xt,e.__scopeScrollArea),{forceMount:s,...o}=e,[i,a]=p.useState(!1),l=e.orientation==="horizontal",c=wi(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;a(l?u:d)}},10);return zs(n.viewport,c),zs(n.content,c),r.jsx(St,{present:s||i,children:r.jsx(xc,{"data-state":i?"visible":"hidden",...o,ref:t})})}),xc=p.forwardRef((e,t)=>{const{orientation:n="vertical",...s}=e,o=zt(Xt,e.__scopeScrollArea),i=p.useRef(null),a=p.useRef(0),[l,c]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Sm(l.viewport,l.content),d={...s,sizes:l,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:m=>i.current=m,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:m=>a.current=m};function f(m,h){return M3(m,a.current,l,h)}return n==="horizontal"?r.jsx(A3,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const m=o.viewport.scrollLeft,h=rd(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(R3,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const m=o.viewport.scrollTop,h=rd(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}),A3=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,i=zt(Xt,e.__scopeScrollArea),[a,l]=p.useState(),c=p.useRef(null),u=$e(t,c,i.onScrollbarXChange);return p.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),r.jsx(_m,{"data-orientation":"horizontal",...o,ref:u,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":yi(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(i.viewport){const m=i.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),Nm(m,f)&&d.preventDefault()}},onResize:()=>{c.current&&i.viewport&&a&&s({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Fo(a.paddingLeft),paddingEnd:Fo(a.paddingRight)}})}})}),R3=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,i=zt(Xt,e.__scopeScrollArea),[a,l]=p.useState(),c=p.useRef(null),u=$e(t,c,i.onScrollbarYChange);return p.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),r.jsx(_m,{"data-orientation":"vertical",...o,ref:u,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":yi(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(i.viewport){const m=i.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),Nm(m,f)&&d.preventDefault()}},onResize:()=>{c.current&&i.viewport&&a&&s({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Fo(a.paddingTop),paddingEnd:Fo(a.paddingBottom)}})}})}),[I3,wm]=mm(Xt),_m=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:s,hasThumb:o,onThumbChange:i,onThumbPointerUp:a,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...m}=e,h=zt(Xt,n),[x,g]=p.useState(null),b=$e(t,g),v=p.useRef(null),y=p.useRef(""),_=h.viewport,j=s.content-s.viewport,S=nt(d),E=nt(c),T=wi(f,10);function R(A){if(v.current){const z=A.clientX-v.current.left,H=A.clientY-v.current.top;u({x:z,y:H})}}return p.useEffect(()=>{const A=z=>{const H=z.target;x?.contains(H)&&S(z,j)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[_,x,j,S]),p.useEffect(E,[s,E]),zs(x,T),zs(h.content,T),r.jsx(I3,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:nt(i),onThumbPointerUp:nt(a),onThumbPositionChange:E,onThumbPointerDown:nt(l),children:r.jsx(Ie.div,{...m,ref:b,style:{position:"absolute",...m.style},onPointerDown:Ne(e.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),v.current=x.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),R(A))}),onPointerMove:Ne(e.onPointerMove,R),onPointerUp:Ne(e.onPointerUp,A=>{const z=A.target;z.hasPointerCapture(A.pointerId)&&z.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=y.current,h.viewport&&(h.viewport.style.scrollBehavior=""),v.current=null})})})}),$o="ScrollAreaThumb",km=p.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=wm($o,e.__scopeScrollArea);return r.jsx(St,{present:n||o.hasThumb,children:r.jsx(P3,{ref:t,...s})})}),P3=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:s,...o}=e,i=zt($o,n),a=wm($o,n),{onThumbPositionChange:l}=a,c=$e(t,a.onThumbChange),u=p.useRef(void 0),d=wi(()=>{u.current&&(u.current(),u.current=void 0)},100);return p.useEffect(()=>{const f=i.viewport;if(f){const m=()=>{if(d(),!u.current){const h=O3(f,l);u.current=h,l()}};return l(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[i.viewport,d,l]),r.jsx(Ie.div,{"data-state":a.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:Ne(e.onPointerDownCapture,f=>{const h=f.target.getBoundingClientRect(),x=f.clientX-h.left,g=f.clientY-h.top;a.onThumbPointerDown({x,y:g})}),onPointerUp:Ne(e.onPointerUp,a.onThumbPointerUp)})});km.displayName=$o;var bc="ScrollAreaCorner",jm=p.forwardRef((e,t)=>{const n=zt(bc,e.__scopeScrollArea),s=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&s?r.jsx(z3,{...e,ref:t}):null});jm.displayName=bc;var z3=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...s}=e,o=zt(bc,n),[i,a]=p.useState(0),[l,c]=p.useState(0),u=!!(i&&l),{onCornerWidthChange:d,onCornerHeightChange:f}=o;return zs(o.scrollbarX,()=>{const m=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(m),c(m)}),zs(o.scrollbarY,()=>{const m=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(m),a(m)}),p.useEffect(()=>()=>{d(0),f(0)},[d,f]),u?r.jsx(Ie.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 Fo(e){return e?parseInt(e,10):0}function Sm(e,t){const n=e/t;return isNaN(n)?0:n}function yi(e){const t=Sm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=(e.scrollbar.size-n)*t;return Math.max(s,18)}function M3(e,t,n,s="ltr"){const o=yi(n),i=o/2,a=t||i,l=o-a,c=n.scrollbar.paddingStart+a,u=n.scrollbar.size-n.scrollbar.paddingEnd-l,d=n.content-n.viewport,f=s==="ltr"?[0,d]:[d*-1,0];return Cm([c,u],f)(e)}function rd(e,t,n="ltr"){const s=yi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,a=t.content-t.viewport,l=i-s,c=n==="ltr"?[0,a]:[a*-1,0],u=Ga(e,c);return Cm([0,a],[0,l])(u)}function Cm(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 Nm(e,t){return e>0&&e<t}var O3=(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 wi(e,t){const n=nt(e),s=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(s.current),[]),p.useCallback(()=>{window.clearTimeout(s.current),s.current=window.setTimeout(n,t)},[n,t])}function zs(e,t){const n=nt(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 L3=gm,D3=bm,$3=jm,F3=[" ","Enter","ArrowUp","ArrowDown"],U3=[" ","Enter"],Yn="Select",[_i,ki,B3]=ih(Yn),[is]=ln(Yn,[B3,vi]),ji=vi(),[W3,En]=is(Yn),[H3,V3]=is(Yn),q3="SelectProvider";function Tm(e){const{__scopeSelect:t,children:n,open:s,defaultOpen:o,onOpenChange:i,value:a,defaultValue:l,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:m,required:h,form:x,internal_do_not_use_render:g}=e,b=ji(t),[v,y]=p.useState(null),[_,j]=p.useState(null),[S,E]=p.useState(!1),T=ui(u),[R,A]=Kn({prop:s,defaultProp:o??!1,onChange:i,caller:Yn}),[z,H]=Kn({prop:a,defaultProp:l,onChange:c,caller:Yn}),N=p.useRef(null),L=p.useRef(z);p.useEffect(()=>{const V=x?v?.ownerDocument.getElementById(x):v?.form;if(V instanceof HTMLFormElement){const ue=()=>H(L.current);return V.addEventListener("reset",ue),()=>V.removeEventListener("reset",ue)}},[x,v,H]);const w=v?!!x||!!v.closest("form"):!0,[$,X]=p.useState(new Set),B=Zt(),Q=Array.from($).map(V=>V.props.value).join(";"),D=p.useCallback(V=>{X(ue=>new Set(ue).add(V))},[]),Z=p.useCallback(V=>{X(ue=>{const te=new Set(ue);return te.delete(V),te})},[]),W={required:h,trigger:v,onTriggerChange:y,valueNode:_,onValueNodeChange:j,valueNodeHasChildren:S,onValueNodeHasChildrenChange:E,contentId:B,value:z,onValueChange:H,open:R,onOpenChange:A,dir:T,triggerPointerDownPosRef:N,disabled:m,name:d,autoComplete:f,form:x,nativeOptions:$,nativeSelectKey:Q,isFormControl:w};return r.jsx(rm,{...b,children:r.jsx(W3,{scope:t,...W,children:r.jsx(_i.Provider,{scope:t,children:r.jsx(H3,{scope:t,onNativeOptionAdd:D,onNativeOptionRemove:Z,children:cN(g)?g(W):n})})})})}Tm.displayName=q3;var Em=e=>{const{__scopeSelect:t,children:n,...s}=e;return r.jsx(Tm,{__scopeSelect:t,...s,internal_do_not_use_render:({isFormControl:o})=>r.jsxs(r.Fragment,{children:[n,o?r.jsx(t0,{__scopeSelect:t}):null]})})};Em.displayName=Yn;var Am="SelectTrigger",Rm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...o}=e,i=ji(n),a=En(Am,n),l=a.disabled||s,c=$e(t,a.onTriggerChange),u=ki(n),d=p.useRef("touch"),[f,m,h]=n0(g=>{const b=u().filter(_=>!_.disabled),v=b.find(_=>_.value===a.value),y=s0(b,g,v);y!==void 0&&a.onValueChange(y.value)}),x=g=>{l||(a.onOpenChange(!0),h()),g&&(a.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return r.jsx(om,{asChild:!0,...i,children:r.jsx(Ie.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":Si(a.value)?"":void 0,...o,ref:c,onClick:Ne(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&x(g)}),onPointerDown:Ne(o.onPointerDown,g=>{d.current=g.pointerType;const b=g.target;b.hasPointerCapture(g.pointerId)&&b.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(x(g),g.preventDefault())}),onKeyDown:Ne(o.onKeyDown,g=>{const b=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(b&&g.key===" ")&&F3.includes(g.key)&&(x(),g.preventDefault())})})})});Rm.displayName=Am;var Im="SelectValue",Pm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,children:i,placeholder:a="",...l}=e,c=En(Im,n),{onValueNodeHasChildrenChange:u}=c,d=i!==void 0,f=$e(t,c.onValueNodeChange);Je(()=>{u(d)},[u,d]);const m=Si(c.value);return r.jsx(Ie.span,{...l,asChild:m?!1:l.asChild,ref:f,style:{pointerEvents:"none"},children:r.jsx(p.Fragment,{children:m?a:i},m?"placeholder":"value")})});Pm.displayName=Im;var Z3="SelectIcon",zm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...o}=e;return r.jsx(Ie.span,{"aria-hidden":!0,...o,ref:t,children:s||"▼"})});zm.displayName=Z3;var Mm="SelectPortal",[G3,K3]=is(Mm,{forceMount:void 0}),Om=e=>{const{__scopeSelect:t,forceMount:n,...s}=e;return r.jsx(G3,{scope:e.__scopeSelect,forceMount:n,children:r.jsx(fi,{asChild:!0,...s})})};Om.displayName=Mm;var kn="SelectContent",Lm=p.forwardRef((e,t)=>{const n=K3(kn,e.__scopeSelect),{forceMount:s=n.forceMount,...o}=e,i=En(kn,e.__scopeSelect),[a,l]=p.useState();return Je(()=>{l(new DocumentFragment)},[]),r.jsx(St,{present:s||i.open,children:({present:c})=>c?r.jsx(Fm,{...o,ref:t}):r.jsx(Dm,{...o,fragment:a})})});Lm.displayName=kn;var Dm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,fragment:o}=e;return o?Ds.createPortal(r.jsx($m,{scope:n,children:r.jsx(_i.Slot,{scope:n,children:r.jsx("div",{ref:t,children:s})})}),o):null});Dm.displayName="SelectContentFragment";var Dt=10,[$m,An]=is(kn),J3="SelectContentImpl",Y3=Rs("SelectContent.RemoveScroll"),Fm=p.forwardRef((e,t)=>{const{__scopeSelect:n}=e,{position:s="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:a,side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:x,hideWhenDetached:g,avoidCollisions:b,...v}=e,y=En(kn,n),[_,j]=p.useState(null),[S,E]=p.useState(null),T=$e(t,j),[R,A]=p.useState(null),[z,H]=p.useState(null),N=ki(n),[L,w]=p.useState(!1),$=p.useRef(!1);p.useEffect(()=>{if(_)return _h(_)},[_]),ph();const X=p.useCallback(de=>{const[pe,...me]=N().map(Ce=>Ce.ref.current),[ve]=me.slice(-1),xe=document.activeElement;for(const Ce of de)if(Ce===xe||(Ce?.scrollIntoView({block:"nearest"}),Ce===pe&&S&&(S.scrollTop=0),Ce===ve&&S&&(S.scrollTop=S.scrollHeight),Ce?.focus(),document.activeElement!==xe))return},[N,S]),B=p.useCallback(()=>X([R,_]),[X,R,_]);p.useEffect(()=>{L&&B()},[L,B]);const{onOpenChange:Q,triggerPointerDownPosRef:D}=y;p.useEffect(()=>{if(_){let de={x:0,y:0};const pe=ve=>{de={x:Math.abs(Math.round(ve.pageX)-(D.current?.x??0)),y:Math.abs(Math.round(ve.pageY)-(D.current?.y??0))}},me=ve=>{de.x<=10&&de.y<=10?ve.preventDefault():ve.composedPath().includes(_)||Q(!1),document.removeEventListener("pointermove",pe),D.current=null};return D.current!==null&&(document.addEventListener("pointermove",pe),document.addEventListener("pointerup",me,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",pe),document.removeEventListener("pointerup",me,{capture:!0})}}},[_,Q,D]),p.useEffect(()=>{const de=()=>Q(!1);return window.addEventListener("blur",de),window.addEventListener("resize",de),()=>{window.removeEventListener("blur",de),window.removeEventListener("resize",de)}},[Q]);const[Z,W]=n0(de=>{const pe=N().filter(xe=>!xe.disabled),me=pe.find(xe=>xe.ref.current===document.activeElement),ve=s0(pe,de,me);ve&&setTimeout(()=>ve.ref.current?.focus())}),V=p.useCallback((de,pe,me)=>{const ve=!$.current&&!me;(y.value!==void 0&&y.value===pe||ve)&&(A(de),ve&&($.current=!0))},[y.value]),ue=p.useCallback(()=>_?.focus(),[_]),te=p.useCallback((de,pe,me)=>{const ve=!$.current&&!me;(y.value!==void 0&&y.value===pe||ve)&&H(de)},[y.value]),F=s==="popper"?Ka:Um,ge=F===Ka?{side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:x,hideWhenDetached:g,avoidCollisions:b}:{};return r.jsx($m,{scope:n,content:_,viewport:S,onViewportChange:E,itemRefCallback:V,selectedItem:R,onItemLeave:ue,itemTextRefCallback:te,focusSelectedItem:B,selectedItemText:z,position:s,isPositioned:L,searchRef:Z,children:r.jsx(rc,{as:Y3,allowPinchZoom:!0,children:r.jsx(sc,{asChild:!0,trapped:y.open,onMountAutoFocus:de=>{de.preventDefault()},onUnmountAutoFocus:Ne(o,de=>{y.trigger?.focus({preventScroll:!0}),de.preventDefault()}),children:r.jsx(di,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:de=>de.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:r.jsx(F,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:de=>de.preventDefault(),...v,...ge,onPlaced:()=>w(!0),ref:T,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:Ne(v.onKeyDown,de=>{const pe=de.ctrlKey||de.altKey||de.metaKey;if(de.key==="Tab"&&de.preventDefault(),!pe&&de.key.length===1&&W(de.key),["ArrowUp","ArrowDown","Home","End"].includes(de.key)){let ve=N().filter(xe=>!xe.disabled).map(xe=>xe.ref.current);if(["ArrowUp","End"].includes(de.key)&&(ve=ve.slice().reverse()),["ArrowUp","ArrowDown"].includes(de.key)){const xe=de.target,Ce=ve.indexOf(xe);ve=ve.slice(Ce+1)}setTimeout(()=>X(ve)),de.preventDefault()}})})})})})})});Fm.displayName=J3;var X3="SelectItemAlignedPosition",Um=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...o}=e,i=En(kn,n),a=An(kn,n),[l,c]=p.useState(null),[u,d]=p.useState(null),f=$e(t,d),m=ki(n),h=p.useRef(!1),x=p.useRef(!0),{viewport:g,selectedItem:b,selectedItemText:v,focusSelectedItem:y}=a,_=p.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&u&&g&&b&&v){const T=i.trigger.getBoundingClientRect(),R=u.getBoundingClientRect(),A=i.valueNode.getBoundingClientRect(),z=v.getBoundingClientRect();if(i.dir!=="rtl"){const xe=z.left-R.left,Ce=A.left-xe,Ae=T.left-Ce,k=T.width+Ae,ee=Math.max(k,R.width),K=window.innerWidth-Dt,M=Ga(Ce,[Dt,Math.max(Dt,K-ee)]);l.style.minWidth=k+"px",l.style.left=M+"px"}else{const xe=R.right-z.right,Ce=window.innerWidth-A.right-xe,Ae=window.innerWidth-T.right-Ce,k=T.width+Ae,ee=Math.max(k,R.width),K=window.innerWidth-Dt,M=Ga(Ce,[Dt,Math.max(Dt,K-ee)]);l.style.minWidth=k+"px",l.style.right=M+"px"}const H=m(),N=window.innerHeight-Dt*2,L=g.scrollHeight,w=window.getComputedStyle(u),$=parseInt(w.borderTopWidth,10),X=parseInt(w.paddingTop,10),B=parseInt(w.borderBottomWidth,10),Q=parseInt(w.paddingBottom,10),D=$+X+L+Q+B,Z=Math.min(b.offsetHeight*5,D),W=window.getComputedStyle(g),V=parseInt(W.paddingTop,10),ue=parseInt(W.paddingBottom,10),te=T.top+T.height/2-Dt,F=N-te,ge=b.offsetHeight/2,de=b.offsetTop+ge,pe=$+X+de,me=D-pe;if(pe<=te){const xe=H.length>0&&b===H[H.length-1].ref.current;l.style.bottom="0px";const Ce=u.clientHeight-g.offsetTop-g.offsetHeight,Ae=Math.max(F,ge+(xe?ue:0)+Ce+B),k=pe+Ae;l.style.height=k+"px"}else{const xe=H.length>0&&b===H[0].ref.current;l.style.top="0px";const Ae=Math.max(te,$+g.offsetTop+(xe?V:0)+ge)+me;l.style.height=Ae+"px",g.scrollTop=pe-te+g.offsetTop}l.style.margin=`${Dt}px 0`,l.style.minHeight=Z+"px",l.style.maxHeight=N+"px",s?.(),requestAnimationFrame(()=>h.current=!0)}},[m,i.trigger,i.valueNode,l,u,g,b,v,i.dir,s]);Je(()=>_(),[_]);const[j,S]=p.useState();Je(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const E=p.useCallback(T=>{T&&x.current===!0&&(_(),y?.(),x.current=!1)},[_,y]);return r.jsx(eN,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:h,onScrollButtonChange:E,children:r.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:j},children:r.jsx(Ie.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Um.displayName=X3;var Q3="SelectPopperPosition",Ka=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:o=Dt,...i}=e,a=ji(n);return r.jsx(im,{...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)"}})});Ka.displayName=Q3;var[eN,vc]=is(kn,{}),Ja="SelectViewport",Bm=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...o}=e,i=An(Ja,n),a=vc(Ja,n),l=$e(t,i.onViewportChange),c=p.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(_i.Slot,{scope:n,children:r.jsx(Ie.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ne(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=a;if(m?.current&&f){const h=Math.abs(c.current-d.scrollTop);if(h>0){const x=window.innerHeight-Dt*2,g=parseFloat(f.style.minHeight),b=parseFloat(f.style.height),v=Math.max(g,b);if(v<x){const y=v+h,_=Math.min(x,y),j=y-_;f.style.height=_+"px",f.style.bottom==="0px"&&(d.scrollTop=j>0?j:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});Bm.displayName=Ja;var Wm="SelectGroup",[tN,nN]=is(Wm),sN=p.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Zt();return r.jsx(tN,{scope:n,id:o,children:r.jsx(Ie.div,{role:"group","aria-labelledby":o,...s,ref:t})})});sN.displayName=Wm;var Hm="SelectLabel",rN=p.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=nN(Hm,n);return r.jsx(Ie.div,{id:o.id,...s,ref:t})});rN.displayName=Hm;var Uo="SelectItem",[oN,Vm]=is(Uo),qm=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:o=!1,textValue:i,...a}=e,l=En(Uo,n),c=An(Uo,n),u=l.value===s,[d,f]=p.useState(i??""),[m,h]=p.useState(!1),x=nt(_=>c.itemRefCallback?.(_,s,o)),g=$e(t,x),b=Zt(),v=p.useRef("touch"),y=()=>{o||(l.onValueChange(s),l.onOpenChange(!1))};return r.jsx(oN,{scope:n,value:s,disabled:o,textId:b,isSelected:u,onItemTextChange:p.useCallback(_=>{f(j=>j||(_?.textContent??"").trim())},[]),children:r.jsx(_i.ItemSlot,{scope:n,value:s,disabled:o,textValue:d,children:r.jsx(Ie.div,{role:"option","aria-labelledby":b,"data-highlighted":m?"":void 0,"aria-selected":u&&m,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:g,onFocus:Ne(a.onFocus,()=>h(!0)),onBlur:Ne(a.onBlur,()=>h(!1)),onClick:Ne(a.onClick,()=>{v.current!=="mouse"&&y()}),onPointerUp:Ne(a.onPointerUp,()=>{v.current==="mouse"&&y()}),onPointerDown:Ne(a.onPointerDown,_=>{v.current=_.pointerType}),onPointerMove:Ne(a.onPointerMove,_=>{v.current=_.pointerType,o?c.onItemLeave?.():v.current==="mouse"&&_.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ne(a.onPointerLeave,_=>{_.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Ne(a.onKeyDown,_=>{o||_.target!==_.currentTarget||c.searchRef?.current!==""&&_.key===" "||(U3.includes(_.key)&&y(),_.key===" "&&_.preventDefault())})})})})});qm.displayName=Uo;var tr="SelectItemText",Zm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,...i}=e,a=En(tr,n),l=An(tr,n),c=Vm(tr,n),u=V3(tr,n),[d,f]=p.useState(null),m=nt(y=>l.itemTextRefCallback?.(y,c.value,c.disabled)),h=$e(t,f,c.onItemTextChange,m),x=d?.textContent,g=p.useMemo(()=>r.jsx("option",{value:c.value,disabled:c.disabled,children:x},c.value),[c.disabled,c.value,x]),{onNativeOptionAdd:b,onNativeOptionRemove:v}=u;return Je(()=>(b(g),()=>v(g)),[b,v,g]),r.jsxs(r.Fragment,{children:[r.jsx(Ie.span,{id:c.textId,...i,ref:h}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren&&!Si(a.value)?Ds.createPortal(i.children,a.valueNode):null]})});Zm.displayName=tr;var Gm="SelectItemIndicator",Km=p.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return Vm(Gm,n).isSelected?r.jsx(Ie.span,{"aria-hidden":!0,...s,ref:t}):null});Km.displayName=Gm;var Ya="SelectScrollUpButton",Jm=p.forwardRef((e,t)=>{const n=An(Ya,e.__scopeSelect),s=vc(Ya,e.__scopeSelect),[o,i]=p.useState(!1),a=$e(t,s.onScrollButtonChange);return Je(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=c.scrollTop>0;i(u)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?r.jsx(Xm,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});Jm.displayName=Ya;var Xa="SelectScrollDownButton",Ym=p.forwardRef((e,t)=>{const n=An(Xa,e.__scopeSelect),s=vc(Xa,e.__scopeSelect),[o,i]=p.useState(!1),a=$e(t,s.onScrollButtonChange);return Je(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;i(d)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?r.jsx(Xm,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});Ym.displayName=Xa;var Xm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...o}=e,i=An("SelectScrollButton",n),a=p.useRef(null),l=ki(n),c=p.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return p.useEffect(()=>()=>c(),[c]),Je(()=>{l().find(d=>d.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),r.jsx(Ie.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Ne(o.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(s,50))}),onPointerMove:Ne(o.onPointerMove,()=>{i.onItemLeave?.(),a.current===null&&(a.current=window.setInterval(s,50))}),onPointerLeave:Ne(o.onPointerLeave,()=>{c()})})}),iN="SelectSeparator",aN=p.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(Ie.div,{"aria-hidden":!0,...s,ref:t})});aN.displayName=iN;var Qm="SelectArrow",lN=p.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=ji(n);return An(Qm,n).position==="popper"?r.jsx(am,{...o,...s,ref:t}):null});lN.displayName=Qm;var e0="SelectBubbleInput",t0=p.forwardRef(({__scopeSelect:e,...t},n)=>{const s=En(e0,e),{value:o,onValueChange:i,required:a,disabled:l,name:c,autoComplete:u,form:d}=s,{nativeOptions:f,nativeSelectKey:m}=s,h=p.useRef(null),x=$e(n,h),g=o??"",b=BS(g),v=Array.from(f).some(y=>(y.props.value??"")==="");return p.useEffect(()=>{const y=h.current;if(!y)return;const _=window.HTMLSelectElement.prototype,S=Object.getOwnPropertyDescriptor(_,"value").set;if(b!==g&&S){const E=new Event("change",{bubbles:!0});S.call(y,g),y.dispatchEvent(E)}},[b,g]),r.jsxs(Ie.select,{"aria-hidden":!0,required:a,tabIndex:-1,name:c,autoComplete:u,disabled:l,form:d,onChange:y=>i(y.target.value),...t,style:{...rh,...t.style},ref:x,defaultValue:g,children:[Si(o)&&!v?r.jsx("option",{value:""}):null,Array.from(f)]},m)});t0.displayName=e0;function cN(e){return typeof e=="function"}function Si(e){return e===""||e===void 0}function n0(e){const t=nt(e),n=p.useRef(""),s=p.useRef(0),o=p.useCallback(a=>{const l=n.current+a;t(l),(function c(u){n.current=u,window.clearTimeout(s.current),u!==""&&(s.current=window.setTimeout(()=>c(""),1e3))})(l)},[t]),i=p.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,o,i]}function s0(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let a=uN(e,Math.max(i,0));o.length===1&&(a=a.filter(u=>u!==n));const c=a.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function uN(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Ci="Tabs",[dN]=ln(Ci,[um]),r0=um(),[fN,yc]=dN(Ci),o0=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:i,orientation:a="horizontal",dir:l,activationMode:c="automatic",...u}=e,d=ui(l),[f,m]=Kn({prop:s,onChange:o,defaultProp:i??"",caller:Ci});return r.jsx(fN,{scope:n,baseId:Zt(),value:f,onValueChange:m,orientation:a,dir:d,activationMode:c,children:r.jsx(Ie.div,{dir:d,"data-orientation":a,...u,ref:t})})});o0.displayName=Ci;var i0="TabsList",a0=p.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,i=yc(i0,n),a=r0(n);return r.jsx(k3,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:s,children:r.jsx(Ie.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});a0.displayName=i0;var l0="TabsTrigger",c0=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...i}=e,a=yc(l0,n),l=r0(n),c=f0(a.baseId,s),u=p0(a.baseId,s),d=s===a.value;return r.jsx(j3,{asChild:!0,...l,focusable:!o,active:d,children:r.jsx(Ie.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":u,"data-state":d?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...i,ref:t,onMouseDown:Ne(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?a.onValueChange(s):f.preventDefault()}),onKeyDown:Ne(e.onKeyDown,f=>{o||f.target!==f.currentTarget||[" ","Enter"].includes(f.key)&&a.onValueChange(s)}),onFocus:Ne(e.onFocus,()=>{const f=a.activationMode!=="manual";!d&&!o&&f&&a.onValueChange(s)})})})});c0.displayName=l0;var u0="TabsContent",d0=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:i,...a}=e,l=yc(u0,n),c=f0(l.baseId,s),u=p0(l.baseId,s),d=s===l.value,f=p.useRef(d);return p.useEffect(()=>{const m=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(m)},[]),r.jsx(St,{present:o||d,children:({present:m})=>r.jsx(Ie.div,{"data-state":d?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:u,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:m&&i})})});d0.displayName=u0;function f0(e,t){return`${e}-trigger-${t}`}function p0(e,t){return`${e}-content-${t}`}var pN=o0,hN=a0,mN=c0,gN=d0,[Ni]=ln("Tooltip",[vi]),Ti=vi(),h0="TooltipProvider",xN=700,Qa="tooltip.open",[bN,wc]=Ni(h0),m0=e=>{const{__scopeTooltip:t,delayDuration:n=xN,skipDelayDuration:s=300,disableHoverableContent:o=!1,children:i}=e,a=p.useRef(!0),l=p.useRef(!1),c=p.useRef(0);return p.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),r.jsx(bN,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:p.useCallback(()=>{s<=0||(window.clearTimeout(c.current),a.current=!1)},[s]),onClose:p.useCallback(()=>{s<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,s))},[s]),isPointerInTransitRef:l,onPointerInTransitChange:p.useCallback(u=>{l.current=u},[]),disableHoverableContent:o,children:i})};m0.displayName=h0;var dr="Tooltip",[vN,Cr]=Ni(dr),g0=e=>{const{__scopeTooltip:t,children:n,open:s,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:l}=e,c=wc(dr,e.__scopeTooltip),u=Ti(t),[d,f]=p.useState(null),m=Zt(),h=p.useRef(0),x=a??c.disableHoverableContent,g=l??c.delayDuration,b=p.useRef(!1),[v,y]=Kn({prop:s,defaultProp:o??!1,onChange:T=>{T?(c.onOpen(),document.dispatchEvent(new CustomEvent(Qa))):c.onClose(),i?.(T)},caller:dr}),_=p.useMemo(()=>v?b.current?"delayed-open":"instant-open":"closed",[v]),j=p.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b.current=!1,y(!0)},[y]),S=p.useCallback(()=>{window.clearTimeout(h.current),h.current=0,y(!1)},[y]),E=p.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{b.current=!0,y(!0),h.current=0},g)},[g,y]);return p.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),r.jsx(rm,{...u,children:r.jsx(vN,{scope:t,contentId:m,open:v,stateAttribute:_,trigger:d,onTriggerChange:f,onTriggerEnter:p.useCallback(()=>{c.isOpenDelayedRef.current?E():j()},[c.isOpenDelayedRef,E,j]),onTriggerLeave:p.useCallback(()=>{x?S():(window.clearTimeout(h.current),h.current=0)},[S,x]),onOpen:j,onClose:S,disableHoverableContent:x,children:n})})};g0.displayName=dr;var el="TooltipTrigger",x0=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,o=Cr(el,n),i=wc(el,n),a=Ti(n),l=p.useRef(null),c=$e(t,l,o.onTriggerChange),u=p.useRef(!1),d=p.useRef(!1),f=p.useCallback(()=>u.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),r.jsx(om,{asChild:!0,...a,children:r.jsx(Ie.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...s,ref:c,onPointerMove:Ne(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:Ne(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:Ne(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Ne(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:Ne(e.onBlur,o.onClose),onClick:Ne(e.onClick,o.onClose)})})});x0.displayName=el;var _c="TooltipPortal",[yN,wN]=Ni(_c,{forceMount:void 0}),b0=e=>{const{__scopeTooltip:t,forceMount:n,children:s,container:o}=e,i=Cr(_c,t);return r.jsx(yN,{scope:t,forceMount:n,children:r.jsx(St,{present:n||i.open,children:r.jsx(fi,{asChild:!0,container:o,children:s})})})};b0.displayName=_c;var Ms="TooltipContent",v0=p.forwardRef((e,t)=>{const n=wN(Ms,e.__scopeTooltip),{forceMount:s=n.forceMount,side:o="top",...i}=e,a=Cr(Ms,e.__scopeTooltip);return r.jsx(St,{present:s||a.open,children:a.disableHoverableContent?r.jsx(y0,{side:o,...i,ref:t}):r.jsx(_N,{side:o,...i,ref:t})})}),_N=p.forwardRef((e,t)=>{const n=Cr(Ms,e.__scopeTooltip),s=wc(Ms,e.__scopeTooltip),o=p.useRef(null),i=$e(t,o),[a,l]=p.useState(null),{trigger:c,onClose:u}=n,d=o.current,{onPointerInTransitChange:f}=s,m=p.useCallback(()=>{l(null),f(!1)},[f]),h=p.useCallback((x,g)=>{const b=x.currentTarget,v={x:x.clientX,y:x.clientY},y=CN(v,b.getBoundingClientRect()),_=NN(v,y),j=TN(g.getBoundingClientRect()),S=AN([..._,...j]);l(S),f(!0)},[f]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(c&&d){const x=b=>h(b,d),g=b=>h(b,c);return c.addEventListener("pointerleave",x),d.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",x),d.removeEventListener("pointerleave",g)}}},[c,d,h,m]),p.useEffect(()=>{if(a){const x=g=>{const b=g.target,v={x:g.clientX,y:g.clientY},y=c?.contains(b)||d?.contains(b),_=!EN(v,a);y?m():_&&(m(),u())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[c,d,a,u,m]),r.jsx(y0,{...e,ref:i})}),[kN,jN]=Ni(dr,{isInside:!1}),SN=ij("TooltipContent"),y0=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:s,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...l}=e,c=Cr(Ms,n),u=Ti(n),{onClose:d}=c;return p.useEffect(()=>(document.addEventListener(Qa,d),()=>document.removeEventListener(Qa,d)),[d]),p.useEffect(()=>{if(c.trigger){const f=m=>{m.target instanceof Node&&m.target.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),r.jsx(di,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:r.jsxs(im,{"data-state":c.stateAttribute,...u,...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(SN,{children:s}),r.jsx(kN,{scope:n,isInside:!0,children:r.jsx(bj,{id:c.contentId,role:"tooltip",children:o||s})})]})})});v0.displayName=Ms;var w0="TooltipArrow",_0=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,o=Ti(n);return jN(w0,n).isInside?null:r.jsx(am,{...o,...s,ref:t})});_0.displayName=w0;function CN(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 NN(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 TN(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 EN(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],c=t[a],u=l.x,d=l.y,f=c.x,m=c.y;d>s!=m>s&&n<(f-u)*(s-d)/(m-d)+u&&(o=!o)}return o}function AN(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),RN(t)}function RN(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 IN=m0,PN=g0,zN=x0,MN=b0,ON=v0,LN=_0;function Rn({...e}){return r.jsx(jh,{"data-slot":"dialog",...e})}function Nr({...e}){return r.jsx(Ch,{"data-slot":"dialog-trigger",...e})}function DN({...e}){return r.jsx(Th,{"data-slot":"dialog-portal",...e})}function $N({className:e,...t}){return r.jsx(Eh,{"data-slot":"dialog-overlay",className:oe("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 In({className:e,children:t,...n}){return r.jsxs(DN,{children:[r.jsx($N,{}),r.jsxs(Ah,{"data-slot":"dialog-content",className:oe("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(Lh,{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(kr,{className:"size-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Pn({className:e,...t}){return r.jsx("div",{"data-slot":"dialog-header",className:oe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function zn({className:e,...t}){return r.jsx(Ph,{"data-slot":"dialog-title",className:oe("text-lg font-semibold leading-none tracking-tight",e),...t})}function kc({className:e,...t}){return r.jsx(Mh,{"data-slot":"dialog-description",className:oe("text-sm text-muted-foreground",e),...t})}const od=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,id=Up,jc=(e,t)=>n=>{var s;if(t?.variants==null)return id(e,n?.class,n?.className);const{variants:o,defaultVariants:i}=t,a=Object.keys(o).map(u=>{const d=n?.[u],f=i?.[u];if(d===null)return null;const m=od(d)||od(f);return o[u][m]}),l=n&&Object.entries(n).reduce((u,d)=>{let[f,m]=d;return m===void 0||(u[f]=m),u},{}),c=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((u,d)=>{let{class:f,className:m,...h}=d;return Object.entries(h).every(x=>{let[g,b]=x;return Array.isArray(b)?b.includes({...i,...l}[g]):{...i,...l}[g]===b})?[...u,f,m]:u},[]);return id(e,a,c,n?.class,n?.className)},FN=jc("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function je({className:e,variant:t,size:n,...s}){return r.jsx("button",{"data-slot":"button",className:oe(FN({variant:t,size:n,className:e})),...s})}function k0({open:e,onOpenChange:t,title:n,description:s,confirmLabel:o="Confirm",variant:i="default",onConfirm:a}){return r.jsx(Rn,{open:e,onOpenChange:t,children:r.jsxs(In,{children:[r.jsx(Pn,{children:r.jsx(zn,{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(je,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),r.jsx(je,{variant:i,size:"sm",onClick:()=>{a(),t(!1)},children:o})]})]})})}const UN="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",BN="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",WN="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",HN="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",VN="/assets/agent-inspector-58K1_MsC.ico",qN={"agent-inspector":"Inspector",codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code"};function ta(e){return e?.toLowerCase()??""}function Zs(e,t){for(const n of t)if(e.includes(n))return!0;return!1}function Sc(e){const t=[ta(e.userAgent),ta(e.conversationId),ta(e.clientProjectFolder)].join(" ");return Zs(t,["agent-inspector","agent inspector","provider-test"])?"agent-inspector":Zs(t,["mimocode","mimo-code","mimo code"])?"mimo-code":Zs(t,["opencode","open-code","open code"])?"opencode":Zs(t,["claude-code","claude code","claudecode","claude-cli","claude cli"])?"claude-code":Zs(t,["codex desktop","codex-cli","openai-codex","codex"])?"codex":"unknown"}function Ei(e){switch(e){case"agent-inspector":case"codex":case"opencode":case"mimo-code":case"claude-code":return qN[e];case"unknown":return null}}const ZN={"agent-inspector":VN,codex:BN,opencode:WN,"mimo-code":HN,"claude-code":UN},GN={"agent-inspector":"border-orange-200/25 bg-orange-300/[0.12]",codex:"border-cyan-200/20 bg-cyan-300/[0.08]",opencode:"border-sky-200/25 bg-sky-300/[0.12]","mimo-code":"border-orange-200/25 bg-orange-400/[0.12]","claude-code":"border-amber-100/20 bg-amber-300/[0.09]"},KN={"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 Ai({client:e,className:t}){if(e==="unknown")return null;const n=Ei(e);if(n===null)return null;const s=ZN[e];return r.jsx("span",{className:oe("inline-flex size-6 shrink-0 items-center justify-center rounded-md border p-0 shadow-sm",GN[e],t),"aria-label":n,title:n,children:r.jsx("img",{src:s,alt:"",className:oe("size-full object-contain",KN[e]),"aria-hidden":"true"})})}const JN="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",YN="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",XN="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",QN="/assets/minimax-BPMzvuL-.jpeg",e4="/assets/alibaba-TTwafVwX.svg",t4="/assets/qwen-CONDcHqt.png",n4="/assets/zhipuai-BPNAnxo-.svg",s4={"claude-":"anthropic","gpt-":"openai","o1-":"openai","o3-":"openai","deepseek-":"deepseek",MiniMax:"minimax",qwen:"qwen"};function r4(e){return e.replace(/[_\s]+/g,"-").split(/[/:@]/).some(n=>n.startsWith("glm-"))}function o4(e){if(e===null)return"unknown";const t=e.toLowerCase();if(r4(t))return"zhipuai";for(const[n,s]of Object.entries(s4))if(t.startsWith(n.toLowerCase()))return s;return"unknown"}const as={width:24,height:24,objectFit:"contain"},i4=ts.memo(({className:e})=>r.jsx("img",{src:JN,alt:"Anthropic",className:e,style:as})),a4=ts.memo(({className:e})=>r.jsx("img",{src:YN,alt:"OpenAI",className:e,style:{...as,background:"white",borderRadius:"4px"}})),l4=ts.memo(({className:e})=>r.jsx("img",{src:XN,alt:"DeepSeek",className:e,style:as})),c4=ts.memo(({className:e})=>r.jsx("img",{src:QN,alt:"MiniMax",className:e,style:as})),u4=ts.memo(({className:e})=>r.jsx("img",{src:e4,alt:"Alibaba",className:e,style:as})),d4=ts.memo(({className:e})=>r.jsx("img",{src:t4,alt:"Qwen",className:e,style:as})),f4=ts.memo(({className:e})=>r.jsx("img",{src:n4,alt:"ZhipuAI",className:e,style:as}));function p4({provider:e,className:t}){switch(e){case"anthropic":return r.jsx(i4,{className:t});case"openai":return r.jsx(a4,{className:t});case"deepseek":return r.jsx(l4,{className:t});case"minimax":return r.jsx(c4,{className:t});case"alibaba":return r.jsx(u4,{className:t});case"qwen":return r.jsx(d4,{className:t});case"zhipuai":return r.jsx(f4,{className:t});case"unknown":return null}}function jn({delayDuration:e=600,...t}){return r.jsx(IN,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function dt({...e}){return r.jsx(PN,{"data-slot":"tooltip",...e})}function ft({...e}){return r.jsx(zN,{"data-slot":"tooltip-trigger",...e})}function pt({className:e,sideOffset:t=0,children:n,...s}){return r.jsx(MN,{children:r.jsxs(ON,{"data-slot":"tooltip-content",sideOffset:t,className:oe("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(LN,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const h4=3;function m4({items:e,ariaLabel:t,className:n}){if(e.length===0)return r.jsx("span",{className:oe("flex h-8 w-12 shrink-0 items-center",n),"aria-hidden":"true"});const s=e.slice(0,h4),o=e.length-s.length;return r.jsx(jn,{delayDuration:150,children:r.jsxs("span",{className:oe("flex h-8 w-12 shrink-0 items-center",n),"aria-label":t,children:[s.map((i,a)=>r.jsxs(dt,{children:[r.jsx(ft,{asChild:!0,children:r.jsx("span",{className:oe("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(p4,{provider:i.provider,className:"size-4"})})}),r.jsx(pt,{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 g4="/v1/chat/completions",x4="/chat/completions",b4="/v1/responses",v4="/responses",y4="/v1/messages";class w4{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 Mn=new w4;function _4(e){return Mn.getApiFormatByPath(e)??"unknown"}Mn.registerPath(y4,"anthropic");Mn.registerPath(g4,"openai");Mn.registerPath(x4,"openai");Mn.registerPath(b4,"openai");Mn.registerPath(v4,"openai");function k4(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}catch{return{}}}function j4(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:k4(e.inputJson)}}}function j0(e,t,n,s){const o=new Map;let i="",a="",l=null,c=null,u=0,d=0;const f=1e3;let m=0,h=0;const x=[];for(const b of e.split(`
107
- `)){const v=b.trim();if(v.startsWith("data: "))try{const y=JSON.parse(v.slice(6)),_=gy.safeParse(y);if(!_.success)continue;const j=_.data;switch(m===0&&(h=Date.now()),s===!0&&x.length<f&&x.push({index:m,timestamp:Date.now()-h,type:j.type,data:tp(j)}),m++,j.type){case"message_start":i=j.message.id,a=j.message.model,u=j.message.usage.input_tokens,t.inputTokens=u,t.cacheCreationInputTokens=j.message.usage.cache_creation_input_tokens??null,t.cacheReadInputTokens=j.message.usage.cache_read_input_tokens??null,t.model===null&&(t.model=a);break;case"content_block_start":{const S=j.content_block;switch(S.type){case"text":o.set(j.index,{type:"text",text:S.text??""});break;case"thinking":o.set(j.index,{type:"thinking",thinking:S.thinking??"",signature:S.signature??""});break;case"think":o.set(j.index,{type:"think",thinking:S.thinking??"",signature:S.signature??""});break;case"tool_use":o.set(j.index,{type:"tool_use",id:S.id,name:S.name,inputJson:""});break}break}case"content_block_delta":{const S=o.get(j.index);if(S===void 0)break;const E=j.delta;E.type==="text_delta"&&S.type==="text"?S.text+=E.text:E.type==="thinking_delta"&&(S.type==="thinking"||S.type==="think")?S.thinking+=E.thinking:E.type==="signature_delta"&&(S.type==="thinking"||S.type==="think")?S.signature+=E.signature:E.type==="input_json_delta"&&S.type==="tool_use"&&(S.inputJson+=E.partial_json);break}case"message_delta":l=j.delta.stop_reason,c=j.delta.stop_sequence??null,d=j.usage.output_tokens,t.outputTokens=d,j.usage.cache_creation_input_tokens!==void 0&&(t.cacheCreationInputTokens=j.usage.cache_creation_input_tokens),j.usage.cache_read_input_tokens!==void 0&&(t.cacheReadInputTokens=j.usage.cache_read_input_tokens);break;case"error":t.error=j.error.message;break;case"content_block_stop":case"message_stop":case"ping":break}}catch{}}s===!0&&(t.streamingChunks={chunks:x,truncated:m>f});const g=[...o.entries()].sort(([b],[v])=>b-v).map(([,b])=>j4(b));return JSON.stringify({id:i,type:"message",model:a!==""?a:n??"",role:"assistant",content:g,stop_reason:l,stop_sequence:c,usage:{input_tokens:u,output_tokens:d}})}const S4={format:"anthropic",parseRequest(e,t){try{const n=JSON.parse(e),s=ip.safeParse(n);return s.success?{model:s.data.model,sessionId:s.data.metadata?.user_id??t?.get("x-session-affinity")??null}:null}catch{return null}},extractTokens(e){try{const t=JSON.parse(e),n=ap.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 j0(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}}};Mn.register(S4);class C4{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 Ri=new C4,N4="https://api.anthropic.com",T4={MiniMax:"https://api.minimaxi.com/anthropic"},E4={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(T4))if(t.startsWith(n.toLowerCase()))return!0;return!0},getUpstreamBase(e,t){return t?.baseUrl!==void 0?t.baseUrl:N4},extractStream(e,t,n,s){return j0(e,t,n,s)}};Ri.register(E4);const Cc=1e3;function Tr(e,t){if(!(e===null||typeof e!="object"||Array.isArray(e)))return Object.getOwnPropertyDescriptor(e,t)?.value}function it(e,t){const n=Tr(e,t);return typeof n=="string"?n:null}function S0(e,t){const n=Tr(e,t);return typeof n=="number"&&Number.isFinite(n)?n:null}function Bo(e,t){const n=Tr(e,t);return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:null}function A4(e,t){const n=Tr(e,t);return Array.isArray(n)?n:[]}function R4(e){const t=[];let n=null,s=[];const o=()=>{n===null&&s.length===0||(t.push({event:n,data:s.join(`
108
- `)}),n=null,s=[])};for(const i of e.split(`
109
- `)){const a=i.endsWith("\r")?i.slice(0,-1):i;if(a===""){o();continue}if(a.startsWith(":"))continue;const l=a.indexOf(":"),c=l===-1?a:a.slice(0,l),u=l===-1?"":a.slice(l+1),d=u.startsWith(" ")?u.slice(1):u;switch(c){case"event":n=d;break;case"data":n===null&&s.length>0&&(d.startsWith("{")||d==="[DONE]")&&o(),s.push(d);break}}return o(),t}function Nc(e){try{return JSON.parse(e)}catch{return null}}function C0(e,t){if(e.event!==null&&e.event!=="")return e.event;const n=Cy.safeParse(t);return n.success?n.data.type:""}function I4(e){if(e.data==="[DONE]")return!1;const t=Nc(e.data),n=C0(e,t);return n.startsWith("response.")||n==="error"}function N0(e,t,n,s,o){e.length>=Cc||e.push({index:t,timestamp:Date.now()-n,type:s,data:tp(o)})}function tl(e,t){const n=Bo(t,"error"),s=it(n,"message")??it(t,"message")??it(t,"error");s!==null&&s.length>0&&(e.error=s)}function P4(e,t,n,s){let o="",i="",a="",l="",c=null,u=0,d=0,f=!1,m=!1;const h=new Map;let x=0,g=0;const b=[];for(const y of e){if(y.data==="[DONE]")break;const _=Nc(y.data);if(_===null)continue;tl(t,_);const j=ky.safeParse(_);if(!j.success)continue;const S=j.data;if(x===0&&(g=Date.now()),s&&N0(b,x,g,"chat.completion.chunk",S),x++,m||(o=S.id,i=S.model,m=!0),!f&&S.usage!==void 0&&S.usage!==null){u=S.usage.prompt_tokens??0,d=S.usage.completion_tokens??0,t.inputTokens=u;const E=Bo(_,"usage"),T=Bo(E,"prompt_tokens_details"),R=S0(T,"cached_tokens");R!==null&&(t.cacheReadInputTokens=R),f=!0}for(const E of S.choices){const T=E.delta;T.content!==void 0&&T.content!==null&&(a+=T.content),T.reasoning_content!==void 0&&T.reasoning_content!==null&&(l+=T.reasoning_content),T.thinking!==void 0&&T.thinking!==null&&(l+=T.thinking);const R=T.think;if(R!=null&&(l+=R),E.finish_reason!==void 0&&E.finish_reason!==null&&(c=E.finish_reason),T.tool_calls!==void 0&&T.tool_calls!==null)for(const A of T.tool_calls){let z=h.get(A.index);z===void 0&&(z={index:A.index,type:"function",function:{name:"",arguments:""}},h.set(A.index,z)),A.id!==void 0&&(z.id=A.id),A.function?.name!==void 0&&(z.function.name+=A.function.name),A.function?.arguments!==void 0&&(z.function.arguments+=A.function.arguments)}}}s&&(t.streamingChunks={chunks:b,truncated:x>Cc}),f||(d=Math.ceil(a.length/4)),t.outputTokens=d;const v={role:"assistant",content:a};return l.length>0&&(v.reasoning_content=l),h.size>0&&(v.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:v,finish_reason:c}],usage:{prompt_tokens:u,completion_tokens:d,total_tokens:u+d}})}function z4(e){const t=Co.safeParse(Tr(e,"response"));if(t.success)return t.data;const n=Co.safeParse(e);return n.success?n.data:null}function T0(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=A4(n,"content");for(const o of s){const i=it(o,"type"),a=it(o,"text");(i==="output_text"||i==="text")&&a!==null&&a.length>0&&t.push(a)}}return t.join(`
110
- `)}function ad(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 na(e,t){const n=it(e,"item_id");if(n!==null&&n.length>0)return n;const s=S0(e,"output_index");return s!==null?String(s):`function-${String(t)}`}function nl(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 M4(e,t,n){if(it(n,"type")!=="function_call")return;const s=nl(e,t),o=it(n,"id"),i=it(n,"call_id"),a=it(n,"name"),l=it(n,"arguments"),c=it(n,"status");o!==null&&(s.id=o),i!==null&&(s.call_id=i),a!==null&&(s.name=a),l!==null&&(s.arguments=l),c!==null&&(s.status=c)}function O4(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 L4(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 D4(e){const t=e.completedResponse===null?"":T0(e.completedResponse),n=t.length>0?t:e.outputText,s=e.completedResponse?.output,o=s!==void 0&&s.length>0?s:O4(n,e.calls),i=e.completedResponse?.usage??L4(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 $4(e,t,n,s){let o=null,i="",a=n??"",l=null,c="",u=null,d=null,f=0,m=0;const h=[],x=new Map;for(const v of e){if(v.data==="[DONE]")break;const y=Nc(v.data);if(y===null)continue;const _=C0(v,y);if(f===0&&(m=Date.now()),s&&N0(h,f,m,_===""?"response.event":_,y),f++,tl(t,y),_==="error")continue;const j=z4(y);if(j!==null){o=j,i=j.id,a=j.model??a,l=j.status??l;const E=ad(j,t);u=E.inputTokens??u,d=E.outputTokens??d,tl(t,j)}const S=it(y,"delta");switch(_){case"response.output_text.delta":S!==null&&(c+=S);break;case"response.output_text.done":{const E=it(y,"text");c.length===0&&E!==null&&(c=E);break}case"response.function_call_arguments.delta":{if(S!==null){const E=nl(x,na(y,x.size));E.arguments+=S}break}case"response.function_call_arguments.done":{const E=it(y,"arguments");if(E!==null){const T=nl(x,na(y,x.size));T.arguments=E}break}case"response.output_item.added":case"response.output_item.done":{const E=Bo(y,"item");M4(x,na(y,x.size),E);break}case"response.failed":case"response.incomplete":l=_.slice(9);break;case"response.completed":l="completed";break}}s&&(t.streamingChunks={chunks:h,truncated:f>Cc});const g=D4({completedResponse:o,responseId:i,model:a,status:l,outputText:c,calls:x,inputTokens:u,outputTokens:d}),b=Co.safeParse(g);if(b.success){if(ad(b.data,t).outputTokens===null){const y=T0(b.data),_=Math.ceil(y.length/4);t.outputTokens=_}return JSON.stringify(b.data)}if(t.outputTokens===null){const v=it(g,"output_text")??c,y=Math.ceil(v.length/4);t.outputTokens=y}return JSON.stringify(g)}function Ii(e,t,n,s=!0){const o=R4(e);return o.some(I4)?$4(o,t,n,s):P4(o,t,n,s)}const F4={sessionId:null,threadId:null,turnId:null,installationId:null,windowId:null};function sl(e,t){if(!(typeof e!="object"||e===null||Array.isArray(e)))return Object.getOwnPropertyDescriptor(e,t)?.value}function Wt(e,t){const n=sl(e,t);return typeof n=="string"&&n.length>0?n:null}function U4(e){if(typeof e!="string"||e.length===0)return null;try{return JSON.parse(e)}catch{return null}}function B4(e){const t=sl(e,"client_metadata");if(t===void 0)return F4;const n=U4(sl(t,"x-codex-turn-metadata"));return{sessionId:Wt(t,"session_id")??Wt(n,"session_id"),threadId:Wt(t,"thread_id")??Wt(n,"thread_id"),turnId:Wt(t,"turn_id")??Wt(n,"turn_id"),installationId:Wt(t,"x-codex-installation-id")??Wt(n,"installation_id"),windowId:Wt(t,"x-codex-window-id")??Wt(n,"window_id")}}function ld(e){return B4(e).sessionId}function W4(){return{inputTokens:null,outputTokens:null,cacheCreationInputTokens:null,cacheReadInputTokens:null}}function cd(e){return e===void 0?null:e.get("x-agent-inspector-session-id")??e.get("x-session-affinity")}const H4={format:"openai",parseRequest(e,t){try{const n=JSON.parse(e),s=up.safeParse(n);if(s.success)return{model:s.data.model,sessionId:ld(n)??cd(t)};const o=dp.safeParse(n);return o.success?{model:o.data.model,sessionId:ld(n)??cd(t)}:null}catch{return null}},extractTokens(e){const t=pp(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=hp(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 W4()},extractStream(e,t,n,s){return Ii(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}}};Mn.register(H4);const V4="https://api.openai.com/v1",q4={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:V4},extractStream(e,t,n,s){return Ii(e,t,n,s)}};Ri.register(q4);const Z4="https://open.bigmodel.cn/api/paas/v4",G4=["glm-","charglm-","cogview-","embedding-","rerank-"],K4={name:"zhipu",matches(e){const t=e.toLowerCase().replace(/\s+/g,"-");return G4.some(n=>t.startsWith(n))},getUpstreamBase(e,t){return t?.baseUrl??Z4},extractStream(e,t,n,s){return Ii(e,t,n,s)}};Ri.register(K4);const J4="https://dashscope.aliyuncs.com/compatible-mode/v1",Y4={name:"alibaba",matches(e){return!!e.toLowerCase().replace(/\s+/g,"-").startsWith("qwen")},getUpstreamBase(e,t){return J4},extractStream(e,t,n){return Ii(e,t,n)}};Ri.register(Y4);function E0(e,t){for(const n of Array.from(e))t(n)}const X4=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function Tc(e){if(e.length===0)return 0;let t=0,n=0;return E0(e,s=>{X4.test(s)?t+=1:n+=1}),Math.ceil(t*1)+Math.ceil(n/4)}function Ec(e){if(e.length===0)return 0;let t=0;return E0(e,()=>{t+=1}),t}function Ac(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ke(e,t){return e===null||typeof e!="object"||Array.isArray(e)?void 0:Object.getOwnPropertyDescriptor(e,t)?.value}const Q4=["file","shell","browser","web","mcp","code","other"];function rl(e){const t=e.replace(/\s+/g," ").trim();return t.length<=120?t:`${t.slice(0,119)}...`}function A0(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?rl(t.slice(0,n+1)):rl(t)}function eT(e,t){return`${e} ${t??""}`.toLowerCase()}function fs(e,t){return t.some(n=>e.includes(n))}function R0(e,t){const n=eT(e,t);return e.startsWith("mcp__")||e.startsWith("inspector_")||fs(n,[" mcp","model context protocol"])?"mcp":fs(n,["bash","shell","terminal","command","powershell","exec","process"])?"shell":fs(n,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":fs(n,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":fs(n,["web","search","http","url","fetch"])?"web":fs(n,["code","typescript","javascript","python","repl"])?"code":"other"}function I0(e){const t=ke(e,"properties");return t===null||typeof t!="object"||Array.isArray(t)?[]:Object.keys(t).sort((n,s)=>n.localeCompare(s))}function P0(e){const t=ke(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 tT(e){const t=ke(e,"name");if(typeof t!="string"||t.length===0)return null;const n=ke(e,"description"),s=ke(e,"input_schema")??null,o=typeof n=="string"?n:null;return{name:t,description:o,descriptionPreview:A0(o),category:R0(t,o),parameterCount:I0(s).length,requiredParameters:P0(s),schema:s}}function nT(e){const t=ke(e,"function"),n=ke(e,"type");if(t===void 0&&typeof n!="string")return null;const s=ke(t,"name")??ke(e,"name")??(typeof n=="string"?n:void 0);if(typeof s!="string"||s.length===0)return null;const o=ke(t,"description")??ke(e,"description"),i=ke(t,"parameters")??ke(e,"parameters")??null,a=typeof o=="string"?o:null;return{name:s,description:a,descriptionPreview:A0(a),category:R0(s,a),parameterCount:I0(i).length,requiredParameters:P0(i),schema:i}}function sT(e){const t=nT(e);return t!==null?t:tT(e)}function rT(e){if(e==null)return null;if(typeof e=="string")return e;const t=ke(e,"type"),n=ke(e,"name"),s=ke(ke(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:rl(o)}function oT(e){const t=new Map;for(const n of e)t.set(n.category,(t.get(n.category)??0)+1);return Q4.flatMap(n=>{const s=t.get(n)??0;return s>0?[{category:n,count:s}]:[]})}function Rc(e){const t=ke(e,"tools");if(!Array.isArray(t)||t.length===0)return null;const n=[];for(const s of t){const o=sT(s);o!==null&&n.push(o)}return n.length===0?null:{tools:n,toolChoiceLabel:rT(ke(e,"tool_choice")),categories:oT(n)}}function Gn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const js={parsed:null,toolNames:null};function iT(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(`
111
- `)}function aT(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(`
112
- `)}function lT(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(`
113
- `)}function sa(e,t,n,s){return{role:e,label:t,text:n,size:Tc(n),characters:Ec(n),path:s}}const cT={format:"anthropic",analyzeRequest(e){if(e===null)return Gn(e);try{const t=JSON.parse(e),n=Rc(t)?.tools.length??null,s=ip.safeParse(t);return s.success?{parsed:s.data,comparisonValue:s.data,messageCount:s.data.messages.length,toolCount:n}:Gn(e)}catch{return Gn(e)}},analyzeResponse(e){if(e===null)return js;try{let t=JSON.parse(e);typeof t=="string"&&(t=JSON.parse(t));const n=ap.safeParse(t);if(!n.success)return js;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 js}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,n=[];if(t.system!==void 0){const s=aT(t.system);s.length>0&&n.push(sa("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=iT(i.content);n.push(sa(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.tools)&&t.tools.length>0){const s=lT(t.tools);n.push(sa("tools","tools",s,"/tools"))}return n.length>0?n:null}};function ol(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(`
114
- `)}function uT(e){const t=[],n=ol(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:"",c=typeof a.arguments=="string"?a.arguments:"";t.push(`${l} ${c}`.trim())}return t.join(`
115
- `)}function dT(e){if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const s=ke(n,"function"),o=ke(s,"name")??ke(n,"name"),i=ke(s,"description")??ke(n,"description"),a=ke(s,"parameters")??ke(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(`
116
- `)}function fT(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function pT(e){if(typeof e=="string")return e;const t=ke(e,"text");if(typeof t=="string")return t;const n=ol(ke(e,"content"));if(n.length>0)return n;const s=ol(ke(e,"output"));if(s.length>0)return s;const o=ke(e,"arguments");return typeof o=="string"?o:""}function hT(e){const t=ke(e,"role");if(t==="system"||t==="user"||t==="assistant"||t==="tool")return t;const n=ke(e,"type");return n==="function_call_output"?"tool":"user"}function mT(e){const t=ke(e,"output");if(!Array.isArray(t))return[];const n=[];for(const s of t){if(ke(s,"type")!=="function_call")continue;const o=ke(s,"name");typeof o=="string"&&o.length>0&&n.push(o)}return n}function Gs(e,t,n,s){return{role:e,label:t,text:n,size:Tc(n),characters:Ec(n),path:s}}const gT={format:"openai",analyzeRequest(e){if(e===null)return Gn(e);try{const t=JSON.parse(e),n=Rc(t)?.tools.length??null,s=up.safeParse(t);if(!s.success){const o=dp.safeParse(t);return o.success?{parsed:o.data,comparisonValue:o.data,messageCount:fT(o.data.input),toolCount:n}:Gn(e)}return{parsed:s.data,comparisonValue:s.data,messageCount:s.data.messages.length,toolCount:n}}catch{return Gn(e)}},analyzeResponse(e){if(e===null)return js;const t=pp(e);if(t===null){const s=hp(e);if(s===null)return js;const o=mT(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(Gs("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=uT(i);n.push(Gs(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.messages)||(typeof t.input=="string"&&t.input.length>0?n.push(Gs("user","input",t.input,"/input")):Array.isArray(t.input)&&t.input.forEach((s,o)=>{const i=hT(s),a=pT(s);n.push(Gs(i,`[${o}] ${i}`,a,`/input/${o}`))})),Array.isArray(t.tools)&&t.tools.length>0){const s=dT(t.tools);n.push(Gs("tools","tools",s,"/tools"))}return n.length>0?n:null}},xT={format:"unknown",analyzeRequest(e){return Gn(e)},analyzeResponse(){return js},anatomySegments(){return null}},bT={anthropic:cT,openai:gT,unknown:xT};function z0(e){return bT[e]}function fr(e){const t=_4(e.path);return t==="unknown"?e.apiFormat:t}const ud="bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground";function ra({icon:e,children:t,title:n,className:s}){return r.jsxs("span",{className:oe("bg-white/[0.045] inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md 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 vT(){return r.jsxs("span",{className:"inline-flex h-6 shrink-0 items-center gap-1.5 rounded-md bg-amber-300/[0.10] px-1.5 font-mono text-[10px] uppercase tracking-[0.14em] text-amber-100/90 ring-1 ring-amber-200/10",title:"This session has a turn that has not finished yet",children:[r.jsx(Ye,{className:"size-3 animate-spin"}),"Turn open"]})}function yT({conversationId:e,startTime:t,endTime:n,totalCalls:s,totalInputTokens:o,totalOutputTokens:i,expanded:a,onToggle:l,providers:c,isLoading:u=!1,userAgent:d,clientPid:f,clientProjectFolder:m,showClientIdentity:h=!0,showProcessMetadata:x=!0,timeDisplayFormat:g,onClear:b}){const[v,y]=p.useState(!1),_=$=>{$.stopPropagation(),b!==void 0&&y(!0)},j=p.useCallback($=>{$.stopPropagation(),window.open(kf(e),"_blank","noopener,noreferrer")},[e]),S=c?.map(({provider:$,models:X})=>({provider:$,tooltip:X.length===1?X[0]??$:X.join(", ")}))??[],E=Sc({userAgent:d,conversationId:e,clientProjectFolder:m}),T=Ei(E),R=d!=null&&d!=="",A=T??d??null,z=T!==null&&R?`${T} - ${d}`:null,H=e.startsWith("PID:")||e.includes("|"),N=e.length>24?e.slice(0,12)+"..."+e.slice(-12):e,L=li(t,n,g),w=`${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:oe("bg-card/80 shadow-sm relative flex cursor-pointer items-start gap-3 overflow-hidden rounded-[8px] px-3 py-2.5 transition-colors","hover:bg-card","select-none","sticky top-0 z-10 mb-2","focus-visible:ring-1 focus-visible:ring-cyan-300/35 focus-visible:outline-none"),onClick:l,onKeyDown:$=>{$.target===$.currentTarget&&($.key==="Enter"||$.key===" ")&&($.preventDefault(),l())},children:[r.jsx(m4,{items:S,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:[H&&x?f!=null?r.jsxs("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-violet-200",title:`PID ${f}`,children:["PID ",f]}):r.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-violet-200",title:e,children:e}):r.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-violet-200",title:e,children:H?"sessionless":N}),!H&&x&&f!==null&&f!==void 0&&r.jsxs("span",{className:"bg-white/[0.045] shrink-0 rounded px-1.5 py-0.5 font-mono text-xs tabular-nums text-muted-foreground",title:`Client process ID ${f}`,children:["PID ",f]}),H&&x&&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:"bg-white/[0.045] inline-flex min-h-6 shrink-0 flex-wrap items-center gap-1 rounded-md px-1.5 py-0.5 text-xs text-muted-foreground",title:z??A,children:[r.jsx(Ai,{client:E,className:"size-4 shrink-0"}),r.jsx("span",{className:"font-mono leading-snug tabular-nums",children:A})]}),u&&r.jsx(vT,{})]}),r.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[r.jsx(ra,{icon:r.jsx(tn,{className:"size-3 shrink-0"}),title:L,children:L}),r.jsx(ra,{icon:r.jsx(ai,{className:"size-3 shrink-0"}),children:w}),r.jsxs(ra,{icon:r.jsx(cr,{className:"size-3 shrink-0"}),className:"max-w-full",children:[r.jsx("span",{className:"text-blue-400",children:Fe(o)})," / ",r.jsx("span",{className:"text-amber-400",children:Fe(i)})]})]})]}),r.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[r.jsx("button",{type:"button",onClick:j,onKeyDown:$=>{($.key==="Enter"||$.key===" ")&&j($)},"aria-label":`Open session ${e} in a new tab`,title:"Open this session in a new tab",className:ud,children:r.jsx(Zl,{className:"size-3.5"})}),b!==void 0&&r.jsx("button",{type:"button",onClick:_,"aria-label":`Clear group (${s} request${s!==1?"s":""})`,title:"Clear this group from the current view",className:ud,children:r.jsx(yn,{className:"size-3.5"})}),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:a?r.jsx(rt,{className:"size-4 shrink-0"}):u?r.jsx(Ye,{className:"size-4 shrink-0 animate-spin"}):r.jsx(jt,{className:"size-4 shrink-0"})})]}),u&&r.jsx("span",{className:"pointer-events-none absolute inset-x-3 bottom-0 h-px overflow-hidden rounded-full bg-white/[0.06]","aria-hidden":"true",children:r.jsx("span",{className:"absolute inset-y-0 left-0 w-1/3 animate-pulse rounded-full bg-amber-200/65 shadow-[0_0_14px_rgba(252,211,77,0.32)]"})}),r.jsx(k0,{open:v,onOpenChange:y,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 wT(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 _T(e){const t=new Map;for(const s of e){const o=wT(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 kT(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 c=+i;if(Number.isInteger(c)&&c>=0&&c<e){let u=o[c];if(!u){const d=t[c*2];u=o[c]={index:c,key:n(c),start:d,size:t[c*2+1],end:d+t[c*2+1],lane:0}}return u}}if(i==="length")return e}return Reflect.get(o,i,a)}})}function ps(e,t,n){let s=n.initialDeps??[],o,i=!0;function a(){const l=e();return(l.length!==s.length||l.some((u,d)=>s[d]!==u))&&(s=l,o=t(...l),n?.onChange&&!(i&&n.skipInitialOnChange)&&n.onChange(o),i=!1),o}return a.updateDeps=l=>{s=l},a}function dd(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const jT=(e,t)=>Math.abs(e-t)<1.01,ST=(e,t,n)=>{let s;return function(...o){e.clearTimeout(s),s=e.setTimeout(()=>t.apply(this,o),n)}};let Ks;const oa=()=>{if(Ks!==void 0)return Ks;if(typeof navigator>"u")return Ks=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ks=!0;const e=navigator.maxTouchPoints;return Ks=navigator.platform==="MacIntel"&&e!==void 0&&e>0},fd=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},CT=e=>e,NT=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},TT=(e,t)=>{const n=e.scrollElement;if(!n)return;const s=e.targetWindow;if(!s)return;const o=a=>{const{width:l,height:c}=a;t({width:Math.round(l),height:Math.round(c)})};if(o(fd(n)),!s.ResizeObserver)return()=>{};const i=new s.ResizeObserver(a=>{const l=()=>{const c=a[0];if(c?.borderBoxSize){const u=c.borderBoxSize[0];if(u){o({width:u.inlineSize,height:u.blockSize});return}}o(fd(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},pr={passive:!0},ET=(e,t)=>{const n=e.scrollElement;if(!n)return;const s=()=>{t({width:n.innerWidth,height:n.innerHeight})};return s(),n.addEventListener("resize",s,pr),()=>{n.removeEventListener("resize",s)}},AT=typeof window>"u"?!0:"onscrollend"in window,M0=(e,t,n)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&AT;let a=0;const l=i?null:ST(o,()=>t(a,!1),e.options.isScrollingResetDelay),c=f=>()=>{a=n(s),l?.(),t(a,f)},u=c(!0),d=c(!1);return s.addEventListener("scroll",u,pr),i&&s.addEventListener("scrollend",d,pr),()=>{s.removeEventListener("scroll",u),i&&s.removeEventListener("scrollend",d)}},RT=(e,t)=>M0(e,t,n=>{const{horizontal:s,isRtl:o}=e.options;return s?n.scrollLeft*(o&&-1||1):n.scrollTop}),IT=(e,t)=>M0(e,t,n=>e.options.horizontal?n.scrollX:n.scrollY),PT=(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})},zT=O0,MT=O0;class OT{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,c=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);for(const[u,d]of this.elementsCache)if(d===l){this.elementsCache.delete(u);break}return}this.shouldMeasureDuringScroll(c)&&this.resizeItem(c,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:CT,rangeExtractor:NT,onChange:()=>{},measureElement:PT,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,c=null,u=!1;if(a!==void 0&&a.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=a.count,h=i.count,x=this.getMeasurements(),g=m>0?((s=x[0])==null?void 0:s.key)??a.getItemKey(0):null,b=m>0?((o=x[m-1])==null?void 0:o.key)??a.getItemKey(m-1):null;if(h!==m||m>0&&h>0&&(i.getItemKey(0)!==g||i.getItemKey(h-1)!==b)){u=!0;const _=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??x[0]:null;_&&(l=[_.key,this.getScrollOffset()-_.start]);const j=i.followOnAppend===!0?"auto":i.followOnAppend||null;j&&h>m&&this.isAtEnd(a.scrollEndThreshold)&&(m===0||i.getItemKey(h-1)!==b)&&(c=j)}}this.options=i,u&&(this.pendingMin=0,this.itemSizeCacheVersion++);let d=!1,f=0;if(l&&this.scrollOffset!==null){const[m,h]=l,x=this.getMeasurements(),{count:g,getItemKey:b}=this.options;let v=0;for(;v<g&&b(v)!==m;)v++;if(v<g){const y=x[v];if(y){const _=y.start+h;_!==this.scrollOffset&&(f=_-this.scrollOffset,this.scrollOffset=_,d=!0)}}}(d||c)&&(this.pendingScrollAnchor=[d?l[0]:null,d?l[1]:0,c,f])},this.notify=n=>{var s,o;(o=(s=this.options).onChange)==null||o.call(s,this,n)},this.maybeNotify=ps(()=>(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,!(!oa()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",a,pr),i.addEventListener("touchend",l,pr),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,c]=o;i!==null&&!l&&(oa()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?c!==0&&(this._iosDeferredAdjustment+=c):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 c=i.get(l.lane);if(c==null||l.end>c.end?i.set(l.lane,l):l.end<c.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=ps(()=>[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,c)=>(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:c}),{key:!1}),this.getMeasurements=ps(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:s,scrollMargin:o,getItemKey:i,enabled:a,lanes:l,laneAssignmentMode:c},u)=>{const d=this.itemSizeCache;if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const x of this.laneAssignments.keys())x>=n&&this.laneAssignments.delete(x);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(x=>{this.itemSizeCache.set(x.key,x.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 x=this.options.gap,g=n*2;let b=this._flatMeasurements;if(!b||b.length<g){const _=new Float64Array(g);b&&f>0&&_.set(b.subarray(0,f*2)),b=_,this._flatMeasurements=b}let v;if(f===0)v=s+o;else{const _=f-1;v=b[_*2]+b[_*2+1]+x}for(let _=f;_<n;_++){const j=i(_),S=d.get(j),E=typeof S=="number"?S:this.options.estimateSize(_);b[_*2]=v,b[_*2+1]=E,v+=E+x}const y=kT(n,b,i);return this.measurementsCache=y,y}const m=this.measurementsCache.slice(0,f),h=new Array(l).fill(void 0);for(let x=0;x<f;x++){const g=m[x];g&&(h[g.lane]=x)}for(let x=f;x<n;x++){const g=i(x),b=this.laneAssignments.get(x);let v,y;const _=c==="estimate"||d.has(g);if(b!==void 0&&this.options.lanes>1){v=b;const T=h[v],R=T!==void 0?m[T]:void 0;y=R?R.end+this.options.gap:s+o}else{const T=this.options.lanes===1?m[x-1]:this.getFurthestMeasurement(m,x);y=T?T.end+this.options.gap:s+o,v=T?T.lane:x%this.options.lanes,this.options.lanes>1&&_&&this.laneAssignments.set(x,v)}const j=d.get(g),S=typeof j=="number"?j:this.options.estimateSize(x),E=y+S;m[x]={index:x,start:y,size:S,end:E,key:g,lane:v},h[v]=x}return this.measurementsCache=m,m},{key:!1,debug:()=>this.options.debug}),this.calculateRange=ps(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,s,o,i)=>n.length===0||s===0?(this.range=null,null):(this.range=DT(n,s,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ps(()=>{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,c;const u=this._flatMeasurements;if(this.options.lanes===1&&u!==null)c=this.options.getItemKey(n),l=u[n*2],a=u[n*2+1];else{const m=this.measurementsCache[n];if(!m)return;c=m.key,l=m.start,a=m.size}const d=this.itemSizeCache.get(c)??a,f=s-d;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,x=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:c,start:l,size:a,end:l+a,lane:0},f,this):l<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(c)||this.scrollDirection!=="backward"));(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(c,s),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-h):x&&this.applyScrollAdjustment(f),this.notify(!1)}},this.getVirtualItems=ps(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,s)=>{const o=[];for(let i=0,a=n.length;i<a;i++){const l=n[i],c=s[l];o.push(c)}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=L0(0,s.length-1,i?l=>o[l*2]:l=>dd(s[l]).start,n);return dd(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,c=this.now();this.scrollState={index:n,align:l,behavior:o,startedAt:c,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&&(oa()&&(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&&jT(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,c=Math.abs(o-this.getScrollOffset()),u=this.scrollState.behavior==="smooth"&&c>l;this.scrollState.lastTargetOffset=o,u||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:u?"smooth":"auto"})}this.scheduleScrollReconcile()}}const L0=(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 LT(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 DT(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 u=LT(o,i,n);let d=u;const f=n+t;for(;d<i&&o[d*2]+o[d*2+1]<f;)d++;return{startIndex:u,endIndex:d}}let l=L0(0,i,u=>e[u].start,n),c=l;if(s===1)for(;c<i&&e[c].end<n+t;)c++;else if(s>1){const u=Array(s).fill(0);for(;c<i&&u.some(f=>f<n+t);){const f=e[c];u[f.lane]=f.end,c++}const d=Array(s).fill(n+t);for(;l>=0&&d.some(f=>f>=n);){const f=e[l];d[f.lane]=f.start,l--}l=Math.max(0,l-l%s),c=Math.min(i,c+(s-1-c%s))}return{startIndex:l,endIndex:c}}const ia=typeof document<"u"?p.useLayoutEffect:p.useEffect;function D0({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...s}){const o=p.useReducer(u=>u+1,0)[1],i=p.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=t,i.current.mode=n;const a=u=>{const d=i.current;if(!d.enabled||!d.container)return;const f=u.getTotalSize();if(f!==d.lastSize){d.lastSize=f;const v=u.options.horizontal?"width":"height";d.container.style[v]=`${f}px`}const m=!!u.options.horizontal,h=d.mode==="transform",x=m?"left":"top",g=u.options.scrollMargin,b=u.getVirtualItems();for(const v of b){const y=v.start-g,_=u.elementsCache.get(v.key);_&&d.lastPositions.get(_)!==y&&(d.lastPositions.set(_,y),h?_.style.transform=m?`translate3d(${y}px, 0, 0)`:`translate3d(0, ${y}px, 0)`:_.style[x]=`${y}px`)}},l={...s,onChange:(u,d)=>{var f;const m=i.current;let h=!0;if(m.enabled){a(u);const x=u.range,g=m.prevRange;h=!g||g.isScrolling!==u.isScrolling||g.startIndex!==x?.startIndex||g.endIndex!==x?.endIndex,h&&(m.prevRange=x?{startIndex:x.startIndex,endIndex:x.endIndex,isScrolling:u.isScrolling}:null)}h&&(e&&d?Ds.flushSync(o):o()),(f=s.onChange)==null||f.call(s,u,d)}},[c]=p.useState(()=>{const u=new OT(l);return Object.assign(u,{containerRef:d=>{const f=i.current;if(f.container=d,f.lastSize=null,d&&f.enabled){const m=u.getTotalSize();f.lastSize=m;const h=u.options.horizontal?"width":"height";d.style[h]=`${m}px`}}})});return c.setOptions(l),ia(()=>c._didMount(),[]),ia(()=>c._willUpdate()),ia(()=>{a(c)}),c}function $T(e){return D0({observeElementRect:TT,observeElementOffset:RT,scrollToFn:MT,...e})}function FT(e){return D0({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:ET,observeElementOffset:IT,scrollToFn:zT,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const an="agent-inspector:focus-log";function hr(e){window.dispatchEvent(new CustomEvent(an,{detail:e}))}function Pi(e){if(typeof CustomEvent>"u"||!(e instanceof CustomEvent))return null;const t=e.detail,n=ke(t,"logId");if(typeof n!="number"||!Number.isInteger(n)||n<0)return null;const s=ke(t,"tab");switch(s){case"anatomy":case"request":case"response":break;case void 0:break;default:return null}const o=ke(t,"source"),i=ke(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 Jr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function UT(e){switch(e){case"end_turn":case"tool_use":return e;case"max_tokens":return"length";default:return null}}function BT(e){switch(e){case"stop":case"length":return e;case"max_tokens":return"length";default:return null}}function WT(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function $0(e){if(e.responseText===null)return null;try{let t=JSON.parse(e.responseText);if(typeof t=="string"&&(t=JSON.parse(t)),!Jr(t))return null;if(typeof t.stop_reason=="string")return UT(t.stop_reason);if(Array.isArray(t.choices))for(const n of t.choices){if(!Jr(n)||typeof n.finish_reason!="string")continue;const s=BT(n.finish_reason);if(s!==null)return s}if(Array.isArray(t.output)){for(const n of t.output)if(Jr(n)&&n.type==="function_call")return"tool_use";if(t.status==="completed")return"stop"}if(t.status==="incomplete"&&Jr(t.incomplete_details)){const n=t.incomplete_details.reason;if(typeof n=="string"&&WT(n))return"length"}return null}catch{return null}}function Ic(e){return e==="end_turn"||e==="stop"||e==="length"}function Mt({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:oe("inline-block size-5",e),children:[r.jsx("path",{d:n}),s,o,i,a]})}const On=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"})]}),F0=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(Mt,{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:On,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 HT({className:e}){return r.jsx(Mt,{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:F0,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 VT({className:e}){return r.jsx(Mt,{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:On,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 qT({className:e}){return r.jsx(Mt,{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 ZT({className:e}){return r.jsx(Mt,{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:On,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 GT({className:e}){return r.jsx(Mt,{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:On,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 KT({className:e}){return r.jsx(Mt,{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:F0,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 JT({className:e}){return r.jsx(Mt,{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:On,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 YT({className:e}){return r.jsx(Mt,{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:On,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 XT({className:e}){return r.jsx(Mt,{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:On,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 QT({className:e}){return r.jsx(Mt,{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:On,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 eE({className:e}){return r.jsx(Mt,{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 mr=[U0,HT,VT,qT,ZT,GT,KT,JT,YT,XT,QT,eE];function Pc(e){return mr[Math.abs(e)%mr.length]??U0}function tE(e){const t=mr.length-2;return t<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%t+t)%t}function nE(e){return Pc(tE(e))}const sE="x-anthropic-billing-header:";function rE(e){return e.trimStart().toLowerCase().startsWith(sE)}function oE(e){return Ac(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function iE(e){if(!Ac(e))return!1;const t=ke(e,"type"),n=ke(e,"text");return typeof t!="string"||t!=="text"||typeof n!="string"?!1:rE(n)}function aE(e){let t;try{t=JSON.parse(e)}catch{return{body:e,removed:0}}if(!oE(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(iE(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 lE=400,pd=2e3;function cE(e){return Array.isArray(e)}function uE(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(cE(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 dE(e){const t=uE(e,pd+1);return t<=lE?{depth:Number.POSITIVE_INFINITY}:t<=pd?{depth:3}:{depth:2}}function fE(e){try{const t=JSON.parse(e);return{kind:"json",data:Wo(t)}}catch{return{kind:"text"}}}function aa(e){const t=p.useMemo(()=>e===null?null:fE(e),[e]),n=t?.kind==="json"?t.data:null,s=p.useMemo(()=>n===null?null:dE(n),[n]),[o,i]=p.useState(!1),[a,l]=p.useState(0),[c,u]=p.useState(0),[d,f]=p.useTransition(),m=p.useCallback(()=>{const h=!o,x=h&&s!==null?s.depth:0;f(()=>{i(h),l(x),u(g=>g+1)})},[o,s]);return{parsedData:n,policy:s,isExpanded:o,toggle:m,isPending:d,bulkDepth:a,bulkRevision:c}}function Wo(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=>Wo(n));const t={};for(const n of Object.keys(e)){const s=Object.getOwnPropertyDescriptor(e,n);t[n]=Wo(s?.value)}return t}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function B0({className:e,orientation:t="horizontal",...n}){return r.jsx(pN,{"data-slot":"tabs","data-orientation":t,orientation:t,className:oe("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...n})}const pE=jc("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 W0({className:e,variant:t="default",...n}){return r.jsx(hN,{"data-slot":"tabs-list","data-variant":t,className:oe(pE({variant:t}),e),...n})}function Tt({className:e,...t}){return r.jsx(mN,{"data-slot":"tabs-trigger",className:oe("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark: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]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background dark:data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 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 Et({className:e,...t}){return r.jsx(gN,{"data-slot":"tabs-content",className:oe("flex-1 outline-none",e),...t})}function gn(e){const[t,n]=p.useState(!1),s=p.useRef(null);p.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]);const o=p.useCallback(i=>{i.stopPropagation(),e!==null&&At(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 hE=p.lazy(()=>ns(()=>import("./CompareDrawer-BnvOPwpe.js"),__vite__mapDeps([0,1])).then(e=>({default:e.CompareDrawer}))),mE=p.lazy(()=>ns(()=>import("./ReplayDialog-BJgoQWdW.js"),__vite__mapDeps([2,1,3])).then(e=>({default:e.ReplayDialog}))),gE=p.lazy(()=>ns(()=>import("./RequestAnatomy-CpBZEHnM.js"),__vite__mapDeps([4,1])).then(e=>({default:e.RequestAnatomy}))),xE=p.lazy(()=>ns(()=>import("./ResponseView-CWmyRb2M.js"),__vite__mapDeps([3,1])).then(e=>({default:e.ResponseView}))),bE=p.lazy(()=>ns(()=>import("./StreamingChunkSequence-BWhC8bwx.js"),__vite__mapDeps([5,1])).then(e=>({default:e.StreamingChunkSequence}))),il=p.lazy(()=>ns(()=>import("./json-viewer-Bqu_4hmm.js"),__vite__mapDeps([6,1])).then(e=>({default:e.JsonViewer}))),vE=p.lazy(()=>ns(()=>import("./json-viewer-Bqu_4hmm.js"),__vite__mapDeps([6,1])).then(e=>({default:e.JsonViewerFromString}))),yE=1200,wE=12;function _E(e){const{containerRef:t,setExpandToPath:n,ensureTabActive:s,highlightMs:o}=e,i=p.useRef(null);return p.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??yE)},u=`[data-anatomy-path="${(f=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(f):f.replace(/(["'\\[\](){}])/g,"\\$1"))(a.path)}"]`,d=f=>{const m=t.current;if(m!==null){const h=m.querySelector(u);if(h!==null){l(h);return}}f>0?window.requestAnimationFrame(()=>d(f-1)):n(null)};window.requestAnimationFrame(()=>d(wE))},[t,s,o,n])}const hd="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.";function ys(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 kE(e,t){const n=[];return e!=null&&n.push(`Request ${ys(e)}`),t!=null&&n.push(`Response ${ys(t)}`),n.length===0?null:n.join(" · ")}function jE(e){if(e instanceof ri)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===""?hd:t}}return{title:"Full bodies could not be loaded",detail:hd}}class H0{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)),c=this.removeEmpty(this.tokenize(a,s));return this.diffWithOptionsObj(l,c,s,o)}diffWithOptionsObj(t,n,s,o){var i;const a=y=>{if(y=this.postProcess(y,s),o){setTimeout(function(){o(y)},0);return}else return y},l=n.length,c=t.length;let u=1,d=l+c;s.maxEditLength!=null&&(d=Math.min(d,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 x=this.extractCommon(h[0],n,t,0,s);if(h[0].oldPos+1>=c&&x+1>=l)return a(this.buildValues(h[0].lastComponent,n,t));let g=-1/0,b=1/0;const v=()=>{for(let y=Math.max(g,-u);y<=Math.min(b,u);y+=2){let _;const j=h[y-1],S=h[y+1];j&&(h[y-1]=void 0);let E=!1;if(S){const R=S.oldPos-y;E=S&&0<=R&&R<l}const T=j&&j.oldPos+1<c;if(!E&&!T){h[y]=void 0;continue}if(!T||E&&j.oldPos<S.oldPos?_=this.addToPath(S,!0,!1,0,s):_=this.addToPath(j,!1,!0,1,s),x=this.extractCommon(_,n,t,y,s),_.oldPos+1>=c&&x+1>=l)return a(this.buildValues(_.lastComponent,n,t))||!0;h[y]=_,_.oldPos+1>=c&&(b=Math.min(b,y-1)),x+1>=l&&(g=Math.max(g,y+1))}u++};if(o)(function y(){setTimeout(function(){if(u>d||Date.now()>m)return o(void 0);v()||y()},0)})();else for(;u<=d&&Date.now()<=m;){const y=v();if(y)return y}}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 c=t.oldPos,u=c-o,d=0;for(;u+1<a&&c+1<l&&this.equals(s[c+1],n[u+1],i);)u++,c++,d++,i.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return d&&!i.oneChangePerToken&&(t.lastComponent={count:d,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=c,u}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,c=0,u=0;for(;l<a;l++){const d=o[l];if(d.removed)d.value=this.join(s.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let f=n.slice(c,c+d.count);f=f.map(function(m,h){const x=s[u+h];return x.length>m.length?x:m}),d.value=this.join(f)}else d.value=this.join(n.slice(c,c+d.count));c+=d.count,d.added||(u+=d.count)}}return o}}class SE extends H0{constructor(){super(...arguments),this.tokenize=q0}equals(t,n,s){return s.ignoreWhitespace?((!s.newlineIsToken||!t.includes(`
117
- `))&&(t=t.trim()),(!s.newlineIsToken||!n.includes(`
118
- `))&&(n=n.trim())):s.ignoreNewlineAtEof&&!s.newlineIsToken&&(t.endsWith(`
119
- `)&&(t=t.slice(0,-1)),n.endsWith(`
120
- `)&&(n=n.slice(0,-1))),super.equals(t,n,s)}}const CE=new SE;function V0(e,t,n){return CE.diff(e,t,n)}function q0(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
121
- `));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 NE extends H0{constructor(){super(...arguments),this.tokenize=q0}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(al(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 TE=new NE;function EE(e,t,n){return TE.diff(e,t,n)}function al(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]=al(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 c;for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&l.push(c);for(l.sort(),i=0;i<l.length;i+=1)c=l[i],a[c]=al(e[c],t,n,s,c);t.pop(),n.pop()}else a=e;return a}function md(e){return e===void 0?[]:Object.entries(e).map(t=>[t[0].toLowerCase(),t[1]]).sort(([t],[n])=>t.localeCompare(n))}function gd([e,t]){return`${e}: ${t}`}function ll(e){const t=[];let n=0,s=0;for(const o of e){const i=o.value.split(`
122
- `);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 AE(e,t){const n=md(e).map(gd).join(`
123
- `),s=md(t).map(gd).join(`
124
- `);if(n===s)return{lines:[],isEmpty:!0};const o=V0(n,s);return{lines:ll(o),isEmpty:!1}}function xd(e){try{const t=JSON.parse(e);return t===null||typeof t=="string"||typeof t=="object"?t:null}catch{return null}}function RE(e,t){const n=e??"",s=t??"";if(n===s)return{lines:[],isEmpty:!0};const o=xd(n),i=xd(s);if(o!==null&&i!==null){const l=EE(o,i)??[];if(l.length===1){const c=l[0];if(c!==void 0&&!c.added&&!c.removed)return{lines:[],isEmpty:!0}}return{lines:ll(l),isEmpty:!1}}const a=V0(n,s);return{lines:ll(a),isEmpty:!1}}const IE=22,la=1e4;function PE(e){return e==="added"?"+":e==="removed"?"-":" "}function zE(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 ME=function({result:t,emptyLabel:n}){const[s,o]=p.useState("unified"),i=p.useRef(null),a=$T({count:t.lines.length,getScrollElement:()=>i.current,estimateSize:()=>IE,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,c=l>la,u=c?t.lines.slice(0,la):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",c&&` (showing first ${la.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:oe("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(r5,{className:"size-3"}),"Unified"]}),r.jsxs("button",{type:"button",onClick:()=>o("split"),"aria-pressed":s==="split",className:oe("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(Ww,{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(OE,{virtualizer:a,lines:u}):r.jsx($E,{lines:u})})]})};function OE({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:oe("flex items-start gap-3 px-2",zE(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:oe("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:PE(s.kind)}),r.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.text})]},n.key)})})}function LE(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 c=o[l],u=i[l];c!==void 0&&u!==void 0?t.push({left:{text:c.text,lineNumber:c.oldLineNumber},right:{text:u.text,lineNumber:u.newLineNumber},kind:"changed"}):c!==void 0?t.push({left:{text:c.text,lineNumber:c.oldLineNumber},right:null,kind:"removed"}):u!==void 0&&t.push({left:null,right:{text:u.text,lineNumber:u.newLineNumber},kind:"added"})}}return t}function DE(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 $E({lines:e}){const t=LE(e);return r.jsx("div",{"data-testid":"diff-split",children:t.map((n,s)=>r.jsxs("div",{className:oe("grid grid-cols-2 font-mono text-xs",DE(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:oe("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:oe("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 Z0=p.memo(ME),FE=jc("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 ze({className:e,variant:t="default",asChild:n=!1,...s}){const o=n?oj:"span";return r.jsx(o,{"data-slot":"badge","data-variant":t,className:oe(FE({variant:t}),e),...s})}const UE=3;function BE({event:e}){const t=n=>{n.stopPropagation(),hr({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 WE({events:e}){if(e.length===0)return null;const t=e.slice(0,UE),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(_r,{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(BE,{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 HE={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"},VE={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"}},Js="border border-transparent bg-white/[0.045] hover:bg-white/[0.075] size-8 text-muted-foreground shadow-none hover:text-cyan-100",Lt="bg-white/[0.045] flex h-7 items-center gap-1 rounded-md px-2 text-xs";function Ys(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function qE(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function ZE(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 bd({trend:e}){if(e===null)return null;const t=e.direction==="up",n=t?rw:Xy,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,Fe(e.delta)]})]})}const GE=p.memo(function({log:e,displayNumber:t,messageCount:n=null,toolCount:s=null,toolEvents:o=[],expanded:i,onToggle:a,cacheTrend:l=null,activeTab:c,tabActions:u,onReplay:d,slowResponseThresholdSeconds:f=0,showClientMetadata:m=!0,timeDisplayFormat:h}){const x=Qk(e.responseStatus),g=e.elapsedMs!==null&&f>0&&e.elapsedMs>f*1e3,b=e.inputTokens!==null||e.outputTokens!==null,v=e.firstChunkMs??null,y=e.tokensPerSecond??null,_=v===null?null:Ys(v),j=y===null||y<=0?null:qE(y),S=e.warnings?.length??0,E=e.clientPid!==null&&e.clientPid!==void 0,T=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="";e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd;const R=VE[x],A=ZE(x,e.responseStatus),z=x!=="success"||e.responseStatus!==200,H=e.streaming&&_===null&&j===null;return r.jsx(jn,{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:oe("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:N=>{(N.key==="Enter"||N.key===" ")&&(N.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:oe("inline-flex h-8 shrink-0 items-center rounded-md px-2 font-mono",R.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(tn,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:Fa(e.timestamp,h)})]}),z&&r.jsxs(ze,{variant:"outline",className:oe("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)]",HE[x]),children:[x==="success"?r.jsx(qe,{className:"size-3","aria-label":"Success"}):x==="server_error"?r.jsx(D_,{className:"size-3","aria-label":"Server error"}):x==="client_error"?r.jsx(bn,{className:"size-3","aria-label":"Client error"}):r.jsx(Ye,{className:"size-3 animate-spin","aria-label":"Pending"}),A]}),S>0&&r.jsxs(dt,{children:[r.jsx(ft,{asChild:!0,children:r.jsxs(ze,{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(bn,{className:"size-3","aria-label":"Tool schema warnings"}),S]})}),r.jsx(pt,{children:S===1?"1 tool schema warning":`${S} tool schema warnings`})]}),e.elapsedMs!==null&&(g?r.jsxs(dt,{children:[r.jsx(ft,{asChild:!0,children:r.jsxs("span",{className:oe(Lt,"shrink-0 border-amber-300/25 text-amber-200"),children:[r.jsx(tn,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:Ys(e.elapsedMs)}),r.jsx(bn,{className:"size-3","aria-label":"Slow response"})]})}),r.jsxs(pt,{children:["Slow response: ",Ys(e.elapsedMs)," exceeds"," ",Ys(f*1e3)]})]}):r.jsxs("span",{className:oe(Lt,"shrink-0 text-muted-foreground"),children:[r.jsx(tn,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:Ys(e.elapsedMs)})]})),e.streaming&&_!==null&&r.jsxs("span",{className:oe(Lt,"shrink-0 text-cyan-300"),children:[r.jsx(yu,{className:"size-3"}),r.jsxs("span",{className:"font-mono tabular-nums",children:["first ",_]})]}),e.streaming&&j!==null&&r.jsxs("span",{className:oe(Lt,"shrink-0 text-cyan-300"),children:[r.jsx(Kl,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:j})]}),b&&r.jsxs("span",{className:oe(Lt,"min-w-0 sm:shrink-0"),children:[r.jsx(cr,{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:oe("whitespace-nowrap",e.inputTokens!==null?"text-blue-400":"text-muted-foreground"),children:["IN ",e.inputTokens!==null?Fe(e.inputTokens):"n/a"]}),r.jsx("span",{className:"text-muted-foreground",children:"/"}),r.jsxs("span",{className:oe("whitespace-nowrap",e.outputTokens!==null?"text-amber-400":"text-muted-foreground"),children:["OUT ",e.outputTokens!==null?Fe(e.outputTokens):"n/a"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&r.jsxs("span",{className:oe(Lt,"shrink-0"),children:[r.jsx(bd,{trend:l?.creation??null}),r.jsxs("span",{className:"font-mono tabular-nums text-cyan-300",children:["KV Cache +",Fe(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&r.jsxs("span",{className:oe(Lt,"shrink-0"),children:[r.jsx(bd,{trend:l?.read??null}),r.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",Fe(e.cacheReadInputTokens)]})]}),n!==null&&r.jsxs("span",{className:oe(Lt,"shrink-0 text-muted-foreground"),children:[r.jsx(ai,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:n})]}),s!==null&&r.jsxs("span",{className:oe(Lt,"shrink-0 text-muted-foreground"),children:[r.jsx(_r,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:s})]}),r.jsx(WE,{events:o}),e.origin!==null&&r.jsxs("span",{className:oe(Lt,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[r.jsx(Rp,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),m&&(E||T)&&r.jsxs("span",{className:oe(Lt,"hidden shrink-0 text-purple-300 xl:flex"),children:[r.jsx(i_,{className:"size-3"}),T?r.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):r.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]}),H&&r.jsx(yu,{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:N=>N.stopPropagation(),onKeyDown:N=>N.stopPropagation(),children:[u!==void 0&&c!==void 0&&(()=>{const N=u[c];return N===void 0?null:r.jsxs(r.Fragment,{children:[N.expansion!==null&&r.jsxs(dt,{children:[r.jsx(ft,{asChild:!0,children:r.jsx(je,{variant:"outline",size:"icon",className:Js,onClick:N.expansion.onToggle,disabled:N.expansion.isPending,"aria-pressed":N.expansion.isExpanded,"aria-label":N.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:N.expansion.isExpanded?r.jsx(Cw,{className:"size-3.5"}):r.jsx(yw,{className:"size-3.5"})})}),r.jsx(pt,{children:N.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),N.diffWithRaw!==void 0&&r.jsxs(dt,{children:[r.jsx(ft,{asChild:!0,children:r.jsx(je,{variant:"outline",size:"icon",className:oe(Js,N.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:N.diffWithRaw.onToggle,"aria-pressed":N.diffWithRaw.active,"aria-label":N.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:r.jsx(n_,{className:"size-3.5"})})}),r.jsx(pt,{children:N.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),N.diffWithPrevious!==void 0&&r.jsxs(dt,{children:[r.jsx(ft,{asChild:!0,children:r.jsx(je,{variant:"outline",size:"icon",className:Js,onClick:N.diffWithPrevious,"aria-label":"Diff with previous",children:r.jsx(Ip,{className:"size-3.5"})})}),r.jsx(pt,{children:"Compare this request with the immediately preceding one"})]}),N.copyText!==null&&r.jsxs(dt,{children:[r.jsx(ft,{asChild:!0,children:r.jsx(je,{variant:"outline",size:"icon",className:Js,onClick:N.onCopy,"aria-label":N.copyCopied?"Copied":N.copyLabel,children:N.copyCopied?r.jsx(qe,{className:"size-3.5 text-cyan-300"}):r.jsx(Pt,{className:"size-3.5"})})}),r.jsx(pt,{children:N.copyCopied?"Copied to clipboard":N.copyLabel})]})]})})(),d!==void 0&&r.jsxs(dt,{children:[r.jsx(ft,{asChild:!0,children:r.jsx(je,{variant:"outline",size:"icon",className:Js,onClick:d,"aria-label":"Replay request",children:r.jsx(t5,{className:"size-3.5"})})}),r.jsx(pt,{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(rt,{className:"size-4 shrink-0"}):r.jsx(jt,{className:"size-4 shrink-0"})})]})]})})});function KE({...e}){return r.jsx(Ij,{"data-slot":"collapsible",...e})}function Qz({...e}){return r.jsx(ch,{"data-slot":"collapsible-trigger",...e})}function JE({...e}){return r.jsx(uh,{"data-slot":"collapsible-content",...e})}function YE({className:e,children:t,...n}){return r.jsxs(L3,{"data-slot":"scroll-area",className:oe("relative overflow-hidden",e),...n,children:[r.jsx(D3,{"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(XE,{}),r.jsx($3,{})]})}function XE({className:e,orientation:t="vertical",...n}){return r.jsx(vm,{"data-slot":"scroll-area-scrollbar",orientation:t,className:oe("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(km,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const G0={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},QE={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 eA({category:e}){switch(e){case"file":return r.jsx(l_,{className:"size-3.5"});case"shell":return r.jsx(Fs,{className:"size-3.5"});case"browser":return r.jsx(z_,{className:"size-3.5"});case"web":return r.jsx(Rp,{className:"size-3.5"});case"mcp":return r.jsx(cw,{className:"size-3.5"});case"code":return r.jsx(Uw,{className:"size-3.5"});case"other":return r.jsx(Kw,{className:"size-3.5"})}}function tA({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(ze,{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 nA({tool:e,called:t}){const[n,s]=p.useState(!1),o=gn(e.name),i=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return r.jsx(KE,{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(eA,{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(ze,{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(rt,{className:"size-3.5 shrink-0 text-muted-foreground"}):r.jsx(jt,{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(qe,{className:"size-3.5 text-emerald-400"}):r.jsx(Pt,{className:"size-3.5"})})]}),r.jsx(JE,{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(tA,{names:e.requiredParameters}),e.schema!==null&&r.jsx(YE,{className:"bg-black/[0.16] max-h-64 rounded-[8px] p-2",children:r.jsx(p.Suspense,{fallback:r.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:r.jsx(il,{data:Wo(e.schema),defaultExpandDepth:0})})})]})})]})})}function sA(e,t){return t.length===0?!0:`${e.name} ${e.description??""} ${G0[e.category]}`.toLowerCase().trim().includes(t)}const rA=p.memo(function({summary:t,calledToolNames:n}){const[s,o]=p.useState(!1),[i,a]=p.useState(""),l=p.useMemo(()=>new Set(n),[n]),c=i.trim().toLowerCase(),u=p.useMemo(()=>t===null?[]:t.tools.filter(m=>sA(m,c)),[c,t]);if(t===null)return null;const d=t.tools.slice(0,6),f=t.tools.length-d.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(_r,{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(ze,{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(ze,{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(ze,{variant:"outline",className:oe("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",QE[m.category]),children:[m.count," ",G0[m.category]]},m.category))})]})]}),r.jsxs(je,{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(rt,{className:"size-3.5"}):r.jsx(jt,{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:[d.map(m=>r.jsx(ze,{variant:"outline",className:oe("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(Op,{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:u.length>0?u.map(m=>r.jsx(nA,{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 vd(e,t,n){return e==="anthropic"&&t==="full"&&n}function oA(e,t){return e==="full"&&t}function ca(e,t){return e==="full"&&t}function ua(e,t){return e==="full"&&t}function iA(e,t,n,s){return e==="anthropic"&&t==="full"&&n&&s}function hs(){return r.jsx("div",{className:"h-1","aria-hidden":"true"})}function aA(e,t){switch(e){case"anatomy":return t===null?"request":"anatomy";case"request":return"request";case"response":return"parsed"}}const lA=15e3,cA=15e3,uA=256*1024,Ho=1024*1024,Fn="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 Yr(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function Vo(e){return e??0}function K0(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function J0(e){return K0(e)?Vo(e.rawRequestBodyBytes)>Ho||Vo(e.responseTextBytes)>Ho:!1}function dA(e){return K0(e)&&!J0(e)}function fA(e){return e instanceof ri?"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 Xr({status:e,error:t,footprint:n,onRetry:s}){switch(e){case"idle":return null;case"loading":return r.jsx(gr,{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(Ye,{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(gr,{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(je,{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(vn,{className:"size-3"}),"Retry"]})]})})}}function yd(e,t){return e?t.text!==""?t.text:t.status==="success"?"":null:null}function Un({children:e,className:t}){return r.jsx("div",{className:oe("bg-black/[0.14] inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",t),children:e})}function bo({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 Qr({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 pA={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 gr({tone:e,title:t,children:n}){return r.jsxs("div",{className:oe("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",pA[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 eo({label:e,state:t,expectedBytes:n,onLoadMore:s}){const o=t.totalBytes??n,i=o===null?ys(t.offset):`${ys(t.offset)} / ${ys(o)}`,a=t.status!=="loading"&&t.hasMore,l=t.status==="failed"?"Retry":"Load more";return r.jsx(gr,{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 ${ys(o)}. Loading the first preview chunk.`:`Loaded ${i}.`,t.status==="failed"&&t.error!==null&&` ${t.error}`]}),a&&r.jsx(je,{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 wd({headers:e,emptyLabel:t}){const n=e===void 0?[]:Object.entries(e).sort(([s],[o])=>s.localeCompare(o));return n.length===0?r.jsx(bo,{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 hA({active:e,onClick:t}){return r.jsxs(dt,{children:[r.jsx(ft,{asChild:!0,children:r.jsxs(je,{variant:e?"default":"outline",size:"sm",className:oe("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(g_,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),r.jsx(pt,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const mA=p.memo(function({rawBody:e,displayedBody:t,emptyLabel:n}){const s=p.useMemo(()=>RE(e,t),[e,t]);return r.jsx(Z0,{result:s,emptyLabel:n})}),gA=p.memo(function({rawHeaders:e,headers:t,emptyLabel:n}){const s=p.useMemo(()=>AE(e,t),[e,t]);return r.jsx(Z0,{result:s,emptyLabel:n})}),xA=p.memo(function({log:e,displayNumber:t,viewMode:n="simple",strip:s,slowResponseThresholdSeconds:o,timeDisplayFormat:i,cacheTrend:a=null,onCompareWithPrevious:l,showClientMetadata:c=!0,toolEvents:u=[]}){const[d,f]=p.useState(!1),[m,h]=p.useState(!1),[x,g]=p.useState(!1),[b,v]=p.useState(!1),[y,_]=p.useState("request"),[j,S]=p.useState(null),[E,T]=p.useState(0),[R,A]=p.useState(null),[z,H]=p.useState(null),[N,L]=p.useState("idle"),[w,$]=p.useState(null),[X,B]=p.useState(0),[Q,D]=p.useState(()=>Yr(e.rawRequestBodyBytes??null)),[Z,W]=p.useState(()=>Yr(e.responseTextBytes??null)),V=p.useRef(null),ue=p.useRef(e.id),te=p.useRef(!1),F=z??e,ge=z===null&&J0(e),de=p.useMemo(()=>kE(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),pe=yd(ge,Q),me=yd(ge,Z),ve=F.rawRequestBody??pe,xe=F.responseText??me,Ce=F.rawRequestBody===null&&pe!==null,Ae=F.responseText===null&&me!==null,k=!Ce||Q.hasMore===!1&&Vo(Q.totalBytes)<=Ho,ee=!Ae||Z.hasMore===!1&&Vo(Z.totalBytes)<=Ho,K=fr(F),M=z0(K),P=p.useMemo(()=>M.analyzeRequest(F.rawRequestBody),[M,F.rawRequestBody]),U=p.useMemo(()=>M.analyzeResponse(F.responseText),[M,F.responseText]),se=p.useMemo(()=>!s||K!=="anthropic"||F.rawRequestBody===null?null:aE(F.rawRequestBody).body,[F.rawRequestBody,K,s])??ve,q=aa(k?se:null),ae=aa(y==="raw-request"&&k?ve:null),I=aa(y==="raw"&&ee?xe:null),O=p.useMemo(()=>F.headers&&Object.keys(F.headers).length>0?JSON.stringify(F.headers,null,2):null,[F.headers]),Y=p.useMemo(()=>F.rawHeaders&&Object.keys(F.rawHeaders).length>0?JSON.stringify(F.rawHeaders,null,2):null,[F.rawHeaders]),ie=gn(se),le=gn(ve),_e=gn(O),be=gn(Y),he=gn(xe),Oe=p.useMemo(()=>({request:{copyLabel:Ce?"Copy loaded request preview":"Copy request body",copyText:se,copyCopied:ie.copied,onCopy:ie.copy,expansion:k?{isExpanded:q.isExpanded,isPending:q.isPending,onToggle:q.toggle}:null,diffWithRaw:iA(K,n,s,F.rawRequestBody!==null)?{active:b,onToggle:()=>v(!b)}:void 0,diffWithPrevious:l===void 0?void 0:()=>{l(F)}},"raw-request":{copyLabel:Ce?"Copy loaded raw request preview":"Copy raw request",copyText:ve,copyCopied:le.copied,onCopy:le.copy,expansion:k?{isExpanded:ae.isExpanded,isPending:ae.isPending,onToggle:ae.toggle}:null},...ua(n,F.headers!==void 0&&Object.keys(F.headers).length>0)?{headers:{copyLabel:"Copy headers",copyText:O,copyCopied:_e.copied,onCopy:_e.copy,expansion:null}}:{},...ca(n,F.rawHeaders!==void 0&&Object.keys(F.rawHeaders).length>0)?{"raw-headers":{copyLabel:"Copy raw headers",copyText:Y,copyCopied:be.copied,onCopy:be.copy,expansion:null}}:{},raw:{copyLabel:Ae?"Copy loaded response preview":"Copy response",copyText:xe,copyCopied:he.copied,onCopy:he.copy,expansion:ee?{isExpanded:I.isExpanded,isPending:I.isPending,onToggle:I.toggle}:null}}),[se,Ce,k,ie,q,b,F,F.rawRequestBody,ve,le,ae,O,_e,Y,be,F.responseText,Ae,ee,xe,he,I,K,n,s,l]),Re=p.useMemo(()=>q.parsedData!==null?M.anatomySegments(q.parsedData):null,[M,q.parsedData]),xt=p.useMemo(()=>Rc(q.parsedData),[q.parsedData]),Ct=F.warnings??[],mt=p.useMemo(()=>{if(Re!==null)return new Set(Re.map(De=>De.path))},[Re]),Ln=_E({containerRef:V,setExpandToPath:A,ensureTabActive:()=>{y!=="request"&&_("request")}}),Nt=p.useCallback((De,at)=>{const tt=De==="request"?D:W;tt(bt=>({...bt,status:"loading",error:null}));const Ws=new URLSearchParams({part:De,offset:String(at),limit:String(uA)});Ze(`/api/logs/${String(e.id)}/body?${Ws.toString()}`,G2,cA).then(bt=>{ue.current===e.id&&tt(Hs=>({status:"success",text:bt.offset===0?bt.text:`${Hs.text}${bt.text}`,offset:bt.nextOffset??bt.totalBytes,totalBytes:bt.totalBytes,hasMore:bt.hasMore,error:null}))}).catch(bt=>{ue.current===e.id&&tt(Hs=>({...Hs,status:"failed",error:fA(bt)}))})},[e.id]),cn=p.useCallback(()=>{te.current||(H(null),L("idle"),$(null),B(De=>De+1))},[]),Dn=p.useCallback(()=>{const De=!d;De&&_(Re!==null?"anatomy":"request"),f(De)},[Re,d]);return p.useEffect(()=>{ue.current=e.id,te.current=!1,H(null),L("idle"),$(null),B(0),D(Yr(e.rawRequestBodyBytes??null)),W(Yr(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),p.useEffect(()=>{if(!d||!dA(e)||z!==null||te.current)return;let De=!1;return te.current=!0,L("loading"),$(null),Ze(`/api/logs/${String(e.id)}`,lr,lA).then(at=>{De||(te.current=!1,H(at),L("idle"),$(null))}).catch(at=>{De||(te.current=!1,L("failed"),$(jE(at)))}),()=>{De=!0,te.current=!1}},[d,z,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,X]),p.useEffect(()=>{d&&ge&&Q.status==="idle"&&(y!=="request"&&y!=="raw-request"&&y!=="anatomy"||Nt("request",0))},[y,d,Nt,Q.status,ge]),p.useEffect(()=>{d&&ge&&Z.status==="idle"&&(y!=="parsed"&&y!=="raw"||Nt("response",0))},[y,d,Nt,Z.status,ge]),p.useEffect(()=>{const De=at=>{const tt=Pi(at);tt!==null&&tt.logId===e.id&&(f(!0),_(aA(tt.tab,Re)),tt.tab==="response"&&tt.toolCallIndex!==void 0&&(S(tt.toolCallIndex),T(Ws=>Ws+1)))};return window.addEventListener(an,De),()=>{window.removeEventListener(an,De)}},[Re,e.id]),r.jsxs(jn,{children:[r.jsxs("div",{className:oe("bg-card/80 relative mb-1.5 overflow-hidden rounded-[8px] transition-[background-color,box-shadow]",d?"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(GE,{log:F,displayNumber:t,messageCount:P.messageCount,toolCount:P.toolCount,toolEvents:u,expanded:d,onToggle:Dn,cacheTrend:a,slowResponseThresholdSeconds:o,showClientMetadata:c,timeDisplayFormat:i,activeTab:y,tabActions:Oe,onReplay:l===void 0?void 0:()=>{h(!0)}}),d&&r.jsxs("div",{className:"relative bg-black/[0.14] pt-2",onClick:De=>De.stopPropagation(),onKeyDown:De=>De.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.jsxs(B0,{value:y,onValueChange:_,className:"gap-2",children:[r.jsxs(W0,{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:[ca(n,F.rawHeaders!==void 0&&Object.keys(F.rawHeaders).length>0)&&r.jsx(Tt,{className:Fn,value:"raw-headers",children:"Raw Headers"}),ua(n,F.headers!==void 0&&Object.keys(F.headers).length>0)&&r.jsx(Tt,{className:Fn,value:"headers",children:"Headers"}),Re!==null&&r.jsx(Tt,{className:Fn,value:"anatomy",children:"Context"}),vd(K,n,s)&&r.jsx(Tt,{className:Fn,value:"raw-request",children:"Raw Request"}),r.jsx(Tt,{className:Fn,value:"request",children:"Request"}),n==="full"&&r.jsx(Tt,{className:Fn,value:"raw",children:"Raw Response"}),r.jsx(Tt,{className:Fn,value:"parsed",children:"Response"})]}),vd(K,n,s)&&r.jsx(Et,{value:"raw-request",children:y==="raw-request"&&r.jsxs(Un,{children:[r.jsx(Xr,{status:N,error:w,footprint:de,onRetry:cn}),ge&&r.jsx(eo,{label:"Request",state:Q,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>Nt("request",Q.offset)}),ve===null?r.jsx(bo,{children:ge?"Request preview is loading":"No request body"}):ae.parsedData!==null?r.jsx(p.Suspense,{fallback:r.jsx(hs,{}),children:r.jsx(il,{data:ae.parsedData,bulkDepth:ae.bulkDepth,bulkRevision:ae.bulkRevision})}):r.jsx(Qr,{children:ve})]})}),r.jsx(Et,{value:"request",children:y==="request"&&r.jsxs(Un,{children:[r.jsx(Xr,{status:N,error:w,footprint:de,onRetry:cn}),ge&&r.jsx(eo,{label:"Request",state:Q,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>Nt("request",Q.offset)}),Ct.length>0&&r.jsxs(gr,{tone:"warning",children:[r.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[r.jsx(bn,{className:"size-3.5"}),"Tool schema warnings"]}),r.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:Ct.map(De=>r.jsx("li",{children:De},De))})]}),r.jsx(rA,{summary:xt,calledToolNames:U.toolNames??[]}),b?r.jsx(mA,{rawBody:F.rawRequestBody,displayedBody:se,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):r.jsx("div",{ref:V,children:se===null?r.jsx(bo,{children:ge?"Request preview is loading":"No request body"}):q.parsedData!==null?r.jsx(p.Suspense,{fallback:r.jsx(hs,{}),children:r.jsx(il,{data:q.parsedData,bulkDepth:q.bulkDepth,bulkRevision:q.bulkRevision,anatomyPaths:mt,expandToPath:R})}):r.jsx(Qr,{children:se})})]})}),Re!==null&&r.jsx(Et,{value:"anatomy",children:y==="anatomy"&&r.jsx(Un,{className:"p-0",children:r.jsx(p.Suspense,{fallback:r.jsx(hs,{}),children:r.jsx(gE,{parsed:q.parsedData,inputTokens:F.inputTokens??null,model:F.model,segments:Re,onSegmentActivate:Ln})})})}),ua(n,F.headers!==void 0&&Object.keys(F.headers).length>0)&&r.jsx(Et,{value:"headers",children:y==="headers"&&r.jsxs(Un,{children:[r.jsx("div",{className:"flex justify-end gap-2 mb-2",children:oA(n,F.rawHeaders!==void 0&&Object.keys(F.rawHeaders).length>0)&&r.jsx(hA,{active:x,onClick:De=>{De.stopPropagation(),g(!x)}})}),x?r.jsx(gA,{rawHeaders:F.rawHeaders,headers:F.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):r.jsx(wd,{headers:F.headers,emptyLabel:"No headers captured"})]})}),ca(n,F.rawHeaders!==void 0&&Object.keys(F.rawHeaders).length>0)&&r.jsx(Et,{value:"raw-headers",children:y==="raw-headers"&&r.jsx(Un,{children:r.jsx(wd,{headers:F.rawHeaders,emptyLabel:"No raw headers captured"})})}),r.jsx(Et,{value:"raw",children:y==="raw"&&r.jsxs(Un,{className:"space-y-3",children:[r.jsx(Xr,{status:N,error:w,footprint:de,onRetry:cn}),ge&&r.jsx(eo,{label:"Response",state:Z,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>Nt("response",Z.offset)}),F.error!==void 0&&F.error!==null&&r.jsx(gr,{tone:"danger",title:"SSE Error",children:r.jsx("span",{className:"font-mono",children:F.error})}),xe!==null&&ee?r.jsx(p.Suspense,{fallback:r.jsx(hs,{}),children:r.jsx(vE,{text:xe,defaultExpandDepth:0,bulkDepth:I.bulkDepth,bulkRevision:I.bulkRevision})}):xe!==null?r.jsx(Qr,{children:xe}):r.jsx(bo,{children:ge?"Response preview is loading":"No response"}),F.streaming===!0&&r.jsx(p.Suspense,{fallback:r.jsx(hs,{}),children:r.jsx(bE,{logId:F.id,truncated:F.streamingChunksPath!==null})})]})}),r.jsx(Et,{value:"parsed",children:y==="parsed"&&r.jsxs(Un,{children:[r.jsx(Xr,{status:N,error:w,footprint:de,onRetry:cn}),ge&&r.jsx(eo,{label:"Response",state:Z,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>Nt("response",Z.offset)}),Ae&&!ee?r.jsx(Qr,{children:xe}):r.jsx(p.Suspense,{fallback:r.jsx(hs,{}),children:r.jsx(xE,{responseText:xe,responseStatus:F.responseStatus,streaming:F.streaming,inputTokens:F.inputTokens,outputTokens:F.outputTokens,cacheCreationInputTokens:F.cacheCreationInputTokens,cacheReadInputTokens:F.cacheReadInputTokens,apiFormat:K,error:F.error,focusedToolIndex:j,toolFocusNonce:E})})]})})]})]})]}),r.jsx(p.Suspense,{fallback:null,children:r.jsx(mE,{log:F,displayNumber:t,open:m,onOpenChange:h})})]})});function bA(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 da(e){return e?"cursor-pointer transition-transform hover:scale-110":""}function vA({stopReason:e,isPending:t,isFirst:n,isTurnStart:s,isOnlyEntry:o=!1,crabIndex:i=0,collapsible:a=!1,onToggle:l}){const c=Ic(e),u=o&&s&&c,d=t&&!c,f=a&&l!==void 0,m=p.useMemo(()=>Pc(i),[i]),h=p.useMemo(()=>nE(i),[i]),x=b=>{!f||l===void 0||(b.stopPropagation(),l())},g=b=>{!f||l===void 0||b.key!=="Enter"&&b.key!==" "||(b.preventDefault(),l())};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"})}),u?r.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Single-request turn",className:da(f),onClick:x,onKeyDown:g,children:r.jsx(h,{className:oe("size-3.5 text-[#80FF00]","animate-crab-settle","drop-shadow-[0_0_4px_rgba(128,255,0,0.5)]")})}):c?r.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:bA(e),className:da(f),onClick:x,onKeyDown:g,children:r.jsx(m,{className:oe("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:f?"button":void 0,tabIndex:f?0:void 0,title:"Start of turn",className:da(f),onClick:x,onKeyDown:g,children:r.jsx(m,{className:oe("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):d?r.jsx("span",{title:"Processing",children:r.jsx(m,{className:oe("size-3.5 text-amber-300/80","animate-crab-crawl")})}):r.jsx("span",{title:"Request in turn",children:r.jsx(m,{className:"size-3.5 text-muted-foreground/40"})}),r.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!c&&r.jsx("div",{className:oe("w-0.5 h-full",t?"border-dashed bg-transparent border-l border-muted-foreground/14":"bg-muted-foreground/18")})})]})}const _d=180,fa=new WeakMap;function yA(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 wA(e,t,n){return e>1&&t&&!n}function cl(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:$0(i),sessionLogNumber:o+1});const a=n[n.length-1];a!==void 0&&Ic(a.stopReason)&&(t.push({entries:n,turnIndex:s}),n=[],s+=1)}return n.length>0&&t.push({entries:n,turnIndex:s}),t}function _A(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=fr(o),l=fr(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 vo(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>_d?`${n.slice(0,_d-1)}...`:n}function yo(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 kA(e){const t=Y0(e.responseText),n=ke(t,"content");if(!Array.isArray(n))return[];const s=[];for(const o of n){if(ke(o,"type")!=="tool_use")continue;const a=ke(o,"name");if(typeof a!="string"||a.length===0)continue;const l=ke(o,"input");s.push({id:`${String(e.id)}-anthropic-tool-${String(s.length)}`,logId:e.id,index:s.length,provider:"anthropic",name:a,argumentsText:yo(l),argumentsPreview:vo(l)})}return s}function jA(e){const t=Y0(e.responseText),n=ke(t,"choices");if(!Array.isArray(n))return[];const s=[];for(const i of n){const a=ke(i,"message"),l=ke(a,"tool_calls");if(Array.isArray(l))for(const d of l){const f=ke(d,"function"),m=ke(f,"name");if(typeof m!="string"||m.length===0)continue;const h=ke(f,"arguments");s.push({id:`${String(e.id)}-openai-tool-${String(s.length)}`,logId:e.id,index:s.length,provider:"openai",name:m,argumentsText:yo(h),argumentsPreview:vo(h)})}const c=ke(a,"function_call"),u=ke(c,"name");if(typeof u=="string"&&u.length>0){const d=ke(c,"arguments");s.push({id:`${String(e.id)}-openai-tool-${String(s.length)}`,logId:e.id,index:s.length,provider:"openai",name:u,argumentsText:yo(d),argumentsPreview:vo(d)})}}const o=ke(t,"output");if(Array.isArray(o))for(const i of o){if(ke(i,"type")!=="function_call")continue;const a=ke(i,"name");if(typeof a!="string"||a.length===0)continue;const l=ke(i,"arguments");s.push({id:`${String(e.id)}-openai-tool-${String(s.length)}`,logId:e.id,index:s.length,provider:"openai",name:a,argumentsText:yo(l),argumentsPreview:vo(l)})}return s}function zc(e){const t=fa.get(e);if(t!==void 0&&t.apiFormat===e.apiFormat&&t.responseText===e.responseText)return t.events;const n=fr(e);if(!yA(e,n)){const o=[];return fa.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:o}),o}let s;switch(n){case"anthropic":s=kA(e);break;case"openai":s=jA(e);break;case"unknown":s=[];break}return fa.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:s}),s}function SA(e,t,n=0){let s=0,o=0,i=0,a=0,l=0,c=0,u=0,d=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&&(c+=h.cacheCreationInputTokens),h.cacheReadInputTokens!==null&&(u+=h.cacheReadInputTokens),h.elapsedMs!==null&&(d+=h.elapsedMs,f=f===null?h.elapsedMs:Math.max(f,h.elapsedMs)),m+=zc(h).length;return{llmCallCount:e.length,toolCallCount:m,failedCallCount:s,pendingCallCount:o,slowCallCount:i,totalInputTokens:a,totalOutputTokens:l,totalCacheCreationInputTokens:c,totalCacheReadInputTokens:u,totalElapsedMs:d,maxElapsedMs:f,startedAt:e[0]?.timestamp??null,endedAt:e[e.length-1]?.timestamp??null,knowledgeCandidateCount:n}}function pa(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const CA=p.memo(function({entries:t,viewMode:n,strip:s,slowResponseThresholdSeconds:o,cacheTrends:i,onCompareWithPrevious:a,comparisonPredecessors:l,turnIndex:c=0,timeDisplayFormat:u,pendingFocusRequest:d,showLogClientMetadata:f=!0}){const m=t.length-1,h=t[m]?.stopReason??null,x=h!==null?Ic(h):!1,g=t[m]?.log.responseStatus===null,b=t.length===1,v=wA(t.length,x,g),[y,_]=p.useState(!1),j=p.useRef(!1);p.useEffect(()=>{v?x&&!j.current&&_(!0):_(!1),j.current=x},[v,x]),p.useEffect(()=>{const B=Q=>{const D=Pi(Q);D!==null&&t.some(Z=>Z.log.id===D.logId)&&v&&_(!1)};return window.addEventListener(an,B),()=>{window.removeEventListener(an,B)}},[v,t]),p.useEffect(()=>{if(d===void 0||!t.some(Q=>Q.log.id===d.logId))return;v&&_(!1);const B=window.setTimeout(()=>{hr({logId:d.logId,tab:d.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(B)},[v,t,d]);const S=p.useCallback(()=>{v&&_(B=>!B)},[v]),E=p.useMemo(()=>{let B=0,Q=0,D=null,Z=!1;for(const W of t)W.log.inputTokens!==null&&(B+=W.log.inputTokens,Z=!0),W.log.outputTokens!==null&&(Q+=W.log.outputTokens,Z=!0),W.log.elapsedMs!==null&&(D=D===null?W.log.elapsedMs:Math.max(D,W.log.elapsedMs));return{totalInput:B,totalOutput:Q,hasTokens:Z,maxElapsed:D}},[t,m]),T=c%2===0?"bg-white/[0.008]":"bg-cyan-300/[0.008]",R=E.maxElapsed!==null&&o>0&&E.maxElapsed>o*1e3,A=p.useMemo(()=>{const B=new Map;for(const Q of t){const D=zc(Q.log);D.length>0&&B.set(Q.log.id,D)}return B},[t]),[z,H]=p.useState(0),N=p.useRef(null);p.useEffect(()=>{const B=N.current;if(!B)return;let Q=0;const D=new ResizeObserver(()=>{window.cancelAnimationFrame(Q),Q=window.requestAnimationFrame(()=>H(Z=>Z+1))});return D.observe(B),()=>{D.disconnect(),window.cancelAnimationFrame(Q)}},[]);const L=t[0]?.log.id??c,w=`Turn ${String(c+1)}`,$=p.useMemo(()=>Pc(L%12),[L]),X=p.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:y?"48px":"160px"}),[y]);return r.jsx("div",{ref:N,style:X,tabIndex:y?void 0:0,role:y?void 0:"group","aria-label":y?void 0:w,"data-nav-id":y?void 0:`turn-${String(L)}`,className:oe("rounded-[8px] transition-[background-color,box-shadow]",g?"bg-amber-300/[0.018] shadow-[0_0_0_1px_rgba(252,211,77,0.035)]":"",!y&&"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),children:y?r.jsxs("div",{"data-nav-id":`turn-collapsed-${String(L)}`,"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:S,onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),S())},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($,{className:oe("size-3.5",g?"animate-crab-crawl text-amber-300/80":"animate-crab-appear text-emerald-400",g?"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"})}),x&&r.jsx($,{className:oe("size-3.5 animate-crab-settle text-amber-400","drop-shadow-[0_0_4px_rgba(251,191,36,0.45)]")})]}),t.length>1&&r.jsxs("div",{className:oe("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",T),children:[r.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:w}),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":""]}),E.maxElapsed!==null&&r.jsx(jn,{children:r.jsxs(dt,{children:[r.jsx(ft,{asChild:!0,children:r.jsxs("span",{className:oe("flex items-center gap-1 shrink-0",R?"text-amber-400":"text-muted-foreground"),children:[r.jsx(tn,{className:"size-3"}),r.jsx("span",{className:"font-mono tabular-nums",children:pa(E.maxElapsed)}),R&&r.jsx(bn,{className:"size-3","aria-label":"Slow response"})]})}),r.jsx(pt,{children:R?`Slow response: ${pa(E.maxElapsed)} exceeds ${pa(o*1e3)}`:"Slowest request in this turn"})]})}),E.hasTokens&&r.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[r.jsx(cr,{className:"size-3 text-muted-foreground"}),r.jsxs("span",{className:"font-mono tabular-nums",children:[r.jsxs("span",{className:"text-blue-400",children:["IN ",Fe(E.totalInput)]})," / ",r.jsxs("span",{className:"text-amber-400",children:["OUT ",Fe(E.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(jt,{className:"size-4 shrink-0"})})]})]}):t.map((B,Q)=>{const{log:D,stopReason:Z}=B,W=Q===0;return r.jsxs("div",{className:"flex items-stretch",children:[r.jsx(vA,{stopReason:Z,isPending:D.responseStatus===null,isFirst:Q===0,isTurnStart:W,isOnlyEntry:b,crabIndex:D.id%12,collapsible:v&&W,onToggle:S}),r.jsx("div",{className:oe("flex-1 min-w-0 mb-0.5 rounded-[8px]",T),children:r.jsx(xA,{log:D,displayNumber:B.sessionLogNumber,viewMode:n,strip:s,slowResponseThresholdSeconds:o,timeDisplayFormat:u,cacheTrend:i?.get(D.id)??null,showClientMetadata:f,toolEvents:A.get(D.id),onCompareWithPrevious:l.has(D.id)?a:void 0})})]},D.id)})})}),NA=24,TA=132,EA=8;function AA(e){return e>NA}function RA(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 X0(e,t,n){return r.jsx(CA,{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 IA(e){return AA(e.turnGroups.length)?r.jsx(PA,{...e}):r.jsx(r.Fragment,{children:e.turnGroups.map(t=>X0(t,e))})}function PA(e){const{turnGroups:t}=e,[n,s]=p.useState(null),o=FT({count:t.length,estimateSize:()=>TA,overscan:EA,getItemKey:a=>t[a]?.turnIndex??a}),i=p.useMemo(()=>RA(t),[t]);return p.useEffect(()=>{const a=l=>{const c=Pi(l);if(c===null||c.source==="virtualizer")return;const u=i.get(c.logId);u!==void 0&&(o.scrollToIndex(u,{align:"center"}),s(d=>({...c,turnIndex:u,nonce:d===null?1:d.nonce+1})))};return window.addEventListener(an,a),()=>{window.removeEventListener(an,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 c=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:X0(l,e,c)},a.key)})})}const Mc=Te(["episode","procedure","preference","project-fact"]),zA=Te(["draft","promoted","failed"]),Q0=J({source:Ee("agent-inspector"),sessionId:C(),logIds:fe(G().int().positive()),project:C().nullable(),models:fe(C())}),MA=J({redacted:Le(),patterns:fe(C())}),Er=J({id:C(),type:Mc,title:C(),content:C(),tags:fe(C()),source:Ee("agent-inspector"),sessionId:C(),logIds:fe(G().int().positive()),evidence:Q0,status:zA,createdAt:C(),updatedAt:C(),openClawMemoryId:C().nullable(),error:C().nullable(),redaction:MA});J({idempotencyKey:C(),type:Mc,title:C(),content:C(),tags:fe(C()),source:Ee("agent-inspector"),project:C().nullable(),evidence:Q0});const OA=J({id:C(),type:Mc.or(C()),title:C(),content:C(),score:G().nullable(),source:C().nullable(),project:C().nullable(),evidence:qn().optional()});J({results:fe(OA),warning:C().nullable()});const LA=J({candidates:fe(Er)}),DA=J({candidate:Er}),$A=J({error:C().optional(),candidate:Er.optional()}),FA=J({candidate:Er}),UA=3e4,BA=15e3,WA=15e3,HA={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 ul(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function VA(e,t,n){return e===null||t===null?null:li(e,t,n)}function qA(e){return`${String(e)} candidate${e===1?"":"s"}`}function eg(e){return`log-${String(e)}`}function tg(e){const t=eg(e),n=document.getElementById(t);window.history.replaceState(null,"",`#${t}`),n instanceof HTMLElement&&(n.scrollIntoView({block:"center",behavior:"smooth"}),n.focus({preventScroll:!0}))}function ZA(e){for(const t of e)if(t.responseStatus!==null&&t.responseStatus>=400)return t;return null}function GA(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 KA(e){for(const t of e)if(zc(t).length>0)return t;return null}function JA(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 Ss(e,t){return String(t.get(e)??e)}function YA(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=KA(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 #${Ss(n.id,e.displayNumberByLogId)}`,logId:n.id});const s=ZA(e.logs);s!==null&&t.push({kind:"failure",title:`Failure #${String(s.responseStatus)}`,detail:`First failed request is #${Ss(s.id,e.displayNumberByLogId)}`,logId:s.id});const o=GA(e.logs);if(o!==null&&e.summary.maxElapsedMs!==null&&t.push({kind:"slow",title:`Slowest ${ul(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${Ss(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 XA(e){switch(e){case"session":return r.jsx(ai,{className:"size-3.5 text-blue-400"});case"tool":return r.jsx(_r,{className:"size-3.5 text-sky-400/70"});case"slow":return r.jsx(tn,{className:"size-3.5 text-amber-400"});case"failure":return r.jsx(Tp,{className:"size-3.5 text-destructive"});case"candidate":return r.jsx(Np,{className:"size-3.5 text-emerald-400"})}}function QA({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:oe("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&&tg(t.logId)},disabled:t.logId===null,children:[XA(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 eR(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function tR(e,t){if(t)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function nR(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function sR(e,t){const n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,t-3)}...`}function rR(e,t){const n=e[0],s=e[e.length-1];if(n===void 0)return"No evidence logs";const o=Ss(n,t);return s===void 0||n===s?`#${o}`:`#${o}-#${Ss(s,t)}`}function kd(e){return e.join(", ")}function oR(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function iR({candidate:e,isPromoting:t,isUpdating:n,onPromoteCandidate:s,onUpdateCandidate:o,displayNumberByLogId:i}){const[a,l]=p.useState(!1),[c,u]=p.useState(e.type),[d,f]=p.useState(e.title),[m,h]=p.useState(e.content),[x,g]=p.useState(kd(e.tags)),[b,v]=p.useState(null),y=e.status!=="promoted",_=e.status!=="promoted",j=p.useCallback(()=>{u(e.type),f(e.title),h(e.content),g(kd(e.tags)),v(null)},[e.content,e.tags,e.title,e.type]),S=p.useCallback(async()=>{const E=d.trim(),T=m.trim(),R=oR(x);if(E.length===0){v("Title is required.");return}if(T.length===0){v("Content is required.");return}if(R.length===0){v("At least one tag is required.");return}v(null),await o(e.id,{type:c,title:E,content:T,tags:R})&&l(!1)},[e.id,m,x,d,c,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:c,disabled:n,onChange:E=>{const T=Er.shape.type.safeParse(E.currentTarget.value);T.success&&u(T.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:d,disabled:n,onChange:E=>f(E.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:E=>h(E.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:x,disabled:n,onChange:E=>g(E.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(wu,{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(je,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{j(),l(!1)},children:[r.jsx(kr,{className:"size-3.5"}),"Cancel"]}),r.jsxs(je,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{S()},children:[n?r.jsx(vn,{className:"size-3.5 animate-spin"}):r.jsx(i5,{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(ze,{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(ze,{variant:"outline",className:oe("h-5 shrink-0 px-1.5 text-[10px] font-mono",HA[e.status]),children:eR(e.status)})]}),r.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:sR(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(r_,{className:"size-3"}),rR(e.logIds,i)]}),r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(wu,{className:"size-3"}),nR(e)]}),e.status==="promoted"&&r.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[r.jsx(za,{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(Tp,{className:"size-3"}),e.error]})]}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.logIds.map(E=>{const T=Ss(E,i);return r.jsxs("a",{href:`#${eg(E)}`,onClick:R=>{R.preventDefault(),tg(E)},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 ${T}`,title:`Log ID ${String(E)}`,children:["#",T]},E)}),r.jsx("span",{className:"flex-1"}),_&&r.jsxs(je,{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(zp,{className:"size-3"}),"Review"]}),r.jsxs(je,{type:"button",variant:y?"outline":"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",onClick:()=>s(e.id),disabled:!y||t||n,children:[t?r.jsx(vn,{className:"size-3 animate-spin"}):y?r.jsx($w,{className:"size-3"}):r.jsx(za,{className:"size-3"}),tR(e,t)]})]})]})}function aR({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(iR,{candidate:a,isPromoting:t.has(a.id),isUpdating:n.has(a.id),onPromoteCandidate:s,onUpdateCandidate:o,displayNumberByLogId:i},a.id))})}function lR({logs:e,scopeId:t,slowResponseThresholdSeconds:n,showRollupMetrics:s,timeDisplayFormat:o}){const[i,a]=p.useState([]),[l,c]=p.useState(!0),[u,d]=p.useState({status:"idle",error:null}),[f,m]=p.useState(()=>new Set),[h,x]=p.useState(()=>new Set),g=i.length>0,b=p.useMemo(()=>SA(e,n,i.length),[i.length,e,n]),v=p.useMemo(()=>JA(e),[e]),y=p.useMemo(()=>YA({logs:e,scopeId:t,summary:b,candidates:i,displayNumberByLogId:v}),[i,v,e,t,b]),_=s||b.maxElapsedMs!==null,j=p.useMemo(()=>VA(b.startedAt,b.endedAt,o),[b.endedAt,b.startedAt,o]),S=p.useCallback(()=>{e.length===0||u.status==="loading"||(d({status:"loading",error:null}),(async()=>{try{const R=await Ze(`/api/knowledge/sessions/${encodeURIComponent(t)}/candidates`,LA,UA,{method:"POST"},A=>`Candidate generation failed with ${String(A.status)}`);a(R.candidates),c(R.candidates.length>0),d(R.candidates.length>0?{status:"ready",error:null}:{status:"failed",error:"No candidate was generated for this trace scope."})}catch(R){d({status:"failed",error:R instanceof Error?R.message:"Candidate response was invalid"})}})())},[u.status,e.length,t]),E=p.useCallback(R=>{m(A=>{if(A.has(R))return A;const z=new Set(A);return z.add(R),z}),(async()=>{try{const A=await Zn(`/api/knowledge/candidates/${encodeURIComponent(R)}/promote`,BA,{method:"POST"}),z=await A.json().catch(()=>null),H=DA.safeParse(z);if(A.ok&&H.success){a(L=>L.map(w=>w.id===H.data.candidate.id?H.data.candidate:w)),d({status:"ready",error:null});return}const N=$A.safeParse(z);N.success&&N.data.candidate!==void 0&&a(L=>L.map(w=>w.id===N.data.candidate?.id?N.data.candidate:w)),d({status:"failed",error:N.success?N.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(A.status)}`})}catch(A){d({status:"failed",error:A instanceof Error?A.message:"Candidate promotion failed"})}finally{m(A=>{const z=new Set(A);return z.delete(R),z})}})()},[]),T=p.useCallback(async(R,A)=>{x(z=>{if(z.has(R))return z;const H=new Set(z);return H.add(R),H});try{const z=await Ze(`/api/knowledge/candidates/${encodeURIComponent(R)}`,FA,WA,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)},H=>`Candidate update failed with ${String(H.status)}`);return a(H=>H.map(N=>N.id===z.candidate.id?z.candidate:N)),d({status:"ready",error:null}),!0}catch(z){return d({status:"failed",error:z instanceof Error?z.message:"Candidate update failed"}),!1}finally{x(z=>{const H=new Set(z);return H.delete(R),H})}},[]);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(ai,{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(_r,{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(cr,{className:"size-3.5 text-emerald-400"}),r.jsxs("span",{className:"font-mono",children:[Fe(b.totalInputTokens)," / ",Fe(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(cr,{className:"size-3.5 text-purple-400"}),r.jsxs("span",{className:"font-mono",children:["KV Cache +",Fe(b.totalCacheCreationInputTokens)," / ~",Fe(b.totalCacheReadInputTokens)]})]}),_&&r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[r.jsx(tn,{className:"size-3.5"}),s&&r.jsx("span",{className:"font-mono",children:ul(b.totalElapsedMs)}),b.maxElapsedMs!==null&&r.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",ul(b.maxElapsedMs)]})]}),s&&j!==null&&r.jsx("span",{className:"font-mono text-muted-foreground/70",children:j}),(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(bn,{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"}),g&&r.jsx(ze,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:qA(b.knowledgeCandidateCount)}),r.jsxs(je,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:S,disabled:u.status==="loading",children:[u.status==="loading"?r.jsx(Ye,{className:"size-3.5 animate-spin"}):r.jsx(Np,{className:"size-3.5"}),"Candidate"]}),g&&r.jsx(je,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onClick:()=>c(R=>!R),"aria-expanded":l,"aria-label":l?"Collapse memory candidates":"Expand memory candidates",children:l?r.jsx(rt,{className:"size-3.5"}):r.jsx(jt,{className:"size-3.5"})})]}),u.status==="failed"&&r.jsx("p",{className:"mt-2 text-xs text-destructive",children:u.error}),r.jsx(QA,{insights:y}),l&&r.jsx(aR,{candidates:i,promotingCandidateIds:f,updatingCandidateIds:h,onPromoteCandidate:E,onUpdateCandidate:T,displayNumberByLogId:v})]})}function cR(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 uR(e){const t=new Map;for(const n of e){if(n.model===null)continue;const s=o4(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 dR(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function fR(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}const pR=p.memo(function({group:e,viewMode:t="simple",strip:n,slowResponseThresholdSeconds:s,cacheTrends:o,onCompareWithPrevious:i,comparisonPredecessors:a,onClearGroup:l,showClientIdentity:c=!0,showProcessMetadata:u=!0,showLogClientMetadata:d=!0,defaultExpanded:f=!1,timeDisplayFormat:m,expanded:h,onExpandedChange:x}){const[g,b]=p.useState(f),v=h??g,y=p.useCallback(H=>{if(x!==void 0){x(H);return}b(H)},[x]);p.useEffect(()=>{!f||h!==void 0||b(!0)},[h,f]);const _=p.useMemo(()=>cR(e.logs),[e.logs]),j=p.useMemo(()=>uR(e.logs),[e.logs]),S=e.logs[0]?.timestamp??new Date().toISOString(),E=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),T=e.logs.some(H=>H.responseStatus===null),R=p.useMemo(()=>dR(e.logs),[e.logs]),A=p.useMemo(()=>fR(e.logs),[e.logs]),z=p.useMemo(()=>cl(e.logs),[e.logs]);return p.useEffect(()=>{const H=N=>{const L=Pi(N);L!==null&&e.logs.some(w=>w.id===L.logId)&&y(!0)};return window.addEventListener(an,H),()=>{window.removeEventListener(an,H)}},[e.logs,y]),r.jsxs("div",{className:"mb-2",children:[r.jsx(yT,{conversationId:e.conversationId,startTime:S,endTime:E,totalCalls:e.logs.length,totalInputTokens:_.totalInputTokens,totalOutputTokens:_.totalOutputTokens,expanded:v,onToggle:()=>y(!v),providers:j,isLoading:T,userAgent:e.logs[0]?.userAgent??null,clientPid:R,clientProjectFolder:A,showClientIdentity:c,showProcessMetadata:u,timeDisplayFormat:m,onClear:()=>l(e.logs.map(H=>H.id))}),v&&r.jsxs("div",{children:[r.jsx(lR,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:s,showRollupMetrics:!1,timeDisplayFormat:m}),r.jsx(IA,{turnGroups:z,viewMode:t,strip:n,slowResponseThresholdSeconds:s,timeDisplayFormat:m,cacheTrends:o,onCompareWithPrevious:i,comparisonPredecessors:a,showLogClientMetadata:d})]})]})});function hR(e){return e==="full"}function mR(e,t){const n=t>0;return{redacted:n,raw:n&&hR(e)}}function gR(e,t){const n=e[0],s=e[e.length-1];return n===void 0||s===void 0?null:li(n.timestamp,s.timestamp,t)}function xR(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function bR(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 vR(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 yR(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 wR(e,t){return`${Fe(e)} in / ${Fe(t)} out`}function _R(e,t){if(e.length===0)return 0;if(t.length===0)return cl(e).length;let n=0;for(const s of t)n+=cl(s.logs).length;return n}function kR({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 jR(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 SR({pending:e,failures:t,lengthStops:n,stopReason:s,lastFailure:o}){if(o!==null&&(o.status===499||jR(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 CR({logs:e,conversationGroups:t,isLoading:n,timeDisplayFormat:s,slowResponseThresholdSeconds:o}){let i=0,a=0,l=0,c=0,u=0,d=0,f=null,m=null,h=null,x=null,g=null,b=0,v=0,y=0,_=null;const j=o*1e3;for(let A=0;A<e.length;A+=1){const z=e[A];if(z===void 0)continue;const H=A+1,N=$0(z);N!==null&&(f=N),N==="length"&&(c+=1),xR(z)&&(i+=1,m=H,h={logNumber:H,status:z.responseStatus,error:z.error??null}),z.responseStatus===null&&(a+=1),o>0&&z.elapsedMs!==null&&z.elapsedMs>=j&&(l+=1),z.inputTokens!==null&&(u+=z.inputTokens),z.outputTokens!==null&&(d+=z.outputTokens),z.elapsedMs!==null&&(x===null||z.elapsedMs>x)&&(x=z.elapsedMs,g=H);const L=z.inputTokens??0,w=z.outputTokens??0,$=L+w;$>b&&(b=$,v=L,y=w,_=H)}const S=n||a>0&&i===0?"rolling":i>0?"failed":l>0||c>0?"watch":"clear",E=S==="rolling"?"Rolling":S==="failed"?"Failure":S==="watch"?"Watch":"Clear",T=kR({stopReason:f,pending:a,lastFailureLogNumber:m}),R=SR({pending:a,failures:i,lengthStops:c,stopReason:f,lastFailure:h});return{status:S,statusLabel:E,modelLabel:bR(e),providerLabel:vR(e),requests:e.length,turns:_R(e,t),failures:i,pending:a,slow:l,lengthStops:c,timeRange:gR(e,s),tokenLabel:`${Fe(u)} in / ${Fe(d)} out`,finishLabel:T.label,finishDetail:T.detail,finishTone:T.tone,outcomeLabel:R.label,outcomeDetail:R.detail,outcomeTone:R.tone,slowestLabel:x===null?"n/a":yR(x),slowestDetail:g===null?"Latency pending":`Request #${g}`,heaviestDetail:_===null?"Tokens pending":`#${_} ${wR(v,y)}`}}function NR({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 TR({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 dl({className:e}){return r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:oe("inline-block size-5",e),children:[r.jsx("path",{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"}),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:"10",y1:"7",x2:"9.5",y2:"5"}),r.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"}),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"}),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"})]})}const ER="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPoAAAD6CAQAAAAi5ZK2AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAHdElNRQfpCxsJDCnsge2KAAAM2ElEQVR42u2de3AW1RnGnyQQDARDwiUFpHIVMHIpYgFRB2nLxQrC0FIDiCKDWNqBUqBlai8wvciIpaRTWh3QDqCDIIjKDL0IaBC5SKlysWJArgqh3BMICYFs/wgpGUi+8579dr89e/Z5zp/59j2755fn3d2z5wJQFEVRFEVRoVQSm+AG1UFrtEdT1EcjNEA5SlCMIhxDAQoJ3S4lIwf9cD+6ozXq1vKbYuzHNmxEPo6xwcKtungIS3EajkYpwLPoyqYLp3KwACe1cFcvezATmWzEMOk+rMBV18CrSjHy0IqNGQb1wMa4cV8vZfgzGrNRTVYm8nDFQ+SV5QymIIWNa6ZGaz6y6ZR/I4cNbJrSkOcb8MpyCVPYzCapKz71GXllWY5b2dhm6EGcTwhyBw52oyUbPHgNx6WEIXfg4CDuYKMHq0kevI/rlhP4Ghs+OE1ERcKRO3BwEh3Z+NFC7sDBATQngMRrcoDIHTj4iE/yUXJ5VVlhYsMkWezy+a6urgRbsAP7cRincQGpqI+maI+O6IMuSHYRbwIW0X/mJvZTeAH9ah1CATTCaKxBmWbUi7iTOMxEXoCncIsodgvM1ezo2cFPMebdy89qfyHL0vxSN5FQzHL5ajRxVU8v7NO4cWQRjCnIy/DDOOq6FcvENS0gGjMS+wUMjvvdZ5awrsv4KvEE7/Iz+Lontc4Q1vc8AQXt8rO4x7Oa54hqLOLI2aBdfrenHVyviWqdQUx2uLxS6fhMUO8ugrLD5VXqLfpmfxdh2eHyKi0S1P5b4rLF5ZVqiiJl/Z8SmD0ur9TzgnNoQWi2uLxSt+Gy8ixGEpvZLs9AN3RGqsYRa5Xn8SeCM9XlDfFT7Ll2bDnWYYRwOMZjyjP5kOjMdPkDOHpTjPX4iuDILOWL2znCMxH5IyitMc4+ZAuO3q08nyYEaFpiHxbjYWyDIMm/qDyje4kwPMgdOBihjDBNeU7fJcQwIXewTnBzUJ3Vk8Rozr18mOAtuxT1FFH6KmNMJkhTkH+7lse3G0s7RZyuygjPEGVYEntV6aSIlKOM8CvCDEtirywVyFDE6q2M8WPiDJPLJcMgBiljPEWg4XG5AwfTlfEmKWPkEml4XO7gCBooI85TRvlm8I1ax3CX68w8PYeB2KGFfEWM6Yo3qgy5uKj8VU/lLz5HG2QjHRlIA1CCIhTjBI6ggg43LbGXYYggZj3lgkYVtbwaluITvIlf4gHhNEomdheJXfpeXoX8EVHUAR4sY1CKfEyN5gibMCIHXvJsBYur2IDxSCNy05HXx1mPFy/5L2ZFZb6rGR2uusiByb6sWlOMZ5FOl5vocqAuDvm2XNExjLV5t52wuhyY7vM6Ve+jA11uksuB5glYcLgIY+hyc1yeJBj87E35q6BXkC5PAHJgdgKXI9xlzzt8eF0OjE/wypQH7Li7h9nl4wJYjPQ4utPlwSF/LKD1Z8+gC10eLeQOHHyJ1nR54pGPCniVadmcGyK3xOVVZYvWnNpqb5hBIv+L1hCJAdiuhXyVcpT6dV3GSLylhXyxy7YrxHYU4CBO4yKABmiCNuiIe9DMVbT5mMp7eWJc/rgLl1dgC6bE2NelM6Zim4uoDzOxm5nYS/GicNOuznhJc0X5k2HprIkS8gos1cTSSrgYodFbhkQ5sR/F/a7aqD8Oa9TSny43x+UblDNialcmVovr2WP2qOYoIV8V57tREuaK6/o+E7sJid2bO+00Ya0HTPV6lFy+3LNWmymsMZfIg+1w9fZ5ep6ozp3mjaKjy90rGetF9d5H5Ha4vFLZOB62zYGIPH6NEk2NqEvk4U/s1V/f8gX1DyJye5ADQC/BGfyRyO1I7Nf1rvIcPiZye1xeqaGCua6ZNiMf7sOSAolD3h+v4otrH2RewYPCo1JxWnkmQ4jcROTZNcyGWSMcN7PQ5KUJw4zc33t5G+xHzfu3S7655wqmPRG5ccgPxxjkqN7DvbnyfDYRuVmJvY1iYMQEQYxCxRkVEnlYXF5ZdguibFLEKI/6S9pQg1x+Ow4IYrZSxlmqjJFGl4fF5dLVJBcoYzQl8jDcy3XestV7tbcl8vC43IGD3spo6gEVtxF5mJCXCu7H6u6ZRlFE/nAoE7sDB8sEEd9URqkTfuT2P7FXlSuiZQb2KKKU0OXhcbmDGYKYdZWrTO8l8nDcyx04mCeKqh5IsYaJPRyJ3cEfhHFnePTPQ+ShQQ68r4z1NJEHkdj9Q95KcN7didwmlwOzBC2dTOT2uByoj5PBPcbR5UEgly0tPo3I7XE5kI1zgoVOWhO5PS4HXhHE/IDI7XE5MFIU9QdEbo/LO6NIEPWS98Mn/F04pD+R16oWOCiK+4LXyMf4irwnin1ErrtWzGtGIW+MXcJvdB4v/H87LvqIvL1yWG90XZ6J7UHNpVvoI/KGKPDxS5q/Lm/ry5e06i7/SBi5HHd5izxVI/nqIpcM6aXL1WW+1z7v6SPyJ0I7RMJvl+sgP+H9uLihviFvp5FDmNhrL096/34+2Jf3cgBYw8TuAfI3/OiHu8MXl+tsMM97ee3lKBr7AT1JuVuwG+Sp2EvkcSMvR1+/PqbO9Bw5MIn38rgTu69rP6fFeJd2hzwFn/OJPU6XO5gNX5VTy6iNk66QA4+KLqoCY5nYay0L4bs6YedN1e5EJ5fRdogu60dM7DE+/SZk+lIqxmMzrl5br2wzxrvbCA5Ad9FlraTLay2vJ3YV2DS0Rds4VzuYI7isQ1q9TNG6l79uzsK/8ldAyffhYRoRwz0qJgLIgT6CC/uHMcjpck/0c8Gl9aHLbUIO/FN5aflEbhfyOoJBfrlEbhNyydf5C0jnvdwm5MAY5eWtInK7kAOzlRc4mYndLuTAq8pL7KGMMTzUXTGGdrj6qc2KS7yq7O27E1fYxx4ufaK4yCOK41M0ofg7dYHIRVIh2xr3gyBdbpxUW8+8ozh+PV0ePqkmSK1RJPdLhrj890Qu1ynFxa6PeXRTQ76X871cS6rPqh/GPDrLiJc0ulxTqgVtj8U8OglneS8Pn9RrHjaMefwbvJeHT4vj/JY+iMjDJ/UQip8oIqyNcewyJnYT9T3lpf9NEaEJPqvlyEV0uZnqKpjVkqWIkV3DTuKlmusfE3kClYwzygaYIIiSi03XxuA7OIF5aE7kJuttZRPsQpIoUga64W601l75mF0xCZdkYdvBPtZP5AGom6Ahtvu2brnfiZ3IXfbKye7rdHmo9AtBc5zyYftIujxAtRONcduIFLrcJm3wpdmDdfm/iDy2BgqbZnpoXE7kSiUJOy8qMNWD2nJwlC43QY+Km+i5OF/fHhD0ARJ5grpjt4qbaT1auM4oU1DGxG6Oev2/71xdCpEr7Jqtro5YpwWELk+AXtZqsHz01ojdDHM1PU7kCVEznNDEko8RuEXQ0bsAJZqRiTxhGqQ5FdGBg3NYgsfRpoZoDTEIv8N/tCNGDnlSwPU/hxkujyzCPhzBOZQiBY3QFB3i6Lidp7lhZSbe0VorcyVGoZwer1JdbHHlTC8LE3vC1US8CLg/xf+XtDqEfLPa4BiRR0/dBXsGhzOxE3kMdcGXCUc+h8iDT/IFCQR+BROJ3ARlaw5DcF8uYAiRm6J6yHPRXaNb9mhvUknkPmuocuGC+MoS1Cdy89QSK3wCvg8PaZ8NkSdM/YT7hsvLRcwSfKwh8kBVB08LN/JSlxIscNUzT+QBKBlDsC1O4OeR53LkDZEHqN7Ic9VRW4a3kav92EbkxigF38BcbEO5CMBhLME45Tz3yCJPChn8dPRBF7RHB3RARrVtvC6hGIewHwUowBYcirMW/e/lubhCZybunyALmR7/6zKxR05ETuRETuRETuRsNCKniJwicorIKSKniJwicorIKSKniJyqGfnHmvsyE3nIlRJzHxi63ErlEXnUNI6JPWrKUO7rTJdbp98QedSUjWIm9qjpGSKPnrYysUdNzYRLEBO5RRrLxF6p5AhB7yz4zUqMtn+CUpSgZyt/sZpz0mzTWuXU5sbRaIgoOT1T8fdCnCZ026RC2lJzQ25CD4EKFX9PwWLUI/RoQQe+hbdcrEBFGazRovf0tdFwe1SUJVyx5u90u03aKOx7J3aLNEP8lY1J3ho10hg3Q7dbo59pjJwhdkvUAMeJPXr6jtY2Ary3W6Jfaw2CptutUJLmJgLEboXSsUkLO5O8JQ9079LtxE7sxE7sxE7sFqkhH+mIXV1WhG43DMoD7OPZZNHD/gWnPUUR+4BwX2wyeQMAijEYH4h/fS+hRw97c0K3B/tAvCf6ZRmh26OLGCpy+wE2VfQe6XLYTFHD/h6bKGrYy9CDDWQr9vwakV/FE2wce5WGl29CfgrD2TC2qy+W4/w14Hsxy5aVKvjFSN1CLVAPp1DEpqAoiqIoyiz9D9lYMumhgrvLAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDI1LTExLTI3VDA5OjEyOjQxKzAwOjAwvIZCxQAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyNS0xMS0yN1QwOToxMjo0MSswMDowMM3b+nkAAAAASUVORK5CYII=";function AR({className:e}){return r.jsx("img",{src:ER,alt:"Model Context Protocol","aria-hidden":"true",className:oe("inline-block size-8 object-contain invert",e)})}function Xn({...e}){return r.jsx(Em,{"data-slot":"select",...e})}function Os({...e}){return r.jsx(Pm,{"data-slot":"select-value",...e})}function Qn({className:e,size:t="default",children:n,...s}){return r.jsxs(Rm,{"data-slot":"select-trigger","data-size":t,className:oe("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(zm,{asChild:!0,children:r.jsx(rt,{className:"size-4 opacity-50"})})]})}function es({className:e,children:t,position:n="popper",align:s="center",...o}){return r.jsx(Om,{children:r.jsxs(Lm,{"data-slot":"select-content",className:oe("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 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(RR,{}),r.jsx(Bm,{className:oe("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(IR,{})]})})}function Qe({className:e,children:t,...n}){return r.jsxs(qm,{"data-slot":"select-item",className:oe("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(Km,{children:r.jsx(qe,{className:"size-4"})})}),r.jsx(Zm,{children:t})]})}function RR({className:e,...t}){return r.jsx(Jm,{"data-slot":"select-scroll-up-button",className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(ql,{className:"size-4"})})}function IR({className:e,...t}){return r.jsx(Ym,{"data-slot":"select-scroll-down-button",className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(rt,{className:"size-4"})})}const PR=Te(["critical","warning","notice"]),zR=Te(["open"]),MR=Te(["proxy","tool-schema","run","group"]),ng=Te(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),OR=Te(["log","session","run","group"]),LR=Te(["anthropic","openai","unknown"]),DR=J({kind:OR,id:C(),label:C(),href:C().nullable()}),$R=J({id:C(),fingerprint:C(),severity:PR,category:ng,source:MR,status:zR,title:C(),message:C(),count:G().int().positive(),firstSeenAt:C(),lastSeenAt:C(),logIds:fe(G().int().positive()),sessionIds:fe(C()),runIds:fe(C()),groupIds:fe(C()),provider:C().nullable(),model:C().nullable(),apiFormat:LR.nullable(),evidence:fe(DR),metadata:Ke(C(),st)}),FR=J({category:ng,count:G().int().nonnegative()}),sg=J({total:G().int().nonnegative(),open:G().int().nonnegative(),critical:G().int().nonnegative(),warning:G().int().nonnegative(),notice:G().int().nonnegative(),byCategory:fe(FR)}),UR=J({alerts:fe($R),total:G().int().nonnegative(),limit:G().int().positive(),summary:sg}),BR=8e3,WR=1e4;function HR(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 VR(e,t){const n=qt(t?HR(e):null,s=>Ze(s,UR,WR));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 qR(){const e=qt("/api/alerts/summary",t=>Ze(t,sg,BR),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const zi="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",ZR=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function rg(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function GR(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function Oc(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 KR(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 JR(e){switch(e){case"critical":return"bg-red-400";case"warning":return"bg-amber-300";case"notice":return"bg-sky-300"}}function YR(e){switch(e){case"critical":return"text-red-200";case"warning":return"text-amber-100";case"notice":return"text-sky-100"}}function XR(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return r.jsx(x5,{className:"size-3.5"});case"request-timeout":case"slow-response":return r.jsx(Ow,{className:"size-3.5"});case"tool-schema":return r.jsx(bn,{className:"size-3.5"});case"group-incomplete":return r.jsx(aw,{className:"size-3.5"})}}function fl(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 _t(e){return e.toLocaleString()}function og(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 QR(e,t){const n={limit:100};return e!=="all"&&(n.severity=e),t!=="all"&&(n.category=t),n}function e6(e,t){if(t!==null){const n=e.find(s=>s.id===t);if(n!==void 0)return n}return e[0]??null}function to({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:oe("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:_t(t)})]})}function no({value:e,active:t,label:n,count:s,onClick:o}){return r.jsxs(je,{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(ze,{variant:"outline",children:_t(s)}):null]})}function t6({category:e,active:t,count:n,onClick:s}){return r.jsxs(je,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>s(e),className:"h-7 px-2",children:[XR(e),Oc(e),r.jsx(ze,{variant:"outline",children:_t(n)})]})}function n6({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(Ye,{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:oe("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:oe("size-2 rounded-full",JR(i.severity))}),r.jsx("span",{className:oe("text-xs font-semibold",YR(i.severity)),children:rg(i.severity)}),r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:Oc(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(ze,{variant:"outline",className:"shrink-0",children:["x",_t(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:og(i)}),r.jsx("span",{className:"shrink-0",children:fl(i.lastSeenAt)})]})]},i.id)})})}function s6({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(ze,{variant:"outline",children:n.label},`${n.kind}:${n.id}`):r.jsx(ze,{variant:"outline",asChild:!0,children:r.jsx("a",{href:n.href,onClick:t,children:n.label})},`${n.kind}:${n.id}`))})}function r6({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:oe("border-b px-4 py-3",KR(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(ze,{variant:"outline",children:rg(e.severity)}),r.jsx(ze,{variant:"outline",children:GR(e.source)}),r.jsx(ze,{variant:"outline",children:Oc(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(ze,{variant:"outline",className:"shrink-0",children:[_t(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(dn,{label:"Target",value:og(e)}),r.jsx(dn,{label:"Last seen",value:fl(e.lastSeenAt)}),r.jsx(dn,{label:"First seen",value:fl(e.firstSeenAt)}),r.jsx(dn,{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(s6,{alert:e,onNavigate:t})]}),r.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[r.jsx(dn,{label:"Logs",value:e.logIds.length===0?"n/a":_t(e.logIds.length)}),r.jsx(dn,{label:"Sessions",value:e.sessionIds.length===0?"n/a":_t(e.sessionIds.length)}),r.jsx(dn,{label:"Runs",value:e.runIds.length===0?"n/a":_t(e.runIds.length)}),r.jsx(dn,{label:"Groups",value:e.groupIds.length===0?"n/a":_t(e.groupIds.length)})]})]})]})}function dn({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 jd(){const[e,t]=p.useState(!1),[n,s]=p.useState("all"),[o,i]=p.useState("all"),[a,l]=p.useState(null),{summary:c,isLoading:u}=qR(),d=p.useMemo(()=>QR(n,o),[o,n]),{alerts:f,total:m,isLoading:h,error:x,mutate:g}=VR(d,e),b=p.useMemo(()=>e6(f,a),[f,a]);p.useEffect(()=>{!e||a!==null&&f.some(T=>T.id===a)||l(f[0]?.id??null)},[f,e,a]);const v=c?.total??0,y=c?.critical??0,_=c?.warning??0,j=c?.notice??0,S=y>0?"bg-red-600 text-white":_>0?"bg-amber-400 text-zinc-950":"bg-sky-400 text-zinc-950";return r.jsxs(Rn,{open:e,onOpenChange:t,children:[r.jsx(Nr,{asChild:!0,children:r.jsxs(je,{type:"button",variant:"ghost",size:"icon",className:zi,"aria-label":"Alerts",title:"Alerts",children:[r.jsx(Oa,{className:"size-4"}),u?r.jsx(Ye,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):v>0?r.jsx("span",{className:oe("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4",S),children:_t(v)}):null,r.jsx("span",{className:"sr-only",children:"Alerts"})]})}),r.jsxs(In,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[r.jsxs(Pn,{children:[r.jsxs(zn,{className:"flex items-center gap-2 pr-8",children:[r.jsx(Oa,{className:"size-5 text-red-300"}),r.jsx("span",{children:"Alerts"}),r.jsx(ze,{variant:"outline",children:_t(v)})]}),r.jsx(kc,{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(to,{label:"Open",count:c?.open??0,tone:"neutral"}),r.jsx(to,{label:"Critical",count:y,tone:"critical"}),r.jsx(to,{label:"Warning",count:_,tone:"warning"}),r.jsx(to,{label:"Notice",count:j,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(no,{value:"all",active:n==="all",label:"All",count:c?.total??null,onClick:s}),r.jsx(no,{value:"critical",active:n==="critical",label:"Critical",count:y,onClick:s}),r.jsx(no,{value:"warning",active:n==="warning",label:"Warning",count:_,onClick:s}),r.jsx(no,{value:"notice",active:n==="notice",label:"Notice",count:j,onClick:s})]}),r.jsxs(je,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{g()},children:[r.jsx(vn,{className:"size-3.5"}),"Refresh"]})]}),r.jsxs("div",{className:"flex flex-wrap gap-1",children:[r.jsx(je,{type:"button",variant:o==="all"?"secondary":"ghost",size:"sm","aria-pressed":o==="all",onClick:()=>i("all"),className:"h-7 px-2",children:"All categories"}),ZR.map(E=>{const T=c?.byCategory.find(R=>R.category===E)?.count??0;return T===0?null:r.jsx(t6,{category:E,active:o===E,count:T,onClick:i},E)})]}),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:[_t(m)," matched"]}),r.jsx("span",{children:f.length<m?`${_t(f.length)} shown`:"Latest"})]}),r.jsx(n6,{alerts:f,selectedAlertId:b?.id??null,isLoading:h,error:x,onSelect:l})]}),r.jsx(r6,{alert:b,onNavigate:()=>t(!1)})]})]})]})}const o6=12e3;function i6(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function a6(e){const t=qt(i6(e),n=>Ze(n,My,o6));return{evidenceResponse:t.data??null,isLoading:t.isLoading,error:t.error,mutate:t.mutate}}const l6=8e3;function c6(){const e=qt("/api/groups",t=>Ze(t,jp,l6));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const u6=3e3;function d6(e,t){return{id:(e?.id??0)+1,message:t.message,tone:t.tone??"error"}}function ig(){const[e,t]=p.useState(null),n=p.useCallback(o=>{t(i=>d6(i,o))},[]),s=p.useCallback(()=>{t(null)},[]);return p.useEffect(()=>{if(e===null)return;const o=window.setTimeout(()=>{t(null)},u6);return()=>{window.clearTimeout(o)}},[e]),{notice:e,showToast:n,dismissToast:s}}function ag({notice:e,onDismiss:t}){if(e===null)return null;const n=e.tone==="error",s=n?bn:za;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:oe("pointer-events-auto flex items-start gap-2 rounded-md border px-3 py-2 text-sm shadow-[0_18px_50px_rgba(0,0,0,0.45)] backdrop-blur",n?"border-red-400/30 bg-[#16090b]/95 text-red-100":"border-cyan-300/25 bg-[#071318]/95 text-cyan-100"),children:[r.jsx(s,{className:oe("mt-0.5 size-4 shrink-0",n?"text-red-300":"text-cyan-200")}),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","aria-label":"Dismiss notification",onClick:t,children:r.jsx(kr,{className:"size-3.5"})})]},e.id)})}const ha=2e4;function f6(e,t){const n=`/api/groups/${encodeURIComponent(e)}`;return t?`${n}?deleteEvidence=1`:n}function p6(e){return"/api/groups"}function lg(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 h6(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 Lc(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 Dc(e){return e??"unknown"}function m6(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 Mi(e){return e===null||e.trim().length===0?"-":e}function wt(e){return e.toLocaleString()}function pl(e){return e==null?"-":e<1e3?`${wt(e)} ms`:`${(e/1e3).toFixed(1)} s`}function Ls(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 Sd(e){return e===null?"-":Ls(e)}function g6(e){const t=JSON.stringify(e),n=t===void 0?String(e):t;return n.length<=160?n:`${n.slice(0,157)}...`}function cg(...e){for(const t of e)if(t!==null&&t.trim().length>0)return t;return"-"}function x6(...e){for(const t of e)if(t!=null&&t.trim().length>0)return t;return null}function b6(e){const t=e.provider,n=e.model;return t!==null&&t.length>0&&n!==null&&n.length>0?`${t} / ${n}`:cg(t,n)}function v6(e,t){if(t!==null){const n=e.find(s=>s.id===t);if(n!==void 0)return n}return e[0]??null}function y6(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function w6(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function _6(e,t){return t!==null&&t.group.id===e.id?t.evidence:e.evidence}function k6(e,t,n){return t!==null&&t.group.id===e.id?t.summary:n!==null&&n.group.id===e.id?n.summary:null}function j6(e,t,n){return t!==null&&t.group.id===e.id?t.jenkinsReport:n!==null&&n.group.id===e.id?n.report:null}function Cd(){const[e,t]=p.useState(!1),[n,s]=p.useState(null),[o,i]=p.useState(null),[a,l]=p.useState(null),[c,u]=p.useState(null),[d,f]=p.useState(null),[m,h]=p.useState(!1),[x,g]=p.useState(null),[b,v]=p.useState(null),[y,_]=p.useState(!1),{notice:j,showToast:S,dismissToast:E}=ig(),{groups:T,isLoading:R,error:A,mutate:z}=c6(),H=p.useMemo(()=>v6(T,n),[T,n]);p.useEffect(()=>{!e||n!==null&&T.some(F=>F.id===n)||s(T[0]?.id??null)},[T,e,n]);const N=H!==null&&c!==null&&c.group.id===H.id?c:null,{evidenceResponse:L,isLoading:w,error:$,mutate:X}=a6(H),B=p.useCallback(()=>{z()},[z]),Q=p.useCallback(async()=>{if(!(T.length===0||y)){_(!0),f(null),h(!1),v(null),l(null);try{const te=await Ze(p6(!1),wp,ha,{method:"DELETE"},F=>`Clear failed with status ${String(F.status)}`);u(null),s(null),await z(),await X(),S({message:`Cleared ${wt(te.deleted)} group${te.deleted===1?"":"s"}.`,tone:"success"})}catch(te){S({message:te instanceof Error?te.message:"Unknown error clearing groups",tone:"error"})}finally{_(!1)}}},[y,T.length,z,X,S]),D=p.useCallback(async te=>{i(te.id),l(null);try{const F=await Ze(`/api/groups/${encodeURIComponent(te.id)}/evidence`,Oy,ha,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})},ge=>`Export failed with status ${String(ge.status)}`);u(F),await z(),await X()}catch(F){l(F instanceof Error?F.message:String(F))}finally{i(null)}},[z,X]),Z=p.useCallback(te=>{f(te),h(!1),v(null)},[]),W=p.useCallback(()=>{x===null&&(f(null),h(!1),v(null))},[x]),V=p.useCallback(te=>{s(te),f(null),h(!1),v(null)},[]),ue=p.useCallback(async()=>{const te=d;if(te!==null){g(te.id),v(null);try{await Ze(f6(te.id,m),yp,ha,{method:"DELETE"},F=>`Delete failed with status ${String(F.status)}`),u(F=>F!==null&&F.group.id===te.id?null:F),s(F=>F===te.id?null:F),f(null),h(!1),await z(),await X()}catch(F){v(F instanceof Error?F.message:String(F))}finally{g(null)}}},[m,d,z,X]);return r.jsxs(Rn,{open:e,onOpenChange:t,children:[r.jsx(ag,{notice:j,onDismiss:E}),r.jsx(Nr,{asChild:!0,children:r.jsxs(je,{type:"button",variant:"ghost",size:"icon",className:zi,"aria-label":"Evaluation groups",title:"Evaluation groups",children:[r.jsx(vu,{className:"size-4"}),R?r.jsx(Ye,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):T.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:T.length}):null,r.jsx("span",{className:"sr-only",children:"Evaluation groups"})]})}),r.jsxs(In,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[r.jsx(Pn,{children:r.jsxs(zn,{className:"flex items-center gap-2 pr-8",children:[r.jsx(vu,{className:"size-5 text-muted-foreground"}),r.jsx("span",{children:"Groups"}),r.jsx(ze,{variant:"outline",children:wt(T.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(je,{type:"button",variant:"outline",size:"sm",disabled:T.length===0||y,onClick:()=>{Q()},title:"Clear all groups. Session logs and run records stay intact.",children:[y?r.jsx(Ye,{className:"size-3.5 animate-spin"}):r.jsx(yn,{className:"size-3.5"}),"Clear"]}),r.jsxs(je,{type:"button",variant:"outline",size:"sm",onClick:B,children:[r.jsx(vn,{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(S6,{groups:T,selectedGroupId:H?.id??null,isLoading:R,error:A,onSelect:V}),r.jsx(C6,{group:H,deleteTarget:d,deleteEvidence:m,exportResult:N,evidenceResponse:L,evidenceLoading:w,evidenceError:$,exportError:a,deleteError:b,exportingGroupId:o,deletingGroupId:x,onDeleteEvidenceChange:h,onExport:D,onRequestDelete:Z,onCancelDelete:W,onConfirmDelete:()=>{ue()}})]})]})]})}function S6({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=lg(i),l=t===i.id;return r.jsxs("button",{type:"button",onClick:()=>o(i.id),className:oe("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(ze,{variant:"outline",className:Lc(i.status),children:Dc(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:Ls(i.updatedAt)})]})]},i.id)})})})}function C6({group:e,deleteTarget:t,deleteEvidence:n,exportResult:s,evidenceResponse:o,evidenceLoading:i,evidenceError:a,exportError:l,deleteError:c,exportingGroupId:u,deletingGroupId:d,onDeleteEvidenceChange:f,onExport:m,onRequestDelete:h,onCancelDelete:x,onConfirmDelete:g}){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=lg(e),v=k6(e,s,o),y=j6(e,s,o),_=_6(e,s),j=h6(e,s,o),S=u===e.id,E=d===e.id,T=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(ze,{variant:"outline",className:Lc(e.status),children:Dc(e.status)}),r.jsx(ze,{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:Mi(e.project)}),r.jsxs("span",{children:["updated ",Ls(e.updatedAt)]})]})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(je,{type:"button",variant:"outline",size:"icon",className:"size-8 text-red-600 hover:text-red-700","aria-label":"Delete group",title:"Delete group",disabled:E,onClick:()=>h(e),children:E?r.jsx(Ye,{className:"size-3.5 animate-spin"}):r.jsx(yn,{className:"size-3.5"})}),r.jsxs(je,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:S||E,onClick:()=>{m(e)},children:[S?r.jsx(Ye,{className:"size-3.5 animate-spin"}):r.jsx(wr,{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}),T&&r.jsx(N6,{group:e,deleteEvidence:n,isDeleting:E,error:c,onDeleteEvidenceChange:f,onCancel:x,onConfirm:g}),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})]}),v!==null&&r.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[r.jsx(fn,{label:"Requests",value:v.requestCount}),r.jsx(fn,{label:"Errors",value:v.errorCount}),r.jsx(fn,{label:"Tokens",value:v.tokenUsage.total}),r.jsx(fn,{label:"Missing",value:v.missingSessions})]}),r.jsx(T6,{report:y,loading:i,error:a,hasEvidence:_!==null}),r.jsx(E6,{evidence:_}),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}),c!==null&&!T&&r.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:c}),r.jsx(A6,{rows:j})]})})}function N6({group:e,deleteEvidence:t,isDeleting:n,error:s,onDeleteEvidenceChange:o,onCancel:i,onConfirm:a}){const l=e.evidence!==null,c=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(yn,{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:oe("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:u=>o(u.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:c})]})]}),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(je,{type:"button",variant:"outline",size:"sm",disabled:n,onClick:i,children:"Cancel"}),r.jsxs(je,{type:"button",variant:"destructive",size:"sm",disabled:n,onClick:a,children:[n?r.jsx(Ye,{className:"size-3.5 animate-spin"}):r.jsx(yn,{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:wt(t)})]})}function T6({report:e,loading:t,error:n,hasEvidence:s}){const{copied:o,copy:i}=gn(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(Ye,{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(ze,{variant:"outline",className:m6(e.status),children:e.status})]}),r.jsx(je,{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(qe,{className:"size-3.5 text-emerald-500"}):r.jsx(Pt,{className:"size-3.5"})})]}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function E6({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:Ls(e.exportedAt)})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx(ma,{label:"JSON",value:e.jsonPath}),r.jsx(ma,{label:"Markdown",value:e.markdownPath}),r.jsx(ma,{label:"HTML",value:e.htmlPath})]})]})}function ma({label:e,value:t}){const{copied:n,copy:s}=gn(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(je,{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(qe,{className:"size-3.5 text-emerald-500"}):r.jsx(Pt,{className:"size-3.5"})})]})}function A6({rows:e}){const[t,n]=p.useState(null),s=p.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(p.Fragment,{children:[r.jsx(R6,{row:o,isExpanded:i,onToggleDetails:s}),r.jsx(I6,{row:o,isExpanded:i})]},o.member.id)})})]})})]})}function R6({row:e,isExpanded:t,onToggleDetails:n}){const s=e.member,o=e.exportMember?.session??null,i=y6(e),a=o?.inspectorPath??kf(s.sessionId),l=e.source!=="evidence",c=o?.requestCount??null,u=o?.errorCount??null,d=o?.tokenUsage.total??null,f=i?.firstChunkMs??null,m=cg(s.label,s.sessionId),h=x6(o?.clientUserAgent,i?.userAgent,s.agent),x=o?.clientProjectFolder??null,g=Sc({userAgent:h,conversationId:s.sessionId,clientProjectFolder:x}),b=Ei(g);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(je,{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(rt,{className:"size-3.5"}):r.jsx(jt,{className:"size-3.5"})}),b!==null&&r.jsx(Ai,{client:g,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(Zl,{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(ze,{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:Mi(s.agent)})]}),r.jsx("td",{className:"max-w-52 px-3 py-2",children:r.jsx("span",{className:"block whitespace-normal leading-snug",children:b6(s)})}),r.jsx("td",{className:"px-3 py-2",children:r.jsx(ze,{variant:"outline",className:Lc(s.status),children:Dc(s.status)})}),r.jsx("td",{className:"px-3 py-2 font-mono",children:c===null?"-":wt(c)}),r.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":wt(u)}),r.jsx("td",{className:"px-3 py-2 font-mono",children:pl(f)}),r.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":wt(d)})]})}function I6({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(ot,{label:"Source",value:w6(e.source)}),r.jsx(ot,{label:"Member ID",value:n.id,mono:!0}),r.jsx(ot,{label:"Session ID",value:n.sessionId,mono:!0}),r.jsx(ot,{label:"Run ID",value:i?.id??n.runId??"-",mono:!0}),r.jsx(ot,{label:"Created",value:Ls(n.addedAt)}),r.jsx(ot,{label:"Updated",value:Ls(n.updatedAt)}),r.jsx(ot,{label:"Session created",value:Sd(o?.createdAt??null)}),r.jsx(ot,{label:"Session updated",value:Sd(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(ot,{label:"Log coverage",value:o.logCoverage}),r.jsx(ot,{label:"Runtime",value:Mi(o.runtimeMode)}),r.jsx(ot,{label:"Requests",value:wt(o.requestCount),mono:!0}),r.jsx(ot,{label:"Errors",value:wt(o.errorCount),mono:!0}),r.jsx(ot,{label:"Input tokens",value:wt(o.tokenUsage.input),mono:!0}),r.jsx(ot,{label:"Output tokens",value:wt(o.tokenUsage.output),mono:!0}),r.jsx(ot,{label:"Cache read",value:wt(o.tokenUsage.cacheRead),mono:!0}),r.jsx(ot,{label:"Total tokens",value:wt(o.tokenUsage.total),mono:!0})]}),r.jsx(P6,{logs:o?.latestLogs??[]}),r.jsx(z6,{entries:a})]})})})}function ot({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:oe("truncate text-xs text-foreground",n?"font-mono":""),title:t,children:t})]})}function P6({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:[Mi(n.model)," · ",n.apiFormat," · ",n.path]}),r.jsx("span",{className:"font-mono text-muted-foreground",children:pl(n.firstChunkMs)}),r.jsx("span",{className:"font-mono text-muted-foreground",children:pl(n.latencyMs)})]},n.id)})})]})}function z6({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=g6(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 M6=J({name:C(),apiKey:C(),format:Te(["anthropic","openai"]),anthropicBaseUrl:C(),openaiBaseUrl:C(),openaiResponsesBaseUrl:C().optional().default(""),models:fe(C()),sourceTool:Te(["claude-code","opencode","mimo-code"]),alreadyExists:Le()}),O6=J({providers:fe(M6),warnings:fe(C()).optional()}),L6=J({success:Le().optional(),imported:G().optional(),message:C().optional(),errors:fe(C()).optional()}),Nd=2e4;function D6({open:e,onOpenChange:t,onImportComplete:n}){const[s,o]=p.useState(!1),[i,a]=p.useState(null),[l,c]=p.useState([]),[u,d]=p.useState([]),[f,m]=p.useState(new Set),[h,x]=p.useState(!1),[g,b]=p.useState(null),[v,y]=p.useState(null),_=p.useRef(0),j=p.useRef(0),S=p.useCallback(()=>{const A=_.current+1;_.current=A,o(!0),a(null),d([]),c([]),m(new Set),b(null),y(null),Ze("/api/providers/scan",O6,Nd,void 0,z=>`Scan failed (${String(z.status)})`).then(z=>{if(_.current!==A)return;c(z.providers),d(z.warnings??[]);const H=new Set;z.providers.forEach((N,L)=>{N.alreadyExists||H.add(L)}),m(H)}).catch(z=>{_.current===A&&a(z instanceof Error?z.message:String(z))}).finally(()=>{_.current===A&&o(!1)})},[]);p.useEffect(()=>{e&&S()},[e,S]),p.useEffect(()=>{e||(_.current+=1,j.current+=1,o(!1),x(!1))},[e]);const E=p.useCallback(A=>{m(z=>{const H=new Set(z);return H.has(A)?H.delete(A):H.add(A),H})},[]),T=p.useCallback(()=>{const A=l.filter((L,w)=>f.has(w));if(A.length===0)return;const z=j.current+1;j.current=z,x(!0),y(null),b(null);const H=new Date().toISOString(),N=A.map(L=>({id:window.crypto.randomUUID(),name:L.name,apiKey:L.apiKey,format:L.format,anthropicBaseUrl:L.anthropicBaseUrl,openaiBaseUrl:L.openaiBaseUrl,openaiResponsesBaseUrl:L.openaiResponsesBaseUrl,models:L.models,createdAt:H,updatedAt:H}));Ze("/api/providers/import",L6,Nd,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providers:N})},L=>`Import failed (${String(L.status)})`).then(L=>{j.current===z&&(c(w=>w.map(($,X)=>f.has(X)?{...$,alreadyExists:!0}:$)),m(new Set),L.errors!==void 0&&L.errors.length>0&&L.message!==void 0?b(L.message):b(`Imported ${L.imported??A.length} provider(s)`),n())}).catch(L=>{j.current===z&&y(L instanceof Error?L.message:String(L))}).finally(()=>{j.current===z&&x(!1)})},[l,f,n]),R=l.some(A=>!A.alreadyExists);return r.jsx(Rn,{open:e,onOpenChange:t,children:r.jsxs(In,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[r.jsxs(Pn,{children:[r.jsx(zn,{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(Ye,{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(As,{className:"size-4"}),i]}),!s&&i===null&&l.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&&l.map((A,z)=>r.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${A.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!A.alreadyExists&&r.jsx("input",{type:"checkbox",checked:f.has(z),disabled:h,onChange:()=>E(z),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(Ai,{client:A.sourceTool,className:"size-7 rounded-[8px]"}),A.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:[A.models.slice(0,4).join(", "),A.models.length>4?` +${A.models.length-4} more`:""]}),r.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:A.format==="anthropic"?A.anthropicBaseUrl:A.openaiResponsesBaseUrl!==""?A.openaiResponsesBaseUrl:A.openaiBaseUrl}),r.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:A.apiKey.length>8?`${A.apiKey.slice(0,4)}••••${A.apiKey.slice(-4)}`:"••••"})]})]},`${A.sourceTool}-${A.name}`)),u.length>0&&r.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:u.map((A,z)=>r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(As,{className:"size-3"}),A]},z))}),g!==null&&r.jsx("div",{className:"text-sm text-green-500 border-t pt-2",children:g}),v!==null&&r.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:v})]}),r.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[r.jsxs(je,{variant:"outline",size:"sm",onClick:S,disabled:s,children:[r.jsx(Ye,{className:`size-3 mr-1 ${s?"animate-spin":""}`}),"Rescan"]}),r.jsxs(je,{size:"sm",onClick:T,disabled:!R||f.size===0||h,children:[r.jsx(wr,{className:"size-3 mr-1"}),h?"Importing...":`Import Selected (${f.size})`]})]})]})})}function ug(e){return e.length<=8?"••••••••":e.slice(0,4)+"••••••••"+e.slice(-4)}const dg=J({id:C().min(1),aliases:fe(C()).optional().default([]),contextWindow:G().int().positive().optional(),outputLimit:G().int().positive().optional(),sourceUrl:C().optional()}),$6=J({name:C().min(1).optional(),aliases:fe(C()).optional().default([]),baseUrls:fe(C()).optional().default([]),models:fe(dg).min(1)});J({version:G().int().positive().optional(),updatedAt:C().optional(),providers:fe($6).optional().default([]),models:fe(dg).optional().default([])});function Td(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function F6(e){const t=e.models.filter(n=>n.trim()!=="");return t.length>0?t:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function $c(e,t){const n=Td(t);return(e.modelMetadata??[]).find(o=>Td(o.model)===n)??null}function U6(e){const t=F6(e);return t.length===0?!1:t.every(n=>{const s=$c(e,n);return s!==null&&s.contextWindow!==void 0})}function B6(e,t){if(e===null)return null;for(const n of t){const s=$c(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 xr(e){return Object.prototype.hasOwnProperty.call(e,"success")}function Oi(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function Rt(e){return e!==void 0&&e!==""}function ut(e){return e!==void 0&&e.trim()!==""}function Cs(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function fg(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function pg(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 W6(e){return e.firstChunkMs!==void 0&&e.firstChunkMs!==null?Cs(e.firstChunkMs):e.latencyMs!==void 0?Cs(e.latencyMs):e.totalStreamMs!==void 0&&e.totalStreamMs!==null?Cs(e.totalStreamMs):e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?fg(e.tokensPerSecond):null}function H6(e){return Oi(e)?{tone:"quiet",label:"N/A",metric:null,hasDetails:!1}:xr(e)?e.success?{tone:"success",label:"Pass",metric:W6(e),hasDetails:!0}:{tone:"failure",label:pg(e.error?.type??"unknown"),metric:null,hasDetails:!0}:{tone:"pending",label:"Running",metric:null,hasDetails:!1}}function V6(e,t){if(t===void 0)return[];const n=[];return Rt(e.anthropicBaseUrl)&&n.push(t.anthropic),Rt(e.openaiBaseUrl)&&n.push(t.openaiChat),Rt(e.openaiResponsesBaseUrl)&&n.push(t.openaiResponses),n}function q6(e,t){const n={total:0,passed:0,failed:0,testing:0};for(const s of V6(e,t))for(const o of[s.nonStreaming,s.streaming])Oi(o)||(n.total+=1,xr(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(`
125
- `)}function pn({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 Bn({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 Wn({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 Z6({result:e}){const t=e.inputTokens!==void 0||e.outputTokens!==void 0,n=e.cacheCreationInputTokens!==void 0||e.cacheReadInputTokens!==void 0;return ut(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:[ut(e.model)&&r.jsx(Wn,{label:"Model",value:e.model}),e.latencyMs!==void 0&&r.jsx(Wn,{label:"Latency",value:Cs(e.latencyMs)}),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&r.jsx(Wn,{label:"First chunk",value:Cs(e.firstChunkMs)}),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&r.jsx(Wn,{label:"Stream total",value:Cs(e.totalStreamMs)}),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&r.jsx(Wn,{label:"Token rate",value:`${fg(e.tokensPerSecond)} tok`}),t&&r.jsx(Wn,{label:"Tokens in / out",value:`${String(e.inputTokens??0)} / ${String(e.outputTokens??0)}`}),n&&r.jsx(Wn,{label:"Cache create / read",value:`${String(e.cacheCreationInputTokens??0)} / ${String(e.cacheReadInputTokens??0)}`})]}):null}function G6({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)}${ut(t.responseStatusText)?` ${t.responseStatusText}`:""}`,l=t?.responseBody??e.rawResponse;return ut(e.error?.hint)||ut(e.error?.details)||ut(n)||o!==void 0||ut(t?.requestBody)||ut(a)||i!==void 0||ut(l)?r.jsxs("div",{className:"space-y-4 border-t border-border/70 pt-4 text-xs text-muted-foreground",children:[ut(e.error?.hint)&&r.jsx(pn,{title:"Hint",children:r.jsx("p",{className:"break-words text-foreground/80",children:e.error.hint})}),ut(e.error?.details)&&r.jsx(pn,{title:"Error details",children:r.jsx(Bn,{value:e.error.details})}),ut(n)&&r.jsx(pn,{title:"Request",children:r.jsx(Bn,{value:`${s} ${n}`})}),o!==void 0&&r.jsx(pn,{title:"Request headers",children:r.jsx(Bn,{value:o})}),ut(t?.requestBody)&&r.jsx(pn,{title:"Request body",children:r.jsx(Bn,{value:t.requestBody})}),ut(a)&&r.jsx(pn,{title:"Response status",children:r.jsx(Bn,{value:a})}),i!==void 0&&r.jsx(pn,{title:"Response headers",children:r.jsx(Bn,{value:i})}),ut(l)&&r.jsx(pn,{title:"Response body",children:r.jsx(Bn,{value:l})})]}):null}function K6({result:e,probeLabel:t,children:n}){const s=e.error?.message??"Connection failed";return r.jsxs(Rn,{children:[r.jsx(Nr,{asChild:!0,children:n}),r.jsxs(In,{className:"max-h-[82vh] max-w-2xl gap-0 overflow-hidden p-0",children:[r.jsxs(Pn,{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(ii,{className:"size-4 text-cyan-300"}):r.jsx(As,{className:"size-4 text-red-300"}),r.jsx(zn,{className:"text-base",children:t})]}),r.jsx(kc,{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:pg(e.error?.type??"unknown")}),r.jsx("div",{className:"mt-1 break-words text-xs text-muted-foreground",children:s})]}),r.jsx(Z6,{result:e}),r.jsx(G6,{result:e})]})]})]})}function J6(e){const t="size-3 shrink-0";switch(e){case"timeout":return r.jsx(tn,{className:t});case"network_unreachable":return r.jsx(A5,{className:t});case"connection_refused":return r.jsx(I5,{className:t});case"auth_failed":return r.jsx(C_,{className:t});case"rate_limited":return r.jsx(Kl,{className:t});case"server_error":return r.jsx(p5,{className:t});case"invalid_response":return r.jsx(Rw,{className:t});case"unknown":return r.jsx(As,{className:t})}}const Y6={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 Ad({result:e,probeLabel:t}){const n=H6(e),s=Oi(e)?r.jsx(Pp,{className:"size-3 shrink-0"}):xr(e)?e.success?r.jsx(ii,{className:"size-3 shrink-0"}):J6(e.error?.type??"unknown"):r.jsx(Ao,{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=oe("inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors",Y6[n.tone]);return xr(e)&&n.hasDetails?r.jsx(K6,{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 Rd({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(Pp,{className:"size-3 shrink-0"}),r.jsx("span",{className:"truncate",children:e})]})}function ga({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(Ad,{result:t.nonStreaming,probeLabel:`${e} non-stream`}):r.jsx(Rd,{label:n?"Not tested":"Off"}),n&&t!==void 0?r.jsx(Ad,{result:t.streaming,probeLabel:`${e} stream`}):r.jsx(Rd,{label:n?"Not tested":"Off"})]})}function hg({provider:e,results:t}){const n=Rt(e.anthropicBaseUrl),s=Rt(e.openaiBaseUrl),o=Rt(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(ga,{label:"Anthropic",results:t?.anthropic}),s&&r.jsx(ga,{label:"OpenAI Chat",results:t?.openaiChat}),r.jsx(ga,{label:"OpenAI Responses",results:t?.openaiResponses,configured:o})]})})}function X6(e){const t={total:0,passed:0,failed:0,testing:0};for(const n of[e.nonStreaming,e.streaming])Oi(n)||(t.total+=1,xr(n)?n.success?t.passed+=1:t.failed+=1:t.testing+=1);return t}function xa({label:e,results:t}){const n=X6(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:oe("rounded border px-1.5 py-0.5 text-[10px]",s),children:[e," ",o]})}function Q6({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(rt,{className:"size-3.5 shrink-0 text-muted-foreground"}):r.jsx(jt,{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:[Rt(e.anthropicBaseUrl)&&r.jsx(xa,{label:"A",results:n.anthropic}),Rt(e.openaiBaseUrl)&&r.jsx(xa,{label:"Chat",results:n.openaiChat}),Rt(e.openaiResponsesBaseUrl)&&r.jsx(xa,{label:"Resp",results:n.openaiResponses})]})]}),s&&r.jsx("div",{className:"px-2 pb-3",children:r.jsx(hg,{provider:e,results:n})})]})}function eI({provider:e,testResults:t}){const n=Object.entries(t.models??{}),[s,o]=p.useState(!1),[i,a]=p.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(rt,{className:"size-3.5"}):r.jsx(jt,{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,c])=>r.jsx(Q6,{provider:e,modelName:l,results:c,expanded:i===l,onToggle:()=>a(u=>u===l?null:l)},l))})]})}function tI({provider:e,testResults:t,isTesting:n}){const s=Rt(e.anthropicBaseUrl)||Rt(e.openaiBaseUrl)||Rt(e.openaiResponsesBaseUrl),o=q6(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(Ao,{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(As,{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(ii,{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 nI={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function ba(e){return e!==void 0&&e!==""}function va({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(ii,{className:"size-3"}),e]})}function sI({provider:e}){const t=ba(e.anthropicBaseUrl),n=ba(e.openaiBaseUrl),s=ba(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(va,{label:"Anthropic"}),n&&r.jsx(va,{label:"OpenAI Chat"}),s&&r.jsx(va,{label:"OpenAI Responses"})]})}function rI(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 oI({provider:e,model:t}){const n=$c(e,t),s=aI(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:nh(n.contextWindow)}),s!==null&&r.jsx(jn,{children:r.jsxs(dt,{children:[r.jsx(ft,{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(pt,{children:s.title})]})})]})}function iI(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 aI(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 lI({provider:e,testResults:t,isTesting:n,testingTimeLeft:s,isHighlighted:o,onEdit:i,onDelete:a,onTest:l,onRefreshMetadata:c,isRefreshingMetadata:u=!1}){const[d,f]=p.useState(!1),[m,h]=p.useState(!1),[x,g]=p.useState(!1);function b(){At(e.apiKey).then(T=>{T&&(h(!0),setTimeout(()=>h(!1),2e3))})}const v=e.apiDocsUrl??Object.entries(nI).find(([T])=>e.name.toLowerCase().includes(T))?.[1],y=U6(e),_=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",j=_?"Refresh":"Import defaults",S=n??!1,E=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}),E]}),r.jsx("div",{className:"text-xs leading-snug text-muted-foreground",children:rI(e)})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(tI,{provider:e,testResults:t,isTesting:S}),v!==void 0&&r.jsxs("a",{href:v,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(Zl,{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(sI,{provider:e}),t?.testedAt!==void 0&&r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(tn,{className:"size-3"}),iI(t.testedAt)]})]}),!y&&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(je,{type:"button",variant:"outline",size:"sm",onClick:()=>c?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:u,children:[r.jsx(Ao,{className:`size-3 ${u?"animate-spin":""}`}),j]}),!_&&r.jsx(je,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),x&&r.jsxs("div",{className:"space-y-3 border-t border-border/60 pt-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 truncate rounded bg-muted px-2 py-1 text-xs text-muted-foreground",children:d?e.apiKey:ug(e.apiKey)}),r.jsx("button",{type:"button",onClick:()=>f(T=>!T),className:"p-1 text-muted-foreground transition-colors hover:text-foreground","aria-label":d?"Hide API key":"Show API key",children:d?r.jsx(Ep,{className:"size-4"}):r.jsx(Gl,{className:"size-4"})}),r.jsx("button",{type:"button",onClick:b,className:"p-1 text-muted-foreground transition-colors hover:text-foreground","aria-label":"Copy API key",children:m?r.jsx(qe,{className:"size-4 text-cyan-300"}):r.jsx(Pt,{className:"size-4"})})]}),e.models!==void 0&&e.models.length>0&&r.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(T=>r.jsx(oI,{provider:e,model:T},T))}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:"Connection probes"}),r.jsx(hg,{provider:e,results:t})]}),t!==void 0&&r.jsx(eI,{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:()=>g(T=>!T),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":x,children:[x?r.jsx(rt,{className:"size-3"}):r.jsx(jt,{className:"size-3"}),"Details"]}),r.jsxs("div",{className:"flex gap-2",children:[l!==void 0&&r.jsxs(je,{variant:"outline",size:"sm",onClick:()=>l(e.id),className:"text-xs h-7 gap-1",disabled:S,children:[r.jsx(Ao,{className:`size-3 ${S?"animate-spin":""}`}),S?s!==void 0?`Testing (${s}s)`:"Testing...":"Test"]}),r.jsxs(je,{variant:"outline",size:"sm",onClick:()=>i(e),className:"text-xs h-7 gap-1",disabled:S,children:[r.jsx(zp,{className:"size-3"}),"Edit"]}),r.jsxs(je,{variant:"outline",size:"sm",onClick:()=>a(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:S,children:[r.jsx(yn,{className:"size-3"}),"Delete"]})]})]})]})}const Ns="/v1/chat/completions",hl="/v1/responses",cI="/v1/messages";function uI(e,t){const n=e.endsWith("/")?e.slice(0,-1):e,s=mg(t),o=t.indexOf("?"),i=o>=0?t.slice(o):"";return s!==""&&n.endsWith(s)?n+i:xg(n)&&gg(t)||n.endsWith("/v1")&&t.startsWith("/v1/")?n+t.slice(3):n+t}function dI(e,t,n={}){const s=e.trim().replace(/\/+$/,""),o=mg(t),i=uI(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."}):xg(s)&&gg(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."}),Id(o)&&pI(s)&&a.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),fI(o)&&hI(s)&&a.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),Id(o)&&mI(s,n.providerName)&&a.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:i,diagnostics:a}}function mg(e){return e.split("?")[0]??e}function gg(e){return e===Ns||e.startsWith(`${Ns}?`)||e.startsWith(`${Ns}/`)}function fI(e){return e===Ns||e.startsWith(`${Ns}/`)}function Id(e){return e===hl||e.startsWith(`${hl}/`)}function pI(e){return e.toLowerCase().endsWith("/chat/completions")}function hI(e){return e.toLowerCase().endsWith("/responses")}function mI(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 xg(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}}const Pd=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],zd=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],so=cI,ro=Ns,oo=hl,gI={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"}},Md=["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"],Od=["qwen3.6-plus","qwen3.7-max"],Ld=["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"],ml="__unset__",qo="__custom__",bg=[{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 Hn(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function Dd(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function vg(e,t){const n=Dd(t);return e?.modelMetadata?.find(s=>Dd(s.model)===n)??null}function yg(e){const t=Io(e);if(t===null)return null;for(const n of bg)if(Io(n.value)===t)return n.value;return null}function xI(e){return e.trim()===""?"unset":yg(e)!==null?"preset":"custom"}function bI(e){switch(e.contextWindowMode){case"unset":return ml;case"custom":return qo;case"preset":return yg(e.contextWindow)??qo}}function ya(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 $d(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=vg(e,n),o=s?.contextWindow!==void 0?Yk(s.contextWindow):"";return{contextWindow:o,contextWindowMode:xI(o),outputLimit:s?.outputLimit?.toString()??""}})}function Ud(e){const t=e.trim();if(t==="")return null;const n=Number(t);return!Number.isInteger(n)||n<=0?null:n}function ms(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 vI(e,t,n){const s=e.trim();return s===""?null:dI(s,t,{providerName:n})}function wa({baseUrl:e,endpoint:t,providerName:n}){const s=vI(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 yI({provider:e,onSubmit:t,onCancel:n}){const[s,o]=p.useState(e?.name??""),[i,a]=p.useState(e?.apiKey??""),[l,c]=p.useState(!1),[u,d]=p.useState(!1),f=e?.models,[m,h]=p.useState(f!==void 0&&f.length>0?f:[""]),[x,g]=p.useState(()=>Fd(e,f!==void 0&&f.length>0?f:[""])),[b,v]=p.useState("anthropic"),[y,_]=p.useState(ms(e?.anthropicBaseUrl,so)),[j,S]=p.useState(ms(e?.openaiBaseUrl,ro)),[E,T]=p.useState(ms(e?.openaiResponsesBaseUrl,oo)),[R,A]=p.useState(e?.apiDocsUrl??""),[z,H]=p.useState(e?.modelMetadataUrl??""),[N,L]=p.useState(e?.source),[w,$]=p.useState({}),[X,B]=p.useState(!1),[Q,D]=p.useState(null),Z=p.useRef([]);p.useEffect(()=>{if(Q===null)return;const I=Q;function O(Y){if(!(Y.target instanceof Node))return;const ie=Z.current[I];ie!=null&&!ie.contains(Y.target)&&D(null)}return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[Q]);const[W,V]=p.useState(!1),[ue,te]=p.useState(!1),[F,ge]=p.useState(!1),de=s.toLowerCase().includes("minimax"),pe=s.toLowerCase().includes("alibaba"),me=[...Pd,...zd].some(I=>s.toLowerCase().includes(I)),ve=de?Md:me?Ld:pe?Od:[],xe=e?.modelMetadata?.some(I=>I.contextWindow!==void 0)??!1;function Ce(){At(i).then(I=>{I&&(d(!0),setTimeout(()=>d(!1),2e3))})}p.useEffect(()=>{if(e){o(e.name),a(e.apiKey);const I=(e.models?.length??0)>0?e.models:[""];h(I),g(Fd(e,I)),_(ms(e.anthropicBaseUrl,so)),S(ms(e.openaiBaseUrl,ro)),T(ms(e.openaiResponsesBaseUrl,oo)),A(e.apiDocsUrl??""),H(e.modelMetadataUrl??""),L(e.source),V(!1),te(!1),ge(!1)}},[e]),p.useEffect(()=>{const I=s.toLowerCase();for(const[O,Y]of Object.entries(gI))if(I.includes(O)){Y.anthropicBaseUrl!==void 0&&!W&&_(Y.anthropicBaseUrl),Y.openaiBaseUrl!==void 0&&!ue&&S(Y.openaiBaseUrl),Y.openaiResponsesBaseUrl!==void 0&&!F&&T(Y.openaiResponsesBaseUrl),Y.apiDocsUrl!==void 0&&!R&&A(Y.apiDocsUrl),O==="minimax"&&m.length===1&&m[0]===""&&h([Md[0]??""]),O==="alibaba"&&m.length===1&&m[0]===""&&h([Od[0]??""]),(Pd.includes(O)||zd.includes(O))&&m.length===1&&m[0]===""&&h([Ld[0]??""]);break}},[s]);function Ae(){const I={};return s.trim()||(I.name="Name is required"),i.trim()||(I.apiKey="API key is required"),(m.length===0||m.every(O=>!O.trim()))&&(I.models="At least one model is required"),y.trim()&&!k(y.trim())&&(I.anthropicBaseUrl="Invalid URL format"),j.trim()&&!k(j.trim())&&(I.openaiBaseUrl="Invalid URL format"),E.trim()&&!k(E.trim())&&(I.openaiResponsesBaseUrl="Invalid URL format"),z.trim()&&!k(z.trim())&&(I.modelMetadataUrl="Invalid URL format"),x.forEach((O,Y)=>{const ie=Io(O.contextWindow),le=Ud(O.outputLimit);O.contextWindow.trim()!==""&&ie===null&&(I[`modelMetadata.${Y}.contextWindow`]="Context window must be a positive number, optionally using K or M"),O.outputLimit.trim()!==""&&le===null&&(I[`modelMetadata.${Y}.outputLimit`]="Output limit must be a positive integer"),ie!==null&&le!==null&&le>ie&&(I[`modelMetadata.${Y}.outputLimit`]="Output limit should not exceed context window")}),!y.trim()&&!j.trim()&&!E.trim()&&(I.format="At least one format URL (Anthropic or OpenAI) is required"),$(I),Object.keys(I).length===0}function k(I){try{return new URL(I),!0}catch{return!1}}function ee(I,O){h(Y=>{const ie=[...Y];return ie[I]=O,ie})}function K(I,O){g(Y=>{const ie=[...Y];return ie[I]={...ie[I]??Hn(),...O},ie})}function M(I,O){switch(O){case ml:K(I,{contextWindow:"",contextWindowMode:"unset"});return;case qo:{const Y=x[I]??Hn();K(I,{contextWindow:Y.contextWindow,contextWindowMode:"custom"});return}default:K(I,{contextWindow:O,contextWindowMode:"preset"});return}}function P(I,O){const Y=x[I]??Hn(),ie=ya(Y.contextWindow);K(I,{contextWindow:$d(O,ie.unit),contextWindowMode:"custom"})}function U(I,O){const Y=x[I]??Hn(),ie=ya(Y.contextWindow);switch(O){case"K":case"M":case"tokens":K(I,{contextWindow:$d(ie.amount,O),contextWindowMode:"custom"});return;default:return}}function re(I){h(O=>O.filter((Y,ie)=>ie!==I)),g(O=>O.filter((Y,ie)=>ie!==I))}function se(){h(I=>[...I,""]),g(I=>[...I,Hn()])}function q(){const I=new Date().toISOString(),O=[];return m.forEach((Y,ie)=>{const le=Y.trim();if(le==="")return;const _e=x[ie]??Hn(),be=Io(_e.contextWindow),he=Ud(_e.outputLimit);if(be===null&&he===null)return;const Oe=vg(e,le);if(Oe!==null&&Oe.contextWindow===(be??void 0)&&Oe.outputLimit===(he??void 0)){O.push({...Oe,model:le});return}const Re={model:le,source:"manual",updatedAt:I};be!==null&&(Re.contextWindow=be),he!==null&&(Re.outputLimit=he),O.push(Re)}),O.length>0?O:e?.modelMetadata!==void 0?[]:void 0}function ae(I){if(I.preventDefault(),!!Ae()){B(!0);try{t({name:s.trim(),apiKey:i.trim(),models:m.map(O=>O.trim()).filter(O=>O!==""),anthropicBaseUrl:y.trim()||void 0,openaiBaseUrl:j.trim()||void 0,openaiResponsesBaseUrl:E.trim()||void 0,apiDocsUrl:R.trim()||void 0,modelMetadataUrl:z.trim()||void 0,modelMetadata:q(),source:N})}finally{B(!1)}}}return r.jsxs("form",{onSubmit:ae,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:s,onChange:I=>o(I.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"}),w.name!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:w.name})]}),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:N??"",onChange:I=>L(I.target.value==="company"||I.target.value==="personal"?I.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:z,onChange:I=>H(I.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"}),w.modelMetadataUrl!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:w.modelMetadataUrl}),z.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&&!xe&&z.trim()===""&&r.jsx("p",{className:"text-xs text-amber-400",children:"This provider has no matching context metadata yet."}),z.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 ",r.jsx("span",{className:"text-destructive",children:"*"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{id:"provider-apikey",type:"text",value:l||i.length===0?i:ug(i),onChange:I=>a(I.target.value),onFocus:()=>{!l&&i.length>0&&c(!0)},placeholder:"sk-ant-...",readOnly:!l&&i.length>0,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:()=>c(I=>!I),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":l?"Hide API key":"Show API key",children:l?r.jsx(Ep,{className:"size-4"}):r.jsx(Gl,{className:"size-4"})}),r.jsx("button",{type:"button",onClick:Ce,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:u?r.jsx(qe,{className:"size-4 text-cyan-300"}):r.jsx(Pt,{className:"size-4"})})]}),w.apiKey!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:w.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:"*"})]}),m.map((I,O)=>{const Y=x[O]??Hn(),ie=w[`modelMetadata.${O}.contextWindow`],le=w[`modelMetadata.${O}.outputLimit`],_e=bI(Y),be=ya(Y.contextWindow);return r.jsxs("div",{ref:he=>{Z.current[O]=he},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:I,onChange:he=>ee(O,he.target.value),placeholder:ve.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"}),ve.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>D(Q===O?null:O),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(rt,{className:"size-4"})}),Q===O&&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:ve.map(he=>r.jsx("button",{type:"button",onClick:()=>{ee(O,he),D(null)},className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-white/[0.06]",children:he},he))})]})]}),m.length>1&&r.jsx("button",{type:"button",onClick:()=>re(O),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(Xn,{value:_e,onValueChange:he=>M(O,he),children:[r.jsx(Qn,{size:"sm",className:"w-full bg-background font-mono text-xs",children:r.jsx(Os,{})}),r.jsxs(es,{className:"max-h-64",children:[r.jsx(Qe,{value:ml,children:"Not set"}),bg.map(he=>r.jsxs(Qe,{value:he.value,children:[he.label," · ",he.value]},he.value)),r.jsx(Qe,{value:qo,children:"Custom"})]})]}),Y.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:be.amount,onChange:he=>P(O,he.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(Xn,{value:be.unit,onValueChange:he=>U(O,he),children:[r.jsx(Qn,{size:"sm",className:"w-full bg-background font-mono text-xs",children:r.jsx(Os,{})}),r.jsxs(es,{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:Y.outputLimit,onChange:he=>K(O,{outputLimit:he.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]"}),le!==void 0&&r.jsx("span",{className:"block text-destructive",children:le})]})]})]},O)}),r.jsx("button",{type:"button",onClick:se,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),w.models!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:w.models})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"border border-border bg-muted/40 flex gap-1 rounded-[8px] p-1",children:[r.jsx(jn,{children:r.jsxs(dt,{children:[r.jsx(ft,{asChild:!0,children:r.jsx("button",{type:"button",onClick:()=>v("anthropic"),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${b==="anthropic"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Anthropic Format"})}),r.jsx(pt,{children:"Anthropic Messages API format"})]})}),r.jsx(jn,{children:r.jsxs(dt,{children:[r.jsx(ft,{asChild:!0,children:r.jsx("button",{type:"button",onClick:()=>v("openai"),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${b==="openai"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"OpenAI Format"})}),r.jsx(pt,{children:"OpenAI Chat Completions API format"})]})})]}),w.format!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:w.format})]}),b==="anthropic"&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:"Anthropic Base URL"}),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:y,onChange:I=>{V(!0),_(I.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:so})]}),w.anthropicBaseUrl!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:w.anthropicBaseUrl}),r.jsx(wa,{baseUrl:y,endpoint:so,providerName:s}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Anthropic-compatible base URL. Leave empty if this provider does not support Anthropic format."})]}),b==="openai"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:"OpenAI Chat Base URL"}),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:j,onChange:I=>{te(!0),S(I.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:ro})]}),w.openaiBaseUrl!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:w.openaiBaseUrl}),r.jsx(wa,{baseUrl:j,endpoint:ro,providerName:s}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"OpenAI Chat Completions-compatible base URL. Leave empty if this provider only supports the Responses API."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{htmlFor:"provider-openai-responses-base-url",className:"text-sm font-medium",children:"OpenAI Responses Base URL"}),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:E,onChange:I=>{ge(!0),T(I.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:oo})]}),w.openaiResponsesBaseUrl!==void 0&&r.jsx("p",{className:"text-xs text-destructive",children:w.openaiResponsesBaseUrl}),r.jsx(wa,{baseUrl:E,endpoint:oo,providerName:s}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional Responses-compatible base URL. Set only when the provider supports the Responses API."})]})]}),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:R,onChange:I=>A(I.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(je,{type:"button",variant:"outline",onClick:n,disabled:X,children:"Cancel"}),r.jsx(je,{type:"submit",disabled:X,children:X?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const wI=Te(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),_I=J({message:C(),type:wI,details:C().optional(),hint:C().optional()}),kI=J({type:Te(["text","thinking"]),text:C().optional(),thinking:C().optional()}),jI=J({requestUrl:C().optional(),requestMethod:C().optional(),requestHeaders:Ke(C(),C()).optional(),requestBody:C().optional(),responseStatus:G().optional(),responseStatusText:C().optional(),responseHeaders:Ke(C(),C()).optional(),responseBody:C().optional()}),SI=J({success:Le(),error:_I.optional(),model:C().optional(),inputTokens:G().optional(),outputTokens:G().optional(),cacheCreationInputTokens:G().optional(),cacheReadInputTokens:G().optional(),latencyMs:G().optional(),firstChunkMs:G().nullable().optional(),totalStreamMs:G().nullable().optional(),tokensPerSecond:G().nullable().optional(),content:fe(kI).optional(),rawResponse:C().optional(),streaming:Le().optional(),streamingChunks:J({chunks:fe(np),truncated:Le().default(!1)}).optional(),requestHeaders:Ke(C(),C()).optional(),debug:jI.optional()}),Bd=Jt([SI,J({notConfigured:Ee(!0)}),J({testing:Ee(!0)})]),xn=J({nonStreaming:Bd,streaming:Bd});function Zo(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const CI=J({anthropic:xn,openai:xn.optional(),openaiChat:xn.optional(),openaiResponses:xn.optional()}).transform(e=>{const t=e.openaiChat??e.openai??Zo();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??Zo()}}),NI=J({anthropic:xn,openai:xn.optional(),openaiChat:xn.optional(),openaiResponses:xn.optional(),models:Ke(C(),CI).optional(),testedAt:C().optional()}).transform(e=>{const t=e.openaiChat??e.openai??Zo();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??Zo()}});function TI(){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 Wd(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 EI=J({providerConfig:C()}),AI=J({success:Le().optional(),imported:G().optional(),message:C().optional(),errors:fe(C()).optional()}),RI=J({provider:Po,imported:G(),matchedModels:fe(C()),missingModels:fe(C()),sourceUrl:C()}),io="Network error: could not reach the server. Is the proxy running?",II=5e3,PI=5e3,Hd=15e3,zI=1e4,MI=2e4,OI=2e4,LI=3e4;function Vd(e){return{name:e.name,apiKey:e.apiKey,models:e.models,anthropicBaseUrl:(e.anthropicBaseUrl?.length??0)>0?e.anthropicBaseUrl:void 0,openaiBaseUrl:(e.openaiBaseUrl?.length??0)>0?e.openaiBaseUrl:void 0,openaiResponsesBaseUrl:(e.openaiResponsesBaseUrl?.length??0)>0?e.openaiResponsesBaseUrl:void 0,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 DI(e,t){const n=e?.models?.map(s=>s.trim()).filter(s=>s!=="").length??0;return Math.max(1,n)*t}async function $I(e,t){if(t.models!==void 0)try{await Zn(`/api/providers/${e}/test/log`,PI,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function FI({externalProviders:e,isLoading:t=!1,externalTestResults:n,externalTestingProviders:s,externalTestingTimeLeft:o,onProvidersMutate:i,onTestResultsChange:a,onTestingProvidersChange:l,onTestingTimeLeftChange:c}){const[u,d]=p.useState(!1),[f,m]=p.useState(),[h,x]=p.useState(null),[g,b]=p.useState({}),[v,y]=p.useState(new Set),[_,j]=p.useState({}),[S,E]=p.useState(null),[T,R]=p.useState(!1),[A,z]=p.useState(null),[H,N]=p.useState(!1),[L,w]=p.useState(!1),[$,X]=p.useState(null),[B,Q]=p.useState("all"),[D,Z]=p.useState(new Set),{providerTestTimeoutSeconds:W}=Hl(),V=p.useRef(null),ue=p.useRef(null),te=e??[],F=p.useMemo(()=>{const I=B==="all"?te:te.filter(O=>O.source===B);return B==="all"?[...I].sort((O,Y)=>{const ie={personal:0,company:1};return(ie[O.source??""]??2)-(ie[Y.source??""]??2)}):I},[te,B]),ge=n??g,de=s??v,pe=o??_,me=c?(I,O)=>c(I,O):(I,O)=>{j(O===void 0?Y=>{const ie={...Y};return delete ie[I],ie}:Y=>({...Y,[I]:O}))};p.useEffect(()=>{(async()=>{try{const I=await Ze("/api/config/paths",EI,II);E(I.providerConfig)}catch{}})()},[]);const ve=p.useCallback(I=>{ue.current!==null&&clearTimeout(ue.current),z(I),V.current?.scrollTo({top:V.current.scrollHeight,behavior:"smooth"}),ue.current=setTimeout(()=>{z(null),ue.current=null},2e3)},[]);p.useEffect(()=>()=>{ue.current!==null&&clearTimeout(ue.current)},[]);const xe=p.useCallback(()=>{i?.().catch(()=>{})},[i]),Ce=p.useCallback((I,O)=>{a?a(I,O):b(Y=>({...Y,[I]:O}))},[a]),Ae=p.useCallback((I,O)=>{if(l){l(I,O);return}y(Y=>{const ie=new Set(Y);return O?ie.add(I):ie.delete(I),ie})},[l]),k=p.useCallback(async I=>{Ce(I,TI()),Ae(I,!0);const O=new AbortController,Y=te.find(be=>be.id===I),ie=DI(Y,W);let le=ie;me(I,le);const _e=setInterval(()=>{le--,me(I,le),le<=0&&(clearInterval(_e),O.abort())},1e3);try{const be=await Ze(`/api/providers/${I}/test`,NI,ie*1e3+1e3,{method:"POST",signal:O.signal},he=>`HTTP ${he.status}: ${he.statusText}`);Ce(I,be),await $I(I,be)}catch(be){const he=be instanceof Error&&be.name==="AbortError",Oe=be instanceof ri;he||Oe?Ce(I,Wd("Request timed out","timeout")):be instanceof Error&&Ce(I,Wd(be.message,"server_error"))}finally{clearInterval(_e),me(I,void 0),Ae(I,!1)}},[W,te,me,Ce,Ae]),ee=p.useCallback(async(I,O,Y=!0)=>{Z(ie=>{const le=new Set(ie);return le.add(I),le});try{const ie=O!==void 0&&O.trim()!==""?{url:O}:{},le=await Ze(`/api/providers/${I}/model-metadata`,RI,LI,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie)},()=>"Failed to refresh model metadata");return le.imported===0&&Y?x("No matching model metadata found for this provider."):x(null),ve(le.provider.id),xe(),le.imported>0}catch(ie){return Y&&x(ie instanceof Error?ie.message:io),!1}finally{Z(ie=>{const le=new Set(ie);return le.delete(I),le})}},[xe,ve]);function K(I){(async()=>{try{const O=await Ze("/api/providers",Po,Hd,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Vd(I))},()=>"Failed to add provider");d(!1),ve(O.id),I.modelMetadataUrl!==void 0&&I.modelMetadataUrl.trim()!==""&&await ee(O.id,I.modelMetadataUrl,!1),xe(),await k(O.id)}catch(O){x(O instanceof Error?O.message:io)}})()}function M(I){f&&(async()=>{try{const O=await Ze(`/api/providers/${f.id}`,Po,Hd,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Vd(I))},()=>"Failed to update provider");m(void 0),ve(O.id),I.modelMetadataUrl!==void 0&&I.modelMetadataUrl.trim()!==""&&await ee(O.id,I.modelMetadataUrl,!1),xe(),((I.apiKey??"")!==(f.apiKey??"")||JSON.stringify(I.models)!==JSON.stringify(f.models)||(I.anthropicBaseUrl??"")!==(f.anthropicBaseUrl??"")||(I.openaiBaseUrl??"")!==(f.openaiBaseUrl??"")||(I.openaiResponsesBaseUrl??"")!==(f.openaiResponsesBaseUrl??""))&&await k(O.id)}catch(O){x(O instanceof Error?O.message:io)}})()}function P(I){X(I),w(!0)}function U(){const I=$;I!==null&&(async()=>{let O;try{O=await Zn(`/api/providers/${I}`,zI,{method:"DELETE"})}catch{x(io);return}if(!O.ok){x(await Ml(O,"Failed to delete provider"));return}xe()})()}const re=p.useRef(null);function se(I){const O="/api/providers/export";(async()=>{try{const Y=await Zn(O,MI);if(!Y.ok){x("Failed to export providers");return}const ie=await Y.blob(),le=URL.createObjectURL(ie),_e=document.createElement("a");_e.href=le,_e.download=Y.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(_e),_e.click(),document.body.removeChild(_e),URL.revokeObjectURL(le)}catch{x("Failed to export providers")}})()}function q(){re.current?.click()}function ae(I){const O=I.target.files?.[0];O&&(async()=>{try{const Y=await O.text(),ie=await Zn("/api/providers/import",OI,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Y)}),le=await zl(ie,AI);ie.ok&&le.imported!==void 0&&le.imported>0?(xe(),x(null)):le.errors&&le.errors.length>0?x(le.errors.join("; ")):x(le.message??"Import failed")}catch{x("Failed to import providers")}I.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..."})}):u||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(yI,{provider:f,onSubmit:f?M:K,onCancel:()=>{d(!1),m(void 0)}})]}):r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-end gap-2 rounded-[8px] bg-background/95 px-1 py-1 backdrop-blur",children:[r.jsxs(je,{variant:"outline",size:"sm",onClick:()=>se(),className:"gap-1 hover:bg-muted",children:[r.jsx(wr,{className:"size-3"}),"Export"]}),r.jsxs(je,{variant:"outline",size:"sm",onClick:q,className:"gap-1 hover:bg-muted",children:[r.jsx(Lp,{className:"size-3"}),"Import"]}),r.jsx("input",{type:"file",ref:re,accept:".json",onChange:ae,style:{display:"none"}}),r.jsxs(je,{variant:"outline",size:"sm",onClick:()=>N(!0),className:"gap-1",children:[r.jsx(l5,{className:"size-3"}),"Scan"]}),r.jsxs(je,{onClick:()=>d(!0),size:"sm",className:"gap-1",children:[r.jsx(Ma,{className:"size-4"}),"Add Provider"]})]}),S!==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:S,children:S}),r.jsx("button",{type:"button",onClick:()=>{At(S).then(I=>{I&&(R(!0),setTimeout(()=>R(!1),2e3))})},className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-foreground","aria-label":T?"Copied config file path":"Copy config file path",children:T?r.jsx(qe,{className:"size-3 text-cyan-300"}):r.jsx(Pt,{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(As,{className:"size-4 shrink-0"}),h]}),te.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(je,{onClick:()=>d(!0),variant:"outline",size:"sm",children:[r.jsx(Ma,{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(I=>r.jsx("button",{type:"button",onClick:()=>Q(I),className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${B===I?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:I==="all"?"All":I==="personal"?"Personal":"Company"},I))}),r.jsx("div",{ref:V,className:"space-y-3",children:F.map(I=>r.jsx(lI,{provider:I,testResults:ge[I.id],isTesting:de.has(I.id),testingTimeLeft:pe[I.id],isHighlighted:I.id===A,onEdit:O=>m(O),onDelete:P,onRefreshMetadata:O=>{ee(O)},isRefreshingMetadata:D.has(I.id),onTest:O=>{k(O)}},I.id))})]}),r.jsx(D6,{open:H,onOpenChange:N,onImportComplete:()=>{i!==void 0&&i()}}),r.jsx(k0,{open:L,onOpenChange:w,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:U})]})}function qd(){const[e,t]=p.useState(!1),[n,s]=p.useState("providers"),{providers:o,isLoading:i,mutate:a}=Xl(),[l,c]=p.useState({}),[u,d]=p.useState(new Set),[f,m]=p.useState({}),h=p.useCallback((b,v)=>{c(y=>({...y,[b]:v}))},[]),x=p.useCallback((b,v)=>{d(y=>{const _=new Set(y);return v?_.add(b):_.delete(b),_})},[]),g=p.useCallback((b,v)=>{m(y=>{if(v===void 0){const _={...y};return delete _[b],_}return{...y,[b]:v}})},[]);return r.jsxs(Rn,{open:e,onOpenChange:t,children:[r.jsx(Nr,{asChild:!0,children:r.jsxs(je,{variant:"ghost",size:"icon",className:zi,"aria-label":"Settings",title:"Settings",children:[r.jsx(m5,{className:"size-4"}),r.jsx("span",{className:"sr-only",children:"Settings"})]})}),r.jsxs(In,{className:"flex max-h-[80vh] max-w-2xl flex-col overflow-hidden",children:[r.jsx(Pn,{children:r.jsx(zn,{children:"Settings"})}),r.jsxs(B0,{value:n,onValueChange:s,className:"flex-1 overflow-hidden",children:[r.jsxs(W0,{className:"w-full justify-start bg-muted/35",children:[r.jsx(Tt,{value:"providers",children:"Providers"}),r.jsx(Tt,{value:"proxy",children:"Proxy"}),r.jsx(Tt,{value:"storage",children:"Storage"}),r.jsx(Tt,{value:"mcp",children:"MCP"}),r.jsx(Tt,{value:"onboarding",children:"Onboarding"})]}),r.jsxs("div",{className:"mt-4 flex-1 overflow-x-hidden overflow-y-auto pr-2",children:[r.jsx(Et,{value:"providers",children:r.jsx(FI,{externalProviders:o,isLoading:i,externalTestResults:l,externalTestingProviders:u,externalTestingTimeLeft:f,onProvidersMutate:()=>a(),onTestResultsChange:h,onTestingProvidersChange:x,onTestingTimeLeftChange:g})}),r.jsx(Et,{value:"proxy",children:r.jsx(qI,{})}),r.jsx(Et,{value:"storage",children:r.jsx(WI,{})}),r.jsx(Et,{value:"mcp",children:r.jsx(VI,{})}),r.jsx(Et,{value:"onboarding",children:r.jsx(HI,{})})]})]})]})]})}const UI=J({memoryCount:G(),logDir:C(),logFileCount:G(),logBytes:G(),chunkDir:C(),chunkFileCount:G(),chunkBytes:G(),sessionArchiveDir:C(),sessionArchiveFileCount:G(),sessionArchiveBytes:G()}),BI=1e4;function _a(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 WI(){const[e,t]=p.useState(null),[n,s]=p.useState(null),[o,i]=p.useState(!1),[a,l]=p.useState(null),c=p.useCallback(async()=>{i(!0),s(null);try{const d=await Ze("/api/logs?stats=1",UI,BI,void 0,f=>`Failed to load storage stats: HTTP ${String(f.status)}`);t(d)}catch(d){s(d instanceof Error?d.message:String(d))}finally{i(!1)}},[]);p.useEffect(()=>{c()},[c]);const u=p.useCallback((d,f)=>{At(f).then(m=>{m&&(l(d),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(je,{type:"button",variant:"outline",size:"sm",onClick:()=>{c()},children:o?"Refreshing...":"Refresh"})]}),e!==null&&r.jsxs("div",{className:"grid gap-2 text-xs",children:[r.jsx(nr,{id:"log-dir",label:"Log storage path",value:e.logDir,copiedId:a,onCopy:u}),r.jsx(nr,{id:"chunk-dir",label:"Streaming chunks storage path",value:e.chunkDir,copiedId:a,onCopy:u}),r.jsx(nr,{id:"session-archive-dir",label:"Session archive storage path",value:e.sessionArchiveDir,copiedId:a,onCopy:u}),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 / ",_a(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 / ",_a(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 /"," ",_a(e.sessionArchiveBytes)]})]})]}),n!==null&&r.jsx("p",{className:"text-xs text-destructive",children:n})]})}function nr({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",children:n}),r.jsx(je,{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(qe,{className:"size-3.5 text-emerald-500"}):r.jsx(Pt,{className:"size-3.5"})})]})]})}function HI(){const[e,t]=p.useState(null),n=p.useMemo(()=>typeof window>"u"?"http://localhost:9527":window.location.origin,[]),s=p.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=p.useCallback((i,a)=>{At(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(Fs,{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(nr,{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(qe,{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(qe,{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(qe,{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(qe,{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(qe,{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(qe,{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 VI(){const[e,t]=p.useState(null),s=`${p.useMemo(()=>typeof window>"u"?"http://localhost:9527":window.location.origin,[])}/api/mcp`,o=p.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:"readonly",label:"Readonly mode",value:"AGENT_INSPECTOR_MCP_READONLY=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]
126
- command = "agent-inspector-mcp"
127
- args = ["stdio", "--url", "${s}"]`}],[s]),i=p.useCallback((a,l)=>{At(l).then(c=>{c&&(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(Fs,{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(nr,{id:a.id,label:a.label,value:a.value,copiedId:e,onCopy:i},a.id))})]})}function qI(){const{strip:e,slowResponseThresholdSeconds:t,providerTestTimeoutSeconds:n,timeDisplayFormat:s,isLoading:o,setStrip:i,setSlowResponseThresholdSeconds:a,setProviderTestTimeoutSeconds:l,setTimeDisplayFormat:c}=Hl(),[u,d]=p.useState(null),[f,m]=p.useState(!1),h=p.useCallback(async v=>{d(null),m(!0);try{await i(v)}catch(y){d(y instanceof Error?y.message:String(y))}finally{m(!1)}},[i]),x=p.useCallback(async v=>{d(null),m(!0);try{await a(v)}catch(y){d(y instanceof Error?y.message:String(y))}finally{m(!1)}},[a]),g=p.useCallback(async v=>{d(null),m(!0);try{await l(v)}catch(y){d(y instanceof Error?y.message:String(y))}finally{m(!1)}},[l]),b=p.useCallback(async v=>{d(null),m(!0);try{await c(v)}catch(y){d(y instanceof Error?y.message:String(y))}finally{m(!1)}},[c]);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:v=>{h(v.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:Ia,step:1,value:t,disabled:o||f,onChange:v=>{const y=Number(v.currentTarget.value);Number.isInteger(y)&&(y<0||y>Ia||x(y))},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:Pa,step:1,value:n,disabled:o||f,onChange:v=>{const y=Number(v.currentTarget.value);Number.isInteger(y)&&(y<1||y>Pa||g(y))},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:v=>{const y=Sp.safeParse(v.currentTarget.value);y.success&&b(y.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"})]})]}),u!==null&&r.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",u]})]})}const ZI=Te(["installed","update-available","available","planned","unknown"]),GI=J({id:C(),name:C(),npmName:C(),capability:C(),description:C(),workflow:C(),installCommand:C(),state:ZI,installedVersion:C().nullable(),latestVersion:C().nullable(),primary:Le()}),KI=J({id:C(),name:C(),validatedVersion:C(),binary:C(),modelFlag:C(),variantFlag:C().nullable(),tools:fe(C()),logDir:C(),skillsDir:C(),agentsDir:C()}),JI=J({id:C(),title:C(),stage:C(),packageId:C(),description:C(),command:C(),requiresSession:Le(),runnable:Le()}),YI=J({checkedAt:C(),packages:fe(GI),runnerPresets:fe(KI),recipes:fe(JI)}),XI=Te(["install","upgrade","help","runner-presets","recipe"]),QI=Te(["queued","running","succeeded","failed"]),wg=J({id:C(),packageId:C(),npmName:C(),recipeId:C().nullable().default(null),action:XI,status:QI,command:C(),output:C(),createdAt:C(),startedAt:C().nullable(),finishedAt:C().nullable(),exitCode:G().nullable(),error:C().nullable()}),Fc=J({task:wg}),eP=J({tasks:fe(wg)}),tP=[{id:"observe",title:"Observe",label:"Live",description:"Capture IDE, process, session, turn, request, response, tools, and providers.",metric:"Inspector core",icon:Gy},{id:"replay",title:"Replay",label:"Ready",description:"Promote real logs into repeatable replay evidence without losing the raw context.",metric:"Session asset",icon:vn},{id:"evaluate",title:"Evaluate",label:"Next",description:"Use eval-harness to turn sessions into regression cases and provider bakeoffs.",metric:"Eval loop",icon:Vl},{id:"connect",title:"Connect",label:"MCP",description:"Expose Inspector state to coding agents as queryable context and durable evidence.",metric:"/api/mcp",icon:O_}];async function nP(e){return ht(e,YI,void 0,t=>`Failed to load ecosystem packages: ${String(t.status)}`)}async function sP(e){return ht(e,Fc,void 0,t=>`Failed to load ecosystem task: ${String(t.status)}`)}async function rP(e){return ht(e,eP,void 0,t=>`Failed to load ecosystem tasks: ${String(t.status)}`)}async function oP(e,t){return(await ht(`/api/ecosystem/packages/${encodeURIComponent(e)}/${t}`,Fc,{method:"POST"},s=>`Failed to start ecosystem task: ${String(s.status)}`)).task}async function iP(e){return(await ht(`/api/ecosystem/recipes/${encodeURIComponent(e)}/run`,Fc,{method:"POST"},n=>`Failed to start ecosystem recipe: ${String(n.status)}`)).task}function aP(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 lP(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 cP(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 sr(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 uP(e){switch(e.status){case"queued":return"Queued";case"running":return`${sr(e.action)} running`;case"succeeded":return`${sr(e.action)} complete`;case"failed":return`${sr(e.action)} failed`}}function _g(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 dP(e){switch(e.state){case"available":return"install";case"update-available":return"upgrade";case"installed":case"planned":case"unknown":return null}}function fP({pkg:e,activeTask:t,onStartTask:n}){const s=dP(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(F_,{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(ze,{className:oe("shrink-0",lP(e.state)),variant:"outline",children:aP(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:cP(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(je,{type:"button",size:"sm",variant:"secondary",disabled:o,onClick:()=>n(e.id,s),children:[o?r.jsx(Ye,{className:"size-3.5 animate-spin"}):r.jsx(wr,{className:"size-3.5"}),sr(s)]}),r.jsxs(je,{type:"button",size:"sm",variant:"outline",disabled:o||e.state==="planned",onClick:()=>n(e.id,"help"),children:[r.jsx(Fs,{className:"size-3.5"}),"Help"]}),e.id==="eval-harness"&&r.jsxs(je,{type:"button",size:"sm",variant:"ghost",disabled:o||e.state==="planned",onClick:()=>n(e.id,"runner-presets"),children:[r.jsx(Vl,{className:"size-3.5"}),"Presets"]})]})]})}function pP({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(Ye,{className:"size-4 animate-spin text-cyan-200/75"}):r.jsx(Fs,{className:"size-4 text-white/55"}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-semibold",children:uP(e)}),r.jsx("div",{className:"break-all font-mono text-[11px] text-white/35",children:e.command})]})]}),r.jsx(ze,{variant:"outline",className:oe("shrink-0",_g(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 hP({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 mP(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 gP({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(Mp,{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(ze,{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 xP({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(Ap,{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(ze,{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(je,{type:"button",size:"sm",variant:"outline",onClick:()=>s(e),children:[t?r.jsx(qe,{className:"size-3.5"}):r.jsx(Pt,{className:"size-3.5"}),t?"Copied":"Copy"]}),e.runnable&&r.jsxs(je,{type:"button",size:"sm",variant:"secondary",disabled:n,onClick:()=>o(e),children:[n?r.jsx(Ye,{className:"size-3.5 animate-spin"}):r.jsx(Mp,{className:"size-3.5"}),n?"Running":"Run"]})]})]})]})}function bP({task:e,selected:t,onSelect:n}){const s=e.recipeId??sr(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(Ip,{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(ze,{variant:"outline",className:oe("shrink-0",_g(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(je,{type:"button",size:"sm",variant:t?"secondary":"outline",onClick:()=>n(e),children:t?"Open":"View"})]})}function Zd({currentSessionId:e,logCount:t}){const[n,s]=p.useState(!1),[o,i]=p.useState(!1),[a,l]=p.useState(!1),[c,u]=p.useState(null),[d,f]=p.useState(null),[m,h]=p.useState(null),x=qt("/api/ecosystem/packages",nP,{revalidateOnFocus:!1,revalidateIfStale:!1}),g=qt(d===null?null:`/api/ecosystem/tasks/${d}`,sP,{refreshInterval:w=>{const $=w?.task;return $!==void 0&&($.status==="queued"||$.status==="running")?900:0},revalidateOnFocus:!1}),b=qt(n?"/api/ecosystem/tasks":null,rP,{refreshInterval:2500,revalidateOnFocus:!1}),v=x.data?.packages??[],y=x.data?.runnerPresets??[],_=x.data?.recipes??[],j=(b.data?.tasks??[]).slice(0,6),S=p.useMemo(()=>v.filter(w=>w.state==="installed"||w.state==="update-available").length,[v]),E=mP(e),T="npx @tonyclaw/eval-harness runner-presets",R=()=>{At(E).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)})},A=()=>{At(T).then(()=>{l(!0),window.setTimeout(()=>l(!1),1200)})},z=w=>{At(w.command).then(()=>{u(w.id),window.setTimeout(()=>u(null),1200)})},H=w=>{h(null),iP(w.id).then($=>{f($.id),g.mutate({task:$},{revalidate:!0}),b.mutate()}).catch($=>{h($ instanceof Error?$.message:"Failed to start ecosystem recipe")})},N=g.data?.task??null;p.useEffect(()=>{N!==null&&(b.mutate(),N.status==="succeeded"&&x.mutate())},[N,x,b]);const L=(w,$)=>{h(null),oP(w,$).then(X=>{f(X.id),g.mutate({task:X},{revalidate:!0}),b.mutate()}).catch(X=>{h(X instanceof Error?X.message:"Failed to start ecosystem task")})};return r.jsxs(Rn,{open:n,onOpenChange:s,children:[r.jsx(Nr,{asChild:!0,children:r.jsxs(je,{variant:"ghost",size:"icon",className:zi,"aria-label":"TonyClaw Lab",title:"TonyClaw Lab",children:[r.jsx(Ap,{className:"size-4"}),r.jsx("span",{className:"sr-only",children:"TonyClaw Lab"})]})}),r.jsxs(In,{className:"flex max-h-[84vh] max-w-5xl flex-col overflow-hidden",children:[r.jsx(Pn,{children:r.jsxs(zn,{className:"flex items-center gap-2",children:[r.jsx(_u,{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(ze,{variant:"outline",className:"border-cyan-300/20 bg-cyan-300/8 text-cyan-100",children:[String(S),"/",String(v.length)," packages"]})]}),r.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:tP.map(w=>r.jsx(hP,{workflow:w},w.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(ze,{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:E}),r.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[r.jsxs(je,{size:"sm",variant:"secondary",onClick:R,children:[o?r.jsx(qe,{className:"size-3.5"}):r.jsx(Pt,{className:"size-3.5"}),o?"Copied":"Copy"]}),r.jsxs(je,{size:"sm",variant:"outline",onClick:A,children:[r.jsx(Vl,{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(_u,{className:"size-3.5"}),"copy-ready workflows"]})]}),r.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[_.map(w=>r.jsx(xP,{recipe:w,copied:c===w.id,running:N!==null&&N.recipeId===w.id&&(N.status==="queued"||N.status==="running"),onCopy:z,onRun:H},w.id)),x.isLoading&&_.length===0&&[0,1].map(w=>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)]"},w))]})]}),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(Fs,{className:"size-3.5"}),T]})]}),r.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[y.map(w=>r.jsx(gP,{preset:w},w.id)),x.isLoading&&y.length===0&&[0,1,2,3].map(w=>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)]"},w))]})]}),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"}),x.isLoading&&r.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"checking npm..."})]}),x.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:[v.map(w=>r.jsx(fP,{pkg:w,activeTask:N,onStartTask:L},w.id)),x.isLoading&&v.length===0&&[0,1,2].map(w=>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)]"},w))]})]}),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}),j.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(j.length)]})]}),r.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:j.map(w=>r.jsx(bP,{task:w,selected:d===w.id,onSelect:$=>{f($.id),g.mutate({task:$},{revalidate:!0})}},w.id))})]}),r.jsx(pP,{task:N})]})]})]})}const Uc=56,br=14,Sn=18,Gd=72,vP=156,yP=45e3,wP=192,_P=68,kP=10,kg=78;function jP(e){const t=e.scale??1;return Number.isFinite(t)&&t>0?t:1}function et(e,t){return e*jP(t)}function gl(e){return Math.min(Math.max(e,0),1)}function Ar(e){const t=et(Sn,e);return Math.max(-t,e.width-et(Uc,e)+t)}function Rr(e){const t=et(Sn,e);return Math.max(-t,e.height-et(Uc,e)+t)}function Bc(e,t){const n=et(Sn,t);return{x:Math.min(Math.max(e.x,-n),Ar(t)),y:Math.min(Math.max(e.y,-n),Rr(t))}}function Wc(e,t){const n=Bc(e,t),s=et(Sn,t);return[{edge:"left",distance:n.x+s},{edge:"right",distance:Ar(t)-n.x},{edge:"top",distance:n.y+Sn},{edge:"bottom",distance:Rr(t)-n.y}].reduce((i,a)=>a.distance<i.distance?a:i).edge}function xl(e,t){const n=Bc(e,t),s=Wc(n,t),o=et(Sn,t);switch(s){case"left":return{x:-o,y:n.y};case"right":return{x:Ar(t),y:n.y};case"top":return{x:n.x,y:-o};case"bottom":return{x:n.x,y:Rr(t)}}}function SP(e,t,n){const s=Ar(e),o=Rr(e),i=et(Sn,e),a=Math.min(et(kg,e),o),l=a+gl(n)*(o-a);switch(Math.min(1,Math.floor(gl(t)*2))){case 0:return{x:-i,y:l};case 1:return{x:s,y:l};default:return{x:s,y:o}}}function CP(e,t,n,s){const o=xl(e,t),i=et(Gd,t)+gl(n)*et(vP-Gd,t),a=s>=.5?1:-1,l=Wc(o,t),c=Ar(t),u=Rr(t),d=et(Sn,t),f=Math.min(et(kg,t),u);switch(l){case"left":return{x:-d,y:Math.min(Math.max(o.y+i*a,f),u)};case"right":return{x:c,y:Math.min(Math.max(o.y+i*a,f),u)};case"top":return{x:Math.min(Math.max(o.x+i*a,-d),c),y:-d};case"bottom":return{x:Math.min(Math.max(o.x+i*a,-d),c),y:u}}}function NP(e,t){const n=Wc(e,t),s=et(Uc,t),o=et(wP,t),i=et(_P,t),a=et(kP,t),l=et(br,t);let c=e.x+s/2-o/2,u=e.y+s/2-i/2;switch(n){case"left":c=e.x+s+a;break;case"right":c=e.x-o-a;break;case"top":u=e.y+s+a;break;case"bottom":u=e.y-i-a;break}return{x:Math.min(Math.max(c,l),Math.max(l,t.width-o-l)),y:Math.min(Math.max(u,l),Math.max(l,t.height-i-l))}}function TP(e){let t=null;for(const n of e)(t===null||n.id>t.id)&&(t=n);return t}function EP(e){const t=e.responseStatus!==null&&e.responseStatus>=400,n=e.error!==null&&e.error!==void 0&&e.error!=="";return t||n}function AP(e,t){const n=e.filter(a=>a.responseStatus===null).length,s=e.length;if(n>0)return{mood:"active",label:`${String(n)} request${n===1?"":"s"} in flight`,pendingCount:n,capturedCount:s};const o=TP(e);if(o!==null&&EP(o))return{mood:"attention",label:"Latest request needs attention",pendingCount:n,capturedCount:s};if(o===null)return{mood:"idle",label:"Waiting for traffic",pendingCount:n,capturedCount:s};const i=Date.parse(o.timestamp);return Number.isFinite(i)&&t-i>=yP?{mood:"sleeping",label:"All quiet",pendingCount:n,capturedCount:s}:{mood:"idle",label:"Watching the session",pendingCount:n,capturedCount:s}}const jg="agent-inspector.pet.roaming",RP=5200,IP=2400,PP=6e3,zP=760,Kd=4;function ka(){if(typeof window>"u")return{width:1280,height:720,scale:1};const e=window.getComputedStyle(document.documentElement).getPropertyValue("--inspector-ui-scale"),t=Number.parseFloat(e),n=Number.isFinite(t)&&t>0?t:1;return{width:Math.max(window.innerWidth,br*2),height:Math.max(window.innerHeight,br*2),scale:n}}function MP(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(jg)!=="0"}catch{return!0}}function Jd(e){switch(e){case"active":return"bg-cyan-400 shadow-[0_0_9px_rgba(34,211,238,0.65)]";case"attention":return"bg-red-500 shadow-[0_0_9px_rgba(239,68,68,0.55)]";case"idle":return"bg-amber-400 shadow-[0_0_8px_rgba(251,191,36,0.45)]";case"sleeping":return"bg-muted-foreground/45"}}function OP(e){switch(e){case"active":return"inspector-pet-active";case"attention":return"inspector-pet-attention";case"idle":return"";case"sleeping":return"inspector-pet-sleeping"}}function LP({logs:e}){const[t,n]=p.useState(ka),[s,o]=p.useState({x:br,y:br}),[i,a]=p.useState(()=>Date.now()),[l,c]=p.useState(0),[u,d]=p.useState(0),[f,m]=p.useState(!1),[h,x]=p.useState(0),[g,b]=p.useState(!1),[v,y]=p.useState(!1),[_,j]=p.useState(MP),[S,E]=p.useState(!1),T=p.useRef(null),R=p.useRef(!1),A=p.useMemo(()=>AP(e,i),[i,e]),z=p.useMemo(()=>NP(s,t),[s,t]);p.useEffect(()=>{const D=ka();n(D),o(SP(D,Math.random(),Math.random()))},[]),p.useEffect(()=>{const D=window.matchMedia("(prefers-reduced-motion: reduce)"),Z=W=>E(W.matches);return E(D.matches),D.addEventListener("change",Z),()=>D.removeEventListener("change",Z)},[]),p.useEffect(()=>{const D=window.setInterval(()=>a(Date.now()),15e3);return()=>window.clearInterval(D)},[]),p.useEffect(()=>{try{window.localStorage.setItem(jg,_?"1":"0")}catch{}},[_]),p.useEffect(()=>{if(!_||v||S)return;let D=null;const Z=()=>{const W=RP+Math.random()*IP;D=window.setTimeout(()=>{c(V=>V+1),o(V=>CP(V,t,Math.random(),Math.random())),Z()},W)};return Z(),()=>{D!==null&&window.clearTimeout(D)}},[v,S,_,t]),p.useEffect(()=>{const D=()=>{const Z=ka();n(Z),o(W=>xl(W,Z))};return window.addEventListener("resize",D),()=>window.removeEventListener("resize",D)},[]),p.useEffect(()=>{if(!f)return;const D=window.setTimeout(()=>m(!1),PP);return()=>window.clearTimeout(D)},[u,f]),p.useEffect(()=>{if(!g)return;const D=window.setTimeout(()=>b(!1),zP);return()=>window.clearTimeout(D)},[h,g]);const H=p.useCallback(()=>{if(R.current){R.current=!1;return}a(Date.now()),d(D=>D+1),m(!0),x(D=>D+1),b(!0)},[]),N=p.useCallback(D=>{const Z=D.currentTarget.getBoundingClientRect();R.current=!1,T.current={pointerId:D.pointerId,offsetX:D.clientX-Z.left,offsetY:D.clientY-Z.top,startX:D.clientX,startY:D.clientY,moved:!1},D.currentTarget.setPointerCapture(D.pointerId),m(!1),y(!0)},[]),L=p.useCallback(D=>{const Z=T.current;if(Z===null||Z.pointerId!==D.pointerId)return;const W=Z.moved||Math.abs(D.clientX-Z.startX)>=Kd||Math.abs(D.clientY-Z.startY)>=Kd;Z.moved=W,R.current=W,o(Bc({x:D.clientX-Z.offsetX,y:D.clientY-Z.offsetY},t))},[t]),w=p.useCallback(D=>{const Z=T.current;Z===null||Z.pointerId!==D.pointerId||(D.currentTarget.hasPointerCapture(D.pointerId)&&D.currentTarget.releasePointerCapture(D.pointerId),R.current=Z.moved,T.current=null,y(!1),o(W=>xl(W,t)))},[t]),$=p.useCallback(D=>{D.currentTarget.hasPointerCapture(D.pointerId)&&D.currentTarget.releasePointerCapture(D.pointerId),T.current=null,R.current=!1,y(!1)},[]),X=p.useMemo(()=>({transform:`translate3d(${String(s.x)}px, ${String(s.y)}px, 0) rotate(${l%2===0?"-4deg":"5deg"}) scale(${v?"1.08":"1"})`,transition:v?"none":"transform 4800ms cubic-bezier(0.33, 1, 0.68, 1)",touchAction:"none"}),[v,l,s.x,s.y]),B=p.useMemo(()=>({left:z.x,top:z.y}),[z.x,z.y]),Q=_?"Pause pet roaming":"Resume pet roaming";return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:oe("fixed left-0 top-0 z-30 flex size-14 items-center justify-center bg-transparent text-foreground outline-none transition-[filter,opacity] duration-200 hover:opacity-95 hover:drop-shadow-[0_0_24px_rgba(245,158,11,0.36)] focus-visible:drop-shadow-[0_0_12px_rgba(251,191,36,0.72)]",v?"cursor-grabbing":"cursor-grab"),style:X,"data-pet-mood":A.mood,onClick:H,onPointerDown:N,onPointerMove:L,onPointerUp:w,onPointerCancel:$,"aria-label":`Inspector pet: ${A.label}`,title:A.label,children:r.jsxs("span",{className:oe("relative flex size-12 items-center justify-center",g&&"inspector-pet-patted"),"aria-hidden":"true",children:[r.jsx("span",{className:oe("relative flex size-12 items-center justify-center",OP(A.mood)),children:r.jsxs("span",{className:oe("relative flex size-12 items-center justify-center",!v&&"floating-crab-body"),children:[r.jsx(dl,{className:"relative z-10 size-11 text-amber-500 drop-shadow-[0_0_15px_rgba(245,158,11,0.30)]"}),r.jsx("span",{className:"pointer-events-none absolute inset-x-0 bottom-0 z-0 flex items-end justify-center gap-1 text-amber-400/80",children:[0,1,2,3,4,5].map(D=>r.jsx("span",{className:oe("floating-crab-leg h-2 w-0.5 rounded-full bg-current shadow-[0_0_7px_rgba(245,158,11,0.24)]",D<3?"floating-crab-leg-left":"floating-crab-leg-right",v&&"animate-none"),style:{animationDelay:`${String(D%2===0?0:180)}ms`}},D))})]})}),r.jsx("span",{className:oe("absolute right-0 top-1 size-2 rounded-full border border-background/90",Jd(A.mood),A.mood==="active"&&!S&&"animate-pulse")}),g&&r.jsx(v_,{className:"inspector-pet-heart absolute -right-1 -top-2 size-3.5 fill-amber-400 text-amber-400"},h)]})}),f&&r.jsxs("div",{className:"fixed z-50 w-48 rounded-md border border-border/80 bg-popover/95 px-3 py-2 text-popover-foreground shadow-[0_14px_34px_rgba(0,0,0,0.28)] backdrop-blur",style:B,role:"status","aria-live":"polite",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:oe("size-2 shrink-0 rounded-full",Jd(A.mood))}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:A.label}),r.jsx("button",{type:"button",className:"inline-flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",onClick:()=>j(D=>!D),"aria-label":Q,title:Q,children:_?r.jsx(q_,{className:"size-3.5"}):r.jsx(K_,{className:"size-3.5"})})]}),r.jsxs("div",{className:"mt-1 flex items-center justify-between gap-3 font-mono text-[10px] text-muted-foreground",children:[r.jsxs("span",{children:[String(A.capturedCount)," captured"]}),r.jsx("span",{children:A.pendingCount>0?`${String(A.pendingCount)} active`:_?"Roaming":"Resting"})]})]})]})}J({question:C().trim().min(1).max(4e3),sessionId:C().trim().min(1).optional(),providerId:C().trim().min(1).optional(),model:C().trim().min(1).optional(),logLimit:G().int().min(1).max(80).optional()});const DP=J({answer:C(),providerId:C(),providerName:C(),model:C(),protocol:Te(["openaiResponses","openaiChat","anthropic"]),logCount:G().int().nonnegative()}),$P="Analyze the current Inspector session. What looks abnormal, slow, or likely to hang?";function FP(e){return e.openaiResponsesBaseUrl!==void 0||e.openaiBaseUrl!==void 0||e.anthropicBaseUrl!==void 0}function UP(e){return e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""?"Responses":e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""?"Chat":"Anthropic"}function BP(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 WP({currentSessionId:e,logCount:t}){const{providers:n}=Xl(),s=p.useMemo(()=>BP(n.filter(FP)),[n]),[o,i]=p.useState($P),[a,l]=p.useState("__auto__"),[c,u]=p.useState("__auto__"),[d,f]=p.useState(""),[m,h]=p.useState(""),[x,g]=p.useState(!1),v=s.find(E=>E.id===a)?.models??[],y=o.trim()!==""&&s.length>0&&!x,_=E=>{i(E.currentTarget.value)},j=E=>{l(E),u("__auto__")},S=()=>{if(!y)return;g(!0),h(""),f("");const E={question:o.trim(),...e!==null?{sessionId:e}:{},...a!=="__auto__"?{providerId:a}:{},...c!=="__auto__"?{model:c}:{},logLimit:24};fetch("/api/pi-agent",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(E)}).then(async T=>{const R=await T.text();if(!T.ok){h(`Pi Agent failed: HTTP ${String(T.status)}`),f(R);return}const A=JSON.parse(R),z=DP.safeParse(A);if(!z.success){h("Pi Agent returned an unexpected response."),f(R);return}h(`${z.data.providerName} / ${z.data.model} / ${z.data.protocol} / ${String(z.data.logCount)} logs`),f(z.data.answer)}).catch(T=>{h(T instanceof Error?T.message:"Pi Agent request failed.")}).finally(()=>{g(!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(dw,{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 analysis":"Session analysis"})]})]}),r.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[r.jsxs(Xn,{value:a,onValueChange:j,children:[r.jsx(Qn,{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(Os,{placeholder:"Provider"})}),r.jsxs(es,{children:[r.jsx(Qe,{value:"__auto__",children:"Auto provider"}),s.map(E=>r.jsxs(Qe,{value:E.id,children:[E.name," / ",UP(E)]},E.id))]})]}),r.jsxs(Xn,{value:c,onValueChange:u,children:[r.jsx(Qn,{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(Os,{placeholder:"Model"})}),r.jsxs(es,{children:[r.jsx(Qe,{value:"__auto__",children:"Auto model"}),v.map(E=>r.jsx(Qe,{value:E,children:E},E))]})]})]}),r.jsx("textarea",{value:o,onChange:_,className:"mt-2 min-h-24 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 about this session..."}),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:[x?r.jsx(Ye,{className:"size-3.5 animate-spin"}):r.jsx(d5,{className:"size-3.5"}),r.jsx("span",{children:x?"Thinking...":"Ask Pi"})]}),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."}),m!==""&&r.jsx("p",{className:"mt-2 break-words font-mono text-[10px] text-cyan-100/70",children:m}),d!==""&&r.jsx("div",{className:"mt-3 max-h-64 overflow-y-auto whitespace-pre-wrap rounded-md bg-black/25 p-3 text-xs leading-5 text-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.05)]",children:d}),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 HP(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:Yd(i.cacheCreationInputTokens,a.cacheCreationInputTokens),read:Yd(i.cacheReadInputTokens,a.cacheReadInputTokens)})}}return t}function Yd(e,t){return t===null||e===null?null:t>e?{direction:"up",delta:t-e}:t<e?{direction:"down",delta:e-t}:null}function Sg(e){return e.filter(t=>t.responseStatus===null).length}function Cg(e){for(const t of e){const n=t.userAgent;if(n!=null&&n!=="")return n}return null}function VP(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function Ng(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}function qP(e){return Sc({userAgent:Cg(e.logs),conversationId:e.conversationId,clientProjectFolder:Ng(e.logs)})}function ZP(e){if(e===null||e==="")return"Unknown IDE";const t=e.split(/[ /;]/)[0]??"";return t===""?"Unknown IDE":t}function GP(e,t){const n=Ei(e);return n!==null?n:ZP(t)}function Go(e){return e===null||e===""?"unknown":String(e)}function KP(e,t,n){return e!=="unknown"?e:`unknown:${Go(t)}:${Go(n)}`}function JP(e,t){return`${Go(e)}:${Go(t)}`}function bl(e){return[...e].sort((t,n)=>t.timestamp.localeCompare(n.timestamp))}function Xd(e){return bl(e)[0]?.timestamp??""}function ja(e){return[...e].sort((t,n)=>Xd(t.logs).localeCompare(Xd(n.logs)))}function YP(e){const t=new Map;for(const s of e){const o=Cg(s.logs),i=Ng(s.logs),a=qP(s),l=KP(a,o,i);let c=t.get(l);c===void 0&&(c={id:l,client:a,label:GP(a,o),userAgent:o,processes:new Map,logs:[]},t.set(l,c)),c.logs.push(...s.logs);const u=VP(s.logs),d=`${l}:${JP(u,i)}`;let f=c.processes.get(d);f===void 0&&(f={id:d,clientPid:u,clientProjectFolder:i,sessions:[],logs:[]},c.processes.set(d,f)),f.sessions.push(s),f.logs.push(...s.logs)}const n=[];for(const s of t.values()){const o=ja([...s.processes.values()].map(i=>({id:i.id,clientPid:i.clientPid,clientProjectFolder:i.clientProjectFolder,sessions:ja(i.sessions),logs:bl(i.logs)})));n.push({id:s.id,client:s.client,label:s.label,userAgent:s.userAgent,processes:o,logs:bl(s.logs)})}return ja(n)}function Ko(e){return e<=0?"0":Fe(e)}function Tg(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 XP(e){let t=0;for(const n of e)t+=n.sessions.length;return t}function QP(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 Jo({label:e,value:t,className:n}){return r.jsxs("span",{className:oe("bg-white/[0.045] inline-flex h-7 items-center gap-1 rounded-md px-2 text-xs text-muted-foreground",n),children:[r.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.12em] text-white/35",children:e}),r.jsx("span",{className:"font-mono tabular-nums text-slate-100",children:t})]})}function Eg({count:e,label:t="Turn open"}){return r.jsxs("span",{className:"inline-flex h-6 shrink-0 items-center gap-1.5 rounded-md bg-amber-300/[0.10] px-1.5 font-mono text-[10px] uppercase tracking-[0.14em] text-amber-100/90 ring-1 ring-amber-200/10",title:`${e} turn${e!==1?"s":""} not finished yet`,children:[r.jsx(Ye,{className:"size-3 animate-spin"}),t,e>1&&r.jsxs("span",{className:"tabular-nums",children:["x",e]})]})}function Ag(){return r.jsx("span",{className:"pointer-events-none absolute inset-x-3 bottom-0 h-px overflow-hidden rounded-full bg-white/[0.06]","aria-hidden":"true",children:r.jsx("span",{className:"absolute inset-y-0 left-0 w-1/3 animate-pulse rounded-full bg-amber-200/65 shadow-[0_0_14px_rgba(252,211,77,0.32)]"})})}function e8({groups:e,...t}){const n=p.useMemo(()=>YP(e),[e]),[s,o]=p.useState(()=>new Set),[i,a]=p.useState(()=>new Set),l=p.useCallback(u=>{o(d=>{const f=new Set(d);return f.has(u)?f.delete(u):f.add(u),f})},[]),c=p.useCallback(u=>{a(d=>{const f=new Set(d);return f.has(u)?f.delete(u):f.add(u),f})},[]);return r.jsx("div",{className:"space-y-4",children:n.map(u=>r.jsx(t8,{group:u,collapsed:s.has(u.id),collapsedProcessIds:i,onToggleIde:()=>l(u.id),onToggleProcess:c,conversationProps:t},u.id))})}function t8({group:e,collapsed:t,collapsedProcessIds:n,onToggleIde:s,onToggleProcess:o,conversationProps:i}){const a=Tg(e.logs),l=XP(e.processes),c=e.logs.length,u=Sg(e.logs),d=u>0;return r.jsxs("section",{className:oe("bg-card/75 shadow-sm relative isolate overflow-hidden rounded-[8px]",d&&"bg-card/85"),"data-ide-group":e.id,children:[r.jsxs("button",{type:"button",className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-white/[0.03] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300/45",onClick:s,"aria-expanded":!t,children:[e.client==="unknown"?r.jsx("span",{className:"bg-white/[0.045] inline-flex size-10 shrink-0 items-center justify-center rounded-[8px] text-slate-200",children:r.jsx(A_,{className:"size-5"})}):r.jsx(Ai,{client:e.client,className:"size-10 rounded-[8px] text-cyan-100"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"truncate text-sm font-semibold text-slate-50",title:e.userAgent??e.label,children:e.label}),r.jsx("span",{className:"rounded bg-cyan-300/[0.06] px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-[0.16em] text-cyan-100/75",children:"IDE"}),d&&r.jsx(Eg,{count:u,label:"Turn open"})]}),r.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs 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:[c," log",c!==1?"s":""]})]})]}),r.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[r.jsx(Jo,{label:"IN",value:Ko(a.inputTokens)}),r.jsx(Jo,{label:"OUT",value:Ko(a.outputTokens)})]}),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",children:t?r.jsx(jt,{className:"size-4"}):r.jsx(rt,{className:"size-4"})})]}),d&&r.jsx(Ag,{}),!t&&r.jsx("div",{className:"space-y-3 px-3 pb-3 pt-2 sm:px-4",children:e.processes.map(f=>r.jsx(n8,{group:f,collapsed:n.has(f.id),onToggle:()=>o(f.id),conversationProps:i},f.id))})]})}function n8({group:e,collapsed:t,onToggle:n,conversationProps:s}){const o=Tg(e.logs),i=QP(e.clientProjectFolder),a=e.sessions.length,l=e.logs.length,c=Sg(e.logs),u=c>0,d=e.clientPid!==null&&e.clientPid!==void 0?`PID ${e.clientPid}`:"process";return r.jsxs("section",{className:"relative pl-5",children:[r.jsx("span",{className:"absolute bottom-1 left-2 top-1 w-px bg-white/[0.055]","aria-hidden":"true"}),r.jsxs("div",{className:"bg-black/[0.10] relative overflow-hidden rounded-[8px]",children:[r.jsxs("button",{type:"button",className:"flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left transition-colors hover:bg-white/[0.035] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300/40",onClick:n,"aria-expanded":!t,children:[r.jsx("span",{className:"bg-white/[0.045] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-amber-100",children:r.jsx(qw,{className:"size-4"})}),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:"font-mono text-xs font-semibold tabular-nums text-slate-100",children:d}),u&&r.jsx(Eg,{count:c,label:"Turn open"}),i!==null&&r.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-xs text-muted-foreground",title:e.clientProjectFolder??i,children:[r.jsx(p_,{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-xs text-muted-foreground",children:[r.jsxs("span",{children:[a," session",a!==1?"s":""]}),r.jsxs("span",{children:[l," log",l!==1?"s":""]})]})]}),r.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[r.jsx(Jo,{label:"IN",value:Ko(o.inputTokens)}),r.jsx(Jo,{label:"OUT",value:Ko(o.outputTokens)})]}),r.jsx("span",{className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-slate-200",children:t?r.jsx(jt,{className:"size-4"}):r.jsx(rt,{className:"size-4"})})]}),u&&r.jsx(Ag,{}),!t&&r.jsx("div",{className:"space-y-2 p-2 pt-1 sm:p-3 sm:pt-2",children:e.sessions.map(f=>r.jsx(pR,{group:f,...s,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},f.id))})]})]})}const Yo="data-nav-id",s8="data-nav-action";function Qd(e){return Array.from(e.querySelectorAll(`[${Yo}]`))}function ef(e){return e instanceof HTMLElement}function r8(e,t){let n=e;for(;n!==null&&n!==t;){if(n.hasAttribute(Yo))return n;n=n.parentElement}return e.hasAttribute(Yo)?e:null}function Sa(e){const t=e.getAttribute(s8);return t==="toggle"||t==="expand"||t==="collapse"?t:null}function Xs(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Qs(e,t){return e[t]??null}function Rg(e){const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function tf(e){const t=e.tagName;return t==="BUTTON"||t==="A"||Rg(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function o8(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function i8(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function ao(e,t){return e.key===t&&e.shiftKey}function a8(e,t,n={}){const s=t??e,o=n.pageWide===!0,i=p.useCallback(a=>{const l=e.current,c=s.current;if(!l||!c)return;const u=a.target;if(!ef(u)||u!==c)return;const d=Qd(l),f=Qs(d,0);f!==null&&Xs(f)},[e,s]);p.useEffect(()=>{const a=l=>{if(l.altKey||l.ctrlKey||l.metaKey)return;const c=e.current;if(!c)return;const u=l.target;if(!ef(u)||Rg(u)||i8())return;const d=c.contains(u);if(d&&tf(u)&&!u.hasAttribute(Yo)||!d&&(!o||tf(u)||o8(u)))return;const f=Qd(c);if(f.length===0)return;const m=r8(u,c),h=m!==null?f.indexOf(m):-1;let x=!1;switch(l.key){case"ArrowUp":case"W":{if(l.shiftKey&&l.key==="ArrowUp"||l.key==="W"&&!ao(l,"W"))break;l.preventDefault();const g=h>0?h-1:h===-1?f.length-1:-1;if(g!==-1){const b=Qs(f,g);b!==null&&Xs(b)}x=!0;break}case"ArrowDown":case"S":{if(l.shiftKey&&l.key==="ArrowDown"||l.key==="S"&&!ao(l,"S"))break;l.preventDefault();const g=h<f.length-1?h+1:h===-1?0:-1;if(g!==-1){const b=Qs(f,g);b!==null&&Xs(b)}x=!0;break}case"ArrowLeft":case"A":{if(l.shiftKey&&l.key==="ArrowLeft"||l.key==="A"&&!ao(l,"A")||m===null)break;if(l.preventDefault(),Sa(m)==="collapse")m.click();else if(h>0){const b=Qs(f,h-1);b!==null&&Xs(b)}x=!0;break}case"ArrowRight":case"D":{if(l.shiftKey&&l.key==="ArrowRight"||l.key==="D"&&!ao(l,"D")||m===null)break;if(l.preventDefault(),Sa(m)==="expand")m.click();else if(h<f.length-1){const b=Qs(f,h+1);b!==null&&Xs(b)}x=!0;break}case" ":{if(m===null)break;l.preventDefault(),Sa(m)!==null&&m.click(),x=!0;break}}x&&l.stopPropagation()};return document.addEventListener("keydown",a,{capture:!0}),()=>document.removeEventListener("keydown",a,{capture:!0})},[e,o,s]),p.useEffect(()=>(document.addEventListener("focusin",i),()=>document.removeEventListener("focusin",i)),[i])}const l8={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},c8={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"},u8={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"},Ca=12,lo=1,nf=80,sf=24;function d8(e){return e.length<=sf?e:`${e.slice(0,sf-3)}...`}function f8(e){const t=e.replace(/\s+/g," ").trim();return t.length<=nf?t:`${t.slice(0,nf)}...`}function co(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const p8=p.memo(function({segments:t,totalTokens:n,showLabels:s=!0,onActivate:o}){const i=p.useMemo(()=>n>0?n:t.reduce((b,v)=>b+v.size,0),[t,n]),a=t.slice(0,Ca),l=t.slice(Ca),c=l.reduce((b,v)=>b+v.size,0),u=l.length,d=Ca,f=d+u-1,m=u>0,h=o!==void 0,x=p.useMemo(()=>a.reduce((b,v)=>b+v.size,0),[a]),g=p.useMemo(()=>`Request context: ~${Fe(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":g,className:"h-6"}):r.jsx(jn,{delayDuration:150,children:r.jsxs("div",{role:"img","aria-label":g,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,v)=>{const y=i>0?b.size/i*100:0,_=Math.max(lo,y),j=oe("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",c8[b.role],h?u8[b.role]:""),S={width:`${_}%`},E=`${b.label}, ${co(y)}, ~${Fe(b.size)} tokens`;return r.jsxs(dt,{children:[r.jsx(ft,{asChild:!0,children:h?r.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>o(b),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),o(b))},"data-anatomy-path":b.path,"aria-label":E,className:j,style:S}):r.jsx("span",{"aria-label":E,className:j,style:S})}),r.jsxs(pt,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[r.jsxs("div",{className:"font-semibold",children:[b.label," - ",co(y)," - ~",Fe(b.size)," ","tokens"]}),r.jsx("div",{className:"text-muted-foreground",children:l8[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:f8(b.text)})]})]},`${b.path}-${v}`)}),m&&r.jsxs(dt,{children:[r.jsx(ft,{asChild:!0,children:r.jsxs("div",{role:"img","aria-label":`${u} 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(lo,c/i*100)}%`},children:["... +",u]})}),r.jsxs(pt,{side:"bottom",className:"text-xs",children:[u," more segment",u===1?"":"s"," (indices"," ",d,"-",f,")"]})]})]}),s&&r.jsxs("div",{className:"flex w-full gap-1 text-[10px] text-muted-foreground",children:[a.map((b,v)=>{const y=i>0?b.size/i*100:0,_=Math.max(lo,y);return r.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${_}%`},title:`${b.label} - ${co(y)} - ~${Fe(b.size)} tokens`,children:[r.jsx("span",{className:"truncate font-mono text-foreground/80",children:d8(b.label)}),r.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[co(y)," - ~",Fe(b.size)]})]},`label-${b.path}-${v}`)}),m&&r.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(lo,c/i*100)}%`},children:[r.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",u]}),r.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",Fe(c)]})]})]}),x<i*.1&&r.jsx("div",{className:"h-0"})]})})}),Ig=.75,Pg=.9,vl=8e3,h8=.35,zg=40,Mg=160,m8=5,g8=8,x8=18,b8=6e4,v8=.7,rf=3e3,y8=.3,of=160,w8=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),_8=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],k8=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],j8=[{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"]}],S8={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function C8(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 Og(e,t){for(const n of t){const s=C8(ke(e,n));if(s!==null)return s}return null}function N8(e){const t=ke(e,"model");if(typeof t!="string")return null;const n=t.trim();return n===""?null:n}function T8(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 E8(e,t,n=[]){const s=Og(t,_8);if(s!==null)return{tokens:s,label:"Request metadata",source:"request"};const o=B6(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 j8)if(T8(i,a))return{tokens:a.tokens,label:`${a.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function A8(e){return e<0?0:e>1?1:e}function R8(e){return e===null?"unknown":e>=Pg?"danger":e>=Ig?"watch":"ok"}function I8(e,t){return e.filter(n=>n.role===t).reduce((n,s)=>n+s.size,0)}function P8(e,t){return["system","user","assistant","tool","tools"].map(s=>{const o=I8(e,s);return{role:s,label:S8[s],tokens:o,percent:t>0?o/t:0}}).filter(s=>s.tokens>0).sort((s,o)=>o.tokens-s.tokens)}function yl(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function z8(e){const t=e.replace(/\s+/g," ").trim();return t.length<=of?t:`${t.slice(0,of-3)}...`}function M8(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function O8(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function L8(e){const t=e.trim();return t.startsWith("{")||t.startsWith("[")}function D8(e){if(!L8(e))return null;try{return JSON.parse(e)}catch{return null}}function $8(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function F8(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 U8(e){const t=F8(e);return t===null?!1:w8.has($8(t))}function B8(e){return e.map(t=>t.startsWith("[")?t:`.${t}`).join("").replace(/^\./,"")}function W8(e,t,n){const s=Ec(t);if(s<Mg)return null;const o=Tc(t);return o<zg?null:{role:e.role,label:`${e.label} ${B8(n)}`,path:e.path,tokens:o,characters:s,text:t}}function wl({value:e,segment:t,path:n,depth:s,candidates:o}){if(!(o.length>=g8)&&!(s>m8)){if(typeof e=="string"){if(!U8(n))return;const i=W8(t,e,n);i!==null&&o.push(i);return}if(Array.isArray(e)){e.forEach((i,a)=>wl({value:i,segment:t,path:[...n,`[${String(a)}]`],depth:s+1,candidates:o}));return}Ac(e)&&Object.entries(e).forEach(([i,a])=>wl({value:a,segment:t,path:[...n,i],depth:s+1,candidates:o}))}}function H8(e){const t=O8(e),n=D8(e.text);if(n===null)return[t];const s=[];wl({value:n,segment:e,path:[],depth:0,candidates:s});const o=yl(e.text),i=new Set([o]),a=s.filter(l=>{const c=yl(l.text);return c===""||i.has(c)?!1:(i.add(c),!0)});return[t,...a]}function V8(e){const t=new Map;for(const s of e){const o=H8(s);for(const i of o){if(i.tokens<zg||i.characters<Mg)continue;const a=yl(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:z8(o.text),firstLabel:o.label,segments:s.candidates.map(M8)})}return n.sort((s,o)=>o.repeatedTokens-s.repeatedTokens||o.totalTokens-s.totalTokens)}function q8(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>=vl?"danger":"watch",title:"Duplicate context",detail:`${String(n)} repeated blocks across ${String(t)} group${t===1?"":"s"}, ~${String(s)} repeated tokens.`}}function Z8(e){return e.reduce((t,n)=>t+n.repeatedTokens,0)}function G8(e,t,n){const s=[],o=e.find(c=>c.role==="tools")??null;o!==null&&(o.tokens>=vl||o.percent>=h8&&o.tokens>=rf)&&s.push({kind:"tool-schema",severity:o.tokens>=vl?"danger":"watch",title:"Large tool schema",detail:`Tool definitions take ${Math.round(o.percent*100)}% of request context.`});const i=e.find(c=>c.role==="system")??null;i!==null&&i.tokens>=rf&&i.percent>=y8&&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(c=>c.role==="user"||c.role==="assistant"||c.role==="tool").reduce((c,u)=>c+u.tokens,0),l=t>0?a/t:0;return n>=x8&&(a>=b8||l>=v8)&&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 K8({risk:e,contextWindow:t,diagnostics:n,duplicateGroups:s}){let i=new Set(n.map(c=>c.kind)).size;(e==="watch"||e==="danger")&&(i+=1),t.source==="unknown"&&(i+=1);const a=n.some(c=>c.severity==="danger");return{level:e==="danger"||a?"risk":i>0?"optimizable":"ok",opportunityCount:i,reclaimableTokens:Z8(s)}}function J8({segments:e,inputTokens:t,parsed:n,model:s,providers:o=[]}){const i=e.reduce((E,T)=>E+T.size,0),a=s??N8(n),l=t??i,c=Og(n,k8),u=E8(a,n,o),d=c??0,f=u.tokens===null?null:l+d,m=u.tokens===null?null:u.tokens-l,h=u.tokens===null?null:u.tokens-l-d,x=u.tokens===null||f===null?null:A8(f/u.tokens),g=P8(e,i),b=g[0]??null,v=e.filter(E=>E.role!=="tools").length,y=V8(e),_=q8(y),j=G8(g,i,v);_!==null&&j.unshift(_);const S=R8(x);return{model:a,contextWindow:u,estimatedInputTokens:l,outputReserveTokens:c,windowUsedTokens:f,remainingInputTokens:m,remainingAfterReserveTokens:h,usagePercent:x,riskLevel:S,roleUsages:g,largestRole:b,diagnostics:j,duplicateGroups:y,health:K8({risk:S,contextWindow:u,diagnostics:j,duplicateGroups:y})}}const eM={watch:Ig,danger:Pg},af=new WeakMap;function Y8(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 X8(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function Q8(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function ez(e,t){const n=X8(e.rawRequestBody);if(n===null)return null;const o=z0(fr(e)).anatomySegments(n);if(o===null)return null;const i=J8({segments:o,inputTokens:e.inputTokens??null,parsed:n,model:e.model,providers:t}),a=i.model??e.model??"Unknown model",l=i.roleUsages.map(Q8);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(c=>c.title),roleSegments:l,roleTotalTokens:l.reduce((c,u)=>c+u.size,0)}}function tz(e,t,n){const s=af.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=ez(e,t);return af.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 nz(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 lf(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function sz(e,t){const n=lf(t.latest.riskLevel)-lf(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 rz(e,t){return e.usagePercent===null||t.usagePercent===null?null:(t.usagePercent-e.usagePercent)*100}function oz(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 iz(e,t=[]){const n=oz(e),s=Y8(t),o=new Map;for(const a of n){const l=tz(a,t,s);if(l===null)continue;const c=o.get(l.model);if(c===void 0){o.set(l.model,{model:l.model,requestCount:1,first:l,latest:l,peak:l});continue}o.set(l.model,{model:c.model,requestCount:c.requestCount+1,first:c.first,latest:l,peak:nz(l,c.peak)?l:c.peak})}return{models:[...o.values()].map(a=>({model:a.model,requestCount:a.requestCount,first:a.first,latest:a.latest,peak:a.peak,trendPercent:rz(a.first,a.latest)})).sort(sz)}}function en(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function az(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 cf(e,t){return t.get(e.id)??e.id}function uf(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 lz(e){for(const t of e)if(t.userAgent!==null&&t.userAgent!==void 0&&t.userAgent!=="")return t.userAgent;return null}function cz(e,t){const n=e[0],s=e[e.length-1];return n===void 0||s===void 0?null:li(n.timestamp,s.timestamp,t)}function uz(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 dz(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function fz(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 gs({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:oe("mt-2 font-mono text-sm font-semibold",uz(o)),children:t}),r.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:n})]})}function pz({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(zw,{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(gs,{label:"Status",value:e.statusLabel,detail:fz(e),tone:dz(e.status)}),r.jsx(gs,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:r.jsx(u_,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),r.jsx(gs,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:r.jsx(Oa,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),r.jsx(gs,{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(gs,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:r.jsx(Kl,{className:"size-3 text-muted-foreground"})}),r.jsx(gs,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function rr(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 hz(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function _l(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function mz(e,t){if(t===null)return null;const n=_l(e),s=_l(t);return s<=0||Math.abs(s-n)<.5?null:s}function gz(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 xz(e){const t=e.latest.contextWindow.tokens;return t===null?"Context window unknown":`Context window ${nh(t)}`}const bz=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function Lg(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 Na(e,t){if(e===null)return null;const n=e.metadata[t];return n===void 0?null:Lg(n)}function vz(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 yz(e){const t=[];for(const n of bz){const s=e.metadata[n];if(s===void 0)continue;const o=Lg(s);o!==null&&t.push({key:n,value:o})}return t}function df({memberships:e,defaultOpen:t=!1}){const[n,s]=p.useState(t);if(e.length===0)return null;const o=e[0],i=o?.member??null,a=Na(i,"score"),l=Na(i,"decision"),c=Na(i,"final_status"),u=[a===null?null:{label:`score ${a}`,value:a},l===null?null:{label:l,value:l},c===null?null:{label:c,value:c},i?.model===null||i?.model===void 0?null:{label:i.model,value:i.model}].filter(d=>d!==null&&d.label.length>0&&d.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(d=>!d),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"]})]}),u.length>0&&r.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:u.slice(0,4).map(d=>r.jsx("span",{className:oe("rounded border px-1.5 py-0.5 font-mono text-[10px]",vz(d.value)),children:d.label},d.label))})]}),n?r.jsx(ql,{className:"size-4 shrink-0 text-muted-foreground"}):r.jsx(rt,{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(d=>{const f=d.member,m=yz(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:d.groupTitle,children:d.groupTitle}),r.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:d.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:en(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 ",en(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))})]},`${d.groupId}:${f.id}`)})})]})}function uo({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 disabled:cursor-not-allowed disabled:opacity-45",title:t,children:[n,r.jsx("span",{children:e})]})}function wz(e){return`${Math.max(0,Math.ceil(e/1e3)).toString()}s`}function wo({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,`${wz(s)} before timeout`].filter(a=>a!==null);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:oe("shrink-0 tabular-nums",o&&"text-amber-300"),children:i.join(" / ")})]}),r.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-white/[0.06]",children:r.jsx("div",{className:oe("h-full rounded-full transition-all duration-300",o?"bg-amber-300/80":"bg-cyan-300/70"),style:{width:`${n.toString()}%`}})})]})}function ff({logs:e,pagination:t,embedded:n=!1}){if(t===void 0)return null;const s=t.isLoading;return r.jsxs("div",{className:oe("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:[TR({logs:e,pagination:t}),t.isLoading&&e.length>0&&r.jsx("span",{className:"ml-2",children:"Loading..."}),t.loadProgress!==void 0&&r.jsx(wo,{progress:t.loadProgress})]}),r.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[r.jsx(uo,{label:"Oldest",title:"Load the oldest logs in this session",icon:r.jsx(_w,{className:"size-3.5"}),disabled:s||!t.hasOlder,onClick:t.onOldest}),r.jsx(uo,{label:"Older",title:"Load older logs",icon:r.jsx(gw,{className:"size-3.5"}),disabled:s||!t.hasOlder,onClick:t.onOlder}),r.jsx(uo,{label:"Newer",title:"Load newer logs",icon:r.jsx(jt,{className:"size-3.5"}),disabled:s||!t.hasNewer,onClick:t.onNewer}),r.jsx(uo,{label:"Newest",title:"Load the newest logs in this session",icon:r.jsx(jw,{className:"size-3.5"}),disabled:s||!t.hasNewer,onClick:t.onNewest})]})]})}function _z(e){return`${e} ${e===1?"request":"requests"}`}function pf(e){return`#${String(e)}`}function hf(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 kz(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 jz(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const Sz=10,Cz=80;function Nz(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function Tz(e){const t=document.getElementById(`log-${String(e)}`);return t instanceof HTMLElement?(t.scrollIntoView({block:"center",behavior:"smooth"}),t.focus({preventScroll:!0}),Nz(t),!0):!1}function Dg(e){hr({logId:e,tab:"anatomy"});let t=0;const n=()=>{hr({logId:e,tab:"anatomy"}),!Tz(e)&&(t+=1,t<Sz&&window.setTimeout(n,Cz))};window.setTimeout(n,0)}function mf({command:e}){const[t,n]=p.useState(!1),s=p.useCallback(()=>{At(e).then(o=>{o&&(n(!0),setTimeout(()=>n(!1),2e3))})},[e]);return r.jsxs("div",{className:"bg-black/20 inline-flex max-w-full items-center gap-2 rounded-md px-3 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[r.jsx("pre",{className:"m-0 overflow-x-auto font-mono text-sm text-cyan-200",children:e}),r.jsx("button",{type:"button",onClick:s,className:"shrink-0 cursor-pointer text-muted-foreground transition-colors hover:text-foreground","aria-label":"Copy command",children:t?r.jsx(qe,{className:"size-4"}):r.jsx(Pt,{className:"size-4"})})]})}function Ta({label:e,children:t,className:n}){return r.jsxs("section",{className:oe("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 fo({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})]})}const Ez=["text-amber-500","text-rose-500","text-sky-500","text-emerald-500","text-violet-500","text-orange-500","text-cyan-500","text-pink-500","text-lime-500","text-blue-500","text-yellow-500","text-fuchsia-500"];function gf({compact:e,entrancePhase:t}){return e?r.jsx(dl,{className:"size-14 text-amber-500"}):r.jsxs("span",{className:"flex shrink-0 items-end gap-1 group cursor-default","aria-hidden":"true",children:[r.jsx(dl,{className:"size-10 text-amber-500 transition-all duration-300 group-hover:scale-125 group-hover:-translate-y-1.5"}),r.jsx("span",{className:"hidden items-end gap-0.5 sm:flex",children:mr.map((n,s)=>{const o=Ez[s]??"text-amber-500",i=t==="hidden"?"opacity-0 scale-0":t==="playing"?"animate-crab-piano-pop":"";return r.jsx(n,{className:`size-5 ${o} transition-all duration-300 ease-out group-hover:scale-125 group-hover:-translate-y-1 ${i}`,style:{transitionDelay:`${s*50}ms`,...t==="playing"?{animationDelay:`${s*400}ms`}:{}}},s)})})]})}function xf(){const{themeMode:e,setThemeMode:t}=ej();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:oe("inline-flex size-7 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground",e==="light"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use light mode","aria-pressed":e==="light",title:"Light mode",children:r.jsx(_5,{className:"size-3.5"})}),r.jsx("button",{type:"button",onClick:()=>t("eye-care"),className:oe("inline-flex size-7 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground",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(Gl,{className:"size-3.5"})}),r.jsx("button",{type:"button",onClick:()=>t("dark"),className:oe("inline-flex size-7 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground",e==="dark"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use dark mode","aria-pressed":e==="dark",title:"Dark mode",children:r.jsx(I_,{className:"size-3.5"})})]})}function bf({preference:e,resolvedScale:t,onChange:n}){const s=ex(t),o=e==="auto"?`Auto (${s})`:`${e}%`;return r.jsxs(Xn,{value:e,onValueChange:i=>n(_f(i)),children:[r.jsxs(Qn,{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(qy,{className:"size-3.5"}),r.jsx("span",{className:"font-mono text-[10px] font-semibold tabular-nums",children:s})]}),r.jsxs(es,{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%"})]})]})}function Az({compact:e,crabEntrancePhase:t,currentSessionId:n,logCount:s,uiScalePreference:o,resolvedUiScale:i,onUiScaleChange:a}){return e?r.jsx("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_16px_44px_rgba(0,0,0,0.18)] rounded-[8px] p-3",children:r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-fit items-start gap-3",children:[r.jsx(gf,{compact:!0,entrancePhase:t}),r.jsxs("div",{className:"min-w-fit",children:[r.jsxs("div",{className:"flex min-w-fit flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[r.jsx("span",{className:"whitespace-nowrap text-base font-bold",children:"Agent Inspector"}),r.jsxs("span",{className:"hidden shrink-0 font-mono text-[11px] font-semibold text-muted-foreground sm:inline",children:["v",Da.version]})]}),r.jsx("div",{className:"hidden text-[11px] font-semibold text-muted-foreground sm:block",children:"Local First. Evidence First."})]})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[r.jsx(xf,{}),r.jsx(bf,{preference:o,resolvedScale:i,onChange:a}),r.jsx(jd,{}),r.jsx(Cd,{}),r.jsx(Zd,{currentSessionId:n,logCount:s}),r.jsx(qd,{})]})]})}):r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-3 pb-6",children:[r.jsx("div",{className:"min-w-10 flex-1","aria-hidden":"true"}),r.jsxs("h1",{className:"flex min-w-fit flex-col items-center gap-2 text-center",children:[r.jsxs("span",{className:"flex max-w-full flex-wrap items-end justify-center gap-x-2 gap-y-1",children:[r.jsx(gf,{compact:!1,entrancePhase:t}),r.jsxs("span",{className:"flex min-w-fit flex-wrap items-baseline justify-center gap-x-2 gap-y-0.5 pl-1",children:[r.jsx("span",{className:"whitespace-nowrap text-lg font-bold",children:"Agent Inspector"}),r.jsxs("span",{className:"shrink-0 font-mono text-xs font-semibold text-muted-foreground",children:["v",Da.version]})]}),r.jsx(Ma,{className:"size-4 shrink-0 text-muted-foreground/70","aria-hidden":"true"}),r.jsx(AR,{className:"size-10 shrink-0"})]}),r.jsx("span",{className:"max-w-full text-sm font-semibold text-muted-foreground",children:"Local First. Evidence First."})]}),r.jsxs("div",{className:"flex flex-1 justify-end gap-1",children:[r.jsx(xf,{}),r.jsx(bf,{preference:o,resolvedScale:i,onChange:a}),r.jsx(jd,{}),r.jsx(Cd,{}),r.jsx(Zd,{currentSessionId:n,logCount:s}),r.jsx(qd,{})]})]})}const $g="agent-inspector.detailsPanelCollapsed";function Rz(){if(typeof window>"u")return!0;const e=window.localStorage.getItem($g);return e===null||e==="1"}function vf({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 ${pf(t)}`,children:[e," ",pf(t)]})}function Iz({latestPercent:e,peakPercent:t,risk:n,onOpenContext:s}){const o=_l(e),i=mz(e,t),a=t===null?`Latest context window usage ${rr(e)}`:`Latest context window usage ${rr(e)}, peak ${rr(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:oe("block h-full rounded-full transition-[width]",gz(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 Pz({summary:e}){const t=e.trendPercent,n=t===null||Math.abs(t)<.1?null:t>0?nw:Jy,s=e.latest.diagnostics[0]??null,o=rr(e.latest.usagePercent),i=rr(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:oe("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",kz(e.latest.health.level)),children:jz(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:_z(e.requestCount)}),r.jsx("span",{children:xz(e)})]})]}),r.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[r.jsx(Iz,{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:oe("mt-0.5 font-mono",hf(e.latest.riskLevel)),children:o}),r.jsx(vf,{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:oe("mt-0.5 font-mono",hf(e.peak.riskLevel)),children:i}),r.jsx(vf,{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:oe("size-3",t!==null&&t>0?"text-amber-300":"text-cyan-300")}),hz(t)]}),r.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),r.jsxs("div",{className:"min-w-0 space-y-1.5",children:[r.jsx(p8,{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:["~",Fe(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&r.jsxs("span",{className:"font-mono",children:["~",Fe(e.latest.windowUsedTokens)," used"]}),s!==null&&r.jsx("span",{className:"truncate",children:s})]})]})]})}function zz({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(Pz,{summary:t},t.model))})]})}function Mz(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 Oz({label:e,logs:t,totalIn:n,totalOut:s,timeDisplayFormat:o,contextSummary:i,showBackLink:a}){const[l,c]=p.useState(!1),[u,d]=p.useState(!1),f=p.useMemo(()=>cz(t,o),[t,o]),m=p.useMemo(()=>lz(t),[t]),h=p.useMemo(()=>Mz(i),[i]),x=p.useCallback(()=>{At(window.location.href).then(g=>{g&&(c(!0),setTimeout(()=>c(!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(ew,{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:en(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:[Fe(n)," in / ",Fe(s)," out"]})]})]}),i.models.length>0&&r.jsxs("button",{type:"button",onClick:()=>d(g=>!g),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":u,title:u?"Hide context details":"Show context details",children:[r.jsx("span",{children:h}),u?r.jsx(ql,{className:"size-3.5"}):r.jsx(rt,{className:"size-3.5"})]}),r.jsx("button",{type:"button",onClick:x,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(qe,{className:"size-3.5"}):r.jsx(Pt,{className:"size-3.5"})})]}),u&&r.jsx(zz,{summary:i})]})}function Lz({logs:e,sessions:t,models:n,selectedSession:s,selectedModel:o,onSessionChange:i,onModelChange:a,onClearAll:l,onDeleteCurrentView:c,onReloadSession:u,onClearGroup:d,onNotify:f,onImportLogs:m,viewMode:h,captureMode:x,strip:g,slowResponseThresholdSeconds:b,timeDisplayFormat:v,isLoading:y=!1,pagination:_,sessionLoadProgress:j,sessionMemberships:S=[],hideSessionFilter:E=!1,pinnedSessionId:T}){const{totalIn:R,totalOut:A}=p.useMemo(()=>uf(e),[e]),{providers:z}=Xl(),{uiScalePreference:H,resolvedUiScale:N,setUiScalePreference:L}=tj(),[w,$]=p.useState(null),[X,B]=p.useState(null),[Q,D]=p.useState(!1),[Z,W]=p.useState(null),[V,ue]=p.useState(null),[te,F]=p.useState(!1),[ge,de]=p.useState(!1),[pe,me]=p.useState(!0),[ve,xe]=p.useState(!1),[Ce,Ae]=p.useState(null),[k,ee]=p.useState("hidden"),K=p.useRef(null),M=p.useRef(null),P=p.useRef(null),U=p.useRef(null),re=p.useRef(0);a8(K,M,{pageWide:!0});const se=p.useCallback(()=>{re.current+=1,U.current?.abort(),U.current=null,$(null),B(null)},[]);p.useEffect(()=>()=>{re.current+=1,U.current?.abort(),U.current=null},[]),p.useEffect(()=>{const vt=50+mr.length*400,Ot=setTimeout(()=>ee("playing"),50),Ir=setTimeout(()=>ee("done"),vt);return()=>{clearTimeout(Ot),clearTimeout(Ir)}},[]),p.useEffect(()=>{me(Rz()),xe(!0)},[]),p.useEffect(()=>{ve&&window.localStorage.setItem($g,pe?"1":"0")},[pe,ve]),p.useEffect(()=>{if(T===void 0){document.title="Agent Inspector";return}const Ue=e.length===1?"1 req":`${e.length} req`;document.title=`${en(T)} - ${Ue} - Agent Inspector`},[e.length,T]);const q=p.useCallback(async Ue=>{U.current?.abort();const lt=new AbortController;U.current=lt;const vt=re.current+1;re.current=vt,$(Ue),B(null);try{const Ot=await nk(e,Ue,{signal:lt.signal});if(re.current!==vt)return;if(!Ot.ok){if(Ot.canceled===!0)return;f!==void 0?f({message:Ot.message,tone:"error"}):B(Ot.message)}}finally{re.current===vt&&(U.current=null,$(null))}},[e,f]),ae=p.useCallback(()=>{P.current?.click()},[]),I=p.useCallback(Ue=>{const lt=Ue.currentTarget.files?.[0];Ue.currentTarget.value="",!(lt===void 0||m===void 0)&&(D(!0),ue(null),W(null),m(lt).then(vt=>{const Ot=vt.skipped>0?`, skipped ${String(vt.skipped)}`:"",Ir=`Imported ${String(vt.imported)} logs as ${vt.sessionId}${Ot}.`;f!==void 0?f({message:Ir,tone:"success"}):W(Ir)}).catch(vt=>{const Ot=vt instanceof Error?vt.message:"Failed to import logs";f!==void 0?f({message:Ot,tone:"error"}):ue(Ot)}).finally(()=>{D(!1)}))},[m,f]);p.useEffect(()=>{se(),Ae(null)},[se,s,o]);const O=p.useCallback(()=>{se(),W(null),ue(null),Ae(null),l()},[se,l]),Y=p.useCallback(()=>{F(!0)},[]),ie=p.useCallback(()=>{se(),W(null),ue(null),Ae(null),c!==void 0&&(de(!0),c().then(()=>{F(!1)}).catch(Ue=>{const lt=Ue instanceof Error?Ue.message:"Failed to delete stored logs";f!==void 0?f({message:lt,tone:"error"}):ue(lt)}).finally(()=>{de(!1)}))},[se,c,f]),le=p.useCallback(()=>{u!==void 0&&(se(),W(null),ue(null),Ae(null),u())},[se,u]),_e=p.useCallback(()=>{Ae(null)},[]),be=p.useCallback(()=>{me(Ue=>!Ue)},[]),he=p.useMemo(()=>_T(e),[e]),Oe=p.useMemo(()=>az(he),[he]),Re=p.useMemo(()=>NR({pinnedSessionId:T,selectedSession:s,sessions:t,logs:e}),[e,T,s,t]),xt=Re?.logs??[],Ct=Re!==null&&xt.length>0,{totalIn:mt,totalOut:Ln}=p.useMemo(()=>uf(xt),[xt]),Nt=p.useMemo(()=>iz(xt,z),[xt,z]),cn=p.useMemo(()=>HP(he),[he]),Dn=p.useMemo(()=>_A(he),[he]),De=mR(x,e.length),at=T!==void 0,tt=e.length>0,Ws=c!==void 0&&(e.length>0||s!=="__all__"),bt=s==="__all__"?"all sessions":"this session",Hs=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.",Ug=e.length===0?"Load":"Reload",Vc=s==="__all__"?"":s,qc=s==="__all__"||t.includes(s)?s:"__typed__",Li=Ct&&Re!==null?en(Re.label):s==="__all__"?"All sessions":en(s),Bg=p.useMemo(()=>CR({logs:e,conversationGroups:he,isLoading:y,timeDisplayFormat:v,slowResponseThresholdSeconds:b}),[he,y,e,b,v]),Wg=p.useCallback(Ue=>{const lt=Dn.get(Ue.id);lt!==void 0&&Ae([lt,Ue])},[Dn]),Hg=p.useCallback(Ue=>{const lt=Ue.currentTarget.value.trim();i(lt===""?"__all__":lt)},[i]),Vg=p.useCallback(Ue=>{Ue!=="__typed__"&&i(Ue)},[i]),Zc=T!==void 0?T:s==="__all__"?null:s;return r.jsxs("div",{className:"bg-background min-h-screen w-full text-foreground lg:h-screen lg:flex lg:flex-col lg:overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:be,className:oe("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 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",pe?"right-3":"lg:right-[calc(21.25rem-0.875rem)] xl:right-[calc(22.5rem-0.875rem)]"),"aria-label":pe?"Show details panel":"Hide details panel",title:pe?"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]"}),pe?r.jsx(H_,{className:"size-3.5"}):r.jsx(B_,{className:"size-3.5"})]}),pe&&r.jsx(LP,{logs:e}),r.jsxs("div",{className:oe("grid w-full min-w-0 grid-cols-1 lg:min-h-0 lg:flex-1 lg:overflow-hidden",pe?"lg:grid-cols-[minmax(0,1fr)]":"lg:grid-cols-[minmax(0,1fr)_21.25rem] xl:grid-cols-[minmax(0,1fr)_22.5rem]"),children:[!pe&&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(Az,{compact:!0,crabEntrancePhase:k,currentSessionId:Zc,logCount:e.length,uiScalePreference:H,resolvedUiScale:N,onUiScaleChange:L}),r.jsxs(Ta,{label:"Session",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsx(fo,{label:"Requests",value:e.length}),r.jsx(fo,{label:"Sessions",value:t.length}),r.jsx(fo,{label:"Input",value:Fe(Ct?mt:R)}),r.jsx(fo,{label:"Output",value:Fe(Ct?Ln:A)})]}),j!==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(wo,{progress:j})})]}),r.jsx(Ta,{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:Li,children:Li}),r.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:at?"Session workspace":"Live workspace"})]})}),r.jsx(WP,{currentSessionId:Zc,logCount:e.length}),Ct&&Re!==null&&r.jsx(Oz,{label:Re.label,logs:xt,totalIn:mt,totalOut:Ln,timeDisplayFormat:v,contextSummary:Nt,showBackLink:Re.showBackLink}),Ct&&T!==void 0&&S.length>0&&r.jsx(df,{memberships:S}),r.jsx(Ta,{label:"Filters",children:r.jsxs("div",{className:"space-y-2",children:[!E&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative",children:[r.jsx(Op,{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:Vc,onChange:Hg,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"}),Vc!==""&&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","aria-label":"Clear session filter",title:"Clear session filter",children:r.jsx(kr,{className:"size-3.5"})})]}),r.jsxs(Xn,{value:qc,onValueChange:Vg,children:[r.jsx(Qn,{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(Os,{placeholder:"All sessions"})}),r.jsxs(es,{children:[r.jsx(Qe,{value:"__all__",children:"All sessions"}),qc==="__typed__"&&r.jsxs(Qe,{value:"__typed__",children:["Typed: ",en(s)]}),t.map(Ue=>r.jsx(Qe,{value:Ue,children:en(Ue)},Ue))]})]})]}),r.jsxs(Xn,{value:o,onValueChange:a,children:[r.jsx(Qn,{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(Os,{placeholder:"All models"})}),r.jsxs(es,{children:[r.jsx(Qe,{value:"__all__",children:"All models"}),n.map(Ue=>r.jsx(Qe,{value:Ue,children:Ue},Ue))]})]})]})})]})}),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:Li})]}),m!==void 0&&r.jsxs(r.Fragment,{children:[r.jsx("input",{ref:P,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:I}),r.jsx("button",{type:"button",onClick:ae,disabled:Q,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 disabled:cursor-not-allowed disabled:opacity-50",title:"Import Agent Inspector export",children:Q?r.jsx("span",{children:"Importing..."}):r.jsxs(r.Fragment,{children:[r.jsx(Lp,{className:"size-3.5"}),r.jsx("span",{children:"Import"})]})})]}),De.redacted&&r.jsx("button",{type:"button",onClick:()=>{q("redacted")},disabled:w!==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 disabled:cursor-not-allowed disabled:opacity-50",title:"Export redacted logs as JSON ZIP",children:w==="redacted"?r.jsx("span",{children:"Exporting..."}):r.jsxs(r.Fragment,{children:[r.jsx(wr,{className:"size-3.5"}),r.jsx("span",{children:"Export"})]})}),De.raw&&r.jsx("button",{type:"button",onClick:()=>{q("raw")},disabled:w!==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 disabled:cursor-not-allowed disabled:opacity-50",title:"Export raw logs without redaction",children:w==="raw"?r.jsx("span",{children:"Exporting..."}):r.jsxs(r.Fragment,{children:[r.jsx(e_,{className:"size-3.5"}),r.jsx("span",{children:"Raw"})]})}),u!==void 0&&r.jsxs("button",{type:"button",onClick:le,disabled:y,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 disabled:cursor-not-allowed disabled:opacity-50",title:"Reload this session from stored logs",children:[r.jsx(vn,{className:oe("size-3.5",y&&"animate-spin")}),r.jsx("span",{children:Ug})]}),r.jsxs("button",{type:"button",onClick:O,disabled:!tt,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 disabled:cursor-not-allowed disabled:opacity-50",title:"Clear the current view. Stored logs remain reloadable.",children:[r.jsx(yn,{className:"size-3.5"}),r.jsx("span",{children:"Clear"})]}),c!==void 0&&r.jsxs("button",{type:"button",onClick:Y,disabled:!Ws||ge,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 disabled:cursor-not-allowed disabled:opacity-50",title:"Delete persisted history for the selected session.",children:[r.jsx(yn,{className:"size-3.5"}),r.jsx("span",{children:"Delete"})]})]}),_===void 0&&j!==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(wo,{progress:j})}),r.jsx(ff,{logs:e,pagination:_,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&&V!==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:V}),f===void 0&&Z!==null&&V===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:Z})]}),r.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[r.jsx(pz,{stats:Bg}),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:y?"Loading session data...":"No logs loaded for this session"}),r.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:en(s)}),j!==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(wo,{progress:j})}),S.length>0&&r.jsx("div",{className:"text-left",children:r.jsx(df,{memberships:S})}),!y&&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:[u!==void 0&&r.jsxs("button",{type:"button",onClick:le,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",children:[r.jsx(vn,{className:"size-3.5"}),r.jsx("span",{children:"Load session"})]}),E?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",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",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",children:"No logs loaded in the current view."}),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."}),r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(mf,{command:"ANTHROPIC_BASE_URL=http://localhost:9527/proxy <your-tool>"}),r.jsx(mf,{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:M,tabIndex:0,className:"flex flex-col gap-2 focus:outline-none",children:[r.jsx("div",{ref:K,children:r.jsx(e8,{groups:he,viewMode:h,strip:g,slowResponseThresholdSeconds:b,cacheTrends:cn,onCompareWithPrevious:Wg,comparisonPredecessors:Dn,onClearGroup:d,defaultExpanded:he.length===1,timeDisplayFormat:v})}),r.jsx("div",{className:"mt-3",children:r.jsx(ff,{logs:e,pagination:_})})]})]})]})]}),r.jsx(Rn,{open:te,onOpenChange:F,children:r.jsxs(In,{className:"border-red-500/20 bg-zinc-950 text-zinc-100 sm:max-w-md",children:[r.jsxs(Pn,{children:[r.jsxs(zn,{children:["Delete ",bt," history?"]}),r.jsx(kc,{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:Hs})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(je,{type:"button",variant:"outline",size:"sm",disabled:ge,onClick:()=>F(!1),children:"Cancel"}),r.jsx(je,{type:"button",variant:"destructive",size:"sm",disabled:ge,onClick:ie,children:ge?"Deleting...":"Delete history"})]})]})}),Ce!==null&&r.jsx(p.Suspense,{fallback:null,children:r.jsx(hE,{left:Ce[0],right:Ce[1],leftDisplayNumber:cf(Ce[0],Oe),rightDisplayNumber:cf(Ce[1],Oe),onClose:_e})})]})}function Dz(e,t,n){return t==="__all__"&&n==="__all__"?e:e.filter(s=>!(t!=="__all__"&&s.sessionId!==t||n!=="__all__"&&s.model!==n))}function po(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 Vn(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 $z=Jt([J({type:Ee("init"),logs:fe(lr)}),J({type:Ee("update"),log:lr})]),Fz=J({logs:fe(lr),total:G().int().nonnegative(),limit:G().int().positive(),hasOlder:Le(),hasNewer:Le(),oldestLogId:G().int().positive().nullable(),newestLogId:G().int().positive().nullable()}),Uz=fe(C()),yf=J({success:Le(),cleared:G().int().nonnegative(),logFilesRewritten:G().int().nonnegative().optional(),chunkFilesDeleted:G().int().nonnegative(),sessionArchiveLogsDeleted:G().int().nonnegative().optional()});function Bz(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 ho(e){const t=new Set;for(const n of e)n.sessionId!==null&&n.sessionId!==""&&t.add(n.sessionId);return[...t]}function Wz(e){const t=new Set;for(const n of e)n.model!==null&&n.model!==""&&t.add(n.model);return[...t]}const Hz=100,Vz=12,qz=1800,Hc=100,Xo=500,Fg=200,kl=2e4,Zz=1e4;function Gz(e){const t=new URLSearchParams;e!==void 0&&(t.set("sessionId",e),t.set("compact","1"));const n=t.toString();return n.length>0?`/api/logs/stream?${n}`:"/api/logs/stream"}function Kz(e,t,n=Hc){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 or(e,t,n=Hc){return Ze(Kz(e,t,n),Fz,kl)}async function Jz(e,t){const n=new Set;let s=await or(e,{kind:"oldest"},Xo);for(const i of s.logs)n.add(i.id);t(n.size,1);let o=1;for(;s.hasNewer&&s.newestLogId!==null&&o<Fg;){s=await or(e,{kind:"newer",afterLogId:s.newestLogId},Xo);for(const i of s.logs)n.add(i.id);o+=1,t(n.size,o)}return{ids:[...n],truncated:s.hasNewer}}async function Yz(){try{return{deleted:(await ht("/api/groups",wp,{method:"DELETE"})).deleted,ok:!0}}catch{return{deleted:0,ok:!1}}}function tM({initialSessionId:e}={}){const[t,n]=p.useState([]),[s,o]=p.useState(e??"__all__"),[i,a]=p.useState("__all__"),[l,c]=p.useState([]),{notice:u,showToast:d,dismissToast:f}=ig(),[m,h]=p.useState(e===void 0),[x,g]=p.useState(null),[b,v]=p.useState(e!==void 0),[y,_]=p.useState(void 0),[j,S]=p.useState([]),[,E]=p.useTransition(),T=p.useRef(null),R=p.useRef(null),A=p.useRef(null),z=p.useRef(0),H=p.useRef(null),N=p.useRef(null),L=p.useRef(new Map),w=p.useRef([]),$=p.useRef(null),X=p.useCallback(I=>{d({message:I,tone:"error"})},[d]),B=p.useCallback(()=>{N.current!==null&&(clearInterval(N.current),N.current=null),H.current=null,_(void 0)},[]),Q=p.useCallback((I,O,Y=0,ie=0)=>{N.current!==null&&clearInterval(N.current);const le=Date.now();H.current=le;const _e=()=>{z.current===O&&_({label:I,elapsedMs:Date.now()-le,timeoutMs:kl,loadedLogs:Y,loadedPages:ie})};_e(),N.current=setInterval(_e,250)},[]),D=p.useCallback((I,O,Y,ie)=>{const le=H.current;le===null||z.current!==O||_({label:I,elapsedMs:Date.now()-le,timeoutMs:kl,loadedLogs:Y,loadedPages:ie})},[]),Z=p.useMemo(()=>Dz(t,s,i),[t,s,i]),W=p.useMemo(()=>Vn(l,ho(t)),[t,l]),V=p.useMemo(()=>Wz(t),[t]),ue=p.useCallback(()=>{ht("/api/sessions",Uz).then(I=>{c(O=>Vn(O,I))}).catch(()=>{})},[]),te=p.useCallback(()=>{$.current=null;const I=w.current;w.current=[],I.length!==0&&E(()=>{n(O=>{const Y=po(O,I);return L.current=hn(Y),Y})})},[E]),F=p.useCallback(I=>{w.current.push(I),$.current===null&&($.current=setTimeout(te,Hz))},[te]),ge=p.useCallback(()=>{T.current&&T.current.close(),h(!1);const I=new EventSource(Gz(e));T.current=I,I.onmessage=O=>{try{const Y=String(O.data),ie=JSON.parse(Y),le=$z.safeParse(ie);if(!le.success){X("Failed to parse SSE data");return}const _e=le.data;_e.type==="init"?($.current!==null&&(clearTimeout($.current),$.current=null),w.current=[],n(be=>{const he=po(be,_e.logs);return L.current=hn(he),he}),c(be=>Vn(be,ho(_e.logs))),h(!0),f()):_e.type==="update"&&(c(be=>_e.log.sessionId===null||_e.log.sessionId===""?be:Vn(be,[_e.log.sessionId])),F(_e.log))}catch{X("Failed to parse SSE data")}},I.onerror=()=>{X("SSE connection lost, reconnecting..."),h(!0),I.close(),R.current!==null&&clearTimeout(R.current),R.current=setTimeout(ge,3e3)}},[f,e,F,X]),de=p.useCallback(I=>{if(e===void 0)return;const O=z.current+1;z.current=O,v(!0),Q("Loading session logs",O),f(),or(e,I).then(Y=>{if(z.current!==O)return;const ie=Y.logs;L.current=hn(ie),n(ie),g(Y),o(e),v(!1),B(),f()}).catch(Y=>{z.current===O&&(n([]),g(null),v(!1),B(),X(Y instanceof Error?Y.message:"Failed to load session logs"))})},[f,e,X,Q,B]),pe=p.useCallback(I=>{const O=z.current+1;z.current=O,v(!0),Q("Reloading full session",O),f(),(async()=>{const Y=[];let ie=await or(I,{kind:"oldest"},Xo);Y.push(...ie.logs),D("Reloading full session",O,Y.length,1);let le=1;for(;ie.hasNewer&&ie.newestLogId!==null&&le<Fg;)ie=await or(I,{kind:"newer",afterLogId:ie.newestLogId},Xo),Y.push(...ie.logs),le+=1,D("Reloading full session",O,Y.length,le);z.current===O&&(n(_e=>{const be=po(_e,Y);return L.current=hn(be),be}),c(_e=>Vn(_e,[I])),v(!1),B(),ie.hasNewer?d({message:`Loaded ${String(Y.length)} logs for this session. More history is available.`,tone:"success"}):f())})().catch(Y=>{z.current===O&&(v(!1),B(),X(Y instanceof Error?Y.message:"Failed to reload session logs"))})},[f,X,d,Q,B,D]);p.useEffect(()=>{if(e===void 0){S([]);return}let I=!1;return Ze("/api/groups",jp,Zz).then(O=>O.groups).then(O=>{I||O===null||S(Bz(O,e))}).catch(()=>{I||S([])}),()=>{I=!0}},[e]),p.useEffect(()=>{ue()},[ue]),p.useEffect(()=>()=>{B()},[B]),p.useEffect(()=>{e!==void 0&&de({kind:"newest"})},[e,de]),p.useEffect(()=>{e===void 0&&s!=="__all__"&&pe(s)},[e,pe,s]),p.useEffect(()=>{if(e===void 0)return ge(),()=>{T.current&&(T.current.close(),T.current=null),R.current!==null&&(clearTimeout(R.current),R.current=null),$.current!==null&&(clearTimeout($.current),$.current=null)}},[ge,e]),p.useEffect(()=>{const I=window.location.hash;if(!I.startsWith("#log-")||A.current===I)return;const O=I.slice(1),Y=Number(O.replace(/^log-/,""));Number.isInteger(Y)&&Y>0&&hr({logId:Y,tab:"request"});let ie=!1,le=0,_e=null,be=null;const he=()=>{if(ie)return;const Oe=document.getElementById(O);if(Oe!==null){A.current=I,Oe.scrollIntoView({block:"center",behavior:"smooth"}),Oe instanceof HTMLElement&&(_e=Oe,Oe.setAttribute("data-deep-link-highlight","true"),be=window.setTimeout(()=>{Oe.removeAttribute("data-deep-link-highlight")},qz),Oe.focus({preventScroll:!0}),Oe.getAttribute("data-nav-action")==="expand"&&Oe.click());return}le+=1,le<Vz&&window.setTimeout(he,100)};return he(),()=>{ie=!0,be!==null&&window.clearTimeout(be),_e!==null&&_e.removeAttribute("data-deep-link-highlight")}},[Z.length]);const me=p.useCallback(()=>{const I=ho(t);B(),v(!1),L.current.clear(),n([]),g(null),c(O=>Vn(O,I)),d({message:"Cleared the current view. Stored logs are still reloadable.",tone:"success"})},[t,d,B]),ve=p.useCallback(I=>{if(I.length===0)return;const O=new Set(I);n(Y=>{const ie=Y.filter(_e=>O.has(_e.id)),le=Y.filter(_e=>!O.has(_e.id));return c(_e=>Vn(_e,ho(ie))),L.current=hn(le),le}),d({message:"Cleared this group from the current view.",tone:"success"})},[d]),xe=p.useCallback(async()=>{const I=z.current+1;z.current=I,v(!0),B(),f();try{if(s==="__all__"){Q("Deleting stored history",I);const be=await ht("/api/logs",yf,{method:"DELETE"}),he=await Yz();if(z.current!==I)return;n([]),L.current.clear(),g(null),c([]),S([]),v(!1),B();const Oe=he.ok?` Cleared ${he.deleted.toString()} group${he.deleted===1?"":"s"}.`:" Group cleanup failed; open Groups to retry Clear.";d({message:`Deleted ${be.cleared.toString()} stored log${be.cleared===1?"":"s"} across all sessions.${Oe}`,tone:he.ok?"success":"error"});return}const O=s;Q("Deleting session history",I);const Y=await Jz(O,(be,he)=>{D("Deleting session history",I,be,he)}),ie=new Set(Y.ids);for(const be of t)be.sessionId===O&&ie.add(be.id);const le=[...ie].filter(be=>Number.isInteger(be)&&be>=0);if(le.length===0){if(z.current!==I)return;n(be=>{const he=be.filter(Oe=>Oe.sessionId!==O);return L.current=hn(he),he}),g(be=>be===null?null:{...be,logs:be.logs.filter(he=>he.sessionId!==O)}),c(be=>be.filter(he=>he!==O)),v(!1),B(),d({message:"No stored log records were found for this session.",tone:"success"});return}const _e=await ht("/api/logs",yf,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({ids:le})});if(z.current!==I)return;n(be=>{const he=be.filter(Oe=>Oe.sessionId!==O);return L.current=hn(he),he}),g(be=>be===null?null:{...be,logs:be.logs.filter(he=>he.sessionId!==O)}),c(be=>be.filter(he=>he!==O)),v(!1),B(),d({message:`Deleted ${_e.cleared.toString()} stored log${_e.cleared===1?"":"s"} for this session${Y.truncated?". More history may remain.":"."}`,tone:Y.truncated?"error":"success"})}finally{z.current===I&&(v(!1),B())}},[t,f,s,d,Q,B,D]),Ce=p.useCallback(()=>{if(e!==void 0){de({kind:"newest"});return}if(s==="__all__"){ue();return}pe(s)},[e,de,ue,pe,s]),Ae=p.useCallback(async I=>{const O=new FormData;O.set("file",I);const Y=await ht("/api/logs/import",Ly,{method:"POST",body:O});return n(ie=>{const le=new Set(Y.logs.map(be=>be.id)),_e=po(ie.filter(be=>!le.has(be.id)),Y.logs);return L.current=hn(_e),_e}),o(Y.sessionId),a("__all__"),g(null),f(),Y},[f]),{strip:k,captureMode:ee,slowResponseThresholdSeconds:K,timeDisplayFormat:M}=Hl(),P=ee,U=p.useCallback(()=>{de({kind:"oldest"})},[de]),re=p.useCallback(()=>{de({kind:"newest"})},[de]),se=p.useCallback(()=>{const I=t[0],O=x?.oldestLogId??I?.id??null;O!==null&&de({kind:"older",beforeLogId:O})},[t,de,x]),q=p.useCallback(()=>{const I=t[t.length-1],O=x?.newestLogId??I?.id??null;O!==null&&de({kind:"newer",afterLogId:O})},[t,de,x]),ae=p.useMemo(()=>{if(e!==void 0)return{isLoading:b,loadProgress:y,total:x?.total??null,pageSize:x?.limit??Hc,hasOlder:x?.hasOlder??!1,hasNewer:x?.hasNewer??!1,oldestLogId:x?.oldestLogId??null,newestLogId:x?.newestLogId??null,onOldest:U,onOlder:se,onNewer:q,onNewest:re}},[e,re,q,se,U,x,y,b]);return r.jsxs(r.Fragment,{children:[r.jsx(ag,{notice:u,onDismiss:f}),r.jsx($5,{}),r.jsx(Lz,{logs:Z,sessions:W,models:V,selectedSession:s,selectedModel:i,onSessionChange:o,onModelChange:a,onClearAll:me,onDeleteCurrentView:xe,onReloadSession:e!==void 0||s!=="__all__"?Ce:void 0,onClearGroup:ve,onNotify:d,onImportLogs:e===void 0?Ae:void 0,isLoading:e===void 0&&!m||b,pagination:ae,sessionLoadProgress:y,sessionMemberships:j,viewMode:P,captureMode:ee,strip:k,slowResponseThresholdSeconds:K,timeDisplayFormat:M,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{Qz as $,J as A,ze as B,Ww as C,Rn as D,G as E,fe as F,hr as G,ri as H,Le as I,C as J,lr as K,vE as L,Pp as M,J8 as N,__ as O,tM as P,c8 as Q,r5 as R,p8 as S,B0 as T,l8 as U,nh as V,eM as W,kr as X,rt as Y,Ie as Z,KE as _,wT as a,Np as a0,JE as a1,YE as a2,Fs as a3,il as a4,Wo as a5,cr as a6,ke as a7,bn as a8,Qk as a9,Ye as aa,np as ab,fE as ac,yw as ad,oe as b,ce as c,Ma as d,zp as e,Fe as f,z0 as g,jt as h,qe as i,Pt as j,At as k,Ze as l,In as m,Pn as n,zn as o,t5 as p,W0 as q,fr as r,Tt as s,Et as t,Xl as u,je as v,jn as w,dt as x,ft as y,pt as z};