@tonyclaw/llm-inspector 1.16.2 → 1.16.3

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.
@@ -1,4 +1,4 @@
1
- import{u as zi,a as lu,r as v,j as l,c as Lr,g as Ri,b as Tr,R as at,d as cu,e as Kp}from"./main-pT0WLAFQ.js";function Q(e,t,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=i.prototype,d=Object.keys(u);for(let h=0;h<d.length;h++){const p=d[h];p in a||(a[p]=u[p].bind(a))}}const o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const u=n?.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Dn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class uu extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const du={};function en(e){return du}function fu(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 Ks(e,t){return typeof t=="bigint"?t.toString():t}function Ro(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Pi(e){return e==null}function Oi(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Gp(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 s=n>o?n:o,i=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return i%a/10**s}const Fa=Symbol("evaluating");function Te(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Fa)return r===void 0&&(r=Fa,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function vn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function on(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function $a(e){return JSON.stringify(e)}function Jp(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const hu="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function wr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Yp=Ro(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Un(e){if(wr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(wr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function pu(e){return Un(e)?{...e}:Array.isArray(e)?[...e]:e}const Xp=new Set(["string","number","symbol"]);function Zn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sn(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function ye(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 Qp(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const em={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 tm(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 s=on(e._zod.def,{get shape(){const i={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=n.shape[a])}return vn(this,"shape",i),i},checks:[]});return sn(e,s)}function nm(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 s=on(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return vn(this,"shape",i),i},checks:[]});return sn(e,s)}function rm(e,t){if(!Un(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=on(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return vn(this,"shape",s),s}});return sn(e,o)}function om(e,t){if(!Un(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=on(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return vn(this,"shape",r),r}});return sn(e,n)}function sm(e,t){const n=on(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return vn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return sn(e,n)}function im(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 i=on(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const u in n){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return vn(this,"shape",c),c},checks:[]});return sn(t,i)}function am(e,t,n){const r=on(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return vn(this,"shape",s),s}});return sn(t,r)}function zn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Rn(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Fr(e){return typeof e=="string"?e:e?.message}function tn(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=Fr(e.inst?._zod.def?.error?.(e))??Fr(t?.error?.(e))??Fr(n.customError?.(e))??Fr(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Di(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function kr(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const mu=(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,Ks,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},gu=Q("$ZodError",mu),xu=Q("$ZodError",mu,{Parent:Error});function lm(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 cm(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>r({issues:i}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(s))):i[c]=i[c]||{_errors:[]},i=i[c],a++}}};return r(e),n}const Mi=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new Dn;if(i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>tn(c,s,en())));throw hu(a,o?.callee),a}return i.value},Li=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>tn(c,s,en())));throw hu(a,o?.callee),a}return i.value},Po=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new Dn;return s.issues.length?{success:!1,error:new(e??gu)(s.issues.map(i=>tn(i,o,en())))}:{success:!0,data:s.value}},um=Po(xu),Oo=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>tn(i,o,en())))}:{success:!0,data:s.value}},dm=Oo(xu),fm=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Mi(e)(t,n,o)},hm=e=>(t,n,r)=>Mi(e)(t,n,r),pm=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Li(e)(t,n,o)},mm=e=>async(t,n,r)=>Li(e)(t,n,r),gm=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Po(e)(t,n,o)},xm=e=>(t,n,r)=>Po(e)(t,n,r),ym=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oo(e)(t,n,o)},vm=e=>async(t,n,r)=>Oo(e)(t,n,r),bm=/^[cC][^\s-]{8,}$/,wm=/^[0-9a-z]+$/,km=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,_m=/^[0-9a-vA-V]{20}$/,Sm=/^[A-Za-z0-9]{27}$/,Cm=/^[a-zA-Z0-9_-]{21}$/,jm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Em=/^([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})$/,Ba=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)$/,Nm=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Tm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Am(){return new RegExp(Tm,"u")}const Im=/^(?:(?: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])$/,zm=/^(([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}|:))$/,Rm=/^((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])$/,Pm=/^(([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])$/,Om=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,yu=/^[A-Za-z0-9_-]*$/,Dm=/^\+[1-9]\d{6,14}$/,vu="(?:(?:\\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])))",Mm=new RegExp(`^${vu}$`);function bu(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 Lm(e){return new RegExp(`^${bu(e)}$`)}function Fm(e){const t=bu({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(`^${vu}T(?:${r})$`)}const $m=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Bm=/^-?\d+$/,wu=/^-?\d+(?:\.\d+)?$/,Um=/^(?:true|false)$/i,Zm=/^null$/i,Vm=/^[^A-Z]*$/,Wm=/^[^a-z]*$/,ut=Q("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ku={number:"number",bigint:"bigint",object:"date"},_u=Q("$ZodCheckLessThan",(e,t)=>{ut.init(e,t);const n=ku[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(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})}}),Su=Q("$ZodCheckGreaterThan",(e,t)=>{ut.init(e,t);const n=ku[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(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})}}),Hm=Q("$ZodCheckMultipleOf",(e,t)=>{ut.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):Gp(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})}}),qm=Q("$ZodCheckNumberFormat",(e,t)=>{ut.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=em[t.format];e._zod.onattach.push(i=>{const a=i._zod.bag;a.format=t.format,a.minimum=o,a.maximum=s,n&&(a.pattern=Bm)}),e._zod.check=i=>{const a=i.value;if(n){if(!Number.isInteger(a)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,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}):i.issues.push({input:a,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}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Km=Q("$ZodCheckMaxLength",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Pi(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 i=Di(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Gm=Q("$ZodCheckMinLength",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Pi(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 i=Di(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Jm=Q("$ZodCheckLengthEquals",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Pi(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,s=o.length;if(s===t.length)return;const i=Di(o),a=s>t.length;r.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Do=Q("$ZodCheckStringFormat",(e,t)=>{var n,r;ut.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.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=()=>{})}),Ym=Q("$ZodCheckRegex",(e,t)=>{Do.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})}}),Xm=Q("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Vm),Do.init(e,t)}),Qm=Q("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Wm),Do.init(e,t)}),eg=Q("$ZodCheckIncludes",(e,t)=>{ut.init(e,t);const n=Zn(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.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})}}),tg=Q("$ZodCheckStartsWith",(e,t)=>{ut.init(e,t);const n=new RegExp(`^${Zn(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})}}),ng=Q("$ZodCheckEndsWith",(e,t)=>{ut.init(e,t);const n=new RegExp(`.*${Zn(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})}}),rg=Q("$ZodCheckOverwrite",(e,t)=>{ut.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class og{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
1
+ import{u as zi,a as lu,r as v,j as l,c as Lr,g as Ri,b as Tr,R as at,d as cu,e as Kp}from"./main-Cpts3Ifr.js";function Q(e,t,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=i.prototype,d=Object.keys(u);for(let h=0;h<d.length;h++){const p=d[h];p in a||(a[p]=u[p].bind(a))}}const o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const u=n?.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Dn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class uu extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const du={};function en(e){return du}function fu(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 Ks(e,t){return typeof t=="bigint"?t.toString():t}function Ro(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Pi(e){return e==null}function Oi(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Gp(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 s=n>o?n:o,i=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return i%a/10**s}const Fa=Symbol("evaluating");function Te(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Fa)return r===void 0&&(r=Fa,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function vn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function on(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function $a(e){return JSON.stringify(e)}function Jp(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const hu="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function wr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Yp=Ro(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Un(e){if(wr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(wr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function pu(e){return Un(e)?{...e}:Array.isArray(e)?[...e]:e}const Xp=new Set(["string","number","symbol"]);function Zn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sn(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function ye(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 Qp(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const em={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 tm(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 s=on(e._zod.def,{get shape(){const i={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=n.shape[a])}return vn(this,"shape",i),i},checks:[]});return sn(e,s)}function nm(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 s=on(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return vn(this,"shape",i),i},checks:[]});return sn(e,s)}function rm(e,t){if(!Un(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=on(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return vn(this,"shape",s),s}});return sn(e,o)}function om(e,t){if(!Un(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=on(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return vn(this,"shape",r),r}});return sn(e,n)}function sm(e,t){const n=on(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return vn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return sn(e,n)}function im(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 i=on(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const u in n){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return vn(this,"shape",c),c},checks:[]});return sn(t,i)}function am(e,t,n){const r=on(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return vn(this,"shape",s),s}});return sn(t,r)}function zn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Rn(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Fr(e){return typeof e=="string"?e:e?.message}function tn(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=Fr(e.inst?._zod.def?.error?.(e))??Fr(t?.error?.(e))??Fr(n.customError?.(e))??Fr(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Di(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function kr(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const mu=(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,Ks,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},gu=Q("$ZodError",mu),xu=Q("$ZodError",mu,{Parent:Error});function lm(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 cm(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>r({issues:i}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(s))):i[c]=i[c]||{_errors:[]},i=i[c],a++}}};return r(e),n}const Mi=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new Dn;if(i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>tn(c,s,en())));throw hu(a,o?.callee),a}return i.value},Li=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>tn(c,s,en())));throw hu(a,o?.callee),a}return i.value},Po=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new Dn;return s.issues.length?{success:!1,error:new(e??gu)(s.issues.map(i=>tn(i,o,en())))}:{success:!0,data:s.value}},um=Po(xu),Oo=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>tn(i,o,en())))}:{success:!0,data:s.value}},dm=Oo(xu),fm=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Mi(e)(t,n,o)},hm=e=>(t,n,r)=>Mi(e)(t,n,r),pm=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Li(e)(t,n,o)},mm=e=>async(t,n,r)=>Li(e)(t,n,r),gm=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Po(e)(t,n,o)},xm=e=>(t,n,r)=>Po(e)(t,n,r),ym=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oo(e)(t,n,o)},vm=e=>async(t,n,r)=>Oo(e)(t,n,r),bm=/^[cC][^\s-]{8,}$/,wm=/^[0-9a-z]+$/,km=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,_m=/^[0-9a-vA-V]{20}$/,Sm=/^[A-Za-z0-9]{27}$/,Cm=/^[a-zA-Z0-9_-]{21}$/,jm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Em=/^([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})$/,Ba=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)$/,Nm=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Tm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Am(){return new RegExp(Tm,"u")}const Im=/^(?:(?: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])$/,zm=/^(([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}|:))$/,Rm=/^((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])$/,Pm=/^(([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])$/,Om=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,yu=/^[A-Za-z0-9_-]*$/,Dm=/^\+[1-9]\d{6,14}$/,vu="(?:(?:\\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])))",Mm=new RegExp(`^${vu}$`);function bu(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 Lm(e){return new RegExp(`^${bu(e)}$`)}function Fm(e){const t=bu({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(`^${vu}T(?:${r})$`)}const $m=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Bm=/^-?\d+$/,wu=/^-?\d+(?:\.\d+)?$/,Um=/^(?:true|false)$/i,Zm=/^null$/i,Vm=/^[^A-Z]*$/,Wm=/^[^a-z]*$/,ut=Q("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ku={number:"number",bigint:"bigint",object:"date"},_u=Q("$ZodCheckLessThan",(e,t)=>{ut.init(e,t);const n=ku[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(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})}}),Su=Q("$ZodCheckGreaterThan",(e,t)=>{ut.init(e,t);const n=ku[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(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})}}),Hm=Q("$ZodCheckMultipleOf",(e,t)=>{ut.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):Gp(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})}}),qm=Q("$ZodCheckNumberFormat",(e,t)=>{ut.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=em[t.format];e._zod.onattach.push(i=>{const a=i._zod.bag;a.format=t.format,a.minimum=o,a.maximum=s,n&&(a.pattern=Bm)}),e._zod.check=i=>{const a=i.value;if(n){if(!Number.isInteger(a)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,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}):i.issues.push({input:a,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}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Km=Q("$ZodCheckMaxLength",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Pi(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 i=Di(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Gm=Q("$ZodCheckMinLength",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Pi(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 i=Di(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Jm=Q("$ZodCheckLengthEquals",(e,t)=>{var n;ut.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Pi(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,s=o.length;if(s===t.length)return;const i=Di(o),a=s>t.length;r.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Do=Q("$ZodCheckStringFormat",(e,t)=>{var n,r;ut.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.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=()=>{})}),Ym=Q("$ZodCheckRegex",(e,t)=>{Do.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})}}),Xm=Q("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Vm),Do.init(e,t)}),Qm=Q("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Wm),Do.init(e,t)}),eg=Q("$ZodCheckIncludes",(e,t)=>{ut.init(e,t);const n=Zn(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.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})}}),tg=Q("$ZodCheckStartsWith",(e,t)=>{ut.init(e,t);const n=new RegExp(`^${Zn(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})}}),ng=Q("$ZodCheckEndsWith",(e,t)=>{ut.init(e,t);const n=new RegExp(`.*${Zn(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})}}),rg=Q("$ZodCheckOverwrite",(e,t)=>{ut.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class og{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(`
2
2
  `).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
3
3
  `))}}const sg={major:4,minor:3,patch:6},Be=Q("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=sg;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(i,a,c)=>{let u=zn(i),d;for(const h of a){if(h._zod.def.when){if(!h._zod.def.when(i))continue}else if(u)continue;const p=i.issues.length,f=h._zod.check(i);if(f instanceof Promise&&c?.async===!1)throw new Dn;if(d||f instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await f,i.issues.length!==p&&(u||(u=zn(i,p)))});else{if(i.issues.length===p)continue;u||(u=zn(i,p))}}return d?d.then(()=>i):i},s=(i,a,c)=>{if(zn(i))return i.aborted=!0,i;const u=o(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new Dn;return u.then(d=>e._zod.parse(d,c))}return e._zod.parse(u,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){const u=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(d=>s(d,i,a)):s(u,i,a)}const c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new Dn;return c.then(u=>o(u,r,a))}return o(c,r,a)}}Te(e,"~standard",()=>({validate:o=>{try{const s=um(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return dm(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Fi=Q("$ZodString",(e,t)=>{Be.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??$m(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=Q("$ZodStringFormat",(e,t)=>{Do.init(e,t),Fi.init(e,t)}),ig=Q("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Em),Ze.init(e,t)}),ag=Q("$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=Ba(r))}else t.pattern??(t.pattern=Ba());Ze.init(e,t)}),lg=Q("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Nm),Ze.init(e,t)}),cg=Q("$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})}}}),ug=Q("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Am()),Ze.init(e,t)}),dg=Q("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Cm),Ze.init(e,t)}),fg=Q("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=bm),Ze.init(e,t)}),hg=Q("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=wm),Ze.init(e,t)}),pg=Q("$ZodULID",(e,t)=>{t.pattern??(t.pattern=km),Ze.init(e,t)}),mg=Q("$ZodXID",(e,t)=>{t.pattern??(t.pattern=_m),Ze.init(e,t)}),gg=Q("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Sm),Ze.init(e,t)}),xg=Q("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Fm(t)),Ze.init(e,t)}),yg=Q("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Mm),Ze.init(e,t)}),vg=Q("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Lm(t)),Ze.init(e,t)}),bg=Q("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=jm),Ze.init(e,t)}),wg=Q("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Im),Ze.init(e,t),e._zod.bag.format="ipv4"}),kg=Q("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=zm),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})}}}),_g=Q("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Rm),Ze.init(e,t)}),Sg=Q("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Pm),Ze.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,s]=r;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>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 Cu(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Cg=Q("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Om),Ze.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Cu(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function jg(e){if(!yu.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Cu(n)}const Eg=Q("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=yu),Ze.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{jg(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Ng=Q("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Dm),Ze.init(e,t)});function Tg(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 Ag=Q("$ZodJWT",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{Tg(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ju=Q("$ZodNumber",(e,t)=>{Be.init(e,t),e._zod.pattern=e._zod.bag.pattern??wu,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 s=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,...s?{received:s}:{}}),n}}),Ig=Q("$ZodNumberFormat",(e,t)=>{qm.init(e,t),ju.init(e,t)}),zg=Q("$ZodBoolean",(e,t)=>{Be.init(e,t),e._zod.pattern=Um,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}}),Rg=Q("$ZodNull",(e,t)=>{Be.init(e,t),e._zod.pattern=Zm,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}}),Pg=Q("$ZodUnknown",(e,t)=>{Be.init(e,t),e._zod.parse=n=>n}),Og=Q("$ZodNever",(e,t)=>{Be.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Ua(e,t,n){e.issues.length&&t.issues.push(...Rn(n,e.issues)),t.value[n]=e.value}const Dg=Q("$ZodArray",(e,t)=>{Be.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 s=[];for(let i=0;i<o.length;i++){const a=o[i],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>Ua(u,n,i))):Ua(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function co(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...Rn(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Eu(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=Qp(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Nu(e,t,n,r,o,s){const i=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,d=c.optout==="optional";for(const h in t){if(a.has(h))continue;if(u==="never"){i.push(h);continue}const p=c.run({value:t[h],issues:[]},r);p instanceof Promise?e.push(p.then(f=>co(f,n,h,t,d))):co(p,n,h,t,d)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const Mg=Q("$ZodObject",(e,t)=>{if(Be.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const r=Ro(()=>Eu(t));Te(e._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const d=a[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const h of d.values)c[u].add(h)}}return c});const o=wr,s=t.catchall;let i;e._zod.parse=(a,c)=>{i??(i=r.value);const u=a.value;if(!o(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};const d=[],h=i.shape;for(const p of i.keys){const f=h[p],g=f._zod.optout==="optional",m=f._zod.run({value:u[p],issues:[]},c);m instanceof Promise?d.push(m.then(x=>co(x,a,p,u,g))):co(m,a,p,u,g)}return s?Nu(d,u,a,c,r.value,e):d.length?Promise.all(d).then(()=>a):a}}),Lg=Q("$ZodObjectJIT",(e,t)=>{Mg.init(e,t);const n=e._zod.parse,r=Ro(()=>Eu(t)),o=p=>{const f=new og(["shape","payload","ctx"]),g=r.value,m=k=>{const S=$a(k);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};f.write("const input = payload.value;");const x=Object.create(null);let y=0;for(const k of g.keys)x[k]=`key_${y++}`;f.write("const newResult = {};");for(const k of g.keys){const S=x[k],C=$a(k),N=p[k]?._zod?.optout==="optional";f.write(`const ${S} = ${m(k)};`),N?f.write(`
4
4
  if (${S}.issues.length) {
@@ -37,7 +37,7 @@ import{u as zi,a as lu,r as v,j as l,c as Lr,g as Ri,b as Tr,R as at,d as cu,e a
37
37
  `)}f.write("payload.value = newResult;"),f.write("return payload;");const b=f.compile();return(k,S)=>b(p,k,S)};let s;const i=wr,a=!du.jitless,u=a&&Yp.value,d=t.catchall;let h;e._zod.parse=(p,f)=>{h??(h=r.value);const g=p.value;return i(g)?a&&u&&f?.async===!1&&f.jitless!==!0?(s||(s=o(t.shape)),p=s(p,f),d?Nu([],g,p,f,h,e):p):n(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),p)}});function Za(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!zn(s));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(s=>s.issues.map(i=>tn(i,r,en())))}),t)}const Tu=Q("$ZodUnion",(e,t)=>{Be.init(e,t),Te(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),Te(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Te(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),Te(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>Oi(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,s)=>{if(n)return r(o,s);let i=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:o.value,issues:[]},s);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(c=>Za(c,o,e,s)):Za(a,o,e,s)}}),Fg=Q("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Tu.init(e,t);const n=e._zod.parse;Te(e._zod,"propValues",()=>{const o={};for(const s of t.options){const i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(const u of c)o[a].add(u)}}return o});const r=Ro(()=>{const o=t.options,s=new Map;for(const i of o){const a=i._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});e._zod.parse=(o,s)=>{const i=o.value;if(!wr(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;const a=r.value.get(i?.[t.discriminator]);return a?a._zod.run(o,s):t.unionFallback?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:i,path:[t.discriminator],inst:e}),o)}}),$g=Q("$ZodIntersection",(e,t)=>{Be.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Va(n,c,u)):Va(n,s,i)}});function Gs(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(Un(e)&&Un(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const i=Gs(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.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],s=t[r],i=Gs(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Va(e,t,n){const r=new Map;let o;for(const a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&o&&e.issues.push({...o,keys:s}),zn(e))return e;const i=Gs(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const Bg=Q("$ZodRecord",(e,t)=>{Be.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Un(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[],i=t.keyType._zod.values;if(i){n.value={};const a=new Set;for(const u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const d=t.valueType._zod.run({value:o[u],issues:[]},r);d instanceof Promise?s.push(d.then(h=>{h.issues.length&&n.issues.push(...Rn(u,h.issues)),n.value[u]=h.value})):(d.issues.length&&n.issues.push(...Rn(u,d.issues)),n.value[u]=d.value)}let c;for(const u in o)a.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 a of Reflect.ownKeys(o)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&wu.test(a)&&c.issues.length){const h=t.keyType._zod.run({value:Number(a),issues:[]},r);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(c=h)}if(c.issues.length){t.mode==="loose"?n.value[a]=o[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(h=>tn(h,r,en())),input:a,path:[a],inst:e});continue}const d=t.valueType._zod.run({value:o[a],issues:[]},r);d instanceof Promise?s.push(d.then(h=>{h.issues.length&&n.issues.push(...Rn(a,h.issues)),n.value[c.value]=h.value})):(d.issues.length&&n.issues.push(...Rn(a,d.issues)),n.value[c.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}}),Ug=Q("$ZodEnum",(e,t)=>{Be.init(e,t);const n=fu(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>Xp.has(typeof o)).map(o=>typeof o=="string"?Zn(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),Zg=Q("$ZodLiteral",(e,t)=>{if(Be.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Zn(r):r?Zn(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),Vg=Q("$ZodTransform",(e,t)=>{Be.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new uu(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new Dn;return n.value=o,n}});function Wa(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Au=Q("$ZodOptional",(e,t)=>{Be.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Te(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Te(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Oi(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(s=>Wa(s,n.value)):Wa(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Wg=Q("$ZodExactOptional",(e,t)=>{Au.init(e,t),Te(e._zod,"values",()=>t.innerType._zod.values),Te(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Hg=Q("$ZodNullable",(e,t)=>{Be.init(e,t),Te(e._zod,"optin",()=>t.innerType._zod.optin),Te(e._zod,"optout",()=>t.innerType._zod.optout),Te(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Oi(n.source)}|null)$`):void 0}),Te(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)}),qg=Q("$ZodDefault",(e,t)=>{Be.init(e,t),e._zod.optin="optional",Te(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(s=>Ha(s,t)):Ha(o,t)}});function Ha(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Kg=Q("$ZodPrefault",(e,t)=>{Be.init(e,t),e._zod.optin="optional",Te(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))}),Gg=Q("$ZodNonOptional",(e,t)=>{Be.init(e,t),Te(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(s=>qa(s,e)):qa(o,e)}});function qa(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 Jg=Q("$ZodCatch",(e,t)=>{Be.init(e,t),Te(e._zod,"optin",()=>t.innerType._zod.optin),Te(e._zod,"optout",()=>t.innerType._zod.optout),Te(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(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>tn(i,r,en()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>tn(s,r,en()))},input:n.value}),n.issues=[]),n)}}),Yg=Q("$ZodPipe",(e,t)=>{Be.init(e,t),Te(e._zod,"values",()=>t.in._zod.values),Te(e._zod,"optin",()=>t.in._zod.optin),Te(e._zod,"optout",()=>t.out._zod.optout),Te(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(i=>$r(i,t.in,r)):$r(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>$r(s,t.out,r)):$r(o,t.out,r)}});function $r(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Xg=Q("$ZodReadonly",(e,t)=>{Be.init(e,t),Te(e._zod,"propValues",()=>t.innerType._zod.propValues),Te(e._zod,"values",()=>t.innerType._zod.values),Te(e._zod,"optin",()=>t.innerType?._zod?.optin),Te(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(Ka):Ka(o)}});function Ka(e){return e.value=Object.freeze(e.value),e}const Qg=Q("$ZodLazy",(e,t)=>{Be.init(e,t),Te(e._zod,"innerType",()=>t.getter()),Te(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),Te(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),Te(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),Te(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),ex=Q("$ZodCustom",(e,t)=>{ut.init(e,t),Be.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(s=>Ga(s,n,r,e));Ga(o,n,r,e)}});function Ga(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(kr(o))}}var Ja;class tx{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 nx(){return new tx}(Ja=globalThis).__zod_globalRegistry??(Ja.__zod_globalRegistry=nx());const gr=globalThis.__zod_globalRegistry;function rx(e,t){return new e({type:"string",...ye(t)})}function ox(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ye(t)})}function Ya(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ye(t)})}function sx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ye(t)})}function ix(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ye(t)})}function ax(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ye(t)})}function lx(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ye(t)})}function cx(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ye(t)})}function ux(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ye(t)})}function dx(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ye(t)})}function fx(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ye(t)})}function hx(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ye(t)})}function px(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ye(t)})}function mx(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ye(t)})}function gx(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ye(t)})}function xx(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ye(t)})}function yx(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ye(t)})}function vx(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ye(t)})}function bx(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ye(t)})}function wx(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ye(t)})}function kx(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ye(t)})}function _x(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ye(t)})}function Sx(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ye(t)})}function Cx(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ye(t)})}function jx(e,t){return new e({type:"string",format:"date",check:"string_format",...ye(t)})}function Ex(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ye(t)})}function Nx(e,t){return new e({type:"string",format:"duration",check:"string_format",...ye(t)})}function Tx(e,t){return new e({type:"number",checks:[],...ye(t)})}function Ax(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ye(t)})}function Ix(e,t){return new e({type:"boolean",...ye(t)})}function zx(e,t){return new e({type:"null",...ye(t)})}function Rx(e){return new e({type:"unknown"})}function Px(e,t){return new e({type:"never",...ye(t)})}function Xa(e,t){return new _u({check:"less_than",...ye(t),value:e,inclusive:!1})}function ps(e,t){return new _u({check:"less_than",...ye(t),value:e,inclusive:!0})}function Qa(e,t){return new Su({check:"greater_than",...ye(t),value:e,inclusive:!1})}function ms(e,t){return new Su({check:"greater_than",...ye(t),value:e,inclusive:!0})}function el(e,t){return new Hm({check:"multiple_of",...ye(t),value:e})}function Iu(e,t){return new Km({check:"max_length",...ye(t),maximum:e})}function uo(e,t){return new Gm({check:"min_length",...ye(t),minimum:e})}function zu(e,t){return new Jm({check:"length_equals",...ye(t),length:e})}function Ox(e,t){return new Ym({check:"string_format",format:"regex",...ye(t),pattern:e})}function Dx(e){return new Xm({check:"string_format",format:"lowercase",...ye(e)})}function Mx(e){return new Qm({check:"string_format",format:"uppercase",...ye(e)})}function Lx(e,t){return new eg({check:"string_format",format:"includes",...ye(t),includes:e})}function Fx(e,t){return new tg({check:"string_format",format:"starts_with",...ye(t),prefix:e})}function $x(e,t){return new ng({check:"string_format",format:"ends_with",...ye(t),suffix:e})}function Yn(e){return new rg({check:"overwrite",tx:e})}function Bx(e){return Yn(t=>t.normalize(e))}function Ux(){return Yn(e=>e.trim())}function Zx(){return Yn(e=>e.toLowerCase())}function Vx(){return Yn(e=>e.toUpperCase())}function Wx(){return Yn(e=>Jp(e))}function Hx(e,t,n){return new e({type:"array",element:t,...ye(n)})}function qx(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ye(n)})}function Kx(e){const t=Gx(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(kr(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(kr(o))}},e(n.value,n)));return t}function Gx(e,t){const n=new ut({check:"custom",...ye(t)});return n._zod.check=e,n}function Ru(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??gr,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 Ke(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,d);else{const p=i.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,p,d)}const h=e._zod.parent;h&&(i.ref||(i.ref=h),Ke(h,t,d),t.seen.get(h).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),t.io==="input"&&ot(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((r=i.schema).default??(r.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Pu(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 i of e.seen.entries()){const a=e.metadataRegistry.get(i[0])?.id;if(a){const c=r.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,i[0])}}const o=i=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const h=e.external.registry.get(i[0])?.id,p=e.external.uri??(g=>g);if(h)return{ref:p(h)};const f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${p("__shared")}#/${a}/${f}`}}if(i[1]===n)return{ref:"#"};const u=`#/${a}/`,d=i[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},s=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);const d=a.schema;for(const h in d)delete d[h];d.$ref=c};if(e.cycles==="throw")for(const i of e.seen.entries()){const a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
38
38
 
39
39
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const a=i[1];if(t===i[0]){s(i);continue}if(e.external){const u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&e.reused==="ref"){s(i);continue}}}function Ou(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=i=>{const a=e.seen.get(i);if(a.ref===null)return;const c=a.def??a.schema,u={...c},d=a.ref;if(a.ref=null,d){r(d);const p=e.seen.get(d),f=p.schema;if(f.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(f)):Object.assign(c,f),Object.assign(c,u),i._zod.parent===d)for(const m in c)m==="$ref"||m==="allOf"||m in u||delete c[m];if(f.$ref&&p.def)for(const m in c)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(c[m])===JSON.stringify(p.def[m])&&delete c[m]}const h=i._zod.parent;if(h&&h!==d){r(h);const p=e.seen.get(h);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(const f in c)f==="$ref"||f==="allOf"||f in p.def&&JSON.stringify(c[f])===JSON.stringify(p.def[f])&&delete c[f]}e.override({zodSchema:i,jsonSchema:c,path:a.path??[]})};for(const i of[...e.seen.entries()].reverse())r(i[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 i=e.external.registry.get(t)?.id;if(!i)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(i)}Object.assign(o,n.def??n.schema);const s=e.external?.defs??{};for(const i of e.seen.entries()){const a=i[1];a.def&&a.defId&&(s[a.defId]=a.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const i=JSON.parse(JSON.stringify(o));return Object.defineProperty(i,"~standard",{value:{...t["~standard"],jsonSchema:{input:fo(t,"input",e.processors),output:fo(t,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function ot(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 ot(r.element,n);if(r.type==="set")return ot(r.valueType,n);if(r.type==="lazy")return ot(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 ot(r.innerType,n);if(r.type==="intersection")return ot(r.left,n)||ot(r.right,n);if(r.type==="record"||r.type==="map")return ot(r.keyType,n)||ot(r.valueType,n);if(r.type==="pipe")return ot(r.in,n)||ot(r.out,n);if(r.type==="object"){for(const o in r.shape)if(ot(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(ot(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(ot(o,n))return!0;return!!(r.rest&&ot(r.rest,n))}return!1}const Jx=(e,t={})=>n=>{const r=Ru({...n,processors:t});return Ke(e,r),Pu(r,e),Ou(r,e)},fo=(e,t,n={})=>r=>{const{libraryOptions:o,target:s}=r??{},i=Ru({...o??{},target:s,io:t,processors:n});return Ke(e,i),Pu(i,e),Ou(i,e)},Yx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Xx=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=Yx[a]??a,o.format===""&&delete o.format,a==="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(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},Qx=(e,t,n,r)=>{const o=n,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.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 s=="number"&&(o.minimum=s,typeof d=="number"&&t.target!=="draft-04"&&(d>=s?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 i=="number"&&(o.maximum=i,typeof u=="number"&&t.target!=="draft-04"&&(u<=i?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},e0=(e,t,n,r)=>{n.type="boolean"},t0=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},n0=(e,t,n,r)=>{n.not={}},r0=(e,t,n,r)=>{},o0=(e,t,n,r)=>{const o=e._zod.def,s=fu(o.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},s0=(e,t,n,r)=>{const o=e._zod.def,s=[];for(const i of o.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){const i=s[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),s.every(i=>typeof i=="boolean")&&(n.type="boolean"),s.every(i=>i===null)&&(n.type="null"),n.enum=s},i0=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},a0=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},l0=(e,t,n,r)=>{const o=n,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=Ke(s.element,t,{...r,path:[...r.path,"items"]})},c0=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="object",o.properties={};const i=s.shape;for(const u in i)o.properties[u]=Ke(i[u],t,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{const d=s.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(o.required=Array.from(c)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=Ke(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},u0=(e,t,n,r)=>{const o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>Ke(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=i:n.anyOf=i},d0=(e,t,n,r)=>{const o=e._zod.def,s=Ke(o.left,t,{...r,path:[...r.path,"allOf",0]}),i=Ke(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c},f0=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="object";const i=s.keyType,c=i._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){const d=Ke(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const h of c)o.patternProperties[h.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=Ke(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=Ke(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=i._zod.values;if(u){const d=[...u].filter(h=>typeof h=="string"||typeof h=="number");d.length>0&&(o.required=d)}},h0=(e,t,n,r)=>{const o=e._zod.def,s=Ke(o.innerType,t,r),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},p0=(e,t,n,r)=>{const o=e._zod.def;Ke(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},m0=(e,t,n,r)=>{const o=e._zod.def;Ke(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},g0=(e,t,n,r)=>{const o=e._zod.def;Ke(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},x0=(e,t,n,r)=>{const o=e._zod.def;Ke(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},y0=(e,t,n,r)=>{const o=e._zod.def,s=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;Ke(s,t,r);const i=t.seen.get(e);i.ref=s},v0=(e,t,n,r)=>{const o=e._zod.def;Ke(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0},Du=(e,t,n,r)=>{const o=e._zod.def;Ke(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},b0=(e,t,n,r)=>{const o=e._zod.innerType;Ke(o,t,r);const s=t.seen.get(e);s.ref=o},w0=Q("ZodISODateTime",(e,t)=>{xg.init(e,t),We.init(e,t)});function k0(e){return Cx(w0,e)}const _0=Q("ZodISODate",(e,t)=>{yg.init(e,t),We.init(e,t)});function S0(e){return jx(_0,e)}const C0=Q("ZodISOTime",(e,t)=>{vg.init(e,t),We.init(e,t)});function j0(e){return Ex(C0,e)}const E0=Q("ZodISODuration",(e,t)=>{bg.init(e,t),We.init(e,t)});function N0(e){return Nx(E0,e)}const T0=(e,t)=>{gu.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>cm(e,n)},flatten:{value:n=>lm(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ks,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ks,2)}},isEmpty:{get(){return e.issues.length===0}}})},wt=Q("ZodError",T0,{Parent:Error}),A0=Mi(wt),I0=Li(wt),z0=Po(wt),R0=Oo(wt),P0=fm(wt),O0=hm(wt),D0=pm(wt),M0=mm(wt),L0=gm(wt),F0=xm(wt),$0=ym(wt),B0=vm(wt),Ue=Q("ZodType",(e,t)=>(Be.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:fo(e,"input"),output:fo(e,"output")}}),e.toJSONSchema=Jx(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(on(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)=>sn(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>A0(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>z0(e,n,r),e.parseAsync=async(n,r)=>I0(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>R0(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>P0(e,n,r),e.decode=(n,r)=>O0(e,n,r),e.encodeAsync=async(n,r)=>D0(e,n,r),e.decodeAsync=async(n,r)=>M0(e,n,r),e.safeEncode=(n,r)=>L0(e,n,r),e.safeDecode=(n,r)=>F0(e,n,r),e.safeEncodeAsync=async(n,r)=>$0(e,n,r),e.safeDecodeAsync=async(n,r)=>B0(e,n,r),e.refine=(n,r)=>e.check(M1(n,r)),e.superRefine=n=>e.check(L1(n)),e.overwrite=n=>e.check(Yn(n)),e.optional=()=>ol(e),e.exactOptional=()=>k1(e),e.nullable=()=>sl(e),e.nullish=()=>ol(sl(e)),e.nonoptional=n=>N1(e,n),e.array=()=>Pe(e),e.or=n=>Kt([e,n]),e.and=n=>g1(e,n),e.transform=n=>il(e,b1(n)),e.default=n=>C1(e,n),e.prefault=n=>E1(e,n),e.catch=n=>A1(e,n),e.pipe=n=>il(e,n),e.readonly=()=>R1(e),e.describe=n=>{const r=e.clone();return gr.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return gr.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return gr.get(e);const r=e.clone();return gr.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Mu=Q("_ZodString",(e,t)=>{Fi.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Xx(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(Ox(...r)),e.includes=(...r)=>e.check(Lx(...r)),e.startsWith=(...r)=>e.check(Fx(...r)),e.endsWith=(...r)=>e.check($x(...r)),e.min=(...r)=>e.check(uo(...r)),e.max=(...r)=>e.check(Iu(...r)),e.length=(...r)=>e.check(zu(...r)),e.nonempty=(...r)=>e.check(uo(1,...r)),e.lowercase=r=>e.check(Dx(r)),e.uppercase=r=>e.check(Mx(r)),e.trim=()=>e.check(Ux()),e.normalize=(...r)=>e.check(Bx(...r)),e.toLowerCase=()=>e.check(Zx()),e.toUpperCase=()=>e.check(Vx()),e.slugify=()=>e.check(Wx())}),U0=Q("ZodString",(e,t)=>{Fi.init(e,t),Mu.init(e,t),e.email=n=>e.check(ox(Z0,n)),e.url=n=>e.check(cx(V0,n)),e.jwt=n=>e.check(Sx(s1,n)),e.emoji=n=>e.check(ux(W0,n)),e.guid=n=>e.check(Ya(tl,n)),e.uuid=n=>e.check(sx(Br,n)),e.uuidv4=n=>e.check(ix(Br,n)),e.uuidv6=n=>e.check(ax(Br,n)),e.uuidv7=n=>e.check(lx(Br,n)),e.nanoid=n=>e.check(dx(H0,n)),e.guid=n=>e.check(Ya(tl,n)),e.cuid=n=>e.check(fx(q0,n)),e.cuid2=n=>e.check(hx(K0,n)),e.ulid=n=>e.check(px(G0,n)),e.base64=n=>e.check(wx(n1,n)),e.base64url=n=>e.check(kx(r1,n)),e.xid=n=>e.check(mx(J0,n)),e.ksuid=n=>e.check(gx(Y0,n)),e.ipv4=n=>e.check(xx(X0,n)),e.ipv6=n=>e.check(yx(Q0,n)),e.cidrv4=n=>e.check(vx(e1,n)),e.cidrv6=n=>e.check(bx(t1,n)),e.e164=n=>e.check(_x(o1,n)),e.datetime=n=>e.check(k0(n)),e.date=n=>e.check(S0(n)),e.time=n=>e.check(j0(n)),e.duration=n=>e.check(N0(n))});function K(e){return rx(U0,e)}const We=Q("ZodStringFormat",(e,t)=>{Ze.init(e,t),Mu.init(e,t)}),Z0=Q("ZodEmail",(e,t)=>{lg.init(e,t),We.init(e,t)}),tl=Q("ZodGUID",(e,t)=>{ig.init(e,t),We.init(e,t)}),Br=Q("ZodUUID",(e,t)=>{ag.init(e,t),We.init(e,t)}),V0=Q("ZodURL",(e,t)=>{cg.init(e,t),We.init(e,t)}),W0=Q("ZodEmoji",(e,t)=>{ug.init(e,t),We.init(e,t)}),H0=Q("ZodNanoID",(e,t)=>{dg.init(e,t),We.init(e,t)}),q0=Q("ZodCUID",(e,t)=>{fg.init(e,t),We.init(e,t)}),K0=Q("ZodCUID2",(e,t)=>{hg.init(e,t),We.init(e,t)}),G0=Q("ZodULID",(e,t)=>{pg.init(e,t),We.init(e,t)}),J0=Q("ZodXID",(e,t)=>{mg.init(e,t),We.init(e,t)}),Y0=Q("ZodKSUID",(e,t)=>{gg.init(e,t),We.init(e,t)}),X0=Q("ZodIPv4",(e,t)=>{wg.init(e,t),We.init(e,t)}),Q0=Q("ZodIPv6",(e,t)=>{kg.init(e,t),We.init(e,t)}),e1=Q("ZodCIDRv4",(e,t)=>{_g.init(e,t),We.init(e,t)}),t1=Q("ZodCIDRv6",(e,t)=>{Sg.init(e,t),We.init(e,t)}),n1=Q("ZodBase64",(e,t)=>{Cg.init(e,t),We.init(e,t)}),r1=Q("ZodBase64URL",(e,t)=>{Eg.init(e,t),We.init(e,t)}),o1=Q("ZodE164",(e,t)=>{Ng.init(e,t),We.init(e,t)}),s1=Q("ZodJWT",(e,t)=>{Ag.init(e,t),We.init(e,t)}),Lu=Q("ZodNumber",(e,t)=>{ju.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Qx(e,r,o),e.gt=(r,o)=>e.check(Qa(r,o)),e.gte=(r,o)=>e.check(ms(r,o)),e.min=(r,o)=>e.check(ms(r,o)),e.lt=(r,o)=>e.check(Xa(r,o)),e.lte=(r,o)=>e.check(ps(r,o)),e.max=(r,o)=>e.check(ps(r,o)),e.int=r=>e.check(nl(r)),e.safe=r=>e.check(nl(r)),e.positive=r=>e.check(Qa(0,r)),e.nonnegative=r=>e.check(ms(0,r)),e.negative=r=>e.check(Xa(0,r)),e.nonpositive=r=>e.check(ps(0,r)),e.multipleOf=(r,o)=>e.check(el(r,o)),e.step=(r,o)=>e.check(el(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 ve(e){return Tx(Lu,e)}const i1=Q("ZodNumberFormat",(e,t)=>{Ig.init(e,t),Lu.init(e,t)});function nl(e){return Ax(i1,e)}const a1=Q("ZodBoolean",(e,t)=>{zg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>e0(e,n,r)});function Qe(e){return Ix(a1,e)}const l1=Q("ZodNull",(e,t)=>{Rg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>t0(e,n,r)});function Js(e){return zx(l1,e)}const c1=Q("ZodUnknown",(e,t)=>{Pg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>r0()});function rl(){return Rx(c1)}const u1=Q("ZodNever",(e,t)=>{Og.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>n0(e,n,r)});function d1(e){return Px(u1,e)}const f1=Q("ZodArray",(e,t)=>{Dg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>l0(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(uo(n,r)),e.nonempty=n=>e.check(uo(1,n)),e.max=(n,r)=>e.check(Iu(n,r)),e.length=(n,r)=>e.check(zu(n,r)),e.unwrap=()=>e.element});function Pe(e,t){return Hx(f1,e,t)}const h1=Q("ZodObject",(e,t)=>{Lg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>c0(e,n,r,o),Te(e,"shape",()=>t.shape),e.keyof=()=>lt(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:rl()}),e.loose=()=>e.clone({...e._zod.def,catchall:rl()}),e.strict=()=>e.clone({...e._zod.def,catchall:d1()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>rm(e,n),e.safeExtend=n=>om(e,n),e.merge=n=>sm(e,n),e.pick=n=>tm(e,n),e.omit=n=>nm(e,n),e.partial=(...n)=>im($u,e,n[0]),e.required=(...n)=>am(Bu,e,n[0])});function ae(e,t){const n={type:"object",shape:e??{},...ye(t)};return new h1(n)}const Fu=Q("ZodUnion",(e,t)=>{Tu.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>u0(e,n,r,o),e.options=t.options});function Kt(e,t){return new Fu({type:"union",options:e,...ye(t)})}const p1=Q("ZodDiscriminatedUnion",(e,t)=>{Fu.init(e,t),Fg.init(e,t)});function bn(e,t,n){return new p1({type:"union",options:t,discriminator:e,...ye(n)})}const m1=Q("ZodIntersection",(e,t)=>{$g.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>d0(e,n,r,o)});function g1(e,t){return new m1({type:"intersection",left:e,right:t})}const x1=Q("ZodRecord",(e,t)=>{Bg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>f0(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function Wt(e,t,n){return new x1({type:"record",keyType:e,valueType:t,...ye(n)})}const Ys=Q("ZodEnum",(e,t)=>{Ug.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(r,o,s)=>o0(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 s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Ys({...t,checks:[],...ye(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Ys({...t,checks:[],...ye(o),entries:s})}});function lt(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Ys({type:"enum",entries:n,...ye(t)})}const y1=Q("ZodLiteral",(e,t)=>{Zg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>s0(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 Se(e,t){return new y1({type:"literal",values:Array.isArray(e)?e:[e],...ye(t)})}const v1=Q("ZodTransform",(e,t)=>{Vg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>a0(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new uu(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(kr(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(kr(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function b1(e){return new v1({type:"transform",transform:e})}const $u=Q("ZodOptional",(e,t)=>{Au.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Du(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ol(e){return new $u({type:"optional",innerType:e})}const w1=Q("ZodExactOptional",(e,t)=>{Wg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Du(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function k1(e){return new w1({type:"optional",innerType:e})}const _1=Q("ZodNullable",(e,t)=>{Hg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>h0(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function sl(e){return new _1({type:"nullable",innerType:e})}const S1=Q("ZodDefault",(e,t)=>{qg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>m0(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function C1(e,t){return new S1({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():pu(t)}})}const j1=Q("ZodPrefault",(e,t)=>{Kg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>g0(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function E1(e,t){return new j1({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():pu(t)}})}const Bu=Q("ZodNonOptional",(e,t)=>{Gg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>p0(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function N1(e,t){return new Bu({type:"nonoptional",innerType:e,...ye(t)})}const T1=Q("ZodCatch",(e,t)=>{Jg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>x0(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function A1(e,t){return new T1({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const I1=Q("ZodPipe",(e,t)=>{Yg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>y0(e,n,r,o),e.in=t.in,e.out=t.out});function il(e,t){return new I1({type:"pipe",in:e,out:t})}const z1=Q("ZodReadonly",(e,t)=>{Xg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>v0(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function R1(e){return new z1({type:"readonly",innerType:e})}const P1=Q("ZodLazy",(e,t)=>{Qg.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>b0(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function O1(e){return new P1({type:"lazy",getter:e})}const D1=Q("ZodCustom",(e,t)=>{ex.init(e,t),Ue.init(e,t),e._zod.processJSONSchema=(n,r,o)=>i0(e,n)});function M1(e,t={}){return qx(D1,e,t)}function L1(e){return Kx(e)}const Vn=O1(()=>Kt([K(),ve(),Qe(),Js(),Pe(Vn),Wt(K(),Vn)]));function Uu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function al(e,t){return e===null||typeof e!="object"||Array.isArray(e)?void 0:Object.getOwnPropertyDescriptor(e,t)?.value}const $i=ae({type:K(),ttl:K().optional(),scope:K().optional()}),Bi=ae({type:Se("text"),text:K(),cache_control:$i.optional()}),Zu=ae({type:Se("thinking"),thinking:K(),signature:K().optional()}),F1=ae({type:Se("think"),thinking:K(),signature:K().optional()}),$1=ae({type:Se("base64"),media_type:K(),data:K()}),Vu=ae({type:Se("image"),source:$1}),Wu=ae({type:Se("tool_use"),id:K(),name:K(),input:Wt(K(),Vn)}),B1=bn("type",[Bi,Vu]),U1=ae({type:Se("tool_result"),tool_use_id:K().optional(),content:Kt([K(),Pe(B1)]),is_error:Qe().optional()}),Z1=bn("type",[Bi,Zu,Vu,Wu,U1]),V1=Kt([K(),Pe(Z1)]),W1=ae({role:lt(["user","assistant"]),content:V1}),H1=ae({type:Se("text"),text:K(),cache_control:$i.optional()}),q1=ae({type:K(),properties:Wt(K(),Wt(K(),Vn)).optional(),required:Pe(K()).optional(),additionalProperties:Qe().optional(),$schema:K().optional()}),K1=ae({name:K(),description:K().optional(),input_schema:q1.optional(),cache_control:$i.optional()}),G1=bn("type",[ae({type:Se("enabled"),budget_tokens:ve()}),ae({type:Se("disabled")}),ae({type:Se("adaptive")})]),Hu=ae({model:K(),messages:Pe(W1),system:Pe(H1).optional(),tools:Pe(K1).optional(),max_tokens:ve().optional(),temperature:ve().optional(),stream:Qe().optional(),thinking:G1.optional(),metadata:ae({user_id:K().optional()}).optional()}),Ui=bn("type",[Bi,Zu,F1,Wu]),J1=ae({input_tokens:ve().nullable().optional(),output_tokens:ve().nullable().optional(),cache_creation_input_tokens:ve().nullable().optional(),cache_read_input_tokens:ve().nullable().optional()}).passthrough(),qu=ae({id:K(),type:Se("message"),model:K(),role:Se("assistant"),content:Pe(Ui),stop_reason:K().nullable(),stop_sequence:K().nullable().optional(),usage:J1}).passthrough(),Y1=ae({type:Se("message_start"),message:ae({id:K(),type:Se("message"),model:K(),role:Se("assistant"),content:Pe(Ui),stop_reason:Js(),stop_sequence:Js(),usage:ae({input_tokens:ve(),cache_creation_input_tokens:ve().optional(),cache_read_input_tokens:ve().optional()}).passthrough()})}),X1=ae({type:Se("content_block_start"),index:ve(),content_block:Ui}),Q1=bn("type",[ae({type:Se("text_delta"),text:K()}),ae({type:Se("input_json_delta"),partial_json:K()}),ae({type:Se("thinking_delta"),thinking:K()}),ae({type:Se("signature_delta"),signature:K()})]),ey=ae({type:Se("content_block_delta"),index:ve(),delta:Q1}),ty=ae({type:Se("content_block_stop"),index:ve()}),ny=ae({type:Se("message_delta"),delta:ae({stop_reason:K().nullable(),stop_sequence:K().nullable().optional()}),usage:ae({output_tokens:ve(),input_tokens:ve().optional(),cache_creation_input_tokens:ve().optional(),cache_read_input_tokens:ve().optional()}).passthrough()}),ry=ae({type:Se("message_stop")}),oy=ae({type:Se("ping")}),sy=ae({type:Se("error"),error:ae({type:K(),message:K()})}),iy=bn("type",[Y1,X1,ey,ty,ny,ry,oy,sy]),ay=Kt([K(),Pe(bn("type",[ae({type:Se("text"),text:K()}),ae({type:Se("image_url"),image_url:ae({url:K(),detail:K().optional()})})]))]),Ku=ae({role:lt(["system","user","assistant","tool"]),content:ay,name:K().optional(),reasoning_content:K().optional(),thinking:K().optional(),think:K().optional()}),ly=ae({name:K(),arguments:K()}),Gu=ae({index:ve().optional(),id:K().optional(),type:Se("function").optional(),function:ae({name:K().optional(),arguments:K().optional()})});Ku.extend({content:Kt([K(),Pe(ae({type:Se("text"),text:K()}))]).optional(),function_call:ly.optional(),tool_calls:Pe(Gu).optional()});const cy=ae({type:Se("function"),function:ae({name:K(),description:K().optional(),parameters:Wt(K(),Vn)})}),Ju=ae({model:K(),messages:Pe(Ku),temperature:ve().optional(),max_tokens:ve().optional(),stream:Qe().optional(),tools:Pe(cy).optional(),tool_choice:Kt([lt(["auto","none","required"]),ae({type:Se("auto")}),ae({type:Se("none")}),ae({type:Se("function"),function:ae({name:K()})})]).optional(),user:K().optional()}),Yu=ae({role:lt(["assistant"]).optional(),content:K().nullable().optional(),reasoning_content:K().nullable().optional(),thinking:K().nullable().optional(),think:K().nullable().optional(),function_call:ae({name:K().optional(),arguments:K().optional()}).nullable().optional(),tool_calls:Pe(ae({index:ve(),id:K().optional(),type:Se("function").optional(),function:ae({name:K().optional(),arguments:K().optional()})})).nullable().optional()}),uy=ae({index:ve(),message:ae({role:lt(["assistant"]),content:K().nullable(),reasoning_content:K().optional(),thinking:K().optional(),think:K().optional(),function_call:ae({name:K(),arguments:K()}).nullable().optional(),tool_calls:Pe(Gu).optional()}).optional(),delta:Yu.optional(),finish_reason:K().nullable()}),dy=ae({id:K(),object:Se("chat.completion"),created:ve(),model:K(),choices:Pe(uy),usage:ae({prompt_tokens:ve().nullable().optional(),completion_tokens:ve().nullable().optional(),total_tokens:ve().nullable().optional()}).passthrough(),service_tier:K().nullable().optional(),system_fingerprint:K().nullable().optional()}).passthrough(),fy=ae({id:K(),object:Se("chat.completion.chunk"),created:ve(),model:K(),choices:Pe(ae({index:ve(),delta:Yu,finish_reason:K().nullable().optional()})),usage:ae({prompt_tokens:ve().nullable().optional(),completion_tokens:ve().nullable().optional(),total_tokens:ve().nullable().optional()}).passthrough().nullable().optional()}).passthrough();function Xu(e){try{const t=JSON.parse(e),n=dy.safeParse(t);return n.success?n.data:null}catch{return null}}const Qu=ae({index:ve(),timestamp:ve(),type:K(),data:Vn}),hy=ae({chunks:Pe(Qu),truncated:Qe().optional().default(!1)}),ll=ae({id:ve(),timestamp:K(),method:K(),path:K(),model:K().nullable(),sessionId:K().nullable(),rawRequestBody:K().nullable(),responseStatus:ve().nullable(),responseText:K().nullable(),inputTokens:ve().nullable(),outputTokens:ve().nullable(),cacheCreationInputTokens:ve().nullable(),cacheReadInputTokens:ve().nullable(),elapsedMs:ve().nullable(),streaming:Qe(),userAgent:K().nullable(),origin:K().nullable(),rawHeaders:Wt(K(),K()).optional(),headers:Wt(K(),K()).optional(),apiFormat:lt(["anthropic","openai","unknown"]).default("unknown"),isTest:Qe().optional().default(!1),providerName:K().nullable().optional(),clientPort:ve().nullable().optional(),clientPid:ve().nullable().optional(),clientCwd:K().nullable().optional(),clientProjectFolder:K().nullable().optional(),streamingChunks:hy.optional(),streamingChunksPath:K().nullable().optional(),error:K().nullable().optional()});ae({model:K()});ae({model:K().optional(),metadata:ae({user_id:K().optional()}).passthrough().optional()});const py=ae({error:K()});async function In(e,t){const n=await e.json();return t.parse(n)}async function no(e,t){try{const n=await e.json(),r=py.safeParse(n);return r.success?r.data.error:t}catch{return t}}async function Ar(e,t,n,r){const o=await fetch(e,n);if(!o.ok){const s=r?.(o)??`Request failed with status ${o.status}`;throw new Error(await no(o,s))}return In(o,t)}const Mo=ae({stripClaudeCodeBillingHeader:Qe(),hasSeenOnboarding:Qe().default(!1)}),Xs="/api/config";async function my(e){return Ar(e,Mo,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function gy(e){return Ar(Xs,Mo,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function ed(){const e=zi(Xs,my,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=lu(),n=e.data?.stripClaudeCodeBillingHeader??!1,r=async o=>{await t(Xs,gy({stripClaudeCodeBillingHeader:o}),{optimisticData:{stripClaudeCodeBillingHeader:o},rollbackOnError:!0,revalidate:!1})};return{strip:n,isLoading:e.isLoading,isError:e.error!==void 0,setStrip:r}}const td=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();const xy=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const yy=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase());const cl=e=>{const t=yy(e);return t.charAt(0).toUpperCase()+t.slice(1)};var vy={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 by=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const wy=v.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:i,...a},c)=>v.createElement("svg",{ref:c,...vy,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:td("lucide",o),...!s&&!by(a)&&{"aria-hidden":"true"},...a},[...i.map(([u,d])=>v.createElement(u,d)),...Array.isArray(s)?s:[s]]));const ke=(e,t)=>{const n=v.forwardRef(({className:r,...o},s)=>v.createElement(wy,{ref:s,iconNode:t,className:td(`lucide-${xy(cl(e))}`,`lucide-${e}`,r),...o}));return n.displayName=cl(e),n};const ky=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],_y=ke("arrow-down",ky);const Sy=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Cy=ke("arrow-up",Sy);const jy=[["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"}]],Ey=ke("brain",jy);const Ny=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Gt=ke("check",Ny);const Ty=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],vt=ke("chevron-down",Ty);const Ay=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],bt=ke("chevron-right",Ay);const Iy=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],zy=ke("chevron-up",Iy);const Ry=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],Py=ke("chevrons-down",Ry);const Oy=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Dy=ke("chevrons-up",Oy);const My=[["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"}]],_r=ke("circle-alert",My);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"}]],Fy=ke("circle-check-big",Ly);const $y=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],By=ke("circle-question-mark",$y);const Uy=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],nd=ke("circle-stop",Uy);const Zy=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ir=ke("clock",Zy);const Vy=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],rd=ke("columns-2",Vy);const Wy=[["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"}]],wn=ke("copy",Wy);const Hy=[["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"}]],Zi=ke("download",Hy);const qy=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],Ky=ke("equal",qy);const Gy=[["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"}]],Jy=ke("external-link",Gy);const Yy=[["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"}]],Vi=ke("eye-off",Yy);const Xy=[["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"}]],Wi=ke("eye",Xy);const Qy=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m8 16 2-2-2-2",key:"10vzyd"}],["path",{d:"M12 18h4",key:"1wd2n7"}]],ev=ke("file-terminal",Qy);const tv=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],nv=ke("gauge",tv);const rv=[["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"}]],od=ke("git-compare-arrows",rv);const ov=[["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"}]],sv=ke("globe",ov);const iv=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Sr=ke("loader-circle",iv);const av=[["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"}]],lv=ke("lock",av);const cv=[["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"}]],sd=ke("message-square",cv);const uv=[["path",{d:"M5 12h14",key:"1ays0h"}]],Hi=ke("minus",uv);const dv=[["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"}]],qi=ke("pencil",dv);const fv=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ho=ke("plus",fv);const hv=[["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"}]],pv=ke("radio",hv);const mv=[["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"}]],id=ke("rotate-ccw",mv);const gv=[["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"}]],ad=ke("rotate-cw",gv);const xv=[["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"}]],ld=ke("rows-3",xv);const yv=[["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"}]],vv=ke("scan",yv);const bv=[["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"}]],wv=ke("server",bv);const kv=[["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"}]],_v=ke("settings",kv);const Sv=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],cd=ke("terminal",Sv);const Cv=[["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"}]],ud=ke("trash-2",Cv);const jv=[["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"}]],Ev=ke("triangle-alert",jv);const Nv=[["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"}]],Tv=ke("upload",Nv);const Av=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Iv=ke("user",Av);const zv=[["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"}]],Rv=ke("wifi-off",zv);const Pv=[["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"}]],Ov=ke("wifi",Pv);const Dv=[["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"}]],ul=ke("wrench",Dv);const Mv=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ki=ke("x",Mv);const Lv=[["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"}]],Xn=ke("zap",Lv),Qs="/api/config";async function Fv(e){return Ar(e,Mo,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function $v(e){return Ar(Qs,Mo,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function Bv(){const e=zi(Qs,Fv,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=lu(),n=e.data?.hasSeenOnboarding??!1,r=async()=>{await t(Qs,$v({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:n,isLoading:e.isLoading,markSeen:r}}function Uv(){const{hasSeenOnboarding:e,isLoading:t,markSeen:n}=Bv();return t||e?null:l.jsxs("div",{role:"note","aria-label":"Onboarding tip",className:"mx-4 mt-2 mb-1 flex items-start gap-3 rounded-md border border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"font-medium text-amber-600 dark:text-amber-400 mb-1",children:"Quick tour of the log tabs"}),l.jsxs("ul",{className:"space-y-0.5 text-muted-foreground text-xs leading-relaxed",children:[l.jsxs("li",{children:[l.jsx("strong",{children:"Request"})," / ",l.jsx("strong",{children:"Response"})," — structured views of what the proxy sent and received."]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Headers"})," — request and response headers after proxy processing."]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Raw Headers"})," / ",l.jsx("strong",{children:"Raw Request"})," /"," ",l.jsx("strong",{children:"Raw Response"})," — exact bytes from the upstream provider (visible in Full mode)."]})]})]}),l.jsxs("button",{type:"button",onClick:()=>{n()},className:"inline-flex items-center gap-1.5 text-xs px-2.5 py-1.5 rounded-md border border-amber-500/40 text-amber-700 dark:text-amber-300 hover:bg-amber-500/10 transition-colors shrink-0","aria-label":"Dismiss onboarding tip",children:[l.jsx(Gt,{className:"size-3"}),"Got it"]}),l.jsx("button",{type:"button",onClick:()=>{n()},className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 p-1 -m-1","aria-label":"Dismiss",children:l.jsx(Ki,{className:"size-3.5"})})]})}function Ur(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 gs={exports:{}};var dl;function Zv(){return dl||(dl=1,(function(e,t){(function(n){e.exports=n()})(function(){return(function n(r,o,s){function i(u,d){if(!o[u]){if(!r[u]){var h=typeof Ur=="function"&&Ur;if(!d&&h)return h(u,!0);if(a)return a(u,!0);var p=new Error("Cannot find module '"+u+"'");throw p.code="MODULE_NOT_FOUND",p}var f=o[u]={exports:{}};r[u][0].call(f.exports,function(g){var m=r[u][1][g];return i(m||g)},f,f.exports,n,r,o,s)}return o[u].exports}for(var a=typeof Ur=="function"&&Ur,c=0;c<s.length;c++)i(s[c]);return i})({1:[function(n,r,o){var s=n("./utils"),i=n("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(c){for(var u,d,h,p,f,g,m,x=[],y=0,b=c.length,k=b,S=s.getTypeOf(c)!=="string";y<c.length;)k=b-y,h=S?(u=c[y++],d=y<b?c[y++]:0,y<b?c[y++]:0):(u=c.charCodeAt(y++),d=y<b?c.charCodeAt(y++):0,y<b?c.charCodeAt(y++):0),p=u>>2,f=(3&u)<<4|d>>4,g=1<k?(15&d)<<2|h>>6:64,m=2<k?63&h:64,x.push(a.charAt(p)+a.charAt(f)+a.charAt(g)+a.charAt(m));return x.join("")},o.decode=function(c){var u,d,h,p,f,g,m=0,x=0,y="data:";if(c.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var b,k=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===a.charAt(64)&&k--,c.charAt(c.length-2)===a.charAt(64)&&k--,k%1!=0)throw new Error("Invalid base64 input, bad content length.");for(b=i.uint8array?new Uint8Array(0|k):new Array(0|k);m<c.length;)u=a.indexOf(c.charAt(m++))<<2|(p=a.indexOf(c.charAt(m++)))>>4,d=(15&p)<<4|(f=a.indexOf(c.charAt(m++)))>>2,h=(3&f)<<6|(g=a.indexOf(c.charAt(m++))),b[x++]=u,f!==64&&(b[x++]=d),g!==64&&(b[x++]=h);return b}},{"./support":30,"./utils":32}],2:[function(n,r,o){var s=n("./external"),i=n("./stream/DataWorker"),a=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,h,p,f,g){this.compressedSize=d,this.uncompressedSize=h,this.crc32=p,this.compression=f,this.compressedContent=g}u.prototype={getContentWorker:function(){var d=new i(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),h=this;return d.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new i(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,h,p){return d.pipe(new a).pipe(new c("uncompressedSize")).pipe(h.compressWorker(p)).pipe(new c("compressedSize")).withStreamInfo("compression",h)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,o){var s=n("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},o.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,o){var s=n("./utils"),i=(function(){for(var a,c=[],u=0;u<256;u++){a=u;for(var d=0;d<8;d++)a=1&a?3988292384^a>>>1:a>>>1;c[u]=a}return c})();r.exports=function(a,c){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?(function(u,d,h,p){var f=i,g=p+h;u^=-1;for(var m=p;m<g;m++)u=u>>>8^f[255&(u^d[m])];return-1^u})(0|c,a,a.length,0):(function(u,d,h,p){var f=i,g=p+h;u^=-1;for(var m=p;m<g;m++)u=u>>>8^f[255&(u^d.charCodeAt(m))];return-1^u})(0|c,a,a.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 s=null;s=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:s}},{lie:37}],7:[function(n,r,o){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",i=n("pako"),a=n("./utils"),c=n("./stream/GenericWorker"),u=s?"uint8array":"array";function d(h,p){c.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=p,this.meta={}}o.magic="\b\0",a.inherits(d,c),d.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(u,h.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 i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var h=this;this._pako.onData=function(p){h.push({data:p,meta:h.meta})}},o.compressWorker=function(h){return new d("Deflate",h)},o.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,o){function s(f,g){var m,x="";for(m=0;m<g;m++)x+=String.fromCharCode(255&f),f>>>=8;return x}function i(f,g,m,x,y,b){var k,S,C=f.file,j=f.compression,N=b!==u.utf8encode,T=a.transformTo("string",b(C.name)),A=a.transformTo("string",u.utf8encode(C.name)),O=C.comment,L=a.transformTo("string",b(O)),E=a.transformTo("string",u.utf8encode(O)),M=A.length!==C.name.length,w=E.length!==O.length,D="",H="",B="",q=C.dir,Y=C.date,I={crc32:0,compressedSize:0,uncompressedSize:0};g&&!m||(I.crc32=f.crc32,I.compressedSize=f.compressedSize,I.uncompressedSize=f.uncompressedSize);var W=0;g&&(W|=8),N||!M&&!w||(W|=2048);var V=0,z=0;q&&(V|=16),y==="UNIX"?(z=798,V|=(function(X,de){var te=X;return X||(te=de?16893:33204),(65535&te)<<16})(C.unixPermissions,q)):(z=20,V|=(function(X){return 63&(X||0)})(C.dosPermissions)),k=Y.getUTCHours(),k<<=6,k|=Y.getUTCMinutes(),k<<=5,k|=Y.getUTCSeconds()/2,S=Y.getUTCFullYear()-1980,S<<=4,S|=Y.getUTCMonth()+1,S<<=5,S|=Y.getUTCDate(),M&&(H=s(1,1)+s(d(T),4)+A,D+="up"+s(H.length,2)+H),w&&(B=s(1,1)+s(d(L),4)+E,D+="uc"+s(B.length,2)+B);var oe="";return oe+=`
40
- \0`,oe+=s(W,2),oe+=j.magic,oe+=s(k,2),oe+=s(S,2),oe+=s(I.crc32,4),oe+=s(I.compressedSize,4),oe+=s(I.uncompressedSize,4),oe+=s(T.length,2),oe+=s(D.length,2),{fileRecord:h.LOCAL_FILE_HEADER+oe+T+D,dirRecord:h.CENTRAL_FILE_HEADER+s(z,2)+oe+s(L.length,2)+"\0\0\0\0"+s(V,4)+s(x,4)+T+D+L}}var a=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),h=n("../signature");function p(f,g,m,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=g,this.zipPlatform=m,this.encodeFileName=x,this.streamFiles=f,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(p,c),p.prototype.push=function(f){var g=f.meta.percent||0,m=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(f):(this.bytesWritten+=f.data.length,c.prototype.push.call(this,{data:f.data,meta:{currentFile:this.currentFile,percent:m?(g+100*(m-x-1))/m:100}}))},p.prototype.openedSource=function(f){this.currentSourceOffset=this.bytesWritten,this.currentFile=f.file.name;var g=this.streamFiles&&!f.file.dir;if(g){var m=i(f,g,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(f){this.accumulate=!1;var g=this.streamFiles&&!f.file.dir,m=i(f,g,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),g)this.push({data:(function(x){return h.DATA_DESCRIPTOR+s(x.crc32,4)+s(x.compressedSize,4)+s(x.uncompressedSize,4)})(f),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var f=this.bytesWritten,g=0;g<this.dirRecords.length;g++)this.push({data:this.dirRecords[g],meta:{percent:100}});var m=this.bytesWritten-f,x=(function(y,b,k,S,C){var j=a.transformTo("string",C(S));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(y,2)+s(y,2)+s(b,4)+s(k,4)+s(j.length,2)+j})(this.dirRecords.length,m,f,this.zipComment,this.encodeFileName);this.push({data:x,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(f){this._sources.push(f);var g=this;return f.on("data",function(m){g.processChunk(m)}),f.on("end",function(){g.closedSource(g.previous.streamInfo),g._sources.length?g.prepareNextSource():g.end()}),f.on("error",function(m){g.error(m)}),this},p.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))},p.prototype.error=function(f){var g=this._sources;if(!c.prototype.error.call(this,f))return!1;for(var m=0;m<g.length;m++)try{g[m].error(f)}catch{}return!0},p.prototype.lock=function(){c.prototype.lock.call(this);for(var f=this._sources,g=0;g<f.length;g++)f[g].lock()},r.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,o){var s=n("../compressions"),i=n("./ZipFileWorker");o.generateWorker=function(a,c,u){var d=new i(c.streamFiles,u,c.platform,c.encodeFileName),h=0;try{a.forEach(function(p,f){h++;var g=(function(b,k){var S=b||k,C=s[S];if(!C)throw new Error(S+" is not a valid compression method !");return C})(f.options.compression,c.compression),m=f.options.compressionOptions||c.compressionOptions||{},x=f.dir,y=f.date;f._compressWorker(g,m).withStreamInfo("file",{name:p,dir:x,date:y,comment:f.comment||"",unixPermissions:f.unixPermissions,dosPermissions:f.dosPermissions}).pipe(d)}),d.entriesCount=h}catch(p){d.error(p)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,o){function s(){if(!(this instanceof s))return new s;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 i=new s;for(var a in this)typeof this[a]!="function"&&(i[a]=this[a]);return i}}(s.prototype=n("./object")).loadAsync=n("./load"),s.support=n("./support"),s.defaults=n("./defaults"),s.version="3.10.1",s.loadAsync=function(i,a){return new s().loadAsync(i,a)},s.external=n("./external"),r.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,o){var s=n("./utils"),i=n("./external"),a=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function h(p){return new i.Promise(function(f,g){var m=p.decompressed.getContentWorker().pipe(new u);m.on("error",function(x){g(x)}).on("end",function(){m.streamInfo.crc32!==p.decompressed.crc32?g(new Error("Corrupted zip : CRC32 mismatch")):f()}).resume()})}r.exports=function(p,f){var g=this;return f=s.extend(f||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),d.isNode&&d.isStream(p)?i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",p,!0,f.optimizedBinaryString,f.base64).then(function(m){var x=new c(f);return x.load(m),x}).then(function(m){var x=[i.Promise.resolve(m)],y=m.files;if(f.checkCRC32)for(var b=0;b<y.length;b++)x.push(h(y[b]));return i.Promise.all(x)}).then(function(m){for(var x=m.shift(),y=x.files,b=0;b<y.length;b++){var k=y[b],S=k.fileNameStr,C=s.resolve(k.fileNameStr);g.file(C,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:f.createFolders}),k.dir||(g.file(C).unsafeOriginalName=S)}return x.zipComment.length&&(g.comment=x.zipComment),g})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,o){var s=n("../utils"),i=n("../stream/GenericWorker");function a(c,u){i.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}s.inherits(a,i),a.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()})},a.prototype.pause=function(){return!!i.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,o){var s=n("readable-stream").Readable;function i(a,c,u){s.call(this,c),this._helper=a;var d=this;a.on("data",function(h,p){d.push(h)||d._helper.pause(),u&&u(p)}).on("error",function(h){d.emit("error",h)}).on("end",function(){d.push(null)})}n("../utils").inherits(i,s),i.prototype._read=function(){this._helper.resume()},r.exports=i},{"../utils":32,"readable-stream":16}],14:[function(n,r,o){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,i){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,i);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,i)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var i=new Buffer(s);return i.fill(0),i},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(n,r,o){function s(C,j,N){var T,A=a.getTypeOf(j),O=a.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&&(C=y(C)),O.createFolders&&(T=x(C))&&b.call(this,T,!0);var L=A==="string"&&O.binary===!1&&O.base64===!1;N&&N.binary!==void 0||(O.binary=!L),(j instanceof h&&j.uncompressedSize===0||O.dir||!j||j.length===0)&&(O.base64=!1,O.binary=!0,j="",O.compression="STORE",A="string");var E=null;E=j instanceof h||j instanceof c?j:g.isNode&&g.isStream(j)?new m(C,j):a.prepareContent(C,j,O.binary,O.optimizedBinaryString,O.base64);var M=new p(C,E,O);this.files[C]=M}var i=n("./utf8"),a=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),h=n("./compressedObject"),p=n("./zipObject"),f=n("./generate"),g=n("./nodejsUtils"),m=n("./nodejs/NodejsStreamInputAdapter"),x=function(C){C.slice(-1)==="/"&&(C=C.substring(0,C.length-1));var j=C.lastIndexOf("/");return 0<j?C.substring(0,j):""},y=function(C){return C.slice(-1)!=="/"&&(C+="/"),C},b=function(C,j){return j=j!==void 0?j:d.createFolders,C=y(C),this.files[C]||s.call(this,C,null,{dir:!0,createFolders:j}),this.files[C]};function k(C){return Object.prototype.toString.call(C)==="[object RegExp]"}var S={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(C){var j,N,T;for(j in this.files)T=this.files[j],(N=j.slice(this.root.length,j.length))&&j.slice(0,this.root.length)===this.root&&C(N,T)},filter:function(C){var j=[];return this.forEach(function(N,T){C(N,T)&&j.push(T)}),j},file:function(C,j,N){if(arguments.length!==1)return C=this.root+C,s.call(this,C,j,N),this;if(k(C)){var T=C;return this.filter(function(O,L){return!L.dir&&T.test(O)})}var A=this.files[this.root+C];return A&&!A.dir?A:null},folder:function(C){if(!C)return this;if(k(C))return this.filter(function(A,O){return O.dir&&C.test(A)});var j=this.root+C,N=b.call(this,j),T=this.clone();return T.root=N.name,T},remove:function(C){C=this.root+C;var j=this.files[C];if(j||(C.slice(-1)!=="/"&&(C+="/"),j=this.files[C]),j&&!j.dir)delete this.files[C];else for(var N=this.filter(function(A,O){return O.name.slice(0,C.length)===C}),T=0;T<N.length;T++)delete this.files[N[T].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(C){var j,N={};try{if((N=a.extend(C||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:i.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.");a.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 T=N.comment||this.comment||"";j=f.generateWorker(this,N,T)}catch(A){(j=new c("error")).error(A)}return new u(j,N.type||"string",N.mimeType)},generateAsync:function(C,j){return this.generateInternalStream(C).accumulate(j)},generateNodeStream:function(C,j){return(C=C||{}).type||(C.type="nodebuffer"),this.generateInternalStream(C).toNodejsStream(j)}};r.exports=S},{"./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 s=n("./DataReader");function i(a){s.call(this,a);for(var c=0;c<this.data.length;c++)a[c]=255&a[c]}n("../utils").inherits(i,s),i.prototype.byteAt=function(a){return this.data[this.zero+a]},i.prototype.lastIndexOfSignature=function(a){for(var c=a.charCodeAt(0),u=a.charCodeAt(1),d=a.charCodeAt(2),h=a.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===c&&this.data[p+1]===u&&this.data[p+2]===d&&this.data[p+3]===h)return p-this.zero;return-1},i.prototype.readAndCheckSignature=function(a){var c=a.charCodeAt(0),u=a.charCodeAt(1),d=a.charCodeAt(2),h=a.charCodeAt(3),p=this.readData(4);return c===p[0]&&u===p[1]&&d===p[2]&&h===p[3]},i.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},r.exports=i},{"../utils":32,"./DataReader":18}],18:[function(n,r,o){var s=n("../utils");function i(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}i.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var c,u=0;for(this.checkOffset(a),c=this.index+a-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=a,u},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=i},{"../utils":32}],19:[function(n,r,o){var s=n("./Uint8ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){this.checkOffset(a);var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},r.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,o){var s=n("./DataReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},i.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},i.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},i.prototype.readData=function(a){this.checkOffset(a);var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},r.exports=i},{"../utils":32,"./DataReader":18}],21:[function(n,r,o){var s=n("./ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},r.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){var s=n("../utils"),i=n("../support"),a=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(h){var p=s.getTypeOf(h);return s.checkSupport(p),p!=="string"||i.uint8array?p==="nodebuffer"?new u(h):i.uint8array?new d(s.transformTo("uint8array",h)):new a(s.transformTo("array",h)):new c(h)}},{"../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 s=n("./GenericWorker"),i=n("../utils");function a(c){s.call(this,"ConvertWorker to "+c),this.destType=c}i.inherits(a,s),a.prototype.processChunk=function(c){this.push({data:i.transformTo(this.destType,c.data),meta:c.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,o){var s=n("./GenericWorker"),i=n("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,s),a.prototype.processChunk=function(c){this.streamInfo.crc32=i(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(c){i.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}s.inherits(a,i),a.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}i.prototype.processChunk.call(this,c)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(c){i.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=s.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}s.inherits(a,i),a.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.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=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,o){function s(i){this.name=i||"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}s.prototype={push:function(i){this.emit("data",i)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(i){this.emit("error",i)}return!0},error:function(i){return!this.isFinished&&(this.isPaused?this.generatedError=i:(this.isFinished=!0,this.emit("error",i),this.previous&&this.previous.error(i),this.cleanUp()),!0)},on:function(i,a){return this._listeners[i].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(i,a){if(this._listeners[i])for(var c=0;c<this._listeners[i].length;c++)this._listeners[i][c].call(this,a)},pipe:function(i){return i.registerPrevious(this)},registerPrevious:function(i){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=i.streamInfo,this.mergeStreamInfo(),this.previous=i;var a=this;return i.on("data",function(c){a.processChunk(c)}),i.on("end",function(){a.end()}),i.on("error",function(c){a.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 i=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),i=!0),this.previous&&this.previous.resume(),!i},flush:function(){},processChunk:function(i){this.push(i)},withStreamInfo:function(i,a){return this.extraStreamInfo[i]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var i in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,i)&&(this.streamInfo[i]=this.extraStreamInfo[i])},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 i="Worker "+this.name;return this.previous?this.previous+" -> "+i:i}},r.exports=s},{}],29:[function(n,r,o){var s=n("../utils"),i=n("./ConvertWorker"),a=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),h=null;if(u.nodestream)try{h=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(g,m){return new d.Promise(function(x,y){var b=[],k=g._internalType,S=g._outputType,C=g._mimeType;g.on("data",function(j,N){b.push(j),m&&m(N)}).on("error",function(j){b=[],y(j)}).on("end",function(){try{var j=(function(N,T,A){switch(N){case"blob":return s.newBlob(s.transformTo("arraybuffer",T),A);case"base64":return c.encode(T);default:return s.transformTo(N,T)}})(S,(function(N,T){var A,O=0,L=null,E=0;for(A=0;A<T.length;A++)E+=T[A].length;switch(N){case"string":return T.join("");case"array":return Array.prototype.concat.apply([],T);case"uint8array":for(L=new Uint8Array(E),A=0;A<T.length;A++)L.set(T[A],O),O+=T[A].length;return L;case"nodebuffer":return Buffer.concat(T);default:throw new Error("concat : unsupported type '"+N+"'")}})(k,b),C);x(j)}catch(N){y(N)}b=[]}).resume()})}function f(g,m,x){var y=m;switch(m){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=m,this._mimeType=x,s.checkSupport(y),this._worker=g.pipe(new i(y)),g.lock()}catch(b){this._worker=new a("error"),this._worker.error(b)}}f.prototype={accumulate:function(g){return p(this,g)},on:function(g,m){var x=this;return g==="data"?this._worker.on(g,function(y){m.call(x,y.data,y.meta)}):this._worker.on(g,function(){s.delay(m,arguments,x)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(g){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:this._outputType!=="nodebuffer"},g)}},r.exports=f},{"../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 s=new ArrayBuffer(0);try{o.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(s),o.blob=i.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 s=n("./utils"),i=n("./support"),a=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 h(){c.call(this,"utf-8 decode"),this.leftOver=null}function p(){c.call(this,"utf-8 encode")}o.utf8encode=function(f){return i.nodebuffer?a.newBufferFrom(f,"utf-8"):(function(g){var m,x,y,b,k,S=g.length,C=0;for(b=0;b<S;b++)(64512&(x=g.charCodeAt(b)))==55296&&b+1<S&&(64512&(y=g.charCodeAt(b+1)))==56320&&(x=65536+(x-55296<<10)+(y-56320),b++),C+=x<128?1:x<2048?2:x<65536?3:4;for(m=i.uint8array?new Uint8Array(C):new Array(C),b=k=0;k<C;b++)(64512&(x=g.charCodeAt(b)))==55296&&b+1<S&&(64512&(y=g.charCodeAt(b+1)))==56320&&(x=65536+(x-55296<<10)+(y-56320),b++),x<128?m[k++]=x:(x<2048?m[k++]=192|x>>>6:(x<65536?m[k++]=224|x>>>12:(m[k++]=240|x>>>18,m[k++]=128|x>>>12&63),m[k++]=128|x>>>6&63),m[k++]=128|63&x);return m})(f)},o.utf8decode=function(f){return i.nodebuffer?s.transformTo("nodebuffer",f).toString("utf-8"):(function(g){var m,x,y,b,k=g.length,S=new Array(2*k);for(m=x=0;m<k;)if((y=g[m++])<128)S[x++]=y;else if(4<(b=u[y]))S[x++]=65533,m+=b-1;else{for(y&=b===2?31:b===3?15:7;1<b&&m<k;)y=y<<6|63&g[m++],b--;1<b?S[x++]=65533:y<65536?S[x++]=y:(y-=65536,S[x++]=55296|y>>10&1023,S[x++]=56320|1023&y)}return S.length!==x&&(S.subarray?S=S.subarray(0,x):S.length=x),s.applyFromCharCode(S)})(f=s.transformTo(i.uint8array?"uint8array":"array",f))},s.inherits(h,c),h.prototype.processChunk=function(f){var g=s.transformTo(i.uint8array?"uint8array":"array",f.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var m=g;(g=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),g.set(m,this.leftOver.length)}else g=this.leftOver.concat(g);this.leftOver=null}var x=(function(b,k){var S;for((k=k||b.length)>b.length&&(k=b.length),S=k-1;0<=S&&(192&b[S])==128;)S--;return S<0||S===0?k:S+u[b[S]]>k?S:k})(g),y=g;x!==g.length&&(i.uint8array?(y=g.subarray(0,x),this.leftOver=g.subarray(x,g.length)):(y=g.slice(0,x),this.leftOver=g.slice(x,g.length))),this.push({data:o.utf8decode(y),meta:f.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=h,s.inherits(p,c),p.prototype.processChunk=function(f){this.push({data:o.utf8encode(f.data),meta:f.meta})},o.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,o){var s=n("./support"),i=n("./base64"),a=n("./nodejsUtils"),c=n("./external");function u(m){return m}function d(m,x){for(var y=0;y<m.length;++y)x[y]=255&m.charCodeAt(y);return x}n("setimmediate"),o.newBlob=function(m,x){o.checkSupport("blob");try{return new Blob([m],{type:x})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(m),y.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(m,x,y){var b=[],k=0,S=m.length;if(S<=y)return String.fromCharCode.apply(null,m);for(;k<S;)x==="array"||x==="nodebuffer"?b.push(String.fromCharCode.apply(null,m.slice(k,Math.min(k+y,S)))):b.push(String.fromCharCode.apply(null,m.subarray(k,Math.min(k+y,S)))),k+=y;return b.join("")},stringifyByChar:function(m){for(var x="",y=0;y<m.length;y++)x+=String.fromCharCode(m[y]);return x},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function p(m){var x=65536,y=o.getTypeOf(m),b=!0;if(y==="uint8array"?b=h.applyCanBeUsed.uint8array:y==="nodebuffer"&&(b=h.applyCanBeUsed.nodebuffer),b)for(;1<x;)try{return h.stringifyByChunk(m,y,x)}catch{x=Math.floor(x/2)}return h.stringifyByChar(m)}function f(m,x){for(var y=0;y<m.length;y++)x[y]=m[y];return x}o.applyFromCharCode=p;var g={};g.string={string:u,array:function(m){return d(m,new Array(m.length))},arraybuffer:function(m){return g.string.uint8array(m).buffer},uint8array:function(m){return d(m,new Uint8Array(m.length))},nodebuffer:function(m){return d(m,a.allocBuffer(m.length))}},g.array={string:p,array:u,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(m)}},g.arraybuffer={string:function(m){return p(new Uint8Array(m))},array:function(m){return f(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:u,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(new Uint8Array(m))}},g.uint8array={string:p,array:function(m){return f(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:u,nodebuffer:function(m){return a.newBufferFrom(m)}},g.nodebuffer={string:p,array:function(m){return f(m,new Array(m.length))},arraybuffer:function(m){return g.nodebuffer.uint8array(m).buffer},uint8array:function(m){return f(m,new Uint8Array(m.length))},nodebuffer:u},o.transformTo=function(m,x){if(x=x||"",!m)return x;o.checkSupport(m);var y=o.getTypeOf(x);return g[y][m](x)},o.resolve=function(m){for(var x=m.split("/"),y=[],b=0;b<x.length;b++){var k=x[b];k==="."||k===""&&b!==0&&b!==x.length-1||(k===".."?y.pop():y.push(k))}return y.join("/")},o.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":s.nodebuffer&&a.isBuffer(m)?"nodebuffer":s.uint8array&&m instanceof Uint8Array?"uint8array":s.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},o.checkSupport=function(m){if(!s[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},o.MAX_VALUE_16BITS=65535,o.MAX_VALUE_32BITS=-1,o.pretty=function(m){var x,y,b="";for(y=0;y<(m||"").length;y++)b+="\\x"+((x=m.charCodeAt(y))<16?"0":"")+x.toString(16).toUpperCase();return b},o.delay=function(m,x,y){setImmediate(function(){m.apply(y||null,x||[])})},o.inherits=function(m,x){function y(){}y.prototype=x.prototype,m.prototype=new y},o.extend=function(){var m,x,y={};for(m=0;m<arguments.length;m++)for(x in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],x)&&y[x]===void 0&&(y[x]=arguments[m][x]);return y},o.prepareContent=function(m,x,y,b,k){return c.Promise.resolve(x).then(function(S){return s.blob&&(S instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(S))!==-1)&&typeof FileReader<"u"?new c.Promise(function(C,j){var N=new FileReader;N.onload=function(T){C(T.target.result)},N.onerror=function(T){j(T.target.error)},N.readAsArrayBuffer(S)}):S}).then(function(S){var C=o.getTypeOf(S);return C?(C==="arraybuffer"?S=o.transformTo("uint8array",S):C==="string"&&(k?S=i.decode(S):y&&b!==!0&&(S=(function(j){return d(j,s.uint8array?new Uint8Array(j.length):new Array(j.length))})(S))),S):c.Promise.reject(new Error("Can't read the data of '"+m+"'. 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 s=n("./reader/readerFor"),i=n("./utils"),a=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(h){this.files=[],this.loadOptions=h}d.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+i.pretty(p)+", expected "+i.pretty(h)+")")}},isSignature:function(h,p){var f=this.reader.index;this.reader.setIndex(h);var g=this.reader.readString(4)===p;return this.reader.setIndex(f),g},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 h=this.reader.readData(this.zipCommentLength),p=u.uint8array?"uint8array":"array",f=i.transformTo(p,h);this.zipComment=this.loadOptions.decodeFileName(f)},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 h,p,f,g=this.zip64EndOfCentralSize-44;0<g;)h=this.reader.readInt(2),p=this.reader.readInt(4),f=this.reader.readData(p),this.zip64ExtensibleData[h]={id:h,length:p,value:f}},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 h,p;for(h=0;h<this.files.length;h++)p=this.files[h],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(h=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);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 h=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(h<0)throw this.isSignature(0,a.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(h);var p=h;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===i.MAX_VALUE_16BITS||this.diskWithCentralDirStart===i.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===i.MAX_VALUE_16BITS||this.centralDirRecords===i.MAX_VALUE_16BITS||this.centralDirSize===i.MAX_VALUE_32BITS||this.centralDirOffset===i.MAX_VALUE_32BITS){if(this.zip64=!0,(h=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(h),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.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(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var f=this.centralDirOffset+this.centralDirSize;this.zip64&&(f+=20,f+=12+this.zip64EndOfCentralSize);var g=p-f;if(0<g)this.isSignature(p,a.CENTRAL_FILE_HEADER)||(this.reader.zero=g);else if(g<0)throw new Error("Corrupted zip: missing "+Math.abs(g)+" bytes.")},prepareReader:function(h){this.reader=s(h)},load:function(h){this.prepareReader(h),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 s=n("./reader/readerFor"),i=n("./utils"),a=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),h=n("./support");function p(f,g){this.options=f,this.loadOptions=g}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(f){var g,m;if(f.skip(22),this.fileNameLength=f.readInt(2),m=f.readInt(2),this.fileName=f.readData(this.fileNameLength),f.skip(m),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((g=(function(x){for(var y in d)if(Object.prototype.hasOwnProperty.call(d,y)&&d[y].magic===x)return d[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+i.pretty(this.compressionMethod)+" unknown (inner file : "+i.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,g,f.readData(this.compressedSize))},readCentralPart:function(f){this.versionMadeBy=f.readInt(2),f.skip(2),this.bitFlag=f.readInt(2),this.compressionMethod=f.readString(2),this.date=f.readDate(),this.crc32=f.readInt(4),this.compressedSize=f.readInt(4),this.uncompressedSize=f.readInt(4);var g=f.readInt(2);if(this.extraFieldsLength=f.readInt(2),this.fileCommentLength=f.readInt(2),this.diskNumberStart=f.readInt(2),this.internalFileAttributes=f.readInt(2),this.externalFileAttributes=f.readInt(4),this.localHeaderOffset=f.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");f.skip(g),this.readExtraFields(f),this.parseZIP64ExtraField(f),this.fileComment=f.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var f=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),f==0&&(this.dosPermissions=63&this.externalFileAttributes),f==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var f=s(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=f.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=f.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=f.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=f.readInt(4))}},readExtraFields:function(f){var g,m,x,y=f.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});f.index+4<y;)g=f.readInt(2),m=f.readInt(2),x=f.readData(m),this.extraFields[g]={id:g,length:m,value:x};f.setIndex(y)},handleUTF8:function(){var f=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var g=this.findExtraFieldUnicodePath();if(g!==null)this.fileNameStr=g;else{var m=i.transformTo(f,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var y=i.transformTo(f,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var f=this.extraFields[28789];if(f){var g=s(f.value);return g.readInt(1)!==1||c(this.fileName)!==g.readInt(4)?null:u.utf8decode(g.readData(f.length-5))}return null},findExtraFieldUnicodeComment:function(){var f=this.extraFields[25461];if(f){var g=s(f.value);return g.readInt(1)!==1||c(this.fileComment)!==g.readInt(4)?null:u.utf8decode(g.readData(f.length-5))}return null}},r.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,o){function s(g,m,x){this.name=g,this.dir=x.dir,this.date=x.date,this.comment=x.comment,this.unixPermissions=x.unixPermissions,this.dosPermissions=x.dosPermissions,this._data=m,this._dataBinary=x.binary,this.options={compression:x.compression,compressionOptions:x.compressionOptions}}var i=n("./stream/StreamHelper"),a=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");s.prototype={internalStream:function(g){var m=null,x="string";try{if(!g)throw new Error("No output type specified.");var y=(x=g.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),m=this._decompressWorker();var b=!this._dataBinary;b&&!y&&(m=m.pipe(new c.Utf8EncodeWorker)),!b&&y&&(m=m.pipe(new c.Utf8DecodeWorker))}catch(k){(m=new d("error")).error(k)}return new i(m,x,"")},async:function(g,m){return this.internalStream(g).accumulate(m)},nodeStream:function(g,m){return this.internalStream(g||"nodebuffer").toNodejsStream(m)},_compressWorker:function(g,m){if(this._data instanceof u&&this._data.compression.magic===g.magic)return this._data.getCompressedWorker();var x=this._decompressWorker();return this._dataBinary||(x=x.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(x,g,m)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new a(this._data)}};for(var h=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},f=0;f<h.length;f++)s.prototype[h[f]]=p;r.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,o){(function(s){var i,a,c=s.MutationObserver||s.WebKitMutationObserver;if(c){var u=0,d=new c(g),h=s.document.createTextNode("");d.observe(h,{characterData:!0}),i=function(){h.data=u=++u%2}}else if(s.setImmediate||s.MessageChannel===void 0)i="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var m=s.document.createElement("script");m.onreadystatechange=function(){g(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},s.document.documentElement.appendChild(m)}:function(){setTimeout(g,0)};else{var p=new s.MessageChannel;p.port1.onmessage=g,i=function(){p.port2.postMessage(0)}}var f=[];function g(){var m,x;a=!0;for(var y=f.length;y;){for(x=f,f=[],m=-1;++m<y;)x[m]();y=f.length}a=!1}r.exports=function(m){f.push(m)!==1||a||i()}}).call(this,typeof Lr<"u"?Lr:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,o){var s=n("immediate");function i(){}var a={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function h(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,y!==i&&m(this,y)}function p(y,b,k){this.promise=y,typeof b=="function"&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),typeof k=="function"&&(this.onRejected=k,this.callRejected=this.otherCallRejected)}function f(y,b,k){s(function(){var S;try{S=b(k)}catch(C){return a.reject(y,C)}S===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,S)})}function g(y){var b=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof b=="function")return function(){b.apply(y,arguments)}}function m(y,b){var k=!1;function S(N){k||(k=!0,a.reject(y,N))}function C(N){k||(k=!0,a.resolve(y,N))}var j=x(function(){b(C,S)});j.status==="error"&&S(j.value)}function x(y,b){var k={};try{k.value=y(b),k.status="success"}catch(S){k.status="error",k.value=S}return k}(r.exports=h).prototype.finally=function(y){if(typeof y!="function")return this;var b=this.constructor;return this.then(function(k){return b.resolve(y()).then(function(){return k})},function(k){return b.resolve(y()).then(function(){throw k})})},h.prototype.catch=function(y){return this.then(null,y)},h.prototype.then=function(y,b){if(typeof y!="function"&&this.state===u||typeof b!="function"&&this.state===c)return this;var k=new this.constructor(i);return this.state!==d?f(k,this.state===u?y:b,this.outcome):this.queue.push(new p(k,y,b)),k},p.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},p.prototype.otherCallFulfilled=function(y){f(this.promise,this.onFulfilled,y)},p.prototype.callRejected=function(y){a.reject(this.promise,y)},p.prototype.otherCallRejected=function(y){f(this.promise,this.onRejected,y)},a.resolve=function(y,b){var k=x(g,b);if(k.status==="error")return a.reject(y,k.value);var S=k.value;if(S)m(y,S);else{y.state=u,y.outcome=b;for(var C=-1,j=y.queue.length;++C<j;)y.queue[C].callFulfilled(b)}return y},a.reject=function(y,b){y.state=c,y.outcome=b;for(var k=-1,S=y.queue.length;++k<S;)y.queue[k].callRejected(b);return y},h.resolve=function(y){return y instanceof this?y:a.resolve(new this(i),y)},h.reject=function(y){var b=new this(i);return a.reject(b,y)},h.all=function(y){var b=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=y.length,S=!1;if(!k)return this.resolve([]);for(var C=new Array(k),j=0,N=-1,T=new this(i);++N<k;)A(y[N],N);return T;function A(O,L){b.resolve(O).then(function(E){C[L]=E,++j!==k||S||(S=!0,a.resolve(T,C))},function(E){S||(S=!0,a.reject(T,E))})}},h.race=function(y){var b=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=y.length,S=!1;if(!k)return this.resolve([]);for(var C=-1,j=new this(i);++C<k;)N=y[C],b.resolve(N).then(function(T){S||(S=!0,a.resolve(j,T))},function(T){S||(S=!0,a.reject(j,T))});var N;return j}},{immediate:36}],38:[function(n,r,o){var s={};(0,n("./lib/utils/common").assign)(s,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,o){var s=n("./zlib/deflate"),i=n("./utils/common"),a=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,h=0,p=-1,f=0,g=8;function m(y){if(!(this instanceof m))return new m(y);this.options=i.assign({level:p,method:g,chunkSize:16384,windowBits:15,memLevel:8,strategy:f,to:""},y||{});var b=this.options;b.raw&&0<b.windowBits?b.windowBits=-b.windowBits:b.gzip&&0<b.windowBits&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var k=s.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(k!==h)throw new Error(c[k]);if(b.header&&s.deflateSetHeader(this.strm,b.header),b.dictionary){var S;if(S=typeof b.dictionary=="string"?a.string2buf(b.dictionary):d.call(b.dictionary)==="[object ArrayBuffer]"?new Uint8Array(b.dictionary):b.dictionary,(k=s.deflateSetDictionary(this.strm,S))!==h)throw new Error(c[k]);this._dict_set=!0}}function x(y,b){var k=new m(b);if(k.push(y,!0),k.err)throw k.msg||c[k.err];return k.result}m.prototype.push=function(y,b){var k,S,C=this.strm,j=this.options.chunkSize;if(this.ended)return!1;S=b===~~b?b:b===!0?4:0,typeof y=="string"?C.input=a.string2buf(y):d.call(y)==="[object ArrayBuffer]"?C.input=new Uint8Array(y):C.input=y,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new i.Buf8(j),C.next_out=0,C.avail_out=j),(k=s.deflate(C,S))!==1&&k!==h)return this.onEnd(k),!(this.ended=!0);C.avail_out!==0&&(C.avail_in!==0||S!==4&&S!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(i.shrinkBuf(C.output,C.next_out))):this.onData(i.shrinkBuf(C.output,C.next_out)))}while((0<C.avail_in||C.avail_out===0)&&k!==1);return S===4?(k=s.deflateEnd(this.strm),this.onEnd(k),this.ended=!0,k===h):S!==2||(this.onEnd(h),!(C.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},o.Deflate=m,o.deflate=x,o.deflateRaw=function(y,b){return(b=b||{}).raw=!0,x(y,b)},o.gzip=function(y,b){return(b=b||{}).gzip=!0,x(y,b)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,o){var s=n("./zlib/inflate"),i=n("./utils/common"),a=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),h=n("./zlib/gzheader"),p=Object.prototype.toString;function f(m){if(!(this instanceof f))return new f(m);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},m||{});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)||m&&m.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 y=s.inflateInit2(this.strm,x.windowBits);if(y!==c.Z_OK)throw new Error(u[y]);this.header=new h,s.inflateGetHeader(this.strm,this.header)}function g(m,x){var y=new f(x);if(y.push(m,!0),y.err)throw y.msg||u[y.err];return y.result}f.prototype.push=function(m,x){var y,b,k,S,C,j,N=this.strm,T=this.options.chunkSize,A=this.options.dictionary,O=!1;if(this.ended)return!1;b=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof m=="string"?N.input=a.binstring2buf(m):p.call(m)==="[object ArrayBuffer]"?N.input=new Uint8Array(m):N.input=m,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new i.Buf8(T),N.next_out=0,N.avail_out=T),(y=s.inflate(N,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&A&&(j=typeof A=="string"?a.string2buf(A):p.call(A)==="[object ArrayBuffer]"?new Uint8Array(A):A,y=s.inflateSetDictionary(this.strm,j)),y===c.Z_BUF_ERROR&&O===!0&&(y=c.Z_OK,O=!1),y!==c.Z_STREAM_END&&y!==c.Z_OK)return this.onEnd(y),!(this.ended=!0);N.next_out&&(N.avail_out!==0&&y!==c.Z_STREAM_END&&(N.avail_in!==0||b!==c.Z_FINISH&&b!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(k=a.utf8border(N.output,N.next_out),S=N.next_out-k,C=a.buf2string(N.output,k),N.next_out=S,N.avail_out=T-S,S&&i.arraySet(N.output,N.output,k,S,0),this.onData(C)):this.onData(i.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)&&y!==c.Z_STREAM_END);return y===c.Z_STREAM_END&&(b=c.Z_FINISH),b===c.Z_FINISH?(y=s.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===c.Z_OK):b!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(N.avail_out=0))},f.prototype.onData=function(m){this.chunks.push(m)},f.prototype.onEnd=function(m){m===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},o.Inflate=f,o.inflate=g,o.inflateRaw=function(m,x){return(x=x||{}).raw=!0,g(m,x)},o.ungzip=g},{"./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 s=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 h in d)d.hasOwnProperty(h)&&(c[h]=d[h])}}return c},o.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var i={arraySet:function(c,u,d,h,p){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+h),p);else for(var f=0;f<h;f++)c[p+f]=u[d+f]},flattenChunks:function(c){var u,d,h,p,f,g;for(u=h=0,d=c.length;u<d;u++)h+=c[u].length;for(g=new Uint8Array(h),u=p=0,d=c.length;u<d;u++)f=c[u],g.set(f,p),p+=f.length;return g}},a={arraySet:function(c,u,d,h,p){for(var f=0;f<h;f++)c[p+f]=u[d+f]},flattenChunks:function(c){return[].concat.apply([],c)}};o.setTyped=function(c){c?(o.Buf8=Uint8Array,o.Buf16=Uint16Array,o.Buf32=Int32Array,o.assign(o,i)):(o.Buf8=Array,o.Buf16=Array,o.Buf32=Array,o.assign(o,a))},o.setTyped(s)},{}],42:[function(n,r,o){var s=n("./common"),i=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var c=new s.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(h,p){if(p<65537&&(h.subarray&&a||!h.subarray&&i))return String.fromCharCode.apply(null,s.shrinkBuf(h,p));for(var f="",g=0;g<p;g++)f+=String.fromCharCode(h[g]);return f}c[254]=c[254]=1,o.string2buf=function(h){var p,f,g,m,x,y=h.length,b=0;for(m=0;m<y;m++)(64512&(f=h.charCodeAt(m)))==55296&&m+1<y&&(64512&(g=h.charCodeAt(m+1)))==56320&&(f=65536+(f-55296<<10)+(g-56320),m++),b+=f<128?1:f<2048?2:f<65536?3:4;for(p=new s.Buf8(b),m=x=0;x<b;m++)(64512&(f=h.charCodeAt(m)))==55296&&m+1<y&&(64512&(g=h.charCodeAt(m+1)))==56320&&(f=65536+(f-55296<<10)+(g-56320),m++),f<128?p[x++]=f:(f<2048?p[x++]=192|f>>>6:(f<65536?p[x++]=224|f>>>12:(p[x++]=240|f>>>18,p[x++]=128|f>>>12&63),p[x++]=128|f>>>6&63),p[x++]=128|63&f);return p},o.buf2binstring=function(h){return d(h,h.length)},o.binstring2buf=function(h){for(var p=new s.Buf8(h.length),f=0,g=p.length;f<g;f++)p[f]=h.charCodeAt(f);return p},o.buf2string=function(h,p){var f,g,m,x,y=p||h.length,b=new Array(2*y);for(f=g=0;f<y;)if((m=h[f++])<128)b[g++]=m;else if(4<(x=c[m]))b[g++]=65533,f+=x-1;else{for(m&=x===2?31:x===3?15:7;1<x&&f<y;)m=m<<6|63&h[f++],x--;1<x?b[g++]=65533:m<65536?b[g++]=m:(m-=65536,b[g++]=55296|m>>10&1023,b[g++]=56320|1023&m)}return d(b,g)},o.utf8border=function(h,p){var f;for((p=p||h.length)>h.length&&(p=h.length),f=p-1;0<=f&&(192&h[f])==128;)f--;return f<0||f===0?p:f+c[h[f]]>p?f:p}},{"./common":41}],43:[function(n,r,o){r.exports=function(s,i,a,c){for(var u=65535&s|0,d=s>>>16&65535|0,h=0;a!==0;){for(a-=h=2e3<a?2e3:a;d=d+(u=u+i[c++]|0)|0,--h;);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 s=(function(){for(var i,a=[],c=0;c<256;c++){i=c;for(var u=0;u<8;u++)i=1&i?3988292384^i>>>1:i>>>1;a[c]=i}return a})();r.exports=function(i,a,c,u){var d=s,h=u+c;i^=-1;for(var p=u;p<h;p++)i=i>>>8^d[255&(i^a[p])];return-1^i}},{}],46:[function(n,r,o){var s,i=n("../utils/common"),a=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),h=0,p=4,f=0,g=-2,m=-1,x=4,y=2,b=8,k=9,S=286,C=30,j=19,N=2*S+1,T=15,A=3,O=258,L=O+A+1,E=42,M=113,w=1,D=2,H=3,B=4;function q(_,ee){return _.msg=d[ee],ee}function Y(_){return(_<<1)-(4<_?9:0)}function I(_){for(var ee=_.length;0<=--ee;)_[ee]=0}function W(_){var ee=_.state,G=ee.pending;G>_.avail_out&&(G=_.avail_out),G!==0&&(i.arraySet(_.output,ee.pending_buf,ee.pending_out,G,_.next_out),_.next_out+=G,ee.pending_out+=G,_.total_out+=G,_.avail_out-=G,ee.pending-=G,ee.pending===0&&(ee.pending_out=0))}function V(_,ee){a._tr_flush_block(_,0<=_.block_start?_.block_start:-1,_.strstart-_.block_start,ee),_.block_start=_.strstart,W(_.strm)}function z(_,ee){_.pending_buf[_.pending++]=ee}function oe(_,ee){_.pending_buf[_.pending++]=ee>>>8&255,_.pending_buf[_.pending++]=255&ee}function X(_,ee){var G,P,R=_.max_chain_length,F=_.strstart,U=_.prev_length,J=_.nice_match,$=_.strstart>_.w_size-L?_.strstart-(_.w_size-L):0,ne=_.window,le=_.w_mask,se=_.prev,Z=_.strstart+O,re=ne[F+U-1],ue=ne[F+U];_.prev_length>=_.good_match&&(R>>=2),J>_.lookahead&&(J=_.lookahead);do if(ne[(G=ee)+U]===ue&&ne[G+U-1]===re&&ne[G]===ne[F]&&ne[++G]===ne[F+1]){F+=2,G++;do;while(ne[++F]===ne[++G]&&ne[++F]===ne[++G]&&ne[++F]===ne[++G]&&ne[++F]===ne[++G]&&ne[++F]===ne[++G]&&ne[++F]===ne[++G]&&ne[++F]===ne[++G]&&ne[++F]===ne[++G]&&F<Z);if(P=O-(Z-F),F=Z-O,U<P){if(_.match_start=ee,J<=(U=P))break;re=ne[F+U-1],ue=ne[F+U]}}while((ee=se[ee&le])>$&&--R!=0);return U<=_.lookahead?U:_.lookahead}function de(_){var ee,G,P,R,F,U,J,$,ne,le,se=_.w_size;do{if(R=_.window_size-_.lookahead-_.strstart,_.strstart>=se+(se-L)){for(i.arraySet(_.window,_.window,se,se,0),_.match_start-=se,_.strstart-=se,_.block_start-=se,ee=G=_.hash_size;P=_.head[--ee],_.head[ee]=se<=P?P-se:0,--G;);for(ee=G=se;P=_.prev[--ee],_.prev[ee]=se<=P?P-se:0,--G;);R+=se}if(_.strm.avail_in===0)break;if(U=_.strm,J=_.window,$=_.strstart+_.lookahead,ne=R,le=void 0,le=U.avail_in,ne<le&&(le=ne),G=le===0?0:(U.avail_in-=le,i.arraySet(J,U.input,U.next_in,le,$),U.state.wrap===1?U.adler=c(U.adler,J,le,$):U.state.wrap===2&&(U.adler=u(U.adler,J,le,$)),U.next_in+=le,U.total_in+=le,le),_.lookahead+=G,_.lookahead+_.insert>=A)for(F=_.strstart-_.insert,_.ins_h=_.window[F],_.ins_h=(_.ins_h<<_.hash_shift^_.window[F+1])&_.hash_mask;_.insert&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[F+A-1])&_.hash_mask,_.prev[F&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=F,F++,_.insert--,!(_.lookahead+_.insert<A)););}while(_.lookahead<L&&_.strm.avail_in!==0)}function te(_,ee){for(var G,P;;){if(_.lookahead<L){if(de(_),_.lookahead<L&&ee===h)return w;if(_.lookahead===0)break}if(G=0,_.lookahead>=A&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+A-1])&_.hash_mask,G=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart),G!==0&&_.strstart-G<=_.w_size-L&&(_.match_length=X(_,G)),_.match_length>=A)if(P=a._tr_tally(_,_.strstart-_.match_start,_.match_length-A),_.lookahead-=_.match_length,_.match_length<=_.max_lazy_match&&_.lookahead>=A){for(_.match_length--;_.strstart++,_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+A-1])&_.hash_mask,G=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart,--_.match_length!=0;);_.strstart++}else _.strstart+=_.match_length,_.match_length=0,_.ins_h=_.window[_.strstart],_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+1])&_.hash_mask;else P=a._tr_tally(_,0,_.window[_.strstart]),_.lookahead--,_.strstart++;if(P&&(V(_,!1),_.strm.avail_out===0))return w}return _.insert=_.strstart<A-1?_.strstart:A-1,ee===p?(V(_,!0),_.strm.avail_out===0?H:B):_.last_lit&&(V(_,!1),_.strm.avail_out===0)?w:D}function ce(_,ee){for(var G,P,R;;){if(_.lookahead<L){if(de(_),_.lookahead<L&&ee===h)return w;if(_.lookahead===0)break}if(G=0,_.lookahead>=A&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+A-1])&_.hash_mask,G=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart),_.prev_length=_.match_length,_.prev_match=_.match_start,_.match_length=A-1,G!==0&&_.prev_length<_.max_lazy_match&&_.strstart-G<=_.w_size-L&&(_.match_length=X(_,G),_.match_length<=5&&(_.strategy===1||_.match_length===A&&4096<_.strstart-_.match_start)&&(_.match_length=A-1)),_.prev_length>=A&&_.match_length<=_.prev_length){for(R=_.strstart+_.lookahead-A,P=a._tr_tally(_,_.strstart-1-_.prev_match,_.prev_length-A),_.lookahead-=_.prev_length-1,_.prev_length-=2;++_.strstart<=R&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+A-1])&_.hash_mask,G=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart),--_.prev_length!=0;);if(_.match_available=0,_.match_length=A-1,_.strstart++,P&&(V(_,!1),_.strm.avail_out===0))return w}else if(_.match_available){if((P=a._tr_tally(_,0,_.window[_.strstart-1]))&&V(_,!1),_.strstart++,_.lookahead--,_.strm.avail_out===0)return w}else _.match_available=1,_.strstart++,_.lookahead--}return _.match_available&&(P=a._tr_tally(_,0,_.window[_.strstart-1]),_.match_available=0),_.insert=_.strstart<A-1?_.strstart:A-1,ee===p?(V(_,!0),_.strm.avail_out===0?H:B):_.last_lit&&(V(_,!1),_.strm.avail_out===0)?w:D}function fe(_,ee,G,P,R){this.good_length=_,this.max_lazy=ee,this.nice_length=G,this.max_chain=P,this.func=R}function ge(){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=b,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 i.Buf16(2*N),this.dyn_dtree=new i.Buf16(2*(2*C+1)),this.bl_tree=new i.Buf16(2*(2*j+1)),I(this.dyn_ltree),I(this.dyn_dtree),I(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(T+1),this.heap=new i.Buf16(2*S+1),I(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(2*S+1),I(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(_){var ee;return _&&_.state?(_.total_in=_.total_out=0,_.data_type=y,(ee=_.state).pending=0,ee.pending_out=0,ee.wrap<0&&(ee.wrap=-ee.wrap),ee.status=ee.wrap?E:M,_.adler=ee.wrap===2?0:1,ee.last_flush=h,a._tr_init(ee),f):q(_,g)}function Ee(_){var ee=xe(_);return ee===f&&(function(G){G.window_size=2*G.w_size,I(G.head),G.max_lazy_match=s[G.level].max_lazy,G.good_match=s[G.level].good_length,G.nice_match=s[G.level].nice_length,G.max_chain_length=s[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})(_.state),ee}function Oe(_,ee,G,P,R,F){if(!_)return g;var U=1;if(ee===m&&(ee=6),P<0?(U=0,P=-P):15<P&&(U=2,P-=16),R<1||k<R||G!==b||P<8||15<P||ee<0||9<ee||F<0||x<F)return q(_,g);P===8&&(P=9);var J=new ge;return(_.state=J).strm=_,J.wrap=U,J.gzhead=null,J.w_bits=P,J.w_size=1<<J.w_bits,J.w_mask=J.w_size-1,J.hash_bits=R+7,J.hash_size=1<<J.hash_bits,J.hash_mask=J.hash_size-1,J.hash_shift=~~((J.hash_bits+A-1)/A),J.window=new i.Buf8(2*J.w_size),J.head=new i.Buf16(J.hash_size),J.prev=new i.Buf16(J.w_size),J.lit_bufsize=1<<R+6,J.pending_buf_size=4*J.lit_bufsize,J.pending_buf=new i.Buf8(J.pending_buf_size),J.d_buf=1*J.lit_bufsize,J.l_buf=3*J.lit_bufsize,J.level=ee,J.strategy=F,J.method=G,Ee(_)}s=[new fe(0,0,0,0,function(_,ee){var G=65535;for(G>_.pending_buf_size-5&&(G=_.pending_buf_size-5);;){if(_.lookahead<=1){if(de(_),_.lookahead===0&&ee===h)return w;if(_.lookahead===0)break}_.strstart+=_.lookahead,_.lookahead=0;var P=_.block_start+G;if((_.strstart===0||_.strstart>=P)&&(_.lookahead=_.strstart-P,_.strstart=P,V(_,!1),_.strm.avail_out===0)||_.strstart-_.block_start>=_.w_size-L&&(V(_,!1),_.strm.avail_out===0))return w}return _.insert=0,ee===p?(V(_,!0),_.strm.avail_out===0?H:B):(_.strstart>_.block_start&&(V(_,!1),_.strm.avail_out),w)}),new fe(4,4,8,4,te),new fe(4,5,16,8,te),new fe(4,6,32,32,te),new fe(4,4,16,16,ce),new fe(8,16,32,32,ce),new fe(8,16,128,128,ce),new fe(8,32,128,256,ce),new fe(32,128,258,1024,ce),new fe(32,258,258,4096,ce)],o.deflateInit=function(_,ee){return Oe(_,ee,b,15,8,0)},o.deflateInit2=Oe,o.deflateReset=Ee,o.deflateResetKeep=xe,o.deflateSetHeader=function(_,ee){return _&&_.state?_.state.wrap!==2?g:(_.state.gzhead=ee,f):g},o.deflate=function(_,ee){var G,P,R,F;if(!_||!_.state||5<ee||ee<0)return _?q(_,g):g;if(P=_.state,!_.output||!_.input&&_.avail_in!==0||P.status===666&&ee!==p)return q(_,_.avail_out===0?-5:g);if(P.strm=_,G=P.last_flush,P.last_flush=ee,P.status===E)if(P.wrap===2)_.adler=0,z(P,31),z(P,139),z(P,8),P.gzhead?(z(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)),z(P,255&P.gzhead.time),z(P,P.gzhead.time>>8&255),z(P,P.gzhead.time>>16&255),z(P,P.gzhead.time>>24&255),z(P,P.level===9?2:2<=P.strategy||P.level<2?4:0),z(P,255&P.gzhead.os),P.gzhead.extra&&P.gzhead.extra.length&&(z(P,255&P.gzhead.extra.length),z(P,P.gzhead.extra.length>>8&255)),P.gzhead.hcrc&&(_.adler=u(_.adler,P.pending_buf,P.pending,0)),P.gzindex=0,P.status=69):(z(P,0),z(P,0),z(P,0),z(P,0),z(P,0),z(P,P.level===9?2:2<=P.strategy||P.level<2?4:0),z(P,3),P.status=M);else{var U=b+(P.w_bits-8<<4)<<8;U|=(2<=P.strategy||P.level<2?0:P.level<6?1:P.level===6?2:3)<<6,P.strstart!==0&&(U|=32),U+=31-U%31,P.status=M,oe(P,U),P.strstart!==0&&(oe(P,_.adler>>>16),oe(P,65535&_.adler)),_.adler=1}if(P.status===69)if(P.gzhead.extra){for(R=P.pending;P.gzindex<(65535&P.gzhead.extra.length)&&(P.pending!==P.pending_buf_size||(P.gzhead.hcrc&&P.pending>R&&(_.adler=u(_.adler,P.pending_buf,P.pending-R,R)),W(_),R=P.pending,P.pending!==P.pending_buf_size));)z(P,255&P.gzhead.extra[P.gzindex]),P.gzindex++;P.gzhead.hcrc&&P.pending>R&&(_.adler=u(_.adler,P.pending_buf,P.pending-R,R)),P.gzindex===P.gzhead.extra.length&&(P.gzindex=0,P.status=73)}else P.status=73;if(P.status===73)if(P.gzhead.name){R=P.pending;do{if(P.pending===P.pending_buf_size&&(P.gzhead.hcrc&&P.pending>R&&(_.adler=u(_.adler,P.pending_buf,P.pending-R,R)),W(_),R=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,z(P,F)}while(F!==0);P.gzhead.hcrc&&P.pending>R&&(_.adler=u(_.adler,P.pending_buf,P.pending-R,R)),F===0&&(P.gzindex=0,P.status=91)}else P.status=91;if(P.status===91)if(P.gzhead.comment){R=P.pending;do{if(P.pending===P.pending_buf_size&&(P.gzhead.hcrc&&P.pending>R&&(_.adler=u(_.adler,P.pending_buf,P.pending-R,R)),W(_),R=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,z(P,F)}while(F!==0);P.gzhead.hcrc&&P.pending>R&&(_.adler=u(_.adler,P.pending_buf,P.pending-R,R)),F===0&&(P.status=103)}else P.status=103;if(P.status===103&&(P.gzhead.hcrc?(P.pending+2>P.pending_buf_size&&W(_),P.pending+2<=P.pending_buf_size&&(z(P,255&_.adler),z(P,_.adler>>8&255),_.adler=0,P.status=M)):P.status=M),P.pending!==0){if(W(_),_.avail_out===0)return P.last_flush=-1,f}else if(_.avail_in===0&&Y(ee)<=Y(G)&&ee!==p)return q(_,-5);if(P.status===666&&_.avail_in!==0)return q(_,-5);if(_.avail_in!==0||P.lookahead!==0||ee!==h&&P.status!==666){var J=P.strategy===2?(function($,ne){for(var le;;){if($.lookahead===0&&(de($),$.lookahead===0)){if(ne===h)return w;break}if($.match_length=0,le=a._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++,le&&(V($,!1),$.strm.avail_out===0))return w}return $.insert=0,ne===p?(V($,!0),$.strm.avail_out===0?H:B):$.last_lit&&(V($,!1),$.strm.avail_out===0)?w:D})(P,ee):P.strategy===3?(function($,ne){for(var le,se,Z,re,ue=$.window;;){if($.lookahead<=O){if(de($),$.lookahead<=O&&ne===h)return w;if($.lookahead===0)break}if($.match_length=0,$.lookahead>=A&&0<$.strstart&&(se=ue[Z=$.strstart-1])===ue[++Z]&&se===ue[++Z]&&se===ue[++Z]){re=$.strstart+O;do;while(se===ue[++Z]&&se===ue[++Z]&&se===ue[++Z]&&se===ue[++Z]&&se===ue[++Z]&&se===ue[++Z]&&se===ue[++Z]&&se===ue[++Z]&&Z<re);$.match_length=O-(re-Z),$.match_length>$.lookahead&&($.match_length=$.lookahead)}if($.match_length>=A?(le=a._tr_tally($,1,$.match_length-A),$.lookahead-=$.match_length,$.strstart+=$.match_length,$.match_length=0):(le=a._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++),le&&(V($,!1),$.strm.avail_out===0))return w}return $.insert=0,ne===p?(V($,!0),$.strm.avail_out===0?H:B):$.last_lit&&(V($,!1),$.strm.avail_out===0)?w:D})(P,ee):s[P.level].func(P,ee);if(J!==H&&J!==B||(P.status=666),J===w||J===H)return _.avail_out===0&&(P.last_flush=-1),f;if(J===D&&(ee===1?a._tr_align(P):ee!==5&&(a._tr_stored_block(P,0,0,!1),ee===3&&(I(P.head),P.lookahead===0&&(P.strstart=0,P.block_start=0,P.insert=0))),W(_),_.avail_out===0))return P.last_flush=-1,f}return ee!==p?f:P.wrap<=0?1:(P.wrap===2?(z(P,255&_.adler),z(P,_.adler>>8&255),z(P,_.adler>>16&255),z(P,_.adler>>24&255),z(P,255&_.total_in),z(P,_.total_in>>8&255),z(P,_.total_in>>16&255),z(P,_.total_in>>24&255)):(oe(P,_.adler>>>16),oe(P,65535&_.adler)),W(_),0<P.wrap&&(P.wrap=-P.wrap),P.pending!==0?f:1)},o.deflateEnd=function(_){var ee;return _&&_.state?(ee=_.state.status)!==E&&ee!==69&&ee!==73&&ee!==91&&ee!==103&&ee!==M&&ee!==666?q(_,g):(_.state=null,ee===M?q(_,-3):f):g},o.deflateSetDictionary=function(_,ee){var G,P,R,F,U,J,$,ne,le=ee.length;if(!_||!_.state||(F=(G=_.state).wrap)===2||F===1&&G.status!==E||G.lookahead)return g;for(F===1&&(_.adler=c(_.adler,ee,le,0)),G.wrap=0,le>=G.w_size&&(F===0&&(I(G.head),G.strstart=0,G.block_start=0,G.insert=0),ne=new i.Buf8(G.w_size),i.arraySet(ne,ee,le-G.w_size,G.w_size,0),ee=ne,le=G.w_size),U=_.avail_in,J=_.next_in,$=_.input,_.avail_in=le,_.next_in=0,_.input=ee,de(G);G.lookahead>=A;){for(P=G.strstart,R=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++,--R;);G.strstart=P,G.lookahead=A-1,de(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,_.next_in=J,_.input=$,_.avail_in=U,G.wrap=F,f},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(s,i){var a,c,u,d,h,p,f,g,m,x,y,b,k,S,C,j,N,T,A,O,L,E,M,w,D;a=s.state,c=s.next_in,w=s.input,u=c+(s.avail_in-5),d=s.next_out,D=s.output,h=d-(i-s.avail_out),p=d+(s.avail_out-257),f=a.dmax,g=a.wsize,m=a.whave,x=a.wnext,y=a.window,b=a.hold,k=a.bits,S=a.lencode,C=a.distcode,j=(1<<a.lenbits)-1,N=(1<<a.distbits)-1;e:do{k<15&&(b+=w[c++]<<k,k+=8,b+=w[c++]<<k,k+=8),T=S[b&j];t:for(;;){if(b>>>=A=T>>>24,k-=A,(A=T>>>16&255)===0)D[d++]=65535&T;else{if(!(16&A)){if((64&A)==0){T=S[(65535&T)+(b&(1<<A)-1)];continue t}if(32&A){a.mode=12;break e}s.msg="invalid literal/length code",a.mode=30;break e}O=65535&T,(A&=15)&&(k<A&&(b+=w[c++]<<k,k+=8),O+=b&(1<<A)-1,b>>>=A,k-=A),k<15&&(b+=w[c++]<<k,k+=8,b+=w[c++]<<k,k+=8),T=C[b&N];n:for(;;){if(b>>>=A=T>>>24,k-=A,!(16&(A=T>>>16&255))){if((64&A)==0){T=C[(65535&T)+(b&(1<<A)-1)];continue n}s.msg="invalid distance code",a.mode=30;break e}if(L=65535&T,k<(A&=15)&&(b+=w[c++]<<k,(k+=8)<A&&(b+=w[c++]<<k,k+=8)),f<(L+=b&(1<<A)-1)){s.msg="invalid distance too far back",a.mode=30;break e}if(b>>>=A,k-=A,(A=d-h)<L){if(m<(A=L-A)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(M=y,(E=0)===x){if(E+=g-A,A<O){for(O-=A;D[d++]=y[E++],--A;);E=d-L,M=D}}else if(x<A){if(E+=g+x-A,(A-=x)<O){for(O-=A;D[d++]=y[E++],--A;);if(E=0,x<O){for(O-=A=x;D[d++]=y[E++],--A;);E=d-L,M=D}}}else if(E+=x-A,A<O){for(O-=A;D[d++]=y[E++],--A;);E=d-L,M=D}for(;2<O;)D[d++]=M[E++],D[d++]=M[E++],D[d++]=M[E++],O-=3;O&&(D[d++]=M[E++],1<O&&(D[d++]=M[E++]))}else{for(E=d-L;D[d++]=D[E++],D[d++]=D[E++],D[d++]=D[E++],2<(O-=3););O&&(D[d++]=D[E++],1<O&&(D[d++]=D[E++]))}break}}break}}while(c<u&&d<p);c-=O=k>>3,b&=(1<<(k-=O<<3))-1,s.next_in=c,s.next_out=d,s.avail_in=c<u?u-c+5:5-(c-u),s.avail_out=d<p?p-d+257:257-(d-p),a.hold=b,a.bits=k}},{}],49:[function(n,r,o){var s=n("../utils/common"),i=n("./adler32"),a=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,h=2,p=0,f=-2,g=1,m=852,x=592;function y(E){return(E>>>24&255)+(E>>>8&65280)+((65280&E)<<8)+((255&E)<<24)}function b(){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 s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function k(E){var M;return E&&E.state?(M=E.state,E.total_in=E.total_out=M.total=0,E.msg="",M.wrap&&(E.adler=1&M.wrap),M.mode=g,M.last=0,M.havedict=0,M.dmax=32768,M.head=null,M.hold=0,M.bits=0,M.lencode=M.lendyn=new s.Buf32(m),M.distcode=M.distdyn=new s.Buf32(x),M.sane=1,M.back=-1,p):f}function S(E){var M;return E&&E.state?((M=E.state).wsize=0,M.whave=0,M.wnext=0,k(E)):f}function C(E,M){var w,D;return E&&E.state?(D=E.state,M<0?(w=0,M=-M):(w=1+(M>>4),M<48&&(M&=15)),M&&(M<8||15<M)?f:(D.window!==null&&D.wbits!==M&&(D.window=null),D.wrap=w,D.wbits=M,S(E))):f}function j(E,M){var w,D;return E?(D=new b,(E.state=D).window=null,(w=C(E,M))!==p&&(E.state=null),w):f}var N,T,A=!0;function O(E){if(A){var M;for(N=new s.Buf32(512),T=new s.Buf32(32),M=0;M<144;)E.lens[M++]=8;for(;M<256;)E.lens[M++]=9;for(;M<280;)E.lens[M++]=7;for(;M<288;)E.lens[M++]=8;for(u(d,E.lens,0,288,N,0,E.work,{bits:9}),M=0;M<32;)E.lens[M++]=5;u(h,E.lens,0,32,T,0,E.work,{bits:5}),A=!1}E.lencode=N,E.lenbits=9,E.distcode=T,E.distbits=5}function L(E,M,w,D){var H,B=E.state;return B.window===null&&(B.wsize=1<<B.wbits,B.wnext=0,B.whave=0,B.window=new s.Buf8(B.wsize)),D>=B.wsize?(s.arraySet(B.window,M,w-B.wsize,B.wsize,0),B.wnext=0,B.whave=B.wsize):(D<(H=B.wsize-B.wnext)&&(H=D),s.arraySet(B.window,M,w-D,H,B.wnext),(D-=H)?(s.arraySet(B.window,M,w-D,D,0),B.wnext=D,B.whave=B.wsize):(B.wnext+=H,B.wnext===B.wsize&&(B.wnext=0),B.whave<B.wsize&&(B.whave+=H))),0}o.inflateReset=S,o.inflateReset2=C,o.inflateResetKeep=k,o.inflateInit=function(E){return j(E,15)},o.inflateInit2=j,o.inflate=function(E,M){var w,D,H,B,q,Y,I,W,V,z,oe,X,de,te,ce,fe,ge,xe,Ee,Oe,_,ee,G,P,R=0,F=new s.Buf8(4),U=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!E||!E.state||!E.output||!E.input&&E.avail_in!==0)return f;(w=E.state).mode===12&&(w.mode=13),q=E.next_out,H=E.output,I=E.avail_out,B=E.next_in,D=E.input,Y=E.avail_in,W=w.hold,V=w.bits,z=Y,oe=I,ee=p;e:for(;;)switch(w.mode){case g:if(w.wrap===0){w.mode=13;break}for(;V<16;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(2&w.wrap&&W===35615){F[w.check=0]=255&W,F[1]=W>>>8&255,w.check=a(w.check,F,2,0),V=W=0,w.mode=2;break}if(w.flags=0,w.head&&(w.head.done=!1),!(1&w.wrap)||(((255&W)<<8)+(W>>8))%31){E.msg="incorrect header check",w.mode=30;break}if((15&W)!=8){E.msg="unknown compression method",w.mode=30;break}if(V-=4,_=8+(15&(W>>>=4)),w.wbits===0)w.wbits=_;else if(_>w.wbits){E.msg="invalid window size",w.mode=30;break}w.dmax=1<<_,E.adler=w.check=1,w.mode=512&W?10:12,V=W=0;break;case 2:for(;V<16;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(w.flags=W,(255&w.flags)!=8){E.msg="unknown compression method",w.mode=30;break}if(57344&w.flags){E.msg="unknown header flags set",w.mode=30;break}w.head&&(w.head.text=W>>8&1),512&w.flags&&(F[0]=255&W,F[1]=W>>>8&255,w.check=a(w.check,F,2,0)),V=W=0,w.mode=3;case 3:for(;V<32;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}w.head&&(w.head.time=W),512&w.flags&&(F[0]=255&W,F[1]=W>>>8&255,F[2]=W>>>16&255,F[3]=W>>>24&255,w.check=a(w.check,F,4,0)),V=W=0,w.mode=4;case 4:for(;V<16;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}w.head&&(w.head.xflags=255&W,w.head.os=W>>8),512&w.flags&&(F[0]=255&W,F[1]=W>>>8&255,w.check=a(w.check,F,2,0)),V=W=0,w.mode=5;case 5:if(1024&w.flags){for(;V<16;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}w.length=W,w.head&&(w.head.extra_len=W),512&w.flags&&(F[0]=255&W,F[1]=W>>>8&255,w.check=a(w.check,F,2,0)),V=W=0}else w.head&&(w.head.extra=null);w.mode=6;case 6:if(1024&w.flags&&(Y<(X=w.length)&&(X=Y),X&&(w.head&&(_=w.head.extra_len-w.length,w.head.extra||(w.head.extra=new Array(w.head.extra_len)),s.arraySet(w.head.extra,D,B,X,_)),512&w.flags&&(w.check=a(w.check,D,X,B)),Y-=X,B+=X,w.length-=X),w.length))break e;w.length=0,w.mode=7;case 7:if(2048&w.flags){if(Y===0)break e;for(X=0;_=D[B+X++],w.head&&_&&w.length<65536&&(w.head.name+=String.fromCharCode(_)),_&&X<Y;);if(512&w.flags&&(w.check=a(w.check,D,X,B)),Y-=X,B+=X,_)break e}else w.head&&(w.head.name=null);w.length=0,w.mode=8;case 8:if(4096&w.flags){if(Y===0)break e;for(X=0;_=D[B+X++],w.head&&_&&w.length<65536&&(w.head.comment+=String.fromCharCode(_)),_&&X<Y;);if(512&w.flags&&(w.check=a(w.check,D,X,B)),Y-=X,B+=X,_)break e}else w.head&&(w.head.comment=null);w.mode=9;case 9:if(512&w.flags){for(;V<16;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(W!==(65535&w.check)){E.msg="header crc mismatch",w.mode=30;break}V=W=0}w.head&&(w.head.hcrc=w.flags>>9&1,w.head.done=!0),E.adler=w.check=0,w.mode=12;break;case 10:for(;V<32;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}E.adler=w.check=y(W),V=W=0,w.mode=11;case 11:if(w.havedict===0)return E.next_out=q,E.avail_out=I,E.next_in=B,E.avail_in=Y,w.hold=W,w.bits=V,2;E.adler=w.check=1,w.mode=12;case 12:if(M===5||M===6)break e;case 13:if(w.last){W>>>=7&V,V-=7&V,w.mode=27;break}for(;V<3;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}switch(w.last=1&W,V-=1,3&(W>>>=1)){case 0:w.mode=14;break;case 1:if(O(w),w.mode=20,M!==6)break;W>>>=2,V-=2;break e;case 2:w.mode=17;break;case 3:E.msg="invalid block type",w.mode=30}W>>>=2,V-=2;break;case 14:for(W>>>=7&V,V-=7&V;V<32;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if((65535&W)!=(W>>>16^65535)){E.msg="invalid stored block lengths",w.mode=30;break}if(w.length=65535&W,V=W=0,w.mode=15,M===6)break e;case 15:w.mode=16;case 16:if(X=w.length){if(Y<X&&(X=Y),I<X&&(X=I),X===0)break e;s.arraySet(H,D,B,X,q),Y-=X,B+=X,I-=X,q+=X,w.length-=X;break}w.mode=12;break;case 17:for(;V<14;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(w.nlen=257+(31&W),W>>>=5,V-=5,w.ndist=1+(31&W),W>>>=5,V-=5,w.ncode=4+(15&W),W>>>=4,V-=4,286<w.nlen||30<w.ndist){E.msg="too many length or distance symbols",w.mode=30;break}w.have=0,w.mode=18;case 18:for(;w.have<w.ncode;){for(;V<3;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}w.lens[U[w.have++]]=7&W,W>>>=3,V-=3}for(;w.have<19;)w.lens[U[w.have++]]=0;if(w.lencode=w.lendyn,w.lenbits=7,G={bits:w.lenbits},ee=u(0,w.lens,0,19,w.lencode,0,w.work,G),w.lenbits=G.bits,ee){E.msg="invalid code lengths set",w.mode=30;break}w.have=0,w.mode=19;case 19:for(;w.have<w.nlen+w.ndist;){for(;fe=(R=w.lencode[W&(1<<w.lenbits)-1])>>>16&255,ge=65535&R,!((ce=R>>>24)<=V);){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(ge<16)W>>>=ce,V-=ce,w.lens[w.have++]=ge;else{if(ge===16){for(P=ce+2;V<P;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(W>>>=ce,V-=ce,w.have===0){E.msg="invalid bit length repeat",w.mode=30;break}_=w.lens[w.have-1],X=3+(3&W),W>>>=2,V-=2}else if(ge===17){for(P=ce+3;V<P;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}V-=ce,_=0,X=3+(7&(W>>>=ce)),W>>>=3,V-=3}else{for(P=ce+7;V<P;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}V-=ce,_=0,X=11+(127&(W>>>=ce)),W>>>=7,V-=7}if(w.have+X>w.nlen+w.ndist){E.msg="invalid bit length repeat",w.mode=30;break}for(;X--;)w.lens[w.have++]=_}}if(w.mode===30)break;if(w.lens[256]===0){E.msg="invalid code -- missing end-of-block",w.mode=30;break}if(w.lenbits=9,G={bits:w.lenbits},ee=u(d,w.lens,0,w.nlen,w.lencode,0,w.work,G),w.lenbits=G.bits,ee){E.msg="invalid literal/lengths set",w.mode=30;break}if(w.distbits=6,w.distcode=w.distdyn,G={bits:w.distbits},ee=u(h,w.lens,w.nlen,w.ndist,w.distcode,0,w.work,G),w.distbits=G.bits,ee){E.msg="invalid distances set",w.mode=30;break}if(w.mode=20,M===6)break e;case 20:w.mode=21;case 21:if(6<=Y&&258<=I){E.next_out=q,E.avail_out=I,E.next_in=B,E.avail_in=Y,w.hold=W,w.bits=V,c(E,oe),q=E.next_out,H=E.output,I=E.avail_out,B=E.next_in,D=E.input,Y=E.avail_in,W=w.hold,V=w.bits,w.mode===12&&(w.back=-1);break}for(w.back=0;fe=(R=w.lencode[W&(1<<w.lenbits)-1])>>>16&255,ge=65535&R,!((ce=R>>>24)<=V);){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(fe&&(240&fe)==0){for(xe=ce,Ee=fe,Oe=ge;fe=(R=w.lencode[Oe+((W&(1<<xe+Ee)-1)>>xe)])>>>16&255,ge=65535&R,!(xe+(ce=R>>>24)<=V);){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}W>>>=xe,V-=xe,w.back+=xe}if(W>>>=ce,V-=ce,w.back+=ce,w.length=ge,fe===0){w.mode=26;break}if(32&fe){w.back=-1,w.mode=12;break}if(64&fe){E.msg="invalid literal/length code",w.mode=30;break}w.extra=15&fe,w.mode=22;case 22:if(w.extra){for(P=w.extra;V<P;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}w.length+=W&(1<<w.extra)-1,W>>>=w.extra,V-=w.extra,w.back+=w.extra}w.was=w.length,w.mode=23;case 23:for(;fe=(R=w.distcode[W&(1<<w.distbits)-1])>>>16&255,ge=65535&R,!((ce=R>>>24)<=V);){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if((240&fe)==0){for(xe=ce,Ee=fe,Oe=ge;fe=(R=w.distcode[Oe+((W&(1<<xe+Ee)-1)>>xe)])>>>16&255,ge=65535&R,!(xe+(ce=R>>>24)<=V);){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}W>>>=xe,V-=xe,w.back+=xe}if(W>>>=ce,V-=ce,w.back+=ce,64&fe){E.msg="invalid distance code",w.mode=30;break}w.offset=ge,w.extra=15&fe,w.mode=24;case 24:if(w.extra){for(P=w.extra;V<P;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}w.offset+=W&(1<<w.extra)-1,W>>>=w.extra,V-=w.extra,w.back+=w.extra}if(w.offset>w.dmax){E.msg="invalid distance too far back",w.mode=30;break}w.mode=25;case 25:if(I===0)break e;if(X=oe-I,w.offset>X){if((X=w.offset-X)>w.whave&&w.sane){E.msg="invalid distance too far back",w.mode=30;break}de=X>w.wnext?(X-=w.wnext,w.wsize-X):w.wnext-X,X>w.length&&(X=w.length),te=w.window}else te=H,de=q-w.offset,X=w.length;for(I<X&&(X=I),I-=X,w.length-=X;H[q++]=te[de++],--X;);w.length===0&&(w.mode=21);break;case 26:if(I===0)break e;H[q++]=w.length,I--,w.mode=21;break;case 27:if(w.wrap){for(;V<32;){if(Y===0)break e;Y--,W|=D[B++]<<V,V+=8}if(oe-=I,E.total_out+=oe,w.total+=oe,oe&&(E.adler=w.check=w.flags?a(w.check,H,oe,q-oe):i(w.check,H,oe,q-oe)),oe=I,(w.flags?W:y(W))!==w.check){E.msg="incorrect data check",w.mode=30;break}V=W=0}w.mode=28;case 28:if(w.wrap&&w.flags){for(;V<32;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(W!==(4294967295&w.total)){E.msg="incorrect length check",w.mode=30;break}V=W=0}w.mode=29;case 29:ee=1;break e;case 30:ee=-3;break e;case 31:return-4;default:return f}return E.next_out=q,E.avail_out=I,E.next_in=B,E.avail_in=Y,w.hold=W,w.bits=V,(w.wsize||oe!==E.avail_out&&w.mode<30&&(w.mode<27||M!==4))&&L(E,E.output,E.next_out,oe-E.avail_out)?(w.mode=31,-4):(z-=E.avail_in,oe-=E.avail_out,E.total_in+=z,E.total_out+=oe,w.total+=oe,w.wrap&&oe&&(E.adler=w.check=w.flags?a(w.check,H,oe,E.next_out-oe):i(w.check,H,oe,E.next_out-oe)),E.data_type=w.bits+(w.last?64:0)+(w.mode===12?128:0)+(w.mode===20||w.mode===15?256:0),(z==0&&oe===0||M===4)&&ee===p&&(ee=-5),ee)},o.inflateEnd=function(E){if(!E||!E.state)return f;var M=E.state;return M.window&&(M.window=null),E.state=null,p},o.inflateGetHeader=function(E,M){var w;return E&&E.state?(2&(w=E.state).wrap)==0?f:((w.head=M).done=!1,p):f},o.inflateSetDictionary=function(E,M){var w,D=M.length;return E&&E.state?(w=E.state).wrap!==0&&w.mode!==11?f:w.mode===11&&i(1,M,D,0)!==w.check?-3:L(E,M,D,D)?(w.mode=31,-4):(w.havedict=1,p):f},o.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,o){var s=n("../utils/common"),i=[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],a=[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,h,p,f,g,m,x,y){var b,k,S,C,j,N,T,A,O,L=y.bits,E=0,M=0,w=0,D=0,H=0,B=0,q=0,Y=0,I=0,W=0,V=null,z=0,oe=new s.Buf16(16),X=new s.Buf16(16),de=null,te=0;for(E=0;E<=15;E++)oe[E]=0;for(M=0;M<f;M++)oe[h[p+M]]++;for(H=L,D=15;1<=D&&oe[D]===0;D--);if(D<H&&(H=D),D===0)return g[m++]=20971520,g[m++]=20971520,y.bits=1,0;for(w=1;w<D&&oe[w]===0;w++);for(H<w&&(H=w),E=Y=1;E<=15;E++)if(Y<<=1,(Y-=oe[E])<0)return-1;if(0<Y&&(d===0||D!==1))return-1;for(X[1]=0,E=1;E<15;E++)X[E+1]=X[E]+oe[E];for(M=0;M<f;M++)h[p+M]!==0&&(x[X[h[p+M]]++]=M);if(N=d===0?(V=de=x,19):d===1?(V=i,z-=257,de=a,te-=257,256):(V=c,de=u,-1),E=w,j=m,q=M=W=0,S=-1,C=(I=1<<(B=H))-1,d===1&&852<I||d===2&&592<I)return 1;for(;;){for(T=E-q,O=x[M]<N?(A=0,x[M]):x[M]>N?(A=de[te+x[M]],V[z+x[M]]):(A=96,0),b=1<<E-q,w=k=1<<B;g[j+(W>>q)+(k-=b)]=T<<24|A<<16|O|0,k!==0;);for(b=1<<E-1;W&b;)b>>=1;if(b!==0?(W&=b-1,W+=b):W=0,M++,--oe[E]==0){if(E===D)break;E=h[p+x[M]]}if(H<E&&(W&C)!==S){for(q===0&&(q=H),j+=w,Y=1<<(B=E-q);B+q<D&&!((Y-=oe[B+q])<=0);)B++,Y<<=1;if(I+=1<<B,d===1&&852<I||d===2&&592<I)return 1;g[S=W&C]=H<<24|B<<16|j-m|0}}return W!==0&&(g[j+W]=E-q<<24|64<<16|0),y.bits=H,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 s=n("../utils/common"),i=0,a=1;function c(R){for(var F=R.length;0<=--F;)R[F]=0}var u=0,d=29,h=256,p=h+1+d,f=30,g=19,m=2*p+1,x=15,y=16,b=7,k=256,S=16,C=17,j=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],T=[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],L=new Array(2*(p+2));c(L);var E=new Array(2*f);c(E);var M=new Array(512);c(M);var w=new Array(256);c(w);var D=new Array(d);c(D);var H,B,q,Y=new Array(f);function I(R,F,U,J,$){this.static_tree=R,this.extra_bits=F,this.extra_base=U,this.elems=J,this.max_length=$,this.has_stree=R&&R.length}function W(R,F){this.dyn_tree=R,this.max_code=0,this.stat_desc=F}function V(R){return R<256?M[R]:M[256+(R>>>7)]}function z(R,F){R.pending_buf[R.pending++]=255&F,R.pending_buf[R.pending++]=F>>>8&255}function oe(R,F,U){R.bi_valid>y-U?(R.bi_buf|=F<<R.bi_valid&65535,z(R,R.bi_buf),R.bi_buf=F>>y-R.bi_valid,R.bi_valid+=U-y):(R.bi_buf|=F<<R.bi_valid&65535,R.bi_valid+=U)}function X(R,F,U){oe(R,U[2*F],U[2*F+1])}function de(R,F){for(var U=0;U|=1&R,R>>>=1,U<<=1,0<--F;);return U>>>1}function te(R,F,U){var J,$,ne=new Array(x+1),le=0;for(J=1;J<=x;J++)ne[J]=le=le+U[J-1]<<1;for($=0;$<=F;$++){var se=R[2*$+1];se!==0&&(R[2*$]=de(ne[se]++,se))}}function ce(R){var F;for(F=0;F<p;F++)R.dyn_ltree[2*F]=0;for(F=0;F<f;F++)R.dyn_dtree[2*F]=0;for(F=0;F<g;F++)R.bl_tree[2*F]=0;R.dyn_ltree[2*k]=1,R.opt_len=R.static_len=0,R.last_lit=R.matches=0}function fe(R){8<R.bi_valid?z(R,R.bi_buf):0<R.bi_valid&&(R.pending_buf[R.pending++]=R.bi_buf),R.bi_buf=0,R.bi_valid=0}function ge(R,F,U,J){var $=2*F,ne=2*U;return R[$]<R[ne]||R[$]===R[ne]&&J[F]<=J[U]}function xe(R,F,U){for(var J=R.heap[U],$=U<<1;$<=R.heap_len&&($<R.heap_len&&ge(F,R.heap[$+1],R.heap[$],R.depth)&&$++,!ge(F,J,R.heap[$],R.depth));)R.heap[U]=R.heap[$],U=$,$<<=1;R.heap[U]=J}function Ee(R,F,U){var J,$,ne,le,se=0;if(R.last_lit!==0)for(;J=R.pending_buf[R.d_buf+2*se]<<8|R.pending_buf[R.d_buf+2*se+1],$=R.pending_buf[R.l_buf+se],se++,J===0?X(R,$,F):(X(R,(ne=w[$])+h+1,F),(le=N[ne])!==0&&oe(R,$-=D[ne],le),X(R,ne=V(--J),U),(le=T[ne])!==0&&oe(R,J-=Y[ne],le)),se<R.last_lit;);X(R,k,F)}function Oe(R,F){var U,J,$,ne=F.dyn_tree,le=F.stat_desc.static_tree,se=F.stat_desc.has_stree,Z=F.stat_desc.elems,re=-1;for(R.heap_len=0,R.heap_max=m,U=0;U<Z;U++)ne[2*U]!==0?(R.heap[++R.heap_len]=re=U,R.depth[U]=0):ne[2*U+1]=0;for(;R.heap_len<2;)ne[2*($=R.heap[++R.heap_len]=re<2?++re:0)]=1,R.depth[$]=0,R.opt_len--,se&&(R.static_len-=le[2*$+1]);for(F.max_code=re,U=R.heap_len>>1;1<=U;U--)xe(R,ne,U);for($=Z;U=R.heap[1],R.heap[1]=R.heap[R.heap_len--],xe(R,ne,1),J=R.heap[1],R.heap[--R.heap_max]=U,R.heap[--R.heap_max]=J,ne[2*$]=ne[2*U]+ne[2*J],R.depth[$]=(R.depth[U]>=R.depth[J]?R.depth[U]:R.depth[J])+1,ne[2*U+1]=ne[2*J+1]=$,R.heap[1]=$++,xe(R,ne,1),2<=R.heap_len;);R.heap[--R.heap_max]=R.heap[1],(function(ue,be){var Ae,He,ft,Ie,It,Ut,Ve=be.dyn_tree,Zt=be.max_code,Ct=be.stat_desc.static_tree,Hp=be.stat_desc.has_stree,qp=be.stat_desc.extra_bits,La=be.stat_desc.extra_base,ar=be.stat_desc.max_length,Mr=0;for(Ie=0;Ie<=x;Ie++)ue.bl_count[Ie]=0;for(Ve[2*ue.heap[ue.heap_max]+1]=0,Ae=ue.heap_max+1;Ae<m;Ae++)ar<(Ie=Ve[2*Ve[2*(He=ue.heap[Ae])+1]+1]+1)&&(Ie=ar,Mr++),Ve[2*He+1]=Ie,Zt<He||(ue.bl_count[Ie]++,It=0,La<=He&&(It=qp[He-La]),Ut=Ve[2*He],ue.opt_len+=Ut*(Ie+It),Hp&&(ue.static_len+=Ut*(Ct[2*He+1]+It)));if(Mr!==0){do{for(Ie=ar-1;ue.bl_count[Ie]===0;)Ie--;ue.bl_count[Ie]--,ue.bl_count[Ie+1]+=2,ue.bl_count[ar]--,Mr-=2}while(0<Mr);for(Ie=ar;Ie!==0;Ie--)for(He=ue.bl_count[Ie];He!==0;)Zt<(ft=ue.heap[--Ae])||(Ve[2*ft+1]!==Ie&&(ue.opt_len+=(Ie-Ve[2*ft+1])*Ve[2*ft],Ve[2*ft+1]=Ie),He--)}})(R,F),te(ne,re,R.bl_count)}function _(R,F,U){var J,$,ne=-1,le=F[1],se=0,Z=7,re=4;for(le===0&&(Z=138,re=3),F[2*(U+1)+1]=65535,J=0;J<=U;J++)$=le,le=F[2*(J+1)+1],++se<Z&&$===le||(se<re?R.bl_tree[2*$]+=se:$!==0?($!==ne&&R.bl_tree[2*$]++,R.bl_tree[2*S]++):se<=10?R.bl_tree[2*C]++:R.bl_tree[2*j]++,ne=$,re=(se=0)===le?(Z=138,3):$===le?(Z=6,3):(Z=7,4))}function ee(R,F,U){var J,$,ne=-1,le=F[1],se=0,Z=7,re=4;for(le===0&&(Z=138,re=3),J=0;J<=U;J++)if($=le,le=F[2*(J+1)+1],!(++se<Z&&$===le)){if(se<re)for(;X(R,$,R.bl_tree),--se!=0;);else $!==0?($!==ne&&(X(R,$,R.bl_tree),se--),X(R,S,R.bl_tree),oe(R,se-3,2)):se<=10?(X(R,C,R.bl_tree),oe(R,se-3,3)):(X(R,j,R.bl_tree),oe(R,se-11,7));ne=$,re=(se=0)===le?(Z=138,3):$===le?(Z=6,3):(Z=7,4)}}c(Y);var G=!1;function P(R,F,U,J){oe(R,(u<<1)+(J?1:0),3),(function($,ne,le,se){fe($),z($,le),z($,~le),s.arraySet($.pending_buf,$.window,ne,le,$.pending),$.pending+=le})(R,F,U)}o._tr_init=function(R){G||((function(){var F,U,J,$,ne,le=new Array(x+1);for($=J=0;$<d-1;$++)for(D[$]=J,F=0;F<1<<N[$];F++)w[J++]=$;for(w[J-1]=$,$=ne=0;$<16;$++)for(Y[$]=ne,F=0;F<1<<T[$];F++)M[ne++]=$;for(ne>>=7;$<f;$++)for(Y[$]=ne<<7,F=0;F<1<<T[$]-7;F++)M[256+ne++]=$;for(U=0;U<=x;U++)le[U]=0;for(F=0;F<=143;)L[2*F+1]=8,F++,le[8]++;for(;F<=255;)L[2*F+1]=9,F++,le[9]++;for(;F<=279;)L[2*F+1]=7,F++,le[7]++;for(;F<=287;)L[2*F+1]=8,F++,le[8]++;for(te(L,p+1,le),F=0;F<f;F++)E[2*F+1]=5,E[2*F]=de(F,5);H=new I(L,N,h+1,p,x),B=new I(E,T,0,f,x),q=new I(new Array(0),A,0,g,b)})(),G=!0),R.l_desc=new W(R.dyn_ltree,H),R.d_desc=new W(R.dyn_dtree,B),R.bl_desc=new W(R.bl_tree,q),R.bi_buf=0,R.bi_valid=0,ce(R)},o._tr_stored_block=P,o._tr_flush_block=function(R,F,U,J){var $,ne,le=0;0<R.level?(R.strm.data_type===2&&(R.strm.data_type=(function(se){var Z,re=4093624447;for(Z=0;Z<=31;Z++,re>>>=1)if(1&re&&se.dyn_ltree[2*Z]!==0)return i;if(se.dyn_ltree[18]!==0||se.dyn_ltree[20]!==0||se.dyn_ltree[26]!==0)return a;for(Z=32;Z<h;Z++)if(se.dyn_ltree[2*Z]!==0)return a;return i})(R)),Oe(R,R.l_desc),Oe(R,R.d_desc),le=(function(se){var Z;for(_(se,se.dyn_ltree,se.l_desc.max_code),_(se,se.dyn_dtree,se.d_desc.max_code),Oe(se,se.bl_desc),Z=g-1;3<=Z&&se.bl_tree[2*O[Z]+1]===0;Z--);return se.opt_len+=3*(Z+1)+5+5+4,Z})(R),$=R.opt_len+3+7>>>3,(ne=R.static_len+3+7>>>3)<=$&&($=ne)):$=ne=U+5,U+4<=$&&F!==-1?P(R,F,U,J):R.strategy===4||ne===$?(oe(R,2+(J?1:0),3),Ee(R,L,E)):(oe(R,4+(J?1:0),3),(function(se,Z,re,ue){var be;for(oe(se,Z-257,5),oe(se,re-1,5),oe(se,ue-4,4),be=0;be<ue;be++)oe(se,se.bl_tree[2*O[be]+1],3);ee(se,se.dyn_ltree,Z-1),ee(se,se.dyn_dtree,re-1)})(R,R.l_desc.max_code+1,R.d_desc.max_code+1,le+1),Ee(R,R.dyn_ltree,R.dyn_dtree)),ce(R),J&&fe(R)},o._tr_tally=function(R,F,U){return R.pending_buf[R.d_buf+2*R.last_lit]=F>>>8&255,R.pending_buf[R.d_buf+2*R.last_lit+1]=255&F,R.pending_buf[R.l_buf+R.last_lit]=255&U,R.last_lit++,F===0?R.dyn_ltree[2*U]++:(R.matches++,F--,R.dyn_ltree[2*(w[U]+h+1)]++,R.dyn_dtree[2*V(F)]++),R.last_lit===R.lit_bufsize-1},o._tr_align=function(R){oe(R,2,3),X(R,k,L),(function(F){F.bi_valid===16?(z(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)})(R)}},{"../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(s){(function(i,a){if(!i.setImmediate){var c,u,d,h,p=1,f={},g=!1,m=i.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(i);x=x&&x.setTimeout?x:i,c={}.toString.call(i.process)==="[object process]"?function(S){process.nextTick(function(){b(S)})}:(function(){if(i.postMessage&&!i.importScripts){var S=!0,C=i.onmessage;return i.onmessage=function(){S=!1},i.postMessage("","*"),i.onmessage=C,S}})()?(h="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",k,!1):i.attachEvent("onmessage",k),function(S){i.postMessage(h+S,"*")}):i.MessageChannel?((d=new MessageChannel).port1.onmessage=function(S){b(S.data)},function(S){d.port2.postMessage(S)}):m&&"onreadystatechange"in m.createElement("script")?(u=m.documentElement,function(S){var C=m.createElement("script");C.onreadystatechange=function(){b(S),C.onreadystatechange=null,u.removeChild(C),C=null},u.appendChild(C)}):function(S){setTimeout(b,0,S)},x.setImmediate=function(S){typeof S!="function"&&(S=new Function(""+S));for(var C=new Array(arguments.length-1),j=0;j<C.length;j++)C[j]=arguments[j+1];var N={callback:S,args:C};return f[p]=N,c(p),p++},x.clearImmediate=y}function y(S){delete f[S]}function b(S){if(g)setTimeout(b,0,S);else{var C=f[S];if(C){g=!0;try{(function(j){var N=j.callback,T=j.args;switch(T.length){case 0:N();break;case 1:N(T[0]);break;case 2:N(T[0],T[1]);break;case 3:N(T[0],T[1],T[2]);break;default:N.apply(a,T)}})(C)}finally{y(S),g=!1}}}}function k(S){S.source===i&&typeof S.data=="string"&&S.data.indexOf(h)===0&&b(+S.data.slice(h.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Lr<"u"?Lr:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(gs)),gs.exports}var Vv=Zv();const Wv=Ri(Vv);async function Hv(e){try{const t=await fetch(`/api/logs/${e}/chunks`);if(!t.ok)return null;const n=await t.json();return JSON.stringify(n,null,2)}catch{return null}}async function qv(e){const t=new Wv;for(const i of e)i.rawRequestBody!==null&&t.file(`#${i.id}.Request.json`,i.rawRequestBody),i.responseText!==null&&t.file(`#${i.id}.Response.json`,i.responseText);const n=e.filter(i=>i.streaming);await Promise.allSettled(n.map(async i=>{const a=await Hv(i.id);a!==null&&t.file(`#${i.id}.SSE.Response.json`,a)}));const r=await t.generateAsync({type:"blob"}),o=URL.createObjectURL(r),s=document.createElement("a");s.href=o,s.download=`llm-inspector-export-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}const Kv="1.16.2",Gv={version:Kv};function dd(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=dd(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function fd(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=dd(e))&&(r&&(r+=" "),r+=t);return r}const Jv=(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},Yv=(e,t)=>({classGroupId:e,validator:t}),hd=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),po="-",fl=[],Xv="arbitrary..",Qv=e=>{const t=tb(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return eb(i);const a=i.split(po),c=a[0]===""&&a.length>1?1:0;return pd(a,c,t)},getConflictingClassGroupIds:(i,a)=>{if(a){const c=r[i],u=n[i];return c?u?Jv(u,c):c:u||fl}return n[i]||fl}}},pd=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],s=n.nextPart.get(o);if(s){const u=pd(e,t+1,s);if(u)return u}const i=n.validators;if(i===null)return;const a=t===0?e.join(po):e.slice(t).join(po),c=i.length;for(let u=0;u<c;u++){const d=i[u];if(d.validator(a))return d.classGroupId}},eb=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?Xv+r:void 0})(),tb=e=>{const{theme:t,classGroups:n}=e;return nb(n,t)},nb=(e,t)=>{const n=hd();for(const r in e){const o=e[r];Gi(o,n,r,t)}return n},Gi=(e,t,n,r)=>{const o=e.length;for(let s=0;s<o;s++){const i=e[s];rb(i,t,n,r)}},rb=(e,t,n,r)=>{if(typeof e=="string"){ob(e,t,n);return}if(typeof e=="function"){sb(e,t,n,r);return}ib(e,t,n,r)},ob=(e,t,n)=>{const r=e===""?t:md(t,e);r.classGroupId=n},sb=(e,t,n,r)=>{if(ab(e)){Gi(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Yv(n,e))},ib=(e,t,n,r)=>{const o=Object.entries(e),s=o.length;for(let i=0;i<s;i++){const[a,c]=o[i];Gi(c,md(t,a),n,r)}},md=(e,t)=>{let n=e;const r=t.split(po),o=r.length;for(let s=0;s<o;s++){const i=r[s];let a=n.nextPart.get(i);a||(a=hd(),n.nextPart.set(i,a)),n=a}return n},ab=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,lb=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(s,i)=>{n[s]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(s){let i=n[s];if(i!==void 0)return i;if((i=r[s])!==void 0)return o(s,i),i},set(s,i){s in n?n[s]=i:o(s,i)}}},ei="!",hl=":",cb=[],pl=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),ub=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const s=[];let i=0,a=0,c=0,u;const d=o.length;for(let m=0;m<d;m++){const x=o[m];if(i===0&&a===0){if(x===hl){s.push(o.slice(c,m)),c=m+1;continue}if(x==="/"){u=m;continue}}x==="["?i++:x==="]"?i--:x==="("?a++:x===")"&&a--}const h=s.length===0?o:o.slice(c);let p=h,f=!1;h.endsWith(ei)?(p=h.slice(0,-1),f=!0):h.startsWith(ei)&&(p=h.slice(1),f=!0);const g=u&&u>c?u-c:void 0;return pl(s,f,p,g)};if(t){const o=t+hl,s=r;r=i=>i.startsWith(o)?s(i.slice(o.length)):pl(cb,!1,i,void 0,!0)}if(n){const o=r;r=s=>n({className:s,parseClassName:o})}return r},db=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let o=[];for(let s=0;s<n.length;s++){const i=n[s],a=i[0]==="[",c=t.has(i);a||c?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(i)):o.push(i)}return o.length>0&&(o.sort(),r.push(...o)),r}},fb=e=>({cache:lb(e.cacheSize),parseClassName:ub(e),sortModifiers:db(e),...Qv(e)}),hb=/\s+/,pb=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s}=t,i=[],a=e.trim().split(hb);let c="";for(let u=a.length-1;u>=0;u-=1){const d=a[u],{isExternal:h,modifiers:p,hasImportantModifier:f,baseClassName:g,maybePostfixModifierPosition:m}=n(d);if(h){c=d+(c.length>0?" "+c:c);continue}let x=!!m,y=r(x?g.substring(0,m):g);if(!y){if(!x){c=d+(c.length>0?" "+c:c);continue}if(y=r(g),!y){c=d+(c.length>0?" "+c:c);continue}x=!1}const b=p.length===0?"":p.length===1?p[0]:s(p).join(":"),k=f?b+ei:b,S=k+y;if(i.indexOf(S)>-1)continue;i.push(S);const C=o(y,x);for(let j=0;j<C.length;++j){const N=C[j];i.push(k+N)}c=d+(c.length>0?" "+c:c)}return c},mb=(...e)=>{let t=0,n,r,o="";for(;t<e.length;)(n=e[t++])&&(r=gd(n))&&(o&&(o+=" "),o+=r);return o},gd=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=gd(e[r]))&&(n&&(n+=" "),n+=t);return n},gb=(e,...t)=>{let n,r,o,s;const i=c=>{const u=t.reduce((d,h)=>h(d),e());return n=fb(u),r=n.cache.get,o=n.cache.set,s=a,a(c)},a=c=>{const u=r(c);if(u)return u;const d=pb(c,n);return o(c,d),d};return s=i,(...c)=>s(mb(...c))},xb=[],Ye=e=>{const t=n=>n[e]||xb;return t.isThemeGetter=!0,t},xd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,yd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,yb=/^\d+\/\d+$/,vb=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,bb=/\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$/,wb=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,kb=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,_b=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Sn=e=>yb.test(e),Ne=e=>!!e&&!Number.isNaN(Number(e)),Yt=e=>!!e&&Number.isInteger(Number(e)),xs=e=>e.endsWith("%")&&Ne(e.slice(0,-1)),Vt=e=>vb.test(e),Sb=()=>!0,Cb=e=>bb.test(e)&&!wb.test(e),vd=()=>!1,jb=e=>kb.test(e),Eb=e=>_b.test(e),Nb=e=>!pe(e)&&!me(e),Tb=e=>Qn(e,kd,vd),pe=e=>xd.test(e),dn=e=>Qn(e,_d,Cb),ys=e=>Qn(e,Pb,Ne),ml=e=>Qn(e,bd,vd),Ab=e=>Qn(e,wd,Eb),Zr=e=>Qn(e,Sd,jb),me=e=>yd.test(e),lr=e=>er(e,_d),Ib=e=>er(e,Ob),gl=e=>er(e,bd),zb=e=>er(e,kd),Rb=e=>er(e,wd),Vr=e=>er(e,Sd,!0),Qn=(e,t,n)=>{const r=xd.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},er=(e,t,n=!1)=>{const r=yd.exec(e);return r?r[1]?t(r[1]):n:!1},bd=e=>e==="position"||e==="percentage",wd=e=>e==="image"||e==="url",kd=e=>e==="length"||e==="size"||e==="bg-size",_d=e=>e==="length",Pb=e=>e==="number",Ob=e=>e==="family-name",Sd=e=>e==="shadow",Db=()=>{const e=Ye("color"),t=Ye("font"),n=Ye("text"),r=Ye("font-weight"),o=Ye("tracking"),s=Ye("leading"),i=Ye("breakpoint"),a=Ye("container"),c=Ye("spacing"),u=Ye("radius"),d=Ye("shadow"),h=Ye("inset-shadow"),p=Ye("text-shadow"),f=Ye("drop-shadow"),g=Ye("blur"),m=Ye("perspective"),x=Ye("aspect"),y=Ye("ease"),b=Ye("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],C=()=>[...S(),me,pe],j=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],T=()=>[me,pe,c],A=()=>[Sn,"full","auto",...T()],O=()=>[Yt,"none","subgrid",me,pe],L=()=>["auto",{span:["full",Yt,me,pe]},Yt,me,pe],E=()=>[Yt,"auto",me,pe],M=()=>["auto","min","max","fr",me,pe],w=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],H=()=>["auto",...T()],B=()=>[Sn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],q=()=>[e,me,pe],Y=()=>[...S(),gl,ml,{position:[me,pe]}],I=()=>["no-repeat",{repeat:["","x","y","space","round"]}],W=()=>["auto","cover","contain",zb,Tb,{size:[me,pe]}],V=()=>[xs,lr,dn],z=()=>["","none","full",u,me,pe],oe=()=>["",Ne,lr,dn],X=()=>["solid","dashed","dotted","double"],de=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],te=()=>[Ne,xs,gl,ml],ce=()=>["","none",g,me,pe],fe=()=>["none",Ne,me,pe],ge=()=>["none",Ne,me,pe],xe=()=>[Ne,me,pe],Ee=()=>[Sn,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Vt],breakpoint:[Vt],color:[Sb],container:[Vt],"drop-shadow":[Vt],ease:["in","out","in-out"],font:[Nb],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Vt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Vt],shadow:[Vt],spacing:["px",Ne],text:[Vt],"text-shadow":[Vt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Sn,pe,me,x]}],container:["container"],columns:[{columns:[Ne,pe,me,a]}],"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:C()}],overflow:[{overflow:j()}],"overflow-x":[{"overflow-x":j()}],"overflow-y":[{"overflow-y":j()}],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:[Yt,"auto",me,pe]}],basis:[{basis:[Sn,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ne,Sn,"auto","initial","none",pe]}],grow:[{grow:["",Ne,me,pe]}],shrink:[{shrink:["",Ne,me,pe]}],order:[{order:[Yt,"first","last","none",me,pe]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":M()}],"auto-rows":[{"auto-rows":M()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...w(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...w()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":w()}],"place-items":[{"place-items":[...D(),"baseline"]}],"place-self":[{"place-self":["auto",...D()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:H()}],mx:[{mx:H()}],my:[{my:H()}],ms:[{ms:H()}],me:[{me:H()}],mt:[{mt:H()}],mr:[{mr:H()}],mb:[{mb:H()}],ml:[{ml:H()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:B()}],w:[{w:[a,"screen",...B()]}],"min-w":[{"min-w":[a,"screen","none",...B()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...B()]}],h:[{h:["screen","lh",...B()]}],"min-h":[{"min-h":["screen","lh","none",...B()]}],"max-h":[{"max-h":["screen","lh",...B()]}],"font-size":[{text:["base",n,lr,dn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,me,ys]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",xs,pe]}],"font-family":[{font:[Ib,pe,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,me,pe]}],"line-clamp":[{"line-clamp":[Ne,"none",me,ys]}],leading:[{leading:[s,...T()]}],"list-image":[{"list-image":["none",me,pe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",me,pe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:q()}],"text-color":[{text:q()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...X(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ne,"from-font","auto",me,dn]}],"text-decoration-color":[{decoration:q()}],"underline-offset":[{"underline-offset":[Ne,"auto",me,pe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",me,pe]}],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",me,pe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Y()}],"bg-repeat":[{bg:I()}],"bg-size":[{bg:W()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Yt,me,pe],radial:["",me,pe],conic:[Yt,me,pe]},Rb,Ab]}],"bg-color":[{bg:q()}],"gradient-from-pos":[{from:V()}],"gradient-via-pos":[{via:V()}],"gradient-to-pos":[{to:V()}],"gradient-from":[{from:q()}],"gradient-via":[{via:q()}],"gradient-to":[{to:q()}],rounded:[{rounded:z()}],"rounded-s":[{"rounded-s":z()}],"rounded-e":[{"rounded-e":z()}],"rounded-t":[{"rounded-t":z()}],"rounded-r":[{"rounded-r":z()}],"rounded-b":[{"rounded-b":z()}],"rounded-l":[{"rounded-l":z()}],"rounded-ss":[{"rounded-ss":z()}],"rounded-se":[{"rounded-se":z()}],"rounded-ee":[{"rounded-ee":z()}],"rounded-es":[{"rounded-es":z()}],"rounded-tl":[{"rounded-tl":z()}],"rounded-tr":[{"rounded-tr":z()}],"rounded-br":[{"rounded-br":z()}],"rounded-bl":[{"rounded-bl":z()}],"border-w":[{border:oe()}],"border-w-x":[{"border-x":oe()}],"border-w-y":[{"border-y":oe()}],"border-w-s":[{"border-s":oe()}],"border-w-e":[{"border-e":oe()}],"border-w-t":[{"border-t":oe()}],"border-w-r":[{"border-r":oe()}],"border-w-b":[{"border-b":oe()}],"border-w-l":[{"border-l":oe()}],"divide-x":[{"divide-x":oe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":oe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...X(),"hidden","none"]}],"divide-style":[{divide:[...X(),"hidden","none"]}],"border-color":[{border:q()}],"border-color-x":[{"border-x":q()}],"border-color-y":[{"border-y":q()}],"border-color-s":[{"border-s":q()}],"border-color-e":[{"border-e":q()}],"border-color-t":[{"border-t":q()}],"border-color-r":[{"border-r":q()}],"border-color-b":[{"border-b":q()}],"border-color-l":[{"border-l":q()}],"divide-color":[{divide:q()}],"outline-style":[{outline:[...X(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ne,me,pe]}],"outline-w":[{outline:["",Ne,lr,dn]}],"outline-color":[{outline:q()}],shadow:[{shadow:["","none",d,Vr,Zr]}],"shadow-color":[{shadow:q()}],"inset-shadow":[{"inset-shadow":["none",h,Vr,Zr]}],"inset-shadow-color":[{"inset-shadow":q()}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:q()}],"ring-offset-w":[{"ring-offset":[Ne,dn]}],"ring-offset-color":[{"ring-offset":q()}],"inset-ring-w":[{"inset-ring":oe()}],"inset-ring-color":[{"inset-ring":q()}],"text-shadow":[{"text-shadow":["none",p,Vr,Zr]}],"text-shadow-color":[{"text-shadow":q()}],opacity:[{opacity:[Ne,me,pe]}],"mix-blend":[{"mix-blend":[...de(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":de()}],"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":[Ne]}],"mask-image-linear-from-pos":[{"mask-linear-from":te()}],"mask-image-linear-to-pos":[{"mask-linear-to":te()}],"mask-image-linear-from-color":[{"mask-linear-from":q()}],"mask-image-linear-to-color":[{"mask-linear-to":q()}],"mask-image-t-from-pos":[{"mask-t-from":te()}],"mask-image-t-to-pos":[{"mask-t-to":te()}],"mask-image-t-from-color":[{"mask-t-from":q()}],"mask-image-t-to-color":[{"mask-t-to":q()}],"mask-image-r-from-pos":[{"mask-r-from":te()}],"mask-image-r-to-pos":[{"mask-r-to":te()}],"mask-image-r-from-color":[{"mask-r-from":q()}],"mask-image-r-to-color":[{"mask-r-to":q()}],"mask-image-b-from-pos":[{"mask-b-from":te()}],"mask-image-b-to-pos":[{"mask-b-to":te()}],"mask-image-b-from-color":[{"mask-b-from":q()}],"mask-image-b-to-color":[{"mask-b-to":q()}],"mask-image-l-from-pos":[{"mask-l-from":te()}],"mask-image-l-to-pos":[{"mask-l-to":te()}],"mask-image-l-from-color":[{"mask-l-from":q()}],"mask-image-l-to-color":[{"mask-l-to":q()}],"mask-image-x-from-pos":[{"mask-x-from":te()}],"mask-image-x-to-pos":[{"mask-x-to":te()}],"mask-image-x-from-color":[{"mask-x-from":q()}],"mask-image-x-to-color":[{"mask-x-to":q()}],"mask-image-y-from-pos":[{"mask-y-from":te()}],"mask-image-y-to-pos":[{"mask-y-to":te()}],"mask-image-y-from-color":[{"mask-y-from":q()}],"mask-image-y-to-color":[{"mask-y-to":q()}],"mask-image-radial":[{"mask-radial":[me,pe]}],"mask-image-radial-from-pos":[{"mask-radial-from":te()}],"mask-image-radial-to-pos":[{"mask-radial-to":te()}],"mask-image-radial-from-color":[{"mask-radial-from":q()}],"mask-image-radial-to-color":[{"mask-radial-to":q()}],"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":S()}],"mask-image-conic-pos":[{"mask-conic":[Ne]}],"mask-image-conic-from-pos":[{"mask-conic-from":te()}],"mask-image-conic-to-pos":[{"mask-conic-to":te()}],"mask-image-conic-from-color":[{"mask-conic-from":q()}],"mask-image-conic-to-color":[{"mask-conic-to":q()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Y()}],"mask-repeat":[{mask:I()}],"mask-size":[{mask:W()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",me,pe]}],filter:[{filter:["","none",me,pe]}],blur:[{blur:ce()}],brightness:[{brightness:[Ne,me,pe]}],contrast:[{contrast:[Ne,me,pe]}],"drop-shadow":[{"drop-shadow":["","none",f,Vr,Zr]}],"drop-shadow-color":[{"drop-shadow":q()}],grayscale:[{grayscale:["",Ne,me,pe]}],"hue-rotate":[{"hue-rotate":[Ne,me,pe]}],invert:[{invert:["",Ne,me,pe]}],saturate:[{saturate:[Ne,me,pe]}],sepia:[{sepia:["",Ne,me,pe]}],"backdrop-filter":[{"backdrop-filter":["","none",me,pe]}],"backdrop-blur":[{"backdrop-blur":ce()}],"backdrop-brightness":[{"backdrop-brightness":[Ne,me,pe]}],"backdrop-contrast":[{"backdrop-contrast":[Ne,me,pe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ne,me,pe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ne,me,pe]}],"backdrop-invert":[{"backdrop-invert":["",Ne,me,pe]}],"backdrop-opacity":[{"backdrop-opacity":[Ne,me,pe]}],"backdrop-saturate":[{"backdrop-saturate":[Ne,me,pe]}],"backdrop-sepia":[{"backdrop-sepia":["",Ne,me,pe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",me,pe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ne,"initial",me,pe]}],ease:[{ease:["linear","initial",y,me,pe]}],delay:[{delay:[Ne,me,pe]}],animate:[{animate:["none",b,me,pe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,me,pe]}],"perspective-origin":[{"perspective-origin":C()}],rotate:[{rotate:fe()}],"rotate-x":[{"rotate-x":fe()}],"rotate-y":[{"rotate-y":fe()}],"rotate-z":[{"rotate-z":fe()}],scale:[{scale:ge()}],"scale-x":[{"scale-x":ge()}],"scale-y":[{"scale-y":ge()}],"scale-z":[{"scale-z":ge()}],"scale-3d":["scale-3d"],skew:[{skew:xe()}],"skew-x":[{"skew-x":xe()}],"skew-y":[{"skew-y":xe()}],transform:[{transform:[me,pe,"","none","gpu","cpu"]}],"transform-origin":[{origin:C()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ee()}],"translate-x":[{"translate-x":Ee()}],"translate-y":[{"translate-y":Ee()}],"translate-z":[{"translate-z":Ee()}],"translate-none":["translate-none"],accent:[{accent:q()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:q()}],"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",me,pe]}],"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":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"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",me,pe]}],fill:[{fill:["none",...q()]}],"stroke-w":[{stroke:[Ne,lr,dn,ys]}],stroke:[{stroke:["none",...q()]}],"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"]}},Mb=gb(Db);function he(...e){return Mb(fd(e))}function qe(e){return e>=1048576?(e/1048576).toFixed(1).replace(/\.0$/,"")+"M":e>=1024?(e/1024).toFixed(1).replace(/\.0$/,"")+"K":e.toString()}function Cd(e){return e===null?"pending":e>=200&&e<300?"success":e>=400&&e<500?"client_error":e>=500?"server_error":"pending"}const xl=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,yl=fd,Ji=(e,t)=>n=>{var r;if(t?.variants==null)return yl(e,n?.class,n?.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(u=>{const d=n?.[u],h=s?.[u];if(d===null)return null;const p=xl(d)||xl(h);return o[u][p]}),a=n&&Object.entries(n).reduce((u,d)=>{let[h,p]=d;return p===void 0||(u[h]=p),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:h,className:p,...f}=d;return Object.entries(f).every(g=>{let[m,x]=g;return Array.isArray(x)?x.includes({...s,...a}[m]):{...s,...a}[m]===x})?[...u,h,p]:u},[]);return yl(e,i,c,n?.class,n?.className)};function vl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function jd(...e){return t=>{let n=!1;const r=e.map(o=>{const s=vl(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():vl(e[o],null)}}}}function Re(...e){return v.useCallback(jd(...e),e)}function Wn(e){const t=Fb(e),n=v.forwardRef((r,o)=>{const{children:s,...i}=r,a=v.Children.toArray(s),c=a.find(Bb);if(c){const u=c.props.children,d=a.map(h=>h===c?v.Children.count(u)>1?v.Children.only(null):v.isValidElement(u)?u.props.children:null:h);return l.jsx(t,{...i,ref:o,children:v.isValidElement(u)?v.cloneElement(u,void 0,d):null})}return l.jsx(t,{...i,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}var Lb=Wn("Slot");function Fb(e){const t=v.forwardRef((n,r)=>{const{children:o,...s}=n;if(v.isValidElement(o)){const i=Zb(o),a=Ub(s,o.props);return o.type!==v.Fragment&&(a.ref=r?jd(r,i):i),v.cloneElement(o,a)}return v.Children.count(o)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ed=Symbol("radix.slottable");function $b(e){const t=({children:n})=>l.jsx(l.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=Ed,t}function Bb(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ed}function Ub(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function Zb(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 Vb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ce=Vb.reduce((e,t)=>{const n=Wn(`Primitive.${t}`),r=v.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Wb(e,t){e&&Tr.flushSync(()=>e.dispatchEvent(t))}var Nd=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"}),Hb="VisuallyHidden",Td=v.forwardRef((e,t)=>l.jsx(Ce.span,{...e,ref:t,style:{...Nd,...e.style}}));Td.displayName=Hb;var qb=Td;function Kb(e,t){const n=v.createContext(t),r=s=>{const{children:i,...a}=s,c=v.useMemo(()=>a,Object.values(a));return l.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=v.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function Jt(e,t=[]){let n=[];function r(s,i){const a=v.createContext(i),c=n.length;n=[...n,i];const u=h=>{const{scope:p,children:f,...g}=h,m=p?.[e]?.[c]||a,x=v.useMemo(()=>g,Object.values(g));return l.jsx(m.Provider,{value:x,children:f})};u.displayName=s+"Provider";function d(h,p){const f=p?.[e]?.[c]||a,g=v.useContext(f);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>v.createContext(i));return function(a){const c=a?.[e]||s;return v.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,Gb(o,...t)]}function Gb(...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(s){const i=r.reduce((a,{useScope:c,scopeName:u})=>{const h=c(s)[`__scope${u}`];return{...a,...h}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Ad(e){const t=e+"CollectionProvider",[n,r]=Jt(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=m=>{const{scope:x,children:y}=m,b=at.useRef(null),k=at.useRef(new Map).current;return l.jsx(o,{scope:x,itemMap:k,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",c=Wn(a),u=at.forwardRef((m,x)=>{const{scope:y,children:b}=m,k=s(a,y),S=Re(x,k.collectionRef);return l.jsx(c,{ref:S,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",p=Wn(d),f=at.forwardRef((m,x)=>{const{scope:y,children:b,...k}=m,S=at.useRef(null),C=Re(x,S),j=s(d,y);return at.useEffect(()=>(j.itemMap.set(S,{ref:S,...k}),()=>{j.itemMap.delete(S)})),l.jsx(p,{[h]:"",ref:C,children:b})});f.displayName=d;function g(m){const x=s(e+"CollectionConsumer",m);return at.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const k=Array.from(b.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((j,N)=>k.indexOf(j.ref.current)-k.indexOf(N.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:u,ItemSlot:f},g,r]}function we(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}var et=globalThis?.document?v.useLayoutEffect:()=>{},Jb=cu[" useInsertionEffect ".trim().toString()]||et;function pn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Yb({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const d=v.useRef(e!==void 0);v.useEffect(()=>{const h=d.current;h!==a&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${a?"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=a},[a,r])}const u=v.useCallback(d=>{if(a){const h=Xb(d)?d(e):d;h!==e&&i.current?.(h)}else s(d)},[a,e,s,i]);return[c,u]}function Yb({defaultProp:e,onChange:t}){const[n,r]=v.useState(e),o=v.useRef(n),s=v.useRef(t);return Jb(()=>{s.current=t},[t]),v.useEffect(()=>{o.current!==n&&(s.current?.(n),o.current=n)},[n,o]),[n,r,s]}function Xb(e){return typeof e=="function"}function Qb(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var kt=e=>{const{present:t,children:n}=e,r=e2(t),o=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),s=Re(r.ref,t2(o));return typeof n=="function"||r.isPresent?v.cloneElement(o,{ref:s}):null};kt.displayName="Presence";function e2(e){const[t,n]=v.useState(),r=v.useRef(null),o=v.useRef(e),s=v.useRef("none"),i=e?"mounted":"unmounted",[a,c]=Qb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const u=Wr(r.current);s.current=a==="mounted"?u:"none"},[a]),et(()=>{const u=r.current,d=o.current;if(d!==e){const p=s.current,f=Wr(u);e?c("MOUNT"):f==="none"||u?.display==="none"?c("UNMOUNT"):c(d&&p!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),et(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,h=f=>{const m=Wr(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&m&&(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)})}},p=f=>{f.target===t&&(s.current=Wr(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:v.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function Wr(e){return e?.animationName||"none"}function t2(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 n2=cu[" useId ".trim().toString()]||(()=>{}),r2=0;function Dt(e){const[t,n]=v.useState(n2());return et(()=>{n(r=>r??String(r2++))},[e]),e||(t?`radix-${t}`:"")}var Lo="Collapsible",[o2]=Jt(Lo),[s2,Yi]=o2(Lo),Id=v.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[c,u]=pn({prop:r,defaultProp:o??!1,onChange:i,caller:Lo});return l.jsx(s2,{scope:n,disabled:s,contentId:Dt(),open:c,onOpenToggle:v.useCallback(()=>u(d=>!d),[u]),children:l.jsx(Ce.div,{"data-state":Qi(c),"data-disabled":s?"":void 0,...a,ref:t})})});Id.displayName=Lo;var zd="CollapsibleTrigger",Rd=v.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Yi(zd,n);return l.jsx(Ce.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Qi(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:we(e.onClick,o.onOpenToggle)})});Rd.displayName=zd;var Xi="CollapsibleContent",Pd=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Yi(Xi,e.__scopeCollapsible);return l.jsx(kt,{present:n||o.open,children:({present:s})=>l.jsx(i2,{...r,ref:t,present:s})})});Pd.displayName=Xi;var i2=v.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Yi(Xi,n),[a,c]=v.useState(r),u=v.useRef(null),d=Re(t,u),h=v.useRef(0),p=h.current,f=v.useRef(0),g=f.current,m=i.open||a,x=v.useRef(m),y=v.useRef(void 0);return v.useEffect(()=>{const b=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(b)},[]),et(()=>{const b=u.current;if(b){y.current=y.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const k=b.getBoundingClientRect();h.current=k.height,f.current=k.width,x.current||(b.style.transitionDuration=y.current.transitionDuration,b.style.animationName=y.current.animationName),c(r)}},[i.open,r]),l.jsx(Ce.div,{"data-state":Qi(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!m,...s,ref:d,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:m&&o})});function Qi(e){return e?"open":"closed"}var a2=Id,l2=v.createContext(void 0);function Fo(e){const t=v.useContext(l2);return e||t||"ltr"}function st(e){const t=v.useRef(e);return v.useEffect(()=>{t.current=e}),v.useMemo(()=>(...n)=>t.current?.(...n),[])}function c2(e,t=globalThis?.document){const n=st(e);v.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 u2="DismissableLayer",ti="dismissableLayer.update",d2="dismissableLayer.pointerDownOutside",f2="dismissableLayer.focusOutside",bl,Od=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),$o=v.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,u=v.useContext(Od),[d,h]=v.useState(null),p=d?.ownerDocument??globalThis?.document,[,f]=v.useState({}),g=Re(t,N=>h(N)),m=Array.from(u.layers),[x]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=m.indexOf(x),b=d?m.indexOf(d):-1,k=u.layersWithOutsidePointerEventsDisabled.size>0,S=b>=y,C=m2(N=>{const T=N.target,A=[...u.branches].some(O=>O.contains(T));!S||A||(o?.(N),i?.(N),N.defaultPrevented||a?.())},p),j=g2(N=>{const T=N.target;[...u.branches].some(O=>O.contains(T))||(s?.(N),i?.(N),N.defaultPrevented||a?.())},p);return c2(N=>{b===u.layers.size-1&&(r?.(N),!N.defaultPrevented&&a&&(N.preventDefault(),a()))},p),v.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(bl=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),wl(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=bl)}},[d,p,n,u]),v.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),wl())},[d,u]),v.useEffect(()=>{const N=()=>f({});return document.addEventListener(ti,N),()=>document.removeEventListener(ti,N)},[]),l.jsx(Ce.div,{...c,ref:g,style:{pointerEvents:k?S?"auto":"none":void 0,...e.style},onFocusCapture:we(e.onFocusCapture,j.onFocusCapture),onBlurCapture:we(e.onBlurCapture,j.onBlurCapture),onPointerDownCapture:we(e.onPointerDownCapture,C.onPointerDownCapture)})});$o.displayName=u2;var h2="DismissableLayerBranch",p2=v.forwardRef((e,t)=>{const n=v.useContext(Od),r=v.useRef(null),o=Re(t,r);return v.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),l.jsx(Ce.div,{...e,ref:o})});p2.displayName=h2;function m2(e,t=globalThis?.document){const n=st(e),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){Dd(d2,n,u,{discrete:!0})};const u={originalEvent:a};a.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},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function g2(e,t=globalThis?.document){const n=st(e),r=v.useRef(!1);return v.useEffect(()=>{const o=s=>{s.target&&!r.current&&Dd(f2,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function wl(){const e=new CustomEvent(ti);document.dispatchEvent(e)}function Dd(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Wb(o,s):o.dispatchEvent(s)}var vs="focusScope.autoFocusOnMount",bs="focusScope.autoFocusOnUnmount",kl={bubbles:!1,cancelable:!0},x2="FocusScope",ea=v.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=v.useState(null),u=st(o),d=st(s),h=v.useRef(null),p=Re(t,m=>c(m)),f=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let m=function(k){if(f.paused||!a)return;const S=k.target;a.contains(S)?h.current=S:Qt(h.current,{select:!0})},x=function(k){if(f.paused||!a)return;const S=k.relatedTarget;S!==null&&(a.contains(S)||Qt(h.current,{select:!0}))},y=function(k){if(document.activeElement===document.body)for(const C of k)C.removedNodes.length>0&&Qt(a)};document.addEventListener("focusin",m),document.addEventListener("focusout",x);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",x),b.disconnect()}}},[r,a,f.paused]),v.useEffect(()=>{if(a){Sl.add(f);const m=document.activeElement;if(!a.contains(m)){const y=new CustomEvent(vs,kl);a.addEventListener(vs,u),a.dispatchEvent(y),y.defaultPrevented||(y2(_2(Md(a)),{select:!0}),document.activeElement===m&&Qt(a))}return()=>{a.removeEventListener(vs,u),setTimeout(()=>{const y=new CustomEvent(bs,kl);a.addEventListener(bs,d),a.dispatchEvent(y),y.defaultPrevented||Qt(m??document.body,{select:!0}),a.removeEventListener(bs,d),Sl.remove(f)},0)}}},[a,u,d,f]);const g=v.useCallback(m=>{if(!n&&!r||f.paused)return;const x=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,y=document.activeElement;if(x&&y){const b=m.currentTarget,[k,S]=v2(b);k&&S?!m.shiftKey&&y===S?(m.preventDefault(),n&&Qt(k,{select:!0})):m.shiftKey&&y===k&&(m.preventDefault(),n&&Qt(S,{select:!0})):y===b&&m.preventDefault()}},[n,r,f.paused]);return l.jsx(Ce.div,{tabIndex:-1,...i,ref:p,onKeyDown:g})});ea.displayName=x2;function y2(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Qt(r,{select:t}),document.activeElement!==n)return}function v2(e){const t=Md(e),n=_l(t,e),r=_l(t.reverse(),e);return[n,r]}function Md(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 _l(e,t){for(const n of e)if(!b2(n,{upTo:t}))return n}function b2(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 w2(e){return e instanceof HTMLInputElement&&"select"in e}function Qt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&w2(e)&&t&&e.select()}}var Sl=k2();function k2(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Cl(e,t),e.unshift(t)},remove(t){e=Cl(e,t),e[0]?.resume()}}}function Cl(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function _2(e){return e.filter(t=>t.tagName!=="A")}var S2="Portal",Bo=v.forwardRef((e,t)=>{const{container:n,...r}=e,[o,s]=v.useState(!1);et(()=>s(!0),[]);const i=n||o&&globalThis?.document?.body;return i?Kp.createPortal(l.jsx(Ce.div,{...r,ref:t}),i):null});Bo.displayName=S2;var ws=0;function Ld(){v.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??jl()),document.body.insertAdjacentElement("beforeend",e[1]??jl()),ws++,()=>{ws===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ws--}},[])}function jl(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Rt=function(){return Rt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Rt.apply(this,arguments)};function Fd(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 C2(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var ro="right-scroll-bar-position",oo="width-before-scroll-bar",j2="with-scroll-bars-hidden",E2="--removed-body-scroll-bar-size";function ks(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function N2(e,t){var n=v.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 T2=typeof window<"u"?v.useLayoutEffect:v.useEffect,El=new WeakMap;function A2(e,t){var n=N2(null,function(r){return e.forEach(function(o){return ks(o,r)})});return T2(function(){var r=El.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||ks(a,null)}),s.forEach(function(a){o.has(a)||ks(a,i)})}El.set(n,e)},[e]),n}function I2(e){return e}function z2(e,t){t===void 0&&(t=I2);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(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var c=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function R2(e){e===void 0&&(e={});var t=z2(null);return t.options=Rt({async:!0,ssr:!1},e),t}var $d=function(e){var t=e.sideCar,n=Fd(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 v.createElement(r,Rt({},n))};$d.isSideCarExport=!0;function P2(e,t){return e.useMedium(t),$d}var Bd=R2(),_s=function(){},Uo=v.forwardRef(function(e,t){var n=v.useRef(null),r=v.useState({onScrollCapture:_s,onWheelCapture:_s,onTouchMoveCapture:_s}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,h=e.shards,p=e.sideCar,f=e.noRelative,g=e.noIsolation,m=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,k=e.gapMode,S=Fd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=p,j=A2([n,t]),N=Rt(Rt({},S),o);return v.createElement(v.Fragment,null,d&&v.createElement(C,{sideCar:Bd,removeScrollBar:u,shards:h,noRelative:f,noIsolation:g,inert:m,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:k}),i?v.cloneElement(v.Children.only(a),Rt(Rt({},N),{ref:j})):v.createElement(b,Rt({},N,{className:c,ref:j}),a))});Uo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Uo.classNames={fullWidth:oo,zeroRight:ro};var O2=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function D2(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=O2();return t&&e.setAttribute("nonce",t),e}function M2(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function L2(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var F2=function(){var e=0,t=null;return{add:function(n){e==0&&(t=D2())&&(M2(t,n),L2(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},$2=function(){var e=F2();return function(t,n){v.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Ud=function(){var e=$2(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},B2={left:0,top:0,right:0,gap:0},Ss=function(e){return parseInt(e||"",10)||0},U2=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[Ss(n),Ss(r),Ss(o)]},Z2=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return B2;var t=U2(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])}},V2=Ud(),Mn="data-scroll-locked",W2=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
40
+ \0`,oe+=s(W,2),oe+=j.magic,oe+=s(k,2),oe+=s(S,2),oe+=s(I.crc32,4),oe+=s(I.compressedSize,4),oe+=s(I.uncompressedSize,4),oe+=s(T.length,2),oe+=s(D.length,2),{fileRecord:h.LOCAL_FILE_HEADER+oe+T+D,dirRecord:h.CENTRAL_FILE_HEADER+s(z,2)+oe+s(L.length,2)+"\0\0\0\0"+s(V,4)+s(x,4)+T+D+L}}var a=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),h=n("../signature");function p(f,g,m,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=g,this.zipPlatform=m,this.encodeFileName=x,this.streamFiles=f,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(p,c),p.prototype.push=function(f){var g=f.meta.percent||0,m=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(f):(this.bytesWritten+=f.data.length,c.prototype.push.call(this,{data:f.data,meta:{currentFile:this.currentFile,percent:m?(g+100*(m-x-1))/m:100}}))},p.prototype.openedSource=function(f){this.currentSourceOffset=this.bytesWritten,this.currentFile=f.file.name;var g=this.streamFiles&&!f.file.dir;if(g){var m=i(f,g,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(f){this.accumulate=!1;var g=this.streamFiles&&!f.file.dir,m=i(f,g,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),g)this.push({data:(function(x){return h.DATA_DESCRIPTOR+s(x.crc32,4)+s(x.compressedSize,4)+s(x.uncompressedSize,4)})(f),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var f=this.bytesWritten,g=0;g<this.dirRecords.length;g++)this.push({data:this.dirRecords[g],meta:{percent:100}});var m=this.bytesWritten-f,x=(function(y,b,k,S,C){var j=a.transformTo("string",C(S));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(y,2)+s(y,2)+s(b,4)+s(k,4)+s(j.length,2)+j})(this.dirRecords.length,m,f,this.zipComment,this.encodeFileName);this.push({data:x,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(f){this._sources.push(f);var g=this;return f.on("data",function(m){g.processChunk(m)}),f.on("end",function(){g.closedSource(g.previous.streamInfo),g._sources.length?g.prepareNextSource():g.end()}),f.on("error",function(m){g.error(m)}),this},p.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))},p.prototype.error=function(f){var g=this._sources;if(!c.prototype.error.call(this,f))return!1;for(var m=0;m<g.length;m++)try{g[m].error(f)}catch{}return!0},p.prototype.lock=function(){c.prototype.lock.call(this);for(var f=this._sources,g=0;g<f.length;g++)f[g].lock()},r.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,o){var s=n("../compressions"),i=n("./ZipFileWorker");o.generateWorker=function(a,c,u){var d=new i(c.streamFiles,u,c.platform,c.encodeFileName),h=0;try{a.forEach(function(p,f){h++;var g=(function(b,k){var S=b||k,C=s[S];if(!C)throw new Error(S+" is not a valid compression method !");return C})(f.options.compression,c.compression),m=f.options.compressionOptions||c.compressionOptions||{},x=f.dir,y=f.date;f._compressWorker(g,m).withStreamInfo("file",{name:p,dir:x,date:y,comment:f.comment||"",unixPermissions:f.unixPermissions,dosPermissions:f.dosPermissions}).pipe(d)}),d.entriesCount=h}catch(p){d.error(p)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,o){function s(){if(!(this instanceof s))return new s;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 i=new s;for(var a in this)typeof this[a]!="function"&&(i[a]=this[a]);return i}}(s.prototype=n("./object")).loadAsync=n("./load"),s.support=n("./support"),s.defaults=n("./defaults"),s.version="3.10.1",s.loadAsync=function(i,a){return new s().loadAsync(i,a)},s.external=n("./external"),r.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,o){var s=n("./utils"),i=n("./external"),a=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function h(p){return new i.Promise(function(f,g){var m=p.decompressed.getContentWorker().pipe(new u);m.on("error",function(x){g(x)}).on("end",function(){m.streamInfo.crc32!==p.decompressed.crc32?g(new Error("Corrupted zip : CRC32 mismatch")):f()}).resume()})}r.exports=function(p,f){var g=this;return f=s.extend(f||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),d.isNode&&d.isStream(p)?i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",p,!0,f.optimizedBinaryString,f.base64).then(function(m){var x=new c(f);return x.load(m),x}).then(function(m){var x=[i.Promise.resolve(m)],y=m.files;if(f.checkCRC32)for(var b=0;b<y.length;b++)x.push(h(y[b]));return i.Promise.all(x)}).then(function(m){for(var x=m.shift(),y=x.files,b=0;b<y.length;b++){var k=y[b],S=k.fileNameStr,C=s.resolve(k.fileNameStr);g.file(C,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:f.createFolders}),k.dir||(g.file(C).unsafeOriginalName=S)}return x.zipComment.length&&(g.comment=x.zipComment),g})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,o){var s=n("../utils"),i=n("../stream/GenericWorker");function a(c,u){i.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}s.inherits(a,i),a.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()})},a.prototype.pause=function(){return!!i.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,o){var s=n("readable-stream").Readable;function i(a,c,u){s.call(this,c),this._helper=a;var d=this;a.on("data",function(h,p){d.push(h)||d._helper.pause(),u&&u(p)}).on("error",function(h){d.emit("error",h)}).on("end",function(){d.push(null)})}n("../utils").inherits(i,s),i.prototype._read=function(){this._helper.resume()},r.exports=i},{"../utils":32,"readable-stream":16}],14:[function(n,r,o){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,i){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,i);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,i)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var i=new Buffer(s);return i.fill(0),i},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(n,r,o){function s(C,j,N){var T,A=a.getTypeOf(j),O=a.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&&(C=y(C)),O.createFolders&&(T=x(C))&&b.call(this,T,!0);var L=A==="string"&&O.binary===!1&&O.base64===!1;N&&N.binary!==void 0||(O.binary=!L),(j instanceof h&&j.uncompressedSize===0||O.dir||!j||j.length===0)&&(O.base64=!1,O.binary=!0,j="",O.compression="STORE",A="string");var E=null;E=j instanceof h||j instanceof c?j:g.isNode&&g.isStream(j)?new m(C,j):a.prepareContent(C,j,O.binary,O.optimizedBinaryString,O.base64);var M=new p(C,E,O);this.files[C]=M}var i=n("./utf8"),a=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),h=n("./compressedObject"),p=n("./zipObject"),f=n("./generate"),g=n("./nodejsUtils"),m=n("./nodejs/NodejsStreamInputAdapter"),x=function(C){C.slice(-1)==="/"&&(C=C.substring(0,C.length-1));var j=C.lastIndexOf("/");return 0<j?C.substring(0,j):""},y=function(C){return C.slice(-1)!=="/"&&(C+="/"),C},b=function(C,j){return j=j!==void 0?j:d.createFolders,C=y(C),this.files[C]||s.call(this,C,null,{dir:!0,createFolders:j}),this.files[C]};function k(C){return Object.prototype.toString.call(C)==="[object RegExp]"}var S={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(C){var j,N,T;for(j in this.files)T=this.files[j],(N=j.slice(this.root.length,j.length))&&j.slice(0,this.root.length)===this.root&&C(N,T)},filter:function(C){var j=[];return this.forEach(function(N,T){C(N,T)&&j.push(T)}),j},file:function(C,j,N){if(arguments.length!==1)return C=this.root+C,s.call(this,C,j,N),this;if(k(C)){var T=C;return this.filter(function(O,L){return!L.dir&&T.test(O)})}var A=this.files[this.root+C];return A&&!A.dir?A:null},folder:function(C){if(!C)return this;if(k(C))return this.filter(function(A,O){return O.dir&&C.test(A)});var j=this.root+C,N=b.call(this,j),T=this.clone();return T.root=N.name,T},remove:function(C){C=this.root+C;var j=this.files[C];if(j||(C.slice(-1)!=="/"&&(C+="/"),j=this.files[C]),j&&!j.dir)delete this.files[C];else for(var N=this.filter(function(A,O){return O.name.slice(0,C.length)===C}),T=0;T<N.length;T++)delete this.files[N[T].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(C){var j,N={};try{if((N=a.extend(C||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:i.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.");a.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 T=N.comment||this.comment||"";j=f.generateWorker(this,N,T)}catch(A){(j=new c("error")).error(A)}return new u(j,N.type||"string",N.mimeType)},generateAsync:function(C,j){return this.generateInternalStream(C).accumulate(j)},generateNodeStream:function(C,j){return(C=C||{}).type||(C.type="nodebuffer"),this.generateInternalStream(C).toNodejsStream(j)}};r.exports=S},{"./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 s=n("./DataReader");function i(a){s.call(this,a);for(var c=0;c<this.data.length;c++)a[c]=255&a[c]}n("../utils").inherits(i,s),i.prototype.byteAt=function(a){return this.data[this.zero+a]},i.prototype.lastIndexOfSignature=function(a){for(var c=a.charCodeAt(0),u=a.charCodeAt(1),d=a.charCodeAt(2),h=a.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===c&&this.data[p+1]===u&&this.data[p+2]===d&&this.data[p+3]===h)return p-this.zero;return-1},i.prototype.readAndCheckSignature=function(a){var c=a.charCodeAt(0),u=a.charCodeAt(1),d=a.charCodeAt(2),h=a.charCodeAt(3),p=this.readData(4);return c===p[0]&&u===p[1]&&d===p[2]&&h===p[3]},i.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},r.exports=i},{"../utils":32,"./DataReader":18}],18:[function(n,r,o){var s=n("../utils");function i(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}i.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var c,u=0;for(this.checkOffset(a),c=this.index+a-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=a,u},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=i},{"../utils":32}],19:[function(n,r,o){var s=n("./Uint8ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){this.checkOffset(a);var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},r.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,o){var s=n("./DataReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},i.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},i.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},i.prototype.readData=function(a){this.checkOffset(a);var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},r.exports=i},{"../utils":32,"./DataReader":18}],21:[function(n,r,o){var s=n("./ArrayReader");function i(a){s.call(this,a)}n("../utils").inherits(i,s),i.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},r.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){var s=n("../utils"),i=n("../support"),a=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(h){var p=s.getTypeOf(h);return s.checkSupport(p),p!=="string"||i.uint8array?p==="nodebuffer"?new u(h):i.uint8array?new d(s.transformTo("uint8array",h)):new a(s.transformTo("array",h)):new c(h)}},{"../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 s=n("./GenericWorker"),i=n("../utils");function a(c){s.call(this,"ConvertWorker to "+c),this.destType=c}i.inherits(a,s),a.prototype.processChunk=function(c){this.push({data:i.transformTo(this.destType,c.data),meta:c.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,o){var s=n("./GenericWorker"),i=n("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,s),a.prototype.processChunk=function(c){this.streamInfo.crc32=i(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(c){i.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}s.inherits(a,i),a.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}i.prototype.processChunk.call(this,c)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,o){var s=n("../utils"),i=n("./GenericWorker");function a(c){i.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=s.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}s.inherits(a,i),a.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.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=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,o){function s(i){this.name=i||"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}s.prototype={push:function(i){this.emit("data",i)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(i){this.emit("error",i)}return!0},error:function(i){return!this.isFinished&&(this.isPaused?this.generatedError=i:(this.isFinished=!0,this.emit("error",i),this.previous&&this.previous.error(i),this.cleanUp()),!0)},on:function(i,a){return this._listeners[i].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(i,a){if(this._listeners[i])for(var c=0;c<this._listeners[i].length;c++)this._listeners[i][c].call(this,a)},pipe:function(i){return i.registerPrevious(this)},registerPrevious:function(i){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=i.streamInfo,this.mergeStreamInfo(),this.previous=i;var a=this;return i.on("data",function(c){a.processChunk(c)}),i.on("end",function(){a.end()}),i.on("error",function(c){a.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 i=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),i=!0),this.previous&&this.previous.resume(),!i},flush:function(){},processChunk:function(i){this.push(i)},withStreamInfo:function(i,a){return this.extraStreamInfo[i]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var i in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,i)&&(this.streamInfo[i]=this.extraStreamInfo[i])},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 i="Worker "+this.name;return this.previous?this.previous+" -> "+i:i}},r.exports=s},{}],29:[function(n,r,o){var s=n("../utils"),i=n("./ConvertWorker"),a=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),h=null;if(u.nodestream)try{h=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(g,m){return new d.Promise(function(x,y){var b=[],k=g._internalType,S=g._outputType,C=g._mimeType;g.on("data",function(j,N){b.push(j),m&&m(N)}).on("error",function(j){b=[],y(j)}).on("end",function(){try{var j=(function(N,T,A){switch(N){case"blob":return s.newBlob(s.transformTo("arraybuffer",T),A);case"base64":return c.encode(T);default:return s.transformTo(N,T)}})(S,(function(N,T){var A,O=0,L=null,E=0;for(A=0;A<T.length;A++)E+=T[A].length;switch(N){case"string":return T.join("");case"array":return Array.prototype.concat.apply([],T);case"uint8array":for(L=new Uint8Array(E),A=0;A<T.length;A++)L.set(T[A],O),O+=T[A].length;return L;case"nodebuffer":return Buffer.concat(T);default:throw new Error("concat : unsupported type '"+N+"'")}})(k,b),C);x(j)}catch(N){y(N)}b=[]}).resume()})}function f(g,m,x){var y=m;switch(m){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=m,this._mimeType=x,s.checkSupport(y),this._worker=g.pipe(new i(y)),g.lock()}catch(b){this._worker=new a("error"),this._worker.error(b)}}f.prototype={accumulate:function(g){return p(this,g)},on:function(g,m){var x=this;return g==="data"?this._worker.on(g,function(y){m.call(x,y.data,y.meta)}):this._worker.on(g,function(){s.delay(m,arguments,x)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(g){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:this._outputType!=="nodebuffer"},g)}},r.exports=f},{"../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 s=new ArrayBuffer(0);try{o.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(s),o.blob=i.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 s=n("./utils"),i=n("./support"),a=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 h(){c.call(this,"utf-8 decode"),this.leftOver=null}function p(){c.call(this,"utf-8 encode")}o.utf8encode=function(f){return i.nodebuffer?a.newBufferFrom(f,"utf-8"):(function(g){var m,x,y,b,k,S=g.length,C=0;for(b=0;b<S;b++)(64512&(x=g.charCodeAt(b)))==55296&&b+1<S&&(64512&(y=g.charCodeAt(b+1)))==56320&&(x=65536+(x-55296<<10)+(y-56320),b++),C+=x<128?1:x<2048?2:x<65536?3:4;for(m=i.uint8array?new Uint8Array(C):new Array(C),b=k=0;k<C;b++)(64512&(x=g.charCodeAt(b)))==55296&&b+1<S&&(64512&(y=g.charCodeAt(b+1)))==56320&&(x=65536+(x-55296<<10)+(y-56320),b++),x<128?m[k++]=x:(x<2048?m[k++]=192|x>>>6:(x<65536?m[k++]=224|x>>>12:(m[k++]=240|x>>>18,m[k++]=128|x>>>12&63),m[k++]=128|x>>>6&63),m[k++]=128|63&x);return m})(f)},o.utf8decode=function(f){return i.nodebuffer?s.transformTo("nodebuffer",f).toString("utf-8"):(function(g){var m,x,y,b,k=g.length,S=new Array(2*k);for(m=x=0;m<k;)if((y=g[m++])<128)S[x++]=y;else if(4<(b=u[y]))S[x++]=65533,m+=b-1;else{for(y&=b===2?31:b===3?15:7;1<b&&m<k;)y=y<<6|63&g[m++],b--;1<b?S[x++]=65533:y<65536?S[x++]=y:(y-=65536,S[x++]=55296|y>>10&1023,S[x++]=56320|1023&y)}return S.length!==x&&(S.subarray?S=S.subarray(0,x):S.length=x),s.applyFromCharCode(S)})(f=s.transformTo(i.uint8array?"uint8array":"array",f))},s.inherits(h,c),h.prototype.processChunk=function(f){var g=s.transformTo(i.uint8array?"uint8array":"array",f.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var m=g;(g=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),g.set(m,this.leftOver.length)}else g=this.leftOver.concat(g);this.leftOver=null}var x=(function(b,k){var S;for((k=k||b.length)>b.length&&(k=b.length),S=k-1;0<=S&&(192&b[S])==128;)S--;return S<0||S===0?k:S+u[b[S]]>k?S:k})(g),y=g;x!==g.length&&(i.uint8array?(y=g.subarray(0,x),this.leftOver=g.subarray(x,g.length)):(y=g.slice(0,x),this.leftOver=g.slice(x,g.length))),this.push({data:o.utf8decode(y),meta:f.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=h,s.inherits(p,c),p.prototype.processChunk=function(f){this.push({data:o.utf8encode(f.data),meta:f.meta})},o.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,o){var s=n("./support"),i=n("./base64"),a=n("./nodejsUtils"),c=n("./external");function u(m){return m}function d(m,x){for(var y=0;y<m.length;++y)x[y]=255&m.charCodeAt(y);return x}n("setimmediate"),o.newBlob=function(m,x){o.checkSupport("blob");try{return new Blob([m],{type:x})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(m),y.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(m,x,y){var b=[],k=0,S=m.length;if(S<=y)return String.fromCharCode.apply(null,m);for(;k<S;)x==="array"||x==="nodebuffer"?b.push(String.fromCharCode.apply(null,m.slice(k,Math.min(k+y,S)))):b.push(String.fromCharCode.apply(null,m.subarray(k,Math.min(k+y,S)))),k+=y;return b.join("")},stringifyByChar:function(m){for(var x="",y=0;y<m.length;y++)x+=String.fromCharCode(m[y]);return x},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function p(m){var x=65536,y=o.getTypeOf(m),b=!0;if(y==="uint8array"?b=h.applyCanBeUsed.uint8array:y==="nodebuffer"&&(b=h.applyCanBeUsed.nodebuffer),b)for(;1<x;)try{return h.stringifyByChunk(m,y,x)}catch{x=Math.floor(x/2)}return h.stringifyByChar(m)}function f(m,x){for(var y=0;y<m.length;y++)x[y]=m[y];return x}o.applyFromCharCode=p;var g={};g.string={string:u,array:function(m){return d(m,new Array(m.length))},arraybuffer:function(m){return g.string.uint8array(m).buffer},uint8array:function(m){return d(m,new Uint8Array(m.length))},nodebuffer:function(m){return d(m,a.allocBuffer(m.length))}},g.array={string:p,array:u,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(m)}},g.arraybuffer={string:function(m){return p(new Uint8Array(m))},array:function(m){return f(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:u,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(new Uint8Array(m))}},g.uint8array={string:p,array:function(m){return f(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:u,nodebuffer:function(m){return a.newBufferFrom(m)}},g.nodebuffer={string:p,array:function(m){return f(m,new Array(m.length))},arraybuffer:function(m){return g.nodebuffer.uint8array(m).buffer},uint8array:function(m){return f(m,new Uint8Array(m.length))},nodebuffer:u},o.transformTo=function(m,x){if(x=x||"",!m)return x;o.checkSupport(m);var y=o.getTypeOf(x);return g[y][m](x)},o.resolve=function(m){for(var x=m.split("/"),y=[],b=0;b<x.length;b++){var k=x[b];k==="."||k===""&&b!==0&&b!==x.length-1||(k===".."?y.pop():y.push(k))}return y.join("/")},o.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":s.nodebuffer&&a.isBuffer(m)?"nodebuffer":s.uint8array&&m instanceof Uint8Array?"uint8array":s.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},o.checkSupport=function(m){if(!s[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},o.MAX_VALUE_16BITS=65535,o.MAX_VALUE_32BITS=-1,o.pretty=function(m){var x,y,b="";for(y=0;y<(m||"").length;y++)b+="\\x"+((x=m.charCodeAt(y))<16?"0":"")+x.toString(16).toUpperCase();return b},o.delay=function(m,x,y){setImmediate(function(){m.apply(y||null,x||[])})},o.inherits=function(m,x){function y(){}y.prototype=x.prototype,m.prototype=new y},o.extend=function(){var m,x,y={};for(m=0;m<arguments.length;m++)for(x in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],x)&&y[x]===void 0&&(y[x]=arguments[m][x]);return y},o.prepareContent=function(m,x,y,b,k){return c.Promise.resolve(x).then(function(S){return s.blob&&(S instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(S))!==-1)&&typeof FileReader<"u"?new c.Promise(function(C,j){var N=new FileReader;N.onload=function(T){C(T.target.result)},N.onerror=function(T){j(T.target.error)},N.readAsArrayBuffer(S)}):S}).then(function(S){var C=o.getTypeOf(S);return C?(C==="arraybuffer"?S=o.transformTo("uint8array",S):C==="string"&&(k?S=i.decode(S):y&&b!==!0&&(S=(function(j){return d(j,s.uint8array?new Uint8Array(j.length):new Array(j.length))})(S))),S):c.Promise.reject(new Error("Can't read the data of '"+m+"'. 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 s=n("./reader/readerFor"),i=n("./utils"),a=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(h){this.files=[],this.loadOptions=h}d.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+i.pretty(p)+", expected "+i.pretty(h)+")")}},isSignature:function(h,p){var f=this.reader.index;this.reader.setIndex(h);var g=this.reader.readString(4)===p;return this.reader.setIndex(f),g},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 h=this.reader.readData(this.zipCommentLength),p=u.uint8array?"uint8array":"array",f=i.transformTo(p,h);this.zipComment=this.loadOptions.decodeFileName(f)},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 h,p,f,g=this.zip64EndOfCentralSize-44;0<g;)h=this.reader.readInt(2),p=this.reader.readInt(4),f=this.reader.readData(p),this.zip64ExtensibleData[h]={id:h,length:p,value:f}},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 h,p;for(h=0;h<this.files.length;h++)p=this.files[h],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(h=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);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 h=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(h<0)throw this.isSignature(0,a.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(h);var p=h;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===i.MAX_VALUE_16BITS||this.diskWithCentralDirStart===i.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===i.MAX_VALUE_16BITS||this.centralDirRecords===i.MAX_VALUE_16BITS||this.centralDirSize===i.MAX_VALUE_32BITS||this.centralDirOffset===i.MAX_VALUE_32BITS){if(this.zip64=!0,(h=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(h),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.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(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var f=this.centralDirOffset+this.centralDirSize;this.zip64&&(f+=20,f+=12+this.zip64EndOfCentralSize);var g=p-f;if(0<g)this.isSignature(p,a.CENTRAL_FILE_HEADER)||(this.reader.zero=g);else if(g<0)throw new Error("Corrupted zip: missing "+Math.abs(g)+" bytes.")},prepareReader:function(h){this.reader=s(h)},load:function(h){this.prepareReader(h),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 s=n("./reader/readerFor"),i=n("./utils"),a=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),h=n("./support");function p(f,g){this.options=f,this.loadOptions=g}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(f){var g,m;if(f.skip(22),this.fileNameLength=f.readInt(2),m=f.readInt(2),this.fileName=f.readData(this.fileNameLength),f.skip(m),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((g=(function(x){for(var y in d)if(Object.prototype.hasOwnProperty.call(d,y)&&d[y].magic===x)return d[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+i.pretty(this.compressionMethod)+" unknown (inner file : "+i.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,g,f.readData(this.compressedSize))},readCentralPart:function(f){this.versionMadeBy=f.readInt(2),f.skip(2),this.bitFlag=f.readInt(2),this.compressionMethod=f.readString(2),this.date=f.readDate(),this.crc32=f.readInt(4),this.compressedSize=f.readInt(4),this.uncompressedSize=f.readInt(4);var g=f.readInt(2);if(this.extraFieldsLength=f.readInt(2),this.fileCommentLength=f.readInt(2),this.diskNumberStart=f.readInt(2),this.internalFileAttributes=f.readInt(2),this.externalFileAttributes=f.readInt(4),this.localHeaderOffset=f.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");f.skip(g),this.readExtraFields(f),this.parseZIP64ExtraField(f),this.fileComment=f.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var f=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),f==0&&(this.dosPermissions=63&this.externalFileAttributes),f==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var f=s(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=f.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=f.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=f.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=f.readInt(4))}},readExtraFields:function(f){var g,m,x,y=f.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});f.index+4<y;)g=f.readInt(2),m=f.readInt(2),x=f.readData(m),this.extraFields[g]={id:g,length:m,value:x};f.setIndex(y)},handleUTF8:function(){var f=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var g=this.findExtraFieldUnicodePath();if(g!==null)this.fileNameStr=g;else{var m=i.transformTo(f,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var y=i.transformTo(f,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var f=this.extraFields[28789];if(f){var g=s(f.value);return g.readInt(1)!==1||c(this.fileName)!==g.readInt(4)?null:u.utf8decode(g.readData(f.length-5))}return null},findExtraFieldUnicodeComment:function(){var f=this.extraFields[25461];if(f){var g=s(f.value);return g.readInt(1)!==1||c(this.fileComment)!==g.readInt(4)?null:u.utf8decode(g.readData(f.length-5))}return null}},r.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,o){function s(g,m,x){this.name=g,this.dir=x.dir,this.date=x.date,this.comment=x.comment,this.unixPermissions=x.unixPermissions,this.dosPermissions=x.dosPermissions,this._data=m,this._dataBinary=x.binary,this.options={compression:x.compression,compressionOptions:x.compressionOptions}}var i=n("./stream/StreamHelper"),a=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");s.prototype={internalStream:function(g){var m=null,x="string";try{if(!g)throw new Error("No output type specified.");var y=(x=g.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),m=this._decompressWorker();var b=!this._dataBinary;b&&!y&&(m=m.pipe(new c.Utf8EncodeWorker)),!b&&y&&(m=m.pipe(new c.Utf8DecodeWorker))}catch(k){(m=new d("error")).error(k)}return new i(m,x,"")},async:function(g,m){return this.internalStream(g).accumulate(m)},nodeStream:function(g,m){return this.internalStream(g||"nodebuffer").toNodejsStream(m)},_compressWorker:function(g,m){if(this._data instanceof u&&this._data.compression.magic===g.magic)return this._data.getCompressedWorker();var x=this._decompressWorker();return this._dataBinary||(x=x.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(x,g,m)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new a(this._data)}};for(var h=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},f=0;f<h.length;f++)s.prototype[h[f]]=p;r.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,o){(function(s){var i,a,c=s.MutationObserver||s.WebKitMutationObserver;if(c){var u=0,d=new c(g),h=s.document.createTextNode("");d.observe(h,{characterData:!0}),i=function(){h.data=u=++u%2}}else if(s.setImmediate||s.MessageChannel===void 0)i="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var m=s.document.createElement("script");m.onreadystatechange=function(){g(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},s.document.documentElement.appendChild(m)}:function(){setTimeout(g,0)};else{var p=new s.MessageChannel;p.port1.onmessage=g,i=function(){p.port2.postMessage(0)}}var f=[];function g(){var m,x;a=!0;for(var y=f.length;y;){for(x=f,f=[],m=-1;++m<y;)x[m]();y=f.length}a=!1}r.exports=function(m){f.push(m)!==1||a||i()}}).call(this,typeof Lr<"u"?Lr:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,o){var s=n("immediate");function i(){}var a={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function h(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,y!==i&&m(this,y)}function p(y,b,k){this.promise=y,typeof b=="function"&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),typeof k=="function"&&(this.onRejected=k,this.callRejected=this.otherCallRejected)}function f(y,b,k){s(function(){var S;try{S=b(k)}catch(C){return a.reject(y,C)}S===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,S)})}function g(y){var b=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof b=="function")return function(){b.apply(y,arguments)}}function m(y,b){var k=!1;function S(N){k||(k=!0,a.reject(y,N))}function C(N){k||(k=!0,a.resolve(y,N))}var j=x(function(){b(C,S)});j.status==="error"&&S(j.value)}function x(y,b){var k={};try{k.value=y(b),k.status="success"}catch(S){k.status="error",k.value=S}return k}(r.exports=h).prototype.finally=function(y){if(typeof y!="function")return this;var b=this.constructor;return this.then(function(k){return b.resolve(y()).then(function(){return k})},function(k){return b.resolve(y()).then(function(){throw k})})},h.prototype.catch=function(y){return this.then(null,y)},h.prototype.then=function(y,b){if(typeof y!="function"&&this.state===u||typeof b!="function"&&this.state===c)return this;var k=new this.constructor(i);return this.state!==d?f(k,this.state===u?y:b,this.outcome):this.queue.push(new p(k,y,b)),k},p.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},p.prototype.otherCallFulfilled=function(y){f(this.promise,this.onFulfilled,y)},p.prototype.callRejected=function(y){a.reject(this.promise,y)},p.prototype.otherCallRejected=function(y){f(this.promise,this.onRejected,y)},a.resolve=function(y,b){var k=x(g,b);if(k.status==="error")return a.reject(y,k.value);var S=k.value;if(S)m(y,S);else{y.state=u,y.outcome=b;for(var C=-1,j=y.queue.length;++C<j;)y.queue[C].callFulfilled(b)}return y},a.reject=function(y,b){y.state=c,y.outcome=b;for(var k=-1,S=y.queue.length;++k<S;)y.queue[k].callRejected(b);return y},h.resolve=function(y){return y instanceof this?y:a.resolve(new this(i),y)},h.reject=function(y){var b=new this(i);return a.reject(b,y)},h.all=function(y){var b=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=y.length,S=!1;if(!k)return this.resolve([]);for(var C=new Array(k),j=0,N=-1,T=new this(i);++N<k;)A(y[N],N);return T;function A(O,L){b.resolve(O).then(function(E){C[L]=E,++j!==k||S||(S=!0,a.resolve(T,C))},function(E){S||(S=!0,a.reject(T,E))})}},h.race=function(y){var b=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=y.length,S=!1;if(!k)return this.resolve([]);for(var C=-1,j=new this(i);++C<k;)N=y[C],b.resolve(N).then(function(T){S||(S=!0,a.resolve(j,T))},function(T){S||(S=!0,a.reject(j,T))});var N;return j}},{immediate:36}],38:[function(n,r,o){var s={};(0,n("./lib/utils/common").assign)(s,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,o){var s=n("./zlib/deflate"),i=n("./utils/common"),a=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,h=0,p=-1,f=0,g=8;function m(y){if(!(this instanceof m))return new m(y);this.options=i.assign({level:p,method:g,chunkSize:16384,windowBits:15,memLevel:8,strategy:f,to:""},y||{});var b=this.options;b.raw&&0<b.windowBits?b.windowBits=-b.windowBits:b.gzip&&0<b.windowBits&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var k=s.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(k!==h)throw new Error(c[k]);if(b.header&&s.deflateSetHeader(this.strm,b.header),b.dictionary){var S;if(S=typeof b.dictionary=="string"?a.string2buf(b.dictionary):d.call(b.dictionary)==="[object ArrayBuffer]"?new Uint8Array(b.dictionary):b.dictionary,(k=s.deflateSetDictionary(this.strm,S))!==h)throw new Error(c[k]);this._dict_set=!0}}function x(y,b){var k=new m(b);if(k.push(y,!0),k.err)throw k.msg||c[k.err];return k.result}m.prototype.push=function(y,b){var k,S,C=this.strm,j=this.options.chunkSize;if(this.ended)return!1;S=b===~~b?b:b===!0?4:0,typeof y=="string"?C.input=a.string2buf(y):d.call(y)==="[object ArrayBuffer]"?C.input=new Uint8Array(y):C.input=y,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new i.Buf8(j),C.next_out=0,C.avail_out=j),(k=s.deflate(C,S))!==1&&k!==h)return this.onEnd(k),!(this.ended=!0);C.avail_out!==0&&(C.avail_in!==0||S!==4&&S!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(i.shrinkBuf(C.output,C.next_out))):this.onData(i.shrinkBuf(C.output,C.next_out)))}while((0<C.avail_in||C.avail_out===0)&&k!==1);return S===4?(k=s.deflateEnd(this.strm),this.onEnd(k),this.ended=!0,k===h):S!==2||(this.onEnd(h),!(C.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},o.Deflate=m,o.deflate=x,o.deflateRaw=function(y,b){return(b=b||{}).raw=!0,x(y,b)},o.gzip=function(y,b){return(b=b||{}).gzip=!0,x(y,b)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,o){var s=n("./zlib/inflate"),i=n("./utils/common"),a=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),h=n("./zlib/gzheader"),p=Object.prototype.toString;function f(m){if(!(this instanceof f))return new f(m);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},m||{});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)||m&&m.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 y=s.inflateInit2(this.strm,x.windowBits);if(y!==c.Z_OK)throw new Error(u[y]);this.header=new h,s.inflateGetHeader(this.strm,this.header)}function g(m,x){var y=new f(x);if(y.push(m,!0),y.err)throw y.msg||u[y.err];return y.result}f.prototype.push=function(m,x){var y,b,k,S,C,j,N=this.strm,T=this.options.chunkSize,A=this.options.dictionary,O=!1;if(this.ended)return!1;b=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof m=="string"?N.input=a.binstring2buf(m):p.call(m)==="[object ArrayBuffer]"?N.input=new Uint8Array(m):N.input=m,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new i.Buf8(T),N.next_out=0,N.avail_out=T),(y=s.inflate(N,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&A&&(j=typeof A=="string"?a.string2buf(A):p.call(A)==="[object ArrayBuffer]"?new Uint8Array(A):A,y=s.inflateSetDictionary(this.strm,j)),y===c.Z_BUF_ERROR&&O===!0&&(y=c.Z_OK,O=!1),y!==c.Z_STREAM_END&&y!==c.Z_OK)return this.onEnd(y),!(this.ended=!0);N.next_out&&(N.avail_out!==0&&y!==c.Z_STREAM_END&&(N.avail_in!==0||b!==c.Z_FINISH&&b!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(k=a.utf8border(N.output,N.next_out),S=N.next_out-k,C=a.buf2string(N.output,k),N.next_out=S,N.avail_out=T-S,S&&i.arraySet(N.output,N.output,k,S,0),this.onData(C)):this.onData(i.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)&&y!==c.Z_STREAM_END);return y===c.Z_STREAM_END&&(b=c.Z_FINISH),b===c.Z_FINISH?(y=s.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===c.Z_OK):b!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(N.avail_out=0))},f.prototype.onData=function(m){this.chunks.push(m)},f.prototype.onEnd=function(m){m===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},o.Inflate=f,o.inflate=g,o.inflateRaw=function(m,x){return(x=x||{}).raw=!0,g(m,x)},o.ungzip=g},{"./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 s=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 h in d)d.hasOwnProperty(h)&&(c[h]=d[h])}}return c},o.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var i={arraySet:function(c,u,d,h,p){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+h),p);else for(var f=0;f<h;f++)c[p+f]=u[d+f]},flattenChunks:function(c){var u,d,h,p,f,g;for(u=h=0,d=c.length;u<d;u++)h+=c[u].length;for(g=new Uint8Array(h),u=p=0,d=c.length;u<d;u++)f=c[u],g.set(f,p),p+=f.length;return g}},a={arraySet:function(c,u,d,h,p){for(var f=0;f<h;f++)c[p+f]=u[d+f]},flattenChunks:function(c){return[].concat.apply([],c)}};o.setTyped=function(c){c?(o.Buf8=Uint8Array,o.Buf16=Uint16Array,o.Buf32=Int32Array,o.assign(o,i)):(o.Buf8=Array,o.Buf16=Array,o.Buf32=Array,o.assign(o,a))},o.setTyped(s)},{}],42:[function(n,r,o){var s=n("./common"),i=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var c=new s.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(h,p){if(p<65537&&(h.subarray&&a||!h.subarray&&i))return String.fromCharCode.apply(null,s.shrinkBuf(h,p));for(var f="",g=0;g<p;g++)f+=String.fromCharCode(h[g]);return f}c[254]=c[254]=1,o.string2buf=function(h){var p,f,g,m,x,y=h.length,b=0;for(m=0;m<y;m++)(64512&(f=h.charCodeAt(m)))==55296&&m+1<y&&(64512&(g=h.charCodeAt(m+1)))==56320&&(f=65536+(f-55296<<10)+(g-56320),m++),b+=f<128?1:f<2048?2:f<65536?3:4;for(p=new s.Buf8(b),m=x=0;x<b;m++)(64512&(f=h.charCodeAt(m)))==55296&&m+1<y&&(64512&(g=h.charCodeAt(m+1)))==56320&&(f=65536+(f-55296<<10)+(g-56320),m++),f<128?p[x++]=f:(f<2048?p[x++]=192|f>>>6:(f<65536?p[x++]=224|f>>>12:(p[x++]=240|f>>>18,p[x++]=128|f>>>12&63),p[x++]=128|f>>>6&63),p[x++]=128|63&f);return p},o.buf2binstring=function(h){return d(h,h.length)},o.binstring2buf=function(h){for(var p=new s.Buf8(h.length),f=0,g=p.length;f<g;f++)p[f]=h.charCodeAt(f);return p},o.buf2string=function(h,p){var f,g,m,x,y=p||h.length,b=new Array(2*y);for(f=g=0;f<y;)if((m=h[f++])<128)b[g++]=m;else if(4<(x=c[m]))b[g++]=65533,f+=x-1;else{for(m&=x===2?31:x===3?15:7;1<x&&f<y;)m=m<<6|63&h[f++],x--;1<x?b[g++]=65533:m<65536?b[g++]=m:(m-=65536,b[g++]=55296|m>>10&1023,b[g++]=56320|1023&m)}return d(b,g)},o.utf8border=function(h,p){var f;for((p=p||h.length)>h.length&&(p=h.length),f=p-1;0<=f&&(192&h[f])==128;)f--;return f<0||f===0?p:f+c[h[f]]>p?f:p}},{"./common":41}],43:[function(n,r,o){r.exports=function(s,i,a,c){for(var u=65535&s|0,d=s>>>16&65535|0,h=0;a!==0;){for(a-=h=2e3<a?2e3:a;d=d+(u=u+i[c++]|0)|0,--h;);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 s=(function(){for(var i,a=[],c=0;c<256;c++){i=c;for(var u=0;u<8;u++)i=1&i?3988292384^i>>>1:i>>>1;a[c]=i}return a})();r.exports=function(i,a,c,u){var d=s,h=u+c;i^=-1;for(var p=u;p<h;p++)i=i>>>8^d[255&(i^a[p])];return-1^i}},{}],46:[function(n,r,o){var s,i=n("../utils/common"),a=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),h=0,p=4,f=0,g=-2,m=-1,x=4,y=2,b=8,k=9,S=286,C=30,j=19,N=2*S+1,T=15,A=3,O=258,L=O+A+1,E=42,M=113,w=1,D=2,H=3,B=4;function q(_,ee){return _.msg=d[ee],ee}function Y(_){return(_<<1)-(4<_?9:0)}function I(_){for(var ee=_.length;0<=--ee;)_[ee]=0}function W(_){var ee=_.state,G=ee.pending;G>_.avail_out&&(G=_.avail_out),G!==0&&(i.arraySet(_.output,ee.pending_buf,ee.pending_out,G,_.next_out),_.next_out+=G,ee.pending_out+=G,_.total_out+=G,_.avail_out-=G,ee.pending-=G,ee.pending===0&&(ee.pending_out=0))}function V(_,ee){a._tr_flush_block(_,0<=_.block_start?_.block_start:-1,_.strstart-_.block_start,ee),_.block_start=_.strstart,W(_.strm)}function z(_,ee){_.pending_buf[_.pending++]=ee}function oe(_,ee){_.pending_buf[_.pending++]=ee>>>8&255,_.pending_buf[_.pending++]=255&ee}function X(_,ee){var G,P,R=_.max_chain_length,F=_.strstart,U=_.prev_length,J=_.nice_match,$=_.strstart>_.w_size-L?_.strstart-(_.w_size-L):0,ne=_.window,le=_.w_mask,se=_.prev,Z=_.strstart+O,re=ne[F+U-1],ue=ne[F+U];_.prev_length>=_.good_match&&(R>>=2),J>_.lookahead&&(J=_.lookahead);do if(ne[(G=ee)+U]===ue&&ne[G+U-1]===re&&ne[G]===ne[F]&&ne[++G]===ne[F+1]){F+=2,G++;do;while(ne[++F]===ne[++G]&&ne[++F]===ne[++G]&&ne[++F]===ne[++G]&&ne[++F]===ne[++G]&&ne[++F]===ne[++G]&&ne[++F]===ne[++G]&&ne[++F]===ne[++G]&&ne[++F]===ne[++G]&&F<Z);if(P=O-(Z-F),F=Z-O,U<P){if(_.match_start=ee,J<=(U=P))break;re=ne[F+U-1],ue=ne[F+U]}}while((ee=se[ee&le])>$&&--R!=0);return U<=_.lookahead?U:_.lookahead}function de(_){var ee,G,P,R,F,U,J,$,ne,le,se=_.w_size;do{if(R=_.window_size-_.lookahead-_.strstart,_.strstart>=se+(se-L)){for(i.arraySet(_.window,_.window,se,se,0),_.match_start-=se,_.strstart-=se,_.block_start-=se,ee=G=_.hash_size;P=_.head[--ee],_.head[ee]=se<=P?P-se:0,--G;);for(ee=G=se;P=_.prev[--ee],_.prev[ee]=se<=P?P-se:0,--G;);R+=se}if(_.strm.avail_in===0)break;if(U=_.strm,J=_.window,$=_.strstart+_.lookahead,ne=R,le=void 0,le=U.avail_in,ne<le&&(le=ne),G=le===0?0:(U.avail_in-=le,i.arraySet(J,U.input,U.next_in,le,$),U.state.wrap===1?U.adler=c(U.adler,J,le,$):U.state.wrap===2&&(U.adler=u(U.adler,J,le,$)),U.next_in+=le,U.total_in+=le,le),_.lookahead+=G,_.lookahead+_.insert>=A)for(F=_.strstart-_.insert,_.ins_h=_.window[F],_.ins_h=(_.ins_h<<_.hash_shift^_.window[F+1])&_.hash_mask;_.insert&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[F+A-1])&_.hash_mask,_.prev[F&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=F,F++,_.insert--,!(_.lookahead+_.insert<A)););}while(_.lookahead<L&&_.strm.avail_in!==0)}function te(_,ee){for(var G,P;;){if(_.lookahead<L){if(de(_),_.lookahead<L&&ee===h)return w;if(_.lookahead===0)break}if(G=0,_.lookahead>=A&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+A-1])&_.hash_mask,G=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart),G!==0&&_.strstart-G<=_.w_size-L&&(_.match_length=X(_,G)),_.match_length>=A)if(P=a._tr_tally(_,_.strstart-_.match_start,_.match_length-A),_.lookahead-=_.match_length,_.match_length<=_.max_lazy_match&&_.lookahead>=A){for(_.match_length--;_.strstart++,_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+A-1])&_.hash_mask,G=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart,--_.match_length!=0;);_.strstart++}else _.strstart+=_.match_length,_.match_length=0,_.ins_h=_.window[_.strstart],_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+1])&_.hash_mask;else P=a._tr_tally(_,0,_.window[_.strstart]),_.lookahead--,_.strstart++;if(P&&(V(_,!1),_.strm.avail_out===0))return w}return _.insert=_.strstart<A-1?_.strstart:A-1,ee===p?(V(_,!0),_.strm.avail_out===0?H:B):_.last_lit&&(V(_,!1),_.strm.avail_out===0)?w:D}function ce(_,ee){for(var G,P,R;;){if(_.lookahead<L){if(de(_),_.lookahead<L&&ee===h)return w;if(_.lookahead===0)break}if(G=0,_.lookahead>=A&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+A-1])&_.hash_mask,G=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart),_.prev_length=_.match_length,_.prev_match=_.match_start,_.match_length=A-1,G!==0&&_.prev_length<_.max_lazy_match&&_.strstart-G<=_.w_size-L&&(_.match_length=X(_,G),_.match_length<=5&&(_.strategy===1||_.match_length===A&&4096<_.strstart-_.match_start)&&(_.match_length=A-1)),_.prev_length>=A&&_.match_length<=_.prev_length){for(R=_.strstart+_.lookahead-A,P=a._tr_tally(_,_.strstart-1-_.prev_match,_.prev_length-A),_.lookahead-=_.prev_length-1,_.prev_length-=2;++_.strstart<=R&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+A-1])&_.hash_mask,G=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart),--_.prev_length!=0;);if(_.match_available=0,_.match_length=A-1,_.strstart++,P&&(V(_,!1),_.strm.avail_out===0))return w}else if(_.match_available){if((P=a._tr_tally(_,0,_.window[_.strstart-1]))&&V(_,!1),_.strstart++,_.lookahead--,_.strm.avail_out===0)return w}else _.match_available=1,_.strstart++,_.lookahead--}return _.match_available&&(P=a._tr_tally(_,0,_.window[_.strstart-1]),_.match_available=0),_.insert=_.strstart<A-1?_.strstart:A-1,ee===p?(V(_,!0),_.strm.avail_out===0?H:B):_.last_lit&&(V(_,!1),_.strm.avail_out===0)?w:D}function fe(_,ee,G,P,R){this.good_length=_,this.max_lazy=ee,this.nice_length=G,this.max_chain=P,this.func=R}function ge(){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=b,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 i.Buf16(2*N),this.dyn_dtree=new i.Buf16(2*(2*C+1)),this.bl_tree=new i.Buf16(2*(2*j+1)),I(this.dyn_ltree),I(this.dyn_dtree),I(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(T+1),this.heap=new i.Buf16(2*S+1),I(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(2*S+1),I(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(_){var ee;return _&&_.state?(_.total_in=_.total_out=0,_.data_type=y,(ee=_.state).pending=0,ee.pending_out=0,ee.wrap<0&&(ee.wrap=-ee.wrap),ee.status=ee.wrap?E:M,_.adler=ee.wrap===2?0:1,ee.last_flush=h,a._tr_init(ee),f):q(_,g)}function Ee(_){var ee=xe(_);return ee===f&&(function(G){G.window_size=2*G.w_size,I(G.head),G.max_lazy_match=s[G.level].max_lazy,G.good_match=s[G.level].good_length,G.nice_match=s[G.level].nice_length,G.max_chain_length=s[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})(_.state),ee}function Oe(_,ee,G,P,R,F){if(!_)return g;var U=1;if(ee===m&&(ee=6),P<0?(U=0,P=-P):15<P&&(U=2,P-=16),R<1||k<R||G!==b||P<8||15<P||ee<0||9<ee||F<0||x<F)return q(_,g);P===8&&(P=9);var J=new ge;return(_.state=J).strm=_,J.wrap=U,J.gzhead=null,J.w_bits=P,J.w_size=1<<J.w_bits,J.w_mask=J.w_size-1,J.hash_bits=R+7,J.hash_size=1<<J.hash_bits,J.hash_mask=J.hash_size-1,J.hash_shift=~~((J.hash_bits+A-1)/A),J.window=new i.Buf8(2*J.w_size),J.head=new i.Buf16(J.hash_size),J.prev=new i.Buf16(J.w_size),J.lit_bufsize=1<<R+6,J.pending_buf_size=4*J.lit_bufsize,J.pending_buf=new i.Buf8(J.pending_buf_size),J.d_buf=1*J.lit_bufsize,J.l_buf=3*J.lit_bufsize,J.level=ee,J.strategy=F,J.method=G,Ee(_)}s=[new fe(0,0,0,0,function(_,ee){var G=65535;for(G>_.pending_buf_size-5&&(G=_.pending_buf_size-5);;){if(_.lookahead<=1){if(de(_),_.lookahead===0&&ee===h)return w;if(_.lookahead===0)break}_.strstart+=_.lookahead,_.lookahead=0;var P=_.block_start+G;if((_.strstart===0||_.strstart>=P)&&(_.lookahead=_.strstart-P,_.strstart=P,V(_,!1),_.strm.avail_out===0)||_.strstart-_.block_start>=_.w_size-L&&(V(_,!1),_.strm.avail_out===0))return w}return _.insert=0,ee===p?(V(_,!0),_.strm.avail_out===0?H:B):(_.strstart>_.block_start&&(V(_,!1),_.strm.avail_out),w)}),new fe(4,4,8,4,te),new fe(4,5,16,8,te),new fe(4,6,32,32,te),new fe(4,4,16,16,ce),new fe(8,16,32,32,ce),new fe(8,16,128,128,ce),new fe(8,32,128,256,ce),new fe(32,128,258,1024,ce),new fe(32,258,258,4096,ce)],o.deflateInit=function(_,ee){return Oe(_,ee,b,15,8,0)},o.deflateInit2=Oe,o.deflateReset=Ee,o.deflateResetKeep=xe,o.deflateSetHeader=function(_,ee){return _&&_.state?_.state.wrap!==2?g:(_.state.gzhead=ee,f):g},o.deflate=function(_,ee){var G,P,R,F;if(!_||!_.state||5<ee||ee<0)return _?q(_,g):g;if(P=_.state,!_.output||!_.input&&_.avail_in!==0||P.status===666&&ee!==p)return q(_,_.avail_out===0?-5:g);if(P.strm=_,G=P.last_flush,P.last_flush=ee,P.status===E)if(P.wrap===2)_.adler=0,z(P,31),z(P,139),z(P,8),P.gzhead?(z(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)),z(P,255&P.gzhead.time),z(P,P.gzhead.time>>8&255),z(P,P.gzhead.time>>16&255),z(P,P.gzhead.time>>24&255),z(P,P.level===9?2:2<=P.strategy||P.level<2?4:0),z(P,255&P.gzhead.os),P.gzhead.extra&&P.gzhead.extra.length&&(z(P,255&P.gzhead.extra.length),z(P,P.gzhead.extra.length>>8&255)),P.gzhead.hcrc&&(_.adler=u(_.adler,P.pending_buf,P.pending,0)),P.gzindex=0,P.status=69):(z(P,0),z(P,0),z(P,0),z(P,0),z(P,0),z(P,P.level===9?2:2<=P.strategy||P.level<2?4:0),z(P,3),P.status=M);else{var U=b+(P.w_bits-8<<4)<<8;U|=(2<=P.strategy||P.level<2?0:P.level<6?1:P.level===6?2:3)<<6,P.strstart!==0&&(U|=32),U+=31-U%31,P.status=M,oe(P,U),P.strstart!==0&&(oe(P,_.adler>>>16),oe(P,65535&_.adler)),_.adler=1}if(P.status===69)if(P.gzhead.extra){for(R=P.pending;P.gzindex<(65535&P.gzhead.extra.length)&&(P.pending!==P.pending_buf_size||(P.gzhead.hcrc&&P.pending>R&&(_.adler=u(_.adler,P.pending_buf,P.pending-R,R)),W(_),R=P.pending,P.pending!==P.pending_buf_size));)z(P,255&P.gzhead.extra[P.gzindex]),P.gzindex++;P.gzhead.hcrc&&P.pending>R&&(_.adler=u(_.adler,P.pending_buf,P.pending-R,R)),P.gzindex===P.gzhead.extra.length&&(P.gzindex=0,P.status=73)}else P.status=73;if(P.status===73)if(P.gzhead.name){R=P.pending;do{if(P.pending===P.pending_buf_size&&(P.gzhead.hcrc&&P.pending>R&&(_.adler=u(_.adler,P.pending_buf,P.pending-R,R)),W(_),R=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,z(P,F)}while(F!==0);P.gzhead.hcrc&&P.pending>R&&(_.adler=u(_.adler,P.pending_buf,P.pending-R,R)),F===0&&(P.gzindex=0,P.status=91)}else P.status=91;if(P.status===91)if(P.gzhead.comment){R=P.pending;do{if(P.pending===P.pending_buf_size&&(P.gzhead.hcrc&&P.pending>R&&(_.adler=u(_.adler,P.pending_buf,P.pending-R,R)),W(_),R=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,z(P,F)}while(F!==0);P.gzhead.hcrc&&P.pending>R&&(_.adler=u(_.adler,P.pending_buf,P.pending-R,R)),F===0&&(P.status=103)}else P.status=103;if(P.status===103&&(P.gzhead.hcrc?(P.pending+2>P.pending_buf_size&&W(_),P.pending+2<=P.pending_buf_size&&(z(P,255&_.adler),z(P,_.adler>>8&255),_.adler=0,P.status=M)):P.status=M),P.pending!==0){if(W(_),_.avail_out===0)return P.last_flush=-1,f}else if(_.avail_in===0&&Y(ee)<=Y(G)&&ee!==p)return q(_,-5);if(P.status===666&&_.avail_in!==0)return q(_,-5);if(_.avail_in!==0||P.lookahead!==0||ee!==h&&P.status!==666){var J=P.strategy===2?(function($,ne){for(var le;;){if($.lookahead===0&&(de($),$.lookahead===0)){if(ne===h)return w;break}if($.match_length=0,le=a._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++,le&&(V($,!1),$.strm.avail_out===0))return w}return $.insert=0,ne===p?(V($,!0),$.strm.avail_out===0?H:B):$.last_lit&&(V($,!1),$.strm.avail_out===0)?w:D})(P,ee):P.strategy===3?(function($,ne){for(var le,se,Z,re,ue=$.window;;){if($.lookahead<=O){if(de($),$.lookahead<=O&&ne===h)return w;if($.lookahead===0)break}if($.match_length=0,$.lookahead>=A&&0<$.strstart&&(se=ue[Z=$.strstart-1])===ue[++Z]&&se===ue[++Z]&&se===ue[++Z]){re=$.strstart+O;do;while(se===ue[++Z]&&se===ue[++Z]&&se===ue[++Z]&&se===ue[++Z]&&se===ue[++Z]&&se===ue[++Z]&&se===ue[++Z]&&se===ue[++Z]&&Z<re);$.match_length=O-(re-Z),$.match_length>$.lookahead&&($.match_length=$.lookahead)}if($.match_length>=A?(le=a._tr_tally($,1,$.match_length-A),$.lookahead-=$.match_length,$.strstart+=$.match_length,$.match_length=0):(le=a._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++),le&&(V($,!1),$.strm.avail_out===0))return w}return $.insert=0,ne===p?(V($,!0),$.strm.avail_out===0?H:B):$.last_lit&&(V($,!1),$.strm.avail_out===0)?w:D})(P,ee):s[P.level].func(P,ee);if(J!==H&&J!==B||(P.status=666),J===w||J===H)return _.avail_out===0&&(P.last_flush=-1),f;if(J===D&&(ee===1?a._tr_align(P):ee!==5&&(a._tr_stored_block(P,0,0,!1),ee===3&&(I(P.head),P.lookahead===0&&(P.strstart=0,P.block_start=0,P.insert=0))),W(_),_.avail_out===0))return P.last_flush=-1,f}return ee!==p?f:P.wrap<=0?1:(P.wrap===2?(z(P,255&_.adler),z(P,_.adler>>8&255),z(P,_.adler>>16&255),z(P,_.adler>>24&255),z(P,255&_.total_in),z(P,_.total_in>>8&255),z(P,_.total_in>>16&255),z(P,_.total_in>>24&255)):(oe(P,_.adler>>>16),oe(P,65535&_.adler)),W(_),0<P.wrap&&(P.wrap=-P.wrap),P.pending!==0?f:1)},o.deflateEnd=function(_){var ee;return _&&_.state?(ee=_.state.status)!==E&&ee!==69&&ee!==73&&ee!==91&&ee!==103&&ee!==M&&ee!==666?q(_,g):(_.state=null,ee===M?q(_,-3):f):g},o.deflateSetDictionary=function(_,ee){var G,P,R,F,U,J,$,ne,le=ee.length;if(!_||!_.state||(F=(G=_.state).wrap)===2||F===1&&G.status!==E||G.lookahead)return g;for(F===1&&(_.adler=c(_.adler,ee,le,0)),G.wrap=0,le>=G.w_size&&(F===0&&(I(G.head),G.strstart=0,G.block_start=0,G.insert=0),ne=new i.Buf8(G.w_size),i.arraySet(ne,ee,le-G.w_size,G.w_size,0),ee=ne,le=G.w_size),U=_.avail_in,J=_.next_in,$=_.input,_.avail_in=le,_.next_in=0,_.input=ee,de(G);G.lookahead>=A;){for(P=G.strstart,R=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++,--R;);G.strstart=P,G.lookahead=A-1,de(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,_.next_in=J,_.input=$,_.avail_in=U,G.wrap=F,f},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(s,i){var a,c,u,d,h,p,f,g,m,x,y,b,k,S,C,j,N,T,A,O,L,E,M,w,D;a=s.state,c=s.next_in,w=s.input,u=c+(s.avail_in-5),d=s.next_out,D=s.output,h=d-(i-s.avail_out),p=d+(s.avail_out-257),f=a.dmax,g=a.wsize,m=a.whave,x=a.wnext,y=a.window,b=a.hold,k=a.bits,S=a.lencode,C=a.distcode,j=(1<<a.lenbits)-1,N=(1<<a.distbits)-1;e:do{k<15&&(b+=w[c++]<<k,k+=8,b+=w[c++]<<k,k+=8),T=S[b&j];t:for(;;){if(b>>>=A=T>>>24,k-=A,(A=T>>>16&255)===0)D[d++]=65535&T;else{if(!(16&A)){if((64&A)==0){T=S[(65535&T)+(b&(1<<A)-1)];continue t}if(32&A){a.mode=12;break e}s.msg="invalid literal/length code",a.mode=30;break e}O=65535&T,(A&=15)&&(k<A&&(b+=w[c++]<<k,k+=8),O+=b&(1<<A)-1,b>>>=A,k-=A),k<15&&(b+=w[c++]<<k,k+=8,b+=w[c++]<<k,k+=8),T=C[b&N];n:for(;;){if(b>>>=A=T>>>24,k-=A,!(16&(A=T>>>16&255))){if((64&A)==0){T=C[(65535&T)+(b&(1<<A)-1)];continue n}s.msg="invalid distance code",a.mode=30;break e}if(L=65535&T,k<(A&=15)&&(b+=w[c++]<<k,(k+=8)<A&&(b+=w[c++]<<k,k+=8)),f<(L+=b&(1<<A)-1)){s.msg="invalid distance too far back",a.mode=30;break e}if(b>>>=A,k-=A,(A=d-h)<L){if(m<(A=L-A)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(M=y,(E=0)===x){if(E+=g-A,A<O){for(O-=A;D[d++]=y[E++],--A;);E=d-L,M=D}}else if(x<A){if(E+=g+x-A,(A-=x)<O){for(O-=A;D[d++]=y[E++],--A;);if(E=0,x<O){for(O-=A=x;D[d++]=y[E++],--A;);E=d-L,M=D}}}else if(E+=x-A,A<O){for(O-=A;D[d++]=y[E++],--A;);E=d-L,M=D}for(;2<O;)D[d++]=M[E++],D[d++]=M[E++],D[d++]=M[E++],O-=3;O&&(D[d++]=M[E++],1<O&&(D[d++]=M[E++]))}else{for(E=d-L;D[d++]=D[E++],D[d++]=D[E++],D[d++]=D[E++],2<(O-=3););O&&(D[d++]=D[E++],1<O&&(D[d++]=D[E++]))}break}}break}}while(c<u&&d<p);c-=O=k>>3,b&=(1<<(k-=O<<3))-1,s.next_in=c,s.next_out=d,s.avail_in=c<u?u-c+5:5-(c-u),s.avail_out=d<p?p-d+257:257-(d-p),a.hold=b,a.bits=k}},{}],49:[function(n,r,o){var s=n("../utils/common"),i=n("./adler32"),a=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,h=2,p=0,f=-2,g=1,m=852,x=592;function y(E){return(E>>>24&255)+(E>>>8&65280)+((65280&E)<<8)+((255&E)<<24)}function b(){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 s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function k(E){var M;return E&&E.state?(M=E.state,E.total_in=E.total_out=M.total=0,E.msg="",M.wrap&&(E.adler=1&M.wrap),M.mode=g,M.last=0,M.havedict=0,M.dmax=32768,M.head=null,M.hold=0,M.bits=0,M.lencode=M.lendyn=new s.Buf32(m),M.distcode=M.distdyn=new s.Buf32(x),M.sane=1,M.back=-1,p):f}function S(E){var M;return E&&E.state?((M=E.state).wsize=0,M.whave=0,M.wnext=0,k(E)):f}function C(E,M){var w,D;return E&&E.state?(D=E.state,M<0?(w=0,M=-M):(w=1+(M>>4),M<48&&(M&=15)),M&&(M<8||15<M)?f:(D.window!==null&&D.wbits!==M&&(D.window=null),D.wrap=w,D.wbits=M,S(E))):f}function j(E,M){var w,D;return E?(D=new b,(E.state=D).window=null,(w=C(E,M))!==p&&(E.state=null),w):f}var N,T,A=!0;function O(E){if(A){var M;for(N=new s.Buf32(512),T=new s.Buf32(32),M=0;M<144;)E.lens[M++]=8;for(;M<256;)E.lens[M++]=9;for(;M<280;)E.lens[M++]=7;for(;M<288;)E.lens[M++]=8;for(u(d,E.lens,0,288,N,0,E.work,{bits:9}),M=0;M<32;)E.lens[M++]=5;u(h,E.lens,0,32,T,0,E.work,{bits:5}),A=!1}E.lencode=N,E.lenbits=9,E.distcode=T,E.distbits=5}function L(E,M,w,D){var H,B=E.state;return B.window===null&&(B.wsize=1<<B.wbits,B.wnext=0,B.whave=0,B.window=new s.Buf8(B.wsize)),D>=B.wsize?(s.arraySet(B.window,M,w-B.wsize,B.wsize,0),B.wnext=0,B.whave=B.wsize):(D<(H=B.wsize-B.wnext)&&(H=D),s.arraySet(B.window,M,w-D,H,B.wnext),(D-=H)?(s.arraySet(B.window,M,w-D,D,0),B.wnext=D,B.whave=B.wsize):(B.wnext+=H,B.wnext===B.wsize&&(B.wnext=0),B.whave<B.wsize&&(B.whave+=H))),0}o.inflateReset=S,o.inflateReset2=C,o.inflateResetKeep=k,o.inflateInit=function(E){return j(E,15)},o.inflateInit2=j,o.inflate=function(E,M){var w,D,H,B,q,Y,I,W,V,z,oe,X,de,te,ce,fe,ge,xe,Ee,Oe,_,ee,G,P,R=0,F=new s.Buf8(4),U=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!E||!E.state||!E.output||!E.input&&E.avail_in!==0)return f;(w=E.state).mode===12&&(w.mode=13),q=E.next_out,H=E.output,I=E.avail_out,B=E.next_in,D=E.input,Y=E.avail_in,W=w.hold,V=w.bits,z=Y,oe=I,ee=p;e:for(;;)switch(w.mode){case g:if(w.wrap===0){w.mode=13;break}for(;V<16;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(2&w.wrap&&W===35615){F[w.check=0]=255&W,F[1]=W>>>8&255,w.check=a(w.check,F,2,0),V=W=0,w.mode=2;break}if(w.flags=0,w.head&&(w.head.done=!1),!(1&w.wrap)||(((255&W)<<8)+(W>>8))%31){E.msg="incorrect header check",w.mode=30;break}if((15&W)!=8){E.msg="unknown compression method",w.mode=30;break}if(V-=4,_=8+(15&(W>>>=4)),w.wbits===0)w.wbits=_;else if(_>w.wbits){E.msg="invalid window size",w.mode=30;break}w.dmax=1<<_,E.adler=w.check=1,w.mode=512&W?10:12,V=W=0;break;case 2:for(;V<16;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(w.flags=W,(255&w.flags)!=8){E.msg="unknown compression method",w.mode=30;break}if(57344&w.flags){E.msg="unknown header flags set",w.mode=30;break}w.head&&(w.head.text=W>>8&1),512&w.flags&&(F[0]=255&W,F[1]=W>>>8&255,w.check=a(w.check,F,2,0)),V=W=0,w.mode=3;case 3:for(;V<32;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}w.head&&(w.head.time=W),512&w.flags&&(F[0]=255&W,F[1]=W>>>8&255,F[2]=W>>>16&255,F[3]=W>>>24&255,w.check=a(w.check,F,4,0)),V=W=0,w.mode=4;case 4:for(;V<16;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}w.head&&(w.head.xflags=255&W,w.head.os=W>>8),512&w.flags&&(F[0]=255&W,F[1]=W>>>8&255,w.check=a(w.check,F,2,0)),V=W=0,w.mode=5;case 5:if(1024&w.flags){for(;V<16;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}w.length=W,w.head&&(w.head.extra_len=W),512&w.flags&&(F[0]=255&W,F[1]=W>>>8&255,w.check=a(w.check,F,2,0)),V=W=0}else w.head&&(w.head.extra=null);w.mode=6;case 6:if(1024&w.flags&&(Y<(X=w.length)&&(X=Y),X&&(w.head&&(_=w.head.extra_len-w.length,w.head.extra||(w.head.extra=new Array(w.head.extra_len)),s.arraySet(w.head.extra,D,B,X,_)),512&w.flags&&(w.check=a(w.check,D,X,B)),Y-=X,B+=X,w.length-=X),w.length))break e;w.length=0,w.mode=7;case 7:if(2048&w.flags){if(Y===0)break e;for(X=0;_=D[B+X++],w.head&&_&&w.length<65536&&(w.head.name+=String.fromCharCode(_)),_&&X<Y;);if(512&w.flags&&(w.check=a(w.check,D,X,B)),Y-=X,B+=X,_)break e}else w.head&&(w.head.name=null);w.length=0,w.mode=8;case 8:if(4096&w.flags){if(Y===0)break e;for(X=0;_=D[B+X++],w.head&&_&&w.length<65536&&(w.head.comment+=String.fromCharCode(_)),_&&X<Y;);if(512&w.flags&&(w.check=a(w.check,D,X,B)),Y-=X,B+=X,_)break e}else w.head&&(w.head.comment=null);w.mode=9;case 9:if(512&w.flags){for(;V<16;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(W!==(65535&w.check)){E.msg="header crc mismatch",w.mode=30;break}V=W=0}w.head&&(w.head.hcrc=w.flags>>9&1,w.head.done=!0),E.adler=w.check=0,w.mode=12;break;case 10:for(;V<32;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}E.adler=w.check=y(W),V=W=0,w.mode=11;case 11:if(w.havedict===0)return E.next_out=q,E.avail_out=I,E.next_in=B,E.avail_in=Y,w.hold=W,w.bits=V,2;E.adler=w.check=1,w.mode=12;case 12:if(M===5||M===6)break e;case 13:if(w.last){W>>>=7&V,V-=7&V,w.mode=27;break}for(;V<3;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}switch(w.last=1&W,V-=1,3&(W>>>=1)){case 0:w.mode=14;break;case 1:if(O(w),w.mode=20,M!==6)break;W>>>=2,V-=2;break e;case 2:w.mode=17;break;case 3:E.msg="invalid block type",w.mode=30}W>>>=2,V-=2;break;case 14:for(W>>>=7&V,V-=7&V;V<32;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if((65535&W)!=(W>>>16^65535)){E.msg="invalid stored block lengths",w.mode=30;break}if(w.length=65535&W,V=W=0,w.mode=15,M===6)break e;case 15:w.mode=16;case 16:if(X=w.length){if(Y<X&&(X=Y),I<X&&(X=I),X===0)break e;s.arraySet(H,D,B,X,q),Y-=X,B+=X,I-=X,q+=X,w.length-=X;break}w.mode=12;break;case 17:for(;V<14;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(w.nlen=257+(31&W),W>>>=5,V-=5,w.ndist=1+(31&W),W>>>=5,V-=5,w.ncode=4+(15&W),W>>>=4,V-=4,286<w.nlen||30<w.ndist){E.msg="too many length or distance symbols",w.mode=30;break}w.have=0,w.mode=18;case 18:for(;w.have<w.ncode;){for(;V<3;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}w.lens[U[w.have++]]=7&W,W>>>=3,V-=3}for(;w.have<19;)w.lens[U[w.have++]]=0;if(w.lencode=w.lendyn,w.lenbits=7,G={bits:w.lenbits},ee=u(0,w.lens,0,19,w.lencode,0,w.work,G),w.lenbits=G.bits,ee){E.msg="invalid code lengths set",w.mode=30;break}w.have=0,w.mode=19;case 19:for(;w.have<w.nlen+w.ndist;){for(;fe=(R=w.lencode[W&(1<<w.lenbits)-1])>>>16&255,ge=65535&R,!((ce=R>>>24)<=V);){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(ge<16)W>>>=ce,V-=ce,w.lens[w.have++]=ge;else{if(ge===16){for(P=ce+2;V<P;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(W>>>=ce,V-=ce,w.have===0){E.msg="invalid bit length repeat",w.mode=30;break}_=w.lens[w.have-1],X=3+(3&W),W>>>=2,V-=2}else if(ge===17){for(P=ce+3;V<P;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}V-=ce,_=0,X=3+(7&(W>>>=ce)),W>>>=3,V-=3}else{for(P=ce+7;V<P;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}V-=ce,_=0,X=11+(127&(W>>>=ce)),W>>>=7,V-=7}if(w.have+X>w.nlen+w.ndist){E.msg="invalid bit length repeat",w.mode=30;break}for(;X--;)w.lens[w.have++]=_}}if(w.mode===30)break;if(w.lens[256]===0){E.msg="invalid code -- missing end-of-block",w.mode=30;break}if(w.lenbits=9,G={bits:w.lenbits},ee=u(d,w.lens,0,w.nlen,w.lencode,0,w.work,G),w.lenbits=G.bits,ee){E.msg="invalid literal/lengths set",w.mode=30;break}if(w.distbits=6,w.distcode=w.distdyn,G={bits:w.distbits},ee=u(h,w.lens,w.nlen,w.ndist,w.distcode,0,w.work,G),w.distbits=G.bits,ee){E.msg="invalid distances set",w.mode=30;break}if(w.mode=20,M===6)break e;case 20:w.mode=21;case 21:if(6<=Y&&258<=I){E.next_out=q,E.avail_out=I,E.next_in=B,E.avail_in=Y,w.hold=W,w.bits=V,c(E,oe),q=E.next_out,H=E.output,I=E.avail_out,B=E.next_in,D=E.input,Y=E.avail_in,W=w.hold,V=w.bits,w.mode===12&&(w.back=-1);break}for(w.back=0;fe=(R=w.lencode[W&(1<<w.lenbits)-1])>>>16&255,ge=65535&R,!((ce=R>>>24)<=V);){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(fe&&(240&fe)==0){for(xe=ce,Ee=fe,Oe=ge;fe=(R=w.lencode[Oe+((W&(1<<xe+Ee)-1)>>xe)])>>>16&255,ge=65535&R,!(xe+(ce=R>>>24)<=V);){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}W>>>=xe,V-=xe,w.back+=xe}if(W>>>=ce,V-=ce,w.back+=ce,w.length=ge,fe===0){w.mode=26;break}if(32&fe){w.back=-1,w.mode=12;break}if(64&fe){E.msg="invalid literal/length code",w.mode=30;break}w.extra=15&fe,w.mode=22;case 22:if(w.extra){for(P=w.extra;V<P;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}w.length+=W&(1<<w.extra)-1,W>>>=w.extra,V-=w.extra,w.back+=w.extra}w.was=w.length,w.mode=23;case 23:for(;fe=(R=w.distcode[W&(1<<w.distbits)-1])>>>16&255,ge=65535&R,!((ce=R>>>24)<=V);){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if((240&fe)==0){for(xe=ce,Ee=fe,Oe=ge;fe=(R=w.distcode[Oe+((W&(1<<xe+Ee)-1)>>xe)])>>>16&255,ge=65535&R,!(xe+(ce=R>>>24)<=V);){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}W>>>=xe,V-=xe,w.back+=xe}if(W>>>=ce,V-=ce,w.back+=ce,64&fe){E.msg="invalid distance code",w.mode=30;break}w.offset=ge,w.extra=15&fe,w.mode=24;case 24:if(w.extra){for(P=w.extra;V<P;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}w.offset+=W&(1<<w.extra)-1,W>>>=w.extra,V-=w.extra,w.back+=w.extra}if(w.offset>w.dmax){E.msg="invalid distance too far back",w.mode=30;break}w.mode=25;case 25:if(I===0)break e;if(X=oe-I,w.offset>X){if((X=w.offset-X)>w.whave&&w.sane){E.msg="invalid distance too far back",w.mode=30;break}de=X>w.wnext?(X-=w.wnext,w.wsize-X):w.wnext-X,X>w.length&&(X=w.length),te=w.window}else te=H,de=q-w.offset,X=w.length;for(I<X&&(X=I),I-=X,w.length-=X;H[q++]=te[de++],--X;);w.length===0&&(w.mode=21);break;case 26:if(I===0)break e;H[q++]=w.length,I--,w.mode=21;break;case 27:if(w.wrap){for(;V<32;){if(Y===0)break e;Y--,W|=D[B++]<<V,V+=8}if(oe-=I,E.total_out+=oe,w.total+=oe,oe&&(E.adler=w.check=w.flags?a(w.check,H,oe,q-oe):i(w.check,H,oe,q-oe)),oe=I,(w.flags?W:y(W))!==w.check){E.msg="incorrect data check",w.mode=30;break}V=W=0}w.mode=28;case 28:if(w.wrap&&w.flags){for(;V<32;){if(Y===0)break e;Y--,W+=D[B++]<<V,V+=8}if(W!==(4294967295&w.total)){E.msg="incorrect length check",w.mode=30;break}V=W=0}w.mode=29;case 29:ee=1;break e;case 30:ee=-3;break e;case 31:return-4;default:return f}return E.next_out=q,E.avail_out=I,E.next_in=B,E.avail_in=Y,w.hold=W,w.bits=V,(w.wsize||oe!==E.avail_out&&w.mode<30&&(w.mode<27||M!==4))&&L(E,E.output,E.next_out,oe-E.avail_out)?(w.mode=31,-4):(z-=E.avail_in,oe-=E.avail_out,E.total_in+=z,E.total_out+=oe,w.total+=oe,w.wrap&&oe&&(E.adler=w.check=w.flags?a(w.check,H,oe,E.next_out-oe):i(w.check,H,oe,E.next_out-oe)),E.data_type=w.bits+(w.last?64:0)+(w.mode===12?128:0)+(w.mode===20||w.mode===15?256:0),(z==0&&oe===0||M===4)&&ee===p&&(ee=-5),ee)},o.inflateEnd=function(E){if(!E||!E.state)return f;var M=E.state;return M.window&&(M.window=null),E.state=null,p},o.inflateGetHeader=function(E,M){var w;return E&&E.state?(2&(w=E.state).wrap)==0?f:((w.head=M).done=!1,p):f},o.inflateSetDictionary=function(E,M){var w,D=M.length;return E&&E.state?(w=E.state).wrap!==0&&w.mode!==11?f:w.mode===11&&i(1,M,D,0)!==w.check?-3:L(E,M,D,D)?(w.mode=31,-4):(w.havedict=1,p):f},o.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,o){var s=n("../utils/common"),i=[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],a=[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,h,p,f,g,m,x,y){var b,k,S,C,j,N,T,A,O,L=y.bits,E=0,M=0,w=0,D=0,H=0,B=0,q=0,Y=0,I=0,W=0,V=null,z=0,oe=new s.Buf16(16),X=new s.Buf16(16),de=null,te=0;for(E=0;E<=15;E++)oe[E]=0;for(M=0;M<f;M++)oe[h[p+M]]++;for(H=L,D=15;1<=D&&oe[D]===0;D--);if(D<H&&(H=D),D===0)return g[m++]=20971520,g[m++]=20971520,y.bits=1,0;for(w=1;w<D&&oe[w]===0;w++);for(H<w&&(H=w),E=Y=1;E<=15;E++)if(Y<<=1,(Y-=oe[E])<0)return-1;if(0<Y&&(d===0||D!==1))return-1;for(X[1]=0,E=1;E<15;E++)X[E+1]=X[E]+oe[E];for(M=0;M<f;M++)h[p+M]!==0&&(x[X[h[p+M]]++]=M);if(N=d===0?(V=de=x,19):d===1?(V=i,z-=257,de=a,te-=257,256):(V=c,de=u,-1),E=w,j=m,q=M=W=0,S=-1,C=(I=1<<(B=H))-1,d===1&&852<I||d===2&&592<I)return 1;for(;;){for(T=E-q,O=x[M]<N?(A=0,x[M]):x[M]>N?(A=de[te+x[M]],V[z+x[M]]):(A=96,0),b=1<<E-q,w=k=1<<B;g[j+(W>>q)+(k-=b)]=T<<24|A<<16|O|0,k!==0;);for(b=1<<E-1;W&b;)b>>=1;if(b!==0?(W&=b-1,W+=b):W=0,M++,--oe[E]==0){if(E===D)break;E=h[p+x[M]]}if(H<E&&(W&C)!==S){for(q===0&&(q=H),j+=w,Y=1<<(B=E-q);B+q<D&&!((Y-=oe[B+q])<=0);)B++,Y<<=1;if(I+=1<<B,d===1&&852<I||d===2&&592<I)return 1;g[S=W&C]=H<<24|B<<16|j-m|0}}return W!==0&&(g[j+W]=E-q<<24|64<<16|0),y.bits=H,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 s=n("../utils/common"),i=0,a=1;function c(R){for(var F=R.length;0<=--F;)R[F]=0}var u=0,d=29,h=256,p=h+1+d,f=30,g=19,m=2*p+1,x=15,y=16,b=7,k=256,S=16,C=17,j=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],T=[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],L=new Array(2*(p+2));c(L);var E=new Array(2*f);c(E);var M=new Array(512);c(M);var w=new Array(256);c(w);var D=new Array(d);c(D);var H,B,q,Y=new Array(f);function I(R,F,U,J,$){this.static_tree=R,this.extra_bits=F,this.extra_base=U,this.elems=J,this.max_length=$,this.has_stree=R&&R.length}function W(R,F){this.dyn_tree=R,this.max_code=0,this.stat_desc=F}function V(R){return R<256?M[R]:M[256+(R>>>7)]}function z(R,F){R.pending_buf[R.pending++]=255&F,R.pending_buf[R.pending++]=F>>>8&255}function oe(R,F,U){R.bi_valid>y-U?(R.bi_buf|=F<<R.bi_valid&65535,z(R,R.bi_buf),R.bi_buf=F>>y-R.bi_valid,R.bi_valid+=U-y):(R.bi_buf|=F<<R.bi_valid&65535,R.bi_valid+=U)}function X(R,F,U){oe(R,U[2*F],U[2*F+1])}function de(R,F){for(var U=0;U|=1&R,R>>>=1,U<<=1,0<--F;);return U>>>1}function te(R,F,U){var J,$,ne=new Array(x+1),le=0;for(J=1;J<=x;J++)ne[J]=le=le+U[J-1]<<1;for($=0;$<=F;$++){var se=R[2*$+1];se!==0&&(R[2*$]=de(ne[se]++,se))}}function ce(R){var F;for(F=0;F<p;F++)R.dyn_ltree[2*F]=0;for(F=0;F<f;F++)R.dyn_dtree[2*F]=0;for(F=0;F<g;F++)R.bl_tree[2*F]=0;R.dyn_ltree[2*k]=1,R.opt_len=R.static_len=0,R.last_lit=R.matches=0}function fe(R){8<R.bi_valid?z(R,R.bi_buf):0<R.bi_valid&&(R.pending_buf[R.pending++]=R.bi_buf),R.bi_buf=0,R.bi_valid=0}function ge(R,F,U,J){var $=2*F,ne=2*U;return R[$]<R[ne]||R[$]===R[ne]&&J[F]<=J[U]}function xe(R,F,U){for(var J=R.heap[U],$=U<<1;$<=R.heap_len&&($<R.heap_len&&ge(F,R.heap[$+1],R.heap[$],R.depth)&&$++,!ge(F,J,R.heap[$],R.depth));)R.heap[U]=R.heap[$],U=$,$<<=1;R.heap[U]=J}function Ee(R,F,U){var J,$,ne,le,se=0;if(R.last_lit!==0)for(;J=R.pending_buf[R.d_buf+2*se]<<8|R.pending_buf[R.d_buf+2*se+1],$=R.pending_buf[R.l_buf+se],se++,J===0?X(R,$,F):(X(R,(ne=w[$])+h+1,F),(le=N[ne])!==0&&oe(R,$-=D[ne],le),X(R,ne=V(--J),U),(le=T[ne])!==0&&oe(R,J-=Y[ne],le)),se<R.last_lit;);X(R,k,F)}function Oe(R,F){var U,J,$,ne=F.dyn_tree,le=F.stat_desc.static_tree,se=F.stat_desc.has_stree,Z=F.stat_desc.elems,re=-1;for(R.heap_len=0,R.heap_max=m,U=0;U<Z;U++)ne[2*U]!==0?(R.heap[++R.heap_len]=re=U,R.depth[U]=0):ne[2*U+1]=0;for(;R.heap_len<2;)ne[2*($=R.heap[++R.heap_len]=re<2?++re:0)]=1,R.depth[$]=0,R.opt_len--,se&&(R.static_len-=le[2*$+1]);for(F.max_code=re,U=R.heap_len>>1;1<=U;U--)xe(R,ne,U);for($=Z;U=R.heap[1],R.heap[1]=R.heap[R.heap_len--],xe(R,ne,1),J=R.heap[1],R.heap[--R.heap_max]=U,R.heap[--R.heap_max]=J,ne[2*$]=ne[2*U]+ne[2*J],R.depth[$]=(R.depth[U]>=R.depth[J]?R.depth[U]:R.depth[J])+1,ne[2*U+1]=ne[2*J+1]=$,R.heap[1]=$++,xe(R,ne,1),2<=R.heap_len;);R.heap[--R.heap_max]=R.heap[1],(function(ue,be){var Ae,He,ft,Ie,It,Ut,Ve=be.dyn_tree,Zt=be.max_code,Ct=be.stat_desc.static_tree,Hp=be.stat_desc.has_stree,qp=be.stat_desc.extra_bits,La=be.stat_desc.extra_base,ar=be.stat_desc.max_length,Mr=0;for(Ie=0;Ie<=x;Ie++)ue.bl_count[Ie]=0;for(Ve[2*ue.heap[ue.heap_max]+1]=0,Ae=ue.heap_max+1;Ae<m;Ae++)ar<(Ie=Ve[2*Ve[2*(He=ue.heap[Ae])+1]+1]+1)&&(Ie=ar,Mr++),Ve[2*He+1]=Ie,Zt<He||(ue.bl_count[Ie]++,It=0,La<=He&&(It=qp[He-La]),Ut=Ve[2*He],ue.opt_len+=Ut*(Ie+It),Hp&&(ue.static_len+=Ut*(Ct[2*He+1]+It)));if(Mr!==0){do{for(Ie=ar-1;ue.bl_count[Ie]===0;)Ie--;ue.bl_count[Ie]--,ue.bl_count[Ie+1]+=2,ue.bl_count[ar]--,Mr-=2}while(0<Mr);for(Ie=ar;Ie!==0;Ie--)for(He=ue.bl_count[Ie];He!==0;)Zt<(ft=ue.heap[--Ae])||(Ve[2*ft+1]!==Ie&&(ue.opt_len+=(Ie-Ve[2*ft+1])*Ve[2*ft],Ve[2*ft+1]=Ie),He--)}})(R,F),te(ne,re,R.bl_count)}function _(R,F,U){var J,$,ne=-1,le=F[1],se=0,Z=7,re=4;for(le===0&&(Z=138,re=3),F[2*(U+1)+1]=65535,J=0;J<=U;J++)$=le,le=F[2*(J+1)+1],++se<Z&&$===le||(se<re?R.bl_tree[2*$]+=se:$!==0?($!==ne&&R.bl_tree[2*$]++,R.bl_tree[2*S]++):se<=10?R.bl_tree[2*C]++:R.bl_tree[2*j]++,ne=$,re=(se=0)===le?(Z=138,3):$===le?(Z=6,3):(Z=7,4))}function ee(R,F,U){var J,$,ne=-1,le=F[1],se=0,Z=7,re=4;for(le===0&&(Z=138,re=3),J=0;J<=U;J++)if($=le,le=F[2*(J+1)+1],!(++se<Z&&$===le)){if(se<re)for(;X(R,$,R.bl_tree),--se!=0;);else $!==0?($!==ne&&(X(R,$,R.bl_tree),se--),X(R,S,R.bl_tree),oe(R,se-3,2)):se<=10?(X(R,C,R.bl_tree),oe(R,se-3,3)):(X(R,j,R.bl_tree),oe(R,se-11,7));ne=$,re=(se=0)===le?(Z=138,3):$===le?(Z=6,3):(Z=7,4)}}c(Y);var G=!1;function P(R,F,U,J){oe(R,(u<<1)+(J?1:0),3),(function($,ne,le,se){fe($),z($,le),z($,~le),s.arraySet($.pending_buf,$.window,ne,le,$.pending),$.pending+=le})(R,F,U)}o._tr_init=function(R){G||((function(){var F,U,J,$,ne,le=new Array(x+1);for($=J=0;$<d-1;$++)for(D[$]=J,F=0;F<1<<N[$];F++)w[J++]=$;for(w[J-1]=$,$=ne=0;$<16;$++)for(Y[$]=ne,F=0;F<1<<T[$];F++)M[ne++]=$;for(ne>>=7;$<f;$++)for(Y[$]=ne<<7,F=0;F<1<<T[$]-7;F++)M[256+ne++]=$;for(U=0;U<=x;U++)le[U]=0;for(F=0;F<=143;)L[2*F+1]=8,F++,le[8]++;for(;F<=255;)L[2*F+1]=9,F++,le[9]++;for(;F<=279;)L[2*F+1]=7,F++,le[7]++;for(;F<=287;)L[2*F+1]=8,F++,le[8]++;for(te(L,p+1,le),F=0;F<f;F++)E[2*F+1]=5,E[2*F]=de(F,5);H=new I(L,N,h+1,p,x),B=new I(E,T,0,f,x),q=new I(new Array(0),A,0,g,b)})(),G=!0),R.l_desc=new W(R.dyn_ltree,H),R.d_desc=new W(R.dyn_dtree,B),R.bl_desc=new W(R.bl_tree,q),R.bi_buf=0,R.bi_valid=0,ce(R)},o._tr_stored_block=P,o._tr_flush_block=function(R,F,U,J){var $,ne,le=0;0<R.level?(R.strm.data_type===2&&(R.strm.data_type=(function(se){var Z,re=4093624447;for(Z=0;Z<=31;Z++,re>>>=1)if(1&re&&se.dyn_ltree[2*Z]!==0)return i;if(se.dyn_ltree[18]!==0||se.dyn_ltree[20]!==0||se.dyn_ltree[26]!==0)return a;for(Z=32;Z<h;Z++)if(se.dyn_ltree[2*Z]!==0)return a;return i})(R)),Oe(R,R.l_desc),Oe(R,R.d_desc),le=(function(se){var Z;for(_(se,se.dyn_ltree,se.l_desc.max_code),_(se,se.dyn_dtree,se.d_desc.max_code),Oe(se,se.bl_desc),Z=g-1;3<=Z&&se.bl_tree[2*O[Z]+1]===0;Z--);return se.opt_len+=3*(Z+1)+5+5+4,Z})(R),$=R.opt_len+3+7>>>3,(ne=R.static_len+3+7>>>3)<=$&&($=ne)):$=ne=U+5,U+4<=$&&F!==-1?P(R,F,U,J):R.strategy===4||ne===$?(oe(R,2+(J?1:0),3),Ee(R,L,E)):(oe(R,4+(J?1:0),3),(function(se,Z,re,ue){var be;for(oe(se,Z-257,5),oe(se,re-1,5),oe(se,ue-4,4),be=0;be<ue;be++)oe(se,se.bl_tree[2*O[be]+1],3);ee(se,se.dyn_ltree,Z-1),ee(se,se.dyn_dtree,re-1)})(R,R.l_desc.max_code+1,R.d_desc.max_code+1,le+1),Ee(R,R.dyn_ltree,R.dyn_dtree)),ce(R),J&&fe(R)},o._tr_tally=function(R,F,U){return R.pending_buf[R.d_buf+2*R.last_lit]=F>>>8&255,R.pending_buf[R.d_buf+2*R.last_lit+1]=255&F,R.pending_buf[R.l_buf+R.last_lit]=255&U,R.last_lit++,F===0?R.dyn_ltree[2*U]++:(R.matches++,F--,R.dyn_ltree[2*(w[U]+h+1)]++,R.dyn_dtree[2*V(F)]++),R.last_lit===R.lit_bufsize-1},o._tr_align=function(R){oe(R,2,3),X(R,k,L),(function(F){F.bi_valid===16?(z(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)})(R)}},{"../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(s){(function(i,a){if(!i.setImmediate){var c,u,d,h,p=1,f={},g=!1,m=i.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(i);x=x&&x.setTimeout?x:i,c={}.toString.call(i.process)==="[object process]"?function(S){process.nextTick(function(){b(S)})}:(function(){if(i.postMessage&&!i.importScripts){var S=!0,C=i.onmessage;return i.onmessage=function(){S=!1},i.postMessage("","*"),i.onmessage=C,S}})()?(h="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",k,!1):i.attachEvent("onmessage",k),function(S){i.postMessage(h+S,"*")}):i.MessageChannel?((d=new MessageChannel).port1.onmessage=function(S){b(S.data)},function(S){d.port2.postMessage(S)}):m&&"onreadystatechange"in m.createElement("script")?(u=m.documentElement,function(S){var C=m.createElement("script");C.onreadystatechange=function(){b(S),C.onreadystatechange=null,u.removeChild(C),C=null},u.appendChild(C)}):function(S){setTimeout(b,0,S)},x.setImmediate=function(S){typeof S!="function"&&(S=new Function(""+S));for(var C=new Array(arguments.length-1),j=0;j<C.length;j++)C[j]=arguments[j+1];var N={callback:S,args:C};return f[p]=N,c(p),p++},x.clearImmediate=y}function y(S){delete f[S]}function b(S){if(g)setTimeout(b,0,S);else{var C=f[S];if(C){g=!0;try{(function(j){var N=j.callback,T=j.args;switch(T.length){case 0:N();break;case 1:N(T[0]);break;case 2:N(T[0],T[1]);break;case 3:N(T[0],T[1],T[2]);break;default:N.apply(a,T)}})(C)}finally{y(S),g=!1}}}}function k(S){S.source===i&&typeof S.data=="string"&&S.data.indexOf(h)===0&&b(+S.data.slice(h.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Lr<"u"?Lr:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(gs)),gs.exports}var Vv=Zv();const Wv=Ri(Vv);async function Hv(e){try{const t=await fetch(`/api/logs/${e}/chunks`);if(!t.ok)return null;const n=await t.json();return JSON.stringify(n,null,2)}catch{return null}}async function qv(e){const t=new Wv;for(const i of e)i.rawRequestBody!==null&&t.file(`#${i.id}.Request.json`,i.rawRequestBody),i.responseText!==null&&t.file(`#${i.id}.Response.json`,i.responseText);const n=e.filter(i=>i.streaming);await Promise.allSettled(n.map(async i=>{const a=await Hv(i.id);a!==null&&t.file(`#${i.id}.SSE.Response.json`,a)}));const r=await t.generateAsync({type:"blob"}),o=URL.createObjectURL(r),s=document.createElement("a");s.href=o,s.download=`llm-inspector-export-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}const Kv="1.16.3",Gv={version:Kv};function dd(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=dd(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function fd(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=dd(e))&&(r&&(r+=" "),r+=t);return r}const Jv=(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},Yv=(e,t)=>({classGroupId:e,validator:t}),hd=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),po="-",fl=[],Xv="arbitrary..",Qv=e=>{const t=tb(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return eb(i);const a=i.split(po),c=a[0]===""&&a.length>1?1:0;return pd(a,c,t)},getConflictingClassGroupIds:(i,a)=>{if(a){const c=r[i],u=n[i];return c?u?Jv(u,c):c:u||fl}return n[i]||fl}}},pd=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],s=n.nextPart.get(o);if(s){const u=pd(e,t+1,s);if(u)return u}const i=n.validators;if(i===null)return;const a=t===0?e.join(po):e.slice(t).join(po),c=i.length;for(let u=0;u<c;u++){const d=i[u];if(d.validator(a))return d.classGroupId}},eb=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?Xv+r:void 0})(),tb=e=>{const{theme:t,classGroups:n}=e;return nb(n,t)},nb=(e,t)=>{const n=hd();for(const r in e){const o=e[r];Gi(o,n,r,t)}return n},Gi=(e,t,n,r)=>{const o=e.length;for(let s=0;s<o;s++){const i=e[s];rb(i,t,n,r)}},rb=(e,t,n,r)=>{if(typeof e=="string"){ob(e,t,n);return}if(typeof e=="function"){sb(e,t,n,r);return}ib(e,t,n,r)},ob=(e,t,n)=>{const r=e===""?t:md(t,e);r.classGroupId=n},sb=(e,t,n,r)=>{if(ab(e)){Gi(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Yv(n,e))},ib=(e,t,n,r)=>{const o=Object.entries(e),s=o.length;for(let i=0;i<s;i++){const[a,c]=o[i];Gi(c,md(t,a),n,r)}},md=(e,t)=>{let n=e;const r=t.split(po),o=r.length;for(let s=0;s<o;s++){const i=r[s];let a=n.nextPart.get(i);a||(a=hd(),n.nextPart.set(i,a)),n=a}return n},ab=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,lb=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(s,i)=>{n[s]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(s){let i=n[s];if(i!==void 0)return i;if((i=r[s])!==void 0)return o(s,i),i},set(s,i){s in n?n[s]=i:o(s,i)}}},ei="!",hl=":",cb=[],pl=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),ub=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const s=[];let i=0,a=0,c=0,u;const d=o.length;for(let m=0;m<d;m++){const x=o[m];if(i===0&&a===0){if(x===hl){s.push(o.slice(c,m)),c=m+1;continue}if(x==="/"){u=m;continue}}x==="["?i++:x==="]"?i--:x==="("?a++:x===")"&&a--}const h=s.length===0?o:o.slice(c);let p=h,f=!1;h.endsWith(ei)?(p=h.slice(0,-1),f=!0):h.startsWith(ei)&&(p=h.slice(1),f=!0);const g=u&&u>c?u-c:void 0;return pl(s,f,p,g)};if(t){const o=t+hl,s=r;r=i=>i.startsWith(o)?s(i.slice(o.length)):pl(cb,!1,i,void 0,!0)}if(n){const o=r;r=s=>n({className:s,parseClassName:o})}return r},db=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let o=[];for(let s=0;s<n.length;s++){const i=n[s],a=i[0]==="[",c=t.has(i);a||c?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(i)):o.push(i)}return o.length>0&&(o.sort(),r.push(...o)),r}},fb=e=>({cache:lb(e.cacheSize),parseClassName:ub(e),sortModifiers:db(e),...Qv(e)}),hb=/\s+/,pb=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s}=t,i=[],a=e.trim().split(hb);let c="";for(let u=a.length-1;u>=0;u-=1){const d=a[u],{isExternal:h,modifiers:p,hasImportantModifier:f,baseClassName:g,maybePostfixModifierPosition:m}=n(d);if(h){c=d+(c.length>0?" "+c:c);continue}let x=!!m,y=r(x?g.substring(0,m):g);if(!y){if(!x){c=d+(c.length>0?" "+c:c);continue}if(y=r(g),!y){c=d+(c.length>0?" "+c:c);continue}x=!1}const b=p.length===0?"":p.length===1?p[0]:s(p).join(":"),k=f?b+ei:b,S=k+y;if(i.indexOf(S)>-1)continue;i.push(S);const C=o(y,x);for(let j=0;j<C.length;++j){const N=C[j];i.push(k+N)}c=d+(c.length>0?" "+c:c)}return c},mb=(...e)=>{let t=0,n,r,o="";for(;t<e.length;)(n=e[t++])&&(r=gd(n))&&(o&&(o+=" "),o+=r);return o},gd=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=gd(e[r]))&&(n&&(n+=" "),n+=t);return n},gb=(e,...t)=>{let n,r,o,s;const i=c=>{const u=t.reduce((d,h)=>h(d),e());return n=fb(u),r=n.cache.get,o=n.cache.set,s=a,a(c)},a=c=>{const u=r(c);if(u)return u;const d=pb(c,n);return o(c,d),d};return s=i,(...c)=>s(mb(...c))},xb=[],Ye=e=>{const t=n=>n[e]||xb;return t.isThemeGetter=!0,t},xd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,yd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,yb=/^\d+\/\d+$/,vb=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,bb=/\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$/,wb=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,kb=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,_b=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Sn=e=>yb.test(e),Ne=e=>!!e&&!Number.isNaN(Number(e)),Yt=e=>!!e&&Number.isInteger(Number(e)),xs=e=>e.endsWith("%")&&Ne(e.slice(0,-1)),Vt=e=>vb.test(e),Sb=()=>!0,Cb=e=>bb.test(e)&&!wb.test(e),vd=()=>!1,jb=e=>kb.test(e),Eb=e=>_b.test(e),Nb=e=>!pe(e)&&!me(e),Tb=e=>Qn(e,kd,vd),pe=e=>xd.test(e),dn=e=>Qn(e,_d,Cb),ys=e=>Qn(e,Pb,Ne),ml=e=>Qn(e,bd,vd),Ab=e=>Qn(e,wd,Eb),Zr=e=>Qn(e,Sd,jb),me=e=>yd.test(e),lr=e=>er(e,_d),Ib=e=>er(e,Ob),gl=e=>er(e,bd),zb=e=>er(e,kd),Rb=e=>er(e,wd),Vr=e=>er(e,Sd,!0),Qn=(e,t,n)=>{const r=xd.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},er=(e,t,n=!1)=>{const r=yd.exec(e);return r?r[1]?t(r[1]):n:!1},bd=e=>e==="position"||e==="percentage",wd=e=>e==="image"||e==="url",kd=e=>e==="length"||e==="size"||e==="bg-size",_d=e=>e==="length",Pb=e=>e==="number",Ob=e=>e==="family-name",Sd=e=>e==="shadow",Db=()=>{const e=Ye("color"),t=Ye("font"),n=Ye("text"),r=Ye("font-weight"),o=Ye("tracking"),s=Ye("leading"),i=Ye("breakpoint"),a=Ye("container"),c=Ye("spacing"),u=Ye("radius"),d=Ye("shadow"),h=Ye("inset-shadow"),p=Ye("text-shadow"),f=Ye("drop-shadow"),g=Ye("blur"),m=Ye("perspective"),x=Ye("aspect"),y=Ye("ease"),b=Ye("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],C=()=>[...S(),me,pe],j=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],T=()=>[me,pe,c],A=()=>[Sn,"full","auto",...T()],O=()=>[Yt,"none","subgrid",me,pe],L=()=>["auto",{span:["full",Yt,me,pe]},Yt,me,pe],E=()=>[Yt,"auto",me,pe],M=()=>["auto","min","max","fr",me,pe],w=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],H=()=>["auto",...T()],B=()=>[Sn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],q=()=>[e,me,pe],Y=()=>[...S(),gl,ml,{position:[me,pe]}],I=()=>["no-repeat",{repeat:["","x","y","space","round"]}],W=()=>["auto","cover","contain",zb,Tb,{size:[me,pe]}],V=()=>[xs,lr,dn],z=()=>["","none","full",u,me,pe],oe=()=>["",Ne,lr,dn],X=()=>["solid","dashed","dotted","double"],de=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],te=()=>[Ne,xs,gl,ml],ce=()=>["","none",g,me,pe],fe=()=>["none",Ne,me,pe],ge=()=>["none",Ne,me,pe],xe=()=>[Ne,me,pe],Ee=()=>[Sn,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Vt],breakpoint:[Vt],color:[Sb],container:[Vt],"drop-shadow":[Vt],ease:["in","out","in-out"],font:[Nb],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Vt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Vt],shadow:[Vt],spacing:["px",Ne],text:[Vt],"text-shadow":[Vt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Sn,pe,me,x]}],container:["container"],columns:[{columns:[Ne,pe,me,a]}],"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:C()}],overflow:[{overflow:j()}],"overflow-x":[{"overflow-x":j()}],"overflow-y":[{"overflow-y":j()}],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:[Yt,"auto",me,pe]}],basis:[{basis:[Sn,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ne,Sn,"auto","initial","none",pe]}],grow:[{grow:["",Ne,me,pe]}],shrink:[{shrink:["",Ne,me,pe]}],order:[{order:[Yt,"first","last","none",me,pe]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":M()}],"auto-rows":[{"auto-rows":M()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...w(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...w()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":w()}],"place-items":[{"place-items":[...D(),"baseline"]}],"place-self":[{"place-self":["auto",...D()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:H()}],mx:[{mx:H()}],my:[{my:H()}],ms:[{ms:H()}],me:[{me:H()}],mt:[{mt:H()}],mr:[{mr:H()}],mb:[{mb:H()}],ml:[{ml:H()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:B()}],w:[{w:[a,"screen",...B()]}],"min-w":[{"min-w":[a,"screen","none",...B()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...B()]}],h:[{h:["screen","lh",...B()]}],"min-h":[{"min-h":["screen","lh","none",...B()]}],"max-h":[{"max-h":["screen","lh",...B()]}],"font-size":[{text:["base",n,lr,dn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,me,ys]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",xs,pe]}],"font-family":[{font:[Ib,pe,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,me,pe]}],"line-clamp":[{"line-clamp":[Ne,"none",me,ys]}],leading:[{leading:[s,...T()]}],"list-image":[{"list-image":["none",me,pe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",me,pe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:q()}],"text-color":[{text:q()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...X(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ne,"from-font","auto",me,dn]}],"text-decoration-color":[{decoration:q()}],"underline-offset":[{"underline-offset":[Ne,"auto",me,pe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",me,pe]}],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",me,pe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Y()}],"bg-repeat":[{bg:I()}],"bg-size":[{bg:W()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Yt,me,pe],radial:["",me,pe],conic:[Yt,me,pe]},Rb,Ab]}],"bg-color":[{bg:q()}],"gradient-from-pos":[{from:V()}],"gradient-via-pos":[{via:V()}],"gradient-to-pos":[{to:V()}],"gradient-from":[{from:q()}],"gradient-via":[{via:q()}],"gradient-to":[{to:q()}],rounded:[{rounded:z()}],"rounded-s":[{"rounded-s":z()}],"rounded-e":[{"rounded-e":z()}],"rounded-t":[{"rounded-t":z()}],"rounded-r":[{"rounded-r":z()}],"rounded-b":[{"rounded-b":z()}],"rounded-l":[{"rounded-l":z()}],"rounded-ss":[{"rounded-ss":z()}],"rounded-se":[{"rounded-se":z()}],"rounded-ee":[{"rounded-ee":z()}],"rounded-es":[{"rounded-es":z()}],"rounded-tl":[{"rounded-tl":z()}],"rounded-tr":[{"rounded-tr":z()}],"rounded-br":[{"rounded-br":z()}],"rounded-bl":[{"rounded-bl":z()}],"border-w":[{border:oe()}],"border-w-x":[{"border-x":oe()}],"border-w-y":[{"border-y":oe()}],"border-w-s":[{"border-s":oe()}],"border-w-e":[{"border-e":oe()}],"border-w-t":[{"border-t":oe()}],"border-w-r":[{"border-r":oe()}],"border-w-b":[{"border-b":oe()}],"border-w-l":[{"border-l":oe()}],"divide-x":[{"divide-x":oe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":oe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...X(),"hidden","none"]}],"divide-style":[{divide:[...X(),"hidden","none"]}],"border-color":[{border:q()}],"border-color-x":[{"border-x":q()}],"border-color-y":[{"border-y":q()}],"border-color-s":[{"border-s":q()}],"border-color-e":[{"border-e":q()}],"border-color-t":[{"border-t":q()}],"border-color-r":[{"border-r":q()}],"border-color-b":[{"border-b":q()}],"border-color-l":[{"border-l":q()}],"divide-color":[{divide:q()}],"outline-style":[{outline:[...X(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ne,me,pe]}],"outline-w":[{outline:["",Ne,lr,dn]}],"outline-color":[{outline:q()}],shadow:[{shadow:["","none",d,Vr,Zr]}],"shadow-color":[{shadow:q()}],"inset-shadow":[{"inset-shadow":["none",h,Vr,Zr]}],"inset-shadow-color":[{"inset-shadow":q()}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:q()}],"ring-offset-w":[{"ring-offset":[Ne,dn]}],"ring-offset-color":[{"ring-offset":q()}],"inset-ring-w":[{"inset-ring":oe()}],"inset-ring-color":[{"inset-ring":q()}],"text-shadow":[{"text-shadow":["none",p,Vr,Zr]}],"text-shadow-color":[{"text-shadow":q()}],opacity:[{opacity:[Ne,me,pe]}],"mix-blend":[{"mix-blend":[...de(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":de()}],"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":[Ne]}],"mask-image-linear-from-pos":[{"mask-linear-from":te()}],"mask-image-linear-to-pos":[{"mask-linear-to":te()}],"mask-image-linear-from-color":[{"mask-linear-from":q()}],"mask-image-linear-to-color":[{"mask-linear-to":q()}],"mask-image-t-from-pos":[{"mask-t-from":te()}],"mask-image-t-to-pos":[{"mask-t-to":te()}],"mask-image-t-from-color":[{"mask-t-from":q()}],"mask-image-t-to-color":[{"mask-t-to":q()}],"mask-image-r-from-pos":[{"mask-r-from":te()}],"mask-image-r-to-pos":[{"mask-r-to":te()}],"mask-image-r-from-color":[{"mask-r-from":q()}],"mask-image-r-to-color":[{"mask-r-to":q()}],"mask-image-b-from-pos":[{"mask-b-from":te()}],"mask-image-b-to-pos":[{"mask-b-to":te()}],"mask-image-b-from-color":[{"mask-b-from":q()}],"mask-image-b-to-color":[{"mask-b-to":q()}],"mask-image-l-from-pos":[{"mask-l-from":te()}],"mask-image-l-to-pos":[{"mask-l-to":te()}],"mask-image-l-from-color":[{"mask-l-from":q()}],"mask-image-l-to-color":[{"mask-l-to":q()}],"mask-image-x-from-pos":[{"mask-x-from":te()}],"mask-image-x-to-pos":[{"mask-x-to":te()}],"mask-image-x-from-color":[{"mask-x-from":q()}],"mask-image-x-to-color":[{"mask-x-to":q()}],"mask-image-y-from-pos":[{"mask-y-from":te()}],"mask-image-y-to-pos":[{"mask-y-to":te()}],"mask-image-y-from-color":[{"mask-y-from":q()}],"mask-image-y-to-color":[{"mask-y-to":q()}],"mask-image-radial":[{"mask-radial":[me,pe]}],"mask-image-radial-from-pos":[{"mask-radial-from":te()}],"mask-image-radial-to-pos":[{"mask-radial-to":te()}],"mask-image-radial-from-color":[{"mask-radial-from":q()}],"mask-image-radial-to-color":[{"mask-radial-to":q()}],"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":S()}],"mask-image-conic-pos":[{"mask-conic":[Ne]}],"mask-image-conic-from-pos":[{"mask-conic-from":te()}],"mask-image-conic-to-pos":[{"mask-conic-to":te()}],"mask-image-conic-from-color":[{"mask-conic-from":q()}],"mask-image-conic-to-color":[{"mask-conic-to":q()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Y()}],"mask-repeat":[{mask:I()}],"mask-size":[{mask:W()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",me,pe]}],filter:[{filter:["","none",me,pe]}],blur:[{blur:ce()}],brightness:[{brightness:[Ne,me,pe]}],contrast:[{contrast:[Ne,me,pe]}],"drop-shadow":[{"drop-shadow":["","none",f,Vr,Zr]}],"drop-shadow-color":[{"drop-shadow":q()}],grayscale:[{grayscale:["",Ne,me,pe]}],"hue-rotate":[{"hue-rotate":[Ne,me,pe]}],invert:[{invert:["",Ne,me,pe]}],saturate:[{saturate:[Ne,me,pe]}],sepia:[{sepia:["",Ne,me,pe]}],"backdrop-filter":[{"backdrop-filter":["","none",me,pe]}],"backdrop-blur":[{"backdrop-blur":ce()}],"backdrop-brightness":[{"backdrop-brightness":[Ne,me,pe]}],"backdrop-contrast":[{"backdrop-contrast":[Ne,me,pe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ne,me,pe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ne,me,pe]}],"backdrop-invert":[{"backdrop-invert":["",Ne,me,pe]}],"backdrop-opacity":[{"backdrop-opacity":[Ne,me,pe]}],"backdrop-saturate":[{"backdrop-saturate":[Ne,me,pe]}],"backdrop-sepia":[{"backdrop-sepia":["",Ne,me,pe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",me,pe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ne,"initial",me,pe]}],ease:[{ease:["linear","initial",y,me,pe]}],delay:[{delay:[Ne,me,pe]}],animate:[{animate:["none",b,me,pe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,me,pe]}],"perspective-origin":[{"perspective-origin":C()}],rotate:[{rotate:fe()}],"rotate-x":[{"rotate-x":fe()}],"rotate-y":[{"rotate-y":fe()}],"rotate-z":[{"rotate-z":fe()}],scale:[{scale:ge()}],"scale-x":[{"scale-x":ge()}],"scale-y":[{"scale-y":ge()}],"scale-z":[{"scale-z":ge()}],"scale-3d":["scale-3d"],skew:[{skew:xe()}],"skew-x":[{"skew-x":xe()}],"skew-y":[{"skew-y":xe()}],transform:[{transform:[me,pe,"","none","gpu","cpu"]}],"transform-origin":[{origin:C()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ee()}],"translate-x":[{"translate-x":Ee()}],"translate-y":[{"translate-y":Ee()}],"translate-z":[{"translate-z":Ee()}],"translate-none":["translate-none"],accent:[{accent:q()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:q()}],"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",me,pe]}],"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":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"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",me,pe]}],fill:[{fill:["none",...q()]}],"stroke-w":[{stroke:[Ne,lr,dn,ys]}],stroke:[{stroke:["none",...q()]}],"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"]}},Mb=gb(Db);function he(...e){return Mb(fd(e))}function qe(e){return e>=1048576?(e/1048576).toFixed(1).replace(/\.0$/,"")+"M":e>=1024?(e/1024).toFixed(1).replace(/\.0$/,"")+"K":e.toString()}function Cd(e){return e===null?"pending":e>=200&&e<300?"success":e>=400&&e<500?"client_error":e>=500?"server_error":"pending"}const xl=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,yl=fd,Ji=(e,t)=>n=>{var r;if(t?.variants==null)return yl(e,n?.class,n?.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(u=>{const d=n?.[u],h=s?.[u];if(d===null)return null;const p=xl(d)||xl(h);return o[u][p]}),a=n&&Object.entries(n).reduce((u,d)=>{let[h,p]=d;return p===void 0||(u[h]=p),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:h,className:p,...f}=d;return Object.entries(f).every(g=>{let[m,x]=g;return Array.isArray(x)?x.includes({...s,...a}[m]):{...s,...a}[m]===x})?[...u,h,p]:u},[]);return yl(e,i,c,n?.class,n?.className)};function vl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function jd(...e){return t=>{let n=!1;const r=e.map(o=>{const s=vl(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():vl(e[o],null)}}}}function Re(...e){return v.useCallback(jd(...e),e)}function Wn(e){const t=Fb(e),n=v.forwardRef((r,o)=>{const{children:s,...i}=r,a=v.Children.toArray(s),c=a.find(Bb);if(c){const u=c.props.children,d=a.map(h=>h===c?v.Children.count(u)>1?v.Children.only(null):v.isValidElement(u)?u.props.children:null:h);return l.jsx(t,{...i,ref:o,children:v.isValidElement(u)?v.cloneElement(u,void 0,d):null})}return l.jsx(t,{...i,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}var Lb=Wn("Slot");function Fb(e){const t=v.forwardRef((n,r)=>{const{children:o,...s}=n;if(v.isValidElement(o)){const i=Zb(o),a=Ub(s,o.props);return o.type!==v.Fragment&&(a.ref=r?jd(r,i):i),v.cloneElement(o,a)}return v.Children.count(o)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ed=Symbol("radix.slottable");function $b(e){const t=({children:n})=>l.jsx(l.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=Ed,t}function Bb(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ed}function Ub(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function Zb(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 Vb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ce=Vb.reduce((e,t)=>{const n=Wn(`Primitive.${t}`),r=v.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Wb(e,t){e&&Tr.flushSync(()=>e.dispatchEvent(t))}var Nd=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"}),Hb="VisuallyHidden",Td=v.forwardRef((e,t)=>l.jsx(Ce.span,{...e,ref:t,style:{...Nd,...e.style}}));Td.displayName=Hb;var qb=Td;function Kb(e,t){const n=v.createContext(t),r=s=>{const{children:i,...a}=s,c=v.useMemo(()=>a,Object.values(a));return l.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=v.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function Jt(e,t=[]){let n=[];function r(s,i){const a=v.createContext(i),c=n.length;n=[...n,i];const u=h=>{const{scope:p,children:f,...g}=h,m=p?.[e]?.[c]||a,x=v.useMemo(()=>g,Object.values(g));return l.jsx(m.Provider,{value:x,children:f})};u.displayName=s+"Provider";function d(h,p){const f=p?.[e]?.[c]||a,g=v.useContext(f);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>v.createContext(i));return function(a){const c=a?.[e]||s;return v.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,Gb(o,...t)]}function Gb(...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(s){const i=r.reduce((a,{useScope:c,scopeName:u})=>{const h=c(s)[`__scope${u}`];return{...a,...h}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Ad(e){const t=e+"CollectionProvider",[n,r]=Jt(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=m=>{const{scope:x,children:y}=m,b=at.useRef(null),k=at.useRef(new Map).current;return l.jsx(o,{scope:x,itemMap:k,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",c=Wn(a),u=at.forwardRef((m,x)=>{const{scope:y,children:b}=m,k=s(a,y),S=Re(x,k.collectionRef);return l.jsx(c,{ref:S,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",p=Wn(d),f=at.forwardRef((m,x)=>{const{scope:y,children:b,...k}=m,S=at.useRef(null),C=Re(x,S),j=s(d,y);return at.useEffect(()=>(j.itemMap.set(S,{ref:S,...k}),()=>{j.itemMap.delete(S)})),l.jsx(p,{[h]:"",ref:C,children:b})});f.displayName=d;function g(m){const x=s(e+"CollectionConsumer",m);return at.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const k=Array.from(b.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((j,N)=>k.indexOf(j.ref.current)-k.indexOf(N.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:u,ItemSlot:f},g,r]}function we(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}var et=globalThis?.document?v.useLayoutEffect:()=>{},Jb=cu[" useInsertionEffect ".trim().toString()]||et;function pn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Yb({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const d=v.useRef(e!==void 0);v.useEffect(()=>{const h=d.current;h!==a&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${a?"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=a},[a,r])}const u=v.useCallback(d=>{if(a){const h=Xb(d)?d(e):d;h!==e&&i.current?.(h)}else s(d)},[a,e,s,i]);return[c,u]}function Yb({defaultProp:e,onChange:t}){const[n,r]=v.useState(e),o=v.useRef(n),s=v.useRef(t);return Jb(()=>{s.current=t},[t]),v.useEffect(()=>{o.current!==n&&(s.current?.(n),o.current=n)},[n,o]),[n,r,s]}function Xb(e){return typeof e=="function"}function Qb(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var kt=e=>{const{present:t,children:n}=e,r=e2(t),o=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),s=Re(r.ref,t2(o));return typeof n=="function"||r.isPresent?v.cloneElement(o,{ref:s}):null};kt.displayName="Presence";function e2(e){const[t,n]=v.useState(),r=v.useRef(null),o=v.useRef(e),s=v.useRef("none"),i=e?"mounted":"unmounted",[a,c]=Qb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const u=Wr(r.current);s.current=a==="mounted"?u:"none"},[a]),et(()=>{const u=r.current,d=o.current;if(d!==e){const p=s.current,f=Wr(u);e?c("MOUNT"):f==="none"||u?.display==="none"?c("UNMOUNT"):c(d&&p!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),et(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,h=f=>{const m=Wr(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&m&&(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)})}},p=f=>{f.target===t&&(s.current=Wr(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:v.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function Wr(e){return e?.animationName||"none"}function t2(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 n2=cu[" useId ".trim().toString()]||(()=>{}),r2=0;function Dt(e){const[t,n]=v.useState(n2());return et(()=>{n(r=>r??String(r2++))},[e]),e||(t?`radix-${t}`:"")}var Lo="Collapsible",[o2]=Jt(Lo),[s2,Yi]=o2(Lo),Id=v.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[c,u]=pn({prop:r,defaultProp:o??!1,onChange:i,caller:Lo});return l.jsx(s2,{scope:n,disabled:s,contentId:Dt(),open:c,onOpenToggle:v.useCallback(()=>u(d=>!d),[u]),children:l.jsx(Ce.div,{"data-state":Qi(c),"data-disabled":s?"":void 0,...a,ref:t})})});Id.displayName=Lo;var zd="CollapsibleTrigger",Rd=v.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Yi(zd,n);return l.jsx(Ce.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Qi(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:we(e.onClick,o.onOpenToggle)})});Rd.displayName=zd;var Xi="CollapsibleContent",Pd=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Yi(Xi,e.__scopeCollapsible);return l.jsx(kt,{present:n||o.open,children:({present:s})=>l.jsx(i2,{...r,ref:t,present:s})})});Pd.displayName=Xi;var i2=v.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Yi(Xi,n),[a,c]=v.useState(r),u=v.useRef(null),d=Re(t,u),h=v.useRef(0),p=h.current,f=v.useRef(0),g=f.current,m=i.open||a,x=v.useRef(m),y=v.useRef(void 0);return v.useEffect(()=>{const b=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(b)},[]),et(()=>{const b=u.current;if(b){y.current=y.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const k=b.getBoundingClientRect();h.current=k.height,f.current=k.width,x.current||(b.style.transitionDuration=y.current.transitionDuration,b.style.animationName=y.current.animationName),c(r)}},[i.open,r]),l.jsx(Ce.div,{"data-state":Qi(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!m,...s,ref:d,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:m&&o})});function Qi(e){return e?"open":"closed"}var a2=Id,l2=v.createContext(void 0);function Fo(e){const t=v.useContext(l2);return e||t||"ltr"}function st(e){const t=v.useRef(e);return v.useEffect(()=>{t.current=e}),v.useMemo(()=>(...n)=>t.current?.(...n),[])}function c2(e,t=globalThis?.document){const n=st(e);v.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 u2="DismissableLayer",ti="dismissableLayer.update",d2="dismissableLayer.pointerDownOutside",f2="dismissableLayer.focusOutside",bl,Od=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),$o=v.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,u=v.useContext(Od),[d,h]=v.useState(null),p=d?.ownerDocument??globalThis?.document,[,f]=v.useState({}),g=Re(t,N=>h(N)),m=Array.from(u.layers),[x]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=m.indexOf(x),b=d?m.indexOf(d):-1,k=u.layersWithOutsidePointerEventsDisabled.size>0,S=b>=y,C=m2(N=>{const T=N.target,A=[...u.branches].some(O=>O.contains(T));!S||A||(o?.(N),i?.(N),N.defaultPrevented||a?.())},p),j=g2(N=>{const T=N.target;[...u.branches].some(O=>O.contains(T))||(s?.(N),i?.(N),N.defaultPrevented||a?.())},p);return c2(N=>{b===u.layers.size-1&&(r?.(N),!N.defaultPrevented&&a&&(N.preventDefault(),a()))},p),v.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(bl=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),wl(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=bl)}},[d,p,n,u]),v.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),wl())},[d,u]),v.useEffect(()=>{const N=()=>f({});return document.addEventListener(ti,N),()=>document.removeEventListener(ti,N)},[]),l.jsx(Ce.div,{...c,ref:g,style:{pointerEvents:k?S?"auto":"none":void 0,...e.style},onFocusCapture:we(e.onFocusCapture,j.onFocusCapture),onBlurCapture:we(e.onBlurCapture,j.onBlurCapture),onPointerDownCapture:we(e.onPointerDownCapture,C.onPointerDownCapture)})});$o.displayName=u2;var h2="DismissableLayerBranch",p2=v.forwardRef((e,t)=>{const n=v.useContext(Od),r=v.useRef(null),o=Re(t,r);return v.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),l.jsx(Ce.div,{...e,ref:o})});p2.displayName=h2;function m2(e,t=globalThis?.document){const n=st(e),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){Dd(d2,n,u,{discrete:!0})};const u={originalEvent:a};a.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},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function g2(e,t=globalThis?.document){const n=st(e),r=v.useRef(!1);return v.useEffect(()=>{const o=s=>{s.target&&!r.current&&Dd(f2,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function wl(){const e=new CustomEvent(ti);document.dispatchEvent(e)}function Dd(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Wb(o,s):o.dispatchEvent(s)}var vs="focusScope.autoFocusOnMount",bs="focusScope.autoFocusOnUnmount",kl={bubbles:!1,cancelable:!0},x2="FocusScope",ea=v.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=v.useState(null),u=st(o),d=st(s),h=v.useRef(null),p=Re(t,m=>c(m)),f=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let m=function(k){if(f.paused||!a)return;const S=k.target;a.contains(S)?h.current=S:Qt(h.current,{select:!0})},x=function(k){if(f.paused||!a)return;const S=k.relatedTarget;S!==null&&(a.contains(S)||Qt(h.current,{select:!0}))},y=function(k){if(document.activeElement===document.body)for(const C of k)C.removedNodes.length>0&&Qt(a)};document.addEventListener("focusin",m),document.addEventListener("focusout",x);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",x),b.disconnect()}}},[r,a,f.paused]),v.useEffect(()=>{if(a){Sl.add(f);const m=document.activeElement;if(!a.contains(m)){const y=new CustomEvent(vs,kl);a.addEventListener(vs,u),a.dispatchEvent(y),y.defaultPrevented||(y2(_2(Md(a)),{select:!0}),document.activeElement===m&&Qt(a))}return()=>{a.removeEventListener(vs,u),setTimeout(()=>{const y=new CustomEvent(bs,kl);a.addEventListener(bs,d),a.dispatchEvent(y),y.defaultPrevented||Qt(m??document.body,{select:!0}),a.removeEventListener(bs,d),Sl.remove(f)},0)}}},[a,u,d,f]);const g=v.useCallback(m=>{if(!n&&!r||f.paused)return;const x=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,y=document.activeElement;if(x&&y){const b=m.currentTarget,[k,S]=v2(b);k&&S?!m.shiftKey&&y===S?(m.preventDefault(),n&&Qt(k,{select:!0})):m.shiftKey&&y===k&&(m.preventDefault(),n&&Qt(S,{select:!0})):y===b&&m.preventDefault()}},[n,r,f.paused]);return l.jsx(Ce.div,{tabIndex:-1,...i,ref:p,onKeyDown:g})});ea.displayName=x2;function y2(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Qt(r,{select:t}),document.activeElement!==n)return}function v2(e){const t=Md(e),n=_l(t,e),r=_l(t.reverse(),e);return[n,r]}function Md(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 _l(e,t){for(const n of e)if(!b2(n,{upTo:t}))return n}function b2(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 w2(e){return e instanceof HTMLInputElement&&"select"in e}function Qt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&w2(e)&&t&&e.select()}}var Sl=k2();function k2(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Cl(e,t),e.unshift(t)},remove(t){e=Cl(e,t),e[0]?.resume()}}}function Cl(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function _2(e){return e.filter(t=>t.tagName!=="A")}var S2="Portal",Bo=v.forwardRef((e,t)=>{const{container:n,...r}=e,[o,s]=v.useState(!1);et(()=>s(!0),[]);const i=n||o&&globalThis?.document?.body;return i?Kp.createPortal(l.jsx(Ce.div,{...r,ref:t}),i):null});Bo.displayName=S2;var ws=0;function Ld(){v.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??jl()),document.body.insertAdjacentElement("beforeend",e[1]??jl()),ws++,()=>{ws===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ws--}},[])}function jl(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Rt=function(){return Rt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Rt.apply(this,arguments)};function Fd(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 C2(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var ro="right-scroll-bar-position",oo="width-before-scroll-bar",j2="with-scroll-bars-hidden",E2="--removed-body-scroll-bar-size";function ks(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function N2(e,t){var n=v.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 T2=typeof window<"u"?v.useLayoutEffect:v.useEffect,El=new WeakMap;function A2(e,t){var n=N2(null,function(r){return e.forEach(function(o){return ks(o,r)})});return T2(function(){var r=El.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||ks(a,null)}),s.forEach(function(a){o.has(a)||ks(a,i)})}El.set(n,e)},[e]),n}function I2(e){return e}function z2(e,t){t===void 0&&(t=I2);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(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var c=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function R2(e){e===void 0&&(e={});var t=z2(null);return t.options=Rt({async:!0,ssr:!1},e),t}var $d=function(e){var t=e.sideCar,n=Fd(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 v.createElement(r,Rt({},n))};$d.isSideCarExport=!0;function P2(e,t){return e.useMedium(t),$d}var Bd=R2(),_s=function(){},Uo=v.forwardRef(function(e,t){var n=v.useRef(null),r=v.useState({onScrollCapture:_s,onWheelCapture:_s,onTouchMoveCapture:_s}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,h=e.shards,p=e.sideCar,f=e.noRelative,g=e.noIsolation,m=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,k=e.gapMode,S=Fd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=p,j=A2([n,t]),N=Rt(Rt({},S),o);return v.createElement(v.Fragment,null,d&&v.createElement(C,{sideCar:Bd,removeScrollBar:u,shards:h,noRelative:f,noIsolation:g,inert:m,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:k}),i?v.cloneElement(v.Children.only(a),Rt(Rt({},N),{ref:j})):v.createElement(b,Rt({},N,{className:c,ref:j}),a))});Uo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Uo.classNames={fullWidth:oo,zeroRight:ro};var O2=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function D2(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=O2();return t&&e.setAttribute("nonce",t),e}function M2(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function L2(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var F2=function(){var e=0,t=null;return{add:function(n){e==0&&(t=D2())&&(M2(t,n),L2(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},$2=function(){var e=F2();return function(t,n){v.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Ud=function(){var e=$2(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},B2={left:0,top:0,right:0,gap:0},Ss=function(e){return parseInt(e||"",10)||0},U2=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[Ss(n),Ss(r),Ss(o)]},Z2=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return B2;var t=U2(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])}},V2=Ud(),Mn="data-scroll-locked",W2=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
41
41
  .`.concat(j2,` {
42
42
  overflow: hidden `).concat(r,`;
43
43
  padding-right: `).concat(a,"px ").concat(r,`;
@@ -102,6 +102,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
102
102
  `));const n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let o=0;o<r.length;o++){const s=r[o];o%2&&!t.newlineIsToken?n[n.length-1]+=s:n.push(s)}return n}class q3 extends Op{constructor(){super(...arguments),this.tokenize=Mp}get useLongestToken(){return!0}castInput(t,n){const{undefinedReplacement:r,stringifyReplacer:o=(s,i)=>typeof i>"u"?r:i}=n;return typeof t=="string"?t:JSON.stringify(ji(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 K3=new q3;function G3(e,t,n){return K3.diff(e,t,n)}function ji(e,t,n,r,o){t=t||[],n=n||[],r&&(e=r(o===void 0?"":o,e));let s;for(s=0;s<t.length;s+=1)if(t[s]===e)return n[s];let i;if(Object.prototype.toString.call(e)==="[object Array]"){for(t.push(e),i=new Array(e.length),n.push(i),s=0;s<e.length;s+=1)i[s]=ji(e[s],t,n,r,String(s));return t.pop(),n.pop(),i}if(e&&e.toJSON&&(e=e.toJSON()),typeof e=="object"&&e!==null){t.push(e),i={},n.push(i);const a=[];let c;for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&a.push(c);for(a.sort(),s=0;s<a.length;s+=1)c=a[s],i[c]=ji(e[c],t,n,r,c);t.pop(),n.pop()}else i=e;return i}function Oc(e){return e===void 0?[]:Object.entries(e).map(t=>[t[0].toLowerCase(),t[1]]).sort(([t],[n])=>t.localeCompare(n))}function Dc([e,t]){return`${e}: ${t}`}function Ei(e){const t=[];let n=0,r=0;for(const o of e){const s=o.value.split(`
103
103
  `);s.length>0&&s[s.length-1]===""&&s.pop();for(const i of s)o.added?(r+=1,t.push({kind:"added",text:i,oldLineNumber:null,newLineNumber:r})):o.removed?(n+=1,t.push({kind:"removed",text:i,oldLineNumber:n,newLineNumber:null})):(n+=1,r+=1,t.push({kind:"context",text:i,oldLineNumber:n,newLineNumber:r}))}return t}function J3(e,t){const n=Oc(e).map(Dc).join(`
104
104
  `),r=Oc(t).map(Dc).join(`
105
- `);if(n===r)return{lines:[],isEmpty:!0};const o=Dp(n,r);return{lines:Ei(o),isEmpty:!1}}function Mc(e){try{const t=JSON.parse(e);return t===null||typeof t=="string"||typeof t=="object"?t:null}catch{return null}}function Y3(e,t){const n=e??"",r=t??"";if(n===r)return{lines:[],isEmpty:!0};const o=Mc(n),s=Mc(r);if(o!==null&&s!==null){const a=G3(o,s)??[];if(a.length===1){const c=a[0];if(c!==void 0&&!c.added&&!c.removed)return{lines:[],isEmpty:!0}}return{lines:Ei(a),isEmpty:!1}}const i=Dp(n,r);return{lines:Ei(i),isEmpty:!1}}function X3(e,t,n){const r=new Array(e);return new Proxy(r,{get(o,s,i){if(typeof s=="string"){const a=s.charCodeAt(0);if(a>=48&&a<=57){const c=+s;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(s==="length")return e}return Reflect.get(o,s,i)}})}function An(e,t,n){let r=n.initialDeps??[],o,s=!0;function i(){const a=e();return(a.length!==r.length||a.some((u,d)=>r[d]!==u))&&(r=a,o=t(...a),n?.onChange&&!(s&&n.skipInitialOnChange)&&n.onChange(o),s=!1),o}return i.updateDeps=a=>{r=a},i}function Lc(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const Fc=(e,t)=>Math.abs(e-t)<1.01,Q3=(e,t,n)=>{let r;return function(...o){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,o),n)}};let hr;const $c=()=>{if(hr!==void 0)return hr;if(typeof navigator>"u")return hr=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return hr=!0;const e=navigator.maxTouchPoints;return hr=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Bc=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},eN=e=>e,tN=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 s=0;s<r;s++)o[s]=t+s;return o},nN=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const o=i=>{const{width:a,height:c}=i;t({width:Math.round(a),height:Math.round(c)})};if(o(Bc(n)),!r.ResizeObserver)return()=>{};const s=new r.ResizeObserver(i=>{const a=()=>{const c=i[0];if(c?.borderBoxSize){const u=c.borderBoxSize[0];if(u){o({width:u.inlineSize,height:u.blockSize});return}}o(Bc(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},No={passive:!0},rN=typeof window>"u"?!0:"onscrollend"in window,oN=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const o=e.targetWindow;if(!o)return;const s=e.options.useScrollendEvent&&rN;let i=0;const a=s?null:Q3(o,()=>t(i,!1),e.options.isScrollingResetDelay),c=h=>()=>{i=n(r),a?.(),t(i,h)},u=c(!0),d=c(!1);return r.addEventListener("scroll",u,No),s&&r.addEventListener("scrollend",d,No),()=>{r.removeEventListener("scroll",u),s&&r.removeEventListener("scrollend",d)}},sN=(e,t)=>oN(e,t,n=>{const{horizontal:r,isRtl:o}=e.options;return r?n.scrollLeft*(o&&-1||1):n.scrollTop}),iN=(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"]},aN=(e,{adjustments:t=0,behavior:n},r)=>{var o,s;(s=(o=r.scrollElement)==null?void 0:o.scrollTo)==null||s.call(o,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})},lN=aN;class cN{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(s=>{const i=()=>{const a=s.target,c=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[u,d]of this.elementsCache)if(d===a){this.elementsCache.delete(u);break}return}this.shouldMeasureDuringScroll(c)&&this.resizeItem(c,this.options.measureElement(a,s,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var o;(o=r())==null||o.disconnect(),n=null},observe:o=>{var s;return(s=r())==null?void 0:s.observe(o,{box:"border-box"})},unobserve:o=>{var s;return(s=r())==null?void 0:s.unobserve(o)}}})(),this.range=null,this.setOptions=n=>{var r,o;const s={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:eN,rangeExtractor:tN,onChange:()=>{},measureElement:iN,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&&(s[u]=d)}const i=this.options;let a=null,c=null;if(i!==void 0&&i.enabled&&s.enabled&&s.anchorTo==="end"&&this.scrollElement!==null){const u=i.count,d=s.count,h=this.getMeasurements(),p=u>0?((r=h[0])==null?void 0:r.key)??i.getItemKey(0):null,f=u>0?((o=h[u-1])==null?void 0:o.key)??i.getItemKey(u-1):null;if(d!==u||u>0&&d>0&&(s.getItemKey(0)!==p||s.getItemKey(d-1)!==f)){const x=u>0?this.getVirtualItemForOffset(this.getScrollOffset())??h[0]:null;x&&(a=[x.key,this.getScrollOffset()-x.start]);const y=s.followOnAppend===!0?"auto":s.followOnAppend||null;y&&d>u&&this.isAtEnd(i.scrollEndThreshold)&&(u===0||s.getItemKey(d-1)!==f)&&(c=y)}}this.options=s,(a||c)&&(this.pendingScrollAnchor=[a?.[0]??null,a?.[1]??0,c])},this.notify=n=>{var r,o;(o=(r=this.options).onChange)==null||o.call(r,this,n)},this.maybeNotify=An(()=>(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(s=>{this.observer.observe(s)}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,i)=>{this._intendedScrollOffset!==null&&Math.abs(s-this._intendedScrollOffset)<1.5&&(s=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=i,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const s=this.scrollElement,i=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!$c()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};s.addEventListener("touchstart",i,No),s.addEventListener("touchend",a,No),this.unsubs.push(()=>{s.removeEventListener("touchstart",i),s.removeEventListener("touchend",a),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[s,i,a]=o;if(s!==null){const{count:c,getItemKey:u}=this.options;let d=0;for(;d<c&&u(d)!==s;)d++;const h=d<c?this.getMeasurements()[d]:void 0;if(h){const p=h.start+i-this.getScrollOffset();Fc(p,0)||this.applyScrollAdjustment(p)}}a&&this.scrollToEnd({behavior:a})}},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,s=new Map;for(let i=r-1;i>=0;i--){const a=n[i];if(o.has(a.lane))continue;const c=s.get(a.lane);if(c==null||a.end>c.end?s.set(a.lane,a):a.end<c.end&&o.set(a.lane,!0),o.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((i,a)=>i.end===a.end?i.index-a.index:i.end-a.end)[0]:void 0},this.getMeasurementOptions=An(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(n,r,o,s,i,a,c)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:n,paddingStart:r,scrollMargin:o,getItemKey:s,enabled:i,lanes:a,laneAssignmentMode:c}),{key:!1}),this.getMeasurements=An(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:r,scrollMargin:o,getItemKey:s,enabled:i,lanes:a,laneAssignmentMode:c},u)=>{const d=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const g of this.laneAssignments.keys())g>=n&&this.laneAssignments.delete(g);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(g=>{this.itemSizeCache.set(g.key,g.size)}));const h=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),a===1){const g=this.options.gap,m=n*2;let x=this._flatMeasurements;if(!x||x.length<m){const k=new Float64Array(m);x&&h>0&&k.set(x.subarray(0,h*2)),x=k,this._flatMeasurements=x}let y;if(h===0)y=r+o;else{const k=h-1;y=x[k*2]+x[k*2+1]+g}for(let k=h;k<n;k++){const S=s(k),C=d.get(S),j=typeof C=="number"?C:this.options.estimateSize(k);x[k*2]=y,x[k*2+1]=j,y+=j+g}const b=X3(n,x,s);return this.measurementsCache=b,b}const p=this.measurementsCache.slice(0,h),f=new Array(a).fill(void 0);for(let g=0;g<h;g++){const m=p[g];m&&(f[m.lane]=g)}for(let g=h;g<n;g++){const m=s(g),x=this.laneAssignments.get(g);let y,b;const k=c==="estimate"||d.has(m);if(x!==void 0&&this.options.lanes>1){y=x;const N=f[y],T=N!==void 0?p[N]:void 0;b=T?T.end+this.options.gap:r+o}else{const N=this.options.lanes===1?p[g-1]:this.getFurthestMeasurement(p,g);b=N?N.end+this.options.gap:r+o,y=N?N.lane:g%this.options.lanes,this.options.lanes>1&&k&&this.laneAssignments.set(g,y)}const S=d.get(m),C=typeof S=="number"?S:this.options.estimateSize(g),j=b+C;p[g]={index:g,start:b,size:C,end:j,key:m,lane:y},f[y]=g}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=An(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,o,s)=>this.range=n.length>0&&r>0?uN({measurements:n,outerSize:r,scrollOffset:o,lanes:s,flat:s===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=An(()=>{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,s,i)=>s===null||i===null?[]:n({startIndex:s,endIndex:i,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 s=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,o-s),a=Math.min(this.options.count-1,o+s);return n>=i&&n<=a}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((i,a)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(a))});return}const r=this.indexFromElement(n),o=this.options.getItemKey(r),s=this.elementsCache.get(o);s!==n&&(s&&this.observer.unobserve(s),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,s;if(n<0||n>=this.options.count)return;let i,a,c;const u=this._flatMeasurements;if(this.options.lanes===1&&u!==null)c=this.options.getItemKey(n),a=u[n*2],i=u[n*2+1];else{const p=this.measurementsCache[n];if(!p)return;c=p.key,a=p.start,i=p.size}const d=this.itemSizeCache.get(c)??i,h=r-d;if(h!==0){const p=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,f=p?this.getTotalSize():0,g=((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:c,start:a,size:i,end:a+i,lane:0},h,this):a<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!=="backward");(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(c,r),this.itemSizeCacheVersion++,p?this.applyScrollAdjustment(this.getTotalSize()-f):g&&this.applyScrollAdjustment(h),this.notify(!1)}},this.getVirtualItems=An(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const o=[];for(let s=0,i=n.length;s<i;s++){const a=n[s],c=r[a];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,s=this.options.lanes===1&&o!=null,i=Lp(0,r.length-1,s?a=>o[a*2]:a=>Lc(r[a]).start,n);return Lc(r[i])},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 s=this.getSize(),i=this.getScrollOffset();r==="auto"&&(r=n>=i+s?"end":"start"),r==="center"?n+=(o-s)/2:r==="end"&&(n-=s);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const o=this.getSize(),s=this.getScrollOffset(),i=this.measurementsCache[n];if(!i)return;if(r==="auto")if(i.end>=s+o-this.options.scrollPaddingEnd)r="end";else if(i.start<=s+this.options.scrollPaddingStart)r="start";else return[s,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const a=r==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,r,i.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:o="auto"}={})=>{const s=this.getOffsetForAlignment(n,r),i=this.now();this.scrollState={index:null,align:r,behavior:o,startedAt:i,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{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 s=this.getOffsetForIndex(n,r);if(!s)return;const[i,a]=s,c=this.now();this.scrollState={index:n,align:a,behavior:o,startedAt:c,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const o=this.getScrollOffset()+n,s=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:s,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 s=r.length-1,i=this._flatMeasurements;i!=null?o=i[s*2]+i[s*2+1]:o=((n=r[s])==null?void 0:n.end)??0}else{const s=Array(this.options.lanes).fill(null);let i=r.length-1;for(;i>=0&&s.some(a=>a===null);){const a=r[i];s[a.lane]===null&&(s[a.lane]=a.end),i--}o=Math.max(...s.filter(a=>a!==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&&($c()&&(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,s=1,i=o!==this.scrollState.lastTargetOffset;if(!i&&Fc(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=s){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,i){const a=this.getSize()||600,c=Math.abs(o-this.getScrollOffset()),u=this.scrollState.behavior==="smooth"&&c>a;this.scrollState.lastTargetOffset=o,u||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:u?"smooth":"auto"})}this.scheduleScrollReconcile()}}const Lp=(e,t,n,r)=>{for(;e<=t;){const o=(e+t)/2|0,s=n(o);if(s<r)e=o+1;else if(s>r)t=o-1;else return o}return e>0?e-1:0};function uN({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:o}){const s=e.length-1,i=o?d=>o[d*2]:d=>e[d].start,a=o?d=>o[d*2]+o[d*2+1]:d=>e[d].end;if(e.length<=r)return{startIndex:0,endIndex:s};let c=Lp(0,s,i,n),u=c;if(r===1)for(;u<s&&a(u)<n+t;)u++;else if(r>1){const d=Array(r).fill(0);for(;u<s&&d.some(p=>p<n+t);){const p=e[u];d[p.lane]=p.end,u++}const h=Array(r).fill(n+t);for(;c>=0&&h.some(p=>p>=n);){const p=e[c];h[p.lane]=p.start,c--}c=Math.max(0,c-c%r),u=Math.min(s,u+(r-1-u%r))}return{startIndex:c,endIndex:u}}const Uc=typeof document<"u"?v.useLayoutEffect:v.useEffect;function dN({useFlushSync:e=!0,...t}){const n=v.useReducer(s=>s+1,0)[1],r={...t,onChange:(s,i)=>{var a;e&&i?Tr.flushSync(n):n(),(a=t.onChange)==null||a.call(t,s,i)}},[o]=v.useState(()=>new cN(r));return o.setOptions(r),Uc(()=>o._didMount(),[]),Uc(()=>o._willUpdate()),o}function fN(e){return dN({observeElementRect:nN,observeElementOffset:sN,scrollToFn:lN,...e})}const hN=22,Us=1e4;function pN(e){return e==="added"?"+":e==="removed"?"-":" "}function mN(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 gN=function({result:t,emptyLabel:n}){const[r,o]=v.useState("unified"),s=v.useRef(null),i=fN({count:t.lines.length,getScrollElement:()=>s.current,estimateSize:()=>hN,overscan:10});if(t.isEmpty)return l.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 a=t.lines.length,c=a>Us,u=c?t.lines.slice(0,Us):t.lines;return l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[l.jsxs("span",{children:[a.toLocaleString()," line",a===1?"":"s",c&&` (showing first ${Us.toLocaleString()})`]}),l.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[l.jsxs("button",{type:"button",onClick:()=>o("unified"),"aria-pressed":r==="unified",className:he("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:[l.jsx(ld,{className:"size-3"}),"Unified"]}),l.jsxs("button",{type:"button",onClick:()=>o("split"),"aria-pressed":r==="split",className:he("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:[l.jsx(rd,{className:"size-3"}),"Split"]})]})]}),l.jsx("div",{ref:s,className:"max-h-[60vh] overflow-auto rounded border border-border bg-background font-mono text-xs","data-testid":"diff-viewport",children:r==="unified"?l.jsx(xN,{virtualizer:i,lines:u}):l.jsx(bN,{lines:u})})]})};function xN({virtualizer:e,lines:t}){return l.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:l.jsxs("div",{"data-index":n.index,ref:e.measureElement,className:he("flex items-start gap-3 px-2",mN(r.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${n.start}px)`},children:[l.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:r.oldLineNumber??""}),l.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:r.newLineNumber??""}),l.jsx("span",{className:he("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:pN(r.kind)}),l.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:r.text})]},n.key)})})}function yN(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=[],s=[];for(;n<e.length&&e[n]?.kind==="removed";){const a=e[n];a!==void 0&&o.push(a),n+=1}for(;n<e.length&&e[n]?.kind==="added";){const a=e[n];a!==void 0&&s.push(a),n+=1}const i=Math.max(o.length,s.length);for(let a=0;a<i;a+=1){const c=o[a],u=s[a];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 vN(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 bN({lines:e}){const t=yN(e);return l.jsx("div",{"data-testid":"diff-split",children:t.map((n,r)=>l.jsxs("div",{className:he("grid grid-cols-2 font-mono text-xs",vN(n.kind)),children:[l.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[l.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.left?.lineNumber??""}),l.jsx("span",{className:he("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?"-":" "}),l.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.left?.text??""})]}),l.jsxs("div",{className:"flex items-start gap-2 px-2",children:[l.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.right?.lineNumber??""}),l.jsx("span",{className:he("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?"+":" "}),l.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.right?.text??""})]})]},r))})}const Fp=v.memo(gN);function wN(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const Zc={success:"bg-emerald-500/15 text-emerald-400 border-emerald-500/25",client_error:"bg-amber-500/15 text-amber-400 border-amber-500/25",server_error:"",pending:"bg-muted text-muted-foreground border-border"};function Vc({trend:e}){if(e===null)return null;const t=e.direction==="up",n=t?Cy:_y,r=t?"+":"-";return l.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[l.jsx(n,{className:t?"size-3 text-emerald-400":"size-3 text-rose-400"}),l.jsxs("span",{className:"font-mono",children:[r,qe(e.delta)]})]})}const kN=v.memo(function({log:e,messageCount:t=null,toolCount:n=null,expanded:r,onToggle:o,responseToolNames:s=null,cacheTrend:i=null}){const a=Cd(e.responseStatus),c=e.inputTokens!==null||e.outputTokens!==null,u=v.useMemo(()=>s?.join(", ")??null,[s]);return l.jsx(Je,{children:l.jsxs("div",{role:"button",tabIndex:0,className:he("flex items-center gap-2 px-3 py-1 cursor-pointer transition-colors","hover:bg-muted/50","select-none"),onClick:o,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),o())},children:[l.jsxs("span",{className:"text-blue-400/80 font-mono text-xs font-semibold tabular-nums shrink-0",children:["#",e.id]}),e.model!==null&&l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("span",{className:"shrink-0",children:l.jsx(Yh,{provider:Jh(e.model),className:"size-4"})})}),l.jsx($e,{children:e.model})]}),a!=="success"&&l.jsx(l.Fragment,{children:a==="server_error"?l.jsx(xt,{variant:"destructive",className:"text-[10px] px-1.5 py-0 h-4 font-mono tabular-nums",children:e.responseStatus}):a==="pending"?l.jsx(xt,{variant:"outline",className:he("text-[10px] px-1.5 py-0 h-4 font-mono tabular-nums",Zc[a]),children:l.jsx(Sr,{className:"size-3 animate-spin"})}):l.jsx(xt,{variant:"outline",className:he("text-[10px] px-1.5 py-0 h-4 font-mono tabular-nums",Zc[a]),children:e.responseStatus})}),e.elapsedMs!==null&&l.jsxs("span",{className:"hidden xl:flex items-center gap-1 text-muted-foreground text-xs shrink-0",children:[l.jsx(Ir,{className:"size-3"}),l.jsx("span",{className:"font-mono tabular-nums",children:wN(e.elapsedMs)})]}),c&&l.jsxs("span",{className:"flex items-center gap-1 text-xs shrink-0",children:[l.jsx(Xn,{className:"size-3 text-muted-foreground"}),l.jsxs("span",{className:"font-mono tabular-nums",children:[l.jsxs("span",{className:e.inputTokens!==null?"text-blue-400":"text-muted-foreground",children:["IN ",e.inputTokens!==null?qe(e.inputTokens):"—"]})," / ",l.jsxs("span",{className:e.outputTokens!==null?"text-amber-400":"text-muted-foreground",children:["OUT ",e.outputTokens!==null?qe(e.outputTokens):"—"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("span",{className:"flex items-center gap-1 text-xs shrink-0",children:[l.jsx(Vc,{trend:i?.creation??null}),l.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["Cache +",qe(e.cacheCreationInputTokens)]})]})}),l.jsx($e,{children:"Tokens cached for reuse, reducing future API cost"})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("span",{className:"flex items-center gap-1 text-xs shrink-0",children:[l.jsx(Vc,{trend:i?.read??null}),l.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["Cache ~",qe(e.cacheReadInputTokens)]})]})}),l.jsx($e,{children:"Tokens served from cache, reducing API cost"})]}),t!==null&&l.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs shrink-0",children:[l.jsx(sd,{className:"size-3"}),l.jsx("span",{className:"font-mono tabular-nums",children:t})]}),n!==null&&l.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs shrink-0",children:[l.jsx(ul,{className:"size-3"}),l.jsx("span",{className:"font-mono tabular-nums",children:n})]}),s!==null&&s.length>0&&l.jsxs("span",{className:"flex items-center gap-1 text-amber-400/80 text-xs shrink-0",children:[l.jsx(ul,{className:"size-3"}),l.jsx("span",{className:"font-mono tabular-nums truncate max-w-[160px]",children:u})]}),e.origin!==null&&l.jsxs("span",{className:"hidden xl:flex items-center gap-1 text-muted-foreground text-xs shrink-0",title:`Origin: ${e.origin}`,children:[l.jsx(sv,{className:"size-3"}),l.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),(e.clientPid!==null||e.clientProjectFolder!==null)&&l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("span",{className:"hidden xl:flex items-center gap-1 text-purple-400/80 text-xs shrink-0",children:[l.jsx(ev,{className:"size-3"}),e.clientProjectFolder!==null?l.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):l.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]})}),l.jsx($e,{children:e.clientCwd!==null?`PID: ${e.clientPid??"?"} CWD: ${e.clientCwd}`:`Process ID: ${e.clientPid??"?"}`})]}),e.streaming&&l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx(pv,{className:"size-3 text-muted-foreground/60 shrink-0"})}),l.jsx($e,{children:"Request used SSE streaming"})]}),l.jsx("span",{className:"flex-1 min-w-0"}),r?l.jsx(vt,{className:"size-4 text-muted-foreground shrink-0"}):l.jsx(bt,{className:"size-4 text-muted-foreground shrink-0"})]})})});function $p({className:e,orientation:t="horizontal",decorative:n=!0,...r}){return l.jsx(oS,{"data-slot":"separator",decorative:n,orientation:t,className:he("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...r})}function ds({...e}){return l.jsx(a2,{"data-slot":"collapsible",...e})}function fs({...e}){return l.jsx(Rd,{"data-slot":"collapsible-trigger",...e})}function hs({...e}){return l.jsx(Pd,{"data-slot":"collapsible-content",...e})}function Oa({className:e,children:t,...n}){return l.jsxs(x_,{"data-slot":"scroll-area",className:he("relative",e),...n,children:[l.jsx(y_,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),l.jsx(_N,{}),l.jsx(v_,{})]})}function _N({className:e,orientation:t="vertical",...n}){return l.jsx(Wf,{"data-slot":"scroll-area-scrollbar",orientation:t,className:he("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:l.jsx(Gf,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}function SN(e){return l.jsx(l.Fragment,{})}function CN({text:e}){const[t,n]=v.useState(!1);return l.jsxs(ds,{open:t,onOpenChange:n,children:[l.jsxs(fs,{className:"flex items-center gap-1.5 py-0.5 cursor-pointer hover:opacity-80 transition-opacity group",children:[t?l.jsx(vt,{className:"size-3 text-muted-foreground"}):l.jsx(bt,{className:"size-3 text-muted-foreground"}),l.jsx("span",{className:"text-muted-foreground text-xs italic select-none opacity-60",children:"[system-reminder]"})]}),l.jsx(hs,{children:l.jsx("div",{className:"pl-4 pt-1",children:l.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1",children:l.jsx(Gn,{children:e})})})})]})}const jN=/<think>([\s\S]*?)<\/think>/gi,EN=/<think>([\s\S]*?)<\/think>/i;function Bp(e){const t=EN.exec(e);if(!t||t[1]===void 0)return{thinking:null,remainingText:e};const n=t[1].trim(),r=e.replace(jN,"").trim();return{thinking:n,remainingText:r}}const NN=v.memo(function({text:t}){if(t.includes("<system-reminder>"))return l.jsx(CN,{text:t});const{thinking:n,remainingText:r}=Bp(t);return l.jsxs("div",{className:"space-y-2",children:[n!==null&&l.jsx(To,{thinking:n}),r.length>0&&l.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1",children:l.jsx(Gn,{children:r})}),n===null&&r.length===0&&l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty text block"})]})}),To=v.memo(function({thinking:t}){const[n,r]=v.useState(!1);return l.jsx(ds,{open:n,onOpenChange:r,children:l.jsxs("div",{className:"border-l-2 border-purple-500/40 my-1",children:[l.jsxs(fs,{className:"flex items-center gap-1.5 px-3 py-1 w-full text-left cursor-pointer hover:bg-purple-500/5 transition-colors rounded-r-sm group",children:[l.jsx(Ey,{className:"size-3.5 text-purple-400 shrink-0"}),l.jsx("span",{className:"text-xs font-medium text-purple-400",children:"Thinking"}),l.jsxs(xt,{variant:"ghost",className:"text-[10px] text-muted-foreground px-1.5 py-0 h-4 font-mono",children:[t.length.toLocaleString()," chars"]}),l.jsx("span",{className:"flex-1"}),n?l.jsx(vt,{className:"size-3 text-muted-foreground"}):l.jsx(bt,{className:"size-3 text-muted-foreground"})]}),l.jsx(hs,{children:l.jsx("div",{className:"px-3 pb-2",children:l.jsx(Oa,{className:"max-h-[60vh]",children:l.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap font-mono leading-relaxed",children:t})})})})]})})}),TN=v.memo(function({name:t,input:n}){const[r,o]=v.useState(!1);return l.jsx(ds,{open:r,onOpenChange:o,children:l.jsxs("div",{className:"border-l-2 border-blue-500/40 my-1",children:[l.jsxs(fs,{className:"flex items-center gap-1.5 px-3 py-1 w-full text-left cursor-pointer hover:bg-blue-500/5 transition-colors rounded-r-sm group",children:[l.jsx(cd,{className:"size-3.5 text-blue-400 shrink-0"}),l.jsx(xt,{variant:"outline",className:"text-[10px] font-mono px-1.5 py-0 h-4",children:t}),l.jsx("span",{className:"flex-1"}),r?l.jsx(vt,{className:"size-3 text-muted-foreground"}):l.jsx(bt,{className:"size-3 text-muted-foreground"})]}),l.jsx(hs,{children:l.jsx("div",{className:"px-3 pb-2",children:l.jsx(Oa,{className:"max-h-[60vh]",children:l.jsx(us,{data:Jn(n),defaultExpandDepth:2})})})})]})})}),AN=v.memo(function({block:t}){switch(t.type){case"text":return l.jsx(NN,{text:t.text});case"thinking":case"think":return l.jsx(To,{thinking:t.thinking});case"tool_use":return l.jsx(TN,{name:t.name,input:t.input});default:return SN()}}),IN=v.memo(function({response:t}){return l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx(xt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-5 font-mono",children:t.model}),t.stop_reason!==null&&l.jsxs(xt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-5 font-mono flex items-center gap-1",children:[l.jsx(nd,{className:"size-2.5"}),t.stop_reason]}),l.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs",children:[l.jsx(Xn,{className:"size-3"}),l.jsxs("span",{className:"font-mono tabular-nums",children:[qe(t.usage.input_tokens??0)," in /"," ",qe(t.usage.output_tokens??0)," out"]}),t.usage.cache_creation_input_tokens!==void 0&&t.usage.cache_creation_input_tokens!==null&&t.usage.cache_creation_input_tokens>0&&l.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["Cache +",qe(t.usage.cache_creation_input_tokens)]}),t.usage.cache_read_input_tokens!==void 0&&t.usage.cache_read_input_tokens!==null&&t.usage.cache_read_input_tokens>0&&l.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["Cache ~",qe(t.usage.cache_read_input_tokens)]})]})]}),l.jsx($p,{className:"opacity-50"}),l.jsxs("div",{className:"space-y-2",children:[t.content.map((n,r)=>l.jsx(AN,{block:n},r)),t.content.length===0&&l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty response content"})]})]})});function zN(e){if(e===void 0||e==="")return{};try{return JSON.parse(e)}catch{return null}}function RN({call:e}){const[t,n]=v.useState(!1),r=e.function.name??"(unnamed tool)",o=zN(e.function.arguments);return l.jsx(ds,{open:t,onOpenChange:n,children:l.jsxs("div",{className:"border-l-2 border-blue-500/40 my-1",children:[l.jsxs(fs,{className:"flex items-center gap-1.5 px-3 py-1 w-full text-left cursor-pointer hover:bg-blue-500/5 transition-colors rounded-r-sm group",children:[l.jsx(cd,{className:"size-3.5 text-blue-400 shrink-0"}),l.jsx(xt,{variant:"outline",className:"text-[10px] font-mono px-1.5 py-0 h-4",children:r}),e.id!==void 0&&e.id!==""&&l.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/60 truncate",children:e.id}),l.jsx("span",{className:"flex-1"}),t?l.jsx(vt,{className:"size-3 text-muted-foreground"}):l.jsx(bt,{className:"size-3 text-muted-foreground"})]}),l.jsx(hs,{children:l.jsx("div",{className:"px-3 pb-2",children:l.jsx(Oa,{className:"max-h-[60vh]",children:o===null?l.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-words text-rose-300/90",children:e.function.arguments}):l.jsx(us,{data:Jn(o),defaultExpandDepth:2})})})})]})})}const PN=v.memo(function({response:t}){const n=t.choices[0],r=n?.message,o=r?.tool_calls??[];return l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx(xt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-5 font-mono",children:t.model}),n?.finish_reason!==null&&n?.finish_reason!==void 0&&l.jsxs(xt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-5 font-mono flex items-center gap-1",children:[l.jsx(nd,{className:"size-2.5"}),n.finish_reason]}),l.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs",children:[l.jsx(Xn,{className:"size-3"}),l.jsxs("span",{className:"font-mono tabular-nums",children:[qe(t.usage.prompt_tokens??0)," in /"," ",qe(t.usage.completion_tokens??0)," out"]})]})]}),l.jsx($p,{className:"opacity-50"}),l.jsxs("div",{className:"space-y-2",children:[r?.reasoning_content!==null&&r?.reasoning_content!==void 0&&r.reasoning_content.length>0&&l.jsx(To,{thinking:r.reasoning_content}),r?.content!==null&&r?.content!==void 0&&r.content.length>0&&(()=>{const s=r.reasoning_content!==null&&r.reasoning_content!==void 0&&r.reasoning_content.length>0,{thinking:i,remainingText:a}=Bp(r.content);return l.jsxs("div",{className:"space-y-2",children:[i!==null&&!s&&l.jsx(To,{thinking:i}),a.length>0&&l.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1",children:l.jsx(Gn,{children:a})})]})})(),o.map((s,i)=>l.jsx(RN,{call:s},s.id??`tc-${i}`)),r?.function_call!==null&&r?.function_call!==void 0&&l.jsxs("div",{className:"border border-blue-500/30 rounded-md p-3 bg-blue-500/5",children:[l.jsx("div",{className:"text-xs text-blue-400 font-mono mb-1",children:"function_call"}),l.jsxs("div",{className:"font-mono text-xs",children:[l.jsx("span",{className:"text-blue-300",children:r.function_call.name}),l.jsxs("span",{className:"text-muted-foreground",children:["(",r.function_call.arguments,")"]})]})]}),(r?.content===null||r?.content===void 0||r.content.length===0)&&(r?.reasoning_content===null||r?.reasoning_content===void 0||r.reasoning_content.length===0)&&(r?.function_call===null||r?.function_call===void 0)&&o.length===0&&l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty response content"})]})]})});function Up(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ON(e){return Up(e)&&e.object==="chat.completion"}function DN(e){return Up(e)&&e.type==="message"&&Array.isArray(e.content)}function MN(e,t){return e==="openai"&&ON(t)?l.jsx(PN,{response:t}):e==="anthropic"&&DN(t)?l.jsx(IN,{response:t}):null}const LN="/v1/chat/completions",FN="/chat/completions",$N="/v1/messages";class BN{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)}detectFormat(t){if(t===null)return"unknown";for(const n of this.handlers.values())if(n.detectFormat(t))return n.format;return"unknown"}}const ir=new BN;function UN(e){return ir.getByPath(e)??null}function ZN(e){return UN(e)?.format??"unknown"}ir.registerPath($N,"anthropic");ir.registerPath(LN,"openai");ir.registerPath(FN,"openai");function VN(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}catch{return{}}}function WN(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:VN(e.inputJson)}}}function Zp(e,t,n,r){const o=new Map;let s="",i="",a=null,c=null,u=0,d=0;const h=1e3;let p=0,f=0;const g=[];for(const x of e.split(`
105
+ `);if(n===r)return{lines:[],isEmpty:!0};const o=Dp(n,r);return{lines:Ei(o),isEmpty:!1}}function Mc(e){try{const t=JSON.parse(e);return t===null||typeof t=="string"||typeof t=="object"?t:null}catch{return null}}function Y3(e,t){const n=e??"",r=t??"";if(n===r)return{lines:[],isEmpty:!0};const o=Mc(n),s=Mc(r);if(o!==null&&s!==null){const a=G3(o,s)??[];if(a.length===1){const c=a[0];if(c!==void 0&&!c.added&&!c.removed)return{lines:[],isEmpty:!0}}return{lines:Ei(a),isEmpty:!1}}const i=Dp(n,r);return{lines:Ei(i),isEmpty:!1}}function X3(e,t,n){const r=new Array(e);return new Proxy(r,{get(o,s,i){if(typeof s=="string"){const a=s.charCodeAt(0);if(a>=48&&a<=57){const c=+s;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(s==="length")return e}return Reflect.get(o,s,i)}})}function An(e,t,n){let r=n.initialDeps??[],o,s=!0;function i(){const a=e();return(a.length!==r.length||a.some((u,d)=>r[d]!==u))&&(r=a,o=t(...a),n?.onChange&&!(s&&n.skipInitialOnChange)&&n.onChange(o),s=!1),o}return i.updateDeps=a=>{r=a},i}function Lc(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const Fc=(e,t)=>Math.abs(e-t)<1.01,Q3=(e,t,n)=>{let r;return function(...o){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,o),n)}};let hr;const $c=()=>{if(hr!==void 0)return hr;if(typeof navigator>"u")return hr=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return hr=!0;const e=navigator.maxTouchPoints;return hr=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Bc=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},eN=e=>e,tN=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 s=0;s<r;s++)o[s]=t+s;return o},nN=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const o=i=>{const{width:a,height:c}=i;t({width:Math.round(a),height:Math.round(c)})};if(o(Bc(n)),!r.ResizeObserver)return()=>{};const s=new r.ResizeObserver(i=>{const a=()=>{const c=i[0];if(c?.borderBoxSize){const u=c.borderBoxSize[0];if(u){o({width:u.inlineSize,height:u.blockSize});return}}o(Bc(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},No={passive:!0},rN=typeof window>"u"?!0:"onscrollend"in window,oN=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const o=e.targetWindow;if(!o)return;const s=e.options.useScrollendEvent&&rN;let i=0;const a=s?null:Q3(o,()=>t(i,!1),e.options.isScrollingResetDelay),c=h=>()=>{i=n(r),a?.(),t(i,h)},u=c(!0),d=c(!1);return r.addEventListener("scroll",u,No),s&&r.addEventListener("scrollend",d,No),()=>{r.removeEventListener("scroll",u),s&&r.removeEventListener("scrollend",d)}},sN=(e,t)=>oN(e,t,n=>{const{horizontal:r,isRtl:o}=e.options;return r?n.scrollLeft*(o&&-1||1):n.scrollTop}),iN=(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"]},aN=(e,{adjustments:t=0,behavior:n},r)=>{var o,s;(s=(o=r.scrollElement)==null?void 0:o.scrollTo)==null||s.call(o,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})},lN=aN;class cN{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(s=>{const i=()=>{const a=s.target,c=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[u,d]of this.elementsCache)if(d===a){this.elementsCache.delete(u);break}return}this.shouldMeasureDuringScroll(c)&&this.resizeItem(c,this.options.measureElement(a,s,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var o;(o=r())==null||o.disconnect(),n=null},observe:o=>{var s;return(s=r())==null?void 0:s.observe(o,{box:"border-box"})},unobserve:o=>{var s;return(s=r())==null?void 0:s.unobserve(o)}}})(),this.range=null,this.setOptions=n=>{var r,o;const s={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:eN,rangeExtractor:tN,onChange:()=>{},measureElement:iN,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&&(s[u]=d)}const i=this.options;let a=null,c=null;if(i!==void 0&&i.enabled&&s.enabled&&s.anchorTo==="end"&&this.scrollElement!==null){const u=i.count,d=s.count,h=this.getMeasurements(),p=u>0?((r=h[0])==null?void 0:r.key)??i.getItemKey(0):null,f=u>0?((o=h[u-1])==null?void 0:o.key)??i.getItemKey(u-1):null;if(d!==u||u>0&&d>0&&(s.getItemKey(0)!==p||s.getItemKey(d-1)!==f)){const x=u>0?this.getVirtualItemForOffset(this.getScrollOffset())??h[0]:null;x&&(a=[x.key,this.getScrollOffset()-x.start]);const y=s.followOnAppend===!0?"auto":s.followOnAppend||null;y&&d>u&&this.isAtEnd(i.scrollEndThreshold)&&(u===0||s.getItemKey(d-1)!==f)&&(c=y)}}this.options=s,(a||c)&&(this.pendingScrollAnchor=[a?.[0]??null,a?.[1]??0,c])},this.notify=n=>{var r,o;(o=(r=this.options).onChange)==null||o.call(r,this,n)},this.maybeNotify=An(()=>(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(s=>{this.observer.observe(s)}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,i)=>{this._intendedScrollOffset!==null&&Math.abs(s-this._intendedScrollOffset)<1.5&&(s=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=i,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const s=this.scrollElement,i=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!$c()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};s.addEventListener("touchstart",i,No),s.addEventListener("touchend",a,No),this.unsubs.push(()=>{s.removeEventListener("touchstart",i),s.removeEventListener("touchend",a),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[s,i,a]=o;if(s!==null){const{count:c,getItemKey:u}=this.options;let d=0;for(;d<c&&u(d)!==s;)d++;const h=d<c?this.getMeasurements()[d]:void 0;if(h){const p=h.start+i-this.getScrollOffset();Fc(p,0)||this.applyScrollAdjustment(p)}}a&&this.scrollToEnd({behavior:a})}},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,s=new Map;for(let i=r-1;i>=0;i--){const a=n[i];if(o.has(a.lane))continue;const c=s.get(a.lane);if(c==null||a.end>c.end?s.set(a.lane,a):a.end<c.end&&o.set(a.lane,!0),o.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((i,a)=>i.end===a.end?i.index-a.index:i.end-a.end)[0]:void 0},this.getMeasurementOptions=An(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(n,r,o,s,i,a,c)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:n,paddingStart:r,scrollMargin:o,getItemKey:s,enabled:i,lanes:a,laneAssignmentMode:c}),{key:!1}),this.getMeasurements=An(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:r,scrollMargin:o,getItemKey:s,enabled:i,lanes:a,laneAssignmentMode:c},u)=>{const d=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const g of this.laneAssignments.keys())g>=n&&this.laneAssignments.delete(g);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(g=>{this.itemSizeCache.set(g.key,g.size)}));const h=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),a===1){const g=this.options.gap,m=n*2;let x=this._flatMeasurements;if(!x||x.length<m){const k=new Float64Array(m);x&&h>0&&k.set(x.subarray(0,h*2)),x=k,this._flatMeasurements=x}let y;if(h===0)y=r+o;else{const k=h-1;y=x[k*2]+x[k*2+1]+g}for(let k=h;k<n;k++){const S=s(k),C=d.get(S),j=typeof C=="number"?C:this.options.estimateSize(k);x[k*2]=y,x[k*2+1]=j,y+=j+g}const b=X3(n,x,s);return this.measurementsCache=b,b}const p=this.measurementsCache.slice(0,h),f=new Array(a).fill(void 0);for(let g=0;g<h;g++){const m=p[g];m&&(f[m.lane]=g)}for(let g=h;g<n;g++){const m=s(g),x=this.laneAssignments.get(g);let y,b;const k=c==="estimate"||d.has(m);if(x!==void 0&&this.options.lanes>1){y=x;const N=f[y],T=N!==void 0?p[N]:void 0;b=T?T.end+this.options.gap:r+o}else{const N=this.options.lanes===1?p[g-1]:this.getFurthestMeasurement(p,g);b=N?N.end+this.options.gap:r+o,y=N?N.lane:g%this.options.lanes,this.options.lanes>1&&k&&this.laneAssignments.set(g,y)}const S=d.get(m),C=typeof S=="number"?S:this.options.estimateSize(g),j=b+C;p[g]={index:g,start:b,size:C,end:j,key:m,lane:y},f[y]=g}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=An(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,o,s)=>this.range=n.length>0&&r>0?uN({measurements:n,outerSize:r,scrollOffset:o,lanes:s,flat:s===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=An(()=>{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,s,i)=>s===null||i===null?[]:n({startIndex:s,endIndex:i,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 s=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,o-s),a=Math.min(this.options.count-1,o+s);return n>=i&&n<=a}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((i,a)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(a))});return}const r=this.indexFromElement(n),o=this.options.getItemKey(r),s=this.elementsCache.get(o);s!==n&&(s&&this.observer.unobserve(s),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,s;if(n<0||n>=this.options.count)return;let i,a,c;const u=this._flatMeasurements;if(this.options.lanes===1&&u!==null)c=this.options.getItemKey(n),a=u[n*2],i=u[n*2+1];else{const p=this.measurementsCache[n];if(!p)return;c=p.key,a=p.start,i=p.size}const d=this.itemSizeCache.get(c)??i,h=r-d;if(h!==0){const p=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,f=p?this.getTotalSize():0,g=((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:c,start:a,size:i,end:a+i,lane:0},h,this):a<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!=="backward");(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(c,r),this.itemSizeCacheVersion++,p?this.applyScrollAdjustment(this.getTotalSize()-f):g&&this.applyScrollAdjustment(h),this.notify(!1)}},this.getVirtualItems=An(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const o=[];for(let s=0,i=n.length;s<i;s++){const a=n[s],c=r[a];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,s=this.options.lanes===1&&o!=null,i=Lp(0,r.length-1,s?a=>o[a*2]:a=>Lc(r[a]).start,n);return Lc(r[i])},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 s=this.getSize(),i=this.getScrollOffset();r==="auto"&&(r=n>=i+s?"end":"start"),r==="center"?n+=(o-s)/2:r==="end"&&(n-=s);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const o=this.getSize(),s=this.getScrollOffset(),i=this.measurementsCache[n];if(!i)return;if(r==="auto")if(i.end>=s+o-this.options.scrollPaddingEnd)r="end";else if(i.start<=s+this.options.scrollPaddingStart)r="start";else return[s,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const a=r==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,r,i.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:o="auto"}={})=>{const s=this.getOffsetForAlignment(n,r),i=this.now();this.scrollState={index:null,align:r,behavior:o,startedAt:i,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{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 s=this.getOffsetForIndex(n,r);if(!s)return;const[i,a]=s,c=this.now();this.scrollState={index:n,align:a,behavior:o,startedAt:c,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const o=this.getScrollOffset()+n,s=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:s,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 s=r.length-1,i=this._flatMeasurements;i!=null?o=i[s*2]+i[s*2+1]:o=((n=r[s])==null?void 0:n.end)??0}else{const s=Array(this.options.lanes).fill(null);let i=r.length-1;for(;i>=0&&s.some(a=>a===null);){const a=r[i];s[a.lane]===null&&(s[a.lane]=a.end),i--}o=Math.max(...s.filter(a=>a!==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&&($c()&&(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,s=1,i=o!==this.scrollState.lastTargetOffset;if(!i&&Fc(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=s){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,i){const a=this.getSize()||600,c=Math.abs(o-this.getScrollOffset()),u=this.scrollState.behavior==="smooth"&&c>a;this.scrollState.lastTargetOffset=o,u||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:u?"smooth":"auto"})}this.scheduleScrollReconcile()}}const Lp=(e,t,n,r)=>{for(;e<=t;){const o=(e+t)/2|0,s=n(o);if(s<r)e=o+1;else if(s>r)t=o-1;else return o}return e>0?e-1:0};function uN({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:o}){const s=e.length-1,i=o?d=>o[d*2]:d=>e[d].start,a=o?d=>o[d*2]+o[d*2+1]:d=>e[d].end;if(e.length<=r)return{startIndex:0,endIndex:s};let c=Lp(0,s,i,n),u=c;if(r===1)for(;u<s&&a(u)<n+t;)u++;else if(r>1){const d=Array(r).fill(0);for(;u<s&&d.some(p=>p<n+t);){const p=e[u];d[p.lane]=p.end,u++}const h=Array(r).fill(n+t);for(;c>=0&&h.some(p=>p>=n);){const p=e[c];h[p.lane]=p.start,c--}c=Math.max(0,c-c%r),u=Math.min(s,u+(r-1-u%r))}return{startIndex:c,endIndex:u}}const Uc=typeof document<"u"?v.useLayoutEffect:v.useEffect;function dN({useFlushSync:e=!0,...t}){const n=v.useReducer(s=>s+1,0)[1],r={...t,onChange:(s,i)=>{var a;e&&i?Tr.flushSync(n):n(),(a=t.onChange)==null||a.call(t,s,i)}},[o]=v.useState(()=>new cN(r));return o.setOptions(r),Uc(()=>o._didMount(),[]),Uc(()=>o._willUpdate()),o}function fN(e){return dN({observeElementRect:nN,observeElementOffset:sN,scrollToFn:lN,...e})}const hN=22,Us=1e4;function pN(e){return e==="added"?"+":e==="removed"?"-":" "}function mN(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 gN=function({result:t,emptyLabel:n}){const[r,o]=v.useState("unified"),s=v.useRef(null),i=fN({count:t.lines.length,getScrollElement:()=>s.current,estimateSize:()=>hN,overscan:10});if(t.isEmpty)return l.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 a=t.lines.length,c=a>Us,u=c?t.lines.slice(0,Us):t.lines;return l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[l.jsxs("span",{children:[a.toLocaleString()," line",a===1?"":"s",c&&` (showing first ${Us.toLocaleString()})`]}),l.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[l.jsxs("button",{type:"button",onClick:()=>o("unified"),"aria-pressed":r==="unified",className:he("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:[l.jsx(ld,{className:"size-3"}),"Unified"]}),l.jsxs("button",{type:"button",onClick:()=>o("split"),"aria-pressed":r==="split",className:he("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:[l.jsx(rd,{className:"size-3"}),"Split"]})]})]}),l.jsx("div",{ref:s,className:"max-h-[60vh] overflow-auto rounded border border-border bg-background font-mono text-xs","data-testid":"diff-viewport",children:r==="unified"?l.jsx(xN,{virtualizer:i,lines:u}):l.jsx(bN,{lines:u})})]})};function xN({virtualizer:e,lines:t}){return l.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:l.jsxs("div",{"data-index":n.index,ref:e.measureElement,className:he("flex items-start gap-3 px-2",mN(r.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${n.start}px)`},children:[l.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:r.oldLineNumber??""}),l.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:r.newLineNumber??""}),l.jsx("span",{className:he("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:pN(r.kind)}),l.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:r.text})]},n.key)})})}function yN(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=[],s=[];for(;n<e.length&&e[n]?.kind==="removed";){const a=e[n];a!==void 0&&o.push(a),n+=1}for(;n<e.length&&e[n]?.kind==="added";){const a=e[n];a!==void 0&&s.push(a),n+=1}const i=Math.max(o.length,s.length);for(let a=0;a<i;a+=1){const c=o[a],u=s[a];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 vN(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 bN({lines:e}){const t=yN(e);return l.jsx("div",{"data-testid":"diff-split",children:t.map((n,r)=>l.jsxs("div",{className:he("grid grid-cols-2 font-mono text-xs",vN(n.kind)),children:[l.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[l.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.left?.lineNumber??""}),l.jsx("span",{className:he("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?"-":" "}),l.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.left?.text??""})]}),l.jsxs("div",{className:"flex items-start gap-2 px-2",children:[l.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.right?.lineNumber??""}),l.jsx("span",{className:he("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?"+":" "}),l.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.right?.text??""})]})]},r))})}const Fp=v.memo(gN);function wN(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const Zc={success:"bg-emerald-500/15 text-emerald-400 border-emerald-500/25",client_error:"bg-amber-500/15 text-amber-400 border-amber-500/25",server_error:"",pending:"bg-muted text-muted-foreground border-border"};function Vc({trend:e}){if(e===null)return null;const t=e.direction==="up",n=t?Cy:_y,r=t?"+":"-";return l.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[l.jsx(n,{className:t?"size-3 text-emerald-400":"size-3 text-rose-400"}),l.jsxs("span",{className:"font-mono",children:[r,qe(e.delta)]})]})}const kN=v.memo(function({log:e,messageCount:t=null,toolCount:n=null,expanded:r,onToggle:o,responseToolNames:s=null,cacheTrend:i=null}){const a=Cd(e.responseStatus),c=e.inputTokens!==null||e.outputTokens!==null,u=v.useMemo(()=>s?.join(", ")??null,[s]);return l.jsx(Je,{children:l.jsxs("div",{role:"button",tabIndex:0,className:he("flex items-center gap-2 px-3 py-1 cursor-pointer transition-colors","hover:bg-muted/50","select-none"),onClick:o,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),o())},children:[l.jsxs("span",{className:"text-blue-400/80 font-mono text-xs font-semibold tabular-nums shrink-0",children:["#",e.id]}),e.model!==null&&l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("span",{className:"shrink-0",children:l.jsx(Yh,{provider:Jh(e.model),className:"size-4"})})}),l.jsx($e,{children:e.model})]}),a!=="success"&&l.jsx(l.Fragment,{children:a==="server_error"?l.jsx(xt,{variant:"destructive",className:"text-[10px] px-1.5 py-0 h-4 font-mono tabular-nums",children:e.responseStatus}):a==="pending"?l.jsx(xt,{variant:"outline",className:he("text-[10px] px-1.5 py-0 h-4 font-mono tabular-nums",Zc[a]),children:l.jsx(Sr,{className:"size-3 animate-spin"})}):l.jsx(xt,{variant:"outline",className:he("text-[10px] px-1.5 py-0 h-4 font-mono tabular-nums",Zc[a]),children:e.responseStatus})}),e.elapsedMs!==null&&l.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs shrink-0",children:[l.jsx(Ir,{className:"size-3"}),l.jsx("span",{className:"font-mono tabular-nums",children:wN(e.elapsedMs)})]}),c&&l.jsxs("span",{className:"flex items-center gap-1 text-xs shrink-0",children:[l.jsx(Xn,{className:"size-3 text-muted-foreground"}),l.jsxs("span",{className:"font-mono tabular-nums",children:[l.jsxs("span",{className:e.inputTokens!==null?"text-blue-400":"text-muted-foreground",children:["IN ",e.inputTokens!==null?qe(e.inputTokens):"—"]})," / ",l.jsxs("span",{className:e.outputTokens!==null?"text-amber-400":"text-muted-foreground",children:["OUT ",e.outputTokens!==null?qe(e.outputTokens):"—"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("span",{className:"flex items-center gap-1 text-xs shrink-0",children:[l.jsx(Vc,{trend:i?.creation??null}),l.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["Cache +",qe(e.cacheCreationInputTokens)]})]})}),l.jsx($e,{children:"Tokens cached for reuse, reducing future API cost"})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("span",{className:"flex items-center gap-1 text-xs shrink-0",children:[l.jsx(Vc,{trend:i?.read??null}),l.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["Cache ~",qe(e.cacheReadInputTokens)]})]})}),l.jsx($e,{children:"Tokens served from cache, reducing API cost"})]}),t!==null&&l.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs shrink-0",children:[l.jsx(sd,{className:"size-3"}),l.jsx("span",{className:"font-mono tabular-nums",children:t})]}),n!==null&&l.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs shrink-0",children:[l.jsx(ul,{className:"size-3"}),l.jsx("span",{className:"font-mono tabular-nums",children:n})]}),s!==null&&s.length>0&&l.jsxs("span",{className:"flex items-center gap-1 text-amber-400/80 text-xs shrink-0",children:[l.jsx(ul,{className:"size-3"}),l.jsx("span",{className:"font-mono tabular-nums truncate max-w-[160px]",children:u})]}),e.origin!==null&&l.jsxs("span",{className:"hidden xl:flex items-center gap-1 text-muted-foreground text-xs shrink-0",title:`Origin: ${e.origin}`,children:[l.jsx(sv,{className:"size-3"}),l.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),(e.clientPid!==null||e.clientProjectFolder!==null)&&l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("span",{className:"hidden xl:flex items-center gap-1 text-purple-400/80 text-xs shrink-0",children:[l.jsx(ev,{className:"size-3"}),e.clientProjectFolder!==null?l.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):l.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]})}),l.jsx($e,{children:e.clientCwd!==null?`PID: ${e.clientPid??"?"} CWD: ${e.clientCwd}`:`Process ID: ${e.clientPid??"?"}`})]}),e.streaming&&l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx(pv,{className:"size-3 text-muted-foreground/60 shrink-0"})}),l.jsx($e,{children:"Request used SSE streaming"})]}),l.jsx("span",{className:"flex-1 min-w-0"}),r?l.jsx(vt,{className:"size-4 text-muted-foreground shrink-0"}):l.jsx(bt,{className:"size-4 text-muted-foreground shrink-0"})]})})});function $p({className:e,orientation:t="horizontal",decorative:n=!0,...r}){return l.jsx(oS,{"data-slot":"separator",decorative:n,orientation:t,className:he("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...r})}function ds({...e}){return l.jsx(a2,{"data-slot":"collapsible",...e})}function fs({...e}){return l.jsx(Rd,{"data-slot":"collapsible-trigger",...e})}function hs({...e}){return l.jsx(Pd,{"data-slot":"collapsible-content",...e})}function Oa({className:e,children:t,...n}){return l.jsxs(x_,{"data-slot":"scroll-area",className:he("relative",e),...n,children:[l.jsx(y_,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),l.jsx(_N,{}),l.jsx(v_,{})]})}function _N({className:e,orientation:t="vertical",...n}){return l.jsx(Wf,{"data-slot":"scroll-area-scrollbar",orientation:t,className:he("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:l.jsx(Gf,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}function SN(e){return l.jsx(l.Fragment,{})}function CN({text:e}){const[t,n]=v.useState(!1);return l.jsxs(ds,{open:t,onOpenChange:n,children:[l.jsxs(fs,{className:"flex items-center gap-1.5 py-0.5 cursor-pointer hover:opacity-80 transition-opacity group",children:[t?l.jsx(vt,{className:"size-3 text-muted-foreground"}):l.jsx(bt,{className:"size-3 text-muted-foreground"}),l.jsx("span",{className:"text-muted-foreground text-xs italic select-none opacity-60",children:"[system-reminder]"})]}),l.jsx(hs,{children:l.jsx("div",{className:"pl-4 pt-1",children:l.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1",children:l.jsx(Gn,{children:e})})})})]})}const jN=/<think>([\s\S]*?)<\/think>/gi,EN=/<think>([\s\S]*?)<\/think>/i;function Bp(e){const t=EN.exec(e);if(!t||t[1]===void 0)return{thinking:null,remainingText:e};const n=t[1].trim(),r=e.replace(jN,"").trim();return{thinking:n,remainingText:r}}const NN=v.memo(function({text:t}){if(t.includes("<system-reminder>"))return l.jsx(CN,{text:t});const{thinking:n,remainingText:r}=Bp(t);return l.jsxs("div",{className:"space-y-2",children:[n!==null&&l.jsx(To,{thinking:n}),r.length>0&&l.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1",children:l.jsx(Gn,{children:r})}),n===null&&r.length===0&&l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty text block"})]})}),To=v.memo(function({thinking:t}){const[n,r]=v.useState(!1);return l.jsx(ds,{open:n,onOpenChange:r,children:l.jsxs("div",{className:"border-l-2 border-purple-500/40 my-1",children:[l.jsxs(fs,{className:"flex items-center gap-1.5 px-3 py-1 w-full text-left cursor-pointer hover:bg-purple-500/5 transition-colors rounded-r-sm group",children:[l.jsx(Ey,{className:"size-3.5 text-purple-400 shrink-0"}),l.jsx("span",{className:"text-xs font-medium text-purple-400",children:"Thinking"}),l.jsxs(xt,{variant:"ghost",className:"text-[10px] text-muted-foreground px-1.5 py-0 h-4 font-mono",children:[t.length.toLocaleString()," chars"]}),l.jsx("span",{className:"flex-1"}),n?l.jsx(vt,{className:"size-3 text-muted-foreground"}):l.jsx(bt,{className:"size-3 text-muted-foreground"})]}),l.jsx(hs,{children:l.jsx("div",{className:"px-3 pb-2",children:l.jsx(Oa,{className:"max-h-[60vh]",children:l.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap font-mono leading-relaxed",children:t})})})})]})})}),TN=v.memo(function({name:t,input:n}){const[r,o]=v.useState(!1);return l.jsx(ds,{open:r,onOpenChange:o,children:l.jsxs("div",{className:"border-l-2 border-blue-500/40 my-1",children:[l.jsxs(fs,{className:"flex items-center gap-1.5 px-3 py-1 w-full text-left cursor-pointer hover:bg-blue-500/5 transition-colors rounded-r-sm group",children:[l.jsx(cd,{className:"size-3.5 text-blue-400 shrink-0"}),l.jsx(xt,{variant:"outline",className:"text-[10px] font-mono px-1.5 py-0 h-4",children:t}),l.jsx("span",{className:"flex-1"}),r?l.jsx(vt,{className:"size-3 text-muted-foreground"}):l.jsx(bt,{className:"size-3 text-muted-foreground"})]}),l.jsx(hs,{children:l.jsx("div",{className:"px-3 pb-2",children:l.jsx(Oa,{className:"max-h-[60vh]",children:l.jsx(us,{data:Jn(n),defaultExpandDepth:2})})})})]})})}),AN=v.memo(function({block:t}){switch(t.type){case"text":return l.jsx(NN,{text:t.text});case"thinking":case"think":return l.jsx(To,{thinking:t.thinking});case"tool_use":return l.jsx(TN,{name:t.name,input:t.input});default:return SN()}}),IN=v.memo(function({response:t}){return l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx(xt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-5 font-mono",children:t.model}),t.stop_reason!==null&&l.jsxs(xt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-5 font-mono flex items-center gap-1",children:[l.jsx(nd,{className:"size-2.5"}),t.stop_reason]}),l.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs",children:[l.jsx(Xn,{className:"size-3"}),l.jsxs("span",{className:"font-mono tabular-nums",children:[qe(t.usage.input_tokens??0)," in /"," ",qe(t.usage.output_tokens??0)," out"]}),t.usage.cache_creation_input_tokens!==void 0&&t.usage.cache_creation_input_tokens!==null&&t.usage.cache_creation_input_tokens>0&&l.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["Cache +",qe(t.usage.cache_creation_input_tokens)]}),t.usage.cache_read_input_tokens!==void 0&&t.usage.cache_read_input_tokens!==null&&t.usage.cache_read_input_tokens>0&&l.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["Cache ~",qe(t.usage.cache_read_input_tokens)]})]})]}),l.jsx($p,{className:"opacity-50"}),l.jsxs("div",{className:"space-y-2",children:[t.content.map((n,r)=>l.jsx(AN,{block:n},r)),t.content.length===0&&l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty response content"})]})]})});function zN(e){if(e===void 0||e==="")return{};try{return JSON.parse(e)}catch{return null}}function RN({call:e}){const[t,n]=v.useState(!1),r=e.function.name??"(unnamed tool)",o=zN(e.function.arguments);return l.jsx(ds,{open:t,onOpenChange:n,children:l.jsxs("div",{className:"border-l-2 border-blue-500/40 my-1",children:[l.jsxs(fs,{className:"flex items-center gap-1.5 px-3 py-1 w-full text-left cursor-pointer hover:bg-blue-500/5 transition-colors rounded-r-sm group",children:[l.jsx(cd,{className:"size-3.5 text-blue-400 shrink-0"}),l.jsx(xt,{variant:"outline",className:"text-[10px] font-mono px-1.5 py-0 h-4",children:r}),e.id!==void 0&&e.id!==""&&l.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/60 truncate",children:e.id}),l.jsx("span",{className:"flex-1"}),t?l.jsx(vt,{className:"size-3 text-muted-foreground"}):l.jsx(bt,{className:"size-3 text-muted-foreground"})]}),l.jsx(hs,{children:l.jsx("div",{className:"px-3 pb-2",children:l.jsx(Oa,{className:"max-h-[60vh]",children:o===null?l.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-words text-rose-300/90",children:e.function.arguments}):l.jsx(us,{data:Jn(o),defaultExpandDepth:2})})})})]})})}const PN=v.memo(function({response:t}){const n=t.choices[0],r=n?.message,o=r?.tool_calls??[];return l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx(xt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-5 font-mono",children:t.model}),n?.finish_reason!==null&&n?.finish_reason!==void 0&&l.jsxs(xt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-5 font-mono flex items-center gap-1",children:[l.jsx(nd,{className:"size-2.5"}),n.finish_reason]}),l.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs",children:[l.jsx(Xn,{className:"size-3"}),l.jsxs("span",{className:"font-mono tabular-nums",children:[qe(t.usage.prompt_tokens??0)," in /"," ",qe(t.usage.completion_tokens??0)," out"]})]})]}),l.jsx($p,{className:"opacity-50"}),l.jsxs("div",{className:"space-y-2",children:[r?.reasoning_content!==null&&r?.reasoning_content!==void 0&&r.reasoning_content.length>0&&l.jsx(To,{thinking:r.reasoning_content}),r?.content!==null&&r?.content!==void 0&&r.content.length>0&&(()=>{const s=r.reasoning_content!==null&&r.reasoning_content!==void 0&&r.reasoning_content.length>0,{thinking:i,remainingText:a}=Bp(r.content);return l.jsxs("div",{className:"space-y-2",children:[i!==null&&!s&&l.jsx(To,{thinking:i}),a.length>0&&l.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1",children:l.jsx(Gn,{children:a})})]})})(),o.map((s,i)=>l.jsx(RN,{call:s},s.id??`tc-${i}`)),r?.function_call!==null&&r?.function_call!==void 0&&l.jsxs("div",{className:"border border-blue-500/30 rounded-md p-3 bg-blue-500/5",children:[l.jsx("div",{className:"text-xs text-blue-400 font-mono mb-1",children:"function_call"}),l.jsxs("div",{className:"font-mono text-xs",children:[l.jsx("span",{className:"text-blue-300",children:r.function_call.name}),l.jsxs("span",{className:"text-muted-foreground",children:["(",r.function_call.arguments,")"]})]})]}),(r?.content===null||r?.content===void 0||r.content.length===0)&&(r?.reasoning_content===null||r?.reasoning_content===void 0||r.reasoning_content.length===0)&&(r?.function_call===null||r?.function_call===void 0)&&o.length===0&&l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty response content"})]})]})});function Up(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ON(e){return Up(e)&&e.object==="chat.completion"}function DN(e){return Up(e)&&e.type==="message"&&Array.isArray(e.content)}function MN(e,t){return e==="openai"&&ON(t)?l.jsx(PN,{response:t}):e==="anthropic"&&DN(t)?l.jsx(IN,{response:t}):null}const LN="/v1/chat/completions",FN="/chat/completions",$N="/v1/messages";class BN{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)}detectFormat(t){if(t===null)return"unknown";for(const n of this.handlers.values())if(n.detectFormat(t))return n.format;return"unknown"}}const ir=new BN;function UN(e){return ir.getByPath(e)??null}function ZN(e){return UN(e)?.format??"unknown"}ir.registerPath($N,"anthropic");ir.registerPath(LN,"openai");ir.registerPath(FN,"openai");function VN(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}catch{return{}}}function WN(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:VN(e.inputJson)}}}function Zp(e,t,n,r){const o=new Map;let s="",i="",a=null,c=null,u=0,d=0;const h=1e3;let p=0,f=0;const g=[];for(const x of e.split(`
106
106
  `)){const y=x.trim();if(y.startsWith("data: "))try{const b=JSON.parse(y.slice(6)),k=iy.safeParse(b);if(!k.success)continue;const S=k.data;switch(p===0&&(f=Date.now()),r===!0&&g.length<h&&g.push({index:p,timestamp:Date.now()-f,type:S.type,data:S}),p++,S.type){case"message_start":s=S.message.id,i=S.message.model,u=S.message.usage.input_tokens,t.inputTokens=u,t.cacheCreationInputTokens=S.message.usage.cache_creation_input_tokens??null,t.cacheReadInputTokens=S.message.usage.cache_read_input_tokens??null,t.model===null&&(t.model=i);break;case"content_block_start":{const C=S.content_block;switch(C.type){case"text":o.set(S.index,{type:"text",text:C.text??""});break;case"thinking":o.set(S.index,{type:"thinking",thinking:C.thinking??"",signature:C.signature??""});break;case"think":o.set(S.index,{type:"think",thinking:C.thinking??"",signature:C.signature??""});break;case"tool_use":o.set(S.index,{type:"tool_use",id:C.id,name:C.name,inputJson:""});break}break}case"content_block_delta":{const C=o.get(S.index);if(C===void 0)break;const j=S.delta;j.type==="text_delta"&&C.type==="text"?C.text+=j.text:j.type==="thinking_delta"&&(C.type==="thinking"||C.type==="think")?C.thinking+=j.thinking:j.type==="signature_delta"&&(C.type==="thinking"||C.type==="think")?C.signature+=j.signature:j.type==="input_json_delta"&&C.type==="tool_use"&&(C.inputJson+=j.partial_json);break}case"message_delta":a=S.delta.stop_reason,c=S.delta.stop_sequence??null,d=S.usage.output_tokens,t.outputTokens=d,S.usage.cache_creation_input_tokens!==void 0&&(t.cacheCreationInputTokens=S.usage.cache_creation_input_tokens),S.usage.cache_read_input_tokens!==void 0&&(t.cacheReadInputTokens=S.usage.cache_read_input_tokens);break;case"error":t.error=S.error.message;break;case"content_block_stop":case"message_stop":case"ping":break}}catch{}}r===!0&&(t.streamingChunks={chunks:g,truncated:p>h});const m=[...o.entries()].sort(([x],[y])=>x-y).map(([,x])=>WN(x));return JSON.stringify({id:s,type:"message",model:i!==""?i:n??"",role:"assistant",content:m,stop_reason:a,stop_sequence:c,usage:{input_tokens:u,output_tokens:d}})}const HN={format:"anthropic",parseRequest(e,t){try{const n=JSON.parse(e),r=Hu.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=qu.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 Zp(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}}};ir.register(HN);class qN{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 Da=new qN,KN="https://api.anthropic.com",GN={MiniMax:"https://api.minimaxi.com/anthropic"},JN={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(GN))if(t.startsWith(n.toLowerCase()))return!0;return!0},getUpstreamBase(e,t){return t?.baseUrl!==void 0?t.baseUrl:KN},extractStream(e,t,n,r){return Zp(e,t,n,r)}};Da.register(JN);function Ma(e,t,n,r=!0){let o="",s="",i="",a="",c=null,u=0,d=0,h=!1,p=!1;const f=new Map,g=1e3;let m=0,x=0;const y=[];for(const k of e.split(`
107
- `)){const S=k.trim();if(!S.startsWith("data: "))continue;const C=S.slice(6);if(C==="[DONE]")break;try{const j=JSON.parse(C);if(typeof j=="object"&&j!==null&&!Array.isArray(j)){const A=Object.getOwnPropertyDescriptor(j,"error");if(A!==void 0&&typeof A.value=="object"&&A.value!==null){const O=Object.getOwnPropertyDescriptor(A.value,"message");O!==void 0&&typeof O.value=="string"&&(t.error=O.value);continue}}const N=fy.safeParse(j);if(!N.success)continue;const T=N.data;if(m===0&&(x=Date.now()),r===!0&&y.length<g&&y.push({index:m,timestamp:Date.now()-x,type:"chat.completion.chunk",data:T}),m++,p||(o=T.id,s=T.model,p=!0),!h&&T.usage!==void 0&&T.usage!==null){if(u=T.usage.prompt_tokens??0,d=T.usage.completion_tokens??0,t.inputTokens=u,typeof j=="object"&&j!==null&&!Array.isArray(j)){const A=Object.getOwnPropertyDescriptor(j,"usage");if(A!==void 0&&typeof A.value=="object"&&A.value!==null){const O=Object.getOwnPropertyDescriptor(A.value,"prompt_tokens_details");if(O!==void 0&&typeof O.value=="object"&&O.value!==null){const L=Object.getOwnPropertyDescriptor(O.value,"cached_tokens");L!==void 0&&typeof L.value=="number"&&(t.cacheReadInputTokens=L.value)}}}h=!0}for(const A of T.choices){const O=A.delta;O.content!==void 0&&O.content!==null&&(i+=O.content),O.reasoning_content!==void 0&&O.reasoning_content!==null&&(a+=O.reasoning_content),O.thinking!==void 0&&O.thinking!==null&&(a+=O.thinking);const L=O.think;if(L!=null&&(a+=L),A.finish_reason!==void 0&&A.finish_reason!==null&&(c=A.finish_reason),O.tool_calls!==void 0&&O.tool_calls!==null)for(const E of O.tool_calls){let M=f.get(E.index);M===void 0&&(M={index:E.index,type:"function",function:{name:"",arguments:""}},f.set(E.index,M)),E.id!==void 0&&(M.id=E.id),E.function?.name!==void 0&&(M.function.name+=E.function.name),E.function?.arguments!==void 0&&(M.function.arguments+=E.function.arguments)}}}catch{}}r===!0&&(t.streamingChunks={chunks:y,truncated:m>g}),h||(d=Math.ceil(i.length/4)),t.outputTokens=d;const b={role:"assistant",content:i};return a&&(b.reasoning_content=a),f.size>0&&(b.tool_calls=[...f.values()]),JSON.stringify({id:o,object:"chat.completion",created:Math.floor(Date.now()/1e3),model:s!==""?s:n??"",choices:[{index:0,message:b,finish_reason:c}],usage:{prompt_tokens:u,completion_tokens:d,total_tokens:u+d}})}const YN={format:"openai",parseRequest(e,t){try{const n=JSON.parse(e),r=Ju.safeParse(n);return r.success?{model:r.data.model,sessionId:t?.get("x-session-affinity")??null}:null}catch{return null}},extractTokens(e){const t=Xu(e);if(t){let n=null;try{const r=JSON.parse(e);if(r!==null&&typeof r=="object"&&!Array.isArray(r)){const o=Object.getOwnPropertyDescriptor(r,"usage");if(o!==void 0&&typeof o.value=="object"&&o.value!==null){const s=Object.getOwnPropertyDescriptor(o.value,"prompt_tokens_details");if(s!==void 0&&typeof s.value=="object"&&s.value!==null){const i=Object.getOwnPropertyDescriptor(s.value,"cached_tokens");i!==void 0&&typeof i.value=="number"&&(n=i.value)}}}}catch{}return{inputTokens:t.usage.prompt_tokens??null,outputTokens:t.usage.completion_tokens??null,cacheCreationInputTokens:null,cacheReadInputTokens:n}}return{inputTokens:null,outputTokens:null,cacheCreationInputTokens:null,cacheReadInputTokens:null}},extractStream(e,t,n,r){return Ma(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}}};ir.register(YN);const XN="https://api.openai.com/v1",QN={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:XN},extractStream(e,t,n,r){return Ma(e,t,n,r)}};Da.register(QN);const e4="https://dashscope.aliyuncs.com/compatible-mode/v1",t4={name:"alibaba",matches(e){const t=e.toLowerCase().replace(/\s+/g,"-");return!!(t.startsWith("glm-5")||t.startsWith("qwen"))},getUpstreamBase(e,t){return e4},extractStream(e,t,n){return Ma(e,t,n)}};Da.register(t4);function hn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const Bn={parsed:null,toolNames:null},n4={format:"anthropic",analyzeRequest(e){if(e===null)return hn(e);try{const t=Hu.safeParse(JSON.parse(e));return t.success?{parsed:t.data,comparisonValue:t.data,messageCount:t.data.messages.length,toolCount:t.data.tools!==void 0&&t.data.tools.length>0?t.data.tools.length:null}:hn(e)}catch{return hn(e)}},analyzeResponse(e){if(e===null)return Bn;try{let t=JSON.parse(e);typeof t=="string"&&(t=JSON.parse(t));const n=qu.safeParse(t);if(!n.success)return Bn;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 Bn}}},r4={format:"openai",analyzeRequest(e){if(e===null)return hn(e);try{const t=Ju.safeParse(JSON.parse(e));return t.success?{parsed:t.data,comparisonValue:t.data,messageCount:t.data.messages.length,toolCount:t.data.tools!==void 0&&t.data.tools.length>0?t.data.tools.length:null}:hn(e)}catch{return hn(e)}},analyzeResponse(e){if(e===null)return Bn;const t=Xu(e);if(t===null)return Bn;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}}},o4={format:"unknown",analyzeRequest(e){return hn(e)},analyzeResponse(){return Bn}},s4={anthropic:n4,openai:r4,unknown:o4};function Ao(e){return s4[e]}function Nr(e){const t=ZN(e.path);return t==="unknown"?e.apiFormat:t}function i4(e){switch(e){case"success":return"text-emerald-400";case"client_error":return"text-amber-400";case"server_error":return"text-red-400";case"pending":return"text-muted-foreground"}}function pr({status:e}){const t=Cd(e),n=i4(t);return e===null?l.jsx("span",{className:"text-xs text-muted-foreground italic",children:"pending"}):l.jsxs("span",{className:he("flex items-center gap-1 text-xs font-mono font-semibold",n),children:[t==="server_error"&&l.jsx(Ev,{className:"size-3"}),e]})}function Wc({text:e}){return l.jsx("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-3",children:l.jsx("pre",{className:"text-xs text-red-300 whitespace-pre-wrap font-mono leading-relaxed overflow-auto max-h-[60vh]",children:e})})}function a4({text:e}){return l.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1",children:l.jsx(Gn,{children:e})})}const ao=v.memo(function({responseText:t,responseStatus:n,streaming:r,inputTokens:o,outputTokens:s,cacheCreationInputTokens:i,cacheReadInputTokens:a,apiFormat:c,error:u}){const d=c??"unknown",h=v.useMemo(()=>Ao(d).analyzeResponse(t).parsed,[d,t]);return t===null&&u===void 0?l.jsxs("div",{className:"flex items-center gap-2 py-3",children:[l.jsx(pr,{status:n}),l.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No response"})]}):n!==null&&n>=400?l.jsxs("div",{className:"space-y-2",children:[l.jsx(pr,{status:n}),l.jsx(Wc,{text:t??""}),u!=null&&l.jsxs("div",{className:"rounded border border-destructive/50 bg-destructive/10 p-3 text-xs",children:[l.jsx("div",{className:"font-semibold text-destructive mb-1",children:"SSE Error"}),l.jsx("div",{className:"text-muted-foreground font-mono",children:u})]})]}):u!=null?l.jsxs("div",{className:"space-y-2",children:[l.jsx(pr,{status:n}),l.jsxs("div",{className:"rounded border border-destructive/50 bg-destructive/10 p-3 text-xs",children:[l.jsx("div",{className:"font-semibold text-destructive mb-1",children:"SSE Error"}),l.jsx("div",{className:"text-muted-foreground font-mono",children:u})]}),t!==null&&l.jsx("div",{className:"mt-2",children:l.jsx(Wc,{text:t})})]}):h!==null?l.jsxs("div",{className:"space-y-2",children:[l.jsx(pr,{status:n}),MN(d,h)]}):l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(pr,{status:n}),r&&(o!==null||s!==null)&&l.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs",children:[l.jsx(Xn,{className:"size-3"}),l.jsxs("span",{className:"font-mono tabular-nums",children:[o!==null?qe(o):"—"," in /"," ",s!==null?qe(s):"—"," out"]}),i!=null&&i>0&&l.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["Cache +",qe(i)]}),a!=null&&a>0&&l.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["Cache ~",qe(a)]})]})]}),l.jsx(a4,{text:t??""})]})}),l4=ae({success:Qe(),error:K().optional(),responseStatus:ve().optional(),responseText:K().optional(),inputTokens:ve().optional(),outputTokens:ve().optional(),elapsedMs:ve().optional(),streaming:Qe().optional()});function c4({log:e,open:t,onOpenChange:n}){const[r,o]=v.useState(()=>e.rawRequestBody??"{}"),[s,i]=v.useState(null),[a,c]=v.useState(!1),[u,d]=v.useState(null);async function h(){c(!0),d(null),i(null);try{const g=await(await fetch(`/api/logs/${e.id}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modifiedBody:r})})).json(),m=l4.safeParse(g);if(!m.success){d("Invalid response from server"),c(!1);return}const x=m.data;i(x),x.success||d(x.error??"Replay failed")}catch(f){d(f instanceof Error?f.message:"Network error")}finally{c(!1)}}function p(){i(null),d(null),n(!1)}return l.jsx(rs,{open:t,onOpenChange:p,children:l.jsxs(os,{className:"max-w-4xl max-h-[85vh] overflow-auto",children:[l.jsx(ss,{children:l.jsxs(is,{className:"flex items-center gap-2",children:[l.jsx(id,{className:"size-4"}),"Replay Request #",e.id]})}),l.jsxs(Pn,{defaultValue:"modified",children:[l.jsxs(On,{children:[l.jsx(tt,{value:"modified",children:"Modified Request"}),l.jsx(tt,{value:"original",children:"Original Response"}),s&&l.jsx(tt,{value:"replay",children:"Replay Response"})]}),l.jsxs(nt,{value:"modified",className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Request Body (JSON)"}),l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("textarea",{className:"w-full h-64 p-3 font-mono text-xs bg-muted rounded-md border border-input resize-none focus:outline-none focus:ring-2 focus:ring-ring",value:r,onChange:f=>o(f.target.value),spellCheck:!1})}),l.jsx($e,{children:"Edit the request body before re-sending to the provider"})]})})]}),u!==null&&u!==""&&l.jsx("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:u}),l.jsx("div",{className:"flex justify-end",children:l.jsx(Xe,{onClick:()=>{h()},disabled:a,children:a?"Replaying...":"Replay"})}),s&&s.success&&l.jsxs(Pn,{defaultValue:"parsed",children:[l.jsxs(On,{children:[l.jsx(tt,{value:"parsed",children:"Response"}),l.jsx(tt,{value:"raw",children:"Raw Response"})]}),l.jsx(nt,{value:"parsed",children:l.jsx(ao,{responseText:s.responseText??null,responseStatus:s.responseStatus??null,streaming:s.streaming??!1,inputTokens:s.inputTokens??null,outputTokens:s.outputTokens??null,apiFormat:e.apiFormat})}),l.jsx(nt,{value:"raw",children:l.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap bg-muted p-3 rounded-md max-h-96 overflow-auto",children:s.responseText??"No response"})})]})]}),l.jsx(nt,{value:"original",children:e.responseText!==null?l.jsxs(Pn,{defaultValue:"parsed",children:[l.jsxs(On,{children:[l.jsx(tt,{value:"parsed",children:"Response"}),l.jsx(tt,{value:"raw",children:"Raw Response"})]}),l.jsx(nt,{value:"parsed",children:l.jsx(ao,{responseText:e.responseText,responseStatus:e.responseStatus,streaming:e.streaming,inputTokens:e.inputTokens,outputTokens:e.outputTokens,cacheCreationInputTokens:e.cacheCreationInputTokens,cacheReadInputTokens:e.cacheReadInputTokens,apiFormat:e.apiFormat})}),l.jsx(nt,{value:"raw",children:l.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap bg-muted p-3 rounded-md max-h-96 overflow-auto",children:e.responseText})})]}):l.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No original response"})}),s&&s.success&&l.jsx(nt,{value:"replay",children:s.responseText!==null?l.jsxs(Pn,{defaultValue:"parsed",children:[l.jsxs(On,{children:[l.jsx(tt,{value:"parsed",children:"Response"}),l.jsx(tt,{value:"raw",children:"Raw Response"})]}),l.jsx(nt,{value:"parsed",children:l.jsx(ao,{responseText:s.responseText??null,responseStatus:s.responseStatus??null,streaming:s.streaming??!1,inputTokens:s.inputTokens??null,outputTokens:s.outputTokens??null,apiFormat:e.apiFormat})}),l.jsx(nt,{value:"raw",children:l.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap bg-muted p-3 rounded-md max-h-96 overflow-auto",children:s.responseText})})]}):l.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No replay response"})})]})]})})}const u4=v.memo(function({logId:t,truncated:n}){const[r,o]=v.useState(!1),[s,i]=v.useState({status:"idle"}),[a,c]=v.useState(new Set);v.useEffect(()=>{if(!r||s.status!=="idle")return;let p=!1;return i({status:"loading"}),fetch(`/api/logs/${t}/chunks`).then(f=>f.ok?f.json():Promise.reject(new Error("Chunks not found"))).then(f=>{p||i({status:"success",chunks:f.chunks})}).catch(()=>{p||i({status:"error",message:"Chunk data unavailable"})}),()=>{p=!0}},[r,t]);const u=v.useMemo(()=>{if(s.status!=="success")return[];const p=new Map;for(const f of s.chunks){const g=p.get(f.index);g?g.push(f):p.set(f.index,[f])}return Array.from(p.entries()).map(([f,g])=>({index:f,chunks:g})).sort((f,g)=>f.index-g.index)},[s]),d=p=>{c(f=>{const g=new Set(f);return g.has(p)?g.delete(p):g.add(p),g})};function h(){return s.status==="idle"||s.status==="loading"?l.jsxs("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[l.jsx(Sr,{className:"size-3 animate-spin"}),l.jsx("span",{children:"Loading chunks..."})]}):s.status==="error"?l.jsx("div",{className:"py-2 text-xs text-muted-foreground italic",children:s.message}):l.jsxs("div",{className:"p-2 space-y-1",children:[l.jsxs("div",{className:"text-[10px] text-muted-foreground font-mono mb-2",children:[u.length," index group",u.length!==1?"s":""," available"]}),u.map(p=>{const f=a.has(p.index);return l.jsxs("div",{className:"rounded border border-border bg-background",children:[l.jsxs("button",{type:"button",className:"flex items-center gap-2 w-full px-2 py-1.5 text-left hover:bg-muted/50 transition-colors cursor-pointer",onClick:()=>d(p.index),children:[f?l.jsx(vt,{className:"size-3 text-muted-foreground"}):l.jsx(bt,{className:"size-3 text-muted-foreground"}),l.jsxs("span",{className:"text-[10px] text-muted-foreground font-mono",children:["[",p.index,"] ",p.chunks[0]?.type??""]}),l.jsxs("span",{className:"text-[10px] text-muted-foreground font-mono",children:[p.chunks.length," chunk",p.chunks.length!==1?"s":""]})]}),f&&l.jsx("div",{className:"px-2 pb-2 space-y-1",children:p.chunks.map(g=>l.jsxs("div",{className:"rounded border border-border bg-muted/20 p-2",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsxs("span",{className:"text-[10px] text-muted-foreground font-mono",children:["+",g.timestamp,"ms"]}),l.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:g.type})]}),l.jsx(us,{data:g,defaultExpandDepth:1,showCopy:!0})]},g.index))})]},p.index)})]})}return l.jsxs("div",{className:"space-y-1",children:[l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:()=>o(p=>!p),children:[r?l.jsx(vt,{className:"size-3"}):l.jsx(bt,{className:"size-3"}),l.jsx("span",{children:"Raw SSE Events"}),l.jsxs(xt,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono ml-1",children:[t,n===!0?"+":""]})]})}),l.jsx($e,{children:"Server-Sent Events streaming chunks from the provider"})]})}),r===!0?l.jsx("div",{className:"rounded-md border border-border bg-muted/20 overflow-auto max-h-64",children:h()}):null]})});function Hc(e,t,n){return e==="anthropic"&&t==="full"&&n}function d4(e,t){return e==="full"&&t}function f4(e,t,n,r){return e==="anthropic"&&t==="full"&&n&&r}function Zs({text:e,label:t,copied:n,onCopy:r}){return e===null?null:l.jsx("button",{type:"button",onClick:r,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-muted",children:n?l.jsxs(l.Fragment,{children:[l.jsx(Gt,{className:"size-3 text-green-500"}),l.jsx("span",{className:"text-green-500",children:"Copied!"})]}):l.jsxs(l.Fragment,{children:[l.jsx(wn,{className:"size-3"}),l.jsx("span",{children:t})]})})}function qc({active:e,onClick:t}){return l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("button",{type:"button",onClick:t,"aria-pressed":e,className:he("flex items-center gap-1.5 text-xs px-2 py-1 rounded transition-colors",e?"bg-primary/10 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted"),children:[l.jsx(od,{className:"size-3"}),e?"Showing diff":"Diff with Raw"]})}),l.jsx($e,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const h4=v.memo(function({rawBody:e,displayedBody:t,emptyLabel:n}){const r=v.useMemo(()=>Y3(e,t),[e,t]);return l.jsx(Fp,{result:r,emptyLabel:n})}),p4=v.memo(function({rawHeaders:e,headers:t,emptyLabel:n}){const r=v.useMemo(()=>J3(e,t),[e,t]);return l.jsx(Fp,{result:r,emptyLabel:n})});function Vs(e){const[t,n]=v.useState(!1),r=v.useRef(null);v.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);const o=v.useCallback(s=>{s.stopPropagation(),e!==null&&window.navigator.clipboard.writeText(e).then(()=>{n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),2e3)})},[e]);return{copied:t,copy:o}}const m4=v.memo(function({log:e,viewMode:t="simple",strip:n,cacheTrend:r=null,onCompareWithPrevious:o}){const[s,i]=v.useState(!1),[a,c]=v.useState(!1),[u,d]=v.useState(!1),[h,p]=v.useState(!1),[f,g]=v.useState("request"),m=Nr(e),x=Ao(m),y=v.useMemo(()=>x.analyzeRequest(e.rawRequestBody),[x,e.rawRequestBody]),b=v.useMemo(()=>x.analyzeResponse(e.responseText),[x,e.responseText]),S=v.useMemo(()=>!n||m!=="anthropic"||e.rawRequestBody===null?null:vC(e.rawRequestBody).body,[e.rawRequestBody,m,n])??e.rawRequestBody,C=Vs(S),j=Vs(e.rawRequestBody),N=Vs(e.responseText);return l.jsxs(Je,{children:[l.jsxs("div",{className:"border border-border rounded-lg mb-1 overflow-hidden",children:[l.jsx(kN,{log:e,messageCount:y.messageCount,toolCount:y.toolCount,expanded:s,onToggle:()=>i(!s),responseToolNames:b.toolNames,cacheTrend:r}),s&&l.jsx("div",{onClick:T=>T.stopPropagation(),onKeyDown:T=>T.stopPropagation(),children:l.jsxs(Pn,{value:f,onValueChange:g,children:[l.jsxs(On,{className:"mx-4 mt-2",children:[t==="full"&&l.jsx(tt,{value:"raw-headers",children:"Raw Headers"}),t==="full"&&l.jsx(tt,{value:"headers",children:"Headers"}),Hc(m,t,n)&&l.jsx(tt,{value:"raw-request",children:"Raw Request"}),l.jsx(tt,{value:"request",children:"Request"}),t==="full"&&l.jsx(tt,{value:"raw",children:"Raw Response"}),l.jsx(tt,{value:"parsed",children:"Response"})]}),Hc(m,t,n)&&l.jsx(nt,{value:"raw-request",children:f==="raw-request"&&l.jsxs("div",{className:"px-4 py-3",children:[l.jsx("div",{className:"flex justify-end mb-2",children:l.jsx(Zs,{text:e.rawRequestBody,label:"Copy Raw Request",copied:j.copied,onCopy:j.copy})}),e.rawRequestBody!==null?l.jsx(fn,{text:e.rawRequestBody,defaultExpandDepth:1}):l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No request body"})]})}),l.jsx(nt,{value:"request",children:f==="request"&&l.jsxs("div",{className:"px-4 py-3",children:[l.jsxs("div",{className:"flex justify-end gap-2 mb-2",children:[f4(m,t,n,e.rawRequestBody!==null)&&l.jsx(qc,{active:h,onClick:T=>{T.stopPropagation(),p(!h)}}),o!==void 0&&l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs(Xe,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:T=>{T.stopPropagation(),o(e)},children:[l.jsx(od,{className:"size-3 mr-1"}),"Diff with Previous"]})}),l.jsx($e,{children:"Compare this request with the immediately preceding one"})]}),l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs(Xe,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:T=>{T.stopPropagation(),c(!0)},children:[l.jsx(id,{className:"size-3 mr-1"}),"Replay"]})}),l.jsx($e,{children:"Re-send this request to the provider"})]}),l.jsx(Zs,{text:S,label:"Copy Request",copied:C.copied,onCopy:C.copy})]}),h?l.jsx(h4,{rawBody:e.rawRequestBody,displayedBody:S,emptyLabel:"No transformation applied — raw and sent request bodies are identical."}):S!==null?l.jsx(fn,{text:S,defaultExpandDepth:1}):l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No request body"})]})}),t==="full"&&l.jsx(nt,{value:"headers",children:f==="headers"&&l.jsxs("div",{className:"px-4 py-3",children:[l.jsx("div",{className:"flex justify-end gap-2 mb-2",children:d4(t,e.rawHeaders!==void 0&&Object.keys(e.rawHeaders).length>0)&&l.jsx(qc,{active:u,onClick:T=>{T.stopPropagation(),d(!u)}})}),u?l.jsx(p4,{rawHeaders:e.rawHeaders,headers:e.headers,emptyLabel:"No transformation applied — raw and processed headers are identical."}):e.headers&&Object.keys(e.headers).length>0?l.jsx("div",{className:"space-y-1 font-mono text-xs",children:Object.entries(e.headers).sort(([T],[A])=>T.localeCompare(A)).map(([T,A])=>l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("span",{className:"text-blue-600 dark:text-blue-400 font-semibold shrink-0",children:[T,":"]}),l.jsx("span",{className:"text-muted-foreground truncate",title:A,children:A})]},T))}):l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No headers captured"})]})}),t==="full"&&l.jsx(nt,{value:"raw-headers",children:f==="raw-headers"&&l.jsx("div",{className:"px-4 py-3",children:e.rawHeaders&&Object.keys(e.rawHeaders).length>0?l.jsx("div",{className:"space-y-1 font-mono text-xs",children:Object.entries(e.rawHeaders).sort(([T],[A])=>T.localeCompare(A)).map(([T,A])=>l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("span",{className:"text-blue-600 dark:text-blue-400 font-semibold shrink-0",children:[T,":"]}),l.jsx("span",{className:"text-muted-foreground truncate",title:A,children:A})]},T))}):l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No raw headers captured"})})}),l.jsx(nt,{value:"raw",children:f==="raw"&&l.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.error!==void 0&&e.error!==null&&l.jsxs("div",{className:"rounded border border-destructive/50 bg-destructive/10 p-3 text-xs",children:[l.jsx("div",{className:"font-semibold text-destructive mb-1",children:"SSE Error"}),l.jsx("div",{className:"text-muted-foreground font-mono",children:e.error})]}),l.jsx("div",{className:"flex justify-end",children:l.jsx(Zs,{text:e.responseText,label:"Copy Response",copied:N.copied,onCopy:N.copy})}),e.responseText!==null?l.jsx(fn,{text:e.responseText,defaultExpandDepth:1}):l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No response"}),e.streaming===!0&&l.jsx(u4,{logId:e.id,truncated:e.streamingChunksPath!==null})]})}),l.jsx(nt,{value:"parsed",children:f==="parsed"&&l.jsx("div",{className:"px-4 py-3",children:l.jsx(ao,{responseText:e.responseText,responseStatus:e.responseStatus,streaming:e.streaming,inputTokens:e.inputTokens,outputTokens:e.outputTokens,cacheCreationInputTokens:e.cacheCreationInputTokens,cacheReadInputTokens:e.cacheReadInputTokens,apiFormat:m,error:e.error})})})]})})]}),l.jsx(c4,{log:e,open:a,onOpenChange:c})]})});function g4({stopReason:e,isPending:t,isFirst:n,isTurnStart:r,crabIndex:o=0,collapsible:s=!1,onToggle:i}){const a=e==="end_turn"||e==="stop",c=t&&!a,u=v.useMemo(()=>mi(o),[o]),d=s&&i?{role:"button",tabIndex:0,className:"cursor-pointer",onClick:h=>{h.stopPropagation(),i()},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),i())}}:{};return l.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[l.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!n&&l.jsx("div",{className:"w-0.5 bg-muted-foreground/30 h-full"})}),a?l.jsx("span",{title:e==="end_turn"?"End of Turn (Anthropic)":"End of Turn (OpenAI)",...d,children:l.jsx(u,{className:he("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})}):r?l.jsx("span",{title:"Start of turn",...d,children:l.jsx(u,{className:he("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):c?l.jsx("span",{title:"Processing…",children:l.jsx(u,{className:he("size-3.5 text-amber-300/80","animate-crab-crawl")})}):l.jsx("span",{children:l.jsx(u,{className:"size-3.5 text-muted-foreground/40"})}),l.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!a&&l.jsx("div",{className:he("w-0.5 h-full",t?"border-dashed bg-transparent border-l-2 border-muted-foreground/20":"bg-muted-foreground/30")})})]})}function x4(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const y4=v.memo(function({entries:t,viewMode:n,strip:r,cacheTrends:o,onCompareWithPrevious:s,comparisonPredecessors:i,turnIndex:a=0}){const c=t.length-1,u=t[c]?.stopReason??null,d=u!==null?qh(u):!1,h=t[c]?.log.responseStatus===null,p=d&&!h,[f,g]=v.useState(!1),m=v.useRef(d);v.useEffect(()=>{d&&!m.current&&g(!0),m.current=d},[d]);const x=v.useCallback(()=>{p&&g(A=>!A)},[p]),y=v.useMemo(()=>{let A=0,O=0,L=0,E=!1,M=!1;for(const w of t)w.log.inputTokens!==null&&(A+=w.log.inputTokens,E=!0),w.log.outputTokens!==null&&(O+=w.log.outputTokens,E=!0),w.log.elapsedMs!==null&&(L+=w.log.elapsedMs,M=!0);return{totalInput:A,totalOutput:O,hasTokens:E,totalElapsed:L,hasElapsed:M}},[t,c]),b=v.useMemo(()=>{const A=new Set;for(const O of t){const L=Jh(O.log.model);L!=="unknown"&&A.add(L)}return[...A]},[t]),k=v.useMemo(()=>mi(t[0]?.log.id??0),[t]),S=v.useMemo(()=>mi(t[c]?.log.id??0),[t,c]),C=a%2===0?"bg-muted/10":"bg-muted/25",[j,N]=v.useState(0),T=v.useRef(null);return v.useEffect(()=>{const A=T.current;if(!A)return;let O=0;const L=new ResizeObserver(()=>{window.cancelAnimationFrame(O),O=window.requestAnimationFrame(()=>N(E=>E+1))});return L.observe(A),()=>{L.disconnect(),window.cancelAnimationFrame(O)}},[]),l.jsx("div",{ref:T,className:he("border rounded-lg",h?"border-amber-500/10":"border-transparent"),children:f?l.jsxs("div",{className:"flex items-stretch",children:[l.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-0.5 pb-0.5",children:[l.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),l.jsx("span",{role:"button",tabIndex:0,title:"Start of turn — click to expand",className:"cursor-pointer",onClick:A=>{A.stopPropagation(),x()},onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),x())},children:l.jsx(k,{className:he("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}),l.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:l.jsx("div",{className:"w-0.5 bg-muted-foreground/30 h-full"})}),l.jsx("span",{role:"button",tabIndex:0,title:"End of Turn — click to expand",className:"cursor-pointer",onClick:A=>{A.stopPropagation(),x()},onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),x())},children:l.jsx(S,{className:he("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})})]}),l.jsxs("div",{className:he("flex-1 min-w-0 mb-0.5 rounded-lg border border-border py-1 px-3 flex items-center gap-3 text-xs cursor-pointer",C),onClick:x,role:"button",tabIndex:0,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),x())},children:[l.jsxs("span",{className:"text-blue-400/80 font-mono font-semibold tabular-nums shrink-0",children:["#",t[0]?.log.id??"?"," ~ #",t[c]?.log.id??"?"]}),l.jsxs("span",{className:"text-muted-foreground shrink-0",children:[t.length," request",t.length>1?"s":""]}),b.length>0&&l.jsx("span",{className:"flex items-center gap-0.5 shrink-0",children:b.map(A=>l.jsx(Yh,{provider:A,className:"size-4"},A))}),y.hasElapsed&&l.jsxs("span",{className:"hidden xl:flex items-center gap-1 text-muted-foreground shrink-0",children:[l.jsx(Ir,{className:"size-3"}),l.jsx("span",{className:"font-mono tabular-nums",children:x4(y.totalElapsed)})]}),y.hasTokens&&l.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[l.jsx(Xn,{className:"size-3 text-muted-foreground"}),l.jsxs("span",{className:"font-mono tabular-nums",children:[l.jsxs("span",{className:"text-blue-400",children:["IN ",qe(y.totalInput)]})," / ",l.jsxs("span",{className:"text-amber-400",children:["OUT ",qe(y.totalOutput)]})]})]}),l.jsx("span",{className:"flex-1 min-w-0"}),l.jsx(bt,{className:"size-4 text-muted-foreground shrink-0"})]})]}):t.map((A,O)=>{const{log:L,stopReason:E}=A,M=O===0;return l.jsxs("div",{className:"flex items-stretch",children:[l.jsx(g4,{stopReason:E,isPending:L.responseStatus===null,isFirst:O===0,isTurnStart:M,crabIndex:L.id%12,collapsible:p&&t.length>1&&M,onToggle:x}),l.jsx("div",{className:he("flex-1 min-w-0 mb-0.5 rounded-lg",C),children:l.jsx(m4,{log:L,viewMode:n,strip:r,cacheTrend:o?.get(L.id)??null,onCompareWithPrevious:i.has(L.id)?s:void 0})})]},L.id)})})});function v4(e,t){return e||t}function b4(e){const t=[];let n=[],r=0;for(const o of e){n.push({log:o,stopReason:US(o)});const s=n[n.length-1];s!==void 0&&qh(s.stopReason)&&(t.push({entries:n,turnIndex:r}),n=[],r+=1)}return n.length>0&&t.push({entries:n,turnIndex:r}),t}function w4(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],s=n.logs[r-1];if(o===void 0||s===void 0)continue;const i=Nr(o),a=Nr(s);i==="unknown"||i!==a||t.set(o.id,s)}return t}function k4(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}}const _4=v.memo(function({group:e,viewMode:t="simple",strip:n,cacheTrends:r,onCompareWithPrevious:o,comparisonPredecessors:s,onClearGroup:i,standalone:a=!1}){const[c,u]=v.useState(!1),d=v.useMemo(()=>k4(e.logs),[e.logs]),h=e.logs[0]?.timestamp??new Date().toISOString(),p=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),f=$S(e.logs),g=e.logs.some(y=>y.responseStatus===null),m=v.useMemo(()=>b4(e.logs),[e.logs]),x=e.conversationId.startsWith("PID:")||e.conversationId.includes("|")?e.conversationId:e.conversationId.length>24?e.conversationId.slice(0,12)+"…"+e.conversationId.slice(-12):e.conversationId;return l.jsxs("div",{className:"mb-2",children:[!a&&l.jsx(LS,{conversationId:x,startTime:h,endTime:p,totalCalls:e.logs.length,totalInputTokens:d.totalInputTokens,totalOutputTokens:d.totalOutputTokens,apiFormat:FS(e.logs),expanded:c,onToggle:()=>u(!c),hideApiFormat:f,isLoading:g,userAgent:e.logs[0]?.userAgent??null,onClear:()=>i(e.logs.map(y=>y.id))}),v4(a,c)&&l.jsx("div",{className:"max-h-[70vh] overflow-y-auto",children:m.map(y=>l.jsx(y4,{entries:y.entries,viewMode:t,strip:n,cacheTrends:r,onCompareWithPrevious:o,comparisonPredecessors:s,turnIndex:y.turnIndex},y.turnIndex))})]})});function S4({className:e}){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:he("inline-block size-5",e),children:[l.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"}),l.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),l.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),l.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),l.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"}),l.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),l.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),l.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),l.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),l.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]})}function Kc({...e}){return l.jsx(Z_,{"data-slot":"select",...e})}function Gc({...e}){return l.jsx(W_,{"data-slot":"select-value",...e})}function Jc({className:e,size:t="default",children:n,...r}){return l.jsxs(V_,{"data-slot":"select-trigger","data-size":t,className:he("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,l.jsx(H_,{asChild:!0,children:l.jsx(vt,{className:"size-4 opacity-50"})})]})}function Yc({className:e,children:t,position:n="popper",align:r="center",...o}){return l.jsx(q_,{children:l.jsxs(K_,{"data-slot":"select-content",className:he("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:[l.jsx(C4,{}),l.jsx(G_,{className:he("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),l.jsx(j4,{})]})})}function eo({className:e,children:t,...n}){return l.jsxs(J_,{"data-slot":"select-item",className:he("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:[l.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:l.jsx(X_,{children:l.jsx(Gt,{className:"size-4"})})}),l.jsx(Y_,{children:t})]})}function C4({className:e,...t}){return l.jsx(Q_,{"data-slot":"select-scroll-up-button",className:he("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(zy,{className:"size-4"})})}function j4({className:e,...t}){return l.jsx(eS,{"data-slot":"select-scroll-down-button",className:he("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(vt,{className:"size-4"})})}function E4(){return l.jsxs("svg",{fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[l.jsx("title",{children:"Claude Code"}),l.jsx("path",{clipRule:"evenodd",d:"M20.998 10.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6 10.949h1.488V8.102H6v2.847zm10.51 0H18V8.102h-1.49v2.847z"})]})}function N4(){return l.jsxs("svg",{fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[l.jsx("title",{children:"OpenCode"}),l.jsx("path",{d:"M16 6H8v12h8V6zm4 16H4V2h16v20z"})]})}function T4(){return l.jsxs("svg",{fill:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[l.jsx("title",{children:"MiMo Code"}),l.jsx("text",{x:"12",y:"18",textAnchor:"middle",fontSize:"16",fontWeight:"800",fontFamily:"system-ui, sans-serif",children:"M"})]})}const A4=ae({name:K(),apiKey:K(),format:lt(["anthropic","openai"]),anthropicBaseUrl:K(),openaiBaseUrl:K(),models:Pe(K()),sourceTool:lt(["claude-code","opencode","mimo-code"]),alreadyExists:Qe()}),I4=ae({providers:Pe(A4),warnings:Pe(K()).optional()}),z4=ae({success:Qe().optional(),imported:ve().optional(),message:K().optional(),errors:Pe(K()).optional()}),R4={"claude-code":E4,opencode:N4,"mimo-code":T4};function P4({open:e,onOpenChange:t,onImportComplete:n}){const[r,o]=v.useState(!1),[s,i]=v.useState(null),[a,c]=v.useState([]),[u,d]=v.useState([]),[h,p]=v.useState(new Set),[f,g]=v.useState(!1),[m,x]=v.useState(null),[y,b]=v.useState(null),k=v.useCallback(()=>{o(!0),i(null),d([]),c([]),p(new Set),x(null),b(null),fetch("/api/providers/scan").then(N=>N.ok?N.json().then(T=>{const A=I4.safeParse(T);if(!A.success){i(`Invalid response: ${A.error.message}`);return}c(A.data.providers),d(A.data.warnings??[]);const O=new Set;A.data.providers.forEach((L,E)=>{L.alreadyExists||O.add(E)}),p(O)}):N.text().then(T=>{i(`Scan failed (${N.status}): ${T}`)})).catch(N=>{i(N instanceof Error?N.message:String(N))}).finally(()=>{o(!1)})},[]);v.useEffect(()=>{e&&k()},[e,k]);const S=v.useCallback(N=>{p(T=>{const A=new Set(T);return A.has(N)?A.delete(N):A.add(N),A})},[]),C=v.useCallback(()=>{const N=a.filter((O,L)=>h.has(L));if(N.length===0)return;g(!0),b(null),x(null);const T=new Date().toISOString(),A=N.map(O=>({id:window.crypto.randomUUID(),name:O.name,apiKey:O.apiKey,format:O.format,anthropicBaseUrl:O.anthropicBaseUrl,openaiBaseUrl:O.openaiBaseUrl,models:O.models,createdAt:T,updatedAt:T}));fetch("/api/providers/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providers:A})}).then(O=>O.json()).then(O=>{const L=z4.safeParse(O);if(!L.success){b(`Invalid response: ${L.error.message}`);return}const E=L.data;c(M=>M.map((w,D)=>h.has(D)?{...w,alreadyExists:!0}:w)),p(new Set),E.errors!==void 0&&E.errors.length>0&&E.message!==void 0?x(E.message):x(`Imported ${E.imported??N.length} provider(s)`),n()}).catch(O=>{b(O instanceof Error?O.message:String(O))}).finally(()=>{g(!1)})},[a,h,n]),j=a.some(N=>!N.alreadyExists);return l.jsx(rs,{open:e,onOpenChange:t,children:l.jsxs(os,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[l.jsxs(ss,{children:[l.jsx(is,{children:"Import from External Tools"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[r&&l.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[l.jsx(Sr,{className:"size-4 animate-spin"}),l.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),s!==null&&l.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[l.jsx(_r,{className:"size-4"}),s]}),!r&&s===null&&a.length===0&&l.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",l.jsx("br",{}),l.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&&a.map((N,T)=>l.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${N.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!N.alreadyExists&&l.jsx("input",{type:"checkbox",checked:h.has(T),disabled:f,onChange:()=>S(T),className:"mt-0.5 size-4"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[(()=>{const A=R4[N.sourceTool];return A===void 0?null:l.jsx(A,{})})(),N.alreadyExists&&l.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),l.jsxs("div",{className:"text-xs text-muted-foreground mt-1 truncate",children:[N.models.slice(0,4).join(", "),N.models.length>4?` +${N.models.length-4} more`:""]}),l.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:N.format==="anthropic"?N.anthropicBaseUrl:N.openaiBaseUrl}),l.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:N.apiKey.length>8?`${N.apiKey.slice(0,4)}••••${N.apiKey.slice(-4)}`:"••••"})]})]},`${N.sourceTool}-${N.name}`)),u.length>0&&l.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:u.map((N,T)=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(_r,{className:"size-3"}),N]},T))}),m!==null&&l.jsx("div",{className:"text-sm text-green-500 border-t pt-2",children:m}),y!==null&&l.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:y})]}),l.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[l.jsxs(Xe,{variant:"outline",size:"sm",onClick:k,disabled:r,children:[l.jsx(Sr,{className:`size-3 mr-1 ${r?"animate-spin":""}`}),"Rescan"]}),l.jsxs(Xe,{size:"sm",onClick:C,disabled:!j||h.size===0||f,children:[l.jsx(Zi,{className:"size-3 mr-1"}),f?"Importing...":`Import Selected (${h.size})`]})]})]})})}function Vp(e){return e.length<=8?"••••••••":e.slice(0,4)+"••••••••"+e.slice(-4)}const O4={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function D4(e){return Object.prototype.hasOwnProperty.call(e,"success")}function M4(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function L4(e){const t={className:"size-3",strokeWidth:2};switch(e){case"timeout":return l.jsx(Ir,{...t});case"network_unreachable":return l.jsx(Rv,{...t});case"connection_refused":return l.jsx(Ov,{...t});case"auth_failed":return l.jsx(lv,{...t});case"rate_limited":return l.jsx(nv,{...t});case"server_error":return l.jsx(wv,{...t});case"invalid_response":return l.jsx(By,{...t});case"unknown":return l.jsx(_r,{...t});default:return l.jsx(_r,{...t})}}function to({result:e}){const[t,n]=v.useState(!1);if(!D4(e))return M4(e)?l.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground shrink-0",children:[l.jsx(Hi,{className:"size-3"}),l.jsx("span",{children:"Not configured"})]}):l.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground shrink-0",children:[l.jsx(ad,{className:"size-3 animate-spin"}),l.jsx("span",{children:"Testing..."})]});if(e.success){const c=[];e.inputTokens!==void 0&&c.push(l.jsxs("span",{children:[e.inputTokens," in"]},"in")),e.outputTokens!==void 0&&c.push(l.jsxs("span",{children:[e.outputTokens," out"]},"out")),e.cacheCreationInputTokens!==void 0&&e.cacheCreationInputTokens>0&&c.push(l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["+",e.cacheCreationInputTokens," cache"]})}),l.jsx($e,{children:"Tokens cached for reuse, reducing future API cost"})]})},"cache-create")),e.cacheReadInputTokens!==void 0&&e.cacheReadInputTokens>0&&c.push(l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["~",e.cacheReadInputTokens," cached"]})}),l.jsx($e,{children:"Tokens served from cache, reducing API cost"})]})},"cache-read"));const u=[];for(let d=0;d<c.length;d++)d>0&&u.push(", "),u.push(c[d]);return l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("div",{className:"flex items-center gap-1 text-xs text-green-600 shrink-0",children:[l.jsx(Fy,{className:"size-3"}),l.jsx("span",{children:"Connected"}),c.length>0&&l.jsxs("span",{className:"text-muted-foreground",children:["(",u,")"]})]})}),l.jsx($e,{children:"Connection test passed"})]})})}const r=e.error,o=r?.message??"Connection failed",s=r?.hint,i=r?.details,a=r?.type??"unknown";return l.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-1 text-xs text-red-600 max-w-[200px]",children:[L4(a),l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("span",{className:"truncate",children:o})}),l.jsx($e,{children:"Connection test failed"})]})}),i!==void 0&&l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("button",{type:"button",onClick:()=>n(!t),className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:t?l.jsx(Vi,{className:"size-3"}):l.jsx(Wi,{className:"size-3"})})}),l.jsx($e,{children:t?"Hide error details":"Show detailed error information"})]})})]}),t&&i!==void 0&&l.jsxs("div",{className:"text-xs text-muted-foreground bg-muted/50 rounded p-2 max-w-[300px]",children:[s!==void 0&&l.jsx("div",{className:"mb-1",children:s}),l.jsx("div",{className:"font-mono whitespace-pre-wrap break-all text-red-400/80",children:i})]})]})}function F4(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 s=Math.floor(o/60);if(s<60)return`${s}m ago`;const i=Math.floor(s/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function $4({provider:e,testResults:t,isTesting:n,testingTimeLeft:r,isHighlighted:o,onEdit:s,onDelete:i,onTest:a}){const[c,u]=v.useState(!1),[d,h]=v.useState(!1),[p,f]=v.useState(!1),g=v.useRef(null),m=v.useRef(void 0);t?.testedAt!==void 0&&t.testedAt!==m.current&&(m.current=t.testedAt,g.current=null);const x=v.useCallback(()=>{f(k=>{const S=!k;return S&&g.current===null&&t?.models!==void 0&&(g.current=t.testedAt??"",fetch(`/api/providers/${e.id}/test/log`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})),S})},[e.id,t]);function y(){navigator.clipboard.writeText(e.apiKey).catch(()=>{}),h(!0),setTimeout(()=>h(!1),2e3)}const b=e.apiDocsUrl??Object.entries(O4).find(([k])=>e.name.toLowerCase().includes(k))?.[1];return l.jsxs("div",{className:`border rounded-lg p-4 flex flex-col gap-3 bg-card transition-all duration-500 ${o===!0?"ring-2 ring-primary shadow-md":""}`,children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("span",{className:"font-medium truncate",children:e.name}),e.source==="company"&&l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400 shrink-0",children:"公司"})}),l.jsx($e,{children:"Company-provided API key"})]})}),e.source==="personal"&&l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400 shrink-0",children:"个人"})}),l.jsx($e,{children:"Your personal API key"})]})})]}),b!==void 0&&l.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1 text-xs",title:"View API documentation",children:[l.jsx(Jy,{className:"size-3"}),l.jsx("span",{className:"sr-only",children:"Docs"})]})]}),e.models!==void 0&&e.models.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(k=>l.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:k},k))}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("code",{className:"text-xs text-muted-foreground bg-muted px-2 py-1 rounded flex-1 truncate",children:c?e.apiKey:Vp(e.apiKey)}),l.jsx("button",{type:"button",onClick:()=>u(k=>!k),className:"text-muted-foreground hover:text-foreground transition-colors p-1","aria-label":c?"Hide API key":"Show API key",children:c?l.jsx(Vi,{className:"size-4"}):l.jsx(Wi,{className:"size-4"})}),l.jsx("button",{type:"button",onClick:y,className:"text-muted-foreground hover:text-foreground transition-colors p-1","aria-label":"Copy API key",children:d?l.jsx(Gt,{className:"size-4 text-green-500"}):l.jsx(wn,{className:"size-4"})})]}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsxs("div",{className:"text-xs text-muted-foreground min-w-0 flex-1",children:[l.jsx("span",{className:"font-medium",children:"Anthropic:"})," ",l.jsx("span",{className:"truncate",children:e.anthropicBaseUrl})]}),t&&l.jsx(to,{result:t.anthropic.nonStreaming})]}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsxs("div",{className:"text-xs text-muted-foreground min-w-0 flex-1",children:[l.jsx("span",{className:"font-medium",children:"OpenAI:"})," ",l.jsx("span",{className:"truncate",children:e.openaiBaseUrl})]}),t&&l.jsx(to,{result:t.openai.nonStreaming})]}),t?.testedAt!==void 0&&l.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[l.jsx(Ir,{className:"size-3"}),l.jsxs("span",{children:["Tested ",F4(t.testedAt)]})]}),t?.models!==void 0&&Object.keys(t.models).length>0&&l.jsxs("div",{className:"border-t pt-2",children:[l.jsxs("button",{type:"button",onClick:x,className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1",children:[l.jsx("span",{className:"font-mono",children:p?"▾":"▸"}),"Model Test Results (",Object.keys(t.models).length,")"]}),p&&l.jsx("div",{className:"mt-2 overflow-x-auto",children:l.jsxs("table",{className:"w-full text-xs border-collapse",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-border",children:[l.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"Model"}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&l.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"Anthropic"}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&l.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"OpenAI"})]})}),l.jsx("tbody",{children:Object.entries(t.models).map(([k,S])=>l.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[l.jsx("td",{className:"py-1 px-2 font-medium",children:k}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&l.jsx("td",{className:"py-1 px-2",children:l.jsx(to,{result:S.anthropic.nonStreaming})}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&l.jsx("td",{className:"py-1 px-2",children:l.jsx(to,{result:S.openai.nonStreaming})})]},k))})]})})]}),l.jsxs("div",{className:"flex gap-2 pt-1 border-t",children:[a!==void 0&&l.jsxs(Xe,{variant:"outline",size:"sm",onClick:()=>a(e.id),className:"text-xs h-7 gap-1",disabled:n??!1,children:[l.jsx(ad,{className:`size-3 ${n??!1?"animate-spin":""}`}),n??!1?r!==void 0?`Testing (${r}s)`:"Testing...":"Test"]}),l.jsxs(Xe,{variant:"outline",size:"sm",onClick:()=>s(e),className:"text-xs h-7 gap-1",disabled:n??!1,children:[l.jsx(qi,{className:"size-3"}),"Edit"]}),l.jsxs(Xe,{variant:"outline",size:"sm",onClick:()=>i(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:n??!1,children:[l.jsx(ud,{className:"size-3"}),"Delete"]})]})]})}const B4={deepseek:{format:"openai",baseUrl:"https://api.deepseek.com"},minimax:{format:"anthropic",baseUrl:"https://api.minimaxi.com/anthropic",apiDocsUrl:"https://platform.minimaxi.com/docs/api-reference/api-overview"},alibaba:{format:"openai",baseUrl:"https://dashscope.aliyuncs.com/compatible-mode"}},Xc=["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"],Qc=["glm-5","glm-5.1","qwen3.6-plus","qwen3.7-max"];function U4({provider:e,onSubmit:t,onCancel:n}){const[r,o]=v.useState(e?.name??""),[s,i]=v.useState(e?.apiKey??""),[a,c]=v.useState(!1),[u,d]=v.useState(!1),h=e?.models,[p,f]=v.useState(h!==void 0&&h.length>0?h:[""]),[g,m]=v.useState("anthropic"),[x,y]=v.useState(e?.anthropicBaseUrl??""),[b,k]=v.useState(e?.openaiBaseUrl??""),[S,C]=v.useState(e?.apiDocsUrl??""),[j,N]=v.useState(e?.source),[T,A]=v.useState({}),[O,L]=v.useState(!1),[E,M]=v.useState(null),w=v.useRef([]);v.useEffect(()=>{if(E===null)return;const X=E;function de(te){if(!(te.target instanceof Node))return;const ce=w.current[X];ce!=null&&!ce.contains(te.target)&&M(null)}return document.addEventListener("mousedown",de),()=>document.removeEventListener("mousedown",de)},[E]);const[D,H]=v.useState(!1),[B,q]=v.useState(!1),Y=r.toLowerCase().includes("minimax"),I=r.toLowerCase().includes("alibaba");function W(){navigator.clipboard.writeText(s).catch(()=>{}),d(!0),setTimeout(()=>d(!1),2e3)}v.useEffect(()=>{e&&(o(e.name),i(e.apiKey),f((e.models?.length??0)>0?e.models:[""]),y(e.anthropicBaseUrl??""),k(e.openaiBaseUrl??""),C(e.apiDocsUrl??""),N(e.source),H(!1),q(!1))},[e]),v.useEffect(()=>{const X=r.toLowerCase();for(const[de,te]of Object.entries(B4))if(X.includes(de)){te.format==="anthropic"&&!D?y(te.baseUrl):te.format==="openai"&&!B&&k(te.baseUrl),te.apiDocsUrl!==void 0&&!S&&C(te.apiDocsUrl),de==="minimax"&&p.length===1&&p[0]===""&&f([Xc[0]??""]),de==="alibaba"&&p.length===1&&p[0]===""&&f([Qc[0]??""]);break}},[r]);function V(){const X={};return r.trim()||(X.name="Name is required"),s.trim()||(X.apiKey="API key is required"),(p.length===0||p.every(de=>!de.trim()))&&(X.models="At least one model is required"),x.trim()&&!z(x.trim())&&(X.anthropicBaseUrl="Invalid URL format"),b.trim()&&!z(b.trim())&&(X.openaiBaseUrl="Invalid URL format"),!x.trim()&&!b.trim()&&(X.format="At least one format URL (Anthropic or OpenAI) is required"),A(X),Object.keys(X).length===0}function z(X){try{return new URL(X),!0}catch{return!1}}function oe(X){if(X.preventDefault(),!!V()){L(!0);try{t({name:r.trim(),apiKey:s.trim(),models:p.map(de=>de.trim()).filter(de=>de!==""),anthropicBaseUrl:x.trim()||void 0,openaiBaseUrl:b.trim()||void 0,apiDocsUrl:S.trim()||void 0,source:j})}finally{L(!1)}}}return l.jsxs("form",{onSubmit:oe,className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",l.jsx("span",{className:"text-destructive",children:"*"})]}),l.jsx("input",{id:"provider-name",type:"text",value:r,onChange:X=>o(X.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"}),T.name!==void 0&&l.jsx("p",{className:"text-xs text-destructive",children:T.name})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),l.jsxs("select",{id:"provider-source",value:j??"",onChange:X=>N(X.target.value==="company"||X.target.value==="personal"?X.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:[l.jsx("option",{value:"",children:"—"}),l.jsx("option",{value:"personal",children:"个人 (Personal)"}),l.jsx("option",{value:"company",children:"公司 (Company)"})]}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",l.jsx("span",{className:"text-destructive",children:"*"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{id:"provider-apikey",type:"text",value:a||s.length===0?s:Vp(s),onChange:X=>i(X.target.value),onFocus:()=>{!a&&s.length>0&&c(!0)},placeholder:"sk-ant-...",readOnly:!a&&s.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"}),l.jsx("button",{type:"button",onClick:()=>c(X=>!X),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":a?"Hide API key":"Show API key",children:a?l.jsx(Vi,{className:"size-4"}):l.jsx(Wi,{className:"size-4"})}),l.jsx("button",{type:"button",onClick:W,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:u?l.jsx(Gt,{className:"size-4 text-green-500"}):l.jsx(wn,{className:"size-4"})})]}),T.apiKey!==void 0&&l.jsx("p",{className:"text-xs text-destructive",children:T.apiKey})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("label",{className:"text-sm font-medium",children:["Models ",l.jsx("span",{className:"text-destructive",children:"*"})]}),p.map((X,de)=>l.jsxs("div",{ref:te=>{w.current[de]=te},className:"flex items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsx("input",{type:"text",value:X,onChange:te=>{f(ce=>{const fe=[...ce];return fe[de]=te.target.value,fe})},placeholder:Y||I?"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"}),(Y||I)&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",onClick:()=>M(E===de?null:de),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:l.jsx(vt,{className:"size-4"})}),E===de&&l.jsx("div",{className:"absolute left-0 right-0 top-full mt-1 z-50 bg-popover border border-border rounded-md shadow-md max-h-48 overflow-y-auto",children:(Y?Xc:Qc).map(te=>l.jsx("button",{type:"button",onClick:()=>{f(ce=>{const fe=[...ce];return fe[de]=te,fe}),M(null)},className:"w-full text-left px-3 py-2 text-sm hover:bg-muted transition-colors",children:te},te))})]})]}),p.length>1&&l.jsx("button",{type:"button",onClick:()=>f(te=>te.filter((ce,fe)=>fe!==de)),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:l.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:[l.jsx("path",{d:"M3 6h18"}),l.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),l.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]},de)),l.jsx("button",{type:"button",onClick:()=>f(X=>[...X,""]),className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),T.models!==void 0&&l.jsx("p",{className:"text-xs text-destructive",children:T.models})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex gap-1 border-b border-border",children:[l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("button",{type:"button",onClick:()=>m("anthropic"),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${g==="anthropic"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Anthropic Format"})}),l.jsx($e,{children:"Anthropic Messages API protocol"})]})}),l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("button",{type:"button",onClick:()=>m("openai"),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${g==="openai"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"OpenAI Format"})}),l.jsx($e,{children:"OpenAI Chat Completions API protocol"})]})})]}),T.format!==void 0&&l.jsx("p",{className:"text-xs text-destructive",children:T.format})]}),g==="anthropic"&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:"Anthropic Base URL"}),l.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:x,onChange:X=>{H(!0),y(X.target.value)},placeholder:"https://api.anthropic.com",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"}),T.anthropicBaseUrl!==void 0&&l.jsx("p",{className:"text-xs text-destructive",children:T.anthropicBaseUrl}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Anthropic-compatible endpoint URL. Leave empty if this provider does not support Anthropic format."})]}),g==="openai"&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:"OpenAI Base URL"}),l.jsx("input",{id:"provider-openai-base-url",type:"text",value:b,onChange:X=>{q(!0),k(X.target.value)},placeholder:"https://api.openai.com/v1",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"}),T.openaiBaseUrl!==void 0&&l.jsx("p",{className:"text-xs text-destructive",children:T.openaiBaseUrl}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"OpenAI-compatible endpoint URL. Leave empty if this provider does not support OpenAI format."})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),l.jsx("input",{id:"provider-api-docs-url",type:"text",value:S,onChange:X=>C(X.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"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),l.jsxs("div",{className:"sticky bottom-0 bg-card border-t flex gap-2 justify-end pt-2 pb-2",children:[l.jsx(Xe,{type:"button",variant:"outline",onClick:n,disabled:O,children:"Cancel"}),l.jsx(Xe,{type:"submit",disabled:O,children:O?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const Ni=ae({id:K(),name:K(),apiKey:K(),model:K().optional(),models:Pe(K()).min(1),format:lt(["anthropic","openai"]).optional(),baseUrl:K().optional(),anthropicBaseUrl:K().optional(),openaiBaseUrl:K().optional(),authHeader:lt(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:K().optional(),source:lt(["company","personal"]).optional(),createdAt:K(),updatedAt:K()}),Z4=lt(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),V4=ae({message:K(),type:Z4,details:K().optional(),hint:K().optional()}),W4=ae({type:lt(["text","thinking"]),text:K().optional(),thinking:K().optional()}),H4=ae({success:Qe(),error:V4.optional(),model:K().optional(),inputTokens:ve().optional(),outputTokens:ve().optional(),cacheCreationInputTokens:ve().optional(),cacheReadInputTokens:ve().optional(),latencyMs:ve().optional(),content:Pe(W4).optional(),rawResponse:K().optional(),streaming:Qe().optional(),streamingChunks:ae({chunks:Pe(Qu),truncated:Qe().default(!1)}).optional(),requestHeaders:Wt(K(),K()).optional()}),eu=Kt([H4,ae({notConfigured:Se(!0)}),ae({testing:Se(!0)})]),Io=ae({nonStreaming:eu,streaming:eu}),q4=ae({anthropic:Io,openai:Io}),K4=ae({anthropic:Io,openai:Io,models:Wt(K(),q4).optional(),testedAt:K().optional()});function G4(){return{anthropic:{nonStreaming:{testing:!0},streaming:{testing:!0}},openai:{nonStreaming:{testing:!0},streaming:{testing:!0}}}}function tu(e,t){const n=()=>({nonStreaming:{success:!1,error:{message:e,type:t}},streaming:{notConfigured:!0}});return{anthropic:n(),openai:n()}}const J4=ae({providerConfig:K()}),Y4=ae({success:Qe().optional(),imported:ve().optional(),message:K().optional(),errors:Pe(K()).optional()}),X4=30,Ws="Network error: could not reach the server. Is the proxy running?";function nu(e){return{name:e.name,apiKey:e.apiKey,models:e.models,anthropicBaseUrl:(e.anthropicBaseUrl?.length??0)>0?e.anthropicBaseUrl:void 0,openaiBaseUrl:(e.openaiBaseUrl?.length??0)>0?e.openaiBaseUrl:void 0,apiDocsUrl:(e.apiDocsUrl?.length??0)>0?e.apiDocsUrl:void 0,source:e.source}}function Q4({externalProviders:e,isLoading:t=!1,externalTestResults:n,externalTestingProviders:r,externalTestingTimeLeft:o,onProvidersMutate:s,onTestResultsChange:i,onTestingProvidersChange:a,onTestingTimeLeftChange:c}){const[u,d]=v.useState(!1),[h,p]=v.useState(),[f,g]=v.useState(null),[m,x]=v.useState({}),[y,b]=v.useState(new Set),[k,S]=v.useState({}),[C,j]=v.useState(null),[N,T]=v.useState(!1),[A,O]=v.useState(null),[L,E]=v.useState(!1),[M,w]=v.useState(!1),[D,H]=v.useState(null),[B,q]=v.useState("all"),Y=v.useRef(null),I=v.useRef(null),W=e??[],V=v.useMemo(()=>{const U=B==="all"?W:W.filter(J=>J.source===B);return B==="all"?[...U].sort((J,$)=>{const ne={personal:0,company:1};return(ne[J.source??""]??2)-(ne[$.source??""]??2)}):U},[W,B]),z=n??m,oe=r??y,X=o??k,de=c?(U,J)=>c(U,J):(U,J)=>{S(J===void 0?$=>{const ne={...$};return delete ne[U],ne}:$=>({...$,[U]:J}))};v.useEffect(()=>{(async()=>{try{const U=await fetch("/api/config/paths");if(U.ok){const J=await In(U,J4);j(J.providerConfig)}}catch{}})()},[]);const te=v.useCallback(U=>{I.current!==null&&clearTimeout(I.current),O(U),Y.current?.scrollTo({top:Y.current.scrollHeight,behavior:"smooth"}),I.current=setTimeout(()=>{O(null),I.current=null},2e3)},[]);v.useEffect(()=>()=>{I.current!==null&&clearTimeout(I.current)},[]);const ce=v.useCallback(()=>{s?.().catch(()=>{})},[s]),fe=v.useCallback((U,J)=>{i?i(U,J):x($=>({...$,[U]:J}))},[i]),ge=v.useCallback((U,J)=>{if(a){a(U,J);return}b($=>{const ne=new Set($);return J?ne.add(U):ne.delete(U),ne})},[a]),xe=v.useCallback(async U=>{fe(U,G4()),ge(U,!0);const J=new AbortController;let $=X4;de(U,$);const ne=setInterval(()=>{$--,de(U,$),$<=0&&(clearInterval(ne),J.abort())},1e3);try{const le=await fetch(`/api/providers/${U}/test`,{method:"POST",signal:J.signal});if(le.ok){const se=await In(le,K4);fe(U,se)}else fe(U,tu(`HTTP ${le.status}: ${le.statusText}`,"server_error"))}catch(le){le instanceof Error&&le.name==="AbortError"&&fe(U,tu("Request timed out","timeout"))}finally{clearInterval(ne),de(U,void 0),ge(U,!1)}},[de,fe,ge]);function Ee(U){(async()=>{try{const J=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(nu(U))});if(!J.ok){g(await no(J,"Failed to add provider"));return}const $=await In(J,Ni);d(!1),te($.id),ce(),await xe($.id)}catch{g(Ws)}})()}function Oe(U){h&&(async()=>{try{const J=await fetch(`/api/providers/${h.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(nu(U))});if(!J.ok){g(await no(J,"Failed to update provider"));return}const $=await In(J,Ni);p(void 0),te($.id),ce(),((U.apiKey??"")!==(h.apiKey??"")||JSON.stringify(U.models)!==JSON.stringify(h.models)||(U.anthropicBaseUrl??"")!==(h.anthropicBaseUrl??"")||(U.openaiBaseUrl??"")!==(h.openaiBaseUrl??""))&&await xe($.id)}catch{g(Ws)}})()}function _(U){H(U),w(!0)}function ee(){const U=D;U!==null&&(async()=>{let J;try{J=await fetch(`/api/providers/${U}`,{method:"DELETE"})}catch{g(Ws);return}if(!J.ok){g(await no(J,"Failed to delete provider"));return}ce()})()}const G=v.useRef(null);function P(U){const J="/api/providers/export";(async()=>{try{const $=await fetch(J);if(!$.ok){g("Failed to export providers");return}const ne=await $.blob(),le=URL.createObjectURL(ne),se=document.createElement("a");se.href=le,se.download=$.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(se),se.click(),document.body.removeChild(se),URL.revokeObjectURL(le)}catch{g("Failed to export providers")}})()}function R(){G.current?.click()}function F(U){const J=U.target.files?.[0];J&&(async()=>{try{const $=await J.text(),ne=await fetch("/api/providers/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)}),le=await In(ne,Y4);ne.ok&&le.imported!==void 0&&le.imported>0?(ce(),g(null)):le.errors&&le.errors.length>0?g(le.errors.join("; ")):g(le.message??"Import failed")}catch{g("Failed to import providers")}U.target.value=""})()}return t?l.jsx("div",{className:"flex items-center justify-center py-8",children:l.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):u||h?l.jsxs("div",{className:"space-y-4",children:[l.jsx("div",{className:"flex items-center justify-between sticky top-0 bg-background z-10 pb-2",children:l.jsx("h3",{className:"text-lg font-medium",children:h?"Edit Provider":"Add New Provider"})}),l.jsx(U4,{provider:h,onSubmit:h?Oe:Ee,onCancel:()=>{d(!1),p(void 0)}})]}):l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between sticky top-0 z-10 bg-background pb-2",children:[l.jsx("h3",{className:"text-lg font-medium",children:"Providers"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs(Xe,{variant:"outline",size:"sm",onClick:()=>P(),className:"gap-1 hover:bg-muted",children:[l.jsx(Zi,{className:"size-3"}),"Export"]})}),l.jsx($e,{children:"Download providers as JSON for backup or sharing"})]})}),l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs(Xe,{variant:"outline",size:"sm",onClick:R,className:"gap-1 hover:bg-muted",children:[l.jsx(Tv,{className:"size-3"}),"Import"]})}),l.jsx($e,{children:"Import providers from an exported JSON file"})]})}),l.jsx("input",{type:"file",ref:G,accept:".json",onChange:F,style:{display:"none"}}),l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs(Xe,{variant:"outline",size:"sm",onClick:()=>E(!0),className:"gap-1",children:[l.jsx(vv,{className:"size-3"}),"Scan"]})}),l.jsx($e,{children:"Detect and import provider configs from Claude Code and OpenCode"})]})}),l.jsxs(Xe,{onClick:()=>d(!0),size:"sm",className:"gap-1",children:[l.jsx(ho,{className:"size-4"}),"Add Provider"]})]})]}),C!==null&&l.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground bg-muted/30 rounded-md px-3 py-2",children:[l.jsx("span",{className:"shrink-0",children:"Config:"}),l.jsx("span",{className:"font-mono truncate",title:C,children:C}),l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("button",{type:"button",onClick:()=>{window.navigator.clipboard.writeText(C).then(()=>{T(!0),setTimeout(()=>T(!1),2e3)})},className:"shrink-0 ml-auto text-muted-foreground hover:text-foreground transition-colors",children:N?l.jsx(Gt,{className:"size-3 text-green-500"}):l.jsx(wn,{className:"size-3"})})}),l.jsx($e,{children:"Copy config file path to clipboard"})]})})]}),f!==null&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive bg-destructive/10 rounded-md px-3 py-2",children:[l.jsx(_r,{className:"size-4 shrink-0"}),f]}),W.length===0?l.jsxs("div",{className:"text-center py-12 space-y-3",children:[l.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),l.jsxs(Xe,{onClick:()=>d(!0),variant:"outline",size:"sm",children:[l.jsx(ho,{className:"size-4"}),"Add Your First Provider"]})]}):l.jsxs("div",{className:"space-y-3",children:[l.jsx("div",{className:"flex gap-1 border-b border-border",children:["all","personal","company"].map(U=>l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("button",{type:"button",onClick:()=>q(U),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${B===U?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:U==="all"?"All":U==="personal"?"Personal":"Company"})}),l.jsx($e,{children:U==="all"?"Show all providers":U==="personal"?"Providers you configured yourself":"Providers set by your organization"})]})},U))}),l.jsx("div",{ref:Y,className:"space-y-3",children:V.map(U=>l.jsx($4,{provider:U,testResults:z[U.id],isTesting:oe.has(U.id),testingTimeLeft:X[U.id],isHighlighted:U.id===A,onEdit:J=>p(J),onDelete:_,onTest:J=>{xe(J)}},U.id))})]}),l.jsx(P4,{open:L,onOpenChange:E,onImportComplete:()=>{s!==void 0&&s()}}),l.jsx(Hh,{open:M,onOpenChange:w,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:ee})]})}async function eT(e){return Ar(e,Ni.array(),void 0,t=>`Failed to fetch ${e}: ${t.status}`)}function tT(){const e=zi("/api/providers",eT,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function nT(){const[e,t]=v.useState(!1),[n,r]=v.useState("providers"),{providers:o,isLoading:s,mutate:i}=tT(),[a,c]=v.useState({}),[u,d]=v.useState(new Set),[h,p]=v.useState({}),f=v.useCallback((x,y)=>{c(b=>({...b,[x]:y}))},[]),g=v.useCallback((x,y)=>{d(b=>{const k=new Set(b);return y?k.add(x):k.delete(x),k})},[]),m=v.useCallback((x,y)=>{p(b=>{if(y===void 0){const k={...b};return delete k[x],k}return{...b,[x]:y}})},[]);return l.jsxs(rs,{open:e,onOpenChange:t,children:[l.jsx(RS,{asChild:!0,children:l.jsxs(Xe,{variant:"ghost",size:"icon",className:"size-8",children:[l.jsx(_v,{className:"size-4"}),l.jsx("span",{className:"sr-only",children:"Settings"})]})}),l.jsxs(os,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[l.jsx(ss,{children:l.jsx(is,{children:"Settings"})}),l.jsxs(Pn,{value:n,onValueChange:r,className:"flex-1 overflow-hidden",children:[l.jsxs(On,{children:[l.jsx(tt,{value:"providers",children:"Providers"}),l.jsx(tt,{value:"proxy",children:"Proxy"})]}),l.jsxs("div",{className:"mt-4 overflow-y-auto flex-1 pr-3",children:[l.jsx(nt,{value:"providers",children:l.jsx(Q4,{externalProviders:o,isLoading:s,externalTestResults:a,externalTestingProviders:u,externalTestingTimeLeft:h,onProvidersMutate:()=>i(),onTestResultsChange:f,onTestingProvidersChange:g,onTestingTimeLeftChange:m})}),l.jsx(nt,{value:"proxy",children:l.jsx(rT,{})})]})]})]})]})}function rT(){const{strip:e,isLoading:t,setStrip:n}=ed(),[r,o]=v.useState(null),[s,i]=v.useState(!1),a=v.useCallback(async c=>{o(null),i(!0);try{await n(c)}catch(u){o(u instanceof Error?u.message:String(u))}finally{i(!1)}},[n]);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:["When enabled, the proxy strips the synthetic ",l.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 ",l.jsx("code",{children:"LLM_INSPECTOR_STRIP_CLAUDE_CODE_BILLING_HEADER"})," environment variable; your choice is persisted to ",l.jsx("code",{children:"config.json"})," and overrides the env var for subsequent requests."]})]}),l.jsxs("label",{className:"flex items-center gap-3",children:[l.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:t||s,onChange:c=>{a(c.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),l.jsx("span",{className:"text-sm",children:t?"Loading…":e?"Stripping enabled":"Stripping disabled"})]}),r!==null&&l.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",r]})]})}function oT(e){const t=new Map;for(const n of e){const r=n.logs;for(let o=1;o<r.length;o++){const s=r[o-1],i=r[o];s===void 0||i===void 0||t.set(i.id,{creation:ru(s.cacheCreationInputTokens,i.cacheCreationInputTokens),read:ru(s.cacheReadInputTokens,i.cacheReadInputTokens)})}}return t}function ru(e,t){return t===null||e===null?null:t>e?{direction:"up",delta:t-e}:t<e?{direction:"down",delta:e-t}:null}const sT="";function mr(e){if(e.length===0)return sT;let t="";for(let n=0;n<e.length;n++){const r=e[n];r!==void 0&&(typeof r=="number"?t+=`[${r}]`:n===0?t+=r:t+=`.${r}`)}return t}function iT(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ou(e){if(typeof e=="string")try{return zo(JSON.parse(e))}catch{return{kind:"primitive",value:e}}return zo(e)}function zo(e){if(e===null)return{kind:"primitive",value:null};if(typeof e=="string")return{kind:"primitive",value:e};if(typeof e=="number")return{kind:"primitive",value:e};if(typeof e=="boolean")return{kind:"primitive",value:e};if(Array.isArray(e))return{kind:"array",value:e.map(t=>zo(t))};if(iT(e)){const t={};for(const n of Object.keys(e).sort())t[n]=zo(e[n]);return{kind:"object",value:t}}return{kind:"primitive",value:null}}function aT(e,t){const n=[];return Ti([],e,t,n),n}function Ti(e,t,n,r){const o=mr(e);if(Ai(t,n)){r.push({kind:"equal",path:o,value:t});return}if(t.kind!==n.kind){r.push({kind:"changed",path:o,left:t,right:n});return}if(t.kind==="primitive"&&n.kind==="primitive"){r.push({kind:"changed",path:o,left:t,right:n});return}if(t.kind==="object"&&n.kind==="object"){const s=Object.keys(t.value),i=Object.keys(n.value),a=new Set(i);for(const c of s){const u=t.value[c];if(u!==void 0)if(!a.has(c))r.push({kind:"removed",path:mr([...e,c]),value:u});else{const d=n.value[c];if(d===void 0)continue;Ti([...e,c],u,d,r)}}for(const c of i){if(s.includes(c))continue;const u=n.value[c];u!==void 0&&r.push({kind:"added",path:mr([...e,c]),value:u})}return}if(t.kind==="array"&&n.kind==="array"){const s=Math.min(t.value.length,n.value.length);for(let i=0;i<s;i++){const a=t.value[i],c=n.value[i];a===void 0||c===void 0||Ti([...e,i],a,c,r)}for(let i=s;i<n.value.length;i++){const a=n.value[i];a!==void 0&&r.push({kind:"added",path:mr([...e,i]),value:a})}for(let i=s;i<t.value.length;i++){const a=t.value[i];a!==void 0&&r.push({kind:"removed",path:mr([...e,i]),value:a})}}}function Ai(e,t){if(e.kind!==t.kind)return!1;if(e.kind==="primitive"&&t.kind==="primitive")return e.value===t.value;if(e.kind==="array"&&t.kind==="array"){if(e.value.length!==t.value.length)return!1;for(let n=0;n<e.value.length;n++){const r=e.value[n],o=t.value[n];if(r===void 0||o===void 0||!Ai(r,o))return!1}return!0}if(e.kind==="object"&&t.kind==="object"){const n=Object.keys(e.value),r=Object.keys(t.value);if(n.length!==r.length)return!1;for(const o of n){const s=e.value[o],i=t.value[o];if(s===void 0||i===void 0||!Ai(s,i))return!1}return!0}return!1}function Et(e,t=80){let n;switch(e.kind){case"primitive":n=e.value===null?"null":JSON.stringify(e.value);break;case"array":n=`[… ${e.value.length} items]`;break;case"object":n=`{… ${Object.keys(e.value).length} keys}`;break}return n.length>t&&(n=`${n.slice(0,t-1)}…`),n}function lo(e,t=2){return JSON.stringify(Ii(e),null,t)}function Ii(e){switch(e.kind){case"primitive":return e.value;case"array":return e.value.map(Ii);case"object":{const t={};for(const[n,r]of Object.entries(e.value))t[n]=Ii(r);return t}}}function su(e){if(e==="")return"";for(let t=e.length-1;t>=0;t--){const n=e[t];if(n==="."||n==="[")return e.substring(0,t)}return""}function iu(e){return e.kind==="equal"&&(e.value.kind==="object"||e.value.kind==="array")}function lT(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(r!==void 0&&iu(r)){const o=su(r.path);let s=n+1;for(;s<e.length;){const i=e[s];if(i===void 0||!iu(i)||su(i.path)!==o)break;s++}if(s-n>1){const i=[];for(let a=n;a<s;a++){const c=e[a];c!==void 0&&c.kind==="equal"&&i.push(c)}t.push({kind:"equal-run",ops:i}),n=s;continue}}r!==void 0&&t.push({kind:"single",op:r}),n++}return t}const Wp={added:{icon:ho,accent:"text-emerald-600 dark:text-emerald-400",bg:"bg-emerald-500/5 hover:bg-emerald-500/10",border:"border-l-emerald-500",label:"ADDED"},removed:{icon:Hi,accent:"text-rose-600 dark:text-rose-400",bg:"bg-rose-500/5 hover:bg-rose-500/10",border:"border-l-rose-500",label:"REMOVED"},changed:{icon:qi,accent:"text-amber-600 dark:text-amber-400",bg:"bg-amber-500/5 hover:bg-amber-500/10",border:"border-l-amber-500",label:"CHANGED"},equal:{icon:Ky,accent:"text-muted-foreground/70",bg:"bg-muted/20 hover:bg-muted/30",border:"border-l-muted-foreground/20",label:"EQUAL"}};function cT({ops:e,expanded:t,onToggle:n}){const r=e[0],o=e[e.length-1];if(r===void 0||o===void 0)return l.jsx("div",{className:"text-muted-foreground/40 text-xs",children:"—"});const s=r.path,i=o.path,a=e.length===1?s:`${s} … ${i}`,c=r.value.kind==="array"?`${e.length} equal arrays`:r.value.kind==="object"?`${e.length} equal objects`:"equal",u=Wp.equal;return l.jsxs("div",{className:he("border-l-4 rounded-sm",u.border,u.bg),children:[l.jsxs("button",{type:"button",onClick:n,className:"w-full text-left flex items-center gap-2 px-3 py-1.5 text-xs text-muted-foreground cursor-pointer",children:[l.jsx(bt,{className:he("size-3 transition-transform shrink-0",t&&"rotate-90")}),l.jsx(u.icon,{className:he("size-3 shrink-0",u.accent)}),l.jsx("span",{className:"font-mono truncate flex-1",title:`${s} … ${i}`,children:a}),l.jsx("span",{className:he("text-[10px] uppercase tracking-wider shrink-0",u.accent),children:u.label}),l.jsxs("span",{className:"text-muted-foreground/60 shrink-0",children:["(",c,")"]})]}),t&&l.jsx("div",{className:"ml-5 mt-1 mb-2 space-y-2 pr-2",children:e.map(d=>l.jsxs("div",{className:"border border-border/50 rounded p-2 bg-muted/20",children:[l.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-1",children:d.path}),l.jsx(fn,{text:lo(d.value),defaultExpandDepth:2})]},d.path))})]})}function uT({op:e,idx:t,copiedPath:n,onCopyPath:r,expanded:o,onToggle:s}){const i=Wp[e.kind],a=i.icon,c=e.kind==="added"||e.kind==="removed"?e.value.kind==="object"||e.value.kind==="array":e.kind==="changed"?e.left.kind==="object"||e.left.kind==="array"||e.right.kind==="object"||e.right.kind==="array":!1,u=e.kind==="changed"?[{text:Et(e.left,400),tone:"text-rose-700 dark:text-rose-300 line-through"},{text:Et(e.right,400),tone:"text-emerald-700 dark:text-emerald-300"}]:e.kind==="removed"?[{text:Et(e.value,400),tone:"text-rose-700 dark:text-rose-300 line-through"}]:e.kind==="added"?[{text:Et(e.value,400),tone:"text-emerald-700 dark:text-emerald-300"}]:[{text:Et(e.value,400),tone:"text-muted-foreground"}],d=n===e.path&&e.path!=="";return l.jsxs("div",{"data-diff-idx":t,"data-diff-kind":e.kind,className:he("border-l-4 rounded-sm px-3 py-2 my-0.5 transition-colors",i.border,i.bg),children:[l.jsxs("button",{type:"button",onClick:s,disabled:!c,className:he("w-full flex items-center gap-2 text-xs text-left rounded-sm",c?"cursor-pointer":"cursor-default"),"aria-expanded":c?o:void 0,"aria-label":c?o?`Collapse ${e.path||"root"}`:`Expand ${e.path||"root"}`:void 0,children:[c?l.jsx(bt,{className:he("size-3 shrink-0 transition-transform",i.accent,o&&"rotate-90")}):l.jsx("span",{className:"size-3 shrink-0","aria-hidden":"true"}),l.jsx(a,{className:he("size-3.5 shrink-0",i.accent),strokeWidth:2.5}),l.jsx("span",{className:"font-mono truncate flex-1 min-w-0",title:e.path||"(root)",children:e.path===""?"(root)":e.path}),l.jsx("span",{className:he("text-[9px] font-bold uppercase tracking-wider shrink-0 px-1.5 py-0.5 rounded",i.accent,e.kind==="equal"?"bg-muted/40":"bg-background/60"),children:i.label}),e.path!==""&&l.jsx("span",{role:"button",tabIndex:0,onClick:h=>{h.stopPropagation(),r(e.path)},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.stopPropagation(),h.preventDefault(),r(e.path))},className:he("shrink-0 p-1 rounded transition-colors cursor-pointer inline-flex items-center justify-center",d?"text-emerald-500":"text-muted-foreground/50 hover:text-foreground hover:bg-muted"),"aria-label":d?"Copied":"Copy path",title:d?"Copied!":"Copy path",children:d?l.jsx(Gt,{className:"size-3"}):l.jsx(wn,{className:"size-3"})})]}),u.map((h,p)=>l.jsx("div",{className:he("font-mono text-xs mt-1 break-all pl-5",h.tone),children:h.text},p)),l.jsx("div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:o&&c?"2000px":"0"},"aria-hidden":!o,children:o&&c&&e.kind!=="equal"?l.jsx(dT,{op:e}):null})]})}function dT({op:e}){if(e.kind==="added"||e.kind==="removed")return l.jsx("div",{className:"pl-5 mt-2 border border-border/50 rounded p-2 bg-muted/20",children:l.jsx(fn,{text:lo(e.value),defaultExpandDepth:2})});const t=e.left.kind==="object"||e.left.kind==="array",n=e.right.kind==="object"||e.right.kind==="array";return!t&&!n?l.jsx("div",{className:"pl-5 mt-2 text-xs text-muted-foreground/70 italic",children:"Primitive values are shown inline above."}):l.jsxs("div",{className:"pl-5 mt-2 grid grid-cols-1 md:grid-cols-2 gap-2",children:[l.jsxs("div",{className:"border border-rose-500/30 rounded p-2 bg-rose-500/5",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-wider text-rose-500 mb-1",children:"Old"}),l.jsx(fn,{text:lo(e.left),defaultExpandDepth:2})]}),l.jsxs("div",{className:"border border-emerald-500/30 rounded p-2 bg-emerald-500/5",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-wider text-emerald-500 mb-1",children:"New"}),l.jsx(fn,{text:lo(e.right),defaultExpandDepth:2})]})]})}function fT({counts:e,onJumpTo:t}){const n=e.added+e.removed+e.changed;return l.jsxs("div",{className:"px-4 py-2 border-b border-border bg-muted/20 flex items-center gap-2 text-xs flex-wrap",children:[l.jsxs("span",{className:"text-muted-foreground font-medium",children:[n," ",n===1?"change":"changes"]}),l.jsxs("button",{type:"button",onClick:()=>t("removed"),disabled:e.removed===0,className:he("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.removed>0?"border-rose-500/40 text-rose-600 dark:text-rose-400 bg-rose-500/10 hover:bg-rose-500/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.removed>0?"Jump to first removed":"No removals",children:[l.jsx(Hi,{className:"size-3"}),e.removed," removed"]}),l.jsxs("button",{type:"button",onClick:()=>t("added"),disabled:e.added===0,className:he("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.added>0?"border-emerald-500/40 text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 hover:bg-emerald-500/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.added>0?"Jump to first added":"No additions",children:[l.jsx(ho,{className:"size-3"}),e.added," added"]}),l.jsxs("button",{type:"button",onClick:()=>t("changed"),disabled:e.changed===0,className:he("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.changed>0?"border-amber-500/40 text-amber-600 dark:text-amber-400 bg-amber-500/10 hover:bg-amber-500/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.changed>0?"Jump to first changed":"No changes",children:[l.jsx(qi,{className:"size-3"}),e.changed," changed"]})]})}function hT({mode:e,onChange:t}){return l.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[l.jsxs("button",{type:"button",onClick:()=>t("unified"),"aria-pressed":e==="unified",className:he("flex items-center gap-1 px-2 py-1 text-xs transition-colors cursor-pointer",e==="unified"?"bg-muted text-foreground":"hover:bg-muted/50 text-muted-foreground"),title:"Unified view (single column, emphasized diffs)",children:[l.jsx(ld,{className:"size-3"}),"Unified"]}),l.jsxs("button",{type:"button",onClick:()=>t("split"),"aria-pressed":e==="split",className:he("flex items-center gap-1 px-2 py-1 text-xs transition-colors border-l border-border cursor-pointer",e==="split"?"bg-muted text-foreground":"hover:bg-muted/50 text-muted-foreground"),title:"Split view (path | left | right)",children:[l.jsx(rd,{className:"size-3"}),"Split"]})]})}function au({log:e,side:t}){const n=_o(e);return l.jsxs("div",{className:"flex-1 min-w-0 space-y-1 text-xs",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(xt,{variant:"outline",className:he("text-[10px] px-1.5 py-0 h-5 font-mono shrink-0",t==="left"?"border-rose-500/40 text-rose-400":"border-emerald-500/40 text-emerald-400"),children:t==="left"?"← Left":"Right →"}),l.jsxs("span",{className:"font-mono text-blue-400/80",children:["#",e.id]}),e.model!==null&&l.jsx("span",{className:"font-mono text-muted-foreground truncate",children:e.model})]}),l.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground font-mono",children:[e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&l.jsxs("span",{className:"text-emerald-400",children:["Cache +",qe(e.cacheCreationInputTokens)]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&l.jsxs("span",{className:"text-purple-400",children:["Cache ~",qe(e.cacheReadInputTokens)]}),l.jsx("span",{className:"truncate",title:e.timestamp,children:e.timestamp})]}),l.jsxs("div",{className:"text-muted-foreground/70 font-mono truncate",title:n,children:["session: ",n]})]})}function pT({left:e,right:t,onClose:n}){const r=v.useMemo(()=>{const j=Ao(Nr(e)).analyzeRequest(e.rawRequestBody),N=Ao(Nr(t)).analyzeRequest(t.rawRequestBody),T=ou(j.comparisonValue),A=ou(N.comparisonValue);return aT(T,A)},[e.apiFormat,e.path,e.rawRequestBody,t.apiFormat,t.path,t.rawRequestBody]),o=v.useMemo(()=>lT(r),[r]),s=v.useMemo(()=>{let j=0,N=0,T=0;for(const A of o)if(A.kind==="single")switch(A.op.kind){case"added":j++;break;case"removed":N++;break;case"changed":T++;break}return{added:j,removed:N,changed:T}},[o]),[i,a]=v.useState(new Set),c=j=>{a(N=>{const T=new Set(N);return T.has(j)?T.delete(j):T.add(j),T})},[u,d]=v.useState(new Set),h=j=>{d(N=>{const T=new Set(N);return T.has(j)?T.delete(j):T.add(j),T})};v.useEffect(()=>{d(new Set)},[e.id,t.id]);const[p,f]=v.useState("unified"),g=v.useRef(null),[m,x]=v.useState(null),y=v.useRef(null),b=j=>{window.navigator.clipboard.writeText(j).then(()=>{x(j),y.current!==null&&clearTimeout(y.current),y.current=setTimeout(()=>x(null),1500)})};v.useEffect(()=>()=>{y.current!==null&&clearTimeout(y.current)},[]);const k=j=>{const N=o.findIndex(O=>O.kind==="single"&&O.op.kind===j);if(N===-1)return;const T=g.current;if(T===null)return;const A=T.querySelector(`[data-diff-idx="${N}"]`);A!==null&&A.scrollIntoView({behavior:"smooth",block:"center"})};v.useEffect(()=>{const j=T=>{T.key==="Escape"&&n()};document.addEventListener("keydown",j);const N=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",j),document.body.style.overflow=N}},[n]);const S=_o(e)===_o(t),C=r.length===1&&r[0]?.kind==="equal";return l.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",role:"dialog","aria-modal":"true","aria-label":"Compare two log requests",children:[l.jsx("button",{type:"button",onClick:n,"aria-label":"Close compare drawer",className:"absolute inset-0 bg-black/40 cursor-default",tabIndex:-1}),l.jsxs("div",{className:he("relative bg-background border-l border-border shadow-xl","w-full md:w-[70vw] max-w-[1100px] flex flex-col h-full"),onClick:j=>j.stopPropagation(),onKeyDown:j=>j.stopPropagation(),children:[l.jsxs("div",{className:"flex items-start gap-4 px-4 py-3 border-b border-border",children:[l.jsxs("div",{className:"flex-1 flex gap-4 min-w-0",children:[l.jsx(au,{log:e,side:"left"}),l.jsx(au,{log:t,side:"right"})]}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[l.jsx(hT,{mode:p,onChange:f}),l.jsx("button",{type:"button",onClick:n,"aria-label":"Close",className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted cursor-pointer",children:l.jsx(Ki,{className:"size-4"})})]})]}),!S&&l.jsx("div",{className:"px-4 py-1.5 text-xs text-amber-400 bg-amber-500/10 border-b border-border",children:"Heads up: the two selected logs are from different sessions."}),C?l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto flex items-center justify-center text-muted-foreground text-sm",children:"The two Request payloads are identical."}):l.jsxs(l.Fragment,{children:[l.jsx(fT,{counts:s,onJumpTo:k}),l.jsx("div",{ref:g,className:"flex-1 min-h-0 overflow-y-auto",children:p==="unified"?l.jsx("div",{className:"px-3 py-2 space-y-0.5",children:o.map((j,N)=>{if(j.kind==="equal-run")return l.jsx(cT,{ops:j.ops,expanded:i.has(N),onToggle:()=>c(N)},`r${N}`);const T=j.op;return l.jsx(uT,{op:T,idx:N,copiedPath:m,onCopyPath:b,expanded:u.has(N),onToggle:()=>h(N)},`o${N}`)})}):l.jsx(mT,{grouped:o,left:e,right:t})})]})]})]})}function mT({grouped:e,left:t,right:n}){return l.jsxs("div",{className:"grid grid-cols-[200px_1fr_1fr] gap-x-2 gap-y-0.5 px-3 py-2 text-xs",children:[l.jsxs("div",{className:"grid grid-cols-[200px_1fr_1fr] gap-x-2 col-span-3 pb-2 mb-2 border-b border-border text-[10px] uppercase tracking-wider text-muted-foreground",children:[l.jsx("span",{children:"Path"}),l.jsxs("span",{children:["Left (Log #",t.id,")"]}),l.jsxs("span",{children:["Right (Log #",n.id,")"]})]}),e.map((r,o)=>{if(r.kind==="equal-run")return l.jsxs("div",{className:"col-span-3 px-2 py-1 text-xs text-muted-foreground/60",children:[r.ops.length," equal siblings collapsed — switch to Unified to expand"]},o);const s=r.op;return s.kind==="equal"?l.jsxs("div",{className:"col-span-3 grid grid-cols-[200px_1fr_1fr] gap-x-2 px-2 py-0.5 text-muted-foreground",children:[l.jsx("span",{className:"font-mono text-xs truncate",title:s.path,children:s.path}),l.jsx("span",{className:"font-mono text-xs break-all opacity-60",children:Et(s.value,200)}),l.jsx("span",{className:"font-mono text-xs break-all opacity-60",children:Et(s.value,200)})]},o):s.kind==="added"?l.jsxs("div",{className:"col-span-3 px-2 py-1 rounded text-xs border-l-2 border-l-emerald-400/70 bg-emerald-500/5",children:[l.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-0.5",children:s.path}),l.jsxs("div",{className:"font-mono break-all text-emerald-300/90",children:["+ ",Et(s.value,400)]})]},o):s.kind==="removed"?l.jsxs("div",{className:"col-span-3 px-2 py-1 rounded text-xs border-l-2 border-l-rose-400/70 bg-rose-500/5",children:[l.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-0.5",children:s.path}),l.jsxs("div",{className:"font-mono break-all text-rose-300/90 line-through",children:["− ",Et(s.value,400)]})]},o):l.jsxs("div",{className:"col-span-3 px-2 py-1 rounded text-xs border-l-2 border-l-amber-400/70 bg-amber-500/5",children:[l.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-1",children:s.path}),l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsx("div",{className:"font-mono text-rose-300/90 break-all line-through",children:Et(s.left,400)}),l.jsx("div",{className:"font-mono text-emerald-300/90 break-all",children:Et(s.right,400)})]})]},o)})]})}function gT(e){return e.length<=30?e:e.slice(0,12)+"…"+e.slice(-12)}function xT(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 yT({command:e}){const[t,n]=v.useState(!1),r=v.useCallback(()=>{window.navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},[e]);return l.jsxs("div",{className:"inline-flex items-center gap-2 bg-muted rounded-md px-3 py-2",children:[l.jsx("pre",{className:"text-blue-500 font-mono text-sm m-0",children:e}),l.jsx("button",{type:"button",onClick:r,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 cursor-pointer","aria-label":"Copy command",children:t?l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M20 6 9 17l-5-5"})}):l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),l.jsx("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})]})}function vT({logs:e,sessions:t,models:n,selectedSession:r,selectedModel:o,onSessionChange:s,onModelChange:i,onClearAll:a,onClearGroup:c,viewMode:u,onViewModeChange:d,strip:h}){const{totalIn:p,totalOut:f}=v.useMemo(()=>xT(e),[e]),[g,m]=v.useState(!1),[x,y]=v.useState(null),[b,k]=v.useState("hidden");v.useEffect(()=>{const E=50+So.length*400,M=setTimeout(()=>k("playing"),50),w=setTimeout(()=>k("done"),E);return()=>{clearTimeout(M),clearTimeout(w)}},[]);const S=v.useCallback(async()=>{m(!0);try{await qv(e)}finally{m(!1)}},[e]);v.useEffect(()=>{y(null)},[r,o]);const C=v.useCallback(()=>{y(null)},[]),j=v.useMemo(()=>BS(e),[e]),N=v.useMemo(()=>oT(j),[j]),T=v.useMemo(()=>w4(j),[j]),A=v.useCallback(O=>{const L=T.get(O.id);L!==void 0&&y([L,O])},[T]);return l.jsxs("div",{className:"max-w-[1200px] mx-auto flex flex-col h-screen",style:{maxHeight:"100vh"},children:[l.jsxs("div",{className:"flex items-end px-6 pt-6 pb-8 relative",children:[l.jsxs("h1",{className:"text-lg font-bold flex items-end gap-2 absolute left-1/2 -translate-x-1/2 whitespace-nowrap",children:[l.jsxs("span",{className:"flex items-end gap-1 group cursor-default","aria-hidden":"true",children:[l.jsx(S4,{className:"size-10 text-amber-500 transition-all duration-300 group-hover:scale-125 group-hover:-translate-y-1.5"}),l.jsx("span",{className:"flex items-end gap-0.5",children:So.map((O,L)=>{const E=["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"][L],M=b==="hidden"?"opacity-0 scale-0":b==="playing"?"animate-crab-piano-pop":"";return l.jsx(O,{className:`size-5 ${E} transition-all duration-300 ease-out group-hover:scale-125 group-hover:-translate-y-1 ${M}`,style:{transitionDelay:`${L*50}ms`,...b==="playing"?{animationDelay:`${L*400}ms`}:{}}},L)})})]}),l.jsxs("span",{className:"flex items-baseline gap-2",children:["LLM Inspector",l.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["v",Gv.version]})]})]}),l.jsx("div",{className:"ml-auto",children:l.jsx(nT,{})})]}),l.jsxs("div",{className:"flex items-center gap-3 px-6 mb-4",children:[l.jsxs(Kc,{value:r,onValueChange:s,children:[l.jsx(Jc,{className:"flex-1 max-w-[350px] text-xs",children:l.jsx(Gc,{placeholder:"All sessions"})}),l.jsxs(Yc,{children:[l.jsx(eo,{value:"__all__",children:"All sessions"}),t.map(O=>l.jsx(eo,{value:O,children:gT(O)},O))]})]}),l.jsxs(Kc,{value:o,onValueChange:i,children:[l.jsx(Jc,{className:"flex-1 max-w-[250px] text-xs",children:l.jsx(Gc,{placeholder:"All models"})}),l.jsxs(Yc,{children:[l.jsx(eo,{value:"__all__",children:"All models"}),n.map(O=>l.jsx(eo,{value:O,children:O},O))]})]}),l.jsxs("div",{className:"flex items-center border border-border rounded-md overflow-hidden",children:[l.jsx("button",{type:"button",onClick:()=>d("simple"),className:`px-2 py-1 cursor-pointer transition-colors text-xs ${u==="simple"?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/50"}`,children:"Simple"}),l.jsx("button",{type:"button",onClick:()=>d("full"),className:`px-2 py-1 cursor-pointer transition-colors text-xs ${u==="full"?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/50"}`,children:"Full"})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("span",{className:"text-muted-foreground text-xs font-mono",children:[e.length," request",e.length!==1?"s":"",p>0||f>0?` · ${p.toLocaleString()} in / ${f.toLocaleString()} out`:""]}),e.length>0&&l.jsx("button",{type:"button",onClick:()=>{S()},disabled:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1",title:"Export all logs as JSON ZIP",children:g?l.jsx("span",{children:"Exporting..."}):l.jsxs(l.Fragment,{children:[l.jsx(Zi,{className:"size-3"}),l.jsx("span",{children:"Export"})]})}),l.jsx("button",{type:"button",onClick:a,className:"text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:"Clear all logs",children:"Clear"})]}),l.jsx("div",{className:"flex-1 min-h-0 px-6 pb-6",children:e.length===0?l.jsxs("div",{className:"text-center text-muted-foreground py-16 space-y-4",children:[l.jsx("p",{className:"text-sm",children:"No requests captured yet."}),l.jsx("p",{className:"text-xs",children:"Route AI coding tools through the proxy:"}),l.jsx(yT,{command:"LLM_BASE_URL=http://localhost:25947/proxy <your-tool>"})]}):l.jsx("div",{className:"overflow-y-auto h-full flex flex-col gap-2",children:j.map(O=>l.jsx(_4,{group:O,viewMode:u,strip:h,cacheTrends:N,onCompareWithPrevious:A,comparisonPredecessors:T,onClearGroup:c,standalone:j.length===1},O.id))})}),x!==null&&l.jsx(pT,{left:x[0],right:x[1],onClose:C})]})}const bT=Kt([ae({type:Se("init"),logs:Pe(ll)}),ae({type:Se("update"),log:ll})]);function Hs(e){const t=new Set;for(const n of e)n.sessionId!==null&&n.sessionId!==""&&t.add(n.sessionId);return[...t]}function qs(e){const t=new Set;for(const n of e)n.model!==null&&n.model!==""&&t.add(n.model);return[...t]}function wT(e,t,n){return t==="__all__"&&n==="__all__"?e:e.filter(r=>!(t!=="__all__"&&r.sessionId!==t||n!=="__all__"&&r.model!==n))}const kT=50;function _T(){const[e,t]=v.useState([]),[n,r]=v.useState([]),[o,s]=v.useState([]),[i,a]=v.useState("__all__"),[c,u]=v.useState("__all__"),[d,h]=v.useState("simple"),[p,f]=v.useState(null),g=v.useRef(null),m=v.useRef(null),x=v.useRef(new Map),y=v.useRef([]),b=v.useRef([]),k=v.useRef(null),S=v.useMemo(()=>wT(e,i,c),[e,i,c]),C=v.useCallback(()=>{k.current=null;const L=b.current;b.current=[],L.length!==0&&t(E=>{let M=E,w=!1,D=!1;for(const H of L){const B=x.current.get(H.id);B!==void 0?M=[...M.slice(0,B),H,...M.slice(B+1)]:(x.current.set(H.id,M.length),M=[...M,H]),H.sessionId!==null&&H.sessionId!==""&&!n.includes(H.sessionId)&&(w=!0),H.model!==null&&H.model!==""&&!o.includes(H.model)&&(D=!0)}return y.current=M,w&&r(H=>Hs(M)),D&&s(H=>qs(M)),M})},[n,o]),j=v.useCallback(L=>{b.current.push(L),k.current===null&&(k.current=setTimeout(C,kT))},[C]),N=v.useCallback(()=>{g.current&&g.current.close();const L=new EventSource("/api/logs/stream");g.current=L,L.onmessage=E=>{try{const M=String(E.data),w=JSON.parse(M),D=bT.safeParse(w);if(!D.success){f("Failed to parse SSE data");return}const H=D.data;if(H.type==="init"){k.current!==null&&(clearTimeout(k.current),k.current=null),b.current=[];const B=new Map;for(let q=0;q<H.logs.length;q++){const Y=H.logs[q];Y!==void 0&&B.set(Y.id,q)}x.current=B,y.current=H.logs,t(H.logs),r(Hs(H.logs)),s(qs(H.logs)),f(null)}else H.type==="update"&&j(H.log)}catch{f("Failed to parse SSE data")}},L.onerror=()=>{f("SSE connection lost, reconnecting..."),L.close(),m.current!==null&&clearTimeout(m.current),m.current=setTimeout(N,3e3)}},[j]);v.useEffect(()=>(N(),()=>{g.current&&(g.current.close(),g.current=null),m.current!==null&&(clearTimeout(m.current),m.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null)}),[N]);const T=v.useCallback(()=>{(async()=>{try{if(!(await fetch("/api/logs",{method:"DELETE"})).ok){f("Failed to clear logs");return}x.current.clear(),y.current=[],t([]),r([]),s([]),f(null)}catch(L){f(L instanceof Error?L.message:"Unknown error clearing logs")}})()},[]),A=v.useCallback(L=>{L.length!==0&&(async()=>{try{if(!(await fetch("/api/logs",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:L})})).ok){f("Failed to clear group");return}const M=new Set(L);t(w=>{const D=w.filter(B=>!M.has(B.id)),H=new Map;for(let B=0;B<D.length;B++){const q=D[B];q!==void 0&&H.set(q.id,B)}return x.current=H,y.current=D,r(Hs(D)),s(qs(D)),D}),f(null)}catch(E){f(E instanceof Error?E.message:"Unknown error clearing group")}})()},[]),{strip:O}=ed();return l.jsxs(l.Fragment,{children:[p!==null&&l.jsx("div",{className:"fixed top-4 right-4 bg-destructive text-destructive-foreground px-4 py-2 rounded-md text-sm z-50",children:p}),l.jsx(Uv,{}),l.jsx(vT,{logs:S,sessions:n,models:o,selectedSession:i,selectedModel:c,onSessionChange:a,onModelChange:u,onClearAll:T,onClearGroup:A,viewMode:d,onViewModeChange:h,strip:O})]})}const jT=_T;export{jT as component};
107
+ `)){const S=k.trim();if(!S.startsWith("data: "))continue;const C=S.slice(6);if(C==="[DONE]")break;try{const j=JSON.parse(C);if(typeof j=="object"&&j!==null&&!Array.isArray(j)){const A=Object.getOwnPropertyDescriptor(j,"error");if(A!==void 0&&typeof A.value=="object"&&A.value!==null){const O=Object.getOwnPropertyDescriptor(A.value,"message");O!==void 0&&typeof O.value=="string"&&(t.error=O.value);continue}}const N=fy.safeParse(j);if(!N.success)continue;const T=N.data;if(m===0&&(x=Date.now()),r===!0&&y.length<g&&y.push({index:m,timestamp:Date.now()-x,type:"chat.completion.chunk",data:T}),m++,p||(o=T.id,s=T.model,p=!0),!h&&T.usage!==void 0&&T.usage!==null){if(u=T.usage.prompt_tokens??0,d=T.usage.completion_tokens??0,t.inputTokens=u,typeof j=="object"&&j!==null&&!Array.isArray(j)){const A=Object.getOwnPropertyDescriptor(j,"usage");if(A!==void 0&&typeof A.value=="object"&&A.value!==null){const O=Object.getOwnPropertyDescriptor(A.value,"prompt_tokens_details");if(O!==void 0&&typeof O.value=="object"&&O.value!==null){const L=Object.getOwnPropertyDescriptor(O.value,"cached_tokens");L!==void 0&&typeof L.value=="number"&&(t.cacheReadInputTokens=L.value)}}}h=!0}for(const A of T.choices){const O=A.delta;O.content!==void 0&&O.content!==null&&(i+=O.content),O.reasoning_content!==void 0&&O.reasoning_content!==null&&(a+=O.reasoning_content),O.thinking!==void 0&&O.thinking!==null&&(a+=O.thinking);const L=O.think;if(L!=null&&(a+=L),A.finish_reason!==void 0&&A.finish_reason!==null&&(c=A.finish_reason),O.tool_calls!==void 0&&O.tool_calls!==null)for(const E of O.tool_calls){let M=f.get(E.index);M===void 0&&(M={index:E.index,type:"function",function:{name:"",arguments:""}},f.set(E.index,M)),E.id!==void 0&&(M.id=E.id),E.function?.name!==void 0&&(M.function.name+=E.function.name),E.function?.arguments!==void 0&&(M.function.arguments+=E.function.arguments)}}}catch{}}r===!0&&(t.streamingChunks={chunks:y,truncated:m>g}),h||(d=Math.ceil(i.length/4)),t.outputTokens=d;const b={role:"assistant",content:i};return a&&(b.reasoning_content=a),f.size>0&&(b.tool_calls=[...f.values()]),JSON.stringify({id:o,object:"chat.completion",created:Math.floor(Date.now()/1e3),model:s!==""?s:n??"",choices:[{index:0,message:b,finish_reason:c}],usage:{prompt_tokens:u,completion_tokens:d,total_tokens:u+d}})}const YN={format:"openai",parseRequest(e,t){try{const n=JSON.parse(e),r=Ju.safeParse(n);return r.success?{model:r.data.model,sessionId:t?.get("x-session-affinity")??null}:null}catch{return null}},extractTokens(e){const t=Xu(e);if(t){let n=null;try{const r=JSON.parse(e);if(r!==null&&typeof r=="object"&&!Array.isArray(r)){const o=Object.getOwnPropertyDescriptor(r,"usage");if(o!==void 0&&typeof o.value=="object"&&o.value!==null){const s=Object.getOwnPropertyDescriptor(o.value,"prompt_tokens_details");if(s!==void 0&&typeof s.value=="object"&&s.value!==null){const i=Object.getOwnPropertyDescriptor(s.value,"cached_tokens");i!==void 0&&typeof i.value=="number"&&(n=i.value)}}}}catch{}return{inputTokens:t.usage.prompt_tokens??null,outputTokens:t.usage.completion_tokens??null,cacheCreationInputTokens:null,cacheReadInputTokens:n}}return{inputTokens:null,outputTokens:null,cacheCreationInputTokens:null,cacheReadInputTokens:null}},extractStream(e,t,n,r){return Ma(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}}};ir.register(YN);const XN="https://api.openai.com/v1",QN={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:XN},extractStream(e,t,n,r){return Ma(e,t,n,r)}};Da.register(QN);const e4="https://dashscope.aliyuncs.com/compatible-mode/v1",t4={name:"alibaba",matches(e){const t=e.toLowerCase().replace(/\s+/g,"-");return!!(t.startsWith("glm-5")||t.startsWith("qwen"))},getUpstreamBase(e,t){return e4},extractStream(e,t,n){return Ma(e,t,n)}};Da.register(t4);function hn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const Bn={parsed:null,toolNames:null},n4={format:"anthropic",analyzeRequest(e){if(e===null)return hn(e);try{const t=Hu.safeParse(JSON.parse(e));return t.success?{parsed:t.data,comparisonValue:t.data,messageCount:t.data.messages.length,toolCount:t.data.tools!==void 0&&t.data.tools.length>0?t.data.tools.length:null}:hn(e)}catch{return hn(e)}},analyzeResponse(e){if(e===null)return Bn;try{let t=JSON.parse(e);typeof t=="string"&&(t=JSON.parse(t));const n=qu.safeParse(t);if(!n.success)return Bn;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 Bn}}},r4={format:"openai",analyzeRequest(e){if(e===null)return hn(e);try{const t=Ju.safeParse(JSON.parse(e));return t.success?{parsed:t.data,comparisonValue:t.data,messageCount:t.data.messages.length,toolCount:t.data.tools!==void 0&&t.data.tools.length>0?t.data.tools.length:null}:hn(e)}catch{return hn(e)}},analyzeResponse(e){if(e===null)return Bn;const t=Xu(e);if(t===null)return Bn;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}}},o4={format:"unknown",analyzeRequest(e){return hn(e)},analyzeResponse(){return Bn}},s4={anthropic:n4,openai:r4,unknown:o4};function Ao(e){return s4[e]}function Nr(e){const t=ZN(e.path);return t==="unknown"?e.apiFormat:t}function i4(e){switch(e){case"success":return"text-emerald-400";case"client_error":return"text-amber-400";case"server_error":return"text-red-400";case"pending":return"text-muted-foreground"}}function pr({status:e}){const t=Cd(e),n=i4(t);return e===null?l.jsx("span",{className:"text-xs text-muted-foreground italic",children:"pending"}):l.jsxs("span",{className:he("flex items-center gap-1 text-xs font-mono font-semibold",n),children:[t==="server_error"&&l.jsx(Ev,{className:"size-3"}),e]})}function Wc({text:e}){return l.jsx("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-3",children:l.jsx("pre",{className:"text-xs text-red-300 whitespace-pre-wrap font-mono leading-relaxed overflow-auto max-h-[60vh]",children:e})})}function a4({text:e}){return l.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_ul]:my-1 [&_ol]:my-1",children:l.jsx(Gn,{children:e})})}const ao=v.memo(function({responseText:t,responseStatus:n,streaming:r,inputTokens:o,outputTokens:s,cacheCreationInputTokens:i,cacheReadInputTokens:a,apiFormat:c,error:u}){const d=c??"unknown",h=v.useMemo(()=>Ao(d).analyzeResponse(t).parsed,[d,t]);return t===null&&u===void 0?l.jsxs("div",{className:"flex items-center gap-2 py-3",children:[l.jsx(pr,{status:n}),l.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No response"})]}):n!==null&&n>=400?l.jsxs("div",{className:"space-y-2",children:[l.jsx(pr,{status:n}),l.jsx(Wc,{text:t??""}),u!=null&&l.jsxs("div",{className:"rounded border border-destructive/50 bg-destructive/10 p-3 text-xs",children:[l.jsx("div",{className:"font-semibold text-destructive mb-1",children:"SSE Error"}),l.jsx("div",{className:"text-muted-foreground font-mono",children:u})]})]}):u!=null?l.jsxs("div",{className:"space-y-2",children:[l.jsx(pr,{status:n}),l.jsxs("div",{className:"rounded border border-destructive/50 bg-destructive/10 p-3 text-xs",children:[l.jsx("div",{className:"font-semibold text-destructive mb-1",children:"SSE Error"}),l.jsx("div",{className:"text-muted-foreground font-mono",children:u})]}),t!==null&&l.jsx("div",{className:"mt-2",children:l.jsx(Wc,{text:t})})]}):h!==null?l.jsxs("div",{className:"space-y-2",children:[l.jsx(pr,{status:n}),MN(d,h)]}):l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(pr,{status:n}),r&&(o!==null||s!==null)&&l.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs",children:[l.jsx(Xn,{className:"size-3"}),l.jsxs("span",{className:"font-mono tabular-nums",children:[o!==null?qe(o):"—"," in /"," ",s!==null?qe(s):"—"," out"]}),i!=null&&i>0&&l.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["Cache +",qe(i)]}),a!=null&&a>0&&l.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["Cache ~",qe(a)]})]})]}),l.jsx(a4,{text:t??""})]})}),l4=ae({success:Qe(),error:K().optional(),responseStatus:ve().optional(),responseText:K().optional(),inputTokens:ve().optional(),outputTokens:ve().optional(),elapsedMs:ve().optional(),streaming:Qe().optional()});function c4({log:e,open:t,onOpenChange:n}){const[r,o]=v.useState(()=>e.rawRequestBody??"{}"),[s,i]=v.useState(null),[a,c]=v.useState(!1),[u,d]=v.useState(null);async function h(){c(!0),d(null),i(null);try{const g=await(await fetch(`/api/logs/${e.id}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modifiedBody:r})})).json(),m=l4.safeParse(g);if(!m.success){d("Invalid response from server"),c(!1);return}const x=m.data;i(x),x.success||d(x.error??"Replay failed")}catch(f){d(f instanceof Error?f.message:"Network error")}finally{c(!1)}}function p(){i(null),d(null),n(!1)}return l.jsx(rs,{open:t,onOpenChange:p,children:l.jsxs(os,{className:"max-w-4xl max-h-[85vh] overflow-auto",children:[l.jsx(ss,{children:l.jsxs(is,{className:"flex items-center gap-2",children:[l.jsx(id,{className:"size-4"}),"Replay Request #",e.id]})}),l.jsxs(Pn,{defaultValue:"modified",children:[l.jsxs(On,{children:[l.jsx(tt,{value:"modified",children:"Modified Request"}),l.jsx(tt,{value:"original",children:"Original Response"}),s&&l.jsx(tt,{value:"replay",children:"Replay Response"})]}),l.jsxs(nt,{value:"modified",className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Request Body (JSON)"}),l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("textarea",{className:"w-full h-64 p-3 font-mono text-xs bg-muted rounded-md border border-input resize-none focus:outline-none focus:ring-2 focus:ring-ring",value:r,onChange:f=>o(f.target.value),spellCheck:!1})}),l.jsx($e,{children:"Edit the request body before re-sending to the provider"})]})})]}),u!==null&&u!==""&&l.jsx("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:u}),l.jsx("div",{className:"flex justify-end",children:l.jsx(Xe,{onClick:()=>{h()},disabled:a,children:a?"Replaying...":"Replay"})}),s&&s.success&&l.jsxs(Pn,{defaultValue:"parsed",children:[l.jsxs(On,{children:[l.jsx(tt,{value:"parsed",children:"Response"}),l.jsx(tt,{value:"raw",children:"Raw Response"})]}),l.jsx(nt,{value:"parsed",children:l.jsx(ao,{responseText:s.responseText??null,responseStatus:s.responseStatus??null,streaming:s.streaming??!1,inputTokens:s.inputTokens??null,outputTokens:s.outputTokens??null,apiFormat:e.apiFormat})}),l.jsx(nt,{value:"raw",children:l.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap bg-muted p-3 rounded-md max-h-96 overflow-auto",children:s.responseText??"No response"})})]})]}),l.jsx(nt,{value:"original",children:e.responseText!==null?l.jsxs(Pn,{defaultValue:"parsed",children:[l.jsxs(On,{children:[l.jsx(tt,{value:"parsed",children:"Response"}),l.jsx(tt,{value:"raw",children:"Raw Response"})]}),l.jsx(nt,{value:"parsed",children:l.jsx(ao,{responseText:e.responseText,responseStatus:e.responseStatus,streaming:e.streaming,inputTokens:e.inputTokens,outputTokens:e.outputTokens,cacheCreationInputTokens:e.cacheCreationInputTokens,cacheReadInputTokens:e.cacheReadInputTokens,apiFormat:e.apiFormat})}),l.jsx(nt,{value:"raw",children:l.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap bg-muted p-3 rounded-md max-h-96 overflow-auto",children:e.responseText})})]}):l.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No original response"})}),s&&s.success&&l.jsx(nt,{value:"replay",children:s.responseText!==null?l.jsxs(Pn,{defaultValue:"parsed",children:[l.jsxs(On,{children:[l.jsx(tt,{value:"parsed",children:"Response"}),l.jsx(tt,{value:"raw",children:"Raw Response"})]}),l.jsx(nt,{value:"parsed",children:l.jsx(ao,{responseText:s.responseText??null,responseStatus:s.responseStatus??null,streaming:s.streaming??!1,inputTokens:s.inputTokens??null,outputTokens:s.outputTokens??null,apiFormat:e.apiFormat})}),l.jsx(nt,{value:"raw",children:l.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap bg-muted p-3 rounded-md max-h-96 overflow-auto",children:s.responseText})})]}):l.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No replay response"})})]})]})})}const u4=v.memo(function({logId:t,truncated:n}){const[r,o]=v.useState(!1),[s,i]=v.useState({status:"idle"}),[a,c]=v.useState(new Set);v.useEffect(()=>{if(!r||s.status!=="idle")return;let p=!1;return i({status:"loading"}),fetch(`/api/logs/${t}/chunks`).then(f=>f.ok?f.json():Promise.reject(new Error("Chunks not found"))).then(f=>{p||i({status:"success",chunks:f.chunks})}).catch(()=>{p||i({status:"error",message:"Chunk data unavailable"})}),()=>{p=!0}},[r,t]);const u=v.useMemo(()=>{if(s.status!=="success")return[];const p=new Map;for(const f of s.chunks){const g=p.get(f.index);g?g.push(f):p.set(f.index,[f])}return Array.from(p.entries()).map(([f,g])=>({index:f,chunks:g})).sort((f,g)=>f.index-g.index)},[s]),d=p=>{c(f=>{const g=new Set(f);return g.has(p)?g.delete(p):g.add(p),g})};function h(){return s.status==="idle"||s.status==="loading"?l.jsxs("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[l.jsx(Sr,{className:"size-3 animate-spin"}),l.jsx("span",{children:"Loading chunks..."})]}):s.status==="error"?l.jsx("div",{className:"py-2 text-xs text-muted-foreground italic",children:s.message}):l.jsxs("div",{className:"p-2 space-y-1",children:[l.jsxs("div",{className:"text-[10px] text-muted-foreground font-mono mb-2",children:[u.length," index group",u.length!==1?"s":""," available"]}),u.map(p=>{const f=a.has(p.index);return l.jsxs("div",{className:"rounded border border-border bg-background",children:[l.jsxs("button",{type:"button",className:"flex items-center gap-2 w-full px-2 py-1.5 text-left hover:bg-muted/50 transition-colors cursor-pointer",onClick:()=>d(p.index),children:[f?l.jsx(vt,{className:"size-3 text-muted-foreground"}):l.jsx(bt,{className:"size-3 text-muted-foreground"}),l.jsxs("span",{className:"text-[10px] text-muted-foreground font-mono",children:["[",p.index,"] ",p.chunks[0]?.type??""]}),l.jsxs("span",{className:"text-[10px] text-muted-foreground font-mono",children:[p.chunks.length," chunk",p.chunks.length!==1?"s":""]})]}),f&&l.jsx("div",{className:"px-2 pb-2 space-y-1",children:p.chunks.map(g=>l.jsxs("div",{className:"rounded border border-border bg-muted/20 p-2",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsxs("span",{className:"text-[10px] text-muted-foreground font-mono",children:["+",g.timestamp,"ms"]}),l.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:g.type})]}),l.jsx(us,{data:g,defaultExpandDepth:1,showCopy:!0})]},g.index))})]},p.index)})]})}return l.jsxs("div",{className:"space-y-1",children:[l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:()=>o(p=>!p),children:[r?l.jsx(vt,{className:"size-3"}):l.jsx(bt,{className:"size-3"}),l.jsx("span",{children:"Raw SSE Events"}),l.jsxs(xt,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono ml-1",children:[t,n===!0?"+":""]})]})}),l.jsx($e,{children:"Server-Sent Events streaming chunks from the provider"})]})}),r===!0?l.jsx("div",{className:"rounded-md border border-border bg-muted/20 overflow-auto max-h-64",children:h()}):null]})});function Hc(e,t,n){return e==="anthropic"&&t==="full"&&n}function d4(e,t){return e==="full"&&t}function f4(e,t,n,r){return e==="anthropic"&&t==="full"&&n&&r}function Zs({text:e,label:t,copied:n,onCopy:r}){return e===null?null:l.jsx("button",{type:"button",onClick:r,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded hover:bg-muted",children:n?l.jsxs(l.Fragment,{children:[l.jsx(Gt,{className:"size-3 text-green-500"}),l.jsx("span",{className:"text-green-500",children:"Copied!"})]}):l.jsxs(l.Fragment,{children:[l.jsx(wn,{className:"size-3"}),l.jsx("span",{children:t})]})})}function qc({active:e,onClick:t}){return l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("button",{type:"button",onClick:t,"aria-pressed":e,className:he("flex items-center gap-1.5 text-xs px-2 py-1 rounded transition-colors",e?"bg-primary/10 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted"),children:[l.jsx(od,{className:"size-3"}),e?"Showing diff":"Diff with Raw"]})}),l.jsx($e,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const h4=v.memo(function({rawBody:e,displayedBody:t,emptyLabel:n}){const r=v.useMemo(()=>Y3(e,t),[e,t]);return l.jsx(Fp,{result:r,emptyLabel:n})}),p4=v.memo(function({rawHeaders:e,headers:t,emptyLabel:n}){const r=v.useMemo(()=>J3(e,t),[e,t]);return l.jsx(Fp,{result:r,emptyLabel:n})});function Vs(e){const[t,n]=v.useState(!1),r=v.useRef(null);v.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);const o=v.useCallback(s=>{s.stopPropagation(),e!==null&&window.navigator.clipboard.writeText(e).then(()=>{n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),2e3)})},[e]);return{copied:t,copy:o}}const m4=v.memo(function({log:e,viewMode:t="simple",strip:n,cacheTrend:r=null,onCompareWithPrevious:o}){const[s,i]=v.useState(!1),[a,c]=v.useState(!1),[u,d]=v.useState(!1),[h,p]=v.useState(!1),[f,g]=v.useState("request"),m=Nr(e),x=Ao(m),y=v.useMemo(()=>x.analyzeRequest(e.rawRequestBody),[x,e.rawRequestBody]),b=v.useMemo(()=>x.analyzeResponse(e.responseText),[x,e.responseText]),S=v.useMemo(()=>!n||m!=="anthropic"||e.rawRequestBody===null?null:vC(e.rawRequestBody).body,[e.rawRequestBody,m,n])??e.rawRequestBody,C=Vs(S),j=Vs(e.rawRequestBody),N=Vs(e.responseText);return l.jsxs(Je,{children:[l.jsxs("div",{className:"border border-border rounded-lg mb-1 overflow-hidden",children:[l.jsx(kN,{log:e,messageCount:y.messageCount,toolCount:y.toolCount,expanded:s,onToggle:()=>i(!s),responseToolNames:b.toolNames,cacheTrend:r}),s&&l.jsx("div",{onClick:T=>T.stopPropagation(),onKeyDown:T=>T.stopPropagation(),children:l.jsxs(Pn,{value:f,onValueChange:g,children:[l.jsxs(On,{className:"mx-4 mt-2",children:[t==="full"&&l.jsx(tt,{value:"raw-headers",children:"Raw Headers"}),t==="full"&&l.jsx(tt,{value:"headers",children:"Headers"}),Hc(m,t,n)&&l.jsx(tt,{value:"raw-request",children:"Raw Request"}),l.jsx(tt,{value:"request",children:"Request"}),t==="full"&&l.jsx(tt,{value:"raw",children:"Raw Response"}),l.jsx(tt,{value:"parsed",children:"Response"})]}),Hc(m,t,n)&&l.jsx(nt,{value:"raw-request",children:f==="raw-request"&&l.jsxs("div",{className:"px-4 py-3",children:[l.jsx("div",{className:"flex justify-end mb-2",children:l.jsx(Zs,{text:e.rawRequestBody,label:"Copy Raw Request",copied:j.copied,onCopy:j.copy})}),e.rawRequestBody!==null?l.jsx(fn,{text:e.rawRequestBody,defaultExpandDepth:1}):l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No request body"})]})}),l.jsx(nt,{value:"request",children:f==="request"&&l.jsxs("div",{className:"px-4 py-3",children:[l.jsxs("div",{className:"flex justify-end gap-2 mb-2",children:[f4(m,t,n,e.rawRequestBody!==null)&&l.jsx(qc,{active:h,onClick:T=>{T.stopPropagation(),p(!h)}}),o!==void 0&&l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs(Xe,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:T=>{T.stopPropagation(),o(e)},children:[l.jsx(od,{className:"size-3 mr-1"}),"Diff with Previous"]})}),l.jsx($e,{children:"Compare this request with the immediately preceding one"})]}),l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs(Xe,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:T=>{T.stopPropagation(),c(!0)},children:[l.jsx(id,{className:"size-3 mr-1"}),"Replay"]})}),l.jsx($e,{children:"Re-send this request to the provider"})]}),l.jsx(Zs,{text:S,label:"Copy Request",copied:C.copied,onCopy:C.copy})]}),h?l.jsx(h4,{rawBody:e.rawRequestBody,displayedBody:S,emptyLabel:"No transformation applied — raw and sent request bodies are identical."}):S!==null?l.jsx(fn,{text:S,defaultExpandDepth:1}):l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No request body"})]})}),t==="full"&&l.jsx(nt,{value:"headers",children:f==="headers"&&l.jsxs("div",{className:"px-4 py-3",children:[l.jsx("div",{className:"flex justify-end gap-2 mb-2",children:d4(t,e.rawHeaders!==void 0&&Object.keys(e.rawHeaders).length>0)&&l.jsx(qc,{active:u,onClick:T=>{T.stopPropagation(),d(!u)}})}),u?l.jsx(p4,{rawHeaders:e.rawHeaders,headers:e.headers,emptyLabel:"No transformation applied — raw and processed headers are identical."}):e.headers&&Object.keys(e.headers).length>0?l.jsx("div",{className:"space-y-1 font-mono text-xs",children:Object.entries(e.headers).sort(([T],[A])=>T.localeCompare(A)).map(([T,A])=>l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("span",{className:"text-blue-600 dark:text-blue-400 font-semibold shrink-0",children:[T,":"]}),l.jsx("span",{className:"text-muted-foreground truncate",title:A,children:A})]},T))}):l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No headers captured"})]})}),t==="full"&&l.jsx(nt,{value:"raw-headers",children:f==="raw-headers"&&l.jsx("div",{className:"px-4 py-3",children:e.rawHeaders&&Object.keys(e.rawHeaders).length>0?l.jsx("div",{className:"space-y-1 font-mono text-xs",children:Object.entries(e.rawHeaders).sort(([T],[A])=>T.localeCompare(A)).map(([T,A])=>l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("span",{className:"text-blue-600 dark:text-blue-400 font-semibold shrink-0",children:[T,":"]}),l.jsx("span",{className:"text-muted-foreground truncate",title:A,children:A})]},T))}):l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No raw headers captured"})})}),l.jsx(nt,{value:"raw",children:f==="raw"&&l.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.error!==void 0&&e.error!==null&&l.jsxs("div",{className:"rounded border border-destructive/50 bg-destructive/10 p-3 text-xs",children:[l.jsx("div",{className:"font-semibold text-destructive mb-1",children:"SSE Error"}),l.jsx("div",{className:"text-muted-foreground font-mono",children:e.error})]}),l.jsx("div",{className:"flex justify-end",children:l.jsx(Zs,{text:e.responseText,label:"Copy Response",copied:N.copied,onCopy:N.copy})}),e.responseText!==null?l.jsx(fn,{text:e.responseText,defaultExpandDepth:1}):l.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No response"}),e.streaming===!0&&l.jsx(u4,{logId:e.id,truncated:e.streamingChunksPath!==null})]})}),l.jsx(nt,{value:"parsed",children:f==="parsed"&&l.jsx("div",{className:"px-4 py-3",children:l.jsx(ao,{responseText:e.responseText,responseStatus:e.responseStatus,streaming:e.streaming,inputTokens:e.inputTokens,outputTokens:e.outputTokens,cacheCreationInputTokens:e.cacheCreationInputTokens,cacheReadInputTokens:e.cacheReadInputTokens,apiFormat:m,error:e.error})})})]})})]}),l.jsx(c4,{log:e,open:a,onOpenChange:c})]})});function g4({stopReason:e,isPending:t,isFirst:n,isTurnStart:r,crabIndex:o=0,collapsible:s=!1,onToggle:i}){const a=e==="end_turn"||e==="stop",c=t&&!a,u=v.useMemo(()=>mi(o),[o]),d=s&&i?{role:"button",tabIndex:0,className:"cursor-pointer",onClick:h=>{h.stopPropagation(),i()},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),i())}}:{};return l.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[l.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!n&&l.jsx("div",{className:"w-0.5 bg-muted-foreground/30 h-full"})}),a?l.jsx("span",{title:e==="end_turn"?"End of Turn (Anthropic)":"End of Turn (OpenAI)",...d,children:l.jsx(u,{className:he("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})}):r?l.jsx("span",{title:"Start of turn",...d,children:l.jsx(u,{className:he("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):c?l.jsx("span",{title:"Processing…",children:l.jsx(u,{className:he("size-3.5 text-amber-300/80","animate-crab-crawl")})}):l.jsx("span",{children:l.jsx(u,{className:"size-3.5 text-muted-foreground/40"})}),l.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!a&&l.jsx("div",{className:he("w-0.5 h-full",t?"border-dashed bg-transparent border-l-2 border-muted-foreground/20":"bg-muted-foreground/30")})})]})}function x4(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const y4=v.memo(function({entries:t,viewMode:n,strip:r,cacheTrends:o,onCompareWithPrevious:s,comparisonPredecessors:i,turnIndex:a=0}){const c=t.length-1,u=t[c]?.stopReason??null,d=u!==null?qh(u):!1,h=t[c]?.log.responseStatus===null,p=d&&!h,[f,g]=v.useState(!1),m=v.useRef(d);v.useEffect(()=>{d&&!m.current&&g(!0),m.current=d},[d]);const x=v.useCallback(()=>{p&&g(A=>!A)},[p]),y=v.useMemo(()=>{let A=0,O=0,L=0,E=!1,M=!1;for(const w of t)w.log.inputTokens!==null&&(A+=w.log.inputTokens,E=!0),w.log.outputTokens!==null&&(O+=w.log.outputTokens,E=!0),w.log.elapsedMs!==null&&(L+=w.log.elapsedMs,M=!0);return{totalInput:A,totalOutput:O,hasTokens:E,totalElapsed:L,hasElapsed:M}},[t,c]),b=v.useMemo(()=>{const A=new Set;for(const O of t){const L=Jh(O.log.model);L!=="unknown"&&A.add(L)}return[...A]},[t]),k=v.useMemo(()=>mi(t[0]?.log.id??0),[t]),S=v.useMemo(()=>mi(t[c]?.log.id??0),[t,c]),C=a%2===0?"bg-muted/10":"bg-muted/25",[j,N]=v.useState(0),T=v.useRef(null);return v.useEffect(()=>{const A=T.current;if(!A)return;let O=0;const L=new ResizeObserver(()=>{window.cancelAnimationFrame(O),O=window.requestAnimationFrame(()=>N(E=>E+1))});return L.observe(A),()=>{L.disconnect(),window.cancelAnimationFrame(O)}},[]),l.jsx("div",{ref:T,className:he("border rounded-lg",h?"border-amber-500/10":"border-transparent"),children:f?l.jsxs("div",{className:"flex items-stretch",children:[l.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-0.5 pb-0.5",children:[l.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),l.jsx("span",{role:"button",tabIndex:0,title:"Start of turn — click to expand",className:"cursor-pointer",onClick:A=>{A.stopPropagation(),x()},onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),x())},children:l.jsx(k,{className:he("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}),l.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:l.jsx("div",{className:"w-0.5 bg-muted-foreground/30 h-full"})}),l.jsx("span",{role:"button",tabIndex:0,title:"End of Turn — click to expand",className:"cursor-pointer",onClick:A=>{A.stopPropagation(),x()},onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),x())},children:l.jsx(S,{className:he("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})})]}),l.jsxs("div",{className:he("flex-1 min-w-0 mb-0.5 rounded-lg border border-border py-1 px-3 flex items-center gap-3 text-xs cursor-pointer",C),onClick:x,role:"button",tabIndex:0,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),x())},children:[l.jsxs("span",{className:"text-blue-400/80 font-mono font-semibold tabular-nums shrink-0",children:["#",t[0]?.log.id??"?"," ~ #",t[c]?.log.id??"?"]}),l.jsxs("span",{className:"text-muted-foreground shrink-0",children:[t.length," request",t.length>1?"s":""]}),b.length>0&&l.jsx("span",{className:"flex items-center gap-0.5 shrink-0",children:b.map(A=>l.jsx(Yh,{provider:A,className:"size-4"},A))}),y.hasElapsed&&l.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground shrink-0",children:[l.jsx(Ir,{className:"size-3"}),l.jsx("span",{className:"font-mono tabular-nums",children:x4(y.totalElapsed)})]}),y.hasTokens&&l.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[l.jsx(Xn,{className:"size-3 text-muted-foreground"}),l.jsxs("span",{className:"font-mono tabular-nums",children:[l.jsxs("span",{className:"text-blue-400",children:["IN ",qe(y.totalInput)]})," / ",l.jsxs("span",{className:"text-amber-400",children:["OUT ",qe(y.totalOutput)]})]})]}),l.jsx("span",{className:"flex-1 min-w-0"}),l.jsx(bt,{className:"size-4 text-muted-foreground shrink-0"})]})]}):t.map((A,O)=>{const{log:L,stopReason:E}=A,M=O===0;return l.jsxs("div",{className:"flex items-stretch",children:[l.jsx(g4,{stopReason:E,isPending:L.responseStatus===null,isFirst:O===0,isTurnStart:M,crabIndex:L.id%12,collapsible:p&&t.length>1&&M,onToggle:x}),l.jsx("div",{className:he("flex-1 min-w-0 mb-0.5 rounded-lg",C),children:l.jsx(m4,{log:L,viewMode:n,strip:r,cacheTrend:o?.get(L.id)??null,onCompareWithPrevious:i.has(L.id)?s:void 0})})]},L.id)})})});function v4(e,t){return e||t}function b4(e){const t=[];let n=[],r=0;for(const o of e){n.push({log:o,stopReason:US(o)});const s=n[n.length-1];s!==void 0&&qh(s.stopReason)&&(t.push({entries:n,turnIndex:r}),n=[],r+=1)}return n.length>0&&t.push({entries:n,turnIndex:r}),t}function w4(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],s=n.logs[r-1];if(o===void 0||s===void 0)continue;const i=Nr(o),a=Nr(s);i==="unknown"||i!==a||t.set(o.id,s)}return t}function k4(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}}const _4=v.memo(function({group:e,viewMode:t="simple",strip:n,cacheTrends:r,onCompareWithPrevious:o,comparisonPredecessors:s,onClearGroup:i,standalone:a=!1}){const[c,u]=v.useState(!1),d=v.useMemo(()=>k4(e.logs),[e.logs]),h=e.logs[0]?.timestamp??new Date().toISOString(),p=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),f=$S(e.logs),g=e.logs.some(y=>y.responseStatus===null),m=v.useMemo(()=>b4(e.logs),[e.logs]),x=e.conversationId.startsWith("PID:")||e.conversationId.includes("|")?e.conversationId:e.conversationId.length>24?e.conversationId.slice(0,12)+"…"+e.conversationId.slice(-12):e.conversationId;return l.jsxs("div",{className:"mb-2",children:[!a&&l.jsx(LS,{conversationId:x,startTime:h,endTime:p,totalCalls:e.logs.length,totalInputTokens:d.totalInputTokens,totalOutputTokens:d.totalOutputTokens,apiFormat:FS(e.logs),expanded:c,onToggle:()=>u(!c),hideApiFormat:f,isLoading:g,userAgent:e.logs[0]?.userAgent??null,onClear:()=>i(e.logs.map(y=>y.id))}),v4(a,c)&&l.jsx("div",{className:"max-h-[70vh] overflow-y-auto",children:m.map(y=>l.jsx(y4,{entries:y.entries,viewMode:t,strip:n,cacheTrends:r,onCompareWithPrevious:o,comparisonPredecessors:s,turnIndex:y.turnIndex},y.turnIndex))})]})});function S4({className:e}){return l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:he("inline-block size-5",e),children:[l.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"}),l.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),l.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),l.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),l.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"}),l.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),l.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),l.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),l.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),l.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]})}function Kc({...e}){return l.jsx(Z_,{"data-slot":"select",...e})}function Gc({...e}){return l.jsx(W_,{"data-slot":"select-value",...e})}function Jc({className:e,size:t="default",children:n,...r}){return l.jsxs(V_,{"data-slot":"select-trigger","data-size":t,className:he("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,l.jsx(H_,{asChild:!0,children:l.jsx(vt,{className:"size-4 opacity-50"})})]})}function Yc({className:e,children:t,position:n="popper",align:r="center",...o}){return l.jsx(q_,{children:l.jsxs(K_,{"data-slot":"select-content",className:he("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:[l.jsx(C4,{}),l.jsx(G_,{className:he("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),l.jsx(j4,{})]})})}function eo({className:e,children:t,...n}){return l.jsxs(J_,{"data-slot":"select-item",className:he("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:[l.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:l.jsx(X_,{children:l.jsx(Gt,{className:"size-4"})})}),l.jsx(Y_,{children:t})]})}function C4({className:e,...t}){return l.jsx(Q_,{"data-slot":"select-scroll-up-button",className:he("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(zy,{className:"size-4"})})}function j4({className:e,...t}){return l.jsx(eS,{"data-slot":"select-scroll-down-button",className:he("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(vt,{className:"size-4"})})}function E4(){return l.jsxs("svg",{fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[l.jsx("title",{children:"Claude Code"}),l.jsx("path",{clipRule:"evenodd",d:"M20.998 10.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6 10.949h1.488V8.102H6v2.847zm10.51 0H18V8.102h-1.49v2.847z"})]})}function N4(){return l.jsxs("svg",{fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[l.jsx("title",{children:"OpenCode"}),l.jsx("path",{d:"M16 6H8v12h8V6zm4 16H4V2h16v20z"})]})}function T4(){return l.jsxs("svg",{fill:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"size-6 shrink-0",children:[l.jsx("title",{children:"MiMo Code"}),l.jsx("text",{x:"12",y:"18",textAnchor:"middle",fontSize:"16",fontWeight:"800",fontFamily:"system-ui, sans-serif",children:"M"})]})}const A4=ae({name:K(),apiKey:K(),format:lt(["anthropic","openai"]),anthropicBaseUrl:K(),openaiBaseUrl:K(),models:Pe(K()),sourceTool:lt(["claude-code","opencode","mimo-code"]),alreadyExists:Qe()}),I4=ae({providers:Pe(A4),warnings:Pe(K()).optional()}),z4=ae({success:Qe().optional(),imported:ve().optional(),message:K().optional(),errors:Pe(K()).optional()}),R4={"claude-code":E4,opencode:N4,"mimo-code":T4};function P4({open:e,onOpenChange:t,onImportComplete:n}){const[r,o]=v.useState(!1),[s,i]=v.useState(null),[a,c]=v.useState([]),[u,d]=v.useState([]),[h,p]=v.useState(new Set),[f,g]=v.useState(!1),[m,x]=v.useState(null),[y,b]=v.useState(null),k=v.useCallback(()=>{o(!0),i(null),d([]),c([]),p(new Set),x(null),b(null),fetch("/api/providers/scan").then(N=>N.ok?N.json().then(T=>{const A=I4.safeParse(T);if(!A.success){i(`Invalid response: ${A.error.message}`);return}c(A.data.providers),d(A.data.warnings??[]);const O=new Set;A.data.providers.forEach((L,E)=>{L.alreadyExists||O.add(E)}),p(O)}):N.text().then(T=>{i(`Scan failed (${N.status}): ${T}`)})).catch(N=>{i(N instanceof Error?N.message:String(N))}).finally(()=>{o(!1)})},[]);v.useEffect(()=>{e&&k()},[e,k]);const S=v.useCallback(N=>{p(T=>{const A=new Set(T);return A.has(N)?A.delete(N):A.add(N),A})},[]),C=v.useCallback(()=>{const N=a.filter((O,L)=>h.has(L));if(N.length===0)return;g(!0),b(null),x(null);const T=new Date().toISOString(),A=N.map(O=>({id:window.crypto.randomUUID(),name:O.name,apiKey:O.apiKey,format:O.format,anthropicBaseUrl:O.anthropicBaseUrl,openaiBaseUrl:O.openaiBaseUrl,models:O.models,createdAt:T,updatedAt:T}));fetch("/api/providers/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providers:A})}).then(O=>O.json()).then(O=>{const L=z4.safeParse(O);if(!L.success){b(`Invalid response: ${L.error.message}`);return}const E=L.data;c(M=>M.map((w,D)=>h.has(D)?{...w,alreadyExists:!0}:w)),p(new Set),E.errors!==void 0&&E.errors.length>0&&E.message!==void 0?x(E.message):x(`Imported ${E.imported??N.length} provider(s)`),n()}).catch(O=>{b(O instanceof Error?O.message:String(O))}).finally(()=>{g(!1)})},[a,h,n]),j=a.some(N=>!N.alreadyExists);return l.jsx(rs,{open:e,onOpenChange:t,children:l.jsxs(os,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[l.jsxs(ss,{children:[l.jsx(is,{children:"Import from External Tools"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[r&&l.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[l.jsx(Sr,{className:"size-4 animate-spin"}),l.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),s!==null&&l.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[l.jsx(_r,{className:"size-4"}),s]}),!r&&s===null&&a.length===0&&l.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",l.jsx("br",{}),l.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&&a.map((N,T)=>l.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${N.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!N.alreadyExists&&l.jsx("input",{type:"checkbox",checked:h.has(T),disabled:f,onChange:()=>S(T),className:"mt-0.5 size-4"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[(()=>{const A=R4[N.sourceTool];return A===void 0?null:l.jsx(A,{})})(),N.alreadyExists&&l.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),l.jsxs("div",{className:"text-xs text-muted-foreground mt-1 truncate",children:[N.models.slice(0,4).join(", "),N.models.length>4?` +${N.models.length-4} more`:""]}),l.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:N.format==="anthropic"?N.anthropicBaseUrl:N.openaiBaseUrl}),l.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:N.apiKey.length>8?`${N.apiKey.slice(0,4)}••••${N.apiKey.slice(-4)}`:"••••"})]})]},`${N.sourceTool}-${N.name}`)),u.length>0&&l.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:u.map((N,T)=>l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(_r,{className:"size-3"}),N]},T))}),m!==null&&l.jsx("div",{className:"text-sm text-green-500 border-t pt-2",children:m}),y!==null&&l.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:y})]}),l.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[l.jsxs(Xe,{variant:"outline",size:"sm",onClick:k,disabled:r,children:[l.jsx(Sr,{className:`size-3 mr-1 ${r?"animate-spin":""}`}),"Rescan"]}),l.jsxs(Xe,{size:"sm",onClick:C,disabled:!j||h.size===0||f,children:[l.jsx(Zi,{className:"size-3 mr-1"}),f?"Importing...":`Import Selected (${h.size})`]})]})]})})}function Vp(e){return e.length<=8?"••••••••":e.slice(0,4)+"••••••••"+e.slice(-4)}const O4={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function D4(e){return Object.prototype.hasOwnProperty.call(e,"success")}function M4(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function L4(e){const t={className:"size-3",strokeWidth:2};switch(e){case"timeout":return l.jsx(Ir,{...t});case"network_unreachable":return l.jsx(Rv,{...t});case"connection_refused":return l.jsx(Ov,{...t});case"auth_failed":return l.jsx(lv,{...t});case"rate_limited":return l.jsx(nv,{...t});case"server_error":return l.jsx(wv,{...t});case"invalid_response":return l.jsx(By,{...t});case"unknown":return l.jsx(_r,{...t});default:return l.jsx(_r,{...t})}}function to({result:e}){const[t,n]=v.useState(!1);if(!D4(e))return M4(e)?l.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground shrink-0",children:[l.jsx(Hi,{className:"size-3"}),l.jsx("span",{children:"Not configured"})]}):l.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground shrink-0",children:[l.jsx(ad,{className:"size-3 animate-spin"}),l.jsx("span",{children:"Testing..."})]});if(e.success){const c=[];e.inputTokens!==void 0&&c.push(l.jsxs("span",{children:[e.inputTokens," in"]},"in")),e.outputTokens!==void 0&&c.push(l.jsxs("span",{children:[e.outputTokens," out"]},"out")),e.cacheCreationInputTokens!==void 0&&e.cacheCreationInputTokens>0&&c.push(l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["+",e.cacheCreationInputTokens," cache"]})}),l.jsx($e,{children:"Tokens cached for reuse, reducing future API cost"})]})},"cache-create")),e.cacheReadInputTokens!==void 0&&e.cacheReadInputTokens>0&&c.push(l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["~",e.cacheReadInputTokens," cached"]})}),l.jsx($e,{children:"Tokens served from cache, reducing API cost"})]})},"cache-read"));const u=[];for(let d=0;d<c.length;d++)d>0&&u.push(", "),u.push(c[d]);return l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs("div",{className:"flex items-center gap-1 text-xs text-green-600 shrink-0",children:[l.jsx(Fy,{className:"size-3"}),l.jsx("span",{children:"Connected"}),c.length>0&&l.jsxs("span",{className:"text-muted-foreground",children:["(",u,")"]})]})}),l.jsx($e,{children:"Connection test passed"})]})})}const r=e.error,o=r?.message??"Connection failed",s=r?.hint,i=r?.details,a=r?.type??"unknown";return l.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-1 text-xs text-red-600 max-w-[200px]",children:[L4(a),l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("span",{className:"truncate",children:o})}),l.jsx($e,{children:"Connection test failed"})]})}),i!==void 0&&l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("button",{type:"button",onClick:()=>n(!t),className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:t?l.jsx(Vi,{className:"size-3"}):l.jsx(Wi,{className:"size-3"})})}),l.jsx($e,{children:t?"Hide error details":"Show detailed error information"})]})})]}),t&&i!==void 0&&l.jsxs("div",{className:"text-xs text-muted-foreground bg-muted/50 rounded p-2 max-w-[300px]",children:[s!==void 0&&l.jsx("div",{className:"mb-1",children:s}),l.jsx("div",{className:"font-mono whitespace-pre-wrap break-all text-red-400/80",children:i})]})]})}function F4(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 s=Math.floor(o/60);if(s<60)return`${s}m ago`;const i=Math.floor(s/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function $4({provider:e,testResults:t,isTesting:n,testingTimeLeft:r,isHighlighted:o,onEdit:s,onDelete:i,onTest:a}){const[c,u]=v.useState(!1),[d,h]=v.useState(!1),[p,f]=v.useState(!1),g=v.useRef(null),m=v.useRef(void 0);t?.testedAt!==void 0&&t.testedAt!==m.current&&(m.current=t.testedAt,g.current=null);const x=v.useCallback(()=>{f(k=>{const S=!k;return S&&g.current===null&&t?.models!==void 0&&(g.current=t.testedAt??"",fetch(`/api/providers/${e.id}/test/log`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})),S})},[e.id,t]);function y(){navigator.clipboard.writeText(e.apiKey).catch(()=>{}),h(!0),setTimeout(()=>h(!1),2e3)}const b=e.apiDocsUrl??Object.entries(O4).find(([k])=>e.name.toLowerCase().includes(k))?.[1];return l.jsxs("div",{className:`border rounded-lg p-4 flex flex-col gap-3 bg-card transition-all duration-500 ${o===!0?"ring-2 ring-primary shadow-md":""}`,children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("span",{className:"font-medium truncate",children:e.name}),e.source==="company"&&l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400 shrink-0",children:"公司"})}),l.jsx($e,{children:"Company-provided API key"})]})}),e.source==="personal"&&l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400 shrink-0",children:"个人"})}),l.jsx($e,{children:"Your personal API key"})]})})]}),b!==void 0&&l.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1 text-xs",title:"View API documentation",children:[l.jsx(Jy,{className:"size-3"}),l.jsx("span",{className:"sr-only",children:"Docs"})]})]}),e.models!==void 0&&e.models.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(k=>l.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:k},k))}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("code",{className:"text-xs text-muted-foreground bg-muted px-2 py-1 rounded flex-1 truncate",children:c?e.apiKey:Vp(e.apiKey)}),l.jsx("button",{type:"button",onClick:()=>u(k=>!k),className:"text-muted-foreground hover:text-foreground transition-colors p-1","aria-label":c?"Hide API key":"Show API key",children:c?l.jsx(Vi,{className:"size-4"}):l.jsx(Wi,{className:"size-4"})}),l.jsx("button",{type:"button",onClick:y,className:"text-muted-foreground hover:text-foreground transition-colors p-1","aria-label":"Copy API key",children:d?l.jsx(Gt,{className:"size-4 text-green-500"}):l.jsx(wn,{className:"size-4"})})]}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsxs("div",{className:"text-xs text-muted-foreground min-w-0 flex-1",children:[l.jsx("span",{className:"font-medium",children:"Anthropic:"})," ",l.jsx("span",{className:"truncate",children:e.anthropicBaseUrl})]}),t&&l.jsx(to,{result:t.anthropic.nonStreaming})]}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsxs("div",{className:"text-xs text-muted-foreground min-w-0 flex-1",children:[l.jsx("span",{className:"font-medium",children:"OpenAI:"})," ",l.jsx("span",{className:"truncate",children:e.openaiBaseUrl})]}),t&&l.jsx(to,{result:t.openai.nonStreaming})]}),t?.testedAt!==void 0&&l.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[l.jsx(Ir,{className:"size-3"}),l.jsxs("span",{children:["Tested ",F4(t.testedAt)]})]}),t?.models!==void 0&&Object.keys(t.models).length>0&&l.jsxs("div",{className:"border-t pt-2",children:[l.jsxs("button",{type:"button",onClick:x,className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1",children:[l.jsx("span",{className:"font-mono",children:p?"▾":"▸"}),"Model Test Results (",Object.keys(t.models).length,")"]}),p&&l.jsx("div",{className:"mt-2 overflow-x-auto",children:l.jsxs("table",{className:"w-full text-xs border-collapse",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-border",children:[l.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"Model"}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&l.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"Anthropic"}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&l.jsx("th",{className:"text-left py-1 px-2 font-medium text-muted-foreground",children:"OpenAI"})]})}),l.jsx("tbody",{children:Object.entries(t.models).map(([k,S])=>l.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[l.jsx("td",{className:"py-1 px-2 font-medium",children:k}),e.anthropicBaseUrl!==void 0&&e.anthropicBaseUrl!==""&&l.jsx("td",{className:"py-1 px-2",children:l.jsx(to,{result:S.anthropic.nonStreaming})}),e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""&&l.jsx("td",{className:"py-1 px-2",children:l.jsx(to,{result:S.openai.nonStreaming})})]},k))})]})})]}),l.jsxs("div",{className:"flex gap-2 pt-1 border-t",children:[a!==void 0&&l.jsxs(Xe,{variant:"outline",size:"sm",onClick:()=>a(e.id),className:"text-xs h-7 gap-1",disabled:n??!1,children:[l.jsx(ad,{className:`size-3 ${n??!1?"animate-spin":""}`}),n??!1?r!==void 0?`Testing (${r}s)`:"Testing...":"Test"]}),l.jsxs(Xe,{variant:"outline",size:"sm",onClick:()=>s(e),className:"text-xs h-7 gap-1",disabled:n??!1,children:[l.jsx(qi,{className:"size-3"}),"Edit"]}),l.jsxs(Xe,{variant:"outline",size:"sm",onClick:()=>i(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:n??!1,children:[l.jsx(ud,{className:"size-3"}),"Delete"]})]})]})}const B4={deepseek:{format:"openai",baseUrl:"https://api.deepseek.com"},minimax:{format:"anthropic",baseUrl:"https://api.minimaxi.com/anthropic",apiDocsUrl:"https://platform.minimaxi.com/docs/api-reference/api-overview"},alibaba:{format:"openai",baseUrl:"https://dashscope.aliyuncs.com/compatible-mode"}},Xc=["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"],Qc=["glm-5","glm-5.1","qwen3.6-plus","qwen3.7-max"];function U4({provider:e,onSubmit:t,onCancel:n}){const[r,o]=v.useState(e?.name??""),[s,i]=v.useState(e?.apiKey??""),[a,c]=v.useState(!1),[u,d]=v.useState(!1),h=e?.models,[p,f]=v.useState(h!==void 0&&h.length>0?h:[""]),[g,m]=v.useState("anthropic"),[x,y]=v.useState(e?.anthropicBaseUrl??""),[b,k]=v.useState(e?.openaiBaseUrl??""),[S,C]=v.useState(e?.apiDocsUrl??""),[j,N]=v.useState(e?.source),[T,A]=v.useState({}),[O,L]=v.useState(!1),[E,M]=v.useState(null),w=v.useRef([]);v.useEffect(()=>{if(E===null)return;const X=E;function de(te){if(!(te.target instanceof Node))return;const ce=w.current[X];ce!=null&&!ce.contains(te.target)&&M(null)}return document.addEventListener("mousedown",de),()=>document.removeEventListener("mousedown",de)},[E]);const[D,H]=v.useState(!1),[B,q]=v.useState(!1),Y=r.toLowerCase().includes("minimax"),I=r.toLowerCase().includes("alibaba");function W(){navigator.clipboard.writeText(s).catch(()=>{}),d(!0),setTimeout(()=>d(!1),2e3)}v.useEffect(()=>{e&&(o(e.name),i(e.apiKey),f((e.models?.length??0)>0?e.models:[""]),y(e.anthropicBaseUrl??""),k(e.openaiBaseUrl??""),C(e.apiDocsUrl??""),N(e.source),H(!1),q(!1))},[e]),v.useEffect(()=>{const X=r.toLowerCase();for(const[de,te]of Object.entries(B4))if(X.includes(de)){te.format==="anthropic"&&!D?y(te.baseUrl):te.format==="openai"&&!B&&k(te.baseUrl),te.apiDocsUrl!==void 0&&!S&&C(te.apiDocsUrl),de==="minimax"&&p.length===1&&p[0]===""&&f([Xc[0]??""]),de==="alibaba"&&p.length===1&&p[0]===""&&f([Qc[0]??""]);break}},[r]);function V(){const X={};return r.trim()||(X.name="Name is required"),s.trim()||(X.apiKey="API key is required"),(p.length===0||p.every(de=>!de.trim()))&&(X.models="At least one model is required"),x.trim()&&!z(x.trim())&&(X.anthropicBaseUrl="Invalid URL format"),b.trim()&&!z(b.trim())&&(X.openaiBaseUrl="Invalid URL format"),!x.trim()&&!b.trim()&&(X.format="At least one format URL (Anthropic or OpenAI) is required"),A(X),Object.keys(X).length===0}function z(X){try{return new URL(X),!0}catch{return!1}}function oe(X){if(X.preventDefault(),!!V()){L(!0);try{t({name:r.trim(),apiKey:s.trim(),models:p.map(de=>de.trim()).filter(de=>de!==""),anthropicBaseUrl:x.trim()||void 0,openaiBaseUrl:b.trim()||void 0,apiDocsUrl:S.trim()||void 0,source:j})}finally{L(!1)}}}return l.jsxs("form",{onSubmit:oe,className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",l.jsx("span",{className:"text-destructive",children:"*"})]}),l.jsx("input",{id:"provider-name",type:"text",value:r,onChange:X=>o(X.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"}),T.name!==void 0&&l.jsx("p",{className:"text-xs text-destructive",children:T.name})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),l.jsxs("select",{id:"provider-source",value:j??"",onChange:X=>N(X.target.value==="company"||X.target.value==="personal"?X.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:[l.jsx("option",{value:"",children:"—"}),l.jsx("option",{value:"personal",children:"个人 (Personal)"}),l.jsx("option",{value:"company",children:"公司 (Company)"})]}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",l.jsx("span",{className:"text-destructive",children:"*"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{id:"provider-apikey",type:"text",value:a||s.length===0?s:Vp(s),onChange:X=>i(X.target.value),onFocus:()=>{!a&&s.length>0&&c(!0)},placeholder:"sk-ant-...",readOnly:!a&&s.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"}),l.jsx("button",{type:"button",onClick:()=>c(X=>!X),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":a?"Hide API key":"Show API key",children:a?l.jsx(Vi,{className:"size-4"}):l.jsx(Wi,{className:"size-4"})}),l.jsx("button",{type:"button",onClick:W,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:u?l.jsx(Gt,{className:"size-4 text-green-500"}):l.jsx(wn,{className:"size-4"})})]}),T.apiKey!==void 0&&l.jsx("p",{className:"text-xs text-destructive",children:T.apiKey})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("label",{className:"text-sm font-medium",children:["Models ",l.jsx("span",{className:"text-destructive",children:"*"})]}),p.map((X,de)=>l.jsxs("div",{ref:te=>{w.current[de]=te},className:"flex items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsx("input",{type:"text",value:X,onChange:te=>{f(ce=>{const fe=[...ce];return fe[de]=te.target.value,fe})},placeholder:Y||I?"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"}),(Y||I)&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",onClick:()=>M(E===de?null:de),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:l.jsx(vt,{className:"size-4"})}),E===de&&l.jsx("div",{className:"absolute left-0 right-0 top-full mt-1 z-50 bg-popover border border-border rounded-md shadow-md max-h-48 overflow-y-auto",children:(Y?Xc:Qc).map(te=>l.jsx("button",{type:"button",onClick:()=>{f(ce=>{const fe=[...ce];return fe[de]=te,fe}),M(null)},className:"w-full text-left px-3 py-2 text-sm hover:bg-muted transition-colors",children:te},te))})]})]}),p.length>1&&l.jsx("button",{type:"button",onClick:()=>f(te=>te.filter((ce,fe)=>fe!==de)),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:l.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:[l.jsx("path",{d:"M3 6h18"}),l.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),l.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]},de)),l.jsx("button",{type:"button",onClick:()=>f(X=>[...X,""]),className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),T.models!==void 0&&l.jsx("p",{className:"text-xs text-destructive",children:T.models})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex gap-1 border-b border-border",children:[l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("button",{type:"button",onClick:()=>m("anthropic"),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${g==="anthropic"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Anthropic Format"})}),l.jsx($e,{children:"Anthropic Messages API protocol"})]})}),l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("button",{type:"button",onClick:()=>m("openai"),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${g==="openai"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"OpenAI Format"})}),l.jsx($e,{children:"OpenAI Chat Completions API protocol"})]})})]}),T.format!==void 0&&l.jsx("p",{className:"text-xs text-destructive",children:T.format})]}),g==="anthropic"&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:"Anthropic Base URL"}),l.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:x,onChange:X=>{H(!0),y(X.target.value)},placeholder:"https://api.anthropic.com",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"}),T.anthropicBaseUrl!==void 0&&l.jsx("p",{className:"text-xs text-destructive",children:T.anthropicBaseUrl}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Anthropic-compatible endpoint URL. Leave empty if this provider does not support Anthropic format."})]}),g==="openai"&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:"OpenAI Base URL"}),l.jsx("input",{id:"provider-openai-base-url",type:"text",value:b,onChange:X=>{q(!0),k(X.target.value)},placeholder:"https://api.openai.com/v1",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"}),T.openaiBaseUrl!==void 0&&l.jsx("p",{className:"text-xs text-destructive",children:T.openaiBaseUrl}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"OpenAI-compatible endpoint URL. Leave empty if this provider does not support OpenAI format."})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),l.jsx("input",{id:"provider-api-docs-url",type:"text",value:S,onChange:X=>C(X.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"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),l.jsxs("div",{className:"sticky bottom-0 bg-card border-t flex gap-2 justify-end pt-2 pb-2",children:[l.jsx(Xe,{type:"button",variant:"outline",onClick:n,disabled:O,children:"Cancel"}),l.jsx(Xe,{type:"submit",disabled:O,children:O?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const Ni=ae({id:K(),name:K(),apiKey:K(),model:K().optional(),models:Pe(K()).min(1),format:lt(["anthropic","openai"]).optional(),baseUrl:K().optional(),anthropicBaseUrl:K().optional(),openaiBaseUrl:K().optional(),authHeader:lt(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:K().optional(),source:lt(["company","personal"]).optional(),createdAt:K(),updatedAt:K()}),Z4=lt(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),V4=ae({message:K(),type:Z4,details:K().optional(),hint:K().optional()}),W4=ae({type:lt(["text","thinking"]),text:K().optional(),thinking:K().optional()}),H4=ae({success:Qe(),error:V4.optional(),model:K().optional(),inputTokens:ve().optional(),outputTokens:ve().optional(),cacheCreationInputTokens:ve().optional(),cacheReadInputTokens:ve().optional(),latencyMs:ve().optional(),content:Pe(W4).optional(),rawResponse:K().optional(),streaming:Qe().optional(),streamingChunks:ae({chunks:Pe(Qu),truncated:Qe().default(!1)}).optional(),requestHeaders:Wt(K(),K()).optional()}),eu=Kt([H4,ae({notConfigured:Se(!0)}),ae({testing:Se(!0)})]),Io=ae({nonStreaming:eu,streaming:eu}),q4=ae({anthropic:Io,openai:Io}),K4=ae({anthropic:Io,openai:Io,models:Wt(K(),q4).optional(),testedAt:K().optional()});function G4(){return{anthropic:{nonStreaming:{testing:!0},streaming:{testing:!0}},openai:{nonStreaming:{testing:!0},streaming:{testing:!0}}}}function tu(e,t){const n=()=>({nonStreaming:{success:!1,error:{message:e,type:t}},streaming:{notConfigured:!0}});return{anthropic:n(),openai:n()}}const J4=ae({providerConfig:K()}),Y4=ae({success:Qe().optional(),imported:ve().optional(),message:K().optional(),errors:Pe(K()).optional()}),X4=30,Ws="Network error: could not reach the server. Is the proxy running?";function nu(e){return{name:e.name,apiKey:e.apiKey,models:e.models,anthropicBaseUrl:(e.anthropicBaseUrl?.length??0)>0?e.anthropicBaseUrl:void 0,openaiBaseUrl:(e.openaiBaseUrl?.length??0)>0?e.openaiBaseUrl:void 0,apiDocsUrl:(e.apiDocsUrl?.length??0)>0?e.apiDocsUrl:void 0,source:e.source}}function Q4({externalProviders:e,isLoading:t=!1,externalTestResults:n,externalTestingProviders:r,externalTestingTimeLeft:o,onProvidersMutate:s,onTestResultsChange:i,onTestingProvidersChange:a,onTestingTimeLeftChange:c}){const[u,d]=v.useState(!1),[h,p]=v.useState(),[f,g]=v.useState(null),[m,x]=v.useState({}),[y,b]=v.useState(new Set),[k,S]=v.useState({}),[C,j]=v.useState(null),[N,T]=v.useState(!1),[A,O]=v.useState(null),[L,E]=v.useState(!1),[M,w]=v.useState(!1),[D,H]=v.useState(null),[B,q]=v.useState("all"),Y=v.useRef(null),I=v.useRef(null),W=e??[],V=v.useMemo(()=>{const U=B==="all"?W:W.filter(J=>J.source===B);return B==="all"?[...U].sort((J,$)=>{const ne={personal:0,company:1};return(ne[J.source??""]??2)-(ne[$.source??""]??2)}):U},[W,B]),z=n??m,oe=r??y,X=o??k,de=c?(U,J)=>c(U,J):(U,J)=>{S(J===void 0?$=>{const ne={...$};return delete ne[U],ne}:$=>({...$,[U]:J}))};v.useEffect(()=>{(async()=>{try{const U=await fetch("/api/config/paths");if(U.ok){const J=await In(U,J4);j(J.providerConfig)}}catch{}})()},[]);const te=v.useCallback(U=>{I.current!==null&&clearTimeout(I.current),O(U),Y.current?.scrollTo({top:Y.current.scrollHeight,behavior:"smooth"}),I.current=setTimeout(()=>{O(null),I.current=null},2e3)},[]);v.useEffect(()=>()=>{I.current!==null&&clearTimeout(I.current)},[]);const ce=v.useCallback(()=>{s?.().catch(()=>{})},[s]),fe=v.useCallback((U,J)=>{i?i(U,J):x($=>({...$,[U]:J}))},[i]),ge=v.useCallback((U,J)=>{if(a){a(U,J);return}b($=>{const ne=new Set($);return J?ne.add(U):ne.delete(U),ne})},[a]),xe=v.useCallback(async U=>{fe(U,G4()),ge(U,!0);const J=new AbortController;let $=X4;de(U,$);const ne=setInterval(()=>{$--,de(U,$),$<=0&&(clearInterval(ne),J.abort())},1e3);try{const le=await fetch(`/api/providers/${U}/test`,{method:"POST",signal:J.signal});if(le.ok){const se=await In(le,K4);fe(U,se)}else fe(U,tu(`HTTP ${le.status}: ${le.statusText}`,"server_error"))}catch(le){le instanceof Error&&le.name==="AbortError"&&fe(U,tu("Request timed out","timeout"))}finally{clearInterval(ne),de(U,void 0),ge(U,!1)}},[de,fe,ge]);function Ee(U){(async()=>{try{const J=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(nu(U))});if(!J.ok){g(await no(J,"Failed to add provider"));return}const $=await In(J,Ni);d(!1),te($.id),ce(),await xe($.id)}catch{g(Ws)}})()}function Oe(U){h&&(async()=>{try{const J=await fetch(`/api/providers/${h.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(nu(U))});if(!J.ok){g(await no(J,"Failed to update provider"));return}const $=await In(J,Ni);p(void 0),te($.id),ce(),((U.apiKey??"")!==(h.apiKey??"")||JSON.stringify(U.models)!==JSON.stringify(h.models)||(U.anthropicBaseUrl??"")!==(h.anthropicBaseUrl??"")||(U.openaiBaseUrl??"")!==(h.openaiBaseUrl??""))&&await xe($.id)}catch{g(Ws)}})()}function _(U){H(U),w(!0)}function ee(){const U=D;U!==null&&(async()=>{let J;try{J=await fetch(`/api/providers/${U}`,{method:"DELETE"})}catch{g(Ws);return}if(!J.ok){g(await no(J,"Failed to delete provider"));return}ce()})()}const G=v.useRef(null);function P(U){const J="/api/providers/export";(async()=>{try{const $=await fetch(J);if(!$.ok){g("Failed to export providers");return}const ne=await $.blob(),le=URL.createObjectURL(ne),se=document.createElement("a");se.href=le,se.download=$.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(se),se.click(),document.body.removeChild(se),URL.revokeObjectURL(le)}catch{g("Failed to export providers")}})()}function R(){G.current?.click()}function F(U){const J=U.target.files?.[0];J&&(async()=>{try{const $=await J.text(),ne=await fetch("/api/providers/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)}),le=await In(ne,Y4);ne.ok&&le.imported!==void 0&&le.imported>0?(ce(),g(null)):le.errors&&le.errors.length>0?g(le.errors.join("; ")):g(le.message??"Import failed")}catch{g("Failed to import providers")}U.target.value=""})()}return t?l.jsx("div",{className:"flex items-center justify-center py-8",children:l.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):u||h?l.jsxs("div",{className:"space-y-4",children:[l.jsx("div",{className:"flex items-center justify-between sticky top-0 bg-background z-10 pb-2",children:l.jsx("h3",{className:"text-lg font-medium",children:h?"Edit Provider":"Add New Provider"})}),l.jsx(U4,{provider:h,onSubmit:h?Oe:Ee,onCancel:()=>{d(!1),p(void 0)}})]}):l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between sticky top-0 z-10 bg-background pb-2",children:[l.jsx("h3",{className:"text-lg font-medium",children:"Providers"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs(Xe,{variant:"outline",size:"sm",onClick:()=>P(),className:"gap-1 hover:bg-muted",children:[l.jsx(Zi,{className:"size-3"}),"Export"]})}),l.jsx($e,{children:"Download providers as JSON for backup or sharing"})]})}),l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs(Xe,{variant:"outline",size:"sm",onClick:R,className:"gap-1 hover:bg-muted",children:[l.jsx(Tv,{className:"size-3"}),"Import"]})}),l.jsx($e,{children:"Import providers from an exported JSON file"})]})}),l.jsx("input",{type:"file",ref:G,accept:".json",onChange:F,style:{display:"none"}}),l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsxs(Xe,{variant:"outline",size:"sm",onClick:()=>E(!0),className:"gap-1",children:[l.jsx(vv,{className:"size-3"}),"Scan"]})}),l.jsx($e,{children:"Detect and import provider configs from Claude Code and OpenCode"})]})}),l.jsxs(Xe,{onClick:()=>d(!0),size:"sm",className:"gap-1",children:[l.jsx(ho,{className:"size-4"}),"Add Provider"]})]})]}),C!==null&&l.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground bg-muted/30 rounded-md px-3 py-2",children:[l.jsx("span",{className:"shrink-0",children:"Config:"}),l.jsx("span",{className:"font-mono truncate",title:C,children:C}),l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("button",{type:"button",onClick:()=>{window.navigator.clipboard.writeText(C).then(()=>{T(!0),setTimeout(()=>T(!1),2e3)})},className:"shrink-0 ml-auto text-muted-foreground hover:text-foreground transition-colors",children:N?l.jsx(Gt,{className:"size-3 text-green-500"}):l.jsx(wn,{className:"size-3"})})}),l.jsx($e,{children:"Copy config file path to clipboard"})]})})]}),f!==null&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive bg-destructive/10 rounded-md px-3 py-2",children:[l.jsx(_r,{className:"size-4 shrink-0"}),f]}),W.length===0?l.jsxs("div",{className:"text-center py-12 space-y-3",children:[l.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),l.jsxs(Xe,{onClick:()=>d(!0),variant:"outline",size:"sm",children:[l.jsx(ho,{className:"size-4"}),"Add Your First Provider"]})]}):l.jsxs("div",{className:"space-y-3",children:[l.jsx("div",{className:"flex gap-1 border-b border-border",children:["all","personal","company"].map(U=>l.jsx(Je,{children:l.jsxs(Le,{children:[l.jsx(Fe,{asChild:!0,children:l.jsx("button",{type:"button",onClick:()=>q(U),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${B===U?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:U==="all"?"All":U==="personal"?"Personal":"Company"})}),l.jsx($e,{children:U==="all"?"Show all providers":U==="personal"?"Providers you configured yourself":"Providers set by your organization"})]})},U))}),l.jsx("div",{ref:Y,className:"space-y-3",children:V.map(U=>l.jsx($4,{provider:U,testResults:z[U.id],isTesting:oe.has(U.id),testingTimeLeft:X[U.id],isHighlighted:U.id===A,onEdit:J=>p(J),onDelete:_,onTest:J=>{xe(J)}},U.id))})]}),l.jsx(P4,{open:L,onOpenChange:E,onImportComplete:()=>{s!==void 0&&s()}}),l.jsx(Hh,{open:M,onOpenChange:w,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:ee})]})}async function eT(e){return Ar(e,Ni.array(),void 0,t=>`Failed to fetch ${e}: ${t.status}`)}function tT(){const e=zi("/api/providers",eT,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function nT(){const[e,t]=v.useState(!1),[n,r]=v.useState("providers"),{providers:o,isLoading:s,mutate:i}=tT(),[a,c]=v.useState({}),[u,d]=v.useState(new Set),[h,p]=v.useState({}),f=v.useCallback((x,y)=>{c(b=>({...b,[x]:y}))},[]),g=v.useCallback((x,y)=>{d(b=>{const k=new Set(b);return y?k.add(x):k.delete(x),k})},[]),m=v.useCallback((x,y)=>{p(b=>{if(y===void 0){const k={...b};return delete k[x],k}return{...b,[x]:y}})},[]);return l.jsxs(rs,{open:e,onOpenChange:t,children:[l.jsx(RS,{asChild:!0,children:l.jsxs(Xe,{variant:"ghost",size:"icon",className:"size-8",children:[l.jsx(_v,{className:"size-4"}),l.jsx("span",{className:"sr-only",children:"Settings"})]})}),l.jsxs(os,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[l.jsx(ss,{children:l.jsx(is,{children:"Settings"})}),l.jsxs(Pn,{value:n,onValueChange:r,className:"flex-1 overflow-hidden",children:[l.jsxs(On,{children:[l.jsx(tt,{value:"providers",children:"Providers"}),l.jsx(tt,{value:"proxy",children:"Proxy"})]}),l.jsxs("div",{className:"mt-4 overflow-y-auto flex-1 pr-3",children:[l.jsx(nt,{value:"providers",children:l.jsx(Q4,{externalProviders:o,isLoading:s,externalTestResults:a,externalTestingProviders:u,externalTestingTimeLeft:h,onProvidersMutate:()=>i(),onTestResultsChange:f,onTestingProvidersChange:g,onTestingTimeLeftChange:m})}),l.jsx(nt,{value:"proxy",children:l.jsx(rT,{})})]})]})]})]})}function rT(){const{strip:e,isLoading:t,setStrip:n}=ed(),[r,o]=v.useState(null),[s,i]=v.useState(!1),a=v.useCallback(async c=>{o(null),i(!0);try{await n(c)}catch(u){o(u instanceof Error?u.message:String(u))}finally{i(!1)}},[n]);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:["When enabled, the proxy strips the synthetic ",l.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 ",l.jsx("code",{children:"LLM_INSPECTOR_STRIP_CLAUDE_CODE_BILLING_HEADER"})," environment variable; your choice is persisted to ",l.jsx("code",{children:"config.json"})," and overrides the env var for subsequent requests."]})]}),l.jsxs("label",{className:"flex items-center gap-3",children:[l.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:t||s,onChange:c=>{a(c.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),l.jsx("span",{className:"text-sm",children:t?"Loading…":e?"Stripping enabled":"Stripping disabled"})]}),r!==null&&l.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",r]})]})}function oT(e){const t=new Map;for(const n of e){const r=n.logs;for(let o=1;o<r.length;o++){const s=r[o-1],i=r[o];s===void 0||i===void 0||t.set(i.id,{creation:ru(s.cacheCreationInputTokens,i.cacheCreationInputTokens),read:ru(s.cacheReadInputTokens,i.cacheReadInputTokens)})}}return t}function ru(e,t){return t===null||e===null?null:t>e?{direction:"up",delta:t-e}:t<e?{direction:"down",delta:e-t}:null}const sT="";function mr(e){if(e.length===0)return sT;let t="";for(let n=0;n<e.length;n++){const r=e[n];r!==void 0&&(typeof r=="number"?t+=`[${r}]`:n===0?t+=r:t+=`.${r}`)}return t}function iT(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ou(e){if(typeof e=="string")try{return zo(JSON.parse(e))}catch{return{kind:"primitive",value:e}}return zo(e)}function zo(e){if(e===null)return{kind:"primitive",value:null};if(typeof e=="string")return{kind:"primitive",value:e};if(typeof e=="number")return{kind:"primitive",value:e};if(typeof e=="boolean")return{kind:"primitive",value:e};if(Array.isArray(e))return{kind:"array",value:e.map(t=>zo(t))};if(iT(e)){const t={};for(const n of Object.keys(e).sort())t[n]=zo(e[n]);return{kind:"object",value:t}}return{kind:"primitive",value:null}}function aT(e,t){const n=[];return Ti([],e,t,n),n}function Ti(e,t,n,r){const o=mr(e);if(Ai(t,n)){r.push({kind:"equal",path:o,value:t});return}if(t.kind!==n.kind){r.push({kind:"changed",path:o,left:t,right:n});return}if(t.kind==="primitive"&&n.kind==="primitive"){r.push({kind:"changed",path:o,left:t,right:n});return}if(t.kind==="object"&&n.kind==="object"){const s=Object.keys(t.value),i=Object.keys(n.value),a=new Set(i);for(const c of s){const u=t.value[c];if(u!==void 0)if(!a.has(c))r.push({kind:"removed",path:mr([...e,c]),value:u});else{const d=n.value[c];if(d===void 0)continue;Ti([...e,c],u,d,r)}}for(const c of i){if(s.includes(c))continue;const u=n.value[c];u!==void 0&&r.push({kind:"added",path:mr([...e,c]),value:u})}return}if(t.kind==="array"&&n.kind==="array"){const s=Math.min(t.value.length,n.value.length);for(let i=0;i<s;i++){const a=t.value[i],c=n.value[i];a===void 0||c===void 0||Ti([...e,i],a,c,r)}for(let i=s;i<n.value.length;i++){const a=n.value[i];a!==void 0&&r.push({kind:"added",path:mr([...e,i]),value:a})}for(let i=s;i<t.value.length;i++){const a=t.value[i];a!==void 0&&r.push({kind:"removed",path:mr([...e,i]),value:a})}}}function Ai(e,t){if(e.kind!==t.kind)return!1;if(e.kind==="primitive"&&t.kind==="primitive")return e.value===t.value;if(e.kind==="array"&&t.kind==="array"){if(e.value.length!==t.value.length)return!1;for(let n=0;n<e.value.length;n++){const r=e.value[n],o=t.value[n];if(r===void 0||o===void 0||!Ai(r,o))return!1}return!0}if(e.kind==="object"&&t.kind==="object"){const n=Object.keys(e.value),r=Object.keys(t.value);if(n.length!==r.length)return!1;for(const o of n){const s=e.value[o],i=t.value[o];if(s===void 0||i===void 0||!Ai(s,i))return!1}return!0}return!1}function Et(e,t=80){let n;switch(e.kind){case"primitive":n=e.value===null?"null":JSON.stringify(e.value);break;case"array":n=`[… ${e.value.length} items]`;break;case"object":n=`{… ${Object.keys(e.value).length} keys}`;break}return n.length>t&&(n=`${n.slice(0,t-1)}…`),n}function lo(e,t=2){return JSON.stringify(Ii(e),null,t)}function Ii(e){switch(e.kind){case"primitive":return e.value;case"array":return e.value.map(Ii);case"object":{const t={};for(const[n,r]of Object.entries(e.value))t[n]=Ii(r);return t}}}function su(e){if(e==="")return"";for(let t=e.length-1;t>=0;t--){const n=e[t];if(n==="."||n==="[")return e.substring(0,t)}return""}function iu(e){return e.kind==="equal"&&(e.value.kind==="object"||e.value.kind==="array")}function lT(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(r!==void 0&&iu(r)){const o=su(r.path);let s=n+1;for(;s<e.length;){const i=e[s];if(i===void 0||!iu(i)||su(i.path)!==o)break;s++}if(s-n>1){const i=[];for(let a=n;a<s;a++){const c=e[a];c!==void 0&&c.kind==="equal"&&i.push(c)}t.push({kind:"equal-run",ops:i}),n=s;continue}}r!==void 0&&t.push({kind:"single",op:r}),n++}return t}const Wp={added:{icon:ho,accent:"text-emerald-600 dark:text-emerald-400",bg:"bg-emerald-500/5 hover:bg-emerald-500/10",border:"border-l-emerald-500",label:"ADDED"},removed:{icon:Hi,accent:"text-rose-600 dark:text-rose-400",bg:"bg-rose-500/5 hover:bg-rose-500/10",border:"border-l-rose-500",label:"REMOVED"},changed:{icon:qi,accent:"text-amber-600 dark:text-amber-400",bg:"bg-amber-500/5 hover:bg-amber-500/10",border:"border-l-amber-500",label:"CHANGED"},equal:{icon:Ky,accent:"text-muted-foreground/70",bg:"bg-muted/20 hover:bg-muted/30",border:"border-l-muted-foreground/20",label:"EQUAL"}};function cT({ops:e,expanded:t,onToggle:n}){const r=e[0],o=e[e.length-1];if(r===void 0||o===void 0)return l.jsx("div",{className:"text-muted-foreground/40 text-xs",children:"—"});const s=r.path,i=o.path,a=e.length===1?s:`${s} … ${i}`,c=r.value.kind==="array"?`${e.length} equal arrays`:r.value.kind==="object"?`${e.length} equal objects`:"equal",u=Wp.equal;return l.jsxs("div",{className:he("border-l-4 rounded-sm",u.border,u.bg),children:[l.jsxs("button",{type:"button",onClick:n,className:"w-full text-left flex items-center gap-2 px-3 py-1.5 text-xs text-muted-foreground cursor-pointer",children:[l.jsx(bt,{className:he("size-3 transition-transform shrink-0",t&&"rotate-90")}),l.jsx(u.icon,{className:he("size-3 shrink-0",u.accent)}),l.jsx("span",{className:"font-mono truncate flex-1",title:`${s} … ${i}`,children:a}),l.jsx("span",{className:he("text-[10px] uppercase tracking-wider shrink-0",u.accent),children:u.label}),l.jsxs("span",{className:"text-muted-foreground/60 shrink-0",children:["(",c,")"]})]}),t&&l.jsx("div",{className:"ml-5 mt-1 mb-2 space-y-2 pr-2",children:e.map(d=>l.jsxs("div",{className:"border border-border/50 rounded p-2 bg-muted/20",children:[l.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-1",children:d.path}),l.jsx(fn,{text:lo(d.value),defaultExpandDepth:2})]},d.path))})]})}function uT({op:e,idx:t,copiedPath:n,onCopyPath:r,expanded:o,onToggle:s}){const i=Wp[e.kind],a=i.icon,c=e.kind==="added"||e.kind==="removed"?e.value.kind==="object"||e.value.kind==="array":e.kind==="changed"?e.left.kind==="object"||e.left.kind==="array"||e.right.kind==="object"||e.right.kind==="array":!1,u=e.kind==="changed"?[{text:Et(e.left,400),tone:"text-rose-700 dark:text-rose-300 line-through"},{text:Et(e.right,400),tone:"text-emerald-700 dark:text-emerald-300"}]:e.kind==="removed"?[{text:Et(e.value,400),tone:"text-rose-700 dark:text-rose-300 line-through"}]:e.kind==="added"?[{text:Et(e.value,400),tone:"text-emerald-700 dark:text-emerald-300"}]:[{text:Et(e.value,400),tone:"text-muted-foreground"}],d=n===e.path&&e.path!=="";return l.jsxs("div",{"data-diff-idx":t,"data-diff-kind":e.kind,className:he("border-l-4 rounded-sm px-3 py-2 my-0.5 transition-colors",i.border,i.bg),children:[l.jsxs("button",{type:"button",onClick:s,disabled:!c,className:he("w-full flex items-center gap-2 text-xs text-left rounded-sm",c?"cursor-pointer":"cursor-default"),"aria-expanded":c?o:void 0,"aria-label":c?o?`Collapse ${e.path||"root"}`:`Expand ${e.path||"root"}`:void 0,children:[c?l.jsx(bt,{className:he("size-3 shrink-0 transition-transform",i.accent,o&&"rotate-90")}):l.jsx("span",{className:"size-3 shrink-0","aria-hidden":"true"}),l.jsx(a,{className:he("size-3.5 shrink-0",i.accent),strokeWidth:2.5}),l.jsx("span",{className:"font-mono truncate flex-1 min-w-0",title:e.path||"(root)",children:e.path===""?"(root)":e.path}),l.jsx("span",{className:he("text-[9px] font-bold uppercase tracking-wider shrink-0 px-1.5 py-0.5 rounded",i.accent,e.kind==="equal"?"bg-muted/40":"bg-background/60"),children:i.label}),e.path!==""&&l.jsx("span",{role:"button",tabIndex:0,onClick:h=>{h.stopPropagation(),r(e.path)},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.stopPropagation(),h.preventDefault(),r(e.path))},className:he("shrink-0 p-1 rounded transition-colors cursor-pointer inline-flex items-center justify-center",d?"text-emerald-500":"text-muted-foreground/50 hover:text-foreground hover:bg-muted"),"aria-label":d?"Copied":"Copy path",title:d?"Copied!":"Copy path",children:d?l.jsx(Gt,{className:"size-3"}):l.jsx(wn,{className:"size-3"})})]}),u.map((h,p)=>l.jsx("div",{className:he("font-mono text-xs mt-1 break-all pl-5",h.tone),children:h.text},p)),l.jsx("div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:o&&c?"2000px":"0"},"aria-hidden":!o,children:o&&c&&e.kind!=="equal"?l.jsx(dT,{op:e}):null})]})}function dT({op:e}){if(e.kind==="added"||e.kind==="removed")return l.jsx("div",{className:"pl-5 mt-2 border border-border/50 rounded p-2 bg-muted/20",children:l.jsx(fn,{text:lo(e.value),defaultExpandDepth:2})});const t=e.left.kind==="object"||e.left.kind==="array",n=e.right.kind==="object"||e.right.kind==="array";return!t&&!n?l.jsx("div",{className:"pl-5 mt-2 text-xs text-muted-foreground/70 italic",children:"Primitive values are shown inline above."}):l.jsxs("div",{className:"pl-5 mt-2 grid grid-cols-1 md:grid-cols-2 gap-2",children:[l.jsxs("div",{className:"border border-rose-500/30 rounded p-2 bg-rose-500/5",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-wider text-rose-500 mb-1",children:"Old"}),l.jsx(fn,{text:lo(e.left),defaultExpandDepth:2})]}),l.jsxs("div",{className:"border border-emerald-500/30 rounded p-2 bg-emerald-500/5",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-wider text-emerald-500 mb-1",children:"New"}),l.jsx(fn,{text:lo(e.right),defaultExpandDepth:2})]})]})}function fT({counts:e,onJumpTo:t}){const n=e.added+e.removed+e.changed;return l.jsxs("div",{className:"px-4 py-2 border-b border-border bg-muted/20 flex items-center gap-2 text-xs flex-wrap",children:[l.jsxs("span",{className:"text-muted-foreground font-medium",children:[n," ",n===1?"change":"changes"]}),l.jsxs("button",{type:"button",onClick:()=>t("removed"),disabled:e.removed===0,className:he("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.removed>0?"border-rose-500/40 text-rose-600 dark:text-rose-400 bg-rose-500/10 hover:bg-rose-500/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.removed>0?"Jump to first removed":"No removals",children:[l.jsx(Hi,{className:"size-3"}),e.removed," removed"]}),l.jsxs("button",{type:"button",onClick:()=>t("added"),disabled:e.added===0,className:he("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.added>0?"border-emerald-500/40 text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 hover:bg-emerald-500/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.added>0?"Jump to first added":"No additions",children:[l.jsx(ho,{className:"size-3"}),e.added," added"]}),l.jsxs("button",{type:"button",onClick:()=>t("changed"),disabled:e.changed===0,className:he("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.changed>0?"border-amber-500/40 text-amber-600 dark:text-amber-400 bg-amber-500/10 hover:bg-amber-500/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.changed>0?"Jump to first changed":"No changes",children:[l.jsx(qi,{className:"size-3"}),e.changed," changed"]})]})}function hT({mode:e,onChange:t}){return l.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[l.jsxs("button",{type:"button",onClick:()=>t("unified"),"aria-pressed":e==="unified",className:he("flex items-center gap-1 px-2 py-1 text-xs transition-colors cursor-pointer",e==="unified"?"bg-muted text-foreground":"hover:bg-muted/50 text-muted-foreground"),title:"Unified view (single column, emphasized diffs)",children:[l.jsx(ld,{className:"size-3"}),"Unified"]}),l.jsxs("button",{type:"button",onClick:()=>t("split"),"aria-pressed":e==="split",className:he("flex items-center gap-1 px-2 py-1 text-xs transition-colors border-l border-border cursor-pointer",e==="split"?"bg-muted text-foreground":"hover:bg-muted/50 text-muted-foreground"),title:"Split view (path | left | right)",children:[l.jsx(rd,{className:"size-3"}),"Split"]})]})}function au({log:e,side:t}){const n=_o(e);return l.jsxs("div",{className:"flex-1 min-w-0 space-y-1 text-xs",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(xt,{variant:"outline",className:he("text-[10px] px-1.5 py-0 h-5 font-mono shrink-0",t==="left"?"border-rose-500/40 text-rose-400":"border-emerald-500/40 text-emerald-400"),children:t==="left"?"← Left":"Right →"}),l.jsxs("span",{className:"font-mono text-blue-400/80",children:["#",e.id]}),e.model!==null&&l.jsx("span",{className:"font-mono text-muted-foreground truncate",children:e.model})]}),l.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground font-mono",children:[e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&l.jsxs("span",{className:"text-emerald-400",children:["Cache +",qe(e.cacheCreationInputTokens)]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&l.jsxs("span",{className:"text-purple-400",children:["Cache ~",qe(e.cacheReadInputTokens)]}),l.jsx("span",{className:"truncate",title:e.timestamp,children:e.timestamp})]}),l.jsxs("div",{className:"text-muted-foreground/70 font-mono truncate",title:n,children:["session: ",n]})]})}function pT({left:e,right:t,onClose:n}){const r=v.useMemo(()=>{const j=Ao(Nr(e)).analyzeRequest(e.rawRequestBody),N=Ao(Nr(t)).analyzeRequest(t.rawRequestBody),T=ou(j.comparisonValue),A=ou(N.comparisonValue);return aT(T,A)},[e.apiFormat,e.path,e.rawRequestBody,t.apiFormat,t.path,t.rawRequestBody]),o=v.useMemo(()=>lT(r),[r]),s=v.useMemo(()=>{let j=0,N=0,T=0;for(const A of o)if(A.kind==="single")switch(A.op.kind){case"added":j++;break;case"removed":N++;break;case"changed":T++;break}return{added:j,removed:N,changed:T}},[o]),[i,a]=v.useState(new Set),c=j=>{a(N=>{const T=new Set(N);return T.has(j)?T.delete(j):T.add(j),T})},[u,d]=v.useState(new Set),h=j=>{d(N=>{const T=new Set(N);return T.has(j)?T.delete(j):T.add(j),T})};v.useEffect(()=>{d(new Set)},[e.id,t.id]);const[p,f]=v.useState("unified"),g=v.useRef(null),[m,x]=v.useState(null),y=v.useRef(null),b=j=>{window.navigator.clipboard.writeText(j).then(()=>{x(j),y.current!==null&&clearTimeout(y.current),y.current=setTimeout(()=>x(null),1500)})};v.useEffect(()=>()=>{y.current!==null&&clearTimeout(y.current)},[]);const k=j=>{const N=o.findIndex(O=>O.kind==="single"&&O.op.kind===j);if(N===-1)return;const T=g.current;if(T===null)return;const A=T.querySelector(`[data-diff-idx="${N}"]`);A!==null&&A.scrollIntoView({behavior:"smooth",block:"center"})};v.useEffect(()=>{const j=T=>{T.key==="Escape"&&n()};document.addEventListener("keydown",j);const N=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",j),document.body.style.overflow=N}},[n]);const S=_o(e)===_o(t),C=r.length===1&&r[0]?.kind==="equal";return l.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",role:"dialog","aria-modal":"true","aria-label":"Compare two log requests",children:[l.jsx("button",{type:"button",onClick:n,"aria-label":"Close compare drawer",className:"absolute inset-0 bg-black/40 cursor-default",tabIndex:-1}),l.jsxs("div",{className:he("relative bg-background border-l border-border shadow-xl","w-full md:w-[70vw] max-w-[1100px] flex flex-col h-full"),onClick:j=>j.stopPropagation(),onKeyDown:j=>j.stopPropagation(),children:[l.jsxs("div",{className:"flex items-start gap-4 px-4 py-3 border-b border-border",children:[l.jsxs("div",{className:"flex-1 flex gap-4 min-w-0",children:[l.jsx(au,{log:e,side:"left"}),l.jsx(au,{log:t,side:"right"})]}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[l.jsx(hT,{mode:p,onChange:f}),l.jsx("button",{type:"button",onClick:n,"aria-label":"Close",className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted cursor-pointer",children:l.jsx(Ki,{className:"size-4"})})]})]}),!S&&l.jsx("div",{className:"px-4 py-1.5 text-xs text-amber-400 bg-amber-500/10 border-b border-border",children:"Heads up: the two selected logs are from different sessions."}),C?l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto flex items-center justify-center text-muted-foreground text-sm",children:"The two Request payloads are identical."}):l.jsxs(l.Fragment,{children:[l.jsx(fT,{counts:s,onJumpTo:k}),l.jsx("div",{ref:g,className:"flex-1 min-h-0 overflow-y-auto",children:p==="unified"?l.jsx("div",{className:"px-3 py-2 space-y-0.5",children:o.map((j,N)=>{if(j.kind==="equal-run")return l.jsx(cT,{ops:j.ops,expanded:i.has(N),onToggle:()=>c(N)},`r${N}`);const T=j.op;return l.jsx(uT,{op:T,idx:N,copiedPath:m,onCopyPath:b,expanded:u.has(N),onToggle:()=>h(N)},`o${N}`)})}):l.jsx(mT,{grouped:o,left:e,right:t})})]})]})]})}function mT({grouped:e,left:t,right:n}){return l.jsxs("div",{className:"grid grid-cols-[200px_1fr_1fr] gap-x-2 gap-y-0.5 px-3 py-2 text-xs",children:[l.jsxs("div",{className:"grid grid-cols-[200px_1fr_1fr] gap-x-2 col-span-3 pb-2 mb-2 border-b border-border text-[10px] uppercase tracking-wider text-muted-foreground",children:[l.jsx("span",{children:"Path"}),l.jsxs("span",{children:["Left (Log #",t.id,")"]}),l.jsxs("span",{children:["Right (Log #",n.id,")"]})]}),e.map((r,o)=>{if(r.kind==="equal-run")return l.jsxs("div",{className:"col-span-3 px-2 py-1 text-xs text-muted-foreground/60",children:[r.ops.length," equal siblings collapsed — switch to Unified to expand"]},o);const s=r.op;return s.kind==="equal"?l.jsxs("div",{className:"col-span-3 grid grid-cols-[200px_1fr_1fr] gap-x-2 px-2 py-0.5 text-muted-foreground",children:[l.jsx("span",{className:"font-mono text-xs truncate",title:s.path,children:s.path}),l.jsx("span",{className:"font-mono text-xs break-all opacity-60",children:Et(s.value,200)}),l.jsx("span",{className:"font-mono text-xs break-all opacity-60",children:Et(s.value,200)})]},o):s.kind==="added"?l.jsxs("div",{className:"col-span-3 px-2 py-1 rounded text-xs border-l-2 border-l-emerald-400/70 bg-emerald-500/5",children:[l.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-0.5",children:s.path}),l.jsxs("div",{className:"font-mono break-all text-emerald-300/90",children:["+ ",Et(s.value,400)]})]},o):s.kind==="removed"?l.jsxs("div",{className:"col-span-3 px-2 py-1 rounded text-xs border-l-2 border-l-rose-400/70 bg-rose-500/5",children:[l.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-0.5",children:s.path}),l.jsxs("div",{className:"font-mono break-all text-rose-300/90 line-through",children:["− ",Et(s.value,400)]})]},o):l.jsxs("div",{className:"col-span-3 px-2 py-1 rounded text-xs border-l-2 border-l-amber-400/70 bg-amber-500/5",children:[l.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-1",children:s.path}),l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsx("div",{className:"font-mono text-rose-300/90 break-all line-through",children:Et(s.left,400)}),l.jsx("div",{className:"font-mono text-emerald-300/90 break-all",children:Et(s.right,400)})]})]},o)})]})}function gT(e){return e.length<=30?e:e.slice(0,12)+"…"+e.slice(-12)}function xT(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 yT({command:e}){const[t,n]=v.useState(!1),r=v.useCallback(()=>{window.navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},[e]);return l.jsxs("div",{className:"inline-flex items-center gap-2 bg-muted rounded-md px-3 py-2",children:[l.jsx("pre",{className:"text-blue-500 font-mono text-sm m-0",children:e}),l.jsx("button",{type:"button",onClick:r,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 cursor-pointer","aria-label":"Copy command",children:t?l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M20 6 9 17l-5-5"})}):l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),l.jsx("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})})]})}function vT({logs:e,sessions:t,models:n,selectedSession:r,selectedModel:o,onSessionChange:s,onModelChange:i,onClearAll:a,onClearGroup:c,viewMode:u,onViewModeChange:d,strip:h}){const{totalIn:p,totalOut:f}=v.useMemo(()=>xT(e),[e]),[g,m]=v.useState(!1),[x,y]=v.useState(null),[b,k]=v.useState("hidden");v.useEffect(()=>{const E=50+So.length*400,M=setTimeout(()=>k("playing"),50),w=setTimeout(()=>k("done"),E);return()=>{clearTimeout(M),clearTimeout(w)}},[]);const S=v.useCallback(async()=>{m(!0);try{await qv(e)}finally{m(!1)}},[e]);v.useEffect(()=>{y(null)},[r,o]);const C=v.useCallback(()=>{y(null)},[]),j=v.useMemo(()=>BS(e),[e]),N=v.useMemo(()=>oT(j),[j]),T=v.useMemo(()=>w4(j),[j]),A=v.useCallback(O=>{const L=T.get(O.id);L!==void 0&&y([L,O])},[T]);return l.jsxs("div",{className:"max-w-[1200px] mx-auto flex flex-col h-screen",style:{maxHeight:"100vh"},children:[l.jsxs("div",{className:"flex items-end px-6 pt-6 pb-8 relative",children:[l.jsxs("h1",{className:"text-lg font-bold flex items-end gap-2 absolute left-1/2 -translate-x-1/2 whitespace-nowrap",children:[l.jsxs("span",{className:"flex items-end gap-1 group cursor-default","aria-hidden":"true",children:[l.jsx(S4,{className:"size-10 text-amber-500 transition-all duration-300 group-hover:scale-125 group-hover:-translate-y-1.5"}),l.jsx("span",{className:"flex items-end gap-0.5",children:So.map((O,L)=>{const E=["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"][L],M=b==="hidden"?"opacity-0 scale-0":b==="playing"?"animate-crab-piano-pop":"";return l.jsx(O,{className:`size-5 ${E} transition-all duration-300 ease-out group-hover:scale-125 group-hover:-translate-y-1 ${M}`,style:{transitionDelay:`${L*50}ms`,...b==="playing"?{animationDelay:`${L*400}ms`}:{}}},L)})})]}),l.jsxs("span",{className:"flex items-baseline gap-2",children:["LLM Inspector",l.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["v",Gv.version]})]})]}),l.jsx("div",{className:"ml-auto",children:l.jsx(nT,{})})]}),l.jsxs("div",{className:"flex items-center gap-3 px-6 mb-4",children:[l.jsxs(Kc,{value:r,onValueChange:s,children:[l.jsx(Jc,{className:"flex-1 max-w-[350px] text-xs",children:l.jsx(Gc,{placeholder:"All sessions"})}),l.jsxs(Yc,{children:[l.jsx(eo,{value:"__all__",children:"All sessions"}),t.map(O=>l.jsx(eo,{value:O,children:gT(O)},O))]})]}),l.jsxs(Kc,{value:o,onValueChange:i,children:[l.jsx(Jc,{className:"flex-1 max-w-[250px] text-xs",children:l.jsx(Gc,{placeholder:"All models"})}),l.jsxs(Yc,{children:[l.jsx(eo,{value:"__all__",children:"All models"}),n.map(O=>l.jsx(eo,{value:O,children:O},O))]})]}),l.jsxs("div",{className:"flex items-center border border-border rounded-md overflow-hidden",children:[l.jsx("button",{type:"button",onClick:()=>d("simple"),className:`px-2 py-1 cursor-pointer transition-colors text-xs ${u==="simple"?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/50"}`,children:"Simple"}),l.jsx("button",{type:"button",onClick:()=>d("full"),className:`px-2 py-1 cursor-pointer transition-colors text-xs ${u==="full"?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/50"}`,children:"Full"})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("span",{className:"text-muted-foreground text-xs font-mono",children:[e.length," request",e.length!==1?"s":"",p>0||f>0?` · ${p.toLocaleString()} in / ${f.toLocaleString()} out`:""]}),e.length>0&&l.jsx("button",{type:"button",onClick:()=>{S()},disabled:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1",title:"Export all logs as JSON ZIP",children:g?l.jsx("span",{children:"Exporting..."}):l.jsxs(l.Fragment,{children:[l.jsx(Zi,{className:"size-3"}),l.jsx("span",{children:"Export"})]})}),l.jsx("button",{type:"button",onClick:a,className:"text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:"Clear all logs",children:"Clear"})]}),l.jsx("div",{className:"flex-1 min-h-0 px-6 pb-6",children:e.length===0?l.jsxs("div",{className:"text-center text-muted-foreground py-16 space-y-4",children:[l.jsx("p",{className:"text-sm",children:"No requests captured yet."}),l.jsx("p",{className:"text-xs",children:"Route AI coding tools through the proxy:"}),l.jsx(yT,{command:"LLM_BASE_URL=http://localhost:25947/proxy <your-tool>"})]}):l.jsx("div",{className:"overflow-y-auto h-full flex flex-col gap-2",children:j.map(O=>l.jsx(_4,{group:O,viewMode:u,strip:h,cacheTrends:N,onCompareWithPrevious:A,comparisonPredecessors:T,onClearGroup:c,standalone:j.length===1},O.id))})}),x!==null&&l.jsx(pT,{left:x[0],right:x[1],onClose:C})]})}const bT=Kt([ae({type:Se("init"),logs:Pe(ll)}),ae({type:Se("update"),log:ll})]);function Hs(e){const t=new Set;for(const n of e)n.sessionId!==null&&n.sessionId!==""&&t.add(n.sessionId);return[...t]}function qs(e){const t=new Set;for(const n of e)n.model!==null&&n.model!==""&&t.add(n.model);return[...t]}function wT(e,t,n){return t==="__all__"&&n==="__all__"?e:e.filter(r=>!(t!=="__all__"&&r.sessionId!==t||n!=="__all__"&&r.model!==n))}const kT=50;function _T(){const[e,t]=v.useState([]),[n,r]=v.useState([]),[o,s]=v.useState([]),[i,a]=v.useState("__all__"),[c,u]=v.useState("__all__"),[d,h]=v.useState("simple"),[p,f]=v.useState(null),g=v.useRef(null),m=v.useRef(null),x=v.useRef(new Map),y=v.useRef([]),b=v.useRef([]),k=v.useRef(null),S=v.useMemo(()=>wT(e,i,c),[e,i,c]),C=v.useCallback(()=>{k.current=null;const L=b.current;b.current=[],L.length!==0&&t(E=>{let M=E,w=!1,D=!1;for(const H of L){const B=x.current.get(H.id);B!==void 0?M=[...M.slice(0,B),H,...M.slice(B+1)]:(x.current.set(H.id,M.length),M=[...M,H]),H.sessionId!==null&&H.sessionId!==""&&!n.includes(H.sessionId)&&(w=!0),H.model!==null&&H.model!==""&&!o.includes(H.model)&&(D=!0)}return y.current=M,w&&r(H=>Hs(M)),D&&s(H=>qs(M)),M})},[n,o]),j=v.useCallback(L=>{b.current.push(L),k.current===null&&(k.current=setTimeout(C,kT))},[C]),N=v.useCallback(()=>{g.current&&g.current.close();const L=new EventSource("/api/logs/stream");g.current=L,L.onmessage=E=>{try{const M=String(E.data),w=JSON.parse(M),D=bT.safeParse(w);if(!D.success){f("Failed to parse SSE data");return}const H=D.data;if(H.type==="init"){k.current!==null&&(clearTimeout(k.current),k.current=null),b.current=[];const B=new Map;for(let q=0;q<H.logs.length;q++){const Y=H.logs[q];Y!==void 0&&B.set(Y.id,q)}x.current=B,y.current=H.logs,t(H.logs),r(Hs(H.logs)),s(qs(H.logs)),f(null)}else H.type==="update"&&j(H.log)}catch{f("Failed to parse SSE data")}},L.onerror=()=>{f("SSE connection lost, reconnecting..."),L.close(),m.current!==null&&clearTimeout(m.current),m.current=setTimeout(N,3e3)}},[j]);v.useEffect(()=>(N(),()=>{g.current&&(g.current.close(),g.current=null),m.current!==null&&(clearTimeout(m.current),m.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null)}),[N]);const T=v.useCallback(()=>{(async()=>{try{if(!(await fetch("/api/logs",{method:"DELETE"})).ok){f("Failed to clear logs");return}x.current.clear(),y.current=[],t([]),r([]),s([]),f(null)}catch(L){f(L instanceof Error?L.message:"Unknown error clearing logs")}})()},[]),A=v.useCallback(L=>{L.length!==0&&(async()=>{try{if(!(await fetch("/api/logs",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:L})})).ok){f("Failed to clear group");return}const M=new Set(L);t(w=>{const D=w.filter(B=>!M.has(B.id)),H=new Map;for(let B=0;B<D.length;B++){const q=D[B];q!==void 0&&H.set(q.id,B)}return x.current=H,y.current=D,r(Hs(D)),s(qs(D)),D}),f(null)}catch(E){f(E instanceof Error?E.message:"Unknown error clearing group")}})()},[]),{strip:O}=ed();return l.jsxs(l.Fragment,{children:[p!==null&&l.jsx("div",{className:"fixed top-4 right-4 bg-destructive text-destructive-foreground px-4 py-2 rounded-md text-sm z-50",children:p}),l.jsx(Uv,{}),l.jsx(vT,{logs:S,sessions:n,models:o,selectedSession:i,selectedModel:c,onSessionChange:a,onModelChange:u,onClearAll:T,onClearGroup:A,viewMode:d,onViewModeChange:h,strip:O})]})}const jT=_T;export{jT as component};