@tonyclaw/agent-inspector 3.0.9 → 3.0.11

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 (38) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/{CompareDrawer-CJKL4LMm.js → CompareDrawer-gb4FHIDP.js} +1 -1
  3. package/.output/public/assets/ProxyViewerContainer-yqasBIbY.js +106 -0
  4. package/.output/public/assets/{ReplayDialog-BYanl-a_.js → ReplayDialog-uXfMIorn.js} +1 -1
  5. package/.output/public/assets/{RequestAnatomy-DvPz1jqE.js → RequestAnatomy-NqGFn7lk.js} +1 -1
  6. package/.output/public/assets/{ResponseView-sZnxp9GN.js → ResponseView-BWSWdjPl.js} +2 -2
  7. package/.output/public/assets/{StreamingChunkSequence-G-tiYiBd.js → StreamingChunkSequence-qeCLglzr.js} +1 -1
  8. package/.output/public/assets/{_sessionId-_hDcsmXq.js → _sessionId-COT-xg31.js} +1 -1
  9. package/.output/public/assets/index-BIgsQvaF.css +1 -0
  10. package/.output/public/assets/{index-SuOSQb2_.js → index-CKVD6xzC.js} +1 -1
  11. package/.output/public/assets/index-swjqFLcG.js +1 -0
  12. package/.output/public/assets/{json-viewer-yQdhgjaw.js → json-viewer-ux5usy0f.js} +1 -1
  13. package/.output/public/assets/{main-CgjcDxjR.js → main-BM5Sp2nO.js} +2 -2
  14. package/.output/server/_libs/lucide-react.mjs +2 -2
  15. package/.output/server/{_sessionId-BGISf2En.mjs → _sessionId-8D0eTdRJ.mjs} +2 -2
  16. package/.output/server/_ssr/{CompareDrawer-s-UF9gW3.mjs → CompareDrawer-Hcs0aQWl.mjs} +3 -3
  17. package/.output/server/_ssr/{ProxyViewerContainer-C0Sbz9ED.mjs → ProxyViewerContainer-D2CkbvcS.mjs} +185 -246
  18. package/.output/server/_ssr/{ReplayDialog-DvS8gvJr.mjs → ReplayDialog-O2R9y9xD.mjs} +3 -3
  19. package/.output/server/_ssr/{RequestAnatomy-BwhWglJL.mjs → RequestAnatomy-DkvrjK-3.mjs} +2 -2
  20. package/.output/server/_ssr/{ResponseView-wBVreqQf.mjs → ResponseView-CPcMs3Um.mjs} +2 -2
  21. package/.output/server/_ssr/{StreamingChunkSequence-Dr6eg-MJ.mjs → StreamingChunkSequence-FlBdqDP3.mjs} +2 -2
  22. package/.output/server/_ssr/{index-B98Wia1X.mjs → index-ChG0L62e.mjs} +2 -2
  23. package/.output/server/_ssr/index.mjs +2 -2
  24. package/.output/server/_ssr/{json-viewer-D7L8y0FH.mjs → json-viewer-Bb1g2nec.mjs} +2 -2
  25. package/.output/server/_ssr/{router-g9mo0nWT.mjs → router-840N-dk9.mjs} +21 -12
  26. package/.output/server/{_tanstack-start-manifest_v-CbGc-o50.mjs → _tanstack-start-manifest_v-Qi0D1Tl0.mjs} +1 -1
  27. package/.output/server/index.mjs +70 -70
  28. package/package.json +1 -1
  29. package/src/components/ProxyViewerContainer.tsx +10 -2
  30. package/src/components/providers/ProviderCard.tsx +98 -136
  31. package/src/components/providers/ProvidersPanel.tsx +61 -106
  32. package/src/components/providers/SettingsDialog.tsx +17 -22
  33. package/src/components/proxy-viewer/LogEntryHeader.tsx +17 -43
  34. package/src/components/ui/tooltip.tsx +1 -1
  35. package/src/routes/api/logs.ts +14 -5
  36. package/.output/public/assets/ProxyViewerContainer-DBUy29O-.js +0 -106
  37. package/.output/public/assets/index-DAPAWsAd.js +0 -1
  38. package/.output/public/assets/index-DspnLqUW.css +0 -1
@@ -1,106 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CompareDrawer-CJKL4LMm.js","assets/main-CgjcDxjR.js","assets/ReplayDialog-BYanl-a_.js","assets/ResponseView-sZnxp9GN.js","assets/RequestAnatomy-DvPz1jqE.js","assets/StreamingChunkSequence-G-tiYiBd.js","assets/json-viewer-yQdhgjaw.js"])))=>i.map(i=>d[i]);
2
- import{u as rn,a as _d,r as p,j as s,c as ms,g as L0,b as kd,d as ss,e as D0,f as ht,h as jd,_ as Wn}from"./main-CgjcDxjR.js";function te(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 h=d[f];h in l||(l[h]=u[h].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 fr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Sd extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Cd={};function vn(e){return Cd}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 ea(e,t){return typeof t=="bigint"?t.toString():t}function Lo(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function qa(e){return e==null}function Za(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function $0(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 ic=Symbol("evaluating");function Oe(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ic)return r===void 0&&(r=ic,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Hn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function kn(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function ac(e){return JSON.stringify(e)}function F0(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Td="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Zr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const B0=Lo(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function xr(e){if(Zr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Zr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ed(e){return xr(e)?{...e}:Array.isArray(e)?[...e]:e}const U0=new Set(["string","number","symbol"]);function br(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jn(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 W0(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const H0={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 V0(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=kn(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 Hn(this,"shape",a),a},checks:[]});return jn(e,i)}function q0(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=kn(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 Hn(this,"shape",a),a},checks:[]});return jn(e,i)}function Z0(e,t){if(!xr(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=kn(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Hn(this,"shape",i),i}});return jn(e,o)}function G0(e,t){if(!xr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=kn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Hn(this,"shape",r),r}});return jn(e,n)}function K0(e,t){const n=kn(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Hn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return jn(e,n)}function J0(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=kn(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 Hn(this,"shape",c),c},checks:[]});return jn(t,a)}function Y0(e,t,n){const r=kn(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 Hn(this,"shape",i),i}});return jn(t,r)}function cr(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 ur(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function gs(e){return typeof e=="string"?e:e?.message}function yn(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=gs(e.inst?._zod.def?.error?.(e))??gs(t?.error?.(e))??gs(n.customError?.(e))??gs(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Ga(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Gr(...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,ea,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Rd=te("$ZodError",Ad),Id=te("$ZodError",Ad,{Parent:Error});function X0(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 Q0(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 Ka=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 fr;if(a.issues.length){const l=new(o?.Err??e)(a.issues.map(c=>yn(c,i,vn())));throw Td(l,o?.callee),l}return a.value},Ja=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=>yn(c,i,vn())));throw Td(l,o?.callee),l}return a.value},Do=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 fr;return i.issues.length?{success:!1,error:new(e??Rd)(i.issues.map(a=>yn(a,o,vn())))}:{success:!0,data:i.value}},eg=Do(Id),$o=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=>yn(a,o,vn())))}:{success:!0,data:i.value}},tg=$o(Id),ng=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ka(e)(t,n,o)},rg=e=>(t,n,r)=>Ka(e)(t,n,r),sg=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ja(e)(t,n,o)},og=e=>async(t,n,r)=>Ja(e)(t,n,r),ig=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Do(e)(t,n,o)},ag=e=>(t,n,r)=>Do(e)(t,n,r),lg=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return $o(e)(t,n,o)},cg=e=>async(t,n,r)=>$o(e)(t,n,r),ug=/^[cC][^\s-]{8,}$/,dg=/^[0-9a-z]+$/,fg=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,pg=/^[0-9a-vA-V]{20}$/,hg=/^[A-Za-z0-9]{27}$/,mg=/^[a-zA-Z0-9_-]{21}$/,gg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,xg=/^([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})$/,lc=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)$/,bg=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,vg="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function yg(){return new RegExp(vg,"u")}const wg=/^(?:(?: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])$/,_g=/^(([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}|:))$/,kg=/^((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])$/,jg=/^(([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])$/,Sg=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,zd=/^[A-Za-z0-9_-]*$/,Cg=/^\+[1-9]\d{6,14}$/,Od="(?:(?:\\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])))",Ng=new RegExp(`^${Od}$`);function Pd(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 Tg(e){return new RegExp(`^${Pd(e)}$`)}function Eg(e){const t=Pd({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(`^${Od}T(?:${r})$`)}const Ag=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Rg=/^-?\d+$/,Md=/^-?\d+(?:\.\d+)?$/,Ig=/^(?:true|false)$/i,zg=/^null$/i,Og=/^[^A-Z]*$/,Pg=/^[^a-z]*$/,mt=te("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ld={number:"number",bigint:"bigint",object:"date"},Dd=te("$ZodCheckLessThan",(e,t)=>{mt.init(e,t);const n=Ld[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})}}),$d=te("$ZodCheckGreaterThan",(e,t)=>{mt.init(e,t);const n=Ld[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})}}),Mg=te("$ZodCheckMultipleOf",(e,t)=>{mt.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):$0(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Lg=te("$ZodCheckNumberFormat",(e,t)=>{mt.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=H0[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=Rg)}),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})}}),Dg=te("$ZodCheckMaxLength",(e,t)=>{var n;mt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!qa(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=Ga(o);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),$g=te("$ZodCheckMinLength",(e,t)=>{var n;mt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!qa(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=Ga(o);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Fg=te("$ZodCheckLengthEquals",(e,t)=>{var n;mt.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!qa(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=Ga(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})}}),Fo=te("$ZodCheckStringFormat",(e,t)=>{var n,r;mt.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=()=>{})}),Bg=te("$ZodCheckRegex",(e,t)=>{Fo.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})}}),Ug=te("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Og),Fo.init(e,t)}),Wg=te("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Pg),Fo.init(e,t)}),Hg=te("$ZodCheckIncludes",(e,t)=>{mt.init(e,t);const n=br(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})}}),Vg=te("$ZodCheckStartsWith",(e,t)=>{mt.init(e,t);const n=new RegExp(`^${br(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})}}),qg=te("$ZodCheckEndsWith",(e,t)=>{mt.init(e,t);const n=new RegExp(`.*${br(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})}}),Zg=te("$ZodCheckOverwrite",(e,t)=>{mt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Gg{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
- `).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 Kg={major:4,minor:3,patch:6},Ve=te("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Kg;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=cr(a),d;for(const f of l){if(f._zod.def.when){if(!f._zod.def.when(a))continue}else if(u)continue;const h=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&c?.async===!1)throw new fr;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==h&&(u||(u=cr(a,h)))});else{if(a.issues.length===h)continue;u||(u=cr(a,h))}}return d?d.then(()=>a):a},i=(a,l,c)=>{if(cr(a))return a.aborted=!0,a;const u=o(l,r,c);if(u instanceof Promise){if(c.async===!1)throw new fr;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 fr;return c.then(u=>o(u,r,l))}return o(c,r,l)}}Oe(e,"~standard",()=>({validate:o=>{try{const i=eg(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return tg(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Ya=te("$ZodString",(e,t)=>{Ve.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Ag(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=te("$ZodStringFormat",(e,t)=>{Fo.init(e,t),Ya.init(e,t)}),Jg=te("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=xg),Ze.init(e,t)}),Yg=te("$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=lc(r))}else t.pattern??(t.pattern=lc());Ze.init(e,t)}),Xg=te("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=bg),Ze.init(e,t)}),Qg=te("$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})}}}),ex=te("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=yg()),Ze.init(e,t)}),tx=te("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=mg),Ze.init(e,t)}),nx=te("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ug),Ze.init(e,t)}),rx=te("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=dg),Ze.init(e,t)}),sx=te("$ZodULID",(e,t)=>{t.pattern??(t.pattern=fg),Ze.init(e,t)}),ox=te("$ZodXID",(e,t)=>{t.pattern??(t.pattern=pg),Ze.init(e,t)}),ix=te("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=hg),Ze.init(e,t)}),ax=te("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Eg(t)),Ze.init(e,t)}),lx=te("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ng),Ze.init(e,t)}),cx=te("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Tg(t)),Ze.init(e,t)}),ux=te("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=gg),Ze.init(e,t)}),dx=te("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=wg),Ze.init(e,t),e._zod.bag.format="ipv4"}),fx=te("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=_g),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})}}}),px=te("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=kg),Ze.init(e,t)}),hx=te("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=jg),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 Fd(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const mx=te("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Sg),Ze.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Fd(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function gx(e){if(!zd.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Fd(n)}const xx=te("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=zd),Ze.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{gx(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),bx=te("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Cg),Ze.init(e,t)});function vx(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 yx=te("$ZodJWT",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{vx(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Bd=te("$ZodNumber",(e,t)=>{Ve.init(e,t),e._zod.pattern=e._zod.bag.pattern??Md,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}}),wx=te("$ZodNumberFormat",(e,t)=>{Lg.init(e,t),Bd.init(e,t)}),_x=te("$ZodBoolean",(e,t)=>{Ve.init(e,t),e._zod.pattern=Ig,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}}),kx=te("$ZodNull",(e,t)=>{Ve.init(e,t),e._zod.pattern=zg,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}}),jx=te("$ZodUnknown",(e,t)=>{Ve.init(e,t),e._zod.parse=n=>n}),Sx=te("$ZodNever",(e,t)=>{Ve.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function cc(e,t,n){e.issues.length&&t.issues.push(...ur(n,e.issues)),t.value[n]=e.value}const Cx=te("$ZodArray",(e,t)=>{Ve.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=>cc(u,n,a))):cc(c,n,a)}return i.length?Promise.all(i).then(()=>n):n}});function to(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...ur(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Ud(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=W0(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Wd(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 h=c.run({value:t[f],issues:[]},r);h instanceof Promise?e.push(h.then(m=>to(m,n,f,t,d))):to(h,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 Nx=te("$ZodObject",(e,t)=>{if(Ve.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=Lo(()=>Ud(t));Oe(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=Zr,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 h of a.keys){const m=f[h],v=m._zod.optout==="optional",g=m._zod.run({value:u[h],issues:[]},c);g instanceof Promise?d.push(g.then(x=>to(x,l,h,u,v))):to(g,l,h,u,v)}return i?Wd(d,u,l,c,r.value,e):d.length?Promise.all(d).then(()=>l):l}}),Tx=te("$ZodObjectJIT",(e,t)=>{Nx.init(e,t);const n=e._zod.parse,r=Lo(()=>Ud(t)),o=h=>{const m=new Gg(["shape","payload","ctx"]),v=r.value,g=k=>{const j=ac(k);return`shape[${j}]._zod.run({ value: input[${j}], issues: [] }, ctx)`};m.write("const input = payload.value;");const x=Object.create(null);let b=0;for(const k of v.keys)x[k]=`key_${b++}`;m.write("const newResult = {};");for(const k of v.keys){const j=x[k],S=ac(k),N=h[k]?._zod?.optout==="optional";m.write(`const ${j} = ${g(k)};`),N?m.write(`
5
- if (${j}.issues.length) {
6
- if (${S} in input) {
7
- payload.issues = payload.issues.concat(${j}.issues.map(iss => ({
8
- ...iss,
9
- path: iss.path ? [${S}, ...iss.path] : [${S}]
10
- })));
11
- }
12
- }
13
-
14
- if (${j}.value === undefined) {
15
- if (${S} in input) {
16
- newResult[${S}] = undefined;
17
- }
18
- } else {
19
- newResult[${S}] = ${j}.value;
20
- }
21
-
22
- `):m.write(`
23
- if (${j}.issues.length) {
24
- payload.issues = payload.issues.concat(${j}.issues.map(iss => ({
25
- ...iss,
26
- path: iss.path ? [${S}, ...iss.path] : [${S}]
27
- })));
28
- }
29
-
30
- if (${j}.value === undefined) {
31
- if (${S} in input) {
32
- newResult[${S}] = undefined;
33
- }
34
- } else {
35
- newResult[${S}] = ${j}.value;
36
- }
37
-
38
- `)}m.write("payload.value = newResult;"),m.write("return payload;");const y=m.compile();return(k,j)=>y(h,k,j)};let i;const a=Zr,l=!Cd.jitless,u=l&&B0.value,d=t.catchall;let f;e._zod.parse=(h,m)=>{f??(f=r.value);const v=h.value;return a(v)?l&&u&&m?.async===!1&&m.jitless!==!0?(i||(i=o(t.shape)),h=i(h,m),d?Wd([],v,h,m,f,e):h):n(h,m):(h.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),h)}});function uc(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=>!cr(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=>yn(a,r,vn())))}),t)}const Hd=te("$ZodUnion",(e,t)=>{Ve.init(e,t),Oe(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),Oe(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Oe(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),Oe(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=>Za(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=>uc(c,o,e,i)):uc(l,o,e,i)}}),Ex=te("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Hd.init(e,t);const n=e._zod.parse;Oe(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=Lo(()=>{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(!Zr(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)}}),Ax=te("$ZodIntersection",(e,t)=>{Ve.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])=>dc(n,c,u)):dc(n,i,a)}});function ta(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(xr(e)&&xr(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=ta(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=ta(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 dc(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}),cr(e))return e;const a=ta(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 Rx=te("$ZodRecord",(e,t)=>{Ve.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!xr(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(...ur(u,f.issues)),n.value[u]=f.value})):(d.issues.length&&n.issues.push(...ur(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"&&Md.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=>yn(f,r,vn())),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(...ur(l,f.issues)),n.value[c.value]=f.value})):(d.issues.length&&n.issues.push(...ur(l,d.issues)),n.value[c.value]=d.value)}}return i.length?Promise.all(i).then(()=>n):n}}),Ix=te("$ZodEnum",(e,t)=>{Ve.init(e,t);const n=Nd(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>U0.has(typeof o)).map(o=>typeof o=="string"?br(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}}),zx=te("$ZodLiteral",(e,t)=>{if(Ve.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"?br(r):r?br(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}}),Ox=te("$ZodTransform",(e,t)=>{Ve.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Sd(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 fr;return n.value=o,n}});function fc(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Vd=te("$ZodOptional",(e,t)=>{Ve.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Oe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Oe(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Za(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=>fc(i,n.value)):fc(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Px=te("$ZodExactOptional",(e,t)=>{Vd.init(e,t),Oe(e._zod,"values",()=>t.innerType._zod.values),Oe(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Mx=te("$ZodNullable",(e,t)=>{Ve.init(e,t),Oe(e._zod,"optin",()=>t.innerType._zod.optin),Oe(e._zod,"optout",()=>t.innerType._zod.optout),Oe(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Za(n.source)}|null)$`):void 0}),Oe(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)}),Lx=te("$ZodDefault",(e,t)=>{Ve.init(e,t),e._zod.optin="optional",Oe(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=>pc(i,t)):pc(o,t)}});function pc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Dx=te("$ZodPrefault",(e,t)=>{Ve.init(e,t),e._zod.optin="optional",Oe(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))}),$x=te("$ZodNonOptional",(e,t)=>{Ve.init(e,t),Oe(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=>hc(i,e)):hc(o,e)}});function hc(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 Fx=te("$ZodCatch",(e,t)=>{Ve.init(e,t),Oe(e._zod,"optin",()=>t.innerType._zod.optin),Oe(e._zod,"optout",()=>t.innerType._zod.optout),Oe(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=>yn(a,r,vn()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>yn(i,r,vn()))},input:n.value}),n.issues=[]),n)}}),Bx=te("$ZodPipe",(e,t)=>{Ve.init(e,t),Oe(e._zod,"values",()=>t.in._zod.values),Oe(e._zod,"optin",()=>t.in._zod.optin),Oe(e._zod,"optout",()=>t.out._zod.optout),Oe(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=>xs(a,t.in,r)):xs(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>xs(i,t.out,r)):xs(o,t.out,r)}});function xs(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Ux=te("$ZodReadonly",(e,t)=>{Ve.init(e,t),Oe(e._zod,"propValues",()=>t.innerType._zod.propValues),Oe(e._zod,"values",()=>t.innerType._zod.values),Oe(e._zod,"optin",()=>t.innerType?._zod?.optin),Oe(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(mc):mc(o)}});function mc(e){return e.value=Object.freeze(e.value),e}const Wx=te("$ZodLazy",(e,t)=>{Ve.init(e,t),Oe(e._zod,"innerType",()=>t.getter()),Oe(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),Oe(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),Oe(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),Oe(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Hx=te("$ZodCustom",(e,t)=>{mt.init(e,t),Ve.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=>gc(i,n,r,e));gc(o,n,r,e)}});function gc(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(Gr(o))}}var xc;class Vx{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 qx(){return new Vx}(xc=globalThis).__zod_globalRegistry??(xc.__zod_globalRegistry=qx());const Wr=globalThis.__zod_globalRegistry;function Zx(e,t){return new e({type:"string",...we(t)})}function Gx(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...we(t)})}function bc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...we(t)})}function Kx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...we(t)})}function Jx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...we(t)})}function Yx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...we(t)})}function Xx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...we(t)})}function Qx(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...we(t)})}function e1(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...we(t)})}function t1(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...we(t)})}function n1(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...we(t)})}function r1(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...we(t)})}function s1(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...we(t)})}function o1(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...we(t)})}function i1(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...we(t)})}function a1(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...we(t)})}function l1(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...we(t)})}function c1(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...we(t)})}function u1(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...we(t)})}function d1(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...we(t)})}function f1(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...we(t)})}function p1(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...we(t)})}function h1(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...we(t)})}function m1(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...we(t)})}function g1(e,t){return new e({type:"string",format:"date",check:"string_format",...we(t)})}function x1(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...we(t)})}function b1(e,t){return new e({type:"string",format:"duration",check:"string_format",...we(t)})}function v1(e,t){return new e({type:"number",checks:[],...we(t)})}function y1(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...we(t)})}function w1(e,t){return new e({type:"boolean",...we(t)})}function _1(e,t){return new e({type:"null",...we(t)})}function k1(e){return new e({type:"unknown"})}function j1(e,t){return new e({type:"never",...we(t)})}function vc(e,t){return new Dd({check:"less_than",...we(t),value:e,inclusive:!1})}function xi(e,t){return new Dd({check:"less_than",...we(t),value:e,inclusive:!0})}function yc(e,t){return new $d({check:"greater_than",...we(t),value:e,inclusive:!1})}function bi(e,t){return new $d({check:"greater_than",...we(t),value:e,inclusive:!0})}function wc(e,t){return new Mg({check:"multiple_of",...we(t),value:e})}function qd(e,t){return new Dg({check:"max_length",...we(t),maximum:e})}function no(e,t){return new $g({check:"min_length",...we(t),minimum:e})}function Zd(e,t){return new Fg({check:"length_equals",...we(t),length:e})}function S1(e,t){return new Bg({check:"string_format",format:"regex",...we(t),pattern:e})}function C1(e){return new Ug({check:"string_format",format:"lowercase",...we(e)})}function N1(e){return new Wg({check:"string_format",format:"uppercase",...we(e)})}function T1(e,t){return new Hg({check:"string_format",format:"includes",...we(t),includes:e})}function E1(e,t){return new Vg({check:"string_format",format:"starts_with",...we(t),prefix:e})}function A1(e,t){return new qg({check:"string_format",format:"ends_with",...we(t),suffix:e})}function Sr(e){return new Zg({check:"overwrite",tx:e})}function R1(e){return Sr(t=>t.normalize(e))}function I1(){return Sr(e=>e.trim())}function z1(){return Sr(e=>e.toLowerCase())}function O1(){return Sr(e=>e.toUpperCase())}function P1(){return Sr(e=>F0(e))}function M1(e,t,n){return new e({type:"array",element:t,...we(n)})}function L1(e,t,n){return new e({type:"custom",check:"custom",fn:t,...we(n)})}function D1(e){const t=$1(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Gr(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(Gr(o))}},e(n.value,n)));return t}function $1(e,t){const n=new mt({check:"custom",...we(t)});return n._zod.check=e,n}function Gd(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??Wr,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 Je(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 h=a.schema,m=t.processors[o.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(e,t,h,d)}const f=e._zod.parent;f&&(a.ref||(a.ref=f),Je(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"&&ut(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 Kd(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,h=e.external.uri??(v=>v);if(f)return{ref:h(f)};const m=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=m,{defId:m,ref:`${h("__shared")}#/${l}/${m}`}}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
-
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 Jd(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 h=e.seen.get(d),m=h.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(m)):Object.assign(c,m),Object.assign(c,u),a._zod.parent===d)for(const g in c)g==="$ref"||g==="allOf"||g in u||delete c[g];if(m.$ref&&h.def)for(const g in c)g==="$ref"||g==="allOf"||g in h.def&&JSON.stringify(c[g])===JSON.stringify(h.def[g])&&delete c[g]}const f=a._zod.parent;if(f&&f!==d){r(f);const h=e.seen.get(f);if(h?.schema.$ref&&(c.$ref=h.schema.$ref,h.def))for(const m in c)m==="$ref"||m==="allOf"||m in h.def&&JSON.stringify(c[m])===JSON.stringify(h.def[m])&&delete c[m]}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:ro(t,"input",e.processors),output:ro(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function ut(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 ut(r.element,n);if(r.type==="set")return ut(r.valueType,n);if(r.type==="lazy")return ut(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 ut(r.innerType,n);if(r.type==="intersection")return ut(r.left,n)||ut(r.right,n);if(r.type==="record"||r.type==="map")return ut(r.keyType,n)||ut(r.valueType,n);if(r.type==="pipe")return ut(r.in,n)||ut(r.out,n);if(r.type==="object"){for(const o in r.shape)if(ut(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(ut(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(ut(o,n))return!0;return!!(r.rest&&ut(r.rest,n))}return!1}const F1=(e,t={})=>n=>{const r=Gd({...n,processors:t});return Je(e,r),Kd(r,e),Jd(r,e)},ro=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},a=Gd({...o??{},target:i,io:t,processors:n});return Je(e,a),Kd(a,e),Jd(a,e)},B1={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},U1=(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=B1[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}))])}},W1=(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)},H1=(e,t,n,r)=>{n.type="boolean"},V1=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},q1=(e,t,n,r)=>{n.not={}},Z1=(e,t,n,r)=>{},G1=(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},K1=(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},J1=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Y1=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},X1=(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=Je(i.element,t,{...r,path:[...r.path,"items"]})},Q1=(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]=Je(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=Je(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},eb=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((l,c)=>Je(l,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=a:n.anyOf=a},tb=(e,t,n,r)=>{const o=e._zod.def,i=Je(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=Je(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},nb=(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=Je(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=Je(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=Je(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)}},rb=(e,t,n,r)=>{const o=e._zod.def,i=Je(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"}]},sb=(e,t,n,r)=>{const o=e._zod.def;Je(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},ob=(e,t,n,r)=>{const o=e._zod.def;Je(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},ib=(e,t,n,r)=>{const o=e._zod.def;Je(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)))},ab=(e,t,n,r)=>{const o=e._zod.def;Je(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},lb=(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;Je(i,t,r);const a=t.seen.get(e);a.ref=i},cb=(e,t,n,r)=>{const o=e._zod.def;Je(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Yd=(e,t,n,r)=>{const o=e._zod.def;Je(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},ub=(e,t,n,r)=>{const o=e._zod.innerType;Je(o,t,r);const i=t.seen.get(e);i.ref=o},db=te("ZodISODateTime",(e,t)=>{ax.init(e,t),Ge.init(e,t)});function fb(e){return m1(db,e)}const pb=te("ZodISODate",(e,t)=>{lx.init(e,t),Ge.init(e,t)});function hb(e){return g1(pb,e)}const mb=te("ZodISOTime",(e,t)=>{cx.init(e,t),Ge.init(e,t)});function gb(e){return x1(mb,e)}const xb=te("ZodISODuration",(e,t)=>{ux.init(e,t),Ge.init(e,t)});function bb(e){return b1(xb,e)}const vb=(e,t)=>{Rd.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Q0(e,n)},flatten:{value:n=>X0(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,ea,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,ea,2)}},isEmpty:{get(){return e.issues.length===0}}})},Nt=te("ZodError",vb,{Parent:Error}),yb=Ka(Nt),wb=Ja(Nt),_b=Do(Nt),kb=$o(Nt),jb=ng(Nt),Sb=rg(Nt),Cb=sg(Nt),Nb=og(Nt),Tb=ig(Nt),Eb=ag(Nt),Ab=lg(Nt),Rb=cg(Nt),qe=te("ZodType",(e,t)=>(Ve.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ro(e,"input"),output:ro(e,"output")}}),e.toJSONSchema=F1(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(kn(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)=>jn(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>yb(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>_b(e,n,r),e.parseAsync=async(n,r)=>wb(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>kb(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>jb(e,n,r),e.decode=(n,r)=>Sb(e,n,r),e.encodeAsync=async(n,r)=>Cb(e,n,r),e.decodeAsync=async(n,r)=>Nb(e,n,r),e.safeEncode=(n,r)=>Tb(e,n,r),e.safeDecode=(n,r)=>Eb(e,n,r),e.safeEncodeAsync=async(n,r)=>Ab(e,n,r),e.safeDecodeAsync=async(n,r)=>Rb(e,n,r),e.refine=(n,r)=>e.check(Nv(n,r)),e.superRefine=n=>e.check(Tv(n)),e.overwrite=n=>e.check(Sr(n)),e.optional=()=>jc(e),e.exactOptional=()=>fv(e),e.nullable=()=>Sc(e),e.nullish=()=>jc(Sc(e)),e.nonoptional=n=>bv(e,n),e.array=()=>fe(e),e.or=n=>Kt([e,n]),e.and=n=>iv(e,n),e.transform=n=>Cc(e,uv(n)),e.default=n=>mv(e,n),e.prefault=n=>xv(e,n),e.catch=n=>yv(e,n),e.pipe=n=>Cc(e,n),e.readonly=()=>kv(e),e.describe=n=>{const r=e.clone();return Wr.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return Wr.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Wr.get(e);const r=e.clone();return Wr.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Xd=te("_ZodString",(e,t)=>{Ya.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(r,o,i)=>U1(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(S1(...r)),e.includes=(...r)=>e.check(T1(...r)),e.startsWith=(...r)=>e.check(E1(...r)),e.endsWith=(...r)=>e.check(A1(...r)),e.min=(...r)=>e.check(no(...r)),e.max=(...r)=>e.check(qd(...r)),e.length=(...r)=>e.check(Zd(...r)),e.nonempty=(...r)=>e.check(no(1,...r)),e.lowercase=r=>e.check(C1(r)),e.uppercase=r=>e.check(N1(r)),e.trim=()=>e.check(I1()),e.normalize=(...r)=>e.check(R1(...r)),e.toLowerCase=()=>e.check(z1()),e.toUpperCase=()=>e.check(O1()),e.slugify=()=>e.check(P1())}),Ib=te("ZodString",(e,t)=>{Ya.init(e,t),Xd.init(e,t),e.email=n=>e.check(Gx(zb,n)),e.url=n=>e.check(Qx(Ob,n)),e.jwt=n=>e.check(h1(Kb,n)),e.emoji=n=>e.check(e1(Pb,n)),e.guid=n=>e.check(bc(_c,n)),e.uuid=n=>e.check(Kx(bs,n)),e.uuidv4=n=>e.check(Jx(bs,n)),e.uuidv6=n=>e.check(Yx(bs,n)),e.uuidv7=n=>e.check(Xx(bs,n)),e.nanoid=n=>e.check(t1(Mb,n)),e.guid=n=>e.check(bc(_c,n)),e.cuid=n=>e.check(n1(Lb,n)),e.cuid2=n=>e.check(r1(Db,n)),e.ulid=n=>e.check(s1($b,n)),e.base64=n=>e.check(d1(qb,n)),e.base64url=n=>e.check(f1(Zb,n)),e.xid=n=>e.check(o1(Fb,n)),e.ksuid=n=>e.check(i1(Bb,n)),e.ipv4=n=>e.check(a1(Ub,n)),e.ipv6=n=>e.check(l1(Wb,n)),e.cidrv4=n=>e.check(c1(Hb,n)),e.cidrv6=n=>e.check(u1(Vb,n)),e.e164=n=>e.check(p1(Gb,n)),e.datetime=n=>e.check(fb(n)),e.date=n=>e.check(hb(n)),e.time=n=>e.check(gb(n)),e.duration=n=>e.check(bb(n))});function C(e){return Zx(Ib,e)}const Ge=te("ZodStringFormat",(e,t)=>{Ze.init(e,t),Xd.init(e,t)}),zb=te("ZodEmail",(e,t)=>{Xg.init(e,t),Ge.init(e,t)}),_c=te("ZodGUID",(e,t)=>{Jg.init(e,t),Ge.init(e,t)}),bs=te("ZodUUID",(e,t)=>{Yg.init(e,t),Ge.init(e,t)}),Ob=te("ZodURL",(e,t)=>{Qg.init(e,t),Ge.init(e,t)}),Pb=te("ZodEmoji",(e,t)=>{ex.init(e,t),Ge.init(e,t)}),Mb=te("ZodNanoID",(e,t)=>{tx.init(e,t),Ge.init(e,t)}),Lb=te("ZodCUID",(e,t)=>{nx.init(e,t),Ge.init(e,t)}),Db=te("ZodCUID2",(e,t)=>{rx.init(e,t),Ge.init(e,t)}),$b=te("ZodULID",(e,t)=>{sx.init(e,t),Ge.init(e,t)}),Fb=te("ZodXID",(e,t)=>{ox.init(e,t),Ge.init(e,t)}),Bb=te("ZodKSUID",(e,t)=>{ix.init(e,t),Ge.init(e,t)}),Ub=te("ZodIPv4",(e,t)=>{dx.init(e,t),Ge.init(e,t)}),Wb=te("ZodIPv6",(e,t)=>{fx.init(e,t),Ge.init(e,t)}),Hb=te("ZodCIDRv4",(e,t)=>{px.init(e,t),Ge.init(e,t)}),Vb=te("ZodCIDRv6",(e,t)=>{hx.init(e,t),Ge.init(e,t)}),qb=te("ZodBase64",(e,t)=>{mx.init(e,t),Ge.init(e,t)}),Zb=te("ZodBase64URL",(e,t)=>{xx.init(e,t),Ge.init(e,t)}),Gb=te("ZodE164",(e,t)=>{bx.init(e,t),Ge.init(e,t)}),Kb=te("ZodJWT",(e,t)=>{yx.init(e,t),Ge.init(e,t)}),Qd=te("ZodNumber",(e,t)=>{Bd.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(r,o,i)=>W1(e,r,o),e.gt=(r,o)=>e.check(yc(r,o)),e.gte=(r,o)=>e.check(bi(r,o)),e.min=(r,o)=>e.check(bi(r,o)),e.lt=(r,o)=>e.check(vc(r,o)),e.lte=(r,o)=>e.check(xi(r,o)),e.max=(r,o)=>e.check(xi(r,o)),e.int=r=>e.check(kc(r)),e.safe=r=>e.check(kc(r)),e.positive=r=>e.check(yc(0,r)),e.nonnegative=r=>e.check(bi(0,r)),e.negative=r=>e.check(vc(0,r)),e.nonpositive=r=>e.check(xi(0,r)),e.multipleOf=(r,o)=>e.check(wc(r,o)),e.step=(r,o)=>e.check(wc(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 v1(Qd,e)}const Jb=te("ZodNumberFormat",(e,t)=>{wx.init(e,t),Qd.init(e,t)});function kc(e){return y1(Jb,e)}const Yb=te("ZodBoolean",(e,t)=>{_x.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>H1(e,n,r)});function Le(e){return w1(Yb,e)}const Xb=te("ZodNull",(e,t)=>{kx.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>V1(e,n,r)});function so(e){return _1(Xb,e)}const Qb=te("ZodUnknown",(e,t)=>{jx.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Z1()});function On(){return k1(Qb)}const ev=te("ZodNever",(e,t)=>{Sx.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>q1(e,n,r)});function tv(e){return j1(ev,e)}const nv=te("ZodArray",(e,t)=>{Cx.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>X1(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(no(n,r)),e.nonempty=n=>e.check(no(1,n)),e.max=(n,r)=>e.check(qd(n,r)),e.length=(n,r)=>e.check(Zd(n,r)),e.unwrap=()=>e.element});function fe(e,t){return M1(nv,e,t)}const rv=te("ZodObject",(e,t)=>{Tx.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Q1(e,n,r,o),Oe(e,"shape",()=>t.shape),e.keyof=()=>Ee(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:On()}),e.loose=()=>e.clone({...e._zod.def,catchall:On()}),e.strict=()=>e.clone({...e._zod.def,catchall:tv()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Z0(e,n),e.safeExtend=n=>G0(e,n),e.merge=n=>K0(e,n),e.pick=n=>V0(e,n),e.omit=n=>q0(e,n),e.partial=(...n)=>J0(tf,e,n[0]),e.required=(...n)=>Y0(nf,e,n[0])});function J(e,t){const n={type:"object",shape:e??{},...we(t)};return new rv(n)}const ef=te("ZodUnion",(e,t)=>{Hd.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>eb(e,n,r,o),e.options=t.options});function Kt(e,t){return new ef({type:"union",options:e,...we(t)})}const sv=te("ZodDiscriminatedUnion",(e,t)=>{ef.init(e,t),Ex.init(e,t)});function Vn(e,t,n){return new sv({type:"union",options:t,discriminator:e,...we(n)})}const ov=te("ZodIntersection",(e,t)=>{Ax.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>tb(e,n,r,o)});function iv(e,t){return new ov({type:"intersection",left:e,right:t})}const av=te("ZodRecord",(e,t)=>{Rx.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>nb(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function Ye(e,t,n){return new av({type:"record",keyType:e,valueType:t,...we(n)})}const na=te("ZodEnum",(e,t)=>{Ix.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(r,o,i)=>G1(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 na({...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 na({...t,checks:[],...we(o),entries:i})}});function Ee(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new na({type:"enum",entries:n,...we(t)})}const lv=te("ZodLiteral",(e,t)=>{zx.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>K1(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 Te(e,t){return new lv({type:"literal",values:Array.isArray(e)?e:[e],...we(t)})}const cv=te("ZodTransform",(e,t)=>{Ox.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Y1(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Sd(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Gr(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(Gr(a))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function uv(e){return new cv({type:"transform",transform:e})}const tf=te("ZodOptional",(e,t)=>{Vd.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Yd(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function jc(e){return new tf({type:"optional",innerType:e})}const dv=te("ZodExactOptional",(e,t)=>{Px.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Yd(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function fv(e){return new dv({type:"optional",innerType:e})}const pv=te("ZodNullable",(e,t)=>{Mx.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rb(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Sc(e){return new pv({type:"nullable",innerType:e})}const hv=te("ZodDefault",(e,t)=>{Lx.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ob(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function mv(e,t){return new hv({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Ed(t)}})}const gv=te("ZodPrefault",(e,t)=>{Dx.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ib(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function xv(e,t){return new gv({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Ed(t)}})}const nf=te("ZodNonOptional",(e,t)=>{$x.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>sb(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function bv(e,t){return new nf({type:"nonoptional",innerType:e,...we(t)})}const vv=te("ZodCatch",(e,t)=>{Fx.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ab(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function yv(e,t){return new vv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const wv=te("ZodPipe",(e,t)=>{Bx.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>lb(e,n,r,o),e.in=t.in,e.out=t.out});function Cc(e,t){return new wv({type:"pipe",in:e,out:t})}const _v=te("ZodReadonly",(e,t)=>{Ux.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>cb(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function kv(e){return new _v({type:"readonly",innerType:e})}const jv=te("ZodLazy",(e,t)=>{Wx.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ub(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function Sv(e){return new jv({type:"lazy",getter:e})}const Cv=te("ZodCustom",(e,t)=>{Hx.init(e,t),qe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>J1(e,n)});function Nv(e,t={}){return L1(Cv,e,t)}function Tv(e){return D1(e)}const st=Sv(()=>Kt([C(),K(),Le(),so(),fe(st),Ye(C(),st)]));const rf=J({index:K(),timestamp:K(),type:C(),data:st}),Ev=J({chunks:fe(rf),truncated:Le().optional().default(!1)}),Av=Ee(["request","response"]),Rv=J({logId:K().int().positive(),part:Av,text:C(),offset:K().int().nonnegative(),limit:K().int().positive(),totalBytes:K().int().nonnegative(),textBytes:K().int().nonnegative(),nextOffset:K().int().nonnegative().nullable(),hasMore:Le(),contentMode:Ee(["empty","partial","full"])}),Kr=J({id:K(),timestamp:C(),method:C(),path:C(),model:C().nullable(),sessionId:C().nullable(),rawRequestBody:C().nullable(),responseStatus:K().nullable(),responseText:C().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:Le(),userAgent:C().nullable(),origin:C().nullable(),rawHeaders:Ye(C(),C()).optional(),headers:Ye(C(),C()).optional(),apiFormat:Ee(["anthropic","openai","unknown"]).default("unknown"),isTest:Le().optional().default(!1),replayOfLogId:K().nullable().optional(),providerName:C().nullable().optional(),clientPort:K().nullable().optional(),clientPid:K().nullable().optional(),clientCwd:C().nullable().optional(),clientProjectFolder:C().nullable().optional(),streamingChunks:Ev.optional(),streamingChunksPath:C().nullable().optional(),rawRequestBodyBytes:K().int().nonnegative().nullable().optional(),responseTextBytes:K().int().nonnegative().nullable().optional(),bodyContentMode:Ee(["full","compact","truncated"]).optional(),warnings:fe(C()).optional(),error:C().nullable().optional()}),Xa=J({type:C(),ttl:C().optional(),scope:C().optional()}),Qa=J({type:Te("text"),text:C(),cache_control:Xa.optional()}),sf=J({type:Te("thinking"),thinking:C(),signature:C().optional()}),Iv=J({type:Te("think"),thinking:C(),signature:C().optional()}),zv=J({type:Te("base64"),media_type:C(),data:C()}),of=J({type:Te("image"),source:zv}),af=J({type:Te("tool_use"),id:C(),name:C(),input:Ye(C(),st)}),Ov=Vn("type",[Qa,of]),Pv=J({type:Te("tool_result"),tool_use_id:C().optional(),content:Kt([C(),fe(Ov)]),is_error:Le().optional()}),Mv=Vn("type",[Qa,sf,of,af,Pv]),Lv=Kt([C(),fe(Mv)]),Dv=J({role:Ee(["user","assistant"]),content:Lv}),$v=J({type:Te("text"),text:C(),cache_control:Xa.optional()}),Fv=J({type:C(),properties:Ye(C(),Ye(C(),st)).optional(),required:fe(C()).optional(),additionalProperties:Le().optional(),$schema:C().optional()}),Bv=J({name:C(),description:C().optional(),input_schema:Fv.optional(),cache_control:Xa.optional()}),Uv=Vn("type",[J({type:Te("enabled"),budget_tokens:K()}),J({type:Te("disabled")}),J({type:Te("adaptive")})]),lf=J({model:C(),messages:fe(Dv),system:fe($v).optional(),tools:fe(Bv).optional(),max_tokens:K().optional(),temperature:K().optional(),stream:Le().optional(),thinking:Uv.optional(),metadata:J({user_id:C().optional()}).optional()}),el=Vn("type",[Qa,sf,Iv,af]),Wv=J({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(),cf=J({id:C(),type:Te("message"),model:C(),role:Te("assistant"),content:fe(el),stop_reason:C().nullable(),stop_sequence:C().nullable().optional(),usage:Wv}).passthrough(),Hv=J({type:Te("message_start"),message:J({id:C(),type:Te("message"),model:C(),role:Te("assistant"),content:fe(el),stop_reason:so(),stop_sequence:so(),usage:J({input_tokens:K(),cache_creation_input_tokens:K().optional(),cache_read_input_tokens:K().optional()}).passthrough()})}),Vv=J({type:Te("content_block_start"),index:K(),content_block:el}),qv=Vn("type",[J({type:Te("text_delta"),text:C()}),J({type:Te("input_json_delta"),partial_json:C()}),J({type:Te("thinking_delta"),thinking:C()}),J({type:Te("signature_delta"),signature:C()})]),Zv=J({type:Te("content_block_delta"),index:K(),delta:qv}),Gv=J({type:Te("content_block_stop"),index:K()}),Kv=J({type:Te("message_delta"),delta:J({stop_reason:C().nullable(),stop_sequence:C().nullable().optional()}),usage:J({output_tokens:K(),input_tokens:K().optional(),cache_creation_input_tokens:K().optional(),cache_read_input_tokens:K().optional()}).passthrough()}),Jv=J({type:Te("message_stop")}),Yv=J({type:Te("ping")}),Xv=J({type:Te("error"),error:J({type:C(),message:C()})}),Qv=Vn("type",[Hv,Vv,Zv,Gv,Kv,Jv,Yv,Xv]),e2=Kt([C(),fe(Vn("type",[J({type:Te("text"),text:C()}),J({type:Te("image_url"),image_url:J({url:C(),detail:C().optional()})})]))]),uf=J({role:Ee(["system","user","assistant","tool"]),content:e2,name:C().optional(),reasoning_content:C().optional(),thinking:C().optional(),think:C().optional()}),t2=J({name:C(),arguments:C()}),df=J({index:K().optional(),id:C().optional(),type:Te("function").optional(),function:J({name:C().optional(),arguments:C().optional()})});uf.extend({content:Kt([C(),fe(J({type:Te("text"),text:C()}))]).optional(),function_call:t2.optional(),tool_calls:fe(df).optional()});const n2=J({type:Te("function"),function:J({name:C(),description:C().optional(),parameters:Ye(C(),st)})}),ff=J({model:C(),messages:fe(uf),temperature:K().optional(),max_tokens:K().optional(),stream:Le().optional(),tools:fe(n2).optional(),tool_choice:Kt([Ee(["auto","none","required"]),J({type:Te("auto")}),J({type:Te("none")}),J({type:Te("function"),function:J({name:C()})})]).optional(),user:C().optional()}),r2=J({type:C(),name:C().optional(),description:C().optional(),parameters:st.optional(),function:J({name:C().optional(),description:C().optional(),parameters:st.optional()}).optional()}).passthrough(),pf=J({model:C(),input:On().optional(),instructions:Kt([C(),so()]).optional(),stream:Le().optional(),tools:fe(r2).optional(),tool_choice:On().optional(),max_output_tokens:K().optional(),temperature:K().optional(),user:C().optional(),metadata:Ye(C(),On()).optional()}).passthrough(),hf=J({role:Ee(["assistant"]).optional(),content:C().nullable().optional(),reasoning_content:C().nullable().optional(),thinking:C().nullable().optional(),think:C().nullable().optional(),function_call:J({name:C().optional(),arguments:C().optional()}).nullable().optional(),tool_calls:fe(J({index:K(),id:C().optional(),type:Te("function").optional(),function:J({name:C().optional(),arguments:C().optional()})})).nullable().optional()}),s2=J({index:K(),message:J({role:Ee(["assistant"]),content:C().nullable(),reasoning_content:C().optional(),thinking:C().optional(),think:C().optional(),function_call:J({name:C(),arguments:C()}).nullable().optional(),tool_calls:fe(df).optional()}).optional(),delta:hf.optional(),finish_reason:C().nullable()}),o2=J({id:C(),object:Te("chat.completion"),created:K(),model:C(),choices:fe(s2),usage:J({prompt_tokens:K().nullable().optional(),completion_tokens:K().nullable().optional(),total_tokens:K().nullable().optional()}).passthrough(),service_tier:C().nullable().optional(),system_fingerprint:C().nullable().optional()}).passthrough(),i2=J({id:C(),object:Te("chat.completion.chunk"),created:K(),model:C(),choices:fe(J({index:K(),delta:hf,finish_reason:C().nullable().optional()})),usage:J({prompt_tokens:K().nullable().optional(),completion_tokens:K().nullable().optional(),total_tokens:K().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),a2=J({input_tokens:K().nullable().optional(),output_tokens:K().nullable().optional(),total_tokens:K().nullable().optional(),input_tokens_details:J({cached_tokens:K().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:J({reasoning_tokens:K().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),l2=J({type:C()}).passthrough(),oo=J({id:C(),object:Te("response").optional(),created_at:K().optional(),status:C().nullable().optional(),model:C().optional(),output:fe(l2).optional(),output_text:C().optional(),usage:a2.nullable().optional(),error:On().optional()}).passthrough(),c2=J({type:C()}).passthrough();function mf(e){try{const t=JSON.parse(e),n=o2.safeParse(t);return n.success?n.data:null}catch{return null}}function gf(e){try{const t=JSON.parse(e),n=oo.safeParse(t);return n.success?n.data:null}catch{return null}}const u2=J({error:C()});async function tl(e,t){const n=await e.json();return t.parse(n)}async function nl(e,t){try{const n=await e.json(),r=u2.safeParse(n);return r.success?r.data.error:t}catch{return t}}async function Mt(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 nl(o,i))}return tl(o,t)}function d2(e){return e<1e3?`${String(e)}ms`:`${String(Math.round(e/1e3))}s`}class Bo extends Error{constructor(t){super(`Request timed out after ${d2(t)}`),this.name="ApiTimeoutError"}}async function Pn(e,t,n){const r=new AbortController;let o=!1;const i=setTimeout(()=>{o=!0,r.abort()},t),a=n?.signal??void 0,l=()=>r.abort();a!==void 0&&(a.aborted?r.abort():a.addEventListener("abort",l,{once:!0}));try{return await fetch(e,{...n,signal:r.signal})}catch(c){throw o&&c instanceof DOMException&&c.name==="AbortError"?new Bo(t):c}finally{clearTimeout(i),a?.removeEventListener("abort",l)}}async function Ke(e,t,n,r,o){const i=await Pn(e,n,r);if(!i.ok){const a=o?.(i)??`Request failed with status ${i.status}`;throw new Error(await nl(i,a))}return tl(i,t)}const xf=J({input:K().int().nonnegative(),output:K().int().nonnegative(),cacheCreate:K().int().nonnegative(),cacheRead:K().int().nonnegative(),total:K().int().nonnegative()}),f2=J({id:K().int().positive(),sessionLogNumber:K().int().positive().optional(),timestamp:C(),provider:C().nullable(),model:C().nullable(),apiFormat:Ee(["anthropic","openai","unknown"]),method:C(),path:C(),status:K().nullable(),isStreaming:Le(),hasError:Le(),error:C().nullable(),latencyMs:K().nullable(),firstChunkMs:K().nullable().optional(),totalStreamMs:K().nullable().optional(),tokensPerSecond:K().nullable().optional(),tokens:J({input:K().nullable(),output:K().nullable(),cacheCreate:K().nullable(),cacheRead:K().nullable()}),sessionId:C().nullable(),userAgent:C().nullable().optional(),clientPid:K().nullable().optional(),clientProjectFolder:C().nullable().optional()}),bf=J({id:C(),status:Ee(["active","failed","completed","empty"]),logCoverage:Ee(["recent","history"]),source:Ee(["explicit","client-process","client-connection","provider-test"]).nullable(),runtimeMode:Ee(["in-process","worker-thread","child-process"]).nullable(),createdAt:C().nullable(),updatedAt:C().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:C().nullable(),logCount:K().int().nonnegative(),errorCount:K().int().nonnegative(),models:fe(C()),providers:fe(C()),tokenUsage:xf,lastLogId:K().nullable(),lastModel:C().nullable(),clientUserAgent:C().nullable().optional(),clientPid:K().nullable(),clientProjectFolder:C().nullable(),inspectorPath:C(),inspectorUrl:C(),apiPath:C(),apiUrl:C(),compactLogsPath:C(),compactLogsUrl:C(),latestLogLimit:K().int().positive(),latestLogs:fe(f2)}),os=Ee(["created","running","completed","failed","cancelled"]),rl=J({jsonPath:C(),markdownPath:C(),htmlPath:C(),exportedAt:C()}),p2=Ee(["run-created","session-started","request","session-finished","evidence-exported"]),h2=Ee(["info","success","warning","error"]),m2=J({timestamp:C(),kind:p2,severity:h2,title:C(),details:C(),logId:K().int().positive().nullable(),status:K().nullable(),model:C().nullable(),provider:C().nullable(),latencyMs:K().nullable(),isStreaming:Le().nullable()}),g2=Ee(["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"]),vf=J({outcome:Ee(["success","failure","active","unknown"]),severity:Ee(["none","low","medium","high"]),category:g2,summary:C(),evidenceLogIds:fe(K().int().positive()),hints:fe(C())}),sl=J({status:Ee(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:C(),markdown:C()}),yf=sl,ol=J({id:C(),sessionId:C(),groupId:C().nullable().default(null),title:C(),task:C().nullable(),project:C().nullable(),agent:C().nullable(),status:os,tags:fe(C()),metadata:Ye(C(),st),evidence:rl.nullable(),createdAt:C(),updatedAt:C()});J({runId:C().min(1).optional(),sessionId:C().min(1).optional(),groupId:C().min(1).nullable().optional(),title:C().min(1).optional(),task:C().nullable().optional(),project:C().nullable().optional(),agent:C().nullable().optional(),status:os.optional(),tags:fe(C()).optional(),metadata:Ye(C(),st).optional()}).optional();J({sessionId:C().min(1).optional(),groupId:C().min(1).nullable().optional(),title:C().min(1).optional(),task:C().nullable().optional(),project:C().nullable().optional(),agent:C().nullable().optional(),status:os.optional(),tags:fe(C()).optional(),metadata:Ye(C(),st).optional()});J({includeHistory:Le().optional(),latestLogLimit:K().int().positive().max(50).optional()}).optional();J({run:ol,evidence:rl,session:bf.nullable(),timeline:fe(m2),classification:vf,jenkinsReport:sl});const x2=J({run:ol,classification:vf,evidence:rl.nullable(),jenkinsReport:sl.nullable(),sessionId:C(),inspectorUrl:C().nullable(),evidenceMarkdownPath:C().nullable(),updatedAt:C()});J({failures:fe(x2),total:K().int().nonnegative(),limit:K().int().positive()});const il=Ee(["created","running","completed","failed","cancelled"]),al=Ee(["evaluation","batch","manual"]),ll=J({jsonPath:C(),markdownPath:C(),htmlPath:C(),exportedAt:C()}),wf=J({id:C(),groupId:C(),sessionId:C(),runId:C().nullable(),label:C().nullable(),agent:C().nullable(),provider:C().nullable(),model:C().nullable(),status:os.nullable(),metadata:Ye(C(),st),addedAt:C(),updatedAt:C()}),cl=J({id:C(),title:C(),kind:al,task:C().nullable(),project:C().nullable(),status:il,tags:fe(C()),metadata:Ye(C(),st),evidence:ll.nullable(),members:fe(wf),createdAt:C(),updatedAt:C()});J({groupId:C().min(1).optional(),title:C().min(1).optional(),kind:al.optional(),task:C().nullable().optional(),project:C().nullable().optional(),status:il.optional(),tags:fe(C()).optional(),metadata:Ye(C(),st).optional()}).optional();J({title:C().min(1).optional(),kind:al.optional(),task:C().nullable().optional(),project:C().nullable().optional(),status:il.optional(),tags:fe(C()).optional(),metadata:Ye(C(),st).optional()});J({memberId:C().min(1).optional(),sessionId:C().min(1),runId:C().min(1).nullable().optional(),label:C().min(1).nullable().optional(),agent:C().min(1).nullable().optional(),provider:C().min(1).nullable().optional(),model:C().min(1).nullable().optional(),status:os.nullable().optional(),metadata:Ye(C(),st).optional()});J({includeHistory:Le().optional(),latestLogLimit:K().int().positive().max(50).optional()}).optional();J({deleteEvidence:Le().optional()});const _f=J({groupId:C(),deleted:Le(),evidenceDeleted:Le(),evidencePath:C().nullable()}),b2=J({deleted:K().int().nonnegative(),groups:fe(_f)}),kf=J({member:wf,run:ol.nullable(),session:bf.nullable()}),jf=J({memberCount:K().int().nonnegative(),sessionsWithData:K().int().nonnegative(),missingSessions:K().int().nonnegative(),requestCount:K().int().nonnegative(),errorCount:K().int().nonnegative(),tokenUsage:xf,models:fe(C()),providers:fe(C()),completedMembers:K().int().nonnegative(),failedMembers:K().int().nonnegative(),runningMembers:K().int().nonnegative()}),v2=J({group:cl,evidence:ll,members:fe(kf).nullable(),markdown:C(),summary:jf.nullable(),report:yf.nullable()}),y2=J({group:cl,evidence:ll,members:fe(kf),summary:jf,jenkinsReport:yf}),Sf=J({groups:fe(cl)}),w2=J({sessionId:C(),imported:K().int().nonnegative(),skipped:K().int().nonnegative(),warnings:fe(C()),logs:fe(Kr)}),io=10,ra=600,ao=60,sa=600,lo="time",ul="simple",Cf=Ee(["time","full"]),_2=Ee(["simple","full"]),Uo=J({stripClaudeCodeBillingHeader:Le(),hasSeenOnboarding:Le().default(!1),slowResponseThresholdSeconds:K().int().min(0).max(ra).default(io),providerTestTimeoutSeconds:K().int().min(1).max(sa).default(ao),timeDisplayFormat:Cf.default(lo),captureMode:_2.default(ul)}),lr="/api/config";async function k2(e){return Mt(e,Uo,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function vs(e){return Mt(lr,Uo,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function dl(){const e=rn(lr,k2,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=_d(),n=e.data?.stripClaudeCodeBillingHeader??!1,r=e.data?.captureMode??ul,o=e.data?.slowResponseThresholdSeconds??io,i=e.data?.providerTestTimeoutSeconds??ao,a=e.data?.timeDisplayFormat??lo,l=h=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??io,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??ao,timeDisplayFormat:e.data?.timeDisplayFormat??lo,captureMode:r,...h}),c=async h=>{await t(lr,vs({stripClaudeCodeBillingHeader:h}),{optimisticData:l({stripClaudeCodeBillingHeader:h}),rollbackOnError:!0,revalidate:!1})},u=async h=>{await t(lr,vs({slowResponseThresholdSeconds:h}),{optimisticData:l({slowResponseThresholdSeconds:h}),rollbackOnError:!0,revalidate:!1})},d=async h=>{await t(lr,vs({timeDisplayFormat:h}),{optimisticData:l({timeDisplayFormat:h}),rollbackOnError:!0,revalidate:!1})},f=async h=>{await t(lr,vs({providerTestTimeoutSeconds:h}),{optimisticData:l({providerTestTimeoutSeconds:h}),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 j2=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const S2=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase());const Nc=e=>{const t=S2(e);return t.charAt(0).toUpperCase()+t.slice(1)};var C2={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 N2=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const T2=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,...C2,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Nf("lucide",o),...!i&&!N2(l)&&{"aria-hidden":"true"},...l},[...a.map(([u,d])=>p.createElement(u,d)),...Array.isArray(i)?i:[i]]));const de=(e,t)=>{const n=p.forwardRef(({className:r,...o},i)=>p.createElement(T2,{ref:i,iconNode:t,className:Nf(`lucide-${j2(Nc(e))}`,`lucide-${e}`,r),...o}));return n.displayName=Nc(e),n};const E2=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],A2=de("activity",E2);const R2=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],I2=de("arrow-down-right",R2);const z2=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],O2=de("arrow-down",z2);const P2=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],M2=de("arrow-left",P2);const L2=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],D2=de("arrow-up-right",L2);const $2=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],F2=de("arrow-up",$2);const B2=[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]],fl=de("beaker",B2);const U2=[["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"}]],W2=de("bell",U2);const H2=[["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"}]],V2=de("blocks",H2);const q2=[["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=de("brain",q2);const Z2=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Xe=de("check",Z2);const G2=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],lt=de("chevron-down",G2);const K2=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],J2=de("chevron-left",K2);const Y2=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ct=de("chevron-right",Y2);const X2=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],pl=de("chevron-up",X2);const Q2=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],ey=de("chevrons-down",Q2);const ty=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],ny=de("chevrons-left",ty);const ry=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],sy=de("chevrons-right",ry);const oy=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],iy=de("chevrons-up",oy);const ay=[["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"}]],vr=de("circle-alert",ay);const ly=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ef=de("circle-check-big",ly);const cy=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],oa=de("circle-check",cy);const uy=[["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"}]],dy=de("circle-question-mark",uy);const fy=[["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"}]],Af=de("circle-x",fy);const py=[["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"}]],hy=de("clapperboard",py);const my=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],gy=de("clock-3",my);const xy=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],tn=de("clock",xy);const by=[["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"}]],vy=de("cloud-upload",by);const yy=[["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"}]],wy=de("code-xml",yy);const _y=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],ky=de("columns-2",_y);const jy=[["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"}]],Ft=de("copy",jy);const Sy=[["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"}]],Cy=de("cpu",Sy);const Ny=[["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"}]],is=de("download",Ny);const Ty=[["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"}]],Ey=de("ellipsis",Ty);const Ay=[["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"}]],hl=de("external-link",Ay);const Ry=[["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"}]],ml=de("eye-off",Ry);const Iy=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],gl=de("eye",Iy);const zy=[["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"}]],Oy=de("file-braces",zy);const Py=[["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"}]],My=de("file-diff",Py);const Ly=[["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"}]],Dy=de("file-search",Ly);const $y=[["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"}]],Fy=de("file-terminal",$y);const By=[["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"}]],Uy=de("file-text",By);const Wy=[["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"}]],Hy=de("flag",Wy);const Vy=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],qy=de("flask-conical",Vy);const Zy=[["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"}]],Gy=de("folder-open",Zy);const Ky=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],xl=de("gauge",Ky);const Jy=[["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"}]],Yy=de("git-compare-arrows",Jy);const Xy=[["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=de("globe",Xy);const Qy=[["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"}]],ew=de("history",Qy);const tw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],nw=de("info",tw);const rw=[["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"}]],Tc=de("layers",rw);const sw=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],tt=de("loader-circle",sw);const ow=[["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"}]],iw=de("lock",ow);const aw=[["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=de("message-square",aw);const lw=[["path",{d:"M5 12h14",key:"1ays0h"}]],cw=de("minus",lw);const uw=[["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"}]],dw=de("monitor",uw);const fw=[["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"}]],pw=de("mouse-pointer-click",fw);const hw=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],mw=de("network",hw);const gw=[["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"}]],xw=de("octagon-alert",gw);const bw=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],vw=de("package-check",bw);const yw=[["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"}]],If=de("pencil",yw);const ww=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ia=de("plus",ww);const _w=[["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"}]],Ec=de("radio",_w);const kw=[["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"}]],nn=de("refresh-cw",kw);const jw=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],Sw=de("rocket",jw);const Cw=[["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"}]],Nw=de("rotate-ccw",Cw);const Tw=[["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"}]],co=de("rotate-cw",Tw);const Ew=[["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"}]],Aw=de("rows-3",Ew);const Rw=[["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"}]],Iw=de("save",Rw);const zw=[["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"}]],Ow=de("scan",zw);const Pw=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],zf=de("search",Pw);const Mw=[["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"}]],Lw=de("server",Mw);const Dw=[["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"}]],$w=de("settings",Dw);const Fw=[["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"}]],Bw=de("shield-alert",Fw);const Uw=[["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=de("shield-check",Uw);const Ww=[["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"}]],aa=de("siren",Ww);const Hw=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Vw=de("sparkles",Hw);const qw=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Cr=de("terminal",qw);const Zw=[["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"}]],Gw=de("timer",Zw);const Kw=[["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"}]],Ht=de("trash-2",Kw);const Jw=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],bn=de("triangle-alert",Jw);const Yw=[["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=de("upload",Yw);const Xw=[["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"}]],Qw=de("wifi-off",Xw);const e_=[["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"}]],t_=de("wifi",e_);const n_=[["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"}]],as=de("wrench",n_);const r_=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ls=de("x",r_);const s_=[["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"}]],Jr=de("zap",s_),la="/api/config";async function o_(e){return Mt(e,Uo,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function i_(e){return Mt(la,Uo,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function a_(){const e=rn(la,o_,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=_d(),n=e.data?.hasSeenOnboarding??!1,r=e.data?.captureMode??ul,o=async()=>{await t(la,i_({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??io,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??ao,timeDisplayFormat:e.data?.timeDisplayFormat??lo,captureMode:r},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:n,captureMode:r,isLoading:e.isLoading,markSeen:o}}function l_(){const{hasSeenOnboarding:e,isLoading:t,markSeen:n}=a_(),[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(nw,{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(lt,{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(Xe,{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(ls,{className:"size-3.5"})})]})})}function ys(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 vi={exports:{}};var Rc;function c_(){return Rc||(Rc=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 ys=="function"&&ys;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var h=new Error("Cannot find module '"+u+"'");throw h.code="MODULE_NOT_FOUND",h}var m=o[u]={exports:{}};r[u][0].call(m.exports,function(v){var g=r[u][1][v];return a(g||v)},m,m.exports,n,r,o,i)}return o[u].exports}for(var l=typeof ys=="function"&&ys,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,h,m,v,g,x=[],b=0,y=c.length,k=y,j=i.getTypeOf(c)!=="string";b<c.length;)k=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),h=u>>2,m=(3&u)<<4|d>>4,v=1<k?(15&d)<<2|f>>6:64,g=2<k?63&f:64,x.push(l.charAt(h)+l.charAt(m)+l.charAt(v)+l.charAt(g));return x.join("")},o.decode=function(c){var u,d,f,h,m,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,k=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&k--,c.charAt(c.length-2)===l.charAt(64)&&k--,k%1!=0)throw new Error("Invalid base64 input, bad content length.");for(y=a.uint8array?new Uint8Array(0|k):new Array(0|k);g<c.length;)u=l.indexOf(c.charAt(g++))<<2|(h=l.indexOf(c.charAt(g++)))>>4,d=(15&h)<<4|(m=l.indexOf(c.charAt(g++)))>>2,f=(3&m)<<6|(v=l.indexOf(c.charAt(g++))),y[x++]=u,m!==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,h,m,v){this.compressedSize=d,this.uncompressedSize=f,this.crc32=h,this.compression=m,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,h){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(h)).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,h){var m=a,v=h+f;u^=-1;for(var g=h;g<v;g++)u=u>>>8^m[255&(u^d[g])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,h){var m=a,v=h+f;u^=-1;for(var g=h;g<v;g++)u=u>>>8^m[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,h){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=h,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(h){f.push({data:h,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(m,v){var g,x="";for(g=0;g<v;g++)x+=String.fromCharCode(255&m),m>>>=8;return x}function a(m,v,g,x,b,y){var k,j,S=m.file,E=m.compression,N=y!==u.utf8encode,z=l.transformTo("string",y(S.name)),A=l.transformTo("string",u.utf8encode(S.name)),O=S.comment,W=l.transformTo("string",y(O)),T=l.transformTo("string",u.utf8encode(O)),L=A.length!==S.name.length,_=T.length!==O.length,$="",ee="",D="",H=S.dir,Z=S.date,ue={crc32:0,compressedSize:0,uncompressedSize:0};v&&!g||(ue.crc32=m.crc32,ue.compressedSize=m.compressedSize,ue.uncompressedSize=m.uncompressedSize);var V=0;v&&(V|=8),N||!L&&!_||(V|=2048);var U=0,ce=0;H&&(U|=16),b==="UNIX"?(ce=798,U|=(function(Q,Se){var ie=Q;return Q||(ie=Se?16893:33204),(65535&ie)<<16})(S.unixPermissions,H)):(ce=20,U|=(function(Q){return 63&(Q||0)})(S.dosPermissions)),k=Z.getUTCHours(),k<<=6,k|=Z.getUTCMinutes(),k<<=5,k|=Z.getUTCSeconds()/2,j=Z.getUTCFullYear()-1980,j<<=4,j|=Z.getUTCMonth()+1,j<<=5,j|=Z.getUTCDate(),L&&(ee=i(1,1)+i(d(z),4)+A,$+="up"+i(ee.length,2)+ee),_&&(D=i(1,1)+i(d(W),4)+T,$+="uc"+i(D.length,2)+D);var B="";return B+=`
41
- \0`,B+=i(V,2),B+=E.magic,B+=i(k,2),B+=i(j,2),B+=i(ue.crc32,4),B+=i(ue.compressedSize,4),B+=i(ue.uncompressedSize,4),B+=i(z.length,2),B+=i($.length,2),{fileRecord:f.LOCAL_FILE_HEADER+B+z+$,dirRecord:f.CENTRAL_FILE_HEADER+i(ce,2)+B+i(W.length,2)+"\0\0\0\0"+i(U,4)+i(x,4)+z+$+W}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function h(m,v,g,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=v,this.zipPlatform=g,this.encodeFileName=x,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(h,c),h.prototype.push=function(m){var v=m.meta.percent||0,g=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,c.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:g?(v+100*(g-x-1))/g:100}}))},h.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var v=this.streamFiles&&!m.file.dir;if(v){var g=a(m,v,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(m){this.accumulate=!1;var v=this.streamFiles&&!m.file.dir,g=a(m,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)})(m),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var m=this.bytesWritten,v=0;v<this.dirRecords.length;v++)this.push({data:this.dirRecords[v],meta:{percent:100}});var g=this.bytesWritten-m,x=(function(b,y,k,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(k,4)+i(E.length,2)+E})(this.dirRecords.length,g,m,this.zipComment,this.encodeFileName);this.push({data:x,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(m){this._sources.push(m);var v=this;return m.on("data",function(g){v.processChunk(g)}),m.on("end",function(){v.closedSource(v.previous.streamInfo),v._sources.length?v.prepareNextSource():v.end()}),m.on("error",function(g){v.error(g)}),this},h.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))},h.prototype.error=function(m){var v=this._sources;if(!c.prototype.error.call(this,m))return!1;for(var g=0;g<v.length;g++)try{v[g].error(m)}catch{}return!0},h.prototype.lock=function(){c.prototype.lock.call(this);for(var m=this._sources,v=0;v<m.length;v++)m[v].lock()},r.exports=h},{"../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(h,m){f++;var v=(function(y,k){var j=y||k,S=i[j];if(!S)throw new Error(j+" is not a valid compression method !");return S})(m.options.compression,c.compression),g=m.options.compressionOptions||c.compressionOptions||{},x=m.dir,b=m.date;m._compressWorker(v,g).withStreamInfo("file",{name:h,dir:x,date:b,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(h){d.error(h)}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(h){return new a.Promise(function(m,v){var g=h.decompressed.getContentWorker().pipe(new u);g.on("error",function(x){v(x)}).on("end",function(){g.streamInfo.crc32!==h.decompressed.crc32?v(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(h,m){var v=this;return m=i.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(h)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip file",h,!0,m.optimizedBinaryString,m.base64).then(function(g){var x=new c(m);return x.load(g),x}).then(function(g){var x=[a.Promise.resolve(g)],b=g.files;if(m.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 k=b[y],j=k.fileNameStr,S=i.resolve(k.fileNameStr);v.file(S,k.decompressed,{binary:!0,optimizedBinaryString:!0,date:k.date,dir:k.dir,comment:k.fileCommentStr.length?k.fileCommentStr:null,unixPermissions:k.unixPermissions,dosPermissions:k.dosPermissions,createFolders:m.createFolders}),k.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,h){d.push(f)||d._helper.pause(),u&&u(h)}).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,N){var z,A=l.getTypeOf(E),O=l.extend(N||{},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&&(z=x(S))&&y.call(this,z,!0);var W=A==="string"&&O.binary===!1&&O.base64===!1;N&&N.binary!==void 0||(O.binary=!W),(E instanceof f&&E.uncompressedSize===0||O.dir||!E||E.length===0)&&(O.base64=!1,O.binary=!0,E="",O.compression="STORE",A="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 L=new h(S,T,O);this.files[S]=L}var a=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),h=n("./zipObject"),m=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 k(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,N,z;for(E in this.files)z=this.files[E],(N=E.slice(this.root.length,E.length))&&E.slice(0,this.root.length)===this.root&&S(N,z)},filter:function(S){var E=[];return this.forEach(function(N,z){S(N,z)&&E.push(z)}),E},file:function(S,E,N){if(arguments.length!==1)return S=this.root+S,i.call(this,S,E,N),this;if(k(S)){var z=S;return this.filter(function(O,W){return!W.dir&&z.test(O)})}var A=this.files[this.root+S];return A&&!A.dir?A:null},folder:function(S){if(!S)return this;if(k(S))return this.filter(function(A,O){return O.dir&&S.test(A)});var E=this.root+S,N=y.call(this,E),z=this.clone();return z.root=N.name,z},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 N=this.filter(function(A,O){return O.name.slice(0,S.length)===S}),z=0;z<N.length;z++)delete this.files[N[z].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,N={};try{if((N=l.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=N.type.toLowerCase(),N.compression=N.compression.toUpperCase(),N.type==="binarystring"&&(N.type="string"),!N.type)throw new Error("No output type specified.");l.checkSupport(N.type),N.platform!=="darwin"&&N.platform!=="freebsd"&&N.platform!=="linux"&&N.platform!=="sunos"||(N.platform="UNIX"),N.platform==="win32"&&(N.platform="DOS");var z=N.comment||this.comment||"";E=m.generateWorker(this,N,z)}catch(A){(E=new c("error")).error(A)}return new u(E,N.type||"string",N.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),h=this.length-4;0<=h;--h)if(this.data[h]===c&&this.data[h+1]===u&&this.data[h+2]===d&&this.data[h+3]===f)return h-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),h=this.readData(4);return c===h[0]&&u===h[1]&&d===h[2]&&f===h[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 h=i.getTypeOf(f);return i.checkSupport(h),h!=="string"||a.uint8array?h==="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 h(v,g){return new d.Promise(function(x,b){var y=[],k=v._internalType,j=v._outputType,S=v._mimeType;v.on("data",function(E,N){y.push(E),g&&g(N)}).on("error",function(E){y=[],b(E)}).on("end",function(){try{var E=(function(N,z,A){switch(N){case"blob":return i.newBlob(i.transformTo("arraybuffer",z),A);case"base64":return c.encode(z);default:return i.transformTo(N,z)}})(j,(function(N,z){var A,O=0,W=null,T=0;for(A=0;A<z.length;A++)T+=z[A].length;switch(N){case"string":return z.join("");case"array":return Array.prototype.concat.apply([],z);case"uint8array":for(W=new Uint8Array(T),A=0;A<z.length;A++)W.set(z[A],O),O+=z[A].length;return W;case"nodebuffer":return Buffer.concat(z);default:throw new Error("concat : unsupported type '"+N+"'")}})(k,y),S);x(E)}catch(N){b(N)}y=[]}).resume()})}function m(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)}}m.prototype={accumulate:function(v){return h(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=m},{"../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 h(){c.call(this,"utf-8 encode")}o.utf8encode=function(m){return a.nodebuffer?l.newBufferFrom(m,"utf-8"):(function(v){var g,x,b,y,k,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=k=0;k<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[k++]=x:(x<2048?g[k++]=192|x>>>6:(x<65536?g[k++]=224|x>>>12:(g[k++]=240|x>>>18,g[k++]=128|x>>>12&63),g[k++]=128|x>>>6&63),g[k++]=128|63&x);return g})(m)},o.utf8decode=function(m){return a.nodebuffer?i.transformTo("nodebuffer",m).toString("utf-8"):(function(v){var g,x,b,y,k=v.length,j=new Array(2*k);for(g=x=0;g<k;)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<k;)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)})(m=i.transformTo(a.uint8array?"uint8array":"array",m))},i.inherits(f,c),f.prototype.processChunk=function(m){var v=i.transformTo(a.uint8array?"uint8array":"array",m.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,k){var j;for((k=k||y.length)>y.length&&(k=y.length),j=k-1;0<=j&&(192&y[j])==128;)j--;return j<0||j===0?k:j+u[y[j]]>k?j:k})(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:m.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(h,c),h.prototype.processChunk=function(m){this.push({data:o.utf8encode(m.data),meta:m.meta})},o.Utf8EncodeWorker=h},{"./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=[],k=0,j=g.length;if(j<=b)return String.fromCharCode.apply(null,g);for(;k<j;)x==="array"||x==="nodebuffer"?y.push(String.fromCharCode.apply(null,g.slice(k,Math.min(k+b,j)))):y.push(String.fromCharCode.apply(null,g.subarray(k,Math.min(k+b,j)))),k+=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 h(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 m(g,x){for(var b=0;b<g.length;b++)x[b]=g[b];return x}o.applyFromCharCode=h;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:h,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 h(new Uint8Array(g))},array:function(g){return m(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:h,array:function(g){return m(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:u,nodebuffer:function(g){return l.newBufferFrom(g)}},v.nodebuffer={string:h,array:function(g){return m(g,new Array(g.length))},arraybuffer:function(g){return v.nodebuffer.uint8array(g).buffer},uint8array:function(g){return m(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 k=x[y];k==="."||k===""&&y!==0&&y!==x.length-1||(k===".."?b.pop():b.push(k))}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,k){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 N=new FileReader;N.onload=function(z){S(z.target.result)},N.onerror=function(z){E(z.target.error)},N.readAsArrayBuffer(j)}):j}).then(function(j){var S=o.getTypeOf(j);return S?(S==="arraybuffer"?j=o.transformTo("uint8array",j):S==="string"&&(k?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 h=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(h)+", expected "+a.pretty(f)+")")}},isSignature:function(f,h){var m=this.reader.index;this.reader.setIndex(f);var v=this.reader.readString(4)===h;return this.reader.setIndex(m),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),h=u.uint8array?"uint8array":"array",m=a.transformTo(h,f);this.zipComment=this.loadOptions.decodeFileName(m)},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,h,m,v=this.zip64EndOfCentralSize-44;0<v;)f=this.reader.readInt(2),h=this.reader.readInt(4),m=this.reader.readData(h),this.zip64ExtensibleData[f]={id:f,length:h,value:m}},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,h;for(f=0;f<this.files.length;f++)h=this.files[f],this.reader.setIndex(h.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),h.readLocalPart(this.reader),h.handleUTF8(),h.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 h=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 m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var v=h-m;if(0<v)this.isSignature(h,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 h(m,v){this.options=m,this.loadOptions=v}h.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var v,g;if(m.skip(22),this.fileNameLength=m.readInt(2),g=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.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,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var v=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(v),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=i(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var v,g,x,b=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<b;)v=m.readInt(2),g=m.readInt(2),x=m.readData(g),this.extraFields[v]={id:v,length:g,value:x};m.setIndex(b)},handleUTF8:function(){var m=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(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var b=a.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(b)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var v=i(m.value);return v.readInt(1)!==1||c(this.fileName)!==v.readInt(4)?null:u.utf8decode(v.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var v=i(m.value);return v.readInt(1)!==1||c(this.fileComment)!==v.readInt(4)?null:u.utf8decode(v.readData(m.length-5))}return null}},r.exports=h},{"./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(k){(g=new d("error")).error(k)}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"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<f.length;m++)i.prototype[f[m]]=h;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 h=new i.MessageChannel;h.port1.onmessage=v,a=function(){h.port2.postMessage(0)}}var m=[];function v(){var g,x;l=!0;for(var b=m.length;b;){for(x=m,m=[],g=-1;++g<b;)x[g]();b=m.length}l=!1}r.exports=function(g){m.push(g)!==1||l||a()}}).call(this,typeof ms<"u"?ms: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 h(b,y,k){this.promise=b,typeof y=="function"&&(this.onFulfilled=y,this.callFulfilled=this.otherCallFulfilled),typeof k=="function"&&(this.onRejected=k,this.callRejected=this.otherCallRejected)}function m(b,y,k){i(function(){var j;try{j=y(k)}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 k=!1;function j(N){k||(k=!0,l.reject(b,N))}function S(N){k||(k=!0,l.resolve(b,N))}var E=x(function(){y(S,j)});E.status==="error"&&j(E.value)}function x(b,y){var k={};try{k.value=b(y),k.status="success"}catch(j){k.status="error",k.value=j}return k}(r.exports=f).prototype.finally=function(b){if(typeof b!="function")return this;var y=this.constructor;return this.then(function(k){return y.resolve(b()).then(function(){return k})},function(k){return y.resolve(b()).then(function(){throw k})})},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 k=new this.constructor(a);return this.state!==d?m(k,this.state===u?b:y,this.outcome):this.queue.push(new h(k,b,y)),k},h.prototype.callFulfilled=function(b){l.resolve(this.promise,b)},h.prototype.otherCallFulfilled=function(b){m(this.promise,this.onFulfilled,b)},h.prototype.callRejected=function(b){l.reject(this.promise,b)},h.prototype.otherCallRejected=function(b){m(this.promise,this.onRejected,b)},l.resolve=function(b,y){var k=x(v,y);if(k.status==="error")return l.reject(b,k.value);var j=k.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 k=-1,j=b.queue.length;++k<j;)b.queue[k].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 k=b.length,j=!1;if(!k)return this.resolve([]);for(var S=new Array(k),E=0,N=-1,z=new this(a);++N<k;)A(b[N],N);return z;function A(O,W){y.resolve(O).then(function(T){S[W]=T,++E!==k||j||(j=!0,l.resolve(z,S))},function(T){j||(j=!0,l.reject(z,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 k=b.length,j=!1;if(!k)return this.resolve([]);for(var S=-1,E=new this(a);++S<k;)N=b[S],y.resolve(N).then(function(z){j||(j=!0,l.resolve(E,z))},function(z){j||(j=!0,l.reject(E,z))});var N;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,h=-1,m=0,v=8;function g(b){if(!(this instanceof g))return new g(b);this.options=a.assign({level:h,method:v,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,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 k=i.deflateInit2(this.strm,y.level,y.method,y.windowBits,y.memLevel,y.strategy);if(k!==f)throw new Error(c[k]);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,(k=i.deflateSetDictionary(this.strm,j))!==f)throw new Error(c[k]);this._dict_set=!0}}function x(b,y){var k=new g(y);if(k.push(b,!0),k.err)throw k.msg||c[k.err];return k.result}g.prototype.push=function(b,y){var k,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),(k=i.deflate(S,j))!==1&&k!==f)return this.onEnd(k),!(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)&&k!==1);return j===4?(k=i.deflateEnd(this.strm),this.onEnd(k),this.ended=!0,k===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"),h=Object.prototype.toString;function m(g){if(!(this instanceof m))return new m(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 m(x);if(b.push(g,!0),b.err)throw b.msg||u[b.err];return b.result}m.prototype.push=function(g,x){var b,y,k,j,S,E,N=this.strm,z=this.options.chunkSize,A=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"?N.input=l.binstring2buf(g):h.call(g)==="[object ArrayBuffer]"?N.input=new Uint8Array(g):N.input=g,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new a.Buf8(z),N.next_out=0,N.avail_out=z),(b=i.inflate(N,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&A&&(E=typeof A=="string"?l.string2buf(A):h.call(A)==="[object ArrayBuffer]"?new Uint8Array(A):A,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);N.next_out&&(N.avail_out!==0&&b!==c.Z_STREAM_END&&(N.avail_in!==0||y!==c.Z_FINISH&&y!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(k=l.utf8border(N.output,N.next_out),j=N.next_out-k,S=l.buf2string(N.output,k),N.next_out=j,N.avail_out=z-j,j&&a.arraySet(N.output,N.output,k,j,0),this.onData(S)):this.onData(a.shrinkBuf(N.output,N.next_out)))),N.avail_in===0&&N.avail_out===0&&(O=!0)}while((0<N.avail_in||N.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),!(N.avail_out=0))},m.prototype.onData=function(g){this.chunks.push(g)},m.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=m,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,h){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),h);else for(var m=0;m<f;m++)c[h+m]=u[d+m]},flattenChunks:function(c){var u,d,f,h,m,v;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(v=new Uint8Array(f),u=h=0,d=c.length;u<d;u++)m=c[u],v.set(m,h),h+=m.length;return v}},l={arraySet:function(c,u,d,f,h){for(var m=0;m<f;m++)c[h+m]=u[d+m]},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,h){if(h<65537&&(f.subarray&&l||!f.subarray&&a))return String.fromCharCode.apply(null,i.shrinkBuf(f,h));for(var m="",v=0;v<h;v++)m+=String.fromCharCode(f[v]);return m}c[254]=c[254]=1,o.string2buf=function(f){var h,m,v,g,x,b=f.length,y=0;for(g=0;g<b;g++)(64512&(m=f.charCodeAt(g)))==55296&&g+1<b&&(64512&(v=f.charCodeAt(g+1)))==56320&&(m=65536+(m-55296<<10)+(v-56320),g++),y+=m<128?1:m<2048?2:m<65536?3:4;for(h=new i.Buf8(y),g=x=0;x<y;g++)(64512&(m=f.charCodeAt(g)))==55296&&g+1<b&&(64512&(v=f.charCodeAt(g+1)))==56320&&(m=65536+(m-55296<<10)+(v-56320),g++),m<128?h[x++]=m:(m<2048?h[x++]=192|m>>>6:(m<65536?h[x++]=224|m>>>12:(h[x++]=240|m>>>18,h[x++]=128|m>>>12&63),h[x++]=128|m>>>6&63),h[x++]=128|63&m);return h},o.buf2binstring=function(f){return d(f,f.length)},o.binstring2buf=function(f){for(var h=new i.Buf8(f.length),m=0,v=h.length;m<v;m++)h[m]=f.charCodeAt(m);return h},o.buf2string=function(f,h){var m,v,g,x,b=h||f.length,y=new Array(2*b);for(m=v=0;m<b;)if((g=f[m++])<128)y[v++]=g;else if(4<(x=c[g]))y[v++]=65533,m+=x-1;else{for(g&=x===2?31:x===3?15:7;1<x&&m<b;)g=g<<6|63&f[m++],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,h){var m;for((h=h||f.length)>f.length&&(h=f.length),m=h-1;0<=m&&(192&f[m])==128;)m--;return m<0||m===0?h:m+c[f[m]]>h?m:h}},{"./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 h=u;h<f;h++)a=a>>>8^d[255&(a^l[h])];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,h=4,m=0,v=-2,g=-1,x=4,b=2,y=8,k=9,j=286,S=30,E=19,N=2*j+1,z=15,A=3,O=258,W=O+A+1,T=42,L=113,_=1,$=2,ee=3,D=4;function H(w,X){return w.msg=d[X],X}function Z(w){return(w<<1)-(4<w?9:0)}function ue(w){for(var X=w.length;0<=--X;)w[X]=0}function V(w){var X=w.state,G=X.pending;G>w.avail_out&&(G=w.avail_out),G!==0&&(a.arraySet(w.output,X.pending_buf,X.pending_out,G,w.next_out),w.next_out+=G,X.pending_out+=G,w.total_out+=G,w.avail_out-=G,X.pending-=G,X.pending===0&&(X.pending_out=0))}function U(w,X){l._tr_flush_block(w,0<=w.block_start?w.block_start:-1,w.strstart-w.block_start,X),w.block_start=w.strstart,V(w.strm)}function ce(w,X){w.pending_buf[w.pending++]=X}function B(w,X){w.pending_buf[w.pending++]=X>>>8&255,w.pending_buf[w.pending++]=255&X}function Q(w,X){var G,P,I=w.max_chain_length,F=w.strstart,re=w.prev_length,ne=w.nice_match,q=w.strstart>w.w_size-W?w.strstart-(w.w_size-W):0,ae=w.window,R=w.w_mask,M=w.prev,Y=w.strstart+O,se=ae[F+re-1],oe=ae[F+re];w.prev_length>=w.good_match&&(I>>=2),ne>w.lookahead&&(ne=w.lookahead);do if(ae[(G=X)+re]===oe&&ae[G+re-1]===se&&ae[G]===ae[F]&&ae[++G]===ae[F+1]){F+=2,G++;do;while(ae[++F]===ae[++G]&&ae[++F]===ae[++G]&&ae[++F]===ae[++G]&&ae[++F]===ae[++G]&&ae[++F]===ae[++G]&&ae[++F]===ae[++G]&&ae[++F]===ae[++G]&&ae[++F]===ae[++G]&&F<Y);if(P=O-(Y-F),F=Y-O,re<P){if(w.match_start=X,ne<=(re=P))break;se=ae[F+re-1],oe=ae[F+re]}}while((X=M[X&R])>q&&--I!=0);return re<=w.lookahead?re:w.lookahead}function Se(w){var X,G,P,I,F,re,ne,q,ae,R,M=w.w_size;do{if(I=w.window_size-w.lookahead-w.strstart,w.strstart>=M+(M-W)){for(a.arraySet(w.window,w.window,M,M,0),w.match_start-=M,w.strstart-=M,w.block_start-=M,X=G=w.hash_size;P=w.head[--X],w.head[X]=M<=P?P-M:0,--G;);for(X=G=M;P=w.prev[--X],w.prev[X]=M<=P?P-M:0,--G;);I+=M}if(w.strm.avail_in===0)break;if(re=w.strm,ne=w.window,q=w.strstart+w.lookahead,ae=I,R=void 0,R=re.avail_in,ae<R&&(R=ae),G=R===0?0:(re.avail_in-=R,a.arraySet(ne,re.input,re.next_in,R,q),re.state.wrap===1?re.adler=c(re.adler,ne,R,q):re.state.wrap===2&&(re.adler=u(re.adler,ne,R,q)),re.next_in+=R,re.total_in+=R,R),w.lookahead+=G,w.lookahead+w.insert>=A)for(F=w.strstart-w.insert,w.ins_h=w.window[F],w.ins_h=(w.ins_h<<w.hash_shift^w.window[F+1])&w.hash_mask;w.insert&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[F+A-1])&w.hash_mask,w.prev[F&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=F,F++,w.insert--,!(w.lookahead+w.insert<A)););}while(w.lookahead<W&&w.strm.avail_in!==0)}function ie(w,X){for(var G,P;;){if(w.lookahead<W){if(Se(w),w.lookahead<W&&X===f)return _;if(w.lookahead===0)break}if(G=0,w.lookahead>=A&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+A-1])&w.hash_mask,G=w.prev[w.strstart&w.w_mask]=w.head[w.ins_h],w.head[w.ins_h]=w.strstart),G!==0&&w.strstart-G<=w.w_size-W&&(w.match_length=Q(w,G)),w.match_length>=A)if(P=l._tr_tally(w,w.strstart-w.match_start,w.match_length-A),w.lookahead-=w.match_length,w.match_length<=w.max_lazy_match&&w.lookahead>=A){for(w.match_length--;w.strstart++,w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+A-1])&w.hash_mask,G=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 P=l._tr_tally(w,0,w.window[w.strstart]),w.lookahead--,w.strstart++;if(P&&(U(w,!1),w.strm.avail_out===0))return _}return w.insert=w.strstart<A-1?w.strstart:A-1,X===h?(U(w,!0),w.strm.avail_out===0?ee:D):w.last_lit&&(U(w,!1),w.strm.avail_out===0)?_:$}function pe(w,X){for(var G,P,I;;){if(w.lookahead<W){if(Se(w),w.lookahead<W&&X===f)return _;if(w.lookahead===0)break}if(G=0,w.lookahead>=A&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+A-1])&w.hash_mask,G=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=A-1,G!==0&&w.prev_length<w.max_lazy_match&&w.strstart-G<=w.w_size-W&&(w.match_length=Q(w,G),w.match_length<=5&&(w.strategy===1||w.match_length===A&&4096<w.strstart-w.match_start)&&(w.match_length=A-1)),w.prev_length>=A&&w.match_length<=w.prev_length){for(I=w.strstart+w.lookahead-A,P=l._tr_tally(w,w.strstart-1-w.prev_match,w.prev_length-A),w.lookahead-=w.prev_length-1,w.prev_length-=2;++w.strstart<=I&&(w.ins_h=(w.ins_h<<w.hash_shift^w.window[w.strstart+A-1])&w.hash_mask,G=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=A-1,w.strstart++,P&&(U(w,!1),w.strm.avail_out===0))return _}else if(w.match_available){if((P=l._tr_tally(w,0,w.window[w.strstart-1]))&&U(w,!1),w.strstart++,w.lookahead--,w.strm.avail_out===0)return _}else w.match_available=1,w.strstart++,w.lookahead--}return w.match_available&&(P=l._tr_tally(w,0,w.window[w.strstart-1]),w.match_available=0),w.insert=w.strstart<A-1?w.strstart:A-1,X===h?(U(w,!0),w.strm.avail_out===0?ee:D):w.last_lit&&(U(w,!1),w.strm.avail_out===0)?_:$}function me(w,X,G,P,I){this.good_length=w,this.max_lazy=X,this.nice_length=G,this.max_chain=P,this.func=I}function he(){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*N),this.dyn_dtree=new a.Buf16(2*(2*S+1)),this.bl_tree=new a.Buf16(2*(2*E+1)),ue(this.dyn_ltree),ue(this.dyn_dtree),ue(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(z+1),this.heap=new a.Buf16(2*j+1),ue(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*j+1),ue(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function xe(w){var X;return w&&w.state?(w.total_in=w.total_out=0,w.data_type=b,(X=w.state).pending=0,X.pending_out=0,X.wrap<0&&(X.wrap=-X.wrap),X.status=X.wrap?T:L,w.adler=X.wrap===2?0:1,X.last_flush=f,l._tr_init(X),m):H(w,v)}function ke(w){var X=xe(w);return X===m&&(function(G){G.window_size=2*G.w_size,ue(G.head),G.max_lazy_match=i[G.level].max_lazy,G.good_match=i[G.level].good_length,G.nice_match=i[G.level].nice_length,G.max_chain_length=i[G.level].max_chain,G.strstart=0,G.block_start=0,G.lookahead=0,G.insert=0,G.match_length=G.prev_length=A-1,G.match_available=0,G.ins_h=0})(w.state),X}function Ae(w,X,G,P,I,F){if(!w)return v;var re=1;if(X===g&&(X=6),P<0?(re=0,P=-P):15<P&&(re=2,P-=16),I<1||k<I||G!==y||P<8||15<P||X<0||9<X||F<0||x<F)return H(w,v);P===8&&(P=9);var ne=new he;return(w.state=ne).strm=w,ne.wrap=re,ne.gzhead=null,ne.w_bits=P,ne.w_size=1<<ne.w_bits,ne.w_mask=ne.w_size-1,ne.hash_bits=I+7,ne.hash_size=1<<ne.hash_bits,ne.hash_mask=ne.hash_size-1,ne.hash_shift=~~((ne.hash_bits+A-1)/A),ne.window=new a.Buf8(2*ne.w_size),ne.head=new a.Buf16(ne.hash_size),ne.prev=new a.Buf16(ne.w_size),ne.lit_bufsize=1<<I+6,ne.pending_buf_size=4*ne.lit_bufsize,ne.pending_buf=new a.Buf8(ne.pending_buf_size),ne.d_buf=1*ne.lit_bufsize,ne.l_buf=3*ne.lit_bufsize,ne.level=X,ne.strategy=F,ne.method=G,ke(w)}i=[new me(0,0,0,0,function(w,X){var G=65535;for(G>w.pending_buf_size-5&&(G=w.pending_buf_size-5);;){if(w.lookahead<=1){if(Se(w),w.lookahead===0&&X===f)return _;if(w.lookahead===0)break}w.strstart+=w.lookahead,w.lookahead=0;var P=w.block_start+G;if((w.strstart===0||w.strstart>=P)&&(w.lookahead=w.strstart-P,w.strstart=P,U(w,!1),w.strm.avail_out===0)||w.strstart-w.block_start>=w.w_size-W&&(U(w,!1),w.strm.avail_out===0))return _}return w.insert=0,X===h?(U(w,!0),w.strm.avail_out===0?ee:D):(w.strstart>w.block_start&&(U(w,!1),w.strm.avail_out),_)}),new me(4,4,8,4,ie),new me(4,5,16,8,ie),new me(4,6,32,32,ie),new me(4,4,16,16,pe),new me(8,16,32,32,pe),new me(8,16,128,128,pe),new me(8,32,128,256,pe),new me(32,128,258,1024,pe),new me(32,258,258,4096,pe)],o.deflateInit=function(w,X){return Ae(w,X,y,15,8,0)},o.deflateInit2=Ae,o.deflateReset=ke,o.deflateResetKeep=xe,o.deflateSetHeader=function(w,X){return w&&w.state?w.state.wrap!==2?v:(w.state.gzhead=X,m):v},o.deflate=function(w,X){var G,P,I,F;if(!w||!w.state||5<X||X<0)return w?H(w,v):v;if(P=w.state,!w.output||!w.input&&w.avail_in!==0||P.status===666&&X!==h)return H(w,w.avail_out===0?-5:v);if(P.strm=w,G=P.last_flush,P.last_flush=X,P.status===T)if(P.wrap===2)w.adler=0,ce(P,31),ce(P,139),ce(P,8),P.gzhead?(ce(P,(P.gzhead.text?1:0)+(P.gzhead.hcrc?2:0)+(P.gzhead.extra?4:0)+(P.gzhead.name?8:0)+(P.gzhead.comment?16:0)),ce(P,255&P.gzhead.time),ce(P,P.gzhead.time>>8&255),ce(P,P.gzhead.time>>16&255),ce(P,P.gzhead.time>>24&255),ce(P,P.level===9?2:2<=P.strategy||P.level<2?4:0),ce(P,255&P.gzhead.os),P.gzhead.extra&&P.gzhead.extra.length&&(ce(P,255&P.gzhead.extra.length),ce(P,P.gzhead.extra.length>>8&255)),P.gzhead.hcrc&&(w.adler=u(w.adler,P.pending_buf,P.pending,0)),P.gzindex=0,P.status=69):(ce(P,0),ce(P,0),ce(P,0),ce(P,0),ce(P,0),ce(P,P.level===9?2:2<=P.strategy||P.level<2?4:0),ce(P,3),P.status=L);else{var re=y+(P.w_bits-8<<4)<<8;re|=(2<=P.strategy||P.level<2?0:P.level<6?1:P.level===6?2:3)<<6,P.strstart!==0&&(re|=32),re+=31-re%31,P.status=L,B(P,re),P.strstart!==0&&(B(P,w.adler>>>16),B(P,65535&w.adler)),w.adler=1}if(P.status===69)if(P.gzhead.extra){for(I=P.pending;P.gzindex<(65535&P.gzhead.extra.length)&&(P.pending!==P.pending_buf_size||(P.gzhead.hcrc&&P.pending>I&&(w.adler=u(w.adler,P.pending_buf,P.pending-I,I)),V(w),I=P.pending,P.pending!==P.pending_buf_size));)ce(P,255&P.gzhead.extra[P.gzindex]),P.gzindex++;P.gzhead.hcrc&&P.pending>I&&(w.adler=u(w.adler,P.pending_buf,P.pending-I,I)),P.gzindex===P.gzhead.extra.length&&(P.gzindex=0,P.status=73)}else P.status=73;if(P.status===73)if(P.gzhead.name){I=P.pending;do{if(P.pending===P.pending_buf_size&&(P.gzhead.hcrc&&P.pending>I&&(w.adler=u(w.adler,P.pending_buf,P.pending-I,I)),V(w),I=P.pending,P.pending===P.pending_buf_size)){F=1;break}F=P.gzindex<P.gzhead.name.length?255&P.gzhead.name.charCodeAt(P.gzindex++):0,ce(P,F)}while(F!==0);P.gzhead.hcrc&&P.pending>I&&(w.adler=u(w.adler,P.pending_buf,P.pending-I,I)),F===0&&(P.gzindex=0,P.status=91)}else P.status=91;if(P.status===91)if(P.gzhead.comment){I=P.pending;do{if(P.pending===P.pending_buf_size&&(P.gzhead.hcrc&&P.pending>I&&(w.adler=u(w.adler,P.pending_buf,P.pending-I,I)),V(w),I=P.pending,P.pending===P.pending_buf_size)){F=1;break}F=P.gzindex<P.gzhead.comment.length?255&P.gzhead.comment.charCodeAt(P.gzindex++):0,ce(P,F)}while(F!==0);P.gzhead.hcrc&&P.pending>I&&(w.adler=u(w.adler,P.pending_buf,P.pending-I,I)),F===0&&(P.status=103)}else P.status=103;if(P.status===103&&(P.gzhead.hcrc?(P.pending+2>P.pending_buf_size&&V(w),P.pending+2<=P.pending_buf_size&&(ce(P,255&w.adler),ce(P,w.adler>>8&255),w.adler=0,P.status=L)):P.status=L),P.pending!==0){if(V(w),w.avail_out===0)return P.last_flush=-1,m}else if(w.avail_in===0&&Z(X)<=Z(G)&&X!==h)return H(w,-5);if(P.status===666&&w.avail_in!==0)return H(w,-5);if(w.avail_in!==0||P.lookahead!==0||X!==f&&P.status!==666){var ne=P.strategy===2?(function(q,ae){for(var R;;){if(q.lookahead===0&&(Se(q),q.lookahead===0)){if(ae===f)return _;break}if(q.match_length=0,R=l._tr_tally(q,0,q.window[q.strstart]),q.lookahead--,q.strstart++,R&&(U(q,!1),q.strm.avail_out===0))return _}return q.insert=0,ae===h?(U(q,!0),q.strm.avail_out===0?ee:D):q.last_lit&&(U(q,!1),q.strm.avail_out===0)?_:$})(P,X):P.strategy===3?(function(q,ae){for(var R,M,Y,se,oe=q.window;;){if(q.lookahead<=O){if(Se(q),q.lookahead<=O&&ae===f)return _;if(q.lookahead===0)break}if(q.match_length=0,q.lookahead>=A&&0<q.strstart&&(M=oe[Y=q.strstart-1])===oe[++Y]&&M===oe[++Y]&&M===oe[++Y]){se=q.strstart+O;do;while(M===oe[++Y]&&M===oe[++Y]&&M===oe[++Y]&&M===oe[++Y]&&M===oe[++Y]&&M===oe[++Y]&&M===oe[++Y]&&M===oe[++Y]&&Y<se);q.match_length=O-(se-Y),q.match_length>q.lookahead&&(q.match_length=q.lookahead)}if(q.match_length>=A?(R=l._tr_tally(q,1,q.match_length-A),q.lookahead-=q.match_length,q.strstart+=q.match_length,q.match_length=0):(R=l._tr_tally(q,0,q.window[q.strstart]),q.lookahead--,q.strstart++),R&&(U(q,!1),q.strm.avail_out===0))return _}return q.insert=0,ae===h?(U(q,!0),q.strm.avail_out===0?ee:D):q.last_lit&&(U(q,!1),q.strm.avail_out===0)?_:$})(P,X):i[P.level].func(P,X);if(ne!==ee&&ne!==D||(P.status=666),ne===_||ne===ee)return w.avail_out===0&&(P.last_flush=-1),m;if(ne===$&&(X===1?l._tr_align(P):X!==5&&(l._tr_stored_block(P,0,0,!1),X===3&&(ue(P.head),P.lookahead===0&&(P.strstart=0,P.block_start=0,P.insert=0))),V(w),w.avail_out===0))return P.last_flush=-1,m}return X!==h?m:P.wrap<=0?1:(P.wrap===2?(ce(P,255&w.adler),ce(P,w.adler>>8&255),ce(P,w.adler>>16&255),ce(P,w.adler>>24&255),ce(P,255&w.total_in),ce(P,w.total_in>>8&255),ce(P,w.total_in>>16&255),ce(P,w.total_in>>24&255)):(B(P,w.adler>>>16),B(P,65535&w.adler)),V(w),0<P.wrap&&(P.wrap=-P.wrap),P.pending!==0?m:1)},o.deflateEnd=function(w){var X;return w&&w.state?(X=w.state.status)!==T&&X!==69&&X!==73&&X!==91&&X!==103&&X!==L&&X!==666?H(w,v):(w.state=null,X===L?H(w,-3):m):v},o.deflateSetDictionary=function(w,X){var G,P,I,F,re,ne,q,ae,R=X.length;if(!w||!w.state||(F=(G=w.state).wrap)===2||F===1&&G.status!==T||G.lookahead)return v;for(F===1&&(w.adler=c(w.adler,X,R,0)),G.wrap=0,R>=G.w_size&&(F===0&&(ue(G.head),G.strstart=0,G.block_start=0,G.insert=0),ae=new a.Buf8(G.w_size),a.arraySet(ae,X,R-G.w_size,G.w_size,0),X=ae,R=G.w_size),re=w.avail_in,ne=w.next_in,q=w.input,w.avail_in=R,w.next_in=0,w.input=X,Se(G);G.lookahead>=A;){for(P=G.strstart,I=G.lookahead-(A-1);G.ins_h=(G.ins_h<<G.hash_shift^G.window[P+A-1])&G.hash_mask,G.prev[P&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=P,P++,--I;);G.strstart=P,G.lookahead=A-1,Se(G)}return G.strstart+=G.lookahead,G.block_start=G.strstart,G.insert=G.lookahead,G.lookahead=0,G.match_length=G.prev_length=A-1,G.match_available=0,w.next_in=ne,w.input=q,w.avail_in=re,G.wrap=F,m},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,h,m,v,g,x,b,y,k,j,S,E,N,z,A,O,W,T,L,_,$;l=i.state,c=i.next_in,_=i.input,u=c+(i.avail_in-5),d=i.next_out,$=i.output,f=d-(a-i.avail_out),h=d+(i.avail_out-257),m=l.dmax,v=l.wsize,g=l.whave,x=l.wnext,b=l.window,y=l.hold,k=l.bits,j=l.lencode,S=l.distcode,E=(1<<l.lenbits)-1,N=(1<<l.distbits)-1;e:do{k<15&&(y+=_[c++]<<k,k+=8,y+=_[c++]<<k,k+=8),z=j[y&E];t:for(;;){if(y>>>=A=z>>>24,k-=A,(A=z>>>16&255)===0)$[d++]=65535&z;else{if(!(16&A)){if((64&A)==0){z=j[(65535&z)+(y&(1<<A)-1)];continue t}if(32&A){l.mode=12;break e}i.msg="invalid literal/length code",l.mode=30;break e}O=65535&z,(A&=15)&&(k<A&&(y+=_[c++]<<k,k+=8),O+=y&(1<<A)-1,y>>>=A,k-=A),k<15&&(y+=_[c++]<<k,k+=8,y+=_[c++]<<k,k+=8),z=S[y&N];n:for(;;){if(y>>>=A=z>>>24,k-=A,!(16&(A=z>>>16&255))){if((64&A)==0){z=S[(65535&z)+(y&(1<<A)-1)];continue n}i.msg="invalid distance code",l.mode=30;break e}if(W=65535&z,k<(A&=15)&&(y+=_[c++]<<k,(k+=8)<A&&(y+=_[c++]<<k,k+=8)),m<(W+=y&(1<<A)-1)){i.msg="invalid distance too far back",l.mode=30;break e}if(y>>>=A,k-=A,(A=d-f)<W){if(g<(A=W-A)&&l.sane){i.msg="invalid distance too far back",l.mode=30;break e}if(L=b,(T=0)===x){if(T+=v-A,A<O){for(O-=A;$[d++]=b[T++],--A;);T=d-W,L=$}}else if(x<A){if(T+=v+x-A,(A-=x)<O){for(O-=A;$[d++]=b[T++],--A;);if(T=0,x<O){for(O-=A=x;$[d++]=b[T++],--A;);T=d-W,L=$}}}else if(T+=x-A,A<O){for(O-=A;$[d++]=b[T++],--A;);T=d-W,L=$}for(;2<O;)$[d++]=L[T++],$[d++]=L[T++],$[d++]=L[T++],O-=3;O&&($[d++]=L[T++],1<O&&($[d++]=L[T++]))}else{for(T=d-W;$[d++]=$[T++],$[d++]=$[T++],$[d++]=$[T++],2<(O-=3););O&&($[d++]=$[T++],1<O&&($[d++]=$[T++]))}break}}break}}while(c<u&&d<h);c-=O=k>>3,y&=(1<<(k-=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<h?h-d+257:257-(d-h),l.hold=y,l.bits=k}},{}],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,h=0,m=-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 k(T){var L;return T&&T.state?(L=T.state,T.total_in=T.total_out=L.total=0,T.msg="",L.wrap&&(T.adler=1&L.wrap),L.mode=v,L.last=0,L.havedict=0,L.dmax=32768,L.head=null,L.hold=0,L.bits=0,L.lencode=L.lendyn=new i.Buf32(g),L.distcode=L.distdyn=new i.Buf32(x),L.sane=1,L.back=-1,h):m}function j(T){var L;return T&&T.state?((L=T.state).wsize=0,L.whave=0,L.wnext=0,k(T)):m}function S(T,L){var _,$;return T&&T.state?($=T.state,L<0?(_=0,L=-L):(_=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15<L)?m:($.window!==null&&$.wbits!==L&&($.window=null),$.wrap=_,$.wbits=L,j(T))):m}function E(T,L){var _,$;return T?($=new y,(T.state=$).window=null,(_=S(T,L))!==h&&(T.state=null),_):m}var N,z,A=!0;function O(T){if(A){var L;for(N=new i.Buf32(512),z=new i.Buf32(32),L=0;L<144;)T.lens[L++]=8;for(;L<256;)T.lens[L++]=9;for(;L<280;)T.lens[L++]=7;for(;L<288;)T.lens[L++]=8;for(u(d,T.lens,0,288,N,0,T.work,{bits:9}),L=0;L<32;)T.lens[L++]=5;u(f,T.lens,0,32,z,0,T.work,{bits:5}),A=!1}T.lencode=N,T.lenbits=9,T.distcode=z,T.distbits=5}function W(T,L,_,$){var ee,D=T.state;return D.window===null&&(D.wsize=1<<D.wbits,D.wnext=0,D.whave=0,D.window=new i.Buf8(D.wsize)),$>=D.wsize?(i.arraySet(D.window,L,_-D.wsize,D.wsize,0),D.wnext=0,D.whave=D.wsize):($<(ee=D.wsize-D.wnext)&&(ee=$),i.arraySet(D.window,L,_-$,ee,D.wnext),($-=ee)?(i.arraySet(D.window,L,_-$,$,0),D.wnext=$,D.whave=D.wsize):(D.wnext+=ee,D.wnext===D.wsize&&(D.wnext=0),D.whave<D.wsize&&(D.whave+=ee))),0}o.inflateReset=j,o.inflateReset2=S,o.inflateResetKeep=k,o.inflateInit=function(T){return E(T,15)},o.inflateInit2=E,o.inflate=function(T,L){var _,$,ee,D,H,Z,ue,V,U,ce,B,Q,Se,ie,pe,me,he,xe,ke,Ae,w,X,G,P,I=0,F=new i.Buf8(4),re=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!T||!T.state||!T.output||!T.input&&T.avail_in!==0)return m;(_=T.state).mode===12&&(_.mode=13),H=T.next_out,ee=T.output,ue=T.avail_out,D=T.next_in,$=T.input,Z=T.avail_in,V=_.hold,U=_.bits,ce=Z,B=ue,X=h;e:for(;;)switch(_.mode){case v:if(_.wrap===0){_.mode=13;break}for(;U<16;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}if(2&_.wrap&&V===35615){F[_.check=0]=255&V,F[1]=V>>>8&255,_.check=l(_.check,F,2,0),U=V=0,_.mode=2;break}if(_.flags=0,_.head&&(_.head.done=!1),!(1&_.wrap)||(((255&V)<<8)+(V>>8))%31){T.msg="incorrect header check",_.mode=30;break}if((15&V)!=8){T.msg="unknown compression method",_.mode=30;break}if(U-=4,w=8+(15&(V>>>=4)),_.wbits===0)_.wbits=w;else if(w>_.wbits){T.msg="invalid window size",_.mode=30;break}_.dmax=1<<w,T.adler=_.check=1,_.mode=512&V?10:12,U=V=0;break;case 2:for(;U<16;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}if(_.flags=V,(255&_.flags)!=8){T.msg="unknown compression method",_.mode=30;break}if(57344&_.flags){T.msg="unknown header flags set",_.mode=30;break}_.head&&(_.head.text=V>>8&1),512&_.flags&&(F[0]=255&V,F[1]=V>>>8&255,_.check=l(_.check,F,2,0)),U=V=0,_.mode=3;case 3:for(;U<32;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}_.head&&(_.head.time=V),512&_.flags&&(F[0]=255&V,F[1]=V>>>8&255,F[2]=V>>>16&255,F[3]=V>>>24&255,_.check=l(_.check,F,4,0)),U=V=0,_.mode=4;case 4:for(;U<16;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}_.head&&(_.head.xflags=255&V,_.head.os=V>>8),512&_.flags&&(F[0]=255&V,F[1]=V>>>8&255,_.check=l(_.check,F,2,0)),U=V=0,_.mode=5;case 5:if(1024&_.flags){for(;U<16;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}_.length=V,_.head&&(_.head.extra_len=V),512&_.flags&&(F[0]=255&V,F[1]=V>>>8&255,_.check=l(_.check,F,2,0)),U=V=0}else _.head&&(_.head.extra=null);_.mode=6;case 6:if(1024&_.flags&&(Z<(Q=_.length)&&(Q=Z),Q&&(_.head&&(w=_.head.extra_len-_.length,_.head.extra||(_.head.extra=new Array(_.head.extra_len)),i.arraySet(_.head.extra,$,D,Q,w)),512&_.flags&&(_.check=l(_.check,$,Q,D)),Z-=Q,D+=Q,_.length-=Q),_.length))break e;_.length=0,_.mode=7;case 7:if(2048&_.flags){if(Z===0)break e;for(Q=0;w=$[D+Q++],_.head&&w&&_.length<65536&&(_.head.name+=String.fromCharCode(w)),w&&Q<Z;);if(512&_.flags&&(_.check=l(_.check,$,Q,D)),Z-=Q,D+=Q,w)break e}else _.head&&(_.head.name=null);_.length=0,_.mode=8;case 8:if(4096&_.flags){if(Z===0)break e;for(Q=0;w=$[D+Q++],_.head&&w&&_.length<65536&&(_.head.comment+=String.fromCharCode(w)),w&&Q<Z;);if(512&_.flags&&(_.check=l(_.check,$,Q,D)),Z-=Q,D+=Q,w)break e}else _.head&&(_.head.comment=null);_.mode=9;case 9:if(512&_.flags){for(;U<16;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}if(V!==(65535&_.check)){T.msg="header crc mismatch",_.mode=30;break}U=V=0}_.head&&(_.head.hcrc=_.flags>>9&1,_.head.done=!0),T.adler=_.check=0,_.mode=12;break;case 10:for(;U<32;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}T.adler=_.check=b(V),U=V=0,_.mode=11;case 11:if(_.havedict===0)return T.next_out=H,T.avail_out=ue,T.next_in=D,T.avail_in=Z,_.hold=V,_.bits=U,2;T.adler=_.check=1,_.mode=12;case 12:if(L===5||L===6)break e;case 13:if(_.last){V>>>=7&U,U-=7&U,_.mode=27;break}for(;U<3;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}switch(_.last=1&V,U-=1,3&(V>>>=1)){case 0:_.mode=14;break;case 1:if(O(_),_.mode=20,L!==6)break;V>>>=2,U-=2;break e;case 2:_.mode=17;break;case 3:T.msg="invalid block type",_.mode=30}V>>>=2,U-=2;break;case 14:for(V>>>=7&U,U-=7&U;U<32;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}if((65535&V)!=(V>>>16^65535)){T.msg="invalid stored block lengths",_.mode=30;break}if(_.length=65535&V,U=V=0,_.mode=15,L===6)break e;case 15:_.mode=16;case 16:if(Q=_.length){if(Z<Q&&(Q=Z),ue<Q&&(Q=ue),Q===0)break e;i.arraySet(ee,$,D,Q,H),Z-=Q,D+=Q,ue-=Q,H+=Q,_.length-=Q;break}_.mode=12;break;case 17:for(;U<14;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}if(_.nlen=257+(31&V),V>>>=5,U-=5,_.ndist=1+(31&V),V>>>=5,U-=5,_.ncode=4+(15&V),V>>>=4,U-=4,286<_.nlen||30<_.ndist){T.msg="too many length or distance symbols",_.mode=30;break}_.have=0,_.mode=18;case 18:for(;_.have<_.ncode;){for(;U<3;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}_.lens[re[_.have++]]=7&V,V>>>=3,U-=3}for(;_.have<19;)_.lens[re[_.have++]]=0;if(_.lencode=_.lendyn,_.lenbits=7,G={bits:_.lenbits},X=u(0,_.lens,0,19,_.lencode,0,_.work,G),_.lenbits=G.bits,X){T.msg="invalid code lengths set",_.mode=30;break}_.have=0,_.mode=19;case 19:for(;_.have<_.nlen+_.ndist;){for(;me=(I=_.lencode[V&(1<<_.lenbits)-1])>>>16&255,he=65535&I,!((pe=I>>>24)<=U);){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}if(he<16)V>>>=pe,U-=pe,_.lens[_.have++]=he;else{if(he===16){for(P=pe+2;U<P;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}if(V>>>=pe,U-=pe,_.have===0){T.msg="invalid bit length repeat",_.mode=30;break}w=_.lens[_.have-1],Q=3+(3&V),V>>>=2,U-=2}else if(he===17){for(P=pe+3;U<P;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}U-=pe,w=0,Q=3+(7&(V>>>=pe)),V>>>=3,U-=3}else{for(P=pe+7;U<P;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}U-=pe,w=0,Q=11+(127&(V>>>=pe)),V>>>=7,U-=7}if(_.have+Q>_.nlen+_.ndist){T.msg="invalid bit length repeat",_.mode=30;break}for(;Q--;)_.lens[_.have++]=w}}if(_.mode===30)break;if(_.lens[256]===0){T.msg="invalid code -- missing end-of-block",_.mode=30;break}if(_.lenbits=9,G={bits:_.lenbits},X=u(d,_.lens,0,_.nlen,_.lencode,0,_.work,G),_.lenbits=G.bits,X){T.msg="invalid literal/lengths set",_.mode=30;break}if(_.distbits=6,_.distcode=_.distdyn,G={bits:_.distbits},X=u(f,_.lens,_.nlen,_.ndist,_.distcode,0,_.work,G),_.distbits=G.bits,X){T.msg="invalid distances set",_.mode=30;break}if(_.mode=20,L===6)break e;case 20:_.mode=21;case 21:if(6<=Z&&258<=ue){T.next_out=H,T.avail_out=ue,T.next_in=D,T.avail_in=Z,_.hold=V,_.bits=U,c(T,B),H=T.next_out,ee=T.output,ue=T.avail_out,D=T.next_in,$=T.input,Z=T.avail_in,V=_.hold,U=_.bits,_.mode===12&&(_.back=-1);break}for(_.back=0;me=(I=_.lencode[V&(1<<_.lenbits)-1])>>>16&255,he=65535&I,!((pe=I>>>24)<=U);){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}if(me&&(240&me)==0){for(xe=pe,ke=me,Ae=he;me=(I=_.lencode[Ae+((V&(1<<xe+ke)-1)>>xe)])>>>16&255,he=65535&I,!(xe+(pe=I>>>24)<=U);){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}V>>>=xe,U-=xe,_.back+=xe}if(V>>>=pe,U-=pe,_.back+=pe,_.length=he,me===0){_.mode=26;break}if(32&me){_.back=-1,_.mode=12;break}if(64&me){T.msg="invalid literal/length code",_.mode=30;break}_.extra=15&me,_.mode=22;case 22:if(_.extra){for(P=_.extra;U<P;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}_.length+=V&(1<<_.extra)-1,V>>>=_.extra,U-=_.extra,_.back+=_.extra}_.was=_.length,_.mode=23;case 23:for(;me=(I=_.distcode[V&(1<<_.distbits)-1])>>>16&255,he=65535&I,!((pe=I>>>24)<=U);){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}if((240&me)==0){for(xe=pe,ke=me,Ae=he;me=(I=_.distcode[Ae+((V&(1<<xe+ke)-1)>>xe)])>>>16&255,he=65535&I,!(xe+(pe=I>>>24)<=U);){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}V>>>=xe,U-=xe,_.back+=xe}if(V>>>=pe,U-=pe,_.back+=pe,64&me){T.msg="invalid distance code",_.mode=30;break}_.offset=he,_.extra=15&me,_.mode=24;case 24:if(_.extra){for(P=_.extra;U<P;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}_.offset+=V&(1<<_.extra)-1,V>>>=_.extra,U-=_.extra,_.back+=_.extra}if(_.offset>_.dmax){T.msg="invalid distance too far back",_.mode=30;break}_.mode=25;case 25:if(ue===0)break e;if(Q=B-ue,_.offset>Q){if((Q=_.offset-Q)>_.whave&&_.sane){T.msg="invalid distance too far back",_.mode=30;break}Se=Q>_.wnext?(Q-=_.wnext,_.wsize-Q):_.wnext-Q,Q>_.length&&(Q=_.length),ie=_.window}else ie=ee,Se=H-_.offset,Q=_.length;for(ue<Q&&(Q=ue),ue-=Q,_.length-=Q;ee[H++]=ie[Se++],--Q;);_.length===0&&(_.mode=21);break;case 26:if(ue===0)break e;ee[H++]=_.length,ue--,_.mode=21;break;case 27:if(_.wrap){for(;U<32;){if(Z===0)break e;Z--,V|=$[D++]<<U,U+=8}if(B-=ue,T.total_out+=B,_.total+=B,B&&(T.adler=_.check=_.flags?l(_.check,ee,B,H-B):a(_.check,ee,B,H-B)),B=ue,(_.flags?V:b(V))!==_.check){T.msg="incorrect data check",_.mode=30;break}U=V=0}_.mode=28;case 28:if(_.wrap&&_.flags){for(;U<32;){if(Z===0)break e;Z--,V+=$[D++]<<U,U+=8}if(V!==(4294967295&_.total)){T.msg="incorrect length check",_.mode=30;break}U=V=0}_.mode=29;case 29:X=1;break e;case 30:X=-3;break e;case 31:return-4;default:return m}return T.next_out=H,T.avail_out=ue,T.next_in=D,T.avail_in=Z,_.hold=V,_.bits=U,(_.wsize||B!==T.avail_out&&_.mode<30&&(_.mode<27||L!==4))&&W(T,T.output,T.next_out,B-T.avail_out)?(_.mode=31,-4):(ce-=T.avail_in,B-=T.avail_out,T.total_in+=ce,T.total_out+=B,_.total+=B,_.wrap&&B&&(T.adler=_.check=_.flags?l(_.check,ee,B,T.next_out-B):a(_.check,ee,B,T.next_out-B)),T.data_type=_.bits+(_.last?64:0)+(_.mode===12?128:0)+(_.mode===20||_.mode===15?256:0),(ce==0&&B===0||L===4)&&X===h&&(X=-5),X)},o.inflateEnd=function(T){if(!T||!T.state)return m;var L=T.state;return L.window&&(L.window=null),T.state=null,h},o.inflateGetHeader=function(T,L){var _;return T&&T.state?(2&(_=T.state).wrap)==0?m:((_.head=L).done=!1,h):m},o.inflateSetDictionary=function(T,L){var _,$=L.length;return T&&T.state?(_=T.state).wrap!==0&&_.mode!==11?m:_.mode===11&&a(1,L,$,0)!==_.check?-3:W(T,L,$,$)?(_.mode=31,-4):(_.havedict=1,h):m},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,h,m,v,g,x,b){var y,k,j,S,E,N,z,A,O,W=b.bits,T=0,L=0,_=0,$=0,ee=0,D=0,H=0,Z=0,ue=0,V=0,U=null,ce=0,B=new i.Buf16(16),Q=new i.Buf16(16),Se=null,ie=0;for(T=0;T<=15;T++)B[T]=0;for(L=0;L<m;L++)B[f[h+L]]++;for(ee=W,$=15;1<=$&&B[$]===0;$--);if($<ee&&(ee=$),$===0)return v[g++]=20971520,v[g++]=20971520,b.bits=1,0;for(_=1;_<$&&B[_]===0;_++);for(ee<_&&(ee=_),T=Z=1;T<=15;T++)if(Z<<=1,(Z-=B[T])<0)return-1;if(0<Z&&(d===0||$!==1))return-1;for(Q[1]=0,T=1;T<15;T++)Q[T+1]=Q[T]+B[T];for(L=0;L<m;L++)f[h+L]!==0&&(x[Q[f[h+L]]++]=L);if(N=d===0?(U=Se=x,19):d===1?(U=a,ce-=257,Se=l,ie-=257,256):(U=c,Se=u,-1),T=_,E=g,H=L=V=0,j=-1,S=(ue=1<<(D=ee))-1,d===1&&852<ue||d===2&&592<ue)return 1;for(;;){for(z=T-H,O=x[L]<N?(A=0,x[L]):x[L]>N?(A=Se[ie+x[L]],U[ce+x[L]]):(A=96,0),y=1<<T-H,_=k=1<<D;v[E+(V>>H)+(k-=y)]=z<<24|A<<16|O|0,k!==0;);for(y=1<<T-1;V&y;)y>>=1;if(y!==0?(V&=y-1,V+=y):V=0,L++,--B[T]==0){if(T===$)break;T=f[h+x[L]]}if(ee<T&&(V&S)!==j){for(H===0&&(H=ee),E+=_,Z=1<<(D=T-H);D+H<$&&!((Z-=B[D+H])<=0);)D++,Z<<=1;if(ue+=1<<D,d===1&&852<ue||d===2&&592<ue)return 1;v[j=V&S]=ee<<24|D<<16|E-g|0}}return V!==0&&(v[E+V]=T-H<<24|64<<16|0),b.bits=ee,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(I){for(var F=I.length;0<=--F;)I[F]=0}var u=0,d=29,f=256,h=f+1+d,m=30,v=19,g=2*h+1,x=15,b=16,y=7,k=256,j=16,S=17,E=18,N=[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],z=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],O=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],W=new Array(2*(h+2));c(W);var T=new Array(2*m);c(T);var L=new Array(512);c(L);var _=new Array(256);c(_);var $=new Array(d);c($);var ee,D,H,Z=new Array(m);function ue(I,F,re,ne,q){this.static_tree=I,this.extra_bits=F,this.extra_base=re,this.elems=ne,this.max_length=q,this.has_stree=I&&I.length}function V(I,F){this.dyn_tree=I,this.max_code=0,this.stat_desc=F}function U(I){return I<256?L[I]:L[256+(I>>>7)]}function ce(I,F){I.pending_buf[I.pending++]=255&F,I.pending_buf[I.pending++]=F>>>8&255}function B(I,F,re){I.bi_valid>b-re?(I.bi_buf|=F<<I.bi_valid&65535,ce(I,I.bi_buf),I.bi_buf=F>>b-I.bi_valid,I.bi_valid+=re-b):(I.bi_buf|=F<<I.bi_valid&65535,I.bi_valid+=re)}function Q(I,F,re){B(I,re[2*F],re[2*F+1])}function Se(I,F){for(var re=0;re|=1&I,I>>>=1,re<<=1,0<--F;);return re>>>1}function ie(I,F,re){var ne,q,ae=new Array(x+1),R=0;for(ne=1;ne<=x;ne++)ae[ne]=R=R+re[ne-1]<<1;for(q=0;q<=F;q++){var M=I[2*q+1];M!==0&&(I[2*q]=Se(ae[M]++,M))}}function pe(I){var F;for(F=0;F<h;F++)I.dyn_ltree[2*F]=0;for(F=0;F<m;F++)I.dyn_dtree[2*F]=0;for(F=0;F<v;F++)I.bl_tree[2*F]=0;I.dyn_ltree[2*k]=1,I.opt_len=I.static_len=0,I.last_lit=I.matches=0}function me(I){8<I.bi_valid?ce(I,I.bi_buf):0<I.bi_valid&&(I.pending_buf[I.pending++]=I.bi_buf),I.bi_buf=0,I.bi_valid=0}function he(I,F,re,ne){var q=2*F,ae=2*re;return I[q]<I[ae]||I[q]===I[ae]&&ne[F]<=ne[re]}function xe(I,F,re){for(var ne=I.heap[re],q=re<<1;q<=I.heap_len&&(q<I.heap_len&&he(F,I.heap[q+1],I.heap[q],I.depth)&&q++,!he(F,ne,I.heap[q],I.depth));)I.heap[re]=I.heap[q],re=q,q<<=1;I.heap[re]=ne}function ke(I,F,re){var ne,q,ae,R,M=0;if(I.last_lit!==0)for(;ne=I.pending_buf[I.d_buf+2*M]<<8|I.pending_buf[I.d_buf+2*M+1],q=I.pending_buf[I.l_buf+M],M++,ne===0?Q(I,q,F):(Q(I,(ae=_[q])+f+1,F),(R=N[ae])!==0&&B(I,q-=$[ae],R),Q(I,ae=U(--ne),re),(R=z[ae])!==0&&B(I,ne-=Z[ae],R)),M<I.last_lit;);Q(I,k,F)}function Ae(I,F){var re,ne,q,ae=F.dyn_tree,R=F.stat_desc.static_tree,M=F.stat_desc.has_stree,Y=F.stat_desc.elems,se=-1;for(I.heap_len=0,I.heap_max=g,re=0;re<Y;re++)ae[2*re]!==0?(I.heap[++I.heap_len]=se=re,I.depth[re]=0):ae[2*re+1]=0;for(;I.heap_len<2;)ae[2*(q=I.heap[++I.heap_len]=se<2?++se:0)]=1,I.depth[q]=0,I.opt_len--,M&&(I.static_len-=R[2*q+1]);for(F.max_code=se,re=I.heap_len>>1;1<=re;re--)xe(I,ae,re);for(q=Y;re=I.heap[1],I.heap[1]=I.heap[I.heap_len--],xe(I,ae,1),ne=I.heap[1],I.heap[--I.heap_max]=re,I.heap[--I.heap_max]=ne,ae[2*q]=ae[2*re]+ae[2*ne],I.depth[q]=(I.depth[re]>=I.depth[ne]?I.depth[re]:I.depth[ne])+1,ae[2*re+1]=ae[2*ne+1]=q,I.heap[1]=q++,xe(I,ae,1),2<=I.heap_len;);I.heap[--I.heap_max]=I.heap[1],(function(oe,ge){var Ce,je,ze,Be,Rt,cn,gt=ge.dyn_tree,ot=ge.max_code,Xt=ge.stat_desc.static_tree,Yn=ge.stat_desc.has_stree,$e=ge.stat_desc.extra_bits,pt=ge.stat_desc.extra_base,et=ge.stat_desc.max_length,Ut=0;for(Be=0;Be<=x;Be++)oe.bl_count[Be]=0;for(gt[2*oe.heap[oe.heap_max]+1]=0,Ce=oe.heap_max+1;Ce<g;Ce++)et<(Be=gt[2*gt[2*(je=oe.heap[Ce])+1]+1]+1)&&(Be=et,Ut++),gt[2*je+1]=Be,ot<je||(oe.bl_count[Be]++,Rt=0,pt<=je&&(Rt=$e[je-pt]),cn=gt[2*je],oe.opt_len+=cn*(Be+Rt),Yn&&(oe.static_len+=cn*(Xt[2*je+1]+Rt)));if(Ut!==0){do{for(Be=et-1;oe.bl_count[Be]===0;)Be--;oe.bl_count[Be]--,oe.bl_count[Be+1]+=2,oe.bl_count[et]--,Ut-=2}while(0<Ut);for(Be=et;Be!==0;Be--)for(je=oe.bl_count[Be];je!==0;)ot<(ze=oe.heap[--Ce])||(gt[2*ze+1]!==Be&&(oe.opt_len+=(Be-gt[2*ze+1])*gt[2*ze],gt[2*ze+1]=Be),je--)}})(I,F),ie(ae,se,I.bl_count)}function w(I,F,re){var ne,q,ae=-1,R=F[1],M=0,Y=7,se=4;for(R===0&&(Y=138,se=3),F[2*(re+1)+1]=65535,ne=0;ne<=re;ne++)q=R,R=F[2*(ne+1)+1],++M<Y&&q===R||(M<se?I.bl_tree[2*q]+=M:q!==0?(q!==ae&&I.bl_tree[2*q]++,I.bl_tree[2*j]++):M<=10?I.bl_tree[2*S]++:I.bl_tree[2*E]++,ae=q,se=(M=0)===R?(Y=138,3):q===R?(Y=6,3):(Y=7,4))}function X(I,F,re){var ne,q,ae=-1,R=F[1],M=0,Y=7,se=4;for(R===0&&(Y=138,se=3),ne=0;ne<=re;ne++)if(q=R,R=F[2*(ne+1)+1],!(++M<Y&&q===R)){if(M<se)for(;Q(I,q,I.bl_tree),--M!=0;);else q!==0?(q!==ae&&(Q(I,q,I.bl_tree),M--),Q(I,j,I.bl_tree),B(I,M-3,2)):M<=10?(Q(I,S,I.bl_tree),B(I,M-3,3)):(Q(I,E,I.bl_tree),B(I,M-11,7));ae=q,se=(M=0)===R?(Y=138,3):q===R?(Y=6,3):(Y=7,4)}}c(Z);var G=!1;function P(I,F,re,ne){B(I,(u<<1)+(ne?1:0),3),(function(q,ae,R,M){me(q),ce(q,R),ce(q,~R),i.arraySet(q.pending_buf,q.window,ae,R,q.pending),q.pending+=R})(I,F,re)}o._tr_init=function(I){G||((function(){var F,re,ne,q,ae,R=new Array(x+1);for(q=ne=0;q<d-1;q++)for($[q]=ne,F=0;F<1<<N[q];F++)_[ne++]=q;for(_[ne-1]=q,q=ae=0;q<16;q++)for(Z[q]=ae,F=0;F<1<<z[q];F++)L[ae++]=q;for(ae>>=7;q<m;q++)for(Z[q]=ae<<7,F=0;F<1<<z[q]-7;F++)L[256+ae++]=q;for(re=0;re<=x;re++)R[re]=0;for(F=0;F<=143;)W[2*F+1]=8,F++,R[8]++;for(;F<=255;)W[2*F+1]=9,F++,R[9]++;for(;F<=279;)W[2*F+1]=7,F++,R[7]++;for(;F<=287;)W[2*F+1]=8,F++,R[8]++;for(ie(W,h+1,R),F=0;F<m;F++)T[2*F+1]=5,T[2*F]=Se(F,5);ee=new ue(W,N,f+1,h,x),D=new ue(T,z,0,m,x),H=new ue(new Array(0),A,0,v,y)})(),G=!0),I.l_desc=new V(I.dyn_ltree,ee),I.d_desc=new V(I.dyn_dtree,D),I.bl_desc=new V(I.bl_tree,H),I.bi_buf=0,I.bi_valid=0,pe(I)},o._tr_stored_block=P,o._tr_flush_block=function(I,F,re,ne){var q,ae,R=0;0<I.level?(I.strm.data_type===2&&(I.strm.data_type=(function(M){var Y,se=4093624447;for(Y=0;Y<=31;Y++,se>>>=1)if(1&se&&M.dyn_ltree[2*Y]!==0)return a;if(M.dyn_ltree[18]!==0||M.dyn_ltree[20]!==0||M.dyn_ltree[26]!==0)return l;for(Y=32;Y<f;Y++)if(M.dyn_ltree[2*Y]!==0)return l;return a})(I)),Ae(I,I.l_desc),Ae(I,I.d_desc),R=(function(M){var Y;for(w(M,M.dyn_ltree,M.l_desc.max_code),w(M,M.dyn_dtree,M.d_desc.max_code),Ae(M,M.bl_desc),Y=v-1;3<=Y&&M.bl_tree[2*O[Y]+1]===0;Y--);return M.opt_len+=3*(Y+1)+5+5+4,Y})(I),q=I.opt_len+3+7>>>3,(ae=I.static_len+3+7>>>3)<=q&&(q=ae)):q=ae=re+5,re+4<=q&&F!==-1?P(I,F,re,ne):I.strategy===4||ae===q?(B(I,2+(ne?1:0),3),ke(I,W,T)):(B(I,4+(ne?1:0),3),(function(M,Y,se,oe){var ge;for(B(M,Y-257,5),B(M,se-1,5),B(M,oe-4,4),ge=0;ge<oe;ge++)B(M,M.bl_tree[2*O[ge]+1],3);X(M,M.dyn_ltree,Y-1),X(M,M.dyn_dtree,se-1)})(I,I.l_desc.max_code+1,I.d_desc.max_code+1,R+1),ke(I,I.dyn_ltree,I.dyn_dtree)),pe(I),ne&&me(I)},o._tr_tally=function(I,F,re){return I.pending_buf[I.d_buf+2*I.last_lit]=F>>>8&255,I.pending_buf[I.d_buf+2*I.last_lit+1]=255&F,I.pending_buf[I.l_buf+I.last_lit]=255&re,I.last_lit++,F===0?I.dyn_ltree[2*re]++:(I.matches++,F--,I.dyn_ltree[2*(_[re]+f+1)]++,I.dyn_dtree[2*U(F)]++),I.last_lit===I.lit_bufsize-1},o._tr_align=function(I){B(I,2,3),Q(I,k,W),(function(F){F.bi_valid===16?(ce(F,F.bi_buf),F.bi_buf=0,F.bi_valid=0):8<=F.bi_valid&&(F.pending_buf[F.pending++]=255&F.bi_buf,F.bi_buf>>=8,F.bi_valid-=8)})(I)}},{"../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,h=1,m={},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",k,!1):a.attachEvent("onmessage",k),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 N={callback:j,args:S};return m[h]=N,c(h),h++},x.clearImmediate=b}function b(j){delete m[j]}function y(j){if(v)setTimeout(y,0,j);else{var S=m[j];if(S){v=!0;try{(function(E){var N=E.callback,z=E.args;switch(z.length){case 0:N();break;case 1:N(z[0]);break;case 2:N(z[0],z[1]);break;case 3:N(z[0],z[1],z[2]);break;default:N.apply(l,z)}})(S)}finally{b(j),v=!1}}}}function k(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 ms<"u"?ms:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(vi)),vi.exports}var u_=c_();const d_=L0(u_),f_="3.0.9",ca={version:f_},Pf="[REDACTED]",p_=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,h_=[/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],Ic=200,m_=25e6,Mf=50,g_=1e4;function x_(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function b_(e){let t=0;for(const n of e)t+=n.rawRequestBody?.length??0,t+=n.responseText?.length??0;return t}function v_(e){if(e.length>Ic)return`Export is limited to ${Ic} logs at once. Narrow the filter and try again.`;const t=b_(e);return t>m_?`Export is too large (${x_(t)} of text). Narrow the filter and try again.`:null}function ws(e){return e?.aborted===!0?{ok:!1,message:"Export canceled.",canceled:!0}:null}async function y_(e,t){try{const n=await Pn(`/api/logs/${e}/chunks`,g_,{signal:t});if(!n.ok)return null;const r=await n.json();return JSON.stringify(r,null,2)}catch{return null}}function w_(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ua(e){if(Array.isArray(e))return e.map(n=>ua(n));if(!w_(e))return e;const t={};for(const[n,r]of Object.entries(e))t[n]=p_.test(n)?Pf:ua(r);return t}function __(e){const t=n=>{let r=n;for(const o of h_)r=r.replace(o,Pf);return r};try{const n=JSON.parse(e);return t(JSON.stringify(ua(n),null,2))}catch{return t(e)}}function yi(e,t){return t==="redacted"?__(e):e}function k_(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 j_(e,t,n,r=new Date().toISOString()){return{version:ca.version,exportedAt:r,mode:t,redacted:t==="redacted",logCount:e.length,logIds:e.map(o=>o.id),streamingChunkExportLimit:Mf,streamingChunkLogIds:n.map(o=>o.id)}}async function S_(e,t="redacted",n={}){const r=ws(n.signal);if(r!==null)return r;const o=v_(e);if(o!==null)return{ok:!1,message:o};const i=new d_,a=t==="redacted"?"redacted":"raw",l=e.filter(h=>h.streaming).slice(0,Mf);i.file("manifest.json",JSON.stringify(j_(e,t,l),null,2)),i.file("logs.json",JSON.stringify(e.map(h=>k_(h,t)),null,2));for(const h of e){const m=ws(n.signal);if(m!==null)return m;h.rawRequestBody!==null&&i.file(`#${h.id}.Request.json`,yi(h.rawRequestBody,t)),h.responseText!==null&&i.file(`#${h.id}.Response.json`,yi(h.responseText,t))}for(const h of l){const m=ws(n.signal);if(m!==null)return m;const v=await y_(h.id,n.signal);v!==null&&i.file(`#${h.id}.SSE.Response.json`,yi(v,t))}const c=await i.generateAsync({type:"blob"}),u=ws(n.signal);if(u!==null)return u;const d=URL.createObjectURL(c),f=document.createElement("a");return f.href=d,f.download=`agent-inspector-export-${a}-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(d),{ok:!0}}function C_(e,t){if(e!==null){e.removeAllRanges();for(const n of t)e.addRange(n)}}function N_(e){if(e===null)return[];const t=[];for(let n=0;n<e.rangeCount;n++)t.push(e.getRangeAt(n));return t}function T_(e){if(typeof document>"u")return!1;const t=document.activeElement,n=document.getSelection(),r=N_(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),C_(n,r),typeof HTMLElement<"u"&&t instanceof HTMLElement&&t.focus({preventScroll:!0})}return i}async function Lt(e){const t=globalThis.navigator?.clipboard;if(t!==void 0)try{return await t.writeText(e),!0}catch{}return T_(e)}function da(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 bl(e,t,n){return`${da(e,n)} - ${da(t,n)}`}function _s(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function E_(e){switch(e){case"end_turn":case"tool_use":return e;case"max_tokens":return"length";default:return null}}function A_(e){switch(e){case"stop":case"length":return e;case"max_tokens":return"length";default:return null}}function R_(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function Lf(e){if(e.responseText===null)return null;try{let t=JSON.parse(e.responseText);if(typeof t=="string"&&(t=JSON.parse(t)),!_s(t))return null;if(typeof t.stop_reason=="string")return E_(t.stop_reason);if(Array.isArray(t.choices))for(const n of t.choices){if(!_s(n)||typeof n.finish_reason!="string")continue;const r=A_(n.finish_reason);if(r!==null)return r}if(Array.isArray(t.output)){for(const n of t.output)if(_s(n)&&n.type==="function_call")return"tool_use";if(t.status==="completed")return"stop"}if(t.status==="incomplete"&&_s(t.incomplete_details)){const n=t.incomplete_details.reason;if(typeof n=="string"&&R_(n))return"length"}return null}catch{return null}}function vl(e){return e==="end_turn"||e==="stop"||e==="length"}function Df(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=Df(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function $f(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Df(e))&&(r&&(r+=" "),r+=t);return r}const I_=(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},z_=(e,t)=>({classGroupId:e,validator:t}),Ff=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),uo="-",zc=[],O_="arbitrary..",P_=e=>{const t=L_(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return M_(a);const l=a.split(uo),c=l[0]===""&&l.length>1?1:0;return Bf(l,c,t)},getConflictingClassGroupIds:(a,l)=>{if(l){const c=r[a],u=n[a];return c?u?I_(u,c):c:u||zc}return n[a]||zc}}},Bf=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],i=n.nextPart.get(o);if(i){const u=Bf(e,t+1,i);if(u)return u}const a=n.validators;if(a===null)return;const l=t===0?e.join(uo):e.slice(t).join(uo),c=a.length;for(let u=0;u<c;u++){const d=a[u];if(d.validator(l))return d.classGroupId}},M_=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?O_+r:void 0})(),L_=e=>{const{theme:t,classGroups:n}=e;return D_(n,t)},D_=(e,t)=>{const n=Ff();for(const r in e){const o=e[r];yl(o,n,r,t)}return n},yl=(e,t,n,r)=>{const o=e.length;for(let i=0;i<o;i++){const a=e[i];$_(a,t,n,r)}},$_=(e,t,n,r)=>{if(typeof e=="string"){F_(e,t,n);return}if(typeof e=="function"){B_(e,t,n,r);return}U_(e,t,n,r)},F_=(e,t,n)=>{const r=e===""?t:Uf(t,e);r.classGroupId=n},B_=(e,t,n,r)=>{if(W_(e)){yl(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(z_(n,e))},U_=(e,t,n,r)=>{const o=Object.entries(e),i=o.length;for(let a=0;a<i;a++){const[l,c]=o[a];yl(c,Uf(t,l),n,r)}},Uf=(e,t)=>{let n=e;const r=t.split(uo),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},W_=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,H_=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)}}},fa="!",Oc=":",V_=[],Pc=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),q_=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===Oc){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 h=f,m=!1;f.endsWith(fa)?(h=f.slice(0,-1),m=!0):f.startsWith(fa)&&(h=f.slice(1),m=!0);const v=u&&u>c?u-c:void 0;return Pc(i,m,h,v)};if(t){const o=t+Oc,i=r;r=a=>a.startsWith(o)?i(a.slice(o.length)):Pc(V_,!1,a,void 0,!0)}if(n){const o=r;r=i=>n({className:i,parseClassName:o})}return r},Z_=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}},G_=e=>({cache:H_(e.cacheSize),parseClassName:q_(e),sortModifiers:Z_(e),...P_(e)}),K_=/\s+/,J_=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:i}=t,a=[],l=e.trim().split(K_);let c="";for(let u=l.length-1;u>=0;u-=1){const d=l[u],{isExternal:f,modifiers:h,hasImportantModifier:m,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=h.length===0?"":h.length===1?h[0]:i(h).join(":"),k=m?y+fa:y,j=k+b;if(a.indexOf(j)>-1)continue;a.push(j);const S=o(b,x);for(let E=0;E<S.length;++E){const N=S[E];a.push(k+N)}c=d+(c.length>0?" "+c:c)}return c},Y_=(...e)=>{let t=0,n,r,o="";for(;t<e.length;)(n=e[t++])&&(r=Wf(n))&&(o&&(o+=" "),o+=r);return o},Wf=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Wf(e[r]))&&(n&&(n+=" "),n+=t);return n},X_=(e,...t)=>{let n,r,o,i;const a=c=>{const u=t.reduce((d,f)=>f(d),e());return n=G_(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=J_(c,n);return o(c,d),d};return i=a,(...c)=>i(Y_(...c))},Q_=[],Qe=e=>{const t=n=>n[e]||Q_;return t.isThemeGetter=!0,t},Hf=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Vf=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ek=/^\d+\/\d+$/,tk=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,nk=/\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$/,rk=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,sk=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ok=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Xn=e=>ek.test(e),Ie=e=>!!e&&!Number.isNaN(Number(e)),un=e=>!!e&&Number.isInteger(Number(e)),wi=e=>e.endsWith("%")&&Ie(e.slice(0,-1)),Qt=e=>tk.test(e),ik=()=>!0,ak=e=>nk.test(e)&&!rk.test(e),qf=()=>!1,lk=e=>sk.test(e),ck=e=>ok.test(e),uk=e=>!be(e)&&!ve(e),dk=e=>Nr(e,Kf,qf),be=e=>Hf.test(e),En=e=>Nr(e,Jf,ak),_i=e=>Nr(e,gk,Ie),Mc=e=>Nr(e,Zf,qf),fk=e=>Nr(e,Gf,ck),ks=e=>Nr(e,Yf,lk),ve=e=>Vf.test(e),zr=e=>Tr(e,Jf),pk=e=>Tr(e,xk),Lc=e=>Tr(e,Zf),hk=e=>Tr(e,Kf),mk=e=>Tr(e,Gf),js=e=>Tr(e,Yf,!0),Nr=(e,t,n)=>{const r=Hf.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Tr=(e,t,n=!1)=>{const r=Vf.exec(e);return r?r[1]?t(r[1]):n:!1},Zf=e=>e==="position"||e==="percentage",Gf=e=>e==="image"||e==="url",Kf=e=>e==="length"||e==="size"||e==="bg-size",Jf=e=>e==="length",gk=e=>e==="number",xk=e=>e==="family-name",Yf=e=>e==="shadow",bk=()=>{const e=Qe("color"),t=Qe("font"),n=Qe("text"),r=Qe("font-weight"),o=Qe("tracking"),i=Qe("leading"),a=Qe("breakpoint"),l=Qe("container"),c=Qe("spacing"),u=Qe("radius"),d=Qe("shadow"),f=Qe("inset-shadow"),h=Qe("text-shadow"),m=Qe("drop-shadow"),v=Qe("blur"),g=Qe("perspective"),x=Qe("aspect"),b=Qe("ease"),y=Qe("animate"),k=()=>["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(),ve,be],E=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],z=()=>[ve,be,c],A=()=>[Xn,"full","auto",...z()],O=()=>[un,"none","subgrid",ve,be],W=()=>["auto",{span:["full",un,ve,be]},un,ve,be],T=()=>[un,"auto",ve,be],L=()=>["auto","min","max","fr",ve,be],_=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],$=()=>["start","end","center","stretch","center-safe","end-safe"],ee=()=>["auto",...z()],D=()=>[Xn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...z()],H=()=>[e,ve,be],Z=()=>[...j(),Lc,Mc,{position:[ve,be]}],ue=()=>["no-repeat",{repeat:["","x","y","space","round"]}],V=()=>["auto","cover","contain",hk,dk,{size:[ve,be]}],U=()=>[wi,zr,En],ce=()=>["","none","full",u,ve,be],B=()=>["",Ie,zr,En],Q=()=>["solid","dashed","dotted","double"],Se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ie=()=>[Ie,wi,Lc,Mc],pe=()=>["","none",v,ve,be],me=()=>["none",Ie,ve,be],he=()=>["none",Ie,ve,be],xe=()=>[Ie,ve,be],ke=()=>[Xn,"full",...z()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Qt],breakpoint:[Qt],color:[ik],container:[Qt],"drop-shadow":[Qt],ease:["in","out","in-out"],font:[uk],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Qt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Qt],shadow:[Qt],spacing:["px",Ie],text:[Qt],"text-shadow":[Qt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Xn,be,ve,x]}],container:["container"],columns:[{columns:[Ie,be,ve,l]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"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:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{start:A()}],end:[{end:A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[un,"auto",ve,be]}],basis:[{basis:[Xn,"full","auto",l,...z()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ie,Xn,"auto","initial","none",be]}],grow:[{grow:["",Ie,ve,be]}],shrink:[{shrink:["",Ie,ve,be]}],order:[{order:[un,"first","last","none",ve,be]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:W()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:W()}],"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":L()}],"auto-rows":[{"auto-rows":L()}],gap:[{gap:z()}],"gap-x":[{"gap-x":z()}],"gap-y":[{"gap-y":z()}],"justify-content":[{justify:[..._(),"normal"]}],"justify-items":[{"justify-items":[...$(),"normal"]}],"justify-self":[{"justify-self":["auto",...$()]}],"align-content":[{content:["normal",..._()]}],"align-items":[{items:[...$(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...$(),{baseline:["","last"]}]}],"place-content":[{"place-content":_()}],"place-items":[{"place-items":[...$(),"baseline"]}],"place-self":[{"place-self":["auto",...$()]}],p:[{p:z()}],px:[{px:z()}],py:[{py:z()}],ps:[{ps:z()}],pe:[{pe:z()}],pt:[{pt:z()}],pr:[{pr:z()}],pb:[{pb:z()}],pl:[{pl:z()}],m:[{m:ee()}],mx:[{mx:ee()}],my:[{my:ee()}],ms:[{ms:ee()}],me:[{me:ee()}],mt:[{mt:ee()}],mr:[{mr:ee()}],mb:[{mb:ee()}],ml:[{ml:ee()}],"space-x":[{"space-x":z()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":z()}],"space-y-reverse":["space-y-reverse"],size:[{size:D()}],w:[{w:[l,"screen",...D()]}],"min-w":[{"min-w":[l,"screen","none",...D()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[a]},...D()]}],h:[{h:["screen","lh",...D()]}],"min-h":[{"min-h":["screen","lh","none",...D()]}],"max-h":[{"max-h":["screen","lh",...D()]}],"font-size":[{text:["base",n,zr,En]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,ve,_i]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",wi,be]}],"font-family":[{font:[pk,be,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,ve,be]}],"line-clamp":[{"line-clamp":[Ie,"none",ve,_i]}],leading:[{leading:[i,...z()]}],"list-image":[{"list-image":["none",ve,be]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ve,be]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:H()}],"text-color":[{text:H()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Q(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ie,"from-font","auto",ve,En]}],"text-decoration-color":[{decoration:H()}],"underline-offset":[{"underline-offset":[Ie,"auto",ve,be]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:z()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ve,be]}],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",ve,be]}],"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:ue()}],"bg-size":[{bg:V()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},un,ve,be],radial:["",ve,be],conic:[un,ve,be]},mk,fk]}],"bg-color":[{bg:H()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:H()}],"gradient-via":[{via:H()}],"gradient-to":[{to:H()}],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:B()}],"border-w-x":[{"border-x":B()}],"border-w-y":[{"border-y":B()}],"border-w-s":[{"border-s":B()}],"border-w-e":[{"border-e":B()}],"border-w-t":[{"border-t":B()}],"border-w-r":[{"border-r":B()}],"border-w-b":[{"border-b":B()}],"border-w-l":[{"border-l":B()}],"divide-x":[{"divide-x":B()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":B()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Q(),"hidden","none"]}],"divide-style":[{divide:[...Q(),"hidden","none"]}],"border-color":[{border:H()}],"border-color-x":[{"border-x":H()}],"border-color-y":[{"border-y":H()}],"border-color-s":[{"border-s":H()}],"border-color-e":[{"border-e":H()}],"border-color-t":[{"border-t":H()}],"border-color-r":[{"border-r":H()}],"border-color-b":[{"border-b":H()}],"border-color-l":[{"border-l":H()}],"divide-color":[{divide:H()}],"outline-style":[{outline:[...Q(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ie,ve,be]}],"outline-w":[{outline:["",Ie,zr,En]}],"outline-color":[{outline:H()}],shadow:[{shadow:["","none",d,js,ks]}],"shadow-color":[{shadow:H()}],"inset-shadow":[{"inset-shadow":["none",f,js,ks]}],"inset-shadow-color":[{"inset-shadow":H()}],"ring-w":[{ring:B()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:H()}],"ring-offset-w":[{"ring-offset":[Ie,En]}],"ring-offset-color":[{"ring-offset":H()}],"inset-ring-w":[{"inset-ring":B()}],"inset-ring-color":[{"inset-ring":H()}],"text-shadow":[{"text-shadow":["none",h,js,ks]}],"text-shadow-color":[{"text-shadow":H()}],opacity:[{opacity:[Ie,ve,be]}],"mix-blend":[{"mix-blend":[...Se(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Se()}],"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":[Ie]}],"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":H()}],"mask-image-linear-to-color":[{"mask-linear-to":H()}],"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":H()}],"mask-image-t-to-color":[{"mask-t-to":H()}],"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":H()}],"mask-image-r-to-color":[{"mask-r-to":H()}],"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":H()}],"mask-image-b-to-color":[{"mask-b-to":H()}],"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":H()}],"mask-image-l-to-color":[{"mask-l-to":H()}],"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":H()}],"mask-image-x-to-color":[{"mask-x-to":H()}],"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":H()}],"mask-image-y-to-color":[{"mask-y-to":H()}],"mask-image-radial":[{"mask-radial":[ve,be]}],"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":H()}],"mask-image-radial-to-color":[{"mask-radial-to":H()}],"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":[Ie]}],"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":H()}],"mask-image-conic-to-color":[{"mask-conic-to":H()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Z()}],"mask-repeat":[{mask:ue()}],"mask-size":[{mask:V()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ve,be]}],filter:[{filter:["","none",ve,be]}],blur:[{blur:pe()}],brightness:[{brightness:[Ie,ve,be]}],contrast:[{contrast:[Ie,ve,be]}],"drop-shadow":[{"drop-shadow":["","none",m,js,ks]}],"drop-shadow-color":[{"drop-shadow":H()}],grayscale:[{grayscale:["",Ie,ve,be]}],"hue-rotate":[{"hue-rotate":[Ie,ve,be]}],invert:[{invert:["",Ie,ve,be]}],saturate:[{saturate:[Ie,ve,be]}],sepia:[{sepia:["",Ie,ve,be]}],"backdrop-filter":[{"backdrop-filter":["","none",ve,be]}],"backdrop-blur":[{"backdrop-blur":pe()}],"backdrop-brightness":[{"backdrop-brightness":[Ie,ve,be]}],"backdrop-contrast":[{"backdrop-contrast":[Ie,ve,be]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ie,ve,be]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ie,ve,be]}],"backdrop-invert":[{"backdrop-invert":["",Ie,ve,be]}],"backdrop-opacity":[{"backdrop-opacity":[Ie,ve,be]}],"backdrop-saturate":[{"backdrop-saturate":[Ie,ve,be]}],"backdrop-sepia":[{"backdrop-sepia":["",Ie,ve,be]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":z()}],"border-spacing-x":[{"border-spacing-x":z()}],"border-spacing-y":[{"border-spacing-y":z()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ve,be]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ie,"initial",ve,be]}],ease:[{ease:["linear","initial",b,ve,be]}],delay:[{delay:[Ie,ve,be]}],animate:[{animate:["none",y,ve,be]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,ve,be]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:me()}],"rotate-x":[{"rotate-x":me()}],"rotate-y":[{"rotate-y":me()}],"rotate-z":[{"rotate-z":me()}],scale:[{scale:he()}],"scale-x":[{"scale-x":he()}],"scale-y":[{"scale-y":he()}],"scale-z":[{"scale-z":he()}],"scale-3d":["scale-3d"],skew:[{skew:xe()}],"skew-x":[{"skew-x":xe()}],"skew-y":[{"skew-y":xe()}],transform:[{transform:[ve,be,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ke()}],"translate-x":[{"translate-x":ke()}],"translate-y":[{"translate-y":ke()}],"translate-z":[{"translate-z":ke()}],"translate-none":["translate-none"],accent:[{accent:H()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:H()}],"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",ve,be]}],"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":z()}],"scroll-mx":[{"scroll-mx":z()}],"scroll-my":[{"scroll-my":z()}],"scroll-ms":[{"scroll-ms":z()}],"scroll-me":[{"scroll-me":z()}],"scroll-mt":[{"scroll-mt":z()}],"scroll-mr":[{"scroll-mr":z()}],"scroll-mb":[{"scroll-mb":z()}],"scroll-ml":[{"scroll-ml":z()}],"scroll-p":[{"scroll-p":z()}],"scroll-px":[{"scroll-px":z()}],"scroll-py":[{"scroll-py":z()}],"scroll-ps":[{"scroll-ps":z()}],"scroll-pe":[{"scroll-pe":z()}],"scroll-pt":[{"scroll-pt":z()}],"scroll-pr":[{"scroll-pr":z()}],"scroll-pb":[{"scroll-pb":z()}],"scroll-pl":[{"scroll-pl":z()}],"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",ve,be]}],fill:[{fill:["none",...H()]}],"stroke-w":[{stroke:[Ie,zr,En,_i]}],stroke:[{stroke:["none",...H()]}],"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"]}},vk=X_(bk);function le(...e){return vk($f(e))}function Fe(e){return e>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+"M":(e/1e3).toFixed(1).replace(/\.0$/,"")+"K"}function Xf(e){return e>=1024*1024?(e/(1024*1024)).toFixed(1).replace(/\.0$/,"")+"M":(e/1024).toFixed(1).replace(/\.0$/,"")+"K"}function Dc(e,t,n){const r=e*10;return!Number.isSafeInteger(r)||r%t!==0?null:(r/t/10).toFixed(1).replace(/\.0$/,"")+n}function yk(e){if(!Number.isSafeInteger(e)||e<=0)return e.toString();if(e>=1024*1024){const n=Dc(e,1048576,"M");if(n!==null)return n}const t=Dc(e,1024,"K");return t!==null?t:e.toString()}function wk(e){if(e===void 0||e==="")return 1;switch(e.toLowerCase()){case"k":return 1024;case"m":return 1024*1024;default:return null}}function fo(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=wk(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 _k(e){return e===null?"pending":e>=200&&e<300?"success":e>=400&&e<500?"client_error":e>=500?"server_error":"pending"}const kk=J({model:C().min(1),contextWindow:K().int().positive().optional(),outputLimit:K().int().positive().optional(),source:Ee(["manual","registry"]).optional(),sourceUrl:C().optional(),updatedAt:C().optional()}),po=J({id:C(),name:C(),apiKey:C(),model:C().optional(),models:fe(C()).min(1),format:Ee(["anthropic","openai"]).optional(),baseUrl:C().optional(),anthropicBaseUrl:C().optional(),openaiBaseUrl:C().optional(),openaiResponsesBaseUrl:C().optional(),authHeader:Ee(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:C().optional(),modelMetadataUrl:C().optional(),modelMetadata:fe(kk).optional(),source:Ee(["company","personal"]).optional(),createdAt:C(),updatedAt:C()});async function jk(e){return Mt(e,po.array(),void 0,t=>`Failed to fetch ${e}: ${t.status}`)}function Qf(){const e=rn("/api/providers?includeSecrets=1",jk,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function Ne(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function $c(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ep(...e){return t=>{let n=!1;const r=e.map(o=>{const i=$c(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():$c(e[o],null)}}}}function De(...e){return p.useCallback(ep(...e),e)}function Sk(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 ln(e,t=[]){let n=[];function r(i,a){const l=p.createContext(a),c=n.length;n=[...n,a];const u=f=>{const{scope:h,children:m,...v}=f,g=h?.[e]?.[c]||l,x=p.useMemo(()=>v,Object.values(v));return s.jsx(g.Provider,{value:x,children:m})};u.displayName=i+"Provider";function d(f,h){const m=h?.[e]?.[c]||l,v=p.useContext(m);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,Ck(o,...t)]}function Ck(...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 nt=globalThis?.document?p.useLayoutEffect:()=>{},Nk=kd[" useId ".trim().toString()]||(()=>{}),Tk=0;function qt(e){const[t,n]=p.useState(Nk());return nt(()=>{n(r=>r??String(Tk++))},[e]),e||(t?`radix-${t}`:"")}var Ek=kd[" useInsertionEffect ".trim().toString()]||nt;function Dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,a]=Ak({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=Rk(d)?d(e):d;f!==e&&a.current?.(f)}else i(d)},[l,e,i,a]);return[c,u]}function Ak({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),i=p.useRef(t);return Ek(()=>{i.current=t},[t]),p.useEffect(()=>{o.current!==n&&(i.current?.(n),o.current=n)},[n,o]),[n,r,i]}function Rk(e){return typeof e=="function"}function yr(e){const t=zk(e),n=p.forwardRef((r,o)=>{const{children:i,...a}=r,l=p.Children.toArray(i),c=l.find(Pk);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 Ik=yr("Slot");function zk(e){const t=p.forwardRef((n,r)=>{const{children:o,...i}=n;if(p.isValidElement(o)){const a=Lk(o),l=Mk(i,o.props);return o.type!==p.Fragment&&(l.ref=r?ep(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 tp=Symbol("radix.slottable");function Ok(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=tp,t}function Pk(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===tp}function Mk(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 Lk(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 Dk=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Re=Dk.reduce((e,t)=>{const n=yr(`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 $k(e,t){e&&ss.flushSync(()=>e.dispatchEvent(t))}function ft(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>t.current?.(...n),[])}function Fk(e,t=globalThis?.document){const n=ft(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 Bk="DismissableLayer",pa="dismissableLayer.update",Uk="dismissableLayer.pointerDownOutside",Wk="dismissableLayer.focusOutside",Fc,np=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ho=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:a,onDismiss:l,...c}=e,u=p.useContext(np),[d,f]=p.useState(null),h=d?.ownerDocument??globalThis?.document,[,m]=p.useState({}),v=De(t,N=>f(N)),g=Array.from(u.layers),[x]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=g.indexOf(x),y=d?g.indexOf(d):-1,k=u.layersWithOutsidePointerEventsDisabled.size>0,j=y>=b,S=qk(N=>{const z=N.target,A=[...u.branches].some(O=>O.contains(z));!j||A||(o?.(N),a?.(N),N.defaultPrevented||l?.())},h),E=Zk(N=>{const z=N.target;[...u.branches].some(O=>O.contains(z))||(i?.(N),a?.(N),N.defaultPrevented||l?.())},h);return Fk(N=>{y===u.layers.size-1&&(r?.(N),!N.defaultPrevented&&l&&(N.preventDefault(),l()))},h),p.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Fc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Bc(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Fc)}},[d,h,n,u]),p.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Bc())},[d,u]),p.useEffect(()=>{const N=()=>m({});return document.addEventListener(pa,N),()=>document.removeEventListener(pa,N)},[]),s.jsx(Re.div,{...c,ref:v,style:{pointerEvents:k?j?"auto":"none":void 0,...e.style},onFocusCapture:Ne(e.onFocusCapture,E.onFocusCapture),onBlurCapture:Ne(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Ne(e.onPointerDownCapture,S.onPointerDownCapture)})});Ho.displayName=Bk;var Hk="DismissableLayerBranch",Vk=p.forwardRef((e,t)=>{const n=p.useContext(np),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(Re.div,{...e,ref:o})});Vk.displayName=Hk;function qk(e,t=globalThis?.document){const n=ft(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let c=function(){rp(Uk,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 Zk(e,t=globalThis?.document){const n=ft(e),r=p.useRef(!1);return p.useEffect(()=>{const o=i=>{i.target&&!r.current&&rp(Wk,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(pa);document.dispatchEvent(e)}function rp(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?$k(o,i):o.dispatchEvent(i)}var ki="focusScope.autoFocusOnMount",ji="focusScope.autoFocusOnUnmount",Uc={bubbles:!1,cancelable:!0},Gk="FocusScope",wl=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...a}=e,[l,c]=p.useState(null),u=ft(o),d=ft(i),f=p.useRef(null),h=De(t,g=>c(g)),m=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(k){if(m.paused||!l)return;const j=k.target;l.contains(j)?f.current=j:mn(f.current,{select:!0})},x=function(k){if(m.paused||!l)return;const j=k.relatedTarget;j!==null&&(l.contains(j)||mn(f.current,{select:!0}))},b=function(k){if(document.activeElement===document.body)for(const S of k)S.removedNodes.length>0&&mn(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,m.paused]),p.useEffect(()=>{if(l){Hc.add(m);const g=document.activeElement;if(!l.contains(g)){const b=new CustomEvent(ki,Uc);l.addEventListener(ki,u),l.dispatchEvent(b),b.defaultPrevented||(Kk(e5(sp(l)),{select:!0}),document.activeElement===g&&mn(l))}return()=>{l.removeEventListener(ki,u),setTimeout(()=>{const b=new CustomEvent(ji,Uc);l.addEventListener(ji,d),l.dispatchEvent(b),b.defaultPrevented||mn(g??document.body,{select:!0}),l.removeEventListener(ji,d),Hc.remove(m)},0)}}},[l,u,d,m]);const v=p.useCallback(g=>{if(!n&&!r||m.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,b=document.activeElement;if(x&&b){const y=g.currentTarget,[k,j]=Jk(y);k&&j?!g.shiftKey&&b===j?(g.preventDefault(),n&&mn(k,{select:!0})):g.shiftKey&&b===k&&(g.preventDefault(),n&&mn(j,{select:!0})):b===y&&g.preventDefault()}},[n,r,m.paused]);return s.jsx(Re.div,{tabIndex:-1,...a,ref:h,onKeyDown:v})});wl.displayName=Gk;function Kk(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(mn(r,{select:t}),document.activeElement!==n)return}function Jk(e){const t=sp(e),n=Wc(t,e),r=Wc(t.reverse(),e);return[n,r]}function sp(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 Wc(e,t){for(const n of e)if(!Yk(n,{upTo:t}))return n}function Yk(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 Xk(e){return e instanceof HTMLInputElement&&"select"in e}function mn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Xk(e)&&t&&e.select()}}var Hc=Qk();function Qk(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Vc(e,t),e.unshift(t)},remove(t){e=Vc(e,t),e[0]?.resume()}}}function Vc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function e5(e){return e.filter(t=>t.tagName!=="A")}var t5="Portal",Vo=p.forwardRef((e,t)=>{const{container:n,...r}=e,[o,i]=p.useState(!1);nt(()=>i(!0),[]);const a=n||o&&globalThis?.document?.body;return a?D0.createPortal(s.jsx(Re.div,{...r,ref:t}),a):null});Vo.displayName=t5;function n5(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Tt=e=>{const{present:t,children:n}=e,r=r5(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),i=De(r.ref,s5(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:i}):null};Tt.displayName="Presence";function r5(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),i=p.useRef("none"),a=e?"mounted":"unmounted",[l,c]=n5(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const u=Ss(r.current);i.current=l==="mounted"?u:"none"},[l]),nt(()=>{const u=r.current,d=o.current;if(d!==e){const h=i.current,m=Ss(u);e?c("MOUNT"):m==="none"||u?.display==="none"?c("UNMOUNT"):c(d&&h!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),nt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const g=Ss(r.current).includes(CSS.escape(m.animationName));if(m.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)})}},h=m=>{m.target===t&&(i.current=Ss(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),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 Ss(e){return e?.animationName||"none"}function s5(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 Si=0;function op(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??qc()),document.body.insertAdjacentElement("beforeend",e[1]??qc()),Si++,()=>{Si===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Si--}},[])}function qc(){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 Wt=function(){return Wt=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},Wt.apply(this,arguments)};function ip(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 o5(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 Zs="right-scroll-bar-position",Gs="width-before-scroll-bar",i5="with-scroll-bars-hidden",a5="--removed-body-scroll-bar-size";function Ci(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function l5(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 c5=typeof window<"u"?p.useLayoutEffect:p.useEffect,Zc=new WeakMap;function u5(e,t){var n=l5(null,function(r){return e.forEach(function(o){return Ci(o,r)})});return c5(function(){var r=Zc.get(n);if(r){var o=new Set(r),i=new Set(e),a=n.current;o.forEach(function(l){i.has(l)||Ci(l,null)}),i.forEach(function(l){o.has(l)||Ci(l,a)})}Zc.set(n,e)},[e]),n}function d5(e){return e}function f5(e,t){t===void 0&&(t=d5);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 p5(e){e===void 0&&(e={});var t=f5(null);return t.options=Wt({async:!0,ssr:!1},e),t}var ap=function(e){var t=e.sideCar,n=ip(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,Wt({},n))};ap.isSideCarExport=!0;function h5(e,t){return e.useMedium(t),ap}var lp=p5(),Ni=function(){},qo=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:Ni,onWheelCapture:Ni,onTouchMoveCapture:Ni}),o=r[0],i=r[1],a=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,m=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,b=e.as,y=b===void 0?"div":b,k=e.gapMode,j=ip(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=h,E=u5([n,t]),N=Wt(Wt({},j),o);return p.createElement(p.Fragment,null,d&&p.createElement(S,{sideCar:lp,removeScrollBar:u,shards:f,noRelative:m,noIsolation:v,inert:g,setCallbacks:i,allowPinchZoom:!!x,lockRef:n,gapMode:k}),a?p.cloneElement(p.Children.only(l),Wt(Wt({},N),{ref:E})):p.createElement(y,Wt({},N,{className:c,ref:E}),l))});qo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};qo.classNames={fullWidth:Gs,zeroRight:Zs};var m5=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function g5(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=m5();return t&&e.setAttribute("nonce",t),e}function x5(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function b5(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var v5=function(){var e=0,t=null;return{add:function(n){e==0&&(t=g5())&&(x5(t,n),b5(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},y5=function(){var e=v5();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},cp=function(){var e=y5(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},w5={left:0,top:0,right:0,gap:0},Ti=function(e){return parseInt(e||"",10)||0},_5=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[Ti(n),Ti(r),Ti(o)]},k5=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return w5;var t=_5(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])}},j5=cp(),pr="data-scroll-locked",S5=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(i5,` {
43
- overflow: hidden `).concat(r,`;
44
- padding-right: `).concat(l,"px ").concat(r,`;
45
- }
46
- body[`).concat(pr,`] {
47
- overflow: hidden `).concat(r,`;
48
- overscroll-behavior: contain;
49
- `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
50
- padding-left: `.concat(o,`px;
51
- padding-top: `).concat(i,`px;
52
- padding-right: `).concat(a,`px;
53
- margin-left:0;
54
- margin-top:0;
55
- margin-right: `).concat(l,"px ").concat(r,`;
56
- `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
57
- }
58
-
59
- .`).concat(Zs,` {
60
- right: `).concat(l,"px ").concat(r,`;
61
- }
62
-
63
- .`).concat(Gs,` {
64
- margin-right: `).concat(l,"px ").concat(r,`;
65
- }
66
-
67
- .`).concat(Zs," .").concat(Zs,` {
68
- right: 0 `).concat(r,`;
69
- }
70
-
71
- .`).concat(Gs," .").concat(Gs,` {
72
- margin-right: 0 `).concat(r,`;
73
- }
74
-
75
- body[`).concat(pr,`] {
76
- `).concat(a5,": ").concat(l,`px;
77
- }
78
- `)},Gc=function(){var e=parseInt(document.body.getAttribute(pr)||"0",10);return isFinite(e)?e:0},C5=function(){p.useEffect(function(){return document.body.setAttribute(pr,(Gc()+1).toString()),function(){var e=Gc()-1;e<=0?document.body.removeAttribute(pr):document.body.setAttribute(pr,e.toString())}},[])},N5=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;C5();var i=p.useMemo(function(){return k5(o)},[o]);return p.createElement(j5,{styles:S5(i,!t,o,n?"":"!important")})},ha=!1;if(typeof window<"u")try{var Cs=Object.defineProperty({},"passive",{get:function(){return ha=!0,!0}});window.addEventListener("test",Cs,Cs),window.removeEventListener("test",Cs,Cs)}catch{ha=!1}var Qn=ha?{passive:!1}:!1,T5=function(e){return e.tagName==="TEXTAREA"},up=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!T5(e)&&n[t]==="visible")},E5=function(e){return up(e,"overflowY")},A5=function(e){return up(e,"overflowX")},Kc=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=dp(e,r);if(o){var i=fp(e,r),a=i[1],l=i[2];if(a>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},R5=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},I5=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},dp=function(e,t){return e==="v"?E5(t):A5(t)},fp=function(e,t){return e==="v"?R5(t):I5(t)},z5=function(e,t){return e==="h"&&t==="rtl"?-1:1},O5=function(e,t,n,r,o){var i=z5(e,window.getComputedStyle(t).direction),a=i*r,l=n.target,c=t.contains(l),u=!1,d=a>0,f=0,h=0;do{if(!l)break;var m=fp(e,l),v=m[0],g=m[1],x=m[2],b=g-x-i*v;(v||b)&&dp(e,l)&&(f+=b,h+=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(h)<1)&&(u=!0),u},Ns=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Jc=function(e){return[e.deltaX,e.deltaY]},Yc=function(e){return e&&"current"in e?e.current:e},P5=function(e,t){return e[0]===t[0]&&e[1]===t[1]},M5=function(e){return`
79
- .block-interactivity-`.concat(e,` {pointer-events: none;}
80
- .allow-interactivity-`).concat(e,` {pointer-events: all;}
81
- `)},L5=0,er=[];function D5(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(L5++)[0],i=p.useState(cp)[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=o5([e.lockRef.current],(e.shards||[]).map(Yc),!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=Ns(g),y=n.current,k="deltaX"in g?g.deltaX:y[0]-b[0],j="deltaY"in g?g.deltaY:y[1]-b[1],S,E=g.target,N=Math.abs(k)>Math.abs(j)?"h":"v";if("touches"in g&&N==="h"&&E.type==="range")return!1;var z=window.getSelection(),A=z&&z.anchorNode,O=A?A===E||A.contains(E):!1;if(O)return!1;var W=Kc(N,E);if(!W)return!0;if(W?S=N:(S=N==="v"?"h":"v",W=Kc(N,E)),!W)return!1;if(!r.current&&"changedTouches"in g&&(k||j)&&(r.current=S),!S)return!0;var T=r.current||S;return O5(T,x,g,T==="h"?k:j)},[]),c=p.useCallback(function(g){var x=g;if(!(!er.length||er[er.length-1]!==i)){var b="deltaY"in x?Jc(x):Ns(x),y=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&P5(S.delta,b)})[0];if(y&&y.should){x.cancelable&&x.preventDefault();return}if(!y){var k=(a.current.shards||[]).map(Yc).filter(Boolean).filter(function(S){return S.contains(x.target)}),j=k.length>0?l(x,k[0]):!a.current.noIsolation;j&&x.cancelable&&x.preventDefault()}}},[]),u=p.useCallback(function(g,x,b,y){var k={name:g,delta:x,target:b,should:y,shadowParent:$5(b)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(j){return j!==k})},1)},[]),d=p.useCallback(function(g){n.current=Ns(g),r.current=void 0},[]),f=p.useCallback(function(g){u(g.type,Jc(g),g.target,l(g,e.lockRef.current))},[]),h=p.useCallback(function(g){u(g.type,Ns(g),g.target,l(g,e.lockRef.current))},[]);p.useEffect(function(){return er.push(i),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,Qn),document.addEventListener("touchmove",c,Qn),document.addEventListener("touchstart",d,Qn),function(){er=er.filter(function(g){return g!==i}),document.removeEventListener("wheel",c,Qn),document.removeEventListener("touchmove",c,Qn),document.removeEventListener("touchstart",d,Qn)}},[]);var m=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(i,{styles:M5(o)}):null,m?p.createElement(N5,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function $5(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const F5=h5(lp,D5);var _l=p.forwardRef(function(e,t){return p.createElement(qo,Wt({},e,{ref:t,sideCar:F5}))});_l.classNames=qo.classNames;var B5=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},tr=new WeakMap,Ts=new WeakMap,Es={},Ei=0,pp=function(e){return e&&(e.host||pp(e.parentNode))},U5=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=pp(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})},W5=function(e,t,n,r){var o=U5(t,Array.isArray(e)?e:[e]);Es[n]||(Es[n]=new WeakMap);var i=Es[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(h){if(l.has(h))d(h);else try{var m=h.getAttribute(r),v=m!==null&&m!=="false",g=(tr.get(h)||0)+1,x=(i.get(h)||0)+1;tr.set(h,g),i.set(h,x),a.push(h),g===1&&v&&Ts.set(h,!0),x===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",h,b)}})};return d(t),l.clear(),Ei++,function(){a.forEach(function(f){var h=tr.get(f)-1,m=i.get(f)-1;tr.set(f,h),i.set(f,m),h||(Ts.has(f)||f.removeAttribute(r),Ts.delete(f)),m||f.removeAttribute(n)}),Ei--,Ei||(tr=new WeakMap,tr=new WeakMap,Ts=new WeakMap,Es={})}},hp=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=B5(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),W5(r,o,n,"aria-hidden")):function(){return null}},Zo="Dialog",[mp]=ln(Zo),[H5,Bt]=mp(Zo),gp=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]=Dn({prop:r,defaultProp:o??!1,onChange:i,caller:Zo});return s.jsx(H5,{scope:t,triggerRef:l,contentRef:c,contentId:qt(),titleId:qt(),descriptionId:qt(),open:u,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(f=>!f),[d]),modal:a,children:n})};gp.displayName=Zo;var xp="DialogTrigger",bp=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(xp,n),i=De(t,o.triggerRef);return s.jsx(Re.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Sl(o.open),...r,ref:i,onClick:Ne(e.onClick,o.onOpenToggle)})});bp.displayName=xp;var kl="DialogPortal",[V5,vp]=mp(kl,{forceMount:void 0}),yp=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,i=Bt(kl,t);return s.jsx(V5,{scope:t,forceMount:n,children:p.Children.map(r,a=>s.jsx(Tt,{present:n||i.open,children:s.jsx(Vo,{asChild:!0,container:o,children:a})}))})};yp.displayName=kl;var ho="DialogOverlay",wp=p.forwardRef((e,t)=>{const n=vp(ho,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Bt(ho,e.__scopeDialog);return i.modal?s.jsx(Tt,{present:r||i.open,children:s.jsx(Z5,{...o,ref:t})}):null});wp.displayName=ho;var q5=yr("DialogOverlay.RemoveScroll"),Z5=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(ho,n);return s.jsx(_l,{as:q5,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(Re.div,{"data-state":Sl(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),$n="DialogContent",_p=p.forwardRef((e,t)=>{const n=vp($n,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Bt($n,e.__scopeDialog);return s.jsx(Tt,{present:r||i.open,children:i.modal?s.jsx(G5,{...o,ref:t}):s.jsx(K5,{...o,ref:t})})});_p.displayName=$n;var G5=p.forwardRef((e,t)=>{const n=Bt($n,e.__scopeDialog),r=p.useRef(null),o=De(t,n.contentRef,r);return p.useEffect(()=>{const i=r.current;if(i)return hp(i)},[]),s.jsx(kp,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ne(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ne(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&i.preventDefault()}),onFocusOutside:Ne(e.onFocusOutside,i=>i.preventDefault())})}),K5=p.forwardRef((e,t)=>{const n=Bt($n,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return s.jsx(kp,{...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()}})}),kp=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...a}=e,l=Bt($n,n),c=p.useRef(null),u=De(t,c);return op(),s.jsxs(s.Fragment,{children:[s.jsx(wl,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:s.jsx(Ho,{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(J5,{titleId:l.titleId}),s.jsx(X5,{contentRef:c,descriptionId:l.descriptionId})]})]})}),jl="DialogTitle",jp=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(jl,n);return s.jsx(Re.h2,{id:o.titleId,...r,ref:t})});jp.displayName=jl;var Sp="DialogDescription",Cp=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(Sp,n);return s.jsx(Re.p,{id:o.descriptionId,...r,ref:t})});Cp.displayName=Sp;var Np="DialogClose",Tp=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(Np,n);return s.jsx(Re.button,{type:"button",...r,ref:t,onClick:Ne(e.onClick,()=>o.onOpenChange(!1))})});Tp.displayName=Np;function Sl(e){return e?"open":"closed"}var Ep="DialogTitleWarning",[P8,Ap]=Sk(Ep,{contentName:$n,titleName:jl,docsSlug:"dialog"}),J5=({titleId:e})=>{const t=Ap(Ep),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
82
-
83
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
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},Y5="DialogDescriptionWarning",X5=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ap(Y5).contentName}}.`;return p.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Q5=gp,ej=bp,tj=yp,nj=wp,rj=_p,sj=jp,oj=Cp,ij=Tp;function qn({...e}){return s.jsx(Q5,{"data-slot":"dialog",...e})}function Go({...e}){return s.jsx(ej,{"data-slot":"dialog-trigger",...e})}function aj({...e}){return s.jsx(tj,{"data-slot":"dialog-portal",...e})}function lj({className:e,...t}){return s.jsx(nj,{"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 Zn({className:e,children:t,...n}){return s.jsxs(aj,{children:[s.jsx(lj,{}),s.jsxs(rj,{"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(ij,{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(ls,{className:"size-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Gn({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 Kn({className:e,...t}){return s.jsx(sj,{"data-slot":"dialog-title",className:le("text-lg font-semibold leading-none tracking-tight",e),...t})}function Rp({className:e,...t}){return s.jsx(oj,{"data-slot":"dialog-description",className:le("text-sm text-muted-foreground",e),...t})}const Xc=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Qc=$f,Cl=(e,t)=>n=>{var r;if(t?.variants==null)return Qc(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 h=Xc(d)||Xc(f);return o[u][h]}),l=n&&Object.entries(n).reduce((u,d)=>{let[f,h]=d;return h===void 0||(u[f]=h),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:f,className:h,...m}=d;return Object.entries(m).every(v=>{let[g,x]=v;return Array.isArray(x)?x.includes({...i,...l}[g]):{...i,...l}[g]===x})?[...u,f,h]:u},[]);return Qc(e,a,c,n?.class,n?.className)},cj=Cl("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 _e({className:e,variant:t,size:n,...r}){return s.jsx("button",{"data-slot":"button",className:le(cj({variant:t,size:n,className:e})),...r})}function Ip({open:e,onOpenChange:t,title:n,description:r,confirmLabel:o="Confirm",variant:i="default",onConfirm:a}){return s.jsx(qn,{open:e,onOpenChange:t,children:s.jsxs(Zn,{children:[s.jsx(Gn,{children:s.jsx(Kn,{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(_e,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),s.jsx(_e,{variant:i,size:"sm",onClick:()=>{a(),t(!1)},children:o})]})]})})}const uj="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eClaude%20Code%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M20.998%2010.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6%2010.949h1.488V8.102H6v2.847zm10.51%200H18V8.102h-1.49v2.847z'%20fill='%23D97757'%20fill-rule='evenodd'%3e%3c/path%3e%3c/svg%3e",dj="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20d='M19.503%200H4.496A4.496%204.496%200%20000%204.496v15.007A4.496%204.496%200%20004.496%2024h15.007A4.496%204.496%200%200024%2019.503V4.496A4.496%204.496%200%200019.503%200z'%20fill='%23fff'%3e%3c/path%3e%3cpath%20d='M9.064%203.344a4.578%204.578%200%20012.285-.312c1%20.115%201.891.54%202.673%201.275.01.01.024.017.037.021a.09.09%200%2000.043%200%204.55%204.55%200%20013.046.275l.047.022.116.057a4.581%204.581%200%20012.188%202.399c.209.51.313%201.041.315%201.595a4.24%204.24%200%2001-.134%201.223.123.123%200%2000.03.115c.594.607.988%201.33%201.183%202.17.289%201.425-.007%202.71-.887%203.854l-.136.166a4.548%204.548%200%2001-2.201%201.388.123.123%200%2000-.081.076c-.191.551-.383%201.023-.74%201.494-.9%201.187-2.222%201.846-3.711%201.838-1.187-.006-2.239-.44-3.157-1.302a.107.107%200%2000-.105-.024c-.388.125-.78.143-1.204.138a4.441%204.441%200%2001-1.945-.466%204.544%204.544%200%2001-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81%205.81%200%2001-.37-.961%204.582%204.582%200%2001-.014-2.298.124.124%200%2000.006-.056.085.085%200%2000-.027-.048%204.467%204.467%200%2001-1.034-1.651%203.896%203.896%200%2001-.251-1.192%205.189%205.189%200%2001.141-1.6c.337-1.112.982-1.985%201.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098%200%2000.065-.066%204.51%204.51%200%2001.829-1.615%204.535%204.535%200%20011.837-1.388zm3.482%2010.565a.637.637%200%20000%201.272h3.636a.637.637%200%20100-1.272h-3.636zM8.462%209.23a.637.637%200%2000-1.106.631l1.272%202.224-1.266%202.136a.636.636%200%20101.095.649l1.454-2.455a.636.636%200%2000.005-.64L8.462%209.23z'%20fill='url(%23lobe-icons-codex-_R_0_)'%3e%3c/path%3e%3cdefs%3e%3clinearGradient%20gradientUnits='userSpaceOnUse'%20id='lobe-icons-codex-_R_0_'%20x1='12'%20x2='12'%20y1='3'%20y2='21'%3e%3cstop%20stop-color='%23B1A7FF'%3e%3c/stop%3e%3cstop%20offset='.5'%20stop-color='%237A9DFF'%3e%3c/stop%3e%3cstop%20offset='1'%20stop-color='%233941FF'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",fj="data:image/svg+xml,%3csvg%20fill='%237dd3fc'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eOpenCode%3c/title%3e%3cpath%20d='M16%206H8v12h8V6zm4%2016H4V2h16v20z'%3e%3c/path%3e%3c/svg%3e",pj="data:image/svg+xml,%3csvg%20fill='%23ff6900'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eMiMo%20Code%3c/title%3e%3cpath%20d='M.958%2015.936a.459.459%200%2001.459.44v2.729a.46.46%200%2001-.918%200v-2.729a.459.459%200%2001.459-.44zm4.814-2.035a.46.46%200%2001.553.45v4.754a.458.458%200%2011-.918%200V15.48L3.74%2017.202a.462.462%200%2001-.655.016.462.462%200%2001-.065-.082L.628%2014.67a.459.459%200%2001.658-.637l2.124%202.187%202.127-2.188a.46.46%200%2001.235-.13zm2.068.004a.46.46%200%2001.458.445v4.755a.46.46%200%2001-.458.458.459.459%200%2001-.458-.458V14.35a.459.459%200%2001.458-.445zm1.973%202.014a.46.46%200%2001.46.457v2.729a.46.46%200%2001-.784.324.46.46%200%2001-.134-.324v-2.729a.46.46%200%2001.458-.458zm.002-2.045a.458.458%200%2001.328.157l2.127%202.19%202.125-2.19a.459.459%200%2001.784.318v4.756a.46.46%200%2001-.455.458.46.46%200%2001-.458-.458V15.48l-1.667%201.723a.46.46%200%2001-.65.008l-.005-.005c0-.002-.002-.002-.004-.003l-2.455-2.534a.46.46%200%2001-.008-.667.461.461%200%2001.338-.128zm6.797%201.206a.46.46%200%2001.53.651A1.966%201.966%200%200019.81%2018.4a.462.462%200%2001.623.18.46.46%200%2001-.181.624%202.863%202.863%200%2001-1.38.353l-.142-.004a2.88%202.88%200%2001-2.393-4.263.461.461%200%2001.274-.21zm.864-.931a2.884%202.884%200%20013.915%203.914.46.46%200%2001-.402.24l-.057-.004a.458.458%200%2001-.164-.055.46.46%200%2001-.182-.622%201.967%201.967%200%2000-2.669-2.67.459.459%200%2011-.441-.803zM9.59%206.368c1.481%200%201.696%201.202%201.696%201.654v2.648h-.917v-.432c-.26.346-.792.535-1.36.535-.133%200-1.289-.03-1.384-1.136-.082-.932.675-1.61%202.053-1.61h.691c0-.563-.367-.886-.983-.886-.44.013-.864.174-1.2.458l-.36-.664c.484-.379%201.012-.567%201.764-.567zm4.427.1c1.263%200%202.082.97%202.083%202.15%200%201.181-.824%202.154-2.083%202.154-1.26%200-2.084-.972-2.084-2.152%200-1.18.82-2.153%202.084-2.153zm6.801.015c.68%200%201.202.465%201.197%201.548v2.642H21.1V8.29c0-.312-.002-.98-.63-.98s-.628.667-.628.838v2.524h-.89V8.148c0-.17-.001-.838-.63-.838-.628%200-.628.668-.628.98v2.383h-.917v-4.03h.917V7a1.22%201.22%200%2001.947-.516c.398%200%20.76.193.982.686a1.321%201.321%200%20011.195-.686zm-18.093.872l1.457-1.772H5.32L3.311%208.07l2.14%202.602H4.24L2.725%208.796%201.21%2010.672H0L2.138%208.07.13%205.583h1.138l1.458%201.772zm4.149%203.317h-.916V6.644h.916v4.028zm16.99%200h-.916V6.644h.916v4.028zM9.925%208.71c-1.055%200-1.359.412-1.326.742.032.329.324.537.757.537a1.013%201.013%200%20001.014-.968l.002-.31h-.447zM14.018%207.3c-.663%200-1.184.487-1.184%201.32%200%20.832.52%201.32%201.184%201.32.662%200%201.182-.49%201.182-1.32%200-.832-.52-1.32-1.182-1.32zM6.417%205.001a.568.568%200%2001.587.582.588.588%200%2001-1.175%200A.57.57%200%20016.417%205zm16.991%200a.57.57%200%2001.592.582.588.588%200%2001-1.174%200%20.57.57%200%2001.357-.542.572.572%200%2001.225-.04z'%3e%3c/path%3e%3c/svg%3e",hj="/assets/agent-inspector-58K1_MsC.ico",mj={"agent-inspector":"Inspector",codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code"};function Ai(e){return e?.toLowerCase()??""}function Or(e,t){for(const n of t)if(e.includes(n))return!0;return!1}function Nl(e){const t=[Ai(e.userAgent),Ai(e.conversationId),Ai(e.clientProjectFolder)].join(" ");return Or(t,["agent-inspector","agent inspector","provider-test"])?"agent-inspector":Or(t,["mimocode","mimo-code","mimo code"])?"mimo-code":Or(t,["opencode","open-code","open code"])?"opencode":Or(t,["claude-code","claude code","claudecode"])?"claude-code":Or(t,["codex desktop","codex-cli","openai-codex","codex"])?"codex":"unknown"}function Ko(e){switch(e){case"agent-inspector":case"codex":case"opencode":case"mimo-code":case"claude-code":return mj[e];case"unknown":return null}}const gj={"agent-inspector":hj,codex:dj,opencode:fj,"mimo-code":pj,"claude-code":uj},xj={"agent-inspector":"border-orange-200/25 bg-orange-300/[0.12]",codex:"border-cyan-200/20 bg-cyan-300/[0.08]",opencode:"border-sky-200/25 bg-sky-300/[0.12]","mimo-code":"border-orange-200/25 bg-orange-400/[0.12]","claude-code":"border-amber-100/20 bg-amber-300/[0.09]"},bj={"agent-inspector":"p-0.5 drop-shadow-[0_0_8px_rgba(251,146,60,0.35)]",codex:"p-0.5",opencode:"p-1 drop-shadow-[0_0_8px_rgba(125,211,252,0.35)]","mimo-code":"p-0.5 drop-shadow-[0_0_8px_rgba(255,105,0,0.35)]","claude-code":"p-0.5"};function Jo({client:e,className:t}){if(e==="unknown")return null;const n=Ko(e);if(n===null)return null;const r=gj[e];return s.jsx("span",{className:le("inline-flex size-6 shrink-0 items-center justify-center rounded-md border p-0 shadow-sm",xj[e],t),"aria-label":n,title:n,children:s.jsx("img",{src:r,alt:"",className:le("size-full object-contain",bj[e]),"aria-hidden":"true"})})}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",_j="/assets/minimax-BPMzvuL-.jpeg",kj="/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 Jn={width:24,height:24,objectFit:"contain"},Ej=ht.memo(({className:e})=>s.jsx("img",{src:vj,alt:"Anthropic",className:e,style:Jn})),Aj=ht.memo(({className:e})=>s.jsx("img",{src:yj,alt:"OpenAI",className:e,style:{...Jn,background:"white",borderRadius:"4px"}})),Rj=ht.memo(({className:e})=>s.jsx("img",{src:wj,alt:"DeepSeek",className:e,style:Jn})),Ij=ht.memo(({className:e})=>s.jsx("img",{src:_j,alt:"MiniMax",className:e,style:Jn})),zj=ht.memo(({className:e})=>s.jsx("img",{src:kj,alt:"Alibaba",className:e,style:Jn})),Oj=ht.memo(({className:e})=>s.jsx("img",{src:jj,alt:"Qwen",className:e,style:Jn})),Pj=ht.memo(({className:e})=>s.jsx("img",{src:Sj,alt:"ZhipuAI",className:e,style:Jn}));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(Oj,{className:t});case"zhipuai":return s.jsx(Pj,{className:t});case"unknown":return null}}var zp=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(Re.span,{...e,ref:t,style:{...zp,...e.style}}));Op.displayName=Lj;var Dj=Op;function Pp(e){const t=e+"CollectionProvider",[n,r]=ln(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=g=>{const{scope:x,children:b}=g,y=ht.useRef(null),k=ht.useRef(new Map).current;return s.jsx(o,{scope:x,itemMap:k,collectionRef:y,children:b})};a.displayName=t;const l=e+"CollectionSlot",c=yr(l),u=ht.forwardRef((g,x)=>{const{scope:b,children:y}=g,k=i(l,b),j=De(x,k.collectionRef);return s.jsx(c,{ref:j,children:y})});u.displayName=l;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=yr(d),m=ht.forwardRef((g,x)=>{const{scope:b,children:y,...k}=g,j=ht.useRef(null),S=De(x,j),E=i(d,b);return ht.useEffect(()=>(E.itemMap.set(j,{ref:j,...k}),()=>{E.itemMap.delete(j)})),s.jsx(h,{[f]:"",ref:S,children:y})});m.displayName=d;function v(g){const x=i(e+"CollectionConsumer",g);return ht.useCallback(()=>{const y=x.collectionRef.current;if(!y)return[];const k=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((E,N)=>k.indexOf(E.ref.current)-k.indexOf(N.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:a,Slot:u,ItemSlot:m},v,r]}var Yo="Collapsible",[$j]=ln(Yo),[Fj,Tl]=$j(Yo),Mp=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:i,onOpenChange:a,...l}=e,[c,u]=Dn({prop:r,defaultProp:o??!1,onChange:a,caller:Yo});return s.jsx(Fj,{scope:n,disabled:i,contentId:qt(),open:c,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),children:s.jsx(Re.div,{"data-state":Al(c),"data-disabled":i?"":void 0,...l,ref:t})})});Mp.displayName=Yo;var Lp="CollapsibleTrigger",Dp=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Tl(Lp,n);return s.jsx(Re.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Al(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:Ne(e.onClick,o.onOpenToggle)})});Dp.displayName=Lp;var El="CollapsibleContent",$p=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Tl(El,e.__scopeCollapsible);return s.jsx(Tt,{present:n||o.open,children:({present:i})=>s.jsx(Bj,{...r,ref:t,present:i})})});$p.displayName=El;var Bj=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...i}=e,a=Tl(El,n),[l,c]=p.useState(r),u=p.useRef(null),d=De(t,u),f=p.useRef(0),h=f.current,m=p.useRef(0),v=m.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)},[]),nt(()=>{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 k=y.getBoundingClientRect();f.current=k.height,m.current=k.width,x.current||(y.style.transitionDuration=b.current.transitionDuration,y.style.animationName=b.current.animationName),c(r)}},[a.open,r]),s.jsx(Re.div,{"data-state":Al(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!g,...i,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style},children:g&&o})});function Al(e){return e?"open":"closed"}var Uj=Mp,Wj=p.createContext(void 0);function Xo(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 Vj(e){const[t,n]=p.useState(void 0);return nt(()=>{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 qj=["top","right","bottom","left"],wn=Math.min,yt=Math.max,mo=Math.round,As=Math.floor,Zt=e=>({x:e,y:e}),Zj={left:"right",right:"left",bottom:"top",top:"bottom"},Gj={start:"end",end:"start"};function ma(e,t,n){return yt(e,wn(t,n))}function sn(e,t){return typeof e=="function"?e(t):e}function on(e){return e.split("-")[0]}function Er(e){return e.split("-")[1]}function Rl(e){return e==="x"?"y":"x"}function Il(e){return e==="y"?"height":"width"}const Kj=new Set(["top","bottom"]);function Vt(e){return Kj.has(on(e))?"y":"x"}function zl(e){return Rl(Vt(e))}function Jj(e,t,n){n===void 0&&(n=!1);const r=Er(e),o=zl(e),i=Il(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=go(a)),[a,go(a)]}function Yj(e){const t=go(e);return[ga(e),t,ga(t)]}function ga(e){return e.replace(/start|end/g,t=>Gj[t])}const eu=["left","right"],tu=["right","left"],Xj=["top","bottom"],Qj=["bottom","top"];function eS(e,t,n){switch(e){case"top":case"bottom":return n?t?tu:eu:t?eu:tu;case"left":case"right":return t?Xj:Qj;default:return[]}}function tS(e,t,n,r){const o=Er(e);let i=eS(on(e),n==="start",r);return o&&(i=i.map(a=>a+"-"+o),t&&(i=i.concat(i.map(ga)))),i}function go(e){return e.replace(/left|right|bottom|top/g,t=>Zj[t])}function nS(e){return{top:0,right:0,bottom:0,left:0,...e}}function Fp(e){return typeof e!="number"?nS(e):{top:e,right:e,bottom:e,left:e}}function xo(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 nu(e,t,n){let{reference:r,floating:o}=e;const i=Vt(t),a=zl(t),l=Il(a),c=on(t),u=i==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[l]/2-o[l]/2;let m;switch(c){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(Er(t)){case"start":m[a]-=h*(n&&u?-1:1);break;case"end":m[a]+=h*(n&&u?-1:1);break}return m}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:h=!1,padding:m=0}=sn(t,e),v=Fp(m),x=l[h?f==="floating"?"reference":"floating":f],b=xo(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,k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),j=await(i.isElement==null?void 0:i.isElement(k))?await(i.getScale==null?void 0:i.getScale(k))||{x:1,y:1}:{x:1,y:1},S=xo(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:k,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}=nu(u,r,c),h=r,m={},v=0;for(let x=0;x<l.length;x++){var g;const{name:b,fn:y}=l[x],{x:k,y:j,data:S,reset:E}=await y({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:m,rects:u,platform:{...a,detectOverflow:(g=a.detectOverflow)!=null?g:rS},elements:{reference:e,floating:t}});d=k??d,f=j??f,m={...m,[b]:{...m[b],...S}},E&&v<=50&&(v++,typeof E=="object"&&(E.placement&&(h=E.placement),E.rects&&(u=E.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):E.rects),{x:d,y:f}=nu(u,h,c)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:m}},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}=sn(e,t)||{};if(u==null)return{};const f=Fp(d),h={x:n,y:r},m=zl(o),v=Il(m),g=await a.getDimensions(u),x=m==="y",b=x?"top":"left",y=x?"bottom":"right",k=x?"clientHeight":"clientWidth",j=i.reference[v]+i.reference[m]-h[m]-i.floating[v],S=h[m]-i.reference[m],E=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let N=E?E[k]:0;(!N||!await(a.isElement==null?void 0:a.isElement(E)))&&(N=l.floating[k]||i.floating[v]);const z=j/2-S/2,A=N/2-g[v]/2-1,O=wn(f[b],A),W=wn(f[y],A),T=O,L=N-g[v]-W,_=N/2-g[v]/2+z,$=ma(T,_,L),ee=!c.arrow&&Er(o)!=null&&_!==$&&i.reference[v]/2-(_<T?O:W)-g[v]/2<0,D=ee?_<T?_-T:_-L:0;return{[m]:h[m]+D,data:{[m]:$,centerOffset:_-$-D,...ee&&{alignmentOffset:D}},reset:ee}}}),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:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=sn(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=on(o),y=Vt(l),k=on(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=h||(k||!g?[go(l)]:Yj(l)),E=v!=="none";!h&&E&&S.push(...tS(l,g,v,j));const N=[l,...S],z=await c.detectOverflow(t,x),A=[];let O=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&A.push(z[b]),f){const _=Jj(o,a,j);A.push(z[_[0]],z[_[1]])}if(O=[...O,{placement:o,overflows:A}],!A.every(_=>_<=0)){var W,T;const _=(((W=i.flip)==null?void 0:W.index)||0)+1,$=N[_];if($&&(!(f==="alignment"?y!==Vt($):!1)||O.every(H=>Vt(H.placement)===y?H.overflows[0]>0:!0)))return{data:{index:_,overflows:O},reset:{placement:$}};let ee=(T=O.filter(D=>D.overflows[0]<=0).sort((D,H)=>D.overflows[1]-H.overflows[1])[0])==null?void 0:T.placement;if(!ee)switch(m){case"bestFit":{var L;const D=(L=O.filter(H=>{if(E){const Z=Vt(H.placement);return Z===y||Z==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(Z=>Z>0).reduce((Z,ue)=>Z+ue,0)]).sort((H,Z)=>H[1]-Z[1])[0])==null?void 0:L[0];D&&(ee=D);break}case"initialPlacement":ee=l;break}if(o!==ee)return{reset:{placement:ee}}}return{}}}};function ru(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function su(e){return qj.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}=sn(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...i,elementContext:"reference"}),l=ru(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:su(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...i,altBoundary:!0}),l=ru(a,n.floating);return{data:{escapedOffsets:l,escaped:su(l)}}}default:return{}}}}},Bp=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=on(n),l=Er(n),c=Vt(n)==="y",u=Bp.has(a)?-1:1,d=i&&c?-1:1,f=sn(t,e);let{mainAxis:h,crossAxis:m,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"&&(m=l==="end"?v*-1:v),c?{x:m*d,y:h*u}:{x:h*u,y:m*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:k}=b;return{x:y,y:k}}},...u}=sn(e,t),d={x:n,y:r},f=await i.detectOverflow(t,u),h=Vt(on(o)),m=Rl(h);let v=d[m],g=d[h];if(a){const b=m==="y"?"top":"left",y=m==="y"?"bottom":"right",k=v+f[b],j=v-f[y];v=ma(k,v,j)}if(l){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",k=g+f[b],j=g-f[y];g=ma(k,g,j)}const x=c.fn({...t,[m]:v,[h]:g});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[m]:a,[h]: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}=sn(e,t),d={x:n,y:r},f=Vt(o),h=Rl(f);let m=d[h],v=d[f];const g=sn(l,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const k=h==="y"?"height":"width",j=i.reference[h]-i.floating[k]+x.mainAxis,S=i.reference[h]+i.reference[k]-x.mainAxis;m<j?m=j:m>S&&(m=S)}if(u){var b,y;const k=h==="y"?"width":"height",j=Bp.has(on(o)),S=i.reference[f]-i.floating[k]+(j&&((b=a.offset)==null?void 0:b[f])||0)+(j?0:x.crossAxis),E=i.reference[f]+i.reference[k]+(j?0:((y=a.offset)==null?void 0:y[f])||0)-(j?x.crossAxis:0);v<S?v=S:v>E&&(v=E)}return{[h]:m,[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}=sn(e,t),d=await a.detectOverflow(t,u),f=on(o),h=Er(o),m=Vt(o)==="y",{width:v,height:g}=i.floating;let x,b;f==="top"||f==="bottom"?(x=f,b=h===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(b=f,x=h==="end"?"top":"bottom");const y=g-d.top-d.bottom,k=v-d.left-d.right,j=wn(g-d[x],y),S=wn(v-d[b],k),E=!t.middlewareData.shift;let N=j,z=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(z=k),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(N=y),E&&!h){const O=yt(d.left,0),W=yt(d.right,0),T=yt(d.top,0),L=yt(d.bottom,0);m?z=v-2*(O!==0||W!==0?O+W:yt(d.left,d.right)):N=g-2*(T!==0||L!==0?T+L:yt(d.top,d.bottom))}await c({...t,availableWidth:z,availableHeight:N});const A=await a.getDimensions(l.floating);return v!==A.width||g!==A.height?{reset:{rects:!0}}:{}}}};function Qo(){return typeof window<"u"}function Ar(e){return Up(e)?(e.nodeName||"").toLowerCase():"#document"}function kt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Jt(e){var t;return(t=(Up(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Up(e){return Qo()?e instanceof Node||e instanceof kt(e).Node:!1}function Dt(e){return Qo()?e instanceof Element||e instanceof kt(e).Element:!1}function Gt(e){return Qo()?e instanceof HTMLElement||e instanceof kt(e).HTMLElement:!1}function ou(e){return!Qo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof kt(e).ShadowRoot}const pS=new Set(["inline","contents"]);function cs(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=$t(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(Ar(e))}const gS=[":popover-open",":modal"];function ei(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 Ol(e){const t=Pl(),n=Dt(e)?$t(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=_n(e);for(;Gt(t)&&!wr(t);){if(Ol(t))return t;if(ei(t))return null;t=_n(t)}return null}function Pl(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const wS=new Set(["html","body","#document"]);function wr(e){return wS.has(Ar(e))}function $t(e){return kt(e).getComputedStyle(e)}function ti(e){return Dt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function _n(e){if(Ar(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ou(e)&&e.host||Jt(e);return ou(t)?t.host:t}function Wp(e){const t=_n(e);return wr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Gt(t)&&cs(t)?t:Wp(t)}function Yr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Wp(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),a=kt(o);if(i){const l=xa(a);return t.concat(a,a.visualViewport||[],cs(o)?o:[],l&&n?Yr(l):[])}return t.concat(o,Yr(o,[],n))}function xa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Hp(e){const t=$t(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Gt(e),i=o?e.offsetWidth:n,a=o?e.offsetHeight:r,l=mo(n)!==i||mo(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function Ml(e){return Dt(e)?e:e.contextElement}function hr(e){const t=Ml(e);if(!Gt(t))return Zt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=Hp(t);let a=(i?mo(n.width):n.width)/r,l=(i?mo(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const _S=Zt(0);function Vp(e){const t=kt(e);return!Pl()||!t.visualViewport?_S:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function kS(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==kt(e)?!1:t}function Fn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Ml(e);let a=Zt(1);t&&(r?Dt(r)&&(a=hr(r)):a=hr(e));const l=kS(i,n,r)?Vp(i):Zt(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 h=kt(i),m=r&&Dt(r)?kt(r):r;let v=h,g=xa(v);for(;g&&r&&m!==v;){const x=hr(g),b=g.getBoundingClientRect(),y=$t(g),k=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+=k,u+=j,v=kt(g),g=xa(v)}}return xo({width:d,height:f,x:c,y:u})}function ni(e,t){const n=ti(e).scrollLeft;return t?t.left+n:Fn(Jt(e)).left+n}function qp(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ni(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=Jt(r),l=t?ei(t.floating):!1;if(r===a||l&&i)return n;let c={scrollLeft:0,scrollTop:0},u=Zt(1);const d=Zt(0),f=Gt(r);if((f||!f&&!i)&&((Ar(r)!=="body"||cs(a))&&(c=ti(r)),Gt(r))){const m=Fn(r);u=hr(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const h=a&&!f&&!i?qp(a,c):Zt(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function SS(e){return Array.from(e.getClientRects())}function CS(e){const t=Jt(e),n=ti(e),r=e.ownerDocument.body,o=yt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=yt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+ni(e);const l=-n.scrollTop;return $t(r).direction==="rtl"&&(a+=yt(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:a,y:l}}const iu=25;function NS(e,t){const n=kt(e),r=Jt(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=Pl();(!d||d&&t==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}const u=ni(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),m=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-m);v<=iu&&(i-=v)}else u<=iu&&(i+=u);return{width:i,height:a,x:l,y:c}}const TS=new Set(["absolute","fixed"]);function ES(e,t){const n=Fn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Gt(e)?hr(e):Zt(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 au(e,t,n){let r;if(t==="viewport")r=NS(e,n);else if(t==="document")r=CS(Jt(e));else if(Dt(t))r=ES(t,n);else{const o=Vp(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return xo(r)}function Zp(e,t){const n=_n(e);return n===t||!Dt(n)||wr(n)?!1:$t(n).position==="fixed"||Zp(n,t)}function AS(e,t){const n=t.get(e);if(n)return n;let r=Yr(e,[],!1).filter(l=>Dt(l)&&Ar(l)!=="body"),o=null;const i=$t(e).position==="fixed";let a=i?_n(e):e;for(;Dt(a)&&!wr(a);){const l=$t(a),c=Ol(a);!c&&l.position==="fixed"&&(o=null),(i?!c&&!o:!c&&l.position==="static"&&!!o&&TS.has(o.position)||cs(a)&&!c&&Zp(e,a))?r=r.filter(d=>d!==a):o=l,a=_n(a)}return t.set(e,r),r}function RS(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?ei(t)?[]:AS(t,this._c):[].concat(n),r],l=a[0],c=a.reduce((u,d)=>{const f=au(t,d,o);return u.top=yt(f.top,u.top),u.right=wn(f.right,u.right),u.bottom=wn(f.bottom,u.bottom),u.left=yt(f.left,u.left),u},au(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}=Hp(e);return{width:t,height:n}}function zS(e,t,n){const r=Gt(t),o=Jt(t),i=n==="fixed",a=Fn(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=Zt(0);function u(){c.x=ni(o)}if(r||!r&&!i)if((Ar(t)!=="body"||cs(o))&&(l=ti(t)),r){const m=Fn(t,!0,i,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else o&&u();i&&!r&&o&&u();const d=o&&!r&&!i?qp(o,l):Zt(0),f=a.left+l.scrollLeft-c.x-d.x,h=a.top+l.scrollTop-c.y-d.y;return{x:f,y:h,width:a.width,height:a.height}}function Ri(e){return $t(e).position==="static"}function lu(e,t){if(!Gt(e)||$t(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Jt(e)===n&&(n=n.ownerDocument.body),n}function Gp(e,t){const n=kt(e);if(ei(e))return n;if(!Gt(e)){let o=_n(e);for(;o&&!wr(o);){if(Dt(o)&&!Ri(o))return o;o=_n(o)}return n}let r=lu(e,t);for(;r&&mS(r)&&Ri(r);)r=lu(r,t);return r&&wr(r)&&Ri(r)&&!Ol(r)?n:r||yS(e)||n}const OS=async function(e){const t=this.getOffsetParent||Gp,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 PS(e){return $t(e).direction==="rtl"}const MS={convertOffsetParentRelativeRectToViewportRelativeRect:jS,getDocumentElement:Jt,getClippingRect:RS,getOffsetParent:Gp,getElementRects:OS,getClientRects:SS,getDimensions:IS,getScale:hr,isElement:Dt,isRTL:PS};function Kp(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=Jt(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:h,height:m}=u;if(l||t(),!h||!m)return;const v=As(f),g=As(o.clientWidth-(d+h)),x=As(o.clientHeight-(f+m)),b=As(d),k={rootMargin:-v+"px "+-g+"px "+-x+"px "+-b+"px",threshold:yt(0,wn(1,c))||1};let j=!0;function S(E){const N=E[0].intersectionRatio;if(N!==c){if(!j)return a();N?a(!1,N):r=setTimeout(()=>{a(!1,1e-7)},1e3)}N===1&&!Kp(u,e.getBoundingClientRect())&&a(),j=!1}try{n=new IntersectionObserver(S,{...k,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,k)}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?Yr(u):[],...Yr(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 h=-1,m=null;a&&(m=new ResizeObserver(b=>{let[y]=b;y&&y.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var k;(k=m)==null||k.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let v,g=c?Fn(e):null;c&&x();function x(){const b=Fn(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=m)==null||b.disconnect(),m=null,c&&cancelAnimationFrame(v)}}const $S=cS,FS=uS,BS=iS,US=fS,WS=aS,cu=oS,HS=dS,VS=(e,t,n)=>{const r=new Map,o={platform:MS,...n},i={...o.platform,_c:r};return sS(e,t,{...o,platform:i})};var qS=typeof document<"u",ZS=function(){},Ks=qS?p.useLayoutEffect:ZS;function bo(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(!bo(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)&&!bo(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function Jp(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function uu(e,t){const n=Jp(e);return Math.round(t*n)/n}function Ii(e){const t=p.useRef(e);return Ks(()=>{t.current=e}),t}function GS(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}),[h,m]=p.useState(r);bo(h,r)||m(r);const[v,g]=p.useState(null),[x,b]=p.useState(null),y=p.useCallback(H=>{H!==E.current&&(E.current=H,g(H))},[]),k=p.useCallback(H=>{H!==N.current&&(N.current=H,b(H))},[]),j=i||v,S=a||x,E=p.useRef(null),N=p.useRef(null),z=p.useRef(d),A=c!=null,O=Ii(c),W=Ii(o),T=Ii(u),L=p.useCallback(()=>{if(!E.current||!N.current)return;const H={placement:t,strategy:n,middleware:h};W.current&&(H.platform=W.current),VS(E.current,N.current,H).then(Z=>{const ue={...Z,isPositioned:T.current!==!1};_.current&&!bo(z.current,ue)&&(z.current=ue,ss.flushSync(()=>{f(ue)}))})},[h,t,n,W,T]);Ks(()=>{u===!1&&z.current.isPositioned&&(z.current.isPositioned=!1,f(H=>({...H,isPositioned:!1})))},[u]);const _=p.useRef(!1);Ks(()=>(_.current=!0,()=>{_.current=!1}),[]),Ks(()=>{if(j&&(E.current=j),S&&(N.current=S),j&&S){if(O.current)return O.current(j,S,L);L()}},[j,S,L,O,A]);const $=p.useMemo(()=>({reference:E,floating:N,setReference:y,setFloating:k}),[y,k]),ee=p.useMemo(()=>({reference:j,floating:S}),[j,S]),D=p.useMemo(()=>{const H={position:n,left:0,top:0};if(!ee.floating)return H;const Z=uu(ee.floating,d.x),ue=uu(ee.floating,d.y);return l?{...H,transform:"translate("+Z+"px, "+ue+"px)",...Jp(ee.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Z,top:ue}},[n,l,ee.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:L,refs:$,elements:ee,floatingStyles:D}),[d,L,$,ee,D])}const KS=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?cu({element:r.current,padding:o}).fn(n):{}:r?cu({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)=>({...KS(e),options:[e,t]});var rC="Arrow",Yp=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return s.jsx(Re.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"})})});Yp.displayName=rC;var sC=Yp,Ll="Popper",[Xp,ri]=ln(Ll),[oC,Qp]=Xp(Ll),eh=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return s.jsx(oC,{scope:t,anchor:r,onAnchorChange:o,children:n})};eh.displayName=Ll;var th="PopperAnchor",nh=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=Qp(th,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(Re.div,{...o,ref:l})});nh.displayName=th;var Dl="PopperContent",[iC,aC]=Xp(Dl),rh=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:h=!1,updatePositionStrategy:m="optimized",onPlaced:v,...g}=e,x=Qp(Dl,n),[b,y]=p.useState(null),k=De(t,ie=>y(ie)),[j,S]=p.useState(null),E=Vj(j),N=E?.width??0,z=E?.height??0,A=r+(i!=="center"?"-"+i:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},W=Array.isArray(u)?u:[u],T=W.length>0,L={padding:O,boundary:W.filter(cC),altBoundary:T},{refs:_,floatingStyles:$,placement:ee,isPositioned:D,middlewareData:H}=GS({strategy:"fixed",placement:A,whileElementsMounted:(...ie)=>DS(...ie,{animationFrame:m==="always"}),elements:{reference:x.anchor},middleware:[JS({mainAxis:o+z,alignmentAxis:a}),c&&YS({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?XS():void 0,...L}),c&&QS({...L}),eC({...L,apply:({elements:ie,rects:pe,availableWidth:me,availableHeight:he})=>{const{width:xe,height:ke}=pe.reference,Ae=ie.floating.style;Ae.setProperty("--radix-popper-available-width",`${me}px`),Ae.setProperty("--radix-popper-available-height",`${he}px`),Ae.setProperty("--radix-popper-anchor-width",`${xe}px`),Ae.setProperty("--radix-popper-anchor-height",`${ke}px`)}}),j&&nC({element:j,padding:l}),uC({arrowWidth:N,arrowHeight:z}),h&&tC({strategy:"referenceHidden",...L})]}),[Z,ue]=ih(ee),V=ft(v);nt(()=>{D&&V?.()},[D,V]);const U=H.arrow?.x,ce=H.arrow?.y,B=H.arrow?.centerOffset!==0,[Q,Se]=p.useState();return nt(()=>{b&&Se(window.getComputedStyle(b).zIndex)},[b]),s.jsx("div",{ref:_.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:D?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[H.transformOrigin?.x,H.transformOrigin?.y].join(" "),...H.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(iC,{scope:n,placedSide:Z,onArrowChange:S,arrowX:U,arrowY:ce,shouldHideArrow:B,children:s.jsx(Re.div,{"data-side":Z,"data-align":ue,...g,ref:k,style:{...g.style,animation:D?void 0:"none"}})})})});rh.displayName=Dl;var sh="PopperArrow",lC={top:"bottom",right:"left",bottom:"top",left:"right"},oh=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=aC(sh,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"}})})});oh.displayName=sh;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]=ih(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(o.arrow?.x??0)+l/2,m=(o.arrow?.y??0)+c/2;let v="",g="";return u==="bottom"?(v=a?f:`${h}px`,g=`${-c}px`):u==="top"?(v=a?f:`${h}px`,g=`${r.floating.height+c}px`):u==="right"?(v=`${-c}px`,g=a?f:`${m}px`):u==="left"&&(v=`${r.floating.width+c}px`,g=a?f:`${m}px`),{data:{x:v,y:g}}}});function ih(e){const[t,n="center"]=e.split("-");return[t,n]}var ah=eh,lh=nh,ch=rh,uh=oh,zi="rovingFocusGroup.onEntryFocus",dC={bubbles:!1,cancelable:!0},us="RovingFocusGroup",[ba,dh,fC]=Pp(us),[pC,fh]=ln(us,[fC]),[hC,mC]=pC(us),ph=p.forwardRef((e,t)=>s.jsx(ba.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(ba.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(gC,{...e,ref:t})})}));ph.displayName=us;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,h=p.useRef(null),m=De(t,h),v=Xo(i),[g,x]=Dn({prop:a,defaultProp:l??null,onChange:c,caller:us}),[b,y]=p.useState(!1),k=ft(u),j=dh(n),S=p.useRef(!1),[E,N]=p.useState(0);return p.useEffect(()=>{const z=h.current;if(z)return z.addEventListener(zi,k),()=>z.removeEventListener(zi,k)},[k]),s.jsx(hC,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(z=>x(z),[x]),onItemShiftTab:p.useCallback(()=>y(!0),[]),onFocusableItemAdd:p.useCallback(()=>N(z=>z+1),[]),onFocusableItemRemove:p.useCallback(()=>N(z=>z-1),[]),children:s.jsx(Re.div,{tabIndex:b||E===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:Ne(e.onMouseDown,()=>{S.current=!0}),onFocus:Ne(e.onFocus,z=>{const A=!S.current;if(z.target===z.currentTarget&&A&&!b){const O=new CustomEvent(zi,dC);if(z.currentTarget.dispatchEvent(O),!O.defaultPrevented){const W=j().filter(ee=>ee.focusable),T=W.find(ee=>ee.active),L=W.find(ee=>ee.id===g),$=[T,L,...W].filter(Boolean).map(ee=>ee.ref.current);gh($,d)}}S.current=!1}),onBlur:Ne(e.onBlur,()=>y(!1))})})}),hh="RovingFocusGroupItem",mh=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:a,...l}=e,c=qt(),u=i||c,d=mC(hh,n),f=d.currentTabStopId===u,h=dh(n),{onFocusableItemAdd:m,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return m(),()=>v()},[r,m,v]),s.jsx(ba.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:s.jsx(Re.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...l,ref:t,onMouseDown:Ne(e.onMouseDown,x=>{r?d.onItemFocus(u):x.preventDefault()}),onFocus:Ne(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:Ne(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 k=h().filter(j=>j.focusable).map(j=>j.ref.current);if(b==="last")k.reverse();else if(b==="prev"||b==="next"){b==="prev"&&k.reverse();const j=k.indexOf(x.currentTarget);k=d.loop?yC(k,j+1):k.slice(j+1)}setTimeout(()=>gh(k))}}),children:typeof a=="function"?a({isCurrentTabStop:f,hasTabStop:g!=null}):a})})});mh.displayName=hh;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 gh(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=ph,_C=mh;function va(e,[t,n]){return Math.min(n,Math.max(t,e))}function kC(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var $l="ScrollArea",[xh]=ln($l),[jC,Et]=xh($l),bh=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,h]=p.useState(null),[m,v]=p.useState(null),[g,x]=p.useState(null),[b,y]=p.useState(0),[k,j]=p.useState(0),[S,E]=p.useState(!1),[N,z]=p.useState(!1),A=De(t,W=>c(W)),O=Xo(o);return s.jsx(jC,{scope:n,type:r,dir:O,scrollHideDelay:i,scrollArea:l,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:m,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:E,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:N,onScrollbarYEnabledChange:z,onCornerWidthChange:y,onCornerHeightChange:j,children:s.jsx(Re.div,{dir:O,...a,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":k+"px",...e.style}})})});bh.displayName=$l;var vh="ScrollAreaViewport",yh=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...i}=e,a=Et(vh,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(Re.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})})]})});yh.displayName=vh;var Yt="ScrollAreaScrollbar",wh=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Et(Yt,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(_h,{...r,ref:t,forceMount:n}):o.type==="always"?s.jsx(Fl,{...r,ref:t}):null});wh.displayName=Yt;var SC=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Et(Yt,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(Tt,{present:n||i,children:s.jsx(_h,{"data-state":i?"visible":"hidden",...r,ref:t})})}),CC=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Et(Yt,e.__scopeScrollArea),i=e.orientation==="horizontal",a=oi(()=>c("SCROLL_END"),100),[l,c]=kC("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 h=()=>{const m=u[d];f!==m&&(c("SCROLL"),a()),f=m};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,i,c,a]),s.jsx(Tt,{present:n||l!=="hidden",children:s.jsx(Fl,{"data-state":l==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:Ne(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Ne(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),_h=p.forwardRef((e,t)=>{const n=Et(Yt,e.__scopeScrollArea),{forceMount:r,...o}=e,[i,a]=p.useState(!1),l=e.orientation==="horizontal",c=oi(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;a(l?u:d)}},10);return _r(n.viewport,c),_r(n.content,c),s.jsx(Tt,{present:r||i,children:s.jsx(Fl,{"data-state":i?"visible":"hidden",...o,ref:t})})}),Fl=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Et(Yt,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=Nh(l.viewport,l.content),d={...r,sizes:l,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:h=>i.current=h,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:h=>a.current=h};function f(h,m){return IC(h,a.current,l,m)}return n==="horizontal"?s.jsx(NC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const h=o.viewport.scrollLeft,m=du(h,l,o.dir);i.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?s.jsx(TC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const h=o.viewport.scrollTop,m=du(h,l);i.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),NC=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=Et(Yt,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(jh,{"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":si(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(i.viewport){const h=i.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),Eh(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&i.viewport&&a&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:yo(a.paddingLeft),paddingEnd:yo(a.paddingRight)}})}})}),TC=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=Et(Yt,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(jh,{"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":si(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(i.viewport){const h=i.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),Eh(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&i.viewport&&a&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:yo(a.paddingTop),paddingEnd:yo(a.paddingBottom)}})}})}),[EC,kh]=xh(Yt),jh=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,...h}=e,m=Et(Yt,n),[v,g]=p.useState(null),x=De(t,A=>g(A)),b=p.useRef(null),y=p.useRef(""),k=m.viewport,j=r.content-r.viewport,S=ft(d),E=ft(c),N=oi(f,10);function z(A){if(b.current){const O=A.clientX-b.current.left,W=A.clientY-b.current.top;u({x:O,y:W})}}return p.useEffect(()=>{const A=O=>{const W=O.target;v?.contains(W)&&S(O,j)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[k,v,j,S]),p.useEffect(E,[r,E]),_r(v,N),_r(m.content,N),s.jsx(EC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:ft(i),onThumbPointerUp:ft(a),onThumbPositionChange:E,onThumbPointerDown:ft(l),children:s.jsx(Re.div,{...h,ref:x,style:{position:"absolute",...h.style},onPointerDown:Ne(e.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),b.current=v.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),z(A))}),onPointerMove:Ne(e.onPointerMove,z),onPointerUp:Ne(e.onPointerUp,A=>{const O=A.target;O.hasPointerCapture(A.pointerId)&&O.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=y.current,m.viewport&&(m.viewport.style.scrollBehavior=""),b.current=null})})})}),vo="ScrollAreaThumb",Sh=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=kh(vo,e.__scopeScrollArea);return s.jsx(Tt,{present:n||o.hasThumb,children:s.jsx(AC,{ref:t,...r})})}),AC=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,i=Et(vo,n),a=kh(vo,n),{onThumbPositionChange:l}=a,c=De(t,f=>a.onThumbChange(f)),u=p.useRef(void 0),d=oi(()=>{u.current&&(u.current(),u.current=void 0)},100);return p.useEffect(()=>{const f=i.viewport;if(f){const h=()=>{if(d(),!u.current){const m=zC(f,l);u.current=m,l()}};return l(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[i.viewport,d,l]),s.jsx(Re.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:Ne(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),v=f.clientX-m.left,g=f.clientY-m.top;a.onThumbPointerDown({x:v,y:g})}),onPointerUp:Ne(e.onPointerUp,a.onThumbPointerUp)})});Sh.displayName=vo;var Bl="ScrollAreaCorner",Ch=p.forwardRef((e,t)=>{const n=Et(Bl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?s.jsx(RC,{...e,ref:t}):null});Ch.displayName=Bl;var RC=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Et(Bl,n),[i,a]=p.useState(0),[l,c]=p.useState(0),u=!!(i&&l);return _r(o.scrollbarX,()=>{const d=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(d),c(d)}),_r(o.scrollbarY,()=>{const d=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(d),a(d)}),u?s.jsx(Re.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 yo(e){return e?parseInt(e,10):0}function Nh(e,t){const n=e/t;return isNaN(n)?0:n}function si(e){const t=Nh(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=si(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 du(e,t,n="ltr"){const r=si(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=va(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 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 oi(e,t){const n=ft(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 _r(e,t){const n=ft(t);nt(()=>{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 OC=bh,PC=yh,MC=Ch,LC=[" ","Enter","ArrowUp","ArrowDown"],DC=[" ","Enter"],Bn="Select",[ii,ai,$C]=Pp(Bn),[Rr]=ln(Bn,[$C,ri]),li=ri(),[FC,Sn]=Rr(Bn),[BC,UC]=Rr(Bn),Ah=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:h,required:m,form:v}=e,g=li(t),[x,b]=p.useState(null),[y,k]=p.useState(null),[j,S]=p.useState(!1),E=Xo(u),[N,z]=Dn({prop:r,defaultProp:o??!1,onChange:i,caller:Bn}),[A,O]=Dn({prop:a,defaultProp:l,onChange:c,caller:Bn}),W=p.useRef(null),T=x?v||!!x.closest("form"):!0,[L,_]=p.useState(new Set),$=Array.from(L).map(ee=>ee.props.value).join(";");return s.jsx(ah,{...g,children:s.jsxs(FC,{required:m,scope:t,trigger:x,onTriggerChange:b,valueNode:y,onValueNodeChange:k,valueNodeHasChildren:j,onValueNodeHasChildrenChange:S,contentId:qt(),value:A,onValueChange:O,open:N,onOpenChange:z,dir:E,triggerPointerDownPosRef:W,disabled:h,children:[s.jsx(ii.Provider,{scope:t,children:s.jsx(BC,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(ee=>{_(D=>new Set(D).add(ee))},[]),onNativeOptionRemove:p.useCallback(ee=>{_(D=>{const H=new Set(D);return H.delete(ee),H})},[]),children:n})}),T?s.jsxs(Xh,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:A,onChange:ee=>O(ee.target.value),disabled:h,form:v,children:[A===void 0?s.jsx("option",{value:""}):null,Array.from(L)]},$):null]})})};Ah.displayName=Bn;var Rh="SelectTrigger",Ih=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,i=li(n),a=Sn(Rh,n),l=a.disabled||r,c=De(t,a.onTriggerChange),u=ai(n),d=p.useRef("touch"),[f,h,m]=em(g=>{const x=u().filter(k=>!k.disabled),b=x.find(k=>k.value===a.value),y=tm(x,g,b);y!==void 0&&a.onValueChange(y.value)}),v=g=>{l||(a.onOpenChange(!0),m()),g&&(a.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return s.jsx(lh,{asChild:!0,...i,children:s.jsx(Re.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":Qh(a.value)?"":void 0,...o,ref:c,onClick:Ne(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:Ne(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:Ne(o.onKeyDown,g=>{const x=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&h(g.key),!(x&&g.key===" ")&&LC.includes(g.key)&&(v(),g.preventDefault())})})})});Ih.displayName=Rh;var zh="SelectValue",Oh=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:a="",...l}=e,c=Sn(zh,n),{onValueNodeHasChildrenChange:u}=c,d=i!==void 0,f=De(t,c.onValueNodeChange);return nt(()=>{u(d)},[u,d]),s.jsx(Re.span,{...l,ref:f,style:{pointerEvents:"none"},children:Qh(c.value)?s.jsx(s.Fragment,{children:a}):i})});Oh.displayName=zh;var WC="SelectIcon",Ph=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return s.jsx(Re.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Ph.displayName=WC;var HC="SelectPortal",Mh=e=>s.jsx(Vo,{asChild:!0,...e});Mh.displayName=HC;var Un="SelectContent",Lh=p.forwardRef((e,t)=>{const n=Sn(Un,e.__scopeSelect),[r,o]=p.useState();if(nt(()=>{o(new DocumentFragment)},[]),!n.open){const i=r;return i?ss.createPortal(s.jsx(Dh,{scope:e.__scopeSelect,children:s.jsx(ii.Slot,{scope:e.__scopeSelect,children:s.jsx("div",{children:e.children})})}),i):null}return s.jsx($h,{...e,ref:t})});Lh.displayName=Un;var Ot=10,[Dh,Cn]=Rr(Un),VC="SelectContentImpl",qC=yr("SelectContent.RemoveScroll"),$h=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:h,collisionPadding:m,sticky:v,hideWhenDetached:g,avoidCollisions:x,...b}=e,y=Sn(Un,n),[k,j]=p.useState(null),[S,E]=p.useState(null),N=De(t,ie=>j(ie)),[z,A]=p.useState(null),[O,W]=p.useState(null),T=ai(n),[L,_]=p.useState(!1),$=p.useRef(!1);p.useEffect(()=>{if(k)return hp(k)},[k]),op();const ee=p.useCallback(ie=>{const[pe,...me]=T().map(ke=>ke.ref.current),[he]=me.slice(-1),xe=document.activeElement;for(const ke of ie)if(ke===xe||(ke?.scrollIntoView({block:"nearest"}),ke===pe&&S&&(S.scrollTop=0),ke===he&&S&&(S.scrollTop=S.scrollHeight),ke?.focus(),document.activeElement!==xe))return},[T,S]),D=p.useCallback(()=>ee([z,k]),[ee,z,k]);p.useEffect(()=>{L&&D()},[L,D]);const{onOpenChange:H,triggerPointerDownPosRef:Z}=y;p.useEffect(()=>{if(k){let ie={x:0,y:0};const pe=he=>{ie={x:Math.abs(Math.round(he.pageX)-(Z.current?.x??0)),y:Math.abs(Math.round(he.pageY)-(Z.current?.y??0))}},me=he=>{ie.x<=10&&ie.y<=10?he.preventDefault():k.contains(he.target)||H(!1),document.removeEventListener("pointermove",pe),Z.current=null};return Z.current!==null&&(document.addEventListener("pointermove",pe),document.addEventListener("pointerup",me,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",pe),document.removeEventListener("pointerup",me,{capture:!0})}}},[k,H,Z]),p.useEffect(()=>{const ie=()=>H(!1);return window.addEventListener("blur",ie),window.addEventListener("resize",ie),()=>{window.removeEventListener("blur",ie),window.removeEventListener("resize",ie)}},[H]);const[ue,V]=em(ie=>{const pe=T().filter(xe=>!xe.disabled),me=pe.find(xe=>xe.ref.current===document.activeElement),he=tm(pe,ie,me);he&&setTimeout(()=>he.ref.current.focus())}),U=p.useCallback((ie,pe,me)=>{const he=!$.current&&!me;(y.value!==void 0&&y.value===pe||he)&&(A(ie),he&&($.current=!0))},[y.value]),ce=p.useCallback(()=>k?.focus(),[k]),B=p.useCallback((ie,pe,me)=>{const he=!$.current&&!me;(y.value!==void 0&&y.value===pe||he)&&W(ie)},[y.value]),Q=r==="popper"?ya:Fh,Se=Q===ya?{side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return s.jsx(Dh,{scope:n,content:k,viewport:S,onViewportChange:E,itemRefCallback:U,selectedItem:z,onItemLeave:ce,itemTextRefCallback:B,focusSelectedItem:D,selectedItemText:O,position:r,isPositioned:L,searchRef:ue,children:s.jsx(_l,{as:qC,allowPinchZoom:!0,children:s.jsx(wl,{asChild:!0,trapped:y.open,onMountAutoFocus:ie=>{ie.preventDefault()},onUnmountAutoFocus:Ne(o,ie=>{y.trigger?.focus({preventScroll:!0}),ie.preventDefault()}),children:s.jsx(Ho,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:ie=>ie.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:s.jsx(Q,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:ie=>ie.preventDefault(),...b,...Se,onPlaced:()=>_(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:Ne(b.onKeyDown,ie=>{const pe=ie.ctrlKey||ie.altKey||ie.metaKey;if(ie.key==="Tab"&&ie.preventDefault(),!pe&&ie.key.length===1&&V(ie.key),["ArrowUp","ArrowDown","Home","End"].includes(ie.key)){let he=T().filter(xe=>!xe.disabled).map(xe=>xe.ref.current);if(["ArrowUp","End"].includes(ie.key)&&(he=he.slice().reverse()),["ArrowUp","ArrowDown"].includes(ie.key)){const xe=ie.target,ke=he.indexOf(xe);he=he.slice(ke+1)}setTimeout(()=>ee(he)),ie.preventDefault()}})})})})})})});$h.displayName=VC;var ZC="SelectItemAlignedPosition",Fh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,i=Sn(Un,n),a=Cn(Un,n),[l,c]=p.useState(null),[u,d]=p.useState(null),f=De(t,N=>d(N)),h=ai(n),m=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:b,focusSelectedItem:y}=a,k=p.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&u&&g&&x&&b){const N=i.trigger.getBoundingClientRect(),z=u.getBoundingClientRect(),A=i.valueNode.getBoundingClientRect(),O=b.getBoundingClientRect();if(i.dir!=="rtl"){const xe=O.left-z.left,ke=A.left-xe,Ae=N.left-ke,w=N.width+Ae,X=Math.max(w,z.width),G=window.innerWidth-Ot,P=va(ke,[Ot,Math.max(Ot,G-X)]);l.style.minWidth=w+"px",l.style.left=P+"px"}else{const xe=z.right-O.right,ke=window.innerWidth-A.right-xe,Ae=window.innerWidth-N.right-ke,w=N.width+Ae,X=Math.max(w,z.width),G=window.innerWidth-Ot,P=va(ke,[Ot,Math.max(Ot,G-X)]);l.style.minWidth=w+"px",l.style.right=P+"px"}const W=h(),T=window.innerHeight-Ot*2,L=g.scrollHeight,_=window.getComputedStyle(u),$=parseInt(_.borderTopWidth,10),ee=parseInt(_.paddingTop,10),D=parseInt(_.borderBottomWidth,10),H=parseInt(_.paddingBottom,10),Z=$+ee+L+H+D,ue=Math.min(x.offsetHeight*5,Z),V=window.getComputedStyle(g),U=parseInt(V.paddingTop,10),ce=parseInt(V.paddingBottom,10),B=N.top+N.height/2-Ot,Q=T-B,Se=x.offsetHeight/2,ie=x.offsetTop+Se,pe=$+ee+ie,me=Z-pe;if(pe<=B){const xe=W.length>0&&x===W[W.length-1].ref.current;l.style.bottom="0px";const ke=u.clientHeight-g.offsetTop-g.offsetHeight,Ae=Math.max(Q,Se+(xe?ce:0)+ke+D),w=pe+Ae;l.style.height=w+"px"}else{const xe=W.length>0&&x===W[0].ref.current;l.style.top="0px";const Ae=Math.max(B,$+g.offsetTop+(xe?U:0)+Se)+me;l.style.height=Ae+"px",g.scrollTop=pe-B+g.offsetTop}l.style.margin=`${Ot}px 0`,l.style.minHeight=ue+"px",l.style.maxHeight=T+"px",r?.(),requestAnimationFrame(()=>m.current=!0)}},[h,i.trigger,i.valueNode,l,u,g,x,b,i.dir,r]);nt(()=>k(),[k]);const[j,S]=p.useState();nt(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const E=p.useCallback(N=>{N&&v.current===!0&&(k(),y?.(),v.current=!1)},[k,y]);return s.jsx(KC,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:m,onScrollButtonChange:E,children:s.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:j},children:s.jsx(Re.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Fh.displayName=ZC;var GC="SelectPopperPosition",ya=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Ot,...i}=e,a=li(n);return s.jsx(ch,{...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)"}})});ya.displayName=GC;var[KC,Ul]=Rr(Un,{}),wa="SelectViewport",Bh=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,i=Cn(wa,n),a=Ul(wa,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(ii.Slot,{scope:n,children:s.jsx(Re.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ne(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=a;if(h?.current&&f){const m=Math.abs(c.current-d.scrollTop);if(m>0){const v=window.innerHeight-Ot*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),b=Math.max(g,x);if(b<v){const y=b+m,k=Math.min(v,y),j=y-k;f.style.height=k+"px",f.style.bottom==="0px"&&(d.scrollTop=j>0?j:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});Bh.displayName=wa;var Uh="SelectGroup",[JC,YC]=Rr(Uh),XC=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=qt();return s.jsx(JC,{scope:n,id:o,children:s.jsx(Re.div,{role:"group","aria-labelledby":o,...r,ref:t})})});XC.displayName=Uh;var Wh="SelectLabel",QC=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=YC(Wh,n);return s.jsx(Re.div,{id:o.id,...r,ref:t})});QC.displayName=Wh;var wo="SelectItem",[eN,Hh]=Rr(wo),Vh=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...a}=e,l=Sn(wo,n),c=Cn(wo,n),u=l.value===r,[d,f]=p.useState(i??""),[h,m]=p.useState(!1),v=De(t,y=>c.itemRefCallback?.(y,r,o)),g=qt(),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(eN,{scope:n,value:r,disabled:o,textId:g,isSelected:u,onItemTextChange:p.useCallback(y=>{f(k=>k||(y?.textContent??"").trim())},[]),children:s.jsx(ii.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:s.jsx(Re.div,{role:"option","aria-labelledby":g,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:v,onFocus:Ne(a.onFocus,()=>m(!0)),onBlur:Ne(a.onBlur,()=>m(!1)),onClick:Ne(a.onClick,()=>{x.current!=="mouse"&&b()}),onPointerUp:Ne(a.onPointerUp,()=>{x.current==="mouse"&&b()}),onPointerDown:Ne(a.onPointerDown,y=>{x.current=y.pointerType}),onPointerMove:Ne(a.onPointerMove,y=>{x.current=y.pointerType,o?c.onItemLeave?.():x.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ne(a.onPointerLeave,y=>{y.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Ne(a.onKeyDown,y=>{c.searchRef?.current!==""&&y.key===" "||(DC.includes(y.key)&&b(),y.key===" "&&y.preventDefault())})})})})});Vh.displayName=wo;var Hr="SelectItemText",qh=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...i}=e,a=Sn(Hr,n),l=Cn(Hr,n),c=Hh(Hr,n),u=UC(Hr,n),[d,f]=p.useState(null),h=De(t,b=>f(b),c.onItemTextChange,b=>l.itemTextRefCallback?.(b,c.value,c.disabled)),m=d?.textContent,v=p.useMemo(()=>s.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=u;return nt(()=>(g(v),()=>x(v)),[g,x,v]),s.jsxs(s.Fragment,{children:[s.jsx(Re.span,{id:c.textId,...i,ref:h}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren?ss.createPortal(i.children,a.valueNode):null]})});qh.displayName=Hr;var Zh="SelectItemIndicator",Gh=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Hh(Zh,n).isSelected?s.jsx(Re.span,{"aria-hidden":!0,...r,ref:t}):null});Gh.displayName=Zh;var _a="SelectScrollUpButton",Kh=p.forwardRef((e,t)=>{const n=Cn(_a,e.__scopeSelect),r=Ul(_a,e.__scopeSelect),[o,i]=p.useState(!1),a=De(t,r.onScrollButtonChange);return nt(()=>{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(Yh,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});Kh.displayName=_a;var ka="SelectScrollDownButton",Jh=p.forwardRef((e,t)=>{const n=Cn(ka,e.__scopeSelect),r=Ul(ka,e.__scopeSelect),[o,i]=p.useState(!1),a=De(t,r.onScrollButtonChange);return nt(()=>{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(Yh,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});Jh.displayName=ka;var Yh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,i=Cn("SelectScrollButton",n),a=p.useRef(null),l=ai(n),c=p.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return p.useEffect(()=>()=>c(),[c]),nt(()=>{l().find(d=>d.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),s.jsx(Re.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Ne(o.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(r,50))}),onPointerMove:Ne(o.onPointerMove,()=>{i.onItemLeave?.(),a.current===null&&(a.current=window.setInterval(r,50))}),onPointerLeave:Ne(o.onPointerLeave,()=>{c()})})}),tN="SelectSeparator",nN=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return s.jsx(Re.div,{"aria-hidden":!0,...r,ref:t})});nN.displayName=tN;var ja="SelectArrow",rN=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=li(n),i=Sn(ja,n),a=Cn(ja,n);return i.open&&a.position==="popper"?s.jsx(uh,{...o,...r,ref:t}):null});rN.displayName=ja;var sN="SelectBubbleInput",Xh=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(Re.select,{...n,style:{...zp,...n.style},ref:i,defaultValue:t})});Xh.displayName=sN;function Qh(e){return e===""||e===void 0}function em(e){const t=ft(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 tm(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=oN(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 oN(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var iN=Ah,aN=Ih,lN=Oh,cN=Ph,uN=Mh,dN=Lh,fN=Bh,pN=Vh,hN=qh,mN=Gh,gN=Kh,xN=Jh,ci="Tabs",[bN]=ln(ci,[fh]),nm=fh(),[vN,Wl]=bN(ci),rm=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:a="horizontal",dir:l,activationMode:c="automatic",...u}=e,d=Xo(l),[f,h]=Dn({prop:r,onChange:o,defaultProp:i??"",caller:ci});return s.jsx(vN,{scope:n,baseId:qt(),value:f,onValueChange:h,orientation:a,dir:d,activationMode:c,children:s.jsx(Re.div,{dir:d,"data-orientation":a,...u,ref:t})})});rm.displayName=ci;var sm="TabsList",om=p.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Wl(sm,n),a=nm(n);return s.jsx(wC,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(Re.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});om.displayName=sm;var im="TabsTrigger",am=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,a=Wl(im,n),l=nm(n),c=um(a.baseId,r),u=dm(a.baseId,r),d=r===a.value;return s.jsx(_C,{asChild:!0,...l,focusable:!o,active:d,children:s.jsx(Re.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":u,"data-state":d?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...i,ref:t,onMouseDown:Ne(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?a.onValueChange(r):f.preventDefault()}),onKeyDown:Ne(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&a.onValueChange(r)}),onFocus:Ne(e.onFocus,()=>{const f=a.activationMode!=="manual";!d&&!o&&f&&a.onValueChange(r)})})})});am.displayName=im;var lm="TabsContent",cm=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...a}=e,l=Wl(lm,n),c=um(l.baseId,r),u=dm(l.baseId,r),d=r===l.value,f=p.useRef(d);return p.useEffect(()=>{const h=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(h)},[]),s.jsx(Tt,{present:o||d,children:({present:h})=>s.jsx(Re.div,{"data-state":d?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!h,id:u,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:h&&i})})});cm.displayName=lm;function um(e,t){return`${e}-trigger-${t}`}function dm(e,t){return`${e}-content-${t}`}var yN=rm,wN=om,_N=am,kN=cm,[ui]=ln("Tooltip",[ri]),di=ri(),fm="TooltipProvider",jN=700,Sa="tooltip.open",[SN,Hl]=ui(fm),pm=e=>{const{__scopeTooltip:t,delayDuration:n=jN,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(SN,{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})};pm.displayName=fm;var Xr="Tooltip",[CN,ds]=ui(Xr),hm=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:l}=e,c=Hl(Xr,e.__scopeTooltip),u=di(t),[d,f]=p.useState(null),h=qt(),m=p.useRef(0),v=a??c.disableHoverableContent,g=l??c.delayDuration,x=p.useRef(!1),[b,y]=Dn({prop:r,defaultProp:o??!1,onChange:N=>{N?(c.onOpen(),document.dispatchEvent(new CustomEvent(Sa))):c.onClose(),i?.(N)},caller:Xr}),k=p.useMemo(()=>b?x.current?"delayed-open":"instant-open":"closed",[b]),j=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,x.current=!1,y(!0)},[y]),S=p.useCallback(()=>{window.clearTimeout(m.current),m.current=0,y(!1)},[y]),E=p.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{x.current=!0,y(!0),m.current=0},g)},[g,y]);return p.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),s.jsx(ah,{...u,children:s.jsx(CN,{scope:t,contentId:h,open:b,stateAttribute:k,trigger:d,onTriggerChange:f,onTriggerEnter:p.useCallback(()=>{c.isOpenDelayedRef.current?E():j()},[c.isOpenDelayedRef,E,j]),onTriggerLeave:p.useCallback(()=>{v?S():(window.clearTimeout(m.current),m.current=0)},[S,v]),onOpen:j,onClose:S,disableHoverableContent:v,children:n})})};hm.displayName=Xr;var Ca="TooltipTrigger",mm=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ds(Ca,n),i=Hl(Ca,n),a=di(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(lh,{asChild:!0,...a,children:s.jsx(Re.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:Ne(e.onPointerMove,h=>{h.pointerType!=="touch"&&!d.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:Ne(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:Ne(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Ne(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:Ne(e.onBlur,o.onClose),onClick:Ne(e.onClick,o.onClose)})})});mm.displayName=Ca;var Vl="TooltipPortal",[NN,TN]=ui(Vl,{forceMount:void 0}),gm=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=ds(Vl,t);return s.jsx(NN,{scope:t,forceMount:n,children:s.jsx(Tt,{present:n||i.open,children:s.jsx(Vo,{asChild:!0,container:o,children:r})})})};gm.displayName=Vl;var kr="TooltipContent",xm=p.forwardRef((e,t)=>{const n=TN(kr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=ds(kr,e.__scopeTooltip);return s.jsx(Tt,{present:r||a.open,children:a.disableHoverableContent?s.jsx(bm,{side:o,...i,ref:t}):s.jsx(EN,{side:o,...i,ref:t})})}),EN=p.forwardRef((e,t)=>{const n=ds(kr,e.__scopeTooltip),r=Hl(kr,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,h=p.useCallback(()=>{l(null),f(!1)},[f]),m=p.useCallback((v,g)=>{const x=v.currentTarget,b={x:v.clientX,y:v.clientY},y=zN(b,x.getBoundingClientRect()),k=ON(b,y),j=PN(g.getBoundingClientRect()),S=LN([...k,...j]);l(S),f(!0)},[f]);return p.useEffect(()=>()=>h(),[h]),p.useEffect(()=>{if(c&&d){const v=x=>m(x,d),g=x=>m(x,c);return c.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[c,d,m,h]),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),k=!MN(b,a);y?h():k&&(h(),u())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[c,d,a,u,h]),s.jsx(bm,{...e,ref:i})}),[AN,RN]=ui(Xr,{isInside:!1}),IN=Ok("TooltipContent"),bm=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...l}=e,c=ds(kr,n),u=di(n),{onClose:d}=c;return p.useEffect(()=>(document.addEventListener(Sa,d),()=>document.removeEventListener(Sa,d)),[d]),p.useEffect(()=>{if(c.trigger){const f=h=>{h.target?.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),s.jsx(Ho,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:s.jsxs(ch,{"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(IN,{children:r}),s.jsx(AN,{scope:n,isInside:!0,children:s.jsx(Dj,{id:c.contentId,role:"tooltip",children:o||r})})]})})});xm.displayName=kr;var vm="TooltipArrow",ym=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=di(n);return RN(vm,n).isInside?null:s.jsx(uh,{...o,...r,ref:t})});ym.displayName=vm;function zN(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 ON(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 PN(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 MN(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,h=c.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function LN(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),DN(t)}function DN(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 $N=pm,FN=hm,BN=mm,UN=gm,WN=xm,HN=ym;function rt({delayDuration:e=0,...t}){return s.jsx($N,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Ue({...e}){return s.jsx(FN,{"data-slot":"tooltip",...e})}function We({...e}){return s.jsx(BN,{"data-slot":"tooltip-trigger",...e})}function He({className:e,sideOffset:t=0,children:n,...r}){return s.jsx(UN,{children:s.jsxs(WN,{"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(HN,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const VN=3;function qN({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,VN),o=e.length-r.length;return s.jsx(rt,{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(Ue,{children:[s.jsx(We,{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(Mj,{provider:i.provider,className:"size-4"})})}),s.jsx(He,{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 ZN="/v1/chat/completions",GN="/chat/completions",KN="/v1/responses",JN="/responses",YN="/v1/messages";class XN{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 Nn=new XN;function QN(e){return Nn.getApiFormatByPath(e)??"unknown"}Nn.registerPath(YN,"anthropic");Nn.registerPath(ZN,"openai");Nn.registerPath(GN,"openai");Nn.registerPath(KN,"openai");Nn.registerPath(JN,"openai");function e3(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}catch{return{}}}function t3(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:e3(e.inputJson)}}}function wm(e,t,n,r){const o=new Map;let i="",a="",l=null,c=null,u=0,d=0;const f=1e3;let h=0,m=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)),k=Qv.safeParse(y);if(!k.success)continue;const j=k.data;switch(h===0&&(m=Date.now()),r===!0&&v.length<f&&v.push({index:h,timestamp:Date.now()-m,type:j.type,data:j}),h++,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:h>f});const g=[...o.entries()].sort(([x],[b])=>x-b).map(([,x])=>t3(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 n3={format:"anthropic",parseRequest(e,t){try{const n=JSON.parse(e),r=lf.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=cf.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 wm(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}}};Nn.register(n3);class r3{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 fi=new r3,s3="https://api.anthropic.com",o3={MiniMax:"https://api.minimaxi.com/anthropic"},i3={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(o3))if(t.startsWith(n.toLowerCase()))return!0;return!0},getUpstreamBase(e,t){return t?.baseUrl!==void 0?t.baseUrl:s3},extractStream(e,t,n,r){return wm(e,t,n,r)}};fi.register(i3);const ql=1e3;function fs(e,t){if(!(e===null||typeof e!="object"||Array.isArray(e)))return Object.getOwnPropertyDescriptor(e,t)?.value}function at(e,t){const n=fs(e,t);return typeof n=="string"?n:null}function _m(e,t){const n=fs(e,t);return typeof n=="number"&&Number.isFinite(n)?n:null}function _o(e,t){const n=fs(e,t);return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:null}function a3(e,t){const n=fs(e,t);return Array.isArray(n)?n:[]}function l3(e){const t=[];let n=null,r=[];const o=()=>{n===null&&r.length===0||(t.push({event:n,data:r.join(`
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 Zl(e){try{return JSON.parse(e)}catch{return null}}function km(e,t){if(e.event!==null&&e.event!=="")return e.event;const n=c2.safeParse(t);return n.success?n.data.type:""}function c3(e){if(e.data==="[DONE]")return!1;const t=Zl(e.data),n=km(e,t);return n.startsWith("response.")||n==="error"}function jm(e,t,n,r,o){e.length>=ql||e.push({index:t,timestamp:Date.now()-n,type:r,data:o})}function Na(e,t){const n=_o(t,"error"),r=at(n,"message")??at(t,"message")??at(t,"error");r!==null&&r.length>0&&(e.error=r)}function u3(e,t,n,r){let o="",i="",a="",l="",c=null,u=0,d=0,f=!1,h=!1;const m=new Map;let v=0,g=0;const x=[];for(const y of e){if(y.data==="[DONE]")break;const k=Zl(y.data);if(k===null)continue;Na(t,k);const j=i2.safeParse(k);if(!j.success)continue;const S=j.data;if(v===0&&(g=Date.now()),r&&jm(x,v,g,"chat.completion.chunk",S),v++,h||(o=S.id,i=S.model,h=!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=_o(k,"usage"),N=_o(E,"prompt_tokens_details"),z=_m(N,"cached_tokens");z!==null&&(t.cacheReadInputTokens=z),f=!0}for(const E of S.choices){const N=E.delta;N.content!==void 0&&N.content!==null&&(a+=N.content),N.reasoning_content!==void 0&&N.reasoning_content!==null&&(l+=N.reasoning_content),N.thinking!==void 0&&N.thinking!==null&&(l+=N.thinking);const z=N.think;if(z!=null&&(l+=z),E.finish_reason!==void 0&&E.finish_reason!==null&&(c=E.finish_reason),N.tool_calls!==void 0&&N.tool_calls!==null)for(const A of N.tool_calls){let O=m.get(A.index);O===void 0&&(O={index:A.index,type:"function",function:{name:"",arguments:""}},m.set(A.index,O)),A.id!==void 0&&(O.id=A.id),A.function?.name!==void 0&&(O.function.name+=A.function.name),A.function?.arguments!==void 0&&(O.function.arguments+=A.function.arguments)}}}r&&(t.streamingChunks={chunks:x,truncated:v>ql}),f||(d=Math.ceil(a.length/4)),t.outputTokens=d;const b={role:"assistant",content:a};return l.length>0&&(b.reasoning_content=l),m.size>0&&(b.tool_calls=[...m.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 d3(e){const t=oo.safeParse(fs(e,"response"));if(t.success)return t.data;const n=oo.safeParse(e);return n.success?n.data:null}function Sm(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=a3(n,"content");for(const o of r){const i=at(o,"type"),a=at(o,"text");(i==="output_text"||i==="text")&&a!==null&&a.length>0&&t.push(a)}}return t.join(`
89
- `)}function fu(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 Oi(e,t){const n=at(e,"item_id");if(n!==null&&n.length>0)return n;const r=_m(e,"output_index");return r!==null?String(r):`function-${String(t)}`}function Ta(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 f3(e,t,n){if(at(n,"type")!=="function_call")return;const r=Ta(e,t),o=at(n,"id"),i=at(n,"call_id"),a=at(n,"name"),l=at(n,"arguments"),c=at(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 p3(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 h3(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 m3(e){const t=e.completedResponse===null?"":Sm(e.completedResponse),n=t.length>0?t:e.outputText,r=e.completedResponse?.output,o=r!==void 0&&r.length>0?r:p3(n,e.calls),i=e.completedResponse?.usage??h3(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 g3(e,t,n,r){let o=null,i="",a=n??"",l=null,c="",u=null,d=null,f=0,h=0;const m=[],v=new Map;for(const b of e){if(b.data==="[DONE]")break;const y=Zl(b.data);if(y===null)continue;const k=km(b,y);if(f===0&&(h=Date.now()),r&&jm(m,f,h,k===""?"response.event":k,y),f++,Na(t,y),k==="error")continue;const j=d3(y);if(j!==null){o=j,i=j.id,a=j.model??a,l=j.status??l;const E=fu(j,t);u=E.inputTokens??u,d=E.outputTokens??d,Na(t,j)}const S=at(y,"delta");switch(k){case"response.output_text.delta":S!==null&&(c+=S);break;case"response.output_text.done":{const E=at(y,"text");c.length===0&&E!==null&&(c=E);break}case"response.function_call_arguments.delta":{if(S!==null){const E=Ta(v,Oi(y,v.size));E.arguments+=S}break}case"response.function_call_arguments.done":{const E=at(y,"arguments");if(E!==null){const N=Ta(v,Oi(y,v.size));N.arguments=E}break}case"response.output_item.added":case"response.output_item.done":{const E=_o(y,"item");f3(v,Oi(y,v.size),E);break}case"response.failed":case"response.incomplete":l=k.slice(9);break;case"response.completed":l="completed";break}}r&&(t.streamingChunks={chunks:m,truncated:f>ql});const g=m3({completedResponse:o,responseId:i,model:a,status:l,outputText:c,calls:v,inputTokens:u,outputTokens:d}),x=oo.safeParse(g);if(x.success){if(fu(x.data,t).outputTokens===null){const y=Sm(x.data),k=Math.ceil(y.length/4);t.outputTokens=k}return JSON.stringify(x.data)}if(t.outputTokens===null){const b=at(g,"output_text")??c,y=Math.ceil(b.length/4);t.outputTokens=y}return JSON.stringify(g)}function pi(e,t,n,r=!0){const o=l3(e);return o.some(c3)?g3(o,t,n,r):u3(o,t,n,r)}function x3(){return{inputTokens:null,outputTokens:null,cacheCreationInputTokens:null,cacheReadInputTokens:null}}const b3={format:"openai",parseRequest(e,t){try{const n=JSON.parse(e),r=ff.safeParse(n);if(r.success)return{model:r.data.model,sessionId:t?.get("x-session-affinity")??null};const o=pf.safeParse(n);return o.success?{model:o.data.model,sessionId:t?.get("x-session-affinity")??null}:null}catch{return null}},extractTokens(e){const t=mf(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=gf(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 x3()},extractStream(e,t,n,r){return pi(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}}};Nn.register(b3);const v3="https://api.openai.com/v1",y3={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:v3},extractStream(e,t,n,r){return pi(e,t,n,r)}};fi.register(y3);const w3="https://open.bigmodel.cn/api/paas/v4",_3=["glm-","charglm-","cogview-","embedding-","rerank-"],k3={name:"zhipu",matches(e){const t=e.toLowerCase().replace(/\s+/g,"-");return _3.some(n=>t.startsWith(n))},getUpstreamBase(e,t){return t?.baseUrl??w3},extractStream(e,t,n,r){return pi(e,t,n,r)}};fi.register(k3);const j3="https://dashscope.aliyuncs.com/compatible-mode/v1",S3={name:"alibaba",matches(e){return!!e.toLowerCase().replace(/\s+/g,"-").startsWith("qwen")},getUpstreamBase(e,t){return j3},extractStream(e,t,n){return pi(e,t,n)}};fi.register(S3);function Cm(e,t){for(const n of Array.from(e))t(n)}const C3=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function Gl(e){if(e.length===0)return 0;let t=0,n=0;return Cm(e,r=>{C3.test(r)?t+=1:n+=1}),Math.ceil(t*1)+Math.ceil(n/4)}function Kl(e){if(e.length===0)return 0;let t=0;return Cm(e,()=>{t+=1}),t}function Jl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ye(e,t){return e===null||typeof e!="object"||Array.isArray(e)?void 0:Object.getOwnPropertyDescriptor(e,t)?.value}const N3=["file","shell","browser","web","mcp","code","other"];function Ea(e){const t=e.replace(/\s+/g," ").trim();return t.length<=120?t:`${t.slice(0,119)}...`}function Nm(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?Ea(t.slice(0,n+1)):Ea(t)}function T3(e,t){return`${e} ${t??""}`.toLowerCase()}function nr(e,t){return t.some(n=>e.includes(n))}function Tm(e,t){const n=T3(e,t);return e.startsWith("mcp__")||e.startsWith("inspector_")||nr(n,[" mcp","model context protocol"])?"mcp":nr(n,["bash","shell","terminal","command","powershell","exec","process"])?"shell":nr(n,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":nr(n,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":nr(n,["web","search","http","url","fetch"])?"web":nr(n,["code","typescript","javascript","python","repl"])?"code":"other"}function Em(e){const t=ye(e,"properties");return t===null||typeof t!="object"||Array.isArray(t)?[]:Object.keys(t).sort((n,r)=>n.localeCompare(r))}function Am(e){const t=ye(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 E3(e){const t=ye(e,"name");if(typeof t!="string"||t.length===0)return null;const n=ye(e,"description"),r=ye(e,"input_schema")??null,o=typeof n=="string"?n:null;return{name:t,description:o,descriptionPreview:Nm(o),category:Tm(t,o),parameterCount:Em(r).length,requiredParameters:Am(r),schema:r}}function A3(e){const t=ye(e,"function"),n=ye(e,"type");if(t===void 0&&typeof n!="string")return null;const r=ye(t,"name")??ye(e,"name")??(typeof n=="string"?n:void 0);if(typeof r!="string"||r.length===0)return null;const o=ye(t,"description")??ye(e,"description"),i=ye(t,"parameters")??ye(e,"parameters")??null,a=typeof o=="string"?o:null;return{name:r,description:a,descriptionPreview:Nm(a),category:Tm(r,a),parameterCount:Em(i).length,requiredParameters:Am(i),schema:i}}function R3(e){const t=A3(e);return t!==null?t:E3(e)}function I3(e){if(e==null)return null;if(typeof e=="string")return e;const t=ye(e,"type"),n=ye(e,"name"),r=ye(ye(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:Ea(o)}function z3(e){const t=new Map;for(const n of e)t.set(n.category,(t.get(n.category)??0)+1);return N3.flatMap(n=>{const r=t.get(n)??0;return r>0?[{category:n,count:r}]:[]})}function Yl(e){const t=ye(e,"tools");if(!Array.isArray(t)||t.length===0)return null;const n=[];for(const r of t){const o=R3(r);o!==null&&n.push(o)}return n.length===0?null:{tools:n,toolChoiceLabel:I3(ye(e,"tool_choice")),categories:z3(n)}}function Mn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const mr={parsed:null,toolNames:null};function O3(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 P3(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 M3(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:Gl(n),characters:Kl(n),path:r}}const L3={format:"anthropic",analyzeRequest(e){if(e===null)return Mn(e);try{const t=JSON.parse(e),n=Yl(t)?.tools.length??null,r=lf.safeParse(t);return r.success?{parsed:r.data,comparisonValue:r.data,messageCount:r.data.messages.length,toolCount:n}:Mn(e)}catch{return Mn(e)}},analyzeResponse(e){if(e===null)return mr;try{let t=JSON.parse(e);typeof t=="string"&&(t=JSON.parse(t));const n=cf.safeParse(t);if(!n.success)return mr;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 mr}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,n=[];if(t.system!==void 0){const r=P3(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=O3(i.content);n.push(Pi(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.tools)&&t.tools.length>0){const r=M3(t.tools);n.push(Pi("tools","tools",r,"/tools"))}return n.length>0?n:null}};function Aa(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 D3(e){const t=[],n=Aa(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 $3(e){if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const r=ye(n,"function"),o=ye(r,"name")??ye(n,"name"),i=ye(r,"description")??ye(n,"description"),a=ye(r,"parameters")??ye(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 F3(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function B3(e){if(typeof e=="string")return e;const t=ye(e,"text");if(typeof t=="string")return t;const n=Aa(ye(e,"content"));if(n.length>0)return n;const r=Aa(ye(e,"output"));if(r.length>0)return r;const o=ye(e,"arguments");return typeof o=="string"?o:""}function U3(e){const t=ye(e,"role");if(t==="system"||t==="user"||t==="assistant"||t==="tool")return t;const n=ye(e,"type");return n==="function_call_output"?"tool":"user"}function W3(e){const t=ye(e,"output");if(!Array.isArray(t))return[];const n=[];for(const r of t){if(ye(r,"type")!=="function_call")continue;const o=ye(r,"name");typeof o=="string"&&o.length>0&&n.push(o)}return n}function Pr(e,t,n,r){return{role:e,label:t,text:n,size:Gl(n),characters:Kl(n),path:r}}const H3={format:"openai",analyzeRequest(e){if(e===null)return Mn(e);try{const t=JSON.parse(e),n=Yl(t)?.tools.length??null,r=ff.safeParse(t);if(!r.success){const o=pf.safeParse(t);return o.success?{parsed:o.data,comparisonValue:o.data,messageCount:F3(o.data.input),toolCount:n}:Mn(e)}return{parsed:r.data,comparisonValue:r.data,messageCount:r.data.messages.length,toolCount:n}}catch{return Mn(e)}},analyzeResponse(e){if(e===null)return mr;const t=mf(e);if(t===null){const r=gf(e);if(r===null)return mr;const o=W3(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(Pr("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=D3(i);n.push(Pr(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.messages)||(typeof t.input=="string"&&t.input.length>0?n.push(Pr("user","input",t.input,"/input")):Array.isArray(t.input)&&t.input.forEach((r,o)=>{const i=U3(r),a=B3(r);n.push(Pr(i,`[${o}] ${i}`,a,`/input/${o}`))})),Array.isArray(t.tools)&&t.tools.length>0){const r=$3(t.tools);n.push(Pr("tools","tools",r,"/tools"))}return n.length>0?n:null}},V3={format:"unknown",analyzeRequest(e){return Mn(e)},analyzeResponse(){return mr},anatomySegments(){return null}},q3={anthropic:L3,openai:H3,unknown:V3};function Rm(e){return q3[e]}function Qr(e){const t=QN(e.path);return t==="unknown"?e.apiFormat:t}const pu="bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground";function Mi({icon:e,children:t,title:n,className:r}){return s.jsxs("span",{className:le("bg-white/[0.045] inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground",r),title:n,children:[e,s.jsx("span",{className:"min-w-0 font-mono tabular-nums",children:t})]})}function Z3(){return s.jsxs("span",{className:"inline-flex h-6 shrink-0 items-center gap-1.5 rounded-md bg-amber-300/[0.10] px-1.5 font-mono text-[10px] uppercase tracking-[0.14em] text-amber-100/90 ring-1 ring-amber-200/10",title:"This session has a turn that has not finished yet",children:[s.jsx(tt,{className:"size-3 animate-spin"}),"Turn open"]})}function G3({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:h,showClientIdentity:m=!0,showProcessMetadata:v=!0,timeDisplayFormat:g,onClear:x}){const[b,y]=p.useState(!1),k=$=>{$.stopPropagation(),x!==void 0&&y(!0)},j=p.useCallback($=>{$.stopPropagation(),window.open(jd(e),"_blank","noopener,noreferrer")},[e]),S=c?.map(({provider:$,models:ee})=>({provider:$,tooltip:ee.length===1?ee[0]??$:ee.join(", ")}))??[],E=Nl({userAgent:d,conversationId:e,clientProjectFolder:h}),N=Ko(E),z=d!=null&&d!=="",A=N??d??null,O=N!==null&&z?`${N} - ${d}`:null,W=e.startsWith("PID:")||e.includes("|"),T=e.length>24?e.slice(0,12)+"..."+e.slice(-12):e,L=bl(t,n,g),_=`${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("bg-card/80 shadow-sm relative flex cursor-pointer items-start gap-3 overflow-hidden rounded-[8px] px-3 py-2.5 transition-colors","hover:bg-card","select-none","sticky top-0 z-10 mb-2","focus-visible:ring-1 focus-visible:ring-cyan-300/35 focus-visible:outline-none"),onClick:l,onKeyDown:$=>{$.target===$.currentTarget&&($.key==="Enter"||$.key===" ")&&($.preventDefault(),l())},children:[s.jsx(qN,{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:[W&&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:W?"sessionless":T}),!W&&v&&f!==null&&f!==void 0&&s.jsxs("span",{className:"bg-white/[0.045] shrink-0 rounded px-1.5 py-0.5 font-mono text-xs tabular-nums text-muted-foreground",title:`Client process ID ${f}`,children:["PID ",f]}),W&&v&&h!==null&&h!==void 0&&h!==""&&s.jsx("span",{className:"min-w-0 max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:h,children:h}),m&&A!==null&&A!==""&&s.jsxs("span",{className:"bg-white/[0.045] inline-flex min-h-6 shrink-0 flex-wrap items-center gap-1 rounded-md px-1.5 py-0.5 text-xs text-muted-foreground",title:O??A,children:[s.jsx(Jo,{client:E,className:"size-4 shrink-0"}),s.jsx("span",{className:"font-mono leading-snug tabular-nums",children:A})]}),u&&s.jsx(Z3,{})]}),s.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx(Mi,{icon:s.jsx(tn,{className:"size-3 shrink-0"}),title:L,children:L}),s.jsx(Mi,{icon:s.jsx(Wo,{className:"size-3 shrink-0"}),children:_}),s.jsxs(Mi,{icon:s.jsx(Jr,{className:"size-3 shrink-0"}),className:"max-w-full",children:[s.jsx("span",{className:"text-blue-400",children:Fe(o)})," / ",s.jsx("span",{className:"text-amber-400",children:Fe(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:pu,children:s.jsx(hl,{className:"size-3.5"})}),x!==void 0&&s.jsx("button",{type:"button",onClick:k,"aria-label":`Clear group (${r} request${r!==1?"s":""})`,title:"Clear this group from the current view",className:pu,children:s.jsx(Ht,{className:"size-3.5"})}),s.jsx("span",{className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-slate-200","aria-hidden":"true",children:a?s.jsx(lt,{className:"size-4 shrink-0"}):u?s.jsx(tt,{className:"size-4 shrink-0 animate-spin"}):s.jsx(Ct,{className:"size-4 shrink-0"})})]}),u&&s.jsx("span",{className:"pointer-events-none absolute inset-x-3 bottom-0 h-px overflow-hidden rounded-full bg-white/[0.06]","aria-hidden":"true",children:s.jsx("span",{className:"absolute inset-y-0 left-0 w-1/3 animate-pulse rounded-full bg-amber-200/65 shadow-[0_0_14px_rgba(252,211,77,0.32)]"})}),s.jsx(Ip,{open:b,onOpenChange:y,title:"Clear this group from the current view?",description:`This will hide ${r} request${r!==1?"s":""} from the current view. Stored logs remain reloadable.`,confirmLabel:"Clear",variant:"destructive",onConfirm:()=>{x?.()}})]})}function K3(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 J3(e){const t=new Map;for(const r of e){const o=K3(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 Y3(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 rr(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 hu(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const mu=(e,t)=>Math.abs(e-t)<1.01,X3=(e,t,n)=>{let r;return function(...o){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,o),n)}};let Mr;const gu=()=>{if(Mr!==void 0)return Mr;if(typeof navigator>"u")return Mr=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Mr=!0;const e=navigator.maxTouchPoints;return Mr=navigator.platform==="MacIntel"&&e!==void 0&&e>0},xu=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Q3=e=>e,e4=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},t4=(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(xu(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(xu(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},es={passive:!0},n4=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=()=>{t({width:n.innerWidth,height:n.innerHeight})};return r(),n.addEventListener("resize",r,es),()=>{n.removeEventListener("resize",r)}},r4=typeof window>"u"?!0:"onscrollend"in window,Im=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&r4;let a=0;const l=i?null:X3(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,es),i&&r.addEventListener("scrollend",d,es),()=>{r.removeEventListener("scroll",u),i&&r.removeEventListener("scrollend",d)}},s4=(e,t)=>Im(e,t,n=>{const{horizontal:r,isRtl:o}=e.options;return r?n.scrollLeft*(o&&-1||1):n.scrollTop}),o4=(e,t)=>Im(e,t,n=>e.options.horizontal?n.scrollX:n.scrollY),i4=(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"]},zm=(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})},a4=zm,l4=zm;class c4{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:Q3,rangeExtractor:e4,onChange:()=>{},measureElement:i4,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(),h=u>0?((r=f[0])==null?void 0:r.key)??a.getItemKey(0):null,m=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)!==h||i.getItemKey(d-1)!==m)){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)!==m)&&(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=rr(()=>(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,!(!gu()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",a,es),i.addEventListener("touchend",l,es),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 h=f.start+a-this.getScrollOffset();mu(h,0)||this.applyScrollAdjustment(h)}}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=rr(()=>[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=rr(()=>[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 k=new Float64Array(g);x&&f>0&&k.set(x.subarray(0,f*2)),x=k,this._flatMeasurements=x}let b;if(f===0)b=r+o;else{const k=f-1;b=x[k*2]+x[k*2+1]+v}for(let k=f;k<n;k++){const j=i(k),S=d.get(j),E=typeof S=="number"?S:this.options.estimateSize(k);x[k*2]=b,x[k*2+1]=E,b+=E+v}const y=Y3(n,x,i);return this.measurementsCache=y,y}const h=this.measurementsCache.slice(0,f),m=new Array(l).fill(void 0);for(let v=0;v<f;v++){const g=h[v];g&&(m[g.lane]=v)}for(let v=f;v<n;v++){const g=i(v),x=this.laneAssignments.get(v);let b,y;const k=c==="estimate"||d.has(g);if(x!==void 0&&this.options.lanes>1){b=x;const N=m[b],z=N!==void 0?h[N]:void 0;y=z?z.end+this.options.gap:r+o}else{const N=this.options.lanes===1?h[v-1]:this.getFurthestMeasurement(h,v);y=N?N.end+this.options.gap:r+o,b=N?N.lane:v%this.options.lanes,this.options.lanes>1&&k&&this.laneAssignments.set(v,b)}const j=d.get(g),S=typeof j=="number"?j:this.options.estimateSize(v),E=y+S;h[v]={index:v,start:y,size:S,end:E,key:g,lane:b},m[b]=v}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=rr(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,o,i)=>this.range=n.length>0&&r>0?u4({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=rr(()=>{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 h=this.measurementsCache[n];if(!h)return;c=h.key,l=h.start,a=h.size}const d=this.itemSizeCache.get(c)??a,f=r-d;if(f!==0){const h=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,m=h?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++,h?this.applyScrollAdjustment(this.getTotalSize()-m):v&&this.applyScrollAdjustment(f),this.notify(!1)}},this.getVirtualItems=rr(()=>[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=Om(0,r.length-1,i?l=>o[l*2]:l=>hu(r[l]).start,n);return hu(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&&(gu()&&(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&&mu(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 Om=(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 u4({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=Om(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(h=>h<n+t);){const h=e[u];d[h.lane]=h.end,u++}const f=Array(r).fill(n+t);for(;c>=0&&f.some(h=>h>=n);){const h=e[c];f[h.lane]=h.start,c--}c=Math.max(0,c-c%r),u=Math.min(i,u+(r-1-u%r))}return{startIndex:c,endIndex:u}}const bu=typeof document<"u"?p.useLayoutEffect:p.useEffect;function Pm({useFlushSync:e=!0,...t}){const n=p.useReducer(i=>i+1,0)[1],r={...t,onChange:(i,a)=>{var l;e&&a?ss.flushSync(n):n(),(l=t.onChange)==null||l.call(t,i,a)}},[o]=p.useState(()=>new c4(r));return o.setOptions(r),bu(()=>o._didMount(),[]),bu(()=>o._willUpdate()),o}function d4(e){return Pm({observeElementRect:t4,observeElementOffset:s4,scrollToFn:l4,...e})}function f4(e){return Pm({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:n4,observeElementOffset:o4,scrollToFn:a4,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const an="agent-inspector:focus-log";function ts(e){window.dispatchEvent(new CustomEvent(an,{detail:e}))}function hi(e){if(typeof CustomEvent>"u"||!(e instanceof CustomEvent))return null;const t=e.detail,n=ye(t,"logId");if(typeof n!="number"||!Number.isInteger(n)||n<0)return null;const r=ye(t,"tab");switch(r){case"anatomy":case"request":case"response":break;case void 0:break;default:return null}const o=ye(t,"source"),i=ye(t,"toolCallIndex"),a=typeof i=="number"&&Number.isInteger(i)&&i>=0?{logId:n,tab:r??"request",toolCallIndex:i}:{logId:n,tab:r??"request"};switch(o){case"virtualizer":return{...a,source:o};case void 0:return a;default:return null}}function At({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 Tn=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"})]}),Mm=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 Lm({className:e}){return s.jsx(At,{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:Tn,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 p4({className:e}){return s.jsx(At,{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:Mm,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 h4({className:e}){return s.jsx(At,{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:Tn,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 m4({className:e}){return s.jsx(At,{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 g4({className:e}){return s.jsx(At,{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:Tn,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 x4({className:e}){return s.jsx(At,{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:Tn,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 b4({className:e}){return s.jsx(At,{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:Mm,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 v4({className:e}){return s.jsx(At,{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:Tn,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 y4({className:e}){return s.jsx(At,{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:Tn,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 w4({className:e}){return s.jsx(At,{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:Tn,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 _4({className:e}){return s.jsx(At,{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:Tn,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 k4({className:e}){return s.jsx(At,{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 ns=[Lm,p4,h4,m4,g4,x4,b4,v4,y4,w4,_4,k4];function Xl(e){return ns[Math.abs(e)%ns.length]??Lm}function j4(e){const t=ns.length-2;return t<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%t+t)%t}function S4(e){return Xl(j4(e))}const C4="x-anthropic-billing-header:";function N4(e){return e.trimStart().toLowerCase().startsWith(C4)}function T4(e){return Jl(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function E4(e){if(!Jl(e))return!1;const t=ye(e,"type"),n=ye(e,"text");return typeof t!="string"||t!=="text"||typeof n!="string"?!1:N4(n)}function A4(e){let t;try{t=JSON.parse(e)}catch{return{body:e,removed:0}}if(!T4(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(E4(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 R4=400,vu=2e3;function I4(e){return Array.isArray(e)}function z4(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(I4(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 O4(e){const t=z4(e,vu+1);return t<=R4?{depth:Number.POSITIVE_INFINITY}:t<=vu?{depth:3}:{depth:2}}function P4(e){try{const t=JSON.parse(e);return{kind:"json",data:ko(t)}}catch{return{kind:"text"}}}function Li(e){const t=p.useMemo(()=>e===null?null:P4(e),[e]),n=t?.kind==="json"?t.data:null,r=p.useMemo(()=>n===null?null:O4(n),[n]),[o,i]=p.useState(!1),[a,l]=p.useState(0),[c,u]=p.useState(0),[d,f]=p.useTransition(),h=p.useCallback(()=>{const m=!o,v=m&&r!==null?r.depth:0;f(()=>{i(m),l(v),u(g=>g+1)})},[o,r]);return{parsedData:n,policy:r,isExpanded:o,toggle:h,isPending:d,bulkDepth:a,bulkRevision:c}}function ko(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=>ko(n));const t={};for(const n of Object.keys(e)){const r=Object.getOwnPropertyDescriptor(e,n);t[n]=ko(r?.value)}return t}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function Dm({className:e,orientation:t="horizontal",...n}){return s.jsx(yN,{"data-slot":"tabs","data-orientation":t,orientation:t,className:le("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...n})}const M4=Cl("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 $m({className:e,variant:t="default",...n}){return s.jsx(wN,{"data-slot":"tabs-list","data-variant":t,className:le(M4({variant:t}),e),...n})}function jt({className:e,...t}){return s.jsx(_N,{"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 St({className:e,...t}){return s.jsx(kN,{"data-slot":"tabs-content",className:le("flex-1 outline-none",e),...t})}function gn(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&&Lt(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 L4=p.lazy(()=>Wn(()=>import("./CompareDrawer-CJKL4LMm.js"),__vite__mapDeps([0,1])).then(e=>({default:e.CompareDrawer}))),D4=p.lazy(()=>Wn(()=>import("./ReplayDialog-BYanl-a_.js"),__vite__mapDeps([2,1,3])).then(e=>({default:e.ReplayDialog}))),$4=p.lazy(()=>Wn(()=>import("./RequestAnatomy-DvPz1jqE.js"),__vite__mapDeps([4,1])).then(e=>({default:e.RequestAnatomy}))),F4=p.lazy(()=>Wn(()=>import("./ResponseView-sZnxp9GN.js"),__vite__mapDeps([3,1])).then(e=>({default:e.ResponseView}))),B4=p.lazy(()=>Wn(()=>import("./StreamingChunkSequence-G-tiYiBd.js"),__vite__mapDeps([5,1])).then(e=>({default:e.StreamingChunkSequence}))),Ra=p.lazy(()=>Wn(()=>import("./json-viewer-yQdhgjaw.js"),__vite__mapDeps([6,1])).then(e=>({default:e.JsonViewer}))),U4=p.lazy(()=>Wn(()=>import("./json-viewer-yQdhgjaw.js"),__vite__mapDeps([6,1])).then(e=>({default:e.JsonViewerFromString}))),W4=1200,H4=12;function V4(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??W4)},u=`[data-anatomy-path="${(f=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(f):f.replace(/(["'\\[\](){}])/g,"\\$1"))(a.path)}"]`,d=f=>{const h=t.current;if(h!==null){const m=h.querySelector(u);if(m!==null){l(m);return}}f>0?window.requestAnimationFrame(()=>d(f-1)):n(null)};window.requestAnimationFrame(()=>d(H4))},[t,r,o,n])}const yu="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.";function dr(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 q4(e,t){const n=[];return e!=null&&n.push(`Request ${dr(e)}`),t!=null&&n.push(`Response ${dr(t)}`),n.length===0?null:n.join(" · ")}function Z4(e){if(e instanceof Bo)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===""?yu:t}}return{title:"Full bodies could not be loaded",detail:yu}}class Fm{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,h=Date.now()+f,m=[{oldPos:-1,lastComponent:void 0}];let v=this.extractCommon(m[0],n,t,0,r);if(m[0].oldPos+1>=c&&v+1>=l)return a(this.buildValues(m[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 k;const j=m[y-1],S=m[y+1];j&&(m[y-1]=void 0);let E=!1;if(S){const z=S.oldPos-y;E=S&&0<=z&&z<l}const N=j&&j.oldPos+1<c;if(!E&&!N){m[y]=void 0;continue}if(!N||E&&j.oldPos<S.oldPos?k=this.addToPath(S,!0,!1,0,r):k=this.addToPath(j,!1,!0,1,r),v=this.extractCommon(k,n,t,y,r),k.oldPos+1>=c&&v+1>=l)return a(this.buildValues(k.lastComponent,n,t))||!0;m[y]=k,k.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()>h)return o(void 0);b()||y()},0)})();else for(;u<=d&&Date.now()<=h;){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(h,m){const v=r[u+m];return v.length>h.length?v:h}),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 G4 extends Fm{constructor(){super(...arguments),this.tokenize=Um}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
96
- `))&&(t=t.trim()),(!r.newlineIsToken||!n.includes(`
97
- `))&&(n=n.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(t.endsWith(`
98
- `)&&(t=t.slice(0,-1)),n.endsWith(`
99
- `)&&(n=n.slice(0,-1))),super.equals(t,n,r)}}const K4=new G4;function Bm(e,t,n){return K4.diff(e,t,n)}function Um(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 J4 extends Fm{constructor(){super(...arguments),this.tokenize=Um}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(Ia(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 Y4=new J4;function X4(e,t,n){return Y4.diff(e,t,n)}function Ia(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]=Ia(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]=Ia(e[c],t,n,r,c);t.pop(),n.pop()}else a=e;return a}function wu(e){return e===void 0?[]:Object.entries(e).map(t=>[t[0].toLowerCase(),t[1]]).sort(([t],[n])=>t.localeCompare(n))}function _u([e,t]){return`${e}: ${t}`}function za(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 Q4(e,t){const n=wu(e).map(_u).join(`
102
- `),r=wu(t).map(_u).join(`
103
- `);if(n===r)return{lines:[],isEmpty:!0};const o=Bm(n,r);return{lines:za(o),isEmpty:!1}}function ku(e){try{const t=JSON.parse(e);return t===null||typeof t=="string"||typeof t=="object"?t:null}catch{return null}}function eT(e,t){const n=e??"",r=t??"";if(n===r)return{lines:[],isEmpty:!0};const o=ku(n),i=ku(r);if(o!==null&&i!==null){const l=X4(o,i)??[];if(l.length===1){const c=l[0];if(c!==void 0&&!c.added&&!c.removed)return{lines:[],isEmpty:!0}}return{lines:za(l),isEmpty:!1}}const a=Bm(n,r);return{lines:za(a),isEmpty:!1}}const tT=22,Di=1e4;function nT(e){return e==="added"?"+":e==="removed"?"-":" "}function rT(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 sT=function({result:t,emptyLabel:n}){const[r,o]=p.useState("unified"),i=p.useRef(null),a=d4({count:t.lines.length,getScrollElement:()=>i.current,estimateSize:()=>tT,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>Di,u=c?t.lines.slice(0,Di):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 ${Di.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(Aw,{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(ky,{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(oT,{virtualizer:a,lines:u}):s.jsx(lT,{lines:u})})]})};function oT({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",rT(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:nT(r.kind)}),s.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:r.text})]},n.key)})})}function iT(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 aT(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 lT({lines:e}){const t=iT(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",aT(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 Wm=p.memo(sT),cT=Cl("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 Pe({className:e,variant:t="default",asChild:n=!1,...r}){const o=n?Ik:"span";return s.jsx(o,{"data-slot":"badge","data-variant":t,className:le(cT({variant:t}),e),...r})}const uT={success:"bg-slate-300/[0.08] text-slate-100 border-transparent",client_error:"bg-amber-300/[0.10] text-amber-100 border-transparent",server_error:"bg-rose-400/[0.10] text-rose-100 border-transparent",pending:"bg-cyan-300/[0.08] text-cyan-100 border-transparent"},dT={success:{frame:"border-cyan-200/15 bg-white/[0.04] text-slate-100"},client_error:{frame:"border-amber-300/25 bg-amber-300/[0.08] text-amber-100"},server_error:{frame:"border-rose-300/25 bg-rose-300/[0.08] text-rose-100"},pending:{frame:"border-cyan-300/25 bg-cyan-300/[0.08] text-cyan-100"}},Lr="border border-transparent bg-white/[0.045] hover:bg-white/[0.075] size-8 text-muted-foreground shadow-none hover:text-cyan-100",zt="bg-white/[0.045] flex h-7 items-center gap-1 rounded-md px-2 text-xs";function Dr(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function fT(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function pT(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 ju({trend:e}){if(e===null)return null;const t=e.direction==="up",n=t?F2:O2,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,Fe(e.delta)]})]})}const hT=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:h}){const m=_k(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:Dr(x),k=b===null||b<=0?null:fT(b),j=e.warnings?.length??0,S=e.clientPid!==null&&e.clientPid!==void 0,E=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="",N=e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd!=="",z=dT[m],A=pT(m,e.responseStatus),O=m!=="success"||e.responseStatus!==200,W=e.streaming&&y===null&&k===null;return s.jsx(rt,{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.04]":"bg-transparent hover:bg-white/[0.035]","select-none","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),onClick: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.jsx("span",{className:le("inline-flex h-8 shrink-0 items-center rounded-md px-2 font-mono",z.frame),children:s.jsxs("span",{className:"text-xs font-semibold tabular-nums",title:`Log ID ${String(e.id)}`,children:["#",t]})}),s.jsxs("span",{className:"bg-white/[0.045] flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-xs text-muted-foreground",children:[s.jsx(tn,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:da(e.timestamp,h)})]}),O&&s.jsxs(Pe,{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)]",uT[m]),children:[m==="success"?s.jsx(Xe,{className:"size-3","aria-label":"Success"}):m==="server_error"?s.jsx(xw,{className:"size-3","aria-label":"Server error"}):m==="client_error"?s.jsx(bn,{className:"size-3","aria-label":"Client error"}):s.jsx(tt,{className:"size-3 animate-spin","aria-label":"Pending"}),A]}),j>0&&s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsxs(Pe,{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(bn,{className:"size-3","aria-label":"Tool schema warnings"}),j]})}),s.jsx(He,{children:j===1?"1 tool schema warning":`${j} tool schema warnings`})]}),e.elapsedMs!==null&&(v?s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("span",{className:le(zt,"shrink-0 border-amber-300/25 text-amber-200"),children:[s.jsx(tn,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:Dr(e.elapsedMs)}),s.jsx(bn,{className:"size-3","aria-label":"Slow response"})]})}),s.jsxs(He,{children:["Slow response: ",Dr(e.elapsedMs)," exceeds"," ",Dr(d*1e3)]})]}):s.jsxs("span",{className:le(zt,"shrink-0 text-muted-foreground"),children:[s.jsx(tn,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:Dr(e.elapsedMs)})]})),e.streaming&&y!==null&&s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("span",{className:le(zt,"shrink-0 text-cyan-300"),children:[s.jsx(Ec,{className:"size-3"}),s.jsxs("span",{className:"font-mono tabular-nums",children:["first ",y]})]})}),s.jsx(He,{children:"Time to first streaming chunk"})]}),e.streaming&&k!==null&&s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("span",{className:le(zt,"shrink-0 text-cyan-300"),children:[s.jsx(xl,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:k})]})}),s.jsx(He,{children:"Output token throughput after first chunk"})]}),g&&s.jsxs("span",{className:le(zt,"min-w-0 sm:shrink-0"),children:[s.jsx(Jr,{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?Fe(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?Fe(e.outputTokens):"n/a"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&s.jsxs("span",{className:le(zt,"shrink-0"),children:[s.jsx(ju,{trend:a?.creation??null}),s.jsxs("span",{className:"font-mono tabular-nums text-cyan-300",children:["KV Cache +",Fe(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&s.jsxs("span",{className:le(zt,"shrink-0"),children:[s.jsx(ju,{trend:a?.read??null}),s.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",Fe(e.cacheReadInputTokens)]})]}),n!==null&&s.jsxs("span",{className:le(zt,"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:le(zt,"shrink-0 text-muted-foreground"),children:[s.jsx(as,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:r})]}),e.origin!==null&&s.jsxs("span",{className:le(zt,"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(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("span",{className:le(zt,"hidden shrink-0 text-purple-300 xl:flex"),children:[s.jsx(Fy,{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(He,{children:N?`PID: ${e.clientPid??"?"} CWD: ${e.clientCwd}`:`Process ID: ${e.clientPid??"?"}`})]}),W&&s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsx(Ec,{className:"size-3 text-muted-foreground/60 shrink-0"})}),s.jsx(He,{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(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsx(_e,{variant:"outline",size:"icon",className:Lr,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(iy,{className:"size-3.5"}):s.jsx(ey,{className:"size-3.5"})})}),s.jsx(He,{children:T.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),T.diffWithRaw!==void 0&&s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsx(_e,{variant:"outline",size:"icon",className:le(Lr,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(My,{className:"size-3.5"})})}),s.jsx(He,{children:T.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),T.diffWithPrevious!==void 0&&s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsx(_e,{variant:"outline",size:"icon",className:Lr,onClick:T.diffWithPrevious,"aria-label":"Diff with previous",children:s.jsx(ew,{className:"size-3.5"})})}),s.jsx(He,{children:"Compare this request with the immediately preceding one"})]}),T.copyText!==null&&s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsx(_e,{variant:"outline",size:"icon",className:Lr,onClick:T.onCopy,"aria-label":T.copyCopied?"Copied":T.copyLabel,children:T.copyCopied?s.jsx(Xe,{className:"size-3.5 text-cyan-300"}):s.jsx(Ft,{className:"size-3.5"})})}),s.jsx(He,{children:T.copyCopied?"Copied to clipboard":T.copyLabel})]})]})})(),u!==void 0&&s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsx(_e,{variant:"outline",size:"icon",className:Lr,onClick:u,"aria-label":"Replay request",children:s.jsx(Nw,{className:"size-3.5"})})}),s.jsx(He,{children:"Re-send this request to the provider"})]})]}),s.jsx("span",{className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-slate-200","aria-hidden":"true",children:o?s.jsx(lt,{className:"size-4 shrink-0"}):s.jsx(Ct,{className:"size-4 shrink-0"})})]})]})})});function mT({...e}){return s.jsx(Uj,{"data-slot":"collapsible",...e})}function M8({...e}){return s.jsx(Dp,{"data-slot":"collapsible-trigger",...e})}function gT({...e}){return s.jsx($p,{"data-slot":"collapsible-content",...e})}function xT({className:e,children:t,...n}){return s.jsxs(OC,{"data-slot":"scroll-area",className:le("relative overflow-hidden",e),...n,children:[s.jsx(PC,{"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(bT,{}),s.jsx(MC,{})]})}function bT({className:e,orientation:t="vertical",...n}){return s.jsx(wh,{"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(Sh,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const Hm={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},vT={file:"border-transparent bg-blue-400/5 text-blue-300",shell:"border-transparent bg-teal-400/5 text-teal-300",browser:"border-transparent bg-cyan-400/5 text-cyan-300",web:"border-transparent bg-sky-400/5 text-sky-300",mcp:"border-transparent bg-violet-400/5 text-violet-300",code:"border-transparent bg-emerald-400/5 text-emerald-300",other:"border-transparent bg-muted/30 text-muted-foreground"};function yT({category:e}){switch(e){case"file":return s.jsx(Uy,{className:"size-3.5"});case"shell":return s.jsx(Cr,{className:"size-3.5"});case"browser":return s.jsx(pw,{className:"size-3.5"});case"web":return s.jsx(Rf,{className:"size-3.5"});case"mcp":return s.jsx(V2,{className:"size-3.5"});case"code":return s.jsx(wy,{className:"size-3.5"});case"other":return s.jsx(Ey,{className:"size-3.5"})}}function wT({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(Pe,{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 _T({tool:e,called:t}){const[n,r]=p.useState(!1),o=gn(e.name),i=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return s.jsx(mT,{open:n,onOpenChange:r,children:s.jsxs("div",{className:"bg-white/[0.035] 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(yT,{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(Pe,{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(lt,{className:"size-3.5 shrink-0 text-muted-foreground"}):s.jsx(Ct,{className:"size-3.5 shrink-0 text-muted-foreground"}))]}),s.jsx("button",{type:"button",className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:o.copy,"aria-label":o.copied?"Copied tool name":"Copy tool name",children:o.copied?s.jsx(Xe,{className:"size-3.5 text-emerald-400"}):s.jsx(Ft,{className:"size-3.5"})})]}),s.jsx(gT,{children:n&&s.jsxs("div",{className:"space-y-2 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(wT,{names:e.requiredParameters}),e.schema!==null&&s.jsx(xT,{className:"bg-black/[0.16] 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(Ra,{data:ko(e.schema),defaultExpandDepth:0})})})]})})]})})}function kT(e,t){return t.length===0?!0:`${e.name} ${e.description??""} ${Hm[e.category]}`.toLowerCase().trim().includes(t)}const jT=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(h=>kT(h,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:"bg-black/[0.10] 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(as,{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(Pe,{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(Pe,{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(h=>s.jsxs(Pe,{variant:"outline",className:le("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",vT[h.category]),children:[h.count," ",Hm[h.category]]},h.category))})]})]}),s.jsxs(_e,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-cyan-100",onClick:()=>o(h=>!h),"aria-expanded":r,children:[r?s.jsx(lt,{className:"size-3.5"}):s.jsx(Ct,{className:"size-3.5"}),r?"Hide":"Show"]})]}),s.jsxs("div",{className:"flex min-w-0 flex-wrap gap-1.5 bg-white/[0.025] px-3 py-2",children:[d.map(h=>s.jsx(Pe,{variant:"outline",className:le("h-5 max-w-44 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",l.has(h.name)&&"border-emerald-400/20 text-emerald-300"),children:h.name},h.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 bg-black/10 px-3 py-3",children:[s.jsxs("label",{className:"bg-white/[0.045] hover:bg-white/[0.075] flex h-8 items-center gap-2 rounded-md px-2 text-xs",children:[s.jsx(zf,{className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("input",{value:i,onChange:h=>a(h.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(h=>s.jsx(_T,{tool:h,called:l.has(h.name)},h.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 ST(e,t){return e==="full"&&t}function CT(e,t,n,r){return e==="anthropic"&&t==="full"&&n&&r}function sr(){return s.jsx("div",{className:"h-1","aria-hidden":"true"})}function NT(e,t){switch(e){case"anatomy":return t===null?"request":"anatomy";case"request":return"request";case"response":return"parsed"}}const TT=15e3,ET=15e3,AT=256*1024,jo=1024*1024,An="h-9 flex-none rounded-md border border-transparent bg-transparent px-3 text-xs font-semibold text-muted-foreground shadow-none transition-colors hover:bg-white/[0.045] hover:text-foreground data-[state=active]:bg-cyan-300/[0.08] data-[state=active]:text-cyan-100 data-[state=active]:shadow-none";function Rs(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function So(e){return e??0}function Vm(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function qm(e){return Vm(e)?So(e.rawRequestBodyBytes)>jo||So(e.responseTextBytes)>jo:!1}function RT(e){return Vm(e)&&!qm(e)}function IT(e){return e instanceof Bo?"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 Is({status:e,error:t,footprint:n,onRetry:r}){switch(e){case"idle":return null;case"loading":return s.jsx(rs,{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(tt,{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(rs,{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(_e,{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(nn,{className:"size-3"}),"Retry"]})]})})}}function Cu(e,t){return e?t.text!==""?t.text:t.status==="success"?"":null:null}function Rn({children:e,className:t}){return s.jsx("div",{className:le("bg-black/[0.14] inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",t),children:e})}function Js({children:e}){return s.jsx("div",{className:"bg-white/[0.035] rounded-md px-3 py-5 text-center text-xs italic text-muted-foreground",children:e})}function zs({children:e}){return s.jsx("pre",{className:"bg-black/[0.18] inspector-scrollbar max-h-[64vh] overflow-auto whitespace-pre-wrap break-words rounded-[8px] p-3 font-mono text-xs leading-relaxed text-muted-foreground",children:e})}const zT={loading:"border-transparent bg-cyan-400/[0.06] text-cyan-100",warning:"border-transparent bg-amber-400/[0.08] text-amber-100",danger:"border-transparent bg-rose-400/[0.08] text-rose-100"};function rs({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)]",zT[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 Os({label:e,state:t,expectedBytes:n,onLoadMore:r}){const o=t.totalBytes??n,i=o===null?dr(t.offset):`${dr(t.offset)} / ${dr(o)}`,a=t.status!=="loading"&&t.hasMore,l=t.status==="failed"?"Retry":"Load more";return s.jsx(rs,{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 ${dr(o)}. Loading the first preview chunk.`:`Loaded ${i}.`,t.status==="failed"&&t.error!==null&&` ${t.error}`]}),a&&s.jsx(_e,{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 Nu({headers:e,emptyLabel:t}){const n=e===void 0?[]:Object.entries(e).sort(([r],[o])=>r.localeCompare(o));return n.length===0?s.jsx(Js,{children:t}):s.jsx("div",{className:"bg-black/[0.14] 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/[0.055] last:border-b-0",children:[s.jsx("div",{className:"min-w-0 truncate 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 OT({active:e,onClick:t}){return s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsxs(_e,{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(Yy,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),s.jsx(He,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const PT=p.memo(function({rawBody:e,displayedBody:t,emptyLabel:n}){const r=p.useMemo(()=>eT(e,t),[e,t]);return s.jsx(Wm,{result:r,emptyLabel:n})}),MT=p.memo(function({rawHeaders:e,headers:t,emptyLabel:n}){const r=p.useMemo(()=>Q4(e,t),[e,t]);return s.jsx(Wm,{result:r,emptyLabel:n})}),LT=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,h]=p.useState(!1),[m,v]=p.useState(!1),[g,x]=p.useState(!1),[b,y]=p.useState("request"),[k,j]=p.useState(null),[S,E]=p.useState(0),[N,z]=p.useState(null),[A,O]=p.useState(null),[W,T]=p.useState("idle"),[L,_]=p.useState(null),[$,ee]=p.useState(0),[D,H]=p.useState(()=>Rs(e.rawRequestBodyBytes??null)),[Z,ue]=p.useState(()=>Rs(e.responseTextBytes??null)),V=p.useRef(null),U=p.useRef(e.id),ce=p.useRef(!1),B=A??e,Q=A===null&&qm(e),Se=p.useMemo(()=>q4(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),ie=Cu(Q,D),pe=Cu(Q,Z),me=B.rawRequestBody??ie,he=B.responseText??pe,xe=B.rawRequestBody===null&&ie!==null,ke=B.responseText===null&&pe!==null,Ae=!xe||D.hasMore===!1&&So(D.totalBytes)<=jo,w=!ke||Z.hasMore===!1&&So(Z.totalBytes)<=jo,X=Qr(B),G=Rm(X),P=p.useMemo(()=>G.analyzeRequest(B.rawRequestBody),[G,B.rawRequestBody]),I=p.useMemo(()=>G.analyzeResponse(B.responseText),[G,B.responseText]),re=p.useMemo(()=>!r||X!=="anthropic"||B.rawRequestBody===null?null:A4(B.rawRequestBody).body,[B.rawRequestBody,X,r])??me,ne=Li(Ae?re:null),q=Li(b==="raw-request"&&Ae?me:null),ae=Li(b==="raw"&&w?he:null),R=p.useMemo(()=>B.headers&&Object.keys(B.headers).length>0?JSON.stringify(B.headers,null,2):null,[B.headers]),M=p.useMemo(()=>B.rawHeaders&&Object.keys(B.rawHeaders).length>0?JSON.stringify(B.rawHeaders,null,2):null,[B.rawHeaders]),Y=gn(re),se=gn(me),oe=gn(R),ge=gn(M),Ce=gn(he),je=p.useMemo(()=>({request:{copyLabel:xe?"Copy loaded request preview":"Copy request body",copyText:re,copyCopied:Y.copied,onCopy:Y.copy,expansion:Ae?{isExpanded:ne.isExpanded,isPending:ne.isPending,onToggle:ne.toggle}:null,diffWithRaw:CT(X,n,r,B.rawRequestBody!==null)?{active:g,onToggle:()=>x(!g)}:void 0,diffWithPrevious:l===void 0?void 0:()=>{l(B)}},"raw-request":{copyLabel:xe?"Copy loaded raw request preview":"Copy raw request",copyText:me,copyCopied:se.copied,onCopy:se.copy,expansion:Ae?{isExpanded:q.isExpanded,isPending:q.isPending,onToggle:q.toggle}:null},headers:{copyLabel:"Copy headers",copyText:R,copyCopied:oe.copied,onCopy:oe.copy,expansion:null},"raw-headers":{copyLabel:"Copy raw headers",copyText:M,copyCopied:ge.copied,onCopy:ge.copy,expansion:null},raw:{copyLabel:ke?"Copy loaded response preview":"Copy response",copyText:he,copyCopied:Ce.copied,onCopy:Ce.copy,expansion:w?{isExpanded:ae.isExpanded,isPending:ae.isPending,onToggle:ae.toggle}:null}}),[re,xe,Ae,Y,ne,g,B,B.rawRequestBody,me,se,q,R,oe,M,ge,B.responseText,ke,w,he,Ce,ae,X,n,r,l]),ze=p.useMemo(()=>ne.parsedData!==null?G.anatomySegments(ne.parsedData):null,[G,ne.parsedData]),Be=p.useMemo(()=>Yl(ne.parsedData),[ne.parsedData]),Rt=B.warnings??[],cn=p.useMemo(()=>{if(ze!==null)return new Set(ze.map($e=>$e.path))},[ze]),gt=V4({containerRef:V,setExpandToPath:z,ensureTabActive:()=>{b!=="request"&&y("request")}}),ot=p.useCallback(($e,pt)=>{const et=$e==="request"?H:ue;et(xt=>({...xt,status:"loading",error:null}));const Ut=new URLSearchParams({part:$e,offset:String(pt),limit:String(AT)});Ke(`/api/logs/${String(e.id)}/body?${Ut.toString()}`,Rv,ET).then(xt=>{U.current===e.id&&et(Ir=>({status:"success",text:xt.offset===0?xt.text:`${Ir.text}${xt.text}`,offset:xt.nextOffset??xt.totalBytes,totalBytes:xt.totalBytes,hasMore:xt.hasMore,error:null}))}).catch(xt=>{U.current===e.id&&et(Ir=>({...Ir,status:"failed",error:IT(xt)}))})},[e.id]),Xt=p.useCallback(()=>{ce.current||(O(null),T("idle"),_(null),ee($e=>$e+1))},[]),Yn=p.useCallback(()=>{const $e=!u;$e&&y(ze!==null?"anatomy":"request"),d($e)},[ze,u]);return p.useEffect(()=>{U.current=e.id,ce.current=!1,O(null),T("idle"),_(null),ee(0),H(Rs(e.rawRequestBodyBytes??null)),ue(Rs(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),p.useEffect(()=>{if(!u||!RT(e)||A!==null||ce.current)return;let $e=!1;return ce.current=!0,T("loading"),_(null),Ke(`/api/logs/${String(e.id)}`,Kr,TT).then(pt=>{$e||(ce.current=!1,O(pt),T("idle"),_(null))}).catch(pt=>{$e||(ce.current=!1,T("failed"),_(Z4(pt)))}),()=>{$e=!0,ce.current=!1}},[u,A,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,$]),p.useEffect(()=>{u&&Q&&D.status==="idle"&&(b!=="request"&&b!=="raw-request"&&b!=="anatomy"||ot("request",0))},[b,u,ot,D.status,Q]),p.useEffect(()=>{u&&Q&&Z.status==="idle"&&(b!=="parsed"&&b!=="raw"||ot("response",0))},[b,u,ot,Z.status,Q]),p.useEffect(()=>{const $e=pt=>{const et=hi(pt);et!==null&&et.logId===e.id&&(d(!0),y(NT(et.tab,ze)),et.tab==="response"&&et.toolCallIndex!==void 0&&(j(et.toolCallIndex),E(Ut=>Ut+1)))};return window.addEventListener(an,$e),()=>{window.removeEventListener(an,$e)}},[ze,e.id]),s.jsxs(rt,{children:[s.jsxs("div",{className:le("bg-card/80 relative mb-1.5 overflow-hidden rounded-[8px] transition-[background-color,box-shadow]",u?"bg-card shadow-[0_18px_60px_rgba(0,0,0,0.30),0_0_0_1px_rgba(103,232,249,0.08)]":"hover:bg-card"),children:[s.jsx(hT,{log:B,displayNumber:t,messageCount:P.messageCount,toolCount:P.toolCount,expanded:u,onToggle:Yn,cacheTrend:a,slowResponseThresholdSeconds:o,showClientMetadata:c,timeDisplayFormat:i,activeTab:b,tabActions:je,onReplay:l===void 0?void 0:()=>{h(!0)}}),u&&s.jsxs("div",{className:"relative bg-black/[0.14] pt-2",onClick:$e=>$e.stopPropagation(),onKeyDown:$e=>$e.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(Dm,{value:b,onValueChange:y,className:"gap-2",children:[s.jsxs($m,{variant:"line",className:"bg-white/[0.04] inspector-scrollbar relative mx-3 h-auto w-[calc(100%-1.5rem)] justify-start overflow-x-auto rounded-[8px] p-1",children:[n==="full"&&s.jsx(jt,{className:An,value:"raw-headers",children:"Raw Headers"}),n==="full"&&s.jsx(jt,{className:An,value:"headers",children:"Headers"}),ze!==null&&s.jsx(jt,{className:An,value:"anatomy",children:"Context"}),Su(X,n,r)&&s.jsx(jt,{className:An,value:"raw-request",children:"Raw Request"}),s.jsx(jt,{className:An,value:"request",children:"Request"}),n==="full"&&s.jsx(jt,{className:An,value:"raw",children:"Raw Response"}),s.jsx(jt,{className:An,value:"parsed",children:"Response"})]}),Su(X,n,r)&&s.jsx(St,{value:"raw-request",children:b==="raw-request"&&s.jsxs(Rn,{children:[s.jsx(Is,{status:W,error:L,footprint:Se,onRetry:Xt}),Q&&s.jsx(Os,{label:"Request",state:D,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ot("request",D.offset)}),me===null?s.jsx(Js,{children:Q?"Request preview is loading":"No request body"}):q.parsedData!==null?s.jsx(p.Suspense,{fallback:s.jsx(sr,{}),children:s.jsx(Ra,{data:q.parsedData,bulkDepth:q.bulkDepth,bulkRevision:q.bulkRevision})}):s.jsx(zs,{children:me})]})}),s.jsx(St,{value:"request",children:b==="request"&&s.jsxs(Rn,{children:[s.jsx(Is,{status:W,error:L,footprint:Se,onRetry:Xt}),Q&&s.jsx(Os,{label:"Request",state:D,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ot("request",D.offset)}),Rt.length>0&&s.jsxs(rs,{tone:"warning",children:[s.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[s.jsx(bn,{className:"size-3.5"}),"Tool schema warnings"]}),s.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:Rt.map($e=>s.jsx("li",{children:$e},$e))})]}),s.jsx(jT,{summary:Be,calledToolNames:I.toolNames??[]}),g?s.jsx(PT,{rawBody:B.rawRequestBody,displayedBody:re,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):s.jsx("div",{ref:V,children:re===null?s.jsx(Js,{children:Q?"Request preview is loading":"No request body"}):ne.parsedData!==null?s.jsx(p.Suspense,{fallback:s.jsx(sr,{}),children:s.jsx(Ra,{data:ne.parsedData,bulkDepth:ne.bulkDepth,bulkRevision:ne.bulkRevision,anatomyPaths:cn,expandToPath:N})}):s.jsx(zs,{children:re})})]})}),ze!==null&&s.jsx(St,{value:"anatomy",children:b==="anatomy"&&s.jsx(Rn,{className:"p-0",children:s.jsx(p.Suspense,{fallback:s.jsx(sr,{}),children:s.jsx($4,{parsed:ne.parsedData,inputTokens:B.inputTokens??null,model:B.model,segments:ze,onSegmentActivate:gt})})})}),n==="full"&&s.jsx(St,{value:"headers",children:b==="headers"&&s.jsxs(Rn,{children:[s.jsx("div",{className:"flex justify-end gap-2 mb-2",children:ST(n,B.rawHeaders!==void 0&&Object.keys(B.rawHeaders).length>0)&&s.jsx(OT,{active:m,onClick:$e=>{$e.stopPropagation(),v(!m)}})}),m?s.jsx(MT,{rawHeaders:B.rawHeaders,headers:B.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):s.jsx(Nu,{headers:B.headers,emptyLabel:"No headers captured"})]})}),n==="full"&&s.jsx(St,{value:"raw-headers",children:b==="raw-headers"&&s.jsx(Rn,{children:s.jsx(Nu,{headers:B.rawHeaders,emptyLabel:"No raw headers captured"})})}),s.jsx(St,{value:"raw",children:b==="raw"&&s.jsxs(Rn,{className:"space-y-3",children:[s.jsx(Is,{status:W,error:L,footprint:Se,onRetry:Xt}),Q&&s.jsx(Os,{label:"Response",state:Z,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ot("response",Z.offset)}),B.error!==void 0&&B.error!==null&&s.jsx(rs,{tone:"danger",title:"SSE Error",children:s.jsx("span",{className:"font-mono",children:B.error})}),he!==null&&w?s.jsx(p.Suspense,{fallback:s.jsx(sr,{}),children:s.jsx(U4,{text:he,defaultExpandDepth:0,bulkDepth:ae.bulkDepth,bulkRevision:ae.bulkRevision})}):he!==null?s.jsx(zs,{children:he}):s.jsx(Js,{children:Q?"Response preview is loading":"No response"}),B.streaming===!0&&s.jsx(p.Suspense,{fallback:s.jsx(sr,{}),children:s.jsx(B4,{logId:B.id,truncated:B.streamingChunksPath!==null})})]})}),s.jsx(St,{value:"parsed",children:b==="parsed"&&s.jsxs(Rn,{children:[s.jsx(Is,{status:W,error:L,footprint:Se,onRetry:Xt}),Q&&s.jsx(Os,{label:"Response",state:Z,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ot("response",Z.offset)}),ke&&!w?s.jsx(zs,{children:he}):s.jsx(p.Suspense,{fallback:s.jsx(sr,{}),children:s.jsx(F4,{responseText:he,responseStatus:B.responseStatus,streaming:B.streaming,inputTokens:B.inputTokens,outputTokens:B.outputTokens,cacheCreationInputTokens:B.cacheCreationInputTokens,cacheReadInputTokens:B.cacheReadInputTokens,apiFormat:X,error:B.error,focusedToolIndex:k,toolFocusNonce:S})})]})})]})]})]}),s.jsx(p.Suspense,{fallback:null,children:s.jsx(D4,{log:B,displayNumber:t,open:f,onOpenChange:h})})]})});function DT(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 $i(e){return e?"cursor-pointer transition-transform hover:scale-110":""}function $T({stopReason:e,isPending:t,isFirst:n,isTurnStart:r,isOnlyEntry:o=!1,crabIndex:i=0,collapsible:a=!1,onToggle:l}){const c=vl(e),u=o&&r&&c,d=t&&!c,f=a&&l!==void 0,h=p.useMemo(()=>Xl(i),[i]),m=p.useMemo(()=>S4(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-px bg-muted-foreground/18 h-full"})}),u?s.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Single-request turn",className:$i(f),onClick:v,onKeyDown:g,children:s.jsx(m,{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:DT(e),className:$i(f),onClick:v,onKeyDown:g,children:s.jsx(h,{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:$i(f),onClick:v,onKeyDown:g,children:s.jsx(h,{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(h,{className:le("size-3.5 text-amber-300/80","animate-crab-crawl")})}):s.jsx("span",{title:"Request in turn",children:s.jsx(h,{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 border-muted-foreground/14":"bg-muted-foreground/18")})})]})}function FT({event:e}){return s.jsxs("button",{type:"button",className:"inline-flex min-w-0 items-center gap-1.5 rounded-md bg-white/[0.035] px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-sky-400/[0.08] hover:text-sky-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>ts({logId:e.logId,tab:"response",toolCallIndex:e.index}),"aria-label":`Open response tool call ${e.name}`,title:`Open ${e.name} in Response`,children:[s.jsx(as,{className:"size-3.5 shrink-0 text-sky-400/70"}),s.jsx("span",{className:"min-w-0 truncate font-mono font-semibold",children:e.name})]},e.id)}function BT({events:e}){return e.length===0?null:s.jsx("div",{className:"mx-3 mb-2 flex flex-wrap gap-1.5",children:e.map(t=>s.jsx(FT,{event:t},t.id))})}const Tu=180,Fi=new WeakMap;function UT(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 WT(e,t,n){return e>1&&t&&!n}function Oa(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:Lf(i),sessionLogNumber:o+1});const a=n[n.length-1];a!==void 0&&vl(a.stopReason)&&(t.push({entries:n,turnIndex:r}),n=[],r+=1)}return n.length>0&&t.push({entries:n,turnIndex:r}),t}function HT(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=Qr(o),l=Qr(i);a==="unknown"||a!==l||t.set(o.id,i)}return t}function Zm(e){if(e===null)return null;try{const t=JSON.parse(e);return typeof t=="string"?JSON.parse(t):t}catch{return null}}function Ys(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>Tu?`${n.slice(0,Tu-1)}...`:n}function Xs(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 VT(e){const t=Zm(e.responseText),n=ye(t,"content");if(!Array.isArray(n))return[];const r=[];for(const o of n){if(ye(o,"type")!=="tool_use")continue;const a=ye(o,"name");if(typeof a!="string"||a.length===0)continue;const l=ye(o,"input");r.push({id:`${String(e.id)}-anthropic-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"anthropic",name:a,argumentsText:Xs(l),argumentsPreview:Ys(l)})}return r}function qT(e){const t=Zm(e.responseText),n=ye(t,"choices");if(!Array.isArray(n))return[];const r=[];for(const i of n){const a=ye(i,"message"),l=ye(a,"tool_calls");if(Array.isArray(l))for(const d of l){const f=ye(d,"function"),h=ye(f,"name");if(typeof h!="string"||h.length===0)continue;const m=ye(f,"arguments");r.push({id:`${String(e.id)}-openai-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"openai",name:h,argumentsText:Xs(m),argumentsPreview:Ys(m)})}const c=ye(a,"function_call"),u=ye(c,"name");if(typeof u=="string"&&u.length>0){const d=ye(c,"arguments");r.push({id:`${String(e.id)}-openai-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"openai",name:u,argumentsText:Xs(d),argumentsPreview:Ys(d)})}}const o=ye(t,"output");if(Array.isArray(o))for(const i of o){if(ye(i,"type")!=="function_call")continue;const a=ye(i,"name");if(typeof a!="string"||a.length===0)continue;const l=ye(i,"arguments");r.push({id:`${String(e.id)}-openai-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"openai",name:a,argumentsText:Xs(l),argumentsPreview:Ys(l)})}return r}function Ql(e){const t=Fi.get(e);if(t!==void 0&&t.apiFormat===e.apiFormat&&t.responseText===e.responseText)return t.events;const n=Qr(e);if(!UT(e,n)){const o=[];return Fi.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:o}),o}let r;switch(n){case"anthropic":r=VT(e);break;case"openai":r=qT(e);break;case"unknown":r=[];break}return Fi.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:r}),r}function ZT(e,t,n=0){let r=0,o=0,i=0,a=0,l=0,c=0,u=0,d=0,f=null,h=0;for(const m of e)m.responseStatus===null?o+=1:m.responseStatus>=400&&(r+=1),m.elapsedMs!==null&&t>0&&m.elapsedMs>t*1e3&&(i+=1),m.inputTokens!==null&&(a+=m.inputTokens),m.outputTokens!==null&&(l+=m.outputTokens),m.cacheCreationInputTokens!==null&&(c+=m.cacheCreationInputTokens),m.cacheReadInputTokens!==null&&(u+=m.cacheReadInputTokens),m.elapsedMs!==null&&(d+=m.elapsedMs,f=f===null?m.elapsedMs:Math.max(f,m.elapsedMs)),h+=Ql(m).length;return{llmCallCount:e.length,toolCallCount:h,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 Bi(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const GT=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 h=t.length-1,m=t[h]?.stopReason??null,v=m!==null?vl(m):!1,g=t[h]?.log.responseStatus===null,x=t.length===1,b=WT(t.length,v,g),[y,k]=p.useState(!1),j=p.useRef(!1);p.useEffect(()=>{b?v&&!j.current&&k(!0):k(!1),j.current=v},[b,v]),p.useEffect(()=>{const D=H=>{const Z=hi(H);Z!==null&&t.some(ue=>ue.log.id===Z.logId)&&b&&k(!1)};return window.addEventListener(an,D),()=>{window.removeEventListener(an,D)}},[b,t]),p.useEffect(()=>{if(d===void 0||!t.some(H=>H.log.id===d.logId))return;b&&k(!1);const D=window.setTimeout(()=>{ts({logId:d.logId,tab:d.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(D)},[b,t,d]);const S=p.useCallback(()=>{b&&k(D=>!D)},[b]),E=p.useMemo(()=>{let D=0,H=0,Z=null,ue=!1;for(const V of t)V.log.inputTokens!==null&&(D+=V.log.inputTokens,ue=!0),V.log.outputTokens!==null&&(H+=V.log.outputTokens,ue=!0),V.log.elapsedMs!==null&&(Z=Z===null?V.log.elapsedMs:Math.max(Z,V.log.elapsedMs));return{totalInput:D,totalOutput:H,hasTokens:ue,maxElapsed:Z}},[t,h]),N=c%2===0?"bg-white/[0.008]":"bg-cyan-300/[0.008]",z=E.maxElapsed!==null&&o>0&&E.maxElapsed>o*1e3,A=p.useMemo(()=>{const D=new Map;for(const H of t){const Z=Ql(H.log);Z.length>0&&D.set(H.log.id,Z)}return D},[t]),[O,W]=p.useState(0),T=p.useRef(null);p.useEffect(()=>{const D=T.current;if(!D)return;let H=0;const Z=new ResizeObserver(()=>{window.cancelAnimationFrame(H),H=window.requestAnimationFrame(()=>W(ue=>ue+1))});return Z.observe(D),()=>{Z.disconnect(),window.cancelAnimationFrame(H)}},[]);const L=t[0]?.log.id??c,_=`Turn ${String(c+1)}`,$=p.useMemo(()=>Xl(L%12),[L]),ee=p.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:y?"48px":"160px"}),[y]);return s.jsx("div",{ref:T,style:ee,tabIndex:y?void 0:0,role:y?void 0:"group","aria-label":y?void 0:_,"data-nav-id":y?void 0:`turn-${String(L)}`,className:le("rounded-[8px] transition-[background-color,box-shadow]",g?"bg-amber-300/[0.018] shadow-[0_0_0_1px_rgba(252,211,77,0.035)]":"",!y&&"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),children:y?s.jsxs("div",{"data-nav-id":`turn-collapsed-${String(L)}`,"data-nav-action":"expand",role:"button",tabIndex:0,className:"flex items-stretch cursor-pointer focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none rounded-lg",onClick:S,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),S())},children:[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($,{className:le("size-3.5",g?"animate-crab-crawl text-amber-300/80":"animate-crab-appear text-emerald-400",g?"drop-shadow-[0_0_4px_rgba(252,211,77,0.42)]":"drop-shadow-[0_0_4px_rgba(52,211,153,0.45)]")}),s.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:s.jsx("div",{className:"w-px bg-muted-foreground/14 h-full"})}),v&&s.jsx($,{className:le("size-3.5 animate-crab-settle text-amber-400","drop-shadow-[0_0_4px_rgba(251,191,36,0.45)]")})]}),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","bg-card/80 transition-colors hover:bg-card",N),children:[s.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:_}),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[h]?.log.id??"?")}`,children:["#",t[0]?.sessionLogNumber??"?"," ~ #",t[h]?.sessionLogNumber??"?"]}),s.jsxs("span",{className:"text-muted-foreground shrink-0",children:[t.length," request",t.length>1?"s":""]}),E.maxElapsed!==null&&s.jsx(rt,{children:s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("span",{className:le("flex items-center gap-1 shrink-0",z?"text-amber-400":"text-muted-foreground"),children:[s.jsx(tn,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:Bi(E.maxElapsed)}),z&&s.jsx(bn,{className:"size-3","aria-label":"Slow response"})]})}),s.jsx(He,{children:z?`Slow response: ${Bi(E.maxElapsed)} exceeds ${Bi(o*1e3)}`:"Slowest request in this turn"})]})}),E.hasTokens&&s.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[s.jsx(Jr,{className:"size-3 text-muted-foreground"}),s.jsxs("span",{className:"font-mono tabular-nums",children:[s.jsxs("span",{className:"text-blue-400",children:["IN ",Fe(E.totalInput)]})," / ",s.jsxs("span",{className:"text-amber-400",children:["OUT ",Fe(E.totalOutput)]})]})]}),s.jsx("span",{className:"flex-1 min-w-0"}),s.jsx("span",{className:"bg-white/[0.045] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-slate-200","aria-hidden":"true",children:s.jsx(Ct,{className:"size-4 shrink-0"})})]})]}):t.map((D,H)=>{const{log:Z,stopReason:ue}=D,V=H===0;return s.jsxs("div",{className:"flex items-stretch",children:[s.jsx($T,{stopReason:ue,isPending:Z.responseStatus===null,isFirst:H===0,isTurnStart:V,isOnlyEntry:x,crabIndex:Z.id%12,collapsible:b&&V,onToggle:S}),s.jsxs("div",{className:le("flex-1 min-w-0 mb-0.5 rounded-[8px]",N),children:[s.jsx(LT,{log:Z,displayNumber:D.sessionLogNumber,viewMode:n,strip:r,slowResponseThresholdSeconds:o,timeDisplayFormat:u,cacheTrend:i?.get(Z.id)??null,showClientMetadata:f,onCompareWithPrevious:l.has(Z.id)?a:void 0}),s.jsx(BT,{events:A.get(Z.id)??[]})]})]},Z.id)})})}),KT=24,JT=132,YT=8;function XT(e){return e>KT}function QT(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 Gm(e,t,n){return s.jsx(GT,{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 eE(e){return XT(e.turnGroups.length)?s.jsx(tE,{...e}):s.jsx(s.Fragment,{children:e.turnGroups.map(t=>Gm(t,e))})}function tE(e){const{turnGroups:t}=e,[n,r]=p.useState(null),o=f4({count:t.length,estimateSize:()=>JT,overscan:YT,getItemKey:a=>t[a]?.turnIndex??a}),i=p.useMemo(()=>QT(t),[t]);return p.useEffect(()=>{const a=l=>{const c=hi(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(an,a),()=>{window.removeEventListener(an,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:Gm(l,e,c)},a.key)})})}const ec=Ee(["episode","procedure","preference","project-fact"]),nE=Ee(["draft","promoted","failed"]),Km=J({source:Te("agent-inspector"),sessionId:C(),logIds:fe(K().int().positive()),project:C().nullable(),models:fe(C())}),rE=J({redacted:Le(),patterns:fe(C())}),ps=J({id:C(),type:ec,title:C(),content:C(),tags:fe(C()),source:Te("agent-inspector"),sessionId:C(),logIds:fe(K().int().positive()),evidence:Km,status:nE,createdAt:C(),updatedAt:C(),openClawMemoryId:C().nullable(),error:C().nullable(),redaction:rE});J({idempotencyKey:C(),type:ec,title:C(),content:C(),tags:fe(C()),source:Te("agent-inspector"),project:C().nullable(),evidence:Km});const sE=J({id:C(),type:ec.or(C()),title:C(),content:C(),score:K().nullable(),source:C().nullable(),project:C().nullable(),evidence:On().optional()});J({results:fe(sE),warning:C().nullable()});const oE=J({candidates:fe(ps)}),iE=J({candidate:ps}),aE=J({error:C().optional(),candidate:ps.optional()}),lE=J({candidate:ps}),cE=3e4,uE=15e3,dE=15e3,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 Pa(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:bl(e,t,n)}function hE(e){return`${String(e)} candidate${e===1?"":"s"}`}function Jm(e){return`log-${String(e)}`}function Ym(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(Ql(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 gr(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 #${gr(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 #${gr(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 ${Pa(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${gr(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(Wo,{className:"size-3.5 text-blue-400"});case"tool":return s.jsx(as,{className:"size-3.5 text-sky-400/70"});case"slow":return s.jsx(tn,{className:"size-3.5 text-amber-400"});case"failure":return s.jsx(Af,{className:"size-3.5 text-destructive"});case"candidate":return s.jsx(Tf,{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&&Ym(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 _E(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function kE(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=gr(n,t);return r===void 0||n===r?`#${o}`:`#${o}-#${gr(r,t)}`}function Eu(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),[h,m]=p.useState(e.content),[v,g]=p.useState(Eu(e.tags)),[x,b]=p.useState(null),y=e.status!=="promoted",k=e.status!=="promoted",j=p.useCallback(()=>{u(e.type),f(e.title),m(e.content),g(Eu(e.tags)),b(null)},[e.content,e.tags,e.title,e.type]),S=p.useCallback(async()=>{const E=d.trim(),N=h.trim(),z=NE(v);if(E.length===0){b("Title is required.");return}if(N.length===0){b("Content is required.");return}if(z.length===0){b("At least one tag is required.");return}b(null),await o(e.id,{type:c,title:E,content:N,tags:z})&&l(!1)},[e.id,h,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 N=ps.shape.type.safeParse(E.currentTarget.value);N.success&&u(N.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:h,disabled:n,onChange:E=>m(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(_e,{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(ls,{className:"size-3.5"}),"Cancel"]}),s.jsxs(_e,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{S()},children:[n?s.jsx(nn,{className:"size-3.5 animate-spin"}):s.jsx(Iw,{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(Pe,{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(Pe,{variant:"outline",className:le("h-5 shrink-0 px-1.5 text-[10px] font-mono",fE[e.status]),children:_E(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(Dy,{className:"size-3"}),CE(e.logIds,i)]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Ac,{className:"size-3"}),jE(e)]}),e.status==="promoted"&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[s.jsx(oa,{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(Af,{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 N=gr(E,i);return s.jsxs("a",{href:`#${Jm(E)}`,onClick:z=>{z.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 ${N}`,title:`Log ID ${String(E)}`,children:["#",N]},E)}),s.jsx("span",{className:"flex-1"}),k&&s.jsxs(_e,{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(If,{className:"size-3"}),"Review"]}),s.jsxs(_e,{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(nn,{className:"size-3 animate-spin"}):y?s.jsx(vy,{className:"size-3"}):s.jsx(oa,{className:"size-3"}),kE(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,h]=p.useState(()=>new Set),[m,v]=p.useState(()=>new Set),g=i.length>0,x=p.useMemo(()=>ZT(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]),k=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 z=await Ke(`/api/knowledge/sessions/${encodeURIComponent(t)}/candidates`,oE,cE,{method:"POST"},A=>`Candidate generation failed with ${String(A.status)}`);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(z){d({status:"failed",error:z instanceof Error?z.message:"Candidate response was invalid"})}})())},[u.status,e.length,t]),E=p.useCallback(z=>{h(A=>{if(A.has(z))return A;const O=new Set(A);return O.add(z),O}),(async()=>{try{const A=await Pn(`/api/knowledge/candidates/${encodeURIComponent(z)}/promote`,uE,{method:"POST"}),O=await A.json().catch(()=>null),W=iE.safeParse(O);if(A.ok&&W.success){a(L=>L.map(_=>_.id===W.data.candidate.id?W.data.candidate:_)),d({status:"ready",error:null});return}const T=aE.safeParse(O);T.success&&T.data.candidate!==void 0&&a(L=>L.map(_=>_.id===T.data.candidate?.id?T.data.candidate:_)),d({status:"failed",error:T.success?T.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(A.status)}`})}catch(A){d({status:"failed",error:A instanceof Error?A.message:"Candidate promotion failed"})}finally{h(A=>{const O=new Set(A);return O.delete(z),O})}})()},[]),N=p.useCallback(async(z,A)=>{v(O=>{if(O.has(z))return O;const W=new Set(O);return W.add(z),W});try{const O=await Ke(`/api/knowledge/candidates/${encodeURIComponent(z)}`,lE,dE,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)},W=>`Candidate update failed with ${String(W.status)}`);return a(W=>W.map(T=>T.id===O.candidate.id?O.candidate:T)),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 W=new Set(O);return W.delete(z),W})}},[]);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(as,{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(Jr,{className:"size-3.5 text-emerald-400"}),s.jsxs("span",{className:"font-mono",children:[Fe(x.totalInputTokens)," / ",Fe(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(Jr,{className:"size-3.5 text-purple-400"}),s.jsxs("span",{className:"font-mono",children:["KV Cache +",Fe(x.totalCacheCreationInputTokens)," / ~",Fe(x.totalCacheReadInputTokens)]})]}),k&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(tn,{className:"size-3.5"}),r&&s.jsx("span",{className:"font-mono",children:Pa(x.totalElapsedMs)}),x.maxElapsedMs!==null&&s.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",Pa(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(bn,{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(Pe,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:hE(x.knowledgeCandidateCount)}),s.jsxs(_e,{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(tt,{className:"size-3.5 animate-spin"}):s.jsx(Tf,{className:"size-3.5"}),"Candidate"]}),g&&s.jsx(_e,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onClick:()=>c(z=>!z),"aria-expanded":l,"aria-label":l?"Collapse memory candidates":"Expand memory candidates",children:l?s.jsx(lt,{className:"size-3.5"}):s.jsx(Ct,{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:m,onPromoteCandidate:E,onUpdateCandidate:N,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=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 zE(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function OE(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}const PE=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:h,expanded:m,onExpandedChange:v}){const[g,x]=p.useState(f),b=m??g,y=p.useCallback(W=>{if(v!==void 0){v(W);return}x(W)},[v]);p.useEffect(()=>{!f||m!==void 0||x(!0)},[m,f]);const k=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(),N=e.logs.some(W=>W.responseStatus===null),z=p.useMemo(()=>zE(e.logs),[e.logs]),A=p.useMemo(()=>OE(e.logs),[e.logs]),O=p.useMemo(()=>Oa(e.logs),[e.logs]);return p.useEffect(()=>{const W=T=>{const L=hi(T);L!==null&&e.logs.some(_=>_.id===L.logId)&&y(!0)};return window.addEventListener(an,W),()=>{window.removeEventListener(an,W)}},[e.logs,y]),s.jsxs("div",{className:"mb-2",children:[s.jsx(G3,{conversationId:e.conversationId,startTime:S,endTime:E,totalCalls:e.logs.length,totalInputTokens:k.totalInputTokens,totalOutputTokens:k.totalOutputTokens,expanded:b,onToggle:()=>y(!b),providers:j,isLoading:N,userAgent:e.logs[0]?.userAgent??null,clientPid:z,clientProjectFolder:A,showClientIdentity:c,showProcessMetadata:u,timeDisplayFormat:h,onClear:()=>l(e.logs.map(W=>W.id))}),b&&s.jsxs("div",{children:[s.jsx(AE,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:r,showRollupMetrics:!1,timeDisplayFormat:h}),s.jsx(eE,{turnGroups:O,viewMode:t,strip:n,slowResponseThresholdSeconds:r,timeDisplayFormat:h,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: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 Co({...e}){return s.jsx(iN,{"data-slot":"select",...e})}function No({...e}){return s.jsx(lN,{"data-slot":"select-value",...e})}function To({className:e,size:t="default",children:n,...r}){return s.jsxs(aN,{"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(cN,{asChild:!0,children:s.jsx(lt,{className:"size-4 opacity-50"})})]})}function Eo({className:e,children:t,position:n="popper",align:r="center",...o}){return s.jsx(uN,{children:s.jsxs(dN,{"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(fN,{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 Pt({className:e,children:t,...n}){return s.jsxs(pN,{"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(mN,{children:s.jsx(Xe,{className:"size-4"})})}),s.jsx(hN,{children:t})]})}function DE({className:e,...t}){return s.jsx(gN,{"data-slot":"select-scroll-up-button",className:le("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(pl,{className:"size-4"})})}function $E({className:e,...t}){return s.jsx(xN,{"data-slot":"select-scroll-down-button",className:le("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(lt,{className:"size-4"})})}const FE=Ee(["critical","warning","notice"]),BE=Ee(["open"]),UE=Ee(["proxy","tool-schema","run","group"]),Xm=Ee(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),WE=Ee(["log","session","run","group"]),HE=Ee(["anthropic","openai","unknown"]),VE=J({kind:WE,id:C(),label:C(),href:C().nullable()}),qE=J({id:C(),fingerprint:C(),severity:FE,category:Xm,source:UE,status:BE,title:C(),message:C(),count:K().int().positive(),firstSeenAt:C(),lastSeenAt:C(),logIds:fe(K().int().positive()),sessionIds:fe(C()),runIds:fe(C()),groupIds:fe(C()),provider:C().nullable(),model:C().nullable(),apiFormat:HE.nullable(),evidence:fe(VE),metadata:Ye(C(),st)}),ZE=J({category:Xm,count:K().int().nonnegative()}),Qm=J({total:K().int().nonnegative(),open:K().int().nonnegative(),critical:K().int().nonnegative(),warning:K().int().nonnegative(),notice:K().int().nonnegative(),byCategory:fe(ZE)}),GE=J({alerts:fe(qE),total:K().int().nonnegative(),limit:K().int().positive(),summary:Qm}),KE=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=rn(t?YE(e):null,r=>Ke(r,GE,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=rn("/api/alerts/summary",t=>Ke(t,Qm,KE),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const mi="relative size-8 rounded-md border-0 bg-white/[0.035] text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:bg-white/[0.065] hover:text-accent-foreground focus-visible:ring-ring/50",eA=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function e0(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function tA(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function tc(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 nA(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 rA(e){switch(e){case"critical":return"bg-red-400";case"warning":return"bg-amber-300";case"notice":return"bg-sky-300"}}function sA(e){switch(e){case"critical":return"text-red-200";case"warning":return"text-amber-100";case"notice":return"text-sky-100"}}function oA(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return s.jsx(Bw,{className:"size-3.5"});case"request-timeout":case"slow-response":return s.jsx(gy,{className:"size-3.5"});case"tool-schema":return s.jsx(bn,{className:"size-3.5"});case"group-incomplete":return s.jsx(W2,{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 _t(e){return e.toLocaleString()}function t0(e){return e.provider!==null&&e.model!==null?`${e.provider} / ${e.model}`:e.provider!==null?e.provider:e.model!==null?e.model:"Unknown target"}function iA(e,t){const n={limit:100};return e!=="all"&&(n.severity=e),t!=="all"&&(n.category=t),n}function aA(e,t){if(t!==null){const n=e.find(r=>r.id===t);if(n!==void 0)return n}return e[0]??null}function Ps({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:_t(t)})]})}function Ms({value:e,active:t,label:n,count:r,onClick:o}){return s.jsxs(_e,{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(Pe,{variant:"outline",children:_t(r)}):null]})}function lA({category:e,active:t,count:n,onClick:r}){return s.jsxs(_e,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>r(e),className:"h-7 px-2",children:[oA(e),tc(e),s.jsx(Pe,{variant:"outline",children:_t(n)})]})}function cA({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(tt,{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",rA(i.severity))}),s.jsx("span",{className:le("text-xs font-semibold",sA(i.severity)),children:e0(i.severity)}),s.jsx("span",{className:"truncate text-xs text-muted-foreground",children:tc(i.category)})]}),s.jsx("div",{className:"mt-1 text-sm font-semibold leading-snug",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(Pe,{variant:"outline",className:"shrink-0",children:["x",_t(i.count)]}):null]}),s.jsxs("div",{className:"mt-2 flex min-w-0 items-start justify-between gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 leading-snug",children:t0(i)}),s.jsx("span",{className:"shrink-0",children:Ma(i.lastSeenAt)})]})]},i.id)})})}function uA({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(Pe,{variant:"outline",children:n.label},`${n.kind}:${n.id}`):s.jsx(Pe,{variant:"outline",asChild:!0,children:s.jsx("a",{href:n.href,onClick:t,children:n.label})},`${n.kind}:${n.id}`))})}function dA({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",nA(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(Pe,{variant:"outline",children:e0(e.severity)}),s.jsx(Pe,{variant:"outline",children:tA(e.source)}),s.jsx(Pe,{variant:"outline",children:tc(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(Pe,{variant:"outline",className:"shrink-0",children:[_t(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(dn,{label:"Target",value:t0(e)}),s.jsx(dn,{label:"Last seen",value:Ma(e.lastSeenAt)}),s.jsx(dn,{label:"First seen",value:Ma(e.firstSeenAt)}),s.jsx(dn,{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(uA,{alert:e,onNavigate:t})]}),s.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[s.jsx(dn,{label:"Logs",value:e.logIds.length===0?"n/a":_t(e.logIds.length)}),s.jsx(dn,{label:"Sessions",value:e.sessionIds.length===0?"n/a":_t(e.sessionIds.length)}),s.jsx(dn,{label:"Runs",value:e.runIds.length===0?"n/a":_t(e.runIds.length)}),s.jsx(dn,{label:"Groups",value:e.groupIds.length===0?"n/a":_t(e.groupIds.length)})]})]})]})}function dn({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 Ru(){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(()=>iA(n,o),[o,n]),{alerts:f,total:h,isLoading:m,error:v,mutate:g}=XE(d,e),x=p.useMemo(()=>aA(f,a),[f,a]);p.useEffect(()=>{!e||a!==null&&f.some(N=>N.id===a)||l(f[0]?.id??null)},[f,e,a]);const b=c?.total??0,y=c?.critical??0,k=c?.warning??0,j=c?.notice??0,S=y>0?"bg-red-500":k>0?"bg-amber-400":"bg-sky-400";return s.jsxs(qn,{open:e,onOpenChange:t,children:[s.jsx(Go,{asChild:!0,children:s.jsxs(_e,{type:"button",variant:"ghost",size:"icon",className:mi,"aria-label":"Alerts",title:"Alerts",children:[s.jsx(aa,{className:"size-4"}),u?s.jsx(tt,{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:_t(b)}):null,s.jsx("span",{className:"sr-only",children:"Alerts"})]})}),s.jsxs(Zn,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[s.jsxs(Gn,{children:[s.jsxs(Kn,{className:"flex items-center gap-2 pr-8",children:[s.jsx(aa,{className:"size-5 text-red-300"}),s.jsx("span",{children:"Alerts"}),s.jsx(Pe,{variant:"outline",children:_t(b)})]}),s.jsx(Rp,{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(Ps,{label:"Open",count:c?.open??0,tone:"neutral"}),s.jsx(Ps,{label:"Critical",count:y,tone:"critical"}),s.jsx(Ps,{label:"Warning",count:k,tone:"warning"}),s.jsx(Ps,{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(Ms,{value:"all",active:n==="all",label:"All",count:c?.total??null,onClick:r}),s.jsx(Ms,{value:"critical",active:n==="critical",label:"Critical",count:y,onClick:r}),s.jsx(Ms,{value:"warning",active:n==="warning",label:"Warning",count:k,onClick:r}),s.jsx(Ms,{value:"notice",active:n==="notice",label:"Notice",count:j,onClick:r})]}),s.jsxs(_e,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{g()},children:[s.jsx(nn,{className:"size-3.5"}),"Refresh"]})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx(_e,{type:"button",variant:o==="all"?"secondary":"ghost",size:"sm","aria-pressed":o==="all",onClick:()=>i("all"),className:"h-7 px-2",children:"All categories"}),eA.map(E=>{const N=c?.byCategory.find(z=>z.category===E)?.count??0;return N===0?null:s.jsx(lA,{category:E,active:o===E,count:N,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:[_t(h)," matched"]}),s.jsx("span",{children:f.length<h?`${_t(f.length)} shown`:"Latest"})]}),s.jsx(cA,{alerts:f,selectedAlertId:x?.id??null,isLoading:m,error:v,onSelect:l})]}),s.jsx(dA,{alert:x,onNavigate:()=>t(!1)})]})]})]})}const fA=12e3;function pA(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function hA(e){const t=rn(pA(e),n=>Ke(n,v2,fA));return{evidenceResponse:t.data??null,isLoading:t.isLoading,error:t.error,mutate:t.mutate}}const mA=8e3;function gA(){const e=rn("/api/groups",t=>Ke(t,Sf,mA));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const xA=3e3;function bA(e,t){return{id:(e?.id??0)+1,message:t.message,tone:t.tone??"error"}}function n0(){const[e,t]=p.useState(null),n=p.useCallback(o=>{t(i=>bA(i,o))},[]),r=p.useCallback(()=>{t(null)},[]);return p.useEffect(()=>{if(e===null)return;const o=window.setTimeout(()=>{t(null)},xA);return()=>{window.clearTimeout(o)}},[e]),{notice:e,showToast:n,dismissToast:r}}function r0({notice:e,onDismiss:t}){if(e===null)return null;const n=e.tone==="error",r=n?bn:oa;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(ls,{className:"size-3.5"})})]},e.id)})}const Ui=2e4;function vA(e,t){const n=`/api/groups/${encodeURIComponent(e)}`;return t?`${n}?deleteEvidence=1`:n}function yA(e){return"/api/groups"}function s0(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 wA(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 nc(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 rc(e){return e??"unknown"}function _A(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 gi(e){return e===null||e.trim().length===0?"-":e}function wt(e){return e.toLocaleString()}function La(e){return e==null?"-":e<1e3?`${wt(e)} ms`:`${(e/1e3).toFixed(1)} s`}function jr(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 Iu(e){return e===null?"-":jr(e)}function kA(e){const t=JSON.stringify(e),n=t===void 0?String(e):t;return n.length<=160?n:`${n.slice(0,157)}...`}function o0(...e){for(const t of e)if(t!==null&&t.trim().length>0)return t;return"-"}function jA(...e){for(const t of e)if(t!=null&&t.trim().length>0)return t;return null}function SA(e){const t=e.provider,n=e.model;return t!==null&&t.length>0&&n!==null&&n.length>0?`${t} / ${n}`:o0(t,n)}function CA(e,t){if(t!==null){const n=e.find(r=>r.id===t);if(n!==void 0)return n}return e[0]??null}function NA(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function TA(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function EA(e,t){return t!==null&&t.group.id===e.id?t.evidence:e.evidence}function AA(e,t,n){return t!==null&&t.group.id===e.id?t.summary:n!==null&&n.group.id===e.id?n.summary:null}function RA(e,t,n){return t!==null&&t.group.id===e.id?t.jenkinsReport:n!==null&&n.group.id===e.id?n.report:null}function zu(){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),[h,m]=p.useState(!1),[v,g]=p.useState(null),[x,b]=p.useState(null),[y,k]=p.useState(!1),{notice:j,showToast:S,dismissToast:E}=n0(),{groups:N,isLoading:z,error:A,mutate:O}=gA(),W=p.useMemo(()=>CA(N,n),[N,n]);p.useEffect(()=>{!e||n!==null&&N.some(Q=>Q.id===n)||r(N[0]?.id??null)},[N,e,n]);const T=W!==null&&c!==null&&c.group.id===W.id?c:null,{evidenceResponse:L,isLoading:_,error:$,mutate:ee}=hA(W),D=p.useCallback(()=>{O()},[O]),H=p.useCallback(async()=>{if(!(N.length===0||y)){k(!0),f(null),m(!1),b(null),l(null);try{const B=await Ke(yA(!1),b2,Ui,{method:"DELETE"},Q=>`Clear failed with status ${String(Q.status)}`);u(null),r(null),await O(),await ee(),S({message:`Cleared ${wt(B.deleted)} group${B.deleted===1?"":"s"}.`,tone:"success"})}catch(B){S({message:B instanceof Error?B.message:"Unknown error clearing groups",tone:"error"})}finally{k(!1)}}},[y,N.length,O,ee,S]),Z=p.useCallback(async B=>{i(B.id),l(null);try{const Q=await Ke(`/api/groups/${encodeURIComponent(B.id)}/evidence`,y2,Ui,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})},Se=>`Export failed with status ${String(Se.status)}`);u(Q),await O(),await ee()}catch(Q){l(Q instanceof Error?Q.message:String(Q))}finally{i(null)}},[O,ee]),ue=p.useCallback(B=>{f(B),m(!1),b(null)},[]),V=p.useCallback(()=>{v===null&&(f(null),m(!1),b(null))},[v]),U=p.useCallback(B=>{r(B),f(null),m(!1),b(null)},[]),ce=p.useCallback(async()=>{const B=d;if(B!==null){g(B.id),b(null);try{await Ke(vA(B.id,h),_f,Ui,{method:"DELETE"},Q=>`Delete failed with status ${String(Q.status)}`),u(Q=>Q!==null&&Q.group.id===B.id?null:Q),r(Q=>Q===B.id?null:Q),f(null),m(!1),await O(),await ee()}catch(Q){b(Q instanceof Error?Q.message:String(Q))}finally{g(null)}}},[h,d,O,ee]);return s.jsxs(qn,{open:e,onOpenChange:t,children:[s.jsx(r0,{notice:j,onDismiss:E}),s.jsx(Go,{asChild:!0,children:s.jsxs(_e,{type:"button",variant:"ghost",size:"icon",className:mi,"aria-label":"Evaluation groups",title:"Evaluation groups",children:[s.jsx(Tc,{className:"size-4"}),z?s.jsx(tt,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):N.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:N.length}):null,s.jsx("span",{className:"sr-only",children:"Evaluation groups"})]})}),s.jsxs(Zn,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[s.jsx(Gn,{children:s.jsxs(Kn,{className:"flex items-center gap-2 pr-8",children:[s.jsx(Tc,{className:"size-5 text-muted-foreground"}),s.jsx("span",{children:"Groups"}),s.jsx(Pe,{variant:"outline",children:wt(N.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("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs(_e,{type:"button",variant:"outline",size:"sm",disabled:N.length===0||y,onClick:()=>{H()},title:"Clear all groups. Session logs and run records stay intact.",children:[y?s.jsx(tt,{className:"size-3.5 animate-spin"}):s.jsx(Ht,{className:"size-3.5"}),"Clear"]}),s.jsxs(_e,{type:"button",variant:"outline",size:"sm",onClick:D,children:[s.jsx(nn,{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(IA,{groups:N,selectedGroupId:W?.id??null,isLoading:z,error:A,onSelect:U}),s.jsx(zA,{group:W,deleteTarget:d,deleteEvidence:h,exportResult:T,evidenceResponse:L,evidenceLoading:_,evidenceError:$,exportError:a,deleteError:x,exportingGroupId:o,deletingGroupId:v,onDeleteEvidenceChange:m,onExport:Z,onRequestDelete:ue,onCancelDelete:V,onConfirmDelete:()=>{ce()}})]})]})]})}function IA({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=s0(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 text-sm font-medium leading-snug",children:i.title}),s.jsx(Pe,{variant:"outline",className:nc(i.status),children:rc(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:jr(i.updatedAt)})]})]},i.id)})})})}function zA({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:h,onRequestDelete:m,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=s0(e),b=AA(e,r,o),y=RA(e,r,o),k=EA(e,r),j=wA(e,r,o),S=u===e.id,E=d===e.id,N=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 text-base font-semibold leading-snug",children:e.title}),s.jsx(Pe,{variant:"outline",className:nc(e.status),children:rc(e.status)}),s.jsx(Pe,{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:gi(e.project)}),s.jsxs("span",{children:["updated ",jr(e.updatedAt)]})]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(_e,{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:()=>m(e),children:E?s.jsx(tt,{className:"size-3.5 animate-spin"}):s.jsx(Ht,{className:"size-3.5"})}),s.jsxs(_e,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:S||E,onClick:()=>{h(e)},children:[S?s.jsx(tt,{className:"size-3.5 animate-spin"}):s.jsx(is,{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}),N&&s.jsx(OA,{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(fn,{label:"Members",value:x.memberCount}),s.jsx(fn,{label:"Done",value:x.completedMembers}),s.jsx(fn,{label:"Failed",value:x.failedMembers}),s.jsx(fn,{label:"Running",value:x.runningMembers})]}),b!==null&&s.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[s.jsx(fn,{label:"Requests",value:b.requestCount}),s.jsx(fn,{label:"Errors",value:b.errorCount}),s.jsx(fn,{label:"Tokens",value:b.tokenUsage.total}),s.jsx(fn,{label:"Missing",value:b.missingSessions})]}),s.jsx(PA,{report:y,loading:i,error:a,hasEvidence:k!==null}),s.jsx(MA,{evidence:k}),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&&!N&&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(LA,{rows:j})]})})}function OA({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(Ht,{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(_e,{type:"button",variant:"outline",size:"sm",disabled:n,onClick:i,children:"Cancel"}),s.jsxs(_e,{type:"button",variant:"destructive",size:"sm",disabled:n,onClick:a,children:[n?s.jsx(tt,{className:"size-3.5 animate-spin"}):s.jsx(Ht,{className:"size-3.5"}),"Delete"]})]})]})})}function fn({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:wt(t)})]})}function PA({report:e,loading:t,error:n,hasEvidence:r}){const{copied:o,copy:i}=gn(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(tt,{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(Pe,{variant:"outline",className:_A(e.status),children:e.status})]}),s.jsx(_e,{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(Xe,{className:"size-3.5 text-emerald-500"}):s.jsx(Ft,{className:"size-3.5"})})]}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function MA({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:jr(e.exportedAt)})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(Wi,{label:"JSON",value:e.jsonPath}),s.jsx(Wi,{label:"Markdown",value:e.markdownPath}),s.jsx(Wi,{label:"HTML",value:e.htmlPath})]})]})}function Wi({label:e,value:t}){const{copied:n,copy:r}=gn(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(_e,{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(Xe,{className:"size-3.5 text-emerald-500"}):s.jsx(Ft,{className:"size-3.5"})})]})}function LA({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(DA,{row:o,isExpanded:i,onToggleDetails:r}),s.jsx($A,{row:o,isExpanded:i})]},o.member.id)})})]})})]})}function DA({row:e,isExpanded:t,onToggleDetails:n}){const r=e.member,o=e.exportMember?.session??null,i=NA(e),a=o?.inspectorPath??jd(r.sessionId),l=e.source!=="evidence",c=o?.requestCount??null,u=o?.errorCount??null,d=o?.tokenUsage.total??null,f=i?.firstChunkMs??null,h=o0(r.label,r.sessionId),m=jA(o?.clientUserAgent,i?.userAgent,r.agent),v=o?.clientProjectFolder??null,g=Nl({userAgent:m,conversationId:r.sessionId,clientProjectFolder:v}),x=Ko(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(_e,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground","aria-label":t?`Hide member ${h}`:`Show member ${h}`,title:t?"Hide member details":"Show member details",onClick:()=>{n(r.id)},children:t?s.jsx(lt,{className:"size-3.5"}):s.jsx(Ct,{className:"size-3.5"})}),x!==null&&s.jsx(Jo,{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 ${h}`,title:`Open session ${h}`,children:[s.jsx("span",{className:"min-w-0 truncate",children:h}),s.jsx(hl,{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 ${h}`,"aria-label":`Show evidence snapshot for ${h}`,onClick:()=>{n(r.id)},children:[s.jsx("span",{className:"min-w-0 truncate",children:h}),s.jsx(Pe,{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:gi(r.agent)})]}),s.jsx("td",{className:"max-w-52 px-3 py-2",children:s.jsx("span",{className:"block whitespace-normal leading-snug",children:SA(r)})}),s.jsx("td",{className:"px-3 py-2",children:s.jsx(Pe,{variant:"outline",className:nc(r.status),children:rc(r.status)})}),s.jsx("td",{className:"px-3 py-2 font-mono",children:c===null?"-":wt(c)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":wt(u)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:La(f)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":wt(d)})]})}function $A({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(it,{label:"Source",value:TA(e.source)}),s.jsx(it,{label:"Member ID",value:n.id,mono:!0}),s.jsx(it,{label:"Session ID",value:n.sessionId,mono:!0}),s.jsx(it,{label:"Run ID",value:i?.id??n.runId??"-",mono:!0}),s.jsx(it,{label:"Created",value:jr(n.addedAt)}),s.jsx(it,{label:"Updated",value:jr(n.updatedAt)}),s.jsx(it,{label:"Session created",value:Iu(o?.createdAt??null)}),s.jsx(it,{label:"Session updated",value:Iu(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(it,{label:"Log coverage",value:o.logCoverage}),s.jsx(it,{label:"Runtime",value:gi(o.runtimeMode)}),s.jsx(it,{label:"Requests",value:wt(o.requestCount),mono:!0}),s.jsx(it,{label:"Errors",value:wt(o.errorCount),mono:!0}),s.jsx(it,{label:"Input tokens",value:wt(o.tokenUsage.input),mono:!0}),s.jsx(it,{label:"Output tokens",value:wt(o.tokenUsage.output),mono:!0}),s.jsx(it,{label:"Cache read",value:wt(o.tokenUsage.cacheRead),mono:!0}),s.jsx(it,{label:"Total tokens",value:wt(o.tokenUsage.total),mono:!0})]}),s.jsx(FA,{logs:o?.latestLogs??[]}),s.jsx(BA,{entries:a})]})})})}function it({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 FA({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:[gi(n.model)," · ",n.apiFormat," · ",n.path]}),s.jsx("span",{className:"font-mono text-muted-foreground",children:La(n.firstChunkMs)}),s.jsx("span",{className:"font-mono text-muted-foreground",children:La(n.latencyMs)})]},n.id)})})]})}function BA({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=kA(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)})})]})}const UA=J({name:C(),apiKey:C(),format:Ee(["anthropic","openai"]),anthropicBaseUrl:C(),openaiBaseUrl:C(),openaiResponsesBaseUrl:C().optional().default(""),models:fe(C()),sourceTool:Ee(["claude-code","opencode","mimo-code"]),alreadyExists:Le()}),WA=J({providers:fe(UA),warnings:fe(C()).optional()}),HA=J({success:Le().optional(),imported:K().optional(),message:C().optional(),errors:fe(C()).optional()}),Ou=2e4;function VA({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,h]=p.useState(new Set),[m,v]=p.useState(!1),[g,x]=p.useState(null),[b,y]=p.useState(null),k=p.useRef(0),j=p.useRef(0),S=p.useCallback(()=>{const A=k.current+1;k.current=A,o(!0),a(null),d([]),c([]),h(new Set),x(null),y(null),Ke("/api/providers/scan",WA,Ou,void 0,O=>`Scan failed (${String(O.status)})`).then(O=>{if(k.current!==A)return;c(O.providers),d(O.warnings??[]);const W=new Set;O.providers.forEach((T,L)=>{T.alreadyExists||W.add(L)}),h(W)}).catch(O=>{k.current===A&&a(O instanceof Error?O.message:String(O))}).finally(()=>{k.current===A&&o(!1)})},[]);p.useEffect(()=>{e&&S()},[e,S]),p.useEffect(()=>{e||(k.current+=1,j.current+=1,o(!1),v(!1))},[e]);const E=p.useCallback(A=>{h(O=>{const W=new Set(O);return W.has(A)?W.delete(A):W.add(A),W})},[]),N=p.useCallback(()=>{const A=l.filter((L,_)=>f.has(_));if(A.length===0)return;const O=j.current+1;j.current=O,v(!0),y(null),x(null);const W=new Date().toISOString(),T=A.map(L=>({id:window.crypto.randomUUID(),name:L.name,apiKey:L.apiKey,format:L.format,anthropicBaseUrl:L.anthropicBaseUrl,openaiBaseUrl:L.openaiBaseUrl,openaiResponsesBaseUrl:L.openaiResponsesBaseUrl,models:L.models,createdAt:W,updatedAt:W}));Ke("/api/providers/import",HA,Ou,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providers:T})},L=>`Import failed (${String(L.status)})`).then(L=>{j.current===O&&(c(_=>_.map(($,ee)=>f.has(ee)?{...$,alreadyExists:!0}:$)),h(new Set),L.errors!==void 0&&L.errors.length>0&&L.message!==void 0?x(L.message):x(`Imported ${L.imported??A.length} provider(s)`),n())}).catch(L=>{j.current===O&&y(L instanceof Error?L.message:String(L))}).finally(()=>{j.current===O&&v(!1)})},[l,f,n]),z=l.some(A=>!A.alreadyExists);return s.jsx(qn,{open:e,onOpenChange:t,children:s.jsxs(Zn,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[s.jsxs(Gn,{children:[s.jsx(Kn,{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(tt,{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(vr,{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((A,O)=>s.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${A.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!A.alreadyExists&&s.jsx("input",{type:"checkbox",checked:f.has(O),disabled:m,onChange:()=>E(O),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:[s.jsx(Jo,{client:A.sourceTool,className:"size-7 rounded-[8px]"}),A.alreadyExists&&s.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),s.jsxs("div",{className:"mt-1 text-xs leading-snug text-muted-foreground",children:[A.models.slice(0,4).join(", "),A.models.length>4?` +${A.models.length-4} more`:""]}),s.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:A.format==="anthropic"?A.anthropicBaseUrl:A.openaiResponsesBaseUrl!==""?A.openaiResponsesBaseUrl:A.openaiBaseUrl}),s.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:A.apiKey.length>8?`${A.apiKey.slice(0,4)}••••${A.apiKey.slice(-4)}`:"••••"})]})]},`${A.sourceTool}-${A.name}`)),u.length>0&&s.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:u.map((A,O)=>s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(vr,{className:"size-3"}),A]},O))}),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(_e,{variant:"outline",size:"sm",onClick:S,disabled:r,children:[s.jsx(tt,{className:`size-3 mr-1 ${r?"animate-spin":""}`}),"Rescan"]}),s.jsxs(_e,{size:"sm",onClick:N,disabled:!z||f.size===0||m,children:[s.jsx(is,{className:"size-3 mr-1"}),m?"Importing...":`Import Selected (${f.size})`]})]})]})})}function i0(e){return e.length<=8?"••••••••":e.slice(0,4)+"••••••••"+e.slice(-4)}const a0=J({id:C().min(1),aliases:fe(C()).optional().default([]),contextWindow:K().int().positive().optional(),outputLimit:K().int().positive().optional(),sourceUrl:C().optional()}),qA=J({name:C().min(1).optional(),aliases:fe(C()).optional().default([]),baseUrls:fe(C()).optional().default([]),models:fe(a0).min(1)});J({version:K().int().positive().optional(),updatedAt:C().optional(),providers:fe(qA).optional().default([]),models:fe(a0).optional().default([])});function Pu(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function ZA(e){const t=e.models.filter(n=>n.trim()!=="");return t.length>0?t:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function sc(e,t){const n=Pu(t);return(e.modelMetadata??[]).find(o=>Pu(o.model)===n)??null}function GA(e){const t=ZA(e);return t.length===0?!1:t.every(n=>{const r=sc(e,n);return r!==null&&r.contextWindow!==void 0})}function KA(e,t){if(e===null)return null;for(const n of t){const r=sc(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 Ln="/v1/chat/completions",Ao="/v1/responses",l0="/v1/messages";function JA(e,t){const n=e.endsWith("/")?e.slice(0,-1):e,r=u0(t),o=t.indexOf("?"),i=o>=0?t.slice(o):"";return r!==""&&n.endsWith(r)?n+i:f0(n)&&d0(t)||n.endsWith("/v1")&&t.startsWith("/v1/")?n+t.slice(3):n+t}function c0(e,t,n={}){const r=e.trim().replace(/\/+$/,""),o=u0(t),i=JA(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."}):f0(r)&&d0(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."}),Mu(o)&&XA(r)&&a.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),YA(o)&&QA(r)&&a.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),Mu(o)&&e6(r,n.providerName)&&a.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:i,diagnostics:a}}function u0(e){return e.split("?")[0]??e}function d0(e){return e===Ln||e.startsWith(`${Ln}?`)||e.startsWith(`${Ln}/`)}function YA(e){return e===Ln||e.startsWith(`${Ln}/`)}function Mu(e){return e===Ao||e.startsWith(`${Ao}/`)}function XA(e){return e.toLowerCase().endsWith("/chat/completions")}function QA(e){return e.toLowerCase().endsWith("/responses")}function e6(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 f0(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 t6={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function p0(e){return Object.prototype.hasOwnProperty.call(e,"success")}function h0(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function vt(e){return e!==void 0&&e.trim()!==""}function Da(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 Lu(e){return Da(e)!==void 0}function Du(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function n6(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function r6(e){const t=e.debug;return vt(e.error?.hint)||vt(e.error?.details)||vt(e.rawResponse)||vt(t?.requestUrl)||vt(t?.requestBody)||vt(t?.responseBody)||Lu(t?.requestHeaders)||Lu(t?.responseHeaders)||t?.responseStatus!==void 0}function pn({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 $r({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 s6({result:e}){const t=e.debug,n=t?.requestUrl,r=t?.requestMethod??"POST",o=Da(t?.requestHeaders),i=Da(t?.responseHeaders),a=t?.responseStatus!==void 0?`${t.responseStatus}${vt(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:[vt(e.error?.hint)&&s.jsx(pn,{title:"Hint",children:s.jsx("div",{children:e.error.hint})}),vt(e.error?.details)&&s.jsx(pn,{title:"Error",children:s.jsx($r,{value:e.error.details})}),vt(n)&&s.jsx(pn,{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(pn,{title:"Request Headers",children:s.jsx($r,{value:o})}),vt(t?.requestBody)&&s.jsx(pn,{title:"Request Body",children:s.jsx($r,{value:t.requestBody})}),vt(a)&&s.jsx(pn,{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(pn,{title:"Response Headers",children:s.jsx($r,{value:i})}),vt(l)&&s.jsx(pn,{title:"Response Body",children:s.jsx($r,{value:l})})]})}function or({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($u,{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($u,{result:e.streaming})]})]})}function o6({diagnostic:e}){return s.jsx("div",{className:e.severity==="warning"?"text-amber-200":"text-muted-foreground",children:e.message})}function Hi({label:e,baseUrl:t,endpoint:n,providerName:r,children:o}){const i=c0(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(o6,{diagnostic:a},`${a.severity}:${a.message}`))}),o]})}function dt(e){return e!==void 0&&e!==""}function m0(e){const t=[];return dt(e.anthropicBaseUrl)&&t.push("Anthropic"),dt(e.openaiBaseUrl)&&t.push("Chat"),dt(e.openaiResponsesBaseUrl)&&t.push("Responses"),t}function i6({provider:e}){const t=m0(e);return t.length===0?s.jsx("div",{className:"text-xs text-muted-foreground",children:"Test requires at least one configured endpoint."}):s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx("span",{children:"Test covers"}),t.map(n=>s.jsx("span",{className:"rounded border border-border/70 bg-muted/25 px-1.5 py-0.5 text-foreground/80",children:n},n)),s.jsx("span",{children:"non-stream + stream"})]})}function a6(e,t){if(t===void 0)return[];const n=[];return dt(e.anthropicBaseUrl)&&n.push(t.anthropic),dt(e.openaiBaseUrl)&&n.push(t.openaiChat),dt(e.openaiResponsesBaseUrl)&&n.push(t.openaiResponses),n}function l6(e,t){const n={total:0,passed:0,failed:0,testing:0};for(const r of a6(e,t))for(const o of[r.nonStreaming,r.streaming])h0(o)||(n.total+=1,p0(o)?o.success?n.passed+=1:n.failed+=1:n.testing+=1);return n}function c6({provider:e,testResults:t,isTesting:n}){const r=m0(e),o=l6(e,t);return n?s.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-cyan-300/25 bg-cyan-300/[0.08] px-2 py-1 text-xs text-cyan-100",children:[s.jsx(co,{className:"size-3 animate-spin"}),"Testing"]}):r.length===0?s.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"No endpoint"}):t===void 0||o.total===0?s.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"Not tested"}):o.failed>0?s.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-red-400/25 bg-red-500/[0.08] px-2 py-1 text-xs text-red-200",children:[s.jsx(vr,{className:"size-3"}),o.passed,"/",o.total," passed"]}):o.testing>0||o.passed<o.total?s.jsxs("span",{className:"rounded border border-amber-300/25 bg-amber-400/[0.08] px-2 py-1 text-xs text-amber-100",children:["Partial ",o.passed,"/",o.total]}):s.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-cyan-300/25 bg-cyan-300/[0.08] px-2 py-1 text-xs text-cyan-100",children:[s.jsx(Ef,{className:"size-3"}),"OK ",o.passed,"/",o.total]})}function u6(e){const t=e.models??[];if(t.length===0)return"No models configured";const n=t.slice(0,2).join(", "),r=t.length-2;return r>0?`${n} +${r} more`:n}function d6({provider:e,model:t}){const n=sc(e,t),r=m6(n?.sourceUrl);return s.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[s.jsx("span",{children:t}),n!==null&&n.contextWindow!==void 0&&s.jsx("span",{className:"font-mono text-foreground/80",children:Xf(n.contextWindow)}),r!==null&&s.jsx(rt,{children:s.jsxs(Ue,{children:[s.jsx(We,{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(He,{children:r.title})]})})]})}function f6(e){const t=e?.models;if(t===void 0)return null;const n=Object.keys(t).length;return n===0?null:`${n} model${n===1?"":"s"} tested`}function p6(e){const t={className:"size-3",strokeWidth:2};switch(e){case"timeout":return s.jsx(tn,{...t});case"network_unreachable":return s.jsx(Qw,{...t});case"connection_refused":return s.jsx(t_,{...t});case"auth_failed":return s.jsx(iw,{...t});case"rate_limited":return s.jsx(xl,{...t});case"server_error":return s.jsx(Lw,{...t});case"invalid_response":return s.jsx(dy,{...t});case"unknown":return s.jsx(vr,{...t});default:return s.jsx(vr,{...t})}}function $u({result:e}){const[t,n]=p.useState(!1);if(!p0(e))return h0(e)?s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground shrink-0",children:[s.jsx(cw,{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(co,{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 ",Du(e.firstChunkMs)]},"first")),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&c.push(s.jsxs("span",{children:["total ",Du(e.totalStreamMs)]},"total")),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&c.push(s.jsxs("span",{children:[n6(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(rt,{children:s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center gap-1 text-xs text-cyan-100 shrink-0",children:[s.jsx(Ef,{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(He,{children:"Connection test passed"})]})})}const r=e.error,o=r?.message??"Connection failed",i=r?.type??"unknown",a=r6(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:[p6(i),s.jsx(rt,{children:s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsx("span",{className:"truncate",children:o})}),s.jsx(He,{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(ml,{className:"size-3"}):s.jsx(gl,{className:"size-3"}),s.jsx("span",{children:t?"Hide":"Details"})]})]}),t&&a&&s.jsx(s6,{result:e})]})}function h6(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 m6(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 g6({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),[h,m]=p.useState(!1),[v,g]=p.useState(!1),[x,b]=p.useState(!1);function y(){Lt(e.apiKey).then(O=>{O&&(m(!0),setTimeout(()=>m(!1),2e3))})}const k=e.apiDocsUrl??Object.entries(t6).find(([O])=>e.name.toLowerCase().includes(O))?.[1],j=GA(e),S=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",E=S?"Refresh":"Import defaults",N=n??!1,z=f6(t),A=e.source==="company"?s.jsx(rt,{children:s.jsxs(Ue,{children:[s.jsx(We,{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(He,{children:"Company-provided API key"})]})}):e.source==="personal"?s.jsx(rt,{children:s.jsxs(Ue,{children:[s.jsx(We,{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(He,{children:"Your personal API key"})]})}):null;return s.jsxs("div",{className:`flex flex-col gap-3 rounded-[8px] border border-border bg-card p-4 shadow-sm transition-all duration-500 ${o===!0?"ring-2 ring-primary shadow-md":""}`,children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",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("span",{className:"font-medium leading-snug",children:e.name}),A]}),s.jsx("div",{className:"text-xs leading-snug text-muted-foreground",children:u6(e)})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(c6,{provider:e,testResults:t,isTesting:N}),k!==void 0&&s.jsxs("a",{href:k,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",title:"View API documentation",children:[s.jsx(hl,{className:"size-3"}),s.jsx("span",{className:"sr-only",children:"Docs"})]})]})]}),s.jsxs("div",{className:"flex flex-col gap-2 text-xs text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[s.jsx(i6,{provider:e}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{children:"Key configured"}),s.jsx("span",{children:e.authHeader==="x-api-key"?"x-api-key":"Bearer"}),z!==null&&s.jsx("span",{children:z}),t?.testedAt!==void 0&&s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(tn,{className:"size-3"}),h6(t.testedAt)]})]})]}),!j&&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(_e,{type:"button",variant:"outline",size:"sm",onClick:()=>c?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:u,children:[s.jsx(co,{className:`size-3 ${u?"animate-spin":""}`}),E]}),!S&&s.jsx(_e,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),v&&s.jsxs("div",{className:"space-y-3 border-t border-border/60 pt-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"flex-1 truncate rounded bg-muted px-2 py-1 text-xs text-muted-foreground",children:d?e.apiKey:i0(e.apiKey)}),s.jsx("button",{type:"button",onClick:()=>f(O=>!O),className:"p-1 text-muted-foreground transition-colors hover:text-foreground","aria-label":d?"Hide API key":"Show API key",children:d?s.jsx(ml,{className:"size-4"}):s.jsx(gl,{className:"size-4"})}),s.jsx("button",{type:"button",onClick:y,className:"p-1 text-muted-foreground transition-colors hover:text-foreground","aria-label":"Copy API key",children:h?s.jsx(Xe,{className:"size-4 text-cyan-300"}):s.jsx(Ft,{className:"size-4"})})]}),e.models!==void 0&&e.models.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(O=>s.jsx(d6,{provider:e,model:O},O))}),dt(e.anthropicBaseUrl)&&s.jsx(Hi,{label:"Anthropic",baseUrl:e.anthropicBaseUrl,endpoint:l0,providerName:e.name,children:t!==void 0&&s.jsx(or,{results:t.anthropic})}),dt(e.openaiBaseUrl)&&s.jsx(Hi,{label:"Chat",baseUrl:e.openaiBaseUrl,endpoint:Ln,providerName:e.name,children:t!==void 0&&s.jsx(or,{results:t.openaiChat})}),dt(e.openaiResponsesBaseUrl)&&s.jsx(Hi,{label:"Responses",baseUrl:e.openaiResponsesBaseUrl,endpoint:Ao,providerName:e.name,children:t!==void 0&&s.jsx(or,{results:t.openaiResponses})}),t?.models!==void 0&&Object.keys(t.models).length>0&&s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>b(O=>!O),className:"flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[x?s.jsx(lt,{className:"size-3"}):s.jsx(Ct,{className:"size-3"}),"Model Test Results (",Object.keys(t.models).length,")"]}),x&&s.jsx("div",{className:"mt-2 overflow-x-auto",children:s.jsxs("table",{className:"w-full border-collapse text-xs",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border",children:[s.jsx("th",{className:"px-2 py-1 text-left font-medium text-muted-foreground",children:"Model"}),dt(e.anthropicBaseUrl)&&s.jsx("th",{className:"px-2 py-1 text-left font-medium text-muted-foreground",children:"Anthropic"}),dt(e.openaiBaseUrl)&&s.jsx("th",{className:"px-2 py-1 text-left font-medium text-muted-foreground",children:"Chat"}),dt(e.openaiResponsesBaseUrl)&&s.jsx("th",{className:"px-2 py-1 text-left font-medium text-muted-foreground",children:"Responses"})]})}),s.jsx("tbody",{children:Object.entries(t.models).map(([O,W])=>s.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[s.jsx("td",{className:"px-2 py-1 font-medium",children:O}),dt(e.anthropicBaseUrl)&&s.jsx("td",{className:"px-2 py-1 align-top",children:s.jsx(or,{results:W.anthropic})}),dt(e.openaiBaseUrl)&&s.jsx("td",{className:"px-2 py-1 align-top",children:s.jsx(or,{results:W.openaiChat})}),dt(e.openaiResponsesBaseUrl)&&s.jsx("td",{className:"px-2 py-1 align-top",children:s.jsx(or,{results:W.openaiResponses})})]},O))})]})})]})]}),s.jsxs("div",{className:"flex flex-col gap-2 border-t pt-1 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("button",{type:"button",onClick:()=>g(O=>!O),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":v,children:[v?s.jsx(lt,{className:"size-3"}):s.jsx(Ct,{className:"size-3"}),"Details"]}),s.jsxs("div",{className:"flex gap-2",children:[l!==void 0&&s.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>l(e.id),className:"text-xs h-7 gap-1",disabled:N,children:[s.jsx(co,{className:`size-3 ${N?"animate-spin":""}`}),N?r!==void 0?`Testing (${r}s)`:"Testing...":"Test"]}),s.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>i(e),className:"text-xs h-7 gap-1",disabled:N,children:[s.jsx(If,{className:"size-3"}),"Edit"]}),s.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>a(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:N,children:[s.jsx(Ht,{className:"size-3"}),"Delete"]})]})]})]})}const Fu=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],Bu=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],Ls=l0,Ds=Ln,$s=Ao,x6={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"}},Uu=["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"],Hu=["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"],$a="__unset__",Ro="__custom__",g0=[{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 In(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function Vu(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function x0(e,t){const n=Vu(t);return e?.modelMetadata?.find(r=>Vu(r.model)===n)??null}function b0(e){const t=fo(e);if(t===null)return null;for(const n of g0)if(fo(n.value)===t)return n.value;return null}function b6(e){return e.trim()===""?"unset":b0(e)!==null?"preset":"custom"}function v6(e){switch(e.contextWindowMode){case"unset":return $a;case"custom":return Ro;case"preset":return b0(e.contextWindow)??Ro}}function Vi(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 qu(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 Zu(e,t){return t.map(n=>{const r=x0(e,n),o=r?.contextWindow!==void 0?yk(r.contextWindow):"";return{contextWindow:o,contextWindowMode:b6(o),outputLimit:r?.outputLimit?.toString()??""}})}function Gu(e){const t=e.trim();if(t==="")return null;const n=Number(t);return!Number.isInteger(n)||n<=0?null:n}function ir(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 y6(e,t,n){const r=e.trim();return r===""?null:c0(r,t,{providerName:n})}function qi({baseUrl:e,endpoint:t,providerName:n}){const r=y6(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 w6({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,[h,m]=p.useState(f!==void 0&&f.length>0?f:[""]),[v,g]=p.useState(()=>Zu(e,f!==void 0&&f.length>0?f:[""])),[x,b]=p.useState("anthropic"),[y,k]=p.useState(ir(e?.anthropicBaseUrl,Ls)),[j,S]=p.useState(ir(e?.openaiBaseUrl,Ds)),[E,N]=p.useState(ir(e?.openaiResponsesBaseUrl,$s)),[z,A]=p.useState(e?.apiDocsUrl??""),[O,W]=p.useState(e?.modelMetadataUrl??""),[T,L]=p.useState(e?.source),[_,$]=p.useState({}),[ee,D]=p.useState(!1),[H,Z]=p.useState(null),ue=p.useRef([]);p.useEffect(()=>{if(H===null)return;const R=H;function M(Y){if(!(Y.target instanceof Node))return;const se=ue.current[R];se!=null&&!se.contains(Y.target)&&Z(null)}return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[H]);const[V,U]=p.useState(!1),[ce,B]=p.useState(!1),[Q,Se]=p.useState(!1),ie=r.toLowerCase().includes("minimax"),pe=r.toLowerCase().includes("alibaba"),me=[...Fu,...Bu].some(R=>r.toLowerCase().includes(R)),he=ie?Uu:me?Hu:pe?Wu:[],xe=e?.modelMetadata?.some(R=>R.contextWindow!==void 0)??!1;function ke(){Lt(i).then(R=>{R&&(d(!0),setTimeout(()=>d(!1),2e3))})}p.useEffect(()=>{if(e){o(e.name),a(e.apiKey);const R=(e.models?.length??0)>0?e.models:[""];m(R),g(Zu(e,R)),k(ir(e.anthropicBaseUrl,Ls)),S(ir(e.openaiBaseUrl,Ds)),N(ir(e.openaiResponsesBaseUrl,$s)),A(e.apiDocsUrl??""),W(e.modelMetadataUrl??""),L(e.source),U(!1),B(!1),Se(!1)}},[e]),p.useEffect(()=>{const R=r.toLowerCase();for(const[M,Y]of Object.entries(x6))if(R.includes(M)){Y.anthropicBaseUrl!==void 0&&!V&&k(Y.anthropicBaseUrl),Y.openaiBaseUrl!==void 0&&!ce&&S(Y.openaiBaseUrl),Y.openaiResponsesBaseUrl!==void 0&&!Q&&N(Y.openaiResponsesBaseUrl),Y.apiDocsUrl!==void 0&&!z&&A(Y.apiDocsUrl),M==="minimax"&&h.length===1&&h[0]===""&&m([Uu[0]??""]),M==="alibaba"&&h.length===1&&h[0]===""&&m([Wu[0]??""]),(Fu.includes(M)||Bu.includes(M))&&h.length===1&&h[0]===""&&m([Hu[0]??""]);break}},[r]);function Ae(){const R={};return r.trim()||(R.name="Name is required"),i.trim()||(R.apiKey="API key is required"),(h.length===0||h.every(M=>!M.trim()))&&(R.models="At least one model is required"),y.trim()&&!w(y.trim())&&(R.anthropicBaseUrl="Invalid URL format"),j.trim()&&!w(j.trim())&&(R.openaiBaseUrl="Invalid URL format"),E.trim()&&!w(E.trim())&&(R.openaiResponsesBaseUrl="Invalid URL format"),O.trim()&&!w(O.trim())&&(R.modelMetadataUrl="Invalid URL format"),v.forEach((M,Y)=>{const se=fo(M.contextWindow),oe=Gu(M.outputLimit);M.contextWindow.trim()!==""&&se===null&&(R[`modelMetadata.${Y}.contextWindow`]="Context window must be a positive number, optionally using K or M"),M.outputLimit.trim()!==""&&oe===null&&(R[`modelMetadata.${Y}.outputLimit`]="Output limit must be a positive integer"),se!==null&&oe!==null&&oe>se&&(R[`modelMetadata.${Y}.outputLimit`]="Output limit should not exceed context window")}),!y.trim()&&!j.trim()&&!E.trim()&&(R.format="At least one format URL (Anthropic or OpenAI) is required"),$(R),Object.keys(R).length===0}function w(R){try{return new URL(R),!0}catch{return!1}}function X(R,M){m(Y=>{const se=[...Y];return se[R]=M,se})}function G(R,M){g(Y=>{const se=[...Y];return se[R]={...se[R]??In(),...M},se})}function P(R,M){switch(M){case $a:G(R,{contextWindow:"",contextWindowMode:"unset"});return;case Ro:{const Y=v[R]??In();G(R,{contextWindow:Y.contextWindow,contextWindowMode:"custom"});return}default:G(R,{contextWindow:M,contextWindowMode:"preset"});return}}function I(R,M){const Y=v[R]??In(),se=Vi(Y.contextWindow);G(R,{contextWindow:qu(M,se.unit),contextWindowMode:"custom"})}function F(R,M){const Y=v[R]??In(),se=Vi(Y.contextWindow);switch(M){case"K":case"M":case"tokens":G(R,{contextWindow:qu(se.amount,M),contextWindowMode:"custom"});return;default:return}}function re(R){m(M=>M.filter((Y,se)=>se!==R)),g(M=>M.filter((Y,se)=>se!==R))}function ne(){m(R=>[...R,""]),g(R=>[...R,In()])}function q(){const R=new Date().toISOString(),M=[];return h.forEach((Y,se)=>{const oe=Y.trim();if(oe==="")return;const ge=v[se]??In(),Ce=fo(ge.contextWindow),je=Gu(ge.outputLimit);if(Ce===null&&je===null)return;const ze=x0(e,oe);if(ze!==null&&ze.contextWindow===(Ce??void 0)&&ze.outputLimit===(je??void 0)){M.push({...ze,model:oe});return}const Be={model:oe,source:"manual",updatedAt:R};Ce!==null&&(Be.contextWindow=Ce),je!==null&&(Be.outputLimit=je),M.push(Be)}),M.length>0?M:e?.modelMetadata!==void 0?[]:void 0}function ae(R){if(R.preventDefault(),!!Ae()){D(!0);try{t({name:r.trim(),apiKey:i.trim(),models:h.map(M=>M.trim()).filter(M=>M!==""),anthropicBaseUrl:y.trim()||void 0,openaiBaseUrl:j.trim()||void 0,openaiResponsesBaseUrl:E.trim()||void 0,apiDocsUrl:z.trim()||void 0,modelMetadataUrl:O.trim()||void 0,modelMetadata:q(),source:T})}finally{D(!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:R=>o(R.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"}),_.name!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:_.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:R=>L(R.target.value==="company"||R.target.value==="personal"?R.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:R=>W(R.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"}),_.modelMetadataUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:_.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&&!xe&&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:i0(i),onChange:R=>a(R.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(R=>!R),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(ml,{className:"size-4"}):s.jsx(gl,{className:"size-4"})}),s.jsx("button",{type:"button",onClick:ke,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:u?s.jsx(Xe,{className:"size-4 text-cyan-300"}):s.jsx(Ft,{className:"size-4"})})]}),_.apiKey!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:_.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:"*"})]}),h.map((R,M)=>{const Y=v[M]??In(),se=_[`modelMetadata.${M}.contextWindow`],oe=_[`modelMetadata.${M}.outputLimit`],ge=v6(Y),Ce=Vi(Y.contextWindow);return s.jsxs("div",{ref:je=>{ue.current[M]=je},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:R,onChange:je=>X(M,je.target.value),placeholder:he.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"}),he.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:()=>Z(H===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(lt,{className:"size-4"})}),H===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:he.map(je=>s.jsx("button",{type:"button",onClick:()=>{X(M,je),Z(null)},className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-white/[0.06]",children:je},je))})]})]}),h.length>1&&s.jsx("button",{type:"button",onClick:()=>re(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(Co,{value:ge,onValueChange:je=>P(M,je),children:[s.jsx(To,{size:"sm",className:"w-full bg-background font-mono text-xs",children:s.jsx(No,{})}),s.jsxs(Eo,{className:"max-h-64",children:[s.jsx(Pt,{value:$a,children:"Not set"}),g0.map(je=>s.jsxs(Pt,{value:je.value,children:[je.label," · ",je.value]},je.value)),s.jsx(Pt,{value:Ro,children:"Custom"})]})]}),Y.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:Ce.amount,onChange:je=>I(M,je.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(Co,{value:Ce.unit,onValueChange:je=>F(M,je),children:[s.jsx(To,{size:"sm",className:"w-full bg-background font-mono text-xs",children:s.jsx(No,{})}),s.jsxs(Eo,{children:[s.jsx(Pt,{value:"K",children:"K"}),s.jsx(Pt,{value:"M",children:"M"}),s.jsx(Pt,{value:"tokens",children:"tokens"})]})]})]}),se!==void 0&&s.jsx("span",{className:"block text-destructive",children:se})]}),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:Y.outputLimit,onChange:je=>G(M,{outputLimit:je.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]"}),oe!==void 0&&s.jsx("span",{className:"block text-destructive",children:oe})]})]})]},M)}),s.jsx("button",{type:"button",onClick:ne,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),_.models!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:_.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(rt,{children:s.jsxs(Ue,{children:[s.jsx(We,{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(He,{children:"Anthropic Messages API format"})]})}),s.jsx(rt,{children:s.jsxs(Ue,{children:[s.jsx(We,{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(He,{children:"OpenAI Chat Completions API format"})]})})]}),_.format!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:_.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:R=>{U(!0),k(R.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:Ls})]}),_.anthropicBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:_.anthropicBaseUrl}),s.jsx(qi,{baseUrl:y,endpoint:Ls,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:R=>{B(!0),S(R.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:Ds})]}),_.openaiBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:_.openaiBaseUrl}),s.jsx(qi,{baseUrl:j,endpoint:Ds,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:R=>{Se(!0),N(R.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})]}),_.openaiResponsesBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:_.openaiResponsesBaseUrl}),s.jsx(qi,{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:z,onChange:R=>A(R.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(_e,{type:"button",variant:"outline",onClick:n,disabled:ee,children:"Cancel"}),s.jsx(_e,{type:"submit",disabled:ee,children:ee?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const _6=Ee(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),k6=J({message:C(),type:_6,details:C().optional(),hint:C().optional()}),j6=J({type:Ee(["text","thinking"]),text:C().optional(),thinking:C().optional()}),S6=J({requestUrl:C().optional(),requestMethod:C().optional(),requestHeaders:Ye(C(),C()).optional(),requestBody:C().optional(),responseStatus:K().optional(),responseStatusText:C().optional(),responseHeaders:Ye(C(),C()).optional(),responseBody:C().optional()}),C6=J({success:Le(),error:k6.optional(),model:C().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:fe(j6).optional(),rawResponse:C().optional(),streaming:Le().optional(),streamingChunks:J({chunks:fe(rf),truncated:Le().default(!1)}).optional(),requestHeaders:Ye(C(),C()).optional(),debug:S6.optional()}),Ku=Kt([C6,J({notConfigured:Te(!0)}),J({testing:Te(!0)})]),xn=J({nonStreaming:Ku,streaming:Ku});function Io(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const N6=J({anthropic:xn,openai:xn.optional(),openaiChat:xn.optional(),openaiResponses:xn.optional()}).transform(e=>{const t=e.openaiChat??e.openai??Io();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??Io()}}),T6=J({anthropic:xn,openai:xn.optional(),openaiChat:xn.optional(),openaiResponses:xn.optional(),models:Ye(C(),N6).optional(),testedAt:C().optional()}).transform(e=>{const t=e.openaiChat??e.openai??Io();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??Io()}});function E6(){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 Ju(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 A6=J({providerConfig:C()}),R6=J({success:Le().optional(),imported:K().optional(),message:C().optional(),errors:fe(C()).optional()}),I6=J({provider:po,imported:K(),matchedModels:fe(C()),missingModels:fe(C()),sourceUrl:C()}),Fs="Network error: could not reach the server. Is the proxy running?",z6=5e3,O6=5e3,Yu=15e3,P6=1e4,M6=2e4,L6=2e4,D6=3e4;function Xu(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 $6(e,t){const n=e?.models?.map(r=>r.trim()).filter(r=>r!=="").length??0;return Math.max(1,n)*t}async function F6(e,t){if(t.models!==void 0)try{await Pn(`/api/providers/${e}/test/log`,O6,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function B6({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,h]=p.useState(),[m,v]=p.useState(null),[g,x]=p.useState({}),[b,y]=p.useState(new Set),[k,j]=p.useState({}),[S,E]=p.useState(null),[N,z]=p.useState(!1),[A,O]=p.useState(null),[W,T]=p.useState(!1),[L,_]=p.useState(!1),[$,ee]=p.useState(null),[D,H]=p.useState("all"),[Z,ue]=p.useState(new Set),{providerTestTimeoutSeconds:V}=dl(),U=p.useRef(null),ce=p.useRef(null),B=e??[],Q=p.useMemo(()=>{const R=D==="all"?B:B.filter(M=>M.source===D);return D==="all"?[...R].sort((M,Y)=>{const se={personal:0,company:1};return(se[M.source??""]??2)-(se[Y.source??""]??2)}):R},[B,D]),Se=n??g,ie=r??b,pe=o??k,me=c?(R,M)=>c(R,M):(R,M)=>{j(M===void 0?Y=>{const se={...Y};return delete se[R],se}:Y=>({...Y,[R]:M}))};p.useEffect(()=>{(async()=>{try{const R=await Ke("/api/config/paths",A6,z6);E(R.providerConfig)}catch{}})()},[]);const he=p.useCallback(R=>{ce.current!==null&&clearTimeout(ce.current),O(R),U.current?.scrollTo({top:U.current.scrollHeight,behavior:"smooth"}),ce.current=setTimeout(()=>{O(null),ce.current=null},2e3)},[]);p.useEffect(()=>()=>{ce.current!==null&&clearTimeout(ce.current)},[]);const xe=p.useCallback(()=>{i?.().catch(()=>{})},[i]),ke=p.useCallback((R,M)=>{a?a(R,M):x(Y=>({...Y,[R]:M}))},[a]),Ae=p.useCallback((R,M)=>{if(l){l(R,M);return}y(Y=>{const se=new Set(Y);return M?se.add(R):se.delete(R),se})},[l]),w=p.useCallback(async R=>{ke(R,E6()),Ae(R,!0);const M=new AbortController,Y=B.find(Ce=>Ce.id===R),se=$6(Y,V);let oe=se;me(R,oe);const ge=setInterval(()=>{oe--,me(R,oe),oe<=0&&(clearInterval(ge),M.abort())},1e3);try{const Ce=await Ke(`/api/providers/${R}/test`,T6,se*1e3+1e3,{method:"POST",signal:M.signal},je=>`HTTP ${je.status}: ${je.statusText}`);ke(R,Ce),await F6(R,Ce)}catch(Ce){const je=Ce instanceof Error&&Ce.name==="AbortError",ze=Ce instanceof Bo;je||ze?ke(R,Ju("Request timed out","timeout")):Ce instanceof Error&&ke(R,Ju(Ce.message,"server_error"))}finally{clearInterval(ge),me(R,void 0),Ae(R,!1)}},[V,B,me,ke,Ae]),X=p.useCallback(async(R,M,Y=!0)=>{ue(se=>{const oe=new Set(se);return oe.add(R),oe});try{const se=M!==void 0&&M.trim()!==""?{url:M}:{},oe=await Ke(`/api/providers/${R}/model-metadata`,I6,D6,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(se)},()=>"Failed to refresh model metadata");return oe.imported===0&&Y?v("No matching model metadata found for this provider."):v(null),he(oe.provider.id),xe(),oe.imported>0}catch(se){return Y&&v(se instanceof Error?se.message:Fs),!1}finally{ue(se=>{const oe=new Set(se);return oe.delete(R),oe})}},[xe,he]);function G(R){(async()=>{try{const M=await Ke("/api/providers",po,Yu,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Xu(R))},()=>"Failed to add provider");d(!1),he(M.id),R.modelMetadataUrl!==void 0&&R.modelMetadataUrl.trim()!==""&&await X(M.id,R.modelMetadataUrl,!1),xe(),await w(M.id)}catch(M){v(M instanceof Error?M.message:Fs)}})()}function P(R){f&&(async()=>{try{const M=await Ke(`/api/providers/${f.id}`,po,Yu,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Xu(R))},()=>"Failed to update provider");h(void 0),he(M.id),R.modelMetadataUrl!==void 0&&R.modelMetadataUrl.trim()!==""&&await X(M.id,R.modelMetadataUrl,!1),xe(),((R.apiKey??"")!==(f.apiKey??"")||JSON.stringify(R.models)!==JSON.stringify(f.models)||(R.anthropicBaseUrl??"")!==(f.anthropicBaseUrl??"")||(R.openaiBaseUrl??"")!==(f.openaiBaseUrl??"")||(R.openaiResponsesBaseUrl??"")!==(f.openaiResponsesBaseUrl??""))&&await w(M.id)}catch(M){v(M instanceof Error?M.message:Fs)}})()}function I(R){ee(R),_(!0)}function F(){const R=$;R!==null&&(async()=>{let M;try{M=await Pn(`/api/providers/${R}`,P6,{method:"DELETE"})}catch{v(Fs);return}if(!M.ok){v(await nl(M,"Failed to delete provider"));return}xe()})()}const re=p.useRef(null);function ne(R){const M="/api/providers/export";(async()=>{try{const Y=await Pn(M,M6);if(!Y.ok){v("Failed to export providers");return}const se=await Y.blob(),oe=URL.createObjectURL(se),ge=document.createElement("a");ge.href=oe,ge.download=Y.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(ge),ge.click(),document.body.removeChild(ge),URL.revokeObjectURL(oe)}catch{v("Failed to export providers")}})()}function q(){re.current?.click()}function ae(R){const M=R.target.files?.[0];M&&(async()=>{try{const Y=await M.text(),se=await Pn("/api/providers/import",L6,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Y)}),oe=await tl(se,R6);se.ok&&oe.imported!==void 0&&oe.imported>0?(xe(),v(null)):oe.errors&&oe.errors.length>0?v(oe.errors.join("; ")):v(oe.message??"Import failed")}catch{v("Failed to import providers")}R.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(w6,{provider:f,onSubmit:f?P:G,onCancel:()=>{d(!1),h(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(rt,{children:s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>ne(),className:"gap-1 hover:bg-muted",children:[s.jsx(is,{className:"size-3"}),"Export"]})}),s.jsx(He,{children:"Download providers as JSON for backup or sharing"})]})}),s.jsx(rt,{children:s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsxs(_e,{variant:"outline",size:"sm",onClick:q,className:"gap-1 hover:bg-muted",children:[s.jsx(Of,{className:"size-3"}),"Import"]})}),s.jsx(He,{children:"Import providers from an exported JSON file"})]})}),s.jsx("input",{type:"file",ref:re,accept:".json",onChange:ae,style:{display:"none"}}),s.jsx(rt,{children:s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsxs(_e,{variant:"outline",size:"sm",onClick:()=>T(!0),className:"gap-1",children:[s.jsx(Ow,{className:"size-3"}),"Scan"]})}),s.jsx(He,{children:"Detect and import provider configs from Claude Code and OpenCode"})]})}),s.jsxs(_e,{onClick:()=>d(!0),size:"sm",className:"gap-1",children:[s.jsx(ia,{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(rt,{children:s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>{Lt(S).then(R=>{R&&(z(!0),setTimeout(()=>z(!1),2e3))})},className:"shrink-0 ml-auto text-muted-foreground hover:text-foreground transition-colors","aria-label":N?"Copied config file path":"Copy config file path",children:N?s.jsx(Xe,{className:"size-3 text-cyan-300"}):s.jsx(Ft,{className:"size-3"})})}),s.jsx(He,{children:"Copy config file path to clipboard"})]})})]}),m!==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(vr,{className:"size-4 shrink-0"}),m]}),B.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(_e,{onClick:()=>d(!0),variant:"outline",size:"sm",children:[s.jsx(ia,{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(R=>s.jsx(rt,{children:s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>H(R),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${D===R?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:R==="all"?"All":R==="personal"?"Personal":"Company"})}),s.jsx(He,{children:R==="all"?"Show all providers":R==="personal"?"Providers you configured yourself":"Providers set by your organization"})]})},R))}),s.jsx("div",{ref:U,className:"space-y-3",children:Q.map(R=>s.jsx(g6,{provider:R,testResults:Se[R.id],isTesting:ie.has(R.id),testingTimeLeft:pe[R.id],isHighlighted:R.id===A,onEdit:M=>h(M),onDelete:I,onRefreshMetadata:M=>{X(M)},isRefreshingMetadata:Z.has(R.id),onTest:M=>{w(M)}},R.id))})]}),s.jsx(VA,{open:W,onOpenChange:T,onImportComplete:()=>{i!==void 0&&i()}}),s.jsx(Ip,{open:L,onOpenChange:_,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:F})]})}function Qu(){const[e,t]=p.useState(!1),[n,r]=p.useState("providers"),{providers:o,isLoading:i,mutate:a}=Qf(),[l,c]=p.useState({}),[u,d]=p.useState(new Set),[f,h]=p.useState({}),m=p.useCallback((x,b)=>{c(y=>({...y,[x]:b}))},[]),v=p.useCallback((x,b)=>{d(y=>{const k=new Set(y);return b?k.add(x):k.delete(x),k})},[]),g=p.useCallback((x,b)=>{h(y=>{if(b===void 0){const k={...y};return delete k[x],k}return{...y,[x]:b}})},[]);return s.jsxs(qn,{open:e,onOpenChange:t,children:[s.jsx(Go,{asChild:!0,children:s.jsxs(_e,{variant:"ghost",size:"icon",className:mi,"aria-label":"Settings",title:"Settings",children:[s.jsx($w,{className:"size-4"}),s.jsx("span",{className:"sr-only",children:"Settings"})]})}),s.jsxs(Zn,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[s.jsx(Gn,{children:s.jsx(Kn,{children:"Settings"})}),s.jsxs(Dm,{value:n,onValueChange:r,className:"flex-1 overflow-hidden",children:[s.jsxs($m,{children:[s.jsx(jt,{value:"providers",children:"Providers"}),s.jsx(jt,{value:"proxy",children:"Proxy"}),s.jsx(jt,{value:"storage",children:"Storage"}),s.jsx(jt,{value:"mcp",children:"MCP"}),s.jsx(jt,{value:"onboarding",children:"Onboarding"})]}),s.jsxs("div",{className:"mt-4 flex-1 overflow-x-hidden overflow-y-auto pr-3",children:[s.jsx(St,{value:"providers",children:s.jsx(B6,{externalProviders:o,isLoading:i,externalTestResults:l,externalTestingProviders:u,externalTestingTimeLeft:f,onProvidersMutate:()=>a(),onTestResultsChange:m,onTestingProvidersChange:v,onTestingTimeLeftChange:g})}),s.jsx(St,{value:"proxy",children:s.jsx(Z6,{})}),s.jsx(St,{value:"storage",children:s.jsx(H6,{})}),s.jsx(St,{value:"mcp",children:s.jsx(q6,{})}),s.jsx(St,{value:"onboarding",children:s.jsx(V6,{})})]})]})]})]})}const U6=J({memoryCount:K(),logDir:C(),logFileCount:K(),logBytes:K(),chunkDir:C(),chunkFileCount:K(),chunkBytes:K(),sessionArchiveDir:C(),sessionArchiveFileCount:K(),sessionArchiveBytes:K()}),W6=1e4;function Zi(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 H6(){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 Ke("/api/logs?stats=1",U6,W6,void 0,f=>`Failed to load storage stats: HTTP ${String(f.status)}`);t(d)}catch(d){r(d instanceof Error?d.message:String(d))}finally{i(!1)}},[]);p.useEffect(()=>{c()},[c]);const u=p.useCallback((d,f)=>{Lt(f).then(h=>{h&&(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(_e,{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(Vr,{id:"log-dir",label:"Log storage path",value:e.logDir,copiedId:a,onCopy:u}),s.jsx(Vr,{id:"chunk-dir",label:"Streaming chunks storage path",value:e.chunkDir,copiedId:a,onCopy:u}),s.jsx(Vr,{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 / ",Zi(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 / ",Zi(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 /"," ",Zi(e.sessionArchiveBytes)]})]})]}),n!==null&&s.jsx("p",{className:"text-xs text-destructive",children:n})]})}function Vr({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(_e,{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(Xe,{className:"size-3.5 text-emerald-500"}):s.jsx(Ft,{className:"size-3.5"})})]})]})}function V6(){const[e,t]=p.useState(null),n=p.useMemo(()=>typeof window>"u"?"http://localhost:9527":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)=>{Lt(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(Cr,{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(Vr,{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(Xe,{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(Xe,{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(Xe,{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(Xe,{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(Xe,{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(Xe,{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 q6(){const[e,t]=p.useState(null),r=`${p.useMemo(()=>typeof window>"u"?"http://localhost:9527":window.location.origin,[])}/api/mcp`,o=p.useMemo(()=>[{id:"mcp-url",label:"Streamable HTTP MCP URL",value: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
- command = "agent-inspector-mcp"
106
- args = ["stdio", "--url", "${r}"]`}],[r]),i=p.useCallback((a,l)=>{Lt(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(Cr,{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(Vr,{id:a.id,label:a.label,value:a.value,copiedId:e,onCopy:i},a.id))})]})}function Z6(){const{strip:e,slowResponseThresholdSeconds:t,providerTestTimeoutSeconds:n,timeDisplayFormat:r,isLoading:o,setStrip:i,setSlowResponseThresholdSeconds:a,setProviderTestTimeoutSeconds:l,setTimeDisplayFormat:c}=dl(),[u,d]=p.useState(null),[f,h]=p.useState(!1),m=p.useCallback(async b=>{d(null),h(!0);try{await i(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{h(!1)}},[i]),v=p.useCallback(async b=>{d(null),h(!0);try{await a(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{h(!1)}},[a]),g=p.useCallback(async b=>{d(null),h(!0);try{await l(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{h(!1)}},[l]),x=p.useCallback(async b=>{d(null),h(!0);try{await c(b)}catch(y){d(y instanceof Error?y.message:String(y))}finally{h(!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=>{m(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:ra,step:1,value:t,disabled:o||f,onChange:b=>{const y=Number(b.currentTarget.value);Number.isInteger(y)&&(y<0||y>ra||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:sa,step:1,value:n,disabled:o||f,onChange:b=>{const y=Number(b.currentTarget.value);Number.isInteger(y)&&(y<1||y>sa||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=Cf.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]})]})}const G6=Ee(["installed","update-available","available","planned","unknown"]),K6=J({id:C(),name:C(),npmName:C(),capability:C(),description:C(),workflow:C(),installCommand:C(),state:G6,installedVersion:C().nullable(),latestVersion:C().nullable(),primary:Le()}),J6=J({id:C(),name:C(),validatedVersion:C(),binary:C(),modelFlag:C(),variantFlag:C().nullable(),tools:fe(C()),logDir:C(),skillsDir:C(),agentsDir:C()}),Y6=J({checkedAt:C(),packages:fe(K6),runnerPresets:fe(J6)}),X6=Ee(["install","upgrade","help","runner-presets"]),Q6=Ee(["queued","running","succeeded","failed"]),v0=J({id:C(),packageId:C(),npmName:C(),action:X6,status:Q6,command:C(),output:C(),createdAt:C(),startedAt:C().nullable(),finishedAt:C().nullable(),exitCode:K().nullable(),error:C().nullable()}),y0=J({task:v0});J({tasks:fe(v0)});const eR=[{id:"observe",title:"Observe",label:"Live",description:"Capture IDE, process, session, turn, request, response, tools, and providers.",metric:"Inspector core",icon:A2},{id:"replay",title:"Replay",label:"Ready",description:"Promote real logs into repeatable replay evidence without losing the raw context.",metric:"Session asset",icon:nn},{id:"evaluate",title:"Evaluate",label:"Next",description:"Use eval-harness to turn sessions into regression cases and provider bakeoffs.",metric:"Eval loop",icon:fl},{id:"connect",title:"Connect",label:"MCP",description:"Expose Inspector state to coding agents as queryable context and durable evidence.",metric:"/api/mcp",icon:mw}];async function tR(e){return Mt(e,Y6,void 0,t=>`Failed to load ecosystem packages: ${String(t.status)}`)}async function nR(e){return Mt(e,y0,void 0,t=>`Failed to load ecosystem task: ${String(t.status)}`)}async function rR(e,t){return(await Mt(`/api/ecosystem/packages/${encodeURIComponent(e)}/${t}`,y0,{method:"POST"},r=>`Failed to start ecosystem task: ${String(r.status)}`)).task}function sR(e){switch(e){case"installed":return"Installed";case"update-available":return"Update";case"available":return"Available";case"planned":return"Planned";case"unknown":return"Unknown"}}function oR(e){switch(e){case"installed":return"border-emerald-400/20 bg-emerald-400/8 text-emerald-200";case"update-available":return"border-amber-400/20 bg-amber-400/8 text-amber-200";case"available":return"border-sky-400/20 bg-sky-400/8 text-sky-200";case"planned":return"border-white/10 bg-white/[0.04] text-white/55";case"unknown":return"border-white/10 bg-white/[0.04] text-white/45"}}function iR(e){return e.installedVersion!==null&&e.latestVersion!==null?e.installedVersion===e.latestVersion?`v${e.installedVersion}`:`v${e.installedVersion} -> v${e.latestVersion}`:e.installedVersion!==null?`v${e.installedVersion}`:e.latestVersion!==null?`latest v${e.latestVersion}`:"not published"}function Qs(e){switch(e){case"install":return"Install";case"upgrade":return"Upgrade";case"help":return"Help";case"runner-presets":return"Presets"}}function aR(e){switch(e.status){case"queued":return"Queued";case"running":return`${Qs(e.action)} running`;case"succeeded":return`${Qs(e.action)} complete`;case"failed":return`${Qs(e.action)} failed`}}function lR(e){switch(e.state){case"available":return"install";case"update-available":return"upgrade";case"installed":case"planned":case"unknown":return null}}function cR({pkg:e,activeTask:t,onStartTask:n}){const r=lR(e),o=t!==null&&t.packageId===e.id&&t.status==="running";return s.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsx(vw,{className:"size-4 shrink-0 text-white/55"}),s.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),s.jsx("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:e.npmName})]}),s.jsx(Pe,{className:le("shrink-0",oR(e.state)),variant:"outline",children:sR(e.state)})]}),s.jsx("div",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:e.description}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[s.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/50",children:iR(e)}),s.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 text-white/45",children:e.capability}),s.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/35",children:e.installCommand})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[r!==null&&s.jsxs(_e,{type:"button",size:"sm",variant:"secondary",disabled:o,onClick:()=>n(e.id,r),children:[o?s.jsx(tt,{className:"size-3.5 animate-spin"}):s.jsx(is,{className:"size-3.5"}),Qs(r)]}),s.jsxs(_e,{type:"button",size:"sm",variant:"outline",disabled:o||e.state==="planned",onClick:()=>n(e.id,"help"),children:[s.jsx(Cr,{className:"size-3.5"}),"Help"]}),e.id==="eval-harness"&&s.jsxs(_e,{type:"button",size:"sm",variant:"ghost",disabled:o||e.state==="planned",onClick:()=>n(e.id,"runner-presets"),children:[s.jsx(fl,{className:"size-3.5"}),"Presets"]})]})]})}function uR({task:e}){if(e===null)return null;const t=e.status==="queued"||e.status==="running";return s.jsxs("section",{className:"mt-3 rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t?s.jsx(tt,{className:"size-4 animate-spin text-cyan-200/75"}):s.jsx(Cr,{className:"size-4 text-white/55"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-semibold",children:aR(e)}),s.jsx("div",{className:"break-all font-mono text-[11px] text-white/35",children:e.command})]})]}),s.jsx(Pe,{variant:"outline",className:le("shrink-0",e.status==="failed"?"border-red-400/20 bg-red-400/8 text-red-100":"border-cyan-300/20 bg-cyan-300/8 text-cyan-100"),children:e.status})]}),s.jsx("pre",{className:"mt-3 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-black/30 p-3 font-mono text-[11px] leading-5 text-white/60 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.output.trim().length>0?e.output:"Waiting for npm output..."}),e.error!==null&&s.jsx("div",{className:"mt-2 text-xs text-red-100",children:e.error})]})}function dR({workflow:e}){const t=e.icon;return s.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(t,{className:"size-4 shrink-0 text-cyan-200/75"}),s.jsx("div",{className:"text-sm font-semibold",children:e.title})]}),s.jsx("span",{className:"rounded bg-white/[0.04] px-2 py-0.5 font-mono text-[10px] text-white/45",children:e.label})]}),s.jsx("div",{className:"mt-2 min-h-10 text-xs leading-5 text-muted-foreground",children:e.description}),s.jsx("div",{className:"mt-3 font-mono text-[11px] text-white/35",children:e.metric})]})}function fR(e){return e===null?'npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke" --latest-log-limit 5':`npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke ${e}" --latest-log-limit 5`}function pR({preset:e}){return s.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsx(Sw,{className:"size-4 shrink-0 text-cyan-200/75"}),s.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),s.jsxs("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:[e.binary," ",e.modelFlag,e.variantFlag!==null?` ${e.variantFlag}`:""]})]}),s.jsxs(Pe,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:["v",e.validatedVersion]})]}),s.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px]",children:[s.jsxs("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:["logs/",e.logDir]}),s.jsx("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:e.tools.join(", ")}),s.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.skillsDir}),s.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.agentsDir})]})]})}function ed({currentSessionId:e,logCount:t}){const[n,r]=p.useState(!1),[o,i]=p.useState(!1),[a,l]=p.useState(!1),[c,u]=p.useState(null),[d,f]=p.useState(null),h=rn("/api/ecosystem/packages",tR,{revalidateOnFocus:!1,revalidateIfStale:!1}),m=rn(c===null?null:`/api/ecosystem/tasks/${c}`,nR,{refreshInterval:N=>{const z=N?.task;return z!==void 0&&(z.status==="queued"||z.status==="running")?900:0},revalidateOnFocus:!1}),v=h.data?.packages??[],g=h.data?.runnerPresets??[],x=p.useMemo(()=>v.filter(N=>N.state==="installed"||N.state==="update-available").length,[v]),b=fR(e),y="npx @tonyclaw/eval-harness runner-presets",k=()=>{Lt(b).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)})},j=()=>{Lt(y).then(()=>{l(!0),window.setTimeout(()=>l(!1),1200)})},S=m.data?.task??null;p.useEffect(()=>{S!==null&&S.status==="succeeded"&&h.mutate()},[S,h]);const E=(N,z)=>{f(null),rR(N,z).then(A=>{u(A.id),m.mutate({task:A},{revalidate:!0})}).catch(A=>{f(A instanceof Error?A.message:"Failed to start ecosystem task")})};return s.jsxs(qn,{open:n,onOpenChange:r,children:[s.jsx(Go,{asChild:!0,children:s.jsxs(_e,{variant:"ghost",size:"icon",className:mi,"aria-label":"TonyClaw Lab",title:"TonyClaw Lab",children:[s.jsx(qy,{className:"size-4"}),s.jsx("span",{className:"sr-only",children:"TonyClaw Lab"})]})}),s.jsxs(Zn,{className:"flex max-h-[84vh] max-w-5xl flex-col overflow-hidden",children:[s.jsx(Gn,{children:s.jsxs(Kn,{className:"flex items-center gap-2",children:[s.jsx(Vw,{className:"size-4 text-cyan-200/80"}),"TonyClaw Lab"]})}),s.jsxs("div",{className:"overflow-y-auto pr-2",children:[s.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.1fr_0.9fr]",children:[s.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-semibold",children:"Session asset pipeline"}),s.jsx("div",{className:"mt-1 max-w-2xl text-xs leading-5 text-muted-foreground",children:"Treat captured traffic as durable assets: observe it, replay it, evaluate it, and expose it back to agents through MCP."})]}),s.jsxs(Pe,{variant:"outline",className:"border-cyan-300/20 bg-cyan-300/8 text-cyan-100",children:[String(x),"/",String(v.length)," packages"]})]}),s.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:eR.map(N=>s.jsx(dR,{workflow:N},N.id))})]}),s.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-semibold",children:"Current session"}),s.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:e===null?"MCP smoke command":e})]}),s.jsxs(Pe,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:[String(t)," logs"]})]}),s.jsx("div",{className:"mt-4 rounded-md bg-black/20 p-3 font-mono text-[11px] leading-5 text-white/55 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:b}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[s.jsxs(_e,{size:"sm",variant:"secondary",onClick:k,children:[o?s.jsx(Xe,{className:"size-3.5"}):s.jsx(Ft,{className:"size-3.5"}),o?"Copied":"Copy"]}),s.jsxs(_e,{size:"sm",variant:"outline",onClick:j,children:[s.jsx(fl,{className:"size-3.5"}),a?"Presets copied":"Runner Presets"]})]})]})]}),s.jsxs("section",{className:"mt-3",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[s.jsx("div",{className:"text-sm font-semibold",children:"Runner presets"}),s.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[s.jsx(Cr,{className:"size-3.5"}),y]})]}),s.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[g.map(N=>s.jsx(pR,{preset:N},N.id)),h.isLoading&&g.length===0&&[0,1,2,3].map(N=>s.jsx("div",{className:"h-32 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},N))]})]}),s.jsxs("section",{className:"mt-3",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[s.jsx("div",{className:"text-sm font-semibold",children:"TonyClaw packages"}),h.isLoading&&s.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"checking npm..."})]}),h.error!==void 0&&s.jsx("div",{className:"rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:"Package status is temporarily unavailable."}),s.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[v.map(N=>s.jsx(cR,{pkg:N,activeTask:S,onStartTask:E},N.id)),h.isLoading&&v.length===0&&[0,1,2].map(N=>s.jsx("div",{className:"h-36 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},N))]})]}),d!==null&&s.jsx("div",{className:"mt-3 rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:d}),s.jsx(uR,{task:S})]})]})]})}function hR(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:td(i.cacheCreationInputTokens,a.cacheCreationInputTokens),read:td(i.cacheReadInputTokens,a.cacheReadInputTokens)})}}return t}function td(e,t){return t===null||e===null?null:t>e?{direction:"up",delta:t-e}:t<e?{direction:"down",delta:e-t}:null}function w0(e){return e.filter(t=>t.responseStatus===null).length}function _0(e){for(const t of e){const n=t.userAgent;if(n!=null&&n!=="")return n}return null}function mR(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function k0(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}function gR(e){return Nl({userAgent:_0(e.logs),conversationId:e.conversationId,clientProjectFolder:k0(e.logs)})}function xR(e){if(e===null||e==="")return"Unknown IDE";const t=e.split(/[ /;]/)[0]??"";return t===""?"Unknown IDE":t}function bR(e,t){const n=Ko(e);return n!==null?n:xR(t)}function zo(e){return e===null||e===""?"unknown":String(e)}function vR(e,t,n){return e!=="unknown"?e:`unknown:${zo(t)}:${zo(n)}`}function yR(e,t){return`${zo(e)}:${zo(t)}`}function Fa(e){return[...e].sort((t,n)=>t.timestamp.localeCompare(n.timestamp))}function nd(e){return Fa(e)[0]?.timestamp??""}function Gi(e){return[...e].sort((t,n)=>nd(t.logs).localeCompare(nd(n.logs)))}function wR(e){const t=new Map;for(const r of e){const o=_0(r.logs),i=k0(r.logs),a=gR(r),l=vR(a,o,i);let c=t.get(l);c===void 0&&(c={id:l,client:a,label:bR(a,o),userAgent:o,processes:new Map,logs:[]},t.set(l,c)),c.logs.push(...r.logs);const u=mR(r.logs),d=`${l}:${yR(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=Gi([...r.processes.values()].map(i=>({id:i.id,clientPid:i.clientPid,clientProjectFolder:i.clientProjectFolder,sessions:Gi(i.sessions),logs:Fa(i.logs)})));n.push({id:r.id,client:r.client,label:r.label,userAgent:r.userAgent,processes:o,logs:Fa(r.logs)})}return Gi(n)}function Oo(e){return e<=0?"0":Fe(e)}function j0(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 _R(e){let t=0;for(const n of e)t+=n.sessions.length;return t}function kR(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:le("bg-white/[0.045] 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 S0({count:e,label:t="Turn open"}){return s.jsxs("span",{className:"inline-flex h-6 shrink-0 items-center gap-1.5 rounded-md bg-amber-300/[0.10] px-1.5 font-mono text-[10px] uppercase tracking-[0.14em] text-amber-100/90 ring-1 ring-amber-200/10",title:`${e} turn${e!==1?"s":""} not finished yet`,children:[s.jsx(tt,{className:"size-3 animate-spin"}),t,e>1&&s.jsxs("span",{className:"tabular-nums",children:["x",e]})]})}function C0(){return s.jsx("span",{className:"pointer-events-none absolute inset-x-3 bottom-0 h-px overflow-hidden rounded-full bg-white/[0.06]","aria-hidden":"true",children:s.jsx("span",{className:"absolute inset-y-0 left-0 w-1/3 animate-pulse rounded-full bg-amber-200/65 shadow-[0_0_14px_rgba(252,211,77,0.32)]"})})}function jR({groups:e,...t}){const n=p.useMemo(()=>wR(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(SR,{group:u,collapsed:r.has(u.id),collapsedProcessIds:i,onToggleIde:()=>l(u.id),onToggleProcess:c,conversationProps:t},u.id))})}function SR({group:e,collapsed:t,collapsedProcessIds:n,onToggleIde:r,onToggleProcess:o,conversationProps:i}){const a=j0(e.logs),l=_R(e.processes),c=e.logs.length,u=w0(e.logs),d=u>0;return s.jsxs("section",{className:le("bg-card/75 shadow-sm relative isolate overflow-hidden rounded-[8px]",d&&"bg-card/85"),"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:"bg-white/[0.045] inline-flex size-10 shrink-0 items-center justify-center rounded-[8px] text-slate-200",children:s.jsx(dw,{className:"size-5"})}):s.jsx(Jo,{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 bg-cyan-300/[0.06] px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-[0.16em] text-cyan-100/75",children:"IDE"}),d&&s.jsx(S0,{count:u,label:"Turn open"})]}),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:Oo(a.inputTokens)}),s.jsx(Po,{label:"OUT",value:Oo(a.outputTokens)})]}),s.jsx("span",{className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-slate-200",children:t?s.jsx(Ct,{className:"size-4"}):s.jsx(lt,{className:"size-4"})})]}),d&&s.jsx(C0,{}),!t&&s.jsx("div",{className:"space-y-3 px-3 pb-3 pt-2 sm:px-4",children:e.processes.map(f=>s.jsx(CR,{group:f,collapsed:n.has(f.id),onToggle:()=>o(f.id),conversationProps:i},f.id))})]})}function CR({group:e,collapsed:t,onToggle:n,conversationProps:r}){const o=j0(e.logs),i=kR(e.clientProjectFolder),a=e.sessions.length,l=e.logs.length,c=w0(e.logs),u=c>0,d=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-1 left-2 top-1 w-px bg-white/[0.055]","aria-hidden":"true"}),s.jsxs("div",{className:"bg-black/[0.10] relative 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:"bg-white/[0.045] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-amber-100",children:s.jsx(Cy,{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:d}),u&&s.jsx(S0,{count:c,label:"Turn open"}),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(Gy,{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:Oo(o.inputTokens)}),s.jsx(Po,{label:"OUT",value:Oo(o.outputTokens)})]}),s.jsx("span",{className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-slate-200",children:t?s.jsx(Ct,{className:"size-4"}):s.jsx(lt,{className:"size-4"})})]}),u&&s.jsx(C0,{}),!t&&s.jsx("div",{className:"space-y-2 p-2 pt-1 sm:p-3 sm:pt-2",children:e.sessions.map(f=>s.jsx(PE,{group:f,...r,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},f.id))})]})]})}const Mo="data-nav-id",NR="data-nav-action";function rd(e){return Array.from(e.querySelectorAll(`[${Mo}]`))}function sd(e){return e instanceof HTMLElement}function TR(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 Ki(e){const t=e.getAttribute(NR);return t==="toggle"||t==="expand"||t==="collapse"?t:null}function Fr(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Br(e,t){return e[t]??null}function N0(e){const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function od(e){const t=e.tagName;return t==="BUTTON"||t==="A"||N0(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function ER(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function AR(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function Bs(e,t){return e.key===t&&e.shiftKey}function RR(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(!sd(u)||u!==c)return;const d=rd(l),f=Br(d,0);f!==null&&Fr(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(!sd(u)||N0(u)||AR())return;const d=c.contains(u);if(d&&od(u)&&!u.hasAttribute(Mo)||!d&&(!o||od(u)||ER(u)))return;const f=rd(c);if(f.length===0)return;const h=TR(u,c),m=h!==null?f.indexOf(h):-1;let v=!1;switch(l.key){case"ArrowUp":case"W":{if(l.shiftKey&&l.key==="ArrowUp"||l.key==="W"&&!Bs(l,"W"))break;l.preventDefault();const g=m>0?m-1:m===-1?f.length-1:-1;if(g!==-1){const x=Br(f,g);x!==null&&Fr(x)}v=!0;break}case"ArrowDown":case"S":{if(l.shiftKey&&l.key==="ArrowDown"||l.key==="S"&&!Bs(l,"S"))break;l.preventDefault();const g=m<f.length-1?m+1:m===-1?0:-1;if(g!==-1){const x=Br(f,g);x!==null&&Fr(x)}v=!0;break}case"ArrowLeft":case"A":{if(l.shiftKey&&l.key==="ArrowLeft"||l.key==="A"&&!Bs(l,"A")||h===null)break;if(l.preventDefault(),Ki(h)==="collapse")h.click();else if(m>0){const x=Br(f,m-1);x!==null&&Fr(x)}v=!0;break}case"ArrowRight":case"D":{if(l.shiftKey&&l.key==="ArrowRight"||l.key==="D"&&!Bs(l,"D")||h===null)break;if(l.preventDefault(),Ki(h)==="expand")h.click();else if(m<f.length-1){const x=Br(f,m+1);x!==null&&Fr(x)}v=!0;break}case" ":{if(h===null)break;l.preventDefault(),Ki(h)!==null&&h.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 IR={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},zR={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"},OR={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"},Ji=12,Us=1,id=80,ad=24;function PR(e){return e.length<=ad?e:`${e.slice(0,ad-3)}...`}function MR(e){const t=e.replace(/\s+/g," ").trim();return t.length<=id?t:`${t.slice(0,id)}...`}function Ws(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const LR=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,Ji),l=t.slice(Ji),c=l.reduce((x,b)=>x+b.size,0),u=l.length,d=Ji,f=d+u-1,h=u>0,m=o!==void 0,v=p.useMemo(()=>a.reduce((x,b)=>x+b.size,0),[a]),g=p.useMemo(()=>`Request context: ~${Fe(i)} tokens across ${t.length} segment${t.length===1?"":"s"}`,[t.length,i]);return t.length===0||i<=0?s.jsx("div",{role:"img","aria-label":g,className:"h-6"}):s.jsx(rt,{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,k=Math.max(Us,y),j=le("h-full border-r border-background/80 last:border-r-0",m?"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",zR[x.role],m?OR[x.role]:""),S={width:`${k}%`},E=`${x.label}, ${Ws(y)}, ~${Fe(x.size)} tokens`;return s.jsxs(Ue,{children:[s.jsx(We,{asChild:!0,children:m?s.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>o(x),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.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(He,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[s.jsxs("div",{className:"font-semibold",children:[x.label," - ",Ws(y)," - ~",Fe(x.size)," ","tokens"]}),s.jsx("div",{className:"text-muted-foreground",children:IR[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:MR(x.text)})]})]},`${x.path}-${b}`)}),h&&s.jsxs(Ue,{children:[s.jsx(We,{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(Us,c/i*100)}%`},children:["... +",u]})}),s.jsxs(He,{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,k=Math.max(Us,y);return s.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${k}%`},title:`${x.label} - ${Ws(y)} - ~${Fe(x.size)} tokens`,children:[s.jsx("span",{className:"truncate font-mono text-foreground/80",children:PR(x.label)}),s.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[Ws(y)," - ~",Fe(x.size)]})]},`label-${x.path}-${b}`)}),h&&s.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(Us,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:["~",Fe(c)]})]})]}),v<i*.1&&s.jsx("div",{className:"h-0"})]})})}),T0=.75,E0=.9,Ba=8e3,DR=.35,A0=40,R0=160,$R=5,FR=8,BR=18,UR=6e4,WR=.7,ld=3e3,HR=.3,cd=160,VR=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),qR=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],ZR=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],GR=[{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"]}],KR={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function JR(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 I0(e,t){for(const n of t){const r=JR(ye(e,n));if(r!==null)return r}return null}function YR(e){const t=ye(e,"model");if(typeof t!="string")return null;const n=t.trim();return n===""?null:n}function XR(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 QR(e,t,n=[]){const r=I0(t,qR);if(r!==null)return{tokens:r,label:"Request metadata",source:"request"};const o=KA(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 GR)if(XR(i,a))return{tokens:a.tokens,label:`${a.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function eI(e){return e<0?0:e>1?1:e}function tI(e){return e===null?"unknown":e>=E0?"danger":e>=T0?"watch":"ok"}function nI(e,t){return e.filter(n=>n.role===t).reduce((n,r)=>n+r.size,0)}function rI(e,t){return["system","user","assistant","tool","tools"].map(r=>{const o=nI(e,r);return{role:r,label:KR[r],tokens:o,percent:t>0?o/t:0}}).filter(r=>r.tokens>0).sort((r,o)=>o.tokens-r.tokens)}function Ua(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function sI(e){const t=e.replace(/\s+/g," ").trim();return t.length<=cd?t:`${t.slice(0,cd-3)}...`}function oI(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function iI(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function aI(e){const t=e.trim();return t.startsWith("{")||t.startsWith("[")}function lI(e){if(!aI(e))return null;try{return JSON.parse(e)}catch{return null}}function cI(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function uI(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 dI(e){const t=uI(e);return t===null?!1:VR.has(cI(t))}function fI(e){return e.map(t=>t.startsWith("[")?t:`.${t}`).join("").replace(/^\./,"")}function pI(e,t,n){const r=Kl(t);if(r<R0)return null;const o=Gl(t);return o<A0?null:{role:e.role,label:`${e.label} ${fI(n)}`,path:e.path,tokens:o,characters:r,text:t}}function Wa({value:e,segment:t,path:n,depth:r,candidates:o}){if(!(o.length>=FR)&&!(r>$R)){if(typeof e=="string"){if(!dI(n))return;const i=pI(t,e,n);i!==null&&o.push(i);return}if(Array.isArray(e)){e.forEach((i,a)=>Wa({value:i,segment:t,path:[...n,`[${String(a)}]`],depth:r+1,candidates:o}));return}Jl(e)&&Object.entries(e).forEach(([i,a])=>Wa({value:a,segment:t,path:[...n,i],depth:r+1,candidates:o}))}}function hI(e){const t=iI(e),n=lI(e.text);if(n===null)return[t];const r=[];Wa({value:n,segment:e,path:[],depth:0,candidates:r});const o=Ua(e.text),i=new Set([o]),a=r.filter(l=>{const c=Ua(l.text);return c===""||i.has(c)?!1:(i.add(c),!0)});return[t,...a]}function mI(e){const t=new Map;for(const r of e){const o=hI(r);for(const i of o){if(i.tokens<A0||i.characters<R0)continue;const a=Ua(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:sI(o.text),firstLabel:o.label,segments:r.candidates.map(oI)})}return n.sort((r,o)=>o.repeatedTokens-r.repeatedTokens||o.totalTokens-r.totalTokens)}function gI(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>=Ba?"danger":"watch",title:"Duplicate context",detail:`${String(n)} repeated blocks across ${String(t)} group${t===1?"":"s"}, ~${String(r)} repeated tokens.`}}function xI(e){return e.reduce((t,n)=>t+n.repeatedTokens,0)}function bI(e,t,n){const r=[],o=e.find(c=>c.role==="tools")??null;o!==null&&(o.tokens>=Ba||o.percent>=DR&&o.tokens>=ld)&&r.push({kind:"tool-schema",severity:o.tokens>=Ba?"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>=ld&&i.percent>=HR&&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>=BR&&(a>=UR||l>=WR)&&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 vI({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:xI(r)}}function yI({segments:e,inputTokens:t,parsed:n,model:r,providers:o=[]}){const i=e.reduce((E,N)=>E+N.size,0),a=r??YR(n),l=t??i,c=I0(n,ZR),u=QR(a,n,o),d=c??0,f=u.tokens===null?null:l+d,h=u.tokens===null?null:u.tokens-l,m=u.tokens===null?null:u.tokens-l-d,v=u.tokens===null||f===null?null:eI(f/u.tokens),g=rI(e,i),x=g[0]??null,b=e.filter(E=>E.role!=="tools").length,y=mI(e),k=gI(y),j=bI(g,i,b);k!==null&&j.unshift(k);const S=tI(v);return{model:a,contextWindow:u,estimatedInputTokens:l,outputReserveTokens:c,windowUsedTokens:f,remainingInputTokens:h,remainingAfterReserveTokens:m,usagePercent:v,riskLevel:S,roleUsages:g,largestRole:x,diagnostics:j,duplicateGroups:y,health:vI({risk:S,contextWindow:u,diagnostics:j,duplicateGroups:y})}}const L8={watch:T0,danger:E0},ud=new WeakMap;function wI(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 _I(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function kI(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function jI(e,t){const n=_I(e.rawRequestBody);if(n===null)return null;const o=Rm(Qr(e)).anatomySegments(n);if(o===null)return null;const i=yI({segments:o,inputTokens:e.inputTokens??null,parsed:n,model:e.model,providers:t}),a=i.model??e.model??"Unknown model",l=i.roleUsages.map(kI);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 SI(e,t,n){const r=ud.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=jI(e,t);return ud.set(e,{id:e.id,rawRequestBody:e.rawRequestBody,inputTokens:e.inputTokens,model:e.model,path:e.path,apiFormat:e.apiFormat,timestamp:e.timestamp,providersSignature:n,snapshot:o}),o}function CI(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 dd(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function NI(e,t){const n=dd(t.latest.riskLevel)-dd(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 TI(e,t){return e.usagePercent===null||t.usagePercent===null?null:(t.usagePercent-e.usagePercent)*100}function EI(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 AI(e,t=[]){const n=EI(e),r=wI(t),o=new Map;for(const a of n){const l=SI(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:CI(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:TI(a.first,a.latest)})).sort(NI)}}function en(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function RI(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 fd(e,t){return t.get(e.id)??e.id}function II(e){return e==="full"}function zI(e,t){const n=t>0;return{redacted:n,raw:n&&II(e)}}function pd(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 z0(e,t){const n=e[0],r=e[e.length-1];return n===void 0||r===void 0?null:bl(n.timestamp,r.timestamp,t)}function OI(e){for(const t of e)if(t.userAgent!==null&&t.userAgent!==void 0&&t.userAgent!=="")return t.userAgent;return null}function PI(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function MI(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 LI(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 DI(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 $I(e,t){return`${Fe(e)} in / ${Fe(t)} out`}function FI(e,t){if(e.length===0)return 0;if(t.length===0)return Oa(e).length;let n=0;for(const r of t)n+=Oa(r.logs).length;return n}function BI({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 UI(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 WI({pending:e,failures:t,lengthStops:n,stopReason:r,lastFailure:o}){if(o!==null&&(o.status===499||UI(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 HI({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,h=null,m=null,v=null,g=null,x=0,b=0,y=0,k=null;const j=o*1e3;for(let A=0;A<e.length;A+=1){const O=e[A];if(O===void 0)continue;const W=A+1,T=Lf(O);T!==null&&(f=T),T==="length"&&(c+=1),PI(O)&&(i+=1,h=W,m={logNumber:W,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=W);const L=O.inputTokens??0,_=O.outputTokens??0,$=L+_;$>x&&(x=$,b=L,y=_,k=W)}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",N=BI({stopReason:f,pending:a,lastFailureLogNumber:h}),z=WI({pending:a,failures:i,lengthStops:c,stopReason:f,lastFailure:m});return{status:S,statusLabel:E,modelLabel:MI(e),providerLabel:LI(e),requests:e.length,turns:FI(e,t),failures:i,pending:a,slow:l,lengthStops:c,timeRange:z0(e,r),tokenLabel:`${Fe(u)} in / ${Fe(d)} out`,finishLabel:N.label,finishDetail:N.detail,finishTone:N.tone,outcomeLabel:z.label,outcomeDetail:z.detail,outcomeTone:z.tone,slowestLabel:v===null?"n/a":DI(v),slowestDetail:g===null?"Latency pending":`Request #${g}`,heaviestDetail:k===null?"Tokens pending":`#${k} ${$I(b,y)}`}}function VI(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 qI(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function ZI(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 ar({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",VI(o)),children:t}),s.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:n})]})}function GI({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(hy,{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(ar,{label:"Status",value:e.statusLabel,detail:ZI(e),tone:qI(e.status)}),s.jsx(ar,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:s.jsx(Hy,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),s.jsx(ar,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:s.jsx(aa,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),s.jsx(ar,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:s.jsx(Gw,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),s.jsx(ar,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:s.jsx(xl,{className:"size-3 text-muted-foreground"})}),s.jsx(ar,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function KI({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 qr(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 JI(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function Ha(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=Ha(e),r=Ha(t);return r<=0||Math.abs(r-n)<.5?null:r}function XI(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 QI(e){const t=e.latest.contextWindow.tokens;return t===null?"Context window unknown":`Context window ${Xf(t)}`}const e8=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function O0(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 Yi(e,t){if(e===null)return null;const n=e.metadata[t];return n===void 0?null:O0(n)}function t8(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 n8(e){const t=[];for(const n of e8){const r=e.metadata[n];if(r===void 0)continue;const o=O0(r);o!==null&&t.push({key:n,value:o})}return t}function hd({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=Yi(i,"score"),l=Yi(i,"decision"),c=Yi(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]",t8(d.value)),children:d.label},d.label))})]}),n?s.jsx(pl,{className:"size-4 shrink-0 text-muted-foreground"}):s.jsx(lt,{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,h=n8(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:en(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 ",en(f.runId)]})]}),h.length>0&&s.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:h.map(m=>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:m.key}),s.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:m.value,children:m.value})]},m.key))})]},`${d.groupId}:${f.id}`)})})]})}function r8({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}`;return t.total===null?`Showing ${e.length} logs (${o})`:t.total<=e.length?`Showing all ${t.total} logs`:`Showing ${e.length} of ${t.total} logs (${o})`}function Hs({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 s8(e){return`${Math.max(0,Math.ceil(e/1e3)).toString()}s`}function eo({progress:e}){const t=Math.min(1,e.elapsedMs/e.timeoutMs),n=Math.max(4,Math.round(t*100)),r=Math.max(0,e.timeoutMs-e.elapsedMs),o=t>=.75,i=[e.loadedLogs>0?`${e.loadedLogs.toString()} logs`:null,e.loadedPages>0?`${e.loadedPages.toString()} page${e.loadedPages===1?"":"s"}`:null,`${s8(r)} before timeout`].filter(a=>a!==null);return s.jsxs("div",{className:"min-w-0 space-y-1 px-1 pb-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 font-mono text-[10px] text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 truncate",children:e.label}),s.jsx("span",{className:le("shrink-0 tabular-nums",o&&"text-amber-300"),children:i.join(" / ")})]}),s.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-white/[0.06]",children:s.jsx("div",{className:le("h-full rounded-full transition-all duration-300",o?"bg-amber-300/80":"bg-cyan-300/70"),style:{width:`${n.toString()}%`}})})]})}function md({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:[r8({logs:e,pagination:t}),t.isLoading&&e.length>0&&s.jsx("span",{className:"ml-2",children:"Loading..."}),t.loadProgress!==void 0&&s.jsx(eo,{progress:t.loadProgress})]}),s.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[s.jsx(Hs,{label:"Oldest",title:"Load the oldest logs in this session",icon:s.jsx(ny,{className:"size-3.5"}),disabled:r||!t.hasOlder,onClick:t.onOldest}),s.jsx(Hs,{label:"Older",title:"Load older logs",icon:s.jsx(J2,{className:"size-3.5"}),disabled:r||!t.hasOlder,onClick:t.onOlder}),s.jsx(Hs,{label:"Newer",title:"Load newer logs",icon:s.jsx(Ct,{className:"size-3.5"}),disabled:r||!t.hasNewer,onClick:t.onNewer}),s.jsx(Hs,{label:"Newest",title:"Load the newest logs in this session",icon:s.jsx(sy,{className:"size-3.5"}),disabled:r||!t.hasNewer,onClick:t.onNewest})]})]})}function o8(e){return`${e} ${e===1?"request":"requests"}`}function gd(e){return`#${String(e)}`}function xd(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 i8(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 a8(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const l8=10,c8=80;function u8(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function d8(e){const t=document.getElementById(`log-${String(e)}`);return t instanceof HTMLElement?(t.scrollIntoView({block:"center",behavior:"smooth"}),t.focus({preventScroll:!0}),u8(t),!0):!1}function P0(e){ts({logId:e,tab:"anatomy"});let t=0;const n=()=>{ts({logId:e,tab:"anatomy"}),!d8(e)&&(t+=1,t<l8&&window.setTimeout(n,c8))};window.setTimeout(n,0)}function bd({command:e}){const[t,n]=p.useState(!1),r=p.useCallback(()=>{Lt(e).then(o=>{o&&(n(!0),setTimeout(()=>n(!1),2e3))})},[e]);return s.jsxs("div",{className:"bg-black/20 inline-flex max-w-full items-center gap-2 rounded-md px-3 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[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(Xe,{className:"size-4"}):s.jsx(Ft,{className:"size-4"})})]})}function Xi({label:e,children:t,className:n}){return s.jsxs("section",{className:le("bg-white/[0.028] shadow-[inset_0_1px_0_rgba(255,255,255,0.035)] rounded-[8px]",n),children:[s.jsx("div",{className:"px-3 pt-3",children:s.jsx("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-white/35",children:e})}),s.jsx("div",{className:"p-3 pt-2",children:t})]})}function Vs({label:e,value:t}){return s.jsxs("div",{className:"bg-black/20 min-w-0 rounded-md px-2 py-2 shadow-[inset_0_1px_0_rgba(255,255,255,0.035)]",children:[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 f8=["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 vd({compact:e,entrancePhase:t}){return e?s.jsx(Au,{className:"size-14 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:ns.map((n,r)=>{const o=f8[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 p8({compact:e,crabEntrancePhase:t,currentSessionId:n,logCount:r}){return e?s.jsx("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_16px_44px_rgba(0,0,0,0.18)] rounded-[8px] p-3",children:s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"flex min-w-fit items-start gap-3",children:[s.jsx(vd,{compact:!0,entrancePhase:t}),s.jsxs("div",{className:"min-w-fit",children:[s.jsxs("div",{className:"flex min-w-fit flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[s.jsx("span",{className:"whitespace-nowrap text-base font-bold",children:"Agent Inspector"}),s.jsxs("span",{className:"hidden shrink-0 font-mono text-[11px] font-semibold text-muted-foreground sm:inline",children:["v",ca.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(Ru,{}),s.jsx(zu,{}),s.jsx(ed,{currentSessionId:n,logCount:r}),s.jsx(Qu,{})]})]})}):s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-3 pb-6",children:[s.jsx("div",{className:"min-w-10 flex-1","aria-hidden":"true"}),s.jsxs("h1",{className:"flex min-w-fit flex-col items-center gap-2 text-center",children:[s.jsxs("span",{className:"flex max-w-full flex-wrap items-end justify-center gap-x-2 gap-y-1",children:[s.jsx(vd,{compact:!1,entrancePhase:t}),s.jsxs("span",{className:"flex min-w-fit flex-wrap items-baseline justify-center gap-x-2 gap-y-0.5 pl-1",children:[s.jsx("span",{className:"whitespace-nowrap text-lg font-bold",children:"Agent Inspector"}),s.jsxs("span",{className:"shrink-0 font-mono text-xs font-semibold text-muted-foreground",children:["v",ca.version]})]}),s.jsx(ia,{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-full text-sm font-semibold text-muted-foreground",children:"Local First. Evidence First."})]}),s.jsxs("div",{className:"flex flex-1 justify-end gap-1",children:[s.jsx(Ru,{}),s.jsx(zu,{}),s.jsx(ed,{currentSessionId:n,logCount:r}),s.jsx(Qu,{})]})]})}function yd({label:e,logId:t}){return s.jsxs("button",{type:"button",onClick:()=>P0(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 ${gd(t)}`,children:[e," ",gd(t)]})}function h8({latestPercent:e,peakPercent:t,risk:n,onOpenContext:r}){const o=Ha(e),i=YI(e,t),a=t===null?`Latest context window usage ${qr(e)}`:`Latest context window usage ${qr(e)}, peak ${qr(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]",XI(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 m8({summary:e}){const t=e.trendPercent,n=t===null||Math.abs(t)<.1?null:t>0?D2:I2,r=e.latest.diagnostics[0]??null,o=qr(e.latest.usagePercent),i=qr(e.peak.usagePercent),a=()=>{P0(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]",i8(e.latest.health.level)),children:a8(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:o8(e.requestCount)}),s.jsx("span",{children:QI(e)})]})]}),s.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[s.jsx(h8,{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",xd(e.latest.riskLevel)),children:o}),s.jsx(yd,{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",xd(e.peak.riskLevel)),children:i}),s.jsx(yd,{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")}),JI(t)]}),s.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),s.jsxs("div",{className:"min-w-0 space-y-1.5",children:[s.jsx(LR,{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:["~",Fe(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&s.jsxs("span",{className:"font-mono",children:["~",Fe(e.latest.windowUsedTokens)," used"]}),r!==null&&s.jsx("span",{className:"truncate",children:r})]})]})]})}function g8({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(m8,{summary:t},t.model))})]})}function x8(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 b8({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(()=>z0(t,o),[t,o]),h=p.useMemo(()=>OI(t),[t]),m=p.useMemo(()=>x8(i),[i]),v=p.useCallback(()=>{Lt(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:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":"Back to all sessions",title:"Back to all sessions",children:s.jsx(M2,{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:en(e)}),h!==null&&s.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:h,children:h})]}),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:[Fe(n)," in / ",Fe(r)," out"]})]})]}),i.models.length>0&&s.jsxs("button",{type:"button",onClick:()=>d(g=>!g),className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 font-mono text-[11px] text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-expanded":u,title:u?"Hide context details":"Show context details",children:[s.jsx("span",{children:m}),u?s.jsx(pl,{className:"size-3.5"}):s.jsx(lt,{className:"size-3.5"})]}),s.jsx("button",{type:"button",onClick:v,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":l?"Copied session link":"Copy session link",title:l?"Copied session link":"Copy session link",children:l?s.jsx(Xe,{className:"size-3.5"}):s.jsx(Ft,{className:"size-3.5"})})]}),u&&s.jsx(g8,{summary:i})]})}function v8({logs:e,sessions:t,models:n,selectedSession:r,selectedModel:o,onSessionChange:i,onModelChange:a,onClearAll:l,onDeleteCurrentView:c,onReloadSession:u,onClearGroup:d,onNotify:f,onImportLogs:h,viewMode:m,captureMode:v,strip:g,slowResponseThresholdSeconds:x,timeDisplayFormat:b,isLoading:y=!1,pagination:k,sessionLoadProgress:j,sessionMemberships:S=[],hideSessionFilter:E=!1,pinnedSessionId:N}){const{totalIn:z,totalOut:A}=p.useMemo(()=>pd(e),[e]),{providers:O}=Qf(),[W,T]=p.useState(null),[L,_]=p.useState(null),[$,ee]=p.useState(!1),[D,H]=p.useState(null),[Z,ue]=p.useState(null),[V,U]=p.useState(!1),[ce,B]=p.useState(!1),[Q,Se]=p.useState(!1),[ie,pe]=p.useState(null),[me,he]=p.useState("hidden"),xe=p.useRef(null),ke=p.useRef(null),Ae=p.useRef(null),w=p.useRef(null),X=p.useRef(0);RR(xe,ke,{pageWide:!0});const G=p.useCallback(()=>{X.current+=1,w.current?.abort(),w.current=null,T(null),_(null)},[]);p.useEffect(()=>()=>{X.current+=1,w.current?.abort(),w.current=null},[]),p.useEffect(()=>{const bt=50+ns.length*400,It=setTimeout(()=>he("playing"),50),hs=setTimeout(()=>he("done"),bt);return()=>{clearTimeout(It),clearTimeout(hs)}},[]),p.useEffect(()=>{if(N===void 0){document.title="Agent Inspector";return}const Me=e.length===1?"1 req":`${e.length} req`;document.title=`${en(N)} - ${Me} - Agent Inspector`},[e.length,N]);const P=p.useCallback(async Me=>{w.current?.abort();const ct=new AbortController;w.current=ct;const bt=X.current+1;X.current=bt,T(Me),_(null);try{const It=await S_(e,Me,{signal:ct.signal});if(X.current!==bt)return;if(!It.ok){if(It.canceled===!0)return;f!==void 0?f({message:It.message,tone:"error"}):_(It.message)}}finally{X.current===bt&&(w.current=null,T(null))}},[e,f]),I=p.useCallback(()=>{Ae.current?.click()},[]),F=p.useCallback(Me=>{const ct=Me.currentTarget.files?.[0];Me.currentTarget.value="",!(ct===void 0||h===void 0)&&(ee(!0),ue(null),H(null),h(ct).then(bt=>{const It=bt.skipped>0?`, skipped ${String(bt.skipped)}`:"",hs=`Imported ${String(bt.imported)} logs as ${bt.sessionId}${It}.`;f!==void 0?f({message:hs,tone:"success"}):H(hs)}).catch(bt=>{const It=bt instanceof Error?bt.message:"Failed to import logs";f!==void 0?f({message:It,tone:"error"}):ue(It)}).finally(()=>{ee(!1)}))},[h,f]);p.useEffect(()=>{G(),pe(null)},[G,r,o]);const re=p.useCallback(()=>{G(),H(null),ue(null),pe(null),l()},[G,l]),ne=p.useCallback(()=>{B(!1),U(!0)},[]),q=p.useCallback(()=>{if(G(),H(null),ue(null),pe(null),!ce||c===void 0){U(!1),l();return}Se(!0),c(e.map(Me=>Me.id)).then(()=>{U(!1)}).catch(Me=>{const ct=Me instanceof Error?Me.message:"Failed to delete stored logs";f!==void 0?f({message:ct,tone:"error"}):ue(ct)}).finally(()=>{Se(!1)})},[G,ce,e,l,c,f]),ae=p.useCallback(()=>{u!==void 0&&(G(),H(null),ue(null),pe(null),u())},[G,u]),R=p.useCallback(()=>{pe(null)},[]),M=p.useMemo(()=>J3(e),[e]),Y=p.useMemo(()=>RI(M),[M]),se=p.useMemo(()=>KI({pinnedSessionId:N,selectedSession:r,sessions:t,logs:e}),[e,N,r,t]),oe=se?.logs??[],ge=se!==null&&oe.length>0,{totalIn:Ce,totalOut:je}=p.useMemo(()=>pd(oe),[oe]),ze=p.useMemo(()=>AI(oe,O),[oe,O]),Be=p.useMemo(()=>hR(M),[M]),Rt=p.useMemo(()=>HT(M),[M]),cn=zI(v,e.length),gt=N!==void 0,ot=e.length>0,Xt=e.length===0?"Load":"Reload",Yn=r==="__all__"?"":r,$e=r==="__all__"||t.includes(r)?r:"__typed__",pt=ge&&se!==null?en(se.label):r==="__all__"?"All sessions":en(r),et=p.useMemo(()=>HI({logs:e,conversationGroups:M,isLoading:y,timeDisplayFormat:b,slowResponseThresholdSeconds:x}),[M,y,e,x,b]),Ut=p.useCallback(Me=>{const ct=Rt.get(Me.id);ct!==void 0&&pe([ct,Me])},[Rt]),xt=p.useCallback(Me=>{const ct=Me.currentTarget.value.trim();i(ct===""?"__all__":ct)},[i]),Ir=p.useCallback(Me=>{Me!=="__typed__"&&i(Me)},[i]),M0=N!==void 0?N:r==="__all__"?null:r;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-[minmax(0,1fr)_340px] xl:grid-cols-[minmax(0,1fr)_360px]",children:[s.jsx("aside",{className:"bg-background/95 order-1 border-b border-white/[0.045] lg:sticky lg:top-0 lg:order-2 lg:h-screen lg:overflow-y-auto lg:border-b-0 lg:border-l lg:border-white/[0.055]",children:s.jsxs("div",{className:"space-y-4 p-4",children:[s.jsx(p8,{compact:!0,crabEntrancePhase:me,currentSessionId:M0,logCount:e.length}),s.jsxs(Xi,{label:"Session",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(Vs,{label:"Requests",value:e.length}),s.jsx(Vs,{label:"Sessions",value:t.length}),s.jsx(Vs,{label:"Input",value:Fe(ge?Ce:z)}),s.jsx(Vs,{label:"Output",value:Fe(ge?je:A)})]}),s.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-2",children:[u!==void 0&&s.jsxs("button",{type:"button",onClick:ae,disabled:y,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 min-w-0 items-center justify-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",title:"Load stored logs for this session",children:[s.jsx(nn,{className:le("size-3.5",y&&"animate-spin")}),s.jsx("span",{children:Xt})]}),s.jsxs("button",{type:"button",onClick:re,disabled:!ot,className:le("bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 min-w-0 items-center justify-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",u===void 0&&c===void 0&&"col-span-2"),title:"Clear the current view. Stored logs remain reloadable.",children:[s.jsx(Ht,{className:"size-3.5"}),s.jsx("span",{children:"Clear"})]}),c!==void 0&&s.jsxs("button",{type:"button",onClick:ne,disabled:!ot||Q,className:"bg-red-500/[0.07] hover:bg-red-500/[0.12] inline-flex h-8 min-w-0 items-center justify-center gap-1.5 rounded-md px-2 text-xs text-red-200 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.14)] transition-colors hover:text-red-100 disabled:cursor-not-allowed disabled:opacity-50",title:"Choose whether to delete stored data for the current view.",children:[s.jsx(Ht,{className:"size-3.5"}),s.jsx("span",{children:"Delete"})]})]}),j!==void 0&&s.jsx("div",{className:"mt-2 rounded-md bg-black/20 px-2 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:s.jsx(eo,{progress:j})})]}),s.jsx(Xi,{label:"Workspace",children:s.jsxs("div",{className:"bg-black/20 rounded-md px-3 py-2 shadow-[inset_0_1px_0_rgba(255,255,255,0.035)]",children:[s.jsx("div",{className:"truncate font-mono text-xs font-semibold text-cyan-100",title:pt,children:pt}),s.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:gt?"Session workspace":"Live workspace"})]})}),ge&&se!==null&&s.jsx(b8,{label:se.label,logs:oe,totalIn:Ce,totalOut:je,timeDisplayFormat:b,contextSummary:ze,showBackLink:se.showBackLink}),ge&&N!==void 0&&S.length>0&&s.jsx(hd,{memberships:S}),s.jsx(Xi,{label:"Filters",children:s.jsxs("div",{className:"space-y-2",children:[!E&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative",children:[s.jsx(zf,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{type:"search",value:Yn,onChange:xt,placeholder:"Paste session ID",className:"bg-black/25 hover:bg-white/[0.045] focus-visible:ring-ring h-9 w-full rounded-md px-8 font-mono text-xs text-foreground outline-none shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors placeholder:font-sans placeholder:text-muted-foreground focus-visible:ring-1","aria-label":"Filter by session ID",title:"Filter by exact session ID"}),Yn!==""&&s.jsx("button",{type:"button",onClick:()=>i("__all__"),className:"absolute right-1.5 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground","aria-label":"Clear session filter",title:"Clear session filter",children:s.jsx(ls,{className:"size-3.5"})})]}),s.jsxs(Co,{value:$e,onValueChange:Ir,children:[s.jsx(To,{className:"bg-black/25 hover:bg-white/[0.045] h-9 w-full border-0 text-xs text-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:s.jsx(No,{placeholder:"All sessions"})}),s.jsxs(Eo,{children:[s.jsx(Pt,{value:"__all__",children:"All sessions"}),$e==="__typed__"&&s.jsxs(Pt,{value:"__typed__",children:["Typed: ",en(r)]}),t.map(Me=>s.jsx(Pt,{value:Me,children:en(Me)},Me))]})]})]}),s.jsxs(Co,{value:o,onValueChange:a,children:[s.jsx(To,{className:"bg-black/25 hover:bg-white/[0.045] h-9 w-full border-0 text-xs text-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:s.jsx(No,{placeholder:"All models"})}),s.jsxs(Eo,{children:[s.jsx(Pt,{value:"__all__",children:"All models"}),n.map(Me=>s.jsx(Pt,{value:Me,children:Me},Me))]})]})]})})]})}),s.jsxs("main",{className:"order-2 min-w-0 lg:order-1",children:[s.jsxs("div",{className:"bg-background/95 shadow-[0_12px_36px_rgba(0,0,0,0.18),inset_0_-1px_0_rgba(255,255,255,0.045)] sticky top-0 z-30 px-4 py-3 lg:px-5",children:[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:pt})]}),h!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:Ae,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:F}),s.jsx("button",{type:"button",onClick:I,disabled:$,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",title:"Import Agent Inspector export",children:$?s.jsx("span",{children:"Importing..."}):s.jsxs(s.Fragment,{children:[s.jsx(Of,{className:"size-3.5"}),s.jsx("span",{children:"Import"})]})})]}),cn.redacted&&s.jsx("button",{type:"button",onClick:()=>{P("redacted")},disabled:W!==null,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",title:"Export redacted logs as JSON ZIP",children:W==="redacted"?s.jsx("span",{children:"Exporting..."}):s.jsxs(s.Fragment,{children:[s.jsx(is,{className:"size-3.5"}),s.jsx("span",{children:"Export"})]})}),cn.raw&&s.jsx("button",{type:"button",onClick:()=>{P("raw")},disabled:W!==null,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",title:"Export raw logs without redaction",children:W==="raw"?s.jsx("span",{children:"Exporting..."}):s.jsxs(s.Fragment,{children:[s.jsx(Oy,{className:"size-3.5"}),s.jsx("span",{children:"Raw"})]})}),u!==void 0&&s.jsxs("button",{type:"button",onClick:ae,disabled:y,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",title:"Reload this session from stored logs",children:[s.jsx(nn,{className:le("size-3.5",y&&"animate-spin")}),s.jsx("span",{children:Xt})]}),s.jsxs("button",{type:"button",onClick:re,disabled:!ot,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",title:"Clear the current view. Stored logs remain reloadable.",children:[s.jsx(Ht,{className:"size-3.5"}),s.jsx("span",{children:"Clear"})]}),c!==void 0&&s.jsxs("button",{type:"button",onClick:ne,disabled:!ot||Q,className:"bg-red-500/[0.07] hover:bg-red-500/[0.12] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-red-200 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.14)] transition-colors hover:text-red-100 disabled:cursor-not-allowed disabled:opacity-50",title:"Choose whether to delete stored data for the current view.",children:[s.jsx(Ht,{className:"size-3.5"}),s.jsx("span",{children:"Delete"})]})]}),k===void 0&&j!==void 0&&s.jsx("div",{className:"mt-2 rounded-md bg-black/20 px-2 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:s.jsx(eo,{progress:j})}),s.jsx(md,{logs:e,pagination:k,embedded:!0}),f===void 0&&L!==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:L}),f===void 0&&Z!==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:Z}),f===void 0&&D!==null&&Z===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:D})]}),s.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[s.jsx(GI,{stats:et}),e.length===0?r!=="__all__"?s.jsx("div",{className:"py-16 text-center text-muted-foreground",children:s.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-xl space-y-4 rounded-[8px] px-4 py-8",children:[s.jsx("p",{className:"text-sm font-medium",children:y?"Loading session data...":"No logs loaded for this session"}),s.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:en(r)}),j!==void 0&&s.jsx("div",{className:"mx-auto max-w-md rounded-md bg-black/20 px-2 py-2 text-left shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:s.jsx(eo,{progress:j})}),S.length>0&&s.jsx("div",{className:"text-left",children:s.jsx(hd,{memberships:S})}),!y&&s.jsxs("div",{className:"flex flex-col items-center gap-3 text-xs",children:[s.jsx("p",{children:"Stored logs may still be available."}),s.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[u!==void 0&&s.jsxs("button",{type:"button",onClick:ae,className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground",children:[s.jsx(nn,{className:"size-3.5"}),s.jsx("span",{children:"Load session"})]}),E?s.jsx("a",{href:"/",className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground",children:"Back to all sessions"}):s.jsx("button",{type:"button",onClick:()=>i("__all__"),className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground",children:"Show all sessions"})]})]})]})}):s.jsx("div",{className:"py-16 text-center text-muted-foreground",children:s.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-2xl space-y-4 rounded-[8px] px-4 py-8",children:[s.jsx("p",{className:"text-sm",children:"No logs loaded in the current view."}),t.length>0&&s.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Pick a session from the filter panel to load stored logs on demand."}),s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(bd,{command:"ANTHROPIC_BASE_URL=http://localhost:9527/proxy <your-tool>"}),s.jsx(bd,{command:"OPENAI_BASE_URL=http://localhost:9527/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:ke,tabIndex:0,className:"flex flex-col gap-2 focus:outline-none",children:[s.jsx("div",{ref:xe,children:s.jsx(jR,{groups:M,viewMode:m,strip:g,slowResponseThresholdSeconds:x,cacheTrends:Be,onCompareWithPrevious:Ut,comparisonPredecessors:Rt,onClearGroup:d,defaultExpanded:M.length===1,timeDisplayFormat:b})}),s.jsx("div",{className:"mt-3",children:s.jsx(md,{logs:e,pagination:k})})]})]})]})]}),s.jsx(qn,{open:V,onOpenChange:U,children:s.jsxs(Zn,{className:"border-red-500/20 bg-zinc-950 text-zinc-100 sm:max-w-md",children:[s.jsxs(Gn,{children:[s.jsx(Kn,{children:"Delete current logs?"}),s.jsx(Rp,{children:"Choose whether this only clears the UI or also deletes the stored log data for the current view."})]}),s.jsxs("label",{className:"flex items-start gap-3 rounded-md bg-red-500/[0.08] px-3 py-3 text-sm text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:[s.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0",checked:ce,disabled:Q,onChange:Me=>B(Me.currentTarget.checked)}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block font-medium",children:"Also delete stored data"}),s.jsxs("span",{className:"mt-1 block text-xs text-red-200/80",children:["Removes persisted log rows, streaming chunks, and session archive entries for these"," ",e.length.toString()," visible request",e.length===1?"":"s","."]})]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(_e,{type:"button",variant:"outline",size:"sm",disabled:Q,onClick:()=>U(!1),children:"Cancel"}),s.jsx(_e,{type:"button",variant:ce?"destructive":"secondary",size:"sm",disabled:Q,onClick:q,children:Q?"Deleting...":ce?"Delete data":"Clear only"})]})]})}),ie!==null&&s.jsx(p.Suspense,{fallback:null,children:s.jsx(L4,{left:ie[0],right:ie[1],leftDisplayNumber:fd(ie[0],Y),rightDisplayNumber:fd(ie[1],Y),onClose:R})})]})}const y8=Kt([J({type:Te("init"),logs:fe(Kr)}),J({type:Te("update"),log:Kr})]),w8=J({logs:fe(Kr),total:K().int().nonnegative(),limit:K().int().positive(),hasOlder:Le(),hasNewer:Le(),oldestLogId:K().int().positive().nullable(),newestLogId:K().int().positive().nullable()}),_8=fe(C()),k8=J({success:Le(),cleared:K().int().nonnegative(),logFilesRewritten:K().int().nonnegative().optional(),chunkFilesDeleted:K().int().nonnegative(),sessionArchiveLogsDeleted:K().int().nonnegative().optional()});function j8(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 Ur(e){const t=new Set;for(const n of e)n.sessionId!==null&&n.sessionId!==""&&t.add(n.sessionId);return[...t]}function S8(e){const t=new Set;for(const n of e)n.model!==null&&n.model!==""&&t.add(n.model);return[...t]}function C8(e,t,n){return t==="__all__"&&n==="__all__"?e:e.filter(r=>!(t!=="__all__"&&r.sessionId!==t||n!=="__all__"&&r.model!==n))}const N8=100,T8=12,E8=1800,oc=100,wd=500,A8=200,Va=2e4,R8=1e4;function I8(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 z8(e,t,n=oc){const r=new URLSearchParams({cursor:"1",compact:"1",limit:String(n),sessionId:e});switch(t.kind){case"oldest":r.set("anchor","oldest");break;case"older":r.set("beforeLogId",String(t.beforeLogId));break;case"newer":r.set("afterLogId",String(t.afterLogId));break}return`/api/logs?${r.toString()}`}function zn(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 Qi(e,t,n=oc){return Ke(z8(e,t,n),w8,Va)}function qs(e,t){if(t.length===0)return[...e];const n=new Map;for(const r of e)n.set(r.id,r);for(const r of t)n.set(r.id,r);return[...n.values()].sort((r,o)=>r.id-o.id)}function hn(e,t){const n=new Set;for(const r of e)r!==""&&n.add(r);for(const r of t)r!==""&&n.add(r);return[...n].sort()}function D8({initialSessionId:e}={}){const[t,n]=p.useState([]),[r,o]=p.useState(e??"__all__"),[i,a]=p.useState("__all__"),[l,c]=p.useState([]),{notice:u,showToast:d,dismissToast:f}=n0(),[h,m]=p.useState(e===void 0),[v,g]=p.useState(null),[x,b]=p.useState(e!==void 0),[y,k]=p.useState(void 0),[j,S]=p.useState([]),[,E]=p.useTransition(),N=p.useRef(null),z=p.useRef(null),A=p.useRef(null),O=p.useRef(0),W=p.useRef(null),T=p.useRef(null),L=p.useRef(new Map),_=p.useRef([]),$=p.useRef(null),ee=p.useCallback(R=>{d({message:R,tone:"error"})},[d]),D=p.useCallback(()=>{T.current!==null&&(clearInterval(T.current),T.current=null),W.current=null,k(void 0)},[]),H=p.useCallback((R,M,Y=0,se=0)=>{T.current!==null&&clearInterval(T.current);const oe=Date.now();W.current=oe;const ge=()=>{O.current===M&&k({label:R,elapsedMs:Date.now()-oe,timeoutMs:Va,loadedLogs:Y,loadedPages:se})};ge(),T.current=setInterval(ge,250)},[]),Z=p.useCallback((R,M,Y,se)=>{const oe=W.current;oe===null||O.current!==M||k({label:R,elapsedMs:Date.now()-oe,timeoutMs:Va,loadedLogs:Y,loadedPages:se})},[]),ue=p.useMemo(()=>C8(t,r,i),[t,r,i]),V=p.useMemo(()=>hn(l,Ur(t)),[t,l]),U=p.useMemo(()=>S8(t),[t]),ce=p.useCallback(()=>{Mt("/api/sessions",_8).then(R=>{c(M=>hn(M,R))}).catch(()=>{})},[]),B=p.useCallback(()=>{$.current=null;const R=_.current;_.current=[],R.length!==0&&E(()=>{n(M=>{const Y=qs(M,R);return L.current=zn(Y),Y})})},[E]),Q=p.useCallback(R=>{_.current.push(R),$.current===null&&($.current=setTimeout(B,N8))},[B]),Se=p.useCallback(()=>{N.current&&N.current.close(),m(!1);const R=new EventSource(I8(e));N.current=R,R.onmessage=M=>{try{const Y=String(M.data),se=JSON.parse(Y),oe=y8.safeParse(se);if(!oe.success){ee("Failed to parse SSE data");return}const ge=oe.data;ge.type==="init"?($.current!==null&&(clearTimeout($.current),$.current=null),_.current=[],n(Ce=>{const je=qs(Ce,ge.logs);return L.current=zn(je),je}),c(Ce=>hn(Ce,Ur(ge.logs))),m(!0),f()):ge.type==="update"&&(c(Ce=>ge.log.sessionId===null||ge.log.sessionId===""?Ce:hn(Ce,[ge.log.sessionId])),Q(ge.log))}catch{ee("Failed to parse SSE data")}},R.onerror=()=>{ee("SSE connection lost, reconnecting..."),m(!0),R.close(),z.current!==null&&clearTimeout(z.current),z.current=setTimeout(Se,3e3)}},[f,e,Q,ee]),ie=p.useCallback(R=>{if(e===void 0)return;const M=O.current+1;O.current=M,b(!0),H("Loading session logs",M),f(),Qi(e,R).then(Y=>{if(O.current!==M)return;const se=Y.logs;L.current=zn(se),n(se),g(Y),o(e),b(!1),D(),f()}).catch(Y=>{O.current===M&&(n([]),g(null),b(!1),D(),ee(Y instanceof Error?Y.message:"Failed to load session logs"))})},[f,e,ee,H,D]),pe=p.useCallback(R=>{const M=O.current+1;O.current=M,b(!0),H("Reloading full session",M),f(),(async()=>{const Y=[];let se=await Qi(R,{kind:"oldest"},wd);Y.push(...se.logs),Z("Reloading full session",M,Y.length,1);let oe=1;for(;se.hasNewer&&se.newestLogId!==null&&oe<A8;)se=await Qi(R,{kind:"newer",afterLogId:se.newestLogId},wd),Y.push(...se.logs),oe+=1,Z("Reloading full session",M,Y.length,oe);O.current===M&&(n(ge=>{const Ce=qs(ge,Y);return L.current=zn(Ce),Ce}),c(ge=>hn(ge,[R])),b(!1),D(),se.hasNewer?d({message:`Loaded ${String(Y.length)} logs for this session. More history is available.`,tone:"success"}):f())})().catch(Y=>{O.current===M&&(b(!1),D(),ee(Y instanceof Error?Y.message:"Failed to reload session logs"))})},[f,ee,d,H,D,Z]);p.useEffect(()=>{if(e===void 0){S([]);return}let R=!1;return Ke("/api/groups",Sf,R8).then(M=>M.groups).then(M=>{R||M===null||S(j8(M,e))}).catch(()=>{R||S([])}),()=>{R=!0}},[e]),p.useEffect(()=>{ce()},[ce]),p.useEffect(()=>()=>{D()},[D]),p.useEffect(()=>{e!==void 0&&ie({kind:"newest"})},[e,ie]),p.useEffect(()=>{e===void 0&&r!=="__all__"&&pe(r)},[e,pe,r]),p.useEffect(()=>{if(e===void 0)return Se(),()=>{N.current&&(N.current.close(),N.current=null),z.current!==null&&(clearTimeout(z.current),z.current=null),$.current!==null&&(clearTimeout($.current),$.current=null)}},[Se,e]),p.useEffect(()=>{const R=window.location.hash;if(!R.startsWith("#log-")||A.current===R)return;const M=R.slice(1),Y=Number(M.replace(/^log-/,""));Number.isInteger(Y)&&Y>0&&ts({logId:Y,tab:"request"});let se=!1,oe=0,ge=null,Ce=null;const je=()=>{if(se)return;const ze=document.getElementById(M);if(ze!==null){A.current=R,ze.scrollIntoView({block:"center",behavior:"smooth"}),ze instanceof HTMLElement&&(ge=ze,ze.setAttribute("data-deep-link-highlight","true"),Ce=window.setTimeout(()=>{ze.removeAttribute("data-deep-link-highlight")},E8),ze.focus({preventScroll:!0}),ze.getAttribute("data-nav-action")==="expand"&&ze.click());return}oe+=1,oe<T8&&window.setTimeout(je,100)};return je(),()=>{se=!0,Ce!==null&&window.clearTimeout(Ce),ge!==null&&ge.removeAttribute("data-deep-link-highlight")}},[ue.length]);const me=p.useCallback(()=>{const R=Ur(t);D(),b(!1),L.current.clear(),n([]),g(null),c(M=>hn(M,R)),d({message:"Cleared the current view. Stored logs are still reloadable.",tone:"success"})},[t,d,D]),he=p.useCallback(R=>{if(R.length===0)return;const M=new Set(R);n(Y=>{const se=Y.filter(ge=>M.has(ge.id)),oe=Y.filter(ge=>!M.has(ge.id));return c(ge=>hn(ge,Ur(se))),L.current=zn(oe),oe}),d({message:"Cleared this group from the current view.",tone:"success"})},[d]),xe=p.useCallback(async R=>{if(R.length===0)return;const M=new Set(R),Y=t.filter(oe=>M.has(oe.id)),se=await Mt("/api/logs",k8,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({ids:R})});n(oe=>{const ge=oe.filter(Ce=>!M.has(Ce.id));return L.current=zn(ge),ge}),g(oe=>oe===null?null:{...oe,logs:oe.logs.filter(ge=>!M.has(ge.id))}),c(oe=>hn(oe,Ur(Y))),d({message:`Deleted ${se.cleared.toString()} stored log${se.cleared===1?"":"s"} from the current view.`,tone:"success"})},[t,d]),ke=p.useCallback(()=>{if(e!==void 0){ie({kind:"newest"});return}if(r==="__all__"){ce();return}pe(r)},[e,ie,ce,pe,r]),Ae=p.useCallback(async R=>{const M=new FormData;M.set("file",R);const Y=await Mt("/api/logs/import",w2,{method:"POST",body:M});return n(se=>{const oe=new Set(Y.logs.map(Ce=>Ce.id)),ge=qs(se.filter(Ce=>!oe.has(Ce.id)),Y.logs);return L.current=zn(ge),ge}),o(Y.sessionId),a("__all__"),g(null),f(),Y},[f]),{strip:w,captureMode:X,slowResponseThresholdSeconds:G,timeDisplayFormat:P}=dl(),I=X,F=p.useCallback(()=>{ie({kind:"oldest"})},[ie]),re=p.useCallback(()=>{ie({kind:"newest"})},[ie]),ne=p.useCallback(()=>{const R=t[0],M=v?.oldestLogId??R?.id??null;M!==null&&ie({kind:"older",beforeLogId:M})},[t,ie,v]),q=p.useCallback(()=>{const R=t[t.length-1],M=v?.newestLogId??R?.id??null;M!==null&&ie({kind:"newer",afterLogId:M})},[t,ie,v]),ae=p.useMemo(()=>{if(e!==void 0)return{isLoading:x,loadProgress:y,total:v?.total??null,pageSize:v?.limit??oc,hasOlder:v?.hasOlder??!1,hasNewer:v?.hasNewer??!1,oldestLogId:v?.oldestLogId??null,newestLogId:v?.newestLogId??null,onOldest:F,onOlder:ne,onNewer:q,onNewest:re}},[e,re,q,ne,F,v,y,x]);return s.jsxs(s.Fragment,{children:[s.jsx(r0,{notice:u,onDismiss:f}),s.jsx(l_,{}),s.jsx(v8,{logs:ue,sessions:V,models:U,selectedSession:r,selectedModel:i,onSessionChange:o,onModelChange:a,onClearAll:me,onDeleteCurrentView:xe,onReloadSession:e!==void 0||r!=="__all__"?ke:void 0,onClearGroup:he,onNotify:d,onImportLogs:e===void 0?Ae:void 0,isLoading:e===void 0&&!h||x,pagination:ae,sessionLoadProgress:y,sessionMemberships:j,viewMode:I,captureMode:X,strip:w,slowResponseThresholdSeconds:G,timeDisplayFormat:P,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{M8 as $,J as A,Pe as B,ky as C,qn as D,K as E,fe as F,ts as G,Bo as H,Le as I,C as J,Kr as K,U4 as L,cw as M,yI as N,nw as O,D8 as P,zR as Q,Aw as R,LR as S,Dm as T,IR as U,Xf as V,L8 as W,ls as X,lt as Y,Re as Z,mT as _,K3 as a,Tf as a0,gT as a1,xT as a2,Cr as a3,Ra as a4,ko as a5,Jr as a6,ye as a7,bn as a8,_k as a9,tt as aa,rf as ab,P4 as ac,ey as ad,le as b,de as c,ia as d,If as e,Fe as f,Rm as g,Ct as h,Xe as i,Ft as j,Lt as k,Ke as l,Zn as m,Gn as n,Kn as o,Nw as p,$m as q,Qr as r,jt as s,St as t,Qf as u,_e as v,rt as w,Ue as x,We as y,He as z};