@tonyclaw/agent-inspector 2.1.17 → 2.1.18

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-B9sLBHw5.js → CompareDrawer-Fqqw5Lci.js} +1 -1
  3. package/.output/public/assets/{ProxyViewerContainer-DbWjc_BE.js → ProxyViewerContainer-CP_RzwW9.js} +31 -31
  4. package/.output/public/assets/{ReplayDialog-D9I9W9n3.js → ReplayDialog-hYhz_i6W.js} +1 -1
  5. package/.output/public/assets/{RequestAnatomy-DGXK_Rii.js → RequestAnatomy-CTuWbtwC.js} +1 -1
  6. package/.output/public/assets/{ResponseView-df_JzwsS.js → ResponseView-CsZ7S5Gv.js} +2 -2
  7. package/.output/public/assets/{StreamingChunkSequence-i3DM5IKL.js → StreamingChunkSequence-PIbJMotU.js} +1 -1
  8. package/.output/public/assets/_sessionId-CUGA9qU3.js +1 -0
  9. package/.output/public/assets/{index-Dqc2r1ea.js → index-F7mynwuH.js} +1 -1
  10. package/.output/public/assets/index-G4dTUobw.js +1 -0
  11. package/.output/public/assets/index-gvYkgMPF.css +1 -0
  12. package/.output/public/assets/{json-viewer-D3QWQlSB.js → json-viewer-DCXtNmmD.js} +1 -1
  13. package/.output/public/assets/{main-ZhxhOCmF.js → main-BJZf7_Ib.js} +2 -2
  14. package/.output/server/{_sessionId-YFrP0lZP.mjs → _sessionId-DjSHDNh8.mjs} +2 -2
  15. package/.output/server/_ssr/{CompareDrawer-qC3adEeq.mjs → CompareDrawer-Dal52IFo.mjs} +2 -2
  16. package/.output/server/_ssr/{ProxyViewerContainer-DCZIJC2b.mjs → ProxyViewerContainer-CVqFZGff.mjs} +1923 -1918
  17. package/.output/server/_ssr/{ReplayDialog-CvX4XYCi.mjs → ReplayDialog-BOEgdMes.mjs} +3 -3
  18. package/.output/server/_ssr/{RequestAnatomy-HQfrxjO1.mjs → RequestAnatomy-gch7_vCV.mjs} +2 -2
  19. package/.output/server/_ssr/{ResponseView-QSlSD11e.mjs → ResponseView-lEWPy-H4.mjs} +2 -2
  20. package/.output/server/_ssr/{StreamingChunkSequence-DTAiwlnI.mjs → StreamingChunkSequence-DnudbJ1O.mjs} +2 -2
  21. package/.output/server/_ssr/{index-D_EzfXaN.mjs → index-Cza8zDrW.mjs} +2 -2
  22. package/.output/server/_ssr/index.mjs +2 -2
  23. package/.output/server/_ssr/{json-viewer-CrIX0e0Q.mjs → json-viewer-C2lIVEX3.mjs} +2 -2
  24. package/.output/server/_ssr/{router-__o2wrfO.mjs → router-bF9uzd1k.mjs} +545 -22
  25. package/.output/server/{_tanstack-start-manifest_v-DbqyLpsI.mjs → _tanstack-start-manifest_v-ErvW-mtr.mjs} +1 -1
  26. package/.output/server/index.mjs +70 -70
  27. package/package.json +1 -1
  28. package/src/components/proxy-viewer/ThreadConnector.tsx +72 -88
  29. package/src/components/proxy-viewer/TurnGroup.tsx +1 -0
  30. package/src/mcp/server.ts +275 -0
  31. package/src/mcp/toolHandlers.ts +380 -3
  32. package/src/proxy/logSearch.ts +3 -0
  33. package/src/proxy/store.ts +40 -15
  34. package/src/routes/api/logs.ts +8 -2
  35. package/.output/public/assets/_sessionId-CTpCHdFh.js +0 -1
  36. package/.output/public/assets/index-Blqvndcn.js +0 -1
  37. package/.output/public/assets/index-Cs79WRQj.css +0 -1
@@ -1,7 +1,7 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CompareDrawer-B9sLBHw5.js","assets/main-ZhxhOCmF.js","assets/ReplayDialog-D9I9W9n3.js","assets/ResponseView-df_JzwsS.js","assets/RequestAnatomy-DGXK_Rii.js","assets/StreamingChunkSequence-i3DM5IKL.js","assets/json-viewer-D3QWQlSB.js"])))=>i.map(i=>d[i]);
2
- import{u as Tn,a as Yu,r as p,j as s,c as Qr,g as Xm,b as Xu,d as Fr,e as Qm,f as ot,h as Qu,_ as En}from"./main-ZhxhOCmF.js";function ee(e,t,n){function r(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;r(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(a,"init",{value:r}),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 Kn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ed extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const td={};function sn(e){return td}function nd(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function Ai(e,t){return typeof t=="bigint"?t.toString():t}function mo(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ja(e){return e==null}function Sa(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function eg(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}const i=n>o?n:o,a=Number.parseInt(e.toFixed(i).replace(".","")),l=Number.parseInt(t.toFixed(i).replace(".",""));return a%l/10**i}const Ll=Symbol("evaluating");function Ie(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ll)return r===void 0&&(r=Ll,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function An(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function un(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Dl(e){return JSON.stringify(e)}function tg(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const rd="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Er(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const ng=mo(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Qn(e){if(Er(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Er(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function sd(e){return Qn(e)?{...e}:Array.isArray(e)?[...e]:e}const rg=new Set(["string","number","symbol"]);function er(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dn(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function we(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 sg(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const og={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 ig(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=un(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 An(this,"shape",a),a},checks:[]});return dn(e,i)}function ag(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=un(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 An(this,"shape",a),a},checks:[]});return dn(e,i)}function lg(e,t){if(!Qn(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=un(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return An(this,"shape",i),i}});return dn(e,o)}function cg(e,t){if(!Qn(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=un(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return An(this,"shape",r),r}});return dn(e,n)}function ug(e,t){const n=un(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return An(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return dn(e,n)}function dg(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=un(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 An(this,"shape",c),c},checks:[]});return dn(t,a)}function fg(e,t,n){const r=un(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 An(this,"shape",i),i}});return dn(t,r)}function Zn(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 Vn(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function es(e){return typeof e=="string"?e:e?.message}function on(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=es(e.inst?._zod.def?.error?.(e))??es(t?.error?.(e))??es(n.customError?.(e))??es(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Ca(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ar(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const od=(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,Ai,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},id=ee("$ZodError",od),ad=ee("$ZodError",od,{Parent:Error});function pg(e,t=n=>n.message){const n={},r=[];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))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function hg(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>r({issues:a}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let a=n,l=0;for(;l<i.path.length;){const c=i.path[l];l===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(i))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return r(e),n}const Na=e=>(t,n,r,o)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Kn;if(a.issues.length){const l=new(o?.Err??e)(a.issues.map(c=>on(c,i,sn())));throw rd(l,o?.callee),l}return a.value},Ta=e=>async(t,n,r,o)=>{const i=r?Object.assign(r,{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=>on(c,i,sn())));throw rd(l,o?.callee),l}return a.value},go=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Kn;return i.issues.length?{success:!1,error:new(e??id)(i.issues.map(a=>on(a,o,sn())))}:{success:!0,data:i.value}},mg=go(ad),xo=e=>async(t,n,r)=>{const o=r?Object.assign(r,{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=>on(a,o,sn())))}:{success:!0,data:i.value}},gg=xo(ad),xg=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Na(e)(t,n,o)},bg=e=>(t,n,r)=>Na(e)(t,n,r),vg=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ta(e)(t,n,o)},yg=e=>async(t,n,r)=>Ta(e)(t,n,r),wg=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return go(e)(t,n,o)},kg=e=>(t,n,r)=>go(e)(t,n,r),_g=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return xo(e)(t,n,o)},jg=e=>async(t,n,r)=>xo(e)(t,n,r),Sg=/^[cC][^\s-]{8,}$/,Cg=/^[0-9a-z]+$/,Ng=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Tg=/^[0-9a-vA-V]{20}$/,Eg=/^[A-Za-z0-9]{27}$/,Ag=/^[a-zA-Z0-9_-]{21}$/,Rg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ig=/^([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})$/,$l=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)$/,zg=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Pg="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Og(){return new RegExp(Pg,"u")}const Mg=/^(?:(?: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])$/,Lg=/^(([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}|:))$/,Dg=/^((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])$/,$g=/^(([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])$/,Fg=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ld=/^[A-Za-z0-9_-]*$/,Bg=/^\+[1-9]\d{6,14}$/,cd="(?:(?:\\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])))",Ug=new RegExp(`^${cd}$`);function ud(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 Wg(e){return new RegExp(`^${ud(e)}$`)}function Hg(e){const t=ud({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${cd}T(?:${r})$`)}const Zg=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Vg=/^-?\d+$/,dd=/^-?\d+(?:\.\d+)?$/,qg=/^(?:true|false)$/i,Kg=/^null$/i,Gg=/^[^A-Z]*$/,Jg=/^[^a-z]*$/,it=ee("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),fd={number:"number",bigint:"bigint",object:"date"},pd=ee("$ZodCheckLessThan",(e,t)=>{it.init(e,t);const n=fd[typeof t.value];e._zod.onattach.push(r=>{const o=r._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=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hd=ee("$ZodCheckGreaterThan",(e,t)=>{it.init(e,t);const n=fd[typeof t.value];e._zod.onattach.push(r=>{const o=r._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=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Yg=ee("$ZodCheckMultipleOf",(e,t)=>{it.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.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):eg(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})}}),Xg=ee("$ZodCheckNumberFormat",(e,t)=>{it.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=og[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=Vg)}),e._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,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:r,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:r,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})}}),Qg=ee("$ZodCheckMaxLength",(e,t)=>{var n;it.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ja(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const a=Ca(o);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ex=ee("$ZodCheckMinLength",(e,t)=>{var n;it.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ja(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const a=Ca(o);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),tx=ee("$ZodCheckLengthEquals",(e,t)=>{var n;it.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ja(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const a=Ca(o),l=i>t.length;r.issues.push({origin:a,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),bo=ee("$ZodCheckStringFormat",(e,t)=>{var n,r;it.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})}):(r=e._zod).check??(r.check=()=>{})}),nx=ee("$ZodCheckRegex",(e,t)=>{bo.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})}}),rx=ee("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Gg),bo.init(e,t)}),sx=ee("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Jg),bo.init(e,t)}),ox=ee("$ZodCheckIncludes",(e,t)=>{it.init(e,t);const n=er(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),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})}}),ix=ee("$ZodCheckStartsWith",(e,t)=>{it.init(e,t);const n=new RegExp(`^${er(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),ax=ee("$ZodCheckEndsWith",(e,t)=>{it.init(e,t);const n=new RegExp(`.*${er(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),lx=ee("$ZodCheckOverwrite",(e,t)=>{it.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class cx{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 r=t.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CompareDrawer-Fqqw5Lci.js","assets/main-BJZf7_Ib.js","assets/ReplayDialog-hYhz_i6W.js","assets/ResponseView-CsZ7S5Gv.js","assets/RequestAnatomy-CTuWbtwC.js","assets/StreamingChunkSequence-PIbJMotU.js","assets/json-viewer-DCXtNmmD.js"])))=>i.map(i=>d[i]);
2
+ import{u as Tn,a as Qu,r as p,j as s,c as es,g as tg,b as ed,d as Br,e as ng,f as ot,h as td,_ as En}from"./main-BJZf7_Ib.js";function ee(e,t,n){function r(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;r(u,l),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(a,"init",{value:r}),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 Kn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class nd extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const rd={};function sn(e){return rd}function sd(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function Ii(e,t){return typeof t=="bigint"?t.toString():t}function go(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ca(e){return e==null}function Na(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function rg(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}const i=n>o?n:o,a=Number.parseInt(e.toFixed(i).replace(".","")),l=Number.parseInt(t.toFixed(i).replace(".",""));return a%l/10**i}const $l=Symbol("evaluating");function Ie(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==$l)return r===void 0&&(r=$l,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function An(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function un(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Fl(e){return JSON.stringify(e)}function sg(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const od="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Er(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const og=go(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Qn(e){if(Er(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Er(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function id(e){return Qn(e)?{...e}:Array.isArray(e)?[...e]:e}const ig=new Set(["string","number","symbol"]);function er(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dn(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function we(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 ag(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const lg={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 cg(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=un(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 An(this,"shape",a),a},checks:[]});return dn(e,i)}function ug(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=un(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 An(this,"shape",a),a},checks:[]});return dn(e,i)}function dg(e,t){if(!Qn(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=un(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return An(this,"shape",i),i}});return dn(e,o)}function fg(e,t){if(!Qn(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=un(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return An(this,"shape",r),r}});return dn(e,n)}function pg(e,t){const n=un(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return An(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return dn(e,n)}function hg(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=un(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 An(this,"shape",c),c},checks:[]});return dn(t,a)}function mg(e,t,n){const r=un(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 An(this,"shape",i),i}});return dn(t,r)}function Zn(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 Vn(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function ts(e){return typeof e=="string"?e:e?.message}function on(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=ts(e.inst?._zod.def?.error?.(e))??ts(t?.error?.(e))??ts(n.customError?.(e))??ts(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Ta(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ar(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const ad=(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,Ii,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ld=ee("$ZodError",ad),cd=ee("$ZodError",ad,{Parent:Error});function gg(e,t=n=>n.message){const n={},r=[];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))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function xg(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>r({issues:a}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let a=n,l=0;for(;l<i.path.length;){const c=i.path[l];l===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(i))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return r(e),n}const Ea=e=>(t,n,r,o)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Kn;if(a.issues.length){const l=new(o?.Err??e)(a.issues.map(c=>on(c,i,sn())));throw od(l,o?.callee),l}return a.value},Aa=e=>async(t,n,r,o)=>{const i=r?Object.assign(r,{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=>on(c,i,sn())));throw od(l,o?.callee),l}return a.value},xo=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Kn;return i.issues.length?{success:!1,error:new(e??ld)(i.issues.map(a=>on(a,o,sn())))}:{success:!0,data:i.value}},bg=xo(cd),bo=e=>async(t,n,r)=>{const o=r?Object.assign(r,{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=>on(a,o,sn())))}:{success:!0,data:i.value}},vg=bo(cd),yg=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ea(e)(t,n,o)},wg=e=>(t,n,r)=>Ea(e)(t,n,r),kg=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Aa(e)(t,n,o)},_g=e=>async(t,n,r)=>Aa(e)(t,n,r),jg=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return xo(e)(t,n,o)},Sg=e=>(t,n,r)=>xo(e)(t,n,r),Cg=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return bo(e)(t,n,o)},Ng=e=>async(t,n,r)=>bo(e)(t,n,r),Tg=/^[cC][^\s-]{8,}$/,Eg=/^[0-9a-z]+$/,Ag=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Rg=/^[0-9a-vA-V]{20}$/,Ig=/^[A-Za-z0-9]{27}$/,zg=/^[a-zA-Z0-9_-]{21}$/,Pg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Og=/^([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})$/,Bl=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)$/,Mg=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Lg="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Dg(){return new RegExp(Lg,"u")}const $g=/^(?:(?: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])$/,Fg=/^(([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}|:))$/,Bg=/^((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])$/,Ug=/^(([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])$/,Wg=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ud=/^[A-Za-z0-9_-]*$/,Hg=/^\+[1-9]\d{6,14}$/,dd="(?:(?:\\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])))",Zg=new RegExp(`^${dd}$`);function fd(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 Vg(e){return new RegExp(`^${fd(e)}$`)}function qg(e){const t=fd({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${dd}T(?:${r})$`)}const Kg=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Gg=/^-?\d+$/,pd=/^-?\d+(?:\.\d+)?$/,Jg=/^(?:true|false)$/i,Yg=/^null$/i,Xg=/^[^A-Z]*$/,Qg=/^[^a-z]*$/,it=ee("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),hd={number:"number",bigint:"bigint",object:"date"},md=ee("$ZodCheckLessThan",(e,t)=>{it.init(e,t);const n=hd[typeof t.value];e._zod.onattach.push(r=>{const o=r._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=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),gd=ee("$ZodCheckGreaterThan",(e,t)=>{it.init(e,t);const n=hd[typeof t.value];e._zod.onattach.push(r=>{const o=r._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=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ex=ee("$ZodCheckMultipleOf",(e,t)=>{it.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.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):rg(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})}}),tx=ee("$ZodCheckNumberFormat",(e,t)=>{it.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=lg[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=Gg)}),e._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,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:r,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:r,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})}}),nx=ee("$ZodCheckMaxLength",(e,t)=>{var n;it.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Ca(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const a=Ta(o);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),rx=ee("$ZodCheckMinLength",(e,t)=>{var n;it.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Ca(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const a=Ta(o);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),sx=ee("$ZodCheckLengthEquals",(e,t)=>{var n;it.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Ca(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const a=Ta(o),l=i>t.length;r.issues.push({origin:a,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),vo=ee("$ZodCheckStringFormat",(e,t)=>{var n,r;it.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})}):(r=e._zod).check??(r.check=()=>{})}),ox=ee("$ZodCheckRegex",(e,t)=>{vo.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})}}),ix=ee("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Xg),vo.init(e,t)}),ax=ee("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Qg),vo.init(e,t)}),lx=ee("$ZodCheckIncludes",(e,t)=>{it.init(e,t);const n=er(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),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})}}),cx=ee("$ZodCheckStartsWith",(e,t)=>{it.init(e,t);const n=new RegExp(`^${er(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),ux=ee("$ZodCheckEndsWith",(e,t)=>{it.init(e,t);const n=new RegExp(`.*${er(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),dx=ee("$ZodCheckOverwrite",(e,t)=>{it.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class fx{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 r=t.split(`
3
3
  `).filter(a=>a),o=Math.min(...r.map(a=>a.length-a.trimStart().length)),i=r.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 ux={major:4,minor:3,patch:6},We=ee("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ux;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const i of o._zod.onattach)i(e);if(r.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=Zn(a),d;for(const f of l){if(f._zod.def.when){if(!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 Kn;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,a.issues.length!==m&&(u||(u=Zn(a,m)))});else{if(a.issues.length===m)continue;u||(u=Zn(a,m))}}return d?d.then(()=>a):a},i=(a,l,c)=>{if(Zn(a))return a.aborted=!0,a;const u=o(l,r,c);if(u instanceof Promise){if(c.async===!1)throw new Kn;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 Kn;return c.then(u=>o(u,r,l))}return o(c,r,l)}}Ie(e,"~standard",()=>({validate:o=>{try{const i=mg(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return gg(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Ea=ee("$ZodString",(e,t)=>{We.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Zg(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Ze=ee("$ZodStringFormat",(e,t)=>{bo.init(e,t),Ea.init(e,t)}),dx=ee("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ig),Ze.init(e,t)}),fx=ee("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=$l(r))}else t.pattern??(t.pattern=$l());Ze.init(e,t)}),px=ee("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=zg),Ze.init(e,t)}),hx=ee("$ZodURL",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);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=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),mx=ee("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Og()),Ze.init(e,t)}),gx=ee("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ag),Ze.init(e,t)}),xx=ee("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Sg),Ze.init(e,t)}),bx=ee("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Cg),Ze.init(e,t)}),vx=ee("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ng),Ze.init(e,t)}),yx=ee("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Tg),Ze.init(e,t)}),wx=ee("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Eg),Ze.init(e,t)}),kx=ee("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Hg(t)),Ze.init(e,t)}),_x=ee("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ug),Ze.init(e,t)}),jx=ee("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Wg(t)),Ze.init(e,t)}),Sx=ee("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Rg),Ze.init(e,t)}),Cx=ee("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Mg),Ze.init(e,t),e._zod.bag.format="ipv4"}),Nx=ee("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Lg),Ze.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})}}}),Tx=ee("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Dg),Ze.init(e,t)}),Ex=ee("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=$g),Ze.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,i]=r;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 md(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Ax=ee("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Fg),Ze.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{md(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Rx(e){if(!ld.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return md(n)}const Ix=ee("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ld),Ze.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Rx(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),zx=ee("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Bg),Ze.init(e,t)});function Px(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Ox=ee("$ZodJWT",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{Px(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),gd=ee("$ZodNumber",(e,t)=>{We.init(e,t),e._zod.pattern=e._zod.bag.pattern??dd,e._zod.parse=(n,r)=>{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}}),Mx=ee("$ZodNumberFormat",(e,t)=>{Xg.init(e,t),gd.init(e,t)}),Lx=ee("$ZodBoolean",(e,t)=>{We.init(e,t),e._zod.pattern=qg,e._zod.parse=(n,r)=>{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}}),Dx=ee("$ZodNull",(e,t)=>{We.init(e,t),e._zod.pattern=Kg,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),$x=ee("$ZodUnknown",(e,t)=>{We.init(e,t),e._zod.parse=n=>n}),Fx=ee("$ZodNever",(e,t)=>{We.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Fl(e,t,n){e.issues.length&&t.issues.push(...Vn(n,e.issues)),t.value[n]=e.value}const Bx=ee("$ZodArray",(e,t)=>{We.init(e,t),e._zod.parse=(n,r)=>{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:[]},r);c instanceof Promise?i.push(c.then(u=>Fl(u,n,a))):Fl(c,n,a)}return i.length?Promise.all(i).then(()=>n):n}});function zs(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...Vn(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function xd(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=sg(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function bd(e,t,n,r,o,i){const a=[],l=o.keySet,c=o.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const f in t){if(l.has(f))continue;if(u==="never"){a.push(f);continue}const m=c.run({value:t[f],issues:[]},r);m instanceof Promise?e.push(m.then(h=>zs(h,n,f,t,d))):zs(m,n,f,t,d)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const Ux=ee("$ZodObject",(e,t)=>{if(We.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 r=mo(()=>xd(t));Ie(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=Er,i=t.catchall;let a;e._zod.parse=(l,c)=>{a??(a=r.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],v=h._zod.optout==="optional",g=h._zod.run({value:u[m],issues:[]},c);g instanceof Promise?d.push(g.then(x=>zs(x,l,m,u,v))):zs(g,l,m,u,v)}return i?bd(d,u,l,c,r.value,e):d.length?Promise.all(d).then(()=>l):l}}),Wx=ee("$ZodObjectJIT",(e,t)=>{Ux.init(e,t);const n=e._zod.parse,r=mo(()=>xd(t)),o=m=>{const h=new cx(["shape","payload","ctx"]),v=r.value,g=_=>{const j=Dl(_);return`shape[${j}]._zod.run({ value: input[${j}], issues: [] }, ctx)`};h.write("const input = payload.value;");const x=Object.create(null);let b=0;for(const _ of v.keys)x[_]=`key_${b++}`;h.write("const newResult = {};");for(const _ of v.keys){const j=x[_],S=Dl(_),C=m[_]?._zod?.optout==="optional";h.write(`const ${j} = ${g(_)};`),C?h.write(`
4
+ `))}}const px={major:4,minor:3,patch:6},We=ee("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=px;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const i of o._zod.onattach)i(e);if(r.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=Zn(a),d;for(const f of l){if(f._zod.def.when){if(!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 Kn;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,a.issues.length!==m&&(u||(u=Zn(a,m)))});else{if(a.issues.length===m)continue;u||(u=Zn(a,m))}}return d?d.then(()=>a):a},i=(a,l,c)=>{if(Zn(a))return a.aborted=!0,a;const u=o(l,r,c);if(u instanceof Promise){if(c.async===!1)throw new Kn;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 Kn;return c.then(u=>o(u,r,l))}return o(c,r,l)}}Ie(e,"~standard",()=>({validate:o=>{try{const i=bg(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return vg(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Ra=ee("$ZodString",(e,t)=>{We.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Kg(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Ze=ee("$ZodStringFormat",(e,t)=>{vo.init(e,t),Ra.init(e,t)}),hx=ee("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Og),Ze.init(e,t)}),mx=ee("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Bl(r))}else t.pattern??(t.pattern=Bl());Ze.init(e,t)}),gx=ee("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Mg),Ze.init(e,t)}),xx=ee("$ZodURL",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);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=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),bx=ee("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Dg()),Ze.init(e,t)}),vx=ee("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=zg),Ze.init(e,t)}),yx=ee("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Tg),Ze.init(e,t)}),wx=ee("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Eg),Ze.init(e,t)}),kx=ee("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ag),Ze.init(e,t)}),_x=ee("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Rg),Ze.init(e,t)}),jx=ee("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ig),Ze.init(e,t)}),Sx=ee("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=qg(t)),Ze.init(e,t)}),Cx=ee("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Zg),Ze.init(e,t)}),Nx=ee("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Vg(t)),Ze.init(e,t)}),Tx=ee("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Pg),Ze.init(e,t)}),Ex=ee("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=$g),Ze.init(e,t),e._zod.bag.format="ipv4"}),Ax=ee("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Fg),Ze.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})}}}),Rx=ee("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Bg),Ze.init(e,t)}),Ix=ee("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ug),Ze.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,i]=r;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 xd(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const zx=ee("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Wg),Ze.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{xd(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Px(e){if(!ud.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return xd(n)}const Ox=ee("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ud),Ze.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Px(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Mx=ee("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Hg),Ze.init(e,t)});function Lx(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Dx=ee("$ZodJWT",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{Lx(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),bd=ee("$ZodNumber",(e,t)=>{We.init(e,t),e._zod.pattern=e._zod.bag.pattern??pd,e._zod.parse=(n,r)=>{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}}),$x=ee("$ZodNumberFormat",(e,t)=>{tx.init(e,t),bd.init(e,t)}),Fx=ee("$ZodBoolean",(e,t)=>{We.init(e,t),e._zod.pattern=Jg,e._zod.parse=(n,r)=>{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}}),Bx=ee("$ZodNull",(e,t)=>{We.init(e,t),e._zod.pattern=Yg,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),Ux=ee("$ZodUnknown",(e,t)=>{We.init(e,t),e._zod.parse=n=>n}),Wx=ee("$ZodNever",(e,t)=>{We.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Ul(e,t,n){e.issues.length&&t.issues.push(...Vn(n,e.issues)),t.value[n]=e.value}const Hx=ee("$ZodArray",(e,t)=>{We.init(e,t),e._zod.parse=(n,r)=>{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:[]},r);c instanceof Promise?i.push(c.then(u=>Ul(u,n,a))):Ul(c,n,a)}return i.length?Promise.all(i).then(()=>n):n}});function Ps(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...Vn(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function vd(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=ag(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function yd(e,t,n,r,o,i){const a=[],l=o.keySet,c=o.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const f in t){if(l.has(f))continue;if(u==="never"){a.push(f);continue}const m=c.run({value:t[f],issues:[]},r);m instanceof Promise?e.push(m.then(h=>Ps(h,n,f,t,d))):Ps(m,n,f,t,d)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const Zx=ee("$ZodObject",(e,t)=>{if(We.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 r=go(()=>vd(t));Ie(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=Er,i=t.catchall;let a;e._zod.parse=(l,c)=>{a??(a=r.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],v=h._zod.optout==="optional",g=h._zod.run({value:u[m],issues:[]},c);g instanceof Promise?d.push(g.then(x=>Ps(x,l,m,u,v))):Ps(g,l,m,u,v)}return i?yd(d,u,l,c,r.value,e):d.length?Promise.all(d).then(()=>l):l}}),Vx=ee("$ZodObjectJIT",(e,t)=>{Zx.init(e,t);const n=e._zod.parse,r=go(()=>vd(t)),o=m=>{const h=new fx(["shape","payload","ctx"]),v=r.value,g=_=>{const j=Fl(_);return`shape[${j}]._zod.run({ value: input[${j}], issues: [] }, ctx)`};h.write("const input = payload.value;");const x=Object.create(null);let b=0;for(const _ of v.keys)x[_]=`key_${b++}`;h.write("const newResult = {};");for(const _ of v.keys){const j=x[_],S=Fl(_),C=m[_]?._zod?.optout==="optional";h.write(`const ${j} = ${g(_)};`),C?h.write(`
5
5
  if (${j}.issues.length) {
6
6
  if (${S} in input) {
7
7
  payload.issues = payload.issues.concat(${j}.issues.map(iss => ({
@@ -35,11 +35,11 @@ import{u as Tn,a as Yu,r as p,j as s,c as Qr,g as Xm,b as Xu,d as Fr,e as Qm,f a
35
35
  newResult[${S}] = ${j}.value;
36
36
  }
37
37
 
38
- `)}h.write("payload.value = newResult;"),h.write("return payload;");const y=h.compile();return(_,j)=>y(m,_,j)};let i;const a=Er,l=!td.jitless,u=l&&ng.value,d=t.catchall;let f;e._zod.parse=(m,h)=>{f??(f=r.value);const v=m.value;return a(v)?l&&u&&h?.async===!1&&h.jitless!==!0?(i||(i=o(t.shape)),m=i(m,h),d?bd([],v,m,h,f,e):m):n(m,h):(m.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),m)}});function Bl(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!Zn(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=>on(a,r,sn())))}),t)}const vd=ee("$ZodUnion",(e,t)=>{We.init(e,t),Ie(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),Ie(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Ie(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),Ie(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>Sa(i.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let a=!1;const l=[];for(const c of t.options){const u=c._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)l.push(u),a=!0;else{if(u.issues.length===0)return u;l.push(u)}}return a?Promise.all(l).then(c=>Bl(c,o,e,i)):Bl(l,o,e,i)}}),Hx=ee("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,vd.init(e,t);const n=e._zod.parse;Ie(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 r=mo(()=>{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(!Er(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const l=r.value.get(a?.[t.discriminator]);return l?l._zod.run(o,i):t.unionFallback?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),o)}}),Zx=ee("$ZodIntersection",(e,t)=>{We.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),a=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([c,u])=>Ul(n,c,u)):Ul(n,i,a)}});function Ri(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(Qn(e)&&Qn(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const a=Ri(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 r=0;r<e.length;r++){const o=e[r],i=t[r],a=Ri(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ul(e,t,n){const r=new Map;let o;for(const l of t.issues)if(l.code==="unrecognized_keys"){o??(o=l);for(const c of l.keys)r.has(c)||r.set(c,{}),r.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)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(l);const i=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&o&&e.issues.push({...o,keys:i}),Zn(e))return e;const a=Ri(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 Vx=ee("$ZodRecord",(e,t)=>{We.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Qn(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.valueType._zod.run({value:o[u],issues:[]},r);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&n.issues.push(...Vn(u,f.issues)),n.value[u]=f.value})):(d.issues.length&&n.issues.push(...Vn(u,d.issues)),n.value[u]=d.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__")continue;let c=t.keyType._zod.run({value:l,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&dd.test(l)&&c.issues.length){const f=t.keyType._zod.run({value:Number(l),issues:[]},r);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=>on(f,r,sn())),input:l,path:[l],inst:e});continue}const d=t.valueType._zod.run({value:o[l],issues:[]},r);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&n.issues.push(...Vn(l,f.issues)),n.value[c.value]=f.value})):(d.issues.length&&n.issues.push(...Vn(l,d.issues)),n.value[c.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),qx=ee("$ZodEnum",(e,t)=>{We.init(e,t);const n=nd(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>rg.has(typeof o)).map(o=>typeof o=="string"?er(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const a=o.value;return r.has(a)||o.issues.push({code:"invalid_value",values:n,input:a,inst:e}),o}}),Kx=ee("$ZodLiteral",(e,t)=>{if(We.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(r=>typeof r=="string"?er(r):r?er(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),Gx=ee("$ZodTransform",(e,t)=>{We.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new ed(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(n.value=a,n));if(o instanceof Promise)throw new Kn;return n.value=o,n}});function Wl(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const yd=ee("$ZodOptional",(e,t)=>{We.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ie(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ie(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Sa(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Wl(i,n.value)):Wl(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Jx=ee("$ZodExactOptional",(e,t)=>{yd.init(e,t),Ie(e._zod,"values",()=>t.innerType._zod.values),Ie(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Yx=ee("$ZodNullable",(e,t)=>{We.init(e,t),Ie(e._zod,"optin",()=>t.innerType._zod.optin),Ie(e._zod,"optout",()=>t.innerType._zod.optout),Ie(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Sa(n.source)}|null)$`):void 0}),Ie(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Xx=ee("$ZodDefault",(e,t)=>{We.init(e,t),e._zod.optin="optional",Ie(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Hl(i,t)):Hl(o,t)}});function Hl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Qx=ee("$ZodPrefault",(e,t)=>{We.init(e,t),e._zod.optin="optional",Ie(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),e0=ee("$ZodNonOptional",(e,t)=>{We.init(e,t),Ie(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Zl(i,e)):Zl(o,e)}});function Zl(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 t0=ee("$ZodCatch",(e,t)=>{We.init(e,t),Ie(e._zod,"optin",()=>t.innerType._zod.optin),Ie(e._zod,"optout",()=>t.innerType._zod.optout),Ie(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);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=>on(a,r,sn()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>on(i,r,sn()))},input:n.value}),n.issues=[]),n)}}),n0=ee("$ZodPipe",(e,t)=>{We.init(e,t),Ie(e._zod,"values",()=>t.in._zod.values),Ie(e._zod,"optin",()=>t.in._zod.optin),Ie(e._zod,"optout",()=>t.out._zod.optout),Ie(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(a=>ts(a,t.in,r)):ts(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>ts(i,t.out,r)):ts(o,t.out,r)}});function ts(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const r0=ee("$ZodReadonly",(e,t)=>{We.init(e,t),Ie(e._zod,"propValues",()=>t.innerType._zod.propValues),Ie(e._zod,"values",()=>t.innerType._zod.values),Ie(e._zod,"optin",()=>t.innerType?._zod?.optin),Ie(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Vl):Vl(o)}});function Vl(e){return e.value=Object.freeze(e.value),e}const s0=ee("$ZodLazy",(e,t)=>{We.init(e,t),Ie(e._zod,"innerType",()=>t.getter()),Ie(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),Ie(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),Ie(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),Ie(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),o0=ee("$ZodCustom",(e,t)=>{it.init(e,t),We.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>ql(i,n,r,e));ql(o,n,r,e)}});function ql(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Ar(o))}}var Kl;class i0{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.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 r={...this.get(n)??{}};delete r.id;const o={...r,...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 a0(){return new i0}(Kl=globalThis).__zod_globalRegistry??(Kl.__zod_globalRegistry=a0());const Sr=globalThis.__zod_globalRegistry;function l0(e,t){return new e({type:"string",...we(t)})}function c0(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...we(t)})}function Gl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...we(t)})}function u0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...we(t)})}function d0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...we(t)})}function f0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...we(t)})}function p0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...we(t)})}function h0(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...we(t)})}function m0(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...we(t)})}function g0(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...we(t)})}function x0(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...we(t)})}function b0(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...we(t)})}function v0(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...we(t)})}function y0(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...we(t)})}function w0(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...we(t)})}function k0(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...we(t)})}function _0(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...we(t)})}function j0(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...we(t)})}function S0(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...we(t)})}function C0(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...we(t)})}function N0(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...we(t)})}function T0(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...we(t)})}function E0(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...we(t)})}function A0(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...we(t)})}function R0(e,t){return new e({type:"string",format:"date",check:"string_format",...we(t)})}function I0(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...we(t)})}function z0(e,t){return new e({type:"string",format:"duration",check:"string_format",...we(t)})}function P0(e,t){return new e({type:"number",checks:[],...we(t)})}function O0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...we(t)})}function M0(e,t){return new e({type:"boolean",...we(t)})}function L0(e,t){return new e({type:"null",...we(t)})}function D0(e){return new e({type:"unknown"})}function $0(e,t){return new e({type:"never",...we(t)})}function Jl(e,t){return new pd({check:"less_than",...we(t),value:e,inclusive:!1})}function Ko(e,t){return new pd({check:"less_than",...we(t),value:e,inclusive:!0})}function Yl(e,t){return new hd({check:"greater_than",...we(t),value:e,inclusive:!1})}function Go(e,t){return new hd({check:"greater_than",...we(t),value:e,inclusive:!0})}function Xl(e,t){return new Yg({check:"multiple_of",...we(t),value:e})}function wd(e,t){return new Qg({check:"max_length",...we(t),maximum:e})}function Ps(e,t){return new ex({check:"min_length",...we(t),minimum:e})}function kd(e,t){return new tx({check:"length_equals",...we(t),length:e})}function F0(e,t){return new nx({check:"string_format",format:"regex",...we(t),pattern:e})}function B0(e){return new rx({check:"string_format",format:"lowercase",...we(e)})}function U0(e){return new sx({check:"string_format",format:"uppercase",...we(e)})}function W0(e,t){return new ox({check:"string_format",format:"includes",...we(t),includes:e})}function H0(e,t){return new ix({check:"string_format",format:"starts_with",...we(t),prefix:e})}function Z0(e,t){return new ax({check:"string_format",format:"ends_with",...we(t),suffix:e})}function lr(e){return new lx({check:"overwrite",tx:e})}function V0(e){return lr(t=>t.normalize(e))}function q0(){return lr(e=>e.trim())}function K0(){return lr(e=>e.toLowerCase())}function G0(){return lr(e=>e.toUpperCase())}function J0(){return lr(e=>tg(e))}function Y0(e,t,n){return new e({type:"array",element:t,...we(n)})}function X0(e,t,n){return new e({type:"custom",check:"custom",fn:t,...we(n)})}function Q0(e){const t=eb(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Ar(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(Ar(o))}},e(n.value,n)));return t}function eb(e,t){const n=new it({check:"custom",...we(t)});return n._zod.check=e,n}function _d(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??Sr,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 qe(e,t,n={path:[],schemaPath:[]}){var r;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),qe(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"&&nt(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function jd(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const a of e.seen.entries()){const l=e.metadataRegistry.get(a[0])?.id;if(l){const c=r.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.`);r.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??(v=>v);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>
38
+ `)}h.write("payload.value = newResult;"),h.write("return payload;");const y=h.compile();return(_,j)=>y(m,_,j)};let i;const a=Er,l=!rd.jitless,u=l&&og.value,d=t.catchall;let f;e._zod.parse=(m,h)=>{f??(f=r.value);const v=m.value;return a(v)?l&&u&&h?.async===!1&&h.jitless!==!0?(i||(i=o(t.shape)),m=i(m,h),d?yd([],v,m,h,f,e):m):n(m,h):(m.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),m)}});function Wl(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!Zn(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=>on(a,r,sn())))}),t)}const wd=ee("$ZodUnion",(e,t)=>{We.init(e,t),Ie(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),Ie(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Ie(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),Ie(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>Na(i.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let a=!1;const l=[];for(const c of t.options){const u=c._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)l.push(u),a=!0;else{if(u.issues.length===0)return u;l.push(u)}}return a?Promise.all(l).then(c=>Wl(c,o,e,i)):Wl(l,o,e,i)}}),qx=ee("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,wd.init(e,t);const n=e._zod.parse;Ie(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 r=go(()=>{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(!Er(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const l=r.value.get(a?.[t.discriminator]);return l?l._zod.run(o,i):t.unionFallback?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),o)}}),Kx=ee("$ZodIntersection",(e,t)=>{We.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),a=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([c,u])=>Hl(n,c,u)):Hl(n,i,a)}});function zi(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(Qn(e)&&Qn(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const a=zi(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 r=0;r<e.length;r++){const o=e[r],i=t[r],a=zi(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Hl(e,t,n){const r=new Map;let o;for(const l of t.issues)if(l.code==="unrecognized_keys"){o??(o=l);for(const c of l.keys)r.has(c)||r.set(c,{}),r.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)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(l);const i=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&o&&e.issues.push({...o,keys:i}),Zn(e))return e;const a=zi(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 Gx=ee("$ZodRecord",(e,t)=>{We.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Qn(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.valueType._zod.run({value:o[u],issues:[]},r);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&n.issues.push(...Vn(u,f.issues)),n.value[u]=f.value})):(d.issues.length&&n.issues.push(...Vn(u,d.issues)),n.value[u]=d.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__")continue;let c=t.keyType._zod.run({value:l,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&pd.test(l)&&c.issues.length){const f=t.keyType._zod.run({value:Number(l),issues:[]},r);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=>on(f,r,sn())),input:l,path:[l],inst:e});continue}const d=t.valueType._zod.run({value:o[l],issues:[]},r);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&n.issues.push(...Vn(l,f.issues)),n.value[c.value]=f.value})):(d.issues.length&&n.issues.push(...Vn(l,d.issues)),n.value[c.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),Jx=ee("$ZodEnum",(e,t)=>{We.init(e,t);const n=sd(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>ig.has(typeof o)).map(o=>typeof o=="string"?er(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const a=o.value;return r.has(a)||o.issues.push({code:"invalid_value",values:n,input:a,inst:e}),o}}),Yx=ee("$ZodLiteral",(e,t)=>{if(We.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(r=>typeof r=="string"?er(r):r?er(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),Xx=ee("$ZodTransform",(e,t)=>{We.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new nd(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(n.value=a,n));if(o instanceof Promise)throw new Kn;return n.value=o,n}});function Zl(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const kd=ee("$ZodOptional",(e,t)=>{We.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ie(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ie(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Na(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Zl(i,n.value)):Zl(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Qx=ee("$ZodExactOptional",(e,t)=>{kd.init(e,t),Ie(e._zod,"values",()=>t.innerType._zod.values),Ie(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),e0=ee("$ZodNullable",(e,t)=>{We.init(e,t),Ie(e._zod,"optin",()=>t.innerType._zod.optin),Ie(e._zod,"optout",()=>t.innerType._zod.optout),Ie(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Na(n.source)}|null)$`):void 0}),Ie(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),t0=ee("$ZodDefault",(e,t)=>{We.init(e,t),e._zod.optin="optional",Ie(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Vl(i,t)):Vl(o,t)}});function Vl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const n0=ee("$ZodPrefault",(e,t)=>{We.init(e,t),e._zod.optin="optional",Ie(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),r0=ee("$ZodNonOptional",(e,t)=>{We.init(e,t),Ie(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>ql(i,e)):ql(o,e)}});function ql(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 s0=ee("$ZodCatch",(e,t)=>{We.init(e,t),Ie(e._zod,"optin",()=>t.innerType._zod.optin),Ie(e._zod,"optout",()=>t.innerType._zod.optout),Ie(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);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=>on(a,r,sn()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>on(i,r,sn()))},input:n.value}),n.issues=[]),n)}}),o0=ee("$ZodPipe",(e,t)=>{We.init(e,t),Ie(e._zod,"values",()=>t.in._zod.values),Ie(e._zod,"optin",()=>t.in._zod.optin),Ie(e._zod,"optout",()=>t.out._zod.optout),Ie(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(a=>ns(a,t.in,r)):ns(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>ns(i,t.out,r)):ns(o,t.out,r)}});function ns(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const i0=ee("$ZodReadonly",(e,t)=>{We.init(e,t),Ie(e._zod,"propValues",()=>t.innerType._zod.propValues),Ie(e._zod,"values",()=>t.innerType._zod.values),Ie(e._zod,"optin",()=>t.innerType?._zod?.optin),Ie(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Kl):Kl(o)}});function Kl(e){return e.value=Object.freeze(e.value),e}const a0=ee("$ZodLazy",(e,t)=>{We.init(e,t),Ie(e._zod,"innerType",()=>t.getter()),Ie(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),Ie(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),Ie(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),Ie(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),l0=ee("$ZodCustom",(e,t)=>{it.init(e,t),We.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>Gl(i,n,r,e));Gl(o,n,r,e)}});function Gl(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Ar(o))}}var Jl;class c0{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.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 r={...this.get(n)??{}};delete r.id;const o={...r,...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 u0(){return new c0}(Jl=globalThis).__zod_globalRegistry??(Jl.__zod_globalRegistry=u0());const Sr=globalThis.__zod_globalRegistry;function d0(e,t){return new e({type:"string",...we(t)})}function f0(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...we(t)})}function Yl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...we(t)})}function p0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...we(t)})}function h0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...we(t)})}function m0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...we(t)})}function g0(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...we(t)})}function x0(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...we(t)})}function b0(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...we(t)})}function v0(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...we(t)})}function y0(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...we(t)})}function w0(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...we(t)})}function k0(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...we(t)})}function _0(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...we(t)})}function j0(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...we(t)})}function S0(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...we(t)})}function C0(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...we(t)})}function N0(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...we(t)})}function T0(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...we(t)})}function E0(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...we(t)})}function A0(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...we(t)})}function R0(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...we(t)})}function I0(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...we(t)})}function z0(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...we(t)})}function P0(e,t){return new e({type:"string",format:"date",check:"string_format",...we(t)})}function O0(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...we(t)})}function M0(e,t){return new e({type:"string",format:"duration",check:"string_format",...we(t)})}function L0(e,t){return new e({type:"number",checks:[],...we(t)})}function D0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...we(t)})}function $0(e,t){return new e({type:"boolean",...we(t)})}function F0(e,t){return new e({type:"null",...we(t)})}function B0(e){return new e({type:"unknown"})}function U0(e,t){return new e({type:"never",...we(t)})}function Xl(e,t){return new md({check:"less_than",...we(t),value:e,inclusive:!1})}function Go(e,t){return new md({check:"less_than",...we(t),value:e,inclusive:!0})}function Ql(e,t){return new gd({check:"greater_than",...we(t),value:e,inclusive:!1})}function Jo(e,t){return new gd({check:"greater_than",...we(t),value:e,inclusive:!0})}function ec(e,t){return new ex({check:"multiple_of",...we(t),value:e})}function _d(e,t){return new nx({check:"max_length",...we(t),maximum:e})}function Os(e,t){return new rx({check:"min_length",...we(t),minimum:e})}function jd(e,t){return new sx({check:"length_equals",...we(t),length:e})}function W0(e,t){return new ox({check:"string_format",format:"regex",...we(t),pattern:e})}function H0(e){return new ix({check:"string_format",format:"lowercase",...we(e)})}function Z0(e){return new ax({check:"string_format",format:"uppercase",...we(e)})}function V0(e,t){return new lx({check:"string_format",format:"includes",...we(t),includes:e})}function q0(e,t){return new cx({check:"string_format",format:"starts_with",...we(t),prefix:e})}function K0(e,t){return new ux({check:"string_format",format:"ends_with",...we(t),suffix:e})}function lr(e){return new dx({check:"overwrite",tx:e})}function G0(e){return lr(t=>t.normalize(e))}function J0(){return lr(e=>e.trim())}function Y0(){return lr(e=>e.toLowerCase())}function X0(){return lr(e=>e.toUpperCase())}function Q0(){return lr(e=>sg(e))}function eb(e,t,n){return new e({type:"array",element:t,...we(n)})}function tb(e,t,n){return new e({type:"custom",check:"custom",fn:t,...we(n)})}function nb(e){const t=rb(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Ar(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(Ar(o))}},e(n.value,n)));return t}function rb(e,t){const n=new it({check:"custom",...we(t)});return n._zod.check=e,n}function Sd(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??Sr,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 qe(e,t,n={path:[],schemaPath:[]}){var r;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),qe(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"&&nt(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Cd(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const a of e.seen.entries()){const l=e.metadataRegistry.get(a[0])?.id;if(l){const c=r.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.`);r.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??(v=>v);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>
39
39
 
40
- 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 Sd(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const l=e.seen.get(a);if(l.ref===null)return;const c=l.def??l.schema,u={...c},d=l.ref;if(l.ref=null,d){r(d);const m=e.seen.get(d),h=m.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(h)):Object.assign(c,h),Object.assign(c,u),a._zod.parent===d)for(const g in c)g==="$ref"||g==="allOf"||g in u||delete c[g];if(h.$ref&&m.def)for(const g in c)g==="$ref"||g==="allOf"||g in m.def&&JSON.stringify(c[g])===JSON.stringify(m.def[g])&&delete c[g]}const f=a._zod.parent;if(f&&f!==d){r(f);const m=e.seen.get(f);if(m?.schema.$ref&&(c.$ref=m.schema.$ref,m.def))for(const h in c)h==="$ref"||h==="allOf"||h in m.def&&JSON.stringify(c[h])===JSON.stringify(m.def[h])&&delete c[h]}e.override({zodSchema:a,jsonSchema:c,path:l.path??[]})};for(const a of[...e.seen.entries()].reverse())r(a[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 a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,n.def??n.schema);const i=e.external?.defs??{};for(const a of e.seen.entries()){const l=a[1];l.def&&l.defId&&(i[l.defId]=l.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Os(t,"input",e.processors),output:Os(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function nt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return nt(r.element,n);if(r.type==="set")return nt(r.valueType,n);if(r.type==="lazy")return nt(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return nt(r.innerType,n);if(r.type==="intersection")return nt(r.left,n)||nt(r.right,n);if(r.type==="record"||r.type==="map")return nt(r.keyType,n)||nt(r.valueType,n);if(r.type==="pipe")return nt(r.in,n)||nt(r.out,n);if(r.type==="object"){for(const o in r.shape)if(nt(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(nt(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(nt(o,n))return!0;return!!(r.rest&&nt(r.rest,n))}return!1}const tb=(e,t={})=>n=>{const r=_d({...n,processors:t});return qe(e,r),jd(r,e),Sd(r,e)},Os=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},a=_d({...o??{},target:i,io:t,processors:n});return qe(e,a),jd(a,e),Sd(a,e)},nb={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},rb=(e,t,n,r)=>{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=nb[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}))])}},sb=(e,t,n,r)=>{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",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=d,o.exclusiveMinimum=!0):o.exclusiveMinimum=d),typeof i=="number"&&(o.minimum=i,typeof d=="number"&&t.target!=="draft-04"&&(d>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof a=="number"&&(o.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},ob=(e,t,n,r)=>{n.type="boolean"},ib=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},ab=(e,t,n,r)=>{n.not={}},lb=(e,t,n,r)=>{},cb=(e,t,n,r)=>{const o=e._zod.def,i=nd(o.entries);i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i},ub=(e,t,n,r)=>{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},db=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},fb=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},pb=(e,t,n,r)=>{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=qe(i.element,t,{...r,path:[...r.path,"items"]})},hb=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const u in a)o.properties[u]=qe(a[u],t,{...r,path:[...r.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=qe(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},mb=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((l,c)=>qe(l,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=a:n.anyOf=a},gb=(e,t,n,r)=>{const o=e._zod.def,i=qe(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=qe(o.right,t,{...r,path:[...r.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},xb=(e,t,n,r)=>{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=qe(i.valueType,t,{...r,path:[...r.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=qe(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=qe(i.valueType,t,{...r,path:[...r.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)}},bb=(e,t,n,r)=>{const o=e._zod.def,i=qe(o.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},vb=(e,t,n,r)=>{const o=e._zod.def;qe(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},yb=(e,t,n,r)=>{const o=e._zod.def;qe(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},wb=(e,t,n,r)=>{const o=e._zod.def;qe(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},kb=(e,t,n,r)=>{const o=e._zod.def;qe(o.innerType,t,r);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},_b=(e,t,n,r)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;qe(i,t,r);const a=t.seen.get(e);a.ref=i},jb=(e,t,n,r)=>{const o=e._zod.def;qe(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Cd=(e,t,n,r)=>{const o=e._zod.def;qe(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Sb=(e,t,n,r)=>{const o=e._zod.innerType;qe(o,t,r);const i=t.seen.get(e);i.ref=o},Cb=ee("ZodISODateTime",(e,t)=>{kx.init(e,t),Ve.init(e,t)});function Nb(e){return A0(Cb,e)}const Tb=ee("ZodISODate",(e,t)=>{_x.init(e,t),Ve.init(e,t)});function Eb(e){return R0(Tb,e)}const Ab=ee("ZodISOTime",(e,t)=>{jx.init(e,t),Ve.init(e,t)});function Rb(e){return I0(Ab,e)}const Ib=ee("ZodISODuration",(e,t)=>{Sx.init(e,t),Ve.init(e,t)});function zb(e){return z0(Ib,e)}const Pb=(e,t)=>{id.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>hg(e,n)},flatten:{value:n=>pg(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ai,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ai,2)}},isEmpty:{get(){return e.issues.length===0}}})},xt=ee("ZodError",Pb,{Parent:Error}),Ob=Na(xt),Mb=Ta(xt),Lb=go(xt),Db=xo(xt),$b=xg(xt),Fb=bg(xt),Bb=vg(xt),Ub=yg(xt),Wb=wg(xt),Hb=kg(xt),Zb=_g(xt),Vb=jg(xt),He=ee("ZodType",(e,t)=>(We.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Os(e,"input"),output:Os(e,"output")}}),e.toJSONSchema=tb(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(un(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>dn(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>Ob(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Lb(e,n,r),e.parseAsync=async(n,r)=>Mb(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Db(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>$b(e,n,r),e.decode=(n,r)=>Fb(e,n,r),e.encodeAsync=async(n,r)=>Bb(e,n,r),e.decodeAsync=async(n,r)=>Ub(e,n,r),e.safeEncode=(n,r)=>Wb(e,n,r),e.safeDecode=(n,r)=>Hb(e,n,r),e.safeEncodeAsync=async(n,r)=>Zb(e,n,r),e.safeDecodeAsync=async(n,r)=>Vb(e,n,r),e.refine=(n,r)=>e.check(Uv(n,r)),e.superRefine=n=>e.check(Wv(n)),e.overwrite=n=>e.check(lr(n)),e.optional=()=>tc(e),e.exactOptional=()=>Nv(e),e.nullable=()=>nc(e),e.nullish=()=>tc(nc(e)),e.nonoptional=n=>zv(e,n),e.array=()=>me(e),e.or=n=>Mt([e,n]),e.and=n=>wv(e,n),e.transform=n=>rc(e,Sv(n)),e.default=n=>Av(e,n),e.prefault=n=>Iv(e,n),e.catch=n=>Ov(e,n),e.pipe=n=>rc(e,n),e.readonly=()=>Dv(e),e.describe=n=>{const r=e.clone();return Sr.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return Sr.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Sr.get(e);const r=e.clone();return Sr.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Nd=ee("_ZodString",(e,t)=>{Ea.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,o,i)=>rb(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(F0(...r)),e.includes=(...r)=>e.check(W0(...r)),e.startsWith=(...r)=>e.check(H0(...r)),e.endsWith=(...r)=>e.check(Z0(...r)),e.min=(...r)=>e.check(Ps(...r)),e.max=(...r)=>e.check(wd(...r)),e.length=(...r)=>e.check(kd(...r)),e.nonempty=(...r)=>e.check(Ps(1,...r)),e.lowercase=r=>e.check(B0(r)),e.uppercase=r=>e.check(U0(r)),e.trim=()=>e.check(q0()),e.normalize=(...r)=>e.check(V0(...r)),e.toLowerCase=()=>e.check(K0()),e.toUpperCase=()=>e.check(G0()),e.slugify=()=>e.check(J0())}),qb=ee("ZodString",(e,t)=>{Ea.init(e,t),Nd.init(e,t),e.email=n=>e.check(c0(Kb,n)),e.url=n=>e.check(h0(Gb,n)),e.jwt=n=>e.check(E0(uv,n)),e.emoji=n=>e.check(m0(Jb,n)),e.guid=n=>e.check(Gl(Ql,n)),e.uuid=n=>e.check(u0(ns,n)),e.uuidv4=n=>e.check(d0(ns,n)),e.uuidv6=n=>e.check(f0(ns,n)),e.uuidv7=n=>e.check(p0(ns,n)),e.nanoid=n=>e.check(g0(Yb,n)),e.guid=n=>e.check(Gl(Ql,n)),e.cuid=n=>e.check(x0(Xb,n)),e.cuid2=n=>e.check(b0(Qb,n)),e.ulid=n=>e.check(v0(ev,n)),e.base64=n=>e.check(C0(av,n)),e.base64url=n=>e.check(N0(lv,n)),e.xid=n=>e.check(y0(tv,n)),e.ksuid=n=>e.check(w0(nv,n)),e.ipv4=n=>e.check(k0(rv,n)),e.ipv6=n=>e.check(_0(sv,n)),e.cidrv4=n=>e.check(j0(ov,n)),e.cidrv6=n=>e.check(S0(iv,n)),e.e164=n=>e.check(T0(cv,n)),e.datetime=n=>e.check(Nb(n)),e.date=n=>e.check(Eb(n)),e.time=n=>e.check(Rb(n)),e.duration=n=>e.check(zb(n))});function N(e){return l0(qb,e)}const Ve=ee("ZodStringFormat",(e,t)=>{Ze.init(e,t),Nd.init(e,t)}),Kb=ee("ZodEmail",(e,t)=>{px.init(e,t),Ve.init(e,t)}),Ql=ee("ZodGUID",(e,t)=>{dx.init(e,t),Ve.init(e,t)}),ns=ee("ZodUUID",(e,t)=>{fx.init(e,t),Ve.init(e,t)}),Gb=ee("ZodURL",(e,t)=>{hx.init(e,t),Ve.init(e,t)}),Jb=ee("ZodEmoji",(e,t)=>{mx.init(e,t),Ve.init(e,t)}),Yb=ee("ZodNanoID",(e,t)=>{gx.init(e,t),Ve.init(e,t)}),Xb=ee("ZodCUID",(e,t)=>{xx.init(e,t),Ve.init(e,t)}),Qb=ee("ZodCUID2",(e,t)=>{bx.init(e,t),Ve.init(e,t)}),ev=ee("ZodULID",(e,t)=>{vx.init(e,t),Ve.init(e,t)}),tv=ee("ZodXID",(e,t)=>{yx.init(e,t),Ve.init(e,t)}),nv=ee("ZodKSUID",(e,t)=>{wx.init(e,t),Ve.init(e,t)}),rv=ee("ZodIPv4",(e,t)=>{Cx.init(e,t),Ve.init(e,t)}),sv=ee("ZodIPv6",(e,t)=>{Nx.init(e,t),Ve.init(e,t)}),ov=ee("ZodCIDRv4",(e,t)=>{Tx.init(e,t),Ve.init(e,t)}),iv=ee("ZodCIDRv6",(e,t)=>{Ex.init(e,t),Ve.init(e,t)}),av=ee("ZodBase64",(e,t)=>{Ax.init(e,t),Ve.init(e,t)}),lv=ee("ZodBase64URL",(e,t)=>{Ix.init(e,t),Ve.init(e,t)}),cv=ee("ZodE164",(e,t)=>{zx.init(e,t),Ve.init(e,t)}),uv=ee("ZodJWT",(e,t)=>{Ox.init(e,t),Ve.init(e,t)}),Td=ee("ZodNumber",(e,t)=>{gd.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,o,i)=>sb(e,r,o),e.gt=(r,o)=>e.check(Yl(r,o)),e.gte=(r,o)=>e.check(Go(r,o)),e.min=(r,o)=>e.check(Go(r,o)),e.lt=(r,o)=>e.check(Jl(r,o)),e.lte=(r,o)=>e.check(Ko(r,o)),e.max=(r,o)=>e.check(Ko(r,o)),e.int=r=>e.check(ec(r)),e.safe=r=>e.check(ec(r)),e.positive=r=>e.check(Yl(0,r)),e.nonnegative=r=>e.check(Go(0,r)),e.negative=r=>e.check(Jl(0,r)),e.nonpositive=r=>e.check(Ko(0,r)),e.multipleOf=(r,o)=>e.check(Xl(r,o)),e.step=(r,o)=>e.check(Xl(r,o)),e.finite=()=>e;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 K(e){return P0(Td,e)}const dv=ee("ZodNumberFormat",(e,t)=>{Mx.init(e,t),Td.init(e,t)});function ec(e){return O0(dv,e)}const fv=ee("ZodBoolean",(e,t)=>{Lx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ob(e,n,r)});function Fe(e){return M0(fv,e)}const pv=ee("ZodNull",(e,t)=>{Dx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ib(e,n,r)});function Ms(e){return L0(pv,e)}const hv=ee("ZodUnknown",(e,t)=>{$x.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>lb()});function yn(){return D0(hv)}const mv=ee("ZodNever",(e,t)=>{Fx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ab(e,n,r)});function gv(e){return $0(mv,e)}const xv=ee("ZodArray",(e,t)=>{Bx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pb(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(Ps(n,r)),e.nonempty=n=>e.check(Ps(1,n)),e.max=(n,r)=>e.check(wd(n,r)),e.length=(n,r)=>e.check(kd(n,r)),e.unwrap=()=>e.element});function me(e,t){return Y0(xv,e,t)}const bv=ee("ZodObject",(e,t)=>{Wx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hb(e,n,r,o),Ie(e,"shape",()=>t.shape),e.keyof=()=>Te(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:yn()}),e.loose=()=>e.clone({...e._zod.def,catchall:yn()}),e.strict=()=>e.clone({...e._zod.def,catchall:gv()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>lg(e,n),e.safeExtend=n=>cg(e,n),e.merge=n=>ug(e,n),e.pick=n=>ig(e,n),e.omit=n=>ag(e,n),e.partial=(...n)=>dg(Ad,e,n[0]),e.required=(...n)=>fg(Rd,e,n[0])});function G(e,t){const n={type:"object",shape:e??{},...we(t)};return new bv(n)}const Ed=ee("ZodUnion",(e,t)=>{vd.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mb(e,n,r,o),e.options=t.options});function Mt(e,t){return new Ed({type:"union",options:e,...we(t)})}const vv=ee("ZodDiscriminatedUnion",(e,t)=>{Ed.init(e,t),Hx.init(e,t)});function Rn(e,t,n){return new vv({type:"union",options:t,discriminator:e,...we(n)})}const yv=ee("ZodIntersection",(e,t)=>{Zx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gb(e,n,r,o)});function wv(e,t){return new yv({type:"intersection",left:e,right:t})}const kv=ee("ZodRecord",(e,t)=>{Vx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>xb(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function Ke(e,t,n){return new kv({type:"record",keyType:e,valueType:t,...we(n)})}const Ii=ee("ZodEnum",(e,t)=>{qx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,o,i)=>cb(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const a of r)if(n.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Ii({...t,checks:[],...we(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const a of r)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new Ii({...t,checks:[],...we(o),entries:i})}});function Te(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Ii({type:"enum",entries:n,...we(t)})}const _v=ee("ZodLiteral",(e,t)=>{Kx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ub(e,n,r),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 Ce(e,t){return new _v({type:"literal",values:Array.isArray(e)?e:[e],...we(t)})}const jv=ee("ZodTransform",(e,t)=>{Gx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>fb(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new ed(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)):(n.value=o,n)}});function Sv(e){return new jv({type:"transform",transform:e})}const Ad=ee("ZodOptional",(e,t)=>{yd.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Cd(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function tc(e){return new Ad({type:"optional",innerType:e})}const Cv=ee("ZodExactOptional",(e,t)=>{Jx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Cd(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Nv(e){return new Cv({type:"optional",innerType:e})}const Tv=ee("ZodNullable",(e,t)=>{Yx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>bb(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function nc(e){return new Tv({type:"nullable",innerType:e})}const Ev=ee("ZodDefault",(e,t)=>{Xx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>yb(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Av(e,t){return new Ev({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():sd(t)}})}const Rv=ee("ZodPrefault",(e,t)=>{Qx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wb(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Iv(e,t){return new Rv({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():sd(t)}})}const Rd=ee("ZodNonOptional",(e,t)=>{e0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>vb(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function zv(e,t){return new Rd({type:"nonoptional",innerType:e,...we(t)})}const Pv=ee("ZodCatch",(e,t)=>{t0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>kb(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ov(e,t){return new Pv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Mv=ee("ZodPipe",(e,t)=>{n0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_b(e,n,r,o),e.in=t.in,e.out=t.out});function rc(e,t){return new Mv({type:"pipe",in:e,out:t})}const Lv=ee("ZodReadonly",(e,t)=>{r0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>jb(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Dv(e){return new Lv({type:"readonly",innerType:e})}const $v=ee("ZodLazy",(e,t)=>{s0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Sb(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function Fv(e){return new $v({type:"lazy",getter:e})}const Bv=ee("ZodCustom",(e,t)=>{o0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>db(e,n)});function Uv(e,t={}){return X0(Bv,e,t)}function Wv(e){return Q0(e)}const Qe=Fv(()=>Mt([N(),K(),Fe(),Ms(),me(Qe),Ke(N(),Qe)]));const Id=G({index:K(),timestamp:K(),type:N(),data:Qe}),Hv=G({chunks:me(Id),truncated:Fe().optional().default(!1)}),Zv=Te(["request","response"]),Vv=G({logId:K().int().positive(),part:Zv,text:N(),offset:K().int().nonnegative(),limit:K().int().positive(),totalBytes:K().int().nonnegative(),textBytes:K().int().nonnegative(),nextOffset:K().int().nonnegative().nullable(),hasMore:Fe(),contentMode:Te(["empty","partial","full"])}),Rr=G({id:K(),timestamp:N(),method:N(),path:N(),model:N().nullable(),sessionId:N().nullable(),rawRequestBody:N().nullable(),responseStatus:K().nullable(),responseText:N().nullable(),inputTokens:K().nullable(),outputTokens:K().nullable(),cacheCreationInputTokens:K().nullable(),cacheReadInputTokens:K().nullable(),elapsedMs:K().nullable(),firstChunkMs:K().nullable().optional(),totalStreamMs:K().nullable().optional(),tokensPerSecond:K().nullable().optional(),streaming:Fe(),userAgent:N().nullable(),origin:N().nullable(),rawHeaders:Ke(N(),N()).optional(),headers:Ke(N(),N()).optional(),apiFormat:Te(["anthropic","openai","unknown"]).default("unknown"),isTest:Fe().optional().default(!1),replayOfLogId:K().nullable().optional(),providerName:N().nullable().optional(),clientPort:K().nullable().optional(),clientPid:K().nullable().optional(),clientCwd:N().nullable().optional(),clientProjectFolder:N().nullable().optional(),streamingChunks:Hv.optional(),streamingChunksPath:N().nullable().optional(),rawRequestBodyBytes:K().int().nonnegative().nullable().optional(),responseTextBytes:K().int().nonnegative().nullable().optional(),bodyContentMode:Te(["full","compact","truncated"]).optional(),warnings:me(N()).optional(),error:N().nullable().optional()}),Aa=G({type:N(),ttl:N().optional(),scope:N().optional()}),Ra=G({type:Ce("text"),text:N(),cache_control:Aa.optional()}),zd=G({type:Ce("thinking"),thinking:N(),signature:N().optional()}),qv=G({type:Ce("think"),thinking:N(),signature:N().optional()}),Kv=G({type:Ce("base64"),media_type:N(),data:N()}),Pd=G({type:Ce("image"),source:Kv}),Od=G({type:Ce("tool_use"),id:N(),name:N(),input:Ke(N(),Qe)}),Gv=Rn("type",[Ra,Pd]),Jv=G({type:Ce("tool_result"),tool_use_id:N().optional(),content:Mt([N(),me(Gv)]),is_error:Fe().optional()}),Yv=Rn("type",[Ra,zd,Pd,Od,Jv]),Xv=Mt([N(),me(Yv)]),Qv=G({role:Te(["user","assistant"]),content:Xv}),e1=G({type:Ce("text"),text:N(),cache_control:Aa.optional()}),t1=G({type:N(),properties:Ke(N(),Ke(N(),Qe)).optional(),required:me(N()).optional(),additionalProperties:Fe().optional(),$schema:N().optional()}),n1=G({name:N(),description:N().optional(),input_schema:t1.optional(),cache_control:Aa.optional()}),r1=Rn("type",[G({type:Ce("enabled"),budget_tokens:K()}),G({type:Ce("disabled")}),G({type:Ce("adaptive")})]),Md=G({model:N(),messages:me(Qv),system:me(e1).optional(),tools:me(n1).optional(),max_tokens:K().optional(),temperature:K().optional(),stream:Fe().optional(),thinking:r1.optional(),metadata:G({user_id:N().optional()}).optional()}),Ia=Rn("type",[Ra,zd,qv,Od]),s1=G({input_tokens:K().nullable().optional(),output_tokens:K().nullable().optional(),cache_creation_input_tokens:K().nullable().optional(),cache_read_input_tokens:K().nullable().optional()}).passthrough(),Ld=G({id:N(),type:Ce("message"),model:N(),role:Ce("assistant"),content:me(Ia),stop_reason:N().nullable(),stop_sequence:N().nullable().optional(),usage:s1}).passthrough(),o1=G({type:Ce("message_start"),message:G({id:N(),type:Ce("message"),model:N(),role:Ce("assistant"),content:me(Ia),stop_reason:Ms(),stop_sequence:Ms(),usage:G({input_tokens:K(),cache_creation_input_tokens:K().optional(),cache_read_input_tokens:K().optional()}).passthrough()})}),i1=G({type:Ce("content_block_start"),index:K(),content_block:Ia}),a1=Rn("type",[G({type:Ce("text_delta"),text:N()}),G({type:Ce("input_json_delta"),partial_json:N()}),G({type:Ce("thinking_delta"),thinking:N()}),G({type:Ce("signature_delta"),signature:N()})]),l1=G({type:Ce("content_block_delta"),index:K(),delta:a1}),c1=G({type:Ce("content_block_stop"),index:K()}),u1=G({type:Ce("message_delta"),delta:G({stop_reason:N().nullable(),stop_sequence:N().nullable().optional()}),usage:G({output_tokens:K(),input_tokens:K().optional(),cache_creation_input_tokens:K().optional(),cache_read_input_tokens:K().optional()}).passthrough()}),d1=G({type:Ce("message_stop")}),f1=G({type:Ce("ping")}),p1=G({type:Ce("error"),error:G({type:N(),message:N()})}),h1=Rn("type",[o1,i1,l1,c1,u1,d1,f1,p1]),m1=Mt([N(),me(Rn("type",[G({type:Ce("text"),text:N()}),G({type:Ce("image_url"),image_url:G({url:N(),detail:N().optional()})})]))]),Dd=G({role:Te(["system","user","assistant","tool"]),content:m1,name:N().optional(),reasoning_content:N().optional(),thinking:N().optional(),think:N().optional()}),g1=G({name:N(),arguments:N()}),$d=G({index:K().optional(),id:N().optional(),type:Ce("function").optional(),function:G({name:N().optional(),arguments:N().optional()})});Dd.extend({content:Mt([N(),me(G({type:Ce("text"),text:N()}))]).optional(),function_call:g1.optional(),tool_calls:me($d).optional()});const x1=G({type:Ce("function"),function:G({name:N(),description:N().optional(),parameters:Ke(N(),Qe)})}),Fd=G({model:N(),messages:me(Dd),temperature:K().optional(),max_tokens:K().optional(),stream:Fe().optional(),tools:me(x1).optional(),tool_choice:Mt([Te(["auto","none","required"]),G({type:Ce("auto")}),G({type:Ce("none")}),G({type:Ce("function"),function:G({name:N()})})]).optional(),user:N().optional()}),b1=G({type:N(),name:N().optional(),description:N().optional(),parameters:Qe.optional(),function:G({name:N().optional(),description:N().optional(),parameters:Qe.optional()}).optional()}).passthrough(),Bd=G({model:N(),input:yn().optional(),instructions:Mt([N(),Ms()]).optional(),stream:Fe().optional(),tools:me(b1).optional(),tool_choice:yn().optional(),max_output_tokens:K().optional(),temperature:K().optional(),user:N().optional(),metadata:Ke(N(),yn()).optional()}).passthrough(),Ud=G({role:Te(["assistant"]).optional(),content:N().nullable().optional(),reasoning_content:N().nullable().optional(),thinking:N().nullable().optional(),think:N().nullable().optional(),function_call:G({name:N().optional(),arguments:N().optional()}).nullable().optional(),tool_calls:me(G({index:K(),id:N().optional(),type:Ce("function").optional(),function:G({name:N().optional(),arguments:N().optional()})})).nullable().optional()}),v1=G({index:K(),message:G({role:Te(["assistant"]),content:N().nullable(),reasoning_content:N().optional(),thinking:N().optional(),think:N().optional(),function_call:G({name:N(),arguments:N()}).nullable().optional(),tool_calls:me($d).optional()}).optional(),delta:Ud.optional(),finish_reason:N().nullable()}),y1=G({id:N(),object:Ce("chat.completion"),created:K(),model:N(),choices:me(v1),usage:G({prompt_tokens:K().nullable().optional(),completion_tokens:K().nullable().optional(),total_tokens:K().nullable().optional()}).passthrough(),service_tier:N().nullable().optional(),system_fingerprint:N().nullable().optional()}).passthrough(),w1=G({id:N(),object:Ce("chat.completion.chunk"),created:K(),model:N(),choices:me(G({index:K(),delta:Ud,finish_reason:N().nullable().optional()})),usage:G({prompt_tokens:K().nullable().optional(),completion_tokens:K().nullable().optional(),total_tokens:K().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),k1=G({input_tokens:K().nullable().optional(),output_tokens:K().nullable().optional(),total_tokens:K().nullable().optional(),input_tokens_details:G({cached_tokens:K().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:G({reasoning_tokens:K().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),_1=G({type:N()}).passthrough(),Ls=G({id:N(),object:Ce("response").optional(),created_at:K().optional(),status:N().nullable().optional(),model:N().optional(),output:me(_1).optional(),output_text:N().optional(),usage:k1.nullable().optional(),error:yn().optional()}).passthrough(),j1=G({type:N()}).passthrough();function Wd(e){try{const t=JSON.parse(e),n=y1.safeParse(t);return n.success?n.data:null}catch{return null}}function Hd(e){try{const t=JSON.parse(e),n=Ls.safeParse(t);return n.success?n.data:null}catch{return null}}const S1=G({error:N()});async function jt(e,t){const n=await e.json();return t.parse(n)}async function Wt(e,t){try{const n=await e.json(),r=S1.safeParse(n);return r.success?r.data.error:t}catch{return t}}async function an(e,t,n,r){const o=await fetch(e,n);if(!o.ok){const i=r?.(o)??`Request failed with status ${o.status}`;throw new Error(await Wt(o,i))}return jt(o,t)}function C1(e){return e<1e3?`${String(e)}ms`:`${String(Math.round(e/1e3))}s`}class za extends Error{constructor(t){super(`Request timed out after ${C1(t)}`),this.name="ApiTimeoutError"}}async function tr(e,t,n,r,o){const i=new AbortController,a=setTimeout(()=>i.abort(),n);try{return await an(e,t,{...r,signal:i.signal},o)}catch(l){throw l instanceof DOMException&&l.name==="AbortError"?new za(n):l}finally{clearTimeout(a)}}const Zd=G({input:K().int().nonnegative(),output:K().int().nonnegative(),cacheCreate:K().int().nonnegative(),cacheRead:K().int().nonnegative(),total:K().int().nonnegative()}),N1=G({id:K().int().positive(),sessionLogNumber:K().int().positive().optional(),timestamp:N(),provider:N().nullable(),model:N().nullable(),apiFormat:Te(["anthropic","openai","unknown"]),method:N(),path:N(),status:K().nullable(),isStreaming:Fe(),hasError:Fe(),error:N().nullable(),latencyMs:K().nullable(),firstChunkMs:K().nullable().optional(),totalStreamMs:K().nullable().optional(),tokensPerSecond:K().nullable().optional(),tokens:G({input:K().nullable(),output:K().nullable(),cacheCreate:K().nullable(),cacheRead:K().nullable()}),sessionId:N().nullable(),userAgent:N().nullable().optional(),clientPid:K().nullable().optional(),clientProjectFolder:N().nullable().optional()}),Vd=G({id:N(),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:N().nullable(),updatedAt:N().nullable(),requestCount:K().int().nonnegative(),activeRequests:K().int().nonnegative(),completedRequests:K().int().nonnegative(),failedRequests:K().int().nonnegative(),queuedTasks:K().int().nonnegative(),runningTasks:K().int().nonnegative(),lastTaskError:N().nullable(),logCount:K().int().nonnegative(),errorCount:K().int().nonnegative(),models:me(N()),providers:me(N()),tokenUsage:Zd,lastLogId:K().nullable(),lastModel:N().nullable(),clientUserAgent:N().nullable().optional(),clientPid:K().nullable(),clientProjectFolder:N().nullable(),inspectorPath:N(),inspectorUrl:N(),apiPath:N(),apiUrl:N(),compactLogsPath:N(),compactLogsUrl:N(),latestLogLimit:K().int().positive(),latestLogs:me(N1)}),Br=Te(["created","running","completed","failed","cancelled"]),Pa=G({jsonPath:N(),markdownPath:N(),htmlPath:N(),exportedAt:N()}),T1=Te(["run-created","session-started","request","session-finished","evidence-exported"]),E1=Te(["info","success","warning","error"]),A1=G({timestamp:N(),kind:T1,severity:E1,title:N(),details:N(),logId:K().int().positive().nullable(),status:K().nullable(),model:N().nullable(),provider:N().nullable(),latencyMs:K().nullable(),isStreaming:Fe().nullable()}),R1=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"]),qd=G({outcome:Te(["success","failure","active","unknown"]),severity:Te(["none","low","medium","high"]),category:R1,summary:N(),evidenceLogIds:me(K().int().positive()),hints:me(N())}),Oa=G({status:Te(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:N(),markdown:N()}),Kd=Oa,Ma=G({id:N(),sessionId:N(),groupId:N().nullable().default(null),title:N(),task:N().nullable(),project:N().nullable(),agent:N().nullable(),status:Br,tags:me(N()),metadata:Ke(N(),Qe),evidence:Pa.nullable(),createdAt:N(),updatedAt:N()});G({runId:N().min(1).optional(),sessionId:N().min(1).optional(),groupId:N().min(1).nullable().optional(),title:N().min(1).optional(),task:N().nullable().optional(),project:N().nullable().optional(),agent:N().nullable().optional(),status:Br.optional(),tags:me(N()).optional(),metadata:Ke(N(),Qe).optional()}).optional();G({sessionId:N().min(1).optional(),groupId:N().min(1).nullable().optional(),title:N().min(1).optional(),task:N().nullable().optional(),project:N().nullable().optional(),agent:N().nullable().optional(),status:Br.optional(),tags:me(N()).optional(),metadata:Ke(N(),Qe).optional()});G({includeHistory:Fe().optional(),latestLogLimit:K().int().positive().max(50).optional()}).optional();G({run:Ma,evidence:Pa,session:Vd.nullable(),timeline:me(A1),classification:qd,jenkinsReport:Oa});const I1=G({run:Ma,classification:qd,evidence:Pa.nullable(),jenkinsReport:Oa.nullable(),sessionId:N(),inspectorUrl:N().nullable(),evidenceMarkdownPath:N().nullable(),updatedAt:N()});G({failures:me(I1),total:K().int().nonnegative(),limit:K().int().positive()});const La=Te(["created","running","completed","failed","cancelled"]),Da=Te(["evaluation","batch","manual"]),$a=G({jsonPath:N(),markdownPath:N(),htmlPath:N(),exportedAt:N()}),Gd=G({id:N(),groupId:N(),sessionId:N(),runId:N().nullable(),label:N().nullable(),agent:N().nullable(),provider:N().nullable(),model:N().nullable(),status:Br.nullable(),metadata:Ke(N(),Qe),addedAt:N(),updatedAt:N()}),Fa=G({id:N(),title:N(),kind:Da,task:N().nullable(),project:N().nullable(),status:La,tags:me(N()),metadata:Ke(N(),Qe),evidence:$a.nullable(),members:me(Gd),createdAt:N(),updatedAt:N()});G({groupId:N().min(1).optional(),title:N().min(1).optional(),kind:Da.optional(),task:N().nullable().optional(),project:N().nullable().optional(),status:La.optional(),tags:me(N()).optional(),metadata:Ke(N(),Qe).optional()}).optional();G({title:N().min(1).optional(),kind:Da.optional(),task:N().nullable().optional(),project:N().nullable().optional(),status:La.optional(),tags:me(N()).optional(),metadata:Ke(N(),Qe).optional()});G({memberId:N().min(1).optional(),sessionId:N().min(1),runId:N().min(1).nullable().optional(),label:N().min(1).nullable().optional(),agent:N().min(1).nullable().optional(),provider:N().min(1).nullable().optional(),model:N().min(1).nullable().optional(),status:Br.nullable().optional(),metadata:Ke(N(),Qe).optional()});G({includeHistory:Fe().optional(),latestLogLimit:K().int().positive().max(50).optional()}).optional();G({deleteEvidence:Fe().optional()});const z1=G({groupId:N(),deleted:Fe(),evidenceDeleted:Fe(),evidencePath:N().nullable()}),Jd=G({member:Gd,run:Ma.nullable(),session:Vd.nullable()}),Yd=G({memberCount:K().int().nonnegative(),sessionsWithData:K().int().nonnegative(),missingSessions:K().int().nonnegative(),requestCount:K().int().nonnegative(),errorCount:K().int().nonnegative(),tokenUsage:Zd,models:me(N()),providers:me(N()),completedMembers:K().int().nonnegative(),failedMembers:K().int().nonnegative(),runningMembers:K().int().nonnegative()}),P1=G({group:Fa,evidence:$a,members:me(Jd).nullable(),markdown:N(),summary:Yd.nullable(),report:Kd.nullable()}),O1=G({group:Fa,evidence:$a,members:me(Jd),summary:Yd,jenkinsReport:Kd}),Xd=G({groups:me(Fa)}),M1=G({sessionId:N(),imported:K().int().nonnegative(),skipped:K().int().nonnegative(),warnings:me(N()),logs:me(Rr)}),Ds=10,zi=600,$s=60,Pi=600,Fs="time",Ba="simple",Qd=Te(["time","full"]),L1=Te(["simple","full"]),vo=G({stripClaudeCodeBillingHeader:Fe(),hasSeenOnboarding:Fe().default(!1),slowResponseThresholdSeconds:K().int().min(0).max(zi).default(Ds),providerTestTimeoutSeconds:K().int().min(1).max(Pi).default($s),timeDisplayFormat:Qd.default(Fs),captureMode:L1.default(Ba)}),Hn="/api/config";async function D1(e){return an(e,vo,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function rs(e){return an(Hn,vo,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function Ua(){const e=Tn(Hn,D1,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=Yu(),n=e.data?.stripClaudeCodeBillingHeader??!1,r=e.data?.captureMode??Ba,o=e.data?.slowResponseThresholdSeconds??Ds,i=e.data?.providerTestTimeoutSeconds??$s,a=e.data?.timeDisplayFormat??Fs,l=m=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??Ds,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??$s,timeDisplayFormat:e.data?.timeDisplayFormat??Fs,captureMode:r,...m}),c=async m=>{await t(Hn,rs({stripClaudeCodeBillingHeader:m}),{optimisticData:l({stripClaudeCodeBillingHeader:m}),rollbackOnError:!0,revalidate:!1})},u=async m=>{await t(Hn,rs({slowResponseThresholdSeconds:m}),{optimisticData:l({slowResponseThresholdSeconds:m}),rollbackOnError:!0,revalidate:!1})},d=async m=>{await t(Hn,rs({timeDisplayFormat:m}),{optimisticData:l({timeDisplayFormat:m}),rollbackOnError:!0,revalidate:!1})},f=async m=>{await t(Hn,rs({providerTestTimeoutSeconds:m}),{optimisticData:l({providerTestTimeoutSeconds:m}),rollbackOnError:!0,revalidate:!1})};return{strip:n,captureMode:r,slowResponseThresholdSeconds:o,providerTestTimeoutSeconds:i,timeDisplayFormat:a,isLoading:e.isLoading,isError:e.error!==void 0,setStrip:c,setSlowResponseThresholdSeconds:u,setProviderTestTimeoutSeconds:f,setTimeDisplayFormat:d}}const ef=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();const $1=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const F1=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase());const sc=e=>{const t=F1(e);return t.charAt(0).toUpperCase()+t.slice(1)};var B1={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 U1=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const W1=p.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:a,...l},c)=>p.createElement("svg",{ref:c,...B1,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:ef("lucide",o),...!i&&!U1(l)&&{"aria-hidden":"true"},...l},[...a.map(([u,d])=>p.createElement(u,d)),...Array.isArray(i)?i:[i]]));const pe=(e,t)=>{const n=p.forwardRef(({className:r,...o},i)=>p.createElement(W1,{ref:i,iconNode:t,className:ef(`lucide-${$1(sc(e))}`,`lucide-${e}`,r),...o}));return n.displayName=sc(e),n};const H1=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],Z1=pe("arrow-down-right",H1);const V1=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],q1=pe("arrow-down",V1);const K1=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],G1=pe("arrow-left",K1);const J1=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],Y1=pe("arrow-up-right",J1);const X1=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Q1=pe("arrow-up",X1);const ey=[["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"}]],ty=pe("bell",ey);const ny=[["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"}]],ry=pe("blocks",ny);const sy=[["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"}]],tf=pe("brain",sy);const oy=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ge=pe("check",oy);const iy=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],st=pe("chevron-down",iy);const ay=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ly=pe("chevron-left",ay);const cy=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],bt=pe("chevron-right",cy);const uy=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Wa=pe("chevron-up",uy);const dy=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],fy=pe("chevrons-down",dy);const py=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],hy=pe("chevrons-left",py);const my=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],gy=pe("chevrons-right",my);const xy=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],by=pe("chevrons-up",xy);const vy=[["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"}]],Ir=pe("circle-alert",vy);const yy=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],wy=pe("circle-check-big",yy);const ky=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Oi=pe("circle-check",ky);const _y=[["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"}]],jy=pe("circle-question-mark",_y);const Sy=[["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"}]],nf=pe("circle-x",Sy);const Cy=[["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"}]],Ny=pe("clapperboard",Cy);const Ty=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ey=pe("clock-3",Ty);const Ay=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ht=pe("clock",Ay);const Ry=[["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"}]],Iy=pe("cloud-upload",Ry);const zy=[["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"}]],Py=pe("code-xml",zy);const Oy=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],My=pe("columns-2",Oy);const Ly=[["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"}]],Nt=pe("copy",Ly);const Dy=[["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"}]],$y=pe("cpu",Dy);const Fy=[["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"}]],yo=pe("download",Fy);const By=[["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"}]],Uy=pe("ellipsis",By);const Wy=[["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"}]],Ha=pe("external-link",Wy);const Hy=[["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"}]],Za=pe("eye-off",Hy);const Zy=[["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"}]],Va=pe("eye",Zy);const Vy=[["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"}]],qy=pe("file-braces",Vy);const Ky=[["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"}]],Gy=pe("file-diff",Ky);const Jy=[["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"}]],Yy=pe("file-search",Jy);const Xy=[["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"}]],Qy=pe("file-terminal",Xy);const e2=[["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"}]],t2=pe("file-text",e2);const n2=[["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"}]],r2=pe("flag",n2);const s2=[["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"}]],o2=pe("folder-open",s2);const i2=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],qa=pe("gauge",i2);const a2=[["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"}]],l2=pe("git-compare-arrows",a2);const c2=[["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"}]],rf=pe("globe",c2);const u2=[["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"}]],d2=pe("history",u2);const f2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],p2=pe("info",f2);const h2=[["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"}]],oc=pe("layers",h2);const m2=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ft=pe("loader-circle",m2);const g2=[["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"}]],x2=pe("lock",g2);const b2=[["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"}]],wo=pe("message-square",b2);const v2=[["path",{d:"M5 12h14",key:"1ays0h"}]],y2=pe("minus",v2);const w2=[["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"}]],k2=pe("monitor",w2);const _2=[["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"}]],j2=pe("mouse-pointer-click",_2);const S2=[["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"}]],C2=pe("octagon-alert",S2);const N2=[["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"}]],sf=pe("pencil",N2);const T2=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Mi=pe("plus",T2);const E2=[["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"}]],ic=pe("radio",E2);const A2=[["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"}]],zr=pe("refresh-cw",A2);const R2=[["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"}]],I2=pe("rotate-ccw",R2);const z2=[["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"}]],Li=pe("rotate-cw",z2);const P2=[["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"}]],O2=pe("rows-3",P2);const M2=[["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"}]],L2=pe("save",M2);const D2=[["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"}]],$2=pe("scan",D2);const F2=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],B2=pe("search",F2);const U2=[["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"}]],W2=pe("server",U2);const H2=[["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"}]],Z2=pe("settings",H2);const V2=[["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"}]],q2=pe("shield-alert",V2);const K2=[["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"}]],ac=pe("shield-check",K2);const G2=[["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"}]],Di=pe("siren",G2);const J2=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Ka=pe("terminal",J2);const Y2=[["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"}]],X2=pe("timer",Y2);const Q2=[["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"}]],nr=pe("trash-2",Q2);const ew=[["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"}]],rn=pe("triangle-alert",ew);const tw=[["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"}]],of=pe("upload",tw);const nw=[["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"}]],rw=pe("wifi-off",nw);const sw=[["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"}]],ow=pe("wifi",sw);const iw=[["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"}]],Ur=pe("wrench",iw);const aw=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ko=pe("x",aw);const lw=[["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"}]],Pr=pe("zap",lw),$i="/api/config";async function cw(e){return an(e,vo,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function uw(e){return an($i,vo,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function dw(){const e=Tn($i,cw,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=Yu(),n=e.data?.hasSeenOnboarding??!1,r=e.data?.captureMode??Ba,o=async()=>{await t($i,uw({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??Ds,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??$s,timeDisplayFormat:e.data?.timeDisplayFormat??Fs,captureMode:r},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:n,captureMode:r,isLoading:e.isLoading,markSeen:o}}function fw(){const{hasSeenOnboarding:e,isLoading:t,markSeen:n}=dw(),[r,o]=p.useState(!1);if(t||e)return null;const i=r?"grid":"hidden sm:grid";return s.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:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(p2,{className:"mt-0.5 size-4 shrink-0 text-amber-300","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"font-medium text-amber-200",children:"Inspector ready"}),s.jsx("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:"Request, response, tool, timing, token, replay, and memory signals are active."})]}),s.jsx("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground sm:hidden",children:"Core capture is active."}),s.jsxs("div",{className:`${i} mt-2 gap-x-4 gap-y-1 text-xs leading-relaxed text-muted-foreground sm:grid-cols-2`,children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Evidence"}),": logs, sessions, groups, and MCP exports are available."]}),s.jsxs("div",{children:[s.jsx("strong",{children:"Network"}),": replace ",s.jsx("code",{children:"localhost"})," if containers differ."]})]})]}),s.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":r,"aria-label":r?"Hide onboarding details":"Show onboarding details",children:s.jsx(st,{className:`size-3.5 transition-transform ${r?"rotate-180":""}`})}),s.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:[s.jsx(Ge,{className:"size-3.5"}),"Got it"]}),s.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:s.jsx(ko,{className:"size-3.5"})})]})})}function ss(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 Jo={exports:{}};var lc;function pw(){return lc||(lc=1,(function(e,t){(function(n){e.exports=n()})(function(){return(function n(r,o,i){function a(u,d){if(!o[u]){if(!r[u]){var f=typeof ss=="function"&&ss;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:{}};r[u][0].call(h.exports,function(v){var g=r[u][1][v];return a(g||v)},h,h.exports,n,r,o,i)}return o[u].exports}for(var l=typeof ss=="function"&&ss,c=0;c<i.length;c++)a(i[c]);return a})({1:[function(n,r,o){var i=n("./utils"),a=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(c){for(var u,d,f,m,h,v,g,x=[],b=0,y=c.length,_=y,j=i.getTypeOf(c)!=="string";b<c.length;)_=y-b,f=j?(u=c[b++],d=b<y?c[b++]:0,b<y?c[b++]:0):(u=c.charCodeAt(b++),d=b<y?c.charCodeAt(b++):0,b<y?c.charCodeAt(b++):0),m=u>>2,h=(3&u)<<4|d>>4,v=1<_?(15&d)<<2|f>>6:64,g=2<_?63&f:64,x.push(l.charAt(m)+l.charAt(h)+l.charAt(v)+l.charAt(g));return x.join("")},o.decode=function(c){var u,d,f,m,h,v,g=0,x=0,b="data:";if(c.substr(0,b.length)===b)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|(v=l.indexOf(c.charAt(g++))),y[x++]=u,h!==64&&(y[x++]=d),v!==64&&(y[x++]=f);return y}},{"./support":30,"./utils":32}],2:[function(n,r,o){var i=n("./external"),a=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,m,h,v){this.compressedSize=d,this.uncompressedSize=f,this.crc32=m,this.compression=h,this.compressedContent=v}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)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,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,r,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})();r.exports=function(l,c){return l!==void 0&&l.length?i.getTypeOf(l)!=="string"?(function(u,d,f,m){var h=a,v=m+f;u^=-1;for(var g=m;g<v;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,v=m+f;u^=-1;for(var g=m;g<v;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,r,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,r,o){var i=null;i=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:i}},{lie:37}],7:[function(n,r,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,r,o){function i(h,v){var g,x="";for(g=0;g<v;g++)x+=String.fromCharCode(255&h),h>>>=8;return x}function a(h,v,g,x,b,y){var _,j,S=h.file,E=h.compression,C=y!==u.utf8encode,R=l.transformTo("string",y(S.name)),z=l.transformTo("string",u.utf8encode(S.name)),O=S.comment,q=l.transformTo("string",y(O)),T=l.transformTo("string",u.utf8encode(O)),D=z.length!==S.name.length,k=T.length!==O.length,$="",X="",B="",F=S.dir,Z=S.date,J={crc32:0,compressedSize:0,uncompressedSize:0};v&&!g||(J.crc32=h.crc32,J.compressedSize=h.compressedSize,J.uncompressedSize=h.uncompressedSize);var H=0;v&&(H|=8),C||!D&&!k||(H|=2048);var W=0,ce=0;F&&(W|=16),b==="UNIX"?(ce=798,W|=(function(oe,_e){var ie=oe;return oe||(ie=_e?16893:33204),(65535&ie)<<16})(S.unixPermissions,F)):(ce=20,W|=(function(oe){return 63&(oe||0)})(S.dosPermissions)),_=Z.getUTCHours(),_<<=6,_|=Z.getUTCMinutes(),_<<=5,_|=Z.getUTCSeconds()/2,j=Z.getUTCFullYear()-1980,j<<=4,j|=Z.getUTCMonth()+1,j<<=5,j|=Z.getUTCDate(),D&&(X=i(1,1)+i(d(R),4)+z,$+="up"+i(X.length,2)+X),k&&(B=i(1,1)+i(d(q),4)+T,$+="uc"+i(B.length,2)+B);var se="";return se+=`
41
- \0`,se+=i(H,2),se+=E.magic,se+=i(_,2),se+=i(j,2),se+=i(J.crc32,4),se+=i(J.compressedSize,4),se+=i(J.uncompressedSize,4),se+=i(R.length,2),se+=i($.length,2),{fileRecord:f.LOCAL_FILE_HEADER+se+R+$,dirRecord:f.CENTRAL_FILE_HEADER+i(ce,2)+se+i(q.length,2)+"\0\0\0\0"+i(W,4)+i(x,4)+R+$+q}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function m(h,v,g,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=v,this.zipPlatform=g,this.encodeFileName=x,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 v=h.meta.percent||0,g=this.entriesCount,x=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?(v+100*(g-x-1))/g:100}}))},m.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var v=this.streamFiles&&!h.file.dir;if(v){var g=a(h,v,!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 v=this.streamFiles&&!h.file.dir,g=a(h,v,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),v)this.push({data:(function(x){return f.DATA_DESCRIPTOR+i(x.crc32,4)+i(x.compressedSize,4)+i(x.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,v=0;v<this.dirRecords.length;v++)this.push({data:this.dirRecords[v],meta:{percent:100}});var g=this.bytesWritten-h,x=(function(b,y,_,j,S){var E=l.transformTo("string",S(j));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(b,2)+i(b,2)+i(y,4)+i(_,4)+i(E.length,2)+E})(this.dirRecords.length,g,h,this.zipComment,this.encodeFileName);this.push({data:x,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 v=this;return h.on("data",function(g){v.processChunk(g)}),h.on("end",function(){v.closedSource(v.previous.streamInfo),v._sources.length?v.prepareNextSource():v.end()}),h.on("error",function(g){v.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 v=this._sources;if(!c.prototype.error.call(this,h))return!1;for(var g=0;g<v.length;g++)try{v[g].error(h)}catch{}return!0},m.prototype.lock=function(){c.prototype.lock.call(this);for(var h=this._sources,v=0;v<h.length;v++)h[v].lock()},r.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,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 v=(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||{},x=h.dir,b=h.date;h._compressWorker(v,g).withStreamInfo("file",{name:m,dir:x,date:b,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,r,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"),r.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,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,v){var g=m.decompressed.getContentWorker().pipe(new u);g.on("error",function(x){v(x)}).on("end",function(){g.streamInfo.crc32!==m.decompressed.crc32?v(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}r.exports=function(m,h){var v=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 x=new c(h);return x.load(g),x}).then(function(g){var x=[a.Promise.resolve(g)],b=g.files;if(h.checkCRC32)for(var y=0;y<b.length;y++)x.push(f(b[y]));return a.Promise.all(x)}).then(function(g){for(var x=g.shift(),b=x.files,y=0;y<b.length;y++){var _=b[y],j=_.fileNameStr,S=i.resolve(_.fileNameStr);v.file(S,_.decompressed,{binary:!0,optimizedBinaryString:!0,date:_.date,dir:_.dir,comment:_.fileCommentStr.length?_.fileCommentStr:null,unixPermissions:_.unixPermissions,dosPermissions:_.dosPermissions,createFolders:h.createFolders}),_.dir||(v.file(S).unsafeOriginalName=j)}return x.zipComment.length&&(v.comment=x.zipComment),v})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,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)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,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()},r.exports=a},{"../utils":32,"readable-stream":16}],14:[function(n,r,o){r.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,r,o){function i(S,E,C){var R,z=l.getTypeOf(E),O=l.extend(C||{},d);O.date=O.date||new Date,O.compression!==null&&(O.compression=O.compression.toUpperCase()),typeof O.unixPermissions=="string"&&(O.unixPermissions=parseInt(O.unixPermissions,8)),O.unixPermissions&&16384&O.unixPermissions&&(O.dir=!0),O.dosPermissions&&16&O.dosPermissions&&(O.dir=!0),O.dir&&(S=b(S)),O.createFolders&&(R=x(S))&&y.call(this,R,!0);var q=z==="string"&&O.binary===!1&&O.base64===!1;C&&C.binary!==void 0||(O.binary=!q),(E instanceof f&&E.uncompressedSize===0||O.dir||!E||E.length===0)&&(O.base64=!1,O.binary=!0,E="",O.compression="STORE",z="string");var T=null;T=E instanceof f||E instanceof c?E:v.isNode&&v.isStream(E)?new g(S,E):l.prepareContent(S,E,O.binary,O.optimizedBinaryString,O.base64);var D=new m(S,T,O);this.files[S]=D}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"),v=n("./nodejsUtils"),g=n("./nodejs/NodejsStreamInputAdapter"),x=function(S){S.slice(-1)==="/"&&(S=S.substring(0,S.length-1));var E=S.lastIndexOf("/");return 0<E?S.substring(0,E):""},b=function(S){return S.slice(-1)!=="/"&&(S+="/"),S},y=function(S,E){return E=E!==void 0?E:d.createFolders,S=b(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,C,R;for(E in this.files)R=this.files[E],(C=E.slice(this.root.length,E.length))&&E.slice(0,this.root.length)===this.root&&S(C,R)},filter:function(S){var E=[];return this.forEach(function(C,R){S(C,R)&&E.push(R)}),E},file:function(S,E,C){if(arguments.length!==1)return S=this.root+S,i.call(this,S,E,C),this;if(_(S)){var R=S;return this.filter(function(O,q){return!q.dir&&R.test(O)})}var z=this.files[this.root+S];return z&&!z.dir?z:null},folder:function(S){if(!S)return this;if(_(S))return this.filter(function(z,O){return O.dir&&S.test(z)});var E=this.root+S,C=y.call(this,E),R=this.clone();return R.root=C.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 C=this.filter(function(z,O){return O.name.slice(0,S.length)===S}),R=0;R<C.length;R++)delete this.files[C[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,C={};try{if((C=l.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");l.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var R=C.comment||this.comment||"";E=h.generateWorker(this,C,R)}catch(z){(E=new c("error")).error(z)}return new u(E,C.type||"string",C.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)}};r.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,r,o){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,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},r.exports=a},{"../utils":32,"./DataReader":18}],18:[function(n,r,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))}},r.exports=a},{"../utils":32}],19:[function(n,r,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},r.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,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},r.exports=a},{"../utils":32,"./DataReader":18}],21:[function(n,r,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},r.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){var i=n("../utils"),a=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.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,r,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,r,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})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,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)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,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)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,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}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,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}},r.exports=i},{}],29:[function(n,r,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(v,g){return new d.Promise(function(x,b){var y=[],_=v._internalType,j=v._outputType,S=v._mimeType;v.on("data",function(E,C){y.push(E),g&&g(C)}).on("error",function(E){y=[],b(E)}).on("end",function(){try{var E=(function(C,R,z){switch(C){case"blob":return i.newBlob(i.transformTo("arraybuffer",R),z);case"base64":return c.encode(R);default:return i.transformTo(C,R)}})(j,(function(C,R){var z,O=0,q=null,T=0;for(z=0;z<R.length;z++)T+=R[z].length;switch(C){case"string":return R.join("");case"array":return Array.prototype.concat.apply([],R);case"uint8array":for(q=new Uint8Array(T),z=0;z<R.length;z++)q.set(R[z],O),O+=R[z].length;return q;case"nodebuffer":return Buffer.concat(R);default:throw new Error("concat : unsupported type '"+C+"'")}})(_,y),S);x(E)}catch(C){b(C)}y=[]}).resume()})}function h(v,g,x){var b=g;switch(g){case"blob":case"arraybuffer":b="uint8array";break;case"base64":b="string"}try{this._internalType=b,this._outputType=g,this._mimeType=x,i.checkSupport(b),this._worker=v.pipe(new a(b)),v.lock()}catch(y){this._worker=new l("error"),this._worker.error(y)}}h.prototype={accumulate:function(v){return m(this,v)},on:function(v,g){var x=this;return v==="data"?this._worker.on(v,function(b){g.call(x,b.data,b.meta)}):this._worker.on(v,function(){i.delay(g,arguments,x)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(v){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"},v)}},r.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,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,r,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(v){var g,x,b,y,_,j=v.length,S=0;for(y=0;y<j;y++)(64512&(x=v.charCodeAt(y)))==55296&&y+1<j&&(64512&(b=v.charCodeAt(y+1)))==56320&&(x=65536+(x-55296<<10)+(b-56320),y++),S+=x<128?1:x<2048?2:x<65536?3:4;for(g=a.uint8array?new Uint8Array(S):new Array(S),y=_=0;_<S;y++)(64512&(x=v.charCodeAt(y)))==55296&&y+1<j&&(64512&(b=v.charCodeAt(y+1)))==56320&&(x=65536+(x-55296<<10)+(b-56320),y++),x<128?g[_++]=x:(x<2048?g[_++]=192|x>>>6:(x<65536?g[_++]=224|x>>>12:(g[_++]=240|x>>>18,g[_++]=128|x>>>12&63),g[_++]=128|x>>>6&63),g[_++]=128|63&x);return g})(h)},o.utf8decode=function(h){return a.nodebuffer?i.transformTo("nodebuffer",h).toString("utf-8"):(function(v){var g,x,b,y,_=v.length,j=new Array(2*_);for(g=x=0;g<_;)if((b=v[g++])<128)j[x++]=b;else if(4<(y=u[b]))j[x++]=65533,g+=y-1;else{for(b&=y===2?31:y===3?15:7;1<y&&g<_;)b=b<<6|63&v[g++],y--;1<y?j[x++]=65533:b<65536?j[x++]=b:(b-=65536,j[x++]=55296|b>>10&1023,j[x++]=56320|1023&b)}return j.length!==x&&(j.subarray?j=j.subarray(0,x):j.length=x),i.applyFromCharCode(j)})(h=i.transformTo(a.uint8array?"uint8array":"array",h))},i.inherits(f,c),f.prototype.processChunk=function(h){var v=i.transformTo(a.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var g=v;(v=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),v.set(g,this.leftOver.length)}else v=this.leftOver.concat(v);this.leftOver=null}var x=(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:_})(v),b=v;x!==v.length&&(a.uint8array?(b=v.subarray(0,x),this.leftOver=v.subarray(x,v.length)):(b=v.slice(0,x),this.leftOver=v.slice(x,v.length))),this.push({data:o.utf8decode(b),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,r,o){var i=n("./support"),a=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(g){return g}function d(g,x){for(var b=0;b<g.length;++b)x[b]=255&g.charCodeAt(b);return x}n("setimmediate"),o.newBlob=function(g,x){o.checkSupport("blob");try{return new Blob([g],{type:x})}catch{try{var b=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return b.append(g),b.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(g,x,b){var y=[],_=0,j=g.length;if(j<=b)return String.fromCharCode.apply(null,g);for(;_<j;)x==="array"||x==="nodebuffer"?y.push(String.fromCharCode.apply(null,g.slice(_,Math.min(_+b,j)))):y.push(String.fromCharCode.apply(null,g.subarray(_,Math.min(_+b,j)))),_+=b;return y.join("")},stringifyByChar:function(g){for(var x="",b=0;b<g.length;b++)x+=String.fromCharCode(g[b]);return x},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 x=65536,b=o.getTypeOf(g),y=!0;if(b==="uint8array"?y=f.applyCanBeUsed.uint8array:b==="nodebuffer"&&(y=f.applyCanBeUsed.nodebuffer),y)for(;1<x;)try{return f.stringifyByChunk(g,b,x)}catch{x=Math.floor(x/2)}return f.stringifyByChar(g)}function h(g,x){for(var b=0;b<g.length;b++)x[b]=g[b];return x}o.applyFromCharCode=m;var v={};v.string={string:u,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return v.string.uint8array(g).buffer},uint8array:function(g){return d(g,new Uint8Array(g.length))},nodebuffer:function(g){return d(g,l.allocBuffer(g.length))}},v.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)}},v.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))}},v.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)}},v.nodebuffer={string:m,array:function(g){return h(g,new Array(g.length))},arraybuffer:function(g){return v.nodebuffer.uint8array(g).buffer},uint8array:function(g){return h(g,new Uint8Array(g.length))},nodebuffer:u},o.transformTo=function(g,x){if(x=x||"",!g)return x;o.checkSupport(g);var b=o.getTypeOf(x);return v[b][g](x)},o.resolve=function(g){for(var x=g.split("/"),b=[],y=0;y<x.length;y++){var _=x[y];_==="."||_===""&&y!==0&&y!==x.length-1||(_===".."?b.pop():b.push(_))}return b.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 x,b,y="";for(b=0;b<(g||"").length;b++)y+="\\x"+((x=g.charCodeAt(b))<16?"0":"")+x.toString(16).toUpperCase();return y},o.delay=function(g,x,b){setImmediate(function(){g.apply(b||null,x||[])})},o.inherits=function(g,x){function b(){}b.prototype=x.prototype,g.prototype=new b},o.extend=function(){var g,x,b={};for(g=0;g<arguments.length;g++)for(x in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],x)&&b[x]===void 0&&(b[x]=arguments[g][x]);return b},o.prepareContent=function(g,x,b,y,_){return c.Promise.resolve(x).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 C=new FileReader;C.onload=function(R){S(R.target.result)},C.onerror=function(R){E(R.target.error)},C.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):b&&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,r,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 v=this.reader.readString(4)===m;return this.reader.setIndex(h),v},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,v=this.zip64EndOfCentralSize-44;0<v;)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 v=m-h;if(0<v)this.isSignature(m,l.CENTRAL_FILE_HEADER)||(this.reader.zero=v);else if(v<0)throw new Error("Corrupted zip: missing "+Math.abs(v)+" bytes.")},prepareReader:function(f){this.reader=i(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,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,v){this.options=h,this.loadOptions=v}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var v,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((v=(function(x){for(var b in d)if(Object.prototype.hasOwnProperty.call(d,b)&&d[b].magic===x)return d[b];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,v,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 v=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(v),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 v,g,x,b=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<b;)v=h.readInt(2),g=h.readInt(2),x=h.readData(g),this.extraFields[v]={id:v,length:g,value:x};h.setIndex(b)},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 v=this.findExtraFieldUnicodePath();if(v!==null)this.fileNameStr=v;else{var g=a.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var b=a.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(b)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var v=i(h.value);return v.readInt(1)!==1||c(this.fileName)!==v.readInt(4)?null:u.utf8decode(v.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var v=i(h.value);return v.readInt(1)!==1||c(this.fileComment)!==v.readInt(4)?null:u.utf8decode(v.readData(h.length-5))}return null}},r.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,o){function i(v,g,x){this.name=v,this.dir=x.dir,this.date=x.date,this.comment=x.comment,this.unixPermissions=x.unixPermissions,this.dosPermissions=x.dosPermissions,this._data=g,this._dataBinary=x.binary,this.options={compression:x.compression,compressionOptions:x.compressionOptions}}var a=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");i.prototype={internalStream:function(v){var g=null,x="string";try{if(!v)throw new Error("No output type specified.");var b=(x=v.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),g=this._decompressWorker();var y=!this._dataBinary;y&&!b&&(g=g.pipe(new c.Utf8EncodeWorker)),!y&&b&&(g=g.pipe(new c.Utf8DecodeWorker))}catch(_){(g=new d("error")).error(_)}return new a(g,x,"")},async:function(v,g){return this.internalStream(v).accumulate(g)},nodeStream:function(v,g){return this.internalStream(v||"nodebuffer").toNodejsStream(g)},_compressWorker:function(v,g){if(this._data instanceof u&&this._data.compression.magic===v.magic)return this._data.getCompressedWorker();var x=this._decompressWorker();return this._dataBinary||(x=x.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(x,v,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;r.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,o){(function(i){var a,l,c=i.MutationObserver||i.WebKitMutationObserver;if(c){var u=0,d=new c(v),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(){v(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},i.document.documentElement.appendChild(g)}:function(){setTimeout(v,0)};else{var m=new i.MessageChannel;m.port1.onmessage=v,a=function(){m.port2.postMessage(0)}}var h=[];function v(){var g,x;l=!0;for(var b=h.length;b;){for(x=h,h=[],g=-1;++g<b;)x[g]();b=h.length}l=!1}r.exports=function(g){h.push(g)!==1||l||a()}}).call(this,typeof Qr<"u"?Qr:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,o){var i=n("immediate");function a(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(b){if(typeof b!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,b!==a&&g(this,b)}function m(b,y,_){this.promise=b,typeof y=="function"&&(this.onFulfilled=y,this.callFulfilled=this.otherCallFulfilled),typeof _=="function"&&(this.onRejected=_,this.callRejected=this.otherCallRejected)}function h(b,y,_){i(function(){var j;try{j=y(_)}catch(S){return l.reject(b,S)}j===b?l.reject(b,new TypeError("Cannot resolve promise with itself")):l.resolve(b,j)})}function v(b){var y=b&&b.then;if(b&&(typeof b=="object"||typeof b=="function")&&typeof y=="function")return function(){y.apply(b,arguments)}}function g(b,y){var _=!1;function j(C){_||(_=!0,l.reject(b,C))}function S(C){_||(_=!0,l.resolve(b,C))}var E=x(function(){y(S,j)});E.status==="error"&&j(E.value)}function x(b,y){var _={};try{_.value=b(y),_.status="success"}catch(j){_.status="error",_.value=j}return _}(r.exports=f).prototype.finally=function(b){if(typeof b!="function")return this;var y=this.constructor;return this.then(function(_){return y.resolve(b()).then(function(){return _})},function(_){return y.resolve(b()).then(function(){throw _})})},f.prototype.catch=function(b){return this.then(null,b)},f.prototype.then=function(b,y){if(typeof b!="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?b:y,this.outcome):this.queue.push(new m(_,b,y)),_},m.prototype.callFulfilled=function(b){l.resolve(this.promise,b)},m.prototype.otherCallFulfilled=function(b){h(this.promise,this.onFulfilled,b)},m.prototype.callRejected=function(b){l.reject(this.promise,b)},m.prototype.otherCallRejected=function(b){h(this.promise,this.onRejected,b)},l.resolve=function(b,y){var _=x(v,y);if(_.status==="error")return l.reject(b,_.value);var j=_.value;if(j)g(b,j);else{b.state=u,b.outcome=y;for(var S=-1,E=b.queue.length;++S<E;)b.queue[S].callFulfilled(y)}return b},l.reject=function(b,y){b.state=c,b.outcome=y;for(var _=-1,j=b.queue.length;++_<j;)b.queue[_].callRejected(y);return b},f.resolve=function(b){return b instanceof this?b:l.resolve(new this(a),b)},f.reject=function(b){var y=new this(a);return l.reject(y,b)},f.all=function(b){var y=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var _=b.length,j=!1;if(!_)return this.resolve([]);for(var S=new Array(_),E=0,C=-1,R=new this(a);++C<_;)z(b[C],C);return R;function z(O,q){y.resolve(O).then(function(T){S[q]=T,++E!==_||j||(j=!0,l.resolve(R,S))},function(T){j||(j=!0,l.reject(R,T))})}},f.race=function(b){var y=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var _=b.length,j=!1;if(!_)return this.resolve([]);for(var S=-1,E=new this(a);++S<_;)C=b[S],y.resolve(C).then(function(R){j||(j=!0,l.resolve(E,R))},function(R){j||(j=!0,l.reject(E,R))});var C;return E}},{immediate:36}],38:[function(n,r,o){var i={};(0,n("./lib/utils/common").assign)(i,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,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,v=8;function g(b){if(!(this instanceof g))return new g(b);this.options=a.assign({level:m,method:v,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},b||{});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 x(b,y){var _=new g(y);if(_.push(b,!0),_.err)throw _.msg||c[_.err];return _.result}g.prototype.push=function(b,y){var _,j,S=this.strm,E=this.options.chunkSize;if(this.ended)return!1;j=y===~~y?y:y===!0?4:0,typeof b=="string"?S.input=l.string2buf(b):d.call(b)==="[object ArrayBuffer]"?S.input=new Uint8Array(b):S.input=b,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(b){this.chunks.push(b)},g.prototype.onEnd=function(b){b===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},o.Deflate=g,o.deflate=x,o.deflateRaw=function(b,y){return(y=y||{}).raw=!0,x(b,y)},o.gzip=function(b,y){return(y=y||{}).gzip=!0,x(b,y)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,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 x=this.options;x.raw&&0<=x.windowBits&&x.windowBits<16&&(x.windowBits=-x.windowBits,x.windowBits===0&&(x.windowBits=-15)),!(0<=x.windowBits&&x.windowBits<16)||g&&g.windowBits||(x.windowBits+=32),15<x.windowBits&&x.windowBits<48&&(15&x.windowBits)==0&&(x.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var b=i.inflateInit2(this.strm,x.windowBits);if(b!==c.Z_OK)throw new Error(u[b]);this.header=new f,i.inflateGetHeader(this.strm,this.header)}function v(g,x){var b=new h(x);if(b.push(g,!0),b.err)throw b.msg||u[b.err];return b.result}h.prototype.push=function(g,x){var b,y,_,j,S,E,C=this.strm,R=this.options.chunkSize,z=this.options.dictionary,O=!1;if(this.ended)return!1;y=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof g=="string"?C.input=l.binstring2buf(g):m.call(g)==="[object ArrayBuffer]"?C.input=new Uint8Array(g):C.input=g,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new a.Buf8(R),C.next_out=0,C.avail_out=R),(b=i.inflate(C,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&z&&(E=typeof z=="string"?l.string2buf(z):m.call(z)==="[object ArrayBuffer]"?new Uint8Array(z):z,b=i.inflateSetDictionary(this.strm,E)),b===c.Z_BUF_ERROR&&O===!0&&(b=c.Z_OK,O=!1),b!==c.Z_STREAM_END&&b!==c.Z_OK)return this.onEnd(b),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&b!==c.Z_STREAM_END&&(C.avail_in!==0||y!==c.Z_FINISH&&y!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(_=l.utf8border(C.output,C.next_out),j=C.next_out-_,S=l.buf2string(C.output,_),C.next_out=j,C.avail_out=R-j,j&&a.arraySet(C.output,C.output,_,j,0),this.onData(S)):this.onData(a.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(O=!0)}while((0<C.avail_in||C.avail_out===0)&&b!==c.Z_STREAM_END);return b===c.Z_STREAM_END&&(y=c.Z_FINISH),y===c.Z_FINISH?(b=i.inflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===c.Z_OK):y!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(C.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=v,o.inflateRaw=function(g,x){return(x=x||{}).raw=!0,v(g,x)},o.ungzip=v},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,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,v;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(v=new Uint8Array(f),u=m=0,d=c.length;u<d;u++)h=c[u],v.set(h,m),m+=h.length;return v}},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,r,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="",v=0;v<m;v++)h+=String.fromCharCode(f[v]);return h}c[254]=c[254]=1,o.string2buf=function(f){var m,h,v,g,x,b=f.length,y=0;for(g=0;g<b;g++)(64512&(h=f.charCodeAt(g)))==55296&&g+1<b&&(64512&(v=f.charCodeAt(g+1)))==56320&&(h=65536+(h-55296<<10)+(v-56320),g++),y+=h<128?1:h<2048?2:h<65536?3:4;for(m=new i.Buf8(y),g=x=0;x<y;g++)(64512&(h=f.charCodeAt(g)))==55296&&g+1<b&&(64512&(v=f.charCodeAt(g+1)))==56320&&(h=65536+(h-55296<<10)+(v-56320),g++),h<128?m[x++]=h:(h<2048?m[x++]=192|h>>>6:(h<65536?m[x++]=224|h>>>12:(m[x++]=240|h>>>18,m[x++]=128|h>>>12&63),m[x++]=128|h>>>6&63),m[x++]=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,v=m.length;h<v;h++)m[h]=f.charCodeAt(h);return m},o.buf2string=function(f,m){var h,v,g,x,b=m||f.length,y=new Array(2*b);for(h=v=0;h<b;)if((g=f[h++])<128)y[v++]=g;else if(4<(x=c[g]))y[v++]=65533,h+=x-1;else{for(g&=x===2?31:x===3?15:7;1<x&&h<b;)g=g<<6|63&f[h++],x--;1<x?y[v++]=65533:g<65536?y[v++]=g:(g-=65536,y[v++]=55296|g>>10&1023,y[v++]=56320|1023&g)}return d(y,v)},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,r,o){r.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,r,o){r.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,r,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})();r.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,r,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,v=-2,g=-1,x=4,b=2,y=8,_=9,j=286,S=30,E=19,C=2*j+1,R=15,z=3,O=258,q=O+z+1,T=42,D=113,k=1,$=2,X=3,B=4;function F(w,Y){return w.msg=d[Y],Y}function Z(w){return(w<<1)-(4<w?9:0)}function J(w){for(var Y=w.length;0<=--Y;)w[Y]=0}function H(w){var Y=w.state,U=Y.pending;U>w.avail_out&&(U=w.avail_out),U!==0&&(a.arraySet(w.output,Y.pending_buf,Y.pending_out,U,w.next_out),w.next_out+=U,Y.pending_out+=U,w.total_out+=U,w.avail_out-=U,Y.pending-=U,Y.pending===0&&(Y.pending_out=0))}function W(w,Y){l._tr_flush_block(w,0<=w.block_start?w.block_start:-1,w.strstart-w.block_start,Y),w.block_start=w.strstart,H(w.strm)}function ce(w,Y){w.pending_buf[w.pending++]=Y}function se(w,Y){w.pending_buf[w.pending++]=Y>>>8&255,w.pending_buf[w.pending++]=255&Y}function oe(w,Y){var U,I,A=w.max_chain_length,L=w.strstart,ne=w.prev_length,re=w.nice_match,V=w.strstart>w.w_size-q?w.strstart-(w.w_size-q):0,le=w.window,P=w.w_mask,M=w.prev,Q=w.strstart+O,fe=le[L+ne-1],de=le[L+ne];w.prev_length>=w.good_match&&(A>>=2),re>w.lookahead&&(re=w.lookahead);do if(le[(U=Y)+ne]===de&&le[U+ne-1]===fe&&le[U]===le[L]&&le[++U]===le[L+1]){L+=2,U++;do;while(le[++L]===le[++U]&&le[++L]===le[++U]&&le[++L]===le[++U]&&le[++L]===le[++U]&&le[++L]===le[++U]&&le[++L]===le[++U]&&le[++L]===le[++U]&&le[++L]===le[++U]&&L<Q);if(I=O-(Q-L),L=Q-O,ne<I){if(w.match_start=Y,re<=(ne=I))break;fe=le[L+ne-1],de=le[L+ne]}}while((Y=M[Y&P])>V&&--A!=0);return ne<=w.lookahead?ne:w.lookahead}function _e(w){var Y,U,I,A,L,ne,re,V,le,P,M=w.w_size;do{if(A=w.window_size-w.lookahead-w.strstart,w.strstart>=M+(M-q)){for(a.arraySet(w.window,w.window,M,M,0),w.match_start-=M,w.strstart-=M,w.block_start-=M,Y=U=w.hash_size;I=w.head[--Y],w.head[Y]=M<=I?I-M:0,--U;);for(Y=U=M;I=w.prev[--Y],w.prev[Y]=M<=I?I-M:0,--U;);A+=M}if(w.strm.avail_in===0)break;if(ne=w.strm,re=w.window,V=w.strstart+w.lookahead,le=A,P=void 0,P=ne.avail_in,le<P&&(P=le),U=P===0?0:(ne.avail_in-=P,a.arraySet(re,ne.input,ne.next_in,P,V),ne.state.wrap===1?ne.adler=c(ne.adler,re,P,V):ne.state.wrap===2&&(ne.adler=u(ne.adler,re,P,V)),ne.next_in+=P,ne.total_in+=P,P),w.lookahead+=U,w.lookahead+w.insert>=z)for(L=w.strstart-w.insert,w.ins_h=w.window[L],w.ins_h=(w.ins_h<<w.hash_shift^w.window[L+1])&w.hash_mask;w.insert&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[L+z-1])&w.hash_mask,w.prev[L&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=L,L++,w.insert--,!(w.lookahead+w.insert<z)););}while(w.lookahead<q&&w.strm.avail_in!==0)}function ie(w,Y){for(var U,I;;){if(w.lookahead<q){if(_e(w),w.lookahead<q&&Y===f)return k;if(w.lookahead===0)break}if(U=0,w.lookahead>=z&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+z-1])&w.hash_mask,U=w.prev[w.strstart&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=w.strstart),U!==0&&w.strstart-U<=w.w_size-q&&(w.match_length=oe(w,U)),w.match_length>=z)if(I=l._tr_tally(w,w.strstart-w.match_start,w.match_length-z),w.lookahead-=w.match_length,w.match_length<=w.max_lazy_match&&w.lookahead>=z){for(w.match_length--;w.strstart++,w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+z-1])&w.hash_mask,U=w.prev[w.strstart&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=w.strstart,--w.match_length!=0;);w.strstart++}else w.strstart+=w.match_length,w.match_length=0,w.ins_h=w.window[w.strstart],w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+1])&w.hash_mask;else I=l._tr_tally(w,0,w.window[w.strstart]),w.lookahead--,w.strstart++;if(I&&(W(w,!1),w.strm.avail_out===0))return k}return w.insert=w.strstart<z-1?w.strstart:z-1,Y===m?(W(w,!0),w.strm.avail_out===0?X:B):w.last_lit&&(W(w,!1),w.strm.avail_out===0)?k:$}function ge(w,Y){for(var U,I,A;;){if(w.lookahead<q){if(_e(w),w.lookahead<q&&Y===f)return k;if(w.lookahead===0)break}if(U=0,w.lookahead>=z&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+z-1])&w.hash_mask,U=w.prev[w.strstart&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=w.strstart),w.prev_length=w.match_length,w.prev_match=w.match_start,w.match_length=z-1,U!==0&&w.prev_length<w.max_lazy_match&&w.strstart-U<=w.w_size-q&&(w.match_length=oe(w,U),w.match_length<=5&&(w.strategy===1||w.match_length===z&&4096<w.strstart-w.match_start)&&(w.match_length=z-1)),w.prev_length>=z&&w.match_length<=w.prev_length){for(A=w.strstart+w.lookahead-z,I=l._tr_tally(w,w.strstart-1-w.prev_match,w.prev_length-z),w.lookahead-=w.prev_length-1,w.prev_length-=2;++w.strstart<=A&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+z-1])&w.hash_mask,U=w.prev[w.strstart&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=w.strstart),--w.prev_length!=0;);if(w.match_available=0,w.match_length=z-1,w.strstart++,I&&(W(w,!1),w.strm.avail_out===0))return k}else if(w.match_available){if((I=l._tr_tally(w,0,w.window[w.strstart-1]))&&W(w,!1),w.strstart++,w.lookahead--,w.strm.avail_out===0)return k}else w.match_available=1,w.strstart++,w.lookahead--}return w.match_available&&(I=l._tr_tally(w,0,w.window[w.strstart-1]),w.match_available=0),w.insert=w.strstart<z-1?w.strstart:z-1,Y===m?(W(w,!0),w.strm.avail_out===0?X:B):w.last_lit&&(W(w,!1),w.strm.avail_out===0)?k:$}function he(w,Y,U,I,A){this.good_length=w,this.max_lazy=Y,this.nice_length=U,this.max_chain=I,this.func=A}function xe(){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*C),this.dyn_dtree=new a.Buf16(2*(2*S+1)),this.bl_tree=new a.Buf16(2*(2*E+1)),J(this.dyn_ltree),J(this.dyn_dtree),J(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),J(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*j+1),J(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 te(w){var Y;return w&&w.state?(w.total_in=w.total_out=0,w.data_type=b,(Y=w.state).pending=0,Y.pending_out=0,Y.wrap<0&&(Y.wrap=-Y.wrap),Y.status=Y.wrap?T:D,w.adler=Y.wrap===2?0:1,Y.last_flush=f,l._tr_init(Y),h):F(w,v)}function ue(w){var Y=te(w);return Y===h&&(function(U){U.window_size=2*U.w_size,J(U.head),U.max_lazy_match=i[U.level].max_lazy,U.good_match=i[U.level].good_length,U.nice_match=i[U.level].nice_length,U.max_chain_length=i[U.level].max_chain,U.strstart=0,U.block_start=0,U.lookahead=0,U.insert=0,U.match_length=U.prev_length=z-1,U.match_available=0,U.ins_h=0})(w.state),Y}function be(w,Y,U,I,A,L){if(!w)return v;var ne=1;if(Y===g&&(Y=6),I<0?(ne=0,I=-I):15<I&&(ne=2,I-=16),A<1||_<A||U!==y||I<8||15<I||Y<0||9<Y||L<0||x<L)return F(w,v);I===8&&(I=9);var re=new xe;return(w.state=re).strm=w,re.wrap=ne,re.gzhead=null,re.w_bits=I,re.w_size=1<<re.w_bits,re.w_mask=re.w_size-1,re.hash_bits=A+7,re.hash_size=1<<re.hash_bits,re.hash_mask=re.hash_size-1,re.hash_shift=~~((re.hash_bits+z-1)/z),re.window=new a.Buf8(2*re.w_size),re.head=new a.Buf16(re.hash_size),re.prev=new a.Buf16(re.w_size),re.lit_bufsize=1<<A+6,re.pending_buf_size=4*re.lit_bufsize,re.pending_buf=new a.Buf8(re.pending_buf_size),re.d_buf=1*re.lit_bufsize,re.l_buf=3*re.lit_bufsize,re.level=Y,re.strategy=L,re.method=U,ue(w)}i=[new he(0,0,0,0,function(w,Y){var U=65535;for(U>w.pending_buf_size-5&&(U=w.pending_buf_size-5);;){if(w.lookahead<=1){if(_e(w),w.lookahead===0&&Y===f)return k;if(w.lookahead===0)break}w.strstart+=w.lookahead,w.lookahead=0;var I=w.block_start+U;if((w.strstart===0||w.strstart>=I)&&(w.lookahead=w.strstart-I,w.strstart=I,W(w,!1),w.strm.avail_out===0)||w.strstart-w.block_start>=w.w_size-q&&(W(w,!1),w.strm.avail_out===0))return k}return w.insert=0,Y===m?(W(w,!0),w.strm.avail_out===0?X:B):(w.strstart>w.block_start&&(W(w,!1),w.strm.avail_out),k)}),new he(4,4,8,4,ie),new he(4,5,16,8,ie),new he(4,6,32,32,ie),new he(4,4,16,16,ge),new he(8,16,32,32,ge),new he(8,16,128,128,ge),new he(8,32,128,256,ge),new he(32,128,258,1024,ge),new he(32,258,258,4096,ge)],o.deflateInit=function(w,Y){return be(w,Y,y,15,8,0)},o.deflateInit2=be,o.deflateReset=ue,o.deflateResetKeep=te,o.deflateSetHeader=function(w,Y){return w&&w.state?w.state.wrap!==2?v:(w.state.gzhead=Y,h):v},o.deflate=function(w,Y){var U,I,A,L;if(!w||!w.state||5<Y||Y<0)return w?F(w,v):v;if(I=w.state,!w.output||!w.input&&w.avail_in!==0||I.status===666&&Y!==m)return F(w,w.avail_out===0?-5:v);if(I.strm=w,U=I.last_flush,I.last_flush=Y,I.status===T)if(I.wrap===2)w.adler=0,ce(I,31),ce(I,139),ce(I,8),I.gzhead?(ce(I,(I.gzhead.text?1:0)+(I.gzhead.hcrc?2:0)+(I.gzhead.extra?4:0)+(I.gzhead.name?8:0)+(I.gzhead.comment?16:0)),ce(I,255&I.gzhead.time),ce(I,I.gzhead.time>>8&255),ce(I,I.gzhead.time>>16&255),ce(I,I.gzhead.time>>24&255),ce(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),ce(I,255&I.gzhead.os),I.gzhead.extra&&I.gzhead.extra.length&&(ce(I,255&I.gzhead.extra.length),ce(I,I.gzhead.extra.length>>8&255)),I.gzhead.hcrc&&(w.adler=u(w.adler,I.pending_buf,I.pending,0)),I.gzindex=0,I.status=69):(ce(I,0),ce(I,0),ce(I,0),ce(I,0),ce(I,0),ce(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),ce(I,3),I.status=D);else{var ne=y+(I.w_bits-8<<4)<<8;ne|=(2<=I.strategy||I.level<2?0:I.level<6?1:I.level===6?2:3)<<6,I.strstart!==0&&(ne|=32),ne+=31-ne%31,I.status=D,se(I,ne),I.strstart!==0&&(se(I,w.adler>>>16),se(I,65535&w.adler)),w.adler=1}if(I.status===69)if(I.gzhead.extra){for(A=I.pending;I.gzindex<(65535&I.gzhead.extra.length)&&(I.pending!==I.pending_buf_size||(I.gzhead.hcrc&&I.pending>A&&(w.adler=u(w.adler,I.pending_buf,I.pending-A,A)),H(w),A=I.pending,I.pending!==I.pending_buf_size));)ce(I,255&I.gzhead.extra[I.gzindex]),I.gzindex++;I.gzhead.hcrc&&I.pending>A&&(w.adler=u(w.adler,I.pending_buf,I.pending-A,A)),I.gzindex===I.gzhead.extra.length&&(I.gzindex=0,I.status=73)}else I.status=73;if(I.status===73)if(I.gzhead.name){A=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>A&&(w.adler=u(w.adler,I.pending_buf,I.pending-A,A)),H(w),A=I.pending,I.pending===I.pending_buf_size)){L=1;break}L=I.gzindex<I.gzhead.name.length?255&I.gzhead.name.charCodeAt(I.gzindex++):0,ce(I,L)}while(L!==0);I.gzhead.hcrc&&I.pending>A&&(w.adler=u(w.adler,I.pending_buf,I.pending-A,A)),L===0&&(I.gzindex=0,I.status=91)}else I.status=91;if(I.status===91)if(I.gzhead.comment){A=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>A&&(w.adler=u(w.adler,I.pending_buf,I.pending-A,A)),H(w),A=I.pending,I.pending===I.pending_buf_size)){L=1;break}L=I.gzindex<I.gzhead.comment.length?255&I.gzhead.comment.charCodeAt(I.gzindex++):0,ce(I,L)}while(L!==0);I.gzhead.hcrc&&I.pending>A&&(w.adler=u(w.adler,I.pending_buf,I.pending-A,A)),L===0&&(I.status=103)}else I.status=103;if(I.status===103&&(I.gzhead.hcrc?(I.pending+2>I.pending_buf_size&&H(w),I.pending+2<=I.pending_buf_size&&(ce(I,255&w.adler),ce(I,w.adler>>8&255),w.adler=0,I.status=D)):I.status=D),I.pending!==0){if(H(w),w.avail_out===0)return I.last_flush=-1,h}else if(w.avail_in===0&&Z(Y)<=Z(U)&&Y!==m)return F(w,-5);if(I.status===666&&w.avail_in!==0)return F(w,-5);if(w.avail_in!==0||I.lookahead!==0||Y!==f&&I.status!==666){var re=I.strategy===2?(function(V,le){for(var P;;){if(V.lookahead===0&&(_e(V),V.lookahead===0)){if(le===f)return k;break}if(V.match_length=0,P=l._tr_tally(V,0,V.window[V.strstart]),V.lookahead--,V.strstart++,P&&(W(V,!1),V.strm.avail_out===0))return k}return V.insert=0,le===m?(W(V,!0),V.strm.avail_out===0?X:B):V.last_lit&&(W(V,!1),V.strm.avail_out===0)?k:$})(I,Y):I.strategy===3?(function(V,le){for(var P,M,Q,fe,de=V.window;;){if(V.lookahead<=O){if(_e(V),V.lookahead<=O&&le===f)return k;if(V.lookahead===0)break}if(V.match_length=0,V.lookahead>=z&&0<V.strstart&&(M=de[Q=V.strstart-1])===de[++Q]&&M===de[++Q]&&M===de[++Q]){fe=V.strstart+O;do;while(M===de[++Q]&&M===de[++Q]&&M===de[++Q]&&M===de[++Q]&&M===de[++Q]&&M===de[++Q]&&M===de[++Q]&&M===de[++Q]&&Q<fe);V.match_length=O-(fe-Q),V.match_length>V.lookahead&&(V.match_length=V.lookahead)}if(V.match_length>=z?(P=l._tr_tally(V,1,V.match_length-z),V.lookahead-=V.match_length,V.strstart+=V.match_length,V.match_length=0):(P=l._tr_tally(V,0,V.window[V.strstart]),V.lookahead--,V.strstart++),P&&(W(V,!1),V.strm.avail_out===0))return k}return V.insert=0,le===m?(W(V,!0),V.strm.avail_out===0?X:B):V.last_lit&&(W(V,!1),V.strm.avail_out===0)?k:$})(I,Y):i[I.level].func(I,Y);if(re!==X&&re!==B||(I.status=666),re===k||re===X)return w.avail_out===0&&(I.last_flush=-1),h;if(re===$&&(Y===1?l._tr_align(I):Y!==5&&(l._tr_stored_block(I,0,0,!1),Y===3&&(J(I.head),I.lookahead===0&&(I.strstart=0,I.block_start=0,I.insert=0))),H(w),w.avail_out===0))return I.last_flush=-1,h}return Y!==m?h:I.wrap<=0?1:(I.wrap===2?(ce(I,255&w.adler),ce(I,w.adler>>8&255),ce(I,w.adler>>16&255),ce(I,w.adler>>24&255),ce(I,255&w.total_in),ce(I,w.total_in>>8&255),ce(I,w.total_in>>16&255),ce(I,w.total_in>>24&255)):(se(I,w.adler>>>16),se(I,65535&w.adler)),H(w),0<I.wrap&&(I.wrap=-I.wrap),I.pending!==0?h:1)},o.deflateEnd=function(w){var Y;return w&&w.state?(Y=w.state.status)!==T&&Y!==69&&Y!==73&&Y!==91&&Y!==103&&Y!==D&&Y!==666?F(w,v):(w.state=null,Y===D?F(w,-3):h):v},o.deflateSetDictionary=function(w,Y){var U,I,A,L,ne,re,V,le,P=Y.length;if(!w||!w.state||(L=(U=w.state).wrap)===2||L===1&&U.status!==T||U.lookahead)return v;for(L===1&&(w.adler=c(w.adler,Y,P,0)),U.wrap=0,P>=U.w_size&&(L===0&&(J(U.head),U.strstart=0,U.block_start=0,U.insert=0),le=new a.Buf8(U.w_size),a.arraySet(le,Y,P-U.w_size,U.w_size,0),Y=le,P=U.w_size),ne=w.avail_in,re=w.next_in,V=w.input,w.avail_in=P,w.next_in=0,w.input=Y,_e(U);U.lookahead>=z;){for(I=U.strstart,A=U.lookahead-(z-1);U.ins_h=(U.ins_h<<U.hash_shift^U.window[I+z-1])&U.hash_mask,U.prev[I&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=I,I++,--A;);U.strstart=I,U.lookahead=z-1,_e(U)}return U.strstart+=U.lookahead,U.block_start=U.strstart,U.insert=U.lookahead,U.lookahead=0,U.match_length=U.prev_length=z-1,U.match_available=0,w.next_in=re,w.input=V,w.avail_in=ne,U.wrap=L,h},o.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,o){r.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,r,o){r.exports=function(i,a){var l,c,u,d,f,m,h,v,g,x,b,y,_,j,S,E,C,R,z,O,q,T,D,k,$;l=i.state,c=i.next_in,k=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,v=l.wsize,g=l.whave,x=l.wnext,b=l.window,y=l.hold,_=l.bits,j=l.lencode,S=l.distcode,E=(1<<l.lenbits)-1,C=(1<<l.distbits)-1;e:do{_<15&&(y+=k[c++]<<_,_+=8,y+=k[c++]<<_,_+=8),R=j[y&E];t:for(;;){if(y>>>=z=R>>>24,_-=z,(z=R>>>16&255)===0)$[d++]=65535&R;else{if(!(16&z)){if((64&z)==0){R=j[(65535&R)+(y&(1<<z)-1)];continue t}if(32&z){l.mode=12;break e}i.msg="invalid literal/length code",l.mode=30;break e}O=65535&R,(z&=15)&&(_<z&&(y+=k[c++]<<_,_+=8),O+=y&(1<<z)-1,y>>>=z,_-=z),_<15&&(y+=k[c++]<<_,_+=8,y+=k[c++]<<_,_+=8),R=S[y&C];n:for(;;){if(y>>>=z=R>>>24,_-=z,!(16&(z=R>>>16&255))){if((64&z)==0){R=S[(65535&R)+(y&(1<<z)-1)];continue n}i.msg="invalid distance code",l.mode=30;break e}if(q=65535&R,_<(z&=15)&&(y+=k[c++]<<_,(_+=8)<z&&(y+=k[c++]<<_,_+=8)),h<(q+=y&(1<<z)-1)){i.msg="invalid distance too far back",l.mode=30;break e}if(y>>>=z,_-=z,(z=d-f)<q){if(g<(z=q-z)&&l.sane){i.msg="invalid distance too far back",l.mode=30;break e}if(D=b,(T=0)===x){if(T+=v-z,z<O){for(O-=z;$[d++]=b[T++],--z;);T=d-q,D=$}}else if(x<z){if(T+=v+x-z,(z-=x)<O){for(O-=z;$[d++]=b[T++],--z;);if(T=0,x<O){for(O-=z=x;$[d++]=b[T++],--z;);T=d-q,D=$}}}else if(T+=x-z,z<O){for(O-=z;$[d++]=b[T++],--z;);T=d-q,D=$}for(;2<O;)$[d++]=D[T++],$[d++]=D[T++],$[d++]=D[T++],O-=3;O&&($[d++]=D[T++],1<O&&($[d++]=D[T++]))}else{for(T=d-q;$[d++]=$[T++],$[d++]=$[T++],$[d++]=$[T++],2<(O-=3););O&&($[d++]=$[T++],1<O&&($[d++]=$[T++]))}break}}break}}while(c<u&&d<m);c-=O=_>>3,y&=(1<<(_-=O<<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,r,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,v=1,g=852,x=592;function b(T){return(T>>>24&255)+(T>>>8&65280)+((65280&T)<<8)+((255&T)<<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 _(T){var D;return T&&T.state?(D=T.state,T.total_in=T.total_out=D.total=0,T.msg="",D.wrap&&(T.adler=1&D.wrap),D.mode=v,D.last=0,D.havedict=0,D.dmax=32768,D.head=null,D.hold=0,D.bits=0,D.lencode=D.lendyn=new i.Buf32(g),D.distcode=D.distdyn=new i.Buf32(x),D.sane=1,D.back=-1,m):h}function j(T){var D;return T&&T.state?((D=T.state).wsize=0,D.whave=0,D.wnext=0,_(T)):h}function S(T,D){var k,$;return T&&T.state?($=T.state,D<0?(k=0,D=-D):(k=1+(D>>4),D<48&&(D&=15)),D&&(D<8||15<D)?h:($.window!==null&&$.wbits!==D&&($.window=null),$.wrap=k,$.wbits=D,j(T))):h}function E(T,D){var k,$;return T?($=new y,(T.state=$).window=null,(k=S(T,D))!==m&&(T.state=null),k):h}var C,R,z=!0;function O(T){if(z){var D;for(C=new i.Buf32(512),R=new i.Buf32(32),D=0;D<144;)T.lens[D++]=8;for(;D<256;)T.lens[D++]=9;for(;D<280;)T.lens[D++]=7;for(;D<288;)T.lens[D++]=8;for(u(d,T.lens,0,288,C,0,T.work,{bits:9}),D=0;D<32;)T.lens[D++]=5;u(f,T.lens,0,32,R,0,T.work,{bits:5}),z=!1}T.lencode=C,T.lenbits=9,T.distcode=R,T.distbits=5}function q(T,D,k,$){var X,B=T.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,D,k-B.wsize,B.wsize,0),B.wnext=0,B.whave=B.wsize):($<(X=B.wsize-B.wnext)&&(X=$),i.arraySet(B.window,D,k-$,X,B.wnext),($-=X)?(i.arraySet(B.window,D,k-$,$,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(T){return E(T,15)},o.inflateInit2=E,o.inflate=function(T,D){var k,$,X,B,F,Z,J,H,W,ce,se,oe,_e,ie,ge,he,xe,te,ue,be,w,Y,U,I,A=0,L=new i.Buf8(4),ne=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!T||!T.state||!T.output||!T.input&&T.avail_in!==0)return h;(k=T.state).mode===12&&(k.mode=13),F=T.next_out,X=T.output,J=T.avail_out,B=T.next_in,$=T.input,Z=T.avail_in,H=k.hold,W=k.bits,ce=Z,se=J,Y=m;e:for(;;)switch(k.mode){case v:if(k.wrap===0){k.mode=13;break}for(;W<16;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(2&k.wrap&&H===35615){L[k.check=0]=255&H,L[1]=H>>>8&255,k.check=l(k.check,L,2,0),W=H=0,k.mode=2;break}if(k.flags=0,k.head&&(k.head.done=!1),!(1&k.wrap)||(((255&H)<<8)+(H>>8))%31){T.msg="incorrect header check",k.mode=30;break}if((15&H)!=8){T.msg="unknown compression method",k.mode=30;break}if(W-=4,w=8+(15&(H>>>=4)),k.wbits===0)k.wbits=w;else if(w>k.wbits){T.msg="invalid window size",k.mode=30;break}k.dmax=1<<w,T.adler=k.check=1,k.mode=512&H?10:12,W=H=0;break;case 2:for(;W<16;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(k.flags=H,(255&k.flags)!=8){T.msg="unknown compression method",k.mode=30;break}if(57344&k.flags){T.msg="unknown header flags set",k.mode=30;break}k.head&&(k.head.text=H>>8&1),512&k.flags&&(L[0]=255&H,L[1]=H>>>8&255,k.check=l(k.check,L,2,0)),W=H=0,k.mode=3;case 3:for(;W<32;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}k.head&&(k.head.time=H),512&k.flags&&(L[0]=255&H,L[1]=H>>>8&255,L[2]=H>>>16&255,L[3]=H>>>24&255,k.check=l(k.check,L,4,0)),W=H=0,k.mode=4;case 4:for(;W<16;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}k.head&&(k.head.xflags=255&H,k.head.os=H>>8),512&k.flags&&(L[0]=255&H,L[1]=H>>>8&255,k.check=l(k.check,L,2,0)),W=H=0,k.mode=5;case 5:if(1024&k.flags){for(;W<16;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}k.length=H,k.head&&(k.head.extra_len=H),512&k.flags&&(L[0]=255&H,L[1]=H>>>8&255,k.check=l(k.check,L,2,0)),W=H=0}else k.head&&(k.head.extra=null);k.mode=6;case 6:if(1024&k.flags&&(Z<(oe=k.length)&&(oe=Z),oe&&(k.head&&(w=k.head.extra_len-k.length,k.head.extra||(k.head.extra=new Array(k.head.extra_len)),i.arraySet(k.head.extra,$,B,oe,w)),512&k.flags&&(k.check=l(k.check,$,oe,B)),Z-=oe,B+=oe,k.length-=oe),k.length))break e;k.length=0,k.mode=7;case 7:if(2048&k.flags){if(Z===0)break e;for(oe=0;w=$[B+oe++],k.head&&w&&k.length<65536&&(k.head.name+=String.fromCharCode(w)),w&&oe<Z;);if(512&k.flags&&(k.check=l(k.check,$,oe,B)),Z-=oe,B+=oe,w)break e}else k.head&&(k.head.name=null);k.length=0,k.mode=8;case 8:if(4096&k.flags){if(Z===0)break e;for(oe=0;w=$[B+oe++],k.head&&w&&k.length<65536&&(k.head.comment+=String.fromCharCode(w)),w&&oe<Z;);if(512&k.flags&&(k.check=l(k.check,$,oe,B)),Z-=oe,B+=oe,w)break e}else k.head&&(k.head.comment=null);k.mode=9;case 9:if(512&k.flags){for(;W<16;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(H!==(65535&k.check)){T.msg="header crc mismatch",k.mode=30;break}W=H=0}k.head&&(k.head.hcrc=k.flags>>9&1,k.head.done=!0),T.adler=k.check=0,k.mode=12;break;case 10:for(;W<32;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}T.adler=k.check=b(H),W=H=0,k.mode=11;case 11:if(k.havedict===0)return T.next_out=F,T.avail_out=J,T.next_in=B,T.avail_in=Z,k.hold=H,k.bits=W,2;T.adler=k.check=1,k.mode=12;case 12:if(D===5||D===6)break e;case 13:if(k.last){H>>>=7&W,W-=7&W,k.mode=27;break}for(;W<3;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}switch(k.last=1&H,W-=1,3&(H>>>=1)){case 0:k.mode=14;break;case 1:if(O(k),k.mode=20,D!==6)break;H>>>=2,W-=2;break e;case 2:k.mode=17;break;case 3:T.msg="invalid block type",k.mode=30}H>>>=2,W-=2;break;case 14:for(H>>>=7&W,W-=7&W;W<32;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if((65535&H)!=(H>>>16^65535)){T.msg="invalid stored block lengths",k.mode=30;break}if(k.length=65535&H,W=H=0,k.mode=15,D===6)break e;case 15:k.mode=16;case 16:if(oe=k.length){if(Z<oe&&(oe=Z),J<oe&&(oe=J),oe===0)break e;i.arraySet(X,$,B,oe,F),Z-=oe,B+=oe,J-=oe,F+=oe,k.length-=oe;break}k.mode=12;break;case 17:for(;W<14;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(k.nlen=257+(31&H),H>>>=5,W-=5,k.ndist=1+(31&H),H>>>=5,W-=5,k.ncode=4+(15&H),H>>>=4,W-=4,286<k.nlen||30<k.ndist){T.msg="too many length or distance symbols",k.mode=30;break}k.have=0,k.mode=18;case 18:for(;k.have<k.ncode;){for(;W<3;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}k.lens[ne[k.have++]]=7&H,H>>>=3,W-=3}for(;k.have<19;)k.lens[ne[k.have++]]=0;if(k.lencode=k.lendyn,k.lenbits=7,U={bits:k.lenbits},Y=u(0,k.lens,0,19,k.lencode,0,k.work,U),k.lenbits=U.bits,Y){T.msg="invalid code lengths set",k.mode=30;break}k.have=0,k.mode=19;case 19:for(;k.have<k.nlen+k.ndist;){for(;he=(A=k.lencode[H&(1<<k.lenbits)-1])>>>16&255,xe=65535&A,!((ge=A>>>24)<=W);){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(xe<16)H>>>=ge,W-=ge,k.lens[k.have++]=xe;else{if(xe===16){for(I=ge+2;W<I;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(H>>>=ge,W-=ge,k.have===0){T.msg="invalid bit length repeat",k.mode=30;break}w=k.lens[k.have-1],oe=3+(3&H),H>>>=2,W-=2}else if(xe===17){for(I=ge+3;W<I;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}W-=ge,w=0,oe=3+(7&(H>>>=ge)),H>>>=3,W-=3}else{for(I=ge+7;W<I;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}W-=ge,w=0,oe=11+(127&(H>>>=ge)),H>>>=7,W-=7}if(k.have+oe>k.nlen+k.ndist){T.msg="invalid bit length repeat",k.mode=30;break}for(;oe--;)k.lens[k.have++]=w}}if(k.mode===30)break;if(k.lens[256]===0){T.msg="invalid code -- missing end-of-block",k.mode=30;break}if(k.lenbits=9,U={bits:k.lenbits},Y=u(d,k.lens,0,k.nlen,k.lencode,0,k.work,U),k.lenbits=U.bits,Y){T.msg="invalid literal/lengths set",k.mode=30;break}if(k.distbits=6,k.distcode=k.distdyn,U={bits:k.distbits},Y=u(f,k.lens,k.nlen,k.ndist,k.distcode,0,k.work,U),k.distbits=U.bits,Y){T.msg="invalid distances set",k.mode=30;break}if(k.mode=20,D===6)break e;case 20:k.mode=21;case 21:if(6<=Z&&258<=J){T.next_out=F,T.avail_out=J,T.next_in=B,T.avail_in=Z,k.hold=H,k.bits=W,c(T,se),F=T.next_out,X=T.output,J=T.avail_out,B=T.next_in,$=T.input,Z=T.avail_in,H=k.hold,W=k.bits,k.mode===12&&(k.back=-1);break}for(k.back=0;he=(A=k.lencode[H&(1<<k.lenbits)-1])>>>16&255,xe=65535&A,!((ge=A>>>24)<=W);){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(he&&(240&he)==0){for(te=ge,ue=he,be=xe;he=(A=k.lencode[be+((H&(1<<te+ue)-1)>>te)])>>>16&255,xe=65535&A,!(te+(ge=A>>>24)<=W);){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}H>>>=te,W-=te,k.back+=te}if(H>>>=ge,W-=ge,k.back+=ge,k.length=xe,he===0){k.mode=26;break}if(32&he){k.back=-1,k.mode=12;break}if(64&he){T.msg="invalid literal/length code",k.mode=30;break}k.extra=15&he,k.mode=22;case 22:if(k.extra){for(I=k.extra;W<I;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}k.length+=H&(1<<k.extra)-1,H>>>=k.extra,W-=k.extra,k.back+=k.extra}k.was=k.length,k.mode=23;case 23:for(;he=(A=k.distcode[H&(1<<k.distbits)-1])>>>16&255,xe=65535&A,!((ge=A>>>24)<=W);){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if((240&he)==0){for(te=ge,ue=he,be=xe;he=(A=k.distcode[be+((H&(1<<te+ue)-1)>>te)])>>>16&255,xe=65535&A,!(te+(ge=A>>>24)<=W);){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}H>>>=te,W-=te,k.back+=te}if(H>>>=ge,W-=ge,k.back+=ge,64&he){T.msg="invalid distance code",k.mode=30;break}k.offset=xe,k.extra=15&he,k.mode=24;case 24:if(k.extra){for(I=k.extra;W<I;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}k.offset+=H&(1<<k.extra)-1,H>>>=k.extra,W-=k.extra,k.back+=k.extra}if(k.offset>k.dmax){T.msg="invalid distance too far back",k.mode=30;break}k.mode=25;case 25:if(J===0)break e;if(oe=se-J,k.offset>oe){if((oe=k.offset-oe)>k.whave&&k.sane){T.msg="invalid distance too far back",k.mode=30;break}_e=oe>k.wnext?(oe-=k.wnext,k.wsize-oe):k.wnext-oe,oe>k.length&&(oe=k.length),ie=k.window}else ie=X,_e=F-k.offset,oe=k.length;for(J<oe&&(oe=J),J-=oe,k.length-=oe;X[F++]=ie[_e++],--oe;);k.length===0&&(k.mode=21);break;case 26:if(J===0)break e;X[F++]=k.length,J--,k.mode=21;break;case 27:if(k.wrap){for(;W<32;){if(Z===0)break e;Z--,H|=$[B++]<<W,W+=8}if(se-=J,T.total_out+=se,k.total+=se,se&&(T.adler=k.check=k.flags?l(k.check,X,se,F-se):a(k.check,X,se,F-se)),se=J,(k.flags?H:b(H))!==k.check){T.msg="incorrect data check",k.mode=30;break}W=H=0}k.mode=28;case 28:if(k.wrap&&k.flags){for(;W<32;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(H!==(4294967295&k.total)){T.msg="incorrect length check",k.mode=30;break}W=H=0}k.mode=29;case 29:Y=1;break e;case 30:Y=-3;break e;case 31:return-4;default:return h}return T.next_out=F,T.avail_out=J,T.next_in=B,T.avail_in=Z,k.hold=H,k.bits=W,(k.wsize||se!==T.avail_out&&k.mode<30&&(k.mode<27||D!==4))&&q(T,T.output,T.next_out,se-T.avail_out)?(k.mode=31,-4):(ce-=T.avail_in,se-=T.avail_out,T.total_in+=ce,T.total_out+=se,k.total+=se,k.wrap&&se&&(T.adler=k.check=k.flags?l(k.check,X,se,T.next_out-se):a(k.check,X,se,T.next_out-se)),T.data_type=k.bits+(k.last?64:0)+(k.mode===12?128:0)+(k.mode===20||k.mode===15?256:0),(ce==0&&se===0||D===4)&&Y===m&&(Y=-5),Y)},o.inflateEnd=function(T){if(!T||!T.state)return h;var D=T.state;return D.window&&(D.window=null),T.state=null,m},o.inflateGetHeader=function(T,D){var k;return T&&T.state?(2&(k=T.state).wrap)==0?h:((k.head=D).done=!1,m):h},o.inflateSetDictionary=function(T,D){var k,$=D.length;return T&&T.state?(k=T.state).wrap!==0&&k.mode!==11?h:k.mode===11&&a(1,D,$,0)!==k.check?-3:q(T,D,$,$)?(k.mode=31,-4):(k.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,r,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];r.exports=function(d,f,m,h,v,g,x,b){var y,_,j,S,E,C,R,z,O,q=b.bits,T=0,D=0,k=0,$=0,X=0,B=0,F=0,Z=0,J=0,H=0,W=null,ce=0,se=new i.Buf16(16),oe=new i.Buf16(16),_e=null,ie=0;for(T=0;T<=15;T++)se[T]=0;for(D=0;D<h;D++)se[f[m+D]]++;for(X=q,$=15;1<=$&&se[$]===0;$--);if($<X&&(X=$),$===0)return v[g++]=20971520,v[g++]=20971520,b.bits=1,0;for(k=1;k<$&&se[k]===0;k++);for(X<k&&(X=k),T=Z=1;T<=15;T++)if(Z<<=1,(Z-=se[T])<0)return-1;if(0<Z&&(d===0||$!==1))return-1;for(oe[1]=0,T=1;T<15;T++)oe[T+1]=oe[T]+se[T];for(D=0;D<h;D++)f[m+D]!==0&&(x[oe[f[m+D]]++]=D);if(C=d===0?(W=_e=x,19):d===1?(W=a,ce-=257,_e=l,ie-=257,256):(W=c,_e=u,-1),T=k,E=g,F=D=H=0,j=-1,S=(J=1<<(B=X))-1,d===1&&852<J||d===2&&592<J)return 1;for(;;){for(R=T-F,O=x[D]<C?(z=0,x[D]):x[D]>C?(z=_e[ie+x[D]],W[ce+x[D]]):(z=96,0),y=1<<T-F,k=_=1<<B;v[E+(H>>F)+(_-=y)]=R<<24|z<<16|O|0,_!==0;);for(y=1<<T-1;H&y;)y>>=1;if(y!==0?(H&=y-1,H+=y):H=0,D++,--se[T]==0){if(T===$)break;T=f[m+x[D]]}if(X<T&&(H&S)!==j){for(F===0&&(F=X),E+=k,Z=1<<(B=T-F);B+F<$&&!((Z-=se[B+F])<=0);)B++,Z<<=1;if(J+=1<<B,d===1&&852<J||d===2&&592<J)return 1;v[j=H&S]=X<<24|B<<16|E-g|0}}return H!==0&&(v[E+H]=T-F<<24|64<<16|0),b.bits=X,0}},{"../utils/common":41}],51:[function(n,r,o){r.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,r,o){var i=n("../utils/common"),a=0,l=1;function c(A){for(var L=A.length;0<=--L;)A[L]=0}var u=0,d=29,f=256,m=f+1+d,h=30,v=19,g=2*m+1,x=15,b=16,y=7,_=256,j=16,S=17,E=18,C=[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],z=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],O=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],q=new Array(2*(m+2));c(q);var T=new Array(2*h);c(T);var D=new Array(512);c(D);var k=new Array(256);c(k);var $=new Array(d);c($);var X,B,F,Z=new Array(h);function J(A,L,ne,re,V){this.static_tree=A,this.extra_bits=L,this.extra_base=ne,this.elems=re,this.max_length=V,this.has_stree=A&&A.length}function H(A,L){this.dyn_tree=A,this.max_code=0,this.stat_desc=L}function W(A){return A<256?D[A]:D[256+(A>>>7)]}function ce(A,L){A.pending_buf[A.pending++]=255&L,A.pending_buf[A.pending++]=L>>>8&255}function se(A,L,ne){A.bi_valid>b-ne?(A.bi_buf|=L<<A.bi_valid&65535,ce(A,A.bi_buf),A.bi_buf=L>>b-A.bi_valid,A.bi_valid+=ne-b):(A.bi_buf|=L<<A.bi_valid&65535,A.bi_valid+=ne)}function oe(A,L,ne){se(A,ne[2*L],ne[2*L+1])}function _e(A,L){for(var ne=0;ne|=1&A,A>>>=1,ne<<=1,0<--L;);return ne>>>1}function ie(A,L,ne){var re,V,le=new Array(x+1),P=0;for(re=1;re<=x;re++)le[re]=P=P+ne[re-1]<<1;for(V=0;V<=L;V++){var M=A[2*V+1];M!==0&&(A[2*V]=_e(le[M]++,M))}}function ge(A){var L;for(L=0;L<m;L++)A.dyn_ltree[2*L]=0;for(L=0;L<h;L++)A.dyn_dtree[2*L]=0;for(L=0;L<v;L++)A.bl_tree[2*L]=0;A.dyn_ltree[2*_]=1,A.opt_len=A.static_len=0,A.last_lit=A.matches=0}function he(A){8<A.bi_valid?ce(A,A.bi_buf):0<A.bi_valid&&(A.pending_buf[A.pending++]=A.bi_buf),A.bi_buf=0,A.bi_valid=0}function xe(A,L,ne,re){var V=2*L,le=2*ne;return A[V]<A[le]||A[V]===A[le]&&re[L]<=re[ne]}function te(A,L,ne){for(var re=A.heap[ne],V=ne<<1;V<=A.heap_len&&(V<A.heap_len&&xe(L,A.heap[V+1],A.heap[V],A.depth)&&V++,!xe(L,re,A.heap[V],A.depth));)A.heap[ne]=A.heap[V],ne=V,V<<=1;A.heap[ne]=re}function ue(A,L,ne){var re,V,le,P,M=0;if(A.last_lit!==0)for(;re=A.pending_buf[A.d_buf+2*M]<<8|A.pending_buf[A.d_buf+2*M+1],V=A.pending_buf[A.l_buf+M],M++,re===0?oe(A,V,L):(oe(A,(le=k[V])+f+1,L),(P=C[le])!==0&&se(A,V-=$[le],P),oe(A,le=W(--re),ne),(P=R[le])!==0&&se(A,re-=Z[le],P)),M<A.last_lit;);oe(A,_,L)}function be(A,L){var ne,re,V,le=L.dyn_tree,P=L.stat_desc.static_tree,M=L.stat_desc.has_stree,Q=L.stat_desc.elems,fe=-1;for(A.heap_len=0,A.heap_max=g,ne=0;ne<Q;ne++)le[2*ne]!==0?(A.heap[++A.heap_len]=fe=ne,A.depth[ne]=0):le[2*ne+1]=0;for(;A.heap_len<2;)le[2*(V=A.heap[++A.heap_len]=fe<2?++fe:0)]=1,A.depth[V]=0,A.opt_len--,M&&(A.static_len-=P[2*V+1]);for(L.max_code=fe,ne=A.heap_len>>1;1<=ne;ne--)te(A,le,ne);for(V=Q;ne=A.heap[1],A.heap[1]=A.heap[A.heap_len--],te(A,le,1),re=A.heap[1],A.heap[--A.heap_max]=ne,A.heap[--A.heap_max]=re,le[2*V]=le[2*ne]+le[2*re],A.depth[V]=(A.depth[ne]>=A.depth[re]?A.depth[ne]:A.depth[re])+1,le[2*ne+1]=le[2*re+1]=V,A.heap[1]=V++,te(A,le,1),2<=A.heap_len;);A.heap[--A.heap_max]=A.heap[1],(function(de,Pe){var Ue,Ne,pt,ze,$t,hr,Re=Pe.dyn_tree,Et=Pe.max_code,Ft=Pe.stat_desc.static_tree,qo=Pe.stat_desc.has_stree,at=Pe.stat_desc.extra_bits,zn=Pe.stat_desc.extra_base,mr=Pe.stat_desc.max_length,Xr=0;for(ze=0;ze<=x;ze++)de.bl_count[ze]=0;for(Re[2*de.heap[de.heap_max]+1]=0,Ue=de.heap_max+1;Ue<g;Ue++)mr<(ze=Re[2*Re[2*(Ne=de.heap[Ue])+1]+1]+1)&&(ze=mr,Xr++),Re[2*Ne+1]=ze,Et<Ne||(de.bl_count[ze]++,$t=0,zn<=Ne&&($t=at[Ne-zn]),hr=Re[2*Ne],de.opt_len+=hr*(ze+$t),qo&&(de.static_len+=hr*(Ft[2*Ne+1]+$t)));if(Xr!==0){do{for(ze=mr-1;de.bl_count[ze]===0;)ze--;de.bl_count[ze]--,de.bl_count[ze+1]+=2,de.bl_count[mr]--,Xr-=2}while(0<Xr);for(ze=mr;ze!==0;ze--)for(Ne=de.bl_count[ze];Ne!==0;)Et<(pt=de.heap[--Ue])||(Re[2*pt+1]!==ze&&(de.opt_len+=(ze-Re[2*pt+1])*Re[2*pt],Re[2*pt+1]=ze),Ne--)}})(A,L),ie(le,fe,A.bl_count)}function w(A,L,ne){var re,V,le=-1,P=L[1],M=0,Q=7,fe=4;for(P===0&&(Q=138,fe=3),L[2*(ne+1)+1]=65535,re=0;re<=ne;re++)V=P,P=L[2*(re+1)+1],++M<Q&&V===P||(M<fe?A.bl_tree[2*V]+=M:V!==0?(V!==le&&A.bl_tree[2*V]++,A.bl_tree[2*j]++):M<=10?A.bl_tree[2*S]++:A.bl_tree[2*E]++,le=V,fe=(M=0)===P?(Q=138,3):V===P?(Q=6,3):(Q=7,4))}function Y(A,L,ne){var re,V,le=-1,P=L[1],M=0,Q=7,fe=4;for(P===0&&(Q=138,fe=3),re=0;re<=ne;re++)if(V=P,P=L[2*(re+1)+1],!(++M<Q&&V===P)){if(M<fe)for(;oe(A,V,A.bl_tree),--M!=0;);else V!==0?(V!==le&&(oe(A,V,A.bl_tree),M--),oe(A,j,A.bl_tree),se(A,M-3,2)):M<=10?(oe(A,S,A.bl_tree),se(A,M-3,3)):(oe(A,E,A.bl_tree),se(A,M-11,7));le=V,fe=(M=0)===P?(Q=138,3):V===P?(Q=6,3):(Q=7,4)}}c(Z);var U=!1;function I(A,L,ne,re){se(A,(u<<1)+(re?1:0),3),(function(V,le,P,M){he(V),ce(V,P),ce(V,~P),i.arraySet(V.pending_buf,V.window,le,P,V.pending),V.pending+=P})(A,L,ne)}o._tr_init=function(A){U||((function(){var L,ne,re,V,le,P=new Array(x+1);for(V=re=0;V<d-1;V++)for($[V]=re,L=0;L<1<<C[V];L++)k[re++]=V;for(k[re-1]=V,V=le=0;V<16;V++)for(Z[V]=le,L=0;L<1<<R[V];L++)D[le++]=V;for(le>>=7;V<h;V++)for(Z[V]=le<<7,L=0;L<1<<R[V]-7;L++)D[256+le++]=V;for(ne=0;ne<=x;ne++)P[ne]=0;for(L=0;L<=143;)q[2*L+1]=8,L++,P[8]++;for(;L<=255;)q[2*L+1]=9,L++,P[9]++;for(;L<=279;)q[2*L+1]=7,L++,P[7]++;for(;L<=287;)q[2*L+1]=8,L++,P[8]++;for(ie(q,m+1,P),L=0;L<h;L++)T[2*L+1]=5,T[2*L]=_e(L,5);X=new J(q,C,f+1,m,x),B=new J(T,R,0,h,x),F=new J(new Array(0),z,0,v,y)})(),U=!0),A.l_desc=new H(A.dyn_ltree,X),A.d_desc=new H(A.dyn_dtree,B),A.bl_desc=new H(A.bl_tree,F),A.bi_buf=0,A.bi_valid=0,ge(A)},o._tr_stored_block=I,o._tr_flush_block=function(A,L,ne,re){var V,le,P=0;0<A.level?(A.strm.data_type===2&&(A.strm.data_type=(function(M){var Q,fe=4093624447;for(Q=0;Q<=31;Q++,fe>>>=1)if(1&fe&&M.dyn_ltree[2*Q]!==0)return a;if(M.dyn_ltree[18]!==0||M.dyn_ltree[20]!==0||M.dyn_ltree[26]!==0)return l;for(Q=32;Q<f;Q++)if(M.dyn_ltree[2*Q]!==0)return l;return a})(A)),be(A,A.l_desc),be(A,A.d_desc),P=(function(M){var Q;for(w(M,M.dyn_ltree,M.l_desc.max_code),w(M,M.dyn_dtree,M.d_desc.max_code),be(M,M.bl_desc),Q=v-1;3<=Q&&M.bl_tree[2*O[Q]+1]===0;Q--);return M.opt_len+=3*(Q+1)+5+5+4,Q})(A),V=A.opt_len+3+7>>>3,(le=A.static_len+3+7>>>3)<=V&&(V=le)):V=le=ne+5,ne+4<=V&&L!==-1?I(A,L,ne,re):A.strategy===4||le===V?(se(A,2+(re?1:0),3),ue(A,q,T)):(se(A,4+(re?1:0),3),(function(M,Q,fe,de){var Pe;for(se(M,Q-257,5),se(M,fe-1,5),se(M,de-4,4),Pe=0;Pe<de;Pe++)se(M,M.bl_tree[2*O[Pe]+1],3);Y(M,M.dyn_ltree,Q-1),Y(M,M.dyn_dtree,fe-1)})(A,A.l_desc.max_code+1,A.d_desc.max_code+1,P+1),ue(A,A.dyn_ltree,A.dyn_dtree)),ge(A),re&&he(A)},o._tr_tally=function(A,L,ne){return A.pending_buf[A.d_buf+2*A.last_lit]=L>>>8&255,A.pending_buf[A.d_buf+2*A.last_lit+1]=255&L,A.pending_buf[A.l_buf+A.last_lit]=255&ne,A.last_lit++,L===0?A.dyn_ltree[2*ne]++:(A.matches++,L--,A.dyn_ltree[2*(k[ne]+f+1)]++,A.dyn_dtree[2*W(L)]++),A.last_lit===A.lit_bufsize-1},o._tr_align=function(A){se(A,2,3),oe(A,_,q),(function(L){L.bi_valid===16?(ce(L,L.bi_buf),L.bi_buf=0,L.bi_valid=0):8<=L.bi_valid&&(L.pending_buf[L.pending++]=255&L.bi_buf,L.bi_buf>>=8,L.bi_valid-=8)})(A)}},{"../utils/common":41}],53:[function(n,r,o){r.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,r,o){(function(i){(function(a,l){if(!a.setImmediate){var c,u,d,f,m=1,h={},v=!1,g=a.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(a);x=x&&x.setTimeout?x: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)},x.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 C={callback:j,args:S};return h[m]=C,c(m),m++},x.clearImmediate=b}function b(j){delete h[j]}function y(j){if(v)setTimeout(y,0,j);else{var S=h[j];if(S){v=!0;try{(function(E){var C=E.callback,R=E.args;switch(R.length){case 0:C();break;case 1:C(R[0]);break;case 2:C(R[0],R[1]);break;case 3:C(R[0],R[1],R[2]);break;default:C.apply(l,R)}})(S)}finally{b(j),v=!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 Qr<"u"?Qr:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Jo)),Jo.exports}var hw=pw();const mw=Xm(hw),gw="2.1.17",Fi={version:gw},af="[REDACTED]",xw=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,bw=[/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],cc=200,vw=25e6,lf=50;function yw(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function ww(e){let t=0;for(const n of e)t+=n.rawRequestBody?.length??0,t+=n.responseText?.length??0;return t}function kw(e){if(e.length>cc)return`Export is limited to ${cc} logs at once. Narrow the filter and try again.`;const t=ww(e);return t>vw?`Export is too large (${yw(t)} of text). Narrow the filter and try again.`:null}async function _w(e){try{const t=await fetch(`/api/logs/${e}/chunks`);if(!t.ok)return null;const n=await t.json();return JSON.stringify(n,null,2)}catch{return null}}function jw(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Bi(e){if(Array.isArray(e))return e.map(n=>Bi(n));if(!jw(e))return e;const t={};for(const[n,r]of Object.entries(e))t[n]=xw.test(n)?af:Bi(r);return t}function Sw(e){const t=n=>{let r=n;for(const o of bw)r=r.replace(o,af);return r};try{const n=JSON.parse(e);return t(JSON.stringify(Bi(n),null,2))}catch{return t(e)}}function Yo(e,t){return t==="redacted"?Sw(e):e}function Cw(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 Nw(e,t,n,r=new Date().toISOString()){return{version:Fi.version,exportedAt:r,mode:t,redacted:t==="redacted",logCount:e.length,logIds:e.map(o=>o.id),streamingChunkExportLimit:lf,streamingChunkLogIds:n.map(o=>o.id)}}async function Tw(e,t="redacted"){const n=kw(e);if(n!==null)return{ok:!1,message:n};const r=new mw,o=t==="redacted"?"redacted":"raw",i=e.filter(u=>u.streaming).slice(0,lf);r.file("manifest.json",JSON.stringify(Nw(e,t,i),null,2)),r.file("logs.json",JSON.stringify(e.map(u=>Cw(u,t)),null,2));for(const u of e)u.rawRequestBody!==null&&r.file(`#${u.id}.Request.json`,Yo(u.rawRequestBody,t)),u.responseText!==null&&r.file(`#${u.id}.Response.json`,Yo(u.responseText,t));for(const u of i){const d=await _w(u.id);d!==null&&r.file(`#${u.id}.SSE.Response.json`,Yo(d,t))}const a=await r.generateAsync({type:"blob"}),l=URL.createObjectURL(a),c=document.createElement("a");return c.href=l,c.download=`agent-inspector-export-${o}-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(l),{ok:!0}}function Ew(e,t){if(e!==null){e.removeAllRanges();for(const n of t)e.addRange(n)}}function Aw(e){if(e===null)return[];const t=[];for(let n=0;n<e.rangeCount;n++)t.push(e.getRangeAt(n));return t}function Rw(e){if(typeof document>"u")return!1;const t=document.activeElement,n=document.getSelection(),r=Aw(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),Ew(n,r),typeof HTMLElement<"u"&&t instanceof HTMLElement&&t.focus({preventScroll:!0})}return i}async function Kt(e){const t=globalThis.navigator?.clipboard;if(t!==void 0)try{return await t.writeText(e),!0}catch{}return Rw(e)}function Ui(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 Ga(e,t,n){return`${Ui(e,n)} - ${Ui(t,n)}`}function os(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Iw(e){switch(e){case"end_turn":case"tool_use":return e;default:return null}}function zw(e){switch(e){case"stop":case"length":return e;default:return null}}function Pw(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function cf(e){if(e.responseText===null)return null;try{let t=JSON.parse(e.responseText);if(typeof t=="string"&&(t=JSON.parse(t)),!os(t))return null;if(typeof t.stop_reason=="string")return Iw(t.stop_reason);if(Array.isArray(t.choices))for(const n of t.choices){if(!os(n)||typeof n.finish_reason!="string")continue;const r=zw(n.finish_reason);if(r!==null)return r}if(Array.isArray(t.output)){for(const n of t.output)if(os(n)&&n.type==="function_call")return"tool_use";if(t.status==="completed")return"stop"}if(t.status==="incomplete"&&os(t.incomplete_details)){const n=t.incomplete_details.reason;if(typeof n=="string"&&Pw(n))return"length"}return null}catch{return null}}function Ja(e){return e==="end_turn"||e==="stop"||e==="length"}function uf(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=uf(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function df(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=uf(e))&&(r&&(r+=" "),r+=t);return r}const Ow=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Mw=(e,t)=>({classGroupId:e,validator:t}),ff=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Bs="-",uc=[],Lw="arbitrary..",Dw=e=>{const t=Fw(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return $w(a);const l=a.split(Bs),c=l[0]===""&&l.length>1?1:0;return pf(l,c,t)},getConflictingClassGroupIds:(a,l)=>{if(l){const c=r[a],u=n[a];return c?u?Ow(u,c):c:u||uc}return n[a]||uc}}},pf=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],i=n.nextPart.get(o);if(i){const u=pf(e,t+1,i);if(u)return u}const a=n.validators;if(a===null)return;const l=t===0?e.join(Bs):e.slice(t).join(Bs),c=a.length;for(let u=0;u<c;u++){const d=a[u];if(d.validator(l))return d.classGroupId}},$w=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?Lw+r:void 0})(),Fw=e=>{const{theme:t,classGroups:n}=e;return Bw(n,t)},Bw=(e,t)=>{const n=ff();for(const r in e){const o=e[r];Ya(o,n,r,t)}return n},Ya=(e,t,n,r)=>{const o=e.length;for(let i=0;i<o;i++){const a=e[i];Uw(a,t,n,r)}},Uw=(e,t,n,r)=>{if(typeof e=="string"){Ww(e,t,n);return}if(typeof e=="function"){Hw(e,t,n,r);return}Zw(e,t,n,r)},Ww=(e,t,n)=>{const r=e===""?t:hf(t,e);r.classGroupId=n},Hw=(e,t,n,r)=>{if(Vw(e)){Ya(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Mw(n,e))},Zw=(e,t,n,r)=>{const o=Object.entries(e),i=o.length;for(let a=0;a<i;a++){const[l,c]=o[a];Ya(c,hf(t,l),n,r)}},hf=(e,t)=>{let n=e;const r=t.split(Bs),o=r.length;for(let i=0;i<o;i++){const a=r[i];let l=n.nextPart.get(a);l||(l=ff(),n.nextPart.set(a,l)),n=l}return n},Vw=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,qw=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(i){let a=n[i];if(a!==void 0)return a;if((a=r[i])!==void 0)return o(i,a),a},set(i,a){i in n?n[i]=a:o(i,a)}}},Wi="!",dc=":",Kw=[],fc=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),Gw=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const i=[];let a=0,l=0,c=0,u;const d=o.length;for(let g=0;g<d;g++){const x=o[g];if(a===0&&l===0){if(x===dc){i.push(o.slice(c,g)),c=g+1;continue}if(x==="/"){u=g;continue}}x==="["?a++:x==="]"?a--:x==="("?l++:x===")"&&l--}const f=i.length===0?o:o.slice(c);let m=f,h=!1;f.endsWith(Wi)?(m=f.slice(0,-1),h=!0):f.startsWith(Wi)&&(m=f.slice(1),h=!0);const v=u&&u>c?u-c:void 0;return fc(i,h,m,v)};if(t){const o=t+dc,i=r;r=a=>a.startsWith(o)?i(a.slice(o.length)):fc(Kw,!1,a,void 0,!0)}if(n){const o=r;r=i=>n({className:i,parseClassName:o})}return r},Jw=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];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(),r.push(...o),o=[]),r.push(a)):o.push(a)}return o.length>0&&(o.sort(),r.push(...o)),r}},Yw=e=>({cache:qw(e.cacheSize),parseClassName:Gw(e),sortModifiers:Jw(e),...Dw(e)}),Xw=/\s+/,Qw=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:i}=t,a=[],l=e.trim().split(Xw);let c="";for(let u=l.length-1;u>=0;u-=1){const d=l[u],{isExternal:f,modifiers:m,hasImportantModifier:h,baseClassName:v,maybePostfixModifierPosition:g}=n(d);if(f){c=d+(c.length>0?" "+c:c);continue}let x=!!g,b=r(x?v.substring(0,g):v);if(!b){if(!x){c=d+(c.length>0?" "+c:c);continue}if(b=r(v),!b){c=d+(c.length>0?" "+c:c);continue}x=!1}const y=m.length===0?"":m.length===1?m[0]:i(m).join(":"),_=h?y+Wi:y,j=_+b;if(a.indexOf(j)>-1)continue;a.push(j);const S=o(b,x);for(let E=0;E<S.length;++E){const C=S[E];a.push(_+C)}c=d+(c.length>0?" "+c:c)}return c},ek=(...e)=>{let t=0,n,r,o="";for(;t<e.length;)(n=e[t++])&&(r=mf(n))&&(o&&(o+=" "),o+=r);return o},mf=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=mf(e[r]))&&(n&&(n+=" "),n+=t);return n},tk=(e,...t)=>{let n,r,o,i;const a=c=>{const u=t.reduce((d,f)=>f(d),e());return n=Yw(u),r=n.cache.get,o=n.cache.set,i=l,l(c)},l=c=>{const u=r(c);if(u)return u;const d=Qw(c,n);return o(c,d),d};return i=a,(...c)=>i(ek(...c))},nk=[],Ye=e=>{const t=n=>n[e]||nk;return t.isThemeGetter=!0,t},gf=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,xf=/^\((?:(\w[\w-]*):)?(.+)\)$/i,rk=/^\d+\/\d+$/,sk=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ok=/\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)\(.+\)$/,ak=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,lk=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Pn=e=>rk.test(e),Ae=e=>!!e&&!Number.isNaN(Number(e)),Jt=e=>!!e&&Number.isInteger(Number(e)),Xo=e=>e.endsWith("%")&&Ae(e.slice(0,-1)),Bt=e=>sk.test(e),ck=()=>!0,uk=e=>ok.test(e)&&!ik.test(e),bf=()=>!1,dk=e=>ak.test(e),fk=e=>lk.test(e),pk=e=>!ve(e)&&!ye(e),hk=e=>cr(e,wf,bf),ve=e=>gf.test(e),gn=e=>cr(e,kf,uk),Qo=e=>cr(e,vk,Ae),pc=e=>cr(e,vf,bf),mk=e=>cr(e,yf,fk),is=e=>cr(e,_f,dk),ye=e=>xf.test(e),gr=e=>ur(e,kf),gk=e=>ur(e,yk),hc=e=>ur(e,vf),xk=e=>ur(e,wf),bk=e=>ur(e,yf),as=e=>ur(e,_f,!0),cr=(e,t,n)=>{const r=gf.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},ur=(e,t,n=!1)=>{const r=xf.exec(e);return r?r[1]?t(r[1]):n:!1},vf=e=>e==="position"||e==="percentage",yf=e=>e==="image"||e==="url",wf=e=>e==="length"||e==="size"||e==="bg-size",kf=e=>e==="length",vk=e=>e==="number",yk=e=>e==="family-name",_f=e=>e==="shadow",wk=()=>{const e=Ye("color"),t=Ye("font"),n=Ye("text"),r=Ye("font-weight"),o=Ye("tracking"),i=Ye("leading"),a=Ye("breakpoint"),l=Ye("container"),c=Ye("spacing"),u=Ye("radius"),d=Ye("shadow"),f=Ye("inset-shadow"),m=Ye("text-shadow"),h=Ye("drop-shadow"),v=Ye("blur"),g=Ye("perspective"),x=Ye("aspect"),b=Ye("ease"),y=Ye("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(),ye,ve],E=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],R=()=>[ye,ve,c],z=()=>[Pn,"full","auto",...R()],O=()=>[Jt,"none","subgrid",ye,ve],q=()=>["auto",{span:["full",Jt,ye,ve]},Jt,ye,ve],T=()=>[Jt,"auto",ye,ve],D=()=>["auto","min","max","fr",ye,ve],k=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],$=()=>["start","end","center","stretch","center-safe","end-safe"],X=()=>["auto",...R()],B=()=>[Pn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],F=()=>[e,ye,ve],Z=()=>[...j(),hc,pc,{position:[ye,ve]}],J=()=>["no-repeat",{repeat:["","x","y","space","round"]}],H=()=>["auto","cover","contain",xk,hk,{size:[ye,ve]}],W=()=>[Xo,gr,gn],ce=()=>["","none","full",u,ye,ve],se=()=>["",Ae,gr,gn],oe=()=>["solid","dashed","dotted","double"],_e=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ie=()=>[Ae,Xo,hc,pc],ge=()=>["","none",v,ye,ve],he=()=>["none",Ae,ye,ve],xe=()=>["none",Ae,ye,ve],te=()=>[Ae,ye,ve],ue=()=>[Pn,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Bt],breakpoint:[Bt],color:[ck],container:[Bt],"drop-shadow":[Bt],ease:["in","out","in-out"],font:[pk],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Bt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Bt],shadow:[Bt],spacing:["px",Ae],text:[Bt],"text-shadow":[Bt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Pn,ve,ye,x]}],container:["container"],columns:[{columns:[Ae,ve,ye,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:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:z()}],"inset-x":[{"inset-x":z()}],"inset-y":[{"inset-y":z()}],start:[{start:z()}],end:[{end:z()}],top:[{top:z()}],right:[{right:z()}],bottom:[{bottom:z()}],left:[{left:z()}],visibility:["visible","invisible","collapse"],z:[{z:[Jt,"auto",ye,ve]}],basis:[{basis:[Pn,"full","auto",l,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ae,Pn,"auto","initial","none",ve]}],grow:[{grow:["",Ae,ye,ve]}],shrink:[{shrink:["",Ae,ye,ve]}],order:[{order:[Jt,"first","last","none",ye,ve]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:q()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:q()}],"row-start":[{"row-start":T()}],"row-end":[{"row-end":T()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":D()}],"auto-rows":[{"auto-rows":D()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...k(),"normal"]}],"justify-items":[{"justify-items":[...$(),"normal"]}],"justify-self":[{"justify-self":["auto",...$()]}],"align-content":[{content:["normal",...k()]}],"align-items":[{items:[...$(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...$(),{baseline:["","last"]}]}],"place-content":[{"place-content":k()}],"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()}],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()}],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()}],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,gr,gn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,ye,Qo]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Xo,ve]}],"font-family":[{font:[gk,ve,t]}],"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,ye,ve]}],"line-clamp":[{"line-clamp":[Ae,"none",ye,Qo]}],leading:[{leading:[i,...R()]}],"list-image":[{"list-image":["none",ye,ve]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ye,ve]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:F()}],"text-color":[{text:F()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...oe(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ae,"from-font","auto",ye,gn]}],"text-decoration-color":[{decoration:F()}],"underline-offset":[{"underline-offset":[Ae,"auto",ye,ve]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ye,ve]}],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",ye,ve]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Z()}],"bg-repeat":[{bg:J()}],"bg-size":[{bg:H()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Jt,ye,ve],radial:["",ye,ve],conic:[Jt,ye,ve]},bk,mk]}],"bg-color":[{bg:F()}],"gradient-from-pos":[{from:W()}],"gradient-via-pos":[{via:W()}],"gradient-to-pos":[{to:W()}],"gradient-from":[{from:F()}],"gradient-via":[{via:F()}],"gradient-to":[{to:F()}],rounded:[{rounded:ce()}],"rounded-s":[{"rounded-s":ce()}],"rounded-e":[{"rounded-e":ce()}],"rounded-t":[{"rounded-t":ce()}],"rounded-r":[{"rounded-r":ce()}],"rounded-b":[{"rounded-b":ce()}],"rounded-l":[{"rounded-l":ce()}],"rounded-ss":[{"rounded-ss":ce()}],"rounded-se":[{"rounded-se":ce()}],"rounded-ee":[{"rounded-ee":ce()}],"rounded-es":[{"rounded-es":ce()}],"rounded-tl":[{"rounded-tl":ce()}],"rounded-tr":[{"rounded-tr":ce()}],"rounded-br":[{"rounded-br":ce()}],"rounded-bl":[{"rounded-bl":ce()}],"border-w":[{border:se()}],"border-w-x":[{"border-x":se()}],"border-w-y":[{"border-y":se()}],"border-w-s":[{"border-s":se()}],"border-w-e":[{"border-e":se()}],"border-w-t":[{"border-t":se()}],"border-w-r":[{"border-r":se()}],"border-w-b":[{"border-b":se()}],"border-w-l":[{"border-l":se()}],"divide-x":[{"divide-x":se()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":se()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...oe(),"hidden","none"]}],"divide-style":[{divide:[...oe(),"hidden","none"]}],"border-color":[{border:F()}],"border-color-x":[{"border-x":F()}],"border-color-y":[{"border-y":F()}],"border-color-s":[{"border-s":F()}],"border-color-e":[{"border-e":F()}],"border-color-t":[{"border-t":F()}],"border-color-r":[{"border-r":F()}],"border-color-b":[{"border-b":F()}],"border-color-l":[{"border-l":F()}],"divide-color":[{divide:F()}],"outline-style":[{outline:[...oe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ae,ye,ve]}],"outline-w":[{outline:["",Ae,gr,gn]}],"outline-color":[{outline:F()}],shadow:[{shadow:["","none",d,as,is]}],"shadow-color":[{shadow:F()}],"inset-shadow":[{"inset-shadow":["none",f,as,is]}],"inset-shadow-color":[{"inset-shadow":F()}],"ring-w":[{ring:se()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:F()}],"ring-offset-w":[{"ring-offset":[Ae,gn]}],"ring-offset-color":[{"ring-offset":F()}],"inset-ring-w":[{"inset-ring":se()}],"inset-ring-color":[{"inset-ring":F()}],"text-shadow":[{"text-shadow":["none",m,as,is]}],"text-shadow-color":[{"text-shadow":F()}],opacity:[{opacity:[Ae,ye,ve]}],"mix-blend":[{"mix-blend":[..._e(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":_e()}],"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":[Ae]}],"mask-image-linear-from-pos":[{"mask-linear-from":ie()}],"mask-image-linear-to-pos":[{"mask-linear-to":ie()}],"mask-image-linear-from-color":[{"mask-linear-from":F()}],"mask-image-linear-to-color":[{"mask-linear-to":F()}],"mask-image-t-from-pos":[{"mask-t-from":ie()}],"mask-image-t-to-pos":[{"mask-t-to":ie()}],"mask-image-t-from-color":[{"mask-t-from":F()}],"mask-image-t-to-color":[{"mask-t-to":F()}],"mask-image-r-from-pos":[{"mask-r-from":ie()}],"mask-image-r-to-pos":[{"mask-r-to":ie()}],"mask-image-r-from-color":[{"mask-r-from":F()}],"mask-image-r-to-color":[{"mask-r-to":F()}],"mask-image-b-from-pos":[{"mask-b-from":ie()}],"mask-image-b-to-pos":[{"mask-b-to":ie()}],"mask-image-b-from-color":[{"mask-b-from":F()}],"mask-image-b-to-color":[{"mask-b-to":F()}],"mask-image-l-from-pos":[{"mask-l-from":ie()}],"mask-image-l-to-pos":[{"mask-l-to":ie()}],"mask-image-l-from-color":[{"mask-l-from":F()}],"mask-image-l-to-color":[{"mask-l-to":F()}],"mask-image-x-from-pos":[{"mask-x-from":ie()}],"mask-image-x-to-pos":[{"mask-x-to":ie()}],"mask-image-x-from-color":[{"mask-x-from":F()}],"mask-image-x-to-color":[{"mask-x-to":F()}],"mask-image-y-from-pos":[{"mask-y-from":ie()}],"mask-image-y-to-pos":[{"mask-y-to":ie()}],"mask-image-y-from-color":[{"mask-y-from":F()}],"mask-image-y-to-color":[{"mask-y-to":F()}],"mask-image-radial":[{"mask-radial":[ye,ve]}],"mask-image-radial-from-pos":[{"mask-radial-from":ie()}],"mask-image-radial-to-pos":[{"mask-radial-to":ie()}],"mask-image-radial-from-color":[{"mask-radial-from":F()}],"mask-image-radial-to-color":[{"mask-radial-to":F()}],"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":[Ae]}],"mask-image-conic-from-pos":[{"mask-conic-from":ie()}],"mask-image-conic-to-pos":[{"mask-conic-to":ie()}],"mask-image-conic-from-color":[{"mask-conic-from":F()}],"mask-image-conic-to-color":[{"mask-conic-to":F()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Z()}],"mask-repeat":[{mask:J()}],"mask-size":[{mask:H()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ye,ve]}],filter:[{filter:["","none",ye,ve]}],blur:[{blur:ge()}],brightness:[{brightness:[Ae,ye,ve]}],contrast:[{contrast:[Ae,ye,ve]}],"drop-shadow":[{"drop-shadow":["","none",h,as,is]}],"drop-shadow-color":[{"drop-shadow":F()}],grayscale:[{grayscale:["",Ae,ye,ve]}],"hue-rotate":[{"hue-rotate":[Ae,ye,ve]}],invert:[{invert:["",Ae,ye,ve]}],saturate:[{saturate:[Ae,ye,ve]}],sepia:[{sepia:["",Ae,ye,ve]}],"backdrop-filter":[{"backdrop-filter":["","none",ye,ve]}],"backdrop-blur":[{"backdrop-blur":ge()}],"backdrop-brightness":[{"backdrop-brightness":[Ae,ye,ve]}],"backdrop-contrast":[{"backdrop-contrast":[Ae,ye,ve]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ae,ye,ve]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ae,ye,ve]}],"backdrop-invert":[{"backdrop-invert":["",Ae,ye,ve]}],"backdrop-opacity":[{"backdrop-opacity":[Ae,ye,ve]}],"backdrop-saturate":[{"backdrop-saturate":[Ae,ye,ve]}],"backdrop-sepia":[{"backdrop-sepia":["",Ae,ye,ve]}],"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",ye,ve]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ae,"initial",ye,ve]}],ease:[{ease:["linear","initial",b,ye,ve]}],delay:[{delay:[Ae,ye,ve]}],animate:[{animate:["none",y,ye,ve]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,ye,ve]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:he()}],"rotate-x":[{"rotate-x":he()}],"rotate-y":[{"rotate-y":he()}],"rotate-z":[{"rotate-z":he()}],scale:[{scale:xe()}],"scale-x":[{"scale-x":xe()}],"scale-y":[{"scale-y":xe()}],"scale-z":[{"scale-z":xe()}],"scale-3d":["scale-3d"],skew:[{skew:te()}],"skew-x":[{"skew-x":te()}],"skew-y":[{"skew-y":te()}],transform:[{transform:[ye,ve,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ue()}],"translate-x":[{"translate-x":ue()}],"translate-y":[{"translate-y":ue()}],"translate-z":[{"translate-z":ue()}],"translate-none":["translate-none"],accent:[{accent:F()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:F()}],"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",ye,ve]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"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-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-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",ye,ve]}],fill:[{fill:["none",...F()]}],"stroke-w":[{stroke:[Ae,gr,gn,Qo]}],stroke:[{stroke:["none",...F()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","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","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","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-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-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-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-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"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},kk=tk(wk);function ae(...e){return kk(df(e))}function $e(e){return e>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+"M":(e/1e3).toFixed(1).replace(/\.0$/,"")+"K"}function jf(e){return e>=1024*1024?(e/(1024*1024)).toFixed(1).replace(/\.0$/,"")+"M":(e/1024).toFixed(1).replace(/\.0$/,"")+"K"}function mc(e,t,n){const r=e*10;return!Number.isSafeInteger(r)||r%t!==0?null:(r/t/10).toFixed(1).replace(/\.0$/,"")+n}function _k(e){if(!Number.isSafeInteger(e)||e<=0)return e.toString();if(e>=1024*1024){const n=mc(e,1048576,"M");if(n!==null)return n}const t=mc(e,1024,"K");return t!==null?t:e.toString()}function jk(e){if(e===void 0||e==="")return 1;switch(e.toLowerCase()){case"k":return 1024;case"m":return 1024*1024;default:return null}}function Us(e){const t=e.trim().replaceAll(",","");if(t==="")return null;const n=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(t);if(n===null)return null;const r=n[1];if(r===void 0)return null;const o=Number(r),i=n[2],a=jk(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 Sk(e){return e===null?"pending":e>=200&&e<300?"success":e>=400&&e<500?"client_error":e>=500?"server_error":"pending"}const Ck=G({model:N().min(1),contextWindow:K().int().positive().optional(),outputLimit:K().int().positive().optional(),source:Te(["manual","registry"]).optional(),sourceUrl:N().optional(),updatedAt:N().optional()}),Ws=G({id:N(),name:N(),apiKey:N(),model:N().optional(),models:me(N()).min(1),format:Te(["anthropic","openai"]).optional(),baseUrl:N().optional(),anthropicBaseUrl:N().optional(),openaiBaseUrl:N().optional(),openaiResponsesBaseUrl:N().optional(),authHeader:Te(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:N().optional(),modelMetadataUrl:N().optional(),modelMetadata:me(Ck).optional(),source:Te(["company","personal"]).optional(),createdAt:N(),updatedAt:N()});async function Nk(e){return an(e,Ws.array(),void 0,t=>`Failed to fetch ${e}: ${t.status}`)}function Sf(){const e=Tn("/api/providers?includeSecrets=1",Nk,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function je(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function gc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Cf(...e){return t=>{let n=!1;const r=e.map(o=>{const i=gc(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():gc(e[o],null)}}}}function De(...e){return p.useCallback(Cf(...e),e)}function Tk(e,t){const n=p.createContext(t),r=i=>{const{children:a,...l}=i,c=p.useMemo(()=>l,Object.values(l));return s.jsx(n.Provider,{value:c,children:a})};r.displayName=e+"Provider";function o(i){const a=p.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,o]}function Gt(e,t=[]){let n=[];function r(i,a){const l=p.createContext(a),c=n.length;n=[...n,a];const u=f=>{const{scope:m,children:h,...v}=f,g=m?.[e]?.[c]||l,x=p.useMemo(()=>v,Object.values(v));return s.jsx(g.Provider,{value:x,children:h})};u.displayName=i+"Provider";function d(f,m){const h=m?.[e]?.[c]||l,v=p.useContext(h);if(v)return v;if(a!==void 0)return a;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,[r,Ek(o,...t)]}function Ek(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const a=r.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}var Xe=globalThis?.document?p.useLayoutEffect:()=>{},Ak=Xu[" useId ".trim().toString()]||(()=>{}),Rk=0;function zt(e){const[t,n]=p.useState(Ak());return Xe(()=>{n(r=>r??String(Rk++))},[e]),e||(t?`radix-${t}`:"")}var Ik=Xu[" useInsertionEffect ".trim().toString()]||Xe;function _n({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,a]=zk({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(`${r} 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,r])}const u=p.useCallback(d=>{if(l){const f=Pk(d)?d(e):d;f!==e&&a.current?.(f)}else i(d)},[l,e,i,a]);return[c,u]}function zk({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),i=p.useRef(t);return Ik(()=>{i.current=t},[t]),p.useEffect(()=>{o.current!==n&&(i.current?.(n),o.current=n)},[n,o]),[n,r,i]}function Pk(e){return typeof e=="function"}function rr(e){const t=Mk(e),n=p.forwardRef((r,o)=>{const{children:i,...a}=r,l=p.Children.toArray(i),c=l.find(Dk);if(c){const u=c.props.children,d=l.map(f=>f===c?p.Children.count(u)>1?p.Children.only(null):p.isValidElement(u)?u.props.children:null:f);return s.jsx(t,{...a,ref:o,children:p.isValidElement(u)?p.cloneElement(u,void 0,d):null})}return s.jsx(t,{...a,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}var Ok=rr("Slot");function Mk(e){const t=p.forwardRef((n,r)=>{const{children:o,...i}=n;if(p.isValidElement(o)){const a=Fk(o),l=$k(i,o.props);return o.type!==p.Fragment&&(l.ref=r?Cf(r,a):a),p.cloneElement(o,l)}return p.Children.count(o)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Nf=Symbol("radix.slottable");function Lk(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=Nf,t}function Dk(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Nf}function $k(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const c=i(...l);return o(...l),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Fk(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 Bk=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ee=Bk.reduce((e,t)=>{const n=rr(`Primitive.${t}`),r=p.forwardRef((o,i)=>{const{asChild:a,...l}=o,c=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(c,{...l,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Uk(e,t){e&&Fr.flushSync(()=>e.dispatchEvent(t))}function rt(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>t.current?.(...n),[])}function Wk(e,t=globalThis?.document){const n=rt(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Hk="DismissableLayer",Hi="dismissableLayer.update",Zk="dismissableLayer.pointerDownOutside",Vk="dismissableLayer.focusOutside",xc,Tf=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_o=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:a,onDismiss:l,...c}=e,u=p.useContext(Tf),[d,f]=p.useState(null),m=d?.ownerDocument??globalThis?.document,[,h]=p.useState({}),v=De(t,C=>f(C)),g=Array.from(u.layers),[x]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=g.indexOf(x),y=d?g.indexOf(d):-1,_=u.layersWithOutsidePointerEventsDisabled.size>0,j=y>=b,S=Gk(C=>{const R=C.target,z=[...u.branches].some(O=>O.contains(R));!j||z||(o?.(C),a?.(C),C.defaultPrevented||l?.())},m),E=Jk(C=>{const R=C.target;[...u.branches].some(O=>O.contains(R))||(i?.(C),a?.(C),C.defaultPrevented||l?.())},m);return Wk(C=>{y===u.layers.size-1&&(r?.(C),!C.defaultPrevented&&l&&(C.preventDefault(),l()))},m),p.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(xc=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),bc(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=xc)}},[d,m,n,u]),p.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),bc())},[d,u]),p.useEffect(()=>{const C=()=>h({});return document.addEventListener(Hi,C),()=>document.removeEventListener(Hi,C)},[]),s.jsx(Ee.div,{...c,ref:v,style:{pointerEvents:_?j?"auto":"none":void 0,...e.style},onFocusCapture:je(e.onFocusCapture,E.onFocusCapture),onBlurCapture:je(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:je(e.onPointerDownCapture,S.onPointerDownCapture)})});_o.displayName=Hk;var qk="DismissableLayerBranch",Kk=p.forwardRef((e,t)=>{const n=p.useContext(Tf),r=p.useRef(null),o=De(t,r);return p.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(Ee.div,{...e,ref:o})});Kk.displayName=qk;function Gk(e,t=globalThis?.document){const n=rt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let c=function(){Ef(Zk,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Jk(e,t=globalThis?.document){const n=rt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=i=>{i.target&&!r.current&&Ef(Vk,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function bc(){const e=new CustomEvent(Hi);document.dispatchEvent(e)}function Ef(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Uk(o,i):o.dispatchEvent(i)}var ei="focusScope.autoFocusOnMount",ti="focusScope.autoFocusOnUnmount",vc={bubbles:!1,cancelable:!0},Yk="FocusScope",Xa=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...a}=e,[l,c]=p.useState(null),u=rt(o),d=rt(i),f=p.useRef(null),m=De(t,g=>c(g)),h=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(_){if(h.paused||!l)return;const j=_.target;l.contains(j)?f.current=j:en(f.current,{select:!0})},x=function(_){if(h.paused||!l)return;const j=_.relatedTarget;j!==null&&(l.contains(j)||en(f.current,{select:!0}))},b=function(_){if(document.activeElement===document.body)for(const S of _)S.removedNodes.length>0&&en(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const y=new MutationObserver(b);return l&&y.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),y.disconnect()}}},[r,l,h.paused]),p.useEffect(()=>{if(l){wc.add(h);const g=document.activeElement;if(!l.contains(g)){const b=new CustomEvent(ei,vc);l.addEventListener(ei,u),l.dispatchEvent(b),b.defaultPrevented||(Xk(r_(Af(l)),{select:!0}),document.activeElement===g&&en(l))}return()=>{l.removeEventListener(ei,u),setTimeout(()=>{const b=new CustomEvent(ti,vc);l.addEventListener(ti,d),l.dispatchEvent(b),b.defaultPrevented||en(g??document.body,{select:!0}),l.removeEventListener(ti,d),wc.remove(h)},0)}}},[l,u,d,h]);const v=p.useCallback(g=>{if(!n&&!r||h.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,b=document.activeElement;if(x&&b){const y=g.currentTarget,[_,j]=Qk(y);_&&j?!g.shiftKey&&b===j?(g.preventDefault(),n&&en(_,{select:!0})):g.shiftKey&&b===_&&(g.preventDefault(),n&&en(j,{select:!0})):b===y&&g.preventDefault()}},[n,r,h.paused]);return s.jsx(Ee.div,{tabIndex:-1,...a,ref:m,onKeyDown:v})});Xa.displayName=Yk;function Xk(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(en(r,{select:t}),document.activeElement!==n)return}function Qk(e){const t=Af(e),n=yc(t,e),r=yc(t.reverse(),e);return[n,r]}function Af(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function yc(e,t){for(const n of e)if(!e_(n,{upTo:t}))return n}function e_(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 t_(e){return e instanceof HTMLInputElement&&"select"in e}function en(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&t_(e)&&t&&e.select()}}var wc=n_();function n_(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=kc(e,t),e.unshift(t)},remove(t){e=kc(e,t),e[0]?.resume()}}}function kc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function r_(e){return e.filter(t=>t.tagName!=="A")}var s_="Portal",jo=p.forwardRef((e,t)=>{const{container:n,...r}=e,[o,i]=p.useState(!1);Xe(()=>i(!0),[]);const a=n||o&&globalThis?.document?.body;return a?Qm.createPortal(s.jsx(Ee.div,{...r,ref:t}),a):null});jo.displayName=s_;function o_(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var vt=e=>{const{present:t,children:n}=e,r=i_(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),i=De(r.ref,a_(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:i}):null};vt.displayName="Presence";function i_(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),i=p.useRef("none"),a=e?"mounted":"unmounted",[l,c]=o_(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const u=ls(r.current);i.current=l==="mounted"?u:"none"},[l]),Xe(()=>{const u=r.current,d=o.current;if(d!==e){const m=i.current,h=ls(u);e?c("MOUNT"):h==="none"||u?.display==="none"?c("UNMOUNT"):c(d&&m!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),Xe(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=h=>{const g=ls(r.current).includes(CSS.escape(h.animationName));if(h.target===t&&g&&(c("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=h=>{h.target===t&&(i.current=ls(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:p.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function ls(e){return e?.animationName||"none"}function a_(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 ni=0;function Rf(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??_c()),document.body.insertAdjacentElement("beforeend",e[1]??_c()),ni++,()=>{ni===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ni--}},[])}function _c(){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 Rt=function(){return Rt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Rt.apply(this,arguments)};function If(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function l_(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var Es="right-scroll-bar-position",As="width-before-scroll-bar",c_="with-scroll-bars-hidden",u_="--removed-body-scroll-bar-size";function ri(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function d_(e,t){var n=p.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var f_=typeof window<"u"?p.useLayoutEffect:p.useEffect,jc=new WeakMap;function p_(e,t){var n=d_(null,function(r){return e.forEach(function(o){return ri(o,r)})});return f_(function(){var r=jc.get(n);if(r){var o=new Set(r),i=new Set(e),a=n.current;o.forEach(function(l){i.has(l)||ri(l,null)}),i.forEach(function(l){o.has(l)||ri(l,a)})}jc.set(n,e)},[e]),n}function h_(e){return e}function m_(e,t){t===void 0&&(t=h_);var n=[],r=!1,o={read:function(){if(r)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,r);return n.push(a),function(){n=n.filter(function(l){return l!==a})}},assignSyncMedium:function(i){for(r=!0;n.length;){var a=n;n=[],a.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){r=!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 g_(e){e===void 0&&(e={});var t=m_(null);return t.options=Rt({async:!0,ssr:!1},e),t}var zf=function(e){var t=e.sideCar,n=If(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Rt({},n))};zf.isSideCarExport=!0;function x_(e,t){return e.useMedium(t),zf}var Pf=g_(),si=function(){},So=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:si,onWheelCapture:si,onTouchMoveCapture:si}),o=r[0],i=r[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,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,b=e.as,y=b===void 0?"div":b,_=e.gapMode,j=If(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,E=p_([n,t]),C=Rt(Rt({},j),o);return p.createElement(p.Fragment,null,d&&p.createElement(S,{sideCar:Pf,removeScrollBar:u,shards:f,noRelative:h,noIsolation:v,inert:g,setCallbacks:i,allowPinchZoom:!!x,lockRef:n,gapMode:_}),a?p.cloneElement(p.Children.only(l),Rt(Rt({},C),{ref:E})):p.createElement(y,Rt({},C,{className:c,ref:E}),l))});So.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};So.classNames={fullWidth:As,zeroRight:Es};var b_=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function v_(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=b_();return t&&e.setAttribute("nonce",t),e}function y_(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function w_(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var k_=function(){var e=0,t=null;return{add:function(n){e==0&&(t=v_())&&(y_(t,n),w_(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},__=function(){var e=k_();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Of=function(){var e=__(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},j_={left:0,top:0,right:0,gap:0},oi=function(e){return parseInt(e||"",10)||0},S_=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[oi(n),oi(r),oi(o)]},C_=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return j_;var t=S_(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},N_=Of(),Gn="data-scroll-locked",T_=function(e,t,n,r){var o=e.left,i=e.top,a=e.right,l=e.gap;return n===void 0&&(n="margin"),`
42
- .`.concat(c_,` {
40
+ 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 Nd(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const l=e.seen.get(a);if(l.ref===null)return;const c=l.def??l.schema,u={...c},d=l.ref;if(l.ref=null,d){r(d);const m=e.seen.get(d),h=m.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(h)):Object.assign(c,h),Object.assign(c,u),a._zod.parent===d)for(const g in c)g==="$ref"||g==="allOf"||g in u||delete c[g];if(h.$ref&&m.def)for(const g in c)g==="$ref"||g==="allOf"||g in m.def&&JSON.stringify(c[g])===JSON.stringify(m.def[g])&&delete c[g]}const f=a._zod.parent;if(f&&f!==d){r(f);const m=e.seen.get(f);if(m?.schema.$ref&&(c.$ref=m.schema.$ref,m.def))for(const h in c)h==="$ref"||h==="allOf"||h in m.def&&JSON.stringify(c[h])===JSON.stringify(m.def[h])&&delete c[h]}e.override({zodSchema:a,jsonSchema:c,path:l.path??[]})};for(const a of[...e.seen.entries()].reverse())r(a[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 a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,n.def??n.schema);const i=e.external?.defs??{};for(const a of e.seen.entries()){const l=a[1];l.def&&l.defId&&(i[l.defId]=l.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ms(t,"input",e.processors),output:Ms(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function nt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return nt(r.element,n);if(r.type==="set")return nt(r.valueType,n);if(r.type==="lazy")return nt(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return nt(r.innerType,n);if(r.type==="intersection")return nt(r.left,n)||nt(r.right,n);if(r.type==="record"||r.type==="map")return nt(r.keyType,n)||nt(r.valueType,n);if(r.type==="pipe")return nt(r.in,n)||nt(r.out,n);if(r.type==="object"){for(const o in r.shape)if(nt(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(nt(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(nt(o,n))return!0;return!!(r.rest&&nt(r.rest,n))}return!1}const sb=(e,t={})=>n=>{const r=Sd({...n,processors:t});return qe(e,r),Cd(r,e),Nd(r,e)},Ms=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},a=Sd({...o??{},target:i,io:t,processors:n});return qe(e,a),Cd(a,e),Nd(a,e)},ob={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ib=(e,t,n,r)=>{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=ob[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}))])}},ab=(e,t,n,r)=>{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",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=d,o.exclusiveMinimum=!0):o.exclusiveMinimum=d),typeof i=="number"&&(o.minimum=i,typeof d=="number"&&t.target!=="draft-04"&&(d>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof a=="number"&&(o.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},lb=(e,t,n,r)=>{n.type="boolean"},cb=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},ub=(e,t,n,r)=>{n.not={}},db=(e,t,n,r)=>{},fb=(e,t,n,r)=>{const o=e._zod.def,i=sd(o.entries);i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i},pb=(e,t,n,r)=>{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},hb=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},mb=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},gb=(e,t,n,r)=>{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=qe(i.element,t,{...r,path:[...r.path,"items"]})},xb=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const u in a)o.properties[u]=qe(a[u],t,{...r,path:[...r.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=qe(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},bb=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((l,c)=>qe(l,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=a:n.anyOf=a},vb=(e,t,n,r)=>{const o=e._zod.def,i=qe(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=qe(o.right,t,{...r,path:[...r.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},yb=(e,t,n,r)=>{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=qe(i.valueType,t,{...r,path:[...r.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=qe(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=qe(i.valueType,t,{...r,path:[...r.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)}},wb=(e,t,n,r)=>{const o=e._zod.def,i=qe(o.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},kb=(e,t,n,r)=>{const o=e._zod.def;qe(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},_b=(e,t,n,r)=>{const o=e._zod.def;qe(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},jb=(e,t,n,r)=>{const o=e._zod.def;qe(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Sb=(e,t,n,r)=>{const o=e._zod.def;qe(o.innerType,t,r);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},Cb=(e,t,n,r)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;qe(i,t,r);const a=t.seen.get(e);a.ref=i},Nb=(e,t,n,r)=>{const o=e._zod.def;qe(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Td=(e,t,n,r)=>{const o=e._zod.def;qe(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Tb=(e,t,n,r)=>{const o=e._zod.innerType;qe(o,t,r);const i=t.seen.get(e);i.ref=o},Eb=ee("ZodISODateTime",(e,t)=>{Sx.init(e,t),Ve.init(e,t)});function Ab(e){return z0(Eb,e)}const Rb=ee("ZodISODate",(e,t)=>{Cx.init(e,t),Ve.init(e,t)});function Ib(e){return P0(Rb,e)}const zb=ee("ZodISOTime",(e,t)=>{Nx.init(e,t),Ve.init(e,t)});function Pb(e){return O0(zb,e)}const Ob=ee("ZodISODuration",(e,t)=>{Tx.init(e,t),Ve.init(e,t)});function Mb(e){return M0(Ob,e)}const Lb=(e,t)=>{ld.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>xg(e,n)},flatten:{value:n=>gg(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ii,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ii,2)}},isEmpty:{get(){return e.issues.length===0}}})},xt=ee("ZodError",Lb,{Parent:Error}),Db=Ea(xt),$b=Aa(xt),Fb=xo(xt),Bb=bo(xt),Ub=yg(xt),Wb=wg(xt),Hb=kg(xt),Zb=_g(xt),Vb=jg(xt),qb=Sg(xt),Kb=Cg(xt),Gb=Ng(xt),He=ee("ZodType",(e,t)=>(We.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ms(e,"input"),output:Ms(e,"output")}}),e.toJSONSchema=sb(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(un(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>dn(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>Db(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Fb(e,n,r),e.parseAsync=async(n,r)=>$b(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Bb(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Ub(e,n,r),e.decode=(n,r)=>Wb(e,n,r),e.encodeAsync=async(n,r)=>Hb(e,n,r),e.decodeAsync=async(n,r)=>Zb(e,n,r),e.safeEncode=(n,r)=>Vb(e,n,r),e.safeDecode=(n,r)=>qb(e,n,r),e.safeEncodeAsync=async(n,r)=>Kb(e,n,r),e.safeDecodeAsync=async(n,r)=>Gb(e,n,r),e.refine=(n,r)=>e.check(Zv(n,r)),e.superRefine=n=>e.check(Vv(n)),e.overwrite=n=>e.check(lr(n)),e.optional=()=>rc(e),e.exactOptional=()=>Av(e),e.nullable=()=>sc(e),e.nullish=()=>rc(sc(e)),e.nonoptional=n=>Mv(e,n),e.array=()=>me(e),e.or=n=>Mt([e,n]),e.and=n=>jv(e,n),e.transform=n=>oc(e,Tv(n)),e.default=n=>zv(e,n),e.prefault=n=>Ov(e,n),e.catch=n=>Dv(e,n),e.pipe=n=>oc(e,n),e.readonly=()=>Bv(e),e.describe=n=>{const r=e.clone();return Sr.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return Sr.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Sr.get(e);const r=e.clone();return Sr.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Ed=ee("_ZodString",(e,t)=>{Ra.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,o,i)=>ib(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(W0(...r)),e.includes=(...r)=>e.check(V0(...r)),e.startsWith=(...r)=>e.check(q0(...r)),e.endsWith=(...r)=>e.check(K0(...r)),e.min=(...r)=>e.check(Os(...r)),e.max=(...r)=>e.check(_d(...r)),e.length=(...r)=>e.check(jd(...r)),e.nonempty=(...r)=>e.check(Os(1,...r)),e.lowercase=r=>e.check(H0(r)),e.uppercase=r=>e.check(Z0(r)),e.trim=()=>e.check(J0()),e.normalize=(...r)=>e.check(G0(...r)),e.toLowerCase=()=>e.check(Y0()),e.toUpperCase=()=>e.check(X0()),e.slugify=()=>e.check(Q0())}),Jb=ee("ZodString",(e,t)=>{Ra.init(e,t),Ed.init(e,t),e.email=n=>e.check(f0(Yb,n)),e.url=n=>e.check(x0(Xb,n)),e.jwt=n=>e.check(I0(pv,n)),e.emoji=n=>e.check(b0(Qb,n)),e.guid=n=>e.check(Yl(tc,n)),e.uuid=n=>e.check(p0(rs,n)),e.uuidv4=n=>e.check(h0(rs,n)),e.uuidv6=n=>e.check(m0(rs,n)),e.uuidv7=n=>e.check(g0(rs,n)),e.nanoid=n=>e.check(v0(ev,n)),e.guid=n=>e.check(Yl(tc,n)),e.cuid=n=>e.check(y0(tv,n)),e.cuid2=n=>e.check(w0(nv,n)),e.ulid=n=>e.check(k0(rv,n)),e.base64=n=>e.check(E0(uv,n)),e.base64url=n=>e.check(A0(dv,n)),e.xid=n=>e.check(_0(sv,n)),e.ksuid=n=>e.check(j0(ov,n)),e.ipv4=n=>e.check(S0(iv,n)),e.ipv6=n=>e.check(C0(av,n)),e.cidrv4=n=>e.check(N0(lv,n)),e.cidrv6=n=>e.check(T0(cv,n)),e.e164=n=>e.check(R0(fv,n)),e.datetime=n=>e.check(Ab(n)),e.date=n=>e.check(Ib(n)),e.time=n=>e.check(Pb(n)),e.duration=n=>e.check(Mb(n))});function N(e){return d0(Jb,e)}const Ve=ee("ZodStringFormat",(e,t)=>{Ze.init(e,t),Ed.init(e,t)}),Yb=ee("ZodEmail",(e,t)=>{gx.init(e,t),Ve.init(e,t)}),tc=ee("ZodGUID",(e,t)=>{hx.init(e,t),Ve.init(e,t)}),rs=ee("ZodUUID",(e,t)=>{mx.init(e,t),Ve.init(e,t)}),Xb=ee("ZodURL",(e,t)=>{xx.init(e,t),Ve.init(e,t)}),Qb=ee("ZodEmoji",(e,t)=>{bx.init(e,t),Ve.init(e,t)}),ev=ee("ZodNanoID",(e,t)=>{vx.init(e,t),Ve.init(e,t)}),tv=ee("ZodCUID",(e,t)=>{yx.init(e,t),Ve.init(e,t)}),nv=ee("ZodCUID2",(e,t)=>{wx.init(e,t),Ve.init(e,t)}),rv=ee("ZodULID",(e,t)=>{kx.init(e,t),Ve.init(e,t)}),sv=ee("ZodXID",(e,t)=>{_x.init(e,t),Ve.init(e,t)}),ov=ee("ZodKSUID",(e,t)=>{jx.init(e,t),Ve.init(e,t)}),iv=ee("ZodIPv4",(e,t)=>{Ex.init(e,t),Ve.init(e,t)}),av=ee("ZodIPv6",(e,t)=>{Ax.init(e,t),Ve.init(e,t)}),lv=ee("ZodCIDRv4",(e,t)=>{Rx.init(e,t),Ve.init(e,t)}),cv=ee("ZodCIDRv6",(e,t)=>{Ix.init(e,t),Ve.init(e,t)}),uv=ee("ZodBase64",(e,t)=>{zx.init(e,t),Ve.init(e,t)}),dv=ee("ZodBase64URL",(e,t)=>{Ox.init(e,t),Ve.init(e,t)}),fv=ee("ZodE164",(e,t)=>{Mx.init(e,t),Ve.init(e,t)}),pv=ee("ZodJWT",(e,t)=>{Dx.init(e,t),Ve.init(e,t)}),Ad=ee("ZodNumber",(e,t)=>{bd.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,o,i)=>ab(e,r,o),e.gt=(r,o)=>e.check(Ql(r,o)),e.gte=(r,o)=>e.check(Jo(r,o)),e.min=(r,o)=>e.check(Jo(r,o)),e.lt=(r,o)=>e.check(Xl(r,o)),e.lte=(r,o)=>e.check(Go(r,o)),e.max=(r,o)=>e.check(Go(r,o)),e.int=r=>e.check(nc(r)),e.safe=r=>e.check(nc(r)),e.positive=r=>e.check(Ql(0,r)),e.nonnegative=r=>e.check(Jo(0,r)),e.negative=r=>e.check(Xl(0,r)),e.nonpositive=r=>e.check(Go(0,r)),e.multipleOf=(r,o)=>e.check(ec(r,o)),e.step=(r,o)=>e.check(ec(r,o)),e.finite=()=>e;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 K(e){return L0(Ad,e)}const hv=ee("ZodNumberFormat",(e,t)=>{$x.init(e,t),Ad.init(e,t)});function nc(e){return D0(hv,e)}const mv=ee("ZodBoolean",(e,t)=>{Fx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>lb(e,n,r)});function Fe(e){return $0(mv,e)}const gv=ee("ZodNull",(e,t)=>{Bx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>cb(e,n,r)});function Ls(e){return F0(gv,e)}const xv=ee("ZodUnknown",(e,t)=>{Ux.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>db()});function yn(){return B0(xv)}const bv=ee("ZodNever",(e,t)=>{Wx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ub(e,n,r)});function vv(e){return U0(bv,e)}const yv=ee("ZodArray",(e,t)=>{Hx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gb(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(Os(n,r)),e.nonempty=n=>e.check(Os(1,n)),e.max=(n,r)=>e.check(_d(n,r)),e.length=(n,r)=>e.check(jd(n,r)),e.unwrap=()=>e.element});function me(e,t){return eb(yv,e,t)}const wv=ee("ZodObject",(e,t)=>{Vx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>xb(e,n,r,o),Ie(e,"shape",()=>t.shape),e.keyof=()=>Te(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:yn()}),e.loose=()=>e.clone({...e._zod.def,catchall:yn()}),e.strict=()=>e.clone({...e._zod.def,catchall:vv()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>dg(e,n),e.safeExtend=n=>fg(e,n),e.merge=n=>pg(e,n),e.pick=n=>cg(e,n),e.omit=n=>ug(e,n),e.partial=(...n)=>hg(Id,e,n[0]),e.required=(...n)=>mg(zd,e,n[0])});function G(e,t){const n={type:"object",shape:e??{},...we(t)};return new wv(n)}const Rd=ee("ZodUnion",(e,t)=>{wd.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>bb(e,n,r,o),e.options=t.options});function Mt(e,t){return new Rd({type:"union",options:e,...we(t)})}const kv=ee("ZodDiscriminatedUnion",(e,t)=>{Rd.init(e,t),qx.init(e,t)});function Rn(e,t,n){return new kv({type:"union",options:t,discriminator:e,...we(n)})}const _v=ee("ZodIntersection",(e,t)=>{Kx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>vb(e,n,r,o)});function jv(e,t){return new _v({type:"intersection",left:e,right:t})}const Sv=ee("ZodRecord",(e,t)=>{Gx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>yb(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function Ke(e,t,n){return new Sv({type:"record",keyType:e,valueType:t,...we(n)})}const Pi=ee("ZodEnum",(e,t)=>{Jx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(r,o,i)=>fb(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const a of r)if(n.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Pi({...t,checks:[],...we(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const a of r)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new Pi({...t,checks:[],...we(o),entries:i})}});function Te(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Pi({type:"enum",entries:n,...we(t)})}const Cv=ee("ZodLiteral",(e,t)=>{Yx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pb(e,n,r),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 Ce(e,t){return new Cv({type:"literal",values:Array.isArray(e)?e:[e],...we(t)})}const Nv=ee("ZodTransform",(e,t)=>{Xx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mb(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new nd(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)):(n.value=o,n)}});function Tv(e){return new Nv({type:"transform",transform:e})}const Id=ee("ZodOptional",(e,t)=>{kd.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Td(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function rc(e){return new Id({type:"optional",innerType:e})}const Ev=ee("ZodExactOptional",(e,t)=>{Qx.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Td(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Av(e){return new Ev({type:"optional",innerType:e})}const Rv=ee("ZodNullable",(e,t)=>{e0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wb(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function sc(e){return new Rv({type:"nullable",innerType:e})}const Iv=ee("ZodDefault",(e,t)=>{t0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_b(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function zv(e,t){return new Iv({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():id(t)}})}const Pv=ee("ZodPrefault",(e,t)=>{n0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>jb(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ov(e,t){return new Pv({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():id(t)}})}const zd=ee("ZodNonOptional",(e,t)=>{r0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>kb(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Mv(e,t){return new zd({type:"nonoptional",innerType:e,...we(t)})}const Lv=ee("ZodCatch",(e,t)=>{s0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Sb(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Dv(e,t){return new Lv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const $v=ee("ZodPipe",(e,t)=>{o0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Cb(e,n,r,o),e.in=t.in,e.out=t.out});function oc(e,t){return new $v({type:"pipe",in:e,out:t})}const Fv=ee("ZodReadonly",(e,t)=>{i0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Nb(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Bv(e){return new Fv({type:"readonly",innerType:e})}const Uv=ee("ZodLazy",(e,t)=>{a0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Tb(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function Wv(e){return new Uv({type:"lazy",getter:e})}const Hv=ee("ZodCustom",(e,t)=>{l0.init(e,t),He.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hb(e,n)});function Zv(e,t={}){return tb(Hv,e,t)}function Vv(e){return nb(e)}const Qe=Wv(()=>Mt([N(),K(),Fe(),Ls(),me(Qe),Ke(N(),Qe)]));const Pd=G({index:K(),timestamp:K(),type:N(),data:Qe}),qv=G({chunks:me(Pd),truncated:Fe().optional().default(!1)}),Kv=Te(["request","response"]),Gv=G({logId:K().int().positive(),part:Kv,text:N(),offset:K().int().nonnegative(),limit:K().int().positive(),totalBytes:K().int().nonnegative(),textBytes:K().int().nonnegative(),nextOffset:K().int().nonnegative().nullable(),hasMore:Fe(),contentMode:Te(["empty","partial","full"])}),Rr=G({id:K(),timestamp:N(),method:N(),path:N(),model:N().nullable(),sessionId:N().nullable(),rawRequestBody:N().nullable(),responseStatus:K().nullable(),responseText:N().nullable(),inputTokens:K().nullable(),outputTokens:K().nullable(),cacheCreationInputTokens:K().nullable(),cacheReadInputTokens:K().nullable(),elapsedMs:K().nullable(),firstChunkMs:K().nullable().optional(),totalStreamMs:K().nullable().optional(),tokensPerSecond:K().nullable().optional(),streaming:Fe(),userAgent:N().nullable(),origin:N().nullable(),rawHeaders:Ke(N(),N()).optional(),headers:Ke(N(),N()).optional(),apiFormat:Te(["anthropic","openai","unknown"]).default("unknown"),isTest:Fe().optional().default(!1),replayOfLogId:K().nullable().optional(),providerName:N().nullable().optional(),clientPort:K().nullable().optional(),clientPid:K().nullable().optional(),clientCwd:N().nullable().optional(),clientProjectFolder:N().nullable().optional(),streamingChunks:qv.optional(),streamingChunksPath:N().nullable().optional(),rawRequestBodyBytes:K().int().nonnegative().nullable().optional(),responseTextBytes:K().int().nonnegative().nullable().optional(),bodyContentMode:Te(["full","compact","truncated"]).optional(),warnings:me(N()).optional(),error:N().nullable().optional()}),Ia=G({type:N(),ttl:N().optional(),scope:N().optional()}),za=G({type:Ce("text"),text:N(),cache_control:Ia.optional()}),Od=G({type:Ce("thinking"),thinking:N(),signature:N().optional()}),Jv=G({type:Ce("think"),thinking:N(),signature:N().optional()}),Yv=G({type:Ce("base64"),media_type:N(),data:N()}),Md=G({type:Ce("image"),source:Yv}),Ld=G({type:Ce("tool_use"),id:N(),name:N(),input:Ke(N(),Qe)}),Xv=Rn("type",[za,Md]),Qv=G({type:Ce("tool_result"),tool_use_id:N().optional(),content:Mt([N(),me(Xv)]),is_error:Fe().optional()}),e1=Rn("type",[za,Od,Md,Ld,Qv]),t1=Mt([N(),me(e1)]),n1=G({role:Te(["user","assistant"]),content:t1}),r1=G({type:Ce("text"),text:N(),cache_control:Ia.optional()}),s1=G({type:N(),properties:Ke(N(),Ke(N(),Qe)).optional(),required:me(N()).optional(),additionalProperties:Fe().optional(),$schema:N().optional()}),o1=G({name:N(),description:N().optional(),input_schema:s1.optional(),cache_control:Ia.optional()}),i1=Rn("type",[G({type:Ce("enabled"),budget_tokens:K()}),G({type:Ce("disabled")}),G({type:Ce("adaptive")})]),Dd=G({model:N(),messages:me(n1),system:me(r1).optional(),tools:me(o1).optional(),max_tokens:K().optional(),temperature:K().optional(),stream:Fe().optional(),thinking:i1.optional(),metadata:G({user_id:N().optional()}).optional()}),Pa=Rn("type",[za,Od,Jv,Ld]),a1=G({input_tokens:K().nullable().optional(),output_tokens:K().nullable().optional(),cache_creation_input_tokens:K().nullable().optional(),cache_read_input_tokens:K().nullable().optional()}).passthrough(),$d=G({id:N(),type:Ce("message"),model:N(),role:Ce("assistant"),content:me(Pa),stop_reason:N().nullable(),stop_sequence:N().nullable().optional(),usage:a1}).passthrough(),l1=G({type:Ce("message_start"),message:G({id:N(),type:Ce("message"),model:N(),role:Ce("assistant"),content:me(Pa),stop_reason:Ls(),stop_sequence:Ls(),usage:G({input_tokens:K(),cache_creation_input_tokens:K().optional(),cache_read_input_tokens:K().optional()}).passthrough()})}),c1=G({type:Ce("content_block_start"),index:K(),content_block:Pa}),u1=Rn("type",[G({type:Ce("text_delta"),text:N()}),G({type:Ce("input_json_delta"),partial_json:N()}),G({type:Ce("thinking_delta"),thinking:N()}),G({type:Ce("signature_delta"),signature:N()})]),d1=G({type:Ce("content_block_delta"),index:K(),delta:u1}),f1=G({type:Ce("content_block_stop"),index:K()}),p1=G({type:Ce("message_delta"),delta:G({stop_reason:N().nullable(),stop_sequence:N().nullable().optional()}),usage:G({output_tokens:K(),input_tokens:K().optional(),cache_creation_input_tokens:K().optional(),cache_read_input_tokens:K().optional()}).passthrough()}),h1=G({type:Ce("message_stop")}),m1=G({type:Ce("ping")}),g1=G({type:Ce("error"),error:G({type:N(),message:N()})}),x1=Rn("type",[l1,c1,d1,f1,p1,h1,m1,g1]),b1=Mt([N(),me(Rn("type",[G({type:Ce("text"),text:N()}),G({type:Ce("image_url"),image_url:G({url:N(),detail:N().optional()})})]))]),Fd=G({role:Te(["system","user","assistant","tool"]),content:b1,name:N().optional(),reasoning_content:N().optional(),thinking:N().optional(),think:N().optional()}),v1=G({name:N(),arguments:N()}),Bd=G({index:K().optional(),id:N().optional(),type:Ce("function").optional(),function:G({name:N().optional(),arguments:N().optional()})});Fd.extend({content:Mt([N(),me(G({type:Ce("text"),text:N()}))]).optional(),function_call:v1.optional(),tool_calls:me(Bd).optional()});const y1=G({type:Ce("function"),function:G({name:N(),description:N().optional(),parameters:Ke(N(),Qe)})}),Ud=G({model:N(),messages:me(Fd),temperature:K().optional(),max_tokens:K().optional(),stream:Fe().optional(),tools:me(y1).optional(),tool_choice:Mt([Te(["auto","none","required"]),G({type:Ce("auto")}),G({type:Ce("none")}),G({type:Ce("function"),function:G({name:N()})})]).optional(),user:N().optional()}),w1=G({type:N(),name:N().optional(),description:N().optional(),parameters:Qe.optional(),function:G({name:N().optional(),description:N().optional(),parameters:Qe.optional()}).optional()}).passthrough(),Wd=G({model:N(),input:yn().optional(),instructions:Mt([N(),Ls()]).optional(),stream:Fe().optional(),tools:me(w1).optional(),tool_choice:yn().optional(),max_output_tokens:K().optional(),temperature:K().optional(),user:N().optional(),metadata:Ke(N(),yn()).optional()}).passthrough(),Hd=G({role:Te(["assistant"]).optional(),content:N().nullable().optional(),reasoning_content:N().nullable().optional(),thinking:N().nullable().optional(),think:N().nullable().optional(),function_call:G({name:N().optional(),arguments:N().optional()}).nullable().optional(),tool_calls:me(G({index:K(),id:N().optional(),type:Ce("function").optional(),function:G({name:N().optional(),arguments:N().optional()})})).nullable().optional()}),k1=G({index:K(),message:G({role:Te(["assistant"]),content:N().nullable(),reasoning_content:N().optional(),thinking:N().optional(),think:N().optional(),function_call:G({name:N(),arguments:N()}).nullable().optional(),tool_calls:me(Bd).optional()}).optional(),delta:Hd.optional(),finish_reason:N().nullable()}),_1=G({id:N(),object:Ce("chat.completion"),created:K(),model:N(),choices:me(k1),usage:G({prompt_tokens:K().nullable().optional(),completion_tokens:K().nullable().optional(),total_tokens:K().nullable().optional()}).passthrough(),service_tier:N().nullable().optional(),system_fingerprint:N().nullable().optional()}).passthrough(),j1=G({id:N(),object:Ce("chat.completion.chunk"),created:K(),model:N(),choices:me(G({index:K(),delta:Hd,finish_reason:N().nullable().optional()})),usage:G({prompt_tokens:K().nullable().optional(),completion_tokens:K().nullable().optional(),total_tokens:K().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),S1=G({input_tokens:K().nullable().optional(),output_tokens:K().nullable().optional(),total_tokens:K().nullable().optional(),input_tokens_details:G({cached_tokens:K().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:G({reasoning_tokens:K().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),C1=G({type:N()}).passthrough(),Ds=G({id:N(),object:Ce("response").optional(),created_at:K().optional(),status:N().nullable().optional(),model:N().optional(),output:me(C1).optional(),output_text:N().optional(),usage:S1.nullable().optional(),error:yn().optional()}).passthrough(),N1=G({type:N()}).passthrough();function Zd(e){try{const t=JSON.parse(e),n=_1.safeParse(t);return n.success?n.data:null}catch{return null}}function Vd(e){try{const t=JSON.parse(e),n=Ds.safeParse(t);return n.success?n.data:null}catch{return null}}const T1=G({error:N()});async function jt(e,t){const n=await e.json();return t.parse(n)}async function Wt(e,t){try{const n=await e.json(),r=T1.safeParse(n);return r.success?r.data.error:t}catch{return t}}async function an(e,t,n,r){const o=await fetch(e,n);if(!o.ok){const i=r?.(o)??`Request failed with status ${o.status}`;throw new Error(await Wt(o,i))}return jt(o,t)}function E1(e){return e<1e3?`${String(e)}ms`:`${String(Math.round(e/1e3))}s`}class Oa extends Error{constructor(t){super(`Request timed out after ${E1(t)}`),this.name="ApiTimeoutError"}}async function tr(e,t,n,r,o){const i=new AbortController,a=setTimeout(()=>i.abort(),n);try{return await an(e,t,{...r,signal:i.signal},o)}catch(l){throw l instanceof DOMException&&l.name==="AbortError"?new Oa(n):l}finally{clearTimeout(a)}}const qd=G({input:K().int().nonnegative(),output:K().int().nonnegative(),cacheCreate:K().int().nonnegative(),cacheRead:K().int().nonnegative(),total:K().int().nonnegative()}),A1=G({id:K().int().positive(),sessionLogNumber:K().int().positive().optional(),timestamp:N(),provider:N().nullable(),model:N().nullable(),apiFormat:Te(["anthropic","openai","unknown"]),method:N(),path:N(),status:K().nullable(),isStreaming:Fe(),hasError:Fe(),error:N().nullable(),latencyMs:K().nullable(),firstChunkMs:K().nullable().optional(),totalStreamMs:K().nullable().optional(),tokensPerSecond:K().nullable().optional(),tokens:G({input:K().nullable(),output:K().nullable(),cacheCreate:K().nullable(),cacheRead:K().nullable()}),sessionId:N().nullable(),userAgent:N().nullable().optional(),clientPid:K().nullable().optional(),clientProjectFolder:N().nullable().optional()}),Kd=G({id:N(),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:N().nullable(),updatedAt:N().nullable(),requestCount:K().int().nonnegative(),activeRequests:K().int().nonnegative(),completedRequests:K().int().nonnegative(),failedRequests:K().int().nonnegative(),queuedTasks:K().int().nonnegative(),runningTasks:K().int().nonnegative(),lastTaskError:N().nullable(),logCount:K().int().nonnegative(),errorCount:K().int().nonnegative(),models:me(N()),providers:me(N()),tokenUsage:qd,lastLogId:K().nullable(),lastModel:N().nullable(),clientUserAgent:N().nullable().optional(),clientPid:K().nullable(),clientProjectFolder:N().nullable(),inspectorPath:N(),inspectorUrl:N(),apiPath:N(),apiUrl:N(),compactLogsPath:N(),compactLogsUrl:N(),latestLogLimit:K().int().positive(),latestLogs:me(A1)}),Ur=Te(["created","running","completed","failed","cancelled"]),Ma=G({jsonPath:N(),markdownPath:N(),htmlPath:N(),exportedAt:N()}),R1=Te(["run-created","session-started","request","session-finished","evidence-exported"]),I1=Te(["info","success","warning","error"]),z1=G({timestamp:N(),kind:R1,severity:I1,title:N(),details:N(),logId:K().int().positive().nullable(),status:K().nullable(),model:N().nullable(),provider:N().nullable(),latencyMs:K().nullable(),isStreaming:Fe().nullable()}),P1=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"]),Gd=G({outcome:Te(["success","failure","active","unknown"]),severity:Te(["none","low","medium","high"]),category:P1,summary:N(),evidenceLogIds:me(K().int().positive()),hints:me(N())}),La=G({status:Te(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:N(),markdown:N()}),Jd=La,Da=G({id:N(),sessionId:N(),groupId:N().nullable().default(null),title:N(),task:N().nullable(),project:N().nullable(),agent:N().nullable(),status:Ur,tags:me(N()),metadata:Ke(N(),Qe),evidence:Ma.nullable(),createdAt:N(),updatedAt:N()});G({runId:N().min(1).optional(),sessionId:N().min(1).optional(),groupId:N().min(1).nullable().optional(),title:N().min(1).optional(),task:N().nullable().optional(),project:N().nullable().optional(),agent:N().nullable().optional(),status:Ur.optional(),tags:me(N()).optional(),metadata:Ke(N(),Qe).optional()}).optional();G({sessionId:N().min(1).optional(),groupId:N().min(1).nullable().optional(),title:N().min(1).optional(),task:N().nullable().optional(),project:N().nullable().optional(),agent:N().nullable().optional(),status:Ur.optional(),tags:me(N()).optional(),metadata:Ke(N(),Qe).optional()});G({includeHistory:Fe().optional(),latestLogLimit:K().int().positive().max(50).optional()}).optional();G({run:Da,evidence:Ma,session:Kd.nullable(),timeline:me(z1),classification:Gd,jenkinsReport:La});const O1=G({run:Da,classification:Gd,evidence:Ma.nullable(),jenkinsReport:La.nullable(),sessionId:N(),inspectorUrl:N().nullable(),evidenceMarkdownPath:N().nullable(),updatedAt:N()});G({failures:me(O1),total:K().int().nonnegative(),limit:K().int().positive()});const $a=Te(["created","running","completed","failed","cancelled"]),Fa=Te(["evaluation","batch","manual"]),Ba=G({jsonPath:N(),markdownPath:N(),htmlPath:N(),exportedAt:N()}),Yd=G({id:N(),groupId:N(),sessionId:N(),runId:N().nullable(),label:N().nullable(),agent:N().nullable(),provider:N().nullable(),model:N().nullable(),status:Ur.nullable(),metadata:Ke(N(),Qe),addedAt:N(),updatedAt:N()}),Ua=G({id:N(),title:N(),kind:Fa,task:N().nullable(),project:N().nullable(),status:$a,tags:me(N()),metadata:Ke(N(),Qe),evidence:Ba.nullable(),members:me(Yd),createdAt:N(),updatedAt:N()});G({groupId:N().min(1).optional(),title:N().min(1).optional(),kind:Fa.optional(),task:N().nullable().optional(),project:N().nullable().optional(),status:$a.optional(),tags:me(N()).optional(),metadata:Ke(N(),Qe).optional()}).optional();G({title:N().min(1).optional(),kind:Fa.optional(),task:N().nullable().optional(),project:N().nullable().optional(),status:$a.optional(),tags:me(N()).optional(),metadata:Ke(N(),Qe).optional()});G({memberId:N().min(1).optional(),sessionId:N().min(1),runId:N().min(1).nullable().optional(),label:N().min(1).nullable().optional(),agent:N().min(1).nullable().optional(),provider:N().min(1).nullable().optional(),model:N().min(1).nullable().optional(),status:Ur.nullable().optional(),metadata:Ke(N(),Qe).optional()});G({includeHistory:Fe().optional(),latestLogLimit:K().int().positive().max(50).optional()}).optional();G({deleteEvidence:Fe().optional()});const M1=G({groupId:N(),deleted:Fe(),evidenceDeleted:Fe(),evidencePath:N().nullable()}),Xd=G({member:Yd,run:Da.nullable(),session:Kd.nullable()}),Qd=G({memberCount:K().int().nonnegative(),sessionsWithData:K().int().nonnegative(),missingSessions:K().int().nonnegative(),requestCount:K().int().nonnegative(),errorCount:K().int().nonnegative(),tokenUsage:qd,models:me(N()),providers:me(N()),completedMembers:K().int().nonnegative(),failedMembers:K().int().nonnegative(),runningMembers:K().int().nonnegative()}),L1=G({group:Ua,evidence:Ba,members:me(Xd).nullable(),markdown:N(),summary:Qd.nullable(),report:Jd.nullable()}),D1=G({group:Ua,evidence:Ba,members:me(Xd),summary:Qd,jenkinsReport:Jd}),ef=G({groups:me(Ua)}),$1=G({sessionId:N(),imported:K().int().nonnegative(),skipped:K().int().nonnegative(),warnings:me(N()),logs:me(Rr)}),$s=10,Oi=600,Fs=60,Mi=600,Bs="time",Wa="simple",tf=Te(["time","full"]),F1=Te(["simple","full"]),yo=G({stripClaudeCodeBillingHeader:Fe(),hasSeenOnboarding:Fe().default(!1),slowResponseThresholdSeconds:K().int().min(0).max(Oi).default($s),providerTestTimeoutSeconds:K().int().min(1).max(Mi).default(Fs),timeDisplayFormat:tf.default(Bs),captureMode:F1.default(Wa)}),Hn="/api/config";async function B1(e){return an(e,yo,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function ss(e){return an(Hn,yo,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function Ha(){const e=Tn(Hn,B1,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=Qu(),n=e.data?.stripClaudeCodeBillingHeader??!1,r=e.data?.captureMode??Wa,o=e.data?.slowResponseThresholdSeconds??$s,i=e.data?.providerTestTimeoutSeconds??Fs,a=e.data?.timeDisplayFormat??Bs,l=m=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??$s,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Fs,timeDisplayFormat:e.data?.timeDisplayFormat??Bs,captureMode:r,...m}),c=async m=>{await t(Hn,ss({stripClaudeCodeBillingHeader:m}),{optimisticData:l({stripClaudeCodeBillingHeader:m}),rollbackOnError:!0,revalidate:!1})},u=async m=>{await t(Hn,ss({slowResponseThresholdSeconds:m}),{optimisticData:l({slowResponseThresholdSeconds:m}),rollbackOnError:!0,revalidate:!1})},d=async m=>{await t(Hn,ss({timeDisplayFormat:m}),{optimisticData:l({timeDisplayFormat:m}),rollbackOnError:!0,revalidate:!1})},f=async m=>{await t(Hn,ss({providerTestTimeoutSeconds:m}),{optimisticData:l({providerTestTimeoutSeconds:m}),rollbackOnError:!0,revalidate:!1})};return{strip:n,captureMode:r,slowResponseThresholdSeconds:o,providerTestTimeoutSeconds:i,timeDisplayFormat:a,isLoading:e.isLoading,isError:e.error!==void 0,setStrip:c,setSlowResponseThresholdSeconds:u,setProviderTestTimeoutSeconds:f,setTimeDisplayFormat:d}}const nf=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();const U1=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const W1=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase());const ic=e=>{const t=W1(e);return t.charAt(0).toUpperCase()+t.slice(1)};var H1={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 Z1=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const V1=p.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:a,...l},c)=>p.createElement("svg",{ref:c,...H1,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:nf("lucide",o),...!i&&!Z1(l)&&{"aria-hidden":"true"},...l},[...a.map(([u,d])=>p.createElement(u,d)),...Array.isArray(i)?i:[i]]));const pe=(e,t)=>{const n=p.forwardRef(({className:r,...o},i)=>p.createElement(V1,{ref:i,iconNode:t,className:nf(`lucide-${U1(ic(e))}`,`lucide-${e}`,r),...o}));return n.displayName=ic(e),n};const q1=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],K1=pe("arrow-down-right",q1);const G1=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],J1=pe("arrow-down",G1);const Y1=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],X1=pe("arrow-left",Y1);const Q1=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],ey=pe("arrow-up-right",Q1);const ty=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ny=pe("arrow-up",ty);const ry=[["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"}]],sy=pe("bell",ry);const oy=[["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"}]],iy=pe("blocks",oy);const ay=[["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"}]],rf=pe("brain",ay);const ly=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ge=pe("check",ly);const cy=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],st=pe("chevron-down",cy);const uy=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],dy=pe("chevron-left",uy);const fy=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],bt=pe("chevron-right",fy);const py=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Za=pe("chevron-up",py);const hy=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],my=pe("chevrons-down",hy);const gy=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],xy=pe("chevrons-left",gy);const by=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],vy=pe("chevrons-right",by);const yy=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],wy=pe("chevrons-up",yy);const ky=[["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"}]],Ir=pe("circle-alert",ky);const _y=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],jy=pe("circle-check-big",_y);const Sy=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Li=pe("circle-check",Sy);const Cy=[["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"}]],Ny=pe("circle-question-mark",Cy);const Ty=[["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"}]],sf=pe("circle-x",Ty);const Ey=[["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"}]],Ay=pe("clapperboard",Ey);const Ry=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Iy=pe("clock-3",Ry);const zy=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ht=pe("clock",zy);const Py=[["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"}]],Oy=pe("cloud-upload",Py);const My=[["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"}]],Ly=pe("code-xml",My);const Dy=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],$y=pe("columns-2",Dy);const Fy=[["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"}]],Nt=pe("copy",Fy);const By=[["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"}]],Uy=pe("cpu",By);const Wy=[["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"}]],wo=pe("download",Wy);const Hy=[["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"}]],Zy=pe("ellipsis",Hy);const Vy=[["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"}]],Va=pe("external-link",Vy);const qy=[["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"}]],qa=pe("eye-off",qy);const Ky=[["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"}]],Ka=pe("eye",Ky);const Gy=[["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"}]],Jy=pe("file-braces",Gy);const Yy=[["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"}]],Xy=pe("file-diff",Yy);const Qy=[["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"}]],e2=pe("file-search",Qy);const t2=[["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"}]],n2=pe("file-terminal",t2);const r2=[["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"}]],s2=pe("file-text",r2);const o2=[["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"}]],i2=pe("flag",o2);const a2=[["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"}]],l2=pe("folder-open",a2);const c2=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ga=pe("gauge",c2);const u2=[["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"}]],d2=pe("git-compare-arrows",u2);const f2=[["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"}]],of=pe("globe",f2);const p2=[["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"}]],h2=pe("history",p2);const m2=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],g2=pe("info",m2);const x2=[["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"}]],ac=pe("layers",x2);const b2=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ft=pe("loader-circle",b2);const v2=[["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"}]],y2=pe("lock",v2);const w2=[["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"}]],ko=pe("message-square",w2);const k2=[["path",{d:"M5 12h14",key:"1ays0h"}]],_2=pe("minus",k2);const j2=[["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"}]],S2=pe("monitor",j2);const C2=[["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"}]],N2=pe("mouse-pointer-click",C2);const T2=[["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"}]],E2=pe("octagon-alert",T2);const A2=[["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"}]],af=pe("pencil",A2);const R2=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Di=pe("plus",R2);const I2=[["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"}]],lc=pe("radio",I2);const z2=[["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"}]],zr=pe("refresh-cw",z2);const P2=[["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"}]],O2=pe("rotate-ccw",P2);const M2=[["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"}]],$i=pe("rotate-cw",M2);const L2=[["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"}]],D2=pe("rows-3",L2);const $2=[["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"}]],F2=pe("save",$2);const B2=[["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"}]],U2=pe("scan",B2);const W2=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],H2=pe("search",W2);const Z2=[["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"}]],V2=pe("server",Z2);const q2=[["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"}]],K2=pe("settings",q2);const G2=[["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"}]],J2=pe("shield-alert",G2);const Y2=[["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"}]],cc=pe("shield-check",Y2);const X2=[["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"}]],Fi=pe("siren",X2);const Q2=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Ja=pe("terminal",Q2);const ew=[["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"}]],tw=pe("timer",ew);const nw=[["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"}]],nr=pe("trash-2",nw);const rw=[["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"}]],rn=pe("triangle-alert",rw);const sw=[["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"}]],lf=pe("upload",sw);const ow=[["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"}]],iw=pe("wifi-off",ow);const aw=[["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"}]],lw=pe("wifi",aw);const cw=[["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"}]],Wr=pe("wrench",cw);const uw=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],_o=pe("x",uw);const dw=[["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"}]],Pr=pe("zap",dw),Bi="/api/config";async function fw(e){return an(e,yo,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function pw(e){return an(Bi,yo,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function hw(){const e=Tn(Bi,fw,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=Qu(),n=e.data?.hasSeenOnboarding??!1,r=e.data?.captureMode??Wa,o=async()=>{await t(Bi,pw({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??$s,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Fs,timeDisplayFormat:e.data?.timeDisplayFormat??Bs,captureMode:r},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:n,captureMode:r,isLoading:e.isLoading,markSeen:o}}function mw(){const{hasSeenOnboarding:e,isLoading:t,markSeen:n}=hw(),[r,o]=p.useState(!1);if(t||e)return null;const i=r?"grid":"hidden sm:grid";return s.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:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(g2,{className:"mt-0.5 size-4 shrink-0 text-amber-300","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"font-medium text-amber-200",children:"Inspector ready"}),s.jsx("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:"Request, response, tool, timing, token, replay, and memory signals are active."})]}),s.jsx("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground sm:hidden",children:"Core capture is active."}),s.jsxs("div",{className:`${i} mt-2 gap-x-4 gap-y-1 text-xs leading-relaxed text-muted-foreground sm:grid-cols-2`,children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Evidence"}),": logs, sessions, groups, and MCP exports are available."]}),s.jsxs("div",{children:[s.jsx("strong",{children:"Network"}),": replace ",s.jsx("code",{children:"localhost"})," if containers differ."]})]})]}),s.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":r,"aria-label":r?"Hide onboarding details":"Show onboarding details",children:s.jsx(st,{className:`size-3.5 transition-transform ${r?"rotate-180":""}`})}),s.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:[s.jsx(Ge,{className:"size-3.5"}),"Got it"]}),s.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:s.jsx(_o,{className:"size-3.5"})})]})})}function os(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 Yo={exports:{}};var uc;function gw(){return uc||(uc=1,(function(e,t){(function(n){e.exports=n()})(function(){return(function n(r,o,i){function a(u,d){if(!o[u]){if(!r[u]){var f=typeof os=="function"&&os;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:{}};r[u][0].call(h.exports,function(v){var g=r[u][1][v];return a(g||v)},h,h.exports,n,r,o,i)}return o[u].exports}for(var l=typeof os=="function"&&os,c=0;c<i.length;c++)a(i[c]);return a})({1:[function(n,r,o){var i=n("./utils"),a=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(c){for(var u,d,f,m,h,v,g,x=[],b=0,y=c.length,_=y,j=i.getTypeOf(c)!=="string";b<c.length;)_=y-b,f=j?(u=c[b++],d=b<y?c[b++]:0,b<y?c[b++]:0):(u=c.charCodeAt(b++),d=b<y?c.charCodeAt(b++):0,b<y?c.charCodeAt(b++):0),m=u>>2,h=(3&u)<<4|d>>4,v=1<_?(15&d)<<2|f>>6:64,g=2<_?63&f:64,x.push(l.charAt(m)+l.charAt(h)+l.charAt(v)+l.charAt(g));return x.join("")},o.decode=function(c){var u,d,f,m,h,v,g=0,x=0,b="data:";if(c.substr(0,b.length)===b)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|(v=l.indexOf(c.charAt(g++))),y[x++]=u,h!==64&&(y[x++]=d),v!==64&&(y[x++]=f);return y}},{"./support":30,"./utils":32}],2:[function(n,r,o){var i=n("./external"),a=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,m,h,v){this.compressedSize=d,this.uncompressedSize=f,this.crc32=m,this.compression=h,this.compressedContent=v}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)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,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,r,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})();r.exports=function(l,c){return l!==void 0&&l.length?i.getTypeOf(l)!=="string"?(function(u,d,f,m){var h=a,v=m+f;u^=-1;for(var g=m;g<v;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,v=m+f;u^=-1;for(var g=m;g<v;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,r,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,r,o){var i=null;i=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:i}},{lie:37}],7:[function(n,r,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,r,o){function i(h,v){var g,x="";for(g=0;g<v;g++)x+=String.fromCharCode(255&h),h>>>=8;return x}function a(h,v,g,x,b,y){var _,j,S=h.file,E=h.compression,C=y!==u.utf8encode,R=l.transformTo("string",y(S.name)),z=l.transformTo("string",u.utf8encode(S.name)),O=S.comment,q=l.transformTo("string",y(O)),T=l.transformTo("string",u.utf8encode(O)),D=z.length!==S.name.length,k=T.length!==O.length,$="",X="",B="",F=S.dir,Z=S.date,J={crc32:0,compressedSize:0,uncompressedSize:0};v&&!g||(J.crc32=h.crc32,J.compressedSize=h.compressedSize,J.uncompressedSize=h.uncompressedSize);var H=0;v&&(H|=8),C||!D&&!k||(H|=2048);var W=0,ce=0;F&&(W|=16),b==="UNIX"?(ce=798,W|=(function(oe,_e){var ie=oe;return oe||(ie=_e?16893:33204),(65535&ie)<<16})(S.unixPermissions,F)):(ce=20,W|=(function(oe){return 63&(oe||0)})(S.dosPermissions)),_=Z.getUTCHours(),_<<=6,_|=Z.getUTCMinutes(),_<<=5,_|=Z.getUTCSeconds()/2,j=Z.getUTCFullYear()-1980,j<<=4,j|=Z.getUTCMonth()+1,j<<=5,j|=Z.getUTCDate(),D&&(X=i(1,1)+i(d(R),4)+z,$+="up"+i(X.length,2)+X),k&&(B=i(1,1)+i(d(q),4)+T,$+="uc"+i(B.length,2)+B);var se="";return se+=`
41
+ \0`,se+=i(H,2),se+=E.magic,se+=i(_,2),se+=i(j,2),se+=i(J.crc32,4),se+=i(J.compressedSize,4),se+=i(J.uncompressedSize,4),se+=i(R.length,2),se+=i($.length,2),{fileRecord:f.LOCAL_FILE_HEADER+se+R+$,dirRecord:f.CENTRAL_FILE_HEADER+i(ce,2)+se+i(q.length,2)+"\0\0\0\0"+i(W,4)+i(x,4)+R+$+q}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function m(h,v,g,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=v,this.zipPlatform=g,this.encodeFileName=x,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 v=h.meta.percent||0,g=this.entriesCount,x=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?(v+100*(g-x-1))/g:100}}))},m.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var v=this.streamFiles&&!h.file.dir;if(v){var g=a(h,v,!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 v=this.streamFiles&&!h.file.dir,g=a(h,v,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),v)this.push({data:(function(x){return f.DATA_DESCRIPTOR+i(x.crc32,4)+i(x.compressedSize,4)+i(x.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,v=0;v<this.dirRecords.length;v++)this.push({data:this.dirRecords[v],meta:{percent:100}});var g=this.bytesWritten-h,x=(function(b,y,_,j,S){var E=l.transformTo("string",S(j));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(b,2)+i(b,2)+i(y,4)+i(_,4)+i(E.length,2)+E})(this.dirRecords.length,g,h,this.zipComment,this.encodeFileName);this.push({data:x,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 v=this;return h.on("data",function(g){v.processChunk(g)}),h.on("end",function(){v.closedSource(v.previous.streamInfo),v._sources.length?v.prepareNextSource():v.end()}),h.on("error",function(g){v.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 v=this._sources;if(!c.prototype.error.call(this,h))return!1;for(var g=0;g<v.length;g++)try{v[g].error(h)}catch{}return!0},m.prototype.lock=function(){c.prototype.lock.call(this);for(var h=this._sources,v=0;v<h.length;v++)h[v].lock()},r.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,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 v=(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||{},x=h.dir,b=h.date;h._compressWorker(v,g).withStreamInfo("file",{name:m,dir:x,date:b,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,r,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"),r.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,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,v){var g=m.decompressed.getContentWorker().pipe(new u);g.on("error",function(x){v(x)}).on("end",function(){g.streamInfo.crc32!==m.decompressed.crc32?v(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}r.exports=function(m,h){var v=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 x=new c(h);return x.load(g),x}).then(function(g){var x=[a.Promise.resolve(g)],b=g.files;if(h.checkCRC32)for(var y=0;y<b.length;y++)x.push(f(b[y]));return a.Promise.all(x)}).then(function(g){for(var x=g.shift(),b=x.files,y=0;y<b.length;y++){var _=b[y],j=_.fileNameStr,S=i.resolve(_.fileNameStr);v.file(S,_.decompressed,{binary:!0,optimizedBinaryString:!0,date:_.date,dir:_.dir,comment:_.fileCommentStr.length?_.fileCommentStr:null,unixPermissions:_.unixPermissions,dosPermissions:_.dosPermissions,createFolders:h.createFolders}),_.dir||(v.file(S).unsafeOriginalName=j)}return x.zipComment.length&&(v.comment=x.zipComment),v})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,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)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,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()},r.exports=a},{"../utils":32,"readable-stream":16}],14:[function(n,r,o){r.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,r,o){function i(S,E,C){var R,z=l.getTypeOf(E),O=l.extend(C||{},d);O.date=O.date||new Date,O.compression!==null&&(O.compression=O.compression.toUpperCase()),typeof O.unixPermissions=="string"&&(O.unixPermissions=parseInt(O.unixPermissions,8)),O.unixPermissions&&16384&O.unixPermissions&&(O.dir=!0),O.dosPermissions&&16&O.dosPermissions&&(O.dir=!0),O.dir&&(S=b(S)),O.createFolders&&(R=x(S))&&y.call(this,R,!0);var q=z==="string"&&O.binary===!1&&O.base64===!1;C&&C.binary!==void 0||(O.binary=!q),(E instanceof f&&E.uncompressedSize===0||O.dir||!E||E.length===0)&&(O.base64=!1,O.binary=!0,E="",O.compression="STORE",z="string");var T=null;T=E instanceof f||E instanceof c?E:v.isNode&&v.isStream(E)?new g(S,E):l.prepareContent(S,E,O.binary,O.optimizedBinaryString,O.base64);var D=new m(S,T,O);this.files[S]=D}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"),v=n("./nodejsUtils"),g=n("./nodejs/NodejsStreamInputAdapter"),x=function(S){S.slice(-1)==="/"&&(S=S.substring(0,S.length-1));var E=S.lastIndexOf("/");return 0<E?S.substring(0,E):""},b=function(S){return S.slice(-1)!=="/"&&(S+="/"),S},y=function(S,E){return E=E!==void 0?E:d.createFolders,S=b(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,C,R;for(E in this.files)R=this.files[E],(C=E.slice(this.root.length,E.length))&&E.slice(0,this.root.length)===this.root&&S(C,R)},filter:function(S){var E=[];return this.forEach(function(C,R){S(C,R)&&E.push(R)}),E},file:function(S,E,C){if(arguments.length!==1)return S=this.root+S,i.call(this,S,E,C),this;if(_(S)){var R=S;return this.filter(function(O,q){return!q.dir&&R.test(O)})}var z=this.files[this.root+S];return z&&!z.dir?z:null},folder:function(S){if(!S)return this;if(_(S))return this.filter(function(z,O){return O.dir&&S.test(z)});var E=this.root+S,C=y.call(this,E),R=this.clone();return R.root=C.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 C=this.filter(function(z,O){return O.name.slice(0,S.length)===S}),R=0;R<C.length;R++)delete this.files[C[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,C={};try{if((C=l.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");l.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var R=C.comment||this.comment||"";E=h.generateWorker(this,C,R)}catch(z){(E=new c("error")).error(z)}return new u(E,C.type||"string",C.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)}};r.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,r,o){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,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},r.exports=a},{"../utils":32,"./DataReader":18}],18:[function(n,r,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))}},r.exports=a},{"../utils":32}],19:[function(n,r,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},r.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,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},r.exports=a},{"../utils":32,"./DataReader":18}],21:[function(n,r,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},r.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){var i=n("../utils"),a=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.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,r,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,r,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})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,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)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,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)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,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}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,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}},r.exports=i},{}],29:[function(n,r,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(v,g){return new d.Promise(function(x,b){var y=[],_=v._internalType,j=v._outputType,S=v._mimeType;v.on("data",function(E,C){y.push(E),g&&g(C)}).on("error",function(E){y=[],b(E)}).on("end",function(){try{var E=(function(C,R,z){switch(C){case"blob":return i.newBlob(i.transformTo("arraybuffer",R),z);case"base64":return c.encode(R);default:return i.transformTo(C,R)}})(j,(function(C,R){var z,O=0,q=null,T=0;for(z=0;z<R.length;z++)T+=R[z].length;switch(C){case"string":return R.join("");case"array":return Array.prototype.concat.apply([],R);case"uint8array":for(q=new Uint8Array(T),z=0;z<R.length;z++)q.set(R[z],O),O+=R[z].length;return q;case"nodebuffer":return Buffer.concat(R);default:throw new Error("concat : unsupported type '"+C+"'")}})(_,y),S);x(E)}catch(C){b(C)}y=[]}).resume()})}function h(v,g,x){var b=g;switch(g){case"blob":case"arraybuffer":b="uint8array";break;case"base64":b="string"}try{this._internalType=b,this._outputType=g,this._mimeType=x,i.checkSupport(b),this._worker=v.pipe(new a(b)),v.lock()}catch(y){this._worker=new l("error"),this._worker.error(y)}}h.prototype={accumulate:function(v){return m(this,v)},on:function(v,g){var x=this;return v==="data"?this._worker.on(v,function(b){g.call(x,b.data,b.meta)}):this._worker.on(v,function(){i.delay(g,arguments,x)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(v){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"},v)}},r.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,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,r,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(v){var g,x,b,y,_,j=v.length,S=0;for(y=0;y<j;y++)(64512&(x=v.charCodeAt(y)))==55296&&y+1<j&&(64512&(b=v.charCodeAt(y+1)))==56320&&(x=65536+(x-55296<<10)+(b-56320),y++),S+=x<128?1:x<2048?2:x<65536?3:4;for(g=a.uint8array?new Uint8Array(S):new Array(S),y=_=0;_<S;y++)(64512&(x=v.charCodeAt(y)))==55296&&y+1<j&&(64512&(b=v.charCodeAt(y+1)))==56320&&(x=65536+(x-55296<<10)+(b-56320),y++),x<128?g[_++]=x:(x<2048?g[_++]=192|x>>>6:(x<65536?g[_++]=224|x>>>12:(g[_++]=240|x>>>18,g[_++]=128|x>>>12&63),g[_++]=128|x>>>6&63),g[_++]=128|63&x);return g})(h)},o.utf8decode=function(h){return a.nodebuffer?i.transformTo("nodebuffer",h).toString("utf-8"):(function(v){var g,x,b,y,_=v.length,j=new Array(2*_);for(g=x=0;g<_;)if((b=v[g++])<128)j[x++]=b;else if(4<(y=u[b]))j[x++]=65533,g+=y-1;else{for(b&=y===2?31:y===3?15:7;1<y&&g<_;)b=b<<6|63&v[g++],y--;1<y?j[x++]=65533:b<65536?j[x++]=b:(b-=65536,j[x++]=55296|b>>10&1023,j[x++]=56320|1023&b)}return j.length!==x&&(j.subarray?j=j.subarray(0,x):j.length=x),i.applyFromCharCode(j)})(h=i.transformTo(a.uint8array?"uint8array":"array",h))},i.inherits(f,c),f.prototype.processChunk=function(h){var v=i.transformTo(a.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var g=v;(v=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),v.set(g,this.leftOver.length)}else v=this.leftOver.concat(v);this.leftOver=null}var x=(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:_})(v),b=v;x!==v.length&&(a.uint8array?(b=v.subarray(0,x),this.leftOver=v.subarray(x,v.length)):(b=v.slice(0,x),this.leftOver=v.slice(x,v.length))),this.push({data:o.utf8decode(b),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,r,o){var i=n("./support"),a=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(g){return g}function d(g,x){for(var b=0;b<g.length;++b)x[b]=255&g.charCodeAt(b);return x}n("setimmediate"),o.newBlob=function(g,x){o.checkSupport("blob");try{return new Blob([g],{type:x})}catch{try{var b=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return b.append(g),b.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(g,x,b){var y=[],_=0,j=g.length;if(j<=b)return String.fromCharCode.apply(null,g);for(;_<j;)x==="array"||x==="nodebuffer"?y.push(String.fromCharCode.apply(null,g.slice(_,Math.min(_+b,j)))):y.push(String.fromCharCode.apply(null,g.subarray(_,Math.min(_+b,j)))),_+=b;return y.join("")},stringifyByChar:function(g){for(var x="",b=0;b<g.length;b++)x+=String.fromCharCode(g[b]);return x},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 x=65536,b=o.getTypeOf(g),y=!0;if(b==="uint8array"?y=f.applyCanBeUsed.uint8array:b==="nodebuffer"&&(y=f.applyCanBeUsed.nodebuffer),y)for(;1<x;)try{return f.stringifyByChunk(g,b,x)}catch{x=Math.floor(x/2)}return f.stringifyByChar(g)}function h(g,x){for(var b=0;b<g.length;b++)x[b]=g[b];return x}o.applyFromCharCode=m;var v={};v.string={string:u,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return v.string.uint8array(g).buffer},uint8array:function(g){return d(g,new Uint8Array(g.length))},nodebuffer:function(g){return d(g,l.allocBuffer(g.length))}},v.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)}},v.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))}},v.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)}},v.nodebuffer={string:m,array:function(g){return h(g,new Array(g.length))},arraybuffer:function(g){return v.nodebuffer.uint8array(g).buffer},uint8array:function(g){return h(g,new Uint8Array(g.length))},nodebuffer:u},o.transformTo=function(g,x){if(x=x||"",!g)return x;o.checkSupport(g);var b=o.getTypeOf(x);return v[b][g](x)},o.resolve=function(g){for(var x=g.split("/"),b=[],y=0;y<x.length;y++){var _=x[y];_==="."||_===""&&y!==0&&y!==x.length-1||(_===".."?b.pop():b.push(_))}return b.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 x,b,y="";for(b=0;b<(g||"").length;b++)y+="\\x"+((x=g.charCodeAt(b))<16?"0":"")+x.toString(16).toUpperCase();return y},o.delay=function(g,x,b){setImmediate(function(){g.apply(b||null,x||[])})},o.inherits=function(g,x){function b(){}b.prototype=x.prototype,g.prototype=new b},o.extend=function(){var g,x,b={};for(g=0;g<arguments.length;g++)for(x in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],x)&&b[x]===void 0&&(b[x]=arguments[g][x]);return b},o.prepareContent=function(g,x,b,y,_){return c.Promise.resolve(x).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 C=new FileReader;C.onload=function(R){S(R.target.result)},C.onerror=function(R){E(R.target.error)},C.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):b&&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,r,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 v=this.reader.readString(4)===m;return this.reader.setIndex(h),v},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,v=this.zip64EndOfCentralSize-44;0<v;)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 v=m-h;if(0<v)this.isSignature(m,l.CENTRAL_FILE_HEADER)||(this.reader.zero=v);else if(v<0)throw new Error("Corrupted zip: missing "+Math.abs(v)+" bytes.")},prepareReader:function(f){this.reader=i(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,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,v){this.options=h,this.loadOptions=v}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var v,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((v=(function(x){for(var b in d)if(Object.prototype.hasOwnProperty.call(d,b)&&d[b].magic===x)return d[b];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,v,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 v=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(v),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 v,g,x,b=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<b;)v=h.readInt(2),g=h.readInt(2),x=h.readData(g),this.extraFields[v]={id:v,length:g,value:x};h.setIndex(b)},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 v=this.findExtraFieldUnicodePath();if(v!==null)this.fileNameStr=v;else{var g=a.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var b=a.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(b)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var v=i(h.value);return v.readInt(1)!==1||c(this.fileName)!==v.readInt(4)?null:u.utf8decode(v.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var v=i(h.value);return v.readInt(1)!==1||c(this.fileComment)!==v.readInt(4)?null:u.utf8decode(v.readData(h.length-5))}return null}},r.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,o){function i(v,g,x){this.name=v,this.dir=x.dir,this.date=x.date,this.comment=x.comment,this.unixPermissions=x.unixPermissions,this.dosPermissions=x.dosPermissions,this._data=g,this._dataBinary=x.binary,this.options={compression:x.compression,compressionOptions:x.compressionOptions}}var a=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");i.prototype={internalStream:function(v){var g=null,x="string";try{if(!v)throw new Error("No output type specified.");var b=(x=v.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),g=this._decompressWorker();var y=!this._dataBinary;y&&!b&&(g=g.pipe(new c.Utf8EncodeWorker)),!y&&b&&(g=g.pipe(new c.Utf8DecodeWorker))}catch(_){(g=new d("error")).error(_)}return new a(g,x,"")},async:function(v,g){return this.internalStream(v).accumulate(g)},nodeStream:function(v,g){return this.internalStream(v||"nodebuffer").toNodejsStream(g)},_compressWorker:function(v,g){if(this._data instanceof u&&this._data.compression.magic===v.magic)return this._data.getCompressedWorker();var x=this._decompressWorker();return this._dataBinary||(x=x.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(x,v,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;r.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,o){(function(i){var a,l,c=i.MutationObserver||i.WebKitMutationObserver;if(c){var u=0,d=new c(v),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(){v(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},i.document.documentElement.appendChild(g)}:function(){setTimeout(v,0)};else{var m=new i.MessageChannel;m.port1.onmessage=v,a=function(){m.port2.postMessage(0)}}var h=[];function v(){var g,x;l=!0;for(var b=h.length;b;){for(x=h,h=[],g=-1;++g<b;)x[g]();b=h.length}l=!1}r.exports=function(g){h.push(g)!==1||l||a()}}).call(this,typeof es<"u"?es:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,o){var i=n("immediate");function a(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(b){if(typeof b!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,b!==a&&g(this,b)}function m(b,y,_){this.promise=b,typeof y=="function"&&(this.onFulfilled=y,this.callFulfilled=this.otherCallFulfilled),typeof _=="function"&&(this.onRejected=_,this.callRejected=this.otherCallRejected)}function h(b,y,_){i(function(){var j;try{j=y(_)}catch(S){return l.reject(b,S)}j===b?l.reject(b,new TypeError("Cannot resolve promise with itself")):l.resolve(b,j)})}function v(b){var y=b&&b.then;if(b&&(typeof b=="object"||typeof b=="function")&&typeof y=="function")return function(){y.apply(b,arguments)}}function g(b,y){var _=!1;function j(C){_||(_=!0,l.reject(b,C))}function S(C){_||(_=!0,l.resolve(b,C))}var E=x(function(){y(S,j)});E.status==="error"&&j(E.value)}function x(b,y){var _={};try{_.value=b(y),_.status="success"}catch(j){_.status="error",_.value=j}return _}(r.exports=f).prototype.finally=function(b){if(typeof b!="function")return this;var y=this.constructor;return this.then(function(_){return y.resolve(b()).then(function(){return _})},function(_){return y.resolve(b()).then(function(){throw _})})},f.prototype.catch=function(b){return this.then(null,b)},f.prototype.then=function(b,y){if(typeof b!="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?b:y,this.outcome):this.queue.push(new m(_,b,y)),_},m.prototype.callFulfilled=function(b){l.resolve(this.promise,b)},m.prototype.otherCallFulfilled=function(b){h(this.promise,this.onFulfilled,b)},m.prototype.callRejected=function(b){l.reject(this.promise,b)},m.prototype.otherCallRejected=function(b){h(this.promise,this.onRejected,b)},l.resolve=function(b,y){var _=x(v,y);if(_.status==="error")return l.reject(b,_.value);var j=_.value;if(j)g(b,j);else{b.state=u,b.outcome=y;for(var S=-1,E=b.queue.length;++S<E;)b.queue[S].callFulfilled(y)}return b},l.reject=function(b,y){b.state=c,b.outcome=y;for(var _=-1,j=b.queue.length;++_<j;)b.queue[_].callRejected(y);return b},f.resolve=function(b){return b instanceof this?b:l.resolve(new this(a),b)},f.reject=function(b){var y=new this(a);return l.reject(y,b)},f.all=function(b){var y=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var _=b.length,j=!1;if(!_)return this.resolve([]);for(var S=new Array(_),E=0,C=-1,R=new this(a);++C<_;)z(b[C],C);return R;function z(O,q){y.resolve(O).then(function(T){S[q]=T,++E!==_||j||(j=!0,l.resolve(R,S))},function(T){j||(j=!0,l.reject(R,T))})}},f.race=function(b){var y=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var _=b.length,j=!1;if(!_)return this.resolve([]);for(var S=-1,E=new this(a);++S<_;)C=b[S],y.resolve(C).then(function(R){j||(j=!0,l.resolve(E,R))},function(R){j||(j=!0,l.reject(E,R))});var C;return E}},{immediate:36}],38:[function(n,r,o){var i={};(0,n("./lib/utils/common").assign)(i,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,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,v=8;function g(b){if(!(this instanceof g))return new g(b);this.options=a.assign({level:m,method:v,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},b||{});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 x(b,y){var _=new g(y);if(_.push(b,!0),_.err)throw _.msg||c[_.err];return _.result}g.prototype.push=function(b,y){var _,j,S=this.strm,E=this.options.chunkSize;if(this.ended)return!1;j=y===~~y?y:y===!0?4:0,typeof b=="string"?S.input=l.string2buf(b):d.call(b)==="[object ArrayBuffer]"?S.input=new Uint8Array(b):S.input=b,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(b){this.chunks.push(b)},g.prototype.onEnd=function(b){b===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},o.Deflate=g,o.deflate=x,o.deflateRaw=function(b,y){return(y=y||{}).raw=!0,x(b,y)},o.gzip=function(b,y){return(y=y||{}).gzip=!0,x(b,y)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,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 x=this.options;x.raw&&0<=x.windowBits&&x.windowBits<16&&(x.windowBits=-x.windowBits,x.windowBits===0&&(x.windowBits=-15)),!(0<=x.windowBits&&x.windowBits<16)||g&&g.windowBits||(x.windowBits+=32),15<x.windowBits&&x.windowBits<48&&(15&x.windowBits)==0&&(x.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var b=i.inflateInit2(this.strm,x.windowBits);if(b!==c.Z_OK)throw new Error(u[b]);this.header=new f,i.inflateGetHeader(this.strm,this.header)}function v(g,x){var b=new h(x);if(b.push(g,!0),b.err)throw b.msg||u[b.err];return b.result}h.prototype.push=function(g,x){var b,y,_,j,S,E,C=this.strm,R=this.options.chunkSize,z=this.options.dictionary,O=!1;if(this.ended)return!1;y=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof g=="string"?C.input=l.binstring2buf(g):m.call(g)==="[object ArrayBuffer]"?C.input=new Uint8Array(g):C.input=g,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new a.Buf8(R),C.next_out=0,C.avail_out=R),(b=i.inflate(C,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&z&&(E=typeof z=="string"?l.string2buf(z):m.call(z)==="[object ArrayBuffer]"?new Uint8Array(z):z,b=i.inflateSetDictionary(this.strm,E)),b===c.Z_BUF_ERROR&&O===!0&&(b=c.Z_OK,O=!1),b!==c.Z_STREAM_END&&b!==c.Z_OK)return this.onEnd(b),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&b!==c.Z_STREAM_END&&(C.avail_in!==0||y!==c.Z_FINISH&&y!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(_=l.utf8border(C.output,C.next_out),j=C.next_out-_,S=l.buf2string(C.output,_),C.next_out=j,C.avail_out=R-j,j&&a.arraySet(C.output,C.output,_,j,0),this.onData(S)):this.onData(a.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(O=!0)}while((0<C.avail_in||C.avail_out===0)&&b!==c.Z_STREAM_END);return b===c.Z_STREAM_END&&(y=c.Z_FINISH),y===c.Z_FINISH?(b=i.inflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===c.Z_OK):y!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(C.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=v,o.inflateRaw=function(g,x){return(x=x||{}).raw=!0,v(g,x)},o.ungzip=v},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,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,v;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(v=new Uint8Array(f),u=m=0,d=c.length;u<d;u++)h=c[u],v.set(h,m),m+=h.length;return v}},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,r,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="",v=0;v<m;v++)h+=String.fromCharCode(f[v]);return h}c[254]=c[254]=1,o.string2buf=function(f){var m,h,v,g,x,b=f.length,y=0;for(g=0;g<b;g++)(64512&(h=f.charCodeAt(g)))==55296&&g+1<b&&(64512&(v=f.charCodeAt(g+1)))==56320&&(h=65536+(h-55296<<10)+(v-56320),g++),y+=h<128?1:h<2048?2:h<65536?3:4;for(m=new i.Buf8(y),g=x=0;x<y;g++)(64512&(h=f.charCodeAt(g)))==55296&&g+1<b&&(64512&(v=f.charCodeAt(g+1)))==56320&&(h=65536+(h-55296<<10)+(v-56320),g++),h<128?m[x++]=h:(h<2048?m[x++]=192|h>>>6:(h<65536?m[x++]=224|h>>>12:(m[x++]=240|h>>>18,m[x++]=128|h>>>12&63),m[x++]=128|h>>>6&63),m[x++]=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,v=m.length;h<v;h++)m[h]=f.charCodeAt(h);return m},o.buf2string=function(f,m){var h,v,g,x,b=m||f.length,y=new Array(2*b);for(h=v=0;h<b;)if((g=f[h++])<128)y[v++]=g;else if(4<(x=c[g]))y[v++]=65533,h+=x-1;else{for(g&=x===2?31:x===3?15:7;1<x&&h<b;)g=g<<6|63&f[h++],x--;1<x?y[v++]=65533:g<65536?y[v++]=g:(g-=65536,y[v++]=55296|g>>10&1023,y[v++]=56320|1023&g)}return d(y,v)},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,r,o){r.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,r,o){r.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,r,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})();r.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,r,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,v=-2,g=-1,x=4,b=2,y=8,_=9,j=286,S=30,E=19,C=2*j+1,R=15,z=3,O=258,q=O+z+1,T=42,D=113,k=1,$=2,X=3,B=4;function F(w,Y){return w.msg=d[Y],Y}function Z(w){return(w<<1)-(4<w?9:0)}function J(w){for(var Y=w.length;0<=--Y;)w[Y]=0}function H(w){var Y=w.state,U=Y.pending;U>w.avail_out&&(U=w.avail_out),U!==0&&(a.arraySet(w.output,Y.pending_buf,Y.pending_out,U,w.next_out),w.next_out+=U,Y.pending_out+=U,w.total_out+=U,w.avail_out-=U,Y.pending-=U,Y.pending===0&&(Y.pending_out=0))}function W(w,Y){l._tr_flush_block(w,0<=w.block_start?w.block_start:-1,w.strstart-w.block_start,Y),w.block_start=w.strstart,H(w.strm)}function ce(w,Y){w.pending_buf[w.pending++]=Y}function se(w,Y){w.pending_buf[w.pending++]=Y>>>8&255,w.pending_buf[w.pending++]=255&Y}function oe(w,Y){var U,I,A=w.max_chain_length,L=w.strstart,ne=w.prev_length,re=w.nice_match,V=w.strstart>w.w_size-q?w.strstart-(w.w_size-q):0,ae=w.window,P=w.w_mask,M=w.prev,Q=w.strstart+O,fe=ae[L+ne-1],de=ae[L+ne];w.prev_length>=w.good_match&&(A>>=2),re>w.lookahead&&(re=w.lookahead);do if(ae[(U=Y)+ne]===de&&ae[U+ne-1]===fe&&ae[U]===ae[L]&&ae[++U]===ae[L+1]){L+=2,U++;do;while(ae[++L]===ae[++U]&&ae[++L]===ae[++U]&&ae[++L]===ae[++U]&&ae[++L]===ae[++U]&&ae[++L]===ae[++U]&&ae[++L]===ae[++U]&&ae[++L]===ae[++U]&&ae[++L]===ae[++U]&&L<Q);if(I=O-(Q-L),L=Q-O,ne<I){if(w.match_start=Y,re<=(ne=I))break;fe=ae[L+ne-1],de=ae[L+ne]}}while((Y=M[Y&P])>V&&--A!=0);return ne<=w.lookahead?ne:w.lookahead}function _e(w){var Y,U,I,A,L,ne,re,V,ae,P,M=w.w_size;do{if(A=w.window_size-w.lookahead-w.strstart,w.strstart>=M+(M-q)){for(a.arraySet(w.window,w.window,M,M,0),w.match_start-=M,w.strstart-=M,w.block_start-=M,Y=U=w.hash_size;I=w.head[--Y],w.head[Y]=M<=I?I-M:0,--U;);for(Y=U=M;I=w.prev[--Y],w.prev[Y]=M<=I?I-M:0,--U;);A+=M}if(w.strm.avail_in===0)break;if(ne=w.strm,re=w.window,V=w.strstart+w.lookahead,ae=A,P=void 0,P=ne.avail_in,ae<P&&(P=ae),U=P===0?0:(ne.avail_in-=P,a.arraySet(re,ne.input,ne.next_in,P,V),ne.state.wrap===1?ne.adler=c(ne.adler,re,P,V):ne.state.wrap===2&&(ne.adler=u(ne.adler,re,P,V)),ne.next_in+=P,ne.total_in+=P,P),w.lookahead+=U,w.lookahead+w.insert>=z)for(L=w.strstart-w.insert,w.ins_h=w.window[L],w.ins_h=(w.ins_h<<w.hash_shift^w.window[L+1])&w.hash_mask;w.insert&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[L+z-1])&w.hash_mask,w.prev[L&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=L,L++,w.insert--,!(w.lookahead+w.insert<z)););}while(w.lookahead<q&&w.strm.avail_in!==0)}function ie(w,Y){for(var U,I;;){if(w.lookahead<q){if(_e(w),w.lookahead<q&&Y===f)return k;if(w.lookahead===0)break}if(U=0,w.lookahead>=z&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+z-1])&w.hash_mask,U=w.prev[w.strstart&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=w.strstart),U!==0&&w.strstart-U<=w.w_size-q&&(w.match_length=oe(w,U)),w.match_length>=z)if(I=l._tr_tally(w,w.strstart-w.match_start,w.match_length-z),w.lookahead-=w.match_length,w.match_length<=w.max_lazy_match&&w.lookahead>=z){for(w.match_length--;w.strstart++,w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+z-1])&w.hash_mask,U=w.prev[w.strstart&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=w.strstart,--w.match_length!=0;);w.strstart++}else w.strstart+=w.match_length,w.match_length=0,w.ins_h=w.window[w.strstart],w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+1])&w.hash_mask;else I=l._tr_tally(w,0,w.window[w.strstart]),w.lookahead--,w.strstart++;if(I&&(W(w,!1),w.strm.avail_out===0))return k}return w.insert=w.strstart<z-1?w.strstart:z-1,Y===m?(W(w,!0),w.strm.avail_out===0?X:B):w.last_lit&&(W(w,!1),w.strm.avail_out===0)?k:$}function ge(w,Y){for(var U,I,A;;){if(w.lookahead<q){if(_e(w),w.lookahead<q&&Y===f)return k;if(w.lookahead===0)break}if(U=0,w.lookahead>=z&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+z-1])&w.hash_mask,U=w.prev[w.strstart&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=w.strstart),w.prev_length=w.match_length,w.prev_match=w.match_start,w.match_length=z-1,U!==0&&w.prev_length<w.max_lazy_match&&w.strstart-U<=w.w_size-q&&(w.match_length=oe(w,U),w.match_length<=5&&(w.strategy===1||w.match_length===z&&4096<w.strstart-w.match_start)&&(w.match_length=z-1)),w.prev_length>=z&&w.match_length<=w.prev_length){for(A=w.strstart+w.lookahead-z,I=l._tr_tally(w,w.strstart-1-w.prev_match,w.prev_length-z),w.lookahead-=w.prev_length-1,w.prev_length-=2;++w.strstart<=A&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+z-1])&w.hash_mask,U=w.prev[w.strstart&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=w.strstart),--w.prev_length!=0;);if(w.match_available=0,w.match_length=z-1,w.strstart++,I&&(W(w,!1),w.strm.avail_out===0))return k}else if(w.match_available){if((I=l._tr_tally(w,0,w.window[w.strstart-1]))&&W(w,!1),w.strstart++,w.lookahead--,w.strm.avail_out===0)return k}else w.match_available=1,w.strstart++,w.lookahead--}return w.match_available&&(I=l._tr_tally(w,0,w.window[w.strstart-1]),w.match_available=0),w.insert=w.strstart<z-1?w.strstart:z-1,Y===m?(W(w,!0),w.strm.avail_out===0?X:B):w.last_lit&&(W(w,!1),w.strm.avail_out===0)?k:$}function he(w,Y,U,I,A){this.good_length=w,this.max_lazy=Y,this.nice_length=U,this.max_chain=I,this.func=A}function xe(){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*C),this.dyn_dtree=new a.Buf16(2*(2*S+1)),this.bl_tree=new a.Buf16(2*(2*E+1)),J(this.dyn_ltree),J(this.dyn_dtree),J(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),J(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*j+1),J(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 te(w){var Y;return w&&w.state?(w.total_in=w.total_out=0,w.data_type=b,(Y=w.state).pending=0,Y.pending_out=0,Y.wrap<0&&(Y.wrap=-Y.wrap),Y.status=Y.wrap?T:D,w.adler=Y.wrap===2?0:1,Y.last_flush=f,l._tr_init(Y),h):F(w,v)}function ue(w){var Y=te(w);return Y===h&&(function(U){U.window_size=2*U.w_size,J(U.head),U.max_lazy_match=i[U.level].max_lazy,U.good_match=i[U.level].good_length,U.nice_match=i[U.level].nice_length,U.max_chain_length=i[U.level].max_chain,U.strstart=0,U.block_start=0,U.lookahead=0,U.insert=0,U.match_length=U.prev_length=z-1,U.match_available=0,U.ins_h=0})(w.state),Y}function be(w,Y,U,I,A,L){if(!w)return v;var ne=1;if(Y===g&&(Y=6),I<0?(ne=0,I=-I):15<I&&(ne=2,I-=16),A<1||_<A||U!==y||I<8||15<I||Y<0||9<Y||L<0||x<L)return F(w,v);I===8&&(I=9);var re=new xe;return(w.state=re).strm=w,re.wrap=ne,re.gzhead=null,re.w_bits=I,re.w_size=1<<re.w_bits,re.w_mask=re.w_size-1,re.hash_bits=A+7,re.hash_size=1<<re.hash_bits,re.hash_mask=re.hash_size-1,re.hash_shift=~~((re.hash_bits+z-1)/z),re.window=new a.Buf8(2*re.w_size),re.head=new a.Buf16(re.hash_size),re.prev=new a.Buf16(re.w_size),re.lit_bufsize=1<<A+6,re.pending_buf_size=4*re.lit_bufsize,re.pending_buf=new a.Buf8(re.pending_buf_size),re.d_buf=1*re.lit_bufsize,re.l_buf=3*re.lit_bufsize,re.level=Y,re.strategy=L,re.method=U,ue(w)}i=[new he(0,0,0,0,function(w,Y){var U=65535;for(U>w.pending_buf_size-5&&(U=w.pending_buf_size-5);;){if(w.lookahead<=1){if(_e(w),w.lookahead===0&&Y===f)return k;if(w.lookahead===0)break}w.strstart+=w.lookahead,w.lookahead=0;var I=w.block_start+U;if((w.strstart===0||w.strstart>=I)&&(w.lookahead=w.strstart-I,w.strstart=I,W(w,!1),w.strm.avail_out===0)||w.strstart-w.block_start>=w.w_size-q&&(W(w,!1),w.strm.avail_out===0))return k}return w.insert=0,Y===m?(W(w,!0),w.strm.avail_out===0?X:B):(w.strstart>w.block_start&&(W(w,!1),w.strm.avail_out),k)}),new he(4,4,8,4,ie),new he(4,5,16,8,ie),new he(4,6,32,32,ie),new he(4,4,16,16,ge),new he(8,16,32,32,ge),new he(8,16,128,128,ge),new he(8,32,128,256,ge),new he(32,128,258,1024,ge),new he(32,258,258,4096,ge)],o.deflateInit=function(w,Y){return be(w,Y,y,15,8,0)},o.deflateInit2=be,o.deflateReset=ue,o.deflateResetKeep=te,o.deflateSetHeader=function(w,Y){return w&&w.state?w.state.wrap!==2?v:(w.state.gzhead=Y,h):v},o.deflate=function(w,Y){var U,I,A,L;if(!w||!w.state||5<Y||Y<0)return w?F(w,v):v;if(I=w.state,!w.output||!w.input&&w.avail_in!==0||I.status===666&&Y!==m)return F(w,w.avail_out===0?-5:v);if(I.strm=w,U=I.last_flush,I.last_flush=Y,I.status===T)if(I.wrap===2)w.adler=0,ce(I,31),ce(I,139),ce(I,8),I.gzhead?(ce(I,(I.gzhead.text?1:0)+(I.gzhead.hcrc?2:0)+(I.gzhead.extra?4:0)+(I.gzhead.name?8:0)+(I.gzhead.comment?16:0)),ce(I,255&I.gzhead.time),ce(I,I.gzhead.time>>8&255),ce(I,I.gzhead.time>>16&255),ce(I,I.gzhead.time>>24&255),ce(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),ce(I,255&I.gzhead.os),I.gzhead.extra&&I.gzhead.extra.length&&(ce(I,255&I.gzhead.extra.length),ce(I,I.gzhead.extra.length>>8&255)),I.gzhead.hcrc&&(w.adler=u(w.adler,I.pending_buf,I.pending,0)),I.gzindex=0,I.status=69):(ce(I,0),ce(I,0),ce(I,0),ce(I,0),ce(I,0),ce(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),ce(I,3),I.status=D);else{var ne=y+(I.w_bits-8<<4)<<8;ne|=(2<=I.strategy||I.level<2?0:I.level<6?1:I.level===6?2:3)<<6,I.strstart!==0&&(ne|=32),ne+=31-ne%31,I.status=D,se(I,ne),I.strstart!==0&&(se(I,w.adler>>>16),se(I,65535&w.adler)),w.adler=1}if(I.status===69)if(I.gzhead.extra){for(A=I.pending;I.gzindex<(65535&I.gzhead.extra.length)&&(I.pending!==I.pending_buf_size||(I.gzhead.hcrc&&I.pending>A&&(w.adler=u(w.adler,I.pending_buf,I.pending-A,A)),H(w),A=I.pending,I.pending!==I.pending_buf_size));)ce(I,255&I.gzhead.extra[I.gzindex]),I.gzindex++;I.gzhead.hcrc&&I.pending>A&&(w.adler=u(w.adler,I.pending_buf,I.pending-A,A)),I.gzindex===I.gzhead.extra.length&&(I.gzindex=0,I.status=73)}else I.status=73;if(I.status===73)if(I.gzhead.name){A=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>A&&(w.adler=u(w.adler,I.pending_buf,I.pending-A,A)),H(w),A=I.pending,I.pending===I.pending_buf_size)){L=1;break}L=I.gzindex<I.gzhead.name.length?255&I.gzhead.name.charCodeAt(I.gzindex++):0,ce(I,L)}while(L!==0);I.gzhead.hcrc&&I.pending>A&&(w.adler=u(w.adler,I.pending_buf,I.pending-A,A)),L===0&&(I.gzindex=0,I.status=91)}else I.status=91;if(I.status===91)if(I.gzhead.comment){A=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>A&&(w.adler=u(w.adler,I.pending_buf,I.pending-A,A)),H(w),A=I.pending,I.pending===I.pending_buf_size)){L=1;break}L=I.gzindex<I.gzhead.comment.length?255&I.gzhead.comment.charCodeAt(I.gzindex++):0,ce(I,L)}while(L!==0);I.gzhead.hcrc&&I.pending>A&&(w.adler=u(w.adler,I.pending_buf,I.pending-A,A)),L===0&&(I.status=103)}else I.status=103;if(I.status===103&&(I.gzhead.hcrc?(I.pending+2>I.pending_buf_size&&H(w),I.pending+2<=I.pending_buf_size&&(ce(I,255&w.adler),ce(I,w.adler>>8&255),w.adler=0,I.status=D)):I.status=D),I.pending!==0){if(H(w),w.avail_out===0)return I.last_flush=-1,h}else if(w.avail_in===0&&Z(Y)<=Z(U)&&Y!==m)return F(w,-5);if(I.status===666&&w.avail_in!==0)return F(w,-5);if(w.avail_in!==0||I.lookahead!==0||Y!==f&&I.status!==666){var re=I.strategy===2?(function(V,ae){for(var P;;){if(V.lookahead===0&&(_e(V),V.lookahead===0)){if(ae===f)return k;break}if(V.match_length=0,P=l._tr_tally(V,0,V.window[V.strstart]),V.lookahead--,V.strstart++,P&&(W(V,!1),V.strm.avail_out===0))return k}return V.insert=0,ae===m?(W(V,!0),V.strm.avail_out===0?X:B):V.last_lit&&(W(V,!1),V.strm.avail_out===0)?k:$})(I,Y):I.strategy===3?(function(V,ae){for(var P,M,Q,fe,de=V.window;;){if(V.lookahead<=O){if(_e(V),V.lookahead<=O&&ae===f)return k;if(V.lookahead===0)break}if(V.match_length=0,V.lookahead>=z&&0<V.strstart&&(M=de[Q=V.strstart-1])===de[++Q]&&M===de[++Q]&&M===de[++Q]){fe=V.strstart+O;do;while(M===de[++Q]&&M===de[++Q]&&M===de[++Q]&&M===de[++Q]&&M===de[++Q]&&M===de[++Q]&&M===de[++Q]&&M===de[++Q]&&Q<fe);V.match_length=O-(fe-Q),V.match_length>V.lookahead&&(V.match_length=V.lookahead)}if(V.match_length>=z?(P=l._tr_tally(V,1,V.match_length-z),V.lookahead-=V.match_length,V.strstart+=V.match_length,V.match_length=0):(P=l._tr_tally(V,0,V.window[V.strstart]),V.lookahead--,V.strstart++),P&&(W(V,!1),V.strm.avail_out===0))return k}return V.insert=0,ae===m?(W(V,!0),V.strm.avail_out===0?X:B):V.last_lit&&(W(V,!1),V.strm.avail_out===0)?k:$})(I,Y):i[I.level].func(I,Y);if(re!==X&&re!==B||(I.status=666),re===k||re===X)return w.avail_out===0&&(I.last_flush=-1),h;if(re===$&&(Y===1?l._tr_align(I):Y!==5&&(l._tr_stored_block(I,0,0,!1),Y===3&&(J(I.head),I.lookahead===0&&(I.strstart=0,I.block_start=0,I.insert=0))),H(w),w.avail_out===0))return I.last_flush=-1,h}return Y!==m?h:I.wrap<=0?1:(I.wrap===2?(ce(I,255&w.adler),ce(I,w.adler>>8&255),ce(I,w.adler>>16&255),ce(I,w.adler>>24&255),ce(I,255&w.total_in),ce(I,w.total_in>>8&255),ce(I,w.total_in>>16&255),ce(I,w.total_in>>24&255)):(se(I,w.adler>>>16),se(I,65535&w.adler)),H(w),0<I.wrap&&(I.wrap=-I.wrap),I.pending!==0?h:1)},o.deflateEnd=function(w){var Y;return w&&w.state?(Y=w.state.status)!==T&&Y!==69&&Y!==73&&Y!==91&&Y!==103&&Y!==D&&Y!==666?F(w,v):(w.state=null,Y===D?F(w,-3):h):v},o.deflateSetDictionary=function(w,Y){var U,I,A,L,ne,re,V,ae,P=Y.length;if(!w||!w.state||(L=(U=w.state).wrap)===2||L===1&&U.status!==T||U.lookahead)return v;for(L===1&&(w.adler=c(w.adler,Y,P,0)),U.wrap=0,P>=U.w_size&&(L===0&&(J(U.head),U.strstart=0,U.block_start=0,U.insert=0),ae=new a.Buf8(U.w_size),a.arraySet(ae,Y,P-U.w_size,U.w_size,0),Y=ae,P=U.w_size),ne=w.avail_in,re=w.next_in,V=w.input,w.avail_in=P,w.next_in=0,w.input=Y,_e(U);U.lookahead>=z;){for(I=U.strstart,A=U.lookahead-(z-1);U.ins_h=(U.ins_h<<U.hash_shift^U.window[I+z-1])&U.hash_mask,U.prev[I&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=I,I++,--A;);U.strstart=I,U.lookahead=z-1,_e(U)}return U.strstart+=U.lookahead,U.block_start=U.strstart,U.insert=U.lookahead,U.lookahead=0,U.match_length=U.prev_length=z-1,U.match_available=0,w.next_in=re,w.input=V,w.avail_in=ne,U.wrap=L,h},o.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,o){r.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,r,o){r.exports=function(i,a){var l,c,u,d,f,m,h,v,g,x,b,y,_,j,S,E,C,R,z,O,q,T,D,k,$;l=i.state,c=i.next_in,k=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,v=l.wsize,g=l.whave,x=l.wnext,b=l.window,y=l.hold,_=l.bits,j=l.lencode,S=l.distcode,E=(1<<l.lenbits)-1,C=(1<<l.distbits)-1;e:do{_<15&&(y+=k[c++]<<_,_+=8,y+=k[c++]<<_,_+=8),R=j[y&E];t:for(;;){if(y>>>=z=R>>>24,_-=z,(z=R>>>16&255)===0)$[d++]=65535&R;else{if(!(16&z)){if((64&z)==0){R=j[(65535&R)+(y&(1<<z)-1)];continue t}if(32&z){l.mode=12;break e}i.msg="invalid literal/length code",l.mode=30;break e}O=65535&R,(z&=15)&&(_<z&&(y+=k[c++]<<_,_+=8),O+=y&(1<<z)-1,y>>>=z,_-=z),_<15&&(y+=k[c++]<<_,_+=8,y+=k[c++]<<_,_+=8),R=S[y&C];n:for(;;){if(y>>>=z=R>>>24,_-=z,!(16&(z=R>>>16&255))){if((64&z)==0){R=S[(65535&R)+(y&(1<<z)-1)];continue n}i.msg="invalid distance code",l.mode=30;break e}if(q=65535&R,_<(z&=15)&&(y+=k[c++]<<_,(_+=8)<z&&(y+=k[c++]<<_,_+=8)),h<(q+=y&(1<<z)-1)){i.msg="invalid distance too far back",l.mode=30;break e}if(y>>>=z,_-=z,(z=d-f)<q){if(g<(z=q-z)&&l.sane){i.msg="invalid distance too far back",l.mode=30;break e}if(D=b,(T=0)===x){if(T+=v-z,z<O){for(O-=z;$[d++]=b[T++],--z;);T=d-q,D=$}}else if(x<z){if(T+=v+x-z,(z-=x)<O){for(O-=z;$[d++]=b[T++],--z;);if(T=0,x<O){for(O-=z=x;$[d++]=b[T++],--z;);T=d-q,D=$}}}else if(T+=x-z,z<O){for(O-=z;$[d++]=b[T++],--z;);T=d-q,D=$}for(;2<O;)$[d++]=D[T++],$[d++]=D[T++],$[d++]=D[T++],O-=3;O&&($[d++]=D[T++],1<O&&($[d++]=D[T++]))}else{for(T=d-q;$[d++]=$[T++],$[d++]=$[T++],$[d++]=$[T++],2<(O-=3););O&&($[d++]=$[T++],1<O&&($[d++]=$[T++]))}break}}break}}while(c<u&&d<m);c-=O=_>>3,y&=(1<<(_-=O<<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,r,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,v=1,g=852,x=592;function b(T){return(T>>>24&255)+(T>>>8&65280)+((65280&T)<<8)+((255&T)<<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 _(T){var D;return T&&T.state?(D=T.state,T.total_in=T.total_out=D.total=0,T.msg="",D.wrap&&(T.adler=1&D.wrap),D.mode=v,D.last=0,D.havedict=0,D.dmax=32768,D.head=null,D.hold=0,D.bits=0,D.lencode=D.lendyn=new i.Buf32(g),D.distcode=D.distdyn=new i.Buf32(x),D.sane=1,D.back=-1,m):h}function j(T){var D;return T&&T.state?((D=T.state).wsize=0,D.whave=0,D.wnext=0,_(T)):h}function S(T,D){var k,$;return T&&T.state?($=T.state,D<0?(k=0,D=-D):(k=1+(D>>4),D<48&&(D&=15)),D&&(D<8||15<D)?h:($.window!==null&&$.wbits!==D&&($.window=null),$.wrap=k,$.wbits=D,j(T))):h}function E(T,D){var k,$;return T?($=new y,(T.state=$).window=null,(k=S(T,D))!==m&&(T.state=null),k):h}var C,R,z=!0;function O(T){if(z){var D;for(C=new i.Buf32(512),R=new i.Buf32(32),D=0;D<144;)T.lens[D++]=8;for(;D<256;)T.lens[D++]=9;for(;D<280;)T.lens[D++]=7;for(;D<288;)T.lens[D++]=8;for(u(d,T.lens,0,288,C,0,T.work,{bits:9}),D=0;D<32;)T.lens[D++]=5;u(f,T.lens,0,32,R,0,T.work,{bits:5}),z=!1}T.lencode=C,T.lenbits=9,T.distcode=R,T.distbits=5}function q(T,D,k,$){var X,B=T.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,D,k-B.wsize,B.wsize,0),B.wnext=0,B.whave=B.wsize):($<(X=B.wsize-B.wnext)&&(X=$),i.arraySet(B.window,D,k-$,X,B.wnext),($-=X)?(i.arraySet(B.window,D,k-$,$,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(T){return E(T,15)},o.inflateInit2=E,o.inflate=function(T,D){var k,$,X,B,F,Z,J,H,W,ce,se,oe,_e,ie,ge,he,xe,te,ue,be,w,Y,U,I,A=0,L=new i.Buf8(4),ne=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!T||!T.state||!T.output||!T.input&&T.avail_in!==0)return h;(k=T.state).mode===12&&(k.mode=13),F=T.next_out,X=T.output,J=T.avail_out,B=T.next_in,$=T.input,Z=T.avail_in,H=k.hold,W=k.bits,ce=Z,se=J,Y=m;e:for(;;)switch(k.mode){case v:if(k.wrap===0){k.mode=13;break}for(;W<16;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(2&k.wrap&&H===35615){L[k.check=0]=255&H,L[1]=H>>>8&255,k.check=l(k.check,L,2,0),W=H=0,k.mode=2;break}if(k.flags=0,k.head&&(k.head.done=!1),!(1&k.wrap)||(((255&H)<<8)+(H>>8))%31){T.msg="incorrect header check",k.mode=30;break}if((15&H)!=8){T.msg="unknown compression method",k.mode=30;break}if(W-=4,w=8+(15&(H>>>=4)),k.wbits===0)k.wbits=w;else if(w>k.wbits){T.msg="invalid window size",k.mode=30;break}k.dmax=1<<w,T.adler=k.check=1,k.mode=512&H?10:12,W=H=0;break;case 2:for(;W<16;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(k.flags=H,(255&k.flags)!=8){T.msg="unknown compression method",k.mode=30;break}if(57344&k.flags){T.msg="unknown header flags set",k.mode=30;break}k.head&&(k.head.text=H>>8&1),512&k.flags&&(L[0]=255&H,L[1]=H>>>8&255,k.check=l(k.check,L,2,0)),W=H=0,k.mode=3;case 3:for(;W<32;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}k.head&&(k.head.time=H),512&k.flags&&(L[0]=255&H,L[1]=H>>>8&255,L[2]=H>>>16&255,L[3]=H>>>24&255,k.check=l(k.check,L,4,0)),W=H=0,k.mode=4;case 4:for(;W<16;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}k.head&&(k.head.xflags=255&H,k.head.os=H>>8),512&k.flags&&(L[0]=255&H,L[1]=H>>>8&255,k.check=l(k.check,L,2,0)),W=H=0,k.mode=5;case 5:if(1024&k.flags){for(;W<16;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}k.length=H,k.head&&(k.head.extra_len=H),512&k.flags&&(L[0]=255&H,L[1]=H>>>8&255,k.check=l(k.check,L,2,0)),W=H=0}else k.head&&(k.head.extra=null);k.mode=6;case 6:if(1024&k.flags&&(Z<(oe=k.length)&&(oe=Z),oe&&(k.head&&(w=k.head.extra_len-k.length,k.head.extra||(k.head.extra=new Array(k.head.extra_len)),i.arraySet(k.head.extra,$,B,oe,w)),512&k.flags&&(k.check=l(k.check,$,oe,B)),Z-=oe,B+=oe,k.length-=oe),k.length))break e;k.length=0,k.mode=7;case 7:if(2048&k.flags){if(Z===0)break e;for(oe=0;w=$[B+oe++],k.head&&w&&k.length<65536&&(k.head.name+=String.fromCharCode(w)),w&&oe<Z;);if(512&k.flags&&(k.check=l(k.check,$,oe,B)),Z-=oe,B+=oe,w)break e}else k.head&&(k.head.name=null);k.length=0,k.mode=8;case 8:if(4096&k.flags){if(Z===0)break e;for(oe=0;w=$[B+oe++],k.head&&w&&k.length<65536&&(k.head.comment+=String.fromCharCode(w)),w&&oe<Z;);if(512&k.flags&&(k.check=l(k.check,$,oe,B)),Z-=oe,B+=oe,w)break e}else k.head&&(k.head.comment=null);k.mode=9;case 9:if(512&k.flags){for(;W<16;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(H!==(65535&k.check)){T.msg="header crc mismatch",k.mode=30;break}W=H=0}k.head&&(k.head.hcrc=k.flags>>9&1,k.head.done=!0),T.adler=k.check=0,k.mode=12;break;case 10:for(;W<32;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}T.adler=k.check=b(H),W=H=0,k.mode=11;case 11:if(k.havedict===0)return T.next_out=F,T.avail_out=J,T.next_in=B,T.avail_in=Z,k.hold=H,k.bits=W,2;T.adler=k.check=1,k.mode=12;case 12:if(D===5||D===6)break e;case 13:if(k.last){H>>>=7&W,W-=7&W,k.mode=27;break}for(;W<3;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}switch(k.last=1&H,W-=1,3&(H>>>=1)){case 0:k.mode=14;break;case 1:if(O(k),k.mode=20,D!==6)break;H>>>=2,W-=2;break e;case 2:k.mode=17;break;case 3:T.msg="invalid block type",k.mode=30}H>>>=2,W-=2;break;case 14:for(H>>>=7&W,W-=7&W;W<32;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if((65535&H)!=(H>>>16^65535)){T.msg="invalid stored block lengths",k.mode=30;break}if(k.length=65535&H,W=H=0,k.mode=15,D===6)break e;case 15:k.mode=16;case 16:if(oe=k.length){if(Z<oe&&(oe=Z),J<oe&&(oe=J),oe===0)break e;i.arraySet(X,$,B,oe,F),Z-=oe,B+=oe,J-=oe,F+=oe,k.length-=oe;break}k.mode=12;break;case 17:for(;W<14;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(k.nlen=257+(31&H),H>>>=5,W-=5,k.ndist=1+(31&H),H>>>=5,W-=5,k.ncode=4+(15&H),H>>>=4,W-=4,286<k.nlen||30<k.ndist){T.msg="too many length or distance symbols",k.mode=30;break}k.have=0,k.mode=18;case 18:for(;k.have<k.ncode;){for(;W<3;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}k.lens[ne[k.have++]]=7&H,H>>>=3,W-=3}for(;k.have<19;)k.lens[ne[k.have++]]=0;if(k.lencode=k.lendyn,k.lenbits=7,U={bits:k.lenbits},Y=u(0,k.lens,0,19,k.lencode,0,k.work,U),k.lenbits=U.bits,Y){T.msg="invalid code lengths set",k.mode=30;break}k.have=0,k.mode=19;case 19:for(;k.have<k.nlen+k.ndist;){for(;he=(A=k.lencode[H&(1<<k.lenbits)-1])>>>16&255,xe=65535&A,!((ge=A>>>24)<=W);){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(xe<16)H>>>=ge,W-=ge,k.lens[k.have++]=xe;else{if(xe===16){for(I=ge+2;W<I;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(H>>>=ge,W-=ge,k.have===0){T.msg="invalid bit length repeat",k.mode=30;break}w=k.lens[k.have-1],oe=3+(3&H),H>>>=2,W-=2}else if(xe===17){for(I=ge+3;W<I;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}W-=ge,w=0,oe=3+(7&(H>>>=ge)),H>>>=3,W-=3}else{for(I=ge+7;W<I;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}W-=ge,w=0,oe=11+(127&(H>>>=ge)),H>>>=7,W-=7}if(k.have+oe>k.nlen+k.ndist){T.msg="invalid bit length repeat",k.mode=30;break}for(;oe--;)k.lens[k.have++]=w}}if(k.mode===30)break;if(k.lens[256]===0){T.msg="invalid code -- missing end-of-block",k.mode=30;break}if(k.lenbits=9,U={bits:k.lenbits},Y=u(d,k.lens,0,k.nlen,k.lencode,0,k.work,U),k.lenbits=U.bits,Y){T.msg="invalid literal/lengths set",k.mode=30;break}if(k.distbits=6,k.distcode=k.distdyn,U={bits:k.distbits},Y=u(f,k.lens,k.nlen,k.ndist,k.distcode,0,k.work,U),k.distbits=U.bits,Y){T.msg="invalid distances set",k.mode=30;break}if(k.mode=20,D===6)break e;case 20:k.mode=21;case 21:if(6<=Z&&258<=J){T.next_out=F,T.avail_out=J,T.next_in=B,T.avail_in=Z,k.hold=H,k.bits=W,c(T,se),F=T.next_out,X=T.output,J=T.avail_out,B=T.next_in,$=T.input,Z=T.avail_in,H=k.hold,W=k.bits,k.mode===12&&(k.back=-1);break}for(k.back=0;he=(A=k.lencode[H&(1<<k.lenbits)-1])>>>16&255,xe=65535&A,!((ge=A>>>24)<=W);){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(he&&(240&he)==0){for(te=ge,ue=he,be=xe;he=(A=k.lencode[be+((H&(1<<te+ue)-1)>>te)])>>>16&255,xe=65535&A,!(te+(ge=A>>>24)<=W);){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}H>>>=te,W-=te,k.back+=te}if(H>>>=ge,W-=ge,k.back+=ge,k.length=xe,he===0){k.mode=26;break}if(32&he){k.back=-1,k.mode=12;break}if(64&he){T.msg="invalid literal/length code",k.mode=30;break}k.extra=15&he,k.mode=22;case 22:if(k.extra){for(I=k.extra;W<I;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}k.length+=H&(1<<k.extra)-1,H>>>=k.extra,W-=k.extra,k.back+=k.extra}k.was=k.length,k.mode=23;case 23:for(;he=(A=k.distcode[H&(1<<k.distbits)-1])>>>16&255,xe=65535&A,!((ge=A>>>24)<=W);){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if((240&he)==0){for(te=ge,ue=he,be=xe;he=(A=k.distcode[be+((H&(1<<te+ue)-1)>>te)])>>>16&255,xe=65535&A,!(te+(ge=A>>>24)<=W);){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}H>>>=te,W-=te,k.back+=te}if(H>>>=ge,W-=ge,k.back+=ge,64&he){T.msg="invalid distance code",k.mode=30;break}k.offset=xe,k.extra=15&he,k.mode=24;case 24:if(k.extra){for(I=k.extra;W<I;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}k.offset+=H&(1<<k.extra)-1,H>>>=k.extra,W-=k.extra,k.back+=k.extra}if(k.offset>k.dmax){T.msg="invalid distance too far back",k.mode=30;break}k.mode=25;case 25:if(J===0)break e;if(oe=se-J,k.offset>oe){if((oe=k.offset-oe)>k.whave&&k.sane){T.msg="invalid distance too far back",k.mode=30;break}_e=oe>k.wnext?(oe-=k.wnext,k.wsize-oe):k.wnext-oe,oe>k.length&&(oe=k.length),ie=k.window}else ie=X,_e=F-k.offset,oe=k.length;for(J<oe&&(oe=J),J-=oe,k.length-=oe;X[F++]=ie[_e++],--oe;);k.length===0&&(k.mode=21);break;case 26:if(J===0)break e;X[F++]=k.length,J--,k.mode=21;break;case 27:if(k.wrap){for(;W<32;){if(Z===0)break e;Z--,H|=$[B++]<<W,W+=8}if(se-=J,T.total_out+=se,k.total+=se,se&&(T.adler=k.check=k.flags?l(k.check,X,se,F-se):a(k.check,X,se,F-se)),se=J,(k.flags?H:b(H))!==k.check){T.msg="incorrect data check",k.mode=30;break}W=H=0}k.mode=28;case 28:if(k.wrap&&k.flags){for(;W<32;){if(Z===0)break e;Z--,H+=$[B++]<<W,W+=8}if(H!==(4294967295&k.total)){T.msg="incorrect length check",k.mode=30;break}W=H=0}k.mode=29;case 29:Y=1;break e;case 30:Y=-3;break e;case 31:return-4;default:return h}return T.next_out=F,T.avail_out=J,T.next_in=B,T.avail_in=Z,k.hold=H,k.bits=W,(k.wsize||se!==T.avail_out&&k.mode<30&&(k.mode<27||D!==4))&&q(T,T.output,T.next_out,se-T.avail_out)?(k.mode=31,-4):(ce-=T.avail_in,se-=T.avail_out,T.total_in+=ce,T.total_out+=se,k.total+=se,k.wrap&&se&&(T.adler=k.check=k.flags?l(k.check,X,se,T.next_out-se):a(k.check,X,se,T.next_out-se)),T.data_type=k.bits+(k.last?64:0)+(k.mode===12?128:0)+(k.mode===20||k.mode===15?256:0),(ce==0&&se===0||D===4)&&Y===m&&(Y=-5),Y)},o.inflateEnd=function(T){if(!T||!T.state)return h;var D=T.state;return D.window&&(D.window=null),T.state=null,m},o.inflateGetHeader=function(T,D){var k;return T&&T.state?(2&(k=T.state).wrap)==0?h:((k.head=D).done=!1,m):h},o.inflateSetDictionary=function(T,D){var k,$=D.length;return T&&T.state?(k=T.state).wrap!==0&&k.mode!==11?h:k.mode===11&&a(1,D,$,0)!==k.check?-3:q(T,D,$,$)?(k.mode=31,-4):(k.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,r,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];r.exports=function(d,f,m,h,v,g,x,b){var y,_,j,S,E,C,R,z,O,q=b.bits,T=0,D=0,k=0,$=0,X=0,B=0,F=0,Z=0,J=0,H=0,W=null,ce=0,se=new i.Buf16(16),oe=new i.Buf16(16),_e=null,ie=0;for(T=0;T<=15;T++)se[T]=0;for(D=0;D<h;D++)se[f[m+D]]++;for(X=q,$=15;1<=$&&se[$]===0;$--);if($<X&&(X=$),$===0)return v[g++]=20971520,v[g++]=20971520,b.bits=1,0;for(k=1;k<$&&se[k]===0;k++);for(X<k&&(X=k),T=Z=1;T<=15;T++)if(Z<<=1,(Z-=se[T])<0)return-1;if(0<Z&&(d===0||$!==1))return-1;for(oe[1]=0,T=1;T<15;T++)oe[T+1]=oe[T]+se[T];for(D=0;D<h;D++)f[m+D]!==0&&(x[oe[f[m+D]]++]=D);if(C=d===0?(W=_e=x,19):d===1?(W=a,ce-=257,_e=l,ie-=257,256):(W=c,_e=u,-1),T=k,E=g,F=D=H=0,j=-1,S=(J=1<<(B=X))-1,d===1&&852<J||d===2&&592<J)return 1;for(;;){for(R=T-F,O=x[D]<C?(z=0,x[D]):x[D]>C?(z=_e[ie+x[D]],W[ce+x[D]]):(z=96,0),y=1<<T-F,k=_=1<<B;v[E+(H>>F)+(_-=y)]=R<<24|z<<16|O|0,_!==0;);for(y=1<<T-1;H&y;)y>>=1;if(y!==0?(H&=y-1,H+=y):H=0,D++,--se[T]==0){if(T===$)break;T=f[m+x[D]]}if(X<T&&(H&S)!==j){for(F===0&&(F=X),E+=k,Z=1<<(B=T-F);B+F<$&&!((Z-=se[B+F])<=0);)B++,Z<<=1;if(J+=1<<B,d===1&&852<J||d===2&&592<J)return 1;v[j=H&S]=X<<24|B<<16|E-g|0}}return H!==0&&(v[E+H]=T-F<<24|64<<16|0),b.bits=X,0}},{"../utils/common":41}],51:[function(n,r,o){r.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,r,o){var i=n("../utils/common"),a=0,l=1;function c(A){for(var L=A.length;0<=--L;)A[L]=0}var u=0,d=29,f=256,m=f+1+d,h=30,v=19,g=2*m+1,x=15,b=16,y=7,_=256,j=16,S=17,E=18,C=[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],z=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],O=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],q=new Array(2*(m+2));c(q);var T=new Array(2*h);c(T);var D=new Array(512);c(D);var k=new Array(256);c(k);var $=new Array(d);c($);var X,B,F,Z=new Array(h);function J(A,L,ne,re,V){this.static_tree=A,this.extra_bits=L,this.extra_base=ne,this.elems=re,this.max_length=V,this.has_stree=A&&A.length}function H(A,L){this.dyn_tree=A,this.max_code=0,this.stat_desc=L}function W(A){return A<256?D[A]:D[256+(A>>>7)]}function ce(A,L){A.pending_buf[A.pending++]=255&L,A.pending_buf[A.pending++]=L>>>8&255}function se(A,L,ne){A.bi_valid>b-ne?(A.bi_buf|=L<<A.bi_valid&65535,ce(A,A.bi_buf),A.bi_buf=L>>b-A.bi_valid,A.bi_valid+=ne-b):(A.bi_buf|=L<<A.bi_valid&65535,A.bi_valid+=ne)}function oe(A,L,ne){se(A,ne[2*L],ne[2*L+1])}function _e(A,L){for(var ne=0;ne|=1&A,A>>>=1,ne<<=1,0<--L;);return ne>>>1}function ie(A,L,ne){var re,V,ae=new Array(x+1),P=0;for(re=1;re<=x;re++)ae[re]=P=P+ne[re-1]<<1;for(V=0;V<=L;V++){var M=A[2*V+1];M!==0&&(A[2*V]=_e(ae[M]++,M))}}function ge(A){var L;for(L=0;L<m;L++)A.dyn_ltree[2*L]=0;for(L=0;L<h;L++)A.dyn_dtree[2*L]=0;for(L=0;L<v;L++)A.bl_tree[2*L]=0;A.dyn_ltree[2*_]=1,A.opt_len=A.static_len=0,A.last_lit=A.matches=0}function he(A){8<A.bi_valid?ce(A,A.bi_buf):0<A.bi_valid&&(A.pending_buf[A.pending++]=A.bi_buf),A.bi_buf=0,A.bi_valid=0}function xe(A,L,ne,re){var V=2*L,ae=2*ne;return A[V]<A[ae]||A[V]===A[ae]&&re[L]<=re[ne]}function te(A,L,ne){for(var re=A.heap[ne],V=ne<<1;V<=A.heap_len&&(V<A.heap_len&&xe(L,A.heap[V+1],A.heap[V],A.depth)&&V++,!xe(L,re,A.heap[V],A.depth));)A.heap[ne]=A.heap[V],ne=V,V<<=1;A.heap[ne]=re}function ue(A,L,ne){var re,V,ae,P,M=0;if(A.last_lit!==0)for(;re=A.pending_buf[A.d_buf+2*M]<<8|A.pending_buf[A.d_buf+2*M+1],V=A.pending_buf[A.l_buf+M],M++,re===0?oe(A,V,L):(oe(A,(ae=k[V])+f+1,L),(P=C[ae])!==0&&se(A,V-=$[ae],P),oe(A,ae=W(--re),ne),(P=R[ae])!==0&&se(A,re-=Z[ae],P)),M<A.last_lit;);oe(A,_,L)}function be(A,L){var ne,re,V,ae=L.dyn_tree,P=L.stat_desc.static_tree,M=L.stat_desc.has_stree,Q=L.stat_desc.elems,fe=-1;for(A.heap_len=0,A.heap_max=g,ne=0;ne<Q;ne++)ae[2*ne]!==0?(A.heap[++A.heap_len]=fe=ne,A.depth[ne]=0):ae[2*ne+1]=0;for(;A.heap_len<2;)ae[2*(V=A.heap[++A.heap_len]=fe<2?++fe:0)]=1,A.depth[V]=0,A.opt_len--,M&&(A.static_len-=P[2*V+1]);for(L.max_code=fe,ne=A.heap_len>>1;1<=ne;ne--)te(A,ae,ne);for(V=Q;ne=A.heap[1],A.heap[1]=A.heap[A.heap_len--],te(A,ae,1),re=A.heap[1],A.heap[--A.heap_max]=ne,A.heap[--A.heap_max]=re,ae[2*V]=ae[2*ne]+ae[2*re],A.depth[V]=(A.depth[ne]>=A.depth[re]?A.depth[ne]:A.depth[re])+1,ae[2*ne+1]=ae[2*re+1]=V,A.heap[1]=V++,te(A,ae,1),2<=A.heap_len;);A.heap[--A.heap_max]=A.heap[1],(function(de,Pe){var Ue,Ne,pt,ze,$t,hr,Re=Pe.dyn_tree,Et=Pe.max_code,Ft=Pe.stat_desc.static_tree,Ko=Pe.stat_desc.has_stree,at=Pe.stat_desc.extra_bits,zn=Pe.stat_desc.extra_base,mr=Pe.stat_desc.max_length,Qr=0;for(ze=0;ze<=x;ze++)de.bl_count[ze]=0;for(Re[2*de.heap[de.heap_max]+1]=0,Ue=de.heap_max+1;Ue<g;Ue++)mr<(ze=Re[2*Re[2*(Ne=de.heap[Ue])+1]+1]+1)&&(ze=mr,Qr++),Re[2*Ne+1]=ze,Et<Ne||(de.bl_count[ze]++,$t=0,zn<=Ne&&($t=at[Ne-zn]),hr=Re[2*Ne],de.opt_len+=hr*(ze+$t),Ko&&(de.static_len+=hr*(Ft[2*Ne+1]+$t)));if(Qr!==0){do{for(ze=mr-1;de.bl_count[ze]===0;)ze--;de.bl_count[ze]--,de.bl_count[ze+1]+=2,de.bl_count[mr]--,Qr-=2}while(0<Qr);for(ze=mr;ze!==0;ze--)for(Ne=de.bl_count[ze];Ne!==0;)Et<(pt=de.heap[--Ue])||(Re[2*pt+1]!==ze&&(de.opt_len+=(ze-Re[2*pt+1])*Re[2*pt],Re[2*pt+1]=ze),Ne--)}})(A,L),ie(ae,fe,A.bl_count)}function w(A,L,ne){var re,V,ae=-1,P=L[1],M=0,Q=7,fe=4;for(P===0&&(Q=138,fe=3),L[2*(ne+1)+1]=65535,re=0;re<=ne;re++)V=P,P=L[2*(re+1)+1],++M<Q&&V===P||(M<fe?A.bl_tree[2*V]+=M:V!==0?(V!==ae&&A.bl_tree[2*V]++,A.bl_tree[2*j]++):M<=10?A.bl_tree[2*S]++:A.bl_tree[2*E]++,ae=V,fe=(M=0)===P?(Q=138,3):V===P?(Q=6,3):(Q=7,4))}function Y(A,L,ne){var re,V,ae=-1,P=L[1],M=0,Q=7,fe=4;for(P===0&&(Q=138,fe=3),re=0;re<=ne;re++)if(V=P,P=L[2*(re+1)+1],!(++M<Q&&V===P)){if(M<fe)for(;oe(A,V,A.bl_tree),--M!=0;);else V!==0?(V!==ae&&(oe(A,V,A.bl_tree),M--),oe(A,j,A.bl_tree),se(A,M-3,2)):M<=10?(oe(A,S,A.bl_tree),se(A,M-3,3)):(oe(A,E,A.bl_tree),se(A,M-11,7));ae=V,fe=(M=0)===P?(Q=138,3):V===P?(Q=6,3):(Q=7,4)}}c(Z);var U=!1;function I(A,L,ne,re){se(A,(u<<1)+(re?1:0),3),(function(V,ae,P,M){he(V),ce(V,P),ce(V,~P),i.arraySet(V.pending_buf,V.window,ae,P,V.pending),V.pending+=P})(A,L,ne)}o._tr_init=function(A){U||((function(){var L,ne,re,V,ae,P=new Array(x+1);for(V=re=0;V<d-1;V++)for($[V]=re,L=0;L<1<<C[V];L++)k[re++]=V;for(k[re-1]=V,V=ae=0;V<16;V++)for(Z[V]=ae,L=0;L<1<<R[V];L++)D[ae++]=V;for(ae>>=7;V<h;V++)for(Z[V]=ae<<7,L=0;L<1<<R[V]-7;L++)D[256+ae++]=V;for(ne=0;ne<=x;ne++)P[ne]=0;for(L=0;L<=143;)q[2*L+1]=8,L++,P[8]++;for(;L<=255;)q[2*L+1]=9,L++,P[9]++;for(;L<=279;)q[2*L+1]=7,L++,P[7]++;for(;L<=287;)q[2*L+1]=8,L++,P[8]++;for(ie(q,m+1,P),L=0;L<h;L++)T[2*L+1]=5,T[2*L]=_e(L,5);X=new J(q,C,f+1,m,x),B=new J(T,R,0,h,x),F=new J(new Array(0),z,0,v,y)})(),U=!0),A.l_desc=new H(A.dyn_ltree,X),A.d_desc=new H(A.dyn_dtree,B),A.bl_desc=new H(A.bl_tree,F),A.bi_buf=0,A.bi_valid=0,ge(A)},o._tr_stored_block=I,o._tr_flush_block=function(A,L,ne,re){var V,ae,P=0;0<A.level?(A.strm.data_type===2&&(A.strm.data_type=(function(M){var Q,fe=4093624447;for(Q=0;Q<=31;Q++,fe>>>=1)if(1&fe&&M.dyn_ltree[2*Q]!==0)return a;if(M.dyn_ltree[18]!==0||M.dyn_ltree[20]!==0||M.dyn_ltree[26]!==0)return l;for(Q=32;Q<f;Q++)if(M.dyn_ltree[2*Q]!==0)return l;return a})(A)),be(A,A.l_desc),be(A,A.d_desc),P=(function(M){var Q;for(w(M,M.dyn_ltree,M.l_desc.max_code),w(M,M.dyn_dtree,M.d_desc.max_code),be(M,M.bl_desc),Q=v-1;3<=Q&&M.bl_tree[2*O[Q]+1]===0;Q--);return M.opt_len+=3*(Q+1)+5+5+4,Q})(A),V=A.opt_len+3+7>>>3,(ae=A.static_len+3+7>>>3)<=V&&(V=ae)):V=ae=ne+5,ne+4<=V&&L!==-1?I(A,L,ne,re):A.strategy===4||ae===V?(se(A,2+(re?1:0),3),ue(A,q,T)):(se(A,4+(re?1:0),3),(function(M,Q,fe,de){var Pe;for(se(M,Q-257,5),se(M,fe-1,5),se(M,de-4,4),Pe=0;Pe<de;Pe++)se(M,M.bl_tree[2*O[Pe]+1],3);Y(M,M.dyn_ltree,Q-1),Y(M,M.dyn_dtree,fe-1)})(A,A.l_desc.max_code+1,A.d_desc.max_code+1,P+1),ue(A,A.dyn_ltree,A.dyn_dtree)),ge(A),re&&he(A)},o._tr_tally=function(A,L,ne){return A.pending_buf[A.d_buf+2*A.last_lit]=L>>>8&255,A.pending_buf[A.d_buf+2*A.last_lit+1]=255&L,A.pending_buf[A.l_buf+A.last_lit]=255&ne,A.last_lit++,L===0?A.dyn_ltree[2*ne]++:(A.matches++,L--,A.dyn_ltree[2*(k[ne]+f+1)]++,A.dyn_dtree[2*W(L)]++),A.last_lit===A.lit_bufsize-1},o._tr_align=function(A){se(A,2,3),oe(A,_,q),(function(L){L.bi_valid===16?(ce(L,L.bi_buf),L.bi_buf=0,L.bi_valid=0):8<=L.bi_valid&&(L.pending_buf[L.pending++]=255&L.bi_buf,L.bi_buf>>=8,L.bi_valid-=8)})(A)}},{"../utils/common":41}],53:[function(n,r,o){r.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,r,o){(function(i){(function(a,l){if(!a.setImmediate){var c,u,d,f,m=1,h={},v=!1,g=a.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(a);x=x&&x.setTimeout?x: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)},x.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 C={callback:j,args:S};return h[m]=C,c(m),m++},x.clearImmediate=b}function b(j){delete h[j]}function y(j){if(v)setTimeout(y,0,j);else{var S=h[j];if(S){v=!0;try{(function(E){var C=E.callback,R=E.args;switch(R.length){case 0:C();break;case 1:C(R[0]);break;case 2:C(R[0],R[1]);break;case 3:C(R[0],R[1],R[2]);break;default:C.apply(l,R)}})(S)}finally{b(j),v=!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 es<"u"?es:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Yo)),Yo.exports}var xw=gw();const bw=tg(xw),vw="2.1.18",Ui={version:vw},cf="[REDACTED]",yw=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,ww=[/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],dc=200,kw=25e6,uf=50;function _w(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function jw(e){let t=0;for(const n of e)t+=n.rawRequestBody?.length??0,t+=n.responseText?.length??0;return t}function Sw(e){if(e.length>dc)return`Export is limited to ${dc} logs at once. Narrow the filter and try again.`;const t=jw(e);return t>kw?`Export is too large (${_w(t)} of text). Narrow the filter and try again.`:null}async function Cw(e){try{const t=await fetch(`/api/logs/${e}/chunks`);if(!t.ok)return null;const n=await t.json();return JSON.stringify(n,null,2)}catch{return null}}function Nw(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Wi(e){if(Array.isArray(e))return e.map(n=>Wi(n));if(!Nw(e))return e;const t={};for(const[n,r]of Object.entries(e))t[n]=yw.test(n)?cf:Wi(r);return t}function Tw(e){const t=n=>{let r=n;for(const o of ww)r=r.replace(o,cf);return r};try{const n=JSON.parse(e);return t(JSON.stringify(Wi(n),null,2))}catch{return t(e)}}function Xo(e,t){return t==="redacted"?Tw(e):e}function Ew(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 Aw(e,t,n,r=new Date().toISOString()){return{version:Ui.version,exportedAt:r,mode:t,redacted:t==="redacted",logCount:e.length,logIds:e.map(o=>o.id),streamingChunkExportLimit:uf,streamingChunkLogIds:n.map(o=>o.id)}}async function Rw(e,t="redacted"){const n=Sw(e);if(n!==null)return{ok:!1,message:n};const r=new bw,o=t==="redacted"?"redacted":"raw",i=e.filter(u=>u.streaming).slice(0,uf);r.file("manifest.json",JSON.stringify(Aw(e,t,i),null,2)),r.file("logs.json",JSON.stringify(e.map(u=>Ew(u,t)),null,2));for(const u of e)u.rawRequestBody!==null&&r.file(`#${u.id}.Request.json`,Xo(u.rawRequestBody,t)),u.responseText!==null&&r.file(`#${u.id}.Response.json`,Xo(u.responseText,t));for(const u of i){const d=await Cw(u.id);d!==null&&r.file(`#${u.id}.SSE.Response.json`,Xo(d,t))}const a=await r.generateAsync({type:"blob"}),l=URL.createObjectURL(a),c=document.createElement("a");return c.href=l,c.download=`agent-inspector-export-${o}-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(l),{ok:!0}}function Iw(e,t){if(e!==null){e.removeAllRanges();for(const n of t)e.addRange(n)}}function zw(e){if(e===null)return[];const t=[];for(let n=0;n<e.rangeCount;n++)t.push(e.getRangeAt(n));return t}function Pw(e){if(typeof document>"u")return!1;const t=document.activeElement,n=document.getSelection(),r=zw(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),Iw(n,r),typeof HTMLElement<"u"&&t instanceof HTMLElement&&t.focus({preventScroll:!0})}return i}async function Kt(e){const t=globalThis.navigator?.clipboard;if(t!==void 0)try{return await t.writeText(e),!0}catch{}return Pw(e)}function Hi(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 Ya(e,t,n){return`${Hi(e,n)} - ${Hi(t,n)}`}function is(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ow(e){switch(e){case"end_turn":case"tool_use":return e;default:return null}}function Mw(e){switch(e){case"stop":case"length":return e;default:return null}}function Lw(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function df(e){if(e.responseText===null)return null;try{let t=JSON.parse(e.responseText);if(typeof t=="string"&&(t=JSON.parse(t)),!is(t))return null;if(typeof t.stop_reason=="string")return Ow(t.stop_reason);if(Array.isArray(t.choices))for(const n of t.choices){if(!is(n)||typeof n.finish_reason!="string")continue;const r=Mw(n.finish_reason);if(r!==null)return r}if(Array.isArray(t.output)){for(const n of t.output)if(is(n)&&n.type==="function_call")return"tool_use";if(t.status==="completed")return"stop"}if(t.status==="incomplete"&&is(t.incomplete_details)){const n=t.incomplete_details.reason;if(typeof n=="string"&&Lw(n))return"length"}return null}catch{return null}}function Xa(e){return e==="end_turn"||e==="stop"||e==="length"}function ff(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=ff(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function pf(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=ff(e))&&(r&&(r+=" "),r+=t);return r}const Dw=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},$w=(e,t)=>({classGroupId:e,validator:t}),hf=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Us="-",fc=[],Fw="arbitrary..",Bw=e=>{const t=Ww(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return Uw(a);const l=a.split(Us),c=l[0]===""&&l.length>1?1:0;return mf(l,c,t)},getConflictingClassGroupIds:(a,l)=>{if(l){const c=r[a],u=n[a];return c?u?Dw(u,c):c:u||fc}return n[a]||fc}}},mf=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],i=n.nextPart.get(o);if(i){const u=mf(e,t+1,i);if(u)return u}const a=n.validators;if(a===null)return;const l=t===0?e.join(Us):e.slice(t).join(Us),c=a.length;for(let u=0;u<c;u++){const d=a[u];if(d.validator(l))return d.classGroupId}},Uw=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?Fw+r:void 0})(),Ww=e=>{const{theme:t,classGroups:n}=e;return Hw(n,t)},Hw=(e,t)=>{const n=hf();for(const r in e){const o=e[r];Qa(o,n,r,t)}return n},Qa=(e,t,n,r)=>{const o=e.length;for(let i=0;i<o;i++){const a=e[i];Zw(a,t,n,r)}},Zw=(e,t,n,r)=>{if(typeof e=="string"){Vw(e,t,n);return}if(typeof e=="function"){qw(e,t,n,r);return}Kw(e,t,n,r)},Vw=(e,t,n)=>{const r=e===""?t:gf(t,e);r.classGroupId=n},qw=(e,t,n,r)=>{if(Gw(e)){Qa(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push($w(n,e))},Kw=(e,t,n,r)=>{const o=Object.entries(e),i=o.length;for(let a=0;a<i;a++){const[l,c]=o[a];Qa(c,gf(t,l),n,r)}},gf=(e,t)=>{let n=e;const r=t.split(Us),o=r.length;for(let i=0;i<o;i++){const a=r[i];let l=n.nextPart.get(a);l||(l=hf(),n.nextPart.set(a,l)),n=l}return n},Gw=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Jw=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(i){let a=n[i];if(a!==void 0)return a;if((a=r[i])!==void 0)return o(i,a),a},set(i,a){i in n?n[i]=a:o(i,a)}}},Zi="!",pc=":",Yw=[],hc=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),Xw=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const i=[];let a=0,l=0,c=0,u;const d=o.length;for(let g=0;g<d;g++){const x=o[g];if(a===0&&l===0){if(x===pc){i.push(o.slice(c,g)),c=g+1;continue}if(x==="/"){u=g;continue}}x==="["?a++:x==="]"?a--:x==="("?l++:x===")"&&l--}const f=i.length===0?o:o.slice(c);let m=f,h=!1;f.endsWith(Zi)?(m=f.slice(0,-1),h=!0):f.startsWith(Zi)&&(m=f.slice(1),h=!0);const v=u&&u>c?u-c:void 0;return hc(i,h,m,v)};if(t){const o=t+pc,i=r;r=a=>a.startsWith(o)?i(a.slice(o.length)):hc(Yw,!1,a,void 0,!0)}if(n){const o=r;r=i=>n({className:i,parseClassName:o})}return r},Qw=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];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(),r.push(...o),o=[]),r.push(a)):o.push(a)}return o.length>0&&(o.sort(),r.push(...o)),r}},ek=e=>({cache:Jw(e.cacheSize),parseClassName:Xw(e),sortModifiers:Qw(e),...Bw(e)}),tk=/\s+/,nk=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:i}=t,a=[],l=e.trim().split(tk);let c="";for(let u=l.length-1;u>=0;u-=1){const d=l[u],{isExternal:f,modifiers:m,hasImportantModifier:h,baseClassName:v,maybePostfixModifierPosition:g}=n(d);if(f){c=d+(c.length>0?" "+c:c);continue}let x=!!g,b=r(x?v.substring(0,g):v);if(!b){if(!x){c=d+(c.length>0?" "+c:c);continue}if(b=r(v),!b){c=d+(c.length>0?" "+c:c);continue}x=!1}const y=m.length===0?"":m.length===1?m[0]:i(m).join(":"),_=h?y+Zi:y,j=_+b;if(a.indexOf(j)>-1)continue;a.push(j);const S=o(b,x);for(let E=0;E<S.length;++E){const C=S[E];a.push(_+C)}c=d+(c.length>0?" "+c:c)}return c},rk=(...e)=>{let t=0,n,r,o="";for(;t<e.length;)(n=e[t++])&&(r=xf(n))&&(o&&(o+=" "),o+=r);return o},xf=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=xf(e[r]))&&(n&&(n+=" "),n+=t);return n},sk=(e,...t)=>{let n,r,o,i;const a=c=>{const u=t.reduce((d,f)=>f(d),e());return n=ek(u),r=n.cache.get,o=n.cache.set,i=l,l(c)},l=c=>{const u=r(c);if(u)return u;const d=nk(c,n);return o(c,d),d};return i=a,(...c)=>i(rk(...c))},ok=[],Ye=e=>{const t=n=>n[e]||ok;return t.isThemeGetter=!0,t},bf=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,vf=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ik=/^\d+\/\d+$/,ak=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,lk=/\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$/,ck=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,uk=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,dk=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Pn=e=>ik.test(e),Ae=e=>!!e&&!Number.isNaN(Number(e)),Jt=e=>!!e&&Number.isInteger(Number(e)),Qo=e=>e.endsWith("%")&&Ae(e.slice(0,-1)),Bt=e=>ak.test(e),fk=()=>!0,pk=e=>lk.test(e)&&!ck.test(e),yf=()=>!1,hk=e=>uk.test(e),mk=e=>dk.test(e),gk=e=>!ve(e)&&!ye(e),xk=e=>cr(e,_f,yf),ve=e=>bf.test(e),gn=e=>cr(e,jf,pk),ei=e=>cr(e,kk,Ae),mc=e=>cr(e,wf,yf),bk=e=>cr(e,kf,mk),as=e=>cr(e,Sf,hk),ye=e=>vf.test(e),gr=e=>ur(e,jf),vk=e=>ur(e,_k),gc=e=>ur(e,wf),yk=e=>ur(e,_f),wk=e=>ur(e,kf),ls=e=>ur(e,Sf,!0),cr=(e,t,n)=>{const r=bf.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},ur=(e,t,n=!1)=>{const r=vf.exec(e);return r?r[1]?t(r[1]):n:!1},wf=e=>e==="position"||e==="percentage",kf=e=>e==="image"||e==="url",_f=e=>e==="length"||e==="size"||e==="bg-size",jf=e=>e==="length",kk=e=>e==="number",_k=e=>e==="family-name",Sf=e=>e==="shadow",jk=()=>{const e=Ye("color"),t=Ye("font"),n=Ye("text"),r=Ye("font-weight"),o=Ye("tracking"),i=Ye("leading"),a=Ye("breakpoint"),l=Ye("container"),c=Ye("spacing"),u=Ye("radius"),d=Ye("shadow"),f=Ye("inset-shadow"),m=Ye("text-shadow"),h=Ye("drop-shadow"),v=Ye("blur"),g=Ye("perspective"),x=Ye("aspect"),b=Ye("ease"),y=Ye("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(),ye,ve],E=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],R=()=>[ye,ve,c],z=()=>[Pn,"full","auto",...R()],O=()=>[Jt,"none","subgrid",ye,ve],q=()=>["auto",{span:["full",Jt,ye,ve]},Jt,ye,ve],T=()=>[Jt,"auto",ye,ve],D=()=>["auto","min","max","fr",ye,ve],k=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],$=()=>["start","end","center","stretch","center-safe","end-safe"],X=()=>["auto",...R()],B=()=>[Pn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],F=()=>[e,ye,ve],Z=()=>[...j(),gc,mc,{position:[ye,ve]}],J=()=>["no-repeat",{repeat:["","x","y","space","round"]}],H=()=>["auto","cover","contain",yk,xk,{size:[ye,ve]}],W=()=>[Qo,gr,gn],ce=()=>["","none","full",u,ye,ve],se=()=>["",Ae,gr,gn],oe=()=>["solid","dashed","dotted","double"],_e=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ie=()=>[Ae,Qo,gc,mc],ge=()=>["","none",v,ye,ve],he=()=>["none",Ae,ye,ve],xe=()=>["none",Ae,ye,ve],te=()=>[Ae,ye,ve],ue=()=>[Pn,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Bt],breakpoint:[Bt],color:[fk],container:[Bt],"drop-shadow":[Bt],ease:["in","out","in-out"],font:[gk],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Bt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Bt],shadow:[Bt],spacing:["px",Ae],text:[Bt],"text-shadow":[Bt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Pn,ve,ye,x]}],container:["container"],columns:[{columns:[Ae,ve,ye,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:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:z()}],"inset-x":[{"inset-x":z()}],"inset-y":[{"inset-y":z()}],start:[{start:z()}],end:[{end:z()}],top:[{top:z()}],right:[{right:z()}],bottom:[{bottom:z()}],left:[{left:z()}],visibility:["visible","invisible","collapse"],z:[{z:[Jt,"auto",ye,ve]}],basis:[{basis:[Pn,"full","auto",l,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ae,Pn,"auto","initial","none",ve]}],grow:[{grow:["",Ae,ye,ve]}],shrink:[{shrink:["",Ae,ye,ve]}],order:[{order:[Jt,"first","last","none",ye,ve]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:q()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:q()}],"row-start":[{"row-start":T()}],"row-end":[{"row-end":T()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":D()}],"auto-rows":[{"auto-rows":D()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...k(),"normal"]}],"justify-items":[{"justify-items":[...$(),"normal"]}],"justify-self":[{"justify-self":["auto",...$()]}],"align-content":[{content:["normal",...k()]}],"align-items":[{items:[...$(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...$(),{baseline:["","last"]}]}],"place-content":[{"place-content":k()}],"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()}],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()}],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()}],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,gr,gn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,ye,ei]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Qo,ve]}],"font-family":[{font:[vk,ve,t]}],"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,ye,ve]}],"line-clamp":[{"line-clamp":[Ae,"none",ye,ei]}],leading:[{leading:[i,...R()]}],"list-image":[{"list-image":["none",ye,ve]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ye,ve]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:F()}],"text-color":[{text:F()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...oe(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ae,"from-font","auto",ye,gn]}],"text-decoration-color":[{decoration:F()}],"underline-offset":[{"underline-offset":[Ae,"auto",ye,ve]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ye,ve]}],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",ye,ve]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Z()}],"bg-repeat":[{bg:J()}],"bg-size":[{bg:H()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Jt,ye,ve],radial:["",ye,ve],conic:[Jt,ye,ve]},wk,bk]}],"bg-color":[{bg:F()}],"gradient-from-pos":[{from:W()}],"gradient-via-pos":[{via:W()}],"gradient-to-pos":[{to:W()}],"gradient-from":[{from:F()}],"gradient-via":[{via:F()}],"gradient-to":[{to:F()}],rounded:[{rounded:ce()}],"rounded-s":[{"rounded-s":ce()}],"rounded-e":[{"rounded-e":ce()}],"rounded-t":[{"rounded-t":ce()}],"rounded-r":[{"rounded-r":ce()}],"rounded-b":[{"rounded-b":ce()}],"rounded-l":[{"rounded-l":ce()}],"rounded-ss":[{"rounded-ss":ce()}],"rounded-se":[{"rounded-se":ce()}],"rounded-ee":[{"rounded-ee":ce()}],"rounded-es":[{"rounded-es":ce()}],"rounded-tl":[{"rounded-tl":ce()}],"rounded-tr":[{"rounded-tr":ce()}],"rounded-br":[{"rounded-br":ce()}],"rounded-bl":[{"rounded-bl":ce()}],"border-w":[{border:se()}],"border-w-x":[{"border-x":se()}],"border-w-y":[{"border-y":se()}],"border-w-s":[{"border-s":se()}],"border-w-e":[{"border-e":se()}],"border-w-t":[{"border-t":se()}],"border-w-r":[{"border-r":se()}],"border-w-b":[{"border-b":se()}],"border-w-l":[{"border-l":se()}],"divide-x":[{"divide-x":se()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":se()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...oe(),"hidden","none"]}],"divide-style":[{divide:[...oe(),"hidden","none"]}],"border-color":[{border:F()}],"border-color-x":[{"border-x":F()}],"border-color-y":[{"border-y":F()}],"border-color-s":[{"border-s":F()}],"border-color-e":[{"border-e":F()}],"border-color-t":[{"border-t":F()}],"border-color-r":[{"border-r":F()}],"border-color-b":[{"border-b":F()}],"border-color-l":[{"border-l":F()}],"divide-color":[{divide:F()}],"outline-style":[{outline:[...oe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ae,ye,ve]}],"outline-w":[{outline:["",Ae,gr,gn]}],"outline-color":[{outline:F()}],shadow:[{shadow:["","none",d,ls,as]}],"shadow-color":[{shadow:F()}],"inset-shadow":[{"inset-shadow":["none",f,ls,as]}],"inset-shadow-color":[{"inset-shadow":F()}],"ring-w":[{ring:se()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:F()}],"ring-offset-w":[{"ring-offset":[Ae,gn]}],"ring-offset-color":[{"ring-offset":F()}],"inset-ring-w":[{"inset-ring":se()}],"inset-ring-color":[{"inset-ring":F()}],"text-shadow":[{"text-shadow":["none",m,ls,as]}],"text-shadow-color":[{"text-shadow":F()}],opacity:[{opacity:[Ae,ye,ve]}],"mix-blend":[{"mix-blend":[..._e(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":_e()}],"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":[Ae]}],"mask-image-linear-from-pos":[{"mask-linear-from":ie()}],"mask-image-linear-to-pos":[{"mask-linear-to":ie()}],"mask-image-linear-from-color":[{"mask-linear-from":F()}],"mask-image-linear-to-color":[{"mask-linear-to":F()}],"mask-image-t-from-pos":[{"mask-t-from":ie()}],"mask-image-t-to-pos":[{"mask-t-to":ie()}],"mask-image-t-from-color":[{"mask-t-from":F()}],"mask-image-t-to-color":[{"mask-t-to":F()}],"mask-image-r-from-pos":[{"mask-r-from":ie()}],"mask-image-r-to-pos":[{"mask-r-to":ie()}],"mask-image-r-from-color":[{"mask-r-from":F()}],"mask-image-r-to-color":[{"mask-r-to":F()}],"mask-image-b-from-pos":[{"mask-b-from":ie()}],"mask-image-b-to-pos":[{"mask-b-to":ie()}],"mask-image-b-from-color":[{"mask-b-from":F()}],"mask-image-b-to-color":[{"mask-b-to":F()}],"mask-image-l-from-pos":[{"mask-l-from":ie()}],"mask-image-l-to-pos":[{"mask-l-to":ie()}],"mask-image-l-from-color":[{"mask-l-from":F()}],"mask-image-l-to-color":[{"mask-l-to":F()}],"mask-image-x-from-pos":[{"mask-x-from":ie()}],"mask-image-x-to-pos":[{"mask-x-to":ie()}],"mask-image-x-from-color":[{"mask-x-from":F()}],"mask-image-x-to-color":[{"mask-x-to":F()}],"mask-image-y-from-pos":[{"mask-y-from":ie()}],"mask-image-y-to-pos":[{"mask-y-to":ie()}],"mask-image-y-from-color":[{"mask-y-from":F()}],"mask-image-y-to-color":[{"mask-y-to":F()}],"mask-image-radial":[{"mask-radial":[ye,ve]}],"mask-image-radial-from-pos":[{"mask-radial-from":ie()}],"mask-image-radial-to-pos":[{"mask-radial-to":ie()}],"mask-image-radial-from-color":[{"mask-radial-from":F()}],"mask-image-radial-to-color":[{"mask-radial-to":F()}],"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":[Ae]}],"mask-image-conic-from-pos":[{"mask-conic-from":ie()}],"mask-image-conic-to-pos":[{"mask-conic-to":ie()}],"mask-image-conic-from-color":[{"mask-conic-from":F()}],"mask-image-conic-to-color":[{"mask-conic-to":F()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Z()}],"mask-repeat":[{mask:J()}],"mask-size":[{mask:H()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ye,ve]}],filter:[{filter:["","none",ye,ve]}],blur:[{blur:ge()}],brightness:[{brightness:[Ae,ye,ve]}],contrast:[{contrast:[Ae,ye,ve]}],"drop-shadow":[{"drop-shadow":["","none",h,ls,as]}],"drop-shadow-color":[{"drop-shadow":F()}],grayscale:[{grayscale:["",Ae,ye,ve]}],"hue-rotate":[{"hue-rotate":[Ae,ye,ve]}],invert:[{invert:["",Ae,ye,ve]}],saturate:[{saturate:[Ae,ye,ve]}],sepia:[{sepia:["",Ae,ye,ve]}],"backdrop-filter":[{"backdrop-filter":["","none",ye,ve]}],"backdrop-blur":[{"backdrop-blur":ge()}],"backdrop-brightness":[{"backdrop-brightness":[Ae,ye,ve]}],"backdrop-contrast":[{"backdrop-contrast":[Ae,ye,ve]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ae,ye,ve]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ae,ye,ve]}],"backdrop-invert":[{"backdrop-invert":["",Ae,ye,ve]}],"backdrop-opacity":[{"backdrop-opacity":[Ae,ye,ve]}],"backdrop-saturate":[{"backdrop-saturate":[Ae,ye,ve]}],"backdrop-sepia":[{"backdrop-sepia":["",Ae,ye,ve]}],"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",ye,ve]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ae,"initial",ye,ve]}],ease:[{ease:["linear","initial",b,ye,ve]}],delay:[{delay:[Ae,ye,ve]}],animate:[{animate:["none",y,ye,ve]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,ye,ve]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:he()}],"rotate-x":[{"rotate-x":he()}],"rotate-y":[{"rotate-y":he()}],"rotate-z":[{"rotate-z":he()}],scale:[{scale:xe()}],"scale-x":[{"scale-x":xe()}],"scale-y":[{"scale-y":xe()}],"scale-z":[{"scale-z":xe()}],"scale-3d":["scale-3d"],skew:[{skew:te()}],"skew-x":[{"skew-x":te()}],"skew-y":[{"skew-y":te()}],transform:[{transform:[ye,ve,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ue()}],"translate-x":[{"translate-x":ue()}],"translate-y":[{"translate-y":ue()}],"translate-z":[{"translate-z":ue()}],"translate-none":["translate-none"],accent:[{accent:F()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:F()}],"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",ye,ve]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"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-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-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",ye,ve]}],fill:[{fill:["none",...F()]}],"stroke-w":[{stroke:[Ae,gr,gn,ei]}],stroke:[{stroke:["none",...F()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","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","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","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-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-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-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-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"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Sk=sk(jk);function le(...e){return Sk(pf(e))}function $e(e){return e>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+"M":(e/1e3).toFixed(1).replace(/\.0$/,"")+"K"}function Cf(e){return e>=1024*1024?(e/(1024*1024)).toFixed(1).replace(/\.0$/,"")+"M":(e/1024).toFixed(1).replace(/\.0$/,"")+"K"}function xc(e,t,n){const r=e*10;return!Number.isSafeInteger(r)||r%t!==0?null:(r/t/10).toFixed(1).replace(/\.0$/,"")+n}function Ck(e){if(!Number.isSafeInteger(e)||e<=0)return e.toString();if(e>=1024*1024){const n=xc(e,1048576,"M");if(n!==null)return n}const t=xc(e,1024,"K");return t!==null?t:e.toString()}function Nk(e){if(e===void 0||e==="")return 1;switch(e.toLowerCase()){case"k":return 1024;case"m":return 1024*1024;default:return null}}function Ws(e){const t=e.trim().replaceAll(",","");if(t==="")return null;const n=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(t);if(n===null)return null;const r=n[1];if(r===void 0)return null;const o=Number(r),i=n[2],a=Nk(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 Tk(e){return e===null?"pending":e>=200&&e<300?"success":e>=400&&e<500?"client_error":e>=500?"server_error":"pending"}const Ek=G({model:N().min(1),contextWindow:K().int().positive().optional(),outputLimit:K().int().positive().optional(),source:Te(["manual","registry"]).optional(),sourceUrl:N().optional(),updatedAt:N().optional()}),Hs=G({id:N(),name:N(),apiKey:N(),model:N().optional(),models:me(N()).min(1),format:Te(["anthropic","openai"]).optional(),baseUrl:N().optional(),anthropicBaseUrl:N().optional(),openaiBaseUrl:N().optional(),openaiResponsesBaseUrl:N().optional(),authHeader:Te(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:N().optional(),modelMetadataUrl:N().optional(),modelMetadata:me(Ek).optional(),source:Te(["company","personal"]).optional(),createdAt:N(),updatedAt:N()});async function Ak(e){return an(e,Hs.array(),void 0,t=>`Failed to fetch ${e}: ${t.status}`)}function Nf(){const e=Tn("/api/providers?includeSecrets=1",Ak,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function je(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function bc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Tf(...e){return t=>{let n=!1;const r=e.map(o=>{const i=bc(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():bc(e[o],null)}}}}function De(...e){return p.useCallback(Tf(...e),e)}function Rk(e,t){const n=p.createContext(t),r=i=>{const{children:a,...l}=i,c=p.useMemo(()=>l,Object.values(l));return s.jsx(n.Provider,{value:c,children:a})};r.displayName=e+"Provider";function o(i){const a=p.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,o]}function Gt(e,t=[]){let n=[];function r(i,a){const l=p.createContext(a),c=n.length;n=[...n,a];const u=f=>{const{scope:m,children:h,...v}=f,g=m?.[e]?.[c]||l,x=p.useMemo(()=>v,Object.values(v));return s.jsx(g.Provider,{value:x,children:h})};u.displayName=i+"Provider";function d(f,m){const h=m?.[e]?.[c]||l,v=p.useContext(h);if(v)return v;if(a!==void 0)return a;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,[r,Ik(o,...t)]}function Ik(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const a=r.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}var Xe=globalThis?.document?p.useLayoutEffect:()=>{},zk=ed[" useId ".trim().toString()]||(()=>{}),Pk=0;function zt(e){const[t,n]=p.useState(zk());return Xe(()=>{n(r=>r??String(Pk++))},[e]),e||(t?`radix-${t}`:"")}var Ok=ed[" useInsertionEffect ".trim().toString()]||Xe;function _n({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,a]=Mk({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(`${r} 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,r])}const u=p.useCallback(d=>{if(l){const f=Lk(d)?d(e):d;f!==e&&a.current?.(f)}else i(d)},[l,e,i,a]);return[c,u]}function Mk({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),i=p.useRef(t);return Ok(()=>{i.current=t},[t]),p.useEffect(()=>{o.current!==n&&(i.current?.(n),o.current=n)},[n,o]),[n,r,i]}function Lk(e){return typeof e=="function"}function rr(e){const t=$k(e),n=p.forwardRef((r,o)=>{const{children:i,...a}=r,l=p.Children.toArray(i),c=l.find(Bk);if(c){const u=c.props.children,d=l.map(f=>f===c?p.Children.count(u)>1?p.Children.only(null):p.isValidElement(u)?u.props.children:null:f);return s.jsx(t,{...a,ref:o,children:p.isValidElement(u)?p.cloneElement(u,void 0,d):null})}return s.jsx(t,{...a,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}var Dk=rr("Slot");function $k(e){const t=p.forwardRef((n,r)=>{const{children:o,...i}=n;if(p.isValidElement(o)){const a=Wk(o),l=Uk(i,o.props);return o.type!==p.Fragment&&(l.ref=r?Tf(r,a):a),p.cloneElement(o,l)}return p.Children.count(o)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ef=Symbol("radix.slottable");function Fk(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=Ef,t}function Bk(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ef}function Uk(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const c=i(...l);return o(...l),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Wk(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 Hk=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ee=Hk.reduce((e,t)=>{const n=rr(`Primitive.${t}`),r=p.forwardRef((o,i)=>{const{asChild:a,...l}=o,c=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(c,{...l,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Zk(e,t){e&&Br.flushSync(()=>e.dispatchEvent(t))}function rt(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>t.current?.(...n),[])}function Vk(e,t=globalThis?.document){const n=rt(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var qk="DismissableLayer",Vi="dismissableLayer.update",Kk="dismissableLayer.pointerDownOutside",Gk="dismissableLayer.focusOutside",vc,Af=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),jo=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:a,onDismiss:l,...c}=e,u=p.useContext(Af),[d,f]=p.useState(null),m=d?.ownerDocument??globalThis?.document,[,h]=p.useState({}),v=De(t,C=>f(C)),g=Array.from(u.layers),[x]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=g.indexOf(x),y=d?g.indexOf(d):-1,_=u.layersWithOutsidePointerEventsDisabled.size>0,j=y>=b,S=Xk(C=>{const R=C.target,z=[...u.branches].some(O=>O.contains(R));!j||z||(o?.(C),a?.(C),C.defaultPrevented||l?.())},m),E=Qk(C=>{const R=C.target;[...u.branches].some(O=>O.contains(R))||(i?.(C),a?.(C),C.defaultPrevented||l?.())},m);return Vk(C=>{y===u.layers.size-1&&(r?.(C),!C.defaultPrevented&&l&&(C.preventDefault(),l()))},m),p.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(vc=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),yc(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=vc)}},[d,m,n,u]),p.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),yc())},[d,u]),p.useEffect(()=>{const C=()=>h({});return document.addEventListener(Vi,C),()=>document.removeEventListener(Vi,C)},[]),s.jsx(Ee.div,{...c,ref:v,style:{pointerEvents:_?j?"auto":"none":void 0,...e.style},onFocusCapture:je(e.onFocusCapture,E.onFocusCapture),onBlurCapture:je(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:je(e.onPointerDownCapture,S.onPointerDownCapture)})});jo.displayName=qk;var Jk="DismissableLayerBranch",Yk=p.forwardRef((e,t)=>{const n=p.useContext(Af),r=p.useRef(null),o=De(t,r);return p.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(Ee.div,{...e,ref:o})});Yk.displayName=Jk;function Xk(e,t=globalThis?.document){const n=rt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let c=function(){Rf(Kk,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Qk(e,t=globalThis?.document){const n=rt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=i=>{i.target&&!r.current&&Rf(Gk,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function yc(){const e=new CustomEvent(Vi);document.dispatchEvent(e)}function Rf(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Zk(o,i):o.dispatchEvent(i)}var ti="focusScope.autoFocusOnMount",ni="focusScope.autoFocusOnUnmount",wc={bubbles:!1,cancelable:!0},e_="FocusScope",el=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...a}=e,[l,c]=p.useState(null),u=rt(o),d=rt(i),f=p.useRef(null),m=De(t,g=>c(g)),h=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(_){if(h.paused||!l)return;const j=_.target;l.contains(j)?f.current=j:en(f.current,{select:!0})},x=function(_){if(h.paused||!l)return;const j=_.relatedTarget;j!==null&&(l.contains(j)||en(f.current,{select:!0}))},b=function(_){if(document.activeElement===document.body)for(const S of _)S.removedNodes.length>0&&en(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const y=new MutationObserver(b);return l&&y.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),y.disconnect()}}},[r,l,h.paused]),p.useEffect(()=>{if(l){_c.add(h);const g=document.activeElement;if(!l.contains(g)){const b=new CustomEvent(ti,wc);l.addEventListener(ti,u),l.dispatchEvent(b),b.defaultPrevented||(t_(i_(If(l)),{select:!0}),document.activeElement===g&&en(l))}return()=>{l.removeEventListener(ti,u),setTimeout(()=>{const b=new CustomEvent(ni,wc);l.addEventListener(ni,d),l.dispatchEvent(b),b.defaultPrevented||en(g??document.body,{select:!0}),l.removeEventListener(ni,d),_c.remove(h)},0)}}},[l,u,d,h]);const v=p.useCallback(g=>{if(!n&&!r||h.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,b=document.activeElement;if(x&&b){const y=g.currentTarget,[_,j]=n_(y);_&&j?!g.shiftKey&&b===j?(g.preventDefault(),n&&en(_,{select:!0})):g.shiftKey&&b===_&&(g.preventDefault(),n&&en(j,{select:!0})):b===y&&g.preventDefault()}},[n,r,h.paused]);return s.jsx(Ee.div,{tabIndex:-1,...a,ref:m,onKeyDown:v})});el.displayName=e_;function t_(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(en(r,{select:t}),document.activeElement!==n)return}function n_(e){const t=If(e),n=kc(t,e),r=kc(t.reverse(),e);return[n,r]}function If(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function kc(e,t){for(const n of e)if(!r_(n,{upTo:t}))return n}function r_(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 s_(e){return e instanceof HTMLInputElement&&"select"in e}function en(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&s_(e)&&t&&e.select()}}var _c=o_();function o_(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=jc(e,t),e.unshift(t)},remove(t){e=jc(e,t),e[0]?.resume()}}}function jc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function i_(e){return e.filter(t=>t.tagName!=="A")}var a_="Portal",So=p.forwardRef((e,t)=>{const{container:n,...r}=e,[o,i]=p.useState(!1);Xe(()=>i(!0),[]);const a=n||o&&globalThis?.document?.body;return a?ng.createPortal(s.jsx(Ee.div,{...r,ref:t}),a):null});So.displayName=a_;function l_(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var vt=e=>{const{present:t,children:n}=e,r=c_(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),i=De(r.ref,u_(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:i}):null};vt.displayName="Presence";function c_(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),i=p.useRef("none"),a=e?"mounted":"unmounted",[l,c]=l_(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const u=cs(r.current);i.current=l==="mounted"?u:"none"},[l]),Xe(()=>{const u=r.current,d=o.current;if(d!==e){const m=i.current,h=cs(u);e?c("MOUNT"):h==="none"||u?.display==="none"?c("UNMOUNT"):c(d&&m!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),Xe(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=h=>{const g=cs(r.current).includes(CSS.escape(h.animationName));if(h.target===t&&g&&(c("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=h=>{h.target===t&&(i.current=cs(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:p.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function cs(e){return e?.animationName||"none"}function u_(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 ri=0;function zf(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Sc()),document.body.insertAdjacentElement("beforeend",e[1]??Sc()),ri++,()=>{ri===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ri--}},[])}function Sc(){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 Rt=function(){return Rt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Rt.apply(this,arguments)};function Pf(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function d_(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var As="right-scroll-bar-position",Rs="width-before-scroll-bar",f_="with-scroll-bars-hidden",p_="--removed-body-scroll-bar-size";function si(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function h_(e,t){var n=p.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var m_=typeof window<"u"?p.useLayoutEffect:p.useEffect,Cc=new WeakMap;function g_(e,t){var n=h_(null,function(r){return e.forEach(function(o){return si(o,r)})});return m_(function(){var r=Cc.get(n);if(r){var o=new Set(r),i=new Set(e),a=n.current;o.forEach(function(l){i.has(l)||si(l,null)}),i.forEach(function(l){o.has(l)||si(l,a)})}Cc.set(n,e)},[e]),n}function x_(e){return e}function b_(e,t){t===void 0&&(t=x_);var n=[],r=!1,o={read:function(){if(r)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,r);return n.push(a),function(){n=n.filter(function(l){return l!==a})}},assignSyncMedium:function(i){for(r=!0;n.length;){var a=n;n=[],a.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){r=!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 v_(e){e===void 0&&(e={});var t=b_(null);return t.options=Rt({async:!0,ssr:!1},e),t}var Of=function(e){var t=e.sideCar,n=Pf(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Rt({},n))};Of.isSideCarExport=!0;function y_(e,t){return e.useMedium(t),Of}var Mf=v_(),oi=function(){},Co=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:oi,onWheelCapture:oi,onTouchMoveCapture:oi}),o=r[0],i=r[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,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,b=e.as,y=b===void 0?"div":b,_=e.gapMode,j=Pf(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,E=g_([n,t]),C=Rt(Rt({},j),o);return p.createElement(p.Fragment,null,d&&p.createElement(S,{sideCar:Mf,removeScrollBar:u,shards:f,noRelative:h,noIsolation:v,inert:g,setCallbacks:i,allowPinchZoom:!!x,lockRef:n,gapMode:_}),a?p.cloneElement(p.Children.only(l),Rt(Rt({},C),{ref:E})):p.createElement(y,Rt({},C,{className:c,ref:E}),l))});Co.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Co.classNames={fullWidth:Rs,zeroRight:As};var w_=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function k_(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=w_();return t&&e.setAttribute("nonce",t),e}function __(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function j_(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var S_=function(){var e=0,t=null;return{add:function(n){e==0&&(t=k_())&&(__(t,n),j_(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},C_=function(){var e=S_();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Lf=function(){var e=C_(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},N_={left:0,top:0,right:0,gap:0},ii=function(e){return parseInt(e||"",10)||0},T_=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[ii(n),ii(r),ii(o)]},E_=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return N_;var t=T_(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},A_=Lf(),Gn="data-scroll-locked",R_=function(e,t,n,r){var o=e.left,i=e.top,a=e.right,l=e.gap;return n===void 0&&(n="margin"),`
42
+ .`.concat(f_,` {
43
43
  overflow: hidden `).concat(r,`;
44
44
  padding-right: `).concat(l,"px ").concat(r,`;
45
45
  }
@@ -56,51 +56,51 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
56
56
  `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
57
57
  }
58
58
 
59
- .`).concat(Es,` {
59
+ .`).concat(As,` {
60
60
  right: `).concat(l,"px ").concat(r,`;
61
61
  }
62
62
 
63
- .`).concat(As,` {
63
+ .`).concat(Rs,` {
64
64
  margin-right: `).concat(l,"px ").concat(r,`;
65
65
  }
66
66
 
67
- .`).concat(Es," .").concat(Es,` {
67
+ .`).concat(As," .").concat(As,` {
68
68
  right: 0 `).concat(r,`;
69
69
  }
70
70
 
71
- .`).concat(As," .").concat(As,` {
71
+ .`).concat(Rs," .").concat(Rs,` {
72
72
  margin-right: 0 `).concat(r,`;
73
73
  }
74
74
 
75
75
  body[`).concat(Gn,`] {
76
- `).concat(u_,": ").concat(l,`px;
76
+ `).concat(p_,": ").concat(l,`px;
77
77
  }
78
- `)},Sc=function(){var e=parseInt(document.body.getAttribute(Gn)||"0",10);return isFinite(e)?e:0},E_=function(){p.useEffect(function(){return document.body.setAttribute(Gn,(Sc()+1).toString()),function(){var e=Sc()-1;e<=0?document.body.removeAttribute(Gn):document.body.setAttribute(Gn,e.toString())}},[])},A_=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;E_();var i=p.useMemo(function(){return C_(o)},[o]);return p.createElement(N_,{styles:T_(i,!t,o,n?"":"!important")})},Zi=!1;if(typeof window<"u")try{var cs=Object.defineProperty({},"passive",{get:function(){return Zi=!0,!0}});window.addEventListener("test",cs,cs),window.removeEventListener("test",cs,cs)}catch{Zi=!1}var On=Zi?{passive:!1}:!1,R_=function(e){return e.tagName==="TEXTAREA"},Mf=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!R_(e)&&n[t]==="visible")},I_=function(e){return Mf(e,"overflowY")},z_=function(e){return Mf(e,"overflowX")},Cc=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Lf(e,r);if(o){var i=Df(e,r),a=i[1],l=i[2];if(a>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},P_=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},O_=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Lf=function(e,t){return e==="v"?I_(t):z_(t)},Df=function(e,t){return e==="v"?P_(t):O_(t)},M_=function(e,t){return e==="h"&&t==="rtl"?-1:1},L_=function(e,t,n,r,o){var i=M_(e,window.getComputedStyle(t).direction),a=i*r,l=n.target,c=t.contains(l),u=!1,d=a>0,f=0,m=0;do{if(!l)break;var h=Df(e,l),v=h[0],g=h[1],x=h[2],b=g-x-i*v;(v||b)&&Lf(e,l)&&(f+=b,m+=v);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},us=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Nc=function(e){return[e.deltaX,e.deltaY]},Tc=function(e){return e&&"current"in e?e.current:e},D_=function(e,t){return e[0]===t[0]&&e[1]===t[1]},$_=function(e){return`
78
+ `)},Nc=function(){var e=parseInt(document.body.getAttribute(Gn)||"0",10);return isFinite(e)?e:0},I_=function(){p.useEffect(function(){return document.body.setAttribute(Gn,(Nc()+1).toString()),function(){var e=Nc()-1;e<=0?document.body.removeAttribute(Gn):document.body.setAttribute(Gn,e.toString())}},[])},z_=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;I_();var i=p.useMemo(function(){return E_(o)},[o]);return p.createElement(A_,{styles:R_(i,!t,o,n?"":"!important")})},qi=!1;if(typeof window<"u")try{var us=Object.defineProperty({},"passive",{get:function(){return qi=!0,!0}});window.addEventListener("test",us,us),window.removeEventListener("test",us,us)}catch{qi=!1}var On=qi?{passive:!1}:!1,P_=function(e){return e.tagName==="TEXTAREA"},Df=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!P_(e)&&n[t]==="visible")},O_=function(e){return Df(e,"overflowY")},M_=function(e){return Df(e,"overflowX")},Tc=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=$f(e,r);if(o){var i=Ff(e,r),a=i[1],l=i[2];if(a>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},L_=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},D_=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},$f=function(e,t){return e==="v"?O_(t):M_(t)},Ff=function(e,t){return e==="v"?L_(t):D_(t)},$_=function(e,t){return e==="h"&&t==="rtl"?-1:1},F_=function(e,t,n,r,o){var i=$_(e,window.getComputedStyle(t).direction),a=i*r,l=n.target,c=t.contains(l),u=!1,d=a>0,f=0,m=0;do{if(!l)break;var h=Ff(e,l),v=h[0],g=h[1],x=h[2],b=g-x-i*v;(v||b)&&$f(e,l)&&(f+=b,m+=v);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},ds=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ec=function(e){return[e.deltaX,e.deltaY]},Ac=function(e){return e&&"current"in e?e.current:e},B_=function(e,t){return e[0]===t[0]&&e[1]===t[1]},U_=function(e){return`
79
79
  .block-interactivity-`.concat(e,` {pointer-events: none;}
80
80
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
81
- `)},F_=0,Mn=[];function B_(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(F_++)[0],i=p.useState(Of)[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=l_([e.lockRef.current],(e.shards||[]).map(Tc),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=p.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!a.current.allowPinchZoom;var b=us(g),y=n.current,_="deltaX"in g?g.deltaX:y[0]-b[0],j="deltaY"in g?g.deltaY:y[1]-b[1],S,E=g.target,C=Math.abs(_)>Math.abs(j)?"h":"v";if("touches"in g&&C==="h"&&E.type==="range")return!1;var R=window.getSelection(),z=R&&R.anchorNode,O=z?z===E||z.contains(E):!1;if(O)return!1;var q=Cc(C,E);if(!q)return!0;if(q?S=C:(S=C==="v"?"h":"v",q=Cc(C,E)),!q)return!1;if(!r.current&&"changedTouches"in g&&(_||j)&&(r.current=S),!S)return!0;var T=r.current||S;return L_(T,x,g,T==="h"?_:j)},[]),c=p.useCallback(function(g){var x=g;if(!(!Mn.length||Mn[Mn.length-1]!==i)){var b="deltaY"in x?Nc(x):us(x),y=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&D_(S.delta,b)})[0];if(y&&y.should){x.cancelable&&x.preventDefault();return}if(!y){var _=(a.current.shards||[]).map(Tc).filter(Boolean).filter(function(S){return S.contains(x.target)}),j=_.length>0?l(x,_[0]):!a.current.noIsolation;j&&x.cancelable&&x.preventDefault()}}},[]),u=p.useCallback(function(g,x,b,y){var _={name:g,delta:x,target:b,should:y,shadowParent:U_(b)};t.current.push(_),setTimeout(function(){t.current=t.current.filter(function(j){return j!==_})},1)},[]),d=p.useCallback(function(g){n.current=us(g),r.current=void 0},[]),f=p.useCallback(function(g){u(g.type,Nc(g),g.target,l(g,e.lockRef.current))},[]),m=p.useCallback(function(g){u(g.type,us(g),g.target,l(g,e.lockRef.current))},[]);p.useEffect(function(){return Mn.push(i),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",c,On),document.addEventListener("touchmove",c,On),document.addEventListener("touchstart",d,On),function(){Mn=Mn.filter(function(g){return g!==i}),document.removeEventListener("wheel",c,On),document.removeEventListener("touchmove",c,On),document.removeEventListener("touchstart",d,On)}},[]);var h=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(i,{styles:$_(o)}):null,h?p.createElement(A_,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function U_(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const W_=x_(Pf,B_);var Qa=p.forwardRef(function(e,t){return p.createElement(So,Rt({},e,{ref:t,sideCar:W_}))});Qa.classNames=So.classNames;var H_=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ln=new WeakMap,ds=new WeakMap,fs={},ii=0,$f=function(e){return e&&(e.host||$f(e.parentNode))},Z_=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=$f(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},V_=function(e,t,n,r){var o=Z_(t,Array.isArray(e)?e:[e]);fs[n]||(fs[n]=new WeakMap);var i=fs[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(r),v=h!==null&&h!=="false",g=(Ln.get(m)||0)+1,x=(i.get(m)||0)+1;Ln.set(m,g),i.set(m,x),a.push(m),g===1&&v&&ds.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",m,b)}})};return d(t),l.clear(),ii++,function(){a.forEach(function(f){var m=Ln.get(f)-1,h=i.get(f)-1;Ln.set(f,m),i.set(f,h),m||(ds.has(f)||f.removeAttribute(r),ds.delete(f)),h||f.removeAttribute(n)}),ii--,ii||(Ln=new WeakMap,Ln=new WeakMap,ds=new WeakMap,fs={})}},Ff=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=H_(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),V_(r,o,n,"aria-hidden")):function(){return null}},Co="Dialog",[Bf]=Gt(Co),[q_,Tt]=Bf(Co),Uf=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:a=!0}=e,l=p.useRef(null),c=p.useRef(null),[u,d]=_n({prop:r,defaultProp:o??!1,onChange:i,caller:Co});return s.jsx(q_,{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})};Uf.displayName=Co;var Wf="DialogTrigger",Hf=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Tt(Wf,n),i=De(t,o.triggerRef);return s.jsx(Ee.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":nl(o.open),...r,ref:i,onClick:je(e.onClick,o.onOpenToggle)})});Hf.displayName=Wf;var el="DialogPortal",[K_,Zf]=Bf(el,{forceMount:void 0}),Vf=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,i=Tt(el,t);return s.jsx(K_,{scope:t,forceMount:n,children:p.Children.map(r,a=>s.jsx(vt,{present:n||i.open,children:s.jsx(jo,{asChild:!0,container:o,children:a})}))})};Vf.displayName=el;var Hs="DialogOverlay",qf=p.forwardRef((e,t)=>{const n=Zf(Hs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Tt(Hs,e.__scopeDialog);return i.modal?s.jsx(vt,{present:r||i.open,children:s.jsx(J_,{...o,ref:t})}):null});qf.displayName=Hs;var G_=rr("DialogOverlay.RemoveScroll"),J_=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Tt(Hs,n);return s.jsx(Qa,{as:G_,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(Ee.div,{"data-state":nl(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),jn="DialogContent",Kf=p.forwardRef((e,t)=>{const n=Zf(jn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Tt(jn,e.__scopeDialog);return s.jsx(vt,{present:r||i.open,children:i.modal?s.jsx(Y_,{...o,ref:t}):s.jsx(X_,{...o,ref:t})})});Kf.displayName=jn;var Y_=p.forwardRef((e,t)=>{const n=Tt(jn,e.__scopeDialog),r=p.useRef(null),o=De(t,n.contentRef,r);return p.useEffect(()=>{const i=r.current;if(i)return Ff(i)},[]),s.jsx(Gf,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:je(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:je(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&i.preventDefault()}),onFocusOutside:je(e.onFocusOutside,i=>i.preventDefault())})}),X_=p.forwardRef((e,t)=>{const n=Tt(jn,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return s.jsx(Gf,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.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()}})}),Gf=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...a}=e,l=Tt(jn,n),c=p.useRef(null),u=De(t,c);return Rf(),s.jsxs(s.Fragment,{children:[s.jsx(Xa,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:s.jsx(_o,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":nl(l.open),...a,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(Q_,{titleId:l.titleId}),s.jsx(tj,{contentRef:c,descriptionId:l.descriptionId})]})]})}),tl="DialogTitle",Jf=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Tt(tl,n);return s.jsx(Ee.h2,{id:o.titleId,...r,ref:t})});Jf.displayName=tl;var Yf="DialogDescription",Xf=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Tt(Yf,n);return s.jsx(Ee.p,{id:o.descriptionId,...r,ref:t})});Xf.displayName=Yf;var Qf="DialogClose",ep=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Tt(Qf,n);return s.jsx(Ee.button,{type:"button",...r,ref:t,onClick:je(e.onClick,()=>o.onOpenChange(!1))})});ep.displayName=Qf;function nl(e){return e?"open":"closed"}var tp="DialogTitleWarning",[sz,np]=Tk(tp,{contentName:jn,titleName:tl,docsSlug:"dialog"}),Q_=({titleId:e})=>{const t=np(tp),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
81
+ `)},W_=0,Mn=[];function H_(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(W_++)[0],i=p.useState(Lf)[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=d_([e.lockRef.current],(e.shards||[]).map(Ac),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=p.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!a.current.allowPinchZoom;var b=ds(g),y=n.current,_="deltaX"in g?g.deltaX:y[0]-b[0],j="deltaY"in g?g.deltaY:y[1]-b[1],S,E=g.target,C=Math.abs(_)>Math.abs(j)?"h":"v";if("touches"in g&&C==="h"&&E.type==="range")return!1;var R=window.getSelection(),z=R&&R.anchorNode,O=z?z===E||z.contains(E):!1;if(O)return!1;var q=Tc(C,E);if(!q)return!0;if(q?S=C:(S=C==="v"?"h":"v",q=Tc(C,E)),!q)return!1;if(!r.current&&"changedTouches"in g&&(_||j)&&(r.current=S),!S)return!0;var T=r.current||S;return F_(T,x,g,T==="h"?_:j)},[]),c=p.useCallback(function(g){var x=g;if(!(!Mn.length||Mn[Mn.length-1]!==i)){var b="deltaY"in x?Ec(x):ds(x),y=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&B_(S.delta,b)})[0];if(y&&y.should){x.cancelable&&x.preventDefault();return}if(!y){var _=(a.current.shards||[]).map(Ac).filter(Boolean).filter(function(S){return S.contains(x.target)}),j=_.length>0?l(x,_[0]):!a.current.noIsolation;j&&x.cancelable&&x.preventDefault()}}},[]),u=p.useCallback(function(g,x,b,y){var _={name:g,delta:x,target:b,should:y,shadowParent:Z_(b)};t.current.push(_),setTimeout(function(){t.current=t.current.filter(function(j){return j!==_})},1)},[]),d=p.useCallback(function(g){n.current=ds(g),r.current=void 0},[]),f=p.useCallback(function(g){u(g.type,Ec(g),g.target,l(g,e.lockRef.current))},[]),m=p.useCallback(function(g){u(g.type,ds(g),g.target,l(g,e.lockRef.current))},[]);p.useEffect(function(){return Mn.push(i),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",c,On),document.addEventListener("touchmove",c,On),document.addEventListener("touchstart",d,On),function(){Mn=Mn.filter(function(g){return g!==i}),document.removeEventListener("wheel",c,On),document.removeEventListener("touchmove",c,On),document.removeEventListener("touchstart",d,On)}},[]);var h=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(i,{styles:U_(o)}):null,h?p.createElement(z_,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Z_(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const V_=y_(Mf,H_);var tl=p.forwardRef(function(e,t){return p.createElement(Co,Rt({},e,{ref:t,sideCar:V_}))});tl.classNames=Co.classNames;var q_=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ln=new WeakMap,fs=new WeakMap,ps={},ai=0,Bf=function(e){return e&&(e.host||Bf(e.parentNode))},K_=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Bf(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},G_=function(e,t,n,r){var o=K_(t,Array.isArray(e)?e:[e]);ps[n]||(ps[n]=new WeakMap);var i=ps[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(r),v=h!==null&&h!=="false",g=(Ln.get(m)||0)+1,x=(i.get(m)||0)+1;Ln.set(m,g),i.set(m,x),a.push(m),g===1&&v&&fs.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",m,b)}})};return d(t),l.clear(),ai++,function(){a.forEach(function(f){var m=Ln.get(f)-1,h=i.get(f)-1;Ln.set(f,m),i.set(f,h),m||(fs.has(f)||f.removeAttribute(r),fs.delete(f)),h||f.removeAttribute(n)}),ai--,ai||(Ln=new WeakMap,Ln=new WeakMap,fs=new WeakMap,ps={})}},Uf=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=q_(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),G_(r,o,n,"aria-hidden")):function(){return null}},No="Dialog",[Wf]=Gt(No),[J_,Tt]=Wf(No),Hf=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:a=!0}=e,l=p.useRef(null),c=p.useRef(null),[u,d]=_n({prop:r,defaultProp:o??!1,onChange:i,caller:No});return s.jsx(J_,{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})};Hf.displayName=No;var Zf="DialogTrigger",Vf=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Tt(Zf,n),i=De(t,o.triggerRef);return s.jsx(Ee.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":sl(o.open),...r,ref:i,onClick:je(e.onClick,o.onOpenToggle)})});Vf.displayName=Zf;var nl="DialogPortal",[Y_,qf]=Wf(nl,{forceMount:void 0}),Kf=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,i=Tt(nl,t);return s.jsx(Y_,{scope:t,forceMount:n,children:p.Children.map(r,a=>s.jsx(vt,{present:n||i.open,children:s.jsx(So,{asChild:!0,container:o,children:a})}))})};Kf.displayName=nl;var Zs="DialogOverlay",Gf=p.forwardRef((e,t)=>{const n=qf(Zs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Tt(Zs,e.__scopeDialog);return i.modal?s.jsx(vt,{present:r||i.open,children:s.jsx(Q_,{...o,ref:t})}):null});Gf.displayName=Zs;var X_=rr("DialogOverlay.RemoveScroll"),Q_=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Tt(Zs,n);return s.jsx(tl,{as:X_,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(Ee.div,{"data-state":sl(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),jn="DialogContent",Jf=p.forwardRef((e,t)=>{const n=qf(jn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Tt(jn,e.__scopeDialog);return s.jsx(vt,{present:r||i.open,children:i.modal?s.jsx(ej,{...o,ref:t}):s.jsx(tj,{...o,ref:t})})});Jf.displayName=jn;var ej=p.forwardRef((e,t)=>{const n=Tt(jn,e.__scopeDialog),r=p.useRef(null),o=De(t,n.contentRef,r);return p.useEffect(()=>{const i=r.current;if(i)return Uf(i)},[]),s.jsx(Yf,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:je(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:je(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&i.preventDefault()}),onFocusOutside:je(e.onFocusOutside,i=>i.preventDefault())})}),tj=p.forwardRef((e,t)=>{const n=Tt(jn,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return s.jsx(Yf,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.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()}})}),Yf=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...a}=e,l=Tt(jn,n),c=p.useRef(null),u=De(t,c);return zf(),s.jsxs(s.Fragment,{children:[s.jsx(el,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:s.jsx(jo,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":sl(l.open),...a,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(nj,{titleId:l.titleId}),s.jsx(sj,{contentRef:c,descriptionId:l.descriptionId})]})]})}),rl="DialogTitle",Xf=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Tt(rl,n);return s.jsx(Ee.h2,{id:o.titleId,...r,ref:t})});Xf.displayName=rl;var Qf="DialogDescription",ep=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Tt(Qf,n);return s.jsx(Ee.p,{id:o.descriptionId,...r,ref:t})});ep.displayName=Qf;var tp="DialogClose",np=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Tt(tp,n);return s.jsx(Ee.button,{type:"button",...r,ref:t,onClick:je(e.onClick,()=>o.onOpenChange(!1))})});np.displayName=tp;function sl(e){return e?"open":"closed"}var rp="DialogTitleWarning",[sz,sp]=Rk(rp,{contentName:jn,titleName:rl,docsSlug:"dialog"}),nj=({titleId:e})=>{const t=sp(rp),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
82
82
 
83
83
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
84
84
 
85
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},ej="DialogDescriptionWarning",tj=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${np(ej).contentName}}.`;return p.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},nj=Uf,rj=Hf,sj=Vf,oj=qf,ij=Kf,aj=Jf,lj=Xf,cj=ep;function Wr({...e}){return s.jsx(nj,{"data-slot":"dialog",...e})}function rl({...e}){return s.jsx(rj,{"data-slot":"dialog-trigger",...e})}function uj({...e}){return s.jsx(sj,{"data-slot":"dialog-portal",...e})}function dj({className:e,...t}){return s.jsx(oj,{"data-slot":"dialog-overlay",className:ae("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 Hr({className:e,children:t,...n}){return s.jsxs(uj,{children:[s.jsx(dj,{}),s.jsxs(ij,{"data-slot":"dialog-content",className:ae("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,s.jsxs(cj,{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:[s.jsx(ko,{className:"size-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Zr({className:e,...t}){return s.jsx("div",{"data-slot":"dialog-header",className:ae("flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function Vr({className:e,...t}){return s.jsx(aj,{"data-slot":"dialog-title",className:ae("text-lg font-semibold leading-none tracking-tight",e),...t})}function fj({className:e,...t}){return s.jsx(lj,{"data-slot":"dialog-description",className:ae("text-sm text-muted-foreground",e),...t})}const Ec=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ac=df,sl=(e,t)=>n=>{var r;if(t?.variants==null)return Ac(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=Ec(d)||Ec(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||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:f,className:m,...h}=d;return Object.entries(h).every(v=>{let[g,x]=v;return Array.isArray(x)?x.includes({...i,...l}[g]):{...i,...l}[g]===x})?[...u,f,m]:u},[]);return Ac(e,a,c,n?.class,n?.className)},pj=sl("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 Se({className:e,variant:t,size:n,...r}){return s.jsx("button",{"data-slot":"button",className:ae(pj({variant:t,size:n,className:e})),...r})}function rp({open:e,onOpenChange:t,title:n,description:r,confirmLabel:o="Confirm",variant:i="default",onConfirm:a}){return s.jsx(Wr,{open:e,onOpenChange:t,children:s.jsxs(Hr,{children:[s.jsx(Zr,{children:s.jsx(Vr,{children:n})}),s.jsx("p",{className:"text-sm text-muted-foreground",children:r}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Se,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),s.jsx(Se,{variant:i,size:"sm",onClick:()=>{a(),t(!1)},children:o})]})]})})}const hj={codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code"};function ai(e){return e?.toLowerCase()??""}function ps(e,t){for(const n of t)if(e.includes(n))return!0;return!1}function ol(e){const t=[ai(e.userAgent),ai(e.conversationId),ai(e.clientProjectFolder)].join(" ");return ps(t,["mimocode","mimo-code","mimo code"])?"mimo-code":ps(t,["opencode","open-code","open code"])?"opencode":ps(t,["claude-code","claude code","claudecode"])?"claude-code":ps(t,["codex desktop","codex-cli","openai-codex","codex"])?"codex":"unknown"}function No(e){switch(e){case"codex":case"opencode":case"mimo-code":case"claude-code":return hj[e];case"unknown":return null}}function mj(){return s.jsxs("svg",{viewBox:"0 0 24 24",className:"size-full","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"2.2"}),s.jsx("path",{d:"M14.8 8.6a4.8 4.8 0 1 0 0 6.8",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2.2"})]})}function gj(){return s.jsxs("svg",{viewBox:"0 0 24 24",className:"size-full","aria-hidden":"true",children:[s.jsx("path",{d:"M7 4h10v16H7z",fill:"none",stroke:"currentColor",strokeWidth:"2.2"}),s.jsx("path",{d:"M10 8h4M10 12h4M10 16h2",stroke:"currentColor",strokeLinecap:"round"})]})}function xj(){return s.jsx("svg",{viewBox:"0 0 24 24",className:"size-full","aria-hidden":"true",children:s.jsx("path",{d:"M5 18V6h3.2l3.8 6.1L15.8 6H19v12h-3V11.3l-3.1 5h-1.8L8 11.3V18z",fill:"currentColor"})})}function bj(){return s.jsx("svg",{viewBox:"0 0 24 24",className:"size-full","aria-hidden":"true",children:s.jsx("path",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",d:"M21 10.95h3v3.1h-3v3.03h-1.49V20H18v-2.92h-1.49V20H15v-2.92H9V20H7.49v-2.92H6V20H4.49v-2.92H3v-3.03H0v-3.1h3V5h18v5.95zM6 10.95h1.49V8.1H6v2.85zm10.51 0H18V8.1h-1.49v2.85z"})})}function il({client:e,className:t}){const n=No(e);return n===null?null:s.jsxs("span",{className:ae("border border-border bg-muted/40 inline-flex size-6 shrink-0 items-center justify-center rounded-md p-1 text-cyan-100",t),"aria-label":n,title:n,children:[e==="codex"&&s.jsx(mj,{}),e==="opencode"&&s.jsx(gj,{}),e==="mimo-code"&&s.jsx(xj,{}),e==="claude-code"&&s.jsx(bj,{})]})}const vj="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",yj="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",wj="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",kj="/assets/minimax-BPMzvuL-.jpeg",_j="/assets/alibaba-TTwafVwX.svg",jj="/assets/qwen-CONDcHqt.png",Sj="/assets/zhipuai-BPNAnxo-.svg",Cj={"claude-":"anthropic","gpt-":"openai","o1-":"openai","o3-":"openai","deepseek-":"deepseek",MiniMax:"minimax",qwen:"qwen"};function Nj(e){return e.replace(/[_\s]+/g,"-").split(/[/:@]/).some(n=>n.startsWith("glm-"))}function Tj(e){if(e===null)return"unknown";const t=e.toLowerCase();if(Nj(t))return"zhipuai";for(const[n,r]of Object.entries(Cj))if(t.startsWith(n.toLowerCase()))return r;return"unknown"}const In={width:24,height:24,objectFit:"contain"},Ej=ot.memo(({className:e})=>s.jsx("img",{src:vj,alt:"Anthropic",className:e,style:In})),Aj=ot.memo(({className:e})=>s.jsx("img",{src:yj,alt:"OpenAI",className:e,style:{...In,background:"white",borderRadius:"4px"}})),Rj=ot.memo(({className:e})=>s.jsx("img",{src:wj,alt:"DeepSeek",className:e,style:In})),Ij=ot.memo(({className:e})=>s.jsx("img",{src:kj,alt:"MiniMax",className:e,style:In})),zj=ot.memo(({className:e})=>s.jsx("img",{src:_j,alt:"Alibaba",className:e,style:In})),Pj=ot.memo(({className:e})=>s.jsx("img",{src:jj,alt:"Qwen",className:e,style:In})),Oj=ot.memo(({className:e})=>s.jsx("img",{src:Sj,alt:"ZhipuAI",className:e,style:In}));function Mj({provider:e,className:t}){switch(e){case"anthropic":return s.jsx(Ej,{className:t});case"openai":return s.jsx(Aj,{className:t});case"deepseek":return s.jsx(Rj,{className:t});case"minimax":return s.jsx(Ij,{className:t});case"alibaba":return s.jsx(zj,{className:t});case"qwen":return s.jsx(Pj,{className:t});case"zhipuai":return s.jsx(Oj,{className:t});case"unknown":return null}}var sp=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"}),Lj="VisuallyHidden",op=p.forwardRef((e,t)=>s.jsx(Ee.span,{...e,ref:t,style:{...sp,...e.style}}));op.displayName=Lj;var Dj=op;function ip(e){const t=e+"CollectionProvider",[n,r]=Gt(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=g=>{const{scope:x,children:b}=g,y=ot.useRef(null),_=ot.useRef(new Map).current;return s.jsx(o,{scope:x,itemMap:_,collectionRef:y,children:b})};a.displayName=t;const l=e+"CollectionSlot",c=rr(l),u=ot.forwardRef((g,x)=>{const{scope:b,children:y}=g,_=i(l,b),j=De(x,_.collectionRef);return s.jsx(c,{ref:j,children:y})});u.displayName=l;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=rr(d),h=ot.forwardRef((g,x)=>{const{scope:b,children:y,..._}=g,j=ot.useRef(null),S=De(x,j),E=i(d,b);return ot.useEffect(()=>(E.itemMap.set(j,{ref:j,..._}),()=>{E.itemMap.delete(j)})),s.jsx(m,{[f]:"",ref:S,children:y})});h.displayName=d;function v(g){const x=i(e+"CollectionConsumer",g);return ot.useCallback(()=>{const y=x.collectionRef.current;if(!y)return[];const _=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((E,C)=>_.indexOf(E.ref.current)-_.indexOf(C.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:a,Slot:u,ItemSlot:h},v,r]}var To="Collapsible",[$j]=Gt(To),[Fj,al]=$j(To),ap=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:i,onOpenChange:a,...l}=e,[c,u]=_n({prop:r,defaultProp:o??!1,onChange:a,caller:To});return s.jsx(Fj,{scope:n,disabled:i,contentId:zt(),open:c,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),children:s.jsx(Ee.div,{"data-state":cl(c),"data-disabled":i?"":void 0,...l,ref:t})})});ap.displayName=To;var lp="CollapsibleTrigger",cp=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=al(lp,n);return s.jsx(Ee.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":cl(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:je(e.onClick,o.onOpenToggle)})});cp.displayName=lp;var ll="CollapsibleContent",up=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=al(ll,e.__scopeCollapsible);return s.jsx(vt,{present:n||o.open,children:({present:i})=>s.jsx(Bj,{...r,ref:t,present:i})})});up.displayName=ll;var Bj=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...i}=e,a=al(ll,n),[l,c]=p.useState(r),u=p.useRef(null),d=De(t,u),f=p.useRef(0),m=f.current,h=p.useRef(0),v=h.current,g=a.open||l,x=p.useRef(g),b=p.useRef(void 0);return p.useEffect(()=>{const y=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(y)},[]),Xe(()=>{const y=u.current;if(y){b.current=b.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,x.current||(y.style.transitionDuration=b.current.transitionDuration,y.style.animationName=b.current.animationName),c(r)}},[a.open,r]),s.jsx(Ee.div,{"data-state":cl(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":v?`${v}px`:void 0,...e.style},children:g&&o})});function cl(e){return e?"open":"closed"}var Uj=ap,Wj=p.createContext(void 0);function Eo(e){const t=p.useContext(Wj);return e||t||"ltr"}function Hj(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 Zj(e){const[t,n]=p.useState(void 0);return Xe(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=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 r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}const Vj=["top","right","bottom","left"],ln=Math.min,ct=Math.max,Zs=Math.round,hs=Math.floor,Pt=e=>({x:e,y:e}),qj={left:"right",right:"left",bottom:"top",top:"bottom"},Kj={start:"end",end:"start"};function Vi(e,t,n){return ct(e,ln(t,n))}function Zt(e,t){return typeof e=="function"?e(t):e}function Vt(e){return e.split("-")[0]}function dr(e){return e.split("-")[1]}function ul(e){return e==="x"?"y":"x"}function dl(e){return e==="y"?"height":"width"}const Gj=new Set(["top","bottom"]);function It(e){return Gj.has(Vt(e))?"y":"x"}function fl(e){return ul(It(e))}function Jj(e,t,n){n===void 0&&(n=!1);const r=dr(e),o=fl(e),i=dl(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Vs(a)),[a,Vs(a)]}function Yj(e){const t=Vs(e);return[qi(e),t,qi(t)]}function qi(e){return e.replace(/start|end/g,t=>Kj[t])}const Rc=["left","right"],Ic=["right","left"],Xj=["top","bottom"],Qj=["bottom","top"];function eS(e,t,n){switch(e){case"top":case"bottom":return n?t?Ic:Rc:t?Rc:Ic;case"left":case"right":return t?Xj:Qj;default:return[]}}function tS(e,t,n,r){const o=dr(e);let i=eS(Vt(e),n==="start",r);return o&&(i=i.map(a=>a+"-"+o),t&&(i=i.concat(i.map(qi)))),i}function Vs(e){return e.replace(/left|right|bottom|top/g,t=>qj[t])}function nS(e){return{top:0,right:0,bottom:0,left:0,...e}}function dp(e){return typeof e!="number"?nS(e):{top:e,right:e,bottom:e,left:e}}function qs(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function zc(e,t,n){let{reference:r,floating:o}=e;const i=It(t),a=fl(t),l=dl(a),c=Vt(t),u=i==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,m=r[l]/2-o[l]/2;let h;switch(c){case"top":h={x:d,y:r.y-o.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-o.width,y:f};break;default:h={x:r.x,y:r.y}}switch(dr(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 rS(e,t){var n;t===void 0&&(t={});const{x:r,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}=Zt(t,e),v=dp(h),x=l[m?f==="floating"?"reference":"floating":f],b=qs(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(x)))==null||n?x:x.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:u,rootBoundary:d,strategy:c})),y=f==="floating"?{x:r,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=qs(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:_,strategy:c}):y);return{top:(b.top-S.top+v.top)/j.y,bottom:(S.bottom-b.bottom+v.bottom)/j.y,left:(b.left-S.left+v.left)/j.x,right:(S.right-b.right+v.right)/j.x}}const sS=async(e,t,n)=>{const{placement:r="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}=zc(u,r,c),m=r,h={},v=0;for(let x=0;x<l.length;x++){var g;const{name:b,fn:y}=l[x],{x:_,y:j,data:S,reset:E}=await y({x:d,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:h,rects:u,platform:{...a,detectOverflow:(g=a.detectOverflow)!=null?g:rS},elements:{reference:e,floating:t}});d=_??d,f=j??f,h={...h,[b]:{...h[b],...S}},E&&v<=50&&(v++,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}=zc(u,m,c)),x=-1)}return{x:d,y:f,placement:m,strategy:o,middlewareData:h}},oS=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:a,elements:l,middlewareData:c}=t,{element:u,padding:d=0}=Zt(e,t)||{};if(u==null)return{};const f=dp(d),m={x:n,y:r},h=fl(o),v=dl(h),g=await a.getDimensions(u),x=h==="y",b=x?"top":"left",y=x?"bottom":"right",_=x?"clientHeight":"clientWidth",j=i.reference[v]+i.reference[h]-m[h]-i.floating[v],S=m[h]-i.reference[h],E=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let C=E?E[_]:0;(!C||!await(a.isElement==null?void 0:a.isElement(E)))&&(C=l.floating[_]||i.floating[v]);const R=j/2-S/2,z=C/2-g[v]/2-1,O=ln(f[b],z),q=ln(f[y],z),T=O,D=C-g[v]-q,k=C/2-g[v]/2+R,$=Vi(T,k,D),X=!c.arrow&&dr(o)!=null&&k!==$&&i.reference[v]/2-(k<T?O:q)-g[v]/2<0,B=X?k<T?k-T:k-D:0;return{[h]:m[h]+B,data:{[h]:$,centerOffset:k-$-B,...X&&{alignmentOffset:B}},reset:X}}}),iS=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;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:v="none",flipAlignment:g=!0,...x}=Zt(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=Vt(o),y=It(l),_=Vt(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=m||(_||!g?[Vs(l)]:Yj(l)),E=v!=="none";!m&&E&&S.push(...tS(l,g,v,j));const C=[l,...S],R=await c.detectOverflow(t,x),z=[];let O=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&z.push(R[b]),f){const k=Jj(o,a,j);z.push(R[k[0]],R[k[1]])}if(O=[...O,{placement:o,overflows:z}],!z.every(k=>k<=0)){var q,T;const k=(((q=i.flip)==null?void 0:q.index)||0)+1,$=C[k];if($&&(!(f==="alignment"?y!==It($):!1)||O.every(F=>It(F.placement)===y?F.overflows[0]>0:!0)))return{data:{index:k,overflows:O},reset:{placement:$}};let X=(T=O.filter(B=>B.overflows[0]<=0).sort((B,F)=>B.overflows[1]-F.overflows[1])[0])==null?void 0:T.placement;if(!X)switch(h){case"bestFit":{var D;const B=(D=O.filter(F=>{if(E){const Z=It(F.placement);return Z===y||Z==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(Z=>Z>0).reduce((Z,J)=>Z+J,0)]).sort((F,Z)=>F[1]-Z[1])[0])==null?void 0:D[0];B&&(X=B);break}case"initialPlacement":X=l;break}if(o!==X)return{reset:{placement:X}}}return{}}}};function Pc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Oc(e){return Vj.some(t=>e[t]>=0)}const aS=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...i}=Zt(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...i,elementContext:"reference"}),l=Pc(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Oc(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...i,altBoundary:!0}),l=Pc(a,n.floating);return{data:{escapedOffsets:l,escaped:Oc(l)}}}default:return{}}}}},fp=new Set(["left","top"]);async function lS(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Vt(n),l=dr(n),c=It(n)==="y",u=fp.has(a)?-1:1,d=i&&c?-1:1,f=Zt(t,e);let{mainAxis:m,crossAxis:h,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof v=="number"&&(h=l==="end"?v*-1:v),c?{x:h*d,y:m*u}:{x:m*u,y:h*d}}const cS=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:a,middlewareData:l}=t,c=await lS(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:i+c.y,data:{...c,placement:a}}}}},uS=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:i}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:b=>{let{x:y,y:_}=b;return{x:y,y:_}}},...u}=Zt(e,t),d={x:n,y:r},f=await i.detectOverflow(t,u),m=It(Vt(o)),h=ul(m);let v=d[h],g=d[m];if(a){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",_=v+f[b],j=v-f[y];v=Vi(_,v,j)}if(l){const b=m==="y"?"top":"left",y=m==="y"?"bottom":"right",_=g+f[b],j=g-f[y];g=Vi(_,g,j)}const x=c.fn({...t,[h]:v,[m]:g});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:a,[m]:l}}}}}},dS=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:a}=t,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=Zt(e,t),d={x:n,y:r},f=It(o),m=ul(f);let h=d[m],v=d[f];const g=Zt(l,t),x=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[_]+x.mainAxis,S=i.reference[m]+i.reference[_]-x.mainAxis;h<j?h=j:h>S&&(h=S)}if(u){var b,y;const _=m==="y"?"width":"height",j=fp.has(Vt(o)),S=i.reference[f]-i.floating[_]+(j&&((b=a.offset)==null?void 0:b[f])||0)+(j?0:x.crossAxis),E=i.reference[f]+i.reference[_]+(j?0:((y=a.offset)==null?void 0:y[f])||0)-(j?x.crossAxis:0);v<S?v=S:v>E&&(v=E)}return{[m]:h,[f]:v}}}},fS=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:a,elements:l}=t,{apply:c=()=>{},...u}=Zt(e,t),d=await a.detectOverflow(t,u),f=Vt(o),m=dr(o),h=It(o)==="y",{width:v,height:g}=i.floating;let x,b;f==="top"||f==="bottom"?(x=f,b=m===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(b=f,x=m==="end"?"top":"bottom");const y=g-d.top-d.bottom,_=v-d.left-d.right,j=ln(g-d[x],y),S=ln(v-d[b],_),E=!t.middlewareData.shift;let C=j,R=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(R=_),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=y),E&&!m){const O=ct(d.left,0),q=ct(d.right,0),T=ct(d.top,0),D=ct(d.bottom,0);h?R=v-2*(O!==0||q!==0?O+q:ct(d.left,d.right)):C=g-2*(T!==0||D!==0?T+D:ct(d.top,d.bottom))}await c({...t,availableWidth:R,availableHeight:C});const z=await a.getDimensions(l.floating);return v!==z.width||g!==z.height?{reset:{rects:!0}}:{}}}};function Ao(){return typeof window<"u"}function fr(e){return pp(e)?(e.nodeName||"").toLowerCase():"#document"}function dt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Lt(e){var t;return(t=(pp(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function pp(e){return Ao()?e instanceof Node||e instanceof dt(e).Node:!1}function St(e){return Ao()?e instanceof Element||e instanceof dt(e).Element:!1}function Ot(e){return Ao()?e instanceof HTMLElement||e instanceof dt(e).HTMLElement:!1}function Mc(e){return!Ao()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof dt(e).ShadowRoot}const pS=new Set(["inline","contents"]);function qr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Ct(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!pS.has(o)}const hS=new Set(["table","td","th"]);function mS(e){return hS.has(fr(e))}const gS=[":popover-open",":modal"];function Ro(e){return gS.some(t=>{try{return e.matches(t)}catch{return!1}})}const xS=["transform","translate","scale","rotate","perspective"],bS=["transform","translate","scale","rotate","perspective","filter"],vS=["paint","layout","strict","content"];function pl(e){const t=hl(),n=St(e)?Ct(e):e;return xS.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||bS.some(r=>(n.willChange||"").includes(r))||vS.some(r=>(n.contain||"").includes(r))}function yS(e){let t=cn(e);for(;Ot(t)&&!sr(t);){if(pl(t))return t;if(Ro(t))return null;t=cn(t)}return null}function hl(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const wS=new Set(["html","body","#document"]);function sr(e){return wS.has(fr(e))}function Ct(e){return dt(e).getComputedStyle(e)}function Io(e){return St(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function cn(e){if(fr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Mc(e)&&e.host||Lt(e);return Mc(t)?t.host:t}function hp(e){const t=cn(e);return sr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ot(t)&&qr(t)?t:hp(t)}function Or(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=hp(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),a=dt(o);if(i){const l=Ki(a);return t.concat(a,a.visualViewport||[],qr(o)?o:[],l&&n?Or(l):[])}return t.concat(o,Or(o,[],n))}function Ki(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function mp(e){const t=Ct(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ot(e),i=o?e.offsetWidth:n,a=o?e.offsetHeight:r,l=Zs(n)!==i||Zs(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function ml(e){return St(e)?e:e.contextElement}function Jn(e){const t=ml(e);if(!Ot(t))return Pt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=mp(t);let a=(i?Zs(n.width):n.width)/r,l=(i?Zs(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const kS=Pt(0);function gp(e){const t=dt(e);return!hl()||!t.visualViewport?kS:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function _S(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==dt(e)?!1:t}function Sn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=ml(e);let a=Pt(1);t&&(r?St(r)&&(a=Jn(r)):a=Jn(e));const l=_S(i,n,r)?gp(i):Pt(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=dt(i),h=r&&St(r)?dt(r):r;let v=m,g=Ki(v);for(;g&&r&&h!==v;){const x=Jn(g),b=g.getBoundingClientRect(),y=Ct(g),_=b.left+(g.clientLeft+parseFloat(y.paddingLeft))*x.x,j=b.top+(g.clientTop+parseFloat(y.paddingTop))*x.y;c*=x.x,u*=x.y,d*=x.x,f*=x.y,c+=_,u+=j,v=dt(g),g=Ki(v)}}return qs({width:d,height:f,x:c,y:u})}function zo(e,t){const n=Io(e).scrollLeft;return t?t.left+n:Sn(Lt(e)).left+n}function xp(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-zo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function jS(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",a=Lt(r),l=t?Ro(t.floating):!1;if(r===a||l&&i)return n;let c={scrollLeft:0,scrollTop:0},u=Pt(1);const d=Pt(0),f=Ot(r);if((f||!f&&!i)&&((fr(r)!=="body"||qr(a))&&(c=Io(r)),Ot(r))){const h=Sn(r);u=Jn(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const m=a&&!f&&!i?xp(a,c):Pt(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 SS(e){return Array.from(e.getClientRects())}function CS(e){const t=Lt(e),n=Io(e),r=e.ownerDocument.body,o=ct(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=ct(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+zo(e);const l=-n.scrollTop;return Ct(r).direction==="rtl"&&(a+=ct(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:a,y:l}}const Lc=25;function NS(e,t){const n=dt(e),r=Lt(e),o=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,c=0;if(o){i=o.width,a=o.height;const d=hl();(!d||d&&t==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}const u=zo(r);if(u<=0){const d=r.ownerDocument,f=d.body,m=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-h);v<=Lc&&(i-=v)}else u<=Lc&&(i+=u);return{width:i,height:a,x:l,y:c}}const TS=new Set(["absolute","fixed"]);function ES(e,t){const n=Sn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Ot(e)?Jn(e):Pt(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,c=o*i.x,u=r*i.y;return{width:a,height:l,x:c,y:u}}function Dc(e,t,n){let r;if(t==="viewport")r=NS(e,n);else if(t==="document")r=CS(Lt(e));else if(St(t))r=ES(t,n);else{const o=gp(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return qs(r)}function bp(e,t){const n=cn(e);return n===t||!St(n)||sr(n)?!1:Ct(n).position==="fixed"||bp(n,t)}function AS(e,t){const n=t.get(e);if(n)return n;let r=Or(e,[],!1).filter(l=>St(l)&&fr(l)!=="body"),o=null;const i=Ct(e).position==="fixed";let a=i?cn(e):e;for(;St(a)&&!sr(a);){const l=Ct(a),c=pl(a);!c&&l.position==="fixed"&&(o=null),(i?!c&&!o:!c&&l.position==="static"&&!!o&&TS.has(o.position)||qr(a)&&!c&&bp(e,a))?r=r.filter(d=>d!==a):o=l,a=cn(a)}return t.set(e,r),r}function RS(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?Ro(t)?[]:AS(t,this._c):[].concat(n),r],l=a[0],c=a.reduce((u,d)=>{const f=Dc(t,d,o);return u.top=ct(f.top,u.top),u.right=ln(f.right,u.right),u.bottom=ln(f.bottom,u.bottom),u.left=ct(f.left,u.left),u},Dc(t,l,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function IS(e){const{width:t,height:n}=mp(e);return{width:t,height:n}}function zS(e,t,n){const r=Ot(t),o=Lt(t),i=n==="fixed",a=Sn(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=Pt(0);function u(){c.x=zo(o)}if(r||!r&&!i)if((fr(t)!=="body"||qr(o))&&(l=Io(t)),r){const h=Sn(t,!0,i,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else o&&u();i&&!r&&o&&u();const d=o&&!r&&!i?xp(o,l):Pt(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 li(e){return Ct(e).position==="static"}function $c(e,t){if(!Ot(e)||Ct(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Lt(e)===n&&(n=n.ownerDocument.body),n}function vp(e,t){const n=dt(e);if(Ro(e))return n;if(!Ot(e)){let o=cn(e);for(;o&&!sr(o);){if(St(o)&&!li(o))return o;o=cn(o)}return n}let r=$c(e,t);for(;r&&mS(r)&&li(r);)r=$c(r,t);return r&&sr(r)&&li(r)&&!pl(r)?n:r||yS(e)||n}const PS=async function(e){const t=this.getOffsetParent||vp,n=this.getDimensions,r=await n(e.floating);return{reference:zS(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function OS(e){return Ct(e).direction==="rtl"}const MS={convertOffsetParentRelativeRectToViewportRelativeRect:jS,getDocumentElement:Lt,getClippingRect:RS,getOffsetParent:vp,getElementRects:PS,getClientRects:SS,getDimensions:IS,getScale:Jn,isElement:St,isRTL:OS};function yp(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function LS(e,t){let n=null,r;const o=Lt(e);function i(){var l;clearTimeout(r),(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 v=hs(f),g=hs(o.clientWidth-(d+m)),x=hs(o.clientHeight-(f+h)),b=hs(d),_={rootMargin:-v+"px "+-g+"px "+-x+"px "+-b+"px",threshold:ct(0,ln(1,c))||1};let j=!0;function S(E){const C=E[0].intersectionRatio;if(C!==c){if(!j)return a();C?a(!1,C):r=setTimeout(()=>{a(!1,1e-7)},1e3)}C===1&&!yp(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 DS(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=ml(e),d=o||i?[...u?Or(u):[],...Or(t)]:[];d.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),i&&b.addEventListener("resize",n)});const f=u&&l?LS(u,n):null;let m=-1,h=null;a&&(h=new ResizeObserver(b=>{let[y]=b;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 v,g=c?Sn(e):null;c&&x();function x(){const b=Sn(e);g&&!yp(g,b)&&n(),g=b,v=requestAnimationFrame(x)}return n(),()=>{var b;d.forEach(y=>{o&&y.removeEventListener("scroll",n),i&&y.removeEventListener("resize",n)}),f?.(),(b=h)==null||b.disconnect(),h=null,c&&cancelAnimationFrame(v)}}const $S=cS,FS=uS,BS=iS,US=fS,WS=aS,Fc=oS,HS=dS,ZS=(e,t,n)=>{const r=new Map,o={platform:MS,...n},i={...o.platform,_c:r};return sS(e,t,{...o,platform:i})};var VS=typeof document<"u",qS=function(){},Rs=VS?p.useLayoutEffect:qS;function Ks(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,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Ks(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Ks(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function wp(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Bc(e,t){const n=wp(e);return Math.round(t*n)/n}function ci(e){const t=p.useRef(e);return Rs(()=>{t.current=e}),t}function KS(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],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(r);Ks(m,r)||h(r);const[v,g]=p.useState(null),[x,b]=p.useState(null),y=p.useCallback(F=>{F!==E.current&&(E.current=F,g(F))},[]),_=p.useCallback(F=>{F!==C.current&&(C.current=F,b(F))},[]),j=i||v,S=a||x,E=p.useRef(null),C=p.useRef(null),R=p.useRef(d),z=c!=null,O=ci(c),q=ci(o),T=ci(u),D=p.useCallback(()=>{if(!E.current||!C.current)return;const F={placement:t,strategy:n,middleware:m};q.current&&(F.platform=q.current),ZS(E.current,C.current,F).then(Z=>{const J={...Z,isPositioned:T.current!==!1};k.current&&!Ks(R.current,J)&&(R.current=J,Fr.flushSync(()=>{f(J)}))})},[m,t,n,q,T]);Rs(()=>{u===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,f(F=>({...F,isPositioned:!1})))},[u]);const k=p.useRef(!1);Rs(()=>(k.current=!0,()=>{k.current=!1}),[]),Rs(()=>{if(j&&(E.current=j),S&&(C.current=S),j&&S){if(O.current)return O.current(j,S,D);D()}},[j,S,D,O,z]);const $=p.useMemo(()=>({reference:E,floating:C,setReference:y,setFloating:_}),[y,_]),X=p.useMemo(()=>({reference:j,floating:S}),[j,S]),B=p.useMemo(()=>{const F={position:n,left:0,top:0};if(!X.floating)return F;const Z=Bc(X.floating,d.x),J=Bc(X.floating,d.y);return l?{...F,transform:"translate("+Z+"px, "+J+"px)",...wp(X.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Z,top:J}},[n,l,X.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:D,refs:$,elements:X,floatingStyles:B}),[d,D,$,X,B])}const GS=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Fc({element:r.current,padding:o}).fn(n):{}:r?Fc({element:r,padding:o}).fn(n):{}}}},JS=(e,t)=>({...$S(e),options:[e,t]}),YS=(e,t)=>({...FS(e),options:[e,t]}),XS=(e,t)=>({...HS(e),options:[e,t]}),QS=(e,t)=>({...BS(e),options:[e,t]}),eC=(e,t)=>({...US(e),options:[e,t]}),tC=(e,t)=>({...WS(e),options:[e,t]}),nC=(e,t)=>({...GS(e),options:[e,t]});var rC="Arrow",kp=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return s.jsx(Ee.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});kp.displayName=rC;var sC=kp,gl="Popper",[_p,Po]=Gt(gl),[oC,jp]=_p(gl),Sp=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return s.jsx(oC,{scope:t,anchor:r,onAnchorChange:o,children:n})};Sp.displayName=gl;var Cp="PopperAnchor",Np=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=jp(Cp,n),a=p.useRef(null),l=De(t,a),c=p.useRef(null);return p.useEffect(()=>{const u=c.current;c.current=r?.current||a.current,u!==c.current&&i.onAnchorChange(c.current)}),r?null:s.jsx(Ee.div,{...o,ref:l})});Np.displayName=Cp;var xl="PopperContent",[iC,aC]=_p(xl),Tp=p.forwardRef((e,t)=>{const{__scopePopper:n,side:r="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:v,...g}=e,x=jp(xl,n),[b,y]=p.useState(null),_=De(t,ie=>y(ie)),[j,S]=p.useState(null),E=Zj(j),C=E?.width??0,R=E?.height??0,z=r+(i!=="center"?"-"+i:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},q=Array.isArray(u)?u:[u],T=q.length>0,D={padding:O,boundary:q.filter(cC),altBoundary:T},{refs:k,floatingStyles:$,placement:X,isPositioned:B,middlewareData:F}=KS({strategy:"fixed",placement:z,whileElementsMounted:(...ie)=>DS(...ie,{animationFrame:h==="always"}),elements:{reference:x.anchor},middleware:[JS({mainAxis:o+R,alignmentAxis:a}),c&&YS({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?XS():void 0,...D}),c&&QS({...D}),eC({...D,apply:({elements:ie,rects:ge,availableWidth:he,availableHeight:xe})=>{const{width:te,height:ue}=ge.reference,be=ie.floating.style;be.setProperty("--radix-popper-available-width",`${he}px`),be.setProperty("--radix-popper-available-height",`${xe}px`),be.setProperty("--radix-popper-anchor-width",`${te}px`),be.setProperty("--radix-popper-anchor-height",`${ue}px`)}}),j&&nC({element:j,padding:l}),uC({arrowWidth:C,arrowHeight:R}),m&&tC({strategy:"referenceHidden",...D})]}),[Z,J]=Rp(X),H=rt(v);Xe(()=>{B&&H?.()},[B,H]);const W=F.arrow?.x,ce=F.arrow?.y,se=F.arrow?.centerOffset!==0,[oe,_e]=p.useState();return Xe(()=>{b&&_e(window.getComputedStyle(b).zIndex)},[b]),s.jsx("div",{ref:k.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:B?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oe,"--radix-popper-transform-origin":[F.transformOrigin?.x,F.transformOrigin?.y].join(" "),...F.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(iC,{scope:n,placedSide:Z,onArrowChange:S,arrowX:W,arrowY:ce,shouldHideArrow:se,children:s.jsx(Ee.div,{"data-side":Z,"data-align":J,...g,ref:_,style:{...g.style,animation:B?void 0:"none"}})})})});Tp.displayName=xl;var Ep="PopperArrow",lC={top:"bottom",right:"left",bottom:"top",left:"right"},Ap=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=aC(Ep,r),a=lC[i.placedSide];return s.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:s.jsx(sC,{...o,ref:n,style:{...o.style,display:"block"}})})});Ap.displayName=Ep;function cC(e){return e!==null}var uC=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,a=o.arrow?.centerOffset!==0,l=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[u,d]=Rp(n),f={start:"0%",center:"50%",end:"100%"}[d],m=(o.arrow?.x??0)+l/2,h=(o.arrow?.y??0)+c/2;let v="",g="";return u==="bottom"?(v=a?f:`${m}px`,g=`${-c}px`):u==="top"?(v=a?f:`${m}px`,g=`${r.floating.height+c}px`):u==="right"?(v=`${-c}px`,g=a?f:`${h}px`):u==="left"&&(v=`${r.floating.width+c}px`,g=a?f:`${h}px`),{data:{x:v,y:g}}}});function Rp(e){const[t,n="center"]=e.split("-");return[t,n]}var Ip=Sp,zp=Np,Pp=Tp,Op=Ap,ui="rovingFocusGroup.onEntryFocus",dC={bubbles:!1,cancelable:!0},Kr="RovingFocusGroup",[Gi,Mp,fC]=ip(Kr),[pC,Lp]=Gt(Kr,[fC]),[hC,mC]=pC(Kr),Dp=p.forwardRef((e,t)=>s.jsx(Gi.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(Gi.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(gC,{...e,ref:t})})}));Dp.displayName=Kr;var gC=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,m=p.useRef(null),h=De(t,m),v=Eo(i),[g,x]=_n({prop:a,defaultProp:l??null,onChange:c,caller:Kr}),[b,y]=p.useState(!1),_=rt(u),j=Mp(n),S=p.useRef(!1),[E,C]=p.useState(0);return p.useEffect(()=>{const R=m.current;if(R)return R.addEventListener(ui,_),()=>R.removeEventListener(ui,_)},[_]),s.jsx(hC,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(R=>x(R),[x]),onItemShiftTab:p.useCallback(()=>y(!0),[]),onFocusableItemAdd:p.useCallback(()=>C(R=>R+1),[]),onFocusableItemRemove:p.useCallback(()=>C(R=>R-1),[]),children:s.jsx(Ee.div,{tabIndex:b||E===0?-1:0,"data-orientation":r,...f,ref:h,style:{outline:"none",...e.style},onMouseDown:je(e.onMouseDown,()=>{S.current=!0}),onFocus:je(e.onFocus,R=>{const z=!S.current;if(R.target===R.currentTarget&&z&&!b){const O=new CustomEvent(ui,dC);if(R.currentTarget.dispatchEvent(O),!O.defaultPrevented){const q=j().filter(X=>X.focusable),T=q.find(X=>X.active),D=q.find(X=>X.id===g),$=[T,D,...q].filter(Boolean).map(X=>X.ref.current);Bp($,d)}}S.current=!1}),onBlur:je(e.onBlur,()=>y(!1))})})}),$p="RovingFocusGroupItem",Fp=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:a,...l}=e,c=zt(),u=i||c,d=mC($p,n),f=d.currentTabStopId===u,m=Mp(n),{onFocusableItemAdd:h,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return h(),()=>v()},[r,h,v]),s.jsx(Gi.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:s.jsx(Ee.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...l,ref:t,onMouseDown:je(e.onMouseDown,x=>{r?d.onItemFocus(u):x.preventDefault()}),onFocus:je(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:je(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const b=vC(x,d.orientation,d.dir);if(b!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let _=m().filter(j=>j.focusable).map(j=>j.ref.current);if(b==="last")_.reverse();else if(b==="prev"||b==="next"){b==="prev"&&_.reverse();const j=_.indexOf(x.currentTarget);_=d.loop?yC(_,j+1):_.slice(j+1)}setTimeout(()=>Bp(_))}}),children:typeof a=="function"?a({isCurrentTabStop:f,hasTabStop:g!=null}):a})})});Fp.displayName=$p;var xC={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function bC(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function vC(e,t,n){const r=bC(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return xC[r]}function Bp(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function yC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var wC=Dp,kC=Fp;function Ji(e,[t,n]){return Math.min(n,Math.max(t,e))}function _C(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var bl="ScrollArea",[Up]=Gt(bl),[jC,yt]=Up(bl),Wp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:i=600,...a}=e,[l,c]=p.useState(null),[u,d]=p.useState(null),[f,m]=p.useState(null),[h,v]=p.useState(null),[g,x]=p.useState(null),[b,y]=p.useState(0),[_,j]=p.useState(0),[S,E]=p.useState(!1),[C,R]=p.useState(!1),z=De(t,q=>c(q)),O=Eo(o);return s.jsx(jC,{scope:n,type:r,dir:O,scrollHideDelay:i,scrollArea:l,viewport:u,onViewportChange:d,content:f,onContentChange:m,scrollbarX:h,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:E,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:C,onScrollbarYEnabledChange:R,onCornerWidthChange:y,onCornerHeightChange:j,children:s.jsx(Ee.div,{dir:O,...a,ref:z,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":_+"px",...e.style}})})});Wp.displayName=bl;var Hp="ScrollAreaViewport",Zp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...i}=e,a=yt(Hp,n),l=p.useRef(null),c=De(t,l,a.onViewportChange);return s.jsxs(s.Fragment,{children:[s.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:o}),s.jsx(Ee.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:s.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Zp.displayName=Hp;var Dt="ScrollAreaScrollbar",Vp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=yt(Dt,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"?s.jsx(SC,{...r,ref:t,forceMount:n}):o.type==="scroll"?s.jsx(CC,{...r,ref:t,forceMount:n}):o.type==="auto"?s.jsx(qp,{...r,ref:t,forceMount:n}):o.type==="always"?s.jsx(vl,{...r,ref:t}):null});Vp.displayName=Dt;var SC=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=yt(Dt,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]),s.jsx(vt,{present:n||i,children:s.jsx(qp,{"data-state":i?"visible":"hidden",...r,ref:t})})}),CC=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=yt(Dt,e.__scopeScrollArea),i=e.orientation==="horizontal",a=Mo(()=>c("SCROLL_END"),100),[l,c]=_C("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]),s.jsx(vt,{present:n||l!=="hidden",children:s.jsx(vl,{"data-state":l==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:je(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:je(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),qp=p.forwardRef((e,t)=>{const n=yt(Dt,e.__scopeScrollArea),{forceMount:r,...o}=e,[i,a]=p.useState(!1),l=e.orientation==="horizontal",c=Mo(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;a(l?u:d)}},10);return or(n.viewport,c),or(n.content,c),s.jsx(vt,{present:r||i,children:s.jsx(vl,{"data-state":i?"visible":"hidden",...o,ref:t})})}),vl=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=yt(Dt,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=Xp(l.viewport,l.content),d={...r,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 IC(m,a.current,l,h)}return n==="horizontal"?s.jsx(NC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const m=o.viewport.scrollLeft,h=Uc(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"?s.jsx(TC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const m=o.viewport.scrollTop,h=Uc(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}),NC=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=yt(Dt,e.__scopeScrollArea),[a,l]=p.useState(),c=p.useRef(null),u=De(t,c,i.onScrollbarXChange);return p.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),s.jsx(Gp,{"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":Oo(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),eh(m,f)&&d.preventDefault()}},onResize:()=>{c.current&&i.viewport&&a&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Js(a.paddingLeft),paddingEnd:Js(a.paddingRight)}})}})}),TC=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=yt(Dt,e.__scopeScrollArea),[a,l]=p.useState(),c=p.useRef(null),u=De(t,c,i.onScrollbarYChange);return p.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),s.jsx(Gp,{"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":Oo(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),eh(m,f)&&d.preventDefault()}},onResize:()=>{c.current&&i.viewport&&a&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Js(a.paddingTop),paddingEnd:Js(a.paddingBottom)}})}})}),[EC,Kp]=Up(Dt),Gp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:i,onThumbPointerUp:a,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...m}=e,h=yt(Dt,n),[v,g]=p.useState(null),x=De(t,z=>g(z)),b=p.useRef(null),y=p.useRef(""),_=h.viewport,j=r.content-r.viewport,S=rt(d),E=rt(c),C=Mo(f,10);function R(z){if(b.current){const O=z.clientX-b.current.left,q=z.clientY-b.current.top;u({x:O,y:q})}}return p.useEffect(()=>{const z=O=>{const q=O.target;v?.contains(q)&&S(O,j)};return document.addEventListener("wheel",z,{passive:!1}),()=>document.removeEventListener("wheel",z,{passive:!1})},[_,v,j,S]),p.useEffect(E,[r,E]),or(v,C),or(h.content,C),s.jsx(EC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:rt(i),onThumbPointerUp:rt(a),onThumbPositionChange:E,onThumbPointerDown:rt(l),children:s.jsx(Ee.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:je(e.onPointerDown,z=>{z.button===0&&(z.target.setPointerCapture(z.pointerId),b.current=v.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),R(z))}),onPointerMove:je(e.onPointerMove,R),onPointerUp:je(e.onPointerUp,z=>{const O=z.target;O.hasPointerCapture(z.pointerId)&&O.releasePointerCapture(z.pointerId),document.body.style.webkitUserSelect=y.current,h.viewport&&(h.viewport.style.scrollBehavior=""),b.current=null})})})}),Gs="ScrollAreaThumb",Jp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Kp(Gs,e.__scopeScrollArea);return s.jsx(vt,{present:n||o.hasThumb,children:s.jsx(AC,{ref:t,...r})})}),AC=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,i=yt(Gs,n),a=Kp(Gs,n),{onThumbPositionChange:l}=a,c=De(t,f=>a.onThumbChange(f)),u=p.useRef(void 0),d=Mo(()=>{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=zC(f,l);u.current=h,l()}};return l(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[i.viewport,d,l]),s.jsx(Ee.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)",...r},onPointerDownCapture:je(e.onPointerDownCapture,f=>{const h=f.target.getBoundingClientRect(),v=f.clientX-h.left,g=f.clientY-h.top;a.onThumbPointerDown({x:v,y:g})}),onPointerUp:je(e.onPointerUp,a.onThumbPointerUp)})});Jp.displayName=Gs;var yl="ScrollAreaCorner",Yp=p.forwardRef((e,t)=>{const n=yt(yl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?s.jsx(RC,{...e,ref:t}):null});Yp.displayName=yl;var RC=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=yt(yl,n),[i,a]=p.useState(0),[l,c]=p.useState(0),u=!!(i&&l);return or(o.scrollbarX,()=>{const d=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(d),c(d)}),or(o.scrollbarY,()=>{const d=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(d),a(d)}),u?s.jsx(Ee.div,{...r,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 Js(e){return e?parseInt(e,10):0}function Xp(e,t){const n=e/t;return isNaN(n)?0:n}function Oo(e){const t=Xp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function IC(e,t,n,r="ltr"){const o=Oo(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=r==="ltr"?[0,d]:[d*-1,0];return Qp([c,u],f)(e)}function Uc(e,t,n="ltr"){const r=Oo(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,a=t.content-t.viewport,l=i-r,c=n==="ltr"?[0,a]:[a*-1,0],u=Ji(e,c);return Qp([0,a],[0,l])(u)}function Qp(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function eh(e,t){return e>0&&e<t}var zC=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=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,r=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(r)};function Mo(e,t){const n=rt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function or(e,t){const n=rt(t);Xe(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var PC=Wp,OC=Zp,MC=Yp,LC=[" ","Enter","ArrowUp","ArrowDown"],DC=[" ","Enter"],Cn="Select",[Lo,Do,$C]=ip(Cn),[pr]=Gt(Cn,[$C,Po]),$o=Po(),[FC,fn]=pr(Cn),[BC,UC]=pr(Cn),th=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:i,value:a,defaultValue:l,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:m,required:h,form:v}=e,g=$o(t),[x,b]=p.useState(null),[y,_]=p.useState(null),[j,S]=p.useState(!1),E=Eo(u),[C,R]=_n({prop:r,defaultProp:o??!1,onChange:i,caller:Cn}),[z,O]=_n({prop:a,defaultProp:l,onChange:c,caller:Cn}),q=p.useRef(null),T=x?v||!!x.closest("form"):!0,[D,k]=p.useState(new Set),$=Array.from(D).map(X=>X.props.value).join(";");return s.jsx(Ip,{...g,children:s.jsxs(FC,{required:h,scope:t,trigger:x,onTriggerChange:b,valueNode:y,onValueNodeChange:_,valueNodeHasChildren:j,onValueNodeHasChildrenChange:S,contentId:zt(),value:z,onValueChange:O,open:C,onOpenChange:R,dir:E,triggerPointerDownPosRef:q,disabled:m,children:[s.jsx(Lo.Provider,{scope:t,children:s.jsx(BC,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(X=>{k(B=>new Set(B).add(X))},[]),onNativeOptionRemove:p.useCallback(X=>{k(B=>{const F=new Set(B);return F.delete(X),F})},[]),children:n})}),T?s.jsxs(_h,{"aria-hidden":!0,required:h,tabIndex:-1,name:d,autoComplete:f,value:z,onChange:X=>O(X.target.value),disabled:m,form:v,children:[z===void 0?s.jsx("option",{value:""}):null,Array.from(D)]},$):null]})})};th.displayName=Cn;var nh="SelectTrigger",rh=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,i=$o(n),a=fn(nh,n),l=a.disabled||r,c=De(t,a.onTriggerChange),u=Do(n),d=p.useRef("touch"),[f,m,h]=Sh(g=>{const x=u().filter(_=>!_.disabled),b=x.find(_=>_.value===a.value),y=Ch(x,g,b);y!==void 0&&a.onValueChange(y.value)}),v=g=>{l||(a.onOpenChange(!0),h()),g&&(a.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return s.jsx(zp,{asChild:!0,...i,children:s.jsx(Ee.button,{type:"button",role:"combobox","aria-controls":a.contentId,"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":jh(a.value)?"":void 0,...o,ref:c,onClick:je(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:je(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:je(o.onKeyDown,g=>{const x=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&LC.includes(g.key)&&(v(),g.preventDefault())})})})});rh.displayName=nh;var sh="SelectValue",oh=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:a="",...l}=e,c=fn(sh,n),{onValueNodeHasChildrenChange:u}=c,d=i!==void 0,f=De(t,c.onValueNodeChange);return Xe(()=>{u(d)},[u,d]),s.jsx(Ee.span,{...l,ref:f,style:{pointerEvents:"none"},children:jh(c.value)?s.jsx(s.Fragment,{children:a}):i})});oh.displayName=sh;var WC="SelectIcon",ih=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return s.jsx(Ee.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});ih.displayName=WC;var HC="SelectPortal",ah=e=>s.jsx(jo,{asChild:!0,...e});ah.displayName=HC;var Nn="SelectContent",lh=p.forwardRef((e,t)=>{const n=fn(Nn,e.__scopeSelect),[r,o]=p.useState();if(Xe(()=>{o(new DocumentFragment)},[]),!n.open){const i=r;return i?Fr.createPortal(s.jsx(ch,{scope:e.__scopeSelect,children:s.jsx(Lo.Slot,{scope:e.__scopeSelect,children:s.jsx("div",{children:e.children})})}),i):null}return s.jsx(uh,{...e,ref:t})});lh.displayName=Nn;var _t=10,[ch,pn]=pr(Nn),ZC="SelectContentImpl",VC=rr("SelectContent.RemoveScroll"),uh=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:a,side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:v,hideWhenDetached:g,avoidCollisions:x,...b}=e,y=fn(Nn,n),[_,j]=p.useState(null),[S,E]=p.useState(null),C=De(t,ie=>j(ie)),[R,z]=p.useState(null),[O,q]=p.useState(null),T=Do(n),[D,k]=p.useState(!1),$=p.useRef(!1);p.useEffect(()=>{if(_)return Ff(_)},[_]),Rf();const X=p.useCallback(ie=>{const[ge,...he]=T().map(ue=>ue.ref.current),[xe]=he.slice(-1),te=document.activeElement;for(const ue of ie)if(ue===te||(ue?.scrollIntoView({block:"nearest"}),ue===ge&&S&&(S.scrollTop=0),ue===xe&&S&&(S.scrollTop=S.scrollHeight),ue?.focus(),document.activeElement!==te))return},[T,S]),B=p.useCallback(()=>X([R,_]),[X,R,_]);p.useEffect(()=>{D&&B()},[D,B]);const{onOpenChange:F,triggerPointerDownPosRef:Z}=y;p.useEffect(()=>{if(_){let ie={x:0,y:0};const ge=xe=>{ie={x:Math.abs(Math.round(xe.pageX)-(Z.current?.x??0)),y:Math.abs(Math.round(xe.pageY)-(Z.current?.y??0))}},he=xe=>{ie.x<=10&&ie.y<=10?xe.preventDefault():_.contains(xe.target)||F(!1),document.removeEventListener("pointermove",ge),Z.current=null};return Z.current!==null&&(document.addEventListener("pointermove",ge),document.addEventListener("pointerup",he,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ge),document.removeEventListener("pointerup",he,{capture:!0})}}},[_,F,Z]),p.useEffect(()=>{const ie=()=>F(!1);return window.addEventListener("blur",ie),window.addEventListener("resize",ie),()=>{window.removeEventListener("blur",ie),window.removeEventListener("resize",ie)}},[F]);const[J,H]=Sh(ie=>{const ge=T().filter(te=>!te.disabled),he=ge.find(te=>te.ref.current===document.activeElement),xe=Ch(ge,ie,he);xe&&setTimeout(()=>xe.ref.current.focus())}),W=p.useCallback((ie,ge,he)=>{const xe=!$.current&&!he;(y.value!==void 0&&y.value===ge||xe)&&(z(ie),xe&&($.current=!0))},[y.value]),ce=p.useCallback(()=>_?.focus(),[_]),se=p.useCallback((ie,ge,he)=>{const xe=!$.current&&!he;(y.value!==void 0&&y.value===ge||xe)&&q(ie)},[y.value]),oe=r==="popper"?Yi:dh,_e=oe===Yi?{side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return s.jsx(ch,{scope:n,content:_,viewport:S,onViewportChange:E,itemRefCallback:W,selectedItem:R,onItemLeave:ce,itemTextRefCallback:se,focusSelectedItem:B,selectedItemText:O,position:r,isPositioned:D,searchRef:J,children:s.jsx(Qa,{as:VC,allowPinchZoom:!0,children:s.jsx(Xa,{asChild:!0,trapped:y.open,onMountAutoFocus:ie=>{ie.preventDefault()},onUnmountAutoFocus:je(o,ie=>{y.trigger?.focus({preventScroll:!0}),ie.preventDefault()}),children:s.jsx(_o,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:ie=>ie.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:s.jsx(oe,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:ie=>ie.preventDefault(),...b,..._e,onPlaced:()=>k(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:je(b.onKeyDown,ie=>{const ge=ie.ctrlKey||ie.altKey||ie.metaKey;if(ie.key==="Tab"&&ie.preventDefault(),!ge&&ie.key.length===1&&H(ie.key),["ArrowUp","ArrowDown","Home","End"].includes(ie.key)){let xe=T().filter(te=>!te.disabled).map(te=>te.ref.current);if(["ArrowUp","End"].includes(ie.key)&&(xe=xe.slice().reverse()),["ArrowUp","ArrowDown"].includes(ie.key)){const te=ie.target,ue=xe.indexOf(te);xe=xe.slice(ue+1)}setTimeout(()=>X(xe)),ie.preventDefault()}})})})})})})});uh.displayName=ZC;var qC="SelectItemAlignedPosition",dh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,i=fn(Nn,n),a=pn(Nn,n),[l,c]=p.useState(null),[u,d]=p.useState(null),f=De(t,C=>d(C)),m=Do(n),h=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:b,focusSelectedItem:y}=a,_=p.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&u&&g&&x&&b){const C=i.trigger.getBoundingClientRect(),R=u.getBoundingClientRect(),z=i.valueNode.getBoundingClientRect(),O=b.getBoundingClientRect();if(i.dir!=="rtl"){const te=O.left-R.left,ue=z.left-te,be=C.left-ue,w=C.width+be,Y=Math.max(w,R.width),U=window.innerWidth-_t,I=Ji(ue,[_t,Math.max(_t,U-Y)]);l.style.minWidth=w+"px",l.style.left=I+"px"}else{const te=R.right-O.right,ue=window.innerWidth-z.right-te,be=window.innerWidth-C.right-ue,w=C.width+be,Y=Math.max(w,R.width),U=window.innerWidth-_t,I=Ji(ue,[_t,Math.max(_t,U-Y)]);l.style.minWidth=w+"px",l.style.right=I+"px"}const q=m(),T=window.innerHeight-_t*2,D=g.scrollHeight,k=window.getComputedStyle(u),$=parseInt(k.borderTopWidth,10),X=parseInt(k.paddingTop,10),B=parseInt(k.borderBottomWidth,10),F=parseInt(k.paddingBottom,10),Z=$+X+D+F+B,J=Math.min(x.offsetHeight*5,Z),H=window.getComputedStyle(g),W=parseInt(H.paddingTop,10),ce=parseInt(H.paddingBottom,10),se=C.top+C.height/2-_t,oe=T-se,_e=x.offsetHeight/2,ie=x.offsetTop+_e,ge=$+X+ie,he=Z-ge;if(ge<=se){const te=q.length>0&&x===q[q.length-1].ref.current;l.style.bottom="0px";const ue=u.clientHeight-g.offsetTop-g.offsetHeight,be=Math.max(oe,_e+(te?ce:0)+ue+B),w=ge+be;l.style.height=w+"px"}else{const te=q.length>0&&x===q[0].ref.current;l.style.top="0px";const be=Math.max(se,$+g.offsetTop+(te?W:0)+_e)+he;l.style.height=be+"px",g.scrollTop=ge-se+g.offsetTop}l.style.margin=`${_t}px 0`,l.style.minHeight=J+"px",l.style.maxHeight=T+"px",r?.(),requestAnimationFrame(()=>h.current=!0)}},[m,i.trigger,i.valueNode,l,u,g,x,b,i.dir,r]);Xe(()=>_(),[_]);const[j,S]=p.useState();Xe(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const E=p.useCallback(C=>{C&&v.current===!0&&(_(),y?.(),v.current=!1)},[_,y]);return s.jsx(GC,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:h,onScrollButtonChange:E,children:s.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:j},children:s.jsx(Ee.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});dh.displayName=qC;var KC="SelectPopperPosition",Yi=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=_t,...i}=e,a=$o(n);return s.jsx(Pp,{...a,...i,ref:t,align:r,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)"}})});Yi.displayName=KC;var[GC,wl]=pr(Nn,{}),Xi="SelectViewport",fh=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,i=pn(Xi,n),a=wl(Xi,n),l=De(t,i.onViewportChange),c=p.useRef(0);return s.jsxs(s.Fragment,{children:[s.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:r}),s.jsx(Lo.Slot,{scope:n,children:s.jsx(Ee.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:je(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 v=window.innerHeight-_t*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),b=Math.max(g,x);if(b<v){const y=b+h,_=Math.min(v,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})})})]})});fh.displayName=Xi;var ph="SelectGroup",[JC,YC]=pr(ph),XC=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=zt();return s.jsx(JC,{scope:n,id:o,children:s.jsx(Ee.div,{role:"group","aria-labelledby":o,...r,ref:t})})});XC.displayName=ph;var hh="SelectLabel",QC=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=YC(hh,n);return s.jsx(Ee.div,{id:o.id,...r,ref:t})});QC.displayName=hh;var Ys="SelectItem",[e5,mh]=pr(Ys),gh=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...a}=e,l=fn(Ys,n),c=pn(Ys,n),u=l.value===r,[d,f]=p.useState(i??""),[m,h]=p.useState(!1),v=De(t,y=>c.itemRefCallback?.(y,r,o)),g=zt(),x=p.useRef("touch"),b=()=>{o||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return s.jsx(e5,{scope:n,value:r,disabled:o,textId:g,isSelected:u,onItemTextChange:p.useCallback(y=>{f(_=>_||(y?.textContent??"").trim())},[]),children:s.jsx(Lo.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:s.jsx(Ee.div,{role:"option","aria-labelledby":g,"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:v,onFocus:je(a.onFocus,()=>h(!0)),onBlur:je(a.onBlur,()=>h(!1)),onClick:je(a.onClick,()=>{x.current!=="mouse"&&b()}),onPointerUp:je(a.onPointerUp,()=>{x.current==="mouse"&&b()}),onPointerDown:je(a.onPointerDown,y=>{x.current=y.pointerType}),onPointerMove:je(a.onPointerMove,y=>{x.current=y.pointerType,o?c.onItemLeave?.():x.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:je(a.onPointerLeave,y=>{y.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:je(a.onKeyDown,y=>{c.searchRef?.current!==""&&y.key===" "||(DC.includes(y.key)&&b(),y.key===" "&&y.preventDefault())})})})})});gh.displayName=Ys;var Cr="SelectItemText",xh=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...i}=e,a=fn(Cr,n),l=pn(Cr,n),c=mh(Cr,n),u=UC(Cr,n),[d,f]=p.useState(null),m=De(t,b=>f(b),c.onItemTextChange,b=>l.itemTextRefCallback?.(b,c.value,c.disabled)),h=d?.textContent,v=p.useMemo(()=>s.jsx("option",{value:c.value,disabled:c.disabled,children:h},c.value),[c.disabled,c.value,h]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=u;return Xe(()=>(g(v),()=>x(v)),[g,x,v]),s.jsxs(s.Fragment,{children:[s.jsx(Ee.span,{id:c.textId,...i,ref:m}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren?Fr.createPortal(i.children,a.valueNode):null]})});xh.displayName=Cr;var bh="SelectItemIndicator",vh=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return mh(bh,n).isSelected?s.jsx(Ee.span,{"aria-hidden":!0,...r,ref:t}):null});vh.displayName=bh;var Qi="SelectScrollUpButton",yh=p.forwardRef((e,t)=>{const n=pn(Qi,e.__scopeSelect),r=wl(Qi,e.__scopeSelect),[o,i]=p.useState(!1),a=De(t,r.onScrollButtonChange);return Xe(()=>{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?s.jsx(kh,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});yh.displayName=Qi;var ea="SelectScrollDownButton",wh=p.forwardRef((e,t)=>{const n=pn(ea,e.__scopeSelect),r=wl(ea,e.__scopeSelect),[o,i]=p.useState(!1),a=De(t,r.onScrollButtonChange);return Xe(()=>{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?s.jsx(kh,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});wh.displayName=ea;var kh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,i=pn("SelectScrollButton",n),a=p.useRef(null),l=Do(n),c=p.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return p.useEffect(()=>()=>c(),[c]),Xe(()=>{l().find(d=>d.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),s.jsx(Ee.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:je(o.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(r,50))}),onPointerMove:je(o.onPointerMove,()=>{i.onItemLeave?.(),a.current===null&&(a.current=window.setInterval(r,50))}),onPointerLeave:je(o.onPointerLeave,()=>{c()})})}),t5="SelectSeparator",n5=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return s.jsx(Ee.div,{"aria-hidden":!0,...r,ref:t})});n5.displayName=t5;var ta="SelectArrow",r5=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=$o(n),i=fn(ta,n),a=pn(ta,n);return i.open&&a.position==="popper"?s.jsx(Op,{...o,...r,ref:t}):null});r5.displayName=ta;var s5="SelectBubbleInput",_h=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),i=De(r,o),a=Hj(t);return p.useEffect(()=>{const l=o.current;if(!l)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(a!==t&&d){const f=new Event("change",{bubbles:!0});d.call(l,t),l.dispatchEvent(f)}},[a,t]),s.jsx(Ee.select,{...n,style:{...sp,...n.style},ref:i,defaultValue:t})});_h.displayName=s5;function jh(e){return e===""||e===void 0}function Sh(e){const t=rt(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(a=>{const l=n.current+a;t(l),(function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))})(l)},[t]),i=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,i]}function Ch(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=o5(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 o5(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var i5=th,a5=rh,l5=oh,c5=ih,u5=ah,d5=lh,f5=fh,p5=gh,h5=xh,m5=vh,g5=yh,x5=wh,Fo="Tabs",[b5]=Gt(Fo,[Lp]),Nh=Lp(),[v5,kl]=b5(Fo),Th=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:a="horizontal",dir:l,activationMode:c="automatic",...u}=e,d=Eo(l),[f,m]=_n({prop:r,onChange:o,defaultProp:i??"",caller:Fo});return s.jsx(v5,{scope:n,baseId:zt(),value:f,onValueChange:m,orientation:a,dir:d,activationMode:c,children:s.jsx(Ee.div,{dir:d,"data-orientation":a,...u,ref:t})})});Th.displayName=Fo;var Eh="TabsList",Ah=p.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=kl(Eh,n),a=Nh(n);return s.jsx(wC,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(Ee.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});Ah.displayName=Eh;var Rh="TabsTrigger",Ih=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,a=kl(Rh,n),l=Nh(n),c=Oh(a.baseId,r),u=Mh(a.baseId,r),d=r===a.value;return s.jsx(kC,{asChild:!0,...l,focusable:!o,active:d,children:s.jsx(Ee.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:je(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?a.onValueChange(r):f.preventDefault()}),onKeyDown:je(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&a.onValueChange(r)}),onFocus:je(e.onFocus,()=>{const f=a.activationMode!=="manual";!d&&!o&&f&&a.onValueChange(r)})})})});Ih.displayName=Rh;var zh="TabsContent",Ph=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...a}=e,l=kl(zh,n),c=Oh(l.baseId,r),u=Mh(l.baseId,r),d=r===l.value,f=p.useRef(d);return p.useEffect(()=>{const m=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(m)},[]),s.jsx(vt,{present:o||d,children:({present:m})=>s.jsx(Ee.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})})});Ph.displayName=zh;function Oh(e,t){return`${e}-trigger-${t}`}function Mh(e,t){return`${e}-content-${t}`}var y5=Th,w5=Ah,k5=Ih,_5=Ph,[Bo]=Gt("Tooltip",[Po]),Uo=Po(),Lh="TooltipProvider",j5=700,na="tooltip.open",[S5,_l]=Bo(Lh),Dh=e=>{const{__scopeTooltip:t,delayDuration:n=j5,skipDelayDuration:r=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)},[]),s.jsx(S5,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(c.current),a.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:p.useCallback(u=>{l.current=u},[]),disableHoverableContent:o,children:i})};Dh.displayName=Lh;var Mr="Tooltip",[C5,Gr]=Bo(Mr),$h=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:l}=e,c=_l(Mr,e.__scopeTooltip),u=Uo(t),[d,f]=p.useState(null),m=zt(),h=p.useRef(0),v=a??c.disableHoverableContent,g=l??c.delayDuration,x=p.useRef(!1),[b,y]=_n({prop:r,defaultProp:o??!1,onChange:C=>{C?(c.onOpen(),document.dispatchEvent(new CustomEvent(na))):c.onClose(),i?.(C)},caller:Mr}),_=p.useMemo(()=>b?x.current?"delayed-open":"instant-open":"closed",[b]),j=p.useCallback(()=>{window.clearTimeout(h.current),h.current=0,x.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(()=>{x.current=!0,y(!0),h.current=0},g)},[g,y]);return p.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),s.jsx(Ip,{...u,children:s.jsx(C5,{scope:t,contentId:m,open:b,stateAttribute:_,trigger:d,onTriggerChange:f,onTriggerEnter:p.useCallback(()=>{c.isOpenDelayedRef.current?E():j()},[c.isOpenDelayedRef,E,j]),onTriggerLeave:p.useCallback(()=>{v?S():(window.clearTimeout(h.current),h.current=0)},[S,v]),onOpen:j,onClose:S,disableHoverableContent:v,children:n})})};$h.displayName=Mr;var ra="TooltipTrigger",Fh=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Gr(ra,n),i=_l(ra,n),a=Uo(n),l=p.useRef(null),c=De(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]),s.jsx(zp,{asChild:!0,...a,children:s.jsx(Ee.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:je(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:je(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:je(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:je(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:je(e.onBlur,o.onClose),onClick:je(e.onClick,o.onClose)})})});Fh.displayName=ra;var jl="TooltipPortal",[N5,T5]=Bo(jl,{forceMount:void 0}),Bh=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=Gr(jl,t);return s.jsx(N5,{scope:t,forceMount:n,children:s.jsx(vt,{present:n||i.open,children:s.jsx(jo,{asChild:!0,container:o,children:r})})})};Bh.displayName=jl;var ir="TooltipContent",Uh=p.forwardRef((e,t)=>{const n=T5(ir,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=Gr(ir,e.__scopeTooltip);return s.jsx(vt,{present:r||a.open,children:a.disableHoverableContent?s.jsx(Wh,{side:o,...i,ref:t}):s.jsx(E5,{side:o,...i,ref:t})})}),E5=p.forwardRef((e,t)=>{const n=Gr(ir,e.__scopeTooltip),r=_l(ir,e.__scopeTooltip),o=p.useRef(null),i=De(t,o),[a,l]=p.useState(null),{trigger:c,onClose:u}=n,d=o.current,{onPointerInTransitChange:f}=r,m=p.useCallback(()=>{l(null),f(!1)},[f]),h=p.useCallback((v,g)=>{const x=v.currentTarget,b={x:v.clientX,y:v.clientY},y=z5(b,x.getBoundingClientRect()),_=P5(b,y),j=O5(g.getBoundingClientRect()),S=L5([..._,...j]);l(S),f(!0)},[f]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(c&&d){const v=x=>h(x,d),g=x=>h(x,c);return c.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[c,d,h,m]),p.useEffect(()=>{if(a){const v=g=>{const x=g.target,b={x:g.clientX,y:g.clientY},y=c?.contains(x)||d?.contains(x),_=!M5(b,a);y?m():_&&(m(),u())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[c,d,a,u,m]),s.jsx(Wh,{...e,ref:i})}),[A5,R5]=Bo(Mr,{isInside:!1}),I5=Lk("TooltipContent"),Wh=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...l}=e,c=Gr(ir,n),u=Uo(n),{onClose:d}=c;return p.useEffect(()=>(document.addEventListener(na,d),()=>document.removeEventListener(na,d)),[d]),p.useEffect(()=>{if(c.trigger){const f=m=>{m.target?.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),s.jsx(_o,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:s.jsxs(Pp,{"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:[s.jsx(I5,{children:r}),s.jsx(A5,{scope:n,isInside:!0,children:s.jsx(Dj,{id:c.contentId,role:"tooltip",children:o||r})})]})})});Uh.displayName=ir;var Hh="TooltipArrow",Zh=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Uo(n);return R5(Hh,n).isInside?null:s.jsx(Op,{...o,...r,ref:t})});Zh.displayName=Hh;function z5(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function P5(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function O5(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function M5(e,t){const{x:n,y:r}=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>r!=m>r&&n<(f-u)*(r-d)/(m-d)+u&&(o=!o)}return o}function L5(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),D5(t)}function D5(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];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 r=e.length-1;r>=0;r--){const o=e[r];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 $5=Dh,F5=$h,B5=Fh,U5=Bh,W5=Uh,H5=Zh;function Je({delayDuration:e=0,...t}){return s.jsx($5,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Oe({...e}){return s.jsx(F5,{"data-slot":"tooltip",...e})}function Me({...e}){return s.jsx(B5,{"data-slot":"tooltip-trigger",...e})}function Le({className:e,sideOffset:t=0,children:n,...r}){return s.jsx(U5,{children:s.jsxs(W5,{"data-slot":"tooltip-content",sideOffset:t,className:ae("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),...r,children:[n,s.jsx(H5,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const Z5=3;function V5({items:e,ariaLabel:t,className:n}){if(e.length===0)return s.jsx("span",{className:ae("flex h-8 w-12 shrink-0 items-center",n),"aria-hidden":"true"});const r=e.slice(0,Z5),o=e.length-r.length;return s.jsx(Je,{delayDuration:150,children:s.jsxs("span",{className:ae("flex h-8 w-12 shrink-0 items-center",n),"aria-label":t,children:[r.map((i,a)=>s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("span",{className:ae("border border-border bg-muted/40 inline-flex size-6 shrink-0 items-center justify-center rounded-md",a>0&&"-ml-2"),children:s.jsx(Mj,{provider:i.provider,className:"size-4"})})}),s.jsx(Le,{children:i.tooltip})]},`${i.provider}-${String(a)}`)),o>0&&s.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 q5="/v1/chat/completions",K5="/chat/completions",G5="/v1/responses",J5="/responses",Y5="/v1/messages";class X5{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]??"",r=this.pathMap.get(n);return r===void 0?void 0:this.handlers.get(r)}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 hn=new X5;function Q5(e){return hn.getApiFormatByPath(e)??"unknown"}hn.registerPath(Y5,"anthropic");hn.registerPath(q5,"openai");hn.registerPath(K5,"openai");hn.registerPath(G5,"openai");hn.registerPath(J5,"openai");function eN(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}catch{return{}}}function tN(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:eN(e.inputJson)}}}function Vh(e,t,n,r){const o=new Map;let i="",a="",l=null,c=null,u=0,d=0;const f=1e3;let m=0,h=0;const v=[];for(const x of e.split(`
86
- `)){const b=x.trim();if(b.startsWith("data: "))try{const y=JSON.parse(b.slice(6)),_=h1.safeParse(y);if(!_.success)continue;const j=_.data;switch(m===0&&(h=Date.now()),r===!0&&v.length<f&&v.push({index:m,timestamp:Date.now()-h,type:j.type,data: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{}}r===!0&&(t.streamingChunks={chunks:v,truncated:m>f});const g=[...o.entries()].sort(([x],[b])=>x-b).map(([,x])=>tN(x));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 nN={format:"anthropic",parseRequest(e,t){try{const n=JSON.parse(e),r=Md.safeParse(n);return r.success?{model:r.data.model,sessionId:r.data.metadata?.user_id??t?.get("x-session-affinity")??null}:null}catch{return null}},extractTokens(e){try{const t=JSON.parse(e),n=Ld.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,r){return Vh(e,t,n,r)},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}}};hn.register(nN);class rN{providers=[];register(t){this.providers.push(t)}findProvider(t){let n=null;for(const r of this.providers)if(r.matches(t)){if(r.name!=="anthropic")return r;n=r}return n}getAll(){return[...this.providers]}}const Wo=new rN,sN="https://api.anthropic.com",oN={MiniMax:"https://api.minimaxi.com/anthropic"},iN={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(oN))if(t.startsWith(n.toLowerCase()))return!0;return!0},getUpstreamBase(e,t){return t?.baseUrl!==void 0?t.baseUrl:sN},extractStream(e,t,n,r){return Vh(e,t,n,r)}};Wo.register(iN);const Sl=1e3;function Jr(e,t){if(!(e===null||typeof e!="object"||Array.isArray(e)))return Object.getOwnPropertyDescriptor(e,t)?.value}function tt(e,t){const n=Jr(e,t);return typeof n=="string"?n:null}function qh(e,t){const n=Jr(e,t);return typeof n=="number"&&Number.isFinite(n)?n:null}function Xs(e,t){const n=Jr(e,t);return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:null}function aN(e,t){const n=Jr(e,t);return Array.isArray(n)?n:[]}function lN(e){const t=[];let n=null,r=[];const o=()=>{n===null&&r.length===0||(t.push({event:n,data:r.join(`
85
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},rj="DialogDescriptionWarning",sj=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${sp(rj).contentName}}.`;return p.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},oj=Hf,ij=Vf,aj=Kf,lj=Gf,cj=Jf,uj=Xf,dj=ep,fj=np;function Hr({...e}){return s.jsx(oj,{"data-slot":"dialog",...e})}function ol({...e}){return s.jsx(ij,{"data-slot":"dialog-trigger",...e})}function pj({...e}){return s.jsx(aj,{"data-slot":"dialog-portal",...e})}function hj({className:e,...t}){return s.jsx(lj,{"data-slot":"dialog-overlay",className:le("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 Zr({className:e,children:t,...n}){return s.jsxs(pj,{children:[s.jsx(hj,{}),s.jsxs(cj,{"data-slot":"dialog-content",className:le("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,s.jsxs(fj,{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:[s.jsx(_o,{className:"size-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Vr({className:e,...t}){return s.jsx("div",{"data-slot":"dialog-header",className:le("flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function qr({className:e,...t}){return s.jsx(uj,{"data-slot":"dialog-title",className:le("text-lg font-semibold leading-none tracking-tight",e),...t})}function mj({className:e,...t}){return s.jsx(dj,{"data-slot":"dialog-description",className:le("text-sm text-muted-foreground",e),...t})}const Rc=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ic=pf,il=(e,t)=>n=>{var r;if(t?.variants==null)return Ic(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=Rc(d)||Rc(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||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:f,className:m,...h}=d;return Object.entries(h).every(v=>{let[g,x]=v;return Array.isArray(x)?x.includes({...i,...l}[g]):{...i,...l}[g]===x})?[...u,f,m]:u},[]);return Ic(e,a,c,n?.class,n?.className)},gj=il("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 Se({className:e,variant:t,size:n,...r}){return s.jsx("button",{"data-slot":"button",className:le(gj({variant:t,size:n,className:e})),...r})}function op({open:e,onOpenChange:t,title:n,description:r,confirmLabel:o="Confirm",variant:i="default",onConfirm:a}){return s.jsx(Hr,{open:e,onOpenChange:t,children:s.jsxs(Zr,{children:[s.jsx(Vr,{children:s.jsx(qr,{children:n})}),s.jsx("p",{className:"text-sm text-muted-foreground",children:r}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Se,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),s.jsx(Se,{variant:i,size:"sm",onClick:()=>{a(),t(!1)},children:o})]})]})})}const xj={codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code"};function li(e){return e?.toLowerCase()??""}function hs(e,t){for(const n of t)if(e.includes(n))return!0;return!1}function al(e){const t=[li(e.userAgent),li(e.conversationId),li(e.clientProjectFolder)].join(" ");return hs(t,["mimocode","mimo-code","mimo code"])?"mimo-code":hs(t,["opencode","open-code","open code"])?"opencode":hs(t,["claude-code","claude code","claudecode"])?"claude-code":hs(t,["codex desktop","codex-cli","openai-codex","codex"])?"codex":"unknown"}function To(e){switch(e){case"codex":case"opencode":case"mimo-code":case"claude-code":return xj[e];case"unknown":return null}}function bj(){return s.jsxs("svg",{viewBox:"0 0 24 24",className:"size-full","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"2.2"}),s.jsx("path",{d:"M14.8 8.6a4.8 4.8 0 1 0 0 6.8",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2.2"})]})}function vj(){return s.jsxs("svg",{viewBox:"0 0 24 24",className:"size-full","aria-hidden":"true",children:[s.jsx("path",{d:"M7 4h10v16H7z",fill:"none",stroke:"currentColor",strokeWidth:"2.2"}),s.jsx("path",{d:"M10 8h4M10 12h4M10 16h2",stroke:"currentColor",strokeLinecap:"round"})]})}function yj(){return s.jsx("svg",{viewBox:"0 0 24 24",className:"size-full","aria-hidden":"true",children:s.jsx("path",{d:"M5 18V6h3.2l3.8 6.1L15.8 6H19v12h-3V11.3l-3.1 5h-1.8L8 11.3V18z",fill:"currentColor"})})}function wj(){return s.jsx("svg",{viewBox:"0 0 24 24",className:"size-full","aria-hidden":"true",children:s.jsx("path",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",d:"M21 10.95h3v3.1h-3v3.03h-1.49V20H18v-2.92h-1.49V20H15v-2.92H9V20H7.49v-2.92H6V20H4.49v-2.92H3v-3.03H0v-3.1h3V5h18v5.95zM6 10.95h1.49V8.1H6v2.85zm10.51 0H18V8.1h-1.49v2.85z"})})}function ll({client:e,className:t}){const n=To(e);return n===null?null:s.jsxs("span",{className:le("border border-border bg-muted/40 inline-flex size-6 shrink-0 items-center justify-center rounded-md p-1 text-cyan-100",t),"aria-label":n,title:n,children:[e==="codex"&&s.jsx(bj,{}),e==="opencode"&&s.jsx(vj,{}),e==="mimo-code"&&s.jsx(yj,{}),e==="claude-code"&&s.jsx(wj,{})]})}const kj="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",_j="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",jj="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",Sj="/assets/minimax-BPMzvuL-.jpeg",Cj="/assets/alibaba-TTwafVwX.svg",Nj="/assets/qwen-CONDcHqt.png",Tj="/assets/zhipuai-BPNAnxo-.svg",Ej={"claude-":"anthropic","gpt-":"openai","o1-":"openai","o3-":"openai","deepseek-":"deepseek",MiniMax:"minimax",qwen:"qwen"};function Aj(e){return e.replace(/[_\s]+/g,"-").split(/[/:@]/).some(n=>n.startsWith("glm-"))}function Rj(e){if(e===null)return"unknown";const t=e.toLowerCase();if(Aj(t))return"zhipuai";for(const[n,r]of Object.entries(Ej))if(t.startsWith(n.toLowerCase()))return r;return"unknown"}const In={width:24,height:24,objectFit:"contain"},Ij=ot.memo(({className:e})=>s.jsx("img",{src:kj,alt:"Anthropic",className:e,style:In})),zj=ot.memo(({className:e})=>s.jsx("img",{src:_j,alt:"OpenAI",className:e,style:{...In,background:"white",borderRadius:"4px"}})),Pj=ot.memo(({className:e})=>s.jsx("img",{src:jj,alt:"DeepSeek",className:e,style:In})),Oj=ot.memo(({className:e})=>s.jsx("img",{src:Sj,alt:"MiniMax",className:e,style:In})),Mj=ot.memo(({className:e})=>s.jsx("img",{src:Cj,alt:"Alibaba",className:e,style:In})),Lj=ot.memo(({className:e})=>s.jsx("img",{src:Nj,alt:"Qwen",className:e,style:In})),Dj=ot.memo(({className:e})=>s.jsx("img",{src:Tj,alt:"ZhipuAI",className:e,style:In}));function $j({provider:e,className:t}){switch(e){case"anthropic":return s.jsx(Ij,{className:t});case"openai":return s.jsx(zj,{className:t});case"deepseek":return s.jsx(Pj,{className:t});case"minimax":return s.jsx(Oj,{className:t});case"alibaba":return s.jsx(Mj,{className:t});case"qwen":return s.jsx(Lj,{className:t});case"zhipuai":return s.jsx(Dj,{className:t});case"unknown":return null}}var ip=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"}),Fj="VisuallyHidden",ap=p.forwardRef((e,t)=>s.jsx(Ee.span,{...e,ref:t,style:{...ip,...e.style}}));ap.displayName=Fj;var Bj=ap;function lp(e){const t=e+"CollectionProvider",[n,r]=Gt(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=g=>{const{scope:x,children:b}=g,y=ot.useRef(null),_=ot.useRef(new Map).current;return s.jsx(o,{scope:x,itemMap:_,collectionRef:y,children:b})};a.displayName=t;const l=e+"CollectionSlot",c=rr(l),u=ot.forwardRef((g,x)=>{const{scope:b,children:y}=g,_=i(l,b),j=De(x,_.collectionRef);return s.jsx(c,{ref:j,children:y})});u.displayName=l;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=rr(d),h=ot.forwardRef((g,x)=>{const{scope:b,children:y,..._}=g,j=ot.useRef(null),S=De(x,j),E=i(d,b);return ot.useEffect(()=>(E.itemMap.set(j,{ref:j,..._}),()=>{E.itemMap.delete(j)})),s.jsx(m,{[f]:"",ref:S,children:y})});h.displayName=d;function v(g){const x=i(e+"CollectionConsumer",g);return ot.useCallback(()=>{const y=x.collectionRef.current;if(!y)return[];const _=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((E,C)=>_.indexOf(E.ref.current)-_.indexOf(C.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:a,Slot:u,ItemSlot:h},v,r]}var Eo="Collapsible",[Uj]=Gt(Eo),[Wj,cl]=Uj(Eo),cp=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:i,onOpenChange:a,...l}=e,[c,u]=_n({prop:r,defaultProp:o??!1,onChange:a,caller:Eo});return s.jsx(Wj,{scope:n,disabled:i,contentId:zt(),open:c,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),children:s.jsx(Ee.div,{"data-state":dl(c),"data-disabled":i?"":void 0,...l,ref:t})})});cp.displayName=Eo;var up="CollapsibleTrigger",dp=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=cl(up,n);return s.jsx(Ee.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":dl(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:je(e.onClick,o.onOpenToggle)})});dp.displayName=up;var ul="CollapsibleContent",fp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=cl(ul,e.__scopeCollapsible);return s.jsx(vt,{present:n||o.open,children:({present:i})=>s.jsx(Hj,{...r,ref:t,present:i})})});fp.displayName=ul;var Hj=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...i}=e,a=cl(ul,n),[l,c]=p.useState(r),u=p.useRef(null),d=De(t,u),f=p.useRef(0),m=f.current,h=p.useRef(0),v=h.current,g=a.open||l,x=p.useRef(g),b=p.useRef(void 0);return p.useEffect(()=>{const y=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(y)},[]),Xe(()=>{const y=u.current;if(y){b.current=b.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,x.current||(y.style.transitionDuration=b.current.transitionDuration,y.style.animationName=b.current.animationName),c(r)}},[a.open,r]),s.jsx(Ee.div,{"data-state":dl(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":v?`${v}px`:void 0,...e.style},children:g&&o})});function dl(e){return e?"open":"closed"}var Zj=cp,Vj=p.createContext(void 0);function Ao(e){const t=p.useContext(Vj);return e||t||"ltr"}function qj(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 Kj(e){const[t,n]=p.useState(void 0);return Xe(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=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 r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}const Gj=["top","right","bottom","left"],ln=Math.min,ct=Math.max,Vs=Math.round,ms=Math.floor,Pt=e=>({x:e,y:e}),Jj={left:"right",right:"left",bottom:"top",top:"bottom"},Yj={start:"end",end:"start"};function Ki(e,t,n){return ct(e,ln(t,n))}function Zt(e,t){return typeof e=="function"?e(t):e}function Vt(e){return e.split("-")[0]}function dr(e){return e.split("-")[1]}function fl(e){return e==="x"?"y":"x"}function pl(e){return e==="y"?"height":"width"}const Xj=new Set(["top","bottom"]);function It(e){return Xj.has(Vt(e))?"y":"x"}function hl(e){return fl(It(e))}function Qj(e,t,n){n===void 0&&(n=!1);const r=dr(e),o=hl(e),i=pl(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=qs(a)),[a,qs(a)]}function eS(e){const t=qs(e);return[Gi(e),t,Gi(t)]}function Gi(e){return e.replace(/start|end/g,t=>Yj[t])}const zc=["left","right"],Pc=["right","left"],tS=["top","bottom"],nS=["bottom","top"];function rS(e,t,n){switch(e){case"top":case"bottom":return n?t?Pc:zc:t?zc:Pc;case"left":case"right":return t?tS:nS;default:return[]}}function sS(e,t,n,r){const o=dr(e);let i=rS(Vt(e),n==="start",r);return o&&(i=i.map(a=>a+"-"+o),t&&(i=i.concat(i.map(Gi)))),i}function qs(e){return e.replace(/left|right|bottom|top/g,t=>Jj[t])}function oS(e){return{top:0,right:0,bottom:0,left:0,...e}}function pp(e){return typeof e!="number"?oS(e):{top:e,right:e,bottom:e,left:e}}function Ks(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Oc(e,t,n){let{reference:r,floating:o}=e;const i=It(t),a=hl(t),l=pl(a),c=Vt(t),u=i==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,m=r[l]/2-o[l]/2;let h;switch(c){case"top":h={x:d,y:r.y-o.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-o.width,y:f};break;default:h={x:r.x,y:r.y}}switch(dr(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 iS(e,t){var n;t===void 0&&(t={});const{x:r,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}=Zt(t,e),v=pp(h),x=l[m?f==="floating"?"reference":"floating":f],b=Ks(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(x)))==null||n?x:x.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:u,rootBoundary:d,strategy:c})),y=f==="floating"?{x:r,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=Ks(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:_,strategy:c}):y);return{top:(b.top-S.top+v.top)/j.y,bottom:(S.bottom-b.bottom+v.bottom)/j.y,left:(b.left-S.left+v.left)/j.x,right:(S.right-b.right+v.right)/j.x}}const aS=async(e,t,n)=>{const{placement:r="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}=Oc(u,r,c),m=r,h={},v=0;for(let x=0;x<l.length;x++){var g;const{name:b,fn:y}=l[x],{x:_,y:j,data:S,reset:E}=await y({x:d,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:h,rects:u,platform:{...a,detectOverflow:(g=a.detectOverflow)!=null?g:iS},elements:{reference:e,floating:t}});d=_??d,f=j??f,h={...h,[b]:{...h[b],...S}},E&&v<=50&&(v++,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}=Oc(u,m,c)),x=-1)}return{x:d,y:f,placement:m,strategy:o,middlewareData:h}},lS=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:a,elements:l,middlewareData:c}=t,{element:u,padding:d=0}=Zt(e,t)||{};if(u==null)return{};const f=pp(d),m={x:n,y:r},h=hl(o),v=pl(h),g=await a.getDimensions(u),x=h==="y",b=x?"top":"left",y=x?"bottom":"right",_=x?"clientHeight":"clientWidth",j=i.reference[v]+i.reference[h]-m[h]-i.floating[v],S=m[h]-i.reference[h],E=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let C=E?E[_]:0;(!C||!await(a.isElement==null?void 0:a.isElement(E)))&&(C=l.floating[_]||i.floating[v]);const R=j/2-S/2,z=C/2-g[v]/2-1,O=ln(f[b],z),q=ln(f[y],z),T=O,D=C-g[v]-q,k=C/2-g[v]/2+R,$=Ki(T,k,D),X=!c.arrow&&dr(o)!=null&&k!==$&&i.reference[v]/2-(k<T?O:q)-g[v]/2<0,B=X?k<T?k-T:k-D:0;return{[h]:m[h]+B,data:{[h]:$,centerOffset:k-$-B,...X&&{alignmentOffset:B}},reset:X}}}),cS=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;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:v="none",flipAlignment:g=!0,...x}=Zt(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=Vt(o),y=It(l),_=Vt(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=m||(_||!g?[qs(l)]:eS(l)),E=v!=="none";!m&&E&&S.push(...sS(l,g,v,j));const C=[l,...S],R=await c.detectOverflow(t,x),z=[];let O=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&z.push(R[b]),f){const k=Qj(o,a,j);z.push(R[k[0]],R[k[1]])}if(O=[...O,{placement:o,overflows:z}],!z.every(k=>k<=0)){var q,T;const k=(((q=i.flip)==null?void 0:q.index)||0)+1,$=C[k];if($&&(!(f==="alignment"?y!==It($):!1)||O.every(F=>It(F.placement)===y?F.overflows[0]>0:!0)))return{data:{index:k,overflows:O},reset:{placement:$}};let X=(T=O.filter(B=>B.overflows[0]<=0).sort((B,F)=>B.overflows[1]-F.overflows[1])[0])==null?void 0:T.placement;if(!X)switch(h){case"bestFit":{var D;const B=(D=O.filter(F=>{if(E){const Z=It(F.placement);return Z===y||Z==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(Z=>Z>0).reduce((Z,J)=>Z+J,0)]).sort((F,Z)=>F[1]-Z[1])[0])==null?void 0:D[0];B&&(X=B);break}case"initialPlacement":X=l;break}if(o!==X)return{reset:{placement:X}}}return{}}}};function Mc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Lc(e){return Gj.some(t=>e[t]>=0)}const uS=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...i}=Zt(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...i,elementContext:"reference"}),l=Mc(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Lc(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...i,altBoundary:!0}),l=Mc(a,n.floating);return{data:{escapedOffsets:l,escaped:Lc(l)}}}default:return{}}}}},hp=new Set(["left","top"]);async function dS(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Vt(n),l=dr(n),c=It(n)==="y",u=hp.has(a)?-1:1,d=i&&c?-1:1,f=Zt(t,e);let{mainAxis:m,crossAxis:h,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof v=="number"&&(h=l==="end"?v*-1:v),c?{x:h*d,y:m*u}:{x:m*u,y:h*d}}const fS=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:a,middlewareData:l}=t,c=await dS(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:i+c.y,data:{...c,placement:a}}}}},pS=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:i}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:b=>{let{x:y,y:_}=b;return{x:y,y:_}}},...u}=Zt(e,t),d={x:n,y:r},f=await i.detectOverflow(t,u),m=It(Vt(o)),h=fl(m);let v=d[h],g=d[m];if(a){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",_=v+f[b],j=v-f[y];v=Ki(_,v,j)}if(l){const b=m==="y"?"top":"left",y=m==="y"?"bottom":"right",_=g+f[b],j=g-f[y];g=Ki(_,g,j)}const x=c.fn({...t,[h]:v,[m]:g});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:a,[m]:l}}}}}},hS=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:a}=t,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=Zt(e,t),d={x:n,y:r},f=It(o),m=fl(f);let h=d[m],v=d[f];const g=Zt(l,t),x=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[_]+x.mainAxis,S=i.reference[m]+i.reference[_]-x.mainAxis;h<j?h=j:h>S&&(h=S)}if(u){var b,y;const _=m==="y"?"width":"height",j=hp.has(Vt(o)),S=i.reference[f]-i.floating[_]+(j&&((b=a.offset)==null?void 0:b[f])||0)+(j?0:x.crossAxis),E=i.reference[f]+i.reference[_]+(j?0:((y=a.offset)==null?void 0:y[f])||0)-(j?x.crossAxis:0);v<S?v=S:v>E&&(v=E)}return{[m]:h,[f]:v}}}},mS=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:a,elements:l}=t,{apply:c=()=>{},...u}=Zt(e,t),d=await a.detectOverflow(t,u),f=Vt(o),m=dr(o),h=It(o)==="y",{width:v,height:g}=i.floating;let x,b;f==="top"||f==="bottom"?(x=f,b=m===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(b=f,x=m==="end"?"top":"bottom");const y=g-d.top-d.bottom,_=v-d.left-d.right,j=ln(g-d[x],y),S=ln(v-d[b],_),E=!t.middlewareData.shift;let C=j,R=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(R=_),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=y),E&&!m){const O=ct(d.left,0),q=ct(d.right,0),T=ct(d.top,0),D=ct(d.bottom,0);h?R=v-2*(O!==0||q!==0?O+q:ct(d.left,d.right)):C=g-2*(T!==0||D!==0?T+D:ct(d.top,d.bottom))}await c({...t,availableWidth:R,availableHeight:C});const z=await a.getDimensions(l.floating);return v!==z.width||g!==z.height?{reset:{rects:!0}}:{}}}};function Ro(){return typeof window<"u"}function fr(e){return mp(e)?(e.nodeName||"").toLowerCase():"#document"}function dt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Lt(e){var t;return(t=(mp(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function mp(e){return Ro()?e instanceof Node||e instanceof dt(e).Node:!1}function St(e){return Ro()?e instanceof Element||e instanceof dt(e).Element:!1}function Ot(e){return Ro()?e instanceof HTMLElement||e instanceof dt(e).HTMLElement:!1}function Dc(e){return!Ro()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof dt(e).ShadowRoot}const gS=new Set(["inline","contents"]);function Kr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Ct(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!gS.has(o)}const xS=new Set(["table","td","th"]);function bS(e){return xS.has(fr(e))}const vS=[":popover-open",":modal"];function Io(e){return vS.some(t=>{try{return e.matches(t)}catch{return!1}})}const yS=["transform","translate","scale","rotate","perspective"],wS=["transform","translate","scale","rotate","perspective","filter"],kS=["paint","layout","strict","content"];function ml(e){const t=gl(),n=St(e)?Ct(e):e;return yS.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||wS.some(r=>(n.willChange||"").includes(r))||kS.some(r=>(n.contain||"").includes(r))}function _S(e){let t=cn(e);for(;Ot(t)&&!sr(t);){if(ml(t))return t;if(Io(t))return null;t=cn(t)}return null}function gl(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const jS=new Set(["html","body","#document"]);function sr(e){return jS.has(fr(e))}function Ct(e){return dt(e).getComputedStyle(e)}function zo(e){return St(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function cn(e){if(fr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Dc(e)&&e.host||Lt(e);return Dc(t)?t.host:t}function gp(e){const t=cn(e);return sr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ot(t)&&Kr(t)?t:gp(t)}function Or(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=gp(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),a=dt(o);if(i){const l=Ji(a);return t.concat(a,a.visualViewport||[],Kr(o)?o:[],l&&n?Or(l):[])}return t.concat(o,Or(o,[],n))}function Ji(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function xp(e){const t=Ct(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ot(e),i=o?e.offsetWidth:n,a=o?e.offsetHeight:r,l=Vs(n)!==i||Vs(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function xl(e){return St(e)?e:e.contextElement}function Jn(e){const t=xl(e);if(!Ot(t))return Pt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=xp(t);let a=(i?Vs(n.width):n.width)/r,l=(i?Vs(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const SS=Pt(0);function bp(e){const t=dt(e);return!gl()||!t.visualViewport?SS:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function CS(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==dt(e)?!1:t}function Sn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=xl(e);let a=Pt(1);t&&(r?St(r)&&(a=Jn(r)):a=Jn(e));const l=CS(i,n,r)?bp(i):Pt(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=dt(i),h=r&&St(r)?dt(r):r;let v=m,g=Ji(v);for(;g&&r&&h!==v;){const x=Jn(g),b=g.getBoundingClientRect(),y=Ct(g),_=b.left+(g.clientLeft+parseFloat(y.paddingLeft))*x.x,j=b.top+(g.clientTop+parseFloat(y.paddingTop))*x.y;c*=x.x,u*=x.y,d*=x.x,f*=x.y,c+=_,u+=j,v=dt(g),g=Ji(v)}}return Ks({width:d,height:f,x:c,y:u})}function Po(e,t){const n=zo(e).scrollLeft;return t?t.left+n:Sn(Lt(e)).left+n}function vp(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Po(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function NS(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",a=Lt(r),l=t?Io(t.floating):!1;if(r===a||l&&i)return n;let c={scrollLeft:0,scrollTop:0},u=Pt(1);const d=Pt(0),f=Ot(r);if((f||!f&&!i)&&((fr(r)!=="body"||Kr(a))&&(c=zo(r)),Ot(r))){const h=Sn(r);u=Jn(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const m=a&&!f&&!i?vp(a,c):Pt(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 TS(e){return Array.from(e.getClientRects())}function ES(e){const t=Lt(e),n=zo(e),r=e.ownerDocument.body,o=ct(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=ct(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Po(e);const l=-n.scrollTop;return Ct(r).direction==="rtl"&&(a+=ct(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:a,y:l}}const $c=25;function AS(e,t){const n=dt(e),r=Lt(e),o=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,c=0;if(o){i=o.width,a=o.height;const d=gl();(!d||d&&t==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}const u=Po(r);if(u<=0){const d=r.ownerDocument,f=d.body,m=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-h);v<=$c&&(i-=v)}else u<=$c&&(i+=u);return{width:i,height:a,x:l,y:c}}const RS=new Set(["absolute","fixed"]);function IS(e,t){const n=Sn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Ot(e)?Jn(e):Pt(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,c=o*i.x,u=r*i.y;return{width:a,height:l,x:c,y:u}}function Fc(e,t,n){let r;if(t==="viewport")r=AS(e,n);else if(t==="document")r=ES(Lt(e));else if(St(t))r=IS(t,n);else{const o=bp(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ks(r)}function yp(e,t){const n=cn(e);return n===t||!St(n)||sr(n)?!1:Ct(n).position==="fixed"||yp(n,t)}function zS(e,t){const n=t.get(e);if(n)return n;let r=Or(e,[],!1).filter(l=>St(l)&&fr(l)!=="body"),o=null;const i=Ct(e).position==="fixed";let a=i?cn(e):e;for(;St(a)&&!sr(a);){const l=Ct(a),c=ml(a);!c&&l.position==="fixed"&&(o=null),(i?!c&&!o:!c&&l.position==="static"&&!!o&&RS.has(o.position)||Kr(a)&&!c&&yp(e,a))?r=r.filter(d=>d!==a):o=l,a=cn(a)}return t.set(e,r),r}function PS(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?Io(t)?[]:zS(t,this._c):[].concat(n),r],l=a[0],c=a.reduce((u,d)=>{const f=Fc(t,d,o);return u.top=ct(f.top,u.top),u.right=ln(f.right,u.right),u.bottom=ln(f.bottom,u.bottom),u.left=ct(f.left,u.left),u},Fc(t,l,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function OS(e){const{width:t,height:n}=xp(e);return{width:t,height:n}}function MS(e,t,n){const r=Ot(t),o=Lt(t),i=n==="fixed",a=Sn(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=Pt(0);function u(){c.x=Po(o)}if(r||!r&&!i)if((fr(t)!=="body"||Kr(o))&&(l=zo(t)),r){const h=Sn(t,!0,i,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else o&&u();i&&!r&&o&&u();const d=o&&!r&&!i?vp(o,l):Pt(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 ci(e){return Ct(e).position==="static"}function Bc(e,t){if(!Ot(e)||Ct(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Lt(e)===n&&(n=n.ownerDocument.body),n}function wp(e,t){const n=dt(e);if(Io(e))return n;if(!Ot(e)){let o=cn(e);for(;o&&!sr(o);){if(St(o)&&!ci(o))return o;o=cn(o)}return n}let r=Bc(e,t);for(;r&&bS(r)&&ci(r);)r=Bc(r,t);return r&&sr(r)&&ci(r)&&!ml(r)?n:r||_S(e)||n}const LS=async function(e){const t=this.getOffsetParent||wp,n=this.getDimensions,r=await n(e.floating);return{reference:MS(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function DS(e){return Ct(e).direction==="rtl"}const $S={convertOffsetParentRelativeRectToViewportRelativeRect:NS,getDocumentElement:Lt,getClippingRect:PS,getOffsetParent:wp,getElementRects:LS,getClientRects:TS,getDimensions:OS,getScale:Jn,isElement:St,isRTL:DS};function kp(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function FS(e,t){let n=null,r;const o=Lt(e);function i(){var l;clearTimeout(r),(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 v=ms(f),g=ms(o.clientWidth-(d+m)),x=ms(o.clientHeight-(f+h)),b=ms(d),_={rootMargin:-v+"px "+-g+"px "+-x+"px "+-b+"px",threshold:ct(0,ln(1,c))||1};let j=!0;function S(E){const C=E[0].intersectionRatio;if(C!==c){if(!j)return a();C?a(!1,C):r=setTimeout(()=>{a(!1,1e-7)},1e3)}C===1&&!kp(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 BS(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=xl(e),d=o||i?[...u?Or(u):[],...Or(t)]:[];d.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),i&&b.addEventListener("resize",n)});const f=u&&l?FS(u,n):null;let m=-1,h=null;a&&(h=new ResizeObserver(b=>{let[y]=b;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 v,g=c?Sn(e):null;c&&x();function x(){const b=Sn(e);g&&!kp(g,b)&&n(),g=b,v=requestAnimationFrame(x)}return n(),()=>{var b;d.forEach(y=>{o&&y.removeEventListener("scroll",n),i&&y.removeEventListener("resize",n)}),f?.(),(b=h)==null||b.disconnect(),h=null,c&&cancelAnimationFrame(v)}}const US=fS,WS=pS,HS=cS,ZS=mS,VS=uS,Uc=lS,qS=hS,KS=(e,t,n)=>{const r=new Map,o={platform:$S,...n},i={...o.platform,_c:r};return aS(e,t,{...o,platform:i})};var GS=typeof document<"u",JS=function(){},Is=GS?p.useLayoutEffect:JS;function Gs(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,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Gs(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Gs(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function _p(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Wc(e,t){const n=_p(e);return Math.round(t*n)/n}function ui(e){const t=p.useRef(e);return Is(()=>{t.current=e}),t}function YS(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],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(r);Gs(m,r)||h(r);const[v,g]=p.useState(null),[x,b]=p.useState(null),y=p.useCallback(F=>{F!==E.current&&(E.current=F,g(F))},[]),_=p.useCallback(F=>{F!==C.current&&(C.current=F,b(F))},[]),j=i||v,S=a||x,E=p.useRef(null),C=p.useRef(null),R=p.useRef(d),z=c!=null,O=ui(c),q=ui(o),T=ui(u),D=p.useCallback(()=>{if(!E.current||!C.current)return;const F={placement:t,strategy:n,middleware:m};q.current&&(F.platform=q.current),KS(E.current,C.current,F).then(Z=>{const J={...Z,isPositioned:T.current!==!1};k.current&&!Gs(R.current,J)&&(R.current=J,Br.flushSync(()=>{f(J)}))})},[m,t,n,q,T]);Is(()=>{u===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,f(F=>({...F,isPositioned:!1})))},[u]);const k=p.useRef(!1);Is(()=>(k.current=!0,()=>{k.current=!1}),[]),Is(()=>{if(j&&(E.current=j),S&&(C.current=S),j&&S){if(O.current)return O.current(j,S,D);D()}},[j,S,D,O,z]);const $=p.useMemo(()=>({reference:E,floating:C,setReference:y,setFloating:_}),[y,_]),X=p.useMemo(()=>({reference:j,floating:S}),[j,S]),B=p.useMemo(()=>{const F={position:n,left:0,top:0};if(!X.floating)return F;const Z=Wc(X.floating,d.x),J=Wc(X.floating,d.y);return l?{...F,transform:"translate("+Z+"px, "+J+"px)",..._p(X.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Z,top:J}},[n,l,X.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:D,refs:$,elements:X,floatingStyles:B}),[d,D,$,X,B])}const XS=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Uc({element:r.current,padding:o}).fn(n):{}:r?Uc({element:r,padding:o}).fn(n):{}}}},QS=(e,t)=>({...US(e),options:[e,t]}),eC=(e,t)=>({...WS(e),options:[e,t]}),tC=(e,t)=>({...qS(e),options:[e,t]}),nC=(e,t)=>({...HS(e),options:[e,t]}),rC=(e,t)=>({...ZS(e),options:[e,t]}),sC=(e,t)=>({...VS(e),options:[e,t]}),oC=(e,t)=>({...XS(e),options:[e,t]});var iC="Arrow",jp=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return s.jsx(Ee.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});jp.displayName=iC;var aC=jp,bl="Popper",[Sp,Oo]=Gt(bl),[lC,Cp]=Sp(bl),Np=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return s.jsx(lC,{scope:t,anchor:r,onAnchorChange:o,children:n})};Np.displayName=bl;var Tp="PopperAnchor",Ep=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=Cp(Tp,n),a=p.useRef(null),l=De(t,a),c=p.useRef(null);return p.useEffect(()=>{const u=c.current;c.current=r?.current||a.current,u!==c.current&&i.onAnchorChange(c.current)}),r?null:s.jsx(Ee.div,{...o,ref:l})});Ep.displayName=Tp;var vl="PopperContent",[cC,uC]=Sp(vl),Ap=p.forwardRef((e,t)=>{const{__scopePopper:n,side:r="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:v,...g}=e,x=Cp(vl,n),[b,y]=p.useState(null),_=De(t,ie=>y(ie)),[j,S]=p.useState(null),E=Kj(j),C=E?.width??0,R=E?.height??0,z=r+(i!=="center"?"-"+i:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},q=Array.isArray(u)?u:[u],T=q.length>0,D={padding:O,boundary:q.filter(fC),altBoundary:T},{refs:k,floatingStyles:$,placement:X,isPositioned:B,middlewareData:F}=YS({strategy:"fixed",placement:z,whileElementsMounted:(...ie)=>BS(...ie,{animationFrame:h==="always"}),elements:{reference:x.anchor},middleware:[QS({mainAxis:o+R,alignmentAxis:a}),c&&eC({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?tC():void 0,...D}),c&&nC({...D}),rC({...D,apply:({elements:ie,rects:ge,availableWidth:he,availableHeight:xe})=>{const{width:te,height:ue}=ge.reference,be=ie.floating.style;be.setProperty("--radix-popper-available-width",`${he}px`),be.setProperty("--radix-popper-available-height",`${xe}px`),be.setProperty("--radix-popper-anchor-width",`${te}px`),be.setProperty("--radix-popper-anchor-height",`${ue}px`)}}),j&&oC({element:j,padding:l}),pC({arrowWidth:C,arrowHeight:R}),m&&sC({strategy:"referenceHidden",...D})]}),[Z,J]=zp(X),H=rt(v);Xe(()=>{B&&H?.()},[B,H]);const W=F.arrow?.x,ce=F.arrow?.y,se=F.arrow?.centerOffset!==0,[oe,_e]=p.useState();return Xe(()=>{b&&_e(window.getComputedStyle(b).zIndex)},[b]),s.jsx("div",{ref:k.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:B?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oe,"--radix-popper-transform-origin":[F.transformOrigin?.x,F.transformOrigin?.y].join(" "),...F.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(cC,{scope:n,placedSide:Z,onArrowChange:S,arrowX:W,arrowY:ce,shouldHideArrow:se,children:s.jsx(Ee.div,{"data-side":Z,"data-align":J,...g,ref:_,style:{...g.style,animation:B?void 0:"none"}})})})});Ap.displayName=vl;var Rp="PopperArrow",dC={top:"bottom",right:"left",bottom:"top",left:"right"},Ip=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=uC(Rp,r),a=dC[i.placedSide];return s.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:s.jsx(aC,{...o,ref:n,style:{...o.style,display:"block"}})})});Ip.displayName=Rp;function fC(e){return e!==null}var pC=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,a=o.arrow?.centerOffset!==0,l=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[u,d]=zp(n),f={start:"0%",center:"50%",end:"100%"}[d],m=(o.arrow?.x??0)+l/2,h=(o.arrow?.y??0)+c/2;let v="",g="";return u==="bottom"?(v=a?f:`${m}px`,g=`${-c}px`):u==="top"?(v=a?f:`${m}px`,g=`${r.floating.height+c}px`):u==="right"?(v=`${-c}px`,g=a?f:`${h}px`):u==="left"&&(v=`${r.floating.width+c}px`,g=a?f:`${h}px`),{data:{x:v,y:g}}}});function zp(e){const[t,n="center"]=e.split("-");return[t,n]}var Pp=Np,Op=Ep,Mp=Ap,Lp=Ip,di="rovingFocusGroup.onEntryFocus",hC={bubbles:!1,cancelable:!0},Gr="RovingFocusGroup",[Yi,Dp,mC]=lp(Gr),[gC,$p]=Gt(Gr,[mC]),[xC,bC]=gC(Gr),Fp=p.forwardRef((e,t)=>s.jsx(Yi.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(Yi.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(vC,{...e,ref:t})})}));Fp.displayName=Gr;var vC=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,m=p.useRef(null),h=De(t,m),v=Ao(i),[g,x]=_n({prop:a,defaultProp:l??null,onChange:c,caller:Gr}),[b,y]=p.useState(!1),_=rt(u),j=Dp(n),S=p.useRef(!1),[E,C]=p.useState(0);return p.useEffect(()=>{const R=m.current;if(R)return R.addEventListener(di,_),()=>R.removeEventListener(di,_)},[_]),s.jsx(xC,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(R=>x(R),[x]),onItemShiftTab:p.useCallback(()=>y(!0),[]),onFocusableItemAdd:p.useCallback(()=>C(R=>R+1),[]),onFocusableItemRemove:p.useCallback(()=>C(R=>R-1),[]),children:s.jsx(Ee.div,{tabIndex:b||E===0?-1:0,"data-orientation":r,...f,ref:h,style:{outline:"none",...e.style},onMouseDown:je(e.onMouseDown,()=>{S.current=!0}),onFocus:je(e.onFocus,R=>{const z=!S.current;if(R.target===R.currentTarget&&z&&!b){const O=new CustomEvent(di,hC);if(R.currentTarget.dispatchEvent(O),!O.defaultPrevented){const q=j().filter(X=>X.focusable),T=q.find(X=>X.active),D=q.find(X=>X.id===g),$=[T,D,...q].filter(Boolean).map(X=>X.ref.current);Wp($,d)}}S.current=!1}),onBlur:je(e.onBlur,()=>y(!1))})})}),Bp="RovingFocusGroupItem",Up=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:a,...l}=e,c=zt(),u=i||c,d=bC(Bp,n),f=d.currentTabStopId===u,m=Dp(n),{onFocusableItemAdd:h,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return h(),()=>v()},[r,h,v]),s.jsx(Yi.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:s.jsx(Ee.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...l,ref:t,onMouseDown:je(e.onMouseDown,x=>{r?d.onItemFocus(u):x.preventDefault()}),onFocus:je(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:je(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const b=kC(x,d.orientation,d.dir);if(b!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let _=m().filter(j=>j.focusable).map(j=>j.ref.current);if(b==="last")_.reverse();else if(b==="prev"||b==="next"){b==="prev"&&_.reverse();const j=_.indexOf(x.currentTarget);_=d.loop?_C(_,j+1):_.slice(j+1)}setTimeout(()=>Wp(_))}}),children:typeof a=="function"?a({isCurrentTabStop:f,hasTabStop:g!=null}):a})})});Up.displayName=Bp;var yC={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function wC(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function kC(e,t,n){const r=wC(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return yC[r]}function Wp(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function _C(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var jC=Fp,SC=Up;function Xi(e,[t,n]){return Math.min(n,Math.max(t,e))}function CC(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var yl="ScrollArea",[Hp]=Gt(yl),[NC,yt]=Hp(yl),Zp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:i=600,...a}=e,[l,c]=p.useState(null),[u,d]=p.useState(null),[f,m]=p.useState(null),[h,v]=p.useState(null),[g,x]=p.useState(null),[b,y]=p.useState(0),[_,j]=p.useState(0),[S,E]=p.useState(!1),[C,R]=p.useState(!1),z=De(t,q=>c(q)),O=Ao(o);return s.jsx(NC,{scope:n,type:r,dir:O,scrollHideDelay:i,scrollArea:l,viewport:u,onViewportChange:d,content:f,onContentChange:m,scrollbarX:h,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:E,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:C,onScrollbarYEnabledChange:R,onCornerWidthChange:y,onCornerHeightChange:j,children:s.jsx(Ee.div,{dir:O,...a,ref:z,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":_+"px",...e.style}})})});Zp.displayName=yl;var Vp="ScrollAreaViewport",qp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...i}=e,a=yt(Vp,n),l=p.useRef(null),c=De(t,l,a.onViewportChange);return s.jsxs(s.Fragment,{children:[s.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:o}),s.jsx(Ee.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:s.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});qp.displayName=Vp;var Dt="ScrollAreaScrollbar",Kp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=yt(Dt,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"?s.jsx(TC,{...r,ref:t,forceMount:n}):o.type==="scroll"?s.jsx(EC,{...r,ref:t,forceMount:n}):o.type==="auto"?s.jsx(Gp,{...r,ref:t,forceMount:n}):o.type==="always"?s.jsx(wl,{...r,ref:t}):null});Kp.displayName=Dt;var TC=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=yt(Dt,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]),s.jsx(vt,{present:n||i,children:s.jsx(Gp,{"data-state":i?"visible":"hidden",...r,ref:t})})}),EC=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=yt(Dt,e.__scopeScrollArea),i=e.orientation==="horizontal",a=Lo(()=>c("SCROLL_END"),100),[l,c]=CC("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]),s.jsx(vt,{present:n||l!=="hidden",children:s.jsx(wl,{"data-state":l==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:je(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:je(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Gp=p.forwardRef((e,t)=>{const n=yt(Dt,e.__scopeScrollArea),{forceMount:r,...o}=e,[i,a]=p.useState(!1),l=e.orientation==="horizontal",c=Lo(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;a(l?u:d)}},10);return or(n.viewport,c),or(n.content,c),s.jsx(vt,{present:r||i,children:s.jsx(wl,{"data-state":i?"visible":"hidden",...o,ref:t})})}),wl=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=yt(Dt,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=eh(l.viewport,l.content),d={...r,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 OC(m,a.current,l,h)}return n==="horizontal"?s.jsx(AC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const m=o.viewport.scrollLeft,h=Hc(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"?s.jsx(RC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const m=o.viewport.scrollTop,h=Hc(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}),AC=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=yt(Dt,e.__scopeScrollArea),[a,l]=p.useState(),c=p.useRef(null),u=De(t,c,i.onScrollbarXChange);return p.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),s.jsx(Yp,{"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":Mo(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),nh(m,f)&&d.preventDefault()}},onResize:()=>{c.current&&i.viewport&&a&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Ys(a.paddingLeft),paddingEnd:Ys(a.paddingRight)}})}})}),RC=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=yt(Dt,e.__scopeScrollArea),[a,l]=p.useState(),c=p.useRef(null),u=De(t,c,i.onScrollbarYChange);return p.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),s.jsx(Yp,{"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":Mo(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),nh(m,f)&&d.preventDefault()}},onResize:()=>{c.current&&i.viewport&&a&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Ys(a.paddingTop),paddingEnd:Ys(a.paddingBottom)}})}})}),[IC,Jp]=Hp(Dt),Yp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:i,onThumbPointerUp:a,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...m}=e,h=yt(Dt,n),[v,g]=p.useState(null),x=De(t,z=>g(z)),b=p.useRef(null),y=p.useRef(""),_=h.viewport,j=r.content-r.viewport,S=rt(d),E=rt(c),C=Lo(f,10);function R(z){if(b.current){const O=z.clientX-b.current.left,q=z.clientY-b.current.top;u({x:O,y:q})}}return p.useEffect(()=>{const z=O=>{const q=O.target;v?.contains(q)&&S(O,j)};return document.addEventListener("wheel",z,{passive:!1}),()=>document.removeEventListener("wheel",z,{passive:!1})},[_,v,j,S]),p.useEffect(E,[r,E]),or(v,C),or(h.content,C),s.jsx(IC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:rt(i),onThumbPointerUp:rt(a),onThumbPositionChange:E,onThumbPointerDown:rt(l),children:s.jsx(Ee.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:je(e.onPointerDown,z=>{z.button===0&&(z.target.setPointerCapture(z.pointerId),b.current=v.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),R(z))}),onPointerMove:je(e.onPointerMove,R),onPointerUp:je(e.onPointerUp,z=>{const O=z.target;O.hasPointerCapture(z.pointerId)&&O.releasePointerCapture(z.pointerId),document.body.style.webkitUserSelect=y.current,h.viewport&&(h.viewport.style.scrollBehavior=""),b.current=null})})})}),Js="ScrollAreaThumb",Xp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Jp(Js,e.__scopeScrollArea);return s.jsx(vt,{present:n||o.hasThumb,children:s.jsx(zC,{ref:t,...r})})}),zC=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,i=yt(Js,n),a=Jp(Js,n),{onThumbPositionChange:l}=a,c=De(t,f=>a.onThumbChange(f)),u=p.useRef(void 0),d=Lo(()=>{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=MC(f,l);u.current=h,l()}};return l(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[i.viewport,d,l]),s.jsx(Ee.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)",...r},onPointerDownCapture:je(e.onPointerDownCapture,f=>{const h=f.target.getBoundingClientRect(),v=f.clientX-h.left,g=f.clientY-h.top;a.onThumbPointerDown({x:v,y:g})}),onPointerUp:je(e.onPointerUp,a.onThumbPointerUp)})});Xp.displayName=Js;var kl="ScrollAreaCorner",Qp=p.forwardRef((e,t)=>{const n=yt(kl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?s.jsx(PC,{...e,ref:t}):null});Qp.displayName=kl;var PC=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=yt(kl,n),[i,a]=p.useState(0),[l,c]=p.useState(0),u=!!(i&&l);return or(o.scrollbarX,()=>{const d=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(d),c(d)}),or(o.scrollbarY,()=>{const d=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(d),a(d)}),u?s.jsx(Ee.div,{...r,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 Ys(e){return e?parseInt(e,10):0}function eh(e,t){const n=e/t;return isNaN(n)?0:n}function Mo(e){const t=eh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function OC(e,t,n,r="ltr"){const o=Mo(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=r==="ltr"?[0,d]:[d*-1,0];return th([c,u],f)(e)}function Hc(e,t,n="ltr"){const r=Mo(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,a=t.content-t.viewport,l=i-r,c=n==="ltr"?[0,a]:[a*-1,0],u=Xi(e,c);return th([0,a],[0,l])(u)}function th(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function nh(e,t){return e>0&&e<t}var MC=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=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,r=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(r)};function Lo(e,t){const n=rt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function or(e,t){const n=rt(t);Xe(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var LC=Zp,DC=qp,$C=Qp,FC=[" ","Enter","ArrowUp","ArrowDown"],BC=[" ","Enter"],Cn="Select",[Do,$o,UC]=lp(Cn),[pr]=Gt(Cn,[UC,Oo]),Fo=Oo(),[WC,fn]=pr(Cn),[HC,ZC]=pr(Cn),rh=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:i,value:a,defaultValue:l,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:m,required:h,form:v}=e,g=Fo(t),[x,b]=p.useState(null),[y,_]=p.useState(null),[j,S]=p.useState(!1),E=Ao(u),[C,R]=_n({prop:r,defaultProp:o??!1,onChange:i,caller:Cn}),[z,O]=_n({prop:a,defaultProp:l,onChange:c,caller:Cn}),q=p.useRef(null),T=x?v||!!x.closest("form"):!0,[D,k]=p.useState(new Set),$=Array.from(D).map(X=>X.props.value).join(";");return s.jsx(Pp,{...g,children:s.jsxs(WC,{required:h,scope:t,trigger:x,onTriggerChange:b,valueNode:y,onValueNodeChange:_,valueNodeHasChildren:j,onValueNodeHasChildrenChange:S,contentId:zt(),value:z,onValueChange:O,open:C,onOpenChange:R,dir:E,triggerPointerDownPosRef:q,disabled:m,children:[s.jsx(Do.Provider,{scope:t,children:s.jsx(HC,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(X=>{k(B=>new Set(B).add(X))},[]),onNativeOptionRemove:p.useCallback(X=>{k(B=>{const F=new Set(B);return F.delete(X),F})},[]),children:n})}),T?s.jsxs(Sh,{"aria-hidden":!0,required:h,tabIndex:-1,name:d,autoComplete:f,value:z,onChange:X=>O(X.target.value),disabled:m,form:v,children:[z===void 0?s.jsx("option",{value:""}):null,Array.from(D)]},$):null]})})};rh.displayName=Cn;var sh="SelectTrigger",oh=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,i=Fo(n),a=fn(sh,n),l=a.disabled||r,c=De(t,a.onTriggerChange),u=$o(n),d=p.useRef("touch"),[f,m,h]=Nh(g=>{const x=u().filter(_=>!_.disabled),b=x.find(_=>_.value===a.value),y=Th(x,g,b);y!==void 0&&a.onValueChange(y.value)}),v=g=>{l||(a.onOpenChange(!0),h()),g&&(a.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return s.jsx(Op,{asChild:!0,...i,children:s.jsx(Ee.button,{type:"button",role:"combobox","aria-controls":a.contentId,"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":Ch(a.value)?"":void 0,...o,ref:c,onClick:je(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:je(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:je(o.onKeyDown,g=>{const x=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&FC.includes(g.key)&&(v(),g.preventDefault())})})})});oh.displayName=sh;var ih="SelectValue",ah=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:a="",...l}=e,c=fn(ih,n),{onValueNodeHasChildrenChange:u}=c,d=i!==void 0,f=De(t,c.onValueNodeChange);return Xe(()=>{u(d)},[u,d]),s.jsx(Ee.span,{...l,ref:f,style:{pointerEvents:"none"},children:Ch(c.value)?s.jsx(s.Fragment,{children:a}):i})});ah.displayName=ih;var VC="SelectIcon",lh=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return s.jsx(Ee.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});lh.displayName=VC;var qC="SelectPortal",ch=e=>s.jsx(So,{asChild:!0,...e});ch.displayName=qC;var Nn="SelectContent",uh=p.forwardRef((e,t)=>{const n=fn(Nn,e.__scopeSelect),[r,o]=p.useState();if(Xe(()=>{o(new DocumentFragment)},[]),!n.open){const i=r;return i?Br.createPortal(s.jsx(dh,{scope:e.__scopeSelect,children:s.jsx(Do.Slot,{scope:e.__scopeSelect,children:s.jsx("div",{children:e.children})})}),i):null}return s.jsx(fh,{...e,ref:t})});uh.displayName=Nn;var _t=10,[dh,pn]=pr(Nn),KC="SelectContentImpl",GC=rr("SelectContent.RemoveScroll"),fh=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:a,side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:v,hideWhenDetached:g,avoidCollisions:x,...b}=e,y=fn(Nn,n),[_,j]=p.useState(null),[S,E]=p.useState(null),C=De(t,ie=>j(ie)),[R,z]=p.useState(null),[O,q]=p.useState(null),T=$o(n),[D,k]=p.useState(!1),$=p.useRef(!1);p.useEffect(()=>{if(_)return Uf(_)},[_]),zf();const X=p.useCallback(ie=>{const[ge,...he]=T().map(ue=>ue.ref.current),[xe]=he.slice(-1),te=document.activeElement;for(const ue of ie)if(ue===te||(ue?.scrollIntoView({block:"nearest"}),ue===ge&&S&&(S.scrollTop=0),ue===xe&&S&&(S.scrollTop=S.scrollHeight),ue?.focus(),document.activeElement!==te))return},[T,S]),B=p.useCallback(()=>X([R,_]),[X,R,_]);p.useEffect(()=>{D&&B()},[D,B]);const{onOpenChange:F,triggerPointerDownPosRef:Z}=y;p.useEffect(()=>{if(_){let ie={x:0,y:0};const ge=xe=>{ie={x:Math.abs(Math.round(xe.pageX)-(Z.current?.x??0)),y:Math.abs(Math.round(xe.pageY)-(Z.current?.y??0))}},he=xe=>{ie.x<=10&&ie.y<=10?xe.preventDefault():_.contains(xe.target)||F(!1),document.removeEventListener("pointermove",ge),Z.current=null};return Z.current!==null&&(document.addEventListener("pointermove",ge),document.addEventListener("pointerup",he,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ge),document.removeEventListener("pointerup",he,{capture:!0})}}},[_,F,Z]),p.useEffect(()=>{const ie=()=>F(!1);return window.addEventListener("blur",ie),window.addEventListener("resize",ie),()=>{window.removeEventListener("blur",ie),window.removeEventListener("resize",ie)}},[F]);const[J,H]=Nh(ie=>{const ge=T().filter(te=>!te.disabled),he=ge.find(te=>te.ref.current===document.activeElement),xe=Th(ge,ie,he);xe&&setTimeout(()=>xe.ref.current.focus())}),W=p.useCallback((ie,ge,he)=>{const xe=!$.current&&!he;(y.value!==void 0&&y.value===ge||xe)&&(z(ie),xe&&($.current=!0))},[y.value]),ce=p.useCallback(()=>_?.focus(),[_]),se=p.useCallback((ie,ge,he)=>{const xe=!$.current&&!he;(y.value!==void 0&&y.value===ge||xe)&&q(ie)},[y.value]),oe=r==="popper"?Qi:ph,_e=oe===Qi?{side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return s.jsx(dh,{scope:n,content:_,viewport:S,onViewportChange:E,itemRefCallback:W,selectedItem:R,onItemLeave:ce,itemTextRefCallback:se,focusSelectedItem:B,selectedItemText:O,position:r,isPositioned:D,searchRef:J,children:s.jsx(tl,{as:GC,allowPinchZoom:!0,children:s.jsx(el,{asChild:!0,trapped:y.open,onMountAutoFocus:ie=>{ie.preventDefault()},onUnmountAutoFocus:je(o,ie=>{y.trigger?.focus({preventScroll:!0}),ie.preventDefault()}),children:s.jsx(jo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:ie=>ie.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:s.jsx(oe,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:ie=>ie.preventDefault(),...b,..._e,onPlaced:()=>k(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:je(b.onKeyDown,ie=>{const ge=ie.ctrlKey||ie.altKey||ie.metaKey;if(ie.key==="Tab"&&ie.preventDefault(),!ge&&ie.key.length===1&&H(ie.key),["ArrowUp","ArrowDown","Home","End"].includes(ie.key)){let xe=T().filter(te=>!te.disabled).map(te=>te.ref.current);if(["ArrowUp","End"].includes(ie.key)&&(xe=xe.slice().reverse()),["ArrowUp","ArrowDown"].includes(ie.key)){const te=ie.target,ue=xe.indexOf(te);xe=xe.slice(ue+1)}setTimeout(()=>X(xe)),ie.preventDefault()}})})})})})})});fh.displayName=KC;var JC="SelectItemAlignedPosition",ph=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,i=fn(Nn,n),a=pn(Nn,n),[l,c]=p.useState(null),[u,d]=p.useState(null),f=De(t,C=>d(C)),m=$o(n),h=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:b,focusSelectedItem:y}=a,_=p.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&u&&g&&x&&b){const C=i.trigger.getBoundingClientRect(),R=u.getBoundingClientRect(),z=i.valueNode.getBoundingClientRect(),O=b.getBoundingClientRect();if(i.dir!=="rtl"){const te=O.left-R.left,ue=z.left-te,be=C.left-ue,w=C.width+be,Y=Math.max(w,R.width),U=window.innerWidth-_t,I=Xi(ue,[_t,Math.max(_t,U-Y)]);l.style.minWidth=w+"px",l.style.left=I+"px"}else{const te=R.right-O.right,ue=window.innerWidth-z.right-te,be=window.innerWidth-C.right-ue,w=C.width+be,Y=Math.max(w,R.width),U=window.innerWidth-_t,I=Xi(ue,[_t,Math.max(_t,U-Y)]);l.style.minWidth=w+"px",l.style.right=I+"px"}const q=m(),T=window.innerHeight-_t*2,D=g.scrollHeight,k=window.getComputedStyle(u),$=parseInt(k.borderTopWidth,10),X=parseInt(k.paddingTop,10),B=parseInt(k.borderBottomWidth,10),F=parseInt(k.paddingBottom,10),Z=$+X+D+F+B,J=Math.min(x.offsetHeight*5,Z),H=window.getComputedStyle(g),W=parseInt(H.paddingTop,10),ce=parseInt(H.paddingBottom,10),se=C.top+C.height/2-_t,oe=T-se,_e=x.offsetHeight/2,ie=x.offsetTop+_e,ge=$+X+ie,he=Z-ge;if(ge<=se){const te=q.length>0&&x===q[q.length-1].ref.current;l.style.bottom="0px";const ue=u.clientHeight-g.offsetTop-g.offsetHeight,be=Math.max(oe,_e+(te?ce:0)+ue+B),w=ge+be;l.style.height=w+"px"}else{const te=q.length>0&&x===q[0].ref.current;l.style.top="0px";const be=Math.max(se,$+g.offsetTop+(te?W:0)+_e)+he;l.style.height=be+"px",g.scrollTop=ge-se+g.offsetTop}l.style.margin=`${_t}px 0`,l.style.minHeight=J+"px",l.style.maxHeight=T+"px",r?.(),requestAnimationFrame(()=>h.current=!0)}},[m,i.trigger,i.valueNode,l,u,g,x,b,i.dir,r]);Xe(()=>_(),[_]);const[j,S]=p.useState();Xe(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const E=p.useCallback(C=>{C&&v.current===!0&&(_(),y?.(),v.current=!1)},[_,y]);return s.jsx(XC,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:h,onScrollButtonChange:E,children:s.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:j},children:s.jsx(Ee.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});ph.displayName=JC;var YC="SelectPopperPosition",Qi=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=_t,...i}=e,a=Fo(n);return s.jsx(Mp,{...a,...i,ref:t,align:r,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)"}})});Qi.displayName=YC;var[XC,_l]=pr(Nn,{}),ea="SelectViewport",hh=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,i=pn(ea,n),a=_l(ea,n),l=De(t,i.onViewportChange),c=p.useRef(0);return s.jsxs(s.Fragment,{children:[s.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:r}),s.jsx(Do.Slot,{scope:n,children:s.jsx(Ee.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:je(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 v=window.innerHeight-_t*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),b=Math.max(g,x);if(b<v){const y=b+h,_=Math.min(v,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})})})]})});hh.displayName=ea;var mh="SelectGroup",[QC,e5]=pr(mh),t5=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=zt();return s.jsx(QC,{scope:n,id:o,children:s.jsx(Ee.div,{role:"group","aria-labelledby":o,...r,ref:t})})});t5.displayName=mh;var gh="SelectLabel",n5=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=e5(gh,n);return s.jsx(Ee.div,{id:o.id,...r,ref:t})});n5.displayName=gh;var Xs="SelectItem",[r5,xh]=pr(Xs),bh=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...a}=e,l=fn(Xs,n),c=pn(Xs,n),u=l.value===r,[d,f]=p.useState(i??""),[m,h]=p.useState(!1),v=De(t,y=>c.itemRefCallback?.(y,r,o)),g=zt(),x=p.useRef("touch"),b=()=>{o||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return s.jsx(r5,{scope:n,value:r,disabled:o,textId:g,isSelected:u,onItemTextChange:p.useCallback(y=>{f(_=>_||(y?.textContent??"").trim())},[]),children:s.jsx(Do.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:s.jsx(Ee.div,{role:"option","aria-labelledby":g,"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:v,onFocus:je(a.onFocus,()=>h(!0)),onBlur:je(a.onBlur,()=>h(!1)),onClick:je(a.onClick,()=>{x.current!=="mouse"&&b()}),onPointerUp:je(a.onPointerUp,()=>{x.current==="mouse"&&b()}),onPointerDown:je(a.onPointerDown,y=>{x.current=y.pointerType}),onPointerMove:je(a.onPointerMove,y=>{x.current=y.pointerType,o?c.onItemLeave?.():x.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:je(a.onPointerLeave,y=>{y.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:je(a.onKeyDown,y=>{c.searchRef?.current!==""&&y.key===" "||(BC.includes(y.key)&&b(),y.key===" "&&y.preventDefault())})})})})});bh.displayName=Xs;var Cr="SelectItemText",vh=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...i}=e,a=fn(Cr,n),l=pn(Cr,n),c=xh(Cr,n),u=ZC(Cr,n),[d,f]=p.useState(null),m=De(t,b=>f(b),c.onItemTextChange,b=>l.itemTextRefCallback?.(b,c.value,c.disabled)),h=d?.textContent,v=p.useMemo(()=>s.jsx("option",{value:c.value,disabled:c.disabled,children:h},c.value),[c.disabled,c.value,h]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=u;return Xe(()=>(g(v),()=>x(v)),[g,x,v]),s.jsxs(s.Fragment,{children:[s.jsx(Ee.span,{id:c.textId,...i,ref:m}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren?Br.createPortal(i.children,a.valueNode):null]})});vh.displayName=Cr;var yh="SelectItemIndicator",wh=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return xh(yh,n).isSelected?s.jsx(Ee.span,{"aria-hidden":!0,...r,ref:t}):null});wh.displayName=yh;var ta="SelectScrollUpButton",kh=p.forwardRef((e,t)=>{const n=pn(ta,e.__scopeSelect),r=_l(ta,e.__scopeSelect),[o,i]=p.useState(!1),a=De(t,r.onScrollButtonChange);return Xe(()=>{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?s.jsx(jh,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});kh.displayName=ta;var na="SelectScrollDownButton",_h=p.forwardRef((e,t)=>{const n=pn(na,e.__scopeSelect),r=_l(na,e.__scopeSelect),[o,i]=p.useState(!1),a=De(t,r.onScrollButtonChange);return Xe(()=>{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?s.jsx(jh,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});_h.displayName=na;var jh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,i=pn("SelectScrollButton",n),a=p.useRef(null),l=$o(n),c=p.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return p.useEffect(()=>()=>c(),[c]),Xe(()=>{l().find(d=>d.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),s.jsx(Ee.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:je(o.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(r,50))}),onPointerMove:je(o.onPointerMove,()=>{i.onItemLeave?.(),a.current===null&&(a.current=window.setInterval(r,50))}),onPointerLeave:je(o.onPointerLeave,()=>{c()})})}),s5="SelectSeparator",o5=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return s.jsx(Ee.div,{"aria-hidden":!0,...r,ref:t})});o5.displayName=s5;var ra="SelectArrow",i5=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Fo(n),i=fn(ra,n),a=pn(ra,n);return i.open&&a.position==="popper"?s.jsx(Lp,{...o,...r,ref:t}):null});i5.displayName=ra;var a5="SelectBubbleInput",Sh=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),i=De(r,o),a=qj(t);return p.useEffect(()=>{const l=o.current;if(!l)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(a!==t&&d){const f=new Event("change",{bubbles:!0});d.call(l,t),l.dispatchEvent(f)}},[a,t]),s.jsx(Ee.select,{...n,style:{...ip,...n.style},ref:i,defaultValue:t})});Sh.displayName=a5;function Ch(e){return e===""||e===void 0}function Nh(e){const t=rt(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(a=>{const l=n.current+a;t(l),(function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))})(l)},[t]),i=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,i]}function Th(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=l5(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 l5(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var c5=rh,u5=oh,d5=ah,f5=lh,p5=ch,h5=uh,m5=hh,g5=bh,x5=vh,b5=wh,v5=kh,y5=_h,Bo="Tabs",[w5]=Gt(Bo,[$p]),Eh=$p(),[k5,jl]=w5(Bo),Ah=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:a="horizontal",dir:l,activationMode:c="automatic",...u}=e,d=Ao(l),[f,m]=_n({prop:r,onChange:o,defaultProp:i??"",caller:Bo});return s.jsx(k5,{scope:n,baseId:zt(),value:f,onValueChange:m,orientation:a,dir:d,activationMode:c,children:s.jsx(Ee.div,{dir:d,"data-orientation":a,...u,ref:t})})});Ah.displayName=Bo;var Rh="TabsList",Ih=p.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=jl(Rh,n),a=Eh(n);return s.jsx(jC,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(Ee.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});Ih.displayName=Rh;var zh="TabsTrigger",Ph=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,a=jl(zh,n),l=Eh(n),c=Lh(a.baseId,r),u=Dh(a.baseId,r),d=r===a.value;return s.jsx(SC,{asChild:!0,...l,focusable:!o,active:d,children:s.jsx(Ee.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:je(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?a.onValueChange(r):f.preventDefault()}),onKeyDown:je(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&a.onValueChange(r)}),onFocus:je(e.onFocus,()=>{const f=a.activationMode!=="manual";!d&&!o&&f&&a.onValueChange(r)})})})});Ph.displayName=zh;var Oh="TabsContent",Mh=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...a}=e,l=jl(Oh,n),c=Lh(l.baseId,r),u=Dh(l.baseId,r),d=r===l.value,f=p.useRef(d);return p.useEffect(()=>{const m=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(m)},[]),s.jsx(vt,{present:o||d,children:({present:m})=>s.jsx(Ee.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})})});Mh.displayName=Oh;function Lh(e,t){return`${e}-trigger-${t}`}function Dh(e,t){return`${e}-content-${t}`}var _5=Ah,j5=Ih,S5=Ph,C5=Mh,[Uo]=Gt("Tooltip",[Oo]),Wo=Oo(),$h="TooltipProvider",N5=700,sa="tooltip.open",[T5,Sl]=Uo($h),Fh=e=>{const{__scopeTooltip:t,delayDuration:n=N5,skipDelayDuration:r=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)},[]),s.jsx(T5,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(c.current),a.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:p.useCallback(u=>{l.current=u},[]),disableHoverableContent:o,children:i})};Fh.displayName=$h;var Mr="Tooltip",[E5,Jr]=Uo(Mr),Bh=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:l}=e,c=Sl(Mr,e.__scopeTooltip),u=Wo(t),[d,f]=p.useState(null),m=zt(),h=p.useRef(0),v=a??c.disableHoverableContent,g=l??c.delayDuration,x=p.useRef(!1),[b,y]=_n({prop:r,defaultProp:o??!1,onChange:C=>{C?(c.onOpen(),document.dispatchEvent(new CustomEvent(sa))):c.onClose(),i?.(C)},caller:Mr}),_=p.useMemo(()=>b?x.current?"delayed-open":"instant-open":"closed",[b]),j=p.useCallback(()=>{window.clearTimeout(h.current),h.current=0,x.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(()=>{x.current=!0,y(!0),h.current=0},g)},[g,y]);return p.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),s.jsx(Pp,{...u,children:s.jsx(E5,{scope:t,contentId:m,open:b,stateAttribute:_,trigger:d,onTriggerChange:f,onTriggerEnter:p.useCallback(()=>{c.isOpenDelayedRef.current?E():j()},[c.isOpenDelayedRef,E,j]),onTriggerLeave:p.useCallback(()=>{v?S():(window.clearTimeout(h.current),h.current=0)},[S,v]),onOpen:j,onClose:S,disableHoverableContent:v,children:n})})};Bh.displayName=Mr;var oa="TooltipTrigger",Uh=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Jr(oa,n),i=Sl(oa,n),a=Wo(n),l=p.useRef(null),c=De(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]),s.jsx(Op,{asChild:!0,...a,children:s.jsx(Ee.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:je(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:je(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:je(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:je(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:je(e.onBlur,o.onClose),onClick:je(e.onClick,o.onClose)})})});Uh.displayName=oa;var Cl="TooltipPortal",[A5,R5]=Uo(Cl,{forceMount:void 0}),Wh=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=Jr(Cl,t);return s.jsx(A5,{scope:t,forceMount:n,children:s.jsx(vt,{present:n||i.open,children:s.jsx(So,{asChild:!0,container:o,children:r})})})};Wh.displayName=Cl;var ir="TooltipContent",Hh=p.forwardRef((e,t)=>{const n=R5(ir,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=Jr(ir,e.__scopeTooltip);return s.jsx(vt,{present:r||a.open,children:a.disableHoverableContent?s.jsx(Zh,{side:o,...i,ref:t}):s.jsx(I5,{side:o,...i,ref:t})})}),I5=p.forwardRef((e,t)=>{const n=Jr(ir,e.__scopeTooltip),r=Sl(ir,e.__scopeTooltip),o=p.useRef(null),i=De(t,o),[a,l]=p.useState(null),{trigger:c,onClose:u}=n,d=o.current,{onPointerInTransitChange:f}=r,m=p.useCallback(()=>{l(null),f(!1)},[f]),h=p.useCallback((v,g)=>{const x=v.currentTarget,b={x:v.clientX,y:v.clientY},y=M5(b,x.getBoundingClientRect()),_=L5(b,y),j=D5(g.getBoundingClientRect()),S=F5([..._,...j]);l(S),f(!0)},[f]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(c&&d){const v=x=>h(x,d),g=x=>h(x,c);return c.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[c,d,h,m]),p.useEffect(()=>{if(a){const v=g=>{const x=g.target,b={x:g.clientX,y:g.clientY},y=c?.contains(x)||d?.contains(x),_=!$5(b,a);y?m():_&&(m(),u())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[c,d,a,u,m]),s.jsx(Zh,{...e,ref:i})}),[z5,P5]=Uo(Mr,{isInside:!1}),O5=Fk("TooltipContent"),Zh=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...l}=e,c=Jr(ir,n),u=Wo(n),{onClose:d}=c;return p.useEffect(()=>(document.addEventListener(sa,d),()=>document.removeEventListener(sa,d)),[d]),p.useEffect(()=>{if(c.trigger){const f=m=>{m.target?.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),s.jsx(jo,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:s.jsxs(Mp,{"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:[s.jsx(O5,{children:r}),s.jsx(z5,{scope:n,isInside:!0,children:s.jsx(Bj,{id:c.contentId,role:"tooltip",children:o||r})})]})})});Hh.displayName=ir;var Vh="TooltipArrow",qh=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Wo(n);return P5(Vh,n).isInside?null:s.jsx(Lp,{...o,...r,ref:t})});qh.displayName=Vh;function M5(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function L5(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function D5(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function $5(e,t){const{x:n,y:r}=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>r!=m>r&&n<(f-u)*(r-d)/(m-d)+u&&(o=!o)}return o}function F5(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),B5(t)}function B5(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];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 r=e.length-1;r>=0;r--){const o=e[r];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 U5=Fh,W5=Bh,H5=Uh,Z5=Wh,V5=Hh,q5=qh;function Je({delayDuration:e=0,...t}){return s.jsx(U5,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Oe({...e}){return s.jsx(W5,{"data-slot":"tooltip",...e})}function Me({...e}){return s.jsx(H5,{"data-slot":"tooltip-trigger",...e})}function Le({className:e,sideOffset:t=0,children:n,...r}){return s.jsx(Z5,{children:s.jsxs(V5,{"data-slot":"tooltip-content",sideOffset:t,className:le("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),...r,children:[n,s.jsx(q5,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const K5=3;function G5({items:e,ariaLabel:t,className:n}){if(e.length===0)return s.jsx("span",{className:le("flex h-8 w-12 shrink-0 items-center",n),"aria-hidden":"true"});const r=e.slice(0,K5),o=e.length-r.length;return s.jsx(Je,{delayDuration:150,children:s.jsxs("span",{className:le("flex h-8 w-12 shrink-0 items-center",n),"aria-label":t,children:[r.map((i,a)=>s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("span",{className:le("border border-border bg-muted/40 inline-flex size-6 shrink-0 items-center justify-center rounded-md",a>0&&"-ml-2"),children:s.jsx($j,{provider:i.provider,className:"size-4"})})}),s.jsx(Le,{children:i.tooltip})]},`${i.provider}-${String(a)}`)),o>0&&s.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 J5="/v1/chat/completions",Y5="/chat/completions",X5="/v1/responses",Q5="/responses",eN="/v1/messages";class tN{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]??"",r=this.pathMap.get(n);return r===void 0?void 0:this.handlers.get(r)}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 hn=new tN;function nN(e){return hn.getApiFormatByPath(e)??"unknown"}hn.registerPath(eN,"anthropic");hn.registerPath(J5,"openai");hn.registerPath(Y5,"openai");hn.registerPath(X5,"openai");hn.registerPath(Q5,"openai");function rN(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}catch{return{}}}function sN(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:rN(e.inputJson)}}}function Kh(e,t,n,r){const o=new Map;let i="",a="",l=null,c=null,u=0,d=0;const f=1e3;let m=0,h=0;const v=[];for(const x of e.split(`
86
+ `)){const b=x.trim();if(b.startsWith("data: "))try{const y=JSON.parse(b.slice(6)),_=x1.safeParse(y);if(!_.success)continue;const j=_.data;switch(m===0&&(h=Date.now()),r===!0&&v.length<f&&v.push({index:m,timestamp:Date.now()-h,type:j.type,data: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{}}r===!0&&(t.streamingChunks={chunks:v,truncated:m>f});const g=[...o.entries()].sort(([x],[b])=>x-b).map(([,x])=>sN(x));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 oN={format:"anthropic",parseRequest(e,t){try{const n=JSON.parse(e),r=Dd.safeParse(n);return r.success?{model:r.data.model,sessionId:r.data.metadata?.user_id??t?.get("x-session-affinity")??null}:null}catch{return null}},extractTokens(e){try{const t=JSON.parse(e),n=$d.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,r){return Kh(e,t,n,r)},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}}};hn.register(oN);class iN{providers=[];register(t){this.providers.push(t)}findProvider(t){let n=null;for(const r of this.providers)if(r.matches(t)){if(r.name!=="anthropic")return r;n=r}return n}getAll(){return[...this.providers]}}const Ho=new iN,aN="https://api.anthropic.com",lN={MiniMax:"https://api.minimaxi.com/anthropic"},cN={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(lN))if(t.startsWith(n.toLowerCase()))return!0;return!0},getUpstreamBase(e,t){return t?.baseUrl!==void 0?t.baseUrl:aN},extractStream(e,t,n,r){return Kh(e,t,n,r)}};Ho.register(cN);const Nl=1e3;function Yr(e,t){if(!(e===null||typeof e!="object"||Array.isArray(e)))return Object.getOwnPropertyDescriptor(e,t)?.value}function tt(e,t){const n=Yr(e,t);return typeof n=="string"?n:null}function Gh(e,t){const n=Yr(e,t);return typeof n=="number"&&Number.isFinite(n)?n:null}function Qs(e,t){const n=Yr(e,t);return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:null}function uN(e,t){const n=Yr(e,t);return Array.isArray(n)?n:[]}function dN(e){const t=[];let n=null,r=[];const o=()=>{n===null&&r.length===0||(t.push({event:n,data:r.join(`
87
87
  `)}),n=null,r=[])};for(const i of e.split(`
88
- `)){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&&r.length>0&&(d.startsWith("{")||d==="[DONE]")&&o(),r.push(d);break}}return o(),t}function Cl(e){try{return JSON.parse(e)}catch{return null}}function Kh(e,t){if(e.event!==null&&e.event!=="")return e.event;const n=j1.safeParse(t);return n.success?n.data.type:""}function cN(e){if(e.data==="[DONE]")return!1;const t=Cl(e.data),n=Kh(e,t);return n.startsWith("response.")||n==="error"}function Gh(e,t,n,r,o){e.length>=Sl||e.push({index:t,timestamp:Date.now()-n,type:r,data:o})}function sa(e,t){const n=Xs(t,"error"),r=tt(n,"message")??tt(t,"message")??tt(t,"error");r!==null&&r.length>0&&(e.error=r)}function uN(e,t,n,r){let o="",i="",a="",l="",c=null,u=0,d=0,f=!1,m=!1;const h=new Map;let v=0,g=0;const x=[];for(const y of e){if(y.data==="[DONE]")break;const _=Cl(y.data);if(_===null)continue;sa(t,_);const j=w1.safeParse(_);if(!j.success)continue;const S=j.data;if(v===0&&(g=Date.now()),r&&Gh(x,v,g,"chat.completion.chunk",S),v++,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=Xs(_,"usage"),C=Xs(E,"prompt_tokens_details"),R=qh(C,"cached_tokens");R!==null&&(t.cacheReadInputTokens=R),f=!0}for(const E of S.choices){const C=E.delta;C.content!==void 0&&C.content!==null&&(a+=C.content),C.reasoning_content!==void 0&&C.reasoning_content!==null&&(l+=C.reasoning_content),C.thinking!==void 0&&C.thinking!==null&&(l+=C.thinking);const R=C.think;if(R!=null&&(l+=R),E.finish_reason!==void 0&&E.finish_reason!==null&&(c=E.finish_reason),C.tool_calls!==void 0&&C.tool_calls!==null)for(const z of C.tool_calls){let O=h.get(z.index);O===void 0&&(O={index:z.index,type:"function",function:{name:"",arguments:""}},h.set(z.index,O)),z.id!==void 0&&(O.id=z.id),z.function?.name!==void 0&&(O.function.name+=z.function.name),z.function?.arguments!==void 0&&(O.function.arguments+=z.function.arguments)}}}r&&(t.streamingChunks={chunks:x,truncated:v>Sl}),f||(d=Math.ceil(a.length/4)),t.outputTokens=d;const b={role:"assistant",content:a};return l.length>0&&(b.reasoning_content=l),h.size>0&&(b.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:b,finish_reason:c}],usage:{prompt_tokens:u,completion_tokens:d,total_tokens:u+d}})}function dN(e){const t=Ls.safeParse(Jr(e,"response"));if(t.success)return t.data;const n=Ls.safeParse(e);return n.success?n.data:null}function Jh(e){if(e.output_text!==void 0&&e.output_text.length>0)return e.output_text;const t=[];for(const n of e.output??[]){const r=aN(n,"content");for(const o of r){const i=tt(o,"type"),a=tt(o,"text");(i==="output_text"||i==="text")&&a!==null&&a.length>0&&t.push(a)}}return t.join(`
89
- `)}function Wc(e,t){const n=e.usage,r=n?.input_tokens??null,o=n?.output_tokens??null;r!==null&&(t.inputTokens=r),o!==null&&(t.outputTokens=o);const i=n?.input_tokens_details?.cached_tokens??null;return i!==null&&(t.cacheReadInputTokens=i),{inputTokens:r,outputTokens:o}}function di(e,t){const n=tt(e,"item_id");if(n!==null&&n.length>0)return n;const r=qh(e,"output_index");return r!==null?String(r):`function-${String(t)}`}function oa(e,t){const n=e.get(t);if(n!==void 0)return n;const r={type:"function_call",arguments:""};return e.set(t,r),r}function fN(e,t,n){if(tt(n,"type")!=="function_call")return;const r=oa(e,t),o=tt(n,"id"),i=tt(n,"call_id"),a=tt(n,"name"),l=tt(n,"arguments"),c=tt(n,"status");o!==null&&(r.id=o),i!==null&&(r.call_id=i),a!==null&&(r.name=a),l!==null&&(r.arguments=l),c!==null&&(r.status=c)}function pN(e,t){const n=[];e.length>0&&n.push({type:"message",role:"assistant",content:[{type:"output_text",text:e,annotations:[]}]});for(const r of t.values())n.push(r);return n}function hN(e,t,n){const r=t??Math.ceil(n.length/4);return{input_tokens:e,output_tokens:r,total_tokens:e===null?r:e+r}}function mN(e){const t=e.completedResponse===null?"":Jh(e.completedResponse),n=t.length>0?t:e.outputText,r=e.completedResponse?.output,o=r!==void 0&&r.length>0?r:pN(n,e.calls),i=e.completedResponse?.usage??hN(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 gN(e,t,n,r){let o=null,i="",a=n??"",l=null,c="",u=null,d=null,f=0,m=0;const h=[],v=new Map;for(const b of e){if(b.data==="[DONE]")break;const y=Cl(b.data);if(y===null)continue;const _=Kh(b,y);if(f===0&&(m=Date.now()),r&&Gh(h,f,m,_===""?"response.event":_,y),f++,sa(t,y),_==="error")continue;const j=dN(y);if(j!==null){o=j,i=j.id,a=j.model??a,l=j.status??l;const E=Wc(j,t);u=E.inputTokens??u,d=E.outputTokens??d,sa(t,j)}const S=tt(y,"delta");switch(_){case"response.output_text.delta":S!==null&&(c+=S);break;case"response.output_text.done":{const E=tt(y,"text");c.length===0&&E!==null&&(c=E);break}case"response.function_call_arguments.delta":{if(S!==null){const E=oa(v,di(y,v.size));E.arguments+=S}break}case"response.function_call_arguments.done":{const E=tt(y,"arguments");if(E!==null){const C=oa(v,di(y,v.size));C.arguments=E}break}case"response.output_item.added":case"response.output_item.done":{const E=Xs(y,"item");fN(v,di(y,v.size),E);break}case"response.failed":case"response.incomplete":l=_.slice(9);break;case"response.completed":l="completed";break}}r&&(t.streamingChunks={chunks:h,truncated:f>Sl});const g=mN({completedResponse:o,responseId:i,model:a,status:l,outputText:c,calls:v,inputTokens:u,outputTokens:d}),x=Ls.safeParse(g);if(x.success){if(Wc(x.data,t).outputTokens===null){const y=Jh(x.data),_=Math.ceil(y.length/4);t.outputTokens=_}return JSON.stringify(x.data)}if(t.outputTokens===null){const b=tt(g,"output_text")??c,y=Math.ceil(b.length/4);t.outputTokens=y}return JSON.stringify(g)}function Ho(e,t,n,r=!0){const o=lN(e);return o.some(cN)?gN(o,t,n,r):uN(o,t,n,r)}function xN(){return{inputTokens:null,outputTokens:null,cacheCreationInputTokens:null,cacheReadInputTokens:null}}const bN={format:"openai",parseRequest(e,t){try{const n=JSON.parse(e),r=Fd.safeParse(n);if(r.success)return{model:r.data.model,sessionId:t?.get("x-session-affinity")??null};const o=Bd.safeParse(n);return o.success?{model:o.data.model,sessionId:t?.get("x-session-affinity")??null}:null}catch{return null}},extractTokens(e){const t=Wd(e);if(t){let r=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"&&(r=l.value)}}}}catch{}return{inputTokens:t.usage.prompt_tokens??null,outputTokens:t.usage.completion_tokens??null,cacheCreationInputTokens:null,cacheReadInputTokens:r}}const n=Hd(e);if(n!==null){const r=n.usage;return{inputTokens:r?.input_tokens??null,outputTokens:r?.output_tokens??null,cacheCreationInputTokens:null,cacheReadInputTokens:r?.input_tokens_details?.cached_tokens??null}}return xN()},extractStream(e,t,n,r){return Ho(e,t,n,r)},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}}};hn.register(bN);const vN="https://api.openai.com/v1",yN={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:vN},extractStream(e,t,n,r){return Ho(e,t,n,r)}};Wo.register(yN);const wN="https://open.bigmodel.cn/api/paas/v4",kN=["glm-","charglm-","cogview-","embedding-","rerank-"],_N={name:"zhipu",matches(e){const t=e.toLowerCase().replace(/\s+/g,"-");return kN.some(n=>t.startsWith(n))},getUpstreamBase(e,t){return t?.baseUrl??wN},extractStream(e,t,n,r){return Ho(e,t,n,r)}};Wo.register(_N);const jN="https://dashscope.aliyuncs.com/compatible-mode/v1",SN={name:"alibaba",matches(e){return!!e.toLowerCase().replace(/\s+/g,"-").startsWith("qwen")},getUpstreamBase(e,t){return jN},extractStream(e,t,n){return Ho(e,t,n)}};Wo.register(SN);function Yh(e,t){for(const n of Array.from(e))t(n)}const CN=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function Nl(e){if(e.length===0)return 0;let t=0,n=0;return Yh(e,r=>{CN.test(r)?t+=1:n+=1}),Math.ceil(t*1)+Math.ceil(n/4)}function Tl(e){if(e.length===0)return 0;let t=0;return Yh(e,()=>{t+=1}),t}function wn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const Yn={parsed:null,toolNames:null};function NN(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 r=n;switch(r.type){case"text":typeof r.text=="string"&&t.push(r.text);break;case"thinking":case"think":typeof r.thinking=="string"&&t.push(r.thinking);break;case"tool_use":{const i=typeof r.name=="string"?r.name:"",a=r.input!==void 0?JSON.stringify(r.input):"";t.push(`${i} ${a}`.trim());break}case"tool_result":{const i=r.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(`
90
- `)}function TN(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 r=n.text;n.type==="text"&&typeof r=="string"&&t.push(r)}return t.join(`
91
- `)}function EN(e){if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const r=n;typeof r.name=="string"&&t.push(r.name),typeof r.description=="string"&&t.push(r.description),r.input_schema!==void 0&&t.push(JSON.stringify(r.input_schema))}return t.join(`
92
- `)}function fi(e,t,n,r){return{role:e,label:t,text:n,size:Nl(n),characters:Tl(n),path:r}}const AN={format:"anthropic",analyzeRequest(e){if(e===null)return wn(e);try{const t=Md.safeParse(JSON.parse(e));return t.success?{parsed:t.data,comparisonValue:t.data,messageCount:t.data.messages.length,toolCount:t.data.tools!==void 0&&t.data.tools.length>0?t.data.tools.length:null}:wn(e)}catch{return wn(e)}},analyzeResponse(e){if(e===null)return Yn;try{let t=JSON.parse(e);typeof t=="string"&&(t=JSON.parse(t));const n=Ld.safeParse(t);if(!n.success)return Yn;const r=n.data.content.filter(o=>o.type==="tool_use").map(o=>o.name);return{parsed:n.data,toolNames:r.length>0?r:null}}catch{return Yn}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,n=[];if(t.system!==void 0){const r=TN(t.system);r.length>0&&n.push(fi("system","system",r,"/system"))}if(Array.isArray(t.messages)&&t.messages.forEach((r,o)=>{if(r===null||typeof r!="object")return;const i=r,a=i.role==="user"||i.role==="assistant"?i.role:"user",l=NN(i.content);n.push(fi(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.tools)&&t.tools.length>0){const r=EN(t.tools);n.push(fi("tools","tools",r,"/tools"))}return n.length>0?n:null}};function El(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}function ia(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 r=n,o=r.type;(o==="text"||o==="input_text"||o==="output_text")&&typeof r.text=="string"?t.push(r.text):(o==="image_url"||o==="input_image")&&t.push("[image]")}return t.join(`
93
- `)}function RN(e){const t=[],n=ia(e.content);n.length>0&&t.push(n);const r=typeof e.reasoning_content=="string"?e.reasoning_content:typeof e.thinking=="string"?e.thinking:typeof e.think=="string"?e.think:"";r.length>0&&t.push(r);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(`
94
- `)}function IN(e){if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const r=ke(n,"function"),o=ke(r,"name")??ke(n,"name"),i=ke(r,"description")??ke(n,"description"),a=ke(r,"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(`
95
- `)}function zN(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function PN(e){if(typeof e=="string")return e;const t=ke(e,"text");if(typeof t=="string")return t;const n=ia(ke(e,"content"));if(n.length>0)return n;const r=ia(ke(e,"output"));if(r.length>0)return r;const o=ke(e,"arguments");return typeof o=="string"?o:""}function ON(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 MN(e){const t=ke(e,"output");if(!Array.isArray(t))return[];const n=[];for(const r of t){if(ke(r,"type")!=="function_call")continue;const o=ke(r,"name");typeof o=="string"&&o.length>0&&n.push(o)}return n}function xr(e,t,n,r){return{role:e,label:t,text:n,size:Nl(n),characters:Tl(n),path:r}}const LN={format:"openai",analyzeRequest(e){if(e===null)return wn(e);try{const t=Fd.safeParse(JSON.parse(e));if(!t.success){const n=Bd.safeParse(JSON.parse(e));return n.success?{parsed:n.data,comparisonValue:n.data,messageCount:zN(n.data.input),toolCount:n.data.tools!==void 0&&n.data.tools.length>0?n.data.tools.length:null}:wn(e)}return{parsed:t.data,comparisonValue:t.data,messageCount:t.data.messages.length,toolCount:t.data.tools!==void 0&&t.data.tools.length>0?t.data.tools.length:null}}catch{return wn(e)}},analyzeResponse(e){if(e===null)return Yn;const t=Wd(e);if(t===null){const r=Hd(e);if(r===null)return Yn;const o=MN(r);return{parsed:r,toolNames:o.length>0?o:null}}const n=t.choices[0]?.message?.tool_calls?.map(r=>r.function?.name??"").filter(r=>r!=="")??[];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(xr("system","instructions",t.instructions,"/instructions")),Array.isArray(t.messages)&&t.messages.forEach((r,o)=>{if(r===null||typeof r!="object")return;const i=r,a=i.role==="user"||i.role==="assistant"||i.role==="system"||i.role==="tool"?i.role:"user",l=RN(i);n.push(xr(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.messages)||(typeof t.input=="string"&&t.input.length>0?n.push(xr("user","input",t.input,"/input")):Array.isArray(t.input)&&t.input.forEach((r,o)=>{const i=ON(r),a=PN(r);n.push(xr(i,`[${o}] ${i}`,a,`/input/${o}`))})),Array.isArray(t.tools)&&t.tools.length>0){const r=IN(t.tools);n.push(xr("tools","tools",r,"/tools"))}return n.length>0?n:null}},DN={format:"unknown",analyzeRequest(e){return wn(e)},analyzeResponse(){return Yn},anatomySegments(){return null}},$N={anthropic:AN,openai:LN,unknown:DN};function Xh(e){return $N[e]}function Lr(e){const t=Q5(e.path);return t==="unknown"?e.apiFormat:t}const Hc="border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground";function pi({icon:e,children:t,title:n,className:r}){return s.jsxs("span",{className:ae("border border-border bg-muted/30 inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground",r),title:n,children:[e,s.jsx("span",{className:"min-w-0 font-mono tabular-nums",children:t})]})}function FN({conversationId:e,startTime:t,endTime:n,totalCalls:r,totalInputTokens:o,totalOutputTokens:i,expanded:a,onToggle:l,providers:c,isLoading:u=!1,userAgent:d,clientPid:f,clientProjectFolder:m,showClientIdentity:h=!0,showProcessMetadata:v=!0,timeDisplayFormat:g,onClear:x}){const[b,y]=p.useState(!1),_=$=>{$.stopPropagation(),x!==void 0&&y(!0)},j=p.useCallback($=>{$.stopPropagation(),window.open(Qu(e),"_blank","noopener,noreferrer")},[e]),S=c?.map(({provider:$,models:X})=>({provider:$,tooltip:X.length===1?X[0]??$:X.join(", ")}))??[],E=ol({userAgent:d,conversationId:e,clientProjectFolder:m}),C=No(E),R=d!=null&&d!=="",z=C??d??null,O=C!==null&&R?`${C} - ${d}`:null,q=e.startsWith("PID:")||e.includes("|"),T=e.length>24?e.slice(0,12)+"..."+e.slice(-12):e,D=Ga(t,n,g),k=`${r} call${r!==1?"s":""}`;return s.jsxs("div",{role:"button",tabIndex:0,"data-nav-id":`conv-${e}`,"data-nav-action":a?"collapse":"expand",className:ae("border border-border bg-card shadow-sm flex cursor-pointer items-start gap-3 rounded-[8px] px-3 py-2.5 transition-colors","hover:border-cyan-200/20","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:[s.jsx(V5,{items:S,ariaLabel:"Models used in this session",className:"mt-0.5"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[q&&v?f!=null?s.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]}):s.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-violet-200",title:e,children:e}):s.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-violet-200",title:e,children:q?"sessionless":T}),!q&&v&&f!==null&&f!==void 0&&s.jsxs("span",{className:"border border-border bg-muted/40 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]}),q&&v&&m!==null&&m!==void 0&&m!==""&&s.jsx("span",{className:"min-w-0 max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:m,children:m}),h&&z!==null&&z!==""&&s.jsxs("span",{className:"border border-border bg-muted/30 inline-flex h-6 max-w-[180px] shrink-0 items-center gap-1 rounded-md px-1.5 text-xs text-muted-foreground",title:O??z,children:[s.jsx(il,{client:E,className:"size-4 shrink-0"}),s.jsx("span",{className:"truncate font-mono tabular-nums",children:z})]})]}),s.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx(pi,{icon:s.jsx(Ht,{className:"size-3 shrink-0"}),title:D,children:D}),s.jsx(pi,{icon:s.jsx(wo,{className:"size-3 shrink-0"}),children:k}),s.jsxs(pi,{icon:s.jsx(Pr,{className:"size-3 shrink-0"}),className:"max-w-full",children:[s.jsx("span",{className:"text-blue-400",children:$e(o)})," / ",s.jsx("span",{className:"text-amber-400",children:$e(i)})]})]})]}),s.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[s.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:Hc,children:s.jsx(Ha,{className:"size-3.5"})}),x!==void 0&&s.jsx("button",{type:"button",onClick:_,"aria-label":`Clear group (${r} request${r!==1?"s":""})`,title:"Clear this group",className:Hc,children:s.jsx(nr,{className:"size-3.5"})}),s.jsx("span",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex size-8 shrink-0 items-center justify-center rounded-md text-slate-200","aria-hidden":"true",children:a?s.jsx(st,{className:"size-4 shrink-0"}):u?s.jsx(ft,{className:"size-4 shrink-0 animate-spin"}):s.jsx(bt,{className:"size-4 shrink-0"})})]}),s.jsx(rp,{open:b,onOpenChange:y,title:"Clear this group?",description:`This will remove ${r} request${r!==1?"s":""} from this conversation. This action cannot be undone.`,confirmLabel:"Clear",variant:"destructive",onConfirm:()=>{x?.()}})]})}function BN(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 r=t?`PID:${e.clientPid}`:"unknown",o=n?e.clientProjectFolder:"no-folder";return`${r}|${o}`}function UN(e){const t=new Map;for(const r of e){const o=BN(r),i=t.get(o);i!==void 0?i.push(r):t.set(o,[r])}const n=[];for(const[r,o]of t){const i=[...o].sort((a,l)=>a.timestamp.localeCompare(l.timestamp));n.push({id:r,conversationId:r,logs:i})}return n.sort((r,o)=>(r.logs[0]?.timestamp??"").localeCompare(o.logs[0]?.timestamp??"")),n}function WN(e,t,n){const r=new Array(e);return new Proxy(r,{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 Dn(e,t,n){let r=n.initialDeps??[],o,i=!0;function a(){const l=e();return(l.length!==r.length||l.some((u,d)=>r[d]!==u))&&(r=l,o=t(...l),n?.onChange&&!(i&&n.skipInitialOnChange)&&n.onChange(o),i=!1),o}return a.updateDeps=l=>{r=l},a}function Zc(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const Vc=(e,t)=>Math.abs(e-t)<1.01,HN=(e,t,n)=>{let r;return function(...o){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,o),n)}};let br;const qc=()=>{if(br!==void 0)return br;if(typeof navigator>"u")return br=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return br=!0;const e=navigator.maxTouchPoints;return br=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Kc=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},ZN=e=>e,VN=e=>{const t=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,o=new Array(r);for(let i=0;i<r;i++)o[i]=t+i;return o},qN=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const o=a=>{const{width:l,height:c}=a;t({width:Math.round(l),height:Math.round(c)})};if(o(Kc(n)),!r.ResizeObserver)return()=>{};const i=new r.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(Kc(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},Dr={passive:!0},KN=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=()=>{t({width:n.innerWidth,height:n.innerHeight})};return r(),n.addEventListener("resize",r,Dr),()=>{n.removeEventListener("resize",r)}},GN=typeof window>"u"?!0:"onscrollend"in window,Qh=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&GN;let a=0;const l=i?null:HN(o,()=>t(a,!1),e.options.isScrollingResetDelay),c=f=>()=>{a=n(r),l?.(),t(a,f)},u=c(!0),d=c(!1);return r.addEventListener("scroll",u,Dr),i&&r.addEventListener("scrollend",d,Dr),()=>{r.removeEventListener("scroll",u),i&&r.removeEventListener("scrollend",d)}},JN=(e,t)=>Qh(e,t,n=>{const{horizontal:r,isRtl:o}=e.options;return r?n.scrollLeft*(o&&-1||1):n.scrollTop}),YN=(e,t)=>Qh(e,t,n=>e.options.horizontal?n.scrollX:n.scrollY),XN=(e,t,n)=>{if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},em=(e,{adjustments:t=0,behavior:n},r)=>{var o,i;(i=(o=r.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})},QN=em,e3=em;class t3{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,r,o;return((o=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:o.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>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=r())==null||o.disconnect(),n=null},observe:o=>{var i;return(i=r())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=r())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=n=>{var r,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ZN,rangeExtractor:VN,onChange:()=>{},measureElement:XN,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"};for(const u in n){const d=n[u];d!==void 0&&(i[u]=d)}const a=this.options;let l=null,c=null;if(a!==void 0&&a.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const u=a.count,d=i.count,f=this.getMeasurements(),m=u>0?((r=f[0])==null?void 0:r.key)??a.getItemKey(0):null,h=u>0?((o=f[u-1])==null?void 0:o.key)??a.getItemKey(u-1):null;if(d!==u||u>0&&d>0&&(i.getItemKey(0)!==m||i.getItemKey(d-1)!==h)){const x=u>0?this.getVirtualItemForOffset(this.getScrollOffset())??f[0]:null;x&&(l=[x.key,this.getScrollOffset()-x.start]);const b=i.followOnAppend===!0?"auto":i.followOnAppend||null;b&&d>u&&this.isAtEnd(a.scrollEndThreshold)&&(u===0||i.getItemKey(d-1)!==h)&&(c=b)}}this.options=i,(l||c)&&(this.pendingScrollAnchor=[l?.[0]??null,l?.[1]??0,c])},this.notify=n=>{var r,o;(o=(r=this.options).onChange)==null||o.call(r,this,n)},this.maybeNotify=Dn(()=>(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 r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,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)=>{this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=a?this.getScrollOffset()<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,!(!qc()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",a,Dr),i.addEventListener("touchend",l,Dr),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]=o;if(i!==null){const{count:c,getItemKey:u}=this.options;let d=0;for(;d<c&&u(d)!==i;)d++;const f=d<c?this.getMeasurements()[d]:void 0;if(f){const m=f.start+a-this.getScrollOffset();Vc(m,0)||this.applyScrollAdjustment(m)}}l&&this.scrollToEnd({behavior:l})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),r=this.getMaxScrollOffset();if(n<0||n>r)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,r)=>{const o=new Map,i=new Map;for(let a=r-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=Dn(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(n,r,o,i,a,l,c)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMin=null,{count:n,paddingStart:r,scrollMargin:o,getItemKey:i,enabled:a,lanes:l,laneAssignmentMode:c}),{key:!1}),this.getMeasurements=Dn(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:r,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 v of this.laneAssignments.keys())v>=n&&this.laneAssignments.delete(v);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(v=>{this.itemSizeCache.set(v.key,v.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 v=this.options.gap,g=n*2;let x=this._flatMeasurements;if(!x||x.length<g){const _=new Float64Array(g);x&&f>0&&_.set(x.subarray(0,f*2)),x=_,this._flatMeasurements=x}let b;if(f===0)b=r+o;else{const _=f-1;b=x[_*2]+x[_*2+1]+v}for(let _=f;_<n;_++){const j=i(_),S=d.get(j),E=typeof S=="number"?S:this.options.estimateSize(_);x[_*2]=b,x[_*2+1]=E,b+=E+v}const y=WN(n,x,i);return this.measurementsCache=y,y}const m=this.measurementsCache.slice(0,f),h=new Array(l).fill(void 0);for(let v=0;v<f;v++){const g=m[v];g&&(h[g.lane]=v)}for(let v=f;v<n;v++){const g=i(v),x=this.laneAssignments.get(v);let b,y;const _=c==="estimate"||d.has(g);if(x!==void 0&&this.options.lanes>1){b=x;const C=h[b],R=C!==void 0?m[C]:void 0;y=R?R.end+this.options.gap:r+o}else{const C=this.options.lanes===1?m[v-1]:this.getFurthestMeasurement(m,v);y=C?C.end+this.options.gap:r+o,b=C?C.lane:v%this.options.lanes,this.options.lanes>1&&_&&this.laneAssignments.set(v,b)}const j=d.get(g),S=typeof j=="number"?j:this.options.estimateSize(v),E=y+S;m[v]={index:v,start:y,size:S,end:E,key:g,lane:b},h[b]=v}return this.measurementsCache=m,m},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Dn(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,o,i)=>this.range=n.length>0&&r>0?n3({measurements:n,outerSize:r,scrollOffset:o,lanes:i,flat:i===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Dn(()=>{let n=null,r=null;const o=this.calculateRange();return o&&(n=o.startIndex,r=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,o,i,a)=>i===null||a===null?[]:n({startIndex:i,endIndex:a,overscan:r,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,o=n.getAttribute(r);return o?parseInt(o,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.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 r=this.indexFromElement(n),o=this.options.getItemKey(r),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(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{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=r-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,v=((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.scrollDirection!=="backward");(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(c,r),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-h):v&&this.applyScrollAdjustment(f),this.notify(!1)}},this.getVirtualItems=Dn(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const o=[];for(let i=0,a=n.length;i<a;i++){const l=n[i],c=r[l];o.push(c)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,a=tm(0,r.length-1,i?l=>o[l*2]:l=>Zc(r[l]).start,n);return Zc(r[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,r,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),a=this.getScrollOffset();r==="auto"&&(r=n>=a+i?"end":"start"),r==="center"?n+=(o-i)/2:r==="end"&&(n-=i);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,r="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(r==="auto")if(a.end>=i+o-this.options.scrollPaddingEnd)r="end";else if(a.start<=i+this.options.scrollPaddingStart)r="start";else return[i,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const l=r==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,r,a.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(n,r),a=this.now();this.scrollState={index:null,align:r,behavior:o,startedAt:a,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:o="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getOffsetForIndex(n,r);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:r="auto"}={})=>{const o=this.getScrollOffset()+n,i=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),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 r=this.getMeasurements();let o;if(r.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=r.length-1,a=this._flatMeasurements;a!=null?o=a[i*2]+a[i*2+1]:o=((n=r[i])==null?void 0:n.end)??0}else{const i=Array(this.options.lanes).fill(null);let a=r.length-1;for(;a>=0&&i.some(l=>l===null);){const l=r[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 r=this.getMeasurements();for(const o of r)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:r,behavior:o})=>{this._intendedScrollOffset=n+(r??0),this.options.scrollToFn(n,{behavior:o,adjustments:r},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&&(qc()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}))}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 r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=r?r[0]:this.scrollState.lastTargetOffset,i=1,a=o!==this.scrollState.lastTargetOffset;if(!a&&Vc(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 tm=(e,t,n,r)=>{for(;e<=t;){const o=(e+t)/2|0,i=n(o);if(i<r)e=o+1;else if(i>r)t=o-1;else return o}return e>0?e-1:0};function n3({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:o}){const i=e.length-1,a=o?d=>o[d*2]:d=>e[d].start,l=o?d=>o[d*2]+o[d*2+1]:d=>e[d].end;if(e.length<=r)return{startIndex:0,endIndex:i};let c=tm(0,i,a,n),u=c;if(r===1)for(;u<i&&l(u)<n+t;)u++;else if(r>1){const d=Array(r).fill(0);for(;u<i&&d.some(m=>m<n+t);){const m=e[u];d[m.lane]=m.end,u++}const f=Array(r).fill(n+t);for(;c>=0&&f.some(m=>m>=n);){const m=e[c];f[m.lane]=m.start,c--}c=Math.max(0,c-c%r),u=Math.min(i,u+(r-1-u%r))}return{startIndex:c,endIndex:u}}const Gc=typeof document<"u"?p.useLayoutEffect:p.useEffect;function nm({useFlushSync:e=!0,...t}){const n=p.useReducer(i=>i+1,0)[1],r={...t,onChange:(i,a)=>{var l;e&&a?Fr.flushSync(n):n(),(l=t.onChange)==null||l.call(t,i,a)}},[o]=p.useState(()=>new t3(r));return o.setOptions(r),Gc(()=>o._didMount(),[]),Gc(()=>o._willUpdate()),o}function r3(e){return nm({observeElementRect:qN,observeElementOffset:JN,scrollToFn:e3,...e})}function s3(e){return nm({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:KN,observeElementOffset:YN,scrollToFn:QN,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const qt="agent-inspector:focus-log";function Qs(e){window.dispatchEvent(new CustomEvent(qt,{detail:e}))}function Zo(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 r=ke(t,"tab");switch(r){case"anatomy":case"request":break;case void 0:break;default:return null}const o=ke(t,"source");switch(o){case"virtualizer":return{logId:n,tab:r??"request",source:o};case void 0:return{logId:n,tab:r??"request"};default:return null}}const o3="x-anthropic-billing-header:";function i3(e){return e.trimStart().toLowerCase().startsWith(o3)}function a3(e){return El(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function l3(e){if(!El(e))return!1;const t=ke(e,"type"),n=ke(e,"text");return typeof t!="string"||t!=="text"||typeof n!="string"?!1:i3(n)}function c3(e){let t;try{t=JSON.parse(e)}catch{return{body:e,removed:0}}if(!a3(t))return{body:e,removed:0};const n=t.system;if(!Array.isArray(n)||n.length===0)return{body:e,removed:0};const r=[];let o=0;for(const i of n){if(l3(i)){o+=1;continue}r.push(i)}return o===0?{body:e,removed:0}:(r.length===0?delete t.system:t.system=r,{body:JSON.stringify(t),removed:o})}const u3=400,Jc=2e3;function d3(e){return Array.isArray(e)}function f3(e,t){const n=[e];let r=0;for(;n.length>0;){const o=n.pop();if(o!==void 0){if(r+=1,r>t)return r;if(!(o===null||typeof o!="object")){if(d3(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 r}function p3(e){const t=f3(e,Jc+1);return t<=u3?{depth:Number.POSITIVE_INFINITY}:t<=Jc?{depth:3}:{depth:2}}function h3(e){try{const t=JSON.parse(e);return{kind:"json",data:eo(t)}}catch{return{kind:"text"}}}function hi(e){const t=p.useMemo(()=>e===null?null:h3(e),[e]),n=t?.kind==="json"?t.data:null,r=p.useMemo(()=>n===null?null:p3(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,v=h&&r!==null?r.depth:0;f(()=>{i(h),l(v),u(g=>g+1)})},[o,r]);return{parsedData:n,policy:r,isExpanded:o,toggle:m,isPending:d,bulkDepth:a,bulkRevision:c}}function eo(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=>eo(n));const t={};for(const n of Object.keys(e)){const r=Object.getOwnPropertyDescriptor(e,n);t[n]=eo(r?.value)}return t}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function rm({className:e,orientation:t="horizontal",...n}){return s.jsx(y5,{"data-slot":"tabs","data-orientation":t,orientation:t,className:ae("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...n})}const m3=sl("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 sm({className:e,variant:t="default",...n}){return s.jsx(w5,{"data-slot":"tabs-list","data-variant":t,className:ae(m3({variant:t}),e),...n})}function ht({className:e,...t}){return s.jsx(k5,{"data-slot":"tabs-trigger",className:ae("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 mt({className:e,...t}){return s.jsx(_5,{"data-slot":"tabs-content",className:ae("flex-1 outline-none",e),...t})}function Ut(e){const[t,n]=p.useState(!1),r=p.useRef(null);p.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);const o=p.useCallback(i=>{i.stopPropagation(),e!==null&&Kt(e).then(a=>{a&&(n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),2e3))})},[e]);return{copied:t,copy:o}}const g3=p.lazy(()=>En(()=>import("./CompareDrawer-B9sLBHw5.js"),__vite__mapDeps([0,1])).then(e=>({default:e.CompareDrawer}))),x3=p.lazy(()=>En(()=>import("./ReplayDialog-D9I9W9n3.js"),__vite__mapDeps([2,1,3])).then(e=>({default:e.ReplayDialog}))),b3=p.lazy(()=>En(()=>import("./RequestAnatomy-DGXK_Rii.js"),__vite__mapDeps([4,1])).then(e=>({default:e.RequestAnatomy}))),v3=p.lazy(()=>En(()=>import("./ResponseView-df_JzwsS.js"),__vite__mapDeps([3,1])).then(e=>({default:e.ResponseView}))),y3=p.lazy(()=>En(()=>import("./StreamingChunkSequence-i3DM5IKL.js"),__vite__mapDeps([5,1])).then(e=>({default:e.StreamingChunkSequence}))),aa=p.lazy(()=>En(()=>import("./json-viewer-D3QWQlSB.js"),__vite__mapDeps([6,1])).then(e=>({default:e.JsonViewer}))),w3=p.lazy(()=>En(()=>import("./json-viewer-D3QWQlSB.js"),__vite__mapDeps([6,1])).then(e=>({default:e.JsonViewerFromString}))),k3=1200,_3=12;function j3(e){const{containerRef:t,setExpandToPath:n,ensureTabActive:r,highlightMs:o}=e,i=p.useRef(null);return p.useCallback(a=>{r?.(),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??k3)},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(_3))},[t,r,o,n])}const Yc="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.";function qn(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 S3(e,t){const n=[];return e!=null&&n.push(`Request ${qn(e)}`),t!=null&&n.push(`Response ${qn(t)}`),n.length===0?null:n.join(" · ")}function C3(e){if(e instanceof za)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===""?Yc:t}}return{title:"Full bodies could not be loaded",detail:Yc}}class om{diff(t,n,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const i=this.castInput(t,r),a=this.castInput(n,r),l=this.removeEmpty(this.tokenize(i,r)),c=this.removeEmpty(this.tokenize(a,r));return this.diffWithOptionsObj(l,c,r,o)}diffWithOptionsObj(t,n,r,o){var i;const a=y=>{if(y=this.postProcess(y,r),o){setTimeout(function(){o(y)},0);return}else return y},l=n.length,c=t.length;let u=1,d=l+c;r.maxEditLength!=null&&(d=Math.min(d,r.maxEditLength));const f=(i=r.timeout)!==null&&i!==void 0?i:1/0,m=Date.now()+f,h=[{oldPos:-1,lastComponent:void 0}];let v=this.extractCommon(h[0],n,t,0,r);if(h[0].oldPos+1>=c&&v+1>=l)return a(this.buildValues(h[0].lastComponent,n,t));let g=-1/0,x=1/0;const b=()=>{for(let y=Math.max(g,-u);y<=Math.min(x,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 C=j&&j.oldPos+1<c;if(!E&&!C){h[y]=void 0;continue}if(!C||E&&j.oldPos<S.oldPos?_=this.addToPath(S,!0,!1,0,r):_=this.addToPath(j,!1,!0,1,r),v=this.extractCommon(_,n,t,y,r),_.oldPos+1>=c&&v+1>=l)return a(this.buildValues(_.lastComponent,n,t))||!0;h[y]=_,_.oldPos+1>=c&&(x=Math.min(x,y-1)),v+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);b()||y()},0)})();else for(;u<=d&&Date.now()<=m;){const y=b();if(y)return y}}addToPath(t,n,r,o,i){const a=t.lastComponent;return a&&!i.oneChangePerToken&&a.added===n&&a.removed===r?{oldPos:t.oldPos+o,lastComponent:{count:a.count+1,added:n,removed:r,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:a}}}extractCommon(t,n,r,o,i){const a=n.length,l=r.length;let c=t.oldPos,u=c-o,d=0;for(;u+1<a&&c+1<l&&this.equals(r[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,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);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,r){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(r.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 v=r[u+h];return v.length>m.length?v: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 N3 extends om{constructor(){super(...arguments),this.tokenize=am}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
88
+ `)){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&&r.length>0&&(d.startsWith("{")||d==="[DONE]")&&o(),r.push(d);break}}return o(),t}function Tl(e){try{return JSON.parse(e)}catch{return null}}function Jh(e,t){if(e.event!==null&&e.event!=="")return e.event;const n=N1.safeParse(t);return n.success?n.data.type:""}function fN(e){if(e.data==="[DONE]")return!1;const t=Tl(e.data),n=Jh(e,t);return n.startsWith("response.")||n==="error"}function Yh(e,t,n,r,o){e.length>=Nl||e.push({index:t,timestamp:Date.now()-n,type:r,data:o})}function ia(e,t){const n=Qs(t,"error"),r=tt(n,"message")??tt(t,"message")??tt(t,"error");r!==null&&r.length>0&&(e.error=r)}function pN(e,t,n,r){let o="",i="",a="",l="",c=null,u=0,d=0,f=!1,m=!1;const h=new Map;let v=0,g=0;const x=[];for(const y of e){if(y.data==="[DONE]")break;const _=Tl(y.data);if(_===null)continue;ia(t,_);const j=j1.safeParse(_);if(!j.success)continue;const S=j.data;if(v===0&&(g=Date.now()),r&&Yh(x,v,g,"chat.completion.chunk",S),v++,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=Qs(_,"usage"),C=Qs(E,"prompt_tokens_details"),R=Gh(C,"cached_tokens");R!==null&&(t.cacheReadInputTokens=R),f=!0}for(const E of S.choices){const C=E.delta;C.content!==void 0&&C.content!==null&&(a+=C.content),C.reasoning_content!==void 0&&C.reasoning_content!==null&&(l+=C.reasoning_content),C.thinking!==void 0&&C.thinking!==null&&(l+=C.thinking);const R=C.think;if(R!=null&&(l+=R),E.finish_reason!==void 0&&E.finish_reason!==null&&(c=E.finish_reason),C.tool_calls!==void 0&&C.tool_calls!==null)for(const z of C.tool_calls){let O=h.get(z.index);O===void 0&&(O={index:z.index,type:"function",function:{name:"",arguments:""}},h.set(z.index,O)),z.id!==void 0&&(O.id=z.id),z.function?.name!==void 0&&(O.function.name+=z.function.name),z.function?.arguments!==void 0&&(O.function.arguments+=z.function.arguments)}}}r&&(t.streamingChunks={chunks:x,truncated:v>Nl}),f||(d=Math.ceil(a.length/4)),t.outputTokens=d;const b={role:"assistant",content:a};return l.length>0&&(b.reasoning_content=l),h.size>0&&(b.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:b,finish_reason:c}],usage:{prompt_tokens:u,completion_tokens:d,total_tokens:u+d}})}function hN(e){const t=Ds.safeParse(Yr(e,"response"));if(t.success)return t.data;const n=Ds.safeParse(e);return n.success?n.data:null}function Xh(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 r=uN(n,"content");for(const o of r){const i=tt(o,"type"),a=tt(o,"text");(i==="output_text"||i==="text")&&a!==null&&a.length>0&&t.push(a)}}return t.join(`
89
+ `)}function Zc(e,t){const n=e.usage,r=n?.input_tokens??null,o=n?.output_tokens??null;r!==null&&(t.inputTokens=r),o!==null&&(t.outputTokens=o);const i=n?.input_tokens_details?.cached_tokens??null;return i!==null&&(t.cacheReadInputTokens=i),{inputTokens:r,outputTokens:o}}function fi(e,t){const n=tt(e,"item_id");if(n!==null&&n.length>0)return n;const r=Gh(e,"output_index");return r!==null?String(r):`function-${String(t)}`}function aa(e,t){const n=e.get(t);if(n!==void 0)return n;const r={type:"function_call",arguments:""};return e.set(t,r),r}function mN(e,t,n){if(tt(n,"type")!=="function_call")return;const r=aa(e,t),o=tt(n,"id"),i=tt(n,"call_id"),a=tt(n,"name"),l=tt(n,"arguments"),c=tt(n,"status");o!==null&&(r.id=o),i!==null&&(r.call_id=i),a!==null&&(r.name=a),l!==null&&(r.arguments=l),c!==null&&(r.status=c)}function gN(e,t){const n=[];e.length>0&&n.push({type:"message",role:"assistant",content:[{type:"output_text",text:e,annotations:[]}]});for(const r of t.values())n.push(r);return n}function xN(e,t,n){const r=t??Math.ceil(n.length/4);return{input_tokens:e,output_tokens:r,total_tokens:e===null?r:e+r}}function bN(e){const t=e.completedResponse===null?"":Xh(e.completedResponse),n=t.length>0?t:e.outputText,r=e.completedResponse?.output,o=r!==void 0&&r.length>0?r:gN(n,e.calls),i=e.completedResponse?.usage??xN(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 vN(e,t,n,r){let o=null,i="",a=n??"",l=null,c="",u=null,d=null,f=0,m=0;const h=[],v=new Map;for(const b of e){if(b.data==="[DONE]")break;const y=Tl(b.data);if(y===null)continue;const _=Jh(b,y);if(f===0&&(m=Date.now()),r&&Yh(h,f,m,_===""?"response.event":_,y),f++,ia(t,y),_==="error")continue;const j=hN(y);if(j!==null){o=j,i=j.id,a=j.model??a,l=j.status??l;const E=Zc(j,t);u=E.inputTokens??u,d=E.outputTokens??d,ia(t,j)}const S=tt(y,"delta");switch(_){case"response.output_text.delta":S!==null&&(c+=S);break;case"response.output_text.done":{const E=tt(y,"text");c.length===0&&E!==null&&(c=E);break}case"response.function_call_arguments.delta":{if(S!==null){const E=aa(v,fi(y,v.size));E.arguments+=S}break}case"response.function_call_arguments.done":{const E=tt(y,"arguments");if(E!==null){const C=aa(v,fi(y,v.size));C.arguments=E}break}case"response.output_item.added":case"response.output_item.done":{const E=Qs(y,"item");mN(v,fi(y,v.size),E);break}case"response.failed":case"response.incomplete":l=_.slice(9);break;case"response.completed":l="completed";break}}r&&(t.streamingChunks={chunks:h,truncated:f>Nl});const g=bN({completedResponse:o,responseId:i,model:a,status:l,outputText:c,calls:v,inputTokens:u,outputTokens:d}),x=Ds.safeParse(g);if(x.success){if(Zc(x.data,t).outputTokens===null){const y=Xh(x.data),_=Math.ceil(y.length/4);t.outputTokens=_}return JSON.stringify(x.data)}if(t.outputTokens===null){const b=tt(g,"output_text")??c,y=Math.ceil(b.length/4);t.outputTokens=y}return JSON.stringify(g)}function Zo(e,t,n,r=!0){const o=dN(e);return o.some(fN)?vN(o,t,n,r):pN(o,t,n,r)}function yN(){return{inputTokens:null,outputTokens:null,cacheCreationInputTokens:null,cacheReadInputTokens:null}}const wN={format:"openai",parseRequest(e,t){try{const n=JSON.parse(e),r=Ud.safeParse(n);if(r.success)return{model:r.data.model,sessionId:t?.get("x-session-affinity")??null};const o=Wd.safeParse(n);return o.success?{model:o.data.model,sessionId:t?.get("x-session-affinity")??null}:null}catch{return null}},extractTokens(e){const t=Zd(e);if(t){let r=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"&&(r=l.value)}}}}catch{}return{inputTokens:t.usage.prompt_tokens??null,outputTokens:t.usage.completion_tokens??null,cacheCreationInputTokens:null,cacheReadInputTokens:r}}const n=Vd(e);if(n!==null){const r=n.usage;return{inputTokens:r?.input_tokens??null,outputTokens:r?.output_tokens??null,cacheCreationInputTokens:null,cacheReadInputTokens:r?.input_tokens_details?.cached_tokens??null}}return yN()},extractStream(e,t,n,r){return Zo(e,t,n,r)},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}}};hn.register(wN);const kN="https://api.openai.com/v1",_N={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:kN},extractStream(e,t,n,r){return Zo(e,t,n,r)}};Ho.register(_N);const jN="https://open.bigmodel.cn/api/paas/v4",SN=["glm-","charglm-","cogview-","embedding-","rerank-"],CN={name:"zhipu",matches(e){const t=e.toLowerCase().replace(/\s+/g,"-");return SN.some(n=>t.startsWith(n))},getUpstreamBase(e,t){return t?.baseUrl??jN},extractStream(e,t,n,r){return Zo(e,t,n,r)}};Ho.register(CN);const NN="https://dashscope.aliyuncs.com/compatible-mode/v1",TN={name:"alibaba",matches(e){return!!e.toLowerCase().replace(/\s+/g,"-").startsWith("qwen")},getUpstreamBase(e,t){return NN},extractStream(e,t,n){return Zo(e,t,n)}};Ho.register(TN);function Qh(e,t){for(const n of Array.from(e))t(n)}const EN=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function El(e){if(e.length===0)return 0;let t=0,n=0;return Qh(e,r=>{EN.test(r)?t+=1:n+=1}),Math.ceil(t*1)+Math.ceil(n/4)}function Al(e){if(e.length===0)return 0;let t=0;return Qh(e,()=>{t+=1}),t}function wn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const Yn={parsed:null,toolNames:null};function AN(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 r=n;switch(r.type){case"text":typeof r.text=="string"&&t.push(r.text);break;case"thinking":case"think":typeof r.thinking=="string"&&t.push(r.thinking);break;case"tool_use":{const i=typeof r.name=="string"?r.name:"",a=r.input!==void 0?JSON.stringify(r.input):"";t.push(`${i} ${a}`.trim());break}case"tool_result":{const i=r.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(`
90
+ `)}function RN(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 r=n.text;n.type==="text"&&typeof r=="string"&&t.push(r)}return t.join(`
91
+ `)}function IN(e){if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const r=n;typeof r.name=="string"&&t.push(r.name),typeof r.description=="string"&&t.push(r.description),r.input_schema!==void 0&&t.push(JSON.stringify(r.input_schema))}return t.join(`
92
+ `)}function pi(e,t,n,r){return{role:e,label:t,text:n,size:El(n),characters:Al(n),path:r}}const zN={format:"anthropic",analyzeRequest(e){if(e===null)return wn(e);try{const t=Dd.safeParse(JSON.parse(e));return t.success?{parsed:t.data,comparisonValue:t.data,messageCount:t.data.messages.length,toolCount:t.data.tools!==void 0&&t.data.tools.length>0?t.data.tools.length:null}:wn(e)}catch{return wn(e)}},analyzeResponse(e){if(e===null)return Yn;try{let t=JSON.parse(e);typeof t=="string"&&(t=JSON.parse(t));const n=$d.safeParse(t);if(!n.success)return Yn;const r=n.data.content.filter(o=>o.type==="tool_use").map(o=>o.name);return{parsed:n.data,toolNames:r.length>0?r:null}}catch{return Yn}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,n=[];if(t.system!==void 0){const r=RN(t.system);r.length>0&&n.push(pi("system","system",r,"/system"))}if(Array.isArray(t.messages)&&t.messages.forEach((r,o)=>{if(r===null||typeof r!="object")return;const i=r,a=i.role==="user"||i.role==="assistant"?i.role:"user",l=AN(i.content);n.push(pi(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.tools)&&t.tools.length>0){const r=IN(t.tools);n.push(pi("tools","tools",r,"/tools"))}return n.length>0?n:null}};function Rl(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}function la(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 r=n,o=r.type;(o==="text"||o==="input_text"||o==="output_text")&&typeof r.text=="string"?t.push(r.text):(o==="image_url"||o==="input_image")&&t.push("[image]")}return t.join(`
93
+ `)}function PN(e){const t=[],n=la(e.content);n.length>0&&t.push(n);const r=typeof e.reasoning_content=="string"?e.reasoning_content:typeof e.thinking=="string"?e.thinking:typeof e.think=="string"?e.think:"";r.length>0&&t.push(r);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(`
94
+ `)}function ON(e){if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const r=ke(n,"function"),o=ke(r,"name")??ke(n,"name"),i=ke(r,"description")??ke(n,"description"),a=ke(r,"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(`
95
+ `)}function MN(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function LN(e){if(typeof e=="string")return e;const t=ke(e,"text");if(typeof t=="string")return t;const n=la(ke(e,"content"));if(n.length>0)return n;const r=la(ke(e,"output"));if(r.length>0)return r;const o=ke(e,"arguments");return typeof o=="string"?o:""}function DN(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 $N(e){const t=ke(e,"output");if(!Array.isArray(t))return[];const n=[];for(const r of t){if(ke(r,"type")!=="function_call")continue;const o=ke(r,"name");typeof o=="string"&&o.length>0&&n.push(o)}return n}function xr(e,t,n,r){return{role:e,label:t,text:n,size:El(n),characters:Al(n),path:r}}const FN={format:"openai",analyzeRequest(e){if(e===null)return wn(e);try{const t=Ud.safeParse(JSON.parse(e));if(!t.success){const n=Wd.safeParse(JSON.parse(e));return n.success?{parsed:n.data,comparisonValue:n.data,messageCount:MN(n.data.input),toolCount:n.data.tools!==void 0&&n.data.tools.length>0?n.data.tools.length:null}:wn(e)}return{parsed:t.data,comparisonValue:t.data,messageCount:t.data.messages.length,toolCount:t.data.tools!==void 0&&t.data.tools.length>0?t.data.tools.length:null}}catch{return wn(e)}},analyzeResponse(e){if(e===null)return Yn;const t=Zd(e);if(t===null){const r=Vd(e);if(r===null)return Yn;const o=$N(r);return{parsed:r,toolNames:o.length>0?o:null}}const n=t.choices[0]?.message?.tool_calls?.map(r=>r.function?.name??"").filter(r=>r!=="")??[];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(xr("system","instructions",t.instructions,"/instructions")),Array.isArray(t.messages)&&t.messages.forEach((r,o)=>{if(r===null||typeof r!="object")return;const i=r,a=i.role==="user"||i.role==="assistant"||i.role==="system"||i.role==="tool"?i.role:"user",l=PN(i);n.push(xr(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.messages)||(typeof t.input=="string"&&t.input.length>0?n.push(xr("user","input",t.input,"/input")):Array.isArray(t.input)&&t.input.forEach((r,o)=>{const i=DN(r),a=LN(r);n.push(xr(i,`[${o}] ${i}`,a,`/input/${o}`))})),Array.isArray(t.tools)&&t.tools.length>0){const r=ON(t.tools);n.push(xr("tools","tools",r,"/tools"))}return n.length>0?n:null}},BN={format:"unknown",analyzeRequest(e){return wn(e)},analyzeResponse(){return Yn},anatomySegments(){return null}},UN={anthropic:zN,openai:FN,unknown:BN};function em(e){return UN[e]}function Lr(e){const t=nN(e.path);return t==="unknown"?e.apiFormat:t}const Vc="border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground";function hi({icon:e,children:t,title:n,className:r}){return s.jsxs("span",{className:le("border border-border bg-muted/30 inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground",r),title:n,children:[e,s.jsx("span",{className:"min-w-0 font-mono tabular-nums",children:t})]})}function WN({conversationId:e,startTime:t,endTime:n,totalCalls:r,totalInputTokens:o,totalOutputTokens:i,expanded:a,onToggle:l,providers:c,isLoading:u=!1,userAgent:d,clientPid:f,clientProjectFolder:m,showClientIdentity:h=!0,showProcessMetadata:v=!0,timeDisplayFormat:g,onClear:x}){const[b,y]=p.useState(!1),_=$=>{$.stopPropagation(),x!==void 0&&y(!0)},j=p.useCallback($=>{$.stopPropagation(),window.open(td(e),"_blank","noopener,noreferrer")},[e]),S=c?.map(({provider:$,models:X})=>({provider:$,tooltip:X.length===1?X[0]??$:X.join(", ")}))??[],E=al({userAgent:d,conversationId:e,clientProjectFolder:m}),C=To(E),R=d!=null&&d!=="",z=C??d??null,O=C!==null&&R?`${C} - ${d}`:null,q=e.startsWith("PID:")||e.includes("|"),T=e.length>24?e.slice(0,12)+"..."+e.slice(-12):e,D=Ya(t,n,g),k=`${r} call${r!==1?"s":""}`;return s.jsxs("div",{role:"button",tabIndex:0,"data-nav-id":`conv-${e}`,"data-nav-action":a?"collapse":"expand",className:le("border border-border bg-card shadow-sm flex cursor-pointer items-start gap-3 rounded-[8px] px-3 py-2.5 transition-colors","hover:border-cyan-200/20","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:[s.jsx(G5,{items:S,ariaLabel:"Models used in this session",className:"mt-0.5"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[q&&v?f!=null?s.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]}):s.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-violet-200",title:e,children:e}):s.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-violet-200",title:e,children:q?"sessionless":T}),!q&&v&&f!==null&&f!==void 0&&s.jsxs("span",{className:"border border-border bg-muted/40 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]}),q&&v&&m!==null&&m!==void 0&&m!==""&&s.jsx("span",{className:"min-w-0 max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:m,children:m}),h&&z!==null&&z!==""&&s.jsxs("span",{className:"border border-border bg-muted/30 inline-flex h-6 max-w-[180px] shrink-0 items-center gap-1 rounded-md px-1.5 text-xs text-muted-foreground",title:O??z,children:[s.jsx(ll,{client:E,className:"size-4 shrink-0"}),s.jsx("span",{className:"truncate font-mono tabular-nums",children:z})]})]}),s.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx(hi,{icon:s.jsx(Ht,{className:"size-3 shrink-0"}),title:D,children:D}),s.jsx(hi,{icon:s.jsx(ko,{className:"size-3 shrink-0"}),children:k}),s.jsxs(hi,{icon:s.jsx(Pr,{className:"size-3 shrink-0"}),className:"max-w-full",children:[s.jsx("span",{className:"text-blue-400",children:$e(o)})," / ",s.jsx("span",{className:"text-amber-400",children:$e(i)})]})]})]}),s.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[s.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:Vc,children:s.jsx(Va,{className:"size-3.5"})}),x!==void 0&&s.jsx("button",{type:"button",onClick:_,"aria-label":`Clear group (${r} request${r!==1?"s":""})`,title:"Clear this group",className:Vc,children:s.jsx(nr,{className:"size-3.5"})}),s.jsx("span",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex size-8 shrink-0 items-center justify-center rounded-md text-slate-200","aria-hidden":"true",children:a?s.jsx(st,{className:"size-4 shrink-0"}):u?s.jsx(ft,{className:"size-4 shrink-0 animate-spin"}):s.jsx(bt,{className:"size-4 shrink-0"})})]}),s.jsx(op,{open:b,onOpenChange:y,title:"Clear this group?",description:`This will remove ${r} request${r!==1?"s":""} from this conversation. This action cannot be undone.`,confirmLabel:"Clear",variant:"destructive",onConfirm:()=>{x?.()}})]})}function HN(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 r=t?`PID:${e.clientPid}`:"unknown",o=n?e.clientProjectFolder:"no-folder";return`${r}|${o}`}function ZN(e){const t=new Map;for(const r of e){const o=HN(r),i=t.get(o);i!==void 0?i.push(r):t.set(o,[r])}const n=[];for(const[r,o]of t){const i=[...o].sort((a,l)=>a.timestamp.localeCompare(l.timestamp));n.push({id:r,conversationId:r,logs:i})}return n.sort((r,o)=>(r.logs[0]?.timestamp??"").localeCompare(o.logs[0]?.timestamp??"")),n}function VN(e,t,n){const r=new Array(e);return new Proxy(r,{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 Dn(e,t,n){let r=n.initialDeps??[],o,i=!0;function a(){const l=e();return(l.length!==r.length||l.some((u,d)=>r[d]!==u))&&(r=l,o=t(...l),n?.onChange&&!(i&&n.skipInitialOnChange)&&n.onChange(o),i=!1),o}return a.updateDeps=l=>{r=l},a}function qc(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const Kc=(e,t)=>Math.abs(e-t)<1.01,qN=(e,t,n)=>{let r;return function(...o){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,o),n)}};let br;const Gc=()=>{if(br!==void 0)return br;if(typeof navigator>"u")return br=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return br=!0;const e=navigator.maxTouchPoints;return br=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Jc=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},KN=e=>e,GN=e=>{const t=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,o=new Array(r);for(let i=0;i<r;i++)o[i]=t+i;return o},JN=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const o=a=>{const{width:l,height:c}=a;t({width:Math.round(l),height:Math.round(c)})};if(o(Jc(n)),!r.ResizeObserver)return()=>{};const i=new r.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(Jc(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},Dr={passive:!0},YN=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=()=>{t({width:n.innerWidth,height:n.innerHeight})};return r(),n.addEventListener("resize",r,Dr),()=>{n.removeEventListener("resize",r)}},XN=typeof window>"u"?!0:"onscrollend"in window,tm=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&XN;let a=0;const l=i?null:qN(o,()=>t(a,!1),e.options.isScrollingResetDelay),c=f=>()=>{a=n(r),l?.(),t(a,f)},u=c(!0),d=c(!1);return r.addEventListener("scroll",u,Dr),i&&r.addEventListener("scrollend",d,Dr),()=>{r.removeEventListener("scroll",u),i&&r.removeEventListener("scrollend",d)}},QN=(e,t)=>tm(e,t,n=>{const{horizontal:r,isRtl:o}=e.options;return r?n.scrollLeft*(o&&-1||1):n.scrollTop}),e3=(e,t)=>tm(e,t,n=>e.options.horizontal?n.scrollX:n.scrollY),t3=(e,t,n)=>{if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},nm=(e,{adjustments:t=0,behavior:n},r)=>{var o,i;(i=(o=r.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})},n3=nm,r3=nm;class s3{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,r,o;return((o=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:o.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>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=r())==null||o.disconnect(),n=null},observe:o=>{var i;return(i=r())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=r())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=n=>{var r,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:KN,rangeExtractor:GN,onChange:()=>{},measureElement:t3,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"};for(const u in n){const d=n[u];d!==void 0&&(i[u]=d)}const a=this.options;let l=null,c=null;if(a!==void 0&&a.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const u=a.count,d=i.count,f=this.getMeasurements(),m=u>0?((r=f[0])==null?void 0:r.key)??a.getItemKey(0):null,h=u>0?((o=f[u-1])==null?void 0:o.key)??a.getItemKey(u-1):null;if(d!==u||u>0&&d>0&&(i.getItemKey(0)!==m||i.getItemKey(d-1)!==h)){const x=u>0?this.getVirtualItemForOffset(this.getScrollOffset())??f[0]:null;x&&(l=[x.key,this.getScrollOffset()-x.start]);const b=i.followOnAppend===!0?"auto":i.followOnAppend||null;b&&d>u&&this.isAtEnd(a.scrollEndThreshold)&&(u===0||i.getItemKey(d-1)!==h)&&(c=b)}}this.options=i,(l||c)&&(this.pendingScrollAnchor=[l?.[0]??null,l?.[1]??0,c])},this.notify=n=>{var r,o;(o=(r=this.options).onChange)==null||o.call(r,this,n)},this.maybeNotify=Dn(()=>(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 r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,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)=>{this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=a?this.getScrollOffset()<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,!(!Gc()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",a,Dr),i.addEventListener("touchend",l,Dr),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]=o;if(i!==null){const{count:c,getItemKey:u}=this.options;let d=0;for(;d<c&&u(d)!==i;)d++;const f=d<c?this.getMeasurements()[d]:void 0;if(f){const m=f.start+a-this.getScrollOffset();Kc(m,0)||this.applyScrollAdjustment(m)}}l&&this.scrollToEnd({behavior:l})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),r=this.getMaxScrollOffset();if(n<0||n>r)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,r)=>{const o=new Map,i=new Map;for(let a=r-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=Dn(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(n,r,o,i,a,l,c)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMin=null,{count:n,paddingStart:r,scrollMargin:o,getItemKey:i,enabled:a,lanes:l,laneAssignmentMode:c}),{key:!1}),this.getMeasurements=Dn(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:r,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 v of this.laneAssignments.keys())v>=n&&this.laneAssignments.delete(v);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(v=>{this.itemSizeCache.set(v.key,v.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 v=this.options.gap,g=n*2;let x=this._flatMeasurements;if(!x||x.length<g){const _=new Float64Array(g);x&&f>0&&_.set(x.subarray(0,f*2)),x=_,this._flatMeasurements=x}let b;if(f===0)b=r+o;else{const _=f-1;b=x[_*2]+x[_*2+1]+v}for(let _=f;_<n;_++){const j=i(_),S=d.get(j),E=typeof S=="number"?S:this.options.estimateSize(_);x[_*2]=b,x[_*2+1]=E,b+=E+v}const y=VN(n,x,i);return this.measurementsCache=y,y}const m=this.measurementsCache.slice(0,f),h=new Array(l).fill(void 0);for(let v=0;v<f;v++){const g=m[v];g&&(h[g.lane]=v)}for(let v=f;v<n;v++){const g=i(v),x=this.laneAssignments.get(v);let b,y;const _=c==="estimate"||d.has(g);if(x!==void 0&&this.options.lanes>1){b=x;const C=h[b],R=C!==void 0?m[C]:void 0;y=R?R.end+this.options.gap:r+o}else{const C=this.options.lanes===1?m[v-1]:this.getFurthestMeasurement(m,v);y=C?C.end+this.options.gap:r+o,b=C?C.lane:v%this.options.lanes,this.options.lanes>1&&_&&this.laneAssignments.set(v,b)}const j=d.get(g),S=typeof j=="number"?j:this.options.estimateSize(v),E=y+S;m[v]={index:v,start:y,size:S,end:E,key:g,lane:b},h[b]=v}return this.measurementsCache=m,m},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Dn(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,o,i)=>this.range=n.length>0&&r>0?o3({measurements:n,outerSize:r,scrollOffset:o,lanes:i,flat:i===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Dn(()=>{let n=null,r=null;const o=this.calculateRange();return o&&(n=o.startIndex,r=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,o,i,a)=>i===null||a===null?[]:n({startIndex:i,endIndex:a,overscan:r,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,o=n.getAttribute(r);return o?parseInt(o,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.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 r=this.indexFromElement(n),o=this.options.getItemKey(r),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(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{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=r-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,v=((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.scrollDirection!=="backward");(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(c,r),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-h):v&&this.applyScrollAdjustment(f),this.notify(!1)}},this.getVirtualItems=Dn(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const o=[];for(let i=0,a=n.length;i<a;i++){const l=n[i],c=r[l];o.push(c)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,a=rm(0,r.length-1,i?l=>o[l*2]:l=>qc(r[l]).start,n);return qc(r[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,r,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),a=this.getScrollOffset();r==="auto"&&(r=n>=a+i?"end":"start"),r==="center"?n+=(o-i)/2:r==="end"&&(n-=i);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,r="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(r==="auto")if(a.end>=i+o-this.options.scrollPaddingEnd)r="end";else if(a.start<=i+this.options.scrollPaddingStart)r="start";else return[i,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const l=r==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,r,a.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(n,r),a=this.now();this.scrollState={index:null,align:r,behavior:o,startedAt:a,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:o="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getOffsetForIndex(n,r);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:r="auto"}={})=>{const o=this.getScrollOffset()+n,i=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),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 r=this.getMeasurements();let o;if(r.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=r.length-1,a=this._flatMeasurements;a!=null?o=a[i*2]+a[i*2+1]:o=((n=r[i])==null?void 0:n.end)??0}else{const i=Array(this.options.lanes).fill(null);let a=r.length-1;for(;a>=0&&i.some(l=>l===null);){const l=r[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 r=this.getMeasurements();for(const o of r)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:r,behavior:o})=>{this._intendedScrollOffset=n+(r??0),this.options.scrollToFn(n,{behavior:o,adjustments:r},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&&(Gc()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}))}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 r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=r?r[0]:this.scrollState.lastTargetOffset,i=1,a=o!==this.scrollState.lastTargetOffset;if(!a&&Kc(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 rm=(e,t,n,r)=>{for(;e<=t;){const o=(e+t)/2|0,i=n(o);if(i<r)e=o+1;else if(i>r)t=o-1;else return o}return e>0?e-1:0};function o3({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:o}){const i=e.length-1,a=o?d=>o[d*2]:d=>e[d].start,l=o?d=>o[d*2]+o[d*2+1]:d=>e[d].end;if(e.length<=r)return{startIndex:0,endIndex:i};let c=rm(0,i,a,n),u=c;if(r===1)for(;u<i&&l(u)<n+t;)u++;else if(r>1){const d=Array(r).fill(0);for(;u<i&&d.some(m=>m<n+t);){const m=e[u];d[m.lane]=m.end,u++}const f=Array(r).fill(n+t);for(;c>=0&&f.some(m=>m>=n);){const m=e[c];f[m.lane]=m.start,c--}c=Math.max(0,c-c%r),u=Math.min(i,u+(r-1-u%r))}return{startIndex:c,endIndex:u}}const Yc=typeof document<"u"?p.useLayoutEffect:p.useEffect;function sm({useFlushSync:e=!0,...t}){const n=p.useReducer(i=>i+1,0)[1],r={...t,onChange:(i,a)=>{var l;e&&a?Br.flushSync(n):n(),(l=t.onChange)==null||l.call(t,i,a)}},[o]=p.useState(()=>new s3(r));return o.setOptions(r),Yc(()=>o._didMount(),[]),Yc(()=>o._willUpdate()),o}function i3(e){return sm({observeElementRect:JN,observeElementOffset:QN,scrollToFn:r3,...e})}function a3(e){return sm({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:YN,observeElementOffset:e3,scrollToFn:n3,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const qt="agent-inspector:focus-log";function eo(e){window.dispatchEvent(new CustomEvent(qt,{detail:e}))}function Vo(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 r=ke(t,"tab");switch(r){case"anatomy":case"request":break;case void 0:break;default:return null}const o=ke(t,"source");switch(o){case"virtualizer":return{logId:n,tab:r??"request",source:o};case void 0:return{logId:n,tab:r??"request"};default:return null}}const l3="x-anthropic-billing-header:";function c3(e){return e.trimStart().toLowerCase().startsWith(l3)}function u3(e){return Rl(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function d3(e){if(!Rl(e))return!1;const t=ke(e,"type"),n=ke(e,"text");return typeof t!="string"||t!=="text"||typeof n!="string"?!1:c3(n)}function f3(e){let t;try{t=JSON.parse(e)}catch{return{body:e,removed:0}}if(!u3(t))return{body:e,removed:0};const n=t.system;if(!Array.isArray(n)||n.length===0)return{body:e,removed:0};const r=[];let o=0;for(const i of n){if(d3(i)){o+=1;continue}r.push(i)}return o===0?{body:e,removed:0}:(r.length===0?delete t.system:t.system=r,{body:JSON.stringify(t),removed:o})}const p3=400,Xc=2e3;function h3(e){return Array.isArray(e)}function m3(e,t){const n=[e];let r=0;for(;n.length>0;){const o=n.pop();if(o!==void 0){if(r+=1,r>t)return r;if(!(o===null||typeof o!="object")){if(h3(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 r}function g3(e){const t=m3(e,Xc+1);return t<=p3?{depth:Number.POSITIVE_INFINITY}:t<=Xc?{depth:3}:{depth:2}}function x3(e){try{const t=JSON.parse(e);return{kind:"json",data:to(t)}}catch{return{kind:"text"}}}function mi(e){const t=p.useMemo(()=>e===null?null:x3(e),[e]),n=t?.kind==="json"?t.data:null,r=p.useMemo(()=>n===null?null:g3(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,v=h&&r!==null?r.depth:0;f(()=>{i(h),l(v),u(g=>g+1)})},[o,r]);return{parsedData:n,policy:r,isExpanded:o,toggle:m,isPending:d,bulkDepth:a,bulkRevision:c}}function to(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=>to(n));const t={};for(const n of Object.keys(e)){const r=Object.getOwnPropertyDescriptor(e,n);t[n]=to(r?.value)}return t}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function om({className:e,orientation:t="horizontal",...n}){return s.jsx(_5,{"data-slot":"tabs","data-orientation":t,orientation:t,className:le("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...n})}const b3=il("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 im({className:e,variant:t="default",...n}){return s.jsx(j5,{"data-slot":"tabs-list","data-variant":t,className:le(b3({variant:t}),e),...n})}function ht({className:e,...t}){return s.jsx(S5,{"data-slot":"tabs-trigger",className:le("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 mt({className:e,...t}){return s.jsx(C5,{"data-slot":"tabs-content",className:le("flex-1 outline-none",e),...t})}function Ut(e){const[t,n]=p.useState(!1),r=p.useRef(null);p.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);const o=p.useCallback(i=>{i.stopPropagation(),e!==null&&Kt(e).then(a=>{a&&(n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),2e3))})},[e]);return{copied:t,copy:o}}const v3=p.lazy(()=>En(()=>import("./CompareDrawer-Fqqw5Lci.js"),__vite__mapDeps([0,1])).then(e=>({default:e.CompareDrawer}))),y3=p.lazy(()=>En(()=>import("./ReplayDialog-hYhz_i6W.js"),__vite__mapDeps([2,1,3])).then(e=>({default:e.ReplayDialog}))),w3=p.lazy(()=>En(()=>import("./RequestAnatomy-CTuWbtwC.js"),__vite__mapDeps([4,1])).then(e=>({default:e.RequestAnatomy}))),k3=p.lazy(()=>En(()=>import("./ResponseView-CsZ7S5Gv.js"),__vite__mapDeps([3,1])).then(e=>({default:e.ResponseView}))),_3=p.lazy(()=>En(()=>import("./StreamingChunkSequence-PIbJMotU.js"),__vite__mapDeps([5,1])).then(e=>({default:e.StreamingChunkSequence}))),ca=p.lazy(()=>En(()=>import("./json-viewer-DCXtNmmD.js"),__vite__mapDeps([6,1])).then(e=>({default:e.JsonViewer}))),j3=p.lazy(()=>En(()=>import("./json-viewer-DCXtNmmD.js"),__vite__mapDeps([6,1])).then(e=>({default:e.JsonViewerFromString}))),S3=1200,C3=12;function N3(e){const{containerRef:t,setExpandToPath:n,ensureTabActive:r,highlightMs:o}=e,i=p.useRef(null);return p.useCallback(a=>{r?.(),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??S3)},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(C3))},[t,r,o,n])}const Qc="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.";function qn(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 T3(e,t){const n=[];return e!=null&&n.push(`Request ${qn(e)}`),t!=null&&n.push(`Response ${qn(t)}`),n.length===0?null:n.join(" · ")}function E3(e){if(e instanceof Oa)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===""?Qc:t}}return{title:"Full bodies could not be loaded",detail:Qc}}class am{diff(t,n,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const i=this.castInput(t,r),a=this.castInput(n,r),l=this.removeEmpty(this.tokenize(i,r)),c=this.removeEmpty(this.tokenize(a,r));return this.diffWithOptionsObj(l,c,r,o)}diffWithOptionsObj(t,n,r,o){var i;const a=y=>{if(y=this.postProcess(y,r),o){setTimeout(function(){o(y)},0);return}else return y},l=n.length,c=t.length;let u=1,d=l+c;r.maxEditLength!=null&&(d=Math.min(d,r.maxEditLength));const f=(i=r.timeout)!==null&&i!==void 0?i:1/0,m=Date.now()+f,h=[{oldPos:-1,lastComponent:void 0}];let v=this.extractCommon(h[0],n,t,0,r);if(h[0].oldPos+1>=c&&v+1>=l)return a(this.buildValues(h[0].lastComponent,n,t));let g=-1/0,x=1/0;const b=()=>{for(let y=Math.max(g,-u);y<=Math.min(x,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 C=j&&j.oldPos+1<c;if(!E&&!C){h[y]=void 0;continue}if(!C||E&&j.oldPos<S.oldPos?_=this.addToPath(S,!0,!1,0,r):_=this.addToPath(j,!1,!0,1,r),v=this.extractCommon(_,n,t,y,r),_.oldPos+1>=c&&v+1>=l)return a(this.buildValues(_.lastComponent,n,t))||!0;h[y]=_,_.oldPos+1>=c&&(x=Math.min(x,y-1)),v+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);b()||y()},0)})();else for(;u<=d&&Date.now()<=m;){const y=b();if(y)return y}}addToPath(t,n,r,o,i){const a=t.lastComponent;return a&&!i.oneChangePerToken&&a.added===n&&a.removed===r?{oldPos:t.oldPos+o,lastComponent:{count:a.count+1,added:n,removed:r,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:a}}}extractCommon(t,n,r,o,i){const a=n.length,l=r.length;let c=t.oldPos,u=c-o,d=0;for(;u+1<a&&c+1<l&&this.equals(r[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,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);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,r){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(r.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 v=r[u+h];return v.length>m.length?v: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 A3 extends am{constructor(){super(...arguments),this.tokenize=cm}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
96
96
  `))&&(t=t.trim()),(!r.newlineIsToken||!n.includes(`
97
97
  `))&&(n=n.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(t.endsWith(`
98
98
  `)&&(t=t.slice(0,-1)),n.endsWith(`
99
- `)&&(n=n.slice(0,-1))),super.equals(t,n,r)}}const T3=new N3;function im(e,t,n){return T3.diff(e,t,n)}function am(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
100
- `));const n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let o=0;o<r.length;o++){const i=r[o];o%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}class E3 extends om{constructor(){super(...arguments),this.tokenize=am}get useLongestToken(){return!0}castInput(t,n){const{undefinedReplacement:r,stringifyReplacer:o=(i,a)=>typeof a>"u"?r:a}=n;return typeof t=="string"?t:JSON.stringify(la(t,null,null,o),null," ")}equals(t,n,r){return super.equals(t.replace(/,([\r\n])/g,"$1"),n.replace(/,([\r\n])/g,"$1"),r)}}const A3=new E3;function R3(e,t,n){return A3.diff(e,t,n)}function la(e,t,n,r,o){t=t||[],n=n||[],r&&(e=r(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]=la(e[i],t,n,r,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]=la(e[c],t,n,r,c);t.pop(),n.pop()}else a=e;return a}function Xc(e){return e===void 0?[]:Object.entries(e).map(t=>[t[0].toLowerCase(),t[1]]).sort(([t],[n])=>t.localeCompare(n))}function Qc([e,t]){return`${e}: ${t}`}function ca(e){const t=[];let n=0,r=0;for(const o of e){const i=o.value.split(`
101
- `);i.length>0&&i[i.length-1]===""&&i.pop();for(const a of i)o.added?(r+=1,t.push({kind:"added",text:a,oldLineNumber:null,newLineNumber:r})):o.removed?(n+=1,t.push({kind:"removed",text:a,oldLineNumber:n,newLineNumber:null})):(n+=1,r+=1,t.push({kind:"context",text:a,oldLineNumber:n,newLineNumber:r}))}return t}function I3(e,t){const n=Xc(e).map(Qc).join(`
102
- `),r=Xc(t).map(Qc).join(`
103
- `);if(n===r)return{lines:[],isEmpty:!0};const o=im(n,r);return{lines:ca(o),isEmpty:!1}}function eu(e){try{const t=JSON.parse(e);return t===null||typeof t=="string"||typeof t=="object"?t:null}catch{return null}}function z3(e,t){const n=e??"",r=t??"";if(n===r)return{lines:[],isEmpty:!0};const o=eu(n),i=eu(r);if(o!==null&&i!==null){const l=R3(o,i)??[];if(l.length===1){const c=l[0];if(c!==void 0&&!c.added&&!c.removed)return{lines:[],isEmpty:!0}}return{lines:ca(l),isEmpty:!1}}const a=im(n,r);return{lines:ca(a),isEmpty:!1}}const P3=22,mi=1e4;function O3(e){return e==="added"?"+":e==="removed"?"-":" "}function M3(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 L3=function({result:t,emptyLabel:n}){const[r,o]=p.useState("unified"),i=p.useRef(null),a=r3({count:t.lines.length,getScrollElement:()=>i.current,estimateSize:()=>P3,overscan:10});if(t.isEmpty)return s.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>mi,u=c?t.lines.slice(0,mi):t.lines;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[s.jsxs("span",{children:[l.toLocaleString()," line",l===1?"":"s",c&&` (showing first ${mi.toLocaleString()})`]}),s.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[s.jsxs("button",{type:"button",onClick:()=>o("unified"),"aria-pressed":r==="unified",className:ae("flex items-center gap-1 px-2 py-1 transition-colors",r==="unified"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Unified diff (single column)",children:[s.jsx(O2,{className:"size-3"}),"Unified"]}),s.jsxs("button",{type:"button",onClick:()=>o("split"),"aria-pressed":r==="split",className:ae("flex items-center gap-1 px-2 py-1 transition-colors border-l border-border",r==="split"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Split diff (side by side)",children:[s.jsx(My,{className:"size-3"}),"Split"]})]})]}),s.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:r==="unified"?s.jsx(D3,{virtualizer:a,lines:u}):s.jsx(B3,{lines:u})})]})};function D3({virtualizer:e,lines:t}){return s.jsx("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:e.getVirtualItems().map(n=>{const r=t[n.index];return r===void 0?null:s.jsxs("div",{"data-index":n.index,ref:e.measureElement,className:ae("flex items-start gap-3 px-2",M3(r.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${n.start}px)`},children:[s.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:r.oldLineNumber??""}),s.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:r.newLineNumber??""}),s.jsx("span",{className:ae("select-none w-3 text-right font-bold",r.kind==="added"&&"text-green-600 dark:text-green-400",r.kind==="removed"&&"text-red-600 dark:text-red-400"),children:O3(r.kind)}),s.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:r.text})]},n.key)})})}function $3(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(r===void 0)break;if(r.kind==="context"){t.push({left:{text:r.text,lineNumber:r.oldLineNumber},right:{text:r.text,lineNumber:r.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 F3(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 B3({lines:e}){const t=$3(e);return s.jsx("div",{"data-testid":"diff-split",children:t.map((n,r)=>s.jsxs("div",{className:ae("grid grid-cols-2 font-mono text-xs",F3(n.kind)),children:[s.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[s.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.left?.lineNumber??""}),s.jsx("span",{className:ae("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?"-":" "}),s.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.left?.text??""})]}),s.jsxs("div",{className:"flex items-start gap-2 px-2",children:[s.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.right?.lineNumber??""}),s.jsx("span",{className:ae("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?"+":" "}),s.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.right?.text??""})]})]},r))})}const lm=p.memo(L3),U3=sl("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 Be({className:e,variant:t="default",asChild:n=!1,...r}){const o=n?Ok:"span";return s.jsx(o,{"data-slot":"badge","data-variant":t,className:ae(U3({variant:t}),e),...r})}const W3={success:"bg-slate-300/[0.08] text-slate-100 border-slate-300/20",client_error:"bg-amber-300/[0.10] text-amber-100 border-amber-300/30",server_error:"bg-rose-400/[0.10] text-rose-100 border-rose-300/30",pending:"bg-cyan-300/[0.08] text-cyan-100 border-cyan-300/25"},H3={success:{frame:"border-cyan-200/15 bg-white/[0.04] text-slate-100",dot:"bg-cyan-200/80 shadow-[0_0_14px_rgba(125,211,252,0.65)]"},client_error:{frame:"border-amber-300/25 bg-amber-300/[0.08] text-amber-100",dot:"bg-amber-200 shadow-[0_0_14px_rgba(252,211,77,0.8)]"},server_error:{frame:"border-rose-300/25 bg-rose-300/[0.08] text-rose-100",dot:"bg-rose-300 shadow-[0_0_14px_rgba(253,164,175,0.8)]"},pending:{frame:"border-cyan-300/25 bg-cyan-300/[0.08] text-cyan-100",dot:"bg-cyan-200 shadow-[0_0_14px_rgba(103,232,249,0.8)]"}},vr="border border-input bg-background hover:bg-accent hover:text-accent-foreground size-8 text-muted-foreground shadow-none hover:text-cyan-100",kt="border border-border bg-muted/40 flex h-7 items-center gap-1 rounded-md px-2 text-xs";function yr(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Z3(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function V3(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 tu({trend:e}){if(e===null)return null;const t=e.direction==="up",n=t?Q1:q1,r=t?"+":"-";return s.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[s.jsx(n,{className:t?"size-3 text-cyan-300":"size-3 text-rose-400"}),s.jsxs("span",{className:"font-mono",children:[r,$e(e.delta)]})]})}const q3=p.memo(function({log:e,displayNumber:t,messageCount:n=null,toolCount:r=null,expanded:o,onToggle:i,cacheTrend:a=null,activeTab:l,tabActions:c,onReplay:u,slowResponseThresholdSeconds:d=0,showClientMetadata:f=!0,timeDisplayFormat:m}){const h=Sk(e.responseStatus),v=e.elapsedMs!==null&&d>0&&e.elapsedMs>d*1e3,g=e.inputTokens!==null||e.outputTokens!==null,x=e.firstChunkMs??null,b=e.tokensPerSecond??null,y=x===null?null:yr(x),_=b===null||b<=0?null:Z3(b),j=e.warnings?.length??0,S=e.clientPid!==null&&e.clientPid!==void 0,E=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="",C=e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd!=="",R=H3[h],z=V3(h,e.responseStatus),O=h!=="success"||e.responseStatus!==200,q=e.streaming&&y===null&&_===null;return s.jsx(Je,{children:s.jsxs("div",{id:`log-${e.id}`,role:"button",tabIndex:0,"data-nav-id":`log-${e.id}`,"data-nav-action":o?"collapse":"expand",className:ae("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]",o?"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.10)]":"bg-transparent hover:bg-white/[0.035]","select-none before:pointer-events-none before:absolute before:inset-x-3 before:top-0 before:h-px before:bg-white/12","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),onClick:i,onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),i())},children:[s.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsxs("span",{className:ae("border border-border bg-muted/40 inline-flex h-8 shrink-0 items-center gap-2 rounded-md px-2 font-mono",R.frame),children:[s.jsx("span",{className:ae("size-1.5 rounded-full",R.dot),"aria-hidden":"true"}),s.jsxs("span",{className:"text-xs font-semibold tabular-nums",title:`Log ID ${String(e.id)}`,children:["#",t]})]}),s.jsxs("span",{className:"border border-border bg-muted/40 flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-xs text-muted-foreground",children:[s.jsx(Ht,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:Ui(e.timestamp,m)})]}),O&&s.jsxs(Be,{variant:"outline",className:ae("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)]",W3[h]),children:[h==="success"?s.jsx(Ge,{className:"size-3","aria-label":"Success"}):h==="server_error"?s.jsx(C2,{className:"size-3","aria-label":"Server error"}):h==="client_error"?s.jsx(rn,{className:"size-3","aria-label":"Client error"}):s.jsx(ft,{className:"size-3 animate-spin","aria-label":"Pending"}),z]}),j>0&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs(Be,{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:[s.jsx(rn,{className:"size-3","aria-label":"Tool schema warnings"}),j]})}),s.jsx(Le,{children:j===1?"1 tool schema warning":`${j} tool schema warnings`})]}),e.elapsedMs!==null&&(v?s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs("span",{className:ae(kt,"shrink-0 border-amber-300/25 text-amber-200"),children:[s.jsx(Ht,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:yr(e.elapsedMs)}),s.jsx(rn,{className:"size-3","aria-label":"Slow response"})]})}),s.jsxs(Le,{children:["Slow response: ",yr(e.elapsedMs)," exceeds"," ",yr(d*1e3)]})]}):s.jsxs("span",{className:ae(kt,"shrink-0 text-muted-foreground"),children:[s.jsx(Ht,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:yr(e.elapsedMs)})]})),e.streaming&&y!==null&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs("span",{className:ae(kt,"shrink-0 text-cyan-300"),children:[s.jsx(ic,{className:"size-3"}),s.jsxs("span",{className:"font-mono tabular-nums",children:["first ",y]})]})}),s.jsx(Le,{children:"Time to first streaming chunk"})]}),e.streaming&&_!==null&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs("span",{className:ae(kt,"shrink-0 text-cyan-300"),children:[s.jsx(qa,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:_})]})}),s.jsx(Le,{children:"Output token throughput after first chunk"})]}),g&&s.jsxs("span",{className:ae(kt,"min-w-0 sm:shrink-0"),children:[s.jsx(Pr,{className:"size-3 text-muted-foreground"}),s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 font-mono tabular-nums",children:[s.jsxs("span",{className:ae("whitespace-nowrap",e.inputTokens!==null?"text-blue-400":"text-muted-foreground"),children:["IN ",e.inputTokens!==null?$e(e.inputTokens):"n/a"]}),s.jsx("span",{className:"text-muted-foreground",children:"/"}),s.jsxs("span",{className:ae("whitespace-nowrap",e.outputTokens!==null?"text-amber-400":"text-muted-foreground"),children:["OUT ",e.outputTokens!==null?$e(e.outputTokens):"n/a"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&s.jsxs("span",{className:ae(kt,"shrink-0"),children:[s.jsx(tu,{trend:a?.creation??null}),s.jsxs("span",{className:"font-mono tabular-nums text-cyan-300",children:["KV Cache +",$e(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&s.jsxs("span",{className:ae(kt,"shrink-0"),children:[s.jsx(tu,{trend:a?.read??null}),s.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",$e(e.cacheReadInputTokens)]})]}),n!==null&&s.jsxs("span",{className:ae(kt,"shrink-0 text-muted-foreground"),children:[s.jsx(wo,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:n})]}),r!==null&&s.jsxs("span",{className:ae(kt,"shrink-0 text-muted-foreground"),children:[s.jsx(Ur,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:r})]}),e.origin!==null&&s.jsxs("span",{className:ae(kt,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[s.jsx(rf,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),f&&(S||E)&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs("span",{className:ae(kt,"hidden shrink-0 text-purple-300 xl:flex"),children:[s.jsx(Qy,{className:"size-3"}),E?s.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):s.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]})}),s.jsx(Le,{children:C?`PID: ${e.clientPid??"?"} CWD: ${e.clientCwd}`:`Process ID: ${e.clientPid??"?"}`})]}),q&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx(ic,{className:"size-3 text-muted-foreground/60 shrink-0"})}),s.jsx(Le,{children:"Request used SSE streaming"})]})]}),s.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[o&&s.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",onClick:T=>T.stopPropagation(),onKeyDown:T=>T.stopPropagation(),children:[c!==void 0&&l!==void 0&&(()=>{const T=c[l];return T===void 0?null:s.jsxs(s.Fragment,{children:[T.expansion!==null&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx(Se,{variant:"outline",size:"icon",className:vr,onClick:T.expansion.onToggle,disabled:T.expansion.isPending,"aria-pressed":T.expansion.isExpanded,"aria-label":T.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:T.expansion.isExpanded?s.jsx(by,{className:"size-3.5"}):s.jsx(fy,{className:"size-3.5"})})}),s.jsx(Le,{children:T.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),T.diffWithRaw!==void 0&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx(Se,{variant:"outline",size:"icon",className:ae(vr,T.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:T.diffWithRaw.onToggle,"aria-pressed":T.diffWithRaw.active,"aria-label":T.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:s.jsx(Gy,{className:"size-3.5"})})}),s.jsx(Le,{children:T.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),T.diffWithPrevious!==void 0&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx(Se,{variant:"outline",size:"icon",className:vr,onClick:T.diffWithPrevious,"aria-label":"Diff with previous",children:s.jsx(d2,{className:"size-3.5"})})}),s.jsx(Le,{children:"Compare this request with the immediately preceding one"})]}),T.copyText!==null&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx(Se,{variant:"outline",size:"icon",className:vr,onClick:T.onCopy,"aria-label":T.copyCopied?"Copied":T.copyLabel,children:T.copyCopied?s.jsx(Ge,{className:"size-3.5 text-cyan-300"}):s.jsx(Nt,{className:"size-3.5"})})}),s.jsx(Le,{children:T.copyCopied?"Copied to clipboard":T.copyLabel})]})]})})(),u!==void 0&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx(Se,{variant:"outline",size:"icon",className:vr,onClick:u,"aria-label":"Replay request",children:s.jsx(I2,{className:"size-3.5"})})}),s.jsx(Le,{children:"Re-send this request to the provider"})]})]}),s.jsx("span",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex size-8 shrink-0 items-center justify-center rounded-md text-slate-200","aria-hidden":"true",children:o?s.jsx(st,{className:"size-4 shrink-0"}):s.jsx(bt,{className:"size-4 shrink-0"})})]})]})})});function K3({...e}){return s.jsx(Uj,{"data-slot":"collapsible",...e})}function oz({...e}){return s.jsx(cp,{"data-slot":"collapsible-trigger",...e})}function G3({...e}){return s.jsx(up,{"data-slot":"collapsible-content",...e})}function J3({className:e,children:t,...n}){return s.jsxs(PC,{"data-slot":"scroll-area",className:ae("relative overflow-hidden",e),...n,children:[s.jsx(OC,{"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}),s.jsx(Y3,{}),s.jsx(MC,{})]})}function Y3({className:e,orientation:t="vertical",...n}){return s.jsx(Vp,{"data-slot":"scroll-area-scrollbar",orientation:t,className:ae("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:s.jsx(Jp,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const cm={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},X3={file:"border-blue-400/20 bg-blue-400/5 text-blue-300",shell:"border-teal-400/20 bg-teal-400/5 text-teal-300",browser:"border-cyan-400/20 bg-cyan-400/5 text-cyan-300",web:"border-sky-400/20 bg-sky-400/5 text-sky-300",mcp:"border-violet-400/20 bg-violet-400/5 text-violet-300",code:"border-emerald-400/20 bg-emerald-400/5 text-emerald-300",other:"border-muted-foreground/20 bg-muted/30 text-muted-foreground"};function Q3({category:e}){switch(e){case"file":return s.jsx(t2,{className:"size-3.5"});case"shell":return s.jsx(Ka,{className:"size-3.5"});case"browser":return s.jsx(j2,{className:"size-3.5"});case"web":return s.jsx(rf,{className:"size-3.5"});case"mcp":return s.jsx(ry,{className:"size-3.5"});case"code":return s.jsx(Py,{className:"size-3.5"});case"other":return s.jsx(Uy,{className:"size-3.5"})}}function eT({names:e}){return e.length===0?null:s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"required"}),e.slice(0,4).map(t=>s.jsx(Be,{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&&s.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e.length-4]})]})}function tT({tool:e,called:t}){const[n,r]=p.useState(!1),o=Ut(e.name),i=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return s.jsx(K3,{open:n,onOpenChange:r,children:s.jsxs("div",{className:"border border-border bg-card shadow-sm rounded-[8px]",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",children:[s.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:()=>r(a=>!a),"aria-expanded":n,disabled:!i,children:[s.jsx(Q3,{category:e.category}),s.jsx("span",{className:"min-w-0 truncate font-mono text-xs font-semibold text-foreground/90",children:e.name}),t&&s.jsx(Be,{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"}),s.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:[e.parameterCount," params"]}),e.descriptionPreview!==null&&s.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground md:inline",children:e.descriptionPreview}),s.jsx("span",{className:"flex-1"}),i&&(n?s.jsx(st,{className:"size-3.5 shrink-0 text-muted-foreground"}):s.jsx(bt,{className:"size-3.5 shrink-0 text-muted-foreground"}))]}),s.jsx("button",{type:"button",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground 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?s.jsx(Ge,{className:"size-3.5 text-emerald-400"}):s.jsx(Nt,{className:"size-3.5"})})]}),s.jsx(G3,{children:n&&s.jsxs("div",{className:"space-y-2 border-t border-white/10 bg-white/[0.025] px-2.5 py-2",children:[e.description!==null&&s.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e.description}),s.jsx(eT,{names:e.requiredParameters}),e.schema!==null&&s.jsx(J3,{className:"border border-border bg-card shadow-sm max-h-64 rounded-[8px] p-2",children:s.jsx(p.Suspense,{fallback:s.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:s.jsx(aa,{data:eo(e.schema),defaultExpandDepth:0})})})]})})]})})}function nT(e,t){return t.length===0?!0:`${e.name} ${e.description??""} ${cm[e.category]}`.toLowerCase().trim().includes(t)}const rT=p.memo(function({summary:t,calledToolNames:n}){const[r,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=>nT(m,c)),[c,t]);if(t===null)return null;const d=t.tools.slice(0,6),f=t.tools.length-d.length;return s.jsxs("section",{className:"border border-border bg-card shadow-sm mb-3 overflow-hidden rounded-[8px]",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx(Ur,{className:"size-4 shrink-0 text-sky-300/80"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Request Tools"}),s.jsx(Be,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",children:t.tools.length}),t.toolChoiceLabel!==null&&s.jsxs(Be,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px] text-muted-foreground",children:["tool_choice: ",t.toolChoiceLabel]})]}),s.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap gap-1",children:t.categories.map(m=>s.jsxs(Be,{variant:"outline",className:ae("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",X3[m.category]),children:[m.count," ",cm[m.category]]},m.category))})]})]}),s.jsxs(Se,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-cyan-100",onClick:()=>o(m=>!m),"aria-expanded":r,children:[r?s.jsx(st,{className:"size-3.5"}):s.jsx(bt,{className:"size-3.5"}),r?"Hide":"Show"]})]}),s.jsxs("div",{className:"flex min-w-0 flex-wrap gap-1.5 border-t border-white/10 bg-white/[0.025] px-3 py-2",children:[d.map(m=>s.jsx(Be,{variant:"outline",className:ae("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&&s.jsxs("span",{className:"font-mono text-[10px] leading-5 text-muted-foreground",children:["+",f]})]}),r&&s.jsxs("div",{className:"space-y-2 border-t border-white/10 bg-black/10 px-3 py-3",children:[s.jsxs("label",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex h-8 items-center gap-2 rounded-md px-2 text-xs",children:[s.jsx(B2,{className:"size-3.5 shrink-0 text-muted-foreground"}),s.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"})]}),s.jsx("div",{className:"grid gap-1.5",children:u.length>0?u.map(m=>s.jsx(tT,{tool:m,called:l.has(m.name)},m.name)):s.jsx("p",{className:"py-2 text-xs text-muted-foreground",children:"No matching tools"})})]})]})});function nu(e,t,n){return e==="anthropic"&&t==="full"&&n}function sT(e,t){return e==="full"&&t}function oT(e,t,n,r){return e==="anthropic"&&t==="full"&&n&&r}const iT=["file","shell","browser","web","mcp","code","other"];function ua(e){const t=e.replace(/\s+/g," ").trim();return t.length<=120?t:`${t.slice(0,119)}...`}function um(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?ua(t.slice(0,n+1)):ua(t)}function aT(e,t){return`${e} ${t??""}`.toLowerCase()}function $n(e,t){return t.some(n=>e.includes(n))}function dm(e,t){const n=aT(e,t);return e.startsWith("mcp__")||e.startsWith("inspector_")||$n(n,[" mcp","model context protocol"])?"mcp":$n(n,["bash","shell","terminal","command","powershell","exec","process"])?"shell":$n(n,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":$n(n,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":$n(n,["web","search","http","url","fetch"])?"web":$n(n,["code","typescript","javascript","python","repl"])?"code":"other"}function fm(e){const t=ke(e,"properties");return t===null||typeof t!="object"||Array.isArray(t)?[]:Object.keys(t).sort((n,r)=>n.localeCompare(r))}function pm(e){const t=ke(e,"required");if(!Array.isArray(t))return[];const n=[];for(const r of t)typeof r=="string"&&r.length>0&&n.push(r);return n.sort((r,o)=>r.localeCompare(o))}function lT(e){const t=ke(e,"name");if(typeof t!="string"||t.length===0)return null;const n=ke(e,"description"),r=ke(e,"input_schema")??null,o=typeof n=="string"?n:null;return{name:t,description:o,descriptionPreview:um(o),category:dm(t,o),parameterCount:fm(r).length,requiredParameters:pm(r),schema:r}}function cT(e){const t=ke(e,"function"),n=ke(e,"type");if(t===void 0&&n!=="function")return null;const r=ke(t,"name")??ke(e,"name");if(typeof r!="string"||r.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:r,description:a,descriptionPreview:um(a),category:dm(r,a),parameterCount:fm(i).length,requiredParameters:pm(i),schema:i}}function uT(e){const t=cT(e);return t!==null?t:lT(e)}function dT(e){if(e==null)return null;if(typeof e=="string")return e;const t=ke(e,"type"),n=ke(e,"name"),r=ke(ke(e,"function"),"name");if(typeof t=="string"&&typeof r=="string"&&r.length>0)return`${t}: ${r}`;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:ua(o)}function fT(e){const t=new Map;for(const n of e)t.set(n.category,(t.get(n.category)??0)+1);return iT.flatMap(n=>{const r=t.get(n)??0;return r>0?[{category:n,count:r}]:[]})}function pT(e){const t=ke(e,"tools");if(!Array.isArray(t)||t.length===0)return null;const n=[];for(const r of t){const o=uT(r);o!==null&&n.push(o)}return n.length===0?null:{tools:n,toolChoiceLabel:dT(ke(e,"tool_choice")),categories:fT(n)}}function Fn(){return s.jsx("div",{className:"h-1","aria-hidden":"true"})}function hT(e,t){switch(e){case"anatomy":return t===null?"request":"anatomy";case"request":return"request"}}const mT=15e3,gT=15e3,xT=256*1024,to=1024*1024,xn="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:border-white/10 hover:bg-white/[0.045] hover:text-foreground data-[state=active]:border-cyan-200/25 data-[state=active]:bg-cyan-300/[0.08] data-[state=active]:text-cyan-100 data-[state=active]:shadow-none";function ms(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function no(e){return e??0}function hm(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function mm(e){return hm(e)?no(e.rawRequestBodyBytes)>to||no(e.responseTextBytes)>to:!1}function bT(e){return hm(e)&&!mm(e)}function vT(e){return e instanceof za?"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 gs({status:e,error:t,footprint:n,onRetry:r}){switch(e){case"idle":return null;case"loading":return s.jsx($r,{tone:"loading",title:"Loading full bodies",children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(ft,{className:"size-3.5 shrink-0 animate-spin text-cyan-200"}),s.jsx("span",{children:"Loading full request and response bodies from the log store."})]}),n!==null&&s.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 s.jsx($r,{tone:"warning",title:t?.title??"Full bodies could not be loaded",children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx("span",{children:t?.detail??"Compact metadata is still available."}),s.jsxs(Se,{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:r,children:[s.jsx(zr,{className:"size-3"}),"Retry"]})]})})}}function ru(e,t){return e?t.text!==""?t.text:t.status==="success"?"":null:null}function bn({children:e,className:t}){return s.jsx("div",{className:ae("border border-border bg-card shadow-sm inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",t),children:e})}function Is({children:e}){return s.jsx("div",{className:"border border-border bg-muted/40 rounded-md border-dashed px-3 py-5 text-center text-xs italic text-muted-foreground",children:e})}function xs({children:e}){return s.jsx("pre",{className:"border border-border bg-card shadow-sm 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 yT={loading:"border-cyan-400/25 bg-cyan-400/[0.06] text-cyan-100",warning:"border-amber-400/25 bg-amber-400/[0.08] text-amber-100",danger:"border-rose-400/25 bg-rose-400/[0.08] text-rose-100"};function $r({tone:e,title:t,children:n}){return s.jsxs("div",{className:ae("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",yT[e]),children:[t!==void 0&&s.jsx("div",{className:"mb-1 font-semibold",children:t}),s.jsx("div",{className:"leading-relaxed text-muted-foreground",children:n})]})}function bs({label:e,state:t,expectedBytes:n,onLoadMore:r}){const o=t.totalBytes??n,i=o===null?qn(t.offset):`${qn(t.offset)} / ${qn(o)}`,a=t.status!=="loading"&&t.hasMore,l=t.status==="failed"?"Retry":"Load more";return s.jsx($r,{tone:t.status==="failed"?"warning":"loading",title:`${e} body preview`,children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("span",{children:[t.status==="idle"&&o!==null?`${e} body is ${qn(o)}. Loading the first preview chunk.`:`Loaded ${i}.`,t.status==="failed"&&t.error!==null&&` ${t.error}`]}),a&&s.jsx(Se,{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:r,children:l})]})})}function su({headers:e,emptyLabel:t}){const n=e===void 0?[]:Object.entries(e).sort(([r],[o])=>r.localeCompare(o));return n.length===0?s.jsx(Is,{children:t}):s.jsx("div",{className:"border border-border bg-card shadow-sm overflow-hidden rounded-[8px] font-mono text-xs",children:n.map(([r,o])=>s.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(140px,0.32fr)_minmax(0,1fr)] border-b border-white/10 last:border-b-0",children:[s.jsx("div",{className:"min-w-0 truncate border-r border-white/10 bg-white/[0.035] px-2.5 py-2 font-semibold text-cyan-200",children:r}),s.jsx("div",{className:"min-w-0 truncate px-2.5 py-2 text-muted-foreground",title:o,children:o})]},r))})}function wT({active:e,onClick:t}){return s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs(Se,{variant:e?"default":"outline",size:"sm",className:ae("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:[s.jsx(l2,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),s.jsx(Le,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const kT=p.memo(function({rawBody:e,displayedBody:t,emptyLabel:n}){const r=p.useMemo(()=>z3(e,t),[e,t]);return s.jsx(lm,{result:r,emptyLabel:n})}),_T=p.memo(function({rawHeaders:e,headers:t,emptyLabel:n}){const r=p.useMemo(()=>I3(e,t),[e,t]);return s.jsx(lm,{result:r,emptyLabel:n})}),jT=p.memo(function({log:e,displayNumber:t,viewMode:n="simple",strip:r,slowResponseThresholdSeconds:o,timeDisplayFormat:i,cacheTrend:a=null,onCompareWithPrevious:l,showClientMetadata:c=!0}){const[u,d]=p.useState(!1),[f,m]=p.useState(!1),[h,v]=p.useState(!1),[g,x]=p.useState(!1),[b,y]=p.useState("request"),[_,j]=p.useState(null),[S,E]=p.useState(null),[C,R]=p.useState("idle"),[z,O]=p.useState(null),[q,T]=p.useState(0),[D,k]=p.useState(()=>ms(e.rawRequestBodyBytes??null)),[$,X]=p.useState(()=>ms(e.responseTextBytes??null)),B=p.useRef(null),F=p.useRef(e.id),Z=p.useRef(!1),J=S??e,H=S===null&&mm(e),W=p.useMemo(()=>S3(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),ce=ru(H,D),se=ru(H,$),oe=J.rawRequestBody??ce,_e=J.responseText??se,ie=J.rawRequestBody===null&&ce!==null,ge=J.responseText===null&&se!==null,he=!ie||D.hasMore===!1&&no(D.totalBytes)<=to,xe=!ge||$.hasMore===!1&&no($.totalBytes)<=to,te=Lr(J),ue=Xh(te),be=p.useMemo(()=>ue.analyzeRequest(J.rawRequestBody),[ue,J.rawRequestBody]),w=p.useMemo(()=>ue.analyzeResponse(J.responseText),[ue,J.responseText]),U=p.useMemo(()=>!r||te!=="anthropic"||J.rawRequestBody===null?null:c3(J.rawRequestBody).body,[J.rawRequestBody,te,r])??oe,I=hi(he?U:null),A=hi(b==="raw-request"&&he?oe:null),L=hi(b==="raw"&&xe?_e:null),ne=p.useMemo(()=>J.headers&&Object.keys(J.headers).length>0?JSON.stringify(J.headers,null,2):null,[J.headers]),re=p.useMemo(()=>J.rawHeaders&&Object.keys(J.rawHeaders).length>0?JSON.stringify(J.rawHeaders,null,2):null,[J.rawHeaders]),V=Ut(U),le=Ut(oe),P=Ut(ne),M=Ut(re),Q=Ut(_e),fe=p.useMemo(()=>({request:{copyLabel:ie?"Copy loaded request preview":"Copy request body",copyText:U,copyCopied:V.copied,onCopy:V.copy,expansion:he?{isExpanded:I.isExpanded,isPending:I.isPending,onToggle:I.toggle}:null,diffWithRaw:oT(te,n,r,J.rawRequestBody!==null)?{active:g,onToggle:()=>x(!g)}:void 0,diffWithPrevious:l===void 0?void 0:()=>{l(J)}},"raw-request":{copyLabel:ie?"Copy loaded raw request preview":"Copy raw request",copyText:oe,copyCopied:le.copied,onCopy:le.copy,expansion:he?{isExpanded:A.isExpanded,isPending:A.isPending,onToggle:A.toggle}:null},headers:{copyLabel:"Copy headers",copyText:ne,copyCopied:P.copied,onCopy:P.copy,expansion:null},"raw-headers":{copyLabel:"Copy raw headers",copyText:re,copyCopied:M.copied,onCopy:M.copy,expansion:null},raw:{copyLabel:ge?"Copy loaded response preview":"Copy response",copyText:_e,copyCopied:Q.copied,onCopy:Q.copy,expansion:xe?{isExpanded:L.isExpanded,isPending:L.isPending,onToggle:L.toggle}:null}}),[U,ie,he,V,I,g,J,J.rawRequestBody,oe,le,A,ne,P,re,M,J.responseText,ge,xe,_e,Q,L,te,n,r,l]),de=p.useMemo(()=>I.parsedData!==null?ue.anatomySegments(I.parsedData):null,[ue,I.parsedData]),Pe=p.useMemo(()=>pT(I.parsedData),[I.parsedData]),Ue=J.warnings??[],Ne=p.useMemo(()=>{if(de!==null)return new Set(de.map(Re=>Re.path))},[de]),pt=j3({containerRef:B,setExpandToPath:j,ensureTabActive:()=>{b!=="request"&&y("request")}}),ze=p.useCallback((Re,Et)=>{const Ft=Re==="request"?k:X;Ft(at=>({...at,status:"loading",error:null}));const qo=new URLSearchParams({part:Re,offset:String(Et),limit:String(xT)});tr(`/api/logs/${String(e.id)}/body?${qo.toString()}`,Vv,gT).then(at=>{F.current===e.id&&Ft(zn=>({status:"success",text:at.offset===0?at.text:`${zn.text}${at.text}`,offset:at.nextOffset??at.totalBytes,totalBytes:at.totalBytes,hasMore:at.hasMore,error:null}))}).catch(at=>{F.current===e.id&&Ft(zn=>({...zn,status:"failed",error:vT(at)}))})},[e.id]),$t=p.useCallback(()=>{Z.current||(E(null),R("idle"),O(null),T(Re=>Re+1))},[]),hr=p.useCallback(()=>{const Re=!u;Re&&y(de!==null?"anatomy":"request"),d(Re)},[de,u]);return p.useEffect(()=>{F.current=e.id,Z.current=!1,E(null),R("idle"),O(null),T(0),k(ms(e.rawRequestBodyBytes??null)),X(ms(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),p.useEffect(()=>{if(!u||!bT(e)||S!==null||Z.current)return;let Re=!1;return Z.current=!0,R("loading"),O(null),tr(`/api/logs/${String(e.id)}`,Rr,mT).then(Et=>{Re||(Z.current=!1,E(Et),R("idle"),O(null))}).catch(Et=>{Re||(Z.current=!1,R("failed"),O(C3(Et)))}),()=>{Re=!0,Z.current=!1}},[u,S,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,q]),p.useEffect(()=>{u&&H&&D.status==="idle"&&(b!=="request"&&b!=="raw-request"&&b!=="anatomy"||ze("request",0))},[b,u,ze,D.status,H]),p.useEffect(()=>{u&&H&&$.status==="idle"&&(b!=="parsed"&&b!=="raw"||ze("response",0))},[b,u,ze,$.status,H]),p.useEffect(()=>{const Re=Et=>{const Ft=Zo(Et);Ft!==null&&Ft.logId===e.id&&(d(!0),y(hT(Ft.tab,de)))};return window.addEventListener(qt,Re),()=>{window.removeEventListener(qt,Re)}},[de,e.id]),s.jsxs(Je,{children:[s.jsxs("div",{className:ae("border border-border bg-card shadow-sm relative mb-2 overflow-hidden rounded-[8px] transition-[background-color,border-color,box-shadow]",u?"border-cyan-200/25 shadow-[0_24px_80px_rgba(0,0,0,0.36),0_0_0_1px_rgba(103,232,249,0.05),inset_0_1px_0_rgba(255,255,255,0.14)]":"hover:border-cyan-200/18"),children:[s.jsx("div",{className:ae("pointer-events-none absolute inset-y-3 left-1 w-px rounded-full",u?"bg-cyan-200/55 shadow-[0_0_20px_rgba(103,232,249,0.26)]":"bg-white/12"),"aria-hidden":"true"}),s.jsx("div",{className:"pointer-events-none absolute inset-x-3 top-0 h-px bg-gradient-to-r from-transparent via-white/15 to-transparent","aria-hidden":"true"}),s.jsx(q3,{log:J,displayNumber:t,messageCount:be.messageCount,toolCount:be.toolCount,expanded:u,onToggle:hr,cacheTrend:a,slowResponseThresholdSeconds:o,showClientMetadata:c,timeDisplayFormat:i,activeTab:b,tabActions:fe,onReplay:l===void 0?void 0:()=>{m(!0)}}),u&&s.jsxs("div",{className:"relative border-t border-white/10 bg-black/[0.18] pt-2",onClick:Re=>Re.stopPropagation(),onKeyDown:Re=>Re.stopPropagation(),children:[s.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"}),s.jsxs(rm,{value:b,onValueChange:y,className:"gap-2",children:[s.jsxs(sm,{variant:"line",className:"border border-border bg-muted/40 inspector-scrollbar relative mx-3 h-auto w-[calc(100%-1.5rem)] justify-start overflow-x-auto rounded-[8px] p-1",children:[n==="full"&&s.jsx(ht,{className:xn,value:"raw-headers",children:"Raw Headers"}),n==="full"&&s.jsx(ht,{className:xn,value:"headers",children:"Headers"}),de!==null&&s.jsx(ht,{className:xn,value:"anatomy",children:"Context"}),nu(te,n,r)&&s.jsx(ht,{className:xn,value:"raw-request",children:"Raw Request"}),s.jsx(ht,{className:xn,value:"request",children:"Request"}),n==="full"&&s.jsx(ht,{className:xn,value:"raw",children:"Raw Response"}),s.jsx(ht,{className:xn,value:"parsed",children:"Response"})]}),nu(te,n,r)&&s.jsx(mt,{value:"raw-request",children:b==="raw-request"&&s.jsxs(bn,{children:[s.jsx(gs,{status:C,error:z,footprint:W,onRetry:$t}),H&&s.jsx(bs,{label:"Request",state:D,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ze("request",D.offset)}),oe===null?s.jsx(Is,{children:H?"Request preview is loading":"No request body"}):A.parsedData!==null?s.jsx(p.Suspense,{fallback:s.jsx(Fn,{}),children:s.jsx(aa,{data:A.parsedData,bulkDepth:A.bulkDepth,bulkRevision:A.bulkRevision})}):s.jsx(xs,{children:oe})]})}),s.jsx(mt,{value:"request",children:b==="request"&&s.jsxs(bn,{children:[s.jsx(gs,{status:C,error:z,footprint:W,onRetry:$t}),H&&s.jsx(bs,{label:"Request",state:D,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ze("request",D.offset)}),Ue.length>0&&s.jsxs($r,{tone:"warning",children:[s.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[s.jsx(rn,{className:"size-3.5"}),"Tool schema warnings"]}),s.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:Ue.map(Re=>s.jsx("li",{children:Re},Re))})]}),s.jsx(rT,{summary:Pe,calledToolNames:w.toolNames??[]}),g?s.jsx(kT,{rawBody:J.rawRequestBody,displayedBody:U,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):s.jsx("div",{ref:B,children:U===null?s.jsx(Is,{children:H?"Request preview is loading":"No request body"}):I.parsedData!==null?s.jsx(p.Suspense,{fallback:s.jsx(Fn,{}),children:s.jsx(aa,{data:I.parsedData,bulkDepth:I.bulkDepth,bulkRevision:I.bulkRevision,anatomyPaths:Ne,expandToPath:_})}):s.jsx(xs,{children:U})})]})}),de!==null&&s.jsx(mt,{value:"anatomy",children:b==="anatomy"&&s.jsx(bn,{className:"p-0",children:s.jsx(p.Suspense,{fallback:s.jsx(Fn,{}),children:s.jsx(b3,{parsed:I.parsedData,inputTokens:J.inputTokens??null,model:J.model,segments:de,onSegmentActivate:pt})})})}),n==="full"&&s.jsx(mt,{value:"headers",children:b==="headers"&&s.jsxs(bn,{children:[s.jsx("div",{className:"flex justify-end gap-2 mb-2",children:sT(n,J.rawHeaders!==void 0&&Object.keys(J.rawHeaders).length>0)&&s.jsx(wT,{active:h,onClick:Re=>{Re.stopPropagation(),v(!h)}})}),h?s.jsx(_T,{rawHeaders:J.rawHeaders,headers:J.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):s.jsx(su,{headers:J.headers,emptyLabel:"No headers captured"})]})}),n==="full"&&s.jsx(mt,{value:"raw-headers",children:b==="raw-headers"&&s.jsx(bn,{children:s.jsx(su,{headers:J.rawHeaders,emptyLabel:"No raw headers captured"})})}),s.jsx(mt,{value:"raw",children:b==="raw"&&s.jsxs(bn,{className:"space-y-3",children:[s.jsx(gs,{status:C,error:z,footprint:W,onRetry:$t}),H&&s.jsx(bs,{label:"Response",state:$,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ze("response",$.offset)}),J.error!==void 0&&J.error!==null&&s.jsx($r,{tone:"danger",title:"SSE Error",children:s.jsx("span",{className:"font-mono",children:J.error})}),_e!==null&&xe?s.jsx(p.Suspense,{fallback:s.jsx(Fn,{}),children:s.jsx(w3,{text:_e,defaultExpandDepth:0,bulkDepth:L.bulkDepth,bulkRevision:L.bulkRevision})}):_e!==null?s.jsx(xs,{children:_e}):s.jsx(Is,{children:H?"Response preview is loading":"No response"}),J.streaming===!0&&s.jsx(p.Suspense,{fallback:s.jsx(Fn,{}),children:s.jsx(y3,{logId:J.id,truncated:J.streamingChunksPath!==null})})]})}),s.jsx(mt,{value:"parsed",children:b==="parsed"&&s.jsxs(bn,{children:[s.jsx(gs,{status:C,error:z,footprint:W,onRetry:$t}),H&&s.jsx(bs,{label:"Response",state:$,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ze("response",$.offset)}),ge&&!xe?s.jsx(xs,{children:_e}):s.jsx(p.Suspense,{fallback:s.jsx(Fn,{}),children:s.jsx(v3,{responseText:_e,responseStatus:J.responseStatus,streaming:J.streaming,inputTokens:J.inputTokens,outputTokens:J.outputTokens,cacheCreationInputTokens:J.cacheCreationInputTokens,cacheReadInputTokens:J.cacheReadInputTokens,apiFormat:te,error:J.error})})]})})]})]})]}),s.jsx(p.Suspense,{fallback:null,children:s.jsx(x3,{log:J,displayNumber:t,open:f,onOpenChange:m})})]})});function ST(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 CT({isFusedBoundary:e,isBoundary:t,isTurnStart:n,isRunning:r}){return e?"fused":t?"end":n?"start":r?"running":"idle"}function NT(e,t){const n="inline-flex size-3.5 items-center justify-center rounded-full border transition-colors",r=t?"cursor-pointer hover:border-cyan-200/70 hover:bg-cyan-300/20":"";switch(e){case"start":return ae(n,r,"border-cyan-300/50 bg-cyan-300/12 text-cyan-200");case"end":return ae(n,r,"border-amber-300/55 bg-amber-300/12 text-amber-200");case"fused":return ae(n,r,"border-slate-200/50 bg-slate-200/10 text-slate-100 ring-2 ring-cyan-300/15");case"running":return ae(n,r,"border-amber-300/45 bg-amber-300/10 text-amber-200 ring-2 ring-amber-300/10");case"idle":return ae(n,r,"border-muted-foreground/25 bg-muted/30 text-muted-foreground/60")}}function TT(e){switch(e){case"running":return"size-1.5 rounded-full bg-current animate-pulse";case"idle":return"size-1 rounded-full bg-current opacity-55";case"start":case"end":case"fused":return"size-1.5 rounded-full bg-current"}}function ET(e,t){switch(e){case"start":return"Start of turn";case"end":return ST(t);case"fused":return"Single-request turn";case"running":return"Processing";case"idle":return"Request in turn"}}function AT({stopReason:e,isPending:t,isFirst:n,isTurnStart:r,isOnlyEntry:o=!1,collapsible:i=!1,onToggle:a}){const l=Ja(e),d=CT({isFusedBoundary:o&&r&&l,isBoundary:l,isTurnStart:r,isRunning:t&&!l}),f=i&&a!==void 0,m=v=>{!f||a===void 0||(v.stopPropagation(),a())},h=v=>{!f||a===void 0||v.key!=="Enter"&&v.key!==" "||(v.preventDefault(),a())};return s.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[s.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!n&&s.jsx("div",{className:"w-0.5 bg-muted-foreground/30 h-full"})}),s.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:ET(d,e),className:NT(d,f),onClick:m,onKeyDown:h,children:s.jsx("span",{className:TT(d)})}),s.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!l&&s.jsx("div",{className:ae("w-0.5 h-full",t?"border-dashed bg-transparent border-l-2 border-muted-foreground/20":"bg-muted-foreground/30")})})]})}function RT({event:e}){const t=Ut(e.argumentsText),n=e.argumentsText!==null;return s.jsxs("div",{className:"group/tool-trace flex min-w-0 items-center gap-2 rounded-md border border-border/70 bg-muted/20 px-2.5 py-1.5 text-xs",children:[s.jsx(Ur,{className:"size-3.5 shrink-0 text-sky-400/70"}),s.jsx("span",{className:"font-mono font-semibold text-foreground/80",children:e.name}),e.argumentsPreview!==null&&s.jsxs(s.Fragment,{children:[s.jsx(bt,{className:"size-3 shrink-0 text-muted-foreground/60"}),s.jsx("span",{className:"min-w-0 truncate font-mono text-muted-foreground",children:e.argumentsPreview})]}),n&&s.jsx("button",{type:"button",className:"ml-auto inline-flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground opacity-0 transition-opacity hover:bg-background/80 hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover/tool-trace:opacity-100 group-focus-within/tool-trace:opacity-100",onClick:t.copy,"aria-label":t.copied?"Copied tool arguments":"Copy tool arguments",title:t.copied?"Copied tool arguments":"Copy tool arguments",children:t.copied?s.jsx(Ge,{className:"size-3.5"}):s.jsx(Nt,{className:"size-3.5"})})]},e.id)}function IT({events:e}){return e.length===0?null:s.jsx("div",{className:"mx-3 mb-2 grid gap-1.5",children:e.map(t=>s.jsx(RT,{event:t},t.id))})}const ou=180,gi=new WeakMap;function zT(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 PT(e,t,n){return e>1&&t&&!n}function da(e){const t=[];let n=[],r=0;for(let o=0;o<e.length;o+=1){const i=e[o];if(i===void 0)continue;n.push({log:i,stopReason:cf(i),sessionLogNumber:o+1});const a=n[n.length-1];a!==void 0&&Ja(a.stopReason)&&(t.push({entries:n,turnIndex:r}),n=[],r+=1)}return n.length>0&&t.push({entries:n,turnIndex:r}),t}function OT(e){const t=new Map;for(const n of e)for(let r=1;r<n.logs.length;r+=1){const o=n.logs[r],i=n.logs[r-1];if(o===void 0||i===void 0)continue;const a=Lr(o),l=Lr(i);a==="unknown"||a!==l||t.set(o.id,i)}return t}function gm(e){if(e===null)return null;try{const t=JSON.parse(e);return typeof t=="string"?JSON.parse(t):t}catch{return null}}function fa(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>ou?`${n.slice(0,ou-1)}...`:n}function pa(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 MT(e){const t=gm(e.responseText),n=ke(t,"content");if(!Array.isArray(n))return[];const r=[];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");r.push({id:`${String(e.id)}-anthropic-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"anthropic",name:a,argumentsText:pa(l),argumentsPreview:fa(l)})}return r}function LT(e){const t=gm(e.responseText),n=ke(t,"choices");if(!Array.isArray(n))return[];const r=[];for(const i of n){const a=ke(i,"message"),l=ke(a,"tool_calls");if(Array.isArray(l))for(const c of l){const u=ke(c,"function"),d=ke(u,"name");if(typeof d!="string"||d.length===0)continue;const f=ke(u,"arguments");r.push({id:`${String(e.id)}-openai-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"openai",name:d,argumentsText:pa(f),argumentsPreview:fa(f)})}}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");r.push({id:`${String(e.id)}-openai-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"openai",name:a,argumentsText:pa(l),argumentsPreview:fa(l)})}return r}function Al(e){const t=gi.get(e);if(t!==void 0&&t.apiFormat===e.apiFormat&&t.responseText===e.responseText)return t.events;const n=Lr(e);if(!zT(e,n)){const o=[];return gi.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:o}),o}let r;switch(n){case"anthropic":r=MT(e);break;case"openai":r=LT(e);break;case"unknown":r=[];break}return gi.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:r}),r}function DT(e,t,n=0){let r=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&&(r+=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+=Al(h).length;return{llmCallCount:e.length,toolCallCount:m,failedCallCount:r,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 xi(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const $T=p.memo(function({entries:t,viewMode:n,strip:r,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,v=h!==null?Ja(h):!1,g=t[m]?.log.responseStatus===null,x=t.length===1,b=PT(t.length,v,g),[y,_]=p.useState(!1),j=p.useRef(!1);p.useEffect(()=>{b?v&&!j.current&&_(!0):_(!1),j.current=v},[b,v]),p.useEffect(()=>{const X=B=>{const F=Zo(B);F!==null&&t.some(Z=>Z.log.id===F.logId)&&b&&_(!1)};return window.addEventListener(qt,X),()=>{window.removeEventListener(qt,X)}},[b,t]),p.useEffect(()=>{if(d===void 0||!t.some(B=>B.log.id===d.logId))return;b&&_(!1);const X=window.setTimeout(()=>{Qs({logId:d.logId,tab:d.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(X)},[b,t,d]);const S=p.useCallback(()=>{b&&_(X=>!X)},[b]),E=p.useMemo(()=>{let X=0,B=0,F=null,Z=!1;for(const J of t)J.log.inputTokens!==null&&(X+=J.log.inputTokens,Z=!0),J.log.outputTokens!==null&&(B+=J.log.outputTokens,Z=!0),J.log.elapsedMs!==null&&(F=F===null?J.log.elapsedMs:Math.max(F,J.log.elapsedMs));return{totalInput:X,totalOutput:B,hasTokens:Z,maxElapsed:F}},[t,m]),C=c%2===0?"bg-white/[0.012]":"bg-cyan-300/[0.012]",R=E.maxElapsed!==null&&o>0&&E.maxElapsed>o*1e3,z=p.useMemo(()=>{const X=new Map;for(const B of t){const F=Al(B.log);F.length>0&&X.set(B.log.id,F)}return X},[t]),[O,q]=p.useState(0),T=p.useRef(null);p.useEffect(()=>{const X=T.current;if(!X)return;let B=0;const F=new ResizeObserver(()=>{window.cancelAnimationFrame(B),B=window.requestAnimationFrame(()=>q(Z=>Z+1))});return F.observe(X),()=>{F.disconnect(),window.cancelAnimationFrame(B)}},[]);const D=t[0]?.log.id??c,k=`Turn ${String(c+1)}`,$=p.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:y?"48px":"160px"}),[y]);return s.jsx("div",{ref:T,style:$,tabIndex:y?void 0:0,role:y?void 0:"group","aria-label":y?void 0:k,"data-nav-id":y?void 0:`turn-${String(D)}`,className:ae("rounded-[8px] border transition-[border-color,box-shadow]",g?"border-amber-300/15 shadow-[0_0_0_1px_rgba(252,211,77,0.04)]":"border-transparent",!y&&"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),children:y?s.jsxs("div",{"data-nav-id":`turn-collapsed-${String(D)}`,"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:X=>{(X.key==="Enter"||X.key===" ")&&(X.preventDefault(),S())},children:[s.jsx("div",{className:"w-5 shrink-0 flex items-start pt-1.5",children:s.jsx("span",{className:"text-[10px] text-muted-foreground/50 font-mono tabular-nums leading-none select-none",children:c+1})}),s.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-1.5 pb-1.5",children:[s.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),s.jsx("span",{className:"size-2 rounded-full border border-cyan-300/45 bg-cyan-300/20"}),s.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:s.jsx("div",{className:"w-px bg-muted-foreground/25 h-full"})}),s.jsx("span",{className:ae("size-2 rounded-full border",v?"border-amber-300/45 bg-amber-300/20":"border-muted-foreground/30 bg-muted/30")})]}),t.length>1&&s.jsxs("div",{className:ae("flex-1 min-w-0 mb-0.5 rounded-[8px] py-1.5 px-3 flex items-center gap-3 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]","border border-border bg-card shadow-sm transition-colors hover:border-cyan-200/20",C),children:[s.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:k}),s.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??"?"]}),s.jsxs("span",{className:"text-muted-foreground shrink-0",children:[t.length," request",t.length>1?"s":""]}),E.maxElapsed!==null&&s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs("span",{className:ae("flex items-center gap-1 shrink-0",R?"text-amber-400":"text-muted-foreground"),children:[s.jsx(Ht,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:xi(E.maxElapsed)}),R&&s.jsx(rn,{className:"size-3","aria-label":"Slow response"})]})}),s.jsx(Le,{children:R?`Slow response: ${xi(E.maxElapsed)} exceeds ${xi(o*1e3)}`:"Slowest request in this turn"})]})}),E.hasTokens&&s.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[s.jsx(Pr,{className:"size-3 text-muted-foreground"}),s.jsxs("span",{className:"font-mono tabular-nums",children:[s.jsxs("span",{className:"text-blue-400",children:["IN ",$e(E.totalInput)]})," / ",s.jsxs("span",{className:"text-amber-400",children:["OUT ",$e(E.totalOutput)]})]})]}),s.jsx("span",{className:"flex-1 min-w-0"}),s.jsx("span",{className:"border border-input bg-background inline-flex size-7 shrink-0 items-center justify-center rounded-md text-slate-200","aria-hidden":"true",children:s.jsx(bt,{className:"size-4 shrink-0"})})]})]}):t.map((X,B)=>{const{log:F,stopReason:Z}=X,J=B===0;return s.jsxs("div",{className:"flex items-stretch",children:[J?s.jsx("div",{className:"w-5 shrink-0 flex items-start pt-1.5",children:s.jsx("span",{className:"text-[10px] text-muted-foreground/50 font-mono tabular-nums leading-none select-none",children:c+1})}):s.jsx("div",{className:"w-5 shrink-0"}),s.jsx(AT,{stopReason:Z,isPending:F.responseStatus===null,isFirst:B===0,isTurnStart:J,isOnlyEntry:x,collapsible:b&&J,onToggle:S}),s.jsxs("div",{className:ae("flex-1 min-w-0 mb-0.5 rounded-[8px]",C),children:[s.jsx(jT,{log:F,displayNumber:X.sessionLogNumber,viewMode:n,strip:r,slowResponseThresholdSeconds:o,timeDisplayFormat:u,cacheTrend:i?.get(F.id)??null,showClientMetadata:f,onCompareWithPrevious:l.has(F.id)?a:void 0}),s.jsx(IT,{events:z.get(F.id)??[]})]})]},F.id)})})}),FT=24,BT=132,UT=8;function WT(e){return e>FT}function HT(e){const t=new Map;for(let n=0;n<e.length;n++){const r=e[n];if(r!==void 0)for(const o of r.entries)t.set(o.log.id,n)}return t}function xm(e,t,n){return s.jsx($T,{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 ZT(e){return WT(e.turnGroups.length)?s.jsx(VT,{...e}):s.jsx(s.Fragment,{children:e.turnGroups.map(t=>xm(t,e))})}function VT(e){const{turnGroups:t}=e,[n,r]=p.useState(null),o=s3({count:t.length,estimateSize:()=>BT,overscan:UT,getItemKey:a=>t[a]?.turnIndex??a}),i=p.useMemo(()=>HT(t),[t]);return p.useEffect(()=>{const a=l=>{const c=Zo(l);if(c===null||c.source==="virtualizer")return;const u=i.get(c.logId);u!==void 0&&(o.scrollToIndex(u,{align:"center"}),r(d=>({...c,turnIndex:u,nonce:d===null?1:d.nonce+1})))};return window.addEventListener(qt,a),()=>{window.removeEventListener(qt,a)}},[i,o]),s.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 s.jsx("div",{"data-index":a.index,ref:o.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${a.start}px)`},children:xm(l,e,c)},a.key)})})}const Rl=Te(["episode","procedure","preference","project-fact"]),qT=Te(["draft","promoted","failed"]),bm=G({source:Ce("agent-inspector"),sessionId:N(),logIds:me(K().int().positive()),project:N().nullable(),models:me(N())}),KT=G({redacted:Fe(),patterns:me(N())}),Yr=G({id:N(),type:Rl,title:N(),content:N(),tags:me(N()),source:Ce("agent-inspector"),sessionId:N(),logIds:me(K().int().positive()),evidence:bm,status:qT,createdAt:N(),updatedAt:N(),openClawMemoryId:N().nullable(),error:N().nullable(),redaction:KT});G({idempotencyKey:N(),type:Rl,title:N(),content:N(),tags:me(N()),source:Ce("agent-inspector"),project:N().nullable(),evidence:bm});const GT=G({id:N(),type:Rl.or(N()),title:N(),content:N(),score:K().nullable(),source:N().nullable(),project:N().nullable(),evidence:yn().optional()});G({results:me(GT),warning:N().nullable()});const JT=G({candidates:me(Yr)}),YT=G({candidate:Yr}),XT=G({error:N().optional(),candidate:Yr.optional()}),QT=G({candidate:Yr}),eE={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 ha(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function tE(e,t,n){return e===null||t===null?null:Ga(e,t,n)}function nE(e){return`${String(e)} candidate${e===1?"":"s"}`}function vm(e){return`log-${String(e)}`}function ym(e){const t=vm(e),n=document.getElementById(t);window.history.replaceState(null,"",`#${t}`),n instanceof HTMLElement&&(n.scrollIntoView({block:"center",behavior:"smooth"}),n.focus({preventScroll:!0}))}function rE(e){for(const t of e)if(t.responseStatus!==null&&t.responseStatus>=400)return t;return null}function sE(e){let t=null,n=-1;for(const r of e)r.elapsedMs!==null&&r.elapsedMs>n&&(t=r,n=r.elapsedMs);return t}function oE(e){for(const t of e)if(Al(t).length>0)return t;return null}function iE(e){const t=new Map;for(let n=0;n<e.length;n+=1){const r=e[n];r!==void 0&&t.set(r.id,n+1)}return t}function Xn(e,t){return String(t.get(e)??e)}function aE(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=oE(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 #${Xn(n.id,e.displayNumberByLogId)}`,logId:n.id});const r=rE(e.logs);r!==null&&t.push({kind:"failure",title:`Failure #${String(r.responseStatus)}`,detail:`First failed request is #${Xn(r.id,e.displayNumberByLogId)}`,logId:r.id});const o=sE(e.logs);if(o!==null&&e.summary.maxElapsedMs!==null&&t.push({kind:"slow",title:`Slowest ${ha(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${Xn(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 lE(e){switch(e){case"session":return s.jsx(wo,{className:"size-3.5 text-blue-400"});case"tool":return s.jsx(Ur,{className:"size-3.5 text-sky-400/70"});case"slow":return s.jsx(Ht,{className:"size-3.5 text-amber-400"});case"failure":return s.jsx(nf,{className:"size-3.5 text-destructive"});case"candidate":return s.jsx(tf,{className:"size-3.5 text-emerald-400"})}}function cE({insights:e}){return e.length===0?null:s.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=>s.jsxs("button",{type:"button",className:ae("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&&ym(t.logId)},disabled:t.logId===null,children:[lE(t.kind),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate font-medium text-foreground/90",children:t.title}),s.jsx("span",{className:"block truncate font-mono text-[10px]",children:t.detail})]})]},`${t.kind}-${t.title}`))})}function uE(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function dE(e,t){if(t)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function fE(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function pE(e,t){const n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,t-3)}...`}function hE(e,t){const n=e[0],r=e[e.length-1];if(n===void 0)return"No evidence logs";const o=Xn(n,t);return r===void 0||n===r?`#${o}`:`#${o}-#${Xn(r,t)}`}function iu(e){return e.join(", ")}function mE(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function gE({candidate:e,isPromoting:t,isUpdating:n,onPromoteCandidate:r,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),[v,g]=p.useState(iu(e.tags)),[x,b]=p.useState(null),y=e.status!=="promoted",_=e.status!=="promoted",j=p.useCallback(()=>{u(e.type),f(e.title),h(e.content),g(iu(e.tags)),b(null)},[e.content,e.tags,e.title,e.type]),S=p.useCallback(async()=>{const E=d.trim(),C=m.trim(),R=mE(v);if(E.length===0){b("Title is required.");return}if(C.length===0){b("Content is required.");return}if(R.length===0){b("At least one tag is required.");return}b(null),await o(e.id,{type:c,title:E,content:C,tags:R})&&l(!1)},[e.id,m,v,d,c,o]);return a?s.jsx("div",{className:"border border-border bg-card shadow-sm rounded-[8px] px-2.5 py-2",children:s.jsxs("div",{className:"grid gap-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("select",{value:c,disabled:n,onChange:E=>{const C=Yr.shape.type.safeParse(E.currentTarget.value);C.success&&u(C.data)},className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 rounded-md px-2 text-xs","aria-label":"Candidate type",children:[s.jsx("option",{value:"episode",children:"episode"}),s.jsx("option",{value:"procedure",children:"procedure"}),s.jsx("option",{value:"preference",children:"preference"}),s.jsx("option",{value:"project-fact",children:"project-fact"})]}),s.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"})]}),s.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"}),s.jsx("input",{value:v,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"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground",children:[s.jsx(ac,{className:"size-3"}),"Saving reruns Inspector redaction before promotion."]}),s.jsx("span",{className:"flex-1"}),x!==null&&s.jsx("span",{className:"text-[10px] text-destructive",children:x}),s.jsxs(Se,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{j(),l(!1)},children:[s.jsx(ko,{className:"size-3.5"}),"Cancel"]}),s.jsxs(Se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{S()},children:[n?s.jsx(zr,{className:"size-3.5 animate-spin"}):s.jsx(L2,{className:"size-3.5"}),"Save"]})]})]})}):s.jsxs("div",{className:"rounded-md border border-border/80 bg-background/60 px-2.5 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(Be,{variant:"outline",className:"h-5 px-1.5 text-[10px] font-mono",children:e.type}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",title:e.title,children:e.title}),s.jsx(Be,{variant:"outline",className:ae("h-5 shrink-0 px-1.5 text-[10px] font-mono",eE[e.status]),children:uE(e.status)})]}),s.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:pE(e.content,360)}),s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Yy,{className:"size-3"}),hE(e.logIds,i)]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(ac,{className:"size-3"}),fE(e)]}),e.status==="promoted"&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[s.jsx(Oi,{className:"size-3"}),e.openClawMemoryId??"OpenClaw"]}),e.status==="failed"&&e.error!==null&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[s.jsx(nf,{className:"size-3"}),e.error]})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.logIds.map(E=>{const C=Xn(E,i);return s.jsxs("a",{href:`#${vm(E)}`,onClick:R=>{R.preventDefault(),ym(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 ${C}`,title:`Log ID ${String(E)}`,children:["#",C]},E)}),s.jsx("span",{className:"flex-1"}),_&&s.jsxs(Se,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",disabled:n||t,onClick:()=>l(!0),children:[s.jsx(sf,{className:"size-3"}),"Review"]}),s.jsxs(Se,{type:"button",variant:y?"outline":"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",onClick:()=>r(e.id),disabled:!y||t||n,children:[t?s.jsx(zr,{className:"size-3 animate-spin"}):y?s.jsx(Iy,{className:"size-3"}):s.jsx(Oi,{className:"size-3"}),dE(e,t)]})]})]})}function xE({candidates:e,promotingCandidateIds:t,updatingCandidateIds:n,onPromoteCandidate:r,onUpdateCandidate:o,displayNumberByLogId:i}){return e.length===0?null:s.jsx("div",{className:"mt-2 grid gap-1.5",children:e.map(a=>s.jsx(gE,{candidate:a,isPromoting:t.has(a.id),isUpdating:n.has(a.id),onPromoteCandidate:r,onUpdateCandidate:o,displayNumberByLogId:i},a.id))})}function bE({logs:e,scopeId:t,slowResponseThresholdSeconds:n,showRollupMetrics:r,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,v]=p.useState(()=>new Set),g=i.length>0,x=p.useMemo(()=>DT(e,n,i.length),[i.length,e,n]),b=p.useMemo(()=>iE(e),[e]),y=p.useMemo(()=>aE({logs:e,scopeId:t,summary:x,candidates:i,displayNumberByLogId:b}),[i,b,e,t,x]),_=r||x.maxElapsedMs!==null,j=p.useMemo(()=>tE(x.startedAt,x.endedAt,o),[x.endedAt,x.startedAt,o]),S=p.useCallback(()=>{e.length===0||u.status==="loading"||(d({status:"loading",error:null}),(async()=>{try{const R=await fetch(`/api/knowledge/sessions/${encodeURIComponent(t)}/candidates`,{method:"POST"});if(!R.ok){const O=await Wt(R,`Candidate generation failed with ${String(R.status)}`);d({status:"failed",error:O});return}const z=await jt(R,JT);a(z.candidates),c(z.candidates.length>0),d(z.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(z=>{if(z.has(R))return z;const O=new Set(z);return O.add(R),O}),(async()=>{try{const z=await fetch(`/api/knowledge/candidates/${encodeURIComponent(R)}/promote`,{method:"POST"}),O=await z.json().catch(()=>null),q=YT.safeParse(O);if(z.ok&&q.success){a(D=>D.map(k=>k.id===q.data.candidate.id?q.data.candidate:k)),d({status:"ready",error:null});return}const T=XT.safeParse(O);T.success&&T.data.candidate!==void 0&&a(D=>D.map(k=>k.id===T.data.candidate?.id?T.data.candidate:k)),d({status:"failed",error:T.success?T.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(z.status)}`})}catch(z){d({status:"failed",error:z instanceof Error?z.message:"Candidate promotion failed"})}finally{m(z=>{const O=new Set(z);return O.delete(R),O})}})()},[]),C=p.useCallback(async(R,z)=>{v(O=>{if(O.has(R))return O;const q=new Set(O);return q.add(R),q});try{const O=await fetch(`/api/knowledge/candidates/${encodeURIComponent(R)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(z)});if(!O.ok){const T=await Wt(O,`Candidate update failed with ${String(O.status)}`);return d({status:"failed",error:T}),!1}const q=await jt(O,QT);return a(T=>T.map(D=>D.id===q.candidate.id?q.candidate:D)),d({status:"ready",error:null}),!0}catch(O){return d({status:"failed",error:O instanceof Error?O.message:"Candidate update failed"}),!1}finally{v(O=>{const q=new Set(O);return q.delete(R),q})}},[]);return e.length===0?null:s.jsxs("section",{className:"border border-border bg-card shadow-sm mb-2 rounded-[8px] px-3 py-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[r&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold text-foreground",children:[s.jsx(wo,{className:"size-3.5 text-blue-400"}),x.llmCallCount," LLM"]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(Ur,{className:"size-3.5 text-sky-400/70"}),x.toolCallCount," tools"]}),r&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(Pr,{className:"size-3.5 text-emerald-400"}),s.jsxs("span",{className:"font-mono",children:[$e(x.totalInputTokens)," / ",$e(x.totalOutputTokens)]})]}),(x.totalCacheCreationInputTokens>0||x.totalCacheReadInputTokens>0)&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(Pr,{className:"size-3.5 text-purple-400"}),s.jsxs("span",{className:"font-mono",children:["KV Cache +",$e(x.totalCacheCreationInputTokens)," / ~",$e(x.totalCacheReadInputTokens)]})]}),_&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(Ht,{className:"size-3.5"}),r&&s.jsx("span",{className:"font-mono",children:ha(x.totalElapsedMs)}),x.maxElapsedMs!==null&&s.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",ha(x.maxElapsedMs)]})]}),r&&j!==null&&s.jsx("span",{className:"font-mono text-muted-foreground/70",children:j}),(x.failedCallCount>0||x.pendingCallCount>0||x.slowCallCount>0)&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-amber-400",children:[s.jsx(rn,{className:"size-3.5"}),s.jsxs("span",{className:"font-mono",children:[x.failedCallCount," fail / ",x.pendingCallCount," pending /"," ",x.slowCallCount," slow"]})]}),s.jsx("span",{className:"flex-1"}),g&&s.jsx(Be,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:nE(x.knowledgeCandidateCount)}),s.jsxs(Se,{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"?s.jsx(ft,{className:"size-3.5 animate-spin"}):s.jsx(tf,{className:"size-3.5"}),"Candidate"]}),g&&s.jsx(Se,{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?s.jsx(st,{className:"size-3.5"}):s.jsx(bt,{className:"size-3.5"})})]}),u.status==="failed"&&s.jsx("p",{className:"mt-2 text-xs text-destructive",children:u.error}),s.jsx(cE,{insights:y}),l&&s.jsx(xE,{candidates:i,promotingCandidateIds:f,updatingCandidateIds:h,onPromoteCandidate:E,onUpdateCandidate:C,displayNumberByLogId:b})]})}function vE(e){let t=0,n=0;for(const r of e)r.inputTokens!==null&&(t+=r.inputTokens),r.outputTokens!==null&&(n+=r.outputTokens);return{totalInputTokens:t,totalOutputTokens:n}}function yE(e){const t=new Map;for(const n of e){if(n.model===null)continue;const r=Tj(n.model);if(r==="unknown")continue;let o=t.get(r);o===void 0&&(o=new Set,t.set(r,o)),o.add(n.model)}return[...t.entries()].map(([n,r])=>({provider:n,models:[...r]}))}function wE(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function kE(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}const _E=p.memo(function({group:e,viewMode:t="simple",strip:n,slowResponseThresholdSeconds:r,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:v}){const[g,x]=p.useState(f),b=h??g,y=p.useCallback(q=>{if(v!==void 0){v(q);return}x(q)},[v]);p.useEffect(()=>{!f||h!==void 0||x(!0)},[h,f]);const _=p.useMemo(()=>vE(e.logs),[e.logs]),j=p.useMemo(()=>yE(e.logs),[e.logs]),S=e.logs[0]?.timestamp??new Date().toISOString(),E=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),C=e.logs.some(q=>q.responseStatus===null),R=p.useMemo(()=>wE(e.logs),[e.logs]),z=p.useMemo(()=>kE(e.logs),[e.logs]),O=p.useMemo(()=>da(e.logs),[e.logs]);return p.useEffect(()=>{const q=T=>{const D=Zo(T);D!==null&&e.logs.some(k=>k.id===D.logId)&&y(!0)};return window.addEventListener(qt,q),()=>{window.removeEventListener(qt,q)}},[e.logs,y]),s.jsxs("div",{className:"mb-2",children:[s.jsx(FN,{conversationId:e.conversationId,startTime:S,endTime:E,totalCalls:e.logs.length,totalInputTokens:_.totalInputTokens,totalOutputTokens:_.totalOutputTokens,expanded:b,onToggle:()=>y(!b),providers:j,isLoading:C,userAgent:e.logs[0]?.userAgent??null,clientPid:R,clientProjectFolder:z,showClientIdentity:c,showProcessMetadata:u,timeDisplayFormat:m,onClear:()=>l(e.logs.map(q=>q.id))}),b&&s.jsxs("div",{children:[s.jsx(bE,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:r,showRollupMetrics:!1,timeDisplayFormat:m}),s.jsx(ZT,{turnGroups:O,viewMode:t,strip:n,slowResponseThresholdSeconds:r,timeDisplayFormat:m,cacheTrends:o,onCompareWithPrevious:i,comparisonPredecessors:a,showLogClientMetadata:d})]})]})});function au({className:e}){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:ae("inline-block size-5",e),children:[s.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"}),s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"}),s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),s.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),s.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),s.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]})}function wt({className:e,style:t,d:n,eyeStalks:r,eyes:o,legs:i,extras:a}){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:t,className:ae("inline-block size-5",e),children:[s.jsx("path",{d:n}),r,o,i,a]})}const mn=s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),s.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),s.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),s.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]}),wm=s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7",y1:"16",x2:"5.5",y2:"18.5"}),s.jsx("line",{x1:"9.5",y1:"17",x2:"8.5",y2:"19.5"}),s.jsx("line",{x1:"14.5",y1:"17",x2:"15.5",y2:"19.5"}),s.jsx("line",{x1:"17",y1:"16",x2:"18.5",y2:"18.5"})]});function jE({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.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 SE({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"9.5",y1:"6.5",x2:"9.5",y2:"4.5"}),s.jsx("line",{x1:"14.5",y1:"6.5",x2:"14.5",y2:"4.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"})]}),legs:wm,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12"}),s.jsx("path",{d:"M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12"})]})})}function CE({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7",y1:"7",x2:"6.5",y2:"4.5"}),s.jsx("line",{x1:"17",y1:"7",x2:"17.5",y2:"4.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"6.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"17.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13"}),s.jsx("path",{d:"M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13"})]})})}function NE({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"6.5",x2:"10",y2:"3.5"}),s.jsx("line",{x1:"14",y1:"6.5",x2:"14",y2:"3.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7",y1:"17",x2:"5",y2:"20.5"}),s.jsx("line",{x1:"9.5",y1:"18.5",x2:"8.5",y2:"21.5"}),s.jsx("line",{x1:"14.5",y1:"18.5",x2:"15.5",y2:"21.5"}),s.jsx("line",{x1:"17",y1:"17",x2:"19",y2:"20.5"})]}),extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12"}),s.jsx("path",{d:"M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12"})]})})}function TE({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.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 EE({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("line",{x1:"13.5",y1:"4",x2:"15.5",y2:"5"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.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 AE({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"6"}),s.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"6"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"9",y1:"6",x2:"11",y2:"6.5"}),s.jsx("line",{x1:"13",y1:"6",x2:"15",y2:"6.5"})]}),legs:wm,extras:s.jsxs(s.Fragment,{children:[s.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"}),s.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 RE({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("line",{x1:"8.5",y1:"4",x2:"10.5",y2:"4.5"}),s.jsx("line",{x1:"15.5",y1:"4",x2:"13.5",y2:"4.5"}),s.jsx("path",{d:"M9 15.5 C10 14.5 14 14.5 15 15.5"})]})})}function IE({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("ellipse",{cx:"12",cy:"15",rx:"2",ry:"1.5",fill:"currentColor",stroke:"none"})]})})}function zE({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"9.5",y1:"7",x2:"9",y2:"5"}),s.jsx("line",{x1:"14.5",y1:"7",x2:"15",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"15",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12"}),s.jsx("path",{d:"M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12"}),s.jsx("path",{d:"M9 14.5 C10 16 14 16 15 14.5"}),s.jsx("circle",{cx:"7",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"}),s.jsx("circle",{cx:"17",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"})]})})}function PE({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5.5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7.5",y1:"5.5",x2:"16.5",y2:"5.5"}),s.jsx("rect",{x:"7",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"}),s.jsx("rect",{x:"13",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("path",{d:"M9.5 15 C10.5 16 13.5 16 14.5 15"})]})})}function OE({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10.5",y1:"9.5",x2:"10.5",y2:"8"}),s.jsx("line",{x1:"13.5",y1:"9.5",x2:"13.5",y2:"8"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"13.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"8",y1:"16",x2:"6.5",y2:"18"}),s.jsx("line",{x1:"10",y1:"17",x2:"9.5",y2:"19"}),s.jsx("line",{x1:"14",y1:"17",x2:"14.5",y2:"19"}),s.jsx("line",{x1:"16",y1:"16",x2:"17.5",y2:"18"})]}),extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13"}),s.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 km=[jE,SE,CE,NE,TE,EE,AE,RE,IE,zE,PE,OE],ME="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 LE({className:e}){return s.jsx("img",{src:ME,alt:"Model Context Protocol","aria-hidden":"true",className:ae("inline-block size-8 object-contain invert",e)})}function ro({...e}){return s.jsx(i5,{"data-slot":"select",...e})}function so({...e}){return s.jsx(l5,{"data-slot":"select-value",...e})}function oo({className:e,size:t="default",children:n,...r}){return s.jsxs(a5,{"data-slot":"select-trigger","data-size":t,className:ae("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),...r,children:[n,s.jsx(c5,{asChild:!0,children:s.jsx(st,{className:"size-4 opacity-50"})})]})}function io({className:e,children:t,position:n="popper",align:r="center",...o}){return s.jsx(u5,{children:s.jsxs(d5,{"data-slot":"select-content",className:ae("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:r,...o,children:[s.jsx(DE,{}),s.jsx(f5,{className:ae("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),s.jsx($E,{})]})})}function At({className:e,children:t,...n}){return s.jsxs(p5,{"data-slot":"select-item",className:ae("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:[s.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:s.jsx(m5,{children:s.jsx(Ge,{className:"size-4"})})}),s.jsx(h5,{children:t})]})}function DE({className:e,...t}){return s.jsx(g5,{"data-slot":"select-scroll-up-button",className:ae("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(Wa,{className:"size-4"})})}function $E({className:e,...t}){return s.jsx(x5,{"data-slot":"select-scroll-down-button",className:ae("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(st,{className:"size-4"})})}const FE=Te(["critical","warning","notice"]),BE=Te(["open"]),UE=Te(["proxy","tool-schema","run","group"]),_m=Te(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),WE=Te(["log","session","run","group"]),HE=Te(["anthropic","openai","unknown"]),ZE=G({kind:WE,id:N(),label:N(),href:N().nullable()}),VE=G({id:N(),fingerprint:N(),severity:FE,category:_m,source:UE,status:BE,title:N(),message:N(),count:K().int().positive(),firstSeenAt:N(),lastSeenAt:N(),logIds:me(K().int().positive()),sessionIds:me(N()),runIds:me(N()),groupIds:me(N()),provider:N().nullable(),model:N().nullable(),apiFormat:HE.nullable(),evidence:me(ZE),metadata:Ke(N(),Qe)}),qE=G({category:_m,count:K().int().nonnegative()}),jm=G({total:K().int().nonnegative(),open:K().int().nonnegative(),critical:K().int().nonnegative(),warning:K().int().nonnegative(),notice:K().int().nonnegative(),byCategory:me(qE)}),KE=G({alerts:me(VE),total:K().int().nonnegative(),limit:K().int().positive(),summary:jm}),GE=8e3,JE=1e4;function YE(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 XE(e,t){const n=Tn(t?YE(e):null,r=>tr(r,KE,JE));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 QE(){const e=Tn("/api/alerts/summary",t=>tr(t,jm,GE),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const Il="relative size-8 rounded-md border border-input bg-background text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:ring-ring/50",e4=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function Sm(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function t4(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function zl(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 n4(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 r4(e){switch(e){case"critical":return"bg-red-400";case"warning":return"bg-amber-300";case"notice":return"bg-sky-300"}}function s4(e){switch(e){case"critical":return"text-red-200";case"warning":return"text-amber-100";case"notice":return"text-sky-100"}}function o4(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return s.jsx(q2,{className:"size-3.5"});case"request-timeout":case"slow-response":return s.jsx(Ey,{className:"size-3.5"});case"tool-schema":return s.jsx(rn,{className:"size-3.5"});case"group-incomplete":return s.jsx(ty,{className:"size-3.5"})}}function ma(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 ut(e){return e.toLocaleString()}function Cm(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 i4(e,t){const n={limit:100};return e!=="all"&&(n.severity=e),t!=="all"&&(n.category=t),n}function a4(e,t){if(t!==null){const n=e.find(r=>r.id===t);if(n!==void 0)return n}return e[0]??null}function vs({label:e,count:t,tone:n}){const r=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 s.jsxs("div",{className:ae("rounded-md border px-3 py-2",r),children:[s.jsx("div",{className:"text-[10px] font-semibold uppercase opacity-75",children:e}),s.jsx("div",{className:"mt-1 text-lg font-semibold leading-none",children:ut(t)})]})}function ys({value:e,active:t,label:n,count:r,onClick:o}){return s.jsxs(Se,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>o(e),className:"h-7 px-2",children:[n,r!==null?s.jsx(Be,{variant:"outline",children:ut(r)}):null]})}function l4({category:e,active:t,count:n,onClick:r}){return s.jsxs(Se,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>r(e),className:"h-7 px-2",children:[o4(e),zl(e),s.jsx(Be,{variant:"outline",children:ut(n)})]})}function c4({alerts:e,selectedAlertId:t,isLoading:n,error:r,onSelect:o}){return n?s.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:[s.jsx(ft,{className:"mr-2 size-3.5 animate-spin"}),"Loading alerts..."]}):r!==void 0?s.jsx("div",{className:"rounded-md border border-red-300/30 bg-red-500/10 px-3 py-2 text-xs text-red-100",children:r.message}):e.length===0?s.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."}):s.jsx("div",{className:"min-h-0 space-y-2 overflow-y-auto pr-1",children:e.map(i=>{const a=i.id===t;return s.jsxs("button",{type:"button",onClick:()=>o(i.id),className:ae("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:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:ae("size-2 rounded-full",r4(i.severity))}),s.jsx("span",{className:ae("text-xs font-semibold",s4(i.severity)),children:Sm(i.severity)}),s.jsx("span",{className:"truncate text-xs text-muted-foreground",children:zl(i.category)})]}),s.jsx("div",{className:"mt-1 truncate text-sm font-semibold",children:i.title}),s.jsx("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:i.message})]}),i.count>1?s.jsxs(Be,{variant:"outline",className:"shrink-0",children:["x",ut(i.count)]}):null]}),s.jsxs("div",{className:"mt-2 flex min-w-0 items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:Cm(i)}),s.jsx("span",{className:"shrink-0",children:ma(i.lastSeenAt)})]})]},i.id)})})}function u4({alert:e,onNavigate:t}){return e.evidence.length===0?s.jsx("span",{className:"text-xs text-muted-foreground",children:"No linked evidence"}):s.jsx("div",{className:"flex flex-wrap gap-2",children:e.evidence.map(n=>n.href===null?s.jsx(Be,{variant:"outline",children:n.label},`${n.kind}:${n.id}`):s.jsx(Be,{variant:"outline",asChild:!0,children:s.jsx("a",{href:n.href,onClick:t,children:n.label})},`${n.kind}:${n.id}`))})}function d4({alert:e,onNavigate:t}){return e===null?s.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."}):s.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-border bg-background/70",children:[s.jsx("div",{className:ae("border-b px-4 py-3",n4(e.severity)),children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Be,{variant:"outline",children:Sm(e.severity)}),s.jsx(Be,{variant:"outline",children:t4(e.source)}),s.jsx(Be,{variant:"outline",children:zl(e.category)})]}),s.jsx("h3",{className:"mt-3 text-base font-semibold",children:e.title}),s.jsx("p",{className:"mt-1 text-sm opacity-85",children:e.message})]}),e.count>1?s.jsxs(Be,{variant:"outline",className:"shrink-0",children:[ut(e.count)," hits"]}):null]})}),s.jsxs("div",{className:"space-y-4 p-4",children:[s.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[s.jsx(Yt,{label:"Target",value:Cm(e)}),s.jsx(Yt,{label:"Last seen",value:ma(e.lastSeenAt)}),s.jsx(Yt,{label:"First seen",value:ma(e.firstSeenAt)}),s.jsx(Yt,{label:"Protocol",value:e.apiFormat??"n/a"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Evidence"}),s.jsx(u4,{alert:e,onNavigate:t})]}),s.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[s.jsx(Yt,{label:"Logs",value:e.logIds.length===0?"n/a":ut(e.logIds.length)}),s.jsx(Yt,{label:"Sessions",value:e.sessionIds.length===0?"n/a":ut(e.sessionIds.length)}),s.jsx(Yt,{label:"Runs",value:e.runIds.length===0?"n/a":ut(e.runIds.length)}),s.jsx(Yt,{label:"Groups",value:e.groupIds.length===0?"n/a":ut(e.groupIds.length)})]})]})]})}function Yt({label:e,value:t}){return s.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2",children:[s.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground",children:e}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-foreground",children:t})]})}function lu(){const[e,t]=p.useState(!1),[n,r]=p.useState("all"),[o,i]=p.useState("all"),[a,l]=p.useState(null),{summary:c,isLoading:u}=QE(),d=p.useMemo(()=>i4(n,o),[o,n]),{alerts:f,total:m,isLoading:h,error:v,mutate:g}=XE(d,e),x=p.useMemo(()=>a4(f,a),[f,a]);p.useEffect(()=>{!e||a!==null&&f.some(C=>C.id===a)||l(f[0]?.id??null)},[f,e,a]);const b=c?.total??0,y=c?.critical??0,_=c?.warning??0,j=c?.notice??0,S=y>0?"bg-red-500":_>0?"bg-amber-400":"bg-sky-400";return s.jsxs(Wr,{open:e,onOpenChange:t,children:[s.jsx(rl,{asChild:!0,children:s.jsxs(Se,{type:"button",variant:"ghost",size:"icon",className:Il,"aria-label":"Alerts",title:"Alerts",children:[s.jsx(Di,{className:"size-4"}),u?s.jsx(ft,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):b>0?s.jsx("span",{className:ae("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4 text-white",S),children:ut(b)}):null,s.jsx("span",{className:"sr-only",children:"Alerts"})]})}),s.jsxs(Hr,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[s.jsxs(Zr,{children:[s.jsxs(Vr,{className:"flex items-center gap-2 pr-8",children:[s.jsx(Di,{className:"size-5 text-red-300"}),s.jsx("span",{children:"Alerts"}),s.jsx(Be,{variant:"outline",children:ut(b)})]}),s.jsx(fj,{className:"sr-only",children:"Local alert board for captured Inspector evidence."})]}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[s.jsx(vs,{label:"Open",count:c?.open??0,tone:"neutral"}),s.jsx(vs,{label:"Critical",count:y,tone:"critical"}),s.jsx(vs,{label:"Warning",count:_,tone:"warning"}),s.jsx(vs,{label:"Notice",count:j,tone:"notice"})]}),s.jsxs("div",{className:"flex min-h-0 flex-wrap items-center justify-between gap-2 border-y border-border py-3",children:[s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx(ys,{value:"all",active:n==="all",label:"All",count:c?.total??null,onClick:r}),s.jsx(ys,{value:"critical",active:n==="critical",label:"Critical",count:y,onClick:r}),s.jsx(ys,{value:"warning",active:n==="warning",label:"Warning",count:_,onClick:r}),s.jsx(ys,{value:"notice",active:n==="notice",label:"Notice",count:j,onClick:r})]}),s.jsxs(Se,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{g()},children:[s.jsx(zr,{className:"size-3.5"}),"Refresh"]})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx(Se,{type:"button",variant:o==="all"?"secondary":"ghost",size:"sm","aria-pressed":o==="all",onClick:()=>i("all"),className:"h-7 px-2",children:"All categories"}),e4.map(E=>{const C=c?.byCategory.find(R=>R.category===E)?.count??0;return C===0?null:s.jsx(l4,{category:E,active:o===E,count:C,onClick:i},E)})]}),s.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[360px_minmax(0,1fr)]",children:[s.jsxs("div",{className:"flex min-h-0 flex-col",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[s.jsxs("span",{children:[ut(m)," matched"]}),s.jsx("span",{children:f.length<m?`${ut(f.length)} shown`:"Latest"})]}),s.jsx(c4,{alerts:f,selectedAlertId:x?.id??null,isLoading:h,error:v,onSelect:l})]}),s.jsx(d4,{alert:x,onNavigate:()=>t(!1)})]})]})]})}const f4=12e3;function p4(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function h4(e){const t=Tn(p4(e),n=>tr(n,P1,f4));return{evidenceResponse:t.data??null,isLoading:t.isLoading,error:t.error,mutate:t.mutate}}const m4=8e3;function g4(){const e=Tn("/api/groups",t=>tr(t,Xd,m4));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}function x4(e,t){const n=`/api/groups/${encodeURIComponent(e)}`;return t?`${n}?deleteEvidence=1`:n}function Nm(e){let t=0,n=0,r=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":r+=1;break;case"created":break;case null:o+=1;break}return{memberCount:e.members.length,completedMembers:t,failedMembers:n,runningMembers:r,missingStatusMembers:o}}function b4(e,t,n=null){return t!==null&&t.group.id===e.id?t.members.map(r=>({member:r.member,exportMember:r,source:"export"})):n!==null&&n.group.id===e.id&&n.members!==null?n.members.map(r=>({member:r.member,exportMember:r,source:"evidence"})):e.members.map(r=>({member:r,exportMember:null,source:"group"}))}function Pl(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 Ol(e){return e??"unknown"}function v4(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 Vo(e){return e===null||e.trim().length===0?"-":e}function gt(e){return e.toLocaleString()}function ga(e){return e==null?"-":e<1e3?`${gt(e)} ms`:`${(e/1e3).toFixed(1)} s`}function ar(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 cu(e){return e===null?"-":ar(e)}function y4(e){const t=JSON.stringify(e),n=t===void 0?String(e):t;return n.length<=160?n:`${n.slice(0,157)}...`}function Tm(...e){for(const t of e)if(t!==null&&t.trim().length>0)return t;return"-"}function w4(...e){for(const t of e)if(t!=null&&t.trim().length>0)return t;return null}function k4(e){const t=e.provider,n=e.model;return t!==null&&t.length>0&&n!==null&&n.length>0?`${t} / ${n}`:Tm(t,n)}function _4(e,t){if(t!==null){const n=e.find(r=>r.id===t);if(n!==void 0)return n}return e[0]??null}function j4(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function S4(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function C4(e,t){return t!==null&&t.group.id===e.id?t.evidence:e.evidence}function N4(e,t,n){return t!==null&&t.group.id===e.id?t.summary:n!==null&&n.group.id===e.id?n.summary:null}function T4(e,t,n){return t!==null&&t.group.id===e.id?t.jenkinsReport:n!==null&&n.group.id===e.id?n.report:null}function uu(){const[e,t]=p.useState(!1),[n,r]=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),[v,g]=p.useState(null),[x,b]=p.useState(null),{groups:y,isLoading:_,error:j,mutate:S}=g4(),E=p.useMemo(()=>_4(y,n),[y,n]);p.useEffect(()=>{!e||n!==null&&y.some(Z=>Z.id===n)||r(y[0]?.id??null)},[y,e,n]);const C=E!==null&&c!==null&&c.group.id===E.id?c:null,{evidenceResponse:R,isLoading:z,error:O,mutate:q}=h4(E),T=p.useCallback(()=>{S()},[S]),D=p.useCallback(async F=>{i(F.id),l(null);try{const Z=await fetch(`/api/groups/${encodeURIComponent(F.id)}/evidence`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})});if(!Z.ok){l(await Wt(Z,`Export failed with status ${String(Z.status)}`));return}const J=await jt(Z,O1);u(J),await S(),await q()}catch(Z){l(Z instanceof Error?Z.message:String(Z))}finally{i(null)}},[S,q]),k=p.useCallback(F=>{f(F),h(!1),b(null)},[]),$=p.useCallback(()=>{v===null&&(f(null),h(!1),b(null))},[v]),X=p.useCallback(F=>{r(F),f(null),h(!1),b(null)},[]),B=p.useCallback(async()=>{const F=d;if(F!==null){g(F.id),b(null);try{const Z=await fetch(x4(F.id,m),{method:"DELETE"});if(!Z.ok){b(await Wt(Z,`Delete failed with status ${String(Z.status)}`));return}await jt(Z,z1),u(J=>J!==null&&J.group.id===F.id?null:J),r(J=>J===F.id?null:J),f(null),h(!1),await S(),await q()}catch(Z){b(Z instanceof Error?Z.message:String(Z))}finally{g(null)}}},[m,d,S,q]);return s.jsxs(Wr,{open:e,onOpenChange:t,children:[s.jsx(rl,{asChild:!0,children:s.jsxs(Se,{type:"button",variant:"ghost",size:"icon",className:Il,"aria-label":"Evaluation groups",title:"Evaluation groups",children:[s.jsx(oc,{className:"size-4"}),_?s.jsx(ft,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):y.length>0?s.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:y.length}):null,s.jsx("span",{className:"sr-only",children:"Evaluation groups"})]})}),s.jsxs(Hr,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[s.jsx(Zr,{children:s.jsxs(Vr,{className:"flex items-center gap-2 pr-8",children:[s.jsx(oc,{className:"size-5 text-muted-foreground"}),s.jsx("span",{children:"Groups"}),s.jsx(Be,{variant:"outline",children:gt(y.length)})]})}),s.jsxs("div",{className:"flex min-h-0 items-center justify-between gap-3 border-b border-border pb-3",children:[s.jsx("p",{className:"text-xs text-muted-foreground",children:"Evaluation batches, model runs, and exported evidence packs."}),s.jsxs(Se,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:T,children:[s.jsx(zr,{className:"size-3.5"}),"Refresh"]})]}),s.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[260px_minmax(0,1fr)]",children:[s.jsx(E4,{groups:y,selectedGroupId:E?.id??null,isLoading:_,error:j,onSelect:X}),s.jsx(A4,{group:E,deleteTarget:d,deleteEvidence:m,exportResult:C,evidenceResponse:R,evidenceLoading:z,evidenceError:O,exportError:a,deleteError:x,exportingGroupId:o,deletingGroupId:v,onDeleteEvidenceChange:h,onExport:D,onRequestDelete:k,onCancelDelete:$,onConfirmDelete:()=>{B()}})]})]})]})}function E4({groups:e,selectedGroupId:t,isLoading:n,error:r,onSelect:o}){return n?s.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..."}):r!==void 0?s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:r.message}):e.length===0?s.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."}):s.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:s.jsx("div",{className:"space-y-2",children:e.map(i=>{const a=Nm(i),l=t===i.id;return s.jsxs("button",{type:"button",onClick:()=>o(i.id),className:ae("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:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:i.title}),s.jsx(Be,{variant:"outline",className:Pl(i.status),children:Ol(i.status)})]}),s.jsxs("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[s.jsxs("span",{children:[a.memberCount," sessions"]}),s.jsx("span",{children:ar(i.updatedAt)})]})]},i.id)})})})}function A4({group:e,deleteTarget:t,deleteEvidence:n,exportResult:r,evidenceResponse:o,evidenceLoading:i,evidenceError:a,exportError:l,deleteError:c,exportingGroupId:u,deletingGroupId:d,onDeleteEvidenceChange:f,onExport:m,onRequestDelete:h,onCancelDelete:v,onConfirmDelete:g}){if(e===null)return s.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 x=Nm(e),b=N4(e,r,o),y=T4(e,r,o),_=C4(e,r),j=b4(e,r,o),S=u===e.id,E=d===e.id,C=t?.id===e.id;return s.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx("h3",{className:"min-w-0 truncate text-base font-semibold",children:e.title}),s.jsx(Be,{variant:"outline",className:Pl(e.status),children:Ol(e.status)}),s.jsx(Be,{variant:"outline",children:e.kind})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("span",{children:Vo(e.project)}),s.jsxs("span",{children:["updated ",ar(e.updatedAt)]})]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(Se,{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?s.jsx(ft,{className:"size-3.5 animate-spin"}):s.jsx(nr,{className:"size-3.5"})}),s.jsxs(Se,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:S||E,onClick:()=>{m(e)},children:[S?s.jsx(ft,{className:"size-3.5 animate-spin"}):s.jsx(yo,{className:"size-3.5"}),"Export evidence"]})]})]}),e.task!==null&&e.task.trim().length>0&&s.jsx("p",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:e.task}),C&&s.jsx(R4,{group:e,deleteEvidence:n,isDeleting:E,error:c,onDeleteEvidenceChange:f,onCancel:v,onConfirm:g}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[s.jsx(Xt,{label:"Members",value:x.memberCount}),s.jsx(Xt,{label:"Done",value:x.completedMembers}),s.jsx(Xt,{label:"Failed",value:x.failedMembers}),s.jsx(Xt,{label:"Running",value:x.runningMembers})]}),b!==null&&s.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[s.jsx(Xt,{label:"Requests",value:b.requestCount}),s.jsx(Xt,{label:"Errors",value:b.errorCount}),s.jsx(Xt,{label:"Tokens",value:b.tokenUsage.total}),s.jsx(Xt,{label:"Missing",value:b.missingSessions})]}),s.jsx(I4,{report:y,loading:i,error:a,hasEvidence:_!==null}),s.jsx(z4,{evidence:_}),l!==null&&s.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&&!C&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:c}),s.jsx(P4,{rows:j})]})})}function R4({group:e,deleteEvidence:t,isDeleting:n,error:r,onDeleteEvidenceChange:o,onCancel:i,onConfirm:a}){const l=e.evidence!==null,c=e.evidence?.markdownPath??"No evidence pack exported.";return s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-3 text-red-900",children:s.jsxs("div",{className:"flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(nr,{className:"size-4 text-red-600"}),s.jsx("span",{children:"Delete group?"})]}),s.jsxs("p",{className:"text-xs text-red-800",children:["Delete ",s.jsx("span",{className:"font-medium",children:e.title}),". Session logs and run records stay intact."]}),s.jsxs("label",{className:ae("flex min-w-0 items-start gap-2 text-xs",l?"cursor-pointer":"opacity-60"),children:[s.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0",checked:t,disabled:!l||n,onChange:u=>o(u.currentTarget.checked)}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block font-medium",children:"Also delete exported evidence files"}),s.jsx("code",{className:"mt-1 block truncate font-mono text-[11px] text-red-700",children:c})]})]}),r!==null&&s.jsx("div",{className:"rounded-md border border-red-200 bg-white px-2 py-1.5 text-xs text-red-700",children:r})]}),s.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[s.jsx(Se,{type:"button",variant:"outline",size:"sm",disabled:n,onClick:i,children:"Cancel"}),s.jsxs(Se,{type:"button",variant:"destructive",size:"sm",disabled:n,onClick:a,children:[n?s.jsx(ft,{className:"size-3.5 animate-spin"}):s.jsx(nr,{className:"size-3.5"}),"Delete"]})]})]})})}function Xt({label:e,value:t}){return s.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsx("div",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:e}),s.jsx("div",{className:"mt-1 font-mono text-sm font-semibold",children:gt(t)})]})}function I4({report:e,loading:t,error:n,hasEvidence:r}){const{copied:o,copy:i}=Ut(e?.markdown??null);return e===null&&!t&&n===void 0?null:t?s.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:[s.jsx(ft,{className:"size-3.5 animate-spin"}),"Loading evidence report..."]}):n!==void 0&&r?s.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:s.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"text-xs font-semibold",children:"Evidence report"}),s.jsx(Be,{variant:"outline",className:v4(e.status),children:e.status})]}),s.jsx(Se,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":o?"Copied evidence report":"Copy evidence report",onClick:i,children:o?s.jsx(Ge,{className:"size-3.5 text-emerald-500"}):s.jsx(Nt,{className:"size-3.5"})})]}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function z4({evidence:e}){return e===null?s.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."}):s.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-xs font-semibold",children:"Evidence paths"}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:ar(e.exportedAt)})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(bi,{label:"JSON",value:e.jsonPath}),s.jsx(bi,{label:"Markdown",value:e.markdownPath}),s.jsx(bi,{label:"HTML",value:e.htmlPath})]})]})}function bi({label:e,value:t}){const{copied:n,copy:r}=Ut(t);return s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border bg-background px-2 py-1.5",children:[s.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground",children:e}),s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t}),s.jsx(Se,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":n?`Copied ${e} path`:`Copy ${e} path`,onClick:r,children:n?s.jsx(Ge,{className:"size-3.5 text-emerald-500"}):s.jsx(Nt,{className:"size-3.5"})})]})}function P4({rows:e}){const[t,n]=p.useState(null),r=p.useCallback(o=>{n(i=>i===o?null:o)},[]);return e.length===0?s.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."}):s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-xs font-semibold",children:"Members"}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[760px] text-left text-xs",children:[s.jsx("thead",{className:"border-b border-border bg-muted/20 text-muted-foreground",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-3 py-2 font-medium",children:"Session"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Provider / Model"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Requests"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Errors"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"First chunk"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Tokens"})]})}),s.jsx("tbody",{children:e.map(o=>{const i=t===o.member.id;return s.jsxs(p.Fragment,{children:[s.jsx(O4,{row:o,isExpanded:i,onToggleDetails:r}),s.jsx(M4,{row:o,isExpanded:i})]},o.member.id)})})]})})]})}function O4({row:e,isExpanded:t,onToggleDetails:n}){const r=e.member,o=e.exportMember?.session??null,i=j4(e),a=o?.inspectorPath??Qu(r.sessionId),l=e.source!=="evidence",c=o?.requestCount??null,u=o?.errorCount??null,d=o?.tokenUsage.total??null,f=i?.firstChunkMs??null,m=Tm(r.label,r.sessionId),h=w4(o?.clientUserAgent,i?.userAgent,r.agent),v=o?.clientProjectFolder??null,g=ol({userAgent:h,conversationId:r.sessionId,clientProjectFolder:v}),x=No(g);return s.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/20",children:[s.jsxs("td",{className:"max-w-56 px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(Se,{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(r.id)},children:t?s.jsx(st,{className:"size-3.5"}):s.jsx(bt,{className:"size-3.5"})}),x!==null&&s.jsx(il,{client:g,className:"size-5"}),l?s.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:[s.jsx("span",{className:"min-w-0 truncate",children:m}),s.jsx(Ha,{className:"size-3 shrink-0 text-muted-foreground"})]}):s.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(r.id)},children:[s.jsx("span",{className:"min-w-0 truncate",children:m}),s.jsx(Be,{variant:"outline",className:"shrink-0 border-zinc-200 bg-zinc-50 text-zinc-600",children:"evidence"})]})]}),s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Vo(r.agent)})]}),s.jsx("td",{className:"max-w-52 px-3 py-2",children:s.jsx("span",{className:"block truncate",children:k4(r)})}),s.jsx("td",{className:"px-3 py-2",children:s.jsx(Be,{variant:"outline",className:Pl(r.status),children:Ol(r.status)})}),s.jsx("td",{className:"px-3 py-2 font-mono",children:c===null?"-":gt(c)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":gt(u)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:ga(f)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":gt(d)})]})}function M4({row:e,isExpanded:t}){if(!t)return null;const n=e.member,r=e.exportMember,o=r?.session??null,i=r?.run??null,a=Object.entries(n.metadata);return s.jsx("tr",{className:"border-b border-border bg-muted/10",children:s.jsx("td",{colSpan:7,className:"px-3 pb-4 pt-2",children:s.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-background p-3",children:[s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(et,{label:"Source",value:S4(e.source)}),s.jsx(et,{label:"Member ID",value:n.id,mono:!0}),s.jsx(et,{label:"Session ID",value:n.sessionId,mono:!0}),s.jsx(et,{label:"Run ID",value:i?.id??n.runId??"-",mono:!0}),s.jsx(et,{label:"Created",value:ar(n.addedAt)}),s.jsx(et,{label:"Updated",value:ar(n.updatedAt)}),s.jsx(et,{label:"Session created",value:cu(o?.createdAt??null)}),s.jsx(et,{label:"Session updated",value:cu(o?.updatedAt??null)})]}),o===null?s.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."}):s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(et,{label:"Log coverage",value:o.logCoverage}),s.jsx(et,{label:"Runtime",value:Vo(o.runtimeMode)}),s.jsx(et,{label:"Requests",value:gt(o.requestCount),mono:!0}),s.jsx(et,{label:"Errors",value:gt(o.errorCount),mono:!0}),s.jsx(et,{label:"Input tokens",value:gt(o.tokenUsage.input),mono:!0}),s.jsx(et,{label:"Output tokens",value:gt(o.tokenUsage.output),mono:!0}),s.jsx(et,{label:"Cache read",value:gt(o.tokenUsage.cacheRead),mono:!0}),s.jsx(et,{label:"Total tokens",value:gt(o.tokenUsage.total),mono:!0})]}),s.jsx(L4,{logs:o?.latestLogs??[]}),s.jsx(D4,{entries:a})]})})})}function et({label:e,value:t,mono:n=!1}){return s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),s.jsx("div",{className:ae("truncate text-xs text-foreground",n?"font-mono":""),title:t,children:t})]})}function L4({logs:e}){const t=e.slice(0,5);return t.length===0?s.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."}):s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.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"}),s.jsx("div",{className:"divide-y divide-border",children:t.map(n=>{const r=n.sessionLogNumber??n.id;return s.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs sm:grid-cols-[72px_1fr_88px_88px]",children:[s.jsxs("span",{className:"font-mono text-muted-foreground",title:`Log ID ${String(n.id)}`,children:["#",r]}),s.jsxs("span",{className:"min-w-0 truncate",children:[Vo(n.model)," · ",n.apiFormat," · ",n.path]}),s.jsx("span",{className:"font-mono text-muted-foreground",children:ga(n.firstChunkMs)}),s.jsx("span",{className:"font-mono text-muted-foreground",children:ga(n.latencyMs)})]},n.id)})})]})}function D4({entries:e}){return e.length===0?null:s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.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"}),s.jsx("div",{className:"grid gap-x-3 gap-y-2 p-3 text-xs sm:grid-cols-2",children:e.map(([t,n])=>{const r=y4(n);return s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"mr-2 text-muted-foreground",children:t}),s.jsx("span",{className:"font-mono text-foreground",title:r,children:r})]},t)})})]})}function $4(){return s.jsxs("svg",{fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[s.jsx("title",{children:"Claude Code"}),s.jsx("path",{clipRule:"evenodd",d:"M20.998 10.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6 10.949h1.488V8.102H6v2.847zm10.51 0H18V8.102h-1.49v2.847z"})]})}function F4(){return s.jsxs("svg",{fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[s.jsx("title",{children:"OpenCode"}),s.jsx("path",{d:"M16 6H8v12h8V6zm4 16H4V2h16v20z"})]})}function B4(){return s.jsxs("svg",{fill:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[s.jsx("title",{children:"MiMo Code"}),s.jsx("text",{x:"12",y:"18",textAnchor:"middle",fontSize:"16",fontWeight:"800",fontFamily:"system-ui, sans-serif",children:"M"})]})}const U4=G({name:N(),apiKey:N(),format:Te(["anthropic","openai"]),anthropicBaseUrl:N(),openaiBaseUrl:N(),openaiResponsesBaseUrl:N().optional().default(""),models:me(N()),sourceTool:Te(["claude-code","opencode","mimo-code"]),alreadyExists:Fe()}),W4=G({providers:me(U4),warnings:me(N()).optional()}),H4=G({success:Fe().optional(),imported:K().optional(),message:N().optional(),errors:me(N()).optional()}),Z4={"claude-code":$4,opencode:F4,"mimo-code":B4};function V4({open:e,onOpenChange:t,onImportComplete:n}){const[r,o]=p.useState(!1),[i,a]=p.useState(null),[l,c]=p.useState([]),[u,d]=p.useState([]),[f,m]=p.useState(new Set),[h,v]=p.useState(!1),[g,x]=p.useState(null),[b,y]=p.useState(null),_=p.useCallback(()=>{o(!0),a(null),d([]),c([]),m(new Set),x(null),y(null),fetch("/api/providers/scan").then(C=>C.ok?C.json().then(R=>{const z=W4.safeParse(R);if(!z.success){a(`Invalid response: ${z.error.message}`);return}c(z.data.providers),d(z.data.warnings??[]);const O=new Set;z.data.providers.forEach((q,T)=>{q.alreadyExists||O.add(T)}),m(O)}):C.text().then(R=>{a(`Scan failed (${C.status}): ${R}`)})).catch(C=>{a(C instanceof Error?C.message:String(C))}).finally(()=>{o(!1)})},[]);p.useEffect(()=>{e&&_()},[e,_]);const j=p.useCallback(C=>{m(R=>{const z=new Set(R);return z.has(C)?z.delete(C):z.add(C),z})},[]),S=p.useCallback(()=>{const C=l.filter((O,q)=>f.has(q));if(C.length===0)return;v(!0),y(null),x(null);const R=new Date().toISOString(),z=C.map(O=>({id:window.crypto.randomUUID(),name:O.name,apiKey:O.apiKey,format:O.format,anthropicBaseUrl:O.anthropicBaseUrl,openaiBaseUrl:O.openaiBaseUrl,openaiResponsesBaseUrl:O.openaiResponsesBaseUrl,models:O.models,createdAt:R,updatedAt:R}));fetch("/api/providers/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providers:z})}).then(O=>O.json()).then(O=>{const q=H4.safeParse(O);if(!q.success){y(`Invalid response: ${q.error.message}`);return}const T=q.data;c(D=>D.map((k,$)=>f.has($)?{...k,alreadyExists:!0}:k)),m(new Set),T.errors!==void 0&&T.errors.length>0&&T.message!==void 0?x(T.message):x(`Imported ${T.imported??C.length} provider(s)`),n()}).catch(O=>{y(O instanceof Error?O.message:String(O))}).finally(()=>{v(!1)})},[l,f,n]),E=l.some(C=>!C.alreadyExists);return s.jsx(Wr,{open:e,onOpenChange:t,children:s.jsxs(Hr,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[s.jsxs(Zr,{children:[s.jsx(Vr,{children:"Import from External Tools"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[r&&s.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[s.jsx(ft,{className:"size-4 animate-spin"}),s.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),i!==null&&s.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[s.jsx(Ir,{className:"size-4"}),i]}),!r&&i===null&&l.length===0&&s.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",s.jsx("br",{}),s.jsx("span",{className:"text-xs",children:"Supported tools: Claude Code (~/.claude/settings.json), OpenCode (~/.config/opencode/opencode.json), MiMo Code (~/.config/mimocode/mimocode.jsonc)"})]}),!r&&l.map((C,R)=>s.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${C.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!C.alreadyExists&&s.jsx("input",{type:"checkbox",checked:f.has(R),disabled:h,onChange:()=>j(R),className:"mt-0.5 size-4"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[(()=>{const z=Z4[C.sourceTool];return z===void 0?null:s.jsx(z,{})})(),C.alreadyExists&&s.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),s.jsxs("div",{className:"text-xs text-muted-foreground mt-1 truncate",children:[C.models.slice(0,4).join(", "),C.models.length>4?` +${C.models.length-4} more`:""]}),s.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:C.format==="anthropic"?C.anthropicBaseUrl:C.openaiResponsesBaseUrl!==""?C.openaiResponsesBaseUrl:C.openaiBaseUrl}),s.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:C.apiKey.length>8?`${C.apiKey.slice(0,4)}••••${C.apiKey.slice(-4)}`:"••••"})]})]},`${C.sourceTool}-${C.name}`)),u.length>0&&s.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:u.map((C,R)=>s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Ir,{className:"size-3"}),C]},R))}),g!==null&&s.jsx("div",{className:"text-sm text-green-500 border-t pt-2",children:g}),b!==null&&s.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:b})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[s.jsxs(Se,{variant:"outline",size:"sm",onClick:_,disabled:r,children:[s.jsx(ft,{className:`size-3 mr-1 ${r?"animate-spin":""}`}),"Rescan"]}),s.jsxs(Se,{size:"sm",onClick:S,disabled:!E||f.size===0||h,children:[s.jsx(yo,{className:"size-3 mr-1"}),h?"Importing...":`Import Selected (${f.size})`]})]})]})})}function Em(e){return e.length<=8?"••••••••":e.slice(0,4)+"••••••••"+e.slice(-4)}const Am=G({id:N().min(1),aliases:me(N()).optional().default([]),contextWindow:K().int().positive().optional(),outputLimit:K().int().positive().optional(),sourceUrl:N().optional()}),q4=G({name:N().min(1).optional(),aliases:me(N()).optional().default([]),baseUrls:me(N()).optional().default([]),models:me(Am).min(1)});G({version:K().int().positive().optional(),updatedAt:N().optional(),providers:me(q4).optional().default([]),models:me(Am).optional().default([])});function du(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function K4(e){const t=e.models.filter(n=>n.trim()!=="");return t.length>0?t:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function Ml(e,t){const n=du(t);return(e.modelMetadata??[]).find(o=>du(o.model)===n)??null}function G4(e){const t=K4(e);return t.length===0?!1:t.every(n=>{const r=Ml(e,n);return r!==null&&r.contextWindow!==void 0})}function J4(e,t){if(e===null)return null;for(const n of t){const r=Ml(n,e);if(r!==null&&r.contextWindow!==void 0)return{providerName:n.name,model:r.model,tokens:r.contextWindow,sourceUrl:r.sourceUrl}}return null}const kn="/v1/chat/completions",ao="/v1/responses",Rm="/v1/messages";function Y4(e,t){const n=e.endsWith("/")?e.slice(0,-1):e,r=zm(t),o=t.indexOf("?"),i=o>=0?t.slice(o):"";return r!==""&&n.endsWith(r)?n+i:Om(n)&&Pm(t)||n.endsWith("/v1")&&t.startsWith("/v1/")?n+t.slice(3):n+t}function Im(e,t,n={}){const r=e.trim().replace(/\/+$/,""),o=zm(t),i=Y4(r,t),a=[];return o!==""&&r.endsWith(o)?a.push({severity:"info",message:"This already includes the exact endpoint; no duplicate suffix will be appended."}):Om(r)&&Pm(t)?a.push({severity:"info",message:"Zhipu bases already include the API version; only /chat/completions is appended."}):r.endsWith("/v1")&&t.startsWith("/v1/")&&a.push({severity:"info",message:"Base URL already ends with /v1; the suffix will not repeat /v1."}),fu(o)&&Q4(r)&&a.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),X4(o)&&eA(r)&&a.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),fu(o)&&tA(r,n.providerName)&&a.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:i,diagnostics:a}}function zm(e){return e.split("?")[0]??e}function Pm(e){return e===kn||e.startsWith(`${kn}?`)||e.startsWith(`${kn}/`)}function X4(e){return e===kn||e.startsWith(`${kn}/`)}function fu(e){return e===ao||e.startsWith(`${ao}/`)}function Q4(e){return e.toLowerCase().endsWith("/chat/completions")}function eA(e){return e.toLowerCase().endsWith("/responses")}function tA(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 Om(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 nA={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function rA(e){return Object.prototype.hasOwnProperty.call(e,"success")}function sA(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function lt(e){return e!==void 0&&e.trim()!==""}function xa(e){if(e===void 0)return;const t=Object.entries(e).map(([n,r])=>`${n}: ${r}`);if(t.length!==0)return t.join(`
104
- `)}function pu(e){return xa(e)!==void 0}function hu(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function oA(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function iA(e){const t=e.debug;return lt(e.error?.hint)||lt(e.error?.details)||lt(e.rawResponse)||lt(t?.requestUrl)||lt(t?.requestBody)||lt(t?.responseBody)||pu(t?.requestHeaders)||pu(t?.responseHeaders)||t?.responseStatus!==void 0}function Qt({title:e,children:t}){return s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"font-medium text-foreground/80",children:e}),t]})}function wr({value:e}){return s.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap break-all rounded-md bg-background/80 p-2 font-mono text-[11px] leading-relaxed text-foreground/80",children:e})}function aA({result:e}){const t=e.debug,n=t?.requestUrl,r=t?.requestMethod??"POST",o=xa(t?.requestHeaders),i=xa(t?.responseHeaders),a=t?.responseStatus!==void 0?`${t.responseStatus}${lt(t.responseStatusText)?` ${t.responseStatusText}`:""}`:void 0,l=t?.responseBody??e.rawResponse;return s.jsxs("div",{className:"max-h-80 max-w-full space-y-2 overflow-auto rounded-md border bg-muted/50 p-2 text-xs text-muted-foreground shadow-sm sm:w-[520px]",children:[lt(e.error?.hint)&&s.jsx(Qt,{title:"Hint",children:s.jsx("div",{children:e.error.hint})}),lt(e.error?.details)&&s.jsx(Qt,{title:"Error",children:s.jsx(wr,{value:e.error.details})}),lt(n)&&s.jsx(Qt,{title:"Request",children:s.jsxs("div",{className:"rounded-md bg-background/80 p-2 font-mono text-[11px] break-all text-foreground/80",children:[r," ",n]})}),o!==void 0&&s.jsx(Qt,{title:"Request Headers",children:s.jsx(wr,{value:o})}),lt(t?.requestBody)&&s.jsx(Qt,{title:"Request Body",children:s.jsx(wr,{value:t.requestBody})}),lt(a)&&s.jsx(Qt,{title:"Response Status",children:s.jsx("div",{className:"rounded-md bg-background/80 p-2 font-mono text-[11px] text-foreground/80",children:a})}),i!==void 0&&s.jsx(Qt,{title:"Response Headers",children:s.jsx(wr,{value:i})}),lt(l)&&s.jsx(Qt,{title:"Response Body",children:s.jsx(wr,{value:l})})]})}function Bn({results:e}){return s.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-2",children:[s.jsxs("div",{className:"min-w-0 rounded-md border border-border/60 bg-muted/20 px-2 py-1.5",children:[s.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Non-stream"}),s.jsx(mu,{result:e.nonStreaming})]}),s.jsxs("div",{className:"min-w-0 rounded-md border border-border/60 bg-muted/20 px-2 py-1.5",children:[s.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Stream"}),s.jsx(mu,{result:e.streaming})]})]})}function lA({diagnostic:e}){return s.jsx("div",{className:e.severity==="warning"?"text-amber-200":"text-muted-foreground",children:e.message})}function vi({label:e,baseUrl:t,endpoint:n,providerName:r,children:o}){const i=Im(t,n,{providerName:r});return s.jsxs("div",{className:"flex min-w-0 flex-col gap-2 border-t border-border/60 pt-2 first:border-t-0 first:pt-0",children:[s.jsxs("div",{className:"grid min-w-0 gap-1 text-xs sm:grid-cols-[104px_minmax(0,1fr)]",children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:e}),s.jsx("code",{className:"min-w-0 break-all font-mono text-foreground/80",children:t}),s.jsx("span",{className:"text-[10px] uppercase text-muted-foreground/80",children:"Final"}),s.jsx("code",{className:"min-w-0 break-all font-mono text-foreground",children:i.finalUrl})]}),i.diagnostics.length>0&&s.jsx("div",{className:"space-y-1 text-xs",children:i.diagnostics.map(a=>s.jsx(lA,{diagnostic:a},`${a.severity}:${a.message}`))}),o]})}function cA(e){const t={className:"size-3",strokeWidth:2};switch(e){case"timeout":return s.jsx(Ht,{...t});case"network_unreachable":return s.jsx(rw,{...t});case"connection_refused":return s.jsx(ow,{...t});case"auth_failed":return s.jsx(x2,{...t});case"rate_limited":return s.jsx(qa,{...t});case"server_error":return s.jsx(W2,{...t});case"invalid_response":return s.jsx(jy,{...t});case"unknown":return s.jsx(Ir,{...t});default:return s.jsx(Ir,{...t})}}function mu({result:e}){const[t,n]=p.useState(!1);if(!rA(e))return sA(e)?s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground shrink-0",children:[s.jsx(y2,{className:"size-3"}),s.jsx("span",{children:"Not configured"})]}):s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground shrink-0",children:[s.jsx(Li,{className:"size-3 animate-spin"}),s.jsx("span",{children:"Testing..."})]});if(e.success){const l=[],c=[];e.inputTokens!==void 0&&l.push(s.jsxs("span",{children:[e.inputTokens," in"]},"in")),e.outputTokens!==void 0&&l.push(s.jsxs("span",{children:[e.outputTokens," out"]},"out")),e.cacheCreationInputTokens!==void 0&&e.cacheCreationInputTokens>0&&l.push(s.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["KV Cache +",e.cacheCreationInputTokens]},"cache-create")),e.cacheReadInputTokens!==void 0&&e.cacheReadInputTokens>0&&l.push(s.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",e.cacheReadInputTokens]},"cache-read")),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&c.push(s.jsxs("span",{children:["first ",hu(e.firstChunkMs)]},"first")),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&c.push(s.jsxs("span",{children:["total ",hu(e.totalStreamMs)]},"total")),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&c.push(s.jsxs("span",{children:[oA(e.tokensPerSecond)," tok/s"]},"rate"));const u=[];for(let f=0;f<l.length;f++)f>0&&u.push(", "),u.push(l[f]);const d=[];for(let f=0;f<c.length;f++)f>0&&d.push(", "),d.push(c[f]);return s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs("div",{className:"flex items-center gap-1 text-xs text-cyan-100 shrink-0",children:[s.jsx(wy,{className:"size-3 text-cyan-300"}),s.jsx("span",{children:"Connected"}),l.length>0&&s.jsxs("span",{className:"text-muted-foreground",children:["(",u,")"]}),c.length>0&&s.jsxs("span",{className:"hidden text-muted-foreground lg:inline",children:["(",d,")"]})]})}),s.jsx(Le,{children:"Connection test passed"})]})})}const r=e.error,o=r?.message??"Connection failed",i=r?.type??"unknown",a=iA(e);return s.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-1 text-xs text-red-600 max-w-[200px]",children:[cA(i),s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("span",{className:"truncate",children:o})}),s.jsx(Le,{children:"Connection test failed"})]})}),a&&s.jsxs("button",{type:"button",onClick:()=>n(l=>!l),"aria-expanded":t,"aria-label":t?"Hide provider test diagnostics":"Show provider test diagnostics",className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-border/70 bg-background/70 px-1.5 text-[10px] text-muted-foreground transition-colors hover:text-foreground",children:[t?s.jsx(Za,{className:"size-3"}):s.jsx(Va,{className:"size-3"}),s.jsx("span",{children:t?"Hide":"Details"})]})]}),t&&a&&s.jsx(aA,{result:e})]})}function uA(e){const t=Date.now(),n=new Date(e).getTime(),r=t-n,o=Math.floor(r/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 dA(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(),r=n==="huggingface.co"||n.endsWith(".huggingface.co");return{label:r?"HF":"Source",title:r?"Open Hugging Face model source":"Open model metadata source",url:e}}catch{return null}}function fA({provider:e,testResults:t,isTesting:n,testingTimeLeft:r,isHighlighted:o,onEdit:i,onDelete:a,onTest:l,onRefreshMetadata:c,isRefreshingMetadata:u=!1}){const[d,f]=p.useState(!1),[m,h]=p.useState(!1),[v,g]=p.useState(!1);function x(){Kt(e.apiKey).then(E=>{E&&(h(!0),setTimeout(()=>h(!1),2e3))})}const b=e.apiDocsUrl??Object.entries(nA).find(([E])=>e.name.toLowerCase().includes(E))?.[1],y=G4(e),_=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",j=_?"Refresh":"Import defaults",S=e.source==="company"?s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.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"})}),s.jsx(Le,{children:"Company-provided API key"})]})}):e.source==="personal"?s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.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"})}),s.jsx(Le,{children:"Your personal API key"})]})}):null;return s.jsxs("div",{className:`border border-border bg-card shadow-sm flex flex-col gap-3 rounded-[8px] p-4 transition-all duration-500 ${o===!0?"ring-2 ring-primary shadow-md":""}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium truncate",children:e.name}),S,S===null&&e.source==="company"&&s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400 shrink-0",children:"公司"})}),s.jsx(Le,{children:"Company-provided API key"})]})}),S===null&&e.source==="personal"&&s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400 shrink-0",children:"个人"})}),s.jsx(Le,{children:"Your personal API key"})]})})]}),b!==void 0&&s.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1 text-xs",title:"View API documentation",children:[s.jsx(Ha,{className:"size-3"}),s.jsx("span",{className:"sr-only",children:"Docs"})]})]}),e.models!==void 0&&e.models.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(E=>{const C=Ml(e,E),R=dA(C?.sourceUrl);return s.jsxs("span",{className:"inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:[s.jsx("span",{children:E}),C!==null&&C.contextWindow!==void 0&&s.jsx("span",{className:"font-mono text-foreground/80",children:jf(C.contextWindow)}),R!==null&&s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("a",{href:R.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":R.title,children:R.label})}),s.jsx(Le,{children:R.title})]})})]},E)})}),!y&&s.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:[s.jsx("span",{children:"Context window metadata missing"}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsxs(Se,{type:"button",variant:"outline",size:"sm",onClick:()=>c?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:u,children:[s.jsx(Li,{className:`size-3 ${u?"animate-spin":""}`}),j]}),!_&&s.jsx(Se,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-xs text-muted-foreground bg-muted px-2 py-1 rounded flex-1 truncate",children:d?e.apiKey:Em(e.apiKey)}),s.jsx("button",{type:"button",onClick:()=>f(E=>!E),className:"text-muted-foreground hover:text-foreground transition-colors p-1","aria-label":d?"Hide API key":"Show API key",children:d?s.jsx(Za,{className:"size-4"}):s.jsx(Va,{className:"size-4"})}),s.jsx("button",{type:"button",onClick:x,className:"text-muted-foreground hover:text-foreground transition-colors p-1","aria-label":"Copy API key",children:m?s.jsx(Ge,{className:"size-4 text-cyan-300"}):s.jsx(Nt,{className:"size-4"})})]}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&s.jsx(vi,{label:"Anthropic",baseUrl:e.anthropicBaseUrl,endpoint:Rm,providerName:e.name,children:t!==void 0&&s.jsx(Bn,{results:t.anthropic})}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&s.jsx(vi,{label:"OpenAI Chat",baseUrl:e.openaiBaseUrl,endpoint:kn,providerName:e.name,children:t!==void 0&&s.jsx(Bn,{results:t.openaiChat})}),e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""&&s.jsx(vi,{label:"OpenAI Responses",baseUrl:e.openaiResponsesBaseUrl,endpoint:ao,providerName:e.name,children:t!==void 0&&s.jsx(Bn,{results:t.openaiResponses})}),t?.testedAt!==void 0&&s.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[s.jsx(Ht,{className:"size-3"}),s.jsxs("span",{children:["Tested ",uA(t.testedAt)]})]}),t?.models!==void 0&&Object.keys(t.models).length>0&&s.jsxs("div",{className:"border-t pt-2",children:[s.jsxs("button",{type:"button",onClick:()=>g(E=>!E),className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1",children:[v?s.jsx(st,{className:"size-3"}):s.jsx(bt,{className:"size-3"}),"Model Test Results (",Object.keys(t.models).length,")"]}),v&&s.jsx("div",{className:"mt-2 overflow-x-auto",children:s.jsxs("table",{className:"w-full text-xs border-collapse",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border",children:[s.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"Model"}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&s.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"Anthropic"}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&s.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"Chat"}),e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""&&s.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"Responses"})]})}),s.jsx("tbody",{children:Object.entries(t.models).map(([E,C])=>s.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[s.jsx("td",{className:"py-1 px-2 font-medium",children:E}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&s.jsx("td",{className:"py-1 px-2 align-top",children:s.jsx(Bn,{results:C.anthropic})}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&s.jsx("td",{className:"py-1 px-2 align-top",children:s.jsx(Bn,{results:C.openaiChat})}),e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""&&s.jsx("td",{className:"py-1 px-2 align-top",children:s.jsx(Bn,{results:C.openaiResponses})})]},E))})]})})]}),s.jsxs("div",{className:"flex gap-2 pt-1 border-t",children:[l!==void 0&&s.jsxs(Se,{variant:"outline",size:"sm",onClick:()=>l(e.id),className:"text-xs h-7 gap-1",disabled:n??!1,children:[s.jsx(Li,{className:`size-3 ${n??!1?"animate-spin":""}`}),n??!1?r!==void 0?`Testing (${r}s)`:"Testing...":"Test"]}),s.jsxs(Se,{variant:"outline",size:"sm",onClick:()=>i(e),className:"text-xs h-7 gap-1",disabled:n??!1,children:[s.jsx(sf,{className:"size-3"}),"Edit"]}),s.jsxs(Se,{variant:"outline",size:"sm",onClick:()=>a(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:n??!1,children:[s.jsx(nr,{className:"size-3"}),"Delete"]})]})]})}const gu=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],xu=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],ws=Rm,ks=kn,_s=ao,pA={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"}},bu=["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"],vu=["qwen3.6-plus","qwen3.7-max"],yu=["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"],ba="__unset__",lo="__custom__",Mm=[{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 vn(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function wu(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function Lm(e,t){const n=wu(t);return e?.modelMetadata?.find(r=>wu(r.model)===n)??null}function Dm(e){const t=Us(e);if(t===null)return null;for(const n of Mm)if(Us(n.value)===t)return n.value;return null}function hA(e){return e.trim()===""?"unset":Dm(e)!==null?"preset":"custom"}function mA(e){switch(e.contextWindowMode){case"unset":return ba;case"custom":return lo;case"preset":return Dm(e.contextWindow)??lo}}function yi(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 r=n[1];if(r===void 0)return{amount:t,unit:"K"};const o=n[2];if(o===void 0||o==="")return{amount:r,unit:"tokens"};switch(o.toLowerCase()){case"k":return{amount:r,unit:"K"};case"m":return{amount:r,unit:"M"};default:return{amount:t,unit:"K"}}}function ku(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 _u(e,t){return t.map(n=>{const r=Lm(e,n),o=r?.contextWindow!==void 0?_k(r.contextWindow):"";return{contextWindow:o,contextWindowMode:hA(o),outputLimit:r?.outputLimit?.toString()??""}})}function ju(e){const t=e.trim();if(t==="")return null;const n=Number(t);return!Number.isInteger(n)||n<=0?null:n}function Un(e,t){if(e===void 0)return"";const n=e.trim(),r=n.replace(/\/+$/,"");return r.endsWith(t)?r.slice(0,-t.length).replace(/\/+$/,""):n}function gA(e,t,n){const r=e.trim();return r===""?null:Im(r,t,{providerName:n})}function wi({baseUrl:e,endpoint:t,providerName:n}){const r=gA(e,t,n);return r===null?null:s.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs",children:[s.jsx("div",{className:"text-muted-foreground",children:"Final URL"}),s.jsx("div",{className:"break-all font-mono text-foreground",children:r.finalUrl}),r.diagnostics.length>0&&s.jsx("div",{className:"mt-2 space-y-1",children:r.diagnostics.map(o=>s.jsx("div",{className:o.severity==="warning"?"text-amber-200":"text-muted-foreground",children:o.message},`${o.severity}:${o.message}`))})]})}function xA({provider:e,onSubmit:t,onCancel:n}){const[r,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:[""]),[v,g]=p.useState(()=>_u(e,f!==void 0&&f.length>0?f:[""])),[x,b]=p.useState("anthropic"),[y,_]=p.useState(Un(e?.anthropicBaseUrl,ws)),[j,S]=p.useState(Un(e?.openaiBaseUrl,ks)),[E,C]=p.useState(Un(e?.openaiResponsesBaseUrl,_s)),[R,z]=p.useState(e?.apiDocsUrl??""),[O,q]=p.useState(e?.modelMetadataUrl??""),[T,D]=p.useState(e?.source),[k,$]=p.useState({}),[X,B]=p.useState(!1),[F,Z]=p.useState(null),J=p.useRef([]);p.useEffect(()=>{if(F===null)return;const P=F;function M(Q){if(!(Q.target instanceof Node))return;const fe=J.current[P];fe!=null&&!fe.contains(Q.target)&&Z(null)}return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[F]);const[H,W]=p.useState(!1),[ce,se]=p.useState(!1),[oe,_e]=p.useState(!1),ie=r.toLowerCase().includes("minimax"),ge=r.toLowerCase().includes("alibaba"),he=[...gu,...xu].some(P=>r.toLowerCase().includes(P)),xe=ie?bu:he?yu:ge?vu:[],te=e?.modelMetadata?.some(P=>P.contextWindow!==void 0)??!1;function ue(){Kt(i).then(P=>{P&&(d(!0),setTimeout(()=>d(!1),2e3))})}p.useEffect(()=>{if(e){o(e.name),a(e.apiKey);const P=(e.models?.length??0)>0?e.models:[""];h(P),g(_u(e,P)),_(Un(e.anthropicBaseUrl,ws)),S(Un(e.openaiBaseUrl,ks)),C(Un(e.openaiResponsesBaseUrl,_s)),z(e.apiDocsUrl??""),q(e.modelMetadataUrl??""),D(e.source),W(!1),se(!1),_e(!1)}},[e]),p.useEffect(()=>{const P=r.toLowerCase();for(const[M,Q]of Object.entries(pA))if(P.includes(M)){Q.anthropicBaseUrl!==void 0&&!H&&_(Q.anthropicBaseUrl),Q.openaiBaseUrl!==void 0&&!ce&&S(Q.openaiBaseUrl),Q.openaiResponsesBaseUrl!==void 0&&!oe&&C(Q.openaiResponsesBaseUrl),Q.apiDocsUrl!==void 0&&!R&&z(Q.apiDocsUrl),M==="minimax"&&m.length===1&&m[0]===""&&h([bu[0]??""]),M==="alibaba"&&m.length===1&&m[0]===""&&h([vu[0]??""]),(gu.includes(M)||xu.includes(M))&&m.length===1&&m[0]===""&&h([yu[0]??""]);break}},[r]);function be(){const P={};return r.trim()||(P.name="Name is required"),i.trim()||(P.apiKey="API key is required"),(m.length===0||m.every(M=>!M.trim()))&&(P.models="At least one model is required"),y.trim()&&!w(y.trim())&&(P.anthropicBaseUrl="Invalid URL format"),j.trim()&&!w(j.trim())&&(P.openaiBaseUrl="Invalid URL format"),E.trim()&&!w(E.trim())&&(P.openaiResponsesBaseUrl="Invalid URL format"),O.trim()&&!w(O.trim())&&(P.modelMetadataUrl="Invalid URL format"),v.forEach((M,Q)=>{const fe=Us(M.contextWindow),de=ju(M.outputLimit);M.contextWindow.trim()!==""&&fe===null&&(P[`modelMetadata.${Q}.contextWindow`]="Context window must be a positive number, optionally using K or M"),M.outputLimit.trim()!==""&&de===null&&(P[`modelMetadata.${Q}.outputLimit`]="Output limit must be a positive integer"),fe!==null&&de!==null&&de>fe&&(P[`modelMetadata.${Q}.outputLimit`]="Output limit should not exceed context window")}),!y.trim()&&!j.trim()&&!E.trim()&&(P.format="At least one format URL (Anthropic or OpenAI) is required"),$(P),Object.keys(P).length===0}function w(P){try{return new URL(P),!0}catch{return!1}}function Y(P,M){h(Q=>{const fe=[...Q];return fe[P]=M,fe})}function U(P,M){g(Q=>{const fe=[...Q];return fe[P]={...fe[P]??vn(),...M},fe})}function I(P,M){switch(M){case ba:U(P,{contextWindow:"",contextWindowMode:"unset"});return;case lo:{const Q=v[P]??vn();U(P,{contextWindow:Q.contextWindow,contextWindowMode:"custom"});return}default:U(P,{contextWindow:M,contextWindowMode:"preset"});return}}function A(P,M){const Q=v[P]??vn(),fe=yi(Q.contextWindow);U(P,{contextWindow:ku(M,fe.unit),contextWindowMode:"custom"})}function L(P,M){const Q=v[P]??vn(),fe=yi(Q.contextWindow);switch(M){case"K":case"M":case"tokens":U(P,{contextWindow:ku(fe.amount,M),contextWindowMode:"custom"});return;default:return}}function ne(P){h(M=>M.filter((Q,fe)=>fe!==P)),g(M=>M.filter((Q,fe)=>fe!==P))}function re(){h(P=>[...P,""]),g(P=>[...P,vn()])}function V(){const P=new Date().toISOString(),M=[];return m.forEach((Q,fe)=>{const de=Q.trim();if(de==="")return;const Pe=v[fe]??vn(),Ue=Us(Pe.contextWindow),Ne=ju(Pe.outputLimit);if(Ue===null&&Ne===null)return;const pt=Lm(e,de);if(pt!==null&&pt.contextWindow===(Ue??void 0)&&pt.outputLimit===(Ne??void 0)){M.push({...pt,model:de});return}const ze={model:de,source:"manual",updatedAt:P};Ue!==null&&(ze.contextWindow=Ue),Ne!==null&&(ze.outputLimit=Ne),M.push(ze)}),M.length>0?M:e?.modelMetadata!==void 0?[]:void 0}function le(P){if(P.preventDefault(),!!be()){B(!0);try{t({name:r.trim(),apiKey:i.trim(),models:m.map(M=>M.trim()).filter(M=>M!==""),anthropicBaseUrl:y.trim()||void 0,openaiBaseUrl:j.trim()||void 0,openaiResponsesBaseUrl:E.trim()||void 0,apiDocsUrl:R.trim()||void 0,modelMetadataUrl:O.trim()||void 0,modelMetadata:V(),source:T})}finally{B(!1)}}}return s.jsxs("form",{onSubmit:le,className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsx("input",{id:"provider-name",type:"text",value:r,onChange:P=>o(P.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"}),k.name!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.name})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),s.jsxs("select",{id:"provider-source",value:T??"",onChange:P=>D(P.target.value==="company"||P.target.value==="personal"?P.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:[s.jsx("option",{value:"",children:"Unspecified"}),s.jsx("option",{value:"personal",children:"个人 (Personal)"}),s.jsx("option",{value:"company",children:"公司 (Company)"})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-model-metadata-url",className:"text-sm font-medium",children:"Model Metadata URL"}),s.jsx("input",{id:"provider-model-metadata-url",type:"text",value:O,onChange:P=>q(P.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"}),k.modelMetadataUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.modelMetadataUrl}),O.trim()===""&&s.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&&!te&&O.trim()===""&&s.jsx("p",{className:"text-xs text-amber-400",children:"This provider has no matching context metadata yet."}),O.trim()!==""&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent Inspector will refresh model limits from this JSON registry after save."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{id:"provider-apikey",type:"text",value:l||i.length===0?i:Em(i),onChange:P=>a(P.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"}),s.jsx("button",{type:"button",onClick:()=>c(P=>!P),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":l?"Hide API key":"Show API key",children:l?s.jsx(Za,{className:"size-4"}):s.jsx(Va,{className:"size-4"})}),s.jsx("button",{type:"button",onClick:ue,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:u?s.jsx(Ge,{className:"size-4 text-cyan-300"}):s.jsx(Nt,{className:"size-4"})})]}),k.apiKey!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.apiKey})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"text-sm font-medium",children:["Models ",s.jsx("span",{className:"text-destructive",children:"*"})]}),m.map((P,M)=>{const Q=v[M]??vn(),fe=k[`modelMetadata.${M}.contextWindow`],de=k[`modelMetadata.${M}.outputLimit`],Pe=mA(Q),Ue=yi(Q.contextWindow);return s.jsxs("div",{ref:Ne=>{J.current[M]=Ne},className:"border border-border bg-card shadow-sm space-y-2 rounded-[8px] p-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx("input",{type:"text",value:P,onChange:Ne=>Y(M,Ne.target.value),placeholder:xe.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"}),xe.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:()=>Z(F===M?null:M),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:s.jsx(st,{className:"size-4"})}),F===M&&s.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:xe.map(Ne=>s.jsx("button",{type:"button",onClick:()=>{Y(M,Ne),Z(null)},className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-white/[0.06]",children:Ne},Ne))})]})]}),m.length>1&&s.jsx("button",{type:"button",onClick:()=>ne(M),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:s.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:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),s.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[s.jsx("span",{children:"Context Window"}),s.jsxs(ro,{value:Pe,onValueChange:Ne=>I(M,Ne),children:[s.jsx(oo,{size:"sm",className:"w-full bg-background font-mono text-xs",children:s.jsx(so,{})}),s.jsxs(io,{className:"max-h-64",children:[s.jsx(At,{value:ba,children:"Not set"}),Mm.map(Ne=>s.jsxs(At,{value:Ne.value,children:[Ne.label," · ",Ne.value]},Ne.value)),s.jsx(At,{value:lo,children:"Custom"})]})]}),Q.contextWindowMode==="custom"&&s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_5.75rem] gap-1.5",children:[s.jsx("input",{type:"text",inputMode:"decimal",value:Ue.amount,onChange:Ne=>A(M,Ne.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]"}),s.jsxs(ro,{value:Ue.unit,onValueChange:Ne=>L(M,Ne),children:[s.jsx(oo,{size:"sm",className:"w-full bg-background font-mono text-xs",children:s.jsx(so,{})}),s.jsxs(io,{children:[s.jsx(At,{value:"K",children:"K"}),s.jsx(At,{value:"M",children:"M"}),s.jsx(At,{value:"tokens",children:"tokens"})]})]})]}),fe!==void 0&&s.jsx("span",{className:"block text-destructive",children:fe})]}),s.jsxs("label",{className:"space-y-1 text-xs text-muted-foreground",children:[s.jsx("span",{children:"Output Limit"}),s.jsx("input",{type:"number",min:1,step:1e3,value:Q.outputLimit,onChange:Ne=>U(M,{outputLimit:Ne.target.value}),placeholder:"e.g. 8192",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),de!==void 0&&s.jsx("span",{className:"block text-destructive",children:de})]})]})]},M)}),s.jsx("button",{type:"button",onClick:re,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),k.models!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.models})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"border border-border bg-muted/40 flex gap-1 rounded-[8px] p-1",children:[s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>b("anthropic"),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${x==="anthropic"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Anthropic Format"})}),s.jsx(Le,{children:"Anthropic Messages API format"})]})}),s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>b("openai"),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${x==="openai"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"OpenAI Format"})}),s.jsx(Le,{children:"OpenAI Chat Completions API format"})]})})]}),k.format!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.format})]}),x==="anthropic"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:"Anthropic Base URL"}),s.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:[s.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:y,onChange:P=>{W(!0),_(P.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"}),s.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:ws})]}),k.anthropicBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.anthropicBaseUrl}),s.jsx(wi,{baseUrl:y,endpoint:ws,providerName:r}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Anthropic-compatible base URL. Leave empty if this provider does not support Anthropic format."})]}),x==="openai"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:"OpenAI Chat Base URL"}),s.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:[s.jsx("input",{id:"provider-openai-base-url",type:"text",value:j,onChange:P=>{se(!0),S(P.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"}),s.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:ks})]}),k.openaiBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.openaiBaseUrl}),s.jsx(wi,{baseUrl:j,endpoint:ks,providerName:r}),s.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."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-openai-responses-base-url",className:"text-sm font-medium",children:"OpenAI Responses Base URL"}),s.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:[s.jsx("input",{id:"provider-openai-responses-base-url",type:"text",value:E,onChange:P=>{_e(!0),C(P.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"}),s.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:_s})]}),k.openaiResponsesBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.openaiResponsesBaseUrl}),s.jsx(wi,{baseUrl:E,endpoint:_s,providerName:r}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional Responses-compatible base URL. Set only when the provider supports the Responses API."})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),s.jsx("input",{id:"provider-api-docs-url",type:"text",value:R,onChange:P=>z(P.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"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),s.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:[s.jsx(Se,{type:"button",variant:"outline",onClick:n,disabled:X,children:"Cancel"}),s.jsx(Se,{type:"submit",disabled:X,children:X?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const bA=Te(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),vA=G({message:N(),type:bA,details:N().optional(),hint:N().optional()}),yA=G({type:Te(["text","thinking"]),text:N().optional(),thinking:N().optional()}),wA=G({requestUrl:N().optional(),requestMethod:N().optional(),requestHeaders:Ke(N(),N()).optional(),requestBody:N().optional(),responseStatus:K().optional(),responseStatusText:N().optional(),responseHeaders:Ke(N(),N()).optional(),responseBody:N().optional()}),kA=G({success:Fe(),error:vA.optional(),model:N().optional(),inputTokens:K().optional(),outputTokens:K().optional(),cacheCreationInputTokens:K().optional(),cacheReadInputTokens:K().optional(),latencyMs:K().optional(),firstChunkMs:K().nullable().optional(),totalStreamMs:K().nullable().optional(),tokensPerSecond:K().nullable().optional(),content:me(yA).optional(),rawResponse:N().optional(),streaming:Fe().optional(),streamingChunks:G({chunks:me(Id),truncated:Fe().default(!1)}).optional(),requestHeaders:Ke(N(),N()).optional(),debug:wA.optional()}),Su=Mt([kA,G({notConfigured:Ce(!0)}),G({testing:Ce(!0)})]),nn=G({nonStreaming:Su,streaming:Su});function co(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const _A=G({anthropic:nn,openai:nn.optional(),openaiChat:nn.optional(),openaiResponses:nn.optional()}).transform(e=>{const t=e.openaiChat??e.openai??co();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??co()}}),jA=G({anthropic:nn,openai:nn.optional(),openaiChat:nn.optional(),openaiResponses:nn.optional(),models:Ke(N(),_A).optional(),testedAt:N().optional()}).transform(e=>{const t=e.openaiChat??e.openai??co();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??co()}});function SA(){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 Cu(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 CA=G({providerConfig:N()}),NA=G({success:Fe().optional(),imported:K().optional(),message:N().optional(),errors:me(N()).optional()}),TA=G({provider:Ws,imported:K(),matchedModels:me(N()),missingModels:me(N()),sourceUrl:N()}),js="Network error: could not reach the server. Is the proxy running?";function Nu(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 EA(e,t){const n=e?.models?.map(r=>r.trim()).filter(r=>r!=="").length??0;return Math.max(1,n)*t}async function AA(e,t){if(t.models!==void 0)try{await fetch(`/api/providers/${e}/test/log`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function RA({externalProviders:e,isLoading:t=!1,externalTestResults:n,externalTestingProviders:r,externalTestingTimeLeft:o,onProvidersMutate:i,onTestResultsChange:a,onTestingProvidersChange:l,onTestingTimeLeftChange:c}){const[u,d]=p.useState(!1),[f,m]=p.useState(),[h,v]=p.useState(null),[g,x]=p.useState({}),[b,y]=p.useState(new Set),[_,j]=p.useState({}),[S,E]=p.useState(null),[C,R]=p.useState(!1),[z,O]=p.useState(null),[q,T]=p.useState(!1),[D,k]=p.useState(!1),[$,X]=p.useState(null),[B,F]=p.useState("all"),[Z,J]=p.useState(new Set),{providerTestTimeoutSeconds:H}=Ua(),W=p.useRef(null),ce=p.useRef(null),se=e??[],oe=p.useMemo(()=>{const P=B==="all"?se:se.filter(M=>M.source===B);return B==="all"?[...P].sort((M,Q)=>{const fe={personal:0,company:1};return(fe[M.source??""]??2)-(fe[Q.source??""]??2)}):P},[se,B]),_e=n??g,ie=r??b,ge=o??_,he=c?(P,M)=>c(P,M):(P,M)=>{j(M===void 0?Q=>{const fe={...Q};return delete fe[P],fe}:Q=>({...Q,[P]:M}))};p.useEffect(()=>{(async()=>{try{const P=await fetch("/api/config/paths");if(P.ok){const M=await jt(P,CA);E(M.providerConfig)}}catch{}})()},[]);const xe=p.useCallback(P=>{ce.current!==null&&clearTimeout(ce.current),O(P),W.current?.scrollTo({top:W.current.scrollHeight,behavior:"smooth"}),ce.current=setTimeout(()=>{O(null),ce.current=null},2e3)},[]);p.useEffect(()=>()=>{ce.current!==null&&clearTimeout(ce.current)},[]);const te=p.useCallback(()=>{i?.().catch(()=>{})},[i]),ue=p.useCallback((P,M)=>{a?a(P,M):x(Q=>({...Q,[P]:M}))},[a]),be=p.useCallback((P,M)=>{if(l){l(P,M);return}y(Q=>{const fe=new Set(Q);return M?fe.add(P):fe.delete(P),fe})},[l]),w=p.useCallback(async P=>{ue(P,SA()),be(P,!0);const M=new AbortController,Q=se.find(Ue=>Ue.id===P);let de=EA(Q,H);he(P,de);const Pe=setInterval(()=>{de--,he(P,de),de<=0&&(clearInterval(Pe),M.abort())},1e3);try{const Ue=await fetch(`/api/providers/${P}/test`,{method:"POST",signal:M.signal});if(Ue.ok){const Ne=await jt(Ue,jA);ue(P,Ne),await AA(P,Ne)}else ue(P,Cu(`HTTP ${Ue.status}: ${Ue.statusText}`,"server_error"))}catch(Ue){Ue instanceof Error&&Ue.name==="AbortError"&&ue(P,Cu("Request timed out","timeout"))}finally{clearInterval(Pe),he(P,void 0),be(P,!1)}},[H,se,he,ue,be]),Y=p.useCallback(async(P,M,Q=!0)=>{J(fe=>{const de=new Set(fe);return de.add(P),de});try{const fe=M!==void 0&&M.trim()!==""?{url:M}:{},de=await fetch(`/api/providers/${P}/model-metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(fe)});if(!de.ok)return Q&&v(await Wt(de,"Failed to refresh model metadata")),!1;const Pe=await jt(de,TA);return Pe.imported===0&&Q?v("No matching model metadata found for this provider."):v(null),xe(Pe.provider.id),te(),Pe.imported>0}catch{return Q&&v(js),!1}finally{J(fe=>{const de=new Set(fe);return de.delete(P),de})}},[te,xe]);function U(P){(async()=>{try{const M=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Nu(P))});if(!M.ok){v(await Wt(M,"Failed to add provider"));return}const Q=await jt(M,Ws);d(!1),xe(Q.id),P.modelMetadataUrl!==void 0&&P.modelMetadataUrl.trim()!==""&&await Y(Q.id,P.modelMetadataUrl,!1),te(),await w(Q.id)}catch{v(js)}})()}function I(P){f&&(async()=>{try{const M=await fetch(`/api/providers/${f.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Nu(P))});if(!M.ok){v(await Wt(M,"Failed to update provider"));return}const Q=await jt(M,Ws);m(void 0),xe(Q.id),P.modelMetadataUrl!==void 0&&P.modelMetadataUrl.trim()!==""&&await Y(Q.id,P.modelMetadataUrl,!1),te(),((P.apiKey??"")!==(f.apiKey??"")||JSON.stringify(P.models)!==JSON.stringify(f.models)||(P.anthropicBaseUrl??"")!==(f.anthropicBaseUrl??"")||(P.openaiBaseUrl??"")!==(f.openaiBaseUrl??"")||(P.openaiResponsesBaseUrl??"")!==(f.openaiResponsesBaseUrl??""))&&await w(Q.id)}catch{v(js)}})()}function A(P){X(P),k(!0)}function L(){const P=$;P!==null&&(async()=>{let M;try{M=await fetch(`/api/providers/${P}`,{method:"DELETE"})}catch{v(js);return}if(!M.ok){v(await Wt(M,"Failed to delete provider"));return}te()})()}const ne=p.useRef(null);function re(P){const M="/api/providers/export";(async()=>{try{const Q=await fetch(M);if(!Q.ok){v("Failed to export providers");return}const fe=await Q.blob(),de=URL.createObjectURL(fe),Pe=document.createElement("a");Pe.href=de,Pe.download=Q.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(Pe),Pe.click(),document.body.removeChild(Pe),URL.revokeObjectURL(de)}catch{v("Failed to export providers")}})()}function V(){ne.current?.click()}function le(P){const M=P.target.files?.[0];M&&(async()=>{try{const Q=await M.text(),fe=await fetch("/api/providers/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)}),de=await jt(fe,NA);fe.ok&&de.imported!==void 0&&de.imported>0?(te(),v(null)):de.errors&&de.errors.length>0?v(de.errors.join("; ")):v(de.message??"Import failed")}catch{v("Failed to import providers")}P.target.value=""})()}return t?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):u||f?s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"border border-border bg-background/95 shadow-sm sticky top-0 z-10 flex items-center justify-between rounded-[8px] px-3 py-2",children:s.jsx("h3",{className:"text-lg font-medium",children:f?"Edit Provider":"Add New Provider"})}),s.jsx(xA,{provider:f,onSubmit:f?I:U,onCancel:()=>{d(!1),m(void 0)}})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"border border-border bg-background/95 shadow-sm sticky top-0 z-10 flex items-center justify-between rounded-[8px] px-3 py-2",children:[s.jsx("h3",{className:"text-lg font-medium",children:"Providers"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs(Se,{variant:"outline",size:"sm",onClick:()=>re(),className:"gap-1 hover:bg-muted",children:[s.jsx(yo,{className:"size-3"}),"Export"]})}),s.jsx(Le,{children:"Download providers as JSON for backup or sharing"})]})}),s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs(Se,{variant:"outline",size:"sm",onClick:V,className:"gap-1 hover:bg-muted",children:[s.jsx(of,{className:"size-3"}),"Import"]})}),s.jsx(Le,{children:"Import providers from an exported JSON file"})]})}),s.jsx("input",{type:"file",ref:ne,accept:".json",onChange:le,style:{display:"none"}}),s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs(Se,{variant:"outline",size:"sm",onClick:()=>T(!0),className:"gap-1",children:[s.jsx($2,{className:"size-3"}),"Scan"]})}),s.jsx(Le,{children:"Detect and import provider configs from Claude Code and OpenCode"})]})}),s.jsxs(Se,{onClick:()=>d(!0),size:"sm",className:"gap-1",children:[s.jsx(Mi,{className:"size-4"}),"Add Provider"]})]})]}),S!==null&&s.jsxs("div",{className:"border border-border bg-card shadow-sm flex items-center gap-2 rounded-[8px] px-3 py-2 text-xs text-muted-foreground",children:[s.jsx("span",{className:"shrink-0",children:"Config:"}),s.jsx("span",{className:"font-mono truncate",title:S,children:S}),s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>{Kt(S).then(P=>{P&&(R(!0),setTimeout(()=>R(!1),2e3))})},className:"shrink-0 ml-auto text-muted-foreground hover:text-foreground transition-colors","aria-label":C?"Copied config file path":"Copy config file path",children:C?s.jsx(Ge,{className:"size-3 text-cyan-300"}):s.jsx(Nt,{className:"size-3"})})}),s.jsx(Le,{children:"Copy config file path to clipboard"})]})})]}),h!==null&&s.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:[s.jsx(Ir,{className:"size-4 shrink-0"}),h]}),se.length===0?s.jsxs("div",{className:"border border-border bg-card shadow-sm space-y-3 rounded-[8px] py-12 text-center",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),s.jsxs(Se,{onClick:()=>d(!0),variant:"outline",size:"sm",children:[s.jsx(Mi,{className:"size-4"}),"Add Your First Provider"]})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"border border-border bg-muted/40 flex gap-1 rounded-[8px] p-1",children:["all","personal","company"].map(P=>s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>F(P),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${B===P?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:P==="all"?"All":P==="personal"?"Personal":"Company"})}),s.jsx(Le,{children:P==="all"?"Show all providers":P==="personal"?"Providers you configured yourself":"Providers set by your organization"})]})},P))}),s.jsx("div",{ref:W,className:"space-y-3",children:oe.map(P=>s.jsx(fA,{provider:P,testResults:_e[P.id],isTesting:ie.has(P.id),testingTimeLeft:ge[P.id],isHighlighted:P.id===z,onEdit:M=>m(M),onDelete:A,onRefreshMetadata:M=>{Y(M)},isRefreshingMetadata:Z.has(P.id),onTest:M=>{w(M)}},P.id))})]}),s.jsx(V4,{open:q,onOpenChange:T,onImportComplete:()=>{i!==void 0&&i()}}),s.jsx(rp,{open:D,onOpenChange:k,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:L})]})}function Tu(){const[e,t]=p.useState(!1),[n,r]=p.useState("providers"),{providers:o,isLoading:i,mutate:a}=Sf(),[l,c]=p.useState({}),[u,d]=p.useState(new Set),[f,m]=p.useState({}),h=p.useCallback((x,b)=>{c(y=>({...y,[x]:b}))},[]),v=p.useCallback((x,b)=>{d(y=>{const _=new Set(y);return b?_.add(x):_.delete(x),_})},[]),g=p.useCallback((x,b)=>{m(y=>{if(b===void 0){const _={...y};return delete _[x],_}return{...y,[x]:b}})},[]);return s.jsxs(Wr,{open:e,onOpenChange:t,children:[s.jsx(rl,{asChild:!0,children:s.jsxs(Se,{variant:"ghost",size:"icon",className:Il,"aria-label":"Settings",title:"Settings",children:[s.jsx(Z2,{className:"size-4"}),s.jsx("span",{className:"sr-only",children:"Settings"})]})}),s.jsxs(Hr,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[s.jsx(Zr,{children:s.jsx(Vr,{children:"Settings"})}),s.jsxs(rm,{value:n,onValueChange:r,className:"flex-1 overflow-hidden",children:[s.jsxs(sm,{children:[s.jsx(ht,{value:"providers",children:"Providers"}),s.jsx(ht,{value:"proxy",children:"Proxy"}),s.jsx(ht,{value:"storage",children:"Storage"}),s.jsx(ht,{value:"mcp",children:"MCP"}),s.jsx(ht,{value:"onboarding",children:"Onboarding"})]}),s.jsxs("div",{className:"mt-4 flex-1 overflow-x-hidden overflow-y-auto pr-3",children:[s.jsx(mt,{value:"providers",children:s.jsx(RA,{externalProviders:o,isLoading:i,externalTestResults:l,externalTestingProviders:u,externalTestingTimeLeft:f,onProvidersMutate:()=>a(),onTestResultsChange:h,onTestingProvidersChange:v,onTestingTimeLeftChange:g})}),s.jsx(mt,{value:"proxy",children:s.jsx(MA,{})}),s.jsx(mt,{value:"storage",children:s.jsx(zA,{})}),s.jsx(mt,{value:"mcp",children:s.jsx(OA,{})}),s.jsx(mt,{value:"onboarding",children:s.jsx(PA,{})})]})]})]})]})}const IA=G({memoryCount:K(),logDir:N(),logFileCount:K(),logBytes:K(),chunkDir:N(),chunkFileCount:K(),chunkBytes:K(),sessionArchiveDir:N(),sessionArchiveFileCount:K(),sessionArchiveBytes:K()});function ki(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 zA(){const[e,t]=p.useState(null),[n,r]=p.useState(null),[o,i]=p.useState(!1),[a,l]=p.useState(null),c=p.useCallback(async()=>{i(!0),r(null);try{const d=await fetch("/api/logs?stats=1");if(!d.ok){r(`Failed to load storage stats: HTTP ${String(d.status)}`);return}const f=await d.json(),m=IA.safeParse(f);if(!m.success){r("Storage stats response was not valid.");return}t(m.data)}catch(d){r(d instanceof Error?d.message:String(d))}finally{i(!1)}},[]);p.useEffect(()=>{c()},[c]);const u=p.useCallback((d,f)=>{Kt(f).then(m=>{m&&(l(d),setTimeout(()=>l(null),1600))})},[]);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold",children:"Log storage"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Inspect local log and streaming chunk footprint before exporting or clearing sessions."})]}),s.jsx(Se,{type:"button",variant:"outline",size:"sm",onClick:()=>{c()},children:o?"Refreshing...":"Refresh"})]}),e!==null&&s.jsxs("div",{className:"grid gap-2 text-xs",children:[s.jsx(Nr,{id:"log-dir",label:"Log storage path",value:e.logDir,copiedId:a,onCopy:u}),s.jsx(Nr,{id:"chunk-dir",label:"Streaming chunks storage path",value:e.chunkDir,copiedId:a,onCopy:u}),s.jsx(Nr,{id:"session-archive-dir",label:"Session archive storage path",value:e.sessionArchiveDir,copiedId:a,onCopy:u}),s.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"In-memory logs"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.memoryCount.toLocaleString()," loaded"]})]}),s.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"Log files"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.logFileCount.toLocaleString()," files / ",ki(e.logBytes)]})]}),s.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"Streaming chunks"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.chunkFileCount.toLocaleString()," files / ",ki(e.chunkBytes)]})]}),s.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"Session archives"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.sessionArchiveFileCount.toLocaleString()," files /"," ",ki(e.sessionArchiveBytes)]})]})]}),n!==null&&s.jsx("p",{className:"text-xs text-destructive",children:n})]})}function Nr({id:e,label:t,value:n,copiedId:r,onCopy:o}){const i=r===e;return s.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-3 py-2",children:[s.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:t}),s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:n}),s.jsx(Se,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>o(e,n),"aria-label":i?`Copied ${t}`:`Copy ${t}`,children:i?s.jsx(Ge,{className:"size-3.5 text-emerald-500"}):s.jsx(Nt,{className:"size-3.5"})})]})]})}function PA(){const[e,t]=p.useState(null),n=p.useMemo(()=>typeof window>"u"?"http://localhost:25947":window.location.origin,[]),r=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)=>{Kt(a).then(l=>{l&&(t(i),setTimeout(()=>t(null),1600))})},[]);return s.jsxs("div",{className:"min-w-0 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ka,{className:"size-4 text-muted-foreground"}),s.jsx("h3",{className:"text-sm font-semibold",children:"Agent onboarding"})]}),s.jsx("div",{className:"grid gap-2",children:r.map(i=>s.jsx(Nr,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:o},i.id))}),s.jsxs("div",{className:"grid gap-2 rounded-md border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ge,{className:"size-3.5 text-emerald-500"}),s.jsx("span",{children:"Provider test creates a traceable memory probe session."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ge,{className:"size-3.5 text-emerald-500"}),s.jsx("span",{children:"Captured sessions can produce reviewable memory candidates."})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),s.jsxs("span",{children:["Streamable HTTP clients should use the MCP URL directly. Stdio-only clients should use",s.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."]})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),s.jsxs("span",{children:["OpenCode onboarding safely merges"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode.json"}),", then verify with"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode mcp list"}),"."]})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),s.jsxs("span",{children:["MiMo Code onboarding safely merges"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",s.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"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"OPENAI_BASE_URL"}),"."]})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),s.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 OA(){const[e,t]=p.useState(null),r=`${p.useMemo(()=>typeof window>"u"?"http://localhost:25947":window.location.origin,[])}/api/mcp`,o=p.useMemo(()=>[{id:"mcp-url",label:"Streamable HTTP MCP URL",value:r},{id:"stdio",label:"Stdio bridge command",value:`agent-inspector-mcp stdio --url ${r}`},{id:"doctor",label:"Bridge doctor",value:`agent-inspector-mcp doctor --url ${r}`},{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:r}}},null,2)},{id:"stdio-json",label:"Stdio MCP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{command:"agent-inspector-mcp",args:["stdio","--url",r]}}},null,2)},{id:"opencode-local",label:"OpenCode local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",r],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",r],enabled:!0}}},null,2)},{id:"codex-toml",label:"Codex TOML",value:`[mcp_servers.agent-inspector]
99
+ `)&&(n=n.slice(0,-1))),super.equals(t,n,r)}}const R3=new A3;function lm(e,t,n){return R3.diff(e,t,n)}function cm(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
100
+ `));const n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let o=0;o<r.length;o++){const i=r[o];o%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}class I3 extends am{constructor(){super(...arguments),this.tokenize=cm}get useLongestToken(){return!0}castInput(t,n){const{undefinedReplacement:r,stringifyReplacer:o=(i,a)=>typeof a>"u"?r:a}=n;return typeof t=="string"?t:JSON.stringify(ua(t,null,null,o),null," ")}equals(t,n,r){return super.equals(t.replace(/,([\r\n])/g,"$1"),n.replace(/,([\r\n])/g,"$1"),r)}}const z3=new I3;function P3(e,t,n){return z3.diff(e,t,n)}function ua(e,t,n,r,o){t=t||[],n=n||[],r&&(e=r(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]=ua(e[i],t,n,r,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]=ua(e[c],t,n,r,c);t.pop(),n.pop()}else a=e;return a}function eu(e){return e===void 0?[]:Object.entries(e).map(t=>[t[0].toLowerCase(),t[1]]).sort(([t],[n])=>t.localeCompare(n))}function tu([e,t]){return`${e}: ${t}`}function da(e){const t=[];let n=0,r=0;for(const o of e){const i=o.value.split(`
101
+ `);i.length>0&&i[i.length-1]===""&&i.pop();for(const a of i)o.added?(r+=1,t.push({kind:"added",text:a,oldLineNumber:null,newLineNumber:r})):o.removed?(n+=1,t.push({kind:"removed",text:a,oldLineNumber:n,newLineNumber:null})):(n+=1,r+=1,t.push({kind:"context",text:a,oldLineNumber:n,newLineNumber:r}))}return t}function O3(e,t){const n=eu(e).map(tu).join(`
102
+ `),r=eu(t).map(tu).join(`
103
+ `);if(n===r)return{lines:[],isEmpty:!0};const o=lm(n,r);return{lines:da(o),isEmpty:!1}}function nu(e){try{const t=JSON.parse(e);return t===null||typeof t=="string"||typeof t=="object"?t:null}catch{return null}}function M3(e,t){const n=e??"",r=t??"";if(n===r)return{lines:[],isEmpty:!0};const o=nu(n),i=nu(r);if(o!==null&&i!==null){const l=P3(o,i)??[];if(l.length===1){const c=l[0];if(c!==void 0&&!c.added&&!c.removed)return{lines:[],isEmpty:!0}}return{lines:da(l),isEmpty:!1}}const a=lm(n,r);return{lines:da(a),isEmpty:!1}}const L3=22,gi=1e4;function D3(e){return e==="added"?"+":e==="removed"?"-":" "}function $3(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 F3=function({result:t,emptyLabel:n}){const[r,o]=p.useState("unified"),i=p.useRef(null),a=i3({count:t.lines.length,getScrollElement:()=>i.current,estimateSize:()=>L3,overscan:10});if(t.isEmpty)return s.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>gi,u=c?t.lines.slice(0,gi):t.lines;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[s.jsxs("span",{children:[l.toLocaleString()," line",l===1?"":"s",c&&` (showing first ${gi.toLocaleString()})`]}),s.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[s.jsxs("button",{type:"button",onClick:()=>o("unified"),"aria-pressed":r==="unified",className:le("flex items-center gap-1 px-2 py-1 transition-colors",r==="unified"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Unified diff (single column)",children:[s.jsx(D2,{className:"size-3"}),"Unified"]}),s.jsxs("button",{type:"button",onClick:()=>o("split"),"aria-pressed":r==="split",className:le("flex items-center gap-1 px-2 py-1 transition-colors border-l border-border",r==="split"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Split diff (side by side)",children:[s.jsx($y,{className:"size-3"}),"Split"]})]})]}),s.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:r==="unified"?s.jsx(B3,{virtualizer:a,lines:u}):s.jsx(H3,{lines:u})})]})};function B3({virtualizer:e,lines:t}){return s.jsx("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:e.getVirtualItems().map(n=>{const r=t[n.index];return r===void 0?null:s.jsxs("div",{"data-index":n.index,ref:e.measureElement,className:le("flex items-start gap-3 px-2",$3(r.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${n.start}px)`},children:[s.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:r.oldLineNumber??""}),s.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:r.newLineNumber??""}),s.jsx("span",{className:le("select-none w-3 text-right font-bold",r.kind==="added"&&"text-green-600 dark:text-green-400",r.kind==="removed"&&"text-red-600 dark:text-red-400"),children:D3(r.kind)}),s.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:r.text})]},n.key)})})}function U3(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(r===void 0)break;if(r.kind==="context"){t.push({left:{text:r.text,lineNumber:r.oldLineNumber},right:{text:r.text,lineNumber:r.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 W3(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 H3({lines:e}){const t=U3(e);return s.jsx("div",{"data-testid":"diff-split",children:t.map((n,r)=>s.jsxs("div",{className:le("grid grid-cols-2 font-mono text-xs",W3(n.kind)),children:[s.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[s.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.left?.lineNumber??""}),s.jsx("span",{className:le("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?"-":" "}),s.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.left?.text??""})]}),s.jsxs("div",{className:"flex items-start gap-2 px-2",children:[s.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.right?.lineNumber??""}),s.jsx("span",{className:le("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?"+":" "}),s.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.right?.text??""})]})]},r))})}const um=p.memo(F3),Z3=il("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 Be({className:e,variant:t="default",asChild:n=!1,...r}){const o=n?Dk:"span";return s.jsx(o,{"data-slot":"badge","data-variant":t,className:le(Z3({variant:t}),e),...r})}const V3={success:"bg-slate-300/[0.08] text-slate-100 border-slate-300/20",client_error:"bg-amber-300/[0.10] text-amber-100 border-amber-300/30",server_error:"bg-rose-400/[0.10] text-rose-100 border-rose-300/30",pending:"bg-cyan-300/[0.08] text-cyan-100 border-cyan-300/25"},q3={success:{frame:"border-cyan-200/15 bg-white/[0.04] text-slate-100",dot:"bg-cyan-200/80 shadow-[0_0_14px_rgba(125,211,252,0.65)]"},client_error:{frame:"border-amber-300/25 bg-amber-300/[0.08] text-amber-100",dot:"bg-amber-200 shadow-[0_0_14px_rgba(252,211,77,0.8)]"},server_error:{frame:"border-rose-300/25 bg-rose-300/[0.08] text-rose-100",dot:"bg-rose-300 shadow-[0_0_14px_rgba(253,164,175,0.8)]"},pending:{frame:"border-cyan-300/25 bg-cyan-300/[0.08] text-cyan-100",dot:"bg-cyan-200 shadow-[0_0_14px_rgba(103,232,249,0.8)]"}},vr="border border-input bg-background hover:bg-accent hover:text-accent-foreground size-8 text-muted-foreground shadow-none hover:text-cyan-100",kt="border border-border bg-muted/40 flex h-7 items-center gap-1 rounded-md px-2 text-xs";function yr(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function K3(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function G3(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 ru({trend:e}){if(e===null)return null;const t=e.direction==="up",n=t?ny:J1,r=t?"+":"-";return s.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[s.jsx(n,{className:t?"size-3 text-cyan-300":"size-3 text-rose-400"}),s.jsxs("span",{className:"font-mono",children:[r,$e(e.delta)]})]})}const J3=p.memo(function({log:e,displayNumber:t,messageCount:n=null,toolCount:r=null,expanded:o,onToggle:i,cacheTrend:a=null,activeTab:l,tabActions:c,onReplay:u,slowResponseThresholdSeconds:d=0,showClientMetadata:f=!0,timeDisplayFormat:m}){const h=Tk(e.responseStatus),v=e.elapsedMs!==null&&d>0&&e.elapsedMs>d*1e3,g=e.inputTokens!==null||e.outputTokens!==null,x=e.firstChunkMs??null,b=e.tokensPerSecond??null,y=x===null?null:yr(x),_=b===null||b<=0?null:K3(b),j=e.warnings?.length??0,S=e.clientPid!==null&&e.clientPid!==void 0,E=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="",C=e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd!=="",R=q3[h],z=G3(h,e.responseStatus),O=h!=="success"||e.responseStatus!==200,q=e.streaming&&y===null&&_===null;return s.jsx(Je,{children:s.jsxs("div",{id:`log-${e.id}`,role:"button",tabIndex:0,"data-nav-id":`log-${e.id}`,"data-nav-action":o?"collapse":"expand",className:le("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]",o?"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.10)]":"bg-transparent hover:bg-white/[0.035]","select-none before:pointer-events-none before:absolute before:inset-x-3 before:top-0 before:h-px before:bg-white/12","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),onClick:i,onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),i())},children:[s.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsxs("span",{className:le("border border-border bg-muted/40 inline-flex h-8 shrink-0 items-center gap-2 rounded-md px-2 font-mono",R.frame),children:[s.jsx("span",{className:le("size-1.5 rounded-full",R.dot),"aria-hidden":"true"}),s.jsxs("span",{className:"text-xs font-semibold tabular-nums",title:`Log ID ${String(e.id)}`,children:["#",t]})]}),s.jsxs("span",{className:"border border-border bg-muted/40 flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-xs text-muted-foreground",children:[s.jsx(Ht,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:Hi(e.timestamp,m)})]}),O&&s.jsxs(Be,{variant:"outline",className:le("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)]",V3[h]),children:[h==="success"?s.jsx(Ge,{className:"size-3","aria-label":"Success"}):h==="server_error"?s.jsx(E2,{className:"size-3","aria-label":"Server error"}):h==="client_error"?s.jsx(rn,{className:"size-3","aria-label":"Client error"}):s.jsx(ft,{className:"size-3 animate-spin","aria-label":"Pending"}),z]}),j>0&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs(Be,{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:[s.jsx(rn,{className:"size-3","aria-label":"Tool schema warnings"}),j]})}),s.jsx(Le,{children:j===1?"1 tool schema warning":`${j} tool schema warnings`})]}),e.elapsedMs!==null&&(v?s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs("span",{className:le(kt,"shrink-0 border-amber-300/25 text-amber-200"),children:[s.jsx(Ht,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:yr(e.elapsedMs)}),s.jsx(rn,{className:"size-3","aria-label":"Slow response"})]})}),s.jsxs(Le,{children:["Slow response: ",yr(e.elapsedMs)," exceeds"," ",yr(d*1e3)]})]}):s.jsxs("span",{className:le(kt,"shrink-0 text-muted-foreground"),children:[s.jsx(Ht,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:yr(e.elapsedMs)})]})),e.streaming&&y!==null&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs("span",{className:le(kt,"shrink-0 text-cyan-300"),children:[s.jsx(lc,{className:"size-3"}),s.jsxs("span",{className:"font-mono tabular-nums",children:["first ",y]})]})}),s.jsx(Le,{children:"Time to first streaming chunk"})]}),e.streaming&&_!==null&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs("span",{className:le(kt,"shrink-0 text-cyan-300"),children:[s.jsx(Ga,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:_})]})}),s.jsx(Le,{children:"Output token throughput after first chunk"})]}),g&&s.jsxs("span",{className:le(kt,"min-w-0 sm:shrink-0"),children:[s.jsx(Pr,{className:"size-3 text-muted-foreground"}),s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 font-mono tabular-nums",children:[s.jsxs("span",{className:le("whitespace-nowrap",e.inputTokens!==null?"text-blue-400":"text-muted-foreground"),children:["IN ",e.inputTokens!==null?$e(e.inputTokens):"n/a"]}),s.jsx("span",{className:"text-muted-foreground",children:"/"}),s.jsxs("span",{className:le("whitespace-nowrap",e.outputTokens!==null?"text-amber-400":"text-muted-foreground"),children:["OUT ",e.outputTokens!==null?$e(e.outputTokens):"n/a"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&s.jsxs("span",{className:le(kt,"shrink-0"),children:[s.jsx(ru,{trend:a?.creation??null}),s.jsxs("span",{className:"font-mono tabular-nums text-cyan-300",children:["KV Cache +",$e(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&s.jsxs("span",{className:le(kt,"shrink-0"),children:[s.jsx(ru,{trend:a?.read??null}),s.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",$e(e.cacheReadInputTokens)]})]}),n!==null&&s.jsxs("span",{className:le(kt,"shrink-0 text-muted-foreground"),children:[s.jsx(ko,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:n})]}),r!==null&&s.jsxs("span",{className:le(kt,"shrink-0 text-muted-foreground"),children:[s.jsx(Wr,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:r})]}),e.origin!==null&&s.jsxs("span",{className:le(kt,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[s.jsx(of,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),f&&(S||E)&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs("span",{className:le(kt,"hidden shrink-0 text-purple-300 xl:flex"),children:[s.jsx(n2,{className:"size-3"}),E?s.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):s.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]})}),s.jsx(Le,{children:C?`PID: ${e.clientPid??"?"} CWD: ${e.clientCwd}`:`Process ID: ${e.clientPid??"?"}`})]}),q&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx(lc,{className:"size-3 text-muted-foreground/60 shrink-0"})}),s.jsx(Le,{children:"Request used SSE streaming"})]})]}),s.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[o&&s.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",onClick:T=>T.stopPropagation(),onKeyDown:T=>T.stopPropagation(),children:[c!==void 0&&l!==void 0&&(()=>{const T=c[l];return T===void 0?null:s.jsxs(s.Fragment,{children:[T.expansion!==null&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx(Se,{variant:"outline",size:"icon",className:vr,onClick:T.expansion.onToggle,disabled:T.expansion.isPending,"aria-pressed":T.expansion.isExpanded,"aria-label":T.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:T.expansion.isExpanded?s.jsx(wy,{className:"size-3.5"}):s.jsx(my,{className:"size-3.5"})})}),s.jsx(Le,{children:T.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),T.diffWithRaw!==void 0&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx(Se,{variant:"outline",size:"icon",className:le(vr,T.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:T.diffWithRaw.onToggle,"aria-pressed":T.diffWithRaw.active,"aria-label":T.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:s.jsx(Xy,{className:"size-3.5"})})}),s.jsx(Le,{children:T.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),T.diffWithPrevious!==void 0&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx(Se,{variant:"outline",size:"icon",className:vr,onClick:T.diffWithPrevious,"aria-label":"Diff with previous",children:s.jsx(h2,{className:"size-3.5"})})}),s.jsx(Le,{children:"Compare this request with the immediately preceding one"})]}),T.copyText!==null&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx(Se,{variant:"outline",size:"icon",className:vr,onClick:T.onCopy,"aria-label":T.copyCopied?"Copied":T.copyLabel,children:T.copyCopied?s.jsx(Ge,{className:"size-3.5 text-cyan-300"}):s.jsx(Nt,{className:"size-3.5"})})}),s.jsx(Le,{children:T.copyCopied?"Copied to clipboard":T.copyLabel})]})]})})(),u!==void 0&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx(Se,{variant:"outline",size:"icon",className:vr,onClick:u,"aria-label":"Replay request",children:s.jsx(O2,{className:"size-3.5"})})}),s.jsx(Le,{children:"Re-send this request to the provider"})]})]}),s.jsx("span",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex size-8 shrink-0 items-center justify-center rounded-md text-slate-200","aria-hidden":"true",children:o?s.jsx(st,{className:"size-4 shrink-0"}):s.jsx(bt,{className:"size-4 shrink-0"})})]})]})})});function Y3({...e}){return s.jsx(Zj,{"data-slot":"collapsible",...e})}function oz({...e}){return s.jsx(dp,{"data-slot":"collapsible-trigger",...e})}function X3({...e}){return s.jsx(fp,{"data-slot":"collapsible-content",...e})}function Q3({className:e,children:t,...n}){return s.jsxs(LC,{"data-slot":"scroll-area",className:le("relative overflow-hidden",e),...n,children:[s.jsx(DC,{"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}),s.jsx(eT,{}),s.jsx($C,{})]})}function eT({className:e,orientation:t="vertical",...n}){return s.jsx(Kp,{"data-slot":"scroll-area-scrollbar",orientation:t,className:le("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:s.jsx(Xp,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const dm={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},tT={file:"border-blue-400/20 bg-blue-400/5 text-blue-300",shell:"border-teal-400/20 bg-teal-400/5 text-teal-300",browser:"border-cyan-400/20 bg-cyan-400/5 text-cyan-300",web:"border-sky-400/20 bg-sky-400/5 text-sky-300",mcp:"border-violet-400/20 bg-violet-400/5 text-violet-300",code:"border-emerald-400/20 bg-emerald-400/5 text-emerald-300",other:"border-muted-foreground/20 bg-muted/30 text-muted-foreground"};function nT({category:e}){switch(e){case"file":return s.jsx(s2,{className:"size-3.5"});case"shell":return s.jsx(Ja,{className:"size-3.5"});case"browser":return s.jsx(N2,{className:"size-3.5"});case"web":return s.jsx(of,{className:"size-3.5"});case"mcp":return s.jsx(iy,{className:"size-3.5"});case"code":return s.jsx(Ly,{className:"size-3.5"});case"other":return s.jsx(Zy,{className:"size-3.5"})}}function rT({names:e}){return e.length===0?null:s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"required"}),e.slice(0,4).map(t=>s.jsx(Be,{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&&s.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e.length-4]})]})}function sT({tool:e,called:t}){const[n,r]=p.useState(!1),o=Ut(e.name),i=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return s.jsx(Y3,{open:n,onOpenChange:r,children:s.jsxs("div",{className:"border border-border bg-card shadow-sm rounded-[8px]",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",children:[s.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:()=>r(a=>!a),"aria-expanded":n,disabled:!i,children:[s.jsx(nT,{category:e.category}),s.jsx("span",{className:"min-w-0 truncate font-mono text-xs font-semibold text-foreground/90",children:e.name}),t&&s.jsx(Be,{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"}),s.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:[e.parameterCount," params"]}),e.descriptionPreview!==null&&s.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground md:inline",children:e.descriptionPreview}),s.jsx("span",{className:"flex-1"}),i&&(n?s.jsx(st,{className:"size-3.5 shrink-0 text-muted-foreground"}):s.jsx(bt,{className:"size-3.5 shrink-0 text-muted-foreground"}))]}),s.jsx("button",{type:"button",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground 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?s.jsx(Ge,{className:"size-3.5 text-emerald-400"}):s.jsx(Nt,{className:"size-3.5"})})]}),s.jsx(X3,{children:n&&s.jsxs("div",{className:"space-y-2 border-t border-white/10 bg-white/[0.025] px-2.5 py-2",children:[e.description!==null&&s.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e.description}),s.jsx(rT,{names:e.requiredParameters}),e.schema!==null&&s.jsx(Q3,{className:"border border-border bg-card shadow-sm max-h-64 rounded-[8px] p-2",children:s.jsx(p.Suspense,{fallback:s.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:s.jsx(ca,{data:to(e.schema),defaultExpandDepth:0})})})]})})]})})}function oT(e,t){return t.length===0?!0:`${e.name} ${e.description??""} ${dm[e.category]}`.toLowerCase().trim().includes(t)}const iT=p.memo(function({summary:t,calledToolNames:n}){const[r,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=>oT(m,c)),[c,t]);if(t===null)return null;const d=t.tools.slice(0,6),f=t.tools.length-d.length;return s.jsxs("section",{className:"border border-border bg-card shadow-sm mb-3 overflow-hidden rounded-[8px]",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx(Wr,{className:"size-4 shrink-0 text-sky-300/80"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Request Tools"}),s.jsx(Be,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",children:t.tools.length}),t.toolChoiceLabel!==null&&s.jsxs(Be,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px] text-muted-foreground",children:["tool_choice: ",t.toolChoiceLabel]})]}),s.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap gap-1",children:t.categories.map(m=>s.jsxs(Be,{variant:"outline",className:le("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",tT[m.category]),children:[m.count," ",dm[m.category]]},m.category))})]})]}),s.jsxs(Se,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-cyan-100",onClick:()=>o(m=>!m),"aria-expanded":r,children:[r?s.jsx(st,{className:"size-3.5"}):s.jsx(bt,{className:"size-3.5"}),r?"Hide":"Show"]})]}),s.jsxs("div",{className:"flex min-w-0 flex-wrap gap-1.5 border-t border-white/10 bg-white/[0.025] px-3 py-2",children:[d.map(m=>s.jsx(Be,{variant:"outline",className:le("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&&s.jsxs("span",{className:"font-mono text-[10px] leading-5 text-muted-foreground",children:["+",f]})]}),r&&s.jsxs("div",{className:"space-y-2 border-t border-white/10 bg-black/10 px-3 py-3",children:[s.jsxs("label",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex h-8 items-center gap-2 rounded-md px-2 text-xs",children:[s.jsx(H2,{className:"size-3.5 shrink-0 text-muted-foreground"}),s.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"})]}),s.jsx("div",{className:"grid gap-1.5",children:u.length>0?u.map(m=>s.jsx(sT,{tool:m,called:l.has(m.name)},m.name)):s.jsx("p",{className:"py-2 text-xs text-muted-foreground",children:"No matching tools"})})]})]})});function su(e,t,n){return e==="anthropic"&&t==="full"&&n}function aT(e,t){return e==="full"&&t}function lT(e,t,n,r){return e==="anthropic"&&t==="full"&&n&&r}const cT=["file","shell","browser","web","mcp","code","other"];function fa(e){const t=e.replace(/\s+/g," ").trim();return t.length<=120?t:`${t.slice(0,119)}...`}function fm(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?fa(t.slice(0,n+1)):fa(t)}function uT(e,t){return`${e} ${t??""}`.toLowerCase()}function $n(e,t){return t.some(n=>e.includes(n))}function pm(e,t){const n=uT(e,t);return e.startsWith("mcp__")||e.startsWith("inspector_")||$n(n,[" mcp","model context protocol"])?"mcp":$n(n,["bash","shell","terminal","command","powershell","exec","process"])?"shell":$n(n,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":$n(n,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":$n(n,["web","search","http","url","fetch"])?"web":$n(n,["code","typescript","javascript","python","repl"])?"code":"other"}function hm(e){const t=ke(e,"properties");return t===null||typeof t!="object"||Array.isArray(t)?[]:Object.keys(t).sort((n,r)=>n.localeCompare(r))}function mm(e){const t=ke(e,"required");if(!Array.isArray(t))return[];const n=[];for(const r of t)typeof r=="string"&&r.length>0&&n.push(r);return n.sort((r,o)=>r.localeCompare(o))}function dT(e){const t=ke(e,"name");if(typeof t!="string"||t.length===0)return null;const n=ke(e,"description"),r=ke(e,"input_schema")??null,o=typeof n=="string"?n:null;return{name:t,description:o,descriptionPreview:fm(o),category:pm(t,o),parameterCount:hm(r).length,requiredParameters:mm(r),schema:r}}function fT(e){const t=ke(e,"function"),n=ke(e,"type");if(t===void 0&&n!=="function")return null;const r=ke(t,"name")??ke(e,"name");if(typeof r!="string"||r.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:r,description:a,descriptionPreview:fm(a),category:pm(r,a),parameterCount:hm(i).length,requiredParameters:mm(i),schema:i}}function pT(e){const t=fT(e);return t!==null?t:dT(e)}function hT(e){if(e==null)return null;if(typeof e=="string")return e;const t=ke(e,"type"),n=ke(e,"name"),r=ke(ke(e,"function"),"name");if(typeof t=="string"&&typeof r=="string"&&r.length>0)return`${t}: ${r}`;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:fa(o)}function mT(e){const t=new Map;for(const n of e)t.set(n.category,(t.get(n.category)??0)+1);return cT.flatMap(n=>{const r=t.get(n)??0;return r>0?[{category:n,count:r}]:[]})}function gT(e){const t=ke(e,"tools");if(!Array.isArray(t)||t.length===0)return null;const n=[];for(const r of t){const o=pT(r);o!==null&&n.push(o)}return n.length===0?null:{tools:n,toolChoiceLabel:hT(ke(e,"tool_choice")),categories:mT(n)}}function Fn(){return s.jsx("div",{className:"h-1","aria-hidden":"true"})}function xT(e,t){switch(e){case"anatomy":return t===null?"request":"anatomy";case"request":return"request"}}const bT=15e3,vT=15e3,yT=256*1024,no=1024*1024,xn="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:border-white/10 hover:bg-white/[0.045] hover:text-foreground data-[state=active]:border-cyan-200/25 data-[state=active]:bg-cyan-300/[0.08] data-[state=active]:text-cyan-100 data-[state=active]:shadow-none";function gs(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function ro(e){return e??0}function gm(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function xm(e){return gm(e)?ro(e.rawRequestBodyBytes)>no||ro(e.responseTextBytes)>no:!1}function wT(e){return gm(e)&&!xm(e)}function kT(e){return e instanceof Oa?"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 xs({status:e,error:t,footprint:n,onRetry:r}){switch(e){case"idle":return null;case"loading":return s.jsx($r,{tone:"loading",title:"Loading full bodies",children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(ft,{className:"size-3.5 shrink-0 animate-spin text-cyan-200"}),s.jsx("span",{children:"Loading full request and response bodies from the log store."})]}),n!==null&&s.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 s.jsx($r,{tone:"warning",title:t?.title??"Full bodies could not be loaded",children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx("span",{children:t?.detail??"Compact metadata is still available."}),s.jsxs(Se,{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:r,children:[s.jsx(zr,{className:"size-3"}),"Retry"]})]})})}}function ou(e,t){return e?t.text!==""?t.text:t.status==="success"?"":null:null}function bn({children:e,className:t}){return s.jsx("div",{className:le("border border-border bg-card shadow-sm inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",t),children:e})}function zs({children:e}){return s.jsx("div",{className:"border border-border bg-muted/40 rounded-md border-dashed px-3 py-5 text-center text-xs italic text-muted-foreground",children:e})}function bs({children:e}){return s.jsx("pre",{className:"border border-border bg-card shadow-sm 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 _T={loading:"border-cyan-400/25 bg-cyan-400/[0.06] text-cyan-100",warning:"border-amber-400/25 bg-amber-400/[0.08] text-amber-100",danger:"border-rose-400/25 bg-rose-400/[0.08] text-rose-100"};function $r({tone:e,title:t,children:n}){return s.jsxs("div",{className:le("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",_T[e]),children:[t!==void 0&&s.jsx("div",{className:"mb-1 font-semibold",children:t}),s.jsx("div",{className:"leading-relaxed text-muted-foreground",children:n})]})}function vs({label:e,state:t,expectedBytes:n,onLoadMore:r}){const o=t.totalBytes??n,i=o===null?qn(t.offset):`${qn(t.offset)} / ${qn(o)}`,a=t.status!=="loading"&&t.hasMore,l=t.status==="failed"?"Retry":"Load more";return s.jsx($r,{tone:t.status==="failed"?"warning":"loading",title:`${e} body preview`,children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("span",{children:[t.status==="idle"&&o!==null?`${e} body is ${qn(o)}. Loading the first preview chunk.`:`Loaded ${i}.`,t.status==="failed"&&t.error!==null&&` ${t.error}`]}),a&&s.jsx(Se,{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:r,children:l})]})})}function iu({headers:e,emptyLabel:t}){const n=e===void 0?[]:Object.entries(e).sort(([r],[o])=>r.localeCompare(o));return n.length===0?s.jsx(zs,{children:t}):s.jsx("div",{className:"border border-border bg-card shadow-sm overflow-hidden rounded-[8px] font-mono text-xs",children:n.map(([r,o])=>s.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(140px,0.32fr)_minmax(0,1fr)] border-b border-white/10 last:border-b-0",children:[s.jsx("div",{className:"min-w-0 truncate border-r border-white/10 bg-white/[0.035] px-2.5 py-2 font-semibold text-cyan-200",children:r}),s.jsx("div",{className:"min-w-0 truncate px-2.5 py-2 text-muted-foreground",title:o,children:o})]},r))})}function jT({active:e,onClick:t}){return s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs(Se,{variant:e?"default":"outline",size:"sm",className:le("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:[s.jsx(d2,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),s.jsx(Le,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const ST=p.memo(function({rawBody:e,displayedBody:t,emptyLabel:n}){const r=p.useMemo(()=>M3(e,t),[e,t]);return s.jsx(um,{result:r,emptyLabel:n})}),CT=p.memo(function({rawHeaders:e,headers:t,emptyLabel:n}){const r=p.useMemo(()=>O3(e,t),[e,t]);return s.jsx(um,{result:r,emptyLabel:n})}),NT=p.memo(function({log:e,displayNumber:t,viewMode:n="simple",strip:r,slowResponseThresholdSeconds:o,timeDisplayFormat:i,cacheTrend:a=null,onCompareWithPrevious:l,showClientMetadata:c=!0}){const[u,d]=p.useState(!1),[f,m]=p.useState(!1),[h,v]=p.useState(!1),[g,x]=p.useState(!1),[b,y]=p.useState("request"),[_,j]=p.useState(null),[S,E]=p.useState(null),[C,R]=p.useState("idle"),[z,O]=p.useState(null),[q,T]=p.useState(0),[D,k]=p.useState(()=>gs(e.rawRequestBodyBytes??null)),[$,X]=p.useState(()=>gs(e.responseTextBytes??null)),B=p.useRef(null),F=p.useRef(e.id),Z=p.useRef(!1),J=S??e,H=S===null&&xm(e),W=p.useMemo(()=>T3(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),ce=ou(H,D),se=ou(H,$),oe=J.rawRequestBody??ce,_e=J.responseText??se,ie=J.rawRequestBody===null&&ce!==null,ge=J.responseText===null&&se!==null,he=!ie||D.hasMore===!1&&ro(D.totalBytes)<=no,xe=!ge||$.hasMore===!1&&ro($.totalBytes)<=no,te=Lr(J),ue=em(te),be=p.useMemo(()=>ue.analyzeRequest(J.rawRequestBody),[ue,J.rawRequestBody]),w=p.useMemo(()=>ue.analyzeResponse(J.responseText),[ue,J.responseText]),U=p.useMemo(()=>!r||te!=="anthropic"||J.rawRequestBody===null?null:f3(J.rawRequestBody).body,[J.rawRequestBody,te,r])??oe,I=mi(he?U:null),A=mi(b==="raw-request"&&he?oe:null),L=mi(b==="raw"&&xe?_e:null),ne=p.useMemo(()=>J.headers&&Object.keys(J.headers).length>0?JSON.stringify(J.headers,null,2):null,[J.headers]),re=p.useMemo(()=>J.rawHeaders&&Object.keys(J.rawHeaders).length>0?JSON.stringify(J.rawHeaders,null,2):null,[J.rawHeaders]),V=Ut(U),ae=Ut(oe),P=Ut(ne),M=Ut(re),Q=Ut(_e),fe=p.useMemo(()=>({request:{copyLabel:ie?"Copy loaded request preview":"Copy request body",copyText:U,copyCopied:V.copied,onCopy:V.copy,expansion:he?{isExpanded:I.isExpanded,isPending:I.isPending,onToggle:I.toggle}:null,diffWithRaw:lT(te,n,r,J.rawRequestBody!==null)?{active:g,onToggle:()=>x(!g)}:void 0,diffWithPrevious:l===void 0?void 0:()=>{l(J)}},"raw-request":{copyLabel:ie?"Copy loaded raw request preview":"Copy raw request",copyText:oe,copyCopied:ae.copied,onCopy:ae.copy,expansion:he?{isExpanded:A.isExpanded,isPending:A.isPending,onToggle:A.toggle}:null},headers:{copyLabel:"Copy headers",copyText:ne,copyCopied:P.copied,onCopy:P.copy,expansion:null},"raw-headers":{copyLabel:"Copy raw headers",copyText:re,copyCopied:M.copied,onCopy:M.copy,expansion:null},raw:{copyLabel:ge?"Copy loaded response preview":"Copy response",copyText:_e,copyCopied:Q.copied,onCopy:Q.copy,expansion:xe?{isExpanded:L.isExpanded,isPending:L.isPending,onToggle:L.toggle}:null}}),[U,ie,he,V,I,g,J,J.rawRequestBody,oe,ae,A,ne,P,re,M,J.responseText,ge,xe,_e,Q,L,te,n,r,l]),de=p.useMemo(()=>I.parsedData!==null?ue.anatomySegments(I.parsedData):null,[ue,I.parsedData]),Pe=p.useMemo(()=>gT(I.parsedData),[I.parsedData]),Ue=J.warnings??[],Ne=p.useMemo(()=>{if(de!==null)return new Set(de.map(Re=>Re.path))},[de]),pt=N3({containerRef:B,setExpandToPath:j,ensureTabActive:()=>{b!=="request"&&y("request")}}),ze=p.useCallback((Re,Et)=>{const Ft=Re==="request"?k:X;Ft(at=>({...at,status:"loading",error:null}));const Ko=new URLSearchParams({part:Re,offset:String(Et),limit:String(yT)});tr(`/api/logs/${String(e.id)}/body?${Ko.toString()}`,Gv,vT).then(at=>{F.current===e.id&&Ft(zn=>({status:"success",text:at.offset===0?at.text:`${zn.text}${at.text}`,offset:at.nextOffset??at.totalBytes,totalBytes:at.totalBytes,hasMore:at.hasMore,error:null}))}).catch(at=>{F.current===e.id&&Ft(zn=>({...zn,status:"failed",error:kT(at)}))})},[e.id]),$t=p.useCallback(()=>{Z.current||(E(null),R("idle"),O(null),T(Re=>Re+1))},[]),hr=p.useCallback(()=>{const Re=!u;Re&&y(de!==null?"anatomy":"request"),d(Re)},[de,u]);return p.useEffect(()=>{F.current=e.id,Z.current=!1,E(null),R("idle"),O(null),T(0),k(gs(e.rawRequestBodyBytes??null)),X(gs(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),p.useEffect(()=>{if(!u||!wT(e)||S!==null||Z.current)return;let Re=!1;return Z.current=!0,R("loading"),O(null),tr(`/api/logs/${String(e.id)}`,Rr,bT).then(Et=>{Re||(Z.current=!1,E(Et),R("idle"),O(null))}).catch(Et=>{Re||(Z.current=!1,R("failed"),O(E3(Et)))}),()=>{Re=!0,Z.current=!1}},[u,S,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,q]),p.useEffect(()=>{u&&H&&D.status==="idle"&&(b!=="request"&&b!=="raw-request"&&b!=="anatomy"||ze("request",0))},[b,u,ze,D.status,H]),p.useEffect(()=>{u&&H&&$.status==="idle"&&(b!=="parsed"&&b!=="raw"||ze("response",0))},[b,u,ze,$.status,H]),p.useEffect(()=>{const Re=Et=>{const Ft=Vo(Et);Ft!==null&&Ft.logId===e.id&&(d(!0),y(xT(Ft.tab,de)))};return window.addEventListener(qt,Re),()=>{window.removeEventListener(qt,Re)}},[de,e.id]),s.jsxs(Je,{children:[s.jsxs("div",{className:le("border border-border bg-card shadow-sm relative mb-2 overflow-hidden rounded-[8px] transition-[background-color,border-color,box-shadow]",u?"border-cyan-200/25 shadow-[0_24px_80px_rgba(0,0,0,0.36),0_0_0_1px_rgba(103,232,249,0.05),inset_0_1px_0_rgba(255,255,255,0.14)]":"hover:border-cyan-200/18"),children:[s.jsx("div",{className:le("pointer-events-none absolute inset-y-3 left-1 w-px rounded-full",u?"bg-cyan-200/55 shadow-[0_0_20px_rgba(103,232,249,0.26)]":"bg-white/12"),"aria-hidden":"true"}),s.jsx("div",{className:"pointer-events-none absolute inset-x-3 top-0 h-px bg-gradient-to-r from-transparent via-white/15 to-transparent","aria-hidden":"true"}),s.jsx(J3,{log:J,displayNumber:t,messageCount:be.messageCount,toolCount:be.toolCount,expanded:u,onToggle:hr,cacheTrend:a,slowResponseThresholdSeconds:o,showClientMetadata:c,timeDisplayFormat:i,activeTab:b,tabActions:fe,onReplay:l===void 0?void 0:()=>{m(!0)}}),u&&s.jsxs("div",{className:"relative border-t border-white/10 bg-black/[0.18] pt-2",onClick:Re=>Re.stopPropagation(),onKeyDown:Re=>Re.stopPropagation(),children:[s.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"}),s.jsxs(om,{value:b,onValueChange:y,className:"gap-2",children:[s.jsxs(im,{variant:"line",className:"border border-border bg-muted/40 inspector-scrollbar relative mx-3 h-auto w-[calc(100%-1.5rem)] justify-start overflow-x-auto rounded-[8px] p-1",children:[n==="full"&&s.jsx(ht,{className:xn,value:"raw-headers",children:"Raw Headers"}),n==="full"&&s.jsx(ht,{className:xn,value:"headers",children:"Headers"}),de!==null&&s.jsx(ht,{className:xn,value:"anatomy",children:"Context"}),su(te,n,r)&&s.jsx(ht,{className:xn,value:"raw-request",children:"Raw Request"}),s.jsx(ht,{className:xn,value:"request",children:"Request"}),n==="full"&&s.jsx(ht,{className:xn,value:"raw",children:"Raw Response"}),s.jsx(ht,{className:xn,value:"parsed",children:"Response"})]}),su(te,n,r)&&s.jsx(mt,{value:"raw-request",children:b==="raw-request"&&s.jsxs(bn,{children:[s.jsx(xs,{status:C,error:z,footprint:W,onRetry:$t}),H&&s.jsx(vs,{label:"Request",state:D,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ze("request",D.offset)}),oe===null?s.jsx(zs,{children:H?"Request preview is loading":"No request body"}):A.parsedData!==null?s.jsx(p.Suspense,{fallback:s.jsx(Fn,{}),children:s.jsx(ca,{data:A.parsedData,bulkDepth:A.bulkDepth,bulkRevision:A.bulkRevision})}):s.jsx(bs,{children:oe})]})}),s.jsx(mt,{value:"request",children:b==="request"&&s.jsxs(bn,{children:[s.jsx(xs,{status:C,error:z,footprint:W,onRetry:$t}),H&&s.jsx(vs,{label:"Request",state:D,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ze("request",D.offset)}),Ue.length>0&&s.jsxs($r,{tone:"warning",children:[s.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[s.jsx(rn,{className:"size-3.5"}),"Tool schema warnings"]}),s.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:Ue.map(Re=>s.jsx("li",{children:Re},Re))})]}),s.jsx(iT,{summary:Pe,calledToolNames:w.toolNames??[]}),g?s.jsx(ST,{rawBody:J.rawRequestBody,displayedBody:U,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):s.jsx("div",{ref:B,children:U===null?s.jsx(zs,{children:H?"Request preview is loading":"No request body"}):I.parsedData!==null?s.jsx(p.Suspense,{fallback:s.jsx(Fn,{}),children:s.jsx(ca,{data:I.parsedData,bulkDepth:I.bulkDepth,bulkRevision:I.bulkRevision,anatomyPaths:Ne,expandToPath:_})}):s.jsx(bs,{children:U})})]})}),de!==null&&s.jsx(mt,{value:"anatomy",children:b==="anatomy"&&s.jsx(bn,{className:"p-0",children:s.jsx(p.Suspense,{fallback:s.jsx(Fn,{}),children:s.jsx(w3,{parsed:I.parsedData,inputTokens:J.inputTokens??null,model:J.model,segments:de,onSegmentActivate:pt})})})}),n==="full"&&s.jsx(mt,{value:"headers",children:b==="headers"&&s.jsxs(bn,{children:[s.jsx("div",{className:"flex justify-end gap-2 mb-2",children:aT(n,J.rawHeaders!==void 0&&Object.keys(J.rawHeaders).length>0)&&s.jsx(jT,{active:h,onClick:Re=>{Re.stopPropagation(),v(!h)}})}),h?s.jsx(CT,{rawHeaders:J.rawHeaders,headers:J.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):s.jsx(iu,{headers:J.headers,emptyLabel:"No headers captured"})]})}),n==="full"&&s.jsx(mt,{value:"raw-headers",children:b==="raw-headers"&&s.jsx(bn,{children:s.jsx(iu,{headers:J.rawHeaders,emptyLabel:"No raw headers captured"})})}),s.jsx(mt,{value:"raw",children:b==="raw"&&s.jsxs(bn,{className:"space-y-3",children:[s.jsx(xs,{status:C,error:z,footprint:W,onRetry:$t}),H&&s.jsx(vs,{label:"Response",state:$,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ze("response",$.offset)}),J.error!==void 0&&J.error!==null&&s.jsx($r,{tone:"danger",title:"SSE Error",children:s.jsx("span",{className:"font-mono",children:J.error})}),_e!==null&&xe?s.jsx(p.Suspense,{fallback:s.jsx(Fn,{}),children:s.jsx(j3,{text:_e,defaultExpandDepth:0,bulkDepth:L.bulkDepth,bulkRevision:L.bulkRevision})}):_e!==null?s.jsx(bs,{children:_e}):s.jsx(zs,{children:H?"Response preview is loading":"No response"}),J.streaming===!0&&s.jsx(p.Suspense,{fallback:s.jsx(Fn,{}),children:s.jsx(_3,{logId:J.id,truncated:J.streamingChunksPath!==null})})]})}),s.jsx(mt,{value:"parsed",children:b==="parsed"&&s.jsxs(bn,{children:[s.jsx(xs,{status:C,error:z,footprint:W,onRetry:$t}),H&&s.jsx(vs,{label:"Response",state:$,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ze("response",$.offset)}),ge&&!xe?s.jsx(bs,{children:_e}):s.jsx(p.Suspense,{fallback:s.jsx(Fn,{}),children:s.jsx(k3,{responseText:_e,responseStatus:J.responseStatus,streaming:J.streaming,inputTokens:J.inputTokens,outputTokens:J.outputTokens,cacheCreationInputTokens:J.cacheCreationInputTokens,cacheReadInputTokens:J.cacheReadInputTokens,apiFormat:te,error:J.error})})]})})]})]})]}),s.jsx(p.Suspense,{fallback:null,children:s.jsx(y3,{log:J,displayNumber:t,open:f,onOpenChange:m})})]})});function wt({className:e,style:t,d:n,eyeStalks:r,eyes:o,legs:i,extras:a}){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:t,className:le("inline-block size-5",e),children:[s.jsx("path",{d:n}),r,o,i,a]})}const mn=s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),s.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),s.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),s.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]}),bm=s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7",y1:"16",x2:"5.5",y2:"18.5"}),s.jsx("line",{x1:"9.5",y1:"17",x2:"8.5",y2:"19.5"}),s.jsx("line",{x1:"14.5",y1:"17",x2:"15.5",y2:"19.5"}),s.jsx("line",{x1:"17",y1:"16",x2:"18.5",y2:"18.5"})]});function vm({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.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 TT({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"9.5",y1:"6.5",x2:"9.5",y2:"4.5"}),s.jsx("line",{x1:"14.5",y1:"6.5",x2:"14.5",y2:"4.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"})]}),legs:bm,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12"}),s.jsx("path",{d:"M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12"})]})})}function ET({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7",y1:"7",x2:"6.5",y2:"4.5"}),s.jsx("line",{x1:"17",y1:"7",x2:"17.5",y2:"4.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"6.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"17.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13"}),s.jsx("path",{d:"M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13"})]})})}function AT({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"6.5",x2:"10",y2:"3.5"}),s.jsx("line",{x1:"14",y1:"6.5",x2:"14",y2:"3.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7",y1:"17",x2:"5",y2:"20.5"}),s.jsx("line",{x1:"9.5",y1:"18.5",x2:"8.5",y2:"21.5"}),s.jsx("line",{x1:"14.5",y1:"18.5",x2:"15.5",y2:"21.5"}),s.jsx("line",{x1:"17",y1:"17",x2:"19",y2:"20.5"})]}),extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12"}),s.jsx("path",{d:"M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12"})]})})}function RT({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.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 IT({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("line",{x1:"13.5",y1:"4",x2:"15.5",y2:"5"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.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 zT({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"6"}),s.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"6"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"9",y1:"6",x2:"11",y2:"6.5"}),s.jsx("line",{x1:"13",y1:"6",x2:"15",y2:"6.5"})]}),legs:bm,extras:s.jsxs(s.Fragment,{children:[s.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"}),s.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 PT({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("line",{x1:"8.5",y1:"4",x2:"10.5",y2:"4.5"}),s.jsx("line",{x1:"15.5",y1:"4",x2:"13.5",y2:"4.5"}),s.jsx("path",{d:"M9 15.5 C10 14.5 14 14.5 15 15.5"})]})})}function OT({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("ellipse",{cx:"12",cy:"15",rx:"2",ry:"1.5",fill:"currentColor",stroke:"none"})]})})}function MT({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"9.5",y1:"7",x2:"9",y2:"5"}),s.jsx("line",{x1:"14.5",y1:"7",x2:"15",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"15",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12"}),s.jsx("path",{d:"M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12"}),s.jsx("path",{d:"M9 14.5 C10 16 14 16 15 14.5"}),s.jsx("circle",{cx:"7",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"}),s.jsx("circle",{cx:"17",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"})]})})}function LT({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5.5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7.5",y1:"5.5",x2:"16.5",y2:"5.5"}),s.jsx("rect",{x:"7",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"}),s.jsx("rect",{x:"13",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"})]}),legs:mn,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("path",{d:"M9.5 15 C10.5 16 13.5 16 14.5 15"})]})})}function DT({className:e}){return s.jsx(wt,{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:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10.5",y1:"9.5",x2:"10.5",y2:"8"}),s.jsx("line",{x1:"13.5",y1:"9.5",x2:"13.5",y2:"8"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"13.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"8",y1:"16",x2:"6.5",y2:"18"}),s.jsx("line",{x1:"10",y1:"17",x2:"9.5",y2:"19"}),s.jsx("line",{x1:"14",y1:"17",x2:"14.5",y2:"19"}),s.jsx("line",{x1:"16",y1:"16",x2:"17.5",y2:"18"})]}),extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13"}),s.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 Fr=[vm,TT,ET,AT,RT,IT,zT,PT,OT,MT,LT,DT];function ym(e){return Fr[Math.abs(e)%Fr.length]??vm}function $T(e){const t=Fr.length-2;return t<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%t+t)%t}function FT(e){return ym($T(e))}function BT(e){switch(e){case"end_turn":return"End of Turn (Anthropic)";case"stop":return"End of Turn (OpenAI)";case"length":return"End of Turn (length limit)";case"tool_use":case null:return"End of Turn"}}function xi(e){return e?"cursor-pointer transition-transform hover:scale-110":""}function UT({stopReason:e,isPending:t,isFirst:n,isTurnStart:r,isOnlyEntry:o=!1,crabIndex:i=0,collapsible:a=!1,onToggle:l}){const c=Xa(e),u=o&&r&&c,d=t&&!c,f=a&&l!==void 0,m=p.useMemo(()=>ym(i),[i]),h=p.useMemo(()=>FT(i),[i]),v=x=>{!f||l===void 0||(x.stopPropagation(),l())},g=x=>{!f||l===void 0||x.key!=="Enter"&&x.key!==" "||(x.preventDefault(),l())};return s.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[s.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!n&&s.jsx("div",{className:"w-0.5 bg-muted-foreground/30 h-full"})}),u?s.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Single-request turn",className:xi(f),onClick:v,onKeyDown:g,children:s.jsx(h,{className:le("size-3.5 text-[#80FF00]","animate-crab-settle","drop-shadow-[0_0_4px_rgba(128,255,0,0.5)]")})}):c?s.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:BT(e),className:xi(f),onClick:v,onKeyDown:g,children:s.jsx(m,{className:le("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})}):r?s.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Start of turn",className:xi(f),onClick:v,onKeyDown:g,children:s.jsx(m,{className:le("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):d?s.jsx("span",{title:"Processing",children:s.jsx(m,{className:le("size-3.5 text-amber-300/80","animate-crab-crawl")})}):s.jsx("span",{title:"Request in turn",children:s.jsx(m,{className:"size-3.5 text-muted-foreground/40"})}),s.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!c&&s.jsx("div",{className:le("w-0.5 h-full",t?"border-dashed bg-transparent border-l-2 border-muted-foreground/20":"bg-muted-foreground/30")})})]})}function WT({event:e}){const t=Ut(e.argumentsText),n=e.argumentsText!==null;return s.jsxs("div",{className:"group/tool-trace flex min-w-0 items-center gap-2 rounded-md border border-border/70 bg-muted/20 px-2.5 py-1.5 text-xs",children:[s.jsx(Wr,{className:"size-3.5 shrink-0 text-sky-400/70"}),s.jsx("span",{className:"font-mono font-semibold text-foreground/80",children:e.name}),e.argumentsPreview!==null&&s.jsxs(s.Fragment,{children:[s.jsx(bt,{className:"size-3 shrink-0 text-muted-foreground/60"}),s.jsx("span",{className:"min-w-0 truncate font-mono text-muted-foreground",children:e.argumentsPreview})]}),n&&s.jsx("button",{type:"button",className:"ml-auto inline-flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground opacity-0 transition-opacity hover:bg-background/80 hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover/tool-trace:opacity-100 group-focus-within/tool-trace:opacity-100",onClick:t.copy,"aria-label":t.copied?"Copied tool arguments":"Copy tool arguments",title:t.copied?"Copied tool arguments":"Copy tool arguments",children:t.copied?s.jsx(Ge,{className:"size-3.5"}):s.jsx(Nt,{className:"size-3.5"})})]},e.id)}function HT({events:e}){return e.length===0?null:s.jsx("div",{className:"mx-3 mb-2 grid gap-1.5",children:e.map(t=>s.jsx(WT,{event:t},t.id))})}const au=180,bi=new WeakMap;function ZT(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 VT(e,t,n){return e>1&&t&&!n}function pa(e){const t=[];let n=[],r=0;for(let o=0;o<e.length;o+=1){const i=e[o];if(i===void 0)continue;n.push({log:i,stopReason:df(i),sessionLogNumber:o+1});const a=n[n.length-1];a!==void 0&&Xa(a.stopReason)&&(t.push({entries:n,turnIndex:r}),n=[],r+=1)}return n.length>0&&t.push({entries:n,turnIndex:r}),t}function qT(e){const t=new Map;for(const n of e)for(let r=1;r<n.logs.length;r+=1){const o=n.logs[r],i=n.logs[r-1];if(o===void 0||i===void 0)continue;const a=Lr(o),l=Lr(i);a==="unknown"||a!==l||t.set(o.id,i)}return t}function wm(e){if(e===null)return null;try{const t=JSON.parse(e);return typeof t=="string"?JSON.parse(t):t}catch{return null}}function ha(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>au?`${n.slice(0,au-1)}...`:n}function ma(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 KT(e){const t=wm(e.responseText),n=ke(t,"content");if(!Array.isArray(n))return[];const r=[];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");r.push({id:`${String(e.id)}-anthropic-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"anthropic",name:a,argumentsText:ma(l),argumentsPreview:ha(l)})}return r}function GT(e){const t=wm(e.responseText),n=ke(t,"choices");if(!Array.isArray(n))return[];const r=[];for(const i of n){const a=ke(i,"message"),l=ke(a,"tool_calls");if(Array.isArray(l))for(const c of l){const u=ke(c,"function"),d=ke(u,"name");if(typeof d!="string"||d.length===0)continue;const f=ke(u,"arguments");r.push({id:`${String(e.id)}-openai-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"openai",name:d,argumentsText:ma(f),argumentsPreview:ha(f)})}}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");r.push({id:`${String(e.id)}-openai-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"openai",name:a,argumentsText:ma(l),argumentsPreview:ha(l)})}return r}function Il(e){const t=bi.get(e);if(t!==void 0&&t.apiFormat===e.apiFormat&&t.responseText===e.responseText)return t.events;const n=Lr(e);if(!ZT(e,n)){const o=[];return bi.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:o}),o}let r;switch(n){case"anthropic":r=KT(e);break;case"openai":r=GT(e);break;case"unknown":r=[];break}return bi.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:r}),r}function JT(e,t,n=0){let r=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&&(r+=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+=Il(h).length;return{llmCallCount:e.length,toolCallCount:m,failedCallCount:r,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 vi(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const YT=p.memo(function({entries:t,viewMode:n,strip:r,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,v=h!==null?Xa(h):!1,g=t[m]?.log.responseStatus===null,x=t.length===1,b=VT(t.length,v,g),[y,_]=p.useState(!1),j=p.useRef(!1);p.useEffect(()=>{b?v&&!j.current&&_(!0):_(!1),j.current=v},[b,v]),p.useEffect(()=>{const X=B=>{const F=Vo(B);F!==null&&t.some(Z=>Z.log.id===F.logId)&&b&&_(!1)};return window.addEventListener(qt,X),()=>{window.removeEventListener(qt,X)}},[b,t]),p.useEffect(()=>{if(d===void 0||!t.some(B=>B.log.id===d.logId))return;b&&_(!1);const X=window.setTimeout(()=>{eo({logId:d.logId,tab:d.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(X)},[b,t,d]);const S=p.useCallback(()=>{b&&_(X=>!X)},[b]),E=p.useMemo(()=>{let X=0,B=0,F=null,Z=!1;for(const J of t)J.log.inputTokens!==null&&(X+=J.log.inputTokens,Z=!0),J.log.outputTokens!==null&&(B+=J.log.outputTokens,Z=!0),J.log.elapsedMs!==null&&(F=F===null?J.log.elapsedMs:Math.max(F,J.log.elapsedMs));return{totalInput:X,totalOutput:B,hasTokens:Z,maxElapsed:F}},[t,m]),C=c%2===0?"bg-white/[0.012]":"bg-cyan-300/[0.012]",R=E.maxElapsed!==null&&o>0&&E.maxElapsed>o*1e3,z=p.useMemo(()=>{const X=new Map;for(const B of t){const F=Il(B.log);F.length>0&&X.set(B.log.id,F)}return X},[t]),[O,q]=p.useState(0),T=p.useRef(null);p.useEffect(()=>{const X=T.current;if(!X)return;let B=0;const F=new ResizeObserver(()=>{window.cancelAnimationFrame(B),B=window.requestAnimationFrame(()=>q(Z=>Z+1))});return F.observe(X),()=>{F.disconnect(),window.cancelAnimationFrame(B)}},[]);const D=t[0]?.log.id??c,k=`Turn ${String(c+1)}`,$=p.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:y?"48px":"160px"}),[y]);return s.jsx("div",{ref:T,style:$,tabIndex:y?void 0:0,role:y?void 0:"group","aria-label":y?void 0:k,"data-nav-id":y?void 0:`turn-${String(D)}`,className:le("rounded-[8px] border transition-[border-color,box-shadow]",g?"border-amber-300/15 shadow-[0_0_0_1px_rgba(252,211,77,0.04)]":"border-transparent",!y&&"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),children:y?s.jsxs("div",{"data-nav-id":`turn-collapsed-${String(D)}`,"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:X=>{(X.key==="Enter"||X.key===" ")&&(X.preventDefault(),S())},children:[s.jsx("div",{className:"w-5 shrink-0 flex items-start pt-1.5",children:s.jsx("span",{className:"text-[10px] text-muted-foreground/50 font-mono tabular-nums leading-none select-none",children:c+1})}),s.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-1.5 pb-1.5",children:[s.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),s.jsx("span",{className:"size-2 rounded-full border border-cyan-300/45 bg-cyan-300/20"}),s.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:s.jsx("div",{className:"w-px bg-muted-foreground/25 h-full"})}),s.jsx("span",{className:le("size-2 rounded-full border",v?"border-amber-300/45 bg-amber-300/20":"border-muted-foreground/30 bg-muted/30")})]}),t.length>1&&s.jsxs("div",{className:le("flex-1 min-w-0 mb-0.5 rounded-[8px] py-1.5 px-3 flex items-center gap-3 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]","border border-border bg-card shadow-sm transition-colors hover:border-cyan-200/20",C),children:[s.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:k}),s.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??"?"]}),s.jsxs("span",{className:"text-muted-foreground shrink-0",children:[t.length," request",t.length>1?"s":""]}),E.maxElapsed!==null&&s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs("span",{className:le("flex items-center gap-1 shrink-0",R?"text-amber-400":"text-muted-foreground"),children:[s.jsx(Ht,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:vi(E.maxElapsed)}),R&&s.jsx(rn,{className:"size-3","aria-label":"Slow response"})]})}),s.jsx(Le,{children:R?`Slow response: ${vi(E.maxElapsed)} exceeds ${vi(o*1e3)}`:"Slowest request in this turn"})]})}),E.hasTokens&&s.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[s.jsx(Pr,{className:"size-3 text-muted-foreground"}),s.jsxs("span",{className:"font-mono tabular-nums",children:[s.jsxs("span",{className:"text-blue-400",children:["IN ",$e(E.totalInput)]})," / ",s.jsxs("span",{className:"text-amber-400",children:["OUT ",$e(E.totalOutput)]})]})]}),s.jsx("span",{className:"flex-1 min-w-0"}),s.jsx("span",{className:"border border-input bg-background inline-flex size-7 shrink-0 items-center justify-center rounded-md text-slate-200","aria-hidden":"true",children:s.jsx(bt,{className:"size-4 shrink-0"})})]})]}):t.map((X,B)=>{const{log:F,stopReason:Z}=X,J=B===0;return s.jsxs("div",{className:"flex items-stretch",children:[J?s.jsx("div",{className:"w-5 shrink-0 flex items-start pt-1.5",children:s.jsx("span",{className:"text-[10px] text-muted-foreground/50 font-mono tabular-nums leading-none select-none",children:c+1})}):s.jsx("div",{className:"w-5 shrink-0"}),s.jsx(UT,{stopReason:Z,isPending:F.responseStatus===null,isFirst:B===0,isTurnStart:J,isOnlyEntry:x,crabIndex:F.id%12,collapsible:b&&J,onToggle:S}),s.jsxs("div",{className:le("flex-1 min-w-0 mb-0.5 rounded-[8px]",C),children:[s.jsx(NT,{log:F,displayNumber:X.sessionLogNumber,viewMode:n,strip:r,slowResponseThresholdSeconds:o,timeDisplayFormat:u,cacheTrend:i?.get(F.id)??null,showClientMetadata:f,onCompareWithPrevious:l.has(F.id)?a:void 0}),s.jsx(HT,{events:z.get(F.id)??[]})]})]},F.id)})})}),XT=24,QT=132,eE=8;function tE(e){return e>XT}function nE(e){const t=new Map;for(let n=0;n<e.length;n++){const r=e[n];if(r!==void 0)for(const o of r.entries)t.set(o.log.id,n)}return t}function km(e,t,n){return s.jsx(YT,{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 rE(e){return tE(e.turnGroups.length)?s.jsx(sE,{...e}):s.jsx(s.Fragment,{children:e.turnGroups.map(t=>km(t,e))})}function sE(e){const{turnGroups:t}=e,[n,r]=p.useState(null),o=a3({count:t.length,estimateSize:()=>QT,overscan:eE,getItemKey:a=>t[a]?.turnIndex??a}),i=p.useMemo(()=>nE(t),[t]);return p.useEffect(()=>{const a=l=>{const c=Vo(l);if(c===null||c.source==="virtualizer")return;const u=i.get(c.logId);u!==void 0&&(o.scrollToIndex(u,{align:"center"}),r(d=>({...c,turnIndex:u,nonce:d===null?1:d.nonce+1})))};return window.addEventListener(qt,a),()=>{window.removeEventListener(qt,a)}},[i,o]),s.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 s.jsx("div",{"data-index":a.index,ref:o.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${a.start}px)`},children:km(l,e,c)},a.key)})})}const zl=Te(["episode","procedure","preference","project-fact"]),oE=Te(["draft","promoted","failed"]),_m=G({source:Ce("agent-inspector"),sessionId:N(),logIds:me(K().int().positive()),project:N().nullable(),models:me(N())}),iE=G({redacted:Fe(),patterns:me(N())}),Xr=G({id:N(),type:zl,title:N(),content:N(),tags:me(N()),source:Ce("agent-inspector"),sessionId:N(),logIds:me(K().int().positive()),evidence:_m,status:oE,createdAt:N(),updatedAt:N(),openClawMemoryId:N().nullable(),error:N().nullable(),redaction:iE});G({idempotencyKey:N(),type:zl,title:N(),content:N(),tags:me(N()),source:Ce("agent-inspector"),project:N().nullable(),evidence:_m});const aE=G({id:N(),type:zl.or(N()),title:N(),content:N(),score:K().nullable(),source:N().nullable(),project:N().nullable(),evidence:yn().optional()});G({results:me(aE),warning:N().nullable()});const lE=G({candidates:me(Xr)}),cE=G({candidate:Xr}),uE=G({error:N().optional(),candidate:Xr.optional()}),dE=G({candidate:Xr}),fE={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 ga(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function pE(e,t,n){return e===null||t===null?null:Ya(e,t,n)}function hE(e){return`${String(e)} candidate${e===1?"":"s"}`}function jm(e){return`log-${String(e)}`}function Sm(e){const t=jm(e),n=document.getElementById(t);window.history.replaceState(null,"",`#${t}`),n instanceof HTMLElement&&(n.scrollIntoView({block:"center",behavior:"smooth"}),n.focus({preventScroll:!0}))}function mE(e){for(const t of e)if(t.responseStatus!==null&&t.responseStatus>=400)return t;return null}function gE(e){let t=null,n=-1;for(const r of e)r.elapsedMs!==null&&r.elapsedMs>n&&(t=r,n=r.elapsedMs);return t}function xE(e){for(const t of e)if(Il(t).length>0)return t;return null}function bE(e){const t=new Map;for(let n=0;n<e.length;n+=1){const r=e[n];r!==void 0&&t.set(r.id,n+1)}return t}function Xn(e,t){return String(t.get(e)??e)}function vE(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=xE(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 #${Xn(n.id,e.displayNumberByLogId)}`,logId:n.id});const r=mE(e.logs);r!==null&&t.push({kind:"failure",title:`Failure #${String(r.responseStatus)}`,detail:`First failed request is #${Xn(r.id,e.displayNumberByLogId)}`,logId:r.id});const o=gE(e.logs);if(o!==null&&e.summary.maxElapsedMs!==null&&t.push({kind:"slow",title:`Slowest ${ga(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${Xn(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 yE(e){switch(e){case"session":return s.jsx(ko,{className:"size-3.5 text-blue-400"});case"tool":return s.jsx(Wr,{className:"size-3.5 text-sky-400/70"});case"slow":return s.jsx(Ht,{className:"size-3.5 text-amber-400"});case"failure":return s.jsx(sf,{className:"size-3.5 text-destructive"});case"candidate":return s.jsx(rf,{className:"size-3.5 text-emerald-400"})}}function wE({insights:e}){return e.length===0?null:s.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=>s.jsxs("button",{type:"button",className:le("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&&Sm(t.logId)},disabled:t.logId===null,children:[yE(t.kind),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate font-medium text-foreground/90",children:t.title}),s.jsx("span",{className:"block truncate font-mono text-[10px]",children:t.detail})]})]},`${t.kind}-${t.title}`))})}function kE(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function _E(e,t){if(t)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function jE(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function SE(e,t){const n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,t-3)}...`}function CE(e,t){const n=e[0],r=e[e.length-1];if(n===void 0)return"No evidence logs";const o=Xn(n,t);return r===void 0||n===r?`#${o}`:`#${o}-#${Xn(r,t)}`}function lu(e){return e.join(", ")}function NE(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function TE({candidate:e,isPromoting:t,isUpdating:n,onPromoteCandidate:r,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),[v,g]=p.useState(lu(e.tags)),[x,b]=p.useState(null),y=e.status!=="promoted",_=e.status!=="promoted",j=p.useCallback(()=>{u(e.type),f(e.title),h(e.content),g(lu(e.tags)),b(null)},[e.content,e.tags,e.title,e.type]),S=p.useCallback(async()=>{const E=d.trim(),C=m.trim(),R=NE(v);if(E.length===0){b("Title is required.");return}if(C.length===0){b("Content is required.");return}if(R.length===0){b("At least one tag is required.");return}b(null),await o(e.id,{type:c,title:E,content:C,tags:R})&&l(!1)},[e.id,m,v,d,c,o]);return a?s.jsx("div",{className:"border border-border bg-card shadow-sm rounded-[8px] px-2.5 py-2",children:s.jsxs("div",{className:"grid gap-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("select",{value:c,disabled:n,onChange:E=>{const C=Xr.shape.type.safeParse(E.currentTarget.value);C.success&&u(C.data)},className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 rounded-md px-2 text-xs","aria-label":"Candidate type",children:[s.jsx("option",{value:"episode",children:"episode"}),s.jsx("option",{value:"procedure",children:"procedure"}),s.jsx("option",{value:"preference",children:"preference"}),s.jsx("option",{value:"project-fact",children:"project-fact"})]}),s.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"})]}),s.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"}),s.jsx("input",{value:v,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"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground",children:[s.jsx(cc,{className:"size-3"}),"Saving reruns Inspector redaction before promotion."]}),s.jsx("span",{className:"flex-1"}),x!==null&&s.jsx("span",{className:"text-[10px] text-destructive",children:x}),s.jsxs(Se,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{j(),l(!1)},children:[s.jsx(_o,{className:"size-3.5"}),"Cancel"]}),s.jsxs(Se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{S()},children:[n?s.jsx(zr,{className:"size-3.5 animate-spin"}):s.jsx(F2,{className:"size-3.5"}),"Save"]})]})]})}):s.jsxs("div",{className:"rounded-md border border-border/80 bg-background/60 px-2.5 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(Be,{variant:"outline",className:"h-5 px-1.5 text-[10px] font-mono",children:e.type}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",title:e.title,children:e.title}),s.jsx(Be,{variant:"outline",className:le("h-5 shrink-0 px-1.5 text-[10px] font-mono",fE[e.status]),children:kE(e.status)})]}),s.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:SE(e.content,360)}),s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(e2,{className:"size-3"}),CE(e.logIds,i)]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(cc,{className:"size-3"}),jE(e)]}),e.status==="promoted"&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[s.jsx(Li,{className:"size-3"}),e.openClawMemoryId??"OpenClaw"]}),e.status==="failed"&&e.error!==null&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[s.jsx(sf,{className:"size-3"}),e.error]})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.logIds.map(E=>{const C=Xn(E,i);return s.jsxs("a",{href:`#${jm(E)}`,onClick:R=>{R.preventDefault(),Sm(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 ${C}`,title:`Log ID ${String(E)}`,children:["#",C]},E)}),s.jsx("span",{className:"flex-1"}),_&&s.jsxs(Se,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",disabled:n||t,onClick:()=>l(!0),children:[s.jsx(af,{className:"size-3"}),"Review"]}),s.jsxs(Se,{type:"button",variant:y?"outline":"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",onClick:()=>r(e.id),disabled:!y||t||n,children:[t?s.jsx(zr,{className:"size-3 animate-spin"}):y?s.jsx(Oy,{className:"size-3"}):s.jsx(Li,{className:"size-3"}),_E(e,t)]})]})]})}function EE({candidates:e,promotingCandidateIds:t,updatingCandidateIds:n,onPromoteCandidate:r,onUpdateCandidate:o,displayNumberByLogId:i}){return e.length===0?null:s.jsx("div",{className:"mt-2 grid gap-1.5",children:e.map(a=>s.jsx(TE,{candidate:a,isPromoting:t.has(a.id),isUpdating:n.has(a.id),onPromoteCandidate:r,onUpdateCandidate:o,displayNumberByLogId:i},a.id))})}function AE({logs:e,scopeId:t,slowResponseThresholdSeconds:n,showRollupMetrics:r,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,v]=p.useState(()=>new Set),g=i.length>0,x=p.useMemo(()=>JT(e,n,i.length),[i.length,e,n]),b=p.useMemo(()=>bE(e),[e]),y=p.useMemo(()=>vE({logs:e,scopeId:t,summary:x,candidates:i,displayNumberByLogId:b}),[i,b,e,t,x]),_=r||x.maxElapsedMs!==null,j=p.useMemo(()=>pE(x.startedAt,x.endedAt,o),[x.endedAt,x.startedAt,o]),S=p.useCallback(()=>{e.length===0||u.status==="loading"||(d({status:"loading",error:null}),(async()=>{try{const R=await fetch(`/api/knowledge/sessions/${encodeURIComponent(t)}/candidates`,{method:"POST"});if(!R.ok){const O=await Wt(R,`Candidate generation failed with ${String(R.status)}`);d({status:"failed",error:O});return}const z=await jt(R,lE);a(z.candidates),c(z.candidates.length>0),d(z.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(z=>{if(z.has(R))return z;const O=new Set(z);return O.add(R),O}),(async()=>{try{const z=await fetch(`/api/knowledge/candidates/${encodeURIComponent(R)}/promote`,{method:"POST"}),O=await z.json().catch(()=>null),q=cE.safeParse(O);if(z.ok&&q.success){a(D=>D.map(k=>k.id===q.data.candidate.id?q.data.candidate:k)),d({status:"ready",error:null});return}const T=uE.safeParse(O);T.success&&T.data.candidate!==void 0&&a(D=>D.map(k=>k.id===T.data.candidate?.id?T.data.candidate:k)),d({status:"failed",error:T.success?T.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(z.status)}`})}catch(z){d({status:"failed",error:z instanceof Error?z.message:"Candidate promotion failed"})}finally{m(z=>{const O=new Set(z);return O.delete(R),O})}})()},[]),C=p.useCallback(async(R,z)=>{v(O=>{if(O.has(R))return O;const q=new Set(O);return q.add(R),q});try{const O=await fetch(`/api/knowledge/candidates/${encodeURIComponent(R)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(z)});if(!O.ok){const T=await Wt(O,`Candidate update failed with ${String(O.status)}`);return d({status:"failed",error:T}),!1}const q=await jt(O,dE);return a(T=>T.map(D=>D.id===q.candidate.id?q.candidate:D)),d({status:"ready",error:null}),!0}catch(O){return d({status:"failed",error:O instanceof Error?O.message:"Candidate update failed"}),!1}finally{v(O=>{const q=new Set(O);return q.delete(R),q})}},[]);return e.length===0?null:s.jsxs("section",{className:"border border-border bg-card shadow-sm mb-2 rounded-[8px] px-3 py-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[r&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold text-foreground",children:[s.jsx(ko,{className:"size-3.5 text-blue-400"}),x.llmCallCount," LLM"]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(Wr,{className:"size-3.5 text-sky-400/70"}),x.toolCallCount," tools"]}),r&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(Pr,{className:"size-3.5 text-emerald-400"}),s.jsxs("span",{className:"font-mono",children:[$e(x.totalInputTokens)," / ",$e(x.totalOutputTokens)]})]}),(x.totalCacheCreationInputTokens>0||x.totalCacheReadInputTokens>0)&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(Pr,{className:"size-3.5 text-purple-400"}),s.jsxs("span",{className:"font-mono",children:["KV Cache +",$e(x.totalCacheCreationInputTokens)," / ~",$e(x.totalCacheReadInputTokens)]})]}),_&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(Ht,{className:"size-3.5"}),r&&s.jsx("span",{className:"font-mono",children:ga(x.totalElapsedMs)}),x.maxElapsedMs!==null&&s.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",ga(x.maxElapsedMs)]})]}),r&&j!==null&&s.jsx("span",{className:"font-mono text-muted-foreground/70",children:j}),(x.failedCallCount>0||x.pendingCallCount>0||x.slowCallCount>0)&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-amber-400",children:[s.jsx(rn,{className:"size-3.5"}),s.jsxs("span",{className:"font-mono",children:[x.failedCallCount," fail / ",x.pendingCallCount," pending /"," ",x.slowCallCount," slow"]})]}),s.jsx("span",{className:"flex-1"}),g&&s.jsx(Be,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:hE(x.knowledgeCandidateCount)}),s.jsxs(Se,{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"?s.jsx(ft,{className:"size-3.5 animate-spin"}):s.jsx(rf,{className:"size-3.5"}),"Candidate"]}),g&&s.jsx(Se,{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?s.jsx(st,{className:"size-3.5"}):s.jsx(bt,{className:"size-3.5"})})]}),u.status==="failed"&&s.jsx("p",{className:"mt-2 text-xs text-destructive",children:u.error}),s.jsx(wE,{insights:y}),l&&s.jsx(EE,{candidates:i,promotingCandidateIds:f,updatingCandidateIds:h,onPromoteCandidate:E,onUpdateCandidate:C,displayNumberByLogId:b})]})}function RE(e){let t=0,n=0;for(const r of e)r.inputTokens!==null&&(t+=r.inputTokens),r.outputTokens!==null&&(n+=r.outputTokens);return{totalInputTokens:t,totalOutputTokens:n}}function IE(e){const t=new Map;for(const n of e){if(n.model===null)continue;const r=Rj(n.model);if(r==="unknown")continue;let o=t.get(r);o===void 0&&(o=new Set,t.set(r,o)),o.add(n.model)}return[...t.entries()].map(([n,r])=>({provider:n,models:[...r]}))}function zE(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function PE(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}const OE=p.memo(function({group:e,viewMode:t="simple",strip:n,slowResponseThresholdSeconds:r,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:v}){const[g,x]=p.useState(f),b=h??g,y=p.useCallback(q=>{if(v!==void 0){v(q);return}x(q)},[v]);p.useEffect(()=>{!f||h!==void 0||x(!0)},[h,f]);const _=p.useMemo(()=>RE(e.logs),[e.logs]),j=p.useMemo(()=>IE(e.logs),[e.logs]),S=e.logs[0]?.timestamp??new Date().toISOString(),E=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),C=e.logs.some(q=>q.responseStatus===null),R=p.useMemo(()=>zE(e.logs),[e.logs]),z=p.useMemo(()=>PE(e.logs),[e.logs]),O=p.useMemo(()=>pa(e.logs),[e.logs]);return p.useEffect(()=>{const q=T=>{const D=Vo(T);D!==null&&e.logs.some(k=>k.id===D.logId)&&y(!0)};return window.addEventListener(qt,q),()=>{window.removeEventListener(qt,q)}},[e.logs,y]),s.jsxs("div",{className:"mb-2",children:[s.jsx(WN,{conversationId:e.conversationId,startTime:S,endTime:E,totalCalls:e.logs.length,totalInputTokens:_.totalInputTokens,totalOutputTokens:_.totalOutputTokens,expanded:b,onToggle:()=>y(!b),providers:j,isLoading:C,userAgent:e.logs[0]?.userAgent??null,clientPid:R,clientProjectFolder:z,showClientIdentity:c,showProcessMetadata:u,timeDisplayFormat:m,onClear:()=>l(e.logs.map(q=>q.id))}),b&&s.jsxs("div",{children:[s.jsx(AE,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:r,showRollupMetrics:!1,timeDisplayFormat:m}),s.jsx(rE,{turnGroups:O,viewMode:t,strip:n,slowResponseThresholdSeconds:r,timeDisplayFormat:m,cacheTrends:o,onCompareWithPrevious:i,comparisonPredecessors:a,showLogClientMetadata:d})]})]})});function cu({className:e}){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:le("inline-block size-5",e),children:[s.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"}),s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"}),s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),s.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),s.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),s.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]})}const ME="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 LE({className:e}){return s.jsx("img",{src:ME,alt:"Model Context Protocol","aria-hidden":"true",className:le("inline-block size-8 object-contain invert",e)})}function so({...e}){return s.jsx(c5,{"data-slot":"select",...e})}function oo({...e}){return s.jsx(d5,{"data-slot":"select-value",...e})}function io({className:e,size:t="default",children:n,...r}){return s.jsxs(u5,{"data-slot":"select-trigger","data-size":t,className:le("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),...r,children:[n,s.jsx(f5,{asChild:!0,children:s.jsx(st,{className:"size-4 opacity-50"})})]})}function ao({className:e,children:t,position:n="popper",align:r="center",...o}){return s.jsx(p5,{children:s.jsxs(h5,{"data-slot":"select-content",className:le("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:r,...o,children:[s.jsx(DE,{}),s.jsx(m5,{className:le("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),s.jsx($E,{})]})})}function At({className:e,children:t,...n}){return s.jsxs(g5,{"data-slot":"select-item",className:le("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:[s.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:s.jsx(b5,{children:s.jsx(Ge,{className:"size-4"})})}),s.jsx(x5,{children:t})]})}function DE({className:e,...t}){return s.jsx(v5,{"data-slot":"select-scroll-up-button",className:le("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(Za,{className:"size-4"})})}function $E({className:e,...t}){return s.jsx(y5,{"data-slot":"select-scroll-down-button",className:le("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(st,{className:"size-4"})})}const FE=Te(["critical","warning","notice"]),BE=Te(["open"]),UE=Te(["proxy","tool-schema","run","group"]),Cm=Te(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),WE=Te(["log","session","run","group"]),HE=Te(["anthropic","openai","unknown"]),ZE=G({kind:WE,id:N(),label:N(),href:N().nullable()}),VE=G({id:N(),fingerprint:N(),severity:FE,category:Cm,source:UE,status:BE,title:N(),message:N(),count:K().int().positive(),firstSeenAt:N(),lastSeenAt:N(),logIds:me(K().int().positive()),sessionIds:me(N()),runIds:me(N()),groupIds:me(N()),provider:N().nullable(),model:N().nullable(),apiFormat:HE.nullable(),evidence:me(ZE),metadata:Ke(N(),Qe)}),qE=G({category:Cm,count:K().int().nonnegative()}),Nm=G({total:K().int().nonnegative(),open:K().int().nonnegative(),critical:K().int().nonnegative(),warning:K().int().nonnegative(),notice:K().int().nonnegative(),byCategory:me(qE)}),KE=G({alerts:me(VE),total:K().int().nonnegative(),limit:K().int().positive(),summary:Nm}),GE=8e3,JE=1e4;function YE(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 XE(e,t){const n=Tn(t?YE(e):null,r=>tr(r,KE,JE));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 QE(){const e=Tn("/api/alerts/summary",t=>tr(t,Nm,GE),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const Pl="relative size-8 rounded-md border border-input bg-background text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:ring-ring/50",e4=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function Tm(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function t4(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function Ol(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 n4(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 r4(e){switch(e){case"critical":return"bg-red-400";case"warning":return"bg-amber-300";case"notice":return"bg-sky-300"}}function s4(e){switch(e){case"critical":return"text-red-200";case"warning":return"text-amber-100";case"notice":return"text-sky-100"}}function o4(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return s.jsx(J2,{className:"size-3.5"});case"request-timeout":case"slow-response":return s.jsx(Iy,{className:"size-3.5"});case"tool-schema":return s.jsx(rn,{className:"size-3.5"});case"group-incomplete":return s.jsx(sy,{className:"size-3.5"})}}function xa(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 ut(e){return e.toLocaleString()}function Em(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 i4(e,t){const n={limit:100};return e!=="all"&&(n.severity=e),t!=="all"&&(n.category=t),n}function a4(e,t){if(t!==null){const n=e.find(r=>r.id===t);if(n!==void 0)return n}return e[0]??null}function ys({label:e,count:t,tone:n}){const r=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 s.jsxs("div",{className:le("rounded-md border px-3 py-2",r),children:[s.jsx("div",{className:"text-[10px] font-semibold uppercase opacity-75",children:e}),s.jsx("div",{className:"mt-1 text-lg font-semibold leading-none",children:ut(t)})]})}function ws({value:e,active:t,label:n,count:r,onClick:o}){return s.jsxs(Se,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>o(e),className:"h-7 px-2",children:[n,r!==null?s.jsx(Be,{variant:"outline",children:ut(r)}):null]})}function l4({category:e,active:t,count:n,onClick:r}){return s.jsxs(Se,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>r(e),className:"h-7 px-2",children:[o4(e),Ol(e),s.jsx(Be,{variant:"outline",children:ut(n)})]})}function c4({alerts:e,selectedAlertId:t,isLoading:n,error:r,onSelect:o}){return n?s.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:[s.jsx(ft,{className:"mr-2 size-3.5 animate-spin"}),"Loading alerts..."]}):r!==void 0?s.jsx("div",{className:"rounded-md border border-red-300/30 bg-red-500/10 px-3 py-2 text-xs text-red-100",children:r.message}):e.length===0?s.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."}):s.jsx("div",{className:"min-h-0 space-y-2 overflow-y-auto pr-1",children:e.map(i=>{const a=i.id===t;return s.jsxs("button",{type:"button",onClick:()=>o(i.id),className:le("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:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:le("size-2 rounded-full",r4(i.severity))}),s.jsx("span",{className:le("text-xs font-semibold",s4(i.severity)),children:Tm(i.severity)}),s.jsx("span",{className:"truncate text-xs text-muted-foreground",children:Ol(i.category)})]}),s.jsx("div",{className:"mt-1 truncate text-sm font-semibold",children:i.title}),s.jsx("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:i.message})]}),i.count>1?s.jsxs(Be,{variant:"outline",className:"shrink-0",children:["x",ut(i.count)]}):null]}),s.jsxs("div",{className:"mt-2 flex min-w-0 items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:Em(i)}),s.jsx("span",{className:"shrink-0",children:xa(i.lastSeenAt)})]})]},i.id)})})}function u4({alert:e,onNavigate:t}){return e.evidence.length===0?s.jsx("span",{className:"text-xs text-muted-foreground",children:"No linked evidence"}):s.jsx("div",{className:"flex flex-wrap gap-2",children:e.evidence.map(n=>n.href===null?s.jsx(Be,{variant:"outline",children:n.label},`${n.kind}:${n.id}`):s.jsx(Be,{variant:"outline",asChild:!0,children:s.jsx("a",{href:n.href,onClick:t,children:n.label})},`${n.kind}:${n.id}`))})}function d4({alert:e,onNavigate:t}){return e===null?s.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."}):s.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-border bg-background/70",children:[s.jsx("div",{className:le("border-b px-4 py-3",n4(e.severity)),children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Be,{variant:"outline",children:Tm(e.severity)}),s.jsx(Be,{variant:"outline",children:t4(e.source)}),s.jsx(Be,{variant:"outline",children:Ol(e.category)})]}),s.jsx("h3",{className:"mt-3 text-base font-semibold",children:e.title}),s.jsx("p",{className:"mt-1 text-sm opacity-85",children:e.message})]}),e.count>1?s.jsxs(Be,{variant:"outline",className:"shrink-0",children:[ut(e.count)," hits"]}):null]})}),s.jsxs("div",{className:"space-y-4 p-4",children:[s.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[s.jsx(Yt,{label:"Target",value:Em(e)}),s.jsx(Yt,{label:"Last seen",value:xa(e.lastSeenAt)}),s.jsx(Yt,{label:"First seen",value:xa(e.firstSeenAt)}),s.jsx(Yt,{label:"Protocol",value:e.apiFormat??"n/a"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Evidence"}),s.jsx(u4,{alert:e,onNavigate:t})]}),s.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[s.jsx(Yt,{label:"Logs",value:e.logIds.length===0?"n/a":ut(e.logIds.length)}),s.jsx(Yt,{label:"Sessions",value:e.sessionIds.length===0?"n/a":ut(e.sessionIds.length)}),s.jsx(Yt,{label:"Runs",value:e.runIds.length===0?"n/a":ut(e.runIds.length)}),s.jsx(Yt,{label:"Groups",value:e.groupIds.length===0?"n/a":ut(e.groupIds.length)})]})]})]})}function Yt({label:e,value:t}){return s.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2",children:[s.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground",children:e}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-foreground",children:t})]})}function uu(){const[e,t]=p.useState(!1),[n,r]=p.useState("all"),[o,i]=p.useState("all"),[a,l]=p.useState(null),{summary:c,isLoading:u}=QE(),d=p.useMemo(()=>i4(n,o),[o,n]),{alerts:f,total:m,isLoading:h,error:v,mutate:g}=XE(d,e),x=p.useMemo(()=>a4(f,a),[f,a]);p.useEffect(()=>{!e||a!==null&&f.some(C=>C.id===a)||l(f[0]?.id??null)},[f,e,a]);const b=c?.total??0,y=c?.critical??0,_=c?.warning??0,j=c?.notice??0,S=y>0?"bg-red-500":_>0?"bg-amber-400":"bg-sky-400";return s.jsxs(Hr,{open:e,onOpenChange:t,children:[s.jsx(ol,{asChild:!0,children:s.jsxs(Se,{type:"button",variant:"ghost",size:"icon",className:Pl,"aria-label":"Alerts",title:"Alerts",children:[s.jsx(Fi,{className:"size-4"}),u?s.jsx(ft,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):b>0?s.jsx("span",{className:le("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4 text-white",S),children:ut(b)}):null,s.jsx("span",{className:"sr-only",children:"Alerts"})]})}),s.jsxs(Zr,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[s.jsxs(Vr,{children:[s.jsxs(qr,{className:"flex items-center gap-2 pr-8",children:[s.jsx(Fi,{className:"size-5 text-red-300"}),s.jsx("span",{children:"Alerts"}),s.jsx(Be,{variant:"outline",children:ut(b)})]}),s.jsx(mj,{className:"sr-only",children:"Local alert board for captured Inspector evidence."})]}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[s.jsx(ys,{label:"Open",count:c?.open??0,tone:"neutral"}),s.jsx(ys,{label:"Critical",count:y,tone:"critical"}),s.jsx(ys,{label:"Warning",count:_,tone:"warning"}),s.jsx(ys,{label:"Notice",count:j,tone:"notice"})]}),s.jsxs("div",{className:"flex min-h-0 flex-wrap items-center justify-between gap-2 border-y border-border py-3",children:[s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx(ws,{value:"all",active:n==="all",label:"All",count:c?.total??null,onClick:r}),s.jsx(ws,{value:"critical",active:n==="critical",label:"Critical",count:y,onClick:r}),s.jsx(ws,{value:"warning",active:n==="warning",label:"Warning",count:_,onClick:r}),s.jsx(ws,{value:"notice",active:n==="notice",label:"Notice",count:j,onClick:r})]}),s.jsxs(Se,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{g()},children:[s.jsx(zr,{className:"size-3.5"}),"Refresh"]})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx(Se,{type:"button",variant:o==="all"?"secondary":"ghost",size:"sm","aria-pressed":o==="all",onClick:()=>i("all"),className:"h-7 px-2",children:"All categories"}),e4.map(E=>{const C=c?.byCategory.find(R=>R.category===E)?.count??0;return C===0?null:s.jsx(l4,{category:E,active:o===E,count:C,onClick:i},E)})]}),s.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[360px_minmax(0,1fr)]",children:[s.jsxs("div",{className:"flex min-h-0 flex-col",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[s.jsxs("span",{children:[ut(m)," matched"]}),s.jsx("span",{children:f.length<m?`${ut(f.length)} shown`:"Latest"})]}),s.jsx(c4,{alerts:f,selectedAlertId:x?.id??null,isLoading:h,error:v,onSelect:l})]}),s.jsx(d4,{alert:x,onNavigate:()=>t(!1)})]})]})]})}const f4=12e3;function p4(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function h4(e){const t=Tn(p4(e),n=>tr(n,L1,f4));return{evidenceResponse:t.data??null,isLoading:t.isLoading,error:t.error,mutate:t.mutate}}const m4=8e3;function g4(){const e=Tn("/api/groups",t=>tr(t,ef,m4));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}function x4(e,t){const n=`/api/groups/${encodeURIComponent(e)}`;return t?`${n}?deleteEvidence=1`:n}function Am(e){let t=0,n=0,r=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":r+=1;break;case"created":break;case null:o+=1;break}return{memberCount:e.members.length,completedMembers:t,failedMembers:n,runningMembers:r,missingStatusMembers:o}}function b4(e,t,n=null){return t!==null&&t.group.id===e.id?t.members.map(r=>({member:r.member,exportMember:r,source:"export"})):n!==null&&n.group.id===e.id&&n.members!==null?n.members.map(r=>({member:r.member,exportMember:r,source:"evidence"})):e.members.map(r=>({member:r,exportMember:null,source:"group"}))}function Ml(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 Ll(e){return e??"unknown"}function v4(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 qo(e){return e===null||e.trim().length===0?"-":e}function gt(e){return e.toLocaleString()}function ba(e){return e==null?"-":e<1e3?`${gt(e)} ms`:`${(e/1e3).toFixed(1)} s`}function ar(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 du(e){return e===null?"-":ar(e)}function y4(e){const t=JSON.stringify(e),n=t===void 0?String(e):t;return n.length<=160?n:`${n.slice(0,157)}...`}function Rm(...e){for(const t of e)if(t!==null&&t.trim().length>0)return t;return"-"}function w4(...e){for(const t of e)if(t!=null&&t.trim().length>0)return t;return null}function k4(e){const t=e.provider,n=e.model;return t!==null&&t.length>0&&n!==null&&n.length>0?`${t} / ${n}`:Rm(t,n)}function _4(e,t){if(t!==null){const n=e.find(r=>r.id===t);if(n!==void 0)return n}return e[0]??null}function j4(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function S4(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function C4(e,t){return t!==null&&t.group.id===e.id?t.evidence:e.evidence}function N4(e,t,n){return t!==null&&t.group.id===e.id?t.summary:n!==null&&n.group.id===e.id?n.summary:null}function T4(e,t,n){return t!==null&&t.group.id===e.id?t.jenkinsReport:n!==null&&n.group.id===e.id?n.report:null}function fu(){const[e,t]=p.useState(!1),[n,r]=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),[v,g]=p.useState(null),[x,b]=p.useState(null),{groups:y,isLoading:_,error:j,mutate:S}=g4(),E=p.useMemo(()=>_4(y,n),[y,n]);p.useEffect(()=>{!e||n!==null&&y.some(Z=>Z.id===n)||r(y[0]?.id??null)},[y,e,n]);const C=E!==null&&c!==null&&c.group.id===E.id?c:null,{evidenceResponse:R,isLoading:z,error:O,mutate:q}=h4(E),T=p.useCallback(()=>{S()},[S]),D=p.useCallback(async F=>{i(F.id),l(null);try{const Z=await fetch(`/api/groups/${encodeURIComponent(F.id)}/evidence`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})});if(!Z.ok){l(await Wt(Z,`Export failed with status ${String(Z.status)}`));return}const J=await jt(Z,D1);u(J),await S(),await q()}catch(Z){l(Z instanceof Error?Z.message:String(Z))}finally{i(null)}},[S,q]),k=p.useCallback(F=>{f(F),h(!1),b(null)},[]),$=p.useCallback(()=>{v===null&&(f(null),h(!1),b(null))},[v]),X=p.useCallback(F=>{r(F),f(null),h(!1),b(null)},[]),B=p.useCallback(async()=>{const F=d;if(F!==null){g(F.id),b(null);try{const Z=await fetch(x4(F.id,m),{method:"DELETE"});if(!Z.ok){b(await Wt(Z,`Delete failed with status ${String(Z.status)}`));return}await jt(Z,M1),u(J=>J!==null&&J.group.id===F.id?null:J),r(J=>J===F.id?null:J),f(null),h(!1),await S(),await q()}catch(Z){b(Z instanceof Error?Z.message:String(Z))}finally{g(null)}}},[m,d,S,q]);return s.jsxs(Hr,{open:e,onOpenChange:t,children:[s.jsx(ol,{asChild:!0,children:s.jsxs(Se,{type:"button",variant:"ghost",size:"icon",className:Pl,"aria-label":"Evaluation groups",title:"Evaluation groups",children:[s.jsx(ac,{className:"size-4"}),_?s.jsx(ft,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):y.length>0?s.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:y.length}):null,s.jsx("span",{className:"sr-only",children:"Evaluation groups"})]})}),s.jsxs(Zr,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[s.jsx(Vr,{children:s.jsxs(qr,{className:"flex items-center gap-2 pr-8",children:[s.jsx(ac,{className:"size-5 text-muted-foreground"}),s.jsx("span",{children:"Groups"}),s.jsx(Be,{variant:"outline",children:gt(y.length)})]})}),s.jsxs("div",{className:"flex min-h-0 items-center justify-between gap-3 border-b border-border pb-3",children:[s.jsx("p",{className:"text-xs text-muted-foreground",children:"Evaluation batches, model runs, and exported evidence packs."}),s.jsxs(Se,{type:"button",variant:"outline",size:"sm",className:"shrink-0",onClick:T,children:[s.jsx(zr,{className:"size-3.5"}),"Refresh"]})]}),s.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[260px_minmax(0,1fr)]",children:[s.jsx(E4,{groups:y,selectedGroupId:E?.id??null,isLoading:_,error:j,onSelect:X}),s.jsx(A4,{group:E,deleteTarget:d,deleteEvidence:m,exportResult:C,evidenceResponse:R,evidenceLoading:z,evidenceError:O,exportError:a,deleteError:x,exportingGroupId:o,deletingGroupId:v,onDeleteEvidenceChange:h,onExport:D,onRequestDelete:k,onCancelDelete:$,onConfirmDelete:()=>{B()}})]})]})]})}function E4({groups:e,selectedGroupId:t,isLoading:n,error:r,onSelect:o}){return n?s.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..."}):r!==void 0?s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:r.message}):e.length===0?s.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."}):s.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:s.jsx("div",{className:"space-y-2",children:e.map(i=>{const a=Am(i),l=t===i.id;return s.jsxs("button",{type:"button",onClick:()=>o(i.id),className:le("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:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:i.title}),s.jsx(Be,{variant:"outline",className:Ml(i.status),children:Ll(i.status)})]}),s.jsxs("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[s.jsxs("span",{children:[a.memberCount," sessions"]}),s.jsx("span",{children:ar(i.updatedAt)})]})]},i.id)})})})}function A4({group:e,deleteTarget:t,deleteEvidence:n,exportResult:r,evidenceResponse:o,evidenceLoading:i,evidenceError:a,exportError:l,deleteError:c,exportingGroupId:u,deletingGroupId:d,onDeleteEvidenceChange:f,onExport:m,onRequestDelete:h,onCancelDelete:v,onConfirmDelete:g}){if(e===null)return s.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 x=Am(e),b=N4(e,r,o),y=T4(e,r,o),_=C4(e,r),j=b4(e,r,o),S=u===e.id,E=d===e.id,C=t?.id===e.id;return s.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx("h3",{className:"min-w-0 truncate text-base font-semibold",children:e.title}),s.jsx(Be,{variant:"outline",className:Ml(e.status),children:Ll(e.status)}),s.jsx(Be,{variant:"outline",children:e.kind})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("span",{children:qo(e.project)}),s.jsxs("span",{children:["updated ",ar(e.updatedAt)]})]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(Se,{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?s.jsx(ft,{className:"size-3.5 animate-spin"}):s.jsx(nr,{className:"size-3.5"})}),s.jsxs(Se,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:S||E,onClick:()=>{m(e)},children:[S?s.jsx(ft,{className:"size-3.5 animate-spin"}):s.jsx(wo,{className:"size-3.5"}),"Export evidence"]})]})]}),e.task!==null&&e.task.trim().length>0&&s.jsx("p",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:e.task}),C&&s.jsx(R4,{group:e,deleteEvidence:n,isDeleting:E,error:c,onDeleteEvidenceChange:f,onCancel:v,onConfirm:g}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[s.jsx(Xt,{label:"Members",value:x.memberCount}),s.jsx(Xt,{label:"Done",value:x.completedMembers}),s.jsx(Xt,{label:"Failed",value:x.failedMembers}),s.jsx(Xt,{label:"Running",value:x.runningMembers})]}),b!==null&&s.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[s.jsx(Xt,{label:"Requests",value:b.requestCount}),s.jsx(Xt,{label:"Errors",value:b.errorCount}),s.jsx(Xt,{label:"Tokens",value:b.tokenUsage.total}),s.jsx(Xt,{label:"Missing",value:b.missingSessions})]}),s.jsx(I4,{report:y,loading:i,error:a,hasEvidence:_!==null}),s.jsx(z4,{evidence:_}),l!==null&&s.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&&!C&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:c}),s.jsx(P4,{rows:j})]})})}function R4({group:e,deleteEvidence:t,isDeleting:n,error:r,onDeleteEvidenceChange:o,onCancel:i,onConfirm:a}){const l=e.evidence!==null,c=e.evidence?.markdownPath??"No evidence pack exported.";return s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-3 text-red-900",children:s.jsxs("div",{className:"flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(nr,{className:"size-4 text-red-600"}),s.jsx("span",{children:"Delete group?"})]}),s.jsxs("p",{className:"text-xs text-red-800",children:["Delete ",s.jsx("span",{className:"font-medium",children:e.title}),". Session logs and run records stay intact."]}),s.jsxs("label",{className:le("flex min-w-0 items-start gap-2 text-xs",l?"cursor-pointer":"opacity-60"),children:[s.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0",checked:t,disabled:!l||n,onChange:u=>o(u.currentTarget.checked)}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block font-medium",children:"Also delete exported evidence files"}),s.jsx("code",{className:"mt-1 block truncate font-mono text-[11px] text-red-700",children:c})]})]}),r!==null&&s.jsx("div",{className:"rounded-md border border-red-200 bg-white px-2 py-1.5 text-xs text-red-700",children:r})]}),s.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[s.jsx(Se,{type:"button",variant:"outline",size:"sm",disabled:n,onClick:i,children:"Cancel"}),s.jsxs(Se,{type:"button",variant:"destructive",size:"sm",disabled:n,onClick:a,children:[n?s.jsx(ft,{className:"size-3.5 animate-spin"}):s.jsx(nr,{className:"size-3.5"}),"Delete"]})]})]})})}function Xt({label:e,value:t}){return s.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsx("div",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:e}),s.jsx("div",{className:"mt-1 font-mono text-sm font-semibold",children:gt(t)})]})}function I4({report:e,loading:t,error:n,hasEvidence:r}){const{copied:o,copy:i}=Ut(e?.markdown??null);return e===null&&!t&&n===void 0?null:t?s.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:[s.jsx(ft,{className:"size-3.5 animate-spin"}),"Loading evidence report..."]}):n!==void 0&&r?s.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:s.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"text-xs font-semibold",children:"Evidence report"}),s.jsx(Be,{variant:"outline",className:v4(e.status),children:e.status})]}),s.jsx(Se,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":o?"Copied evidence report":"Copy evidence report",onClick:i,children:o?s.jsx(Ge,{className:"size-3.5 text-emerald-500"}):s.jsx(Nt,{className:"size-3.5"})})]}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function z4({evidence:e}){return e===null?s.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."}):s.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-xs font-semibold",children:"Evidence paths"}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:ar(e.exportedAt)})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(yi,{label:"JSON",value:e.jsonPath}),s.jsx(yi,{label:"Markdown",value:e.markdownPath}),s.jsx(yi,{label:"HTML",value:e.htmlPath})]})]})}function yi({label:e,value:t}){const{copied:n,copy:r}=Ut(t);return s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border bg-background px-2 py-1.5",children:[s.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground",children:e}),s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t}),s.jsx(Se,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":n?`Copied ${e} path`:`Copy ${e} path`,onClick:r,children:n?s.jsx(Ge,{className:"size-3.5 text-emerald-500"}):s.jsx(Nt,{className:"size-3.5"})})]})}function P4({rows:e}){const[t,n]=p.useState(null),r=p.useCallback(o=>{n(i=>i===o?null:o)},[]);return e.length===0?s.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."}):s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-xs font-semibold",children:"Members"}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[760px] text-left text-xs",children:[s.jsx("thead",{className:"border-b border-border bg-muted/20 text-muted-foreground",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-3 py-2 font-medium",children:"Session"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Provider / Model"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Requests"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Errors"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"First chunk"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Tokens"})]})}),s.jsx("tbody",{children:e.map(o=>{const i=t===o.member.id;return s.jsxs(p.Fragment,{children:[s.jsx(O4,{row:o,isExpanded:i,onToggleDetails:r}),s.jsx(M4,{row:o,isExpanded:i})]},o.member.id)})})]})})]})}function O4({row:e,isExpanded:t,onToggleDetails:n}){const r=e.member,o=e.exportMember?.session??null,i=j4(e),a=o?.inspectorPath??td(r.sessionId),l=e.source!=="evidence",c=o?.requestCount??null,u=o?.errorCount??null,d=o?.tokenUsage.total??null,f=i?.firstChunkMs??null,m=Rm(r.label,r.sessionId),h=w4(o?.clientUserAgent,i?.userAgent,r.agent),v=o?.clientProjectFolder??null,g=al({userAgent:h,conversationId:r.sessionId,clientProjectFolder:v}),x=To(g);return s.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/20",children:[s.jsxs("td",{className:"max-w-56 px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(Se,{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(r.id)},children:t?s.jsx(st,{className:"size-3.5"}):s.jsx(bt,{className:"size-3.5"})}),x!==null&&s.jsx(ll,{client:g,className:"size-5"}),l?s.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:[s.jsx("span",{className:"min-w-0 truncate",children:m}),s.jsx(Va,{className:"size-3 shrink-0 text-muted-foreground"})]}):s.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(r.id)},children:[s.jsx("span",{className:"min-w-0 truncate",children:m}),s.jsx(Be,{variant:"outline",className:"shrink-0 border-zinc-200 bg-zinc-50 text-zinc-600",children:"evidence"})]})]}),s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:qo(r.agent)})]}),s.jsx("td",{className:"max-w-52 px-3 py-2",children:s.jsx("span",{className:"block truncate",children:k4(r)})}),s.jsx("td",{className:"px-3 py-2",children:s.jsx(Be,{variant:"outline",className:Ml(r.status),children:Ll(r.status)})}),s.jsx("td",{className:"px-3 py-2 font-mono",children:c===null?"-":gt(c)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":gt(u)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:ba(f)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":gt(d)})]})}function M4({row:e,isExpanded:t}){if(!t)return null;const n=e.member,r=e.exportMember,o=r?.session??null,i=r?.run??null,a=Object.entries(n.metadata);return s.jsx("tr",{className:"border-b border-border bg-muted/10",children:s.jsx("td",{colSpan:7,className:"px-3 pb-4 pt-2",children:s.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-background p-3",children:[s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(et,{label:"Source",value:S4(e.source)}),s.jsx(et,{label:"Member ID",value:n.id,mono:!0}),s.jsx(et,{label:"Session ID",value:n.sessionId,mono:!0}),s.jsx(et,{label:"Run ID",value:i?.id??n.runId??"-",mono:!0}),s.jsx(et,{label:"Created",value:ar(n.addedAt)}),s.jsx(et,{label:"Updated",value:ar(n.updatedAt)}),s.jsx(et,{label:"Session created",value:du(o?.createdAt??null)}),s.jsx(et,{label:"Session updated",value:du(o?.updatedAt??null)})]}),o===null?s.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."}):s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(et,{label:"Log coverage",value:o.logCoverage}),s.jsx(et,{label:"Runtime",value:qo(o.runtimeMode)}),s.jsx(et,{label:"Requests",value:gt(o.requestCount),mono:!0}),s.jsx(et,{label:"Errors",value:gt(o.errorCount),mono:!0}),s.jsx(et,{label:"Input tokens",value:gt(o.tokenUsage.input),mono:!0}),s.jsx(et,{label:"Output tokens",value:gt(o.tokenUsage.output),mono:!0}),s.jsx(et,{label:"Cache read",value:gt(o.tokenUsage.cacheRead),mono:!0}),s.jsx(et,{label:"Total tokens",value:gt(o.tokenUsage.total),mono:!0})]}),s.jsx(L4,{logs:o?.latestLogs??[]}),s.jsx(D4,{entries:a})]})})})}function et({label:e,value:t,mono:n=!1}){return s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),s.jsx("div",{className:le("truncate text-xs text-foreground",n?"font-mono":""),title:t,children:t})]})}function L4({logs:e}){const t=e.slice(0,5);return t.length===0?s.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."}):s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.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"}),s.jsx("div",{className:"divide-y divide-border",children:t.map(n=>{const r=n.sessionLogNumber??n.id;return s.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs sm:grid-cols-[72px_1fr_88px_88px]",children:[s.jsxs("span",{className:"font-mono text-muted-foreground",title:`Log ID ${String(n.id)}`,children:["#",r]}),s.jsxs("span",{className:"min-w-0 truncate",children:[qo(n.model)," · ",n.apiFormat," · ",n.path]}),s.jsx("span",{className:"font-mono text-muted-foreground",children:ba(n.firstChunkMs)}),s.jsx("span",{className:"font-mono text-muted-foreground",children:ba(n.latencyMs)})]},n.id)})})]})}function D4({entries:e}){return e.length===0?null:s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.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"}),s.jsx("div",{className:"grid gap-x-3 gap-y-2 p-3 text-xs sm:grid-cols-2",children:e.map(([t,n])=>{const r=y4(n);return s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"mr-2 text-muted-foreground",children:t}),s.jsx("span",{className:"font-mono text-foreground",title:r,children:r})]},t)})})]})}function $4(){return s.jsxs("svg",{fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[s.jsx("title",{children:"Claude Code"}),s.jsx("path",{clipRule:"evenodd",d:"M20.998 10.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6 10.949h1.488V8.102H6v2.847zm10.51 0H18V8.102h-1.49v2.847z"})]})}function F4(){return s.jsxs("svg",{fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[s.jsx("title",{children:"OpenCode"}),s.jsx("path",{d:"M16 6H8v12h8V6zm4 16H4V2h16v20z"})]})}function B4(){return s.jsxs("svg",{fill:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[s.jsx("title",{children:"MiMo Code"}),s.jsx("text",{x:"12",y:"18",textAnchor:"middle",fontSize:"16",fontWeight:"800",fontFamily:"system-ui, sans-serif",children:"M"})]})}const U4=G({name:N(),apiKey:N(),format:Te(["anthropic","openai"]),anthropicBaseUrl:N(),openaiBaseUrl:N(),openaiResponsesBaseUrl:N().optional().default(""),models:me(N()),sourceTool:Te(["claude-code","opencode","mimo-code"]),alreadyExists:Fe()}),W4=G({providers:me(U4),warnings:me(N()).optional()}),H4=G({success:Fe().optional(),imported:K().optional(),message:N().optional(),errors:me(N()).optional()}),Z4={"claude-code":$4,opencode:F4,"mimo-code":B4};function V4({open:e,onOpenChange:t,onImportComplete:n}){const[r,o]=p.useState(!1),[i,a]=p.useState(null),[l,c]=p.useState([]),[u,d]=p.useState([]),[f,m]=p.useState(new Set),[h,v]=p.useState(!1),[g,x]=p.useState(null),[b,y]=p.useState(null),_=p.useCallback(()=>{o(!0),a(null),d([]),c([]),m(new Set),x(null),y(null),fetch("/api/providers/scan").then(C=>C.ok?C.json().then(R=>{const z=W4.safeParse(R);if(!z.success){a(`Invalid response: ${z.error.message}`);return}c(z.data.providers),d(z.data.warnings??[]);const O=new Set;z.data.providers.forEach((q,T)=>{q.alreadyExists||O.add(T)}),m(O)}):C.text().then(R=>{a(`Scan failed (${C.status}): ${R}`)})).catch(C=>{a(C instanceof Error?C.message:String(C))}).finally(()=>{o(!1)})},[]);p.useEffect(()=>{e&&_()},[e,_]);const j=p.useCallback(C=>{m(R=>{const z=new Set(R);return z.has(C)?z.delete(C):z.add(C),z})},[]),S=p.useCallback(()=>{const C=l.filter((O,q)=>f.has(q));if(C.length===0)return;v(!0),y(null),x(null);const R=new Date().toISOString(),z=C.map(O=>({id:window.crypto.randomUUID(),name:O.name,apiKey:O.apiKey,format:O.format,anthropicBaseUrl:O.anthropicBaseUrl,openaiBaseUrl:O.openaiBaseUrl,openaiResponsesBaseUrl:O.openaiResponsesBaseUrl,models:O.models,createdAt:R,updatedAt:R}));fetch("/api/providers/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providers:z})}).then(O=>O.json()).then(O=>{const q=H4.safeParse(O);if(!q.success){y(`Invalid response: ${q.error.message}`);return}const T=q.data;c(D=>D.map((k,$)=>f.has($)?{...k,alreadyExists:!0}:k)),m(new Set),T.errors!==void 0&&T.errors.length>0&&T.message!==void 0?x(T.message):x(`Imported ${T.imported??C.length} provider(s)`),n()}).catch(O=>{y(O instanceof Error?O.message:String(O))}).finally(()=>{v(!1)})},[l,f,n]),E=l.some(C=>!C.alreadyExists);return s.jsx(Hr,{open:e,onOpenChange:t,children:s.jsxs(Zr,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[s.jsxs(Vr,{children:[s.jsx(qr,{children:"Import from External Tools"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[r&&s.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[s.jsx(ft,{className:"size-4 animate-spin"}),s.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),i!==null&&s.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[s.jsx(Ir,{className:"size-4"}),i]}),!r&&i===null&&l.length===0&&s.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",s.jsx("br",{}),s.jsx("span",{className:"text-xs",children:"Supported tools: Claude Code (~/.claude/settings.json), OpenCode (~/.config/opencode/opencode.json), MiMo Code (~/.config/mimocode/mimocode.jsonc)"})]}),!r&&l.map((C,R)=>s.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${C.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!C.alreadyExists&&s.jsx("input",{type:"checkbox",checked:f.has(R),disabled:h,onChange:()=>j(R),className:"mt-0.5 size-4"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[(()=>{const z=Z4[C.sourceTool];return z===void 0?null:s.jsx(z,{})})(),C.alreadyExists&&s.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),s.jsxs("div",{className:"text-xs text-muted-foreground mt-1 truncate",children:[C.models.slice(0,4).join(", "),C.models.length>4?` +${C.models.length-4} more`:""]}),s.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:C.format==="anthropic"?C.anthropicBaseUrl:C.openaiResponsesBaseUrl!==""?C.openaiResponsesBaseUrl:C.openaiBaseUrl}),s.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:C.apiKey.length>8?`${C.apiKey.slice(0,4)}••••${C.apiKey.slice(-4)}`:"••••"})]})]},`${C.sourceTool}-${C.name}`)),u.length>0&&s.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:u.map((C,R)=>s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Ir,{className:"size-3"}),C]},R))}),g!==null&&s.jsx("div",{className:"text-sm text-green-500 border-t pt-2",children:g}),b!==null&&s.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:b})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[s.jsxs(Se,{variant:"outline",size:"sm",onClick:_,disabled:r,children:[s.jsx(ft,{className:`size-3 mr-1 ${r?"animate-spin":""}`}),"Rescan"]}),s.jsxs(Se,{size:"sm",onClick:S,disabled:!E||f.size===0||h,children:[s.jsx(wo,{className:"size-3 mr-1"}),h?"Importing...":`Import Selected (${f.size})`]})]})]})})}function Im(e){return e.length<=8?"••••••••":e.slice(0,4)+"••••••••"+e.slice(-4)}const zm=G({id:N().min(1),aliases:me(N()).optional().default([]),contextWindow:K().int().positive().optional(),outputLimit:K().int().positive().optional(),sourceUrl:N().optional()}),q4=G({name:N().min(1).optional(),aliases:me(N()).optional().default([]),baseUrls:me(N()).optional().default([]),models:me(zm).min(1)});G({version:K().int().positive().optional(),updatedAt:N().optional(),providers:me(q4).optional().default([]),models:me(zm).optional().default([])});function pu(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function K4(e){const t=e.models.filter(n=>n.trim()!=="");return t.length>0?t:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function Dl(e,t){const n=pu(t);return(e.modelMetadata??[]).find(o=>pu(o.model)===n)??null}function G4(e){const t=K4(e);return t.length===0?!1:t.every(n=>{const r=Dl(e,n);return r!==null&&r.contextWindow!==void 0})}function J4(e,t){if(e===null)return null;for(const n of t){const r=Dl(n,e);if(r!==null&&r.contextWindow!==void 0)return{providerName:n.name,model:r.model,tokens:r.contextWindow,sourceUrl:r.sourceUrl}}return null}const kn="/v1/chat/completions",lo="/v1/responses",Pm="/v1/messages";function Y4(e,t){const n=e.endsWith("/")?e.slice(0,-1):e,r=Mm(t),o=t.indexOf("?"),i=o>=0?t.slice(o):"";return r!==""&&n.endsWith(r)?n+i:Dm(n)&&Lm(t)||n.endsWith("/v1")&&t.startsWith("/v1/")?n+t.slice(3):n+t}function Om(e,t,n={}){const r=e.trim().replace(/\/+$/,""),o=Mm(t),i=Y4(r,t),a=[];return o!==""&&r.endsWith(o)?a.push({severity:"info",message:"This already includes the exact endpoint; no duplicate suffix will be appended."}):Dm(r)&&Lm(t)?a.push({severity:"info",message:"Zhipu bases already include the API version; only /chat/completions is appended."}):r.endsWith("/v1")&&t.startsWith("/v1/")&&a.push({severity:"info",message:"Base URL already ends with /v1; the suffix will not repeat /v1."}),hu(o)&&Q4(r)&&a.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),X4(o)&&eA(r)&&a.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),hu(o)&&tA(r,n.providerName)&&a.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:i,diagnostics:a}}function Mm(e){return e.split("?")[0]??e}function Lm(e){return e===kn||e.startsWith(`${kn}?`)||e.startsWith(`${kn}/`)}function X4(e){return e===kn||e.startsWith(`${kn}/`)}function hu(e){return e===lo||e.startsWith(`${lo}/`)}function Q4(e){return e.toLowerCase().endsWith("/chat/completions")}function eA(e){return e.toLowerCase().endsWith("/responses")}function tA(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 Dm(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 nA={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function rA(e){return Object.prototype.hasOwnProperty.call(e,"success")}function sA(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function lt(e){return e!==void 0&&e.trim()!==""}function va(e){if(e===void 0)return;const t=Object.entries(e).map(([n,r])=>`${n}: ${r}`);if(t.length!==0)return t.join(`
104
+ `)}function mu(e){return va(e)!==void 0}function gu(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function oA(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function iA(e){const t=e.debug;return lt(e.error?.hint)||lt(e.error?.details)||lt(e.rawResponse)||lt(t?.requestUrl)||lt(t?.requestBody)||lt(t?.responseBody)||mu(t?.requestHeaders)||mu(t?.responseHeaders)||t?.responseStatus!==void 0}function Qt({title:e,children:t}){return s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"font-medium text-foreground/80",children:e}),t]})}function wr({value:e}){return s.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap break-all rounded-md bg-background/80 p-2 font-mono text-[11px] leading-relaxed text-foreground/80",children:e})}function aA({result:e}){const t=e.debug,n=t?.requestUrl,r=t?.requestMethod??"POST",o=va(t?.requestHeaders),i=va(t?.responseHeaders),a=t?.responseStatus!==void 0?`${t.responseStatus}${lt(t.responseStatusText)?` ${t.responseStatusText}`:""}`:void 0,l=t?.responseBody??e.rawResponse;return s.jsxs("div",{className:"max-h-80 max-w-full space-y-2 overflow-auto rounded-md border bg-muted/50 p-2 text-xs text-muted-foreground shadow-sm sm:w-[520px]",children:[lt(e.error?.hint)&&s.jsx(Qt,{title:"Hint",children:s.jsx("div",{children:e.error.hint})}),lt(e.error?.details)&&s.jsx(Qt,{title:"Error",children:s.jsx(wr,{value:e.error.details})}),lt(n)&&s.jsx(Qt,{title:"Request",children:s.jsxs("div",{className:"rounded-md bg-background/80 p-2 font-mono text-[11px] break-all text-foreground/80",children:[r," ",n]})}),o!==void 0&&s.jsx(Qt,{title:"Request Headers",children:s.jsx(wr,{value:o})}),lt(t?.requestBody)&&s.jsx(Qt,{title:"Request Body",children:s.jsx(wr,{value:t.requestBody})}),lt(a)&&s.jsx(Qt,{title:"Response Status",children:s.jsx("div",{className:"rounded-md bg-background/80 p-2 font-mono text-[11px] text-foreground/80",children:a})}),i!==void 0&&s.jsx(Qt,{title:"Response Headers",children:s.jsx(wr,{value:i})}),lt(l)&&s.jsx(Qt,{title:"Response Body",children:s.jsx(wr,{value:l})})]})}function Bn({results:e}){return s.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-2",children:[s.jsxs("div",{className:"min-w-0 rounded-md border border-border/60 bg-muted/20 px-2 py-1.5",children:[s.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Non-stream"}),s.jsx(xu,{result:e.nonStreaming})]}),s.jsxs("div",{className:"min-w-0 rounded-md border border-border/60 bg-muted/20 px-2 py-1.5",children:[s.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Stream"}),s.jsx(xu,{result:e.streaming})]})]})}function lA({diagnostic:e}){return s.jsx("div",{className:e.severity==="warning"?"text-amber-200":"text-muted-foreground",children:e.message})}function wi({label:e,baseUrl:t,endpoint:n,providerName:r,children:o}){const i=Om(t,n,{providerName:r});return s.jsxs("div",{className:"flex min-w-0 flex-col gap-2 border-t border-border/60 pt-2 first:border-t-0 first:pt-0",children:[s.jsxs("div",{className:"grid min-w-0 gap-1 text-xs sm:grid-cols-[104px_minmax(0,1fr)]",children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:e}),s.jsx("code",{className:"min-w-0 break-all font-mono text-foreground/80",children:t}),s.jsx("span",{className:"text-[10px] uppercase text-muted-foreground/80",children:"Final"}),s.jsx("code",{className:"min-w-0 break-all font-mono text-foreground",children:i.finalUrl})]}),i.diagnostics.length>0&&s.jsx("div",{className:"space-y-1 text-xs",children:i.diagnostics.map(a=>s.jsx(lA,{diagnostic:a},`${a.severity}:${a.message}`))}),o]})}function cA(e){const t={className:"size-3",strokeWidth:2};switch(e){case"timeout":return s.jsx(Ht,{...t});case"network_unreachable":return s.jsx(iw,{...t});case"connection_refused":return s.jsx(lw,{...t});case"auth_failed":return s.jsx(y2,{...t});case"rate_limited":return s.jsx(Ga,{...t});case"server_error":return s.jsx(V2,{...t});case"invalid_response":return s.jsx(Ny,{...t});case"unknown":return s.jsx(Ir,{...t});default:return s.jsx(Ir,{...t})}}function xu({result:e}){const[t,n]=p.useState(!1);if(!rA(e))return sA(e)?s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground shrink-0",children:[s.jsx(_2,{className:"size-3"}),s.jsx("span",{children:"Not configured"})]}):s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground shrink-0",children:[s.jsx($i,{className:"size-3 animate-spin"}),s.jsx("span",{children:"Testing..."})]});if(e.success){const l=[],c=[];e.inputTokens!==void 0&&l.push(s.jsxs("span",{children:[e.inputTokens," in"]},"in")),e.outputTokens!==void 0&&l.push(s.jsxs("span",{children:[e.outputTokens," out"]},"out")),e.cacheCreationInputTokens!==void 0&&e.cacheCreationInputTokens>0&&l.push(s.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["KV Cache +",e.cacheCreationInputTokens]},"cache-create")),e.cacheReadInputTokens!==void 0&&e.cacheReadInputTokens>0&&l.push(s.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",e.cacheReadInputTokens]},"cache-read")),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&c.push(s.jsxs("span",{children:["first ",gu(e.firstChunkMs)]},"first")),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&c.push(s.jsxs("span",{children:["total ",gu(e.totalStreamMs)]},"total")),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&c.push(s.jsxs("span",{children:[oA(e.tokensPerSecond)," tok/s"]},"rate"));const u=[];for(let f=0;f<l.length;f++)f>0&&u.push(", "),u.push(l[f]);const d=[];for(let f=0;f<c.length;f++)f>0&&d.push(", "),d.push(c[f]);return s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs("div",{className:"flex items-center gap-1 text-xs text-cyan-100 shrink-0",children:[s.jsx(jy,{className:"size-3 text-cyan-300"}),s.jsx("span",{children:"Connected"}),l.length>0&&s.jsxs("span",{className:"text-muted-foreground",children:["(",u,")"]}),c.length>0&&s.jsxs("span",{className:"hidden text-muted-foreground lg:inline",children:["(",d,")"]})]})}),s.jsx(Le,{children:"Connection test passed"})]})})}const r=e.error,o=r?.message??"Connection failed",i=r?.type??"unknown",a=iA(e);return s.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-1 text-xs text-red-600 max-w-[200px]",children:[cA(i),s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("span",{className:"truncate",children:o})}),s.jsx(Le,{children:"Connection test failed"})]})}),a&&s.jsxs("button",{type:"button",onClick:()=>n(l=>!l),"aria-expanded":t,"aria-label":t?"Hide provider test diagnostics":"Show provider test diagnostics",className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-border/70 bg-background/70 px-1.5 text-[10px] text-muted-foreground transition-colors hover:text-foreground",children:[t?s.jsx(qa,{className:"size-3"}):s.jsx(Ka,{className:"size-3"}),s.jsx("span",{children:t?"Hide":"Details"})]})]}),t&&a&&s.jsx(aA,{result:e})]})}function uA(e){const t=Date.now(),n=new Date(e).getTime(),r=t-n,o=Math.floor(r/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 dA(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(),r=n==="huggingface.co"||n.endsWith(".huggingface.co");return{label:r?"HF":"Source",title:r?"Open Hugging Face model source":"Open model metadata source",url:e}}catch{return null}}function fA({provider:e,testResults:t,isTesting:n,testingTimeLeft:r,isHighlighted:o,onEdit:i,onDelete:a,onTest:l,onRefreshMetadata:c,isRefreshingMetadata:u=!1}){const[d,f]=p.useState(!1),[m,h]=p.useState(!1),[v,g]=p.useState(!1);function x(){Kt(e.apiKey).then(E=>{E&&(h(!0),setTimeout(()=>h(!1),2e3))})}const b=e.apiDocsUrl??Object.entries(nA).find(([E])=>e.name.toLowerCase().includes(E))?.[1],y=G4(e),_=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",j=_?"Refresh":"Import defaults",S=e.source==="company"?s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.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"})}),s.jsx(Le,{children:"Company-provided API key"})]})}):e.source==="personal"?s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.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"})}),s.jsx(Le,{children:"Your personal API key"})]})}):null;return s.jsxs("div",{className:`border border-border bg-card shadow-sm flex flex-col gap-3 rounded-[8px] p-4 transition-all duration-500 ${o===!0?"ring-2 ring-primary shadow-md":""}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium truncate",children:e.name}),S,S===null&&e.source==="company"&&s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400 shrink-0",children:"公司"})}),s.jsx(Le,{children:"Company-provided API key"})]})}),S===null&&e.source==="personal"&&s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400 shrink-0",children:"个人"})}),s.jsx(Le,{children:"Your personal API key"})]})})]}),b!==void 0&&s.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1 text-xs",title:"View API documentation",children:[s.jsx(Va,{className:"size-3"}),s.jsx("span",{className:"sr-only",children:"Docs"})]})]}),e.models!==void 0&&e.models.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(E=>{const C=Dl(e,E),R=dA(C?.sourceUrl);return s.jsxs("span",{className:"inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:[s.jsx("span",{children:E}),C!==null&&C.contextWindow!==void 0&&s.jsx("span",{className:"font-mono text-foreground/80",children:Cf(C.contextWindow)}),R!==null&&s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("a",{href:R.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":R.title,children:R.label})}),s.jsx(Le,{children:R.title})]})})]},E)})}),!y&&s.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:[s.jsx("span",{children:"Context window metadata missing"}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsxs(Se,{type:"button",variant:"outline",size:"sm",onClick:()=>c?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:u,children:[s.jsx($i,{className:`size-3 ${u?"animate-spin":""}`}),j]}),!_&&s.jsx(Se,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-xs text-muted-foreground bg-muted px-2 py-1 rounded flex-1 truncate",children:d?e.apiKey:Im(e.apiKey)}),s.jsx("button",{type:"button",onClick:()=>f(E=>!E),className:"text-muted-foreground hover:text-foreground transition-colors p-1","aria-label":d?"Hide API key":"Show API key",children:d?s.jsx(qa,{className:"size-4"}):s.jsx(Ka,{className:"size-4"})}),s.jsx("button",{type:"button",onClick:x,className:"text-muted-foreground hover:text-foreground transition-colors p-1","aria-label":"Copy API key",children:m?s.jsx(Ge,{className:"size-4 text-cyan-300"}):s.jsx(Nt,{className:"size-4"})})]}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&s.jsx(wi,{label:"Anthropic",baseUrl:e.anthropicBaseUrl,endpoint:Pm,providerName:e.name,children:t!==void 0&&s.jsx(Bn,{results:t.anthropic})}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&s.jsx(wi,{label:"OpenAI Chat",baseUrl:e.openaiBaseUrl,endpoint:kn,providerName:e.name,children:t!==void 0&&s.jsx(Bn,{results:t.openaiChat})}),e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""&&s.jsx(wi,{label:"OpenAI Responses",baseUrl:e.openaiResponsesBaseUrl,endpoint:lo,providerName:e.name,children:t!==void 0&&s.jsx(Bn,{results:t.openaiResponses})}),t?.testedAt!==void 0&&s.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[s.jsx(Ht,{className:"size-3"}),s.jsxs("span",{children:["Tested ",uA(t.testedAt)]})]}),t?.models!==void 0&&Object.keys(t.models).length>0&&s.jsxs("div",{className:"border-t pt-2",children:[s.jsxs("button",{type:"button",onClick:()=>g(E=>!E),className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1",children:[v?s.jsx(st,{className:"size-3"}):s.jsx(bt,{className:"size-3"}),"Model Test Results (",Object.keys(t.models).length,")"]}),v&&s.jsx("div",{className:"mt-2 overflow-x-auto",children:s.jsxs("table",{className:"w-full text-xs border-collapse",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border",children:[s.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"Model"}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&s.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"Anthropic"}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&s.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"Chat"}),e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""&&s.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"Responses"})]})}),s.jsx("tbody",{children:Object.entries(t.models).map(([E,C])=>s.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[s.jsx("td",{className:"py-1 px-2 font-medium",children:E}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&s.jsx("td",{className:"py-1 px-2 align-top",children:s.jsx(Bn,{results:C.anthropic})}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&s.jsx("td",{className:"py-1 px-2 align-top",children:s.jsx(Bn,{results:C.openaiChat})}),e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""&&s.jsx("td",{className:"py-1 px-2 align-top",children:s.jsx(Bn,{results:C.openaiResponses})})]},E))})]})})]}),s.jsxs("div",{className:"flex gap-2 pt-1 border-t",children:[l!==void 0&&s.jsxs(Se,{variant:"outline",size:"sm",onClick:()=>l(e.id),className:"text-xs h-7 gap-1",disabled:n??!1,children:[s.jsx($i,{className:`size-3 ${n??!1?"animate-spin":""}`}),n??!1?r!==void 0?`Testing (${r}s)`:"Testing...":"Test"]}),s.jsxs(Se,{variant:"outline",size:"sm",onClick:()=>i(e),className:"text-xs h-7 gap-1",disabled:n??!1,children:[s.jsx(af,{className:"size-3"}),"Edit"]}),s.jsxs(Se,{variant:"outline",size:"sm",onClick:()=>a(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:n??!1,children:[s.jsx(nr,{className:"size-3"}),"Delete"]})]})]})}const bu=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],vu=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],ks=Pm,_s=kn,js=lo,pA={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"}},yu=["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"],wu=["qwen3.6-plus","qwen3.7-max"],ku=["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"],ya="__unset__",co="__custom__",$m=[{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 vn(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function _u(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function Fm(e,t){const n=_u(t);return e?.modelMetadata?.find(r=>_u(r.model)===n)??null}function Bm(e){const t=Ws(e);if(t===null)return null;for(const n of $m)if(Ws(n.value)===t)return n.value;return null}function hA(e){return e.trim()===""?"unset":Bm(e)!==null?"preset":"custom"}function mA(e){switch(e.contextWindowMode){case"unset":return ya;case"custom":return co;case"preset":return Bm(e.contextWindow)??co}}function ki(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 r=n[1];if(r===void 0)return{amount:t,unit:"K"};const o=n[2];if(o===void 0||o==="")return{amount:r,unit:"tokens"};switch(o.toLowerCase()){case"k":return{amount:r,unit:"K"};case"m":return{amount:r,unit:"M"};default:return{amount:t,unit:"K"}}}function ju(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 Su(e,t){return t.map(n=>{const r=Fm(e,n),o=r?.contextWindow!==void 0?Ck(r.contextWindow):"";return{contextWindow:o,contextWindowMode:hA(o),outputLimit:r?.outputLimit?.toString()??""}})}function Cu(e){const t=e.trim();if(t==="")return null;const n=Number(t);return!Number.isInteger(n)||n<=0?null:n}function Un(e,t){if(e===void 0)return"";const n=e.trim(),r=n.replace(/\/+$/,"");return r.endsWith(t)?r.slice(0,-t.length).replace(/\/+$/,""):n}function gA(e,t,n){const r=e.trim();return r===""?null:Om(r,t,{providerName:n})}function _i({baseUrl:e,endpoint:t,providerName:n}){const r=gA(e,t,n);return r===null?null:s.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs",children:[s.jsx("div",{className:"text-muted-foreground",children:"Final URL"}),s.jsx("div",{className:"break-all font-mono text-foreground",children:r.finalUrl}),r.diagnostics.length>0&&s.jsx("div",{className:"mt-2 space-y-1",children:r.diagnostics.map(o=>s.jsx("div",{className:o.severity==="warning"?"text-amber-200":"text-muted-foreground",children:o.message},`${o.severity}:${o.message}`))})]})}function xA({provider:e,onSubmit:t,onCancel:n}){const[r,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:[""]),[v,g]=p.useState(()=>Su(e,f!==void 0&&f.length>0?f:[""])),[x,b]=p.useState("anthropic"),[y,_]=p.useState(Un(e?.anthropicBaseUrl,ks)),[j,S]=p.useState(Un(e?.openaiBaseUrl,_s)),[E,C]=p.useState(Un(e?.openaiResponsesBaseUrl,js)),[R,z]=p.useState(e?.apiDocsUrl??""),[O,q]=p.useState(e?.modelMetadataUrl??""),[T,D]=p.useState(e?.source),[k,$]=p.useState({}),[X,B]=p.useState(!1),[F,Z]=p.useState(null),J=p.useRef([]);p.useEffect(()=>{if(F===null)return;const P=F;function M(Q){if(!(Q.target instanceof Node))return;const fe=J.current[P];fe!=null&&!fe.contains(Q.target)&&Z(null)}return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[F]);const[H,W]=p.useState(!1),[ce,se]=p.useState(!1),[oe,_e]=p.useState(!1),ie=r.toLowerCase().includes("minimax"),ge=r.toLowerCase().includes("alibaba"),he=[...bu,...vu].some(P=>r.toLowerCase().includes(P)),xe=ie?yu:he?ku:ge?wu:[],te=e?.modelMetadata?.some(P=>P.contextWindow!==void 0)??!1;function ue(){Kt(i).then(P=>{P&&(d(!0),setTimeout(()=>d(!1),2e3))})}p.useEffect(()=>{if(e){o(e.name),a(e.apiKey);const P=(e.models?.length??0)>0?e.models:[""];h(P),g(Su(e,P)),_(Un(e.anthropicBaseUrl,ks)),S(Un(e.openaiBaseUrl,_s)),C(Un(e.openaiResponsesBaseUrl,js)),z(e.apiDocsUrl??""),q(e.modelMetadataUrl??""),D(e.source),W(!1),se(!1),_e(!1)}},[e]),p.useEffect(()=>{const P=r.toLowerCase();for(const[M,Q]of Object.entries(pA))if(P.includes(M)){Q.anthropicBaseUrl!==void 0&&!H&&_(Q.anthropicBaseUrl),Q.openaiBaseUrl!==void 0&&!ce&&S(Q.openaiBaseUrl),Q.openaiResponsesBaseUrl!==void 0&&!oe&&C(Q.openaiResponsesBaseUrl),Q.apiDocsUrl!==void 0&&!R&&z(Q.apiDocsUrl),M==="minimax"&&m.length===1&&m[0]===""&&h([yu[0]??""]),M==="alibaba"&&m.length===1&&m[0]===""&&h([wu[0]??""]),(bu.includes(M)||vu.includes(M))&&m.length===1&&m[0]===""&&h([ku[0]??""]);break}},[r]);function be(){const P={};return r.trim()||(P.name="Name is required"),i.trim()||(P.apiKey="API key is required"),(m.length===0||m.every(M=>!M.trim()))&&(P.models="At least one model is required"),y.trim()&&!w(y.trim())&&(P.anthropicBaseUrl="Invalid URL format"),j.trim()&&!w(j.trim())&&(P.openaiBaseUrl="Invalid URL format"),E.trim()&&!w(E.trim())&&(P.openaiResponsesBaseUrl="Invalid URL format"),O.trim()&&!w(O.trim())&&(P.modelMetadataUrl="Invalid URL format"),v.forEach((M,Q)=>{const fe=Ws(M.contextWindow),de=Cu(M.outputLimit);M.contextWindow.trim()!==""&&fe===null&&(P[`modelMetadata.${Q}.contextWindow`]="Context window must be a positive number, optionally using K or M"),M.outputLimit.trim()!==""&&de===null&&(P[`modelMetadata.${Q}.outputLimit`]="Output limit must be a positive integer"),fe!==null&&de!==null&&de>fe&&(P[`modelMetadata.${Q}.outputLimit`]="Output limit should not exceed context window")}),!y.trim()&&!j.trim()&&!E.trim()&&(P.format="At least one format URL (Anthropic or OpenAI) is required"),$(P),Object.keys(P).length===0}function w(P){try{return new URL(P),!0}catch{return!1}}function Y(P,M){h(Q=>{const fe=[...Q];return fe[P]=M,fe})}function U(P,M){g(Q=>{const fe=[...Q];return fe[P]={...fe[P]??vn(),...M},fe})}function I(P,M){switch(M){case ya:U(P,{contextWindow:"",contextWindowMode:"unset"});return;case co:{const Q=v[P]??vn();U(P,{contextWindow:Q.contextWindow,contextWindowMode:"custom"});return}default:U(P,{contextWindow:M,contextWindowMode:"preset"});return}}function A(P,M){const Q=v[P]??vn(),fe=ki(Q.contextWindow);U(P,{contextWindow:ju(M,fe.unit),contextWindowMode:"custom"})}function L(P,M){const Q=v[P]??vn(),fe=ki(Q.contextWindow);switch(M){case"K":case"M":case"tokens":U(P,{contextWindow:ju(fe.amount,M),contextWindowMode:"custom"});return;default:return}}function ne(P){h(M=>M.filter((Q,fe)=>fe!==P)),g(M=>M.filter((Q,fe)=>fe!==P))}function re(){h(P=>[...P,""]),g(P=>[...P,vn()])}function V(){const P=new Date().toISOString(),M=[];return m.forEach((Q,fe)=>{const de=Q.trim();if(de==="")return;const Pe=v[fe]??vn(),Ue=Ws(Pe.contextWindow),Ne=Cu(Pe.outputLimit);if(Ue===null&&Ne===null)return;const pt=Fm(e,de);if(pt!==null&&pt.contextWindow===(Ue??void 0)&&pt.outputLimit===(Ne??void 0)){M.push({...pt,model:de});return}const ze={model:de,source:"manual",updatedAt:P};Ue!==null&&(ze.contextWindow=Ue),Ne!==null&&(ze.outputLimit=Ne),M.push(ze)}),M.length>0?M:e?.modelMetadata!==void 0?[]:void 0}function ae(P){if(P.preventDefault(),!!be()){B(!0);try{t({name:r.trim(),apiKey:i.trim(),models:m.map(M=>M.trim()).filter(M=>M!==""),anthropicBaseUrl:y.trim()||void 0,openaiBaseUrl:j.trim()||void 0,openaiResponsesBaseUrl:E.trim()||void 0,apiDocsUrl:R.trim()||void 0,modelMetadataUrl:O.trim()||void 0,modelMetadata:V(),source:T})}finally{B(!1)}}}return s.jsxs("form",{onSubmit:ae,className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsx("input",{id:"provider-name",type:"text",value:r,onChange:P=>o(P.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"}),k.name!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.name})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),s.jsxs("select",{id:"provider-source",value:T??"",onChange:P=>D(P.target.value==="company"||P.target.value==="personal"?P.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:[s.jsx("option",{value:"",children:"Unspecified"}),s.jsx("option",{value:"personal",children:"个人 (Personal)"}),s.jsx("option",{value:"company",children:"公司 (Company)"})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-model-metadata-url",className:"text-sm font-medium",children:"Model Metadata URL"}),s.jsx("input",{id:"provider-model-metadata-url",type:"text",value:O,onChange:P=>q(P.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"}),k.modelMetadataUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.modelMetadataUrl}),O.trim()===""&&s.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&&!te&&O.trim()===""&&s.jsx("p",{className:"text-xs text-amber-400",children:"This provider has no matching context metadata yet."}),O.trim()!==""&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent Inspector will refresh model limits from this JSON registry after save."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{id:"provider-apikey",type:"text",value:l||i.length===0?i:Im(i),onChange:P=>a(P.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"}),s.jsx("button",{type:"button",onClick:()=>c(P=>!P),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":l?"Hide API key":"Show API key",children:l?s.jsx(qa,{className:"size-4"}):s.jsx(Ka,{className:"size-4"})}),s.jsx("button",{type:"button",onClick:ue,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:u?s.jsx(Ge,{className:"size-4 text-cyan-300"}):s.jsx(Nt,{className:"size-4"})})]}),k.apiKey!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.apiKey})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"text-sm font-medium",children:["Models ",s.jsx("span",{className:"text-destructive",children:"*"})]}),m.map((P,M)=>{const Q=v[M]??vn(),fe=k[`modelMetadata.${M}.contextWindow`],de=k[`modelMetadata.${M}.outputLimit`],Pe=mA(Q),Ue=ki(Q.contextWindow);return s.jsxs("div",{ref:Ne=>{J.current[M]=Ne},className:"border border-border bg-card shadow-sm space-y-2 rounded-[8px] p-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx("input",{type:"text",value:P,onChange:Ne=>Y(M,Ne.target.value),placeholder:xe.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"}),xe.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:()=>Z(F===M?null:M),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:s.jsx(st,{className:"size-4"})}),F===M&&s.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:xe.map(Ne=>s.jsx("button",{type:"button",onClick:()=>{Y(M,Ne),Z(null)},className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-white/[0.06]",children:Ne},Ne))})]})]}),m.length>1&&s.jsx("button",{type:"button",onClick:()=>ne(M),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:s.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:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),s.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[s.jsx("span",{children:"Context Window"}),s.jsxs(so,{value:Pe,onValueChange:Ne=>I(M,Ne),children:[s.jsx(io,{size:"sm",className:"w-full bg-background font-mono text-xs",children:s.jsx(oo,{})}),s.jsxs(ao,{className:"max-h-64",children:[s.jsx(At,{value:ya,children:"Not set"}),$m.map(Ne=>s.jsxs(At,{value:Ne.value,children:[Ne.label," · ",Ne.value]},Ne.value)),s.jsx(At,{value:co,children:"Custom"})]})]}),Q.contextWindowMode==="custom"&&s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_5.75rem] gap-1.5",children:[s.jsx("input",{type:"text",inputMode:"decimal",value:Ue.amount,onChange:Ne=>A(M,Ne.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]"}),s.jsxs(so,{value:Ue.unit,onValueChange:Ne=>L(M,Ne),children:[s.jsx(io,{size:"sm",className:"w-full bg-background font-mono text-xs",children:s.jsx(oo,{})}),s.jsxs(ao,{children:[s.jsx(At,{value:"K",children:"K"}),s.jsx(At,{value:"M",children:"M"}),s.jsx(At,{value:"tokens",children:"tokens"})]})]})]}),fe!==void 0&&s.jsx("span",{className:"block text-destructive",children:fe})]}),s.jsxs("label",{className:"space-y-1 text-xs text-muted-foreground",children:[s.jsx("span",{children:"Output Limit"}),s.jsx("input",{type:"number",min:1,step:1e3,value:Q.outputLimit,onChange:Ne=>U(M,{outputLimit:Ne.target.value}),placeholder:"e.g. 8192",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),de!==void 0&&s.jsx("span",{className:"block text-destructive",children:de})]})]})]},M)}),s.jsx("button",{type:"button",onClick:re,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),k.models!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.models})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"border border-border bg-muted/40 flex gap-1 rounded-[8px] p-1",children:[s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>b("anthropic"),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${x==="anthropic"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Anthropic Format"})}),s.jsx(Le,{children:"Anthropic Messages API format"})]})}),s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>b("openai"),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${x==="openai"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"OpenAI Format"})}),s.jsx(Le,{children:"OpenAI Chat Completions API format"})]})})]}),k.format!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.format})]}),x==="anthropic"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:"Anthropic Base URL"}),s.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:[s.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:y,onChange:P=>{W(!0),_(P.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"}),s.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:ks})]}),k.anthropicBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.anthropicBaseUrl}),s.jsx(_i,{baseUrl:y,endpoint:ks,providerName:r}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Anthropic-compatible base URL. Leave empty if this provider does not support Anthropic format."})]}),x==="openai"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:"OpenAI Chat Base URL"}),s.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:[s.jsx("input",{id:"provider-openai-base-url",type:"text",value:j,onChange:P=>{se(!0),S(P.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"}),s.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:_s})]}),k.openaiBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.openaiBaseUrl}),s.jsx(_i,{baseUrl:j,endpoint:_s,providerName:r}),s.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."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-openai-responses-base-url",className:"text-sm font-medium",children:"OpenAI Responses Base URL"}),s.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:[s.jsx("input",{id:"provider-openai-responses-base-url",type:"text",value:E,onChange:P=>{_e(!0),C(P.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"}),s.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:js})]}),k.openaiResponsesBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:k.openaiResponsesBaseUrl}),s.jsx(_i,{baseUrl:E,endpoint:js,providerName:r}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional Responses-compatible base URL. Set only when the provider supports the Responses API."})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),s.jsx("input",{id:"provider-api-docs-url",type:"text",value:R,onChange:P=>z(P.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"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),s.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:[s.jsx(Se,{type:"button",variant:"outline",onClick:n,disabled:X,children:"Cancel"}),s.jsx(Se,{type:"submit",disabled:X,children:X?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const bA=Te(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),vA=G({message:N(),type:bA,details:N().optional(),hint:N().optional()}),yA=G({type:Te(["text","thinking"]),text:N().optional(),thinking:N().optional()}),wA=G({requestUrl:N().optional(),requestMethod:N().optional(),requestHeaders:Ke(N(),N()).optional(),requestBody:N().optional(),responseStatus:K().optional(),responseStatusText:N().optional(),responseHeaders:Ke(N(),N()).optional(),responseBody:N().optional()}),kA=G({success:Fe(),error:vA.optional(),model:N().optional(),inputTokens:K().optional(),outputTokens:K().optional(),cacheCreationInputTokens:K().optional(),cacheReadInputTokens:K().optional(),latencyMs:K().optional(),firstChunkMs:K().nullable().optional(),totalStreamMs:K().nullable().optional(),tokensPerSecond:K().nullable().optional(),content:me(yA).optional(),rawResponse:N().optional(),streaming:Fe().optional(),streamingChunks:G({chunks:me(Pd),truncated:Fe().default(!1)}).optional(),requestHeaders:Ke(N(),N()).optional(),debug:wA.optional()}),Nu=Mt([kA,G({notConfigured:Ce(!0)}),G({testing:Ce(!0)})]),nn=G({nonStreaming:Nu,streaming:Nu});function uo(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const _A=G({anthropic:nn,openai:nn.optional(),openaiChat:nn.optional(),openaiResponses:nn.optional()}).transform(e=>{const t=e.openaiChat??e.openai??uo();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??uo()}}),jA=G({anthropic:nn,openai:nn.optional(),openaiChat:nn.optional(),openaiResponses:nn.optional(),models:Ke(N(),_A).optional(),testedAt:N().optional()}).transform(e=>{const t=e.openaiChat??e.openai??uo();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??uo()}});function SA(){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 Tu(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 CA=G({providerConfig:N()}),NA=G({success:Fe().optional(),imported:K().optional(),message:N().optional(),errors:me(N()).optional()}),TA=G({provider:Hs,imported:K(),matchedModels:me(N()),missingModels:me(N()),sourceUrl:N()}),Ss="Network error: could not reach the server. Is the proxy running?";function Eu(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 EA(e,t){const n=e?.models?.map(r=>r.trim()).filter(r=>r!=="").length??0;return Math.max(1,n)*t}async function AA(e,t){if(t.models!==void 0)try{await fetch(`/api/providers/${e}/test/log`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function RA({externalProviders:e,isLoading:t=!1,externalTestResults:n,externalTestingProviders:r,externalTestingTimeLeft:o,onProvidersMutate:i,onTestResultsChange:a,onTestingProvidersChange:l,onTestingTimeLeftChange:c}){const[u,d]=p.useState(!1),[f,m]=p.useState(),[h,v]=p.useState(null),[g,x]=p.useState({}),[b,y]=p.useState(new Set),[_,j]=p.useState({}),[S,E]=p.useState(null),[C,R]=p.useState(!1),[z,O]=p.useState(null),[q,T]=p.useState(!1),[D,k]=p.useState(!1),[$,X]=p.useState(null),[B,F]=p.useState("all"),[Z,J]=p.useState(new Set),{providerTestTimeoutSeconds:H}=Ha(),W=p.useRef(null),ce=p.useRef(null),se=e??[],oe=p.useMemo(()=>{const P=B==="all"?se:se.filter(M=>M.source===B);return B==="all"?[...P].sort((M,Q)=>{const fe={personal:0,company:1};return(fe[M.source??""]??2)-(fe[Q.source??""]??2)}):P},[se,B]),_e=n??g,ie=r??b,ge=o??_,he=c?(P,M)=>c(P,M):(P,M)=>{j(M===void 0?Q=>{const fe={...Q};return delete fe[P],fe}:Q=>({...Q,[P]:M}))};p.useEffect(()=>{(async()=>{try{const P=await fetch("/api/config/paths");if(P.ok){const M=await jt(P,CA);E(M.providerConfig)}}catch{}})()},[]);const xe=p.useCallback(P=>{ce.current!==null&&clearTimeout(ce.current),O(P),W.current?.scrollTo({top:W.current.scrollHeight,behavior:"smooth"}),ce.current=setTimeout(()=>{O(null),ce.current=null},2e3)},[]);p.useEffect(()=>()=>{ce.current!==null&&clearTimeout(ce.current)},[]);const te=p.useCallback(()=>{i?.().catch(()=>{})},[i]),ue=p.useCallback((P,M)=>{a?a(P,M):x(Q=>({...Q,[P]:M}))},[a]),be=p.useCallback((P,M)=>{if(l){l(P,M);return}y(Q=>{const fe=new Set(Q);return M?fe.add(P):fe.delete(P),fe})},[l]),w=p.useCallback(async P=>{ue(P,SA()),be(P,!0);const M=new AbortController,Q=se.find(Ue=>Ue.id===P);let de=EA(Q,H);he(P,de);const Pe=setInterval(()=>{de--,he(P,de),de<=0&&(clearInterval(Pe),M.abort())},1e3);try{const Ue=await fetch(`/api/providers/${P}/test`,{method:"POST",signal:M.signal});if(Ue.ok){const Ne=await jt(Ue,jA);ue(P,Ne),await AA(P,Ne)}else ue(P,Tu(`HTTP ${Ue.status}: ${Ue.statusText}`,"server_error"))}catch(Ue){Ue instanceof Error&&Ue.name==="AbortError"&&ue(P,Tu("Request timed out","timeout"))}finally{clearInterval(Pe),he(P,void 0),be(P,!1)}},[H,se,he,ue,be]),Y=p.useCallback(async(P,M,Q=!0)=>{J(fe=>{const de=new Set(fe);return de.add(P),de});try{const fe=M!==void 0&&M.trim()!==""?{url:M}:{},de=await fetch(`/api/providers/${P}/model-metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(fe)});if(!de.ok)return Q&&v(await Wt(de,"Failed to refresh model metadata")),!1;const Pe=await jt(de,TA);return Pe.imported===0&&Q?v("No matching model metadata found for this provider."):v(null),xe(Pe.provider.id),te(),Pe.imported>0}catch{return Q&&v(Ss),!1}finally{J(fe=>{const de=new Set(fe);return de.delete(P),de})}},[te,xe]);function U(P){(async()=>{try{const M=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Eu(P))});if(!M.ok){v(await Wt(M,"Failed to add provider"));return}const Q=await jt(M,Hs);d(!1),xe(Q.id),P.modelMetadataUrl!==void 0&&P.modelMetadataUrl.trim()!==""&&await Y(Q.id,P.modelMetadataUrl,!1),te(),await w(Q.id)}catch{v(Ss)}})()}function I(P){f&&(async()=>{try{const M=await fetch(`/api/providers/${f.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Eu(P))});if(!M.ok){v(await Wt(M,"Failed to update provider"));return}const Q=await jt(M,Hs);m(void 0),xe(Q.id),P.modelMetadataUrl!==void 0&&P.modelMetadataUrl.trim()!==""&&await Y(Q.id,P.modelMetadataUrl,!1),te(),((P.apiKey??"")!==(f.apiKey??"")||JSON.stringify(P.models)!==JSON.stringify(f.models)||(P.anthropicBaseUrl??"")!==(f.anthropicBaseUrl??"")||(P.openaiBaseUrl??"")!==(f.openaiBaseUrl??"")||(P.openaiResponsesBaseUrl??"")!==(f.openaiResponsesBaseUrl??""))&&await w(Q.id)}catch{v(Ss)}})()}function A(P){X(P),k(!0)}function L(){const P=$;P!==null&&(async()=>{let M;try{M=await fetch(`/api/providers/${P}`,{method:"DELETE"})}catch{v(Ss);return}if(!M.ok){v(await Wt(M,"Failed to delete provider"));return}te()})()}const ne=p.useRef(null);function re(P){const M="/api/providers/export";(async()=>{try{const Q=await fetch(M);if(!Q.ok){v("Failed to export providers");return}const fe=await Q.blob(),de=URL.createObjectURL(fe),Pe=document.createElement("a");Pe.href=de,Pe.download=Q.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(Pe),Pe.click(),document.body.removeChild(Pe),URL.revokeObjectURL(de)}catch{v("Failed to export providers")}})()}function V(){ne.current?.click()}function ae(P){const M=P.target.files?.[0];M&&(async()=>{try{const Q=await M.text(),fe=await fetch("/api/providers/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)}),de=await jt(fe,NA);fe.ok&&de.imported!==void 0&&de.imported>0?(te(),v(null)):de.errors&&de.errors.length>0?v(de.errors.join("; ")):v(de.message??"Import failed")}catch{v("Failed to import providers")}P.target.value=""})()}return t?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):u||f?s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"border border-border bg-background/95 shadow-sm sticky top-0 z-10 flex items-center justify-between rounded-[8px] px-3 py-2",children:s.jsx("h3",{className:"text-lg font-medium",children:f?"Edit Provider":"Add New Provider"})}),s.jsx(xA,{provider:f,onSubmit:f?I:U,onCancel:()=>{d(!1),m(void 0)}})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"border border-border bg-background/95 shadow-sm sticky top-0 z-10 flex items-center justify-between rounded-[8px] px-3 py-2",children:[s.jsx("h3",{className:"text-lg font-medium",children:"Providers"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs(Se,{variant:"outline",size:"sm",onClick:()=>re(),className:"gap-1 hover:bg-muted",children:[s.jsx(wo,{className:"size-3"}),"Export"]})}),s.jsx(Le,{children:"Download providers as JSON for backup or sharing"})]})}),s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs(Se,{variant:"outline",size:"sm",onClick:V,className:"gap-1 hover:bg-muted",children:[s.jsx(lf,{className:"size-3"}),"Import"]})}),s.jsx(Le,{children:"Import providers from an exported JSON file"})]})}),s.jsx("input",{type:"file",ref:ne,accept:".json",onChange:ae,style:{display:"none"}}),s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs(Se,{variant:"outline",size:"sm",onClick:()=>T(!0),className:"gap-1",children:[s.jsx(U2,{className:"size-3"}),"Scan"]})}),s.jsx(Le,{children:"Detect and import provider configs from Claude Code and OpenCode"})]})}),s.jsxs(Se,{onClick:()=>d(!0),size:"sm",className:"gap-1",children:[s.jsx(Di,{className:"size-4"}),"Add Provider"]})]})]}),S!==null&&s.jsxs("div",{className:"border border-border bg-card shadow-sm flex items-center gap-2 rounded-[8px] px-3 py-2 text-xs text-muted-foreground",children:[s.jsx("span",{className:"shrink-0",children:"Config:"}),s.jsx("span",{className:"font-mono truncate",title:S,children:S}),s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>{Kt(S).then(P=>{P&&(R(!0),setTimeout(()=>R(!1),2e3))})},className:"shrink-0 ml-auto text-muted-foreground hover:text-foreground transition-colors","aria-label":C?"Copied config file path":"Copy config file path",children:C?s.jsx(Ge,{className:"size-3 text-cyan-300"}):s.jsx(Nt,{className:"size-3"})})}),s.jsx(Le,{children:"Copy config file path to clipboard"})]})})]}),h!==null&&s.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:[s.jsx(Ir,{className:"size-4 shrink-0"}),h]}),se.length===0?s.jsxs("div",{className:"border border-border bg-card shadow-sm space-y-3 rounded-[8px] py-12 text-center",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),s.jsxs(Se,{onClick:()=>d(!0),variant:"outline",size:"sm",children:[s.jsx(Di,{className:"size-4"}),"Add Your First Provider"]})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"border border-border bg-muted/40 flex gap-1 rounded-[8px] p-1",children:["all","personal","company"].map(P=>s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>F(P),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${B===P?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:P==="all"?"All":P==="personal"?"Personal":"Company"})}),s.jsx(Le,{children:P==="all"?"Show all providers":P==="personal"?"Providers you configured yourself":"Providers set by your organization"})]})},P))}),s.jsx("div",{ref:W,className:"space-y-3",children:oe.map(P=>s.jsx(fA,{provider:P,testResults:_e[P.id],isTesting:ie.has(P.id),testingTimeLeft:ge[P.id],isHighlighted:P.id===z,onEdit:M=>m(M),onDelete:A,onRefreshMetadata:M=>{Y(M)},isRefreshingMetadata:Z.has(P.id),onTest:M=>{w(M)}},P.id))})]}),s.jsx(V4,{open:q,onOpenChange:T,onImportComplete:()=>{i!==void 0&&i()}}),s.jsx(op,{open:D,onOpenChange:k,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:L})]})}function Au(){const[e,t]=p.useState(!1),[n,r]=p.useState("providers"),{providers:o,isLoading:i,mutate:a}=Nf(),[l,c]=p.useState({}),[u,d]=p.useState(new Set),[f,m]=p.useState({}),h=p.useCallback((x,b)=>{c(y=>({...y,[x]:b}))},[]),v=p.useCallback((x,b)=>{d(y=>{const _=new Set(y);return b?_.add(x):_.delete(x),_})},[]),g=p.useCallback((x,b)=>{m(y=>{if(b===void 0){const _={...y};return delete _[x],_}return{...y,[x]:b}})},[]);return s.jsxs(Hr,{open:e,onOpenChange:t,children:[s.jsx(ol,{asChild:!0,children:s.jsxs(Se,{variant:"ghost",size:"icon",className:Pl,"aria-label":"Settings",title:"Settings",children:[s.jsx(K2,{className:"size-4"}),s.jsx("span",{className:"sr-only",children:"Settings"})]})}),s.jsxs(Zr,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[s.jsx(Vr,{children:s.jsx(qr,{children:"Settings"})}),s.jsxs(om,{value:n,onValueChange:r,className:"flex-1 overflow-hidden",children:[s.jsxs(im,{children:[s.jsx(ht,{value:"providers",children:"Providers"}),s.jsx(ht,{value:"proxy",children:"Proxy"}),s.jsx(ht,{value:"storage",children:"Storage"}),s.jsx(ht,{value:"mcp",children:"MCP"}),s.jsx(ht,{value:"onboarding",children:"Onboarding"})]}),s.jsxs("div",{className:"mt-4 flex-1 overflow-x-hidden overflow-y-auto pr-3",children:[s.jsx(mt,{value:"providers",children:s.jsx(RA,{externalProviders:o,isLoading:i,externalTestResults:l,externalTestingProviders:u,externalTestingTimeLeft:f,onProvidersMutate:()=>a(),onTestResultsChange:h,onTestingProvidersChange:v,onTestingTimeLeftChange:g})}),s.jsx(mt,{value:"proxy",children:s.jsx(MA,{})}),s.jsx(mt,{value:"storage",children:s.jsx(zA,{})}),s.jsx(mt,{value:"mcp",children:s.jsx(OA,{})}),s.jsx(mt,{value:"onboarding",children:s.jsx(PA,{})})]})]})]})]})}const IA=G({memoryCount:K(),logDir:N(),logFileCount:K(),logBytes:K(),chunkDir:N(),chunkFileCount:K(),chunkBytes:K(),sessionArchiveDir:N(),sessionArchiveFileCount:K(),sessionArchiveBytes:K()});function ji(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 zA(){const[e,t]=p.useState(null),[n,r]=p.useState(null),[o,i]=p.useState(!1),[a,l]=p.useState(null),c=p.useCallback(async()=>{i(!0),r(null);try{const d=await fetch("/api/logs?stats=1");if(!d.ok){r(`Failed to load storage stats: HTTP ${String(d.status)}`);return}const f=await d.json(),m=IA.safeParse(f);if(!m.success){r("Storage stats response was not valid.");return}t(m.data)}catch(d){r(d instanceof Error?d.message:String(d))}finally{i(!1)}},[]);p.useEffect(()=>{c()},[c]);const u=p.useCallback((d,f)=>{Kt(f).then(m=>{m&&(l(d),setTimeout(()=>l(null),1600))})},[]);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold",children:"Log storage"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Inspect local log and streaming chunk footprint before exporting or clearing sessions."})]}),s.jsx(Se,{type:"button",variant:"outline",size:"sm",onClick:()=>{c()},children:o?"Refreshing...":"Refresh"})]}),e!==null&&s.jsxs("div",{className:"grid gap-2 text-xs",children:[s.jsx(Nr,{id:"log-dir",label:"Log storage path",value:e.logDir,copiedId:a,onCopy:u}),s.jsx(Nr,{id:"chunk-dir",label:"Streaming chunks storage path",value:e.chunkDir,copiedId:a,onCopy:u}),s.jsx(Nr,{id:"session-archive-dir",label:"Session archive storage path",value:e.sessionArchiveDir,copiedId:a,onCopy:u}),s.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"In-memory logs"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.memoryCount.toLocaleString()," loaded"]})]}),s.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"Log files"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.logFileCount.toLocaleString()," files / ",ji(e.logBytes)]})]}),s.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"Streaming chunks"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.chunkFileCount.toLocaleString()," files / ",ji(e.chunkBytes)]})]}),s.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"Session archives"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.sessionArchiveFileCount.toLocaleString()," files /"," ",ji(e.sessionArchiveBytes)]})]})]}),n!==null&&s.jsx("p",{className:"text-xs text-destructive",children:n})]})}function Nr({id:e,label:t,value:n,copiedId:r,onCopy:o}){const i=r===e;return s.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-3 py-2",children:[s.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:t}),s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:n}),s.jsx(Se,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>o(e,n),"aria-label":i?`Copied ${t}`:`Copy ${t}`,children:i?s.jsx(Ge,{className:"size-3.5 text-emerald-500"}):s.jsx(Nt,{className:"size-3.5"})})]})]})}function PA(){const[e,t]=p.useState(null),n=p.useMemo(()=>typeof window>"u"?"http://localhost:25947":window.location.origin,[]),r=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)=>{Kt(a).then(l=>{l&&(t(i),setTimeout(()=>t(null),1600))})},[]);return s.jsxs("div",{className:"min-w-0 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ja,{className:"size-4 text-muted-foreground"}),s.jsx("h3",{className:"text-sm font-semibold",children:"Agent onboarding"})]}),s.jsx("div",{className:"grid gap-2",children:r.map(i=>s.jsx(Nr,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:o},i.id))}),s.jsxs("div",{className:"grid gap-2 rounded-md border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ge,{className:"size-3.5 text-emerald-500"}),s.jsx("span",{children:"Provider test creates a traceable memory probe session."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ge,{className:"size-3.5 text-emerald-500"}),s.jsx("span",{children:"Captured sessions can produce reviewable memory candidates."})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),s.jsxs("span",{children:["Streamable HTTP clients should use the MCP URL directly. Stdio-only clients should use",s.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."]})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),s.jsxs("span",{children:["OpenCode onboarding safely merges"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode.json"}),", then verify with"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode mcp list"}),"."]})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),s.jsxs("span",{children:["MiMo Code onboarding safely merges"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",s.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"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"OPENAI_BASE_URL"}),"."]})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Ge,{className:"mt-0.5 size-3.5 text-emerald-500"}),s.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 OA(){const[e,t]=p.useState(null),r=`${p.useMemo(()=>typeof window>"u"?"http://localhost:25947":window.location.origin,[])}/api/mcp`,o=p.useMemo(()=>[{id:"mcp-url",label:"Streamable HTTP MCP URL",value:r},{id:"stdio",label:"Stdio bridge command",value:`agent-inspector-mcp stdio --url ${r}`},{id:"doctor",label:"Bridge doctor",value:`agent-inspector-mcp doctor --url ${r}`},{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:r}}},null,2)},{id:"stdio-json",label:"Stdio MCP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{command:"agent-inspector-mcp",args:["stdio","--url",r]}}},null,2)},{id:"opencode-local",label:"OpenCode local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",r],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",r],enabled:!0}}},null,2)},{id:"codex-toml",label:"Codex TOML",value:`[mcp_servers.agent-inspector]
105
105
  command = "agent-inspector-mcp"
106
- args = ["stdio", "--url", "${r}"]`}],[r]),i=p.useCallback((a,l)=>{Kt(l).then(c=>{c&&(t(a),setTimeout(()=>t(null),1600))})},[]);return s.jsxs("div",{className:"min-w-0 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ka,{className:"size-4 text-muted-foreground"}),s.jsx("h3",{className:"text-sm font-semibold",children:"MCP access"})]}),s.jsxs("div",{className:"grid gap-2 rounded-md border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:[s.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."}),s.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."})]}),s.jsx("div",{className:"grid gap-2",children:o.map(a=>s.jsx(Nr,{id:a.id,label:a.label,value:a.value,copiedId:e,onCopy:i},a.id))})]})}function MA(){const{strip:e,slowResponseThresholdSeconds:t,providerTestTimeoutSeconds:n,timeDisplayFormat:r,isLoading:o,setStrip:i,setSlowResponseThresholdSeconds:a,setProviderTestTimeoutSeconds:l,setTimeDisplayFormat:c}=Ua(),[u,d]=p.useState(null),[f,m]=p.useState(!1),h=p.useCallback(async b=>{d(null),m(!0);try{await i(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{m(!1)}},[i]),v=p.useCallback(async b=>{d(null),m(!0);try{await a(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{m(!1)}},[a]),g=p.useCallback(async b=>{d(null),m(!0);try{await l(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{m(!1)}},[l]),x=p.useCallback(async b=>{d(null),m(!0);try{await c(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{m(!1)}},[c]);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["When enabled, the proxy strips the synthetic ",s.jsx("code",{children:"x-anthropic-billing-header"})," text block that Claude Code prepends to the system prompt before forwarding to upstream. Improves prefix-cache hit rates against third-party upstreams. The default at startup is controlled by the ",s.jsx("code",{children:"AGENT_INSPECTOR_STRIP_CLAUDE_CODE_BILLING_HEADER"})," ","environment variable; your choice is persisted to ",s.jsx("code",{children:"config.json"})," and overrides the env var for subsequent requests."]})]}),s.jsxs("label",{className:"flex items-center gap-3",children:[s.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:o||f,onChange:b=>{h(b.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("span",{className:"text-sm",children:o?"Loading...":e?"Stripping enabled":"Stripping disabled"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:"slow-response-threshold",className:"text-sm font-semibold",children:"Slow response threshold"}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Logs whose elapsed time exceeds this many seconds show a warning icon next to the duration. Set to ",s.jsx("code",{children:"0"})," to disable the indicator."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{id:"slow-response-threshold",type:"number",min:0,max:zi,step:1,value:t,disabled:o||f,onChange:b=>{const y=Number(b.currentTarget.value);Number.isInteger(y)&&(y<0||y>zi||v(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"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds"})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:"provider-test-timeout",className:"text-sm font-semibold",children:"Provider test timeout"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Provider Test waits this many seconds per configured model before aborting slow probes. The full test window scales with model count."}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{id:"provider-test-timeout",type:"number",min:1,max:Pi,step:1,value:n,disabled:o||f,onChange:b=>{const y=Number(b.currentTarget.value);Number.isInteger(y)&&(y<1||y>Pi||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"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds / model"})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:"time-display-format",className:"text-sm font-semibold",children:"Time display"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls timestamps in session summaries, conversation headers, and log rows."}),s.jsxs("select",{id:"time-display-format",value:r,disabled:o||f,onChange:b=>{const y=Qd.safeParse(b.currentTarget.value);y.success&&x(y.data)},className:"h-8 rounded-md border border-input bg-background px-2 text-sm disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx("option",{value:"time",children:"Time only"}),s.jsx("option",{value:"full",children:"Full ISO"})]})]}),u!==null&&s.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",u]})]})}function LA(e){const t=new Map;for(const n of e){const r=n.logs;for(let o=1;o<r.length;o++){const i=r[o-1],a=r[o];i===void 0||a===void 0||t.set(a.id,{creation:Eu(i.cacheCreationInputTokens,a.cacheCreationInputTokens),read:Eu(i.cacheReadInputTokens,a.cacheReadInputTokens)})}}return t}function Eu(e,t){return t===null||e===null?null:t>e?{direction:"up",delta:t-e}:t<e?{direction:"down",delta:e-t}:null}function $m(e){for(const t of e){const n=t.userAgent;if(n!=null&&n!=="")return n}return null}function DA(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function Fm(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}function $A(e){return ol({userAgent:$m(e.logs),conversationId:e.conversationId,clientProjectFolder:Fm(e.logs)})}function FA(e){if(e===null||e==="")return"Unknown IDE";const t=e.split(/[ /;]/)[0]??"";return t===""?"Unknown IDE":t}function BA(e,t){const n=No(e);return n!==null?n:FA(t)}function uo(e){return e===null||e===""?"unknown":String(e)}function UA(e,t,n){return e!=="unknown"?e:`unknown:${uo(t)}:${uo(n)}`}function WA(e,t){return`${uo(e)}:${uo(t)}`}function va(e){return[...e].sort((t,n)=>t.timestamp.localeCompare(n.timestamp))}function Au(e){return va(e)[0]?.timestamp??""}function _i(e){return[...e].sort((t,n)=>Au(t.logs).localeCompare(Au(n.logs)))}function HA(e){const t=new Map;for(const r of e){const o=$m(r.logs),i=Fm(r.logs),a=$A(r),l=UA(a,o,i);let c=t.get(l);c===void 0&&(c={id:l,client:a,label:BA(a,o),userAgent:o,processes:new Map,logs:[]},t.set(l,c)),c.logs.push(...r.logs);const u=DA(r.logs),d=`${l}:${WA(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(r),f.logs.push(...r.logs)}const n=[];for(const r of t.values()){const o=_i([...r.processes.values()].map(i=>({id:i.id,clientPid:i.clientPid,clientProjectFolder:i.clientProjectFolder,sessions:_i(i.sessions),logs:va(i.logs)})));n.push({id:r.id,client:r.client,label:r.label,userAgent:r.userAgent,processes:o,logs:va(r.logs)})}return _i(n)}function fo(e){return e<=0?"0":$e(e)}function Bm(e){let t=0,n=0;for(const r of e)r.inputTokens!==null&&r.inputTokens!==void 0&&(t+=r.inputTokens),r.outputTokens!==null&&r.outputTokens!==void 0&&(n+=r.outputTokens);return{inputTokens:t,outputTokens:n}}function ZA(e){let t=0;for(const n of e)t+=n.sessions.length;return t}function VA(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 r=t[t.length-2];return r===void 0?n:`${r}/${n}`}function po({label:e,value:t,className:n}){return s.jsxs("span",{className:ae("border border-border bg-muted/40 inline-flex h-7 items-center gap-1 rounded-md px-2 text-xs text-muted-foreground",n),children:[s.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.12em] text-white/35",children:e}),s.jsx("span",{className:"font-mono tabular-nums text-slate-100",children:t})]})}function qA({groups:e,...t}){const n=p.useMemo(()=>HA(e),[e]),[r,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 s.jsx("div",{className:"space-y-4",children:n.map(u=>s.jsx(KA,{group:u,collapsed:r.has(u.id),collapsedProcessIds:i,onToggleIde:()=>l(u.id),onToggleProcess:c,conversationProps:t},u.id))})}function KA({group:e,collapsed:t,collapsedProcessIds:n,onToggleIde:r,onToggleProcess:o,conversationProps:i}){const a=Bm(e.logs),l=ZA(e.processes),c=e.logs.length;return s.jsxs("section",{className:ae("border border-border bg-card shadow-sm relative isolate rounded-[8px]"),"data-ide-group":e.id,children:[s.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:r,"aria-expanded":!t,children:[e.client==="unknown"?s.jsx("span",{className:"border border-border bg-muted/40 inline-flex size-10 shrink-0 items-center justify-center rounded-[8px] text-slate-200",children:s.jsx(k2,{className:"size-5"})}):s.jsx(il,{client:e.client,className:"size-10 rounded-[8px] text-cyan-100"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"truncate text-sm font-semibold text-slate-50",title:e.userAgent??e.label,children:e.label}),s.jsx("span",{className:"rounded border border-cyan-200/15 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"})]}),s.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[s.jsxs("span",{children:[e.processes.length," process",e.processes.length!==1?"es":""]}),s.jsxs("span",{children:[l," session",l!==1?"s":""]}),s.jsxs("span",{children:[c," log",c!==1?"s":""]})]})]}),s.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[s.jsx(po,{label:"IN",value:fo(a.inputTokens)}),s.jsx(po,{label:"OUT",value:fo(a.outputTokens)})]}),s.jsx("span",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex size-8 shrink-0 items-center justify-center rounded-md text-slate-200",children:t?s.jsx(bt,{className:"size-4"}):s.jsx(st,{className:"size-4"})})]}),!t&&s.jsx("div",{className:"space-y-3 border-t border-white/10 px-3 pb-3 pt-3 sm:px-4",children:e.processes.map(u=>s.jsx(GA,{group:u,collapsed:n.has(u.id),onToggle:()=>o(u.id),conversationProps:i},u.id))})]})}function GA({group:e,collapsed:t,onToggle:n,conversationProps:r}){const o=Bm(e.logs),i=VA(e.clientProjectFolder),a=e.sessions.length,l=e.logs.length,c=e.clientPid!==null&&e.clientPid!==void 0?`PID ${e.clientPid}`:"process";return s.jsxs("section",{className:"relative pl-5",children:[s.jsx("span",{className:"absolute bottom-0 left-2 top-0 w-px bg-white/12","aria-hidden":"true"}),s.jsxs("div",{className:"border border-border bg-card shadow-sm overflow-hidden rounded-[8px]",children:[s.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:[s.jsx("span",{className:"border border-border bg-muted/40 inline-flex size-8 shrink-0 items-center justify-center rounded-md text-amber-100",children:s.jsx($y,{className:"size-4"})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"font-mono text-xs font-semibold tabular-nums text-slate-100",children:c}),i!==null&&s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-xs text-muted-foreground",title:e.clientProjectFolder??i,children:[s.jsx(o2,{className:"size-3 shrink-0"}),s.jsx("span",{className:"truncate font-mono",children:i})]})]}),s.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[s.jsxs("span",{children:[a," session",a!==1?"s":""]}),s.jsxs("span",{children:[l," log",l!==1?"s":""]})]})]}),s.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[s.jsx(po,{label:"IN",value:fo(o.inputTokens)}),s.jsx(po,{label:"OUT",value:fo(o.outputTokens)})]}),s.jsx("span",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex size-7 shrink-0 items-center justify-center rounded-md text-slate-200",children:t?s.jsx(bt,{className:"size-4"}):s.jsx(st,{className:"size-4"})})]}),!t&&s.jsx("div",{className:"space-y-2 border-t border-white/10 p-2 sm:p-3",children:e.sessions.map(u=>s.jsx(_E,{group:u,...r,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},u.id))})]})]})}const ho="data-nav-id",JA="data-nav-action";function Ru(e){return Array.from(e.querySelectorAll(`[${ho}]`))}function Iu(e){return e instanceof HTMLElement}function YA(e,t){let n=e;for(;n!==null&&n!==t;){if(n.hasAttribute(ho))return n;n=n.parentElement}return e.hasAttribute(ho)?e:null}function ji(e){const t=e.getAttribute(JA);return t==="toggle"||t==="expand"||t==="collapse"?t:null}function kr(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function _r(e,t){return e[t]??null}function Um(e){const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function zu(e){const t=e.tagName;return t==="BUTTON"||t==="A"||Um(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function XA(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function QA(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function Ss(e,t){return e.key===t&&e.shiftKey}function eR(e,t,n={}){const r=t??e,o=n.pageWide===!0,i=p.useCallback(a=>{const l=e.current,c=r.current;if(!l||!c)return;const u=a.target;if(!Iu(u)||u!==c)return;const d=Ru(l),f=_r(d,0);f!==null&&kr(f)},[e,r]);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(!Iu(u)||Um(u)||QA())return;const d=c.contains(u);if(d&&zu(u)&&!u.hasAttribute(ho)||!d&&(!o||zu(u)||XA(u)))return;const f=Ru(c);if(f.length===0)return;const m=YA(u,c),h=m!==null?f.indexOf(m):-1;let v=!1;switch(l.key){case"ArrowUp":case"W":{if(l.shiftKey&&l.key==="ArrowUp"||l.key==="W"&&!Ss(l,"W"))break;l.preventDefault();const g=h>0?h-1:h===-1?f.length-1:-1;if(g!==-1){const x=_r(f,g);x!==null&&kr(x)}v=!0;break}case"ArrowDown":case"S":{if(l.shiftKey&&l.key==="ArrowDown"||l.key==="S"&&!Ss(l,"S"))break;l.preventDefault();const g=h<f.length-1?h+1:h===-1?0:-1;if(g!==-1){const x=_r(f,g);x!==null&&kr(x)}v=!0;break}case"ArrowLeft":case"A":{if(l.shiftKey&&l.key==="ArrowLeft"||l.key==="A"&&!Ss(l,"A")||m===null)break;if(l.preventDefault(),ji(m)==="collapse")m.click();else if(h>0){const x=_r(f,h-1);x!==null&&kr(x)}v=!0;break}case"ArrowRight":case"D":{if(l.shiftKey&&l.key==="ArrowRight"||l.key==="D"&&!Ss(l,"D")||m===null)break;if(l.preventDefault(),ji(m)==="expand")m.click();else if(h<f.length-1){const x=_r(f,h+1);x!==null&&kr(x)}v=!0;break}case" ":{if(m===null)break;l.preventDefault(),ji(m)!==null&&m.click(),v=!0;break}}v&&l.stopPropagation()};return document.addEventListener("keydown",a,{capture:!0}),()=>document.removeEventListener("keydown",a,{capture:!0})},[e,o,r]),p.useEffect(()=>(document.addEventListener("focusin",i),()=>document.removeEventListener("focusin",i)),[i])}const tR={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},nR={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"},rR={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"},Si=12,Cs=1,Pu=80,Ou=24;function sR(e){return e.length<=Ou?e:`${e.slice(0,Ou-3)}...`}function oR(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Pu?t:`${t.slice(0,Pu)}...`}function Ns(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const iR=p.memo(function({segments:t,totalTokens:n,showLabels:r=!0,onActivate:o}){const i=p.useMemo(()=>n>0?n:t.reduce((x,b)=>x+b.size,0),[t,n]),a=t.slice(0,Si),l=t.slice(Si),c=l.reduce((x,b)=>x+b.size,0),u=l.length,d=Si,f=d+u-1,m=u>0,h=o!==void 0,v=p.useMemo(()=>a.reduce((x,b)=>x+b.size,0),[a]),g=p.useMemo(()=>`Request context: ~${$e(i)} tokens across ${t.length} segment${t.length===1?"":"s"}`,[t.length,i]);return t.length===0||i<=0?s.jsx("div",{role:"img","aria-label":g,className:"h-6"}):s.jsx(Je,{delayDuration:150,children:s.jsxs("div",{role:"img","aria-label":g,className:"flex flex-col gap-1.5",children:[s.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((x,b)=>{const y=i>0?x.size/i*100:0,_=Math.max(Cs,y),j=ae("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",nR[x.role],h?rR[x.role]:""),S={width:`${_}%`},E=`${x.label}, ${Ns(y)}, ~${$e(x.size)} tokens`;return s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:h?s.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>o(x),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),o(x))},"data-anatomy-path":x.path,"aria-label":E,className:j,style:S}):s.jsx("span",{"aria-label":E,className:j,style:S})}),s.jsxs(Le,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[s.jsxs("div",{className:"font-semibold",children:[x.label," - ",Ns(y)," - ~",$e(x.size)," ","tokens"]}),s.jsx("div",{className:"text-muted-foreground",children:tR[x.role]}),s.jsxs("div",{className:"text-muted-foreground",children:[x.characters.toLocaleString()," chars"]}),x.text.length>0&&s.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:oR(x.text)})]})]},`${x.path}-${b}`)}),m&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.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(Cs,c/i*100)}%`},children:["... +",u]})}),s.jsxs(Le,{side:"bottom",className:"text-xs",children:[u," more segment",u===1?"":"s"," (indices"," ",d,"-",f,")"]})]})]}),r&&s.jsxs("div",{className:"flex w-full gap-1 text-[10px] text-muted-foreground",children:[a.map((x,b)=>{const y=i>0?x.size/i*100:0,_=Math.max(Cs,y);return s.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${_}%`},title:`${x.label} - ${Ns(y)} - ~${$e(x.size)} tokens`,children:[s.jsx("span",{className:"truncate font-mono text-foreground/80",children:sR(x.label)}),s.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[Ns(y)," - ~",$e(x.size)]})]},`label-${x.path}-${b}`)}),m&&s.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(Cs,c/i*100)}%`},children:[s.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",u]}),s.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",$e(c)]})]})]}),v<i*.1&&s.jsx("div",{className:"h-0"})]})})}),Wm=.75,Hm=.9,ya=8e3,aR=.35,Zm=40,Vm=160,lR=5,cR=8,uR=18,dR=6e4,fR=.7,Mu=3e3,pR=.3,Lu=160,hR=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),mR=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],gR=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],xR=[{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"]}],bR={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function vR(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 qm(e,t){for(const n of t){const r=vR(ke(e,n));if(r!==null)return r}return null}function yR(e){const t=ke(e,"model");if(typeof t!="string")return null;const n=t.trim();return n===""?null:n}function wR(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 kR(e,t,n=[]){const r=qm(t,mR);if(r!==null)return{tokens:r,label:"Request metadata",source:"request"};const o=J4(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 xR)if(wR(i,a))return{tokens:a.tokens,label:`${a.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function _R(e){return e<0?0:e>1?1:e}function jR(e){return e===null?"unknown":e>=Hm?"danger":e>=Wm?"watch":"ok"}function SR(e,t){return e.filter(n=>n.role===t).reduce((n,r)=>n+r.size,0)}function CR(e,t){return["system","user","assistant","tool","tools"].map(r=>{const o=SR(e,r);return{role:r,label:bR[r],tokens:o,percent:t>0?o/t:0}}).filter(r=>r.tokens>0).sort((r,o)=>o.tokens-r.tokens)}function wa(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function NR(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Lu?t:`${t.slice(0,Lu-3)}...`}function TR(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function ER(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function AR(e){const t=e.trim();return t.startsWith("{")||t.startsWith("[")}function RR(e){if(!AR(e))return null;try{return JSON.parse(e)}catch{return null}}function IR(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function zR(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 PR(e){const t=zR(e);return t===null?!1:hR.has(IR(t))}function OR(e){return e.map(t=>t.startsWith("[")?t:`.${t}`).join("").replace(/^\./,"")}function MR(e,t,n){const r=Tl(t);if(r<Vm)return null;const o=Nl(t);return o<Zm?null:{role:e.role,label:`${e.label} ${OR(n)}`,path:e.path,tokens:o,characters:r,text:t}}function ka({value:e,segment:t,path:n,depth:r,candidates:o}){if(!(o.length>=cR)&&!(r>lR)){if(typeof e=="string"){if(!PR(n))return;const i=MR(t,e,n);i!==null&&o.push(i);return}if(Array.isArray(e)){e.forEach((i,a)=>ka({value:i,segment:t,path:[...n,`[${String(a)}]`],depth:r+1,candidates:o}));return}El(e)&&Object.entries(e).forEach(([i,a])=>ka({value:a,segment:t,path:[...n,i],depth:r+1,candidates:o}))}}function LR(e){const t=ER(e),n=RR(e.text);if(n===null)return[t];const r=[];ka({value:n,segment:e,path:[],depth:0,candidates:r});const o=wa(e.text),i=new Set([o]),a=r.filter(l=>{const c=wa(l.text);return c===""||i.has(c)?!1:(i.add(c),!0)});return[t,...a]}function DR(e){const t=new Map;for(const r of e){const o=LR(r);for(const i of o){if(i.tokens<Zm||i.characters<Vm)continue;const a=wa(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 r of t.values()){if(r.candidates.length<2)continue;const o=r.candidates[0]??null;if(o===null)continue;const i=r.tokens-o.tokens;n.push({key:`${o.path}:${o.label}:${String(r.candidates.length)}:${String(r.tokens)}`,count:r.candidates.length,totalTokens:r.tokens,repeatedTokens:i,preview:NR(o.text),firstLabel:o.label,segments:r.candidates.map(TR)})}return n.sort((r,o)=>o.repeatedTokens-r.repeatedTokens||o.totalTokens-r.totalTokens)}function $R(e){if(e.length===0)return null;const t=e.length,n=e.reduce((o,i)=>o+i.count,0),r=e.reduce((o,i)=>o+i.repeatedTokens,0);return{kind:"duplicate",severity:r>=ya?"danger":"watch",title:"Duplicate context",detail:`${String(n)} repeated blocks across ${String(t)} group${t===1?"":"s"}, ~${String(r)} repeated tokens.`}}function FR(e){return e.reduce((t,n)=>t+n.repeatedTokens,0)}function BR(e,t,n){const r=[],o=e.find(c=>c.role==="tools")??null;o!==null&&(o.tokens>=ya||o.percent>=aR&&o.tokens>=Mu)&&r.push({kind:"tool-schema",severity:o.tokens>=ya?"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>=Mu&&i.percent>=pR&&r.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>=uR&&(a>=dR||l>=fR)&&r.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.`}),r}function UR({risk:e,contextWindow:t,diagnostics:n,duplicateGroups:r}){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:FR(r)}}function WR({segments:e,inputTokens:t,parsed:n,model:r,providers:o=[]}){const i=e.reduce((E,C)=>E+C.size,0),a=r??yR(n),l=t??i,c=qm(n,gR),u=kR(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,v=u.tokens===null||f===null?null:_R(f/u.tokens),g=CR(e,i),x=g[0]??null,b=e.filter(E=>E.role!=="tools").length,y=DR(e),_=$R(y),j=BR(g,i,b);_!==null&&j.unshift(_);const S=jR(v);return{model:a,contextWindow:u,estimatedInputTokens:l,outputReserveTokens:c,windowUsedTokens:f,remainingInputTokens:m,remainingAfterReserveTokens:h,usagePercent:v,riskLevel:S,roleUsages:g,largestRole:x,diagnostics:j,duplicateGroups:y,health:UR({risk:S,contextWindow:u,diagnostics:j,duplicateGroups:y})}}const iz={watch:Wm,danger:Hm},Du=new WeakMap;function HR(e){return e.map(t=>{const n=t.modelMetadata?.map(r=>`${r.model}:${String(r.contextWindow??"")}`).join(",")??"";return`${t.id}:${t.updatedAt}:${t.models.join(",")}:${n}`}).join("|")}function ZR(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function VR(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function qR(e,t){const n=ZR(e.rawRequestBody);if(n===null)return null;const o=Xh(Lr(e)).anatomySegments(n);if(o===null)return null;const i=WR({segments:o,inputTokens:e.inputTokens??null,parsed:n,model:e.model,providers:t}),a=i.model??e.model??"Unknown model",l=i.roleUsages.map(VR);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 KR(e,t,n){const r=Du.get(e);if(r!==void 0&&r.id===e.id&&r.rawRequestBody===e.rawRequestBody&&r.inputTokens===e.inputTokens&&r.model===e.model&&r.path===e.path&&r.apiFormat===e.apiFormat&&r.timestamp===e.timestamp&&r.providersSignature===n)return r.snapshot;const o=qR(e,t);return Du.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 GR(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 $u(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function JR(e,t){const n=$u(t.latest.riskLevel)-$u(e.latest.riskLevel);if(n!==0)return n;const r=e.peak.usagePercent??-1,i=(t.peak.usagePercent??-1)-r;return i!==0?i:t.latest.logId-e.latest.logId}function YR(e,t){return e.usagePercent===null||t.usagePercent===null?null:(t.usagePercent-e.usagePercent)*100}function XR(e){for(let t=1;t<e.length;t++){const n=e[t-1],r=e[t];if(!(n===void 0||r===void 0)&&n.id>r.id)return[...e].sort((o,i)=>o.id-i.id)}return e}function QR(e,t=[]){const n=XR(e),r=HR(t),o=new Map;for(const a of n){const l=KR(a,t,r);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:GR(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:YR(a.first,a.latest)})).sort(JR)}}function tn(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function eI(e){const t=new Map;for(const n of e)for(let r=0;r<n.logs.length;r+=1){const o=n.logs[r];o!==void 0&&t.set(o.id,r+1)}return t}function Fu(e,t){return t.get(e.id)??e.id}function tI(e){return e==="full"}function nI(e,t){const n=t>0;return{redacted:n,raw:n&&tI(e)}}function Bu(e){let t=0,n=0;for(const r of e)r.inputTokens!==null&&(t+=r.inputTokens),r.outputTokens!==null&&(n+=r.outputTokens);return{totalIn:t,totalOut:n}}function Km(e,t){const n=e[0],r=e[e.length-1];return n===void 0||r===void 0?null:Ga(n.timestamp,r.timestamp,t)}function rI(e){for(const t of e)if(t.userAgent!==null&&t.userAgent!==void 0&&t.userAgent!=="")return t.userAgent;return null}function sI(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function oI(e){const t=new Set;for(const r of e)r.model!==null&&r.model.length>0&&t.add(r.model);const n=[...t].sort();return n.length===0?"Model unknown":n.length===1?n[0]??"Model unknown":`${n.length} models`}function iI(e){const t=new Set;for(const r of e)r.providerName!==null&&r.providerName!==void 0&&r.providerName.length>0&&t.add(r.providerName);const n=[...t].sort();return n.length===0?"Provider unknown":n.length===1?n[0]??"Provider unknown":`${n.length} providers`}function aI(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),r=t%60;return`${n}m ${r}s`}function lI(e,t){return`${$e(e)} in / ${$e(t)} out`}function cI(e,t){if(e.length===0)return 0;if(t.length===0)return da(e).length;let n=0;for(const r of t)n+=da(r.logs).length;return n}function uI({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 dI(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 fI({pending:e,failures:t,lengthStops:n,stopReason:r,lastFailure:o}){if(o!==null&&(o.status===499||dI(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||r==="length")return{label:"Output limited",detail:"Model stopped at the output token limit",tone:"watch"};switch(r){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 pI({logs:e,conversationGroups:t,isLoading:n,timeDisplayFormat:r,slowResponseThresholdSeconds:o}){let i=0,a=0,l=0,c=0,u=0,d=0,f=null,m=null,h=null,v=null,g=null,x=0,b=0,y=0,_=null;const j=o*1e3;for(let z=0;z<e.length;z+=1){const O=e[z];if(O===void 0)continue;const q=z+1,T=cf(O);T!==null&&(f=T),T==="length"&&(c+=1),sI(O)&&(i+=1,m=q,h={logNumber:q,status:O.responseStatus,error:O.error??null}),O.responseStatus===null&&(a+=1),o>0&&O.elapsedMs!==null&&O.elapsedMs>=j&&(l+=1),O.inputTokens!==null&&(u+=O.inputTokens),O.outputTokens!==null&&(d+=O.outputTokens),O.elapsedMs!==null&&(v===null||O.elapsedMs>v)&&(v=O.elapsedMs,g=q);const D=O.inputTokens??0,k=O.outputTokens??0,$=D+k;$>x&&(x=$,b=D,y=k,_=q)}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",C=uI({stopReason:f,pending:a,lastFailureLogNumber:m}),R=fI({pending:a,failures:i,lengthStops:c,stopReason:f,lastFailure:h});return{status:S,statusLabel:E,modelLabel:oI(e),providerLabel:iI(e),requests:e.length,turns:cI(e,t),failures:i,pending:a,slow:l,lengthStops:c,timeRange:Km(e,r),tokenLabel:`${$e(u)} in / ${$e(d)} out`,finishLabel:C.label,finishDetail:C.detail,finishTone:C.tone,outcomeLabel:R.label,outcomeDetail:R.detail,outcomeTone:R.tone,slowestLabel:v===null?"n/a":aI(v),slowestDetail:g===null?"Latency pending":`Request #${g}`,heaviestDetail:_===null?"Tokens pending":`#${_} ${lI(b,y)}`}}function hI(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 mI(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function gI(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 Wn({label:e,value:t,detail:n,icon:r,tone:o="neutral"}){return s.jsxs("div",{className:"min-w-0 border-t border-white/10 px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[r,e]}),s.jsx("div",{className:ae("mt-2 font-mono text-sm font-semibold",hI(o)),children:t}),s.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:n})]})}function xI({stats:e}){return e.requests===0?null:s.jsxs("div",{className:"border border-border bg-card shadow-sm mb-4 overflow-hidden rounded-[8px]",children:[s.jsx("div",{className:"px-4 py-3",children:s.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-semibold uppercase text-muted-foreground",children:[s.jsx(Ny,{className:"size-3.5 text-slate-300"}),"Flight Recorder"]}),s.jsx("div",{className:"mt-2 min-w-0 font-mono text-sm font-semibold text-foreground",children:e.modelLabel})]}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 font-mono",children:e.providerLabel}),s.jsx("span",{className:"min-w-0 font-mono",children:e.timeRange??"Timeline pending"})]})]})}),s.jsxs("div",{className:"grid grid-cols-2 border-t border-white/10 md:grid-cols-3 2xl:grid-cols-6",children:[s.jsx(Wn,{label:"Status",value:e.statusLabel,detail:gI(e),tone:mI(e.status)}),s.jsx(Wn,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:s.jsx(r2,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),s.jsx(Wn,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:s.jsx(Di,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),s.jsx(Wn,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:s.jsx(X2,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),s.jsx(Wn,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:s.jsx(qa,{className:"size-3 text-muted-foreground"})}),s.jsx(Wn,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function bI({pinnedSessionId:e,selectedSession:t,sessions:n,logs:r}){if(e!==void 0){const a=r.filter(l=>l.sessionId===e);return a.length===0?null:{label:e,logs:a,showBackLink:!0}}if(t!=="__all__"){const a=r.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&&r.every(l=>l.sessionId===o)?{label:o,logs:[...r],showBackLink:!1}:n.length===0&&r.length>0&&r.every(a=>a.sessionId===null)?{label:"Visible requests",logs:[...r],showBackLink:!1}:null}function Tr(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 vI(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function _a(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function yI(e,t){if(t===null)return null;const n=_a(e),r=_a(t);return r<=0||Math.abs(r-n)<.5?null:r}function wI(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 kI(e){const t=e.latest.contextWindow.tokens;return t===null?"Context window unknown":`Context window ${jf(t)}`}const _I=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function Gm(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 Ci(e,t){if(e===null)return null;const n=e.metadata[t];return n===void 0?null:Gm(n)}function jI(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 SI(e){const t=[];for(const n of _I){const r=e.metadata[n];if(r===void 0)continue;const o=Gm(r);o!==null&&t.push({key:n,value:o})}return t}function Uu({memberships:e,defaultOpen:t=!1}){const[n,r]=p.useState(t);if(e.length===0)return null;const o=e[0],i=o?.member??null,a=Ci(i,"score"),l=Ci(i,"decision"),c=Ci(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 s.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] text-xs",children:[s.jsxs("button",{type:"button",onClick:()=>r(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:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"font-semibold text-foreground",children:"Case File"}),o!==void 0&&s.jsx("span",{className:"truncate text-muted-foreground",title:o.groupTitle,children:o.groupTitle}),s.jsxs("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:[e.length," group",e.length===1?"":"s"]})]}),u.length>0&&s.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=>s.jsx("span",{className:ae("rounded border px-1.5 py-0.5 font-mono text-[10px]",jI(d.value)),children:d.label},d.label))})]}),n?s.jsx(Wa,{className:"size-4 shrink-0 text-muted-foreground"}):s.jsx(st,{className:"size-4 shrink-0 text-muted-foreground"})]}),n&&s.jsx("div",{className:"space-y-2 border-t border-white/10 px-3 py-2",children:e.map(d=>{const f=d.member,m=SI(f);return s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"truncate font-medium text-foreground",title:d.groupTitle,children:d.groupTitle}),s.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:d.groupStatus}),f.status!==null&&s.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["member ",f.status]})]}),s.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[s.jsx("span",{className:"font-mono",title:f.sessionId,children:tn(f.sessionId)}),f.label!==null&&s.jsx("span",{children:f.label}),f.provider!==null&&s.jsx("span",{children:f.provider}),f.model!==null&&s.jsx("span",{className:"font-mono",children:f.model}),f.runId!==null&&s.jsxs("span",{className:"font-mono",title:f.runId,children:["run ",tn(f.runId)]})]}),m.length>0&&s.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:m.map(h=>s.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-1",children:[s.jsx("div",{className:"font-mono text-[10px] text-muted-foreground",children:h.key}),s.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:h.value,children:h.value})]},h.key))})]},`${d.groupId}:${f.id}`)})})]})}function CI({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],r=e[e.length-1],o=n===void 0||r===void 0?"Current page":`#${n.id}-#${r.id}`,i=t.total===null?"logs":`${t.total} logs`;return`Showing ${o} of ${i}`}function Ts({label:e,title:t,icon:n,disabled:r,onClick:o}){return s.jsxs("button",{type:"button",onClick:o,disabled:r,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,s.jsx("span",{children:e})]})}function Wu({logs:e,pagination:t,embedded:n=!1}){if(t===void 0)return null;const r=t.isLoading;return s.jsxs("div",{className:ae("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:[s.jsxs("div",{className:"w-full min-w-0 px-1 font-mono text-[11px] text-muted-foreground sm:flex-1",children:[CI({logs:e,pagination:t}),t.isLoading&&e.length>0&&s.jsx("span",{className:"ml-2",children:"Loading..."})]}),s.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[s.jsx(Ts,{label:"Oldest",title:"Load the oldest logs in this session",icon:s.jsx(hy,{className:"size-3.5"}),disabled:r||!t.hasOlder,onClick:t.onOldest}),s.jsx(Ts,{label:"Older",title:"Load older logs",icon:s.jsx(ly,{className:"size-3.5"}),disabled:r||!t.hasOlder,onClick:t.onOlder}),s.jsx(Ts,{label:"Newer",title:"Load newer logs",icon:s.jsx(bt,{className:"size-3.5"}),disabled:r||!t.hasNewer,onClick:t.onNewer}),s.jsx(Ts,{label:"Newest",title:"Load the newest logs in this session",icon:s.jsx(gy,{className:"size-3.5"}),disabled:r||!t.hasNewer,onClick:t.onNewest})]})]})}function NI(e){return`${e} ${e===1?"request":"requests"}`}function Hu(e){return`#${String(e)}`}function Zu(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 TI(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 EI(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const AI=10,RI=80;function II(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function zI(e){const t=document.getElementById(`log-${String(e)}`);return t instanceof HTMLElement?(t.scrollIntoView({block:"center",behavior:"smooth"}),t.focus({preventScroll:!0}),II(t),!0):!1}function Jm(e){Qs({logId:e,tab:"anatomy"});let t=0;const n=()=>{Qs({logId:e,tab:"anatomy"}),!zI(e)&&(t+=1,t<AI&&window.setTimeout(n,RI))};window.setTimeout(n,0)}function Vu({command:e}){const[t,n]=p.useState(!1),r=p.useCallback(()=>{Kt(e).then(o=>{o&&(n(!0),setTimeout(()=>n(!1),2e3))})},[e]);return s.jsxs("div",{className:"border border-border bg-muted/40 inline-flex max-w-full items-center gap-2 rounded-md px-3 py-2",children:[s.jsx("pre",{className:"m-0 overflow-x-auto font-mono text-sm text-cyan-200",children:e}),s.jsx("button",{type:"button",onClick:r,className:"shrink-0 cursor-pointer text-muted-foreground transition-colors hover:text-foreground","aria-label":"Copy command",children:t?s.jsx(Ge,{className:"size-4"}):s.jsx(Nt,{className:"size-4"})})]})}function qu(){return s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs("span",{className:"border border-border bg-muted/40 inline-flex h-7 items-center gap-2 rounded-md px-2.5 font-mono text-[11px] font-medium text-cyan-200",children:[s.jsx("span",{className:"size-1.5 rounded-full bg-cyan-200 shadow-[0_0_8px_rgba(125,211,252,0.75)]"}),"MCP Ready",s.jsx("span",{className:"hidden text-cyan-200/70 sm:inline",children:"/api/mcp"})]})}),s.jsx(Le,{sideOffset:8,className:"max-w-[320px] text-left leading-relaxed",children:"Coding agents can inspect logs, replay requests, test providers, and debug sessions through MCP at /api/mcp."})]})})}function Ni({label:e,children:t,className:n}){return s.jsxs("section",{className:ae("border border-border bg-card shadow-sm rounded-[8px]",n),children:[s.jsx("div",{className:"border-b border-white/10 px-3 py-2",children:s.jsx("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-white/40",children:e})}),s.jsx("div",{className:"p-3",children:t})]})}function Ti({label:e,value:t}){return s.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-2",children:[s.jsx("div",{className:"truncate font-mono text-lg font-semibold leading-6 text-slate-100",children:t}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] uppercase tracking-[0.12em] text-white/35",children:e})]})}const PI=["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 Ku({compact:e,entrancePhase:t}){return e?s.jsx(au,{className:"size-7 text-amber-500"}):s.jsxs("span",{className:"flex shrink-0 items-end gap-1 group cursor-default","aria-hidden":"true",children:[s.jsx(au,{className:"size-10 text-amber-500 transition-all duration-300 group-hover:scale-125 group-hover:-translate-y-1.5"}),s.jsx("span",{className:"hidden items-end gap-0.5 sm:flex",children:km.map((n,r)=>{const o=PI[r]??"text-amber-500",i=t==="hidden"?"opacity-0 scale-0":t==="playing"?"animate-crab-piano-pop":"";return s.jsx(n,{className:`size-5 ${o} transition-all duration-300 ease-out group-hover:scale-125 group-hover:-translate-y-1 ${i}`,style:{transitionDelay:`${r*50}ms`,...t==="playing"?{animationDelay:`${r*400}ms`}:{}}},r)})})]})}function OI({compact:e,crabEntrancePhase:t}){return e?s.jsxs("div",{className:"border border-border bg-card shadow-sm rounded-[8px] p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsx(Ku,{compact:!0,entrancePhase:t}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[s.jsx("span",{className:"truncate text-base font-bold",children:"Inspector"}),s.jsxs("span",{className:"hidden shrink-0 font-mono text-[11px] font-semibold text-muted-foreground sm:inline",children:["v",Fi.version]})]}),s.jsx("div",{className:"hidden text-[11px] font-semibold text-muted-foreground sm:block",children:"Local First. Evidence First."})]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(lu,{}),s.jsx(uu,{}),s.jsx(Tu,{})]})]}),s.jsx("div",{className:"mt-2 hidden sm:block",children:s.jsx(qu,{})})]}):s.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] items-start gap-3 pb-6",children:[s.jsx("div",{}),s.jsxs("h1",{className:"flex min-w-0 flex-col items-center gap-2 text-center",children:[s.jsxs("span",{className:"flex max-w-[calc(100vw-7rem)] items-end gap-2 whitespace-nowrap",children:[s.jsx(Ku,{compact:!1,entrancePhase:t}),s.jsxs("span",{className:"flex min-w-0 items-baseline gap-2 pl-1",children:[s.jsx("span",{className:"truncate text-lg font-bold",children:"Agent Inspector"}),s.jsxs("span",{className:"shrink-0 font-mono text-xs font-semibold text-muted-foreground",children:["v",Fi.version]})]}),s.jsx(Mi,{className:"size-4 shrink-0 text-muted-foreground/70","aria-hidden":"true"}),s.jsx(LE,{className:"size-10 shrink-0"})]}),s.jsx("span",{className:"max-w-[calc(100vw-7rem)] text-sm font-semibold text-muted-foreground",children:"Local First. Evidence First."}),s.jsx(qu,{})]}),s.jsxs("div",{className:"justify-self-end flex items-center gap-1",children:[s.jsx(lu,{}),s.jsx(uu,{}),s.jsx(Tu,{})]})]})}function Gu({label:e,logId:t}){return s.jsxs("button",{type:"button",onClick:()=>Jm(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 ${Hu(t)}`,children:[e," ",Hu(t)]})}function MI({latestPercent:e,peakPercent:t,risk:n,onOpenContext:r}){const o=_a(e),i=yI(e,t),a=t===null?`Latest context window usage ${Tr(e)}`:`Latest context window usage ${Tr(e)}, peak ${Tr(t)}`;return s.jsx("button",{type:"button",onClick:r,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:s.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:[s.jsx("span",{className:ae("block h-full rounded-full transition-[width]",wI(n)),style:{width:`${o}%`}}),i!==null&&s.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 LI({summary:e}){const t=e.trendPercent,n=t===null||Math.abs(t)<.1?null:t>0?Y1:Z1,r=e.latest.diagnostics[0]??null,o=Tr(e.latest.usagePercent),i=Tr(e.peak.usagePercent),a=()=>{Jm(e.latest.logId)};return s.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:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.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}),s.jsx("span",{className:ae("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",TI(e.latest.health.level)),children:EI(e.latest.health.level)})]}),s.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:[s.jsx("span",{children:NI(e.requestCount)}),s.jsx("span",{children:kI(e)})]})]}),s.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[s.jsx(MI,{latestPercent:e.latest.usagePercent,peakPercent:e.peak.usagePercent,risk:e.latest.riskLevel,onOpenContext:a}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Latest"}),s.jsx("div",{className:ae("mt-0.5 font-mono",Zu(e.latest.riskLevel)),children:o}),s.jsx(Gu,{label:"Log",logId:e.latest.logId})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Peak"}),s.jsx("div",{className:ae("mt-0.5 font-mono",Zu(e.peak.riskLevel)),children:i}),s.jsx(Gu,{label:"Log",logId:e.peak.logId})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Trend"}),s.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-foreground",children:[n!==null&&s.jsx(n,{className:ae("size-3",t!==null&&t>0?"text-amber-300":"text-cyan-300")}),vI(t)]}),s.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),s.jsxs("div",{className:"min-w-0 space-y-1.5",children:[s.jsx(iR,{segments:e.latest.roleSegments,totalTokens:e.latest.roleTotalTokens,showLabels:!1}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsxs("span",{className:"font-mono",children:["~",$e(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&s.jsxs("span",{className:"font-mono",children:["~",$e(e.latest.windowUsedTokens)," used"]}),r!==null&&s.jsx("span",{className:"truncate",children:r})]})]})]})}function DI({summary:e}){return e.models.length===0?null:s.jsxs("div",{className:"mt-3 border-t border-white/10 pt-2",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Session Context"}),s.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:[e.models.length," model",e.models.length===1?"":"s"]})]}),s.jsx("div",{className:"max-h-52 overflow-y-auto pr-1",children:e.models.map(t=>s.jsx(LI,{summary:t},t.model))})]})}function $I(e){const t=e.models.filter(r=>r.latest.health.level==="risk").length;if(t>0)return`${t} risk`;const n=e.models.filter(r=>r.latest.health.level==="optimizable").length;return n>0?`${n} optimizable`:`${e.models.length} model${e.models.length===1?"":"s"}`}function FI({label:e,logs:t,totalIn:n,totalOut:r,timeDisplayFormat:o,contextSummary:i,showBackLink:a}){const[l,c]=p.useState(!1),[u,d]=p.useState(!1),f=p.useMemo(()=>Km(t,o),[t,o]),m=p.useMemo(()=>rI(t),[t]),h=p.useMemo(()=>$I(i),[i]),v=p.useCallback(()=>{Kt(window.location.href).then(g=>{g&&(c(!0),setTimeout(()=>c(!1),2e3))})},[]);return s.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-3 py-2 text-xs",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a&&s.jsx("a",{href:"/",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground","aria-label":"Back to all sessions",title:"Back to all sessions",children:s.jsx(G1,{className:"size-3.5"})}),s.jsxs("div",{className:"min-w-[180px] flex-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"font-mono font-semibold text-purple-400/90 truncate",title:e,children:tn(e)}),m!==null&&s.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:m,children:m})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[s.jsxs("span",{children:[t.length," request",t.length!==1?"s":""]}),f!==null&&s.jsx("span",{children:f}),(n>0||r>0)&&s.jsxs("span",{className:"font-mono",children:[$e(n)," in / ",$e(r)," out"]})]})]}),i.models.length>0&&s.jsxs("button",{type:"button",onClick:()=>d(g=>!g),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 font-mono text-[11px] text-muted-foreground transition-colors hover:text-foreground","aria-expanded":u,title:u?"Hide context details":"Show context details",children:[s.jsx("span",{children:h}),u?s.jsx(Wa,{className:"size-3.5"}):s.jsx(st,{className:"size-3.5"})]}),s.jsx("button",{type:"button",onClick:v,className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground","aria-label":l?"Copied session link":"Copy session link",title:l?"Copied session link":"Copy session link",children:l?s.jsx(Ge,{className:"size-3.5"}):s.jsx(Nt,{className:"size-3.5"})})]}),u&&s.jsx(DI,{summary:i})]})}function BI({logs:e,sessions:t,models:n,selectedSession:r,selectedModel:o,onSessionChange:i,onModelChange:a,onClearAll:l,onClearGroup:c,onNotify:u,onImportLogs:d,viewMode:f,captureMode:m,strip:h,slowResponseThresholdSeconds:v,timeDisplayFormat:g,isLoading:x=!1,pagination:b,sessionMemberships:y=[],hideSessionFilter:_=!1,pinnedSessionId:j}){const{totalIn:S,totalOut:E}=p.useMemo(()=>Bu(e),[e]),{providers:C}=Sf(),[R,z]=p.useState(null),[O,q]=p.useState(null),[T,D]=p.useState(!1),[k,$]=p.useState(null),[X,B]=p.useState(null),[F,Z]=p.useState(null),[J,H]=p.useState("hidden"),W=p.useRef(null),ce=p.useRef(null),se=p.useRef(null);eR(W,ce,{pageWide:!0}),p.useEffect(()=>{const Q=50+km.length*400,fe=setTimeout(()=>H("playing"),50),de=setTimeout(()=>H("done"),Q);return()=>{clearTimeout(fe),clearTimeout(de)}},[]),p.useEffect(()=>{if(j===void 0){document.title="Agent Inspector";return}const P=e.length===1?"1 req":`${e.length} req`;document.title=`${tn(j)} - ${P} - Agent Inspector`},[e.length,j]);const oe=p.useCallback(async P=>{z(P),q(null);try{const M=await Tw(e,P);M.ok||(u!==void 0?u({message:M.message,tone:"error"}):q(M.message))}finally{z(null)}},[e,u]),_e=p.useCallback(()=>{se.current?.click()},[]),ie=p.useCallback(P=>{const M=P.currentTarget.files?.[0];P.currentTarget.value="",!(M===void 0||d===void 0)&&(D(!0),B(null),$(null),d(M).then(Q=>{const fe=Q.skipped>0?`, skipped ${String(Q.skipped)}`:"",de=`Imported ${String(Q.imported)} logs as ${Q.sessionId}${fe}.`;u!==void 0?u({message:de,tone:"success"}):$(de)}).catch(Q=>{const fe=Q instanceof Error?Q.message:"Failed to import logs";u!==void 0?u({message:fe,tone:"error"}):B(fe)}).finally(()=>{D(!1)}))},[d,u]);p.useEffect(()=>{Z(null)},[r,o]);const ge=p.useCallback(()=>{Z(null)},[]),he=p.useMemo(()=>UN(e),[e]),xe=p.useMemo(()=>eI(he),[he]),te=p.useMemo(()=>bI({pinnedSessionId:j,selectedSession:r,sessions:t,logs:e}),[e,j,r,t]),ue=te?.logs??[],be=te!==null&&ue.length>0,{totalIn:w,totalOut:Y}=p.useMemo(()=>Bu(ue),[ue]),U=p.useMemo(()=>QR(ue,C),[ue,C]),I=p.useMemo(()=>LA(he),[he]),A=p.useMemo(()=>OT(he),[he]),L=nI(m,e.length),ne=j!==void 0,re=be&&te!==null?tn(te.label):r==="__all__"?"All sessions":tn(r),V=p.useMemo(()=>pI({logs:e,conversationGroups:he,isLoading:x,timeDisplayFormat:g,slowResponseThresholdSeconds:v}),[he,x,e,v,g]),le=p.useCallback(P=>{const M=A.get(P.id);M!==void 0&&Z([M,P])},[A]);return s.jsxs("div",{className:"bg-background min-h-screen w-full text-foreground",children:[s.jsxs("div",{className:"grid min-h-screen w-full grid-cols-1 lg:grid-cols-[340px_minmax(0,1fr)] xl:grid-cols-[360px_minmax(0,1fr)]",children:[s.jsx("aside",{className:"bg-background border-b lg:sticky lg:top-0 lg:h-screen lg:overflow-y-auto lg:border-b-0 lg:border-r",children:s.jsxs("div",{className:"space-y-4 p-4",children:[s.jsx(OI,{compact:!0,crabEntrancePhase:J}),s.jsx(Ni,{label:"Session",children:s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsx(Ti,{label:"Requests",value:e.length}),s.jsx(Ti,{label:"Input",value:$e(be?w:S)}),s.jsx(Ti,{label:"Output",value:$e(be?Y:E)})]})}),s.jsx(Ni,{label:"Workspace",children:s.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2",children:[s.jsx("div",{className:"truncate font-mono text-xs font-semibold text-cyan-100",title:re,children:re}),s.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:ne?"Session workspace":"Live workspace"})]})}),be&&te!==null&&s.jsx(FI,{label:te.label,logs:ue,totalIn:w,totalOut:Y,timeDisplayFormat:g,contextSummary:U,showBackLink:te.showBackLink}),be&&j!==void 0&&y.length>0&&s.jsx(Uu,{memberships:y}),s.jsx(Ni,{label:"Filters",children:s.jsxs("div",{className:"space-y-2",children:[!_&&s.jsxs(ro,{value:r,onValueChange:i,children:[s.jsx(oo,{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-9 w-full text-xs",children:s.jsx(so,{placeholder:"All sessions"})}),s.jsxs(io,{children:[s.jsx(At,{value:"__all__",children:"All sessions"}),t.map(P=>s.jsx(At,{value:P,children:tn(P)},P))]})]}),s.jsxs(ro,{value:o,onValueChange:a,children:[s.jsx(oo,{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-9 w-full text-xs",children:s.jsx(so,{placeholder:"All models"})}),s.jsxs(io,{children:[s.jsx(At,{value:"__all__",children:"All models"}),n.map(P=>s.jsx(At,{value:P,children:P},P))]})]})]})})]})}),s.jsxs("main",{className:"min-w-0",children:[s.jsxs("div",{className:"border border-border bg-background/95 shadow-sm sticky top-0 z-30 border-b px-4 py-3 lg:px-5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("div",{className:"min-w-[180px] flex-1",children:[s.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Logs"}),s.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:re})]}),d!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:se,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:ie}),s.jsx("button",{type:"button",onClick:_e,disabled:T,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-3 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",title:"Import Agent Inspector export",children:T?s.jsx("span",{children:"Importing..."}):s.jsxs(s.Fragment,{children:[s.jsx(of,{className:"size-3.5"}),s.jsx("span",{children:"Import"})]})})]}),L.redacted&&s.jsx("button",{type:"button",onClick:()=>{oe("redacted")},disabled:R!==null,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-3 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",title:"Export redacted logs as JSON ZIP",children:R==="redacted"?s.jsx("span",{children:"Exporting..."}):s.jsxs(s.Fragment,{children:[s.jsx(yo,{className:"size-3.5"}),s.jsx("span",{children:"Export"})]})}),L.raw&&s.jsx("button",{type:"button",onClick:()=>{oe("raw")},disabled:R!==null,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-50",title:"Export raw logs without redaction",children:R==="raw"?s.jsx("span",{children:"Exporting..."}):s.jsxs(s.Fragment,{children:[s.jsx(qy,{className:"size-3.5"}),s.jsx("span",{children:"Raw"})]})}),s.jsxs("button",{type:"button",onClick:l,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-3 text-xs text-muted-foreground transition-colors hover:text-foreground",title:"Clear all logs",children:[s.jsx(nr,{className:"size-3.5"}),s.jsx("span",{children:"Clear"})]})]}),s.jsx(Wu,{logs:e,pagination:b,embedded:!0}),u===void 0&&O!==null&&s.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:O}),u===void 0&&X!==null&&s.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:X}),u===void 0&&k!==null&&X===null&&s.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:k})]}),s.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[s.jsx(xI,{stats:V}),e.length===0?r!=="__all__"?s.jsx("div",{className:"py-16 text-center text-muted-foreground",children:s.jsxs("div",{className:"border border-border bg-card shadow-sm mx-auto max-w-xl space-y-4 rounded-[8px] px-4 py-8",children:[s.jsx("p",{className:"text-sm font-medium",children:x?"Loading session data...":"Session not found"}),s.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:tn(r)}),y.length>0&&s.jsx("div",{className:"text-left",children:s.jsx(Uu,{memberships:y})}),!x&&s.jsxs("p",{className:"text-xs",children:["This session may have been cleared or never existed."," ",_?s.jsx("a",{href:"/",className:"underline transition-colors hover:text-foreground",children:"Back to all sessions"}):s.jsx("button",{type:"button",onClick:()=>i("__all__"),className:"underline transition-colors hover:text-foreground",children:"Show all sessions"})]})]})}):s.jsx("div",{className:"py-16 text-center text-muted-foreground",children:s.jsxs("div",{className:"border border-border bg-card shadow-sm mx-auto max-w-2xl space-y-4 rounded-[8px] px-4 py-8",children:[s.jsx("p",{className:"text-sm",children:"No requests captured yet."}),s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(Vu,{command:"ANTHROPIC_BASE_URL=http://localhost:25947/proxy <your-tool>"}),s.jsx(Vu,{command:"OPENAI_BASE_URL=http://localhost:25947/proxy <your-tool>"})]}),s.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."})]})}):s.jsxs("div",{ref:ce,tabIndex:0,className:"flex flex-col gap-2 focus:outline-none",children:[s.jsx("div",{ref:W,children:s.jsx(qA,{groups:he,viewMode:f,strip:h,slowResponseThresholdSeconds:v,cacheTrends:I,onCompareWithPrevious:le,comparisonPredecessors:A,onClearGroup:c,defaultExpanded:he.length===1,timeDisplayFormat:g})}),s.jsx("div",{className:"mt-3",children:s.jsx(Wu,{logs:e,pagination:b})})]})]})]})]}),F!==null&&s.jsx(p.Suspense,{fallback:null,children:s.jsx(g3,{left:F[0],right:F[1],leftDisplayNumber:Fu(F[0],xe),rightDisplayNumber:Fu(F[1],xe),onClose:ge})})]})}const UI=3e3;function WI(e,t){return{id:(e?.id??0)+1,message:t.message,tone:t.tone??"error"}}function HI(){const[e,t]=p.useState(null),n=p.useCallback(o=>{t(i=>WI(i,o))},[]),r=p.useCallback(()=>{t(null)},[]);return p.useEffect(()=>{if(e===null)return;const o=window.setTimeout(()=>{t(null)},UI);return()=>{window.clearTimeout(o)}},[e]),{notice:e,showToast:n,dismissToast:r}}function ZI({notice:e,onDismiss:t}){if(e===null)return null;const n=e.tone==="error",r=n?rn:Oi;return s.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:s.jsxs("div",{className:ae("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:[s.jsx(r,{className:ae("mt-0.5 size-4 shrink-0",n?"text-red-300":"text-cyan-200")}),s.jsx("div",{className:"min-w-0 flex-1 break-words leading-5",children:e.message}),s.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:s.jsx(ko,{className:"size-3.5"})})]},e.id)})}const VI=Mt([G({type:Ce("init"),logs:me(Rr)}),G({type:Ce("update"),log:Rr})]),qI=G({logs:me(Rr),total:K().int().nonnegative(),limit:K().int().positive(),hasOlder:Fe(),hasNewer:Fe(),oldestLogId:K().int().positive().nullable(),newestLogId:K().int().positive().nullable()});function KI(e,t){const n=[];for(const r of e)for(const o of r.members)o.sessionId===t&&n.push({groupId:r.id,groupTitle:r.title,groupKind:r.kind,groupStatus:r.status,groupTask:r.task,groupProject:r.project,groupEvidence:r.evidence,member:o});return n}function GI(e){const t=new Set;for(const n of e)n.sessionId!==null&&n.sessionId!==""&&t.add(n.sessionId);return[...t]}function JI(e){const t=new Set;for(const n of e)n.model!==null&&n.model!==""&&t.add(n.model);return[...t]}function YI(e,t,n){return t==="__all__"&&n==="__all__"?e:e.filter(r=>!(t!=="__all__"&&r.sessionId!==t||n!=="__all__"&&r.model!==n))}const XI=100,QI=12,ez=1800,Ju=500,Ym=100;function tz(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 nz(e,t){const n=new URLSearchParams({cursor:"1",compact:"1",limit:String(Ym),sessionId:e});switch(t.kind){case"oldest":n.set("anchor","oldest");break;case"older":n.set("beforeLogId",String(t.beforeLogId));break;case"newer":n.set("afterLogId",String(t.afterLogId));break}return`/api/logs?${n.toString()}`}function jr(e){const t=new Map;for(let n=0;n<e.length;n++){const r=e[n];r!==void 0&&t.set(r.id,n)}return t}function Ei(e){return e.length<=Ju?e:e.slice(e.length-Ju)}function az({initialSessionId:e}={}){const[t,n]=p.useState([]),[r,o]=p.useState(e??"__all__"),[i,a]=p.useState("__all__"),{notice:l,showToast:c,dismissToast:u}=HI(),[d,f]=p.useState(e===void 0),[m,h]=p.useState(null),[v,g]=p.useState(e!==void 0),[x,b]=p.useState([]),[,y]=p.useTransition(),_=p.useRef(null),j=p.useRef(null),S=p.useRef(null),E=p.useRef(0),C=p.useRef(new Map),R=p.useRef([]),z=p.useRef(null),O=p.useCallback(te=>{c({message:te,tone:"error"})},[c]),q=p.useMemo(()=>YI(t,r,i),[t,r,i]),T=p.useMemo(()=>GI(t),[t]),D=p.useMemo(()=>JI(t),[t]),k=p.useCallback(()=>{z.current=null;const te=R.current;R.current=[],te.length!==0&&y(()=>{n(ue=>{const be=[...ue];for(const Y of te){const U=C.current.get(Y.id);if(U!==void 0&&be[U]?.id===Y.id){be[U]=Y;continue}const I=be.findIndex(A=>A.id===Y.id);if(I>=0){be[I]=Y;continue}be.push(Y)}const w=Ei(be);return C.current=jr(w),w})})},[y]),$=p.useCallback(te=>{R.current.push(te),z.current===null&&(z.current=setTimeout(k,XI))},[k]),X=p.useCallback(()=>{_.current&&_.current.close(),f(!1);const te=new EventSource(tz(e));_.current=te,te.onmessage=ue=>{try{const be=String(ue.data),w=JSON.parse(be),Y=VI.safeParse(w);if(!Y.success){O("Failed to parse SSE data");return}const U=Y.data;if(U.type==="init"){z.current!==null&&(clearTimeout(z.current),z.current=null),R.current=[];const I=Ei(U.logs);C.current=jr(I),n(I),f(!0),u()}else U.type==="update"&&$(U.log)}catch{O("Failed to parse SSE data")}},te.onerror=()=>{O("SSE connection lost, reconnecting..."),f(!0),te.close(),j.current!==null&&clearTimeout(j.current),j.current=setTimeout(X,3e3)}},[u,e,$,O]),B=p.useCallback(te=>{if(e===void 0)return;const ue=E.current+1;E.current=ue,g(!0),u(),an(nz(e,te),qI).then(be=>{if(E.current!==ue)return;const w=be.logs;C.current=jr(w),n(w),h(be),o(e),g(!1),u()}).catch(be=>{E.current===ue&&(n([]),h(null),g(!1),O(be instanceof Error?be.message:"Failed to load session logs"))})},[u,e,O]);p.useEffect(()=>{if(e===void 0){b([]);return}let te=!1;return fetch("/api/groups").then(async ue=>{if(!ue.ok)return null;const be=await ue.json(),w=Xd.safeParse(be);return w.success?w.data.groups:null}).then(ue=>{te||ue===null||b(KI(ue,e))}).catch(()=>{te||b([])}),()=>{te=!0}},[e]),p.useEffect(()=>{e!==void 0&&B({kind:"newest"})},[e,B]),p.useEffect(()=>{if(e===void 0)return X(),()=>{_.current&&(_.current.close(),_.current=null),j.current!==null&&(clearTimeout(j.current),j.current=null),z.current!==null&&(clearTimeout(z.current),z.current=null)}},[X,e]),p.useEffect(()=>{const te=window.location.hash;if(!te.startsWith("#log-")||S.current===te)return;const ue=te.slice(1),be=Number(ue.replace(/^log-/,""));Number.isInteger(be)&&be>0&&Qs({logId:be,tab:"request"});let w=!1,Y=0,U=null,I=null;const A=()=>{if(w)return;const L=document.getElementById(ue);if(L!==null){S.current=te,L.scrollIntoView({block:"center",behavior:"smooth"}),L instanceof HTMLElement&&(U=L,L.setAttribute("data-deep-link-highlight","true"),I=window.setTimeout(()=>{L.removeAttribute("data-deep-link-highlight")},ez),L.focus({preventScroll:!0}),L.getAttribute("data-nav-action")==="expand"&&L.click());return}Y+=1,Y<QI&&window.setTimeout(A,100)};return A(),()=>{w=!0,I!==null&&window.clearTimeout(I),U!==null&&U.removeAttribute("data-deep-link-highlight")}},[q.length]);const F=p.useCallback(()=>{e!==void 0&&t.length===0||(async()=>{try{const te=e===void 0?void 0:JSON.stringify({ids:t.map(be=>be.id)});if(!(await fetch("/api/logs",{method:"DELETE",...te===void 0?{}:{headers:{"Content-Type":"application/json"},body:te}})).ok){O("Failed to clear logs");return}C.current.clear(),n([]),u()}catch(te){O(te instanceof Error?te.message:"Unknown error clearing logs")}})()},[t,u,e,O]),Z=p.useCallback(te=>{te.length!==0&&(async()=>{try{if(!(await fetch("/api/logs",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:te})})).ok){O("Failed to clear group");return}const be=new Set(te);n(w=>{const Y=w.filter(U=>!be.has(U.id));return C.current=jr(Y),Y}),u()}catch(ue){O(ue instanceof Error?ue.message:"Unknown error clearing group")}})()},[u,O]),J=p.useCallback(async te=>{const ue=new FormData;ue.set("file",te);const be=await an("/api/logs/import",M1,{method:"POST",body:ue});return n(w=>{const Y=new Set(be.logs.map(A=>A.id)),U=[...w.filter(A=>!Y.has(A.id)),...be.logs].sort((A,L)=>A.id-L.id),I=Ei(U);return C.current=jr(I),I}),o(be.sessionId),a("__all__"),h(null),u(),be},[u]),{strip:H,captureMode:W,slowResponseThresholdSeconds:ce,timeDisplayFormat:se}=Ua(),oe=W,_e=p.useCallback(()=>{B({kind:"oldest"})},[B]),ie=p.useCallback(()=>{B({kind:"newest"})},[B]),ge=p.useCallback(()=>{const te=t[0],ue=m?.oldestLogId??te?.id??null;ue!==null&&B({kind:"older",beforeLogId:ue})},[t,B,m]),he=p.useCallback(()=>{const te=t[t.length-1],ue=m?.newestLogId??te?.id??null;ue!==null&&B({kind:"newer",afterLogId:ue})},[t,B,m]),xe=p.useMemo(()=>{if(e!==void 0)return{isLoading:v,total:m?.total??null,pageSize:m?.limit??Ym,hasOlder:m?.hasOlder??!1,hasNewer:m?.hasNewer??!1,oldestLogId:m?.oldestLogId??null,newestLogId:m?.newestLogId??null,onOldest:_e,onOlder:ge,onNewer:he,onNewest:ie}},[e,ie,he,ge,_e,m,v]);return s.jsxs(s.Fragment,{children:[s.jsx(ZI,{notice:l,onDismiss:u}),s.jsx(fw,{}),s.jsx(BI,{logs:q,sessions:T,models:D,selectedSession:r,selectedModel:i,onSessionChange:o,onModelChange:a,onClearAll:F,onClearGroup:Z,onNotify:c,onImportLogs:e===void 0?J:void 0,isLoading:e===void 0?!d:v,pagination:xe,sessionMemberships:x,viewMode:oe,captureMode:W,strip:H,slowResponseThresholdSeconds:ce,timeDisplayFormat:se,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{G3 as $,K as A,Be as B,My as C,Wr as D,me as E,Qs as F,Fe as G,N as H,Rr as I,WR as J,p2 as K,w3 as L,y2 as M,nR as N,tR as O,az as P,jf as Q,O2 as R,iR as S,rm as T,iz as U,st as V,Ee as W,ko as X,K3 as Y,oz as Z,tf as _,BN as a,J3 as a0,Ka as a1,aa as a2,eo as a3,Pr as a4,ke as a5,rn as a6,Sk as a7,ft as a8,h3 as a9,fy as aa,ae as b,pe as c,Mi as d,sf as e,$e as f,Xh as g,bt as h,Ge as i,Nt as j,Kt as k,Hr as l,Zr as m,Vr as n,I2 as o,sm as p,ht as q,Lr as r,mt as s,Se as t,Sf as u,Je as v,Oe as w,Me as x,Le as y,G as z};
106
+ args = ["stdio", "--url", "${r}"]`}],[r]),i=p.useCallback((a,l)=>{Kt(l).then(c=>{c&&(t(a),setTimeout(()=>t(null),1600))})},[]);return s.jsxs("div",{className:"min-w-0 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ja,{className:"size-4 text-muted-foreground"}),s.jsx("h3",{className:"text-sm font-semibold",children:"MCP access"})]}),s.jsxs("div",{className:"grid gap-2 rounded-md border border-border bg-background px-3 py-2 text-xs text-muted-foreground",children:[s.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."}),s.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."})]}),s.jsx("div",{className:"grid gap-2",children:o.map(a=>s.jsx(Nr,{id:a.id,label:a.label,value:a.value,copiedId:e,onCopy:i},a.id))})]})}function MA(){const{strip:e,slowResponseThresholdSeconds:t,providerTestTimeoutSeconds:n,timeDisplayFormat:r,isLoading:o,setStrip:i,setSlowResponseThresholdSeconds:a,setProviderTestTimeoutSeconds:l,setTimeDisplayFormat:c}=Ha(),[u,d]=p.useState(null),[f,m]=p.useState(!1),h=p.useCallback(async b=>{d(null),m(!0);try{await i(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{m(!1)}},[i]),v=p.useCallback(async b=>{d(null),m(!0);try{await a(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{m(!1)}},[a]),g=p.useCallback(async b=>{d(null),m(!0);try{await l(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{m(!1)}},[l]),x=p.useCallback(async b=>{d(null),m(!0);try{await c(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{m(!1)}},[c]);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["When enabled, the proxy strips the synthetic ",s.jsx("code",{children:"x-anthropic-billing-header"})," text block that Claude Code prepends to the system prompt before forwarding to upstream. Improves prefix-cache hit rates against third-party upstreams. The default at startup is controlled by the ",s.jsx("code",{children:"AGENT_INSPECTOR_STRIP_CLAUDE_CODE_BILLING_HEADER"})," ","environment variable; your choice is persisted to ",s.jsx("code",{children:"config.json"})," and overrides the env var for subsequent requests."]})]}),s.jsxs("label",{className:"flex items-center gap-3",children:[s.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:o||f,onChange:b=>{h(b.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("span",{className:"text-sm",children:o?"Loading...":e?"Stripping enabled":"Stripping disabled"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:"slow-response-threshold",className:"text-sm font-semibold",children:"Slow response threshold"}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Logs whose elapsed time exceeds this many seconds show a warning icon next to the duration. Set to ",s.jsx("code",{children:"0"})," to disable the indicator."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{id:"slow-response-threshold",type:"number",min:0,max:Oi,step:1,value:t,disabled:o||f,onChange:b=>{const y=Number(b.currentTarget.value);Number.isInteger(y)&&(y<0||y>Oi||v(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"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds"})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:"provider-test-timeout",className:"text-sm font-semibold",children:"Provider test timeout"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Provider Test waits this many seconds per configured model before aborting slow probes. The full test window scales with model count."}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{id:"provider-test-timeout",type:"number",min:1,max:Mi,step:1,value:n,disabled:o||f,onChange:b=>{const y=Number(b.currentTarget.value);Number.isInteger(y)&&(y<1||y>Mi||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"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds / model"})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:"time-display-format",className:"text-sm font-semibold",children:"Time display"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls timestamps in session summaries, conversation headers, and log rows."}),s.jsxs("select",{id:"time-display-format",value:r,disabled:o||f,onChange:b=>{const y=tf.safeParse(b.currentTarget.value);y.success&&x(y.data)},className:"h-8 rounded-md border border-input bg-background px-2 text-sm disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx("option",{value:"time",children:"Time only"}),s.jsx("option",{value:"full",children:"Full ISO"})]})]}),u!==null&&s.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",u]})]})}function LA(e){const t=new Map;for(const n of e){const r=n.logs;for(let o=1;o<r.length;o++){const i=r[o-1],a=r[o];i===void 0||a===void 0||t.set(a.id,{creation:Ru(i.cacheCreationInputTokens,a.cacheCreationInputTokens),read:Ru(i.cacheReadInputTokens,a.cacheReadInputTokens)})}}return t}function Ru(e,t){return t===null||e===null?null:t>e?{direction:"up",delta:t-e}:t<e?{direction:"down",delta:e-t}:null}function Um(e){for(const t of e){const n=t.userAgent;if(n!=null&&n!=="")return n}return null}function DA(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function Wm(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}function $A(e){return al({userAgent:Um(e.logs),conversationId:e.conversationId,clientProjectFolder:Wm(e.logs)})}function FA(e){if(e===null||e==="")return"Unknown IDE";const t=e.split(/[ /;]/)[0]??"";return t===""?"Unknown IDE":t}function BA(e,t){const n=To(e);return n!==null?n:FA(t)}function fo(e){return e===null||e===""?"unknown":String(e)}function UA(e,t,n){return e!=="unknown"?e:`unknown:${fo(t)}:${fo(n)}`}function WA(e,t){return`${fo(e)}:${fo(t)}`}function wa(e){return[...e].sort((t,n)=>t.timestamp.localeCompare(n.timestamp))}function Iu(e){return wa(e)[0]?.timestamp??""}function Si(e){return[...e].sort((t,n)=>Iu(t.logs).localeCompare(Iu(n.logs)))}function HA(e){const t=new Map;for(const r of e){const o=Um(r.logs),i=Wm(r.logs),a=$A(r),l=UA(a,o,i);let c=t.get(l);c===void 0&&(c={id:l,client:a,label:BA(a,o),userAgent:o,processes:new Map,logs:[]},t.set(l,c)),c.logs.push(...r.logs);const u=DA(r.logs),d=`${l}:${WA(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(r),f.logs.push(...r.logs)}const n=[];for(const r of t.values()){const o=Si([...r.processes.values()].map(i=>({id:i.id,clientPid:i.clientPid,clientProjectFolder:i.clientProjectFolder,sessions:Si(i.sessions),logs:wa(i.logs)})));n.push({id:r.id,client:r.client,label:r.label,userAgent:r.userAgent,processes:o,logs:wa(r.logs)})}return Si(n)}function po(e){return e<=0?"0":$e(e)}function Hm(e){let t=0,n=0;for(const r of e)r.inputTokens!==null&&r.inputTokens!==void 0&&(t+=r.inputTokens),r.outputTokens!==null&&r.outputTokens!==void 0&&(n+=r.outputTokens);return{inputTokens:t,outputTokens:n}}function ZA(e){let t=0;for(const n of e)t+=n.sessions.length;return t}function VA(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 r=t[t.length-2];return r===void 0?n:`${r}/${n}`}function ho({label:e,value:t,className:n}){return s.jsxs("span",{className:le("border border-border bg-muted/40 inline-flex h-7 items-center gap-1 rounded-md px-2 text-xs text-muted-foreground",n),children:[s.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.12em] text-white/35",children:e}),s.jsx("span",{className:"font-mono tabular-nums text-slate-100",children:t})]})}function qA({groups:e,...t}){const n=p.useMemo(()=>HA(e),[e]),[r,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 s.jsx("div",{className:"space-y-4",children:n.map(u=>s.jsx(KA,{group:u,collapsed:r.has(u.id),collapsedProcessIds:i,onToggleIde:()=>l(u.id),onToggleProcess:c,conversationProps:t},u.id))})}function KA({group:e,collapsed:t,collapsedProcessIds:n,onToggleIde:r,onToggleProcess:o,conversationProps:i}){const a=Hm(e.logs),l=ZA(e.processes),c=e.logs.length;return s.jsxs("section",{className:le("border border-border bg-card shadow-sm relative isolate rounded-[8px]"),"data-ide-group":e.id,children:[s.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:r,"aria-expanded":!t,children:[e.client==="unknown"?s.jsx("span",{className:"border border-border bg-muted/40 inline-flex size-10 shrink-0 items-center justify-center rounded-[8px] text-slate-200",children:s.jsx(S2,{className:"size-5"})}):s.jsx(ll,{client:e.client,className:"size-10 rounded-[8px] text-cyan-100"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"truncate text-sm font-semibold text-slate-50",title:e.userAgent??e.label,children:e.label}),s.jsx("span",{className:"rounded border border-cyan-200/15 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"})]}),s.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[s.jsxs("span",{children:[e.processes.length," process",e.processes.length!==1?"es":""]}),s.jsxs("span",{children:[l," session",l!==1?"s":""]}),s.jsxs("span",{children:[c," log",c!==1?"s":""]})]})]}),s.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[s.jsx(ho,{label:"IN",value:po(a.inputTokens)}),s.jsx(ho,{label:"OUT",value:po(a.outputTokens)})]}),s.jsx("span",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex size-8 shrink-0 items-center justify-center rounded-md text-slate-200",children:t?s.jsx(bt,{className:"size-4"}):s.jsx(st,{className:"size-4"})})]}),!t&&s.jsx("div",{className:"space-y-3 border-t border-white/10 px-3 pb-3 pt-3 sm:px-4",children:e.processes.map(u=>s.jsx(GA,{group:u,collapsed:n.has(u.id),onToggle:()=>o(u.id),conversationProps:i},u.id))})]})}function GA({group:e,collapsed:t,onToggle:n,conversationProps:r}){const o=Hm(e.logs),i=VA(e.clientProjectFolder),a=e.sessions.length,l=e.logs.length,c=e.clientPid!==null&&e.clientPid!==void 0?`PID ${e.clientPid}`:"process";return s.jsxs("section",{className:"relative pl-5",children:[s.jsx("span",{className:"absolute bottom-0 left-2 top-0 w-px bg-white/12","aria-hidden":"true"}),s.jsxs("div",{className:"border border-border bg-card shadow-sm overflow-hidden rounded-[8px]",children:[s.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:[s.jsx("span",{className:"border border-border bg-muted/40 inline-flex size-8 shrink-0 items-center justify-center rounded-md text-amber-100",children:s.jsx(Uy,{className:"size-4"})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"font-mono text-xs font-semibold tabular-nums text-slate-100",children:c}),i!==null&&s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-xs text-muted-foreground",title:e.clientProjectFolder??i,children:[s.jsx(l2,{className:"size-3 shrink-0"}),s.jsx("span",{className:"truncate font-mono",children:i})]})]}),s.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[s.jsxs("span",{children:[a," session",a!==1?"s":""]}),s.jsxs("span",{children:[l," log",l!==1?"s":""]})]})]}),s.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[s.jsx(ho,{label:"IN",value:po(o.inputTokens)}),s.jsx(ho,{label:"OUT",value:po(o.outputTokens)})]}),s.jsx("span",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex size-7 shrink-0 items-center justify-center rounded-md text-slate-200",children:t?s.jsx(bt,{className:"size-4"}):s.jsx(st,{className:"size-4"})})]}),!t&&s.jsx("div",{className:"space-y-2 border-t border-white/10 p-2 sm:p-3",children:e.sessions.map(u=>s.jsx(OE,{group:u,...r,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},u.id))})]})]})}const mo="data-nav-id",JA="data-nav-action";function zu(e){return Array.from(e.querySelectorAll(`[${mo}]`))}function Pu(e){return e instanceof HTMLElement}function YA(e,t){let n=e;for(;n!==null&&n!==t;){if(n.hasAttribute(mo))return n;n=n.parentElement}return e.hasAttribute(mo)?e:null}function Ci(e){const t=e.getAttribute(JA);return t==="toggle"||t==="expand"||t==="collapse"?t:null}function kr(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function _r(e,t){return e[t]??null}function Zm(e){const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function Ou(e){const t=e.tagName;return t==="BUTTON"||t==="A"||Zm(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function XA(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function QA(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function Cs(e,t){return e.key===t&&e.shiftKey}function eR(e,t,n={}){const r=t??e,o=n.pageWide===!0,i=p.useCallback(a=>{const l=e.current,c=r.current;if(!l||!c)return;const u=a.target;if(!Pu(u)||u!==c)return;const d=zu(l),f=_r(d,0);f!==null&&kr(f)},[e,r]);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(!Pu(u)||Zm(u)||QA())return;const d=c.contains(u);if(d&&Ou(u)&&!u.hasAttribute(mo)||!d&&(!o||Ou(u)||XA(u)))return;const f=zu(c);if(f.length===0)return;const m=YA(u,c),h=m!==null?f.indexOf(m):-1;let v=!1;switch(l.key){case"ArrowUp":case"W":{if(l.shiftKey&&l.key==="ArrowUp"||l.key==="W"&&!Cs(l,"W"))break;l.preventDefault();const g=h>0?h-1:h===-1?f.length-1:-1;if(g!==-1){const x=_r(f,g);x!==null&&kr(x)}v=!0;break}case"ArrowDown":case"S":{if(l.shiftKey&&l.key==="ArrowDown"||l.key==="S"&&!Cs(l,"S"))break;l.preventDefault();const g=h<f.length-1?h+1:h===-1?0:-1;if(g!==-1){const x=_r(f,g);x!==null&&kr(x)}v=!0;break}case"ArrowLeft":case"A":{if(l.shiftKey&&l.key==="ArrowLeft"||l.key==="A"&&!Cs(l,"A")||m===null)break;if(l.preventDefault(),Ci(m)==="collapse")m.click();else if(h>0){const x=_r(f,h-1);x!==null&&kr(x)}v=!0;break}case"ArrowRight":case"D":{if(l.shiftKey&&l.key==="ArrowRight"||l.key==="D"&&!Cs(l,"D")||m===null)break;if(l.preventDefault(),Ci(m)==="expand")m.click();else if(h<f.length-1){const x=_r(f,h+1);x!==null&&kr(x)}v=!0;break}case" ":{if(m===null)break;l.preventDefault(),Ci(m)!==null&&m.click(),v=!0;break}}v&&l.stopPropagation()};return document.addEventListener("keydown",a,{capture:!0}),()=>document.removeEventListener("keydown",a,{capture:!0})},[e,o,r]),p.useEffect(()=>(document.addEventListener("focusin",i),()=>document.removeEventListener("focusin",i)),[i])}const tR={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},nR={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"},rR={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"},Ni=12,Ns=1,Mu=80,Lu=24;function sR(e){return e.length<=Lu?e:`${e.slice(0,Lu-3)}...`}function oR(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Mu?t:`${t.slice(0,Mu)}...`}function Ts(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const iR=p.memo(function({segments:t,totalTokens:n,showLabels:r=!0,onActivate:o}){const i=p.useMemo(()=>n>0?n:t.reduce((x,b)=>x+b.size,0),[t,n]),a=t.slice(0,Ni),l=t.slice(Ni),c=l.reduce((x,b)=>x+b.size,0),u=l.length,d=Ni,f=d+u-1,m=u>0,h=o!==void 0,v=p.useMemo(()=>a.reduce((x,b)=>x+b.size,0),[a]),g=p.useMemo(()=>`Request context: ~${$e(i)} tokens across ${t.length} segment${t.length===1?"":"s"}`,[t.length,i]);return t.length===0||i<=0?s.jsx("div",{role:"img","aria-label":g,className:"h-6"}):s.jsx(Je,{delayDuration:150,children:s.jsxs("div",{role:"img","aria-label":g,className:"flex flex-col gap-1.5",children:[s.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((x,b)=>{const y=i>0?x.size/i*100:0,_=Math.max(Ns,y),j=le("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",nR[x.role],h?rR[x.role]:""),S={width:`${_}%`},E=`${x.label}, ${Ts(y)}, ~${$e(x.size)} tokens`;return s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:h?s.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>o(x),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),o(x))},"data-anatomy-path":x.path,"aria-label":E,className:j,style:S}):s.jsx("span",{"aria-label":E,className:j,style:S})}),s.jsxs(Le,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[s.jsxs("div",{className:"font-semibold",children:[x.label," - ",Ts(y)," - ~",$e(x.size)," ","tokens"]}),s.jsx("div",{className:"text-muted-foreground",children:tR[x.role]}),s.jsxs("div",{className:"text-muted-foreground",children:[x.characters.toLocaleString()," chars"]}),x.text.length>0&&s.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:oR(x.text)})]})]},`${x.path}-${b}`)}),m&&s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.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(Ns,c/i*100)}%`},children:["... +",u]})}),s.jsxs(Le,{side:"bottom",className:"text-xs",children:[u," more segment",u===1?"":"s"," (indices"," ",d,"-",f,")"]})]})]}),r&&s.jsxs("div",{className:"flex w-full gap-1 text-[10px] text-muted-foreground",children:[a.map((x,b)=>{const y=i>0?x.size/i*100:0,_=Math.max(Ns,y);return s.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${_}%`},title:`${x.label} - ${Ts(y)} - ~${$e(x.size)} tokens`,children:[s.jsx("span",{className:"truncate font-mono text-foreground/80",children:sR(x.label)}),s.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[Ts(y)," - ~",$e(x.size)]})]},`label-${x.path}-${b}`)}),m&&s.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(Ns,c/i*100)}%`},children:[s.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",u]}),s.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",$e(c)]})]})]}),v<i*.1&&s.jsx("div",{className:"h-0"})]})})}),Vm=.75,qm=.9,ka=8e3,aR=.35,Km=40,Gm=160,lR=5,cR=8,uR=18,dR=6e4,fR=.7,Du=3e3,pR=.3,$u=160,hR=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),mR=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],gR=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],xR=[{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"]}],bR={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function vR(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 Jm(e,t){for(const n of t){const r=vR(ke(e,n));if(r!==null)return r}return null}function yR(e){const t=ke(e,"model");if(typeof t!="string")return null;const n=t.trim();return n===""?null:n}function wR(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 kR(e,t,n=[]){const r=Jm(t,mR);if(r!==null)return{tokens:r,label:"Request metadata",source:"request"};const o=J4(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 xR)if(wR(i,a))return{tokens:a.tokens,label:`${a.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function _R(e){return e<0?0:e>1?1:e}function jR(e){return e===null?"unknown":e>=qm?"danger":e>=Vm?"watch":"ok"}function SR(e,t){return e.filter(n=>n.role===t).reduce((n,r)=>n+r.size,0)}function CR(e,t){return["system","user","assistant","tool","tools"].map(r=>{const o=SR(e,r);return{role:r,label:bR[r],tokens:o,percent:t>0?o/t:0}}).filter(r=>r.tokens>0).sort((r,o)=>o.tokens-r.tokens)}function _a(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function NR(e){const t=e.replace(/\s+/g," ").trim();return t.length<=$u?t:`${t.slice(0,$u-3)}...`}function TR(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function ER(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function AR(e){const t=e.trim();return t.startsWith("{")||t.startsWith("[")}function RR(e){if(!AR(e))return null;try{return JSON.parse(e)}catch{return null}}function IR(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function zR(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 PR(e){const t=zR(e);return t===null?!1:hR.has(IR(t))}function OR(e){return e.map(t=>t.startsWith("[")?t:`.${t}`).join("").replace(/^\./,"")}function MR(e,t,n){const r=Al(t);if(r<Gm)return null;const o=El(t);return o<Km?null:{role:e.role,label:`${e.label} ${OR(n)}`,path:e.path,tokens:o,characters:r,text:t}}function ja({value:e,segment:t,path:n,depth:r,candidates:o}){if(!(o.length>=cR)&&!(r>lR)){if(typeof e=="string"){if(!PR(n))return;const i=MR(t,e,n);i!==null&&o.push(i);return}if(Array.isArray(e)){e.forEach((i,a)=>ja({value:i,segment:t,path:[...n,`[${String(a)}]`],depth:r+1,candidates:o}));return}Rl(e)&&Object.entries(e).forEach(([i,a])=>ja({value:a,segment:t,path:[...n,i],depth:r+1,candidates:o}))}}function LR(e){const t=ER(e),n=RR(e.text);if(n===null)return[t];const r=[];ja({value:n,segment:e,path:[],depth:0,candidates:r});const o=_a(e.text),i=new Set([o]),a=r.filter(l=>{const c=_a(l.text);return c===""||i.has(c)?!1:(i.add(c),!0)});return[t,...a]}function DR(e){const t=new Map;for(const r of e){const o=LR(r);for(const i of o){if(i.tokens<Km||i.characters<Gm)continue;const a=_a(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 r of t.values()){if(r.candidates.length<2)continue;const o=r.candidates[0]??null;if(o===null)continue;const i=r.tokens-o.tokens;n.push({key:`${o.path}:${o.label}:${String(r.candidates.length)}:${String(r.tokens)}`,count:r.candidates.length,totalTokens:r.tokens,repeatedTokens:i,preview:NR(o.text),firstLabel:o.label,segments:r.candidates.map(TR)})}return n.sort((r,o)=>o.repeatedTokens-r.repeatedTokens||o.totalTokens-r.totalTokens)}function $R(e){if(e.length===0)return null;const t=e.length,n=e.reduce((o,i)=>o+i.count,0),r=e.reduce((o,i)=>o+i.repeatedTokens,0);return{kind:"duplicate",severity:r>=ka?"danger":"watch",title:"Duplicate context",detail:`${String(n)} repeated blocks across ${String(t)} group${t===1?"":"s"}, ~${String(r)} repeated tokens.`}}function FR(e){return e.reduce((t,n)=>t+n.repeatedTokens,0)}function BR(e,t,n){const r=[],o=e.find(c=>c.role==="tools")??null;o!==null&&(o.tokens>=ka||o.percent>=aR&&o.tokens>=Du)&&r.push({kind:"tool-schema",severity:o.tokens>=ka?"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>=Du&&i.percent>=pR&&r.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>=uR&&(a>=dR||l>=fR)&&r.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.`}),r}function UR({risk:e,contextWindow:t,diagnostics:n,duplicateGroups:r}){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:FR(r)}}function WR({segments:e,inputTokens:t,parsed:n,model:r,providers:o=[]}){const i=e.reduce((E,C)=>E+C.size,0),a=r??yR(n),l=t??i,c=Jm(n,gR),u=kR(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,v=u.tokens===null||f===null?null:_R(f/u.tokens),g=CR(e,i),x=g[0]??null,b=e.filter(E=>E.role!=="tools").length,y=DR(e),_=$R(y),j=BR(g,i,b);_!==null&&j.unshift(_);const S=jR(v);return{model:a,contextWindow:u,estimatedInputTokens:l,outputReserveTokens:c,windowUsedTokens:f,remainingInputTokens:m,remainingAfterReserveTokens:h,usagePercent:v,riskLevel:S,roleUsages:g,largestRole:x,diagnostics:j,duplicateGroups:y,health:UR({risk:S,contextWindow:u,diagnostics:j,duplicateGroups:y})}}const iz={watch:Vm,danger:qm},Fu=new WeakMap;function HR(e){return e.map(t=>{const n=t.modelMetadata?.map(r=>`${r.model}:${String(r.contextWindow??"")}`).join(",")??"";return`${t.id}:${t.updatedAt}:${t.models.join(",")}:${n}`}).join("|")}function ZR(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function VR(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function qR(e,t){const n=ZR(e.rawRequestBody);if(n===null)return null;const o=em(Lr(e)).anatomySegments(n);if(o===null)return null;const i=WR({segments:o,inputTokens:e.inputTokens??null,parsed:n,model:e.model,providers:t}),a=i.model??e.model??"Unknown model",l=i.roleUsages.map(VR);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 KR(e,t,n){const r=Fu.get(e);if(r!==void 0&&r.id===e.id&&r.rawRequestBody===e.rawRequestBody&&r.inputTokens===e.inputTokens&&r.model===e.model&&r.path===e.path&&r.apiFormat===e.apiFormat&&r.timestamp===e.timestamp&&r.providersSignature===n)return r.snapshot;const o=qR(e,t);return Fu.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 GR(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 Bu(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function JR(e,t){const n=Bu(t.latest.riskLevel)-Bu(e.latest.riskLevel);if(n!==0)return n;const r=e.peak.usagePercent??-1,i=(t.peak.usagePercent??-1)-r;return i!==0?i:t.latest.logId-e.latest.logId}function YR(e,t){return e.usagePercent===null||t.usagePercent===null?null:(t.usagePercent-e.usagePercent)*100}function XR(e){for(let t=1;t<e.length;t++){const n=e[t-1],r=e[t];if(!(n===void 0||r===void 0)&&n.id>r.id)return[...e].sort((o,i)=>o.id-i.id)}return e}function QR(e,t=[]){const n=XR(e),r=HR(t),o=new Map;for(const a of n){const l=KR(a,t,r);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:GR(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:YR(a.first,a.latest)})).sort(JR)}}function tn(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function eI(e){const t=new Map;for(const n of e)for(let r=0;r<n.logs.length;r+=1){const o=n.logs[r];o!==void 0&&t.set(o.id,r+1)}return t}function Uu(e,t){return t.get(e.id)??e.id}function tI(e){return e==="full"}function nI(e,t){const n=t>0;return{redacted:n,raw:n&&tI(e)}}function Wu(e){let t=0,n=0;for(const r of e)r.inputTokens!==null&&(t+=r.inputTokens),r.outputTokens!==null&&(n+=r.outputTokens);return{totalIn:t,totalOut:n}}function Ym(e,t){const n=e[0],r=e[e.length-1];return n===void 0||r===void 0?null:Ya(n.timestamp,r.timestamp,t)}function rI(e){for(const t of e)if(t.userAgent!==null&&t.userAgent!==void 0&&t.userAgent!=="")return t.userAgent;return null}function sI(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function oI(e){const t=new Set;for(const r of e)r.model!==null&&r.model.length>0&&t.add(r.model);const n=[...t].sort();return n.length===0?"Model unknown":n.length===1?n[0]??"Model unknown":`${n.length} models`}function iI(e){const t=new Set;for(const r of e)r.providerName!==null&&r.providerName!==void 0&&r.providerName.length>0&&t.add(r.providerName);const n=[...t].sort();return n.length===0?"Provider unknown":n.length===1?n[0]??"Provider unknown":`${n.length} providers`}function aI(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),r=t%60;return`${n}m ${r}s`}function lI(e,t){return`${$e(e)} in / ${$e(t)} out`}function cI(e,t){if(e.length===0)return 0;if(t.length===0)return pa(e).length;let n=0;for(const r of t)n+=pa(r.logs).length;return n}function uI({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 dI(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 fI({pending:e,failures:t,lengthStops:n,stopReason:r,lastFailure:o}){if(o!==null&&(o.status===499||dI(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||r==="length")return{label:"Output limited",detail:"Model stopped at the output token limit",tone:"watch"};switch(r){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 pI({logs:e,conversationGroups:t,isLoading:n,timeDisplayFormat:r,slowResponseThresholdSeconds:o}){let i=0,a=0,l=0,c=0,u=0,d=0,f=null,m=null,h=null,v=null,g=null,x=0,b=0,y=0,_=null;const j=o*1e3;for(let z=0;z<e.length;z+=1){const O=e[z];if(O===void 0)continue;const q=z+1,T=df(O);T!==null&&(f=T),T==="length"&&(c+=1),sI(O)&&(i+=1,m=q,h={logNumber:q,status:O.responseStatus,error:O.error??null}),O.responseStatus===null&&(a+=1),o>0&&O.elapsedMs!==null&&O.elapsedMs>=j&&(l+=1),O.inputTokens!==null&&(u+=O.inputTokens),O.outputTokens!==null&&(d+=O.outputTokens),O.elapsedMs!==null&&(v===null||O.elapsedMs>v)&&(v=O.elapsedMs,g=q);const D=O.inputTokens??0,k=O.outputTokens??0,$=D+k;$>x&&(x=$,b=D,y=k,_=q)}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",C=uI({stopReason:f,pending:a,lastFailureLogNumber:m}),R=fI({pending:a,failures:i,lengthStops:c,stopReason:f,lastFailure:h});return{status:S,statusLabel:E,modelLabel:oI(e),providerLabel:iI(e),requests:e.length,turns:cI(e,t),failures:i,pending:a,slow:l,lengthStops:c,timeRange:Ym(e,r),tokenLabel:`${$e(u)} in / ${$e(d)} out`,finishLabel:C.label,finishDetail:C.detail,finishTone:C.tone,outcomeLabel:R.label,outcomeDetail:R.detail,outcomeTone:R.tone,slowestLabel:v===null?"n/a":aI(v),slowestDetail:g===null?"Latency pending":`Request #${g}`,heaviestDetail:_===null?"Tokens pending":`#${_} ${lI(b,y)}`}}function hI(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 mI(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function gI(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 Wn({label:e,value:t,detail:n,icon:r,tone:o="neutral"}){return s.jsxs("div",{className:"min-w-0 border-t border-white/10 px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[r,e]}),s.jsx("div",{className:le("mt-2 font-mono text-sm font-semibold",hI(o)),children:t}),s.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:n})]})}function xI({stats:e}){return e.requests===0?null:s.jsxs("div",{className:"border border-border bg-card shadow-sm mb-4 overflow-hidden rounded-[8px]",children:[s.jsx("div",{className:"px-4 py-3",children:s.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-semibold uppercase text-muted-foreground",children:[s.jsx(Ay,{className:"size-3.5 text-slate-300"}),"Flight Recorder"]}),s.jsx("div",{className:"mt-2 min-w-0 font-mono text-sm font-semibold text-foreground",children:e.modelLabel})]}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 font-mono",children:e.providerLabel}),s.jsx("span",{className:"min-w-0 font-mono",children:e.timeRange??"Timeline pending"})]})]})}),s.jsxs("div",{className:"grid grid-cols-2 border-t border-white/10 md:grid-cols-3 2xl:grid-cols-6",children:[s.jsx(Wn,{label:"Status",value:e.statusLabel,detail:gI(e),tone:mI(e.status)}),s.jsx(Wn,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:s.jsx(i2,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),s.jsx(Wn,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:s.jsx(Fi,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),s.jsx(Wn,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:s.jsx(tw,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),s.jsx(Wn,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:s.jsx(Ga,{className:"size-3 text-muted-foreground"})}),s.jsx(Wn,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function bI({pinnedSessionId:e,selectedSession:t,sessions:n,logs:r}){if(e!==void 0){const a=r.filter(l=>l.sessionId===e);return a.length===0?null:{label:e,logs:a,showBackLink:!0}}if(t!=="__all__"){const a=r.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&&r.every(l=>l.sessionId===o)?{label:o,logs:[...r],showBackLink:!1}:n.length===0&&r.length>0&&r.every(a=>a.sessionId===null)?{label:"Visible requests",logs:[...r],showBackLink:!1}:null}function Tr(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 vI(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function Sa(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function yI(e,t){if(t===null)return null;const n=Sa(e),r=Sa(t);return r<=0||Math.abs(r-n)<.5?null:r}function wI(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 kI(e){const t=e.latest.contextWindow.tokens;return t===null?"Context window unknown":`Context window ${Cf(t)}`}const _I=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function Xm(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 Ti(e,t){if(e===null)return null;const n=e.metadata[t];return n===void 0?null:Xm(n)}function jI(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 SI(e){const t=[];for(const n of _I){const r=e.metadata[n];if(r===void 0)continue;const o=Xm(r);o!==null&&t.push({key:n,value:o})}return t}function Hu({memberships:e,defaultOpen:t=!1}){const[n,r]=p.useState(t);if(e.length===0)return null;const o=e[0],i=o?.member??null,a=Ti(i,"score"),l=Ti(i,"decision"),c=Ti(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 s.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] text-xs",children:[s.jsxs("button",{type:"button",onClick:()=>r(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:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"font-semibold text-foreground",children:"Case File"}),o!==void 0&&s.jsx("span",{className:"truncate text-muted-foreground",title:o.groupTitle,children:o.groupTitle}),s.jsxs("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:[e.length," group",e.length===1?"":"s"]})]}),u.length>0&&s.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=>s.jsx("span",{className:le("rounded border px-1.5 py-0.5 font-mono text-[10px]",jI(d.value)),children:d.label},d.label))})]}),n?s.jsx(Za,{className:"size-4 shrink-0 text-muted-foreground"}):s.jsx(st,{className:"size-4 shrink-0 text-muted-foreground"})]}),n&&s.jsx("div",{className:"space-y-2 border-t border-white/10 px-3 py-2",children:e.map(d=>{const f=d.member,m=SI(f);return s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"truncate font-medium text-foreground",title:d.groupTitle,children:d.groupTitle}),s.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:d.groupStatus}),f.status!==null&&s.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["member ",f.status]})]}),s.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[s.jsx("span",{className:"font-mono",title:f.sessionId,children:tn(f.sessionId)}),f.label!==null&&s.jsx("span",{children:f.label}),f.provider!==null&&s.jsx("span",{children:f.provider}),f.model!==null&&s.jsx("span",{className:"font-mono",children:f.model}),f.runId!==null&&s.jsxs("span",{className:"font-mono",title:f.runId,children:["run ",tn(f.runId)]})]}),m.length>0&&s.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:m.map(h=>s.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-1",children:[s.jsx("div",{className:"font-mono text-[10px] text-muted-foreground",children:h.key}),s.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:h.value,children:h.value})]},h.key))})]},`${d.groupId}:${f.id}`)})})]})}function CI({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],r=e[e.length-1],o=n===void 0||r===void 0?"Current page":`#${n.id}-#${r.id}`,i=t.total===null?"logs":`${t.total} logs`;return`Showing ${o} of ${i}`}function Es({label:e,title:t,icon:n,disabled:r,onClick:o}){return s.jsxs("button",{type:"button",onClick:o,disabled:r,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,s.jsx("span",{children:e})]})}function Zu({logs:e,pagination:t,embedded:n=!1}){if(t===void 0)return null;const r=t.isLoading;return s.jsxs("div",{className:le("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:[s.jsxs("div",{className:"w-full min-w-0 px-1 font-mono text-[11px] text-muted-foreground sm:flex-1",children:[CI({logs:e,pagination:t}),t.isLoading&&e.length>0&&s.jsx("span",{className:"ml-2",children:"Loading..."})]}),s.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[s.jsx(Es,{label:"Oldest",title:"Load the oldest logs in this session",icon:s.jsx(xy,{className:"size-3.5"}),disabled:r||!t.hasOlder,onClick:t.onOldest}),s.jsx(Es,{label:"Older",title:"Load older logs",icon:s.jsx(dy,{className:"size-3.5"}),disabled:r||!t.hasOlder,onClick:t.onOlder}),s.jsx(Es,{label:"Newer",title:"Load newer logs",icon:s.jsx(bt,{className:"size-3.5"}),disabled:r||!t.hasNewer,onClick:t.onNewer}),s.jsx(Es,{label:"Newest",title:"Load the newest logs in this session",icon:s.jsx(vy,{className:"size-3.5"}),disabled:r||!t.hasNewer,onClick:t.onNewest})]})]})}function NI(e){return`${e} ${e===1?"request":"requests"}`}function Vu(e){return`#${String(e)}`}function qu(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 TI(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 EI(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const AI=10,RI=80;function II(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function zI(e){const t=document.getElementById(`log-${String(e)}`);return t instanceof HTMLElement?(t.scrollIntoView({block:"center",behavior:"smooth"}),t.focus({preventScroll:!0}),II(t),!0):!1}function Qm(e){eo({logId:e,tab:"anatomy"});let t=0;const n=()=>{eo({logId:e,tab:"anatomy"}),!zI(e)&&(t+=1,t<AI&&window.setTimeout(n,RI))};window.setTimeout(n,0)}function Ku({command:e}){const[t,n]=p.useState(!1),r=p.useCallback(()=>{Kt(e).then(o=>{o&&(n(!0),setTimeout(()=>n(!1),2e3))})},[e]);return s.jsxs("div",{className:"border border-border bg-muted/40 inline-flex max-w-full items-center gap-2 rounded-md px-3 py-2",children:[s.jsx("pre",{className:"m-0 overflow-x-auto font-mono text-sm text-cyan-200",children:e}),s.jsx("button",{type:"button",onClick:r,className:"shrink-0 cursor-pointer text-muted-foreground transition-colors hover:text-foreground","aria-label":"Copy command",children:t?s.jsx(Ge,{className:"size-4"}):s.jsx(Nt,{className:"size-4"})})]})}function Gu(){return s.jsx(Je,{children:s.jsxs(Oe,{children:[s.jsx(Me,{asChild:!0,children:s.jsxs("span",{className:"border border-border bg-muted/40 inline-flex h-7 items-center gap-2 rounded-md px-2.5 font-mono text-[11px] font-medium text-cyan-200",children:[s.jsx("span",{className:"size-1.5 rounded-full bg-cyan-200 shadow-[0_0_8px_rgba(125,211,252,0.75)]"}),"MCP Ready",s.jsx("span",{className:"hidden text-cyan-200/70 sm:inline",children:"/api/mcp"})]})}),s.jsx(Le,{sideOffset:8,className:"max-w-[320px] text-left leading-relaxed",children:"Coding agents can inspect logs, replay requests, test providers, and debug sessions through MCP at /api/mcp."})]})})}function Ei({label:e,children:t,className:n}){return s.jsxs("section",{className:le("border border-border bg-card shadow-sm rounded-[8px]",n),children:[s.jsx("div",{className:"border-b border-white/10 px-3 py-2",children:s.jsx("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-white/40",children:e})}),s.jsx("div",{className:"p-3",children:t})]})}function Ai({label:e,value:t}){return s.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-2",children:[s.jsx("div",{className:"truncate font-mono text-lg font-semibold leading-6 text-slate-100",children:t}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] uppercase tracking-[0.12em] text-white/35",children:e})]})}const PI=["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 Ju({compact:e,entrancePhase:t}){return e?s.jsx(cu,{className:"size-7 text-amber-500"}):s.jsxs("span",{className:"flex shrink-0 items-end gap-1 group cursor-default","aria-hidden":"true",children:[s.jsx(cu,{className:"size-10 text-amber-500 transition-all duration-300 group-hover:scale-125 group-hover:-translate-y-1.5"}),s.jsx("span",{className:"hidden items-end gap-0.5 sm:flex",children:Fr.map((n,r)=>{const o=PI[r]??"text-amber-500",i=t==="hidden"?"opacity-0 scale-0":t==="playing"?"animate-crab-piano-pop":"";return s.jsx(n,{className:`size-5 ${o} transition-all duration-300 ease-out group-hover:scale-125 group-hover:-translate-y-1 ${i}`,style:{transitionDelay:`${r*50}ms`,...t==="playing"?{animationDelay:`${r*400}ms`}:{}}},r)})})]})}function OI({compact:e,crabEntrancePhase:t}){return e?s.jsxs("div",{className:"border border-border bg-card shadow-sm rounded-[8px] p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsx(Ju,{compact:!0,entrancePhase:t}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[s.jsx("span",{className:"truncate text-base font-bold",children:"Inspector"}),s.jsxs("span",{className:"hidden shrink-0 font-mono text-[11px] font-semibold text-muted-foreground sm:inline",children:["v",Ui.version]})]}),s.jsx("div",{className:"hidden text-[11px] font-semibold text-muted-foreground sm:block",children:"Local First. Evidence First."})]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(uu,{}),s.jsx(fu,{}),s.jsx(Au,{})]})]}),s.jsx("div",{className:"mt-2 hidden sm:block",children:s.jsx(Gu,{})})]}):s.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] items-start gap-3 pb-6",children:[s.jsx("div",{}),s.jsxs("h1",{className:"flex min-w-0 flex-col items-center gap-2 text-center",children:[s.jsxs("span",{className:"flex max-w-[calc(100vw-7rem)] items-end gap-2 whitespace-nowrap",children:[s.jsx(Ju,{compact:!1,entrancePhase:t}),s.jsxs("span",{className:"flex min-w-0 items-baseline gap-2 pl-1",children:[s.jsx("span",{className:"truncate text-lg font-bold",children:"Agent Inspector"}),s.jsxs("span",{className:"shrink-0 font-mono text-xs font-semibold text-muted-foreground",children:["v",Ui.version]})]}),s.jsx(Di,{className:"size-4 shrink-0 text-muted-foreground/70","aria-hidden":"true"}),s.jsx(LE,{className:"size-10 shrink-0"})]}),s.jsx("span",{className:"max-w-[calc(100vw-7rem)] text-sm font-semibold text-muted-foreground",children:"Local First. Evidence First."}),s.jsx(Gu,{})]}),s.jsxs("div",{className:"justify-self-end flex items-center gap-1",children:[s.jsx(uu,{}),s.jsx(fu,{}),s.jsx(Au,{})]})]})}function Yu({label:e,logId:t}){return s.jsxs("button",{type:"button",onClick:()=>Qm(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 ${Vu(t)}`,children:[e," ",Vu(t)]})}function MI({latestPercent:e,peakPercent:t,risk:n,onOpenContext:r}){const o=Sa(e),i=yI(e,t),a=t===null?`Latest context window usage ${Tr(e)}`:`Latest context window usage ${Tr(e)}, peak ${Tr(t)}`;return s.jsx("button",{type:"button",onClick:r,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:s.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:[s.jsx("span",{className:le("block h-full rounded-full transition-[width]",wI(n)),style:{width:`${o}%`}}),i!==null&&s.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 LI({summary:e}){const t=e.trendPercent,n=t===null||Math.abs(t)<.1?null:t>0?ey:K1,r=e.latest.diagnostics[0]??null,o=Tr(e.latest.usagePercent),i=Tr(e.peak.usagePercent),a=()=>{Qm(e.latest.logId)};return s.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:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.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}),s.jsx("span",{className:le("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",TI(e.latest.health.level)),children:EI(e.latest.health.level)})]}),s.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:[s.jsx("span",{children:NI(e.requestCount)}),s.jsx("span",{children:kI(e)})]})]}),s.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[s.jsx(MI,{latestPercent:e.latest.usagePercent,peakPercent:e.peak.usagePercent,risk:e.latest.riskLevel,onOpenContext:a}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Latest"}),s.jsx("div",{className:le("mt-0.5 font-mono",qu(e.latest.riskLevel)),children:o}),s.jsx(Yu,{label:"Log",logId:e.latest.logId})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Peak"}),s.jsx("div",{className:le("mt-0.5 font-mono",qu(e.peak.riskLevel)),children:i}),s.jsx(Yu,{label:"Log",logId:e.peak.logId})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Trend"}),s.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-foreground",children:[n!==null&&s.jsx(n,{className:le("size-3",t!==null&&t>0?"text-amber-300":"text-cyan-300")}),vI(t)]}),s.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),s.jsxs("div",{className:"min-w-0 space-y-1.5",children:[s.jsx(iR,{segments:e.latest.roleSegments,totalTokens:e.latest.roleTotalTokens,showLabels:!1}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsxs("span",{className:"font-mono",children:["~",$e(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&s.jsxs("span",{className:"font-mono",children:["~",$e(e.latest.windowUsedTokens)," used"]}),r!==null&&s.jsx("span",{className:"truncate",children:r})]})]})]})}function DI({summary:e}){return e.models.length===0?null:s.jsxs("div",{className:"mt-3 border-t border-white/10 pt-2",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Session Context"}),s.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:[e.models.length," model",e.models.length===1?"":"s"]})]}),s.jsx("div",{className:"max-h-52 overflow-y-auto pr-1",children:e.models.map(t=>s.jsx(LI,{summary:t},t.model))})]})}function $I(e){const t=e.models.filter(r=>r.latest.health.level==="risk").length;if(t>0)return`${t} risk`;const n=e.models.filter(r=>r.latest.health.level==="optimizable").length;return n>0?`${n} optimizable`:`${e.models.length} model${e.models.length===1?"":"s"}`}function FI({label:e,logs:t,totalIn:n,totalOut:r,timeDisplayFormat:o,contextSummary:i,showBackLink:a}){const[l,c]=p.useState(!1),[u,d]=p.useState(!1),f=p.useMemo(()=>Ym(t,o),[t,o]),m=p.useMemo(()=>rI(t),[t]),h=p.useMemo(()=>$I(i),[i]),v=p.useCallback(()=>{Kt(window.location.href).then(g=>{g&&(c(!0),setTimeout(()=>c(!1),2e3))})},[]);return s.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-3 py-2 text-xs",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a&&s.jsx("a",{href:"/",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground","aria-label":"Back to all sessions",title:"Back to all sessions",children:s.jsx(X1,{className:"size-3.5"})}),s.jsxs("div",{className:"min-w-[180px] flex-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"font-mono font-semibold text-purple-400/90 truncate",title:e,children:tn(e)}),m!==null&&s.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:m,children:m})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[s.jsxs("span",{children:[t.length," request",t.length!==1?"s":""]}),f!==null&&s.jsx("span",{children:f}),(n>0||r>0)&&s.jsxs("span",{className:"font-mono",children:[$e(n)," in / ",$e(r)," out"]})]})]}),i.models.length>0&&s.jsxs("button",{type:"button",onClick:()=>d(g=>!g),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 font-mono text-[11px] text-muted-foreground transition-colors hover:text-foreground","aria-expanded":u,title:u?"Hide context details":"Show context details",children:[s.jsx("span",{children:h}),u?s.jsx(Za,{className:"size-3.5"}):s.jsx(st,{className:"size-3.5"})]}),s.jsx("button",{type:"button",onClick:v,className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground","aria-label":l?"Copied session link":"Copy session link",title:l?"Copied session link":"Copy session link",children:l?s.jsx(Ge,{className:"size-3.5"}):s.jsx(Nt,{className:"size-3.5"})})]}),u&&s.jsx(DI,{summary:i})]})}function BI({logs:e,sessions:t,models:n,selectedSession:r,selectedModel:o,onSessionChange:i,onModelChange:a,onClearAll:l,onClearGroup:c,onNotify:u,onImportLogs:d,viewMode:f,captureMode:m,strip:h,slowResponseThresholdSeconds:v,timeDisplayFormat:g,isLoading:x=!1,pagination:b,sessionMemberships:y=[],hideSessionFilter:_=!1,pinnedSessionId:j}){const{totalIn:S,totalOut:E}=p.useMemo(()=>Wu(e),[e]),{providers:C}=Nf(),[R,z]=p.useState(null),[O,q]=p.useState(null),[T,D]=p.useState(!1),[k,$]=p.useState(null),[X,B]=p.useState(null),[F,Z]=p.useState(null),[J,H]=p.useState("hidden"),W=p.useRef(null),ce=p.useRef(null),se=p.useRef(null);eR(W,ce,{pageWide:!0}),p.useEffect(()=>{const Q=50+Fr.length*400,fe=setTimeout(()=>H("playing"),50),de=setTimeout(()=>H("done"),Q);return()=>{clearTimeout(fe),clearTimeout(de)}},[]),p.useEffect(()=>{if(j===void 0){document.title="Agent Inspector";return}const P=e.length===1?"1 req":`${e.length} req`;document.title=`${tn(j)} - ${P} - Agent Inspector`},[e.length,j]);const oe=p.useCallback(async P=>{z(P),q(null);try{const M=await Rw(e,P);M.ok||(u!==void 0?u({message:M.message,tone:"error"}):q(M.message))}finally{z(null)}},[e,u]),_e=p.useCallback(()=>{se.current?.click()},[]),ie=p.useCallback(P=>{const M=P.currentTarget.files?.[0];P.currentTarget.value="",!(M===void 0||d===void 0)&&(D(!0),B(null),$(null),d(M).then(Q=>{const fe=Q.skipped>0?`, skipped ${String(Q.skipped)}`:"",de=`Imported ${String(Q.imported)} logs as ${Q.sessionId}${fe}.`;u!==void 0?u({message:de,tone:"success"}):$(de)}).catch(Q=>{const fe=Q instanceof Error?Q.message:"Failed to import logs";u!==void 0?u({message:fe,tone:"error"}):B(fe)}).finally(()=>{D(!1)}))},[d,u]);p.useEffect(()=>{Z(null)},[r,o]);const ge=p.useCallback(()=>{Z(null)},[]),he=p.useMemo(()=>ZN(e),[e]),xe=p.useMemo(()=>eI(he),[he]),te=p.useMemo(()=>bI({pinnedSessionId:j,selectedSession:r,sessions:t,logs:e}),[e,j,r,t]),ue=te?.logs??[],be=te!==null&&ue.length>0,{totalIn:w,totalOut:Y}=p.useMemo(()=>Wu(ue),[ue]),U=p.useMemo(()=>QR(ue,C),[ue,C]),I=p.useMemo(()=>LA(he),[he]),A=p.useMemo(()=>qT(he),[he]),L=nI(m,e.length),ne=j!==void 0,re=be&&te!==null?tn(te.label):r==="__all__"?"All sessions":tn(r),V=p.useMemo(()=>pI({logs:e,conversationGroups:he,isLoading:x,timeDisplayFormat:g,slowResponseThresholdSeconds:v}),[he,x,e,v,g]),ae=p.useCallback(P=>{const M=A.get(P.id);M!==void 0&&Z([M,P])},[A]);return s.jsxs("div",{className:"bg-background min-h-screen w-full text-foreground",children:[s.jsxs("div",{className:"grid min-h-screen w-full grid-cols-1 lg:grid-cols-[340px_minmax(0,1fr)] xl:grid-cols-[360px_minmax(0,1fr)]",children:[s.jsx("aside",{className:"bg-background border-b lg:sticky lg:top-0 lg:h-screen lg:overflow-y-auto lg:border-b-0 lg:border-r",children:s.jsxs("div",{className:"space-y-4 p-4",children:[s.jsx(OI,{compact:!0,crabEntrancePhase:J}),s.jsx(Ei,{label:"Session",children:s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsx(Ai,{label:"Requests",value:e.length}),s.jsx(Ai,{label:"Input",value:$e(be?w:S)}),s.jsx(Ai,{label:"Output",value:$e(be?Y:E)})]})}),s.jsx(Ei,{label:"Workspace",children:s.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2",children:[s.jsx("div",{className:"truncate font-mono text-xs font-semibold text-cyan-100",title:re,children:re}),s.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:ne?"Session workspace":"Live workspace"})]})}),be&&te!==null&&s.jsx(FI,{label:te.label,logs:ue,totalIn:w,totalOut:Y,timeDisplayFormat:g,contextSummary:U,showBackLink:te.showBackLink}),be&&j!==void 0&&y.length>0&&s.jsx(Hu,{memberships:y}),s.jsx(Ei,{label:"Filters",children:s.jsxs("div",{className:"space-y-2",children:[!_&&s.jsxs(so,{value:r,onValueChange:i,children:[s.jsx(io,{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-9 w-full text-xs",children:s.jsx(oo,{placeholder:"All sessions"})}),s.jsxs(ao,{children:[s.jsx(At,{value:"__all__",children:"All sessions"}),t.map(P=>s.jsx(At,{value:P,children:tn(P)},P))]})]}),s.jsxs(so,{value:o,onValueChange:a,children:[s.jsx(io,{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-9 w-full text-xs",children:s.jsx(oo,{placeholder:"All models"})}),s.jsxs(ao,{children:[s.jsx(At,{value:"__all__",children:"All models"}),n.map(P=>s.jsx(At,{value:P,children:P},P))]})]})]})})]})}),s.jsxs("main",{className:"min-w-0",children:[s.jsxs("div",{className:"border border-border bg-background/95 shadow-sm sticky top-0 z-30 border-b px-4 py-3 lg:px-5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("div",{className:"min-w-[180px] flex-1",children:[s.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Logs"}),s.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:re})]}),d!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:se,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:ie}),s.jsx("button",{type:"button",onClick:_e,disabled:T,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-3 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",title:"Import Agent Inspector export",children:T?s.jsx("span",{children:"Importing..."}):s.jsxs(s.Fragment,{children:[s.jsx(lf,{className:"size-3.5"}),s.jsx("span",{children:"Import"})]})})]}),L.redacted&&s.jsx("button",{type:"button",onClick:()=>{oe("redacted")},disabled:R!==null,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-3 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",title:"Export redacted logs as JSON ZIP",children:R==="redacted"?s.jsx("span",{children:"Exporting..."}):s.jsxs(s.Fragment,{children:[s.jsx(wo,{className:"size-3.5"}),s.jsx("span",{children:"Export"})]})}),L.raw&&s.jsx("button",{type:"button",onClick:()=>{oe("raw")},disabled:R!==null,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-50",title:"Export raw logs without redaction",children:R==="raw"?s.jsx("span",{children:"Exporting..."}):s.jsxs(s.Fragment,{children:[s.jsx(Jy,{className:"size-3.5"}),s.jsx("span",{children:"Raw"})]})}),s.jsxs("button",{type:"button",onClick:l,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-3 text-xs text-muted-foreground transition-colors hover:text-foreground",title:"Clear all logs",children:[s.jsx(nr,{className:"size-3.5"}),s.jsx("span",{children:"Clear"})]})]}),s.jsx(Zu,{logs:e,pagination:b,embedded:!0}),u===void 0&&O!==null&&s.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:O}),u===void 0&&X!==null&&s.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:X}),u===void 0&&k!==null&&X===null&&s.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:k})]}),s.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[s.jsx(xI,{stats:V}),e.length===0?r!=="__all__"?s.jsx("div",{className:"py-16 text-center text-muted-foreground",children:s.jsxs("div",{className:"border border-border bg-card shadow-sm mx-auto max-w-xl space-y-4 rounded-[8px] px-4 py-8",children:[s.jsx("p",{className:"text-sm font-medium",children:x?"Loading session data...":"Session not found"}),s.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:tn(r)}),y.length>0&&s.jsx("div",{className:"text-left",children:s.jsx(Hu,{memberships:y})}),!x&&s.jsxs("p",{className:"text-xs",children:["This session may have been cleared or never existed."," ",_?s.jsx("a",{href:"/",className:"underline transition-colors hover:text-foreground",children:"Back to all sessions"}):s.jsx("button",{type:"button",onClick:()=>i("__all__"),className:"underline transition-colors hover:text-foreground",children:"Show all sessions"})]})]})}):s.jsx("div",{className:"py-16 text-center text-muted-foreground",children:s.jsxs("div",{className:"border border-border bg-card shadow-sm mx-auto max-w-2xl space-y-4 rounded-[8px] px-4 py-8",children:[s.jsx("p",{className:"text-sm",children:"No requests captured yet."}),s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(Ku,{command:"ANTHROPIC_BASE_URL=http://localhost:25947/proxy <your-tool>"}),s.jsx(Ku,{command:"OPENAI_BASE_URL=http://localhost:25947/proxy <your-tool>"})]}),s.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."})]})}):s.jsxs("div",{ref:ce,tabIndex:0,className:"flex flex-col gap-2 focus:outline-none",children:[s.jsx("div",{ref:W,children:s.jsx(qA,{groups:he,viewMode:f,strip:h,slowResponseThresholdSeconds:v,cacheTrends:I,onCompareWithPrevious:ae,comparisonPredecessors:A,onClearGroup:c,defaultExpanded:he.length===1,timeDisplayFormat:g})}),s.jsx("div",{className:"mt-3",children:s.jsx(Zu,{logs:e,pagination:b})})]})]})]})]}),F!==null&&s.jsx(p.Suspense,{fallback:null,children:s.jsx(v3,{left:F[0],right:F[1],leftDisplayNumber:Uu(F[0],xe),rightDisplayNumber:Uu(F[1],xe),onClose:ge})})]})}const UI=3e3;function WI(e,t){return{id:(e?.id??0)+1,message:t.message,tone:t.tone??"error"}}function HI(){const[e,t]=p.useState(null),n=p.useCallback(o=>{t(i=>WI(i,o))},[]),r=p.useCallback(()=>{t(null)},[]);return p.useEffect(()=>{if(e===null)return;const o=window.setTimeout(()=>{t(null)},UI);return()=>{window.clearTimeout(o)}},[e]),{notice:e,showToast:n,dismissToast:r}}function ZI({notice:e,onDismiss:t}){if(e===null)return null;const n=e.tone==="error",r=n?rn:Li;return s.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:s.jsxs("div",{className:le("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:[s.jsx(r,{className:le("mt-0.5 size-4 shrink-0",n?"text-red-300":"text-cyan-200")}),s.jsx("div",{className:"min-w-0 flex-1 break-words leading-5",children:e.message}),s.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:s.jsx(_o,{className:"size-3.5"})})]},e.id)})}const VI=Mt([G({type:Ce("init"),logs:me(Rr)}),G({type:Ce("update"),log:Rr})]),qI=G({logs:me(Rr),total:K().int().nonnegative(),limit:K().int().positive(),hasOlder:Fe(),hasNewer:Fe(),oldestLogId:K().int().positive().nullable(),newestLogId:K().int().positive().nullable()});function KI(e,t){const n=[];for(const r of e)for(const o of r.members)o.sessionId===t&&n.push({groupId:r.id,groupTitle:r.title,groupKind:r.kind,groupStatus:r.status,groupTask:r.task,groupProject:r.project,groupEvidence:r.evidence,member:o});return n}function GI(e){const t=new Set;for(const n of e)n.sessionId!==null&&n.sessionId!==""&&t.add(n.sessionId);return[...t]}function JI(e){const t=new Set;for(const n of e)n.model!==null&&n.model!==""&&t.add(n.model);return[...t]}function YI(e,t,n){return t==="__all__"&&n==="__all__"?e:e.filter(r=>!(t!=="__all__"&&r.sessionId!==t||n!=="__all__"&&r.model!==n))}const XI=100,QI=12,ez=1800,Xu=500,eg=100;function tz(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 nz(e,t){const n=new URLSearchParams({cursor:"1",compact:"1",limit:String(eg),sessionId:e});switch(t.kind){case"oldest":n.set("anchor","oldest");break;case"older":n.set("beforeLogId",String(t.beforeLogId));break;case"newer":n.set("afterLogId",String(t.afterLogId));break}return`/api/logs?${n.toString()}`}function jr(e){const t=new Map;for(let n=0;n<e.length;n++){const r=e[n];r!==void 0&&t.set(r.id,n)}return t}function Ri(e){return e.length<=Xu?e:e.slice(e.length-Xu)}function az({initialSessionId:e}={}){const[t,n]=p.useState([]),[r,o]=p.useState(e??"__all__"),[i,a]=p.useState("__all__"),{notice:l,showToast:c,dismissToast:u}=HI(),[d,f]=p.useState(e===void 0),[m,h]=p.useState(null),[v,g]=p.useState(e!==void 0),[x,b]=p.useState([]),[,y]=p.useTransition(),_=p.useRef(null),j=p.useRef(null),S=p.useRef(null),E=p.useRef(0),C=p.useRef(new Map),R=p.useRef([]),z=p.useRef(null),O=p.useCallback(te=>{c({message:te,tone:"error"})},[c]),q=p.useMemo(()=>YI(t,r,i),[t,r,i]),T=p.useMemo(()=>GI(t),[t]),D=p.useMemo(()=>JI(t),[t]),k=p.useCallback(()=>{z.current=null;const te=R.current;R.current=[],te.length!==0&&y(()=>{n(ue=>{const be=[...ue];for(const Y of te){const U=C.current.get(Y.id);if(U!==void 0&&be[U]?.id===Y.id){be[U]=Y;continue}const I=be.findIndex(A=>A.id===Y.id);if(I>=0){be[I]=Y;continue}be.push(Y)}const w=Ri(be);return C.current=jr(w),w})})},[y]),$=p.useCallback(te=>{R.current.push(te),z.current===null&&(z.current=setTimeout(k,XI))},[k]),X=p.useCallback(()=>{_.current&&_.current.close(),f(!1);const te=new EventSource(tz(e));_.current=te,te.onmessage=ue=>{try{const be=String(ue.data),w=JSON.parse(be),Y=VI.safeParse(w);if(!Y.success){O("Failed to parse SSE data");return}const U=Y.data;if(U.type==="init"){z.current!==null&&(clearTimeout(z.current),z.current=null),R.current=[];const I=Ri(U.logs);C.current=jr(I),n(I),f(!0),u()}else U.type==="update"&&$(U.log)}catch{O("Failed to parse SSE data")}},te.onerror=()=>{O("SSE connection lost, reconnecting..."),f(!0),te.close(),j.current!==null&&clearTimeout(j.current),j.current=setTimeout(X,3e3)}},[u,e,$,O]),B=p.useCallback(te=>{if(e===void 0)return;const ue=E.current+1;E.current=ue,g(!0),u(),an(nz(e,te),qI).then(be=>{if(E.current!==ue)return;const w=be.logs;C.current=jr(w),n(w),h(be),o(e),g(!1),u()}).catch(be=>{E.current===ue&&(n([]),h(null),g(!1),O(be instanceof Error?be.message:"Failed to load session logs"))})},[u,e,O]);p.useEffect(()=>{if(e===void 0){b([]);return}let te=!1;return fetch("/api/groups").then(async ue=>{if(!ue.ok)return null;const be=await ue.json(),w=ef.safeParse(be);return w.success?w.data.groups:null}).then(ue=>{te||ue===null||b(KI(ue,e))}).catch(()=>{te||b([])}),()=>{te=!0}},[e]),p.useEffect(()=>{e!==void 0&&B({kind:"newest"})},[e,B]),p.useEffect(()=>{if(e===void 0)return X(),()=>{_.current&&(_.current.close(),_.current=null),j.current!==null&&(clearTimeout(j.current),j.current=null),z.current!==null&&(clearTimeout(z.current),z.current=null)}},[X,e]),p.useEffect(()=>{const te=window.location.hash;if(!te.startsWith("#log-")||S.current===te)return;const ue=te.slice(1),be=Number(ue.replace(/^log-/,""));Number.isInteger(be)&&be>0&&eo({logId:be,tab:"request"});let w=!1,Y=0,U=null,I=null;const A=()=>{if(w)return;const L=document.getElementById(ue);if(L!==null){S.current=te,L.scrollIntoView({block:"center",behavior:"smooth"}),L instanceof HTMLElement&&(U=L,L.setAttribute("data-deep-link-highlight","true"),I=window.setTimeout(()=>{L.removeAttribute("data-deep-link-highlight")},ez),L.focus({preventScroll:!0}),L.getAttribute("data-nav-action")==="expand"&&L.click());return}Y+=1,Y<QI&&window.setTimeout(A,100)};return A(),()=>{w=!0,I!==null&&window.clearTimeout(I),U!==null&&U.removeAttribute("data-deep-link-highlight")}},[q.length]);const F=p.useCallback(()=>{e!==void 0&&t.length===0||(async()=>{try{const te=e===void 0?void 0:JSON.stringify({ids:t.map(be=>be.id)});if(!(await fetch("/api/logs",{method:"DELETE",...te===void 0?{}:{headers:{"Content-Type":"application/json"},body:te}})).ok){O("Failed to clear logs");return}C.current.clear(),n([]),u()}catch(te){O(te instanceof Error?te.message:"Unknown error clearing logs")}})()},[t,u,e,O]),Z=p.useCallback(te=>{te.length!==0&&(async()=>{try{if(!(await fetch("/api/logs",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:te})})).ok){O("Failed to clear group");return}const be=new Set(te);n(w=>{const Y=w.filter(U=>!be.has(U.id));return C.current=jr(Y),Y}),u()}catch(ue){O(ue instanceof Error?ue.message:"Unknown error clearing group")}})()},[u,O]),J=p.useCallback(async te=>{const ue=new FormData;ue.set("file",te);const be=await an("/api/logs/import",$1,{method:"POST",body:ue});return n(w=>{const Y=new Set(be.logs.map(A=>A.id)),U=[...w.filter(A=>!Y.has(A.id)),...be.logs].sort((A,L)=>A.id-L.id),I=Ri(U);return C.current=jr(I),I}),o(be.sessionId),a("__all__"),h(null),u(),be},[u]),{strip:H,captureMode:W,slowResponseThresholdSeconds:ce,timeDisplayFormat:se}=Ha(),oe=W,_e=p.useCallback(()=>{B({kind:"oldest"})},[B]),ie=p.useCallback(()=>{B({kind:"newest"})},[B]),ge=p.useCallback(()=>{const te=t[0],ue=m?.oldestLogId??te?.id??null;ue!==null&&B({kind:"older",beforeLogId:ue})},[t,B,m]),he=p.useCallback(()=>{const te=t[t.length-1],ue=m?.newestLogId??te?.id??null;ue!==null&&B({kind:"newer",afterLogId:ue})},[t,B,m]),xe=p.useMemo(()=>{if(e!==void 0)return{isLoading:v,total:m?.total??null,pageSize:m?.limit??eg,hasOlder:m?.hasOlder??!1,hasNewer:m?.hasNewer??!1,oldestLogId:m?.oldestLogId??null,newestLogId:m?.newestLogId??null,onOldest:_e,onOlder:ge,onNewer:he,onNewest:ie}},[e,ie,he,ge,_e,m,v]);return s.jsxs(s.Fragment,{children:[s.jsx(ZI,{notice:l,onDismiss:u}),s.jsx(mw,{}),s.jsx(BI,{logs:q,sessions:T,models:D,selectedSession:r,selectedModel:i,onSessionChange:o,onModelChange:a,onClearAll:F,onClearGroup:Z,onNotify:c,onImportLogs:e===void 0?J:void 0,isLoading:e===void 0?!d:v,pagination:xe,sessionMemberships:x,viewMode:oe,captureMode:W,strip:H,slowResponseThresholdSeconds:ce,timeDisplayFormat:se,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{X3 as $,K as A,Be as B,$y as C,Hr as D,me as E,eo as F,Fe as G,N as H,Rr as I,WR as J,g2 as K,j3 as L,_2 as M,nR as N,tR as O,az as P,Cf as Q,D2 as R,iR as S,om as T,iz as U,st as V,Ee as W,_o as X,Y3 as Y,oz as Z,rf as _,HN as a,Q3 as a0,Ja as a1,ca as a2,to as a3,Pr as a4,ke as a5,rn as a6,Tk as a7,ft as a8,x3 as a9,my as aa,le as b,pe as c,Di as d,af as e,$e as f,em as g,bt as h,Ge as i,Nt as j,Kt as k,Zr as l,Vr as m,qr as n,O2 as o,im as p,ht as q,Lr as r,mt as s,Se as t,Nf as u,Je as v,Oe as w,Me as x,Le as y,G as z};