teodor-new-chat-ui 2.0.48 → 2.0.49

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.
package/dist/index.umd.js CHANGED
@@ -1,13 +1,13 @@
1
- (function(ae,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react/jsx-runtime"),require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom"),require("react-markdown"),require("remark-gfm")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","react-markdown","remark-gfm"],i):(ae=typeof globalThis<"u"?globalThis:ae||self,i(ae.NewChatUI={},ae.jsxRuntime,ae.React,ae.LucideReact,ae.reactSlot,ae.classVarianceAuthority,ae.clsx,ae.tailwindMerge,ae.ReactDOM,ae.ReactMarkdown,ae.remarkGfm))})(this,function(ae,i,N,q,Be,Yt,eu,tu,Ts,nu,ru){"use strict";var Wr=typeof document<"u"?document.currentScript:null;function As(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const l=As(N),Nn=As(Ts);function Is(e,t){return function(){return e.apply(t,arguments)}}const{toString:ou}=Object.prototype,{getPrototypeOf:jr}=Object,{iterator:Tn,toStringTag:ks}=Symbol,An=(e=>t=>{const n=ou.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ve=e=>(e=e.toLowerCase(),t=>An(t)===e),In=e=>t=>typeof t===e,{isArray:Mt}=Array,Dt=In("undefined");function Jt(e){return e!==null&&!Dt(e)&&e.constructor!==null&&!Dt(e.constructor)&&Me(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const _s=Ve("ArrayBuffer");function su(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&_s(e.buffer),t}const au=In("string"),Me=In("function"),Ps=In("number"),Zt=e=>e!==null&&typeof e=="object",iu=e=>e===!0||e===!1,kn=e=>{if(An(e)!=="object")return!1;const t=jr(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ks in e)&&!(Tn in e)},cu=e=>{if(!Zt(e)||Jt(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},lu=Ve("Date"),du=Ve("File"),uu=Ve("Blob"),fu=Ve("FileList"),pu=e=>Zt(e)&&Me(e.pipe),hu=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Me(e.append)&&((t=An(e))==="formdata"||t==="object"&&Me(e.toString)&&e.toString()==="[object FormData]"))},gu=Ve("URLSearchParams"),[mu,bu,vu,wu]=["ReadableStream","Request","Response","Headers"].map(Ve),yu=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Qt(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Mt(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Jt(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),a=s.length;let c;for(r=0;r<a;r++)c=s[r],t.call(null,e[c],c,e)}}function Os(e,t){if(Jt(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const St=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ms=e=>!Dt(e)&&e!==St;function Vr(){const{caseless:e,skipUndefined:t}=Ms(this)&&this||{},n={},r=(o,s)=>{const a=e&&Os(n,s)||s;kn(n[a])&&kn(o)?n[a]=Vr(n[a],o):kn(o)?n[a]=Vr({},o):Mt(o)?n[a]=o.slice():(!t||!Dt(o))&&(n[a]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Qt(arguments[o],r);return n}const xu=(e,t,n,{allOwnKeys:r}={})=>(Qt(t,(o,s)=>{n&&Me(o)?e[s]=Is(o,n):e[s]=o},{allOwnKeys:r}),e),Su=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Cu=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Eu=(e,t,n,r)=>{let o,s,a;const c={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)a=o[s],(!r||r(a,e,t))&&!c[a]&&(t[a]=e[a],c[a]=!0);e=n!==!1&&jr(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Nu=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Tu=e=>{if(!e)return null;if(Mt(e))return e;let t=e.length;if(!Ps(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Au=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&jr(Uint8Array)),Iu=(e,t)=>{const r=(e&&e[Tn]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},ku=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},_u=Ve("HTMLFormElement"),Pu=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Ds=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Ou=Ve("RegExp"),Ls=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Qt(n,(o,s)=>{let a;(a=t(o,s,e))!==!1&&(r[s]=a||o)}),Object.defineProperties(e,r)},Mu=e=>{Ls(e,(t,n)=>{if(Me(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Me(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Du=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Mt(e)?r(e):r(String(e).split(t)),n},Lu=()=>{},Fu=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function $u(e){return!!(e&&Me(e.append)&&e[ks]==="FormData"&&e[Tn])}const Bu=e=>{const t=new Array(10),n=(r,o)=>{if(Zt(r)){if(t.indexOf(r)>=0)return;if(Jt(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Mt(r)?[]:{};return Qt(r,(a,c)=>{const d=n(a,o+1);!Dt(d)&&(s[c]=d)}),t[o]=void 0,s}}return r};return n(e,0)},Uu=Ve("AsyncFunction"),Hu=e=>e&&(Zt(e)||Me(e))&&Me(e.then)&&Me(e.catch),Fs=((e,t)=>e?setImmediate:t?((n,r)=>(St.addEventListener("message",({source:o,data:s})=>{o===St&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),St.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Me(St.postMessage)),zu=typeof queueMicrotask<"u"?queueMicrotask.bind(St):typeof process<"u"&&process.nextTick||Fs,S={isArray:Mt,isArrayBuffer:_s,isBuffer:Jt,isFormData:hu,isArrayBufferView:su,isString:au,isNumber:Ps,isBoolean:iu,isObject:Zt,isPlainObject:kn,isEmptyObject:cu,isReadableStream:mu,isRequest:bu,isResponse:vu,isHeaders:wu,isUndefined:Dt,isDate:lu,isFile:du,isBlob:uu,isRegExp:Ou,isFunction:Me,isStream:pu,isURLSearchParams:gu,isTypedArray:Au,isFileList:fu,forEach:Qt,merge:Vr,extend:xu,trim:yu,stripBOM:Su,inherits:Cu,toFlatObject:Eu,kindOf:An,kindOfTest:Ve,endsWith:Nu,toArray:Tu,forEachEntry:Iu,matchAll:ku,isHTMLForm:_u,hasOwnProperty:Ds,hasOwnProp:Ds,reduceDescriptors:Ls,freezeMethods:Mu,toObjectSet:Du,toCamelCase:Pu,noop:Lu,toFiniteNumber:Fu,findKey:Os,global:St,isContextDefined:Ms,isSpecCompliantForm:$u,toJSONObject:Bu,isAsyncFn:Uu,isThenable:Hu,setImmediate:Fs,asap:zu,isIterable:e=>e!=null&&Me(e[Tn])};function ce(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}S.inherits(ce,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:S.toJSONObject(this.config),code:this.code,status:this.status}}});const $s=ce.prototype,Bs={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Bs[e]={value:e}}),Object.defineProperties(ce,Bs),Object.defineProperty($s,"isAxiosError",{value:!0}),ce.from=(e,t,n,r,o,s)=>{const a=Object.create($s);S.toFlatObject(e,a,function(u){return u!==Error.prototype},f=>f!=="isAxiosError");const c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return ce.call(a,c,d,n,r,o),e&&a.cause==null&&Object.defineProperty(a,"cause",{value:e,configurable:!0}),a.name=e&&e.name||"Error",s&&Object.assign(a,s),a};const Wu=null;function Rr(e){return S.isPlainObject(e)||S.isArray(e)}function Us(e){return S.endsWith(e,"[]")?e.slice(0,-2):e}function Hs(e,t,n){return e?e.concat(t).map(function(o,s){return o=Us(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function ju(e){return S.isArray(e)&&!e.some(Rr)}const Vu=S.toFlatObject(S,{},null,function(t){return/^is[A-Z]/.test(t)});function _n(e,t,n){if(!S.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=S.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,b){return!S.isUndefined(b[h])});const r=n.metaTokens,o=n.visitor||u,s=n.dots,a=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&S.isSpecCompliantForm(t);if(!S.isFunction(o))throw new TypeError("visitor must be a function");function f(g){if(g===null)return"";if(S.isDate(g))return g.toISOString();if(S.isBoolean(g))return g.toString();if(!d&&S.isBlob(g))throw new ce("Blob is not supported. Use a Buffer instead.");return S.isArrayBuffer(g)||S.isTypedArray(g)?d&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function u(g,h,b){let w=g;if(g&&!b&&typeof g=="object"){if(S.endsWith(h,"{}"))h=r?h:h.slice(0,-2),g=JSON.stringify(g);else if(S.isArray(g)&&ju(g)||(S.isFileList(g)||S.endsWith(h,"[]"))&&(w=S.toArray(g)))return h=Us(h),w.forEach(function(x,C){!(S.isUndefined(x)||x===null)&&t.append(a===!0?Hs([h],C,s):a===null?h:h+"[]",f(x))}),!1}return Rr(g)?!0:(t.append(Hs(b,h,s),f(g)),!1)}const p=[],m=Object.assign(Vu,{defaultVisitor:u,convertValue:f,isVisitable:Rr});function v(g,h){if(!S.isUndefined(g)){if(p.indexOf(g)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(g),S.forEach(g,function(w,y){(!(S.isUndefined(w)||w===null)&&o.call(t,w,S.isString(y)?y.trim():y,h,m))===!0&&v(w,h?h.concat(y):[y])}),p.pop()}}if(!S.isObject(e))throw new TypeError("data must be an object");return v(e),t}function zs(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Kr(e,t){this._pairs=[],e&&_n(e,this,t)}const Ws=Kr.prototype;Ws.append=function(t,n){this._pairs.push([t,n])},Ws.toString=function(t){const n=t?function(r){return t.call(this,r,zs)}:zs;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Ru(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function js(e,t,n){if(!t)return e;const r=n&&n.encode||Ru;S.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=S.isURLSearchParams(t)?t.toString():new Kr(t,n).toString(r),s){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Vs{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){S.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Rs={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ku={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Kr,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Gr=typeof window<"u"&&typeof document<"u",qr=typeof navigator=="object"&&navigator||void 0,Gu=Gr&&(!qr||["ReactNative","NativeScript","NS"].indexOf(qr.product)<0),qu=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Xu=Gr&&window.location.href||"http://localhost",ke={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Gr,hasStandardBrowserEnv:Gu,hasStandardBrowserWebWorkerEnv:qu,navigator:qr,origin:Xu},Symbol.toStringTag,{value:"Module"})),...Ku};function Yu(e,t){return _n(e,new ke.classes.URLSearchParams,{visitor:function(n,r,o,s){return ke.isNode&&S.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Ju(e){return S.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Zu(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function Ks(e){function t(n,r,o,s){let a=n[s++];if(a==="__proto__")return!0;const c=Number.isFinite(+a),d=s>=n.length;return a=!a&&S.isArray(o)?o.length:a,d?(S.hasOwnProp(o,a)?o[a]=[o[a],r]:o[a]=r,!c):((!o[a]||!S.isObject(o[a]))&&(o[a]=[]),t(n,r,o[a],s)&&S.isArray(o[a])&&(o[a]=Zu(o[a])),!c)}if(S.isFormData(e)&&S.isFunction(e.entries)){const n={};return S.forEachEntry(e,(r,o)=>{t(Ju(r),o,n,0)}),n}return null}function Qu(e,t,n){if(S.isString(e))try{return(t||JSON.parse)(e),S.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const en={transitional:Rs,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=S.isObject(t);if(s&&S.isHTMLForm(t)&&(t=new FormData(t)),S.isFormData(t))return o?JSON.stringify(Ks(t)):t;if(S.isArrayBuffer(t)||S.isBuffer(t)||S.isStream(t)||S.isFile(t)||S.isBlob(t)||S.isReadableStream(t))return t;if(S.isArrayBufferView(t))return t.buffer;if(S.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Yu(t,this.formSerializer).toString();if((c=S.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return _n(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Qu(t)):t}],transformResponse:[function(t){const n=this.transitional||en.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(S.isResponse(t)||S.isReadableStream(t))return t;if(t&&S.isString(t)&&(r&&!this.responseType||o)){const a=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(c){if(a)throw c.name==="SyntaxError"?ce.from(c,ce.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ke.classes.FormData,Blob:ke.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};S.forEach(["delete","get","head","post","put","patch"],e=>{en.headers[e]={}});const ef=S.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),tf=e=>{const t={};let n,r,o;return e&&e.split(`
2
- `).forEach(function(a){o=a.indexOf(":"),n=a.substring(0,o).trim().toLowerCase(),r=a.substring(o+1).trim(),!(!n||t[n]&&ef[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Gs=Symbol("internals");function tn(e){return e&&String(e).trim().toLowerCase()}function Pn(e){return e===!1||e==null?e:S.isArray(e)?e.map(Pn):String(e)}function nf(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const rf=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Xr(e,t,n,r,o){if(S.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!S.isString(t)){if(S.isString(r))return t.indexOf(r)!==-1;if(S.isRegExp(r))return r.test(t)}}function of(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function sf(e,t){const n=S.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,a){return this[r].call(this,t,o,s,a)},configurable:!0})})}let De=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(c,d,f){const u=tn(d);if(!u)throw new Error("header name must be a non-empty string");const p=S.findKey(o,u);(!p||o[p]===void 0||f===!0||f===void 0&&o[p]!==!1)&&(o[p||d]=Pn(c))}const a=(c,d)=>S.forEach(c,(f,u)=>s(f,u,d));if(S.isPlainObject(t)||t instanceof this.constructor)a(t,n);else if(S.isString(t)&&(t=t.trim())&&!rf(t))a(tf(t),n);else if(S.isObject(t)&&S.isIterable(t)){let c={},d,f;for(const u of t){if(!S.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[f=u[0]]=(d=c[f])?S.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}a(c,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=tn(t),t){const r=S.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return nf(o);if(S.isFunction(n))return n.call(this,o,r);if(S.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=tn(t),t){const r=S.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Xr(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(a){if(a=tn(a),a){const c=S.findKey(r,a);c&&(!n||Xr(r,r[c],c,n))&&(delete r[c],o=!0)}}return S.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||Xr(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return S.forEach(this,(o,s)=>{const a=S.findKey(r,s);if(a){n[a]=Pn(o),delete n[s];return}const c=t?of(s):String(s).trim();c!==s&&delete n[s],n[c]=Pn(o),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return S.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&S.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
3
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Gs]=this[Gs]={accessors:{}}).accessors,o=this.prototype;function s(a){const c=tn(a);r[c]||(sf(o,a),r[c]=!0)}return S.isArray(t)?t.forEach(s):s(t),this}};De.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),S.reduceDescriptors(De.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),S.freezeMethods(De);function Yr(e,t){const n=this||en,r=t||n,o=De.from(r.headers);let s=r.data;return S.forEach(e,function(c){s=c.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function qs(e){return!!(e&&e.__CANCEL__)}function Lt(e,t,n){ce.call(this,e??"canceled",ce.ERR_CANCELED,t,n),this.name="CanceledError"}S.inherits(Lt,ce,{__CANCEL__:!0});function Xs(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new ce("Request failed with status code "+n.status,[ce.ERR_BAD_REQUEST,ce.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function af(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function cf(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,a;return t=t!==void 0?t:1e3,function(d){const f=Date.now(),u=r[s];a||(a=f),n[o]=d,r[o]=f;let p=s,m=0;for(;p!==o;)m+=n[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),f-a<t)return;const v=u&&f-u;return v?Math.round(m*1e3/v):void 0}}function lf(e,t){let n=0,r=1e3/t,o,s;const a=(f,u=Date.now())=>{n=u,o=null,s&&(clearTimeout(s),s=null),e(...f)};return[(...f)=>{const u=Date.now(),p=u-n;p>=r?a(f,u):(o=f,s||(s=setTimeout(()=>{s=null,a(o)},r-p)))},()=>o&&a(o)]}const On=(e,t,n=3)=>{let r=0;const o=cf(50,250);return lf(s=>{const a=s.loaded,c=s.lengthComputable?s.total:void 0,d=a-r,f=o(d),u=a<=c;r=a;const p={loaded:a,total:c,progress:c?a/c:void 0,bytes:d,rate:f||void 0,estimated:f&&c&&u?(c-a)/f:void 0,event:s,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(p)},n)},Ys=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Js=e=>(...t)=>S.asap(()=>e(...t)),df=ke.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ke.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ke.origin),ke.navigator&&/(msie|trident)/i.test(ke.navigator.userAgent)):()=>!0,uf=ke.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const a=[e+"="+encodeURIComponent(t)];S.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),S.isString(r)&&a.push("path="+r),S.isString(o)&&a.push("domain="+o),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function ff(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function pf(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Zs(e,t,n){let r=!ff(t);return e&&(r||n==!1)?pf(e,t):t}const Qs=e=>e instanceof De?{...e}:e;function Ct(e,t){t=t||{};const n={};function r(f,u,p,m){return S.isPlainObject(f)&&S.isPlainObject(u)?S.merge.call({caseless:m},f,u):S.isPlainObject(u)?S.merge({},u):S.isArray(u)?u.slice():u}function o(f,u,p,m){if(S.isUndefined(u)){if(!S.isUndefined(f))return r(void 0,f,p,m)}else return r(f,u,p,m)}function s(f,u){if(!S.isUndefined(u))return r(void 0,u)}function a(f,u){if(S.isUndefined(u)){if(!S.isUndefined(f))return r(void 0,f)}else return r(void 0,u)}function c(f,u,p){if(p in t)return r(f,u);if(p in e)return r(void 0,f)}const d={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c,headers:(f,u,p)=>o(Qs(f),Qs(u),p,!0)};return S.forEach(Object.keys({...e,...t}),function(u){const p=d[u]||o,m=p(e[u],t[u],u);S.isUndefined(m)&&p!==c||(n[u]=m)}),n}const ea=e=>{const t=Ct({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:a,auth:c}=t;if(t.headers=a=De.from(a),t.url=js(Zs(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),S.isFormData(n)){if(ke.hasStandardBrowserEnv||ke.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(S.isFunction(n.getHeaders)){const d=n.getHeaders(),f=["content-type","content-length"];Object.entries(d).forEach(([u,p])=>{f.includes(u.toLowerCase())&&a.set(u,p)})}}if(ke.hasStandardBrowserEnv&&(r&&S.isFunction(r)&&(r=r(t)),r||r!==!1&&df(t.url))){const d=o&&s&&uf.read(s);d&&a.set(o,d)}return t},hf=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=ea(e);let s=o.data;const a=De.from(o.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:f}=o,u,p,m,v,g;function h(){v&&v(),g&&g(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(o.method.toUpperCase(),o.url,!0),b.timeout=o.timeout;function w(){if(!b)return;const x=De.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),E={data:!c||c==="text"||c==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:x,config:e,request:b};Xs(function(T){n(T),h()},function(T){r(T),h()},E),b=null}"onloadend"in b?b.onloadend=w:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(w)},b.onabort=function(){b&&(r(new ce("Request aborted",ce.ECONNABORTED,e,b)),b=null)},b.onerror=function(C){const E=C&&C.message?C.message:"Network Error",P=new ce(E,ce.ERR_NETWORK,e,b);P.event=C||null,r(P),b=null},b.ontimeout=function(){let C=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const E=o.transitional||Rs;o.timeoutErrorMessage&&(C=o.timeoutErrorMessage),r(new ce(C,E.clarifyTimeoutError?ce.ETIMEDOUT:ce.ECONNABORTED,e,b)),b=null},s===void 0&&a.setContentType(null),"setRequestHeader"in b&&S.forEach(a.toJSON(),function(C,E){b.setRequestHeader(E,C)}),S.isUndefined(o.withCredentials)||(b.withCredentials=!!o.withCredentials),c&&c!=="json"&&(b.responseType=o.responseType),f&&([m,g]=On(f,!0),b.addEventListener("progress",m)),d&&b.upload&&([p,v]=On(d),b.upload.addEventListener("progress",p),b.upload.addEventListener("loadend",v)),(o.cancelToken||o.signal)&&(u=x=>{b&&(r(!x||x.type?new Lt(null,e,b):x),b.abort(),b=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const y=af(o.url);if(y&&ke.protocols.indexOf(y)===-1){r(new ce("Unsupported protocol "+y+":",ce.ERR_BAD_REQUEST,e));return}b.send(s||null)})},gf=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(f){if(!o){o=!0,c();const u=f instanceof Error?f:this.reason;r.abort(u instanceof ce?u:new Lt(u instanceof Error?u.message:u))}};let a=t&&setTimeout(()=>{a=null,s(new ce(`timeout ${t} of ms exceeded`,ce.ETIMEDOUT))},t);const c=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(f=>{f.unsubscribe?f.unsubscribe(s):f.removeEventListener("abort",s)}),e=null)};e.forEach(f=>f.addEventListener("abort",s));const{signal:d}=r;return d.unsubscribe=()=>S.asap(c),d}},mf=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},bf=async function*(e,t){for await(const n of vf(e))yield*mf(n,t)},vf=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},ta=(e,t,n,r)=>{const o=bf(e,t);let s=0,a,c=d=>{a||(a=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:f,value:u}=await o.next();if(f){c(),d.close();return}let p=u.byteLength;if(n){let m=s+=p;n(m)}d.enqueue(new Uint8Array(u))}catch(f){throw c(f),f}},cancel(d){return c(d),o.return()}},{highWaterMark:2})},na=64*1024,{isFunction:Mn}=S,wf=(({Request:e,Response:t})=>({Request:e,Response:t}))(S.global),{ReadableStream:ra,TextEncoder:oa}=S.global,sa=(e,...t)=>{try{return!!e(...t)}catch{return!1}},yf=e=>{e=S.merge.call({skipUndefined:!0},wf,e);const{fetch:t,Request:n,Response:r}=e,o=t?Mn(t):typeof fetch=="function",s=Mn(n),a=Mn(r);if(!o)return!1;const c=o&&Mn(ra),d=o&&(typeof oa=="function"?(g=>h=>g.encode(h))(new oa):async g=>new Uint8Array(await new n(g).arrayBuffer())),f=s&&c&&sa(()=>{let g=!1;const h=new n(ke.origin,{body:new ra,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return g&&!h}),u=a&&c&&sa(()=>S.isReadableStream(new r("").body)),p={stream:u&&(g=>g.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(g=>{!p[g]&&(p[g]=(h,b)=>{let w=h&&h[g];if(w)return w.call(h);throw new ce(`Response type '${g}' is not supported`,ce.ERR_NOT_SUPPORT,b)})});const m=async g=>{if(g==null)return 0;if(S.isBlob(g))return g.size;if(S.isSpecCompliantForm(g))return(await new n(ke.origin,{method:"POST",body:g}).arrayBuffer()).byteLength;if(S.isArrayBufferView(g)||S.isArrayBuffer(g))return g.byteLength;if(S.isURLSearchParams(g)&&(g=g+""),S.isString(g))return(await d(g)).byteLength},v=async(g,h)=>{const b=S.toFiniteNumber(g.getContentLength());return b??m(h)};return async g=>{let{url:h,method:b,data:w,signal:y,cancelToken:x,timeout:C,onDownloadProgress:E,onUploadProgress:P,responseType:T,headers:F,withCredentials:M="same-origin",fetchOptions:B}=ea(g),j=t||fetch;T=T?(T+"").toLowerCase():"text";let Q=gf([y,x&&x.toAbortSignal()],C),H=null;const O=Q&&Q.unsubscribe&&(()=>{Q.unsubscribe()});let ne;try{if(P&&f&&b!=="get"&&b!=="head"&&(ne=await v(F,w))!==0){let V=new n(h,{method:"POST",body:w,duplex:"half"}),te;if(S.isFormData(w)&&(te=V.headers.get("content-type"))&&F.setContentType(te),V.body){const[D,W]=Ys(ne,On(Js(P)));w=ta(V.body,na,D,W)}}S.isString(M)||(M=M?"include":"omit");const L=s&&"credentials"in n.prototype,z={...B,signal:Q,method:b.toUpperCase(),headers:F.normalize().toJSON(),body:w,duplex:"half",credentials:L?M:void 0};H=s&&new n(h,z);let k=await(s?j(H,B):j(h,z));const I=u&&(T==="stream"||T==="response");if(u&&(E||I&&O)){const V={};["status","statusText","headers"].forEach(xe=>{V[xe]=k[xe]});const te=S.toFiniteNumber(k.headers.get("content-length")),[D,W]=E&&Ys(te,On(Js(E),!0))||[];k=new r(ta(k.body,na,D,()=>{W&&W(),O&&O()}),V)}T=T||"text";let ee=await p[S.findKey(p,T)||"text"](k,g);return!I&&O&&O(),await new Promise((V,te)=>{Xs(V,te,{data:ee,headers:De.from(k.headers),status:k.status,statusText:k.statusText,config:g,request:H})})}catch(L){throw O&&O(),L&&L.name==="TypeError"&&/Load failed|fetch/i.test(L.message)?Object.assign(new ce("Network Error",ce.ERR_NETWORK,g,H),{cause:L.cause||L}):ce.from(L,L&&L.code,g,H)}}},xf=new Map,aa=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let a=s.length,c=a,d,f,u=xf;for(;c--;)d=s[c],f=u.get(d),f===void 0&&u.set(d,f=c?new Map:yf(t)),u=f;return f};aa();const Jr={http:Wu,xhr:hf,fetch:{get:aa}};S.forEach(Jr,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const ia=e=>`- ${e}`,Sf=e=>S.isFunction(e)||e===null||e===!1,ca={getAdapter:(e,t)=>{e=S.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let a=0;a<n;a++){r=e[a];let c;if(o=r,!Sf(r)&&(o=Jr[(c=String(r)).toLowerCase()],o===void 0))throw new ce(`Unknown adapter '${c}'`);if(o&&(S.isFunction(o)||(o=o.get(t))))break;s[c||"#"+a]=o}if(!o){const a=Object.entries(s).map(([d,f])=>`adapter ${d} `+(f===!1?"is not supported by the environment":"is not available in the build"));let c=n?a.length>1?`since :
4
- `+a.map(ia).join(`
5
- `):" "+ia(a[0]):"as no adapter specified";throw new ce("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return o},adapters:Jr};function Zr(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Lt(null,e)}function la(e){return Zr(e),e.headers=De.from(e.headers),e.data=Yr.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),ca.getAdapter(e.adapter||en.adapter,e)(e).then(function(r){return Zr(e),r.data=Yr.call(e,e.transformResponse,r),r.headers=De.from(r.headers),r},function(r){return qs(r)||(Zr(e),r&&r.response&&(r.response.data=Yr.call(e,e.transformResponse,r.response),r.response.headers=De.from(r.response.headers))),Promise.reject(r)})}const da="1.12.2",Dn={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Dn[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const ua={};Dn.transitional=function(t,n,r){function o(s,a){return"[Axios v"+da+"] Transitional option '"+s+"'"+a+(r?". "+r:"")}return(s,a,c)=>{if(t===!1)throw new ce(o(a," has been removed"+(n?" in "+n:"")),ce.ERR_DEPRECATED);return n&&!ua[a]&&(ua[a]=!0,console.warn(o(a," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,a,c):!0}},Dn.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Cf(e,t,n){if(typeof e!="object")throw new ce("options must be an object",ce.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],a=t[s];if(a){const c=e[s],d=c===void 0||a(c,s,e);if(d!==!0)throw new ce("option "+s+" must be "+d,ce.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new ce("Unknown option "+s,ce.ERR_BAD_OPTION)}}const Ln={assertOptions:Cf,validators:Dn},tt=Ln.validators;let Et=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Vs,response:new Vs}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
- `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Ct(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Ln.assertOptions(r,{silentJSONParsing:tt.transitional(tt.boolean),forcedJSONParsing:tt.transitional(tt.boolean),clarifyTimeoutError:tt.transitional(tt.boolean)},!1),o!=null&&(S.isFunction(o)?n.paramsSerializer={serialize:o}:Ln.assertOptions(o,{encode:tt.function,serialize:tt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ln.assertOptions(n,{baseUrl:tt.spelling("baseURL"),withXsrfToken:tt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let a=s&&S.merge(s.common,s[n.method]);s&&S.forEach(["delete","get","head","post","put","patch","common"],g=>{delete s[g]}),n.headers=De.concat(a,s);const c=[];let d=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(d=d&&h.synchronous,c.unshift(h.fulfilled,h.rejected))});const f=[];this.interceptors.response.forEach(function(h){f.push(h.fulfilled,h.rejected)});let u,p=0,m;if(!d){const g=[la.bind(this),void 0];for(g.unshift(...c),g.push(...f),m=g.length,u=Promise.resolve(n);p<m;)u=u.then(g[p++],g[p++]);return u}m=c.length;let v=n;for(;p<m;){const g=c[p++],h=c[p++];try{v=g(v)}catch(b){h.call(this,b);break}}try{u=la.call(this,v)}catch(g){return Promise.reject(g)}for(p=0,m=f.length;p<m;)u=u.then(f[p++],f[p++]);return u}getUri(t){t=Ct(this.defaults,t);const n=Zs(t.baseURL,t.url,t.allowAbsoluteUrls);return js(n,t.params,t.paramsSerializer)}};S.forEach(["delete","get","head","options"],function(t){Et.prototype[t]=function(n,r){return this.request(Ct(r||{},{method:t,url:n,data:(r||{}).data}))}}),S.forEach(["post","put","patch"],function(t){function n(r){return function(s,a,c){return this.request(Ct(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}Et.prototype[t]=n(),Et.prototype[t+"Form"]=n(!0)});let Ef=class Qd{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const a=new Promise(c=>{r.subscribe(c),s=c}).then(o);return a.cancel=function(){r.unsubscribe(s)},a},t(function(s,a,c){r.reason||(r.reason=new Lt(s,a,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Qd(function(o){t=o}),cancel:t}}};function Nf(e){return function(n){return e.apply(null,n)}}function Tf(e){return S.isObject(e)&&e.isAxiosError===!0}const Qr={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Qr).forEach(([e,t])=>{Qr[t]=e});function fa(e){const t=new Et(e),n=Is(Et.prototype.request,t);return S.extend(n,Et.prototype,t,{allOwnKeys:!0}),S.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return fa(Ct(e,o))},n}const Ce=fa(en);Ce.Axios=Et,Ce.CanceledError=Lt,Ce.CancelToken=Ef,Ce.isCancel=qs,Ce.VERSION=da,Ce.toFormData=_n,Ce.AxiosError=ce,Ce.Cancel=Ce.CanceledError,Ce.all=function(t){return Promise.all(t)},Ce.spread=Nf,Ce.isAxiosError=Tf,Ce.mergeConfig=Ct,Ce.AxiosHeaders=De,Ce.formToJSON=e=>Ks(S.isHTMLForm(e)?new FormData(e):e),Ce.getAdapter=ca.getAdapter,Ce.HttpStatusCode=Qr,Ce.default=Ce;const{Axios:zw,AxiosError:Ww,CanceledError:jw,isCancel:Vw,CancelToken:Rw,VERSION:Kw,all:Gw,Cancel:qw,isAxiosError:Xw,spread:Yw,toFormData:Jw,AxiosHeaders:Zw,HttpStatusCode:Qw,formToJSON:ey,getAdapter:ty,mergeConfig:ny}=Ce,eo={};function nn(){var e;try{return typeof window<"u"&&((e=window.localStorage)==null?void 0:e.getItem("chat-debug"))==="1"}catch{return!1}}const pa=eo==null?void 0:eo.VITE_API_BASE_URL,ha=pa?pa.replace(/\/+$/,""):void 0;!ha&&typeof window<"u"&&console.warn("VITE_API_BASE_URL is not set. The API client will need to be configured via apiConfig prop.");let Fn=null;const to=new Set;function no(){return Fn}function ro(e){Fn=e,to.forEach(t=>t(e))}function ga(e){return to.add(e),()=>to.delete(e)}const nt=Ce.create({baseURL:ha||"http://localhost:8000",timeout:3e4,withCredentials:!0});nt.interceptors.request.use(e=>(Fn&&(e.headers.Authorization=`Bearer ${Fn}`),e)),nt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function Nt(e,t){return(await nt.get(e,t)).data}async function oo(e,t,n){return(await nt.post(e,t,n)).data}async function ma(e,t,n){return(await nt.put(e,t,n)).data}async function ba(e,t){return(await nt.delete(e,t)).data}async function Af(e,t){var m;if(nn()){let v=t.body;try{const g=JSON.parse(JSON.stringify(t.body));(m=g==null?void 0:g.payload)!=null&&m.files_info&&Array.isArray(g.payload.files_info)&&(g.payload.files_info=g.payload.files_info.map(h=>({...h,data:h!=null&&h.data?`<base64 ${String(h.data).length} chars>`:h==null?void 0:h.data}))),v=g}catch{}console.debug("[api.stream]",t.method,`${nt.defaults.baseURL}${e}`,v)}const r=(nt.defaults.baseURL||"").replace(/\/+$|^\s+|\s+$/g,""),o=t.method??"POST",s=no(),a=t.headers??{},c=e?e.startsWith("/")?e:`/${e}`:"",d=r?`${r}${c}`:c||r,f=await fetch(d,{method:o,headers:{"Content-Type":"application/json",...s?{Authorization:`Bearer ${s}`}:{},...a},body:t.body!==void 0?JSON.stringify(t.body):void 0,credentials:"include",signal:t.signal});if(!f.ok||!f.body){const v=await f.text().catch(()=>"");throw nn()&&console.debug("[api.stream] non-OK",f.status,v==null?void 0:v.slice(0,500)),new Error(`Stream failed: ${f.status} ${f.statusText}${v?": "+v:""}`)}const u=f.body.getReader(),p=new TextDecoder;for(;;){const{done:v,value:g}=await u.read();if(v)break;const h=p.decode(g,{stream:!0});nn()&&console.debug("[api.stream] chunk",h.slice(0,200)),t.onChunk(h)}}function rt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class $n{get baseUrl(){const t=nt.defaults.baseURL||"";return String(t).replace(/\/+$|^\s+|\s+$/g,"")}updateConfig(t){t.baseUrl&&(nt.defaults.baseURL=String(t.baseUrl).replace(/\/+$/g,"")),t.authToken!==void 0&&ro(t.authToken)}getAuthToken(){return no()}setAuthToken(t){ro(t)}onTokenChange(t){return ga(t)}async listThreads(){const t=await Nt("/chat/threads"),n=rt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await oo("/chat/threads",t?{title:t}:void 0);return rt(r)}async updateThread(t,n){const r=await ma(`/chat/threads/${t}`,{title:n});return rt(r)}async deleteThread(t){const n=await ba(`/chat/threads/${t}`);return rt(n)}async threadInfo(t){const n=await Nt(`/chat/threads/${t}/info`);return rt(n)}async getMessages(t){const n=await Nt("/chat/messages",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return rt(n)}async getState(t){const n=await Nt("/chat/state",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return rt(n)}async getStateHistory(t){const n=await Nt("/chat/state/history",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return rt(n)}async listCheckpoints(t){const n=await Nt("/chat/checkpoints",{params:{thread_id:t}});return rt(n)}async uploadImage(t,n="/upload"){const r=new FormData;r.append("file",t,t.name),nn()&&console.debug("[api.uploadImage] ->",n,{name:t.name,type:t.type,size:t.size});const o=await oo(n,r,{headers:{Accept:"application/json"},maxBodyLength:1/0}),s=rt(o);if(nn()&&console.debug("[api.uploadImage] <-",s),!(s!=null&&s.url))throw new Error("Invalid upload response: missing url");return{url:s.url,mimeType:s.mimeType??t.type,name:s.name??t.name,size:s.size??t.size}}}const dt=new $n;function va(e={}){const t=e.baseUrl??"/api/chat",n=e.streamPath??"/stream",[r,o]=N.useState(e.token??null),s=N.useRef(e.headers??{}),[a,c]=N.useState(!1),[d,f]=N.useState(null),[u,p]=N.useState(""),[m,v]=N.useState(null),g=N.useRef(null),h=N.useCallback(x=>{o(x)},[]),b=N.useCallback(()=>{var x;(x=g.current)==null||x.abort(),g.current=null,c(!1)},[]),w=N.useCallback(()=>{p(""),v(null),f(null)},[]),y=N.useCallback((x,C,E)=>{g.current&&(g.current.abort(),g.current=null),c(!0),f(null),e.autoAppendAssistant!==!1&&p("");const P=new AbortController;return g.current=P,(async()=>{var M,B,j,Q;const T=(()=>{var H;try{return typeof window<"u"&&((H=window.localStorage)==null?void 0:H.getItem("chat-debug"))==="1"}catch{return!1}})(),F=H=>{var O;try{const ne=JSON.parse(JSON.stringify(H));return(O=ne==null?void 0:ne.payload)!=null&&O.files_info&&Array.isArray(ne.payload.files_info)&&(ne.payload.files_info=ne.payload.files_info.map(L=>({...L,data:L!=null&&L.data?`<base64 ${String(L.data).length} chars>`:L==null?void 0:L.data}))),ne}catch{return H}};try{let H={};try{if(r)H={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const I=window.__AUTH_TOKEN__,ee=((M=window.localStorage)==null?void 0:M.getItem("authToken"))||null;let V=null;try{const D=(B=window.localStorage)==null?void 0:B.getItem("chat-settings");D&&(V=((j=JSON.parse(D))==null?void 0:j.apiKey)||null)}catch{}const te=I||ee||V||null;te&&(H={Authorization:`Bearer ${te}`})}}catch{}T&&console.debug("[use-chat] POST",t+n,F(x));const O=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...H,...s.current},body:JSON.stringify(x),signal:P.signal});if(!O.ok||!O.body){const k=await O.text().catch(()=>"");throw T&&console.debug("[use-chat] non-OK response",O.status,k==null?void 0:k.slice(0,500)),new Error(`stream ${O.status}${k?": "+k:""}`)}const ne=O.body.getReader(),L=new TextDecoder;let z="";for(;;){const{value:k,done:I}=await ne.read();if(I)break;z+=L.decode(k,{stream:!0});let ee;for(;(ee=z.indexOf(`
1
+ (function(ae,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react/jsx-runtime"),require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom"),require("react-markdown"),require("remark-gfm")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","react-markdown","remark-gfm"],i):(ae=typeof globalThis<"u"?globalThis:ae||self,i(ae.NewChatUI={},ae.jsxRuntime,ae.React,ae.LucideReact,ae.reactSlot,ae.classVarianceAuthority,ae.clsx,ae.tailwindMerge,ae.ReactDOM,ae.ReactMarkdown,ae.remarkGfm))})(this,function(ae,i,N,q,Be,Jt,tu,nu,As,ru,ou){"use strict";var Vr=typeof document<"u"?document.currentScript:null;function Is(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const l=Is(N),Tn=Is(As);function ks(e,t){return function(){return e.apply(t,arguments)}}const{toString:su}=Object.prototype,{getPrototypeOf:jr}=Object,{iterator:An,toStringTag:_s}=Symbol,In=(e=>t=>{const n=su.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Re=e=>(e=e.toLowerCase(),t=>In(t)===e),kn=e=>t=>typeof t===e,{isArray:Dt}=Array,Lt=kn("undefined");function Zt(e){return e!==null&&!Lt(e)&&e.constructor!==null&&!Lt(e.constructor)&&Me(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ps=Re("ArrayBuffer");function au(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ps(e.buffer),t}const iu=kn("string"),Me=kn("function"),Os=kn("number"),Qt=e=>e!==null&&typeof e=="object",cu=e=>e===!0||e===!1,_n=e=>{if(In(e)!=="object")return!1;const t=jr(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(_s in e)&&!(An in e)},lu=e=>{if(!Qt(e)||Zt(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},du=Re("Date"),uu=Re("File"),fu=Re("Blob"),pu=Re("FileList"),hu=e=>Qt(e)&&Me(e.pipe),gu=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Me(e.append)&&((t=In(e))==="formdata"||t==="object"&&Me(e.toString)&&e.toString()==="[object FormData]"))},mu=Re("URLSearchParams"),[bu,vu,wu,yu]=["ReadableStream","Request","Response","Headers"].map(Re),xu=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function en(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Dt(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Zt(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),a=s.length;let c;for(r=0;r<a;r++)c=s[r],t.call(null,e[c],c,e)}}function Ms(e,t){if(Zt(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Ct=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ds=e=>!Lt(e)&&e!==Ct;function Rr(){const{caseless:e,skipUndefined:t}=Ds(this)&&this||{},n={},r=(o,s)=>{const a=e&&Ms(n,s)||s;_n(n[a])&&_n(o)?n[a]=Rr(n[a],o):_n(o)?n[a]=Rr({},o):Dt(o)?n[a]=o.slice():(!t||!Lt(o))&&(n[a]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&en(arguments[o],r);return n}const Su=(e,t,n,{allOwnKeys:r}={})=>(en(t,(o,s)=>{n&&Me(o)?e[s]=ks(o,n):e[s]=o},{allOwnKeys:r}),e),Cu=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Eu=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Nu=(e,t,n,r)=>{let o,s,a;const c={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)a=o[s],(!r||r(a,e,t))&&!c[a]&&(t[a]=e[a],c[a]=!0);e=n!==!1&&jr(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Tu=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Au=e=>{if(!e)return null;if(Dt(e))return e;let t=e.length;if(!Os(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Iu=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&jr(Uint8Array)),ku=(e,t)=>{const r=(e&&e[An]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},_u=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Pu=Re("HTMLFormElement"),Ou=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Ls=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Mu=Re("RegExp"),Fs=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};en(n,(o,s)=>{let a;(a=t(o,s,e))!==!1&&(r[s]=a||o)}),Object.defineProperties(e,r)},Du=e=>{Fs(e,(t,n)=>{if(Me(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Me(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Lu=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Dt(e)?r(e):r(String(e).split(t)),n},Fu=()=>{},$u=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Bu(e){return!!(e&&Me(e.append)&&e[_s]==="FormData"&&e[An])}const Uu=e=>{const t=new Array(10),n=(r,o)=>{if(Qt(r)){if(t.indexOf(r)>=0)return;if(Zt(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Dt(r)?[]:{};return en(r,(a,c)=>{const d=n(a,o+1);!Lt(d)&&(s[c]=d)}),t[o]=void 0,s}}return r};return n(e,0)},Hu=Re("AsyncFunction"),zu=e=>e&&(Qt(e)||Me(e))&&Me(e.then)&&Me(e.catch),$s=((e,t)=>e?setImmediate:t?((n,r)=>(Ct.addEventListener("message",({source:o,data:s})=>{o===Ct&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Ct.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Me(Ct.postMessage)),Wu=typeof queueMicrotask<"u"?queueMicrotask.bind(Ct):typeof process<"u"&&process.nextTick||$s,S={isArray:Dt,isArrayBuffer:Ps,isBuffer:Zt,isFormData:gu,isArrayBufferView:au,isString:iu,isNumber:Os,isBoolean:cu,isObject:Qt,isPlainObject:_n,isEmptyObject:lu,isReadableStream:bu,isRequest:vu,isResponse:wu,isHeaders:yu,isUndefined:Lt,isDate:du,isFile:uu,isBlob:fu,isRegExp:Mu,isFunction:Me,isStream:hu,isURLSearchParams:mu,isTypedArray:Iu,isFileList:pu,forEach:en,merge:Rr,extend:Su,trim:xu,stripBOM:Cu,inherits:Eu,toFlatObject:Nu,kindOf:In,kindOfTest:Re,endsWith:Tu,toArray:Au,forEachEntry:ku,matchAll:_u,isHTMLForm:Pu,hasOwnProperty:Ls,hasOwnProp:Ls,reduceDescriptors:Fs,freezeMethods:Du,toObjectSet:Lu,toCamelCase:Ou,noop:Fu,toFiniteNumber:$u,findKey:Ms,global:Ct,isContextDefined:Ds,isSpecCompliantForm:Bu,toJSONObject:Uu,isAsyncFn:Hu,isThenable:zu,setImmediate:$s,asap:Wu,isIterable:e=>e!=null&&Me(e[An])};function ce(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}S.inherits(ce,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:S.toJSONObject(this.config),code:this.code,status:this.status}}});const Bs=ce.prototype,Us={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Us[e]={value:e}}),Object.defineProperties(ce,Us),Object.defineProperty(Bs,"isAxiosError",{value:!0}),ce.from=(e,t,n,r,o,s)=>{const a=Object.create(Bs);S.toFlatObject(e,a,function(u){return u!==Error.prototype},f=>f!=="isAxiosError");const c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return ce.call(a,c,d,n,r,o),e&&a.cause==null&&Object.defineProperty(a,"cause",{value:e,configurable:!0}),a.name=e&&e.name||"Error",s&&Object.assign(a,s),a};const Vu=null;function Kr(e){return S.isPlainObject(e)||S.isArray(e)}function Hs(e){return S.endsWith(e,"[]")?e.slice(0,-2):e}function zs(e,t,n){return e?e.concat(t).map(function(o,s){return o=Hs(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function ju(e){return S.isArray(e)&&!e.some(Kr)}const Ru=S.toFlatObject(S,{},null,function(t){return/^is[A-Z]/.test(t)});function Pn(e,t,n){if(!S.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=S.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,b){return!S.isUndefined(b[h])});const r=n.metaTokens,o=n.visitor||u,s=n.dots,a=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&S.isSpecCompliantForm(t);if(!S.isFunction(o))throw new TypeError("visitor must be a function");function f(g){if(g===null)return"";if(S.isDate(g))return g.toISOString();if(S.isBoolean(g))return g.toString();if(!d&&S.isBlob(g))throw new ce("Blob is not supported. Use a Buffer instead.");return S.isArrayBuffer(g)||S.isTypedArray(g)?d&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function u(g,h,b){let w=g;if(g&&!b&&typeof g=="object"){if(S.endsWith(h,"{}"))h=r?h:h.slice(0,-2),g=JSON.stringify(g);else if(S.isArray(g)&&ju(g)||(S.isFileList(g)||S.endsWith(h,"[]"))&&(w=S.toArray(g)))return h=Hs(h),w.forEach(function(x,C){!(S.isUndefined(x)||x===null)&&t.append(a===!0?zs([h],C,s):a===null?h:h+"[]",f(x))}),!1}return Kr(g)?!0:(t.append(zs(b,h,s),f(g)),!1)}const p=[],m=Object.assign(Ru,{defaultVisitor:u,convertValue:f,isVisitable:Kr});function v(g,h){if(!S.isUndefined(g)){if(p.indexOf(g)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(g),S.forEach(g,function(w,y){(!(S.isUndefined(w)||w===null)&&o.call(t,w,S.isString(y)?y.trim():y,h,m))===!0&&v(w,h?h.concat(y):[y])}),p.pop()}}if(!S.isObject(e))throw new TypeError("data must be an object");return v(e),t}function Ws(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Gr(e,t){this._pairs=[],e&&Pn(e,this,t)}const Vs=Gr.prototype;Vs.append=function(t,n){this._pairs.push([t,n])},Vs.toString=function(t){const n=t?function(r){return t.call(this,r,Ws)}:Ws;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Ku(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function js(e,t,n){if(!t)return e;const r=n&&n.encode||Ku;S.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=S.isURLSearchParams(t)?t.toString():new Gr(t,n).toString(r),s){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Rs{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){S.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ks={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Gu={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Gr,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},qr=typeof window<"u"&&typeof document<"u",Xr=typeof navigator=="object"&&navigator||void 0,qu=qr&&(!Xr||["ReactNative","NativeScript","NS"].indexOf(Xr.product)<0),Xu=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Yu=qr&&window.location.href||"http://localhost",ke={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:qr,hasStandardBrowserEnv:qu,hasStandardBrowserWebWorkerEnv:Xu,navigator:Xr,origin:Yu},Symbol.toStringTag,{value:"Module"})),...Gu};function Ju(e,t){return Pn(e,new ke.classes.URLSearchParams,{visitor:function(n,r,o,s){return ke.isNode&&S.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Zu(e){return S.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Qu(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function Gs(e){function t(n,r,o,s){let a=n[s++];if(a==="__proto__")return!0;const c=Number.isFinite(+a),d=s>=n.length;return a=!a&&S.isArray(o)?o.length:a,d?(S.hasOwnProp(o,a)?o[a]=[o[a],r]:o[a]=r,!c):((!o[a]||!S.isObject(o[a]))&&(o[a]=[]),t(n,r,o[a],s)&&S.isArray(o[a])&&(o[a]=Qu(o[a])),!c)}if(S.isFormData(e)&&S.isFunction(e.entries)){const n={};return S.forEachEntry(e,(r,o)=>{t(Zu(r),o,n,0)}),n}return null}function ef(e,t,n){if(S.isString(e))try{return(t||JSON.parse)(e),S.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const tn={transitional:Ks,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=S.isObject(t);if(s&&S.isHTMLForm(t)&&(t=new FormData(t)),S.isFormData(t))return o?JSON.stringify(Gs(t)):t;if(S.isArrayBuffer(t)||S.isBuffer(t)||S.isStream(t)||S.isFile(t)||S.isBlob(t)||S.isReadableStream(t))return t;if(S.isArrayBufferView(t))return t.buffer;if(S.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Ju(t,this.formSerializer).toString();if((c=S.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return Pn(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),ef(t)):t}],transformResponse:[function(t){const n=this.transitional||tn.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(S.isResponse(t)||S.isReadableStream(t))return t;if(t&&S.isString(t)&&(r&&!this.responseType||o)){const a=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(c){if(a)throw c.name==="SyntaxError"?ce.from(c,ce.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ke.classes.FormData,Blob:ke.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};S.forEach(["delete","get","head","post","put","patch"],e=>{tn.headers[e]={}});const tf=S.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),nf=e=>{const t={};let n,r,o;return e&&e.split(`
2
+ `).forEach(function(a){o=a.indexOf(":"),n=a.substring(0,o).trim().toLowerCase(),r=a.substring(o+1).trim(),!(!n||t[n]&&tf[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},qs=Symbol("internals");function nn(e){return e&&String(e).trim().toLowerCase()}function On(e){return e===!1||e==null?e:S.isArray(e)?e.map(On):String(e)}function rf(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const of=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Yr(e,t,n,r,o){if(S.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!S.isString(t)){if(S.isString(r))return t.indexOf(r)!==-1;if(S.isRegExp(r))return r.test(t)}}function sf(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function af(e,t){const n=S.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,a){return this[r].call(this,t,o,s,a)},configurable:!0})})}let De=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(c,d,f){const u=nn(d);if(!u)throw new Error("header name must be a non-empty string");const p=S.findKey(o,u);(!p||o[p]===void 0||f===!0||f===void 0&&o[p]!==!1)&&(o[p||d]=On(c))}const a=(c,d)=>S.forEach(c,(f,u)=>s(f,u,d));if(S.isPlainObject(t)||t instanceof this.constructor)a(t,n);else if(S.isString(t)&&(t=t.trim())&&!of(t))a(nf(t),n);else if(S.isObject(t)&&S.isIterable(t)){let c={},d,f;for(const u of t){if(!S.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[f=u[0]]=(d=c[f])?S.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}a(c,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=nn(t),t){const r=S.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return rf(o);if(S.isFunction(n))return n.call(this,o,r);if(S.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=nn(t),t){const r=S.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Yr(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(a){if(a=nn(a),a){const c=S.findKey(r,a);c&&(!n||Yr(r,r[c],c,n))&&(delete r[c],o=!0)}}return S.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||Yr(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return S.forEach(this,(o,s)=>{const a=S.findKey(r,s);if(a){n[a]=On(o),delete n[s];return}const c=t?sf(s):String(s).trim();c!==s&&delete n[s],n[c]=On(o),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return S.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&S.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
3
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[qs]=this[qs]={accessors:{}}).accessors,o=this.prototype;function s(a){const c=nn(a);r[c]||(af(o,a),r[c]=!0)}return S.isArray(t)?t.forEach(s):s(t),this}};De.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),S.reduceDescriptors(De.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),S.freezeMethods(De);function Jr(e,t){const n=this||tn,r=t||n,o=De.from(r.headers);let s=r.data;return S.forEach(e,function(c){s=c.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Xs(e){return!!(e&&e.__CANCEL__)}function Ft(e,t,n){ce.call(this,e??"canceled",ce.ERR_CANCELED,t,n),this.name="CanceledError"}S.inherits(Ft,ce,{__CANCEL__:!0});function Ys(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new ce("Request failed with status code "+n.status,[ce.ERR_BAD_REQUEST,ce.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function cf(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function lf(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,a;return t=t!==void 0?t:1e3,function(d){const f=Date.now(),u=r[s];a||(a=f),n[o]=d,r[o]=f;let p=s,m=0;for(;p!==o;)m+=n[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),f-a<t)return;const v=u&&f-u;return v?Math.round(m*1e3/v):void 0}}function df(e,t){let n=0,r=1e3/t,o,s;const a=(f,u=Date.now())=>{n=u,o=null,s&&(clearTimeout(s),s=null),e(...f)};return[(...f)=>{const u=Date.now(),p=u-n;p>=r?a(f,u):(o=f,s||(s=setTimeout(()=>{s=null,a(o)},r-p)))},()=>o&&a(o)]}const Mn=(e,t,n=3)=>{let r=0;const o=lf(50,250);return df(s=>{const a=s.loaded,c=s.lengthComputable?s.total:void 0,d=a-r,f=o(d),u=a<=c;r=a;const p={loaded:a,total:c,progress:c?a/c:void 0,bytes:d,rate:f||void 0,estimated:f&&c&&u?(c-a)/f:void 0,event:s,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(p)},n)},Js=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Zs=e=>(...t)=>S.asap(()=>e(...t)),uf=ke.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ke.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ke.origin),ke.navigator&&/(msie|trident)/i.test(ke.navigator.userAgent)):()=>!0,ff=ke.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const a=[e+"="+encodeURIComponent(t)];S.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),S.isString(r)&&a.push("path="+r),S.isString(o)&&a.push("domain="+o),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function pf(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function hf(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Qs(e,t,n){let r=!pf(t);return e&&(r||n==!1)?hf(e,t):t}const ea=e=>e instanceof De?{...e}:e;function Et(e,t){t=t||{};const n={};function r(f,u,p,m){return S.isPlainObject(f)&&S.isPlainObject(u)?S.merge.call({caseless:m},f,u):S.isPlainObject(u)?S.merge({},u):S.isArray(u)?u.slice():u}function o(f,u,p,m){if(S.isUndefined(u)){if(!S.isUndefined(f))return r(void 0,f,p,m)}else return r(f,u,p,m)}function s(f,u){if(!S.isUndefined(u))return r(void 0,u)}function a(f,u){if(S.isUndefined(u)){if(!S.isUndefined(f))return r(void 0,f)}else return r(void 0,u)}function c(f,u,p){if(p in t)return r(f,u);if(p in e)return r(void 0,f)}const d={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c,headers:(f,u,p)=>o(ea(f),ea(u),p,!0)};return S.forEach(Object.keys({...e,...t}),function(u){const p=d[u]||o,m=p(e[u],t[u],u);S.isUndefined(m)&&p!==c||(n[u]=m)}),n}const ta=e=>{const t=Et({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:a,auth:c}=t;if(t.headers=a=De.from(a),t.url=js(Qs(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),S.isFormData(n)){if(ke.hasStandardBrowserEnv||ke.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(S.isFunction(n.getHeaders)){const d=n.getHeaders(),f=["content-type","content-length"];Object.entries(d).forEach(([u,p])=>{f.includes(u.toLowerCase())&&a.set(u,p)})}}if(ke.hasStandardBrowserEnv&&(r&&S.isFunction(r)&&(r=r(t)),r||r!==!1&&uf(t.url))){const d=o&&s&&ff.read(s);d&&a.set(o,d)}return t},gf=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=ta(e);let s=o.data;const a=De.from(o.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:f}=o,u,p,m,v,g;function h(){v&&v(),g&&g(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(o.method.toUpperCase(),o.url,!0),b.timeout=o.timeout;function w(){if(!b)return;const x=De.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),E={data:!c||c==="text"||c==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:x,config:e,request:b};Ys(function(T){n(T),h()},function(T){r(T),h()},E),b=null}"onloadend"in b?b.onloadend=w:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(w)},b.onabort=function(){b&&(r(new ce("Request aborted",ce.ECONNABORTED,e,b)),b=null)},b.onerror=function(C){const E=C&&C.message?C.message:"Network Error",P=new ce(E,ce.ERR_NETWORK,e,b);P.event=C||null,r(P),b=null},b.ontimeout=function(){let C=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const E=o.transitional||Ks;o.timeoutErrorMessage&&(C=o.timeoutErrorMessage),r(new ce(C,E.clarifyTimeoutError?ce.ETIMEDOUT:ce.ECONNABORTED,e,b)),b=null},s===void 0&&a.setContentType(null),"setRequestHeader"in b&&S.forEach(a.toJSON(),function(C,E){b.setRequestHeader(E,C)}),S.isUndefined(o.withCredentials)||(b.withCredentials=!!o.withCredentials),c&&c!=="json"&&(b.responseType=o.responseType),f&&([m,g]=Mn(f,!0),b.addEventListener("progress",m)),d&&b.upload&&([p,v]=Mn(d),b.upload.addEventListener("progress",p),b.upload.addEventListener("loadend",v)),(o.cancelToken||o.signal)&&(u=x=>{b&&(r(!x||x.type?new Ft(null,e,b):x),b.abort(),b=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const y=cf(o.url);if(y&&ke.protocols.indexOf(y)===-1){r(new ce("Unsupported protocol "+y+":",ce.ERR_BAD_REQUEST,e));return}b.send(s||null)})},mf=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(f){if(!o){o=!0,c();const u=f instanceof Error?f:this.reason;r.abort(u instanceof ce?u:new Ft(u instanceof Error?u.message:u))}};let a=t&&setTimeout(()=>{a=null,s(new ce(`timeout ${t} of ms exceeded`,ce.ETIMEDOUT))},t);const c=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(f=>{f.unsubscribe?f.unsubscribe(s):f.removeEventListener("abort",s)}),e=null)};e.forEach(f=>f.addEventListener("abort",s));const{signal:d}=r;return d.unsubscribe=()=>S.asap(c),d}},bf=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},vf=async function*(e,t){for await(const n of wf(e))yield*bf(n,t)},wf=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},na=(e,t,n,r)=>{const o=vf(e,t);let s=0,a,c=d=>{a||(a=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:f,value:u}=await o.next();if(f){c(),d.close();return}let p=u.byteLength;if(n){let m=s+=p;n(m)}d.enqueue(new Uint8Array(u))}catch(f){throw c(f),f}},cancel(d){return c(d),o.return()}},{highWaterMark:2})},ra=64*1024,{isFunction:Dn}=S,yf=(({Request:e,Response:t})=>({Request:e,Response:t}))(S.global),{ReadableStream:oa,TextEncoder:sa}=S.global,aa=(e,...t)=>{try{return!!e(...t)}catch{return!1}},xf=e=>{e=S.merge.call({skipUndefined:!0},yf,e);const{fetch:t,Request:n,Response:r}=e,o=t?Dn(t):typeof fetch=="function",s=Dn(n),a=Dn(r);if(!o)return!1;const c=o&&Dn(oa),d=o&&(typeof sa=="function"?(g=>h=>g.encode(h))(new sa):async g=>new Uint8Array(await new n(g).arrayBuffer())),f=s&&c&&aa(()=>{let g=!1;const h=new n(ke.origin,{body:new oa,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return g&&!h}),u=a&&c&&aa(()=>S.isReadableStream(new r("").body)),p={stream:u&&(g=>g.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(g=>{!p[g]&&(p[g]=(h,b)=>{let w=h&&h[g];if(w)return w.call(h);throw new ce(`Response type '${g}' is not supported`,ce.ERR_NOT_SUPPORT,b)})});const m=async g=>{if(g==null)return 0;if(S.isBlob(g))return g.size;if(S.isSpecCompliantForm(g))return(await new n(ke.origin,{method:"POST",body:g}).arrayBuffer()).byteLength;if(S.isArrayBufferView(g)||S.isArrayBuffer(g))return g.byteLength;if(S.isURLSearchParams(g)&&(g=g+""),S.isString(g))return(await d(g)).byteLength},v=async(g,h)=>{const b=S.toFiniteNumber(g.getContentLength());return b??m(h)};return async g=>{let{url:h,method:b,data:w,signal:y,cancelToken:x,timeout:C,onDownloadProgress:E,onUploadProgress:P,responseType:T,headers:F,withCredentials:M="same-origin",fetchOptions:B}=ta(g),V=t||fetch;T=T?(T+"").toLowerCase():"text";let J=mf([y,x&&x.toAbortSignal()],C),H=null;const O=J&&J.unsubscribe&&(()=>{J.unsubscribe()});let ne;try{if(P&&f&&b!=="get"&&b!=="head"&&(ne=await v(F,w))!==0){let j=new n(h,{method:"POST",body:w,duplex:"half"}),te;if(S.isFormData(w)&&(te=j.headers.get("content-type"))&&F.setContentType(te),j.body){const[D,W]=Js(ne,Mn(Zs(P)));w=na(j.body,ra,D,W)}}S.isString(M)||(M=M?"include":"omit");const L=s&&"credentials"in n.prototype,z={...B,signal:J,method:b.toUpperCase(),headers:F.normalize().toJSON(),body:w,duplex:"half",credentials:L?M:void 0};H=s&&new n(h,z);let k=await(s?V(H,B):V(h,z));const I=u&&(T==="stream"||T==="response");if(u&&(E||I&&O)){const j={};["status","statusText","headers"].forEach(xe=>{j[xe]=k[xe]});const te=S.toFiniteNumber(k.headers.get("content-length")),[D,W]=E&&Js(te,Mn(Zs(E),!0))||[];k=new r(na(k.body,ra,D,()=>{W&&W(),O&&O()}),j)}T=T||"text";let Z=await p[S.findKey(p,T)||"text"](k,g);return!I&&O&&O(),await new Promise((j,te)=>{Ys(j,te,{data:Z,headers:De.from(k.headers),status:k.status,statusText:k.statusText,config:g,request:H})})}catch(L){throw O&&O(),L&&L.name==="TypeError"&&/Load failed|fetch/i.test(L.message)?Object.assign(new ce("Network Error",ce.ERR_NETWORK,g,H),{cause:L.cause||L}):ce.from(L,L&&L.code,g,H)}}},Sf=new Map,ia=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let a=s.length,c=a,d,f,u=Sf;for(;c--;)d=s[c],f=u.get(d),f===void 0&&u.set(d,f=c?new Map:xf(t)),u=f;return f};ia();const Zr={http:Vu,xhr:gf,fetch:{get:ia}};S.forEach(Zr,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const ca=e=>`- ${e}`,Cf=e=>S.isFunction(e)||e===null||e===!1,la={getAdapter:(e,t)=>{e=S.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let a=0;a<n;a++){r=e[a];let c;if(o=r,!Cf(r)&&(o=Zr[(c=String(r)).toLowerCase()],o===void 0))throw new ce(`Unknown adapter '${c}'`);if(o&&(S.isFunction(o)||(o=o.get(t))))break;s[c||"#"+a]=o}if(!o){const a=Object.entries(s).map(([d,f])=>`adapter ${d} `+(f===!1?"is not supported by the environment":"is not available in the build"));let c=n?a.length>1?`since :
4
+ `+a.map(ca).join(`
5
+ `):" "+ca(a[0]):"as no adapter specified";throw new ce("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return o},adapters:Zr};function Qr(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ft(null,e)}function da(e){return Qr(e),e.headers=De.from(e.headers),e.data=Jr.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),la.getAdapter(e.adapter||tn.adapter,e)(e).then(function(r){return Qr(e),r.data=Jr.call(e,e.transformResponse,r),r.headers=De.from(r.headers),r},function(r){return Xs(r)||(Qr(e),r&&r.response&&(r.response.data=Jr.call(e,e.transformResponse,r.response),r.response.headers=De.from(r.response.headers))),Promise.reject(r)})}const ua="1.12.2",Ln={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ln[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const fa={};Ln.transitional=function(t,n,r){function o(s,a){return"[Axios v"+ua+"] Transitional option '"+s+"'"+a+(r?". "+r:"")}return(s,a,c)=>{if(t===!1)throw new ce(o(a," has been removed"+(n?" in "+n:"")),ce.ERR_DEPRECATED);return n&&!fa[a]&&(fa[a]=!0,console.warn(o(a," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,a,c):!0}},Ln.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Ef(e,t,n){if(typeof e!="object")throw new ce("options must be an object",ce.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],a=t[s];if(a){const c=e[s],d=c===void 0||a(c,s,e);if(d!==!0)throw new ce("option "+s+" must be "+d,ce.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new ce("Unknown option "+s,ce.ERR_BAD_OPTION)}}const Fn={assertOptions:Ef,validators:Ln},nt=Fn.validators;let Nt=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Rs,response:new Rs}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
+ `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Et(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Fn.assertOptions(r,{silentJSONParsing:nt.transitional(nt.boolean),forcedJSONParsing:nt.transitional(nt.boolean),clarifyTimeoutError:nt.transitional(nt.boolean)},!1),o!=null&&(S.isFunction(o)?n.paramsSerializer={serialize:o}:Fn.assertOptions(o,{encode:nt.function,serialize:nt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Fn.assertOptions(n,{baseUrl:nt.spelling("baseURL"),withXsrfToken:nt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let a=s&&S.merge(s.common,s[n.method]);s&&S.forEach(["delete","get","head","post","put","patch","common"],g=>{delete s[g]}),n.headers=De.concat(a,s);const c=[];let d=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(d=d&&h.synchronous,c.unshift(h.fulfilled,h.rejected))});const f=[];this.interceptors.response.forEach(function(h){f.push(h.fulfilled,h.rejected)});let u,p=0,m;if(!d){const g=[da.bind(this),void 0];for(g.unshift(...c),g.push(...f),m=g.length,u=Promise.resolve(n);p<m;)u=u.then(g[p++],g[p++]);return u}m=c.length;let v=n;for(;p<m;){const g=c[p++],h=c[p++];try{v=g(v)}catch(b){h.call(this,b);break}}try{u=da.call(this,v)}catch(g){return Promise.reject(g)}for(p=0,m=f.length;p<m;)u=u.then(f[p++],f[p++]);return u}getUri(t){t=Et(this.defaults,t);const n=Qs(t.baseURL,t.url,t.allowAbsoluteUrls);return js(n,t.params,t.paramsSerializer)}};S.forEach(["delete","get","head","options"],function(t){Nt.prototype[t]=function(n,r){return this.request(Et(r||{},{method:t,url:n,data:(r||{}).data}))}}),S.forEach(["post","put","patch"],function(t){function n(r){return function(s,a,c){return this.request(Et(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}Nt.prototype[t]=n(),Nt.prototype[t+"Form"]=n(!0)});let Nf=class eu{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const a=new Promise(c=>{r.subscribe(c),s=c}).then(o);return a.cancel=function(){r.unsubscribe(s)},a},t(function(s,a,c){r.reason||(r.reason=new Ft(s,a,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new eu(function(o){t=o}),cancel:t}}};function Tf(e){return function(n){return e.apply(null,n)}}function Af(e){return S.isObject(e)&&e.isAxiosError===!0}const eo={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(eo).forEach(([e,t])=>{eo[t]=e});function pa(e){const t=new Nt(e),n=ks(Nt.prototype.request,t);return S.extend(n,Nt.prototype,t,{allOwnKeys:!0}),S.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return pa(Et(e,o))},n}const Ce=pa(tn);Ce.Axios=Nt,Ce.CanceledError=Ft,Ce.CancelToken=Nf,Ce.isCancel=Xs,Ce.VERSION=ua,Ce.toFormData=Pn,Ce.AxiosError=ce,Ce.Cancel=Ce.CanceledError,Ce.all=function(t){return Promise.all(t)},Ce.spread=Tf,Ce.isAxiosError=Af,Ce.mergeConfig=Et,Ce.AxiosHeaders=De,Ce.formToJSON=e=>Gs(S.isHTMLForm(e)?new FormData(e):e),Ce.getAdapter=la.getAdapter,Ce.HttpStatusCode=eo,Ce.default=Ce;const{Axios:Vw,AxiosError:jw,CanceledError:Rw,isCancel:Kw,CancelToken:Gw,VERSION:qw,all:Xw,Cancel:Yw,isAxiosError:Jw,spread:Zw,toFormData:Qw,AxiosHeaders:ey,HttpStatusCode:ty,formToJSON:ny,getAdapter:ry,mergeConfig:oy}=Ce,to={};function rn(){var e;try{return typeof window<"u"&&((e=window.localStorage)==null?void 0:e.getItem("chat-debug"))==="1"}catch{return!1}}const ha=to==null?void 0:to.VITE_API_BASE_URL,ga=ha?ha.replace(/\/+$/,""):void 0;!ga&&typeof window<"u"&&console.warn("VITE_API_BASE_URL is not set. The API client will need to be configured via apiConfig prop.");let $n=null;const no=new Set;function ro(){return $n}function oo(e){$n=e,no.forEach(t=>t(e))}function ma(e){return no.add(e),()=>no.delete(e)}const rt=Ce.create({baseURL:ga||"http://localhost:8000",timeout:3e4,withCredentials:!0});rt.interceptors.request.use(e=>($n&&(e.headers.Authorization=`Bearer ${$n}`),e)),rt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function Tt(e,t){return(await rt.get(e,t)).data}async function so(e,t,n){return(await rt.post(e,t,n)).data}async function ba(e,t,n){return(await rt.put(e,t,n)).data}async function va(e,t){return(await rt.delete(e,t)).data}async function If(e,t){var m;if(rn()){let v=t.body;try{const g=JSON.parse(JSON.stringify(t.body));(m=g==null?void 0:g.payload)!=null&&m.files_info&&Array.isArray(g.payload.files_info)&&(g.payload.files_info=g.payload.files_info.map(h=>({...h,data:h!=null&&h.data?`<base64 ${String(h.data).length} chars>`:h==null?void 0:h.data}))),v=g}catch{}console.debug("[api.stream]",t.method,`${rt.defaults.baseURL}${e}`,v)}const r=(rt.defaults.baseURL||"").replace(/\/+$|^\s+|\s+$/g,""),o=t.method??"POST",s=ro(),a=t.headers??{},c=e?e.startsWith("/")?e:`/${e}`:"",d=r?`${r}${c}`:c||r,f=await fetch(d,{method:o,headers:{"Content-Type":"application/json",...s?{Authorization:`Bearer ${s}`}:{},...a},body:t.body!==void 0?JSON.stringify(t.body):void 0,credentials:"include",signal:t.signal});if(!f.ok||!f.body){const v=await f.text().catch(()=>"");throw rn()&&console.debug("[api.stream] non-OK",f.status,v==null?void 0:v.slice(0,500)),new Error(`Stream failed: ${f.status} ${f.statusText}${v?": "+v:""}`)}const u=f.body.getReader(),p=new TextDecoder;for(;;){const{done:v,value:g}=await u.read();if(v)break;const h=p.decode(g,{stream:!0});rn()&&console.debug("[api.stream] chunk",h.slice(0,200)),t.onChunk(h)}}function ot(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Bn{get baseUrl(){const t=rt.defaults.baseURL||"";return String(t).replace(/\/+$|^\s+|\s+$/g,"")}updateConfig(t){t.baseUrl&&(rt.defaults.baseURL=String(t.baseUrl).replace(/\/+$/g,"")),t.authToken!==void 0&&oo(t.authToken)}getAuthToken(){return ro()}setAuthToken(t){oo(t)}onTokenChange(t){return ma(t)}async listThreads(){const t=await Tt("/chat/threads"),n=ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await so("/chat/threads",t?{title:t}:void 0);return ot(r)}async updateThread(t,n){const r=await ba(`/chat/threads/${t}`,{title:n});return ot(r)}async deleteThread(t){const n=await va(`/chat/threads/${t}`);return ot(n)}async threadInfo(t){const n=await Tt(`/chat/threads/${t}/info`);return ot(n)}async getMessages(t){const n=await Tt("/chat/messages",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return ot(n)}async getState(t){const n=await Tt("/chat/state",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return ot(n)}async getStateHistory(t){const n=await Tt("/chat/state/history",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return ot(n)}async listCheckpoints(t){const n=await Tt("/chat/checkpoints",{params:{thread_id:t}});return ot(n)}async uploadImage(t,n="/upload"){const r=new FormData;r.append("file",t,t.name),rn()&&console.debug("[api.uploadImage] ->",n,{name:t.name,type:t.type,size:t.size});const o=await so(n,r,{headers:{Accept:"application/json"},maxBodyLength:1/0}),s=ot(o);if(rn()&&console.debug("[api.uploadImage] <-",s),!(s!=null&&s.url))throw new Error("Invalid upload response: missing url");return{url:s.url,mimeType:s.mimeType??t.type,name:s.name??t.name,size:s.size??t.size}}}const ut=new Bn;function wa(e={}){const t=e.baseUrl??"/api/chat",n=e.streamPath??"/stream",[r,o]=N.useState(e.token??null),s=N.useRef(e.headers??{}),[a,c]=N.useState(!1),[d,f]=N.useState(null),[u,p]=N.useState(""),[m,v]=N.useState(null),g=N.useRef(null),h=N.useCallback(x=>{o(x)},[]),b=N.useCallback(()=>{var x;(x=g.current)==null||x.abort(),g.current=null,c(!1)},[]),w=N.useCallback(()=>{p(""),v(null),f(null)},[]),y=N.useCallback((x,C,E)=>{g.current&&(g.current.abort(),g.current=null),c(!0),f(null),e.autoAppendAssistant!==!1&&p("");const P=new AbortController;return g.current=P,(async()=>{var M,B,V,J;const T=(()=>{var H;try{return typeof window<"u"&&((H=window.localStorage)==null?void 0:H.getItem("chat-debug"))==="1"}catch{return!1}})(),F=H=>{var O;try{const ne=JSON.parse(JSON.stringify(H));return(O=ne==null?void 0:ne.payload)!=null&&O.files_info&&Array.isArray(ne.payload.files_info)&&(ne.payload.files_info=ne.payload.files_info.map(L=>({...L,data:L!=null&&L.data?`<base64 ${String(L.data).length} chars>`:L==null?void 0:L.data}))),ne}catch{return H}};try{let H={};try{if(r)H={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const I=window.__AUTH_TOKEN__,Z=((M=window.localStorage)==null?void 0:M.getItem("authToken"))||null;let j=null;try{const D=(B=window.localStorage)==null?void 0:B.getItem("chat-settings");D&&(j=((V=JSON.parse(D))==null?void 0:V.apiKey)||null)}catch{}const te=I||Z||j||null;te&&(H={Authorization:`Bearer ${te}`})}}catch{}T&&console.debug("[use-chat] POST",t+n,F(x));const O=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...H,...s.current},body:JSON.stringify(x),signal:P.signal});if(!O.ok||!O.body){const k=await O.text().catch(()=>"");throw T&&console.debug("[use-chat] non-OK response",O.status,k==null?void 0:k.slice(0,500)),new Error(`stream ${O.status}${k?": "+k:""}`)}const ne=O.body.getReader(),L=new TextDecoder;let z="";for(;;){const{value:k,done:I}=await ne.read();if(I)break;z+=L.decode(k,{stream:!0});let Z;for(;(Z=z.indexOf(`
7
7
 
8
- `))>=0;){const V=z.slice(0,ee);z=z.slice(ee+2);const te=kf(V);if(!te)continue;let D;try{D=JSON.parse(te)}catch{T&&console.debug("[use-chat] skip malformed SSE data:",te==null?void 0:te.slice(0,200));continue}const W=If(D)?D.data:D;if(T&&console.debug("[use-chat] event:",W==null?void 0:W.type,W),C==null||C(W),W.type==="token")e.autoAppendAssistant!==!1&&p(xe=>xe+W.content);else if(W.type==="message_delta"){const xe=W.delta.filter(ie=>ie.type==="text").map(ie=>ie.text).join("");xe&&e.autoAppendAssistant!==!1&&p(ie=>ie+xe)}else W.type==="checkpoint"?v(W.checkpointId):W.type==="error"&&f(W.message)}}}catch(H){if((H==null?void 0:H.name)==="AbortError")return;const O=(H==null?void 0:H.message)||String(H);T&&console.debug("[use-chat] error:",O),f(O),(Q=E==null?void 0:E.onError)==null||Q.call(E,O)}finally{c(!1),g.current=null}})(),{close:()=>P.abort()}},[t,r,e.autoAppendAssistant]);return N.useEffect(()=>()=>{var x;return(x=g.current)==null?void 0:x.abort()},[]),{isStreaming:a,error:d,assistantText:u,lastCheckpointId:m,stream:y,stop:b,clear:w,setToken:h}}function If(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function kf(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
9
- `)}const _f={messages:[],assemblingId:null,lastCheckpointId:null,toolIndex:{},lastBranch:null};function Pf(e,t){var n,r;switch(t.type){case"reset":return{messages:so(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,toolIndex:{},lastBranch:null};case"seed":return{...e,messages:so(t.payload.messages)};case"prepend":{const o=so(t.payload.messages);if(!o.length)return e;const s=new Set(e.messages.map(c=>c.id)),a=o.filter(c=>!s.has(c.id));return a.length?{...e,messages:[...a,...e.messages]}:e}case"user_message":{const o=t.payload.message;if(e.assemblingId){const s=e.messages.findIndex(a=>a.id===e.assemblingId&&a.role==="assistant");if(s>=0){const a=e.messages.slice(0,s),c=e.messages.slice(s);return{...e,messages:[...a,o,...c]}}}return{...e,messages:[...e.messages,o]}}case"event":{const o=t.payload.ev;if(o.type==="message_start"&&o.role==="assistant"){const s=o.id,a=Lf(o.model),c={id:s,role:"assistant",name:a||void 0,model:o.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,c]}}if(o.type==="token"){const s=e.assemblingId??ao(e.messages);return s?{...e,messages:Of(e.messages,s,o.content)}:e}if(o.type==="message_delta"){const s=e.assemblingId??ao(e.messages);return s?{...e,messages:ya(e.messages,s,o.delta)}:e}if(o.type==="message_end"){const s=e.assemblingId??ao(e.messages);if(!s)return{...e,assemblingId:null};const a=e.messages,c=a.findIndex(d=>d.id===s&&d.role==="assistant");if(c>=0&&!((r=a[c].content)==null?void 0:r.some(u=>{var p;return(u==null?void 0:u.type)==="text"&&((p=u.text)==null?void 0:p.trim())}))){const u=[...a.slice(0,c),...a.slice(c+1)];return{...e,assemblingId:null,messages:u}}return{...e,assemblingId:null}}if(o.type==="tool_start"){const s=`tool-${o.id}`,a={type:"tool_call",id:o.id,name:o.name,args:o.args},c={id:s,role:"tool",name:o.name,createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,c],toolIndex:{...e.toolIndex,[o.id]:s}}}if(o.type==="tool_result"){const s=e.toolIndex[o.id]??`tool-${o.id}`,a={type:"tool_result",toolCallId:o.id,output:o.output,error:o.error},c=e.messages.find(u=>u.id===s),d={id:s,role:"tool",content:[a],createdAt:new Date().toISOString()},f=c?ya(e.messages,s,[a]):[...e.messages,d];return{...e,messages:f}}if(o.type==="checkpoint"){const s=Df(e.messages,o.checkpointId);return{...e,lastCheckpointId:o.checkpointId,messages:s}}if(o.type==="branch"){const s=o.checkpointId??e.lastCheckpointId;return{...e,lastBranch:o,lastCheckpointId:s??null}}if(o.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${o.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}return e}default:return e}}function wa(e=[]){const[t,n]=N.useReducer(Pf,{..._f,messages:e}),r=N.useCallback(s=>{n({type:"event",payload:{ev:s}})},[]),o=N.useMemo(()=>({reset:s=>n({type:"reset",payload:{messages:s}}),seed:s=>n({type:"seed",payload:{messages:s}}),prepend:s=>n({type:"prepend",payload:{messages:s}}),pushUser:s=>n({type:"user_message",payload:{message:s}}),onEvent:r}),[r]);return{state:t,dispatch:n,...o}}function so(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function ao(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function Of(e,t,n){return e.map(r=>{if(r.id!==t)return r;const o=r.content.slice(),s=o[o.length-1];return s&&s.type==="text"?s.text+=n:o.push({type:"text",text:n}),{...r,content:o}})}function ya(e,t,n){return e.map(r=>r.id===t?{...r,content:Mf(r.content,n)}:r)}function Mf(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1];(o==null?void 0:o.type)==="text"?o.text+=r.text:n.push({type:"text",text:r.text})}else n.push(r);return n}function Df(e,t){for(let n=e.length-1;n>=0;n--)if(e[n].role==="assistant"){const o={...e[n],checkpointId:t};return[...e.slice(0,n),o,...e.slice(n+1)]}return e}function Lf(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const xa=N.createContext(null);function rn({children:e,apiConfig:t,onError:n,onThreadChange:r,initialThreadId:o=null,historyPageSize:s}){const a=dt;N.useEffect(()=>{t&&a.updateConfig({baseUrl:t.baseUrl,authToken:t.apiKey})},[a,t]);const{isStreaming:c,error:d,stream:f,stop:u,setToken:p}=va({baseUrl:a.baseUrl,token:null,headers:t==null?void 0:t.headers,streamPath:"/chat/stream"}),[m,v]=N.useState(()=>typeof a.getAuthToken=="function"?a.getAuthToken():null);N.useEffect(()=>{p(typeof a.getAuthToken=="function"?a.getAuthToken():null);const G=a.onTokenChange(Y=>{v(Y),p(Y)});return()=>{G()}},[a,p]);const g=N.useCallback(G=>{a.setAuthToken(G)},[a]),{state:h,seed:b,prepend:w,pushUser:y,onEvent:x,reset:C}=wa(),E=s&&s>0?s:6,[P,T]=N.useState(!1),[F,M]=N.useState(!1),[B,j]=N.useState(null),[Q,H]=N.useState(void 0),O=N.useCallback((G,Y)=>{const ye=Array.isArray(G==null?void 0:G.messages)?G.messages:[];Y==="replace"?b(ye):Y==="prepend"&&ye.length&&w(ye),j((G==null?void 0:G.nextCursor)??null),T(!!(G!=null&&G.hasMore)),H(se=>(G==null?void 0:G.checkpointId)??se??void 0)},[b,w]),[ne,L]=N.useState([]),[z,k]=N.useState(null),I=N.useCallback(async()=>{const G=await a.listThreads();L(G)},[a]);N.useEffect(()=>{I().catch(()=>{})},[I]),N.useEffect(()=>{r==null||r(z)},[z,r]);const ee=N.useRef(null);N.useEffect(()=>{o&&ee.current!==o&&(ee.current=o,te(o).catch(()=>{}))},[o]);const V=N.useRef(null),te=N.useCallback(async(G,Y,ye)=>{var se;if(V.current!==G){V.current=G;try{const Se=Y??((se=(await a.listCheckpoints(G)).checkpoints.slice().sort((ve,_e)=>new Date(_e.createdAt).getTime()-new Date(ve.createdAt).getTime())[0])==null?void 0:se.checkpointId);T(!1),j(null),H(void 0);const fe=await a.getMessages({threadId:G,checkpointId:Se,checkpointNs:ye,limit:E});k(G),O(fe,"replace")}finally{V.current=null}}},[a,O]),D=N.useCallback(async G=>a.listCheckpoints(G),[a]),W=N.useCallback(async G=>{if(!z)throw new Error("No active thread");T(!1),j(null),H(void 0);const Y=await a.getMessages({threadId:z,checkpointId:G,limit:E});O(Y,"replace")},[a,z,O]),xe=N.useCallback(async()=>{if(!z)throw new Error("No active thread");await te(z)},[z,te]),ie=N.useRef(!1);N.useEffect(()=>{const G=ie.current;if(ie.current=c,G&&!c&&z){const Y=h.lastCheckpointId??void 0;(async()=>{try{const ye=await a.getMessages({threadId:z,checkpointId:Y,limit:E});O(ye,"replace")}catch{}try{await I()}catch{}})()}},[c,z,h.lastCheckpointId,a,O,I]);const R=N.useCallback(async G=>{const Y=await a.createThread(G);return await I(),await te(Y.threadId),Y.threadId},[a,I,te]),le=N.useCallback(async G=>{await a.deleteThread(G),await I(),z===G&&(k(null),C([]),T(!1),j(null),H(void 0))},[a,I,z,C]),he=N.useCallback(async(G,Y)=>{await a.updateThread(G,Y),await I()},[a,I]),de=N.useCallback(async(G,Y)=>{var Fr;if(!z)throw new Error("No active thread");async function ye(me){return await new Promise((Ie,$e)=>{const Je=new FileReader;Je.onload=()=>Ie(String(Je.result)),Je.onerror=ht=>$e(ht),Je.readAsDataURL(me)})}async function se(me){return await new Promise((Ie,$e)=>{const Je=new FileReader;Je.onload=()=>{try{const ht=Je.result;let $r="";const _=new Uint8Array(ht),$=_.byteLength;for(let K=0;K<$;K++)$r+=String.fromCharCode(_[K]);Ie(btoa($r))}catch(ht){$e(ht)}},Je.onerror=ht=>$e(ht),Je.readAsArrayBuffer(me)})}const Se=[];G&&Se.push({type:"text",text:G});const fe=(Y==null?void 0:Y.attachments)||[];let ve=[];if(fe.length>0)for(const me of fe)if(me.type&&me.type.startsWith("image/")){let Ie=null;try{const $e=await a.uploadImage(me,(t==null?void 0:t.uploadPath)||"/upload").catch(()=>null);Ie=($e==null?void 0:$e.url)||null}catch{}if(!Ie)try{Ie=await ye(me)}catch{Ie=null}if(Ie){const $e={type:"image_url",url:Ie,mimeType:me.type,alt:me.name};Se.push($e)}try{ve.push({filename:me.name,data:await se(me),mime_type:me.type||"application/octet-stream"})}catch{}}else{const Ie=await ye(me).catch(()=>null),$e={type:"file",url:String(Ie),mimeType:me.type||void 0,name:me.name,size:me.size};Se.push($e);try{ve.push({filename:me.name,data:await se(me),mime_type:me.type||"application/octet-stream"})}catch{}}const _e={id:((Fr=crypto.randomUUID)==null?void 0:Fr.call(crypto))||`user-${Date.now()}`,role:"user",content:Se,createdAt:new Date().toISOString(),checkpointId:(Y==null?void 0:Y.checkpointId)??h.lastCheckpointId??void 0};y(_e);const Fe={..._e,content:_e.content.filter(me=>me.type==="text"||me.type==="image_url")},pt={...(Y==null?void 0:Y.payloadExtras)??{}},Cs=!!pt.edit,Cn=pt.originalMessageId,Es=typeof Cn=="string"?Cn:void 0,Lr=pt.branchLabel,En=typeof Lr=="string"?Lr:void 0,Ns={threadId:z,payload:{messages:[Fe],attachments:_e.content.filter(me=>me.type==="file").map(me=>({type:"file",url:me.url,mimeType:me.mimeType,name:me.name,size:me.size})),files_info:ve,...pt},checkpointId:(Y==null?void 0:Y.checkpointId)??h.lastCheckpointId??void 0,checkpointNs:Y==null?void 0:Y.checkpointNs,nodeFilter:Y==null?void 0:Y.nodeFilter,config:Y==null?void 0:Y.config,edit:Cs,originalMessageId:Es,branchLabel:En};f(Ns,me=>x(me),{onError:me=>console.warn("stream error",me)})},[z,y,f,x,h.lastCheckpointId,a,t==null?void 0:t.uploadPath]),be=N.useCallback(async G=>{if(!z)throw new Error("No active thread");if(F||!P)return;const Y=B;if(Y){M(!0);try{const ye=await a.getMessages({threadId:z,checkpointId:Q,limit:(G==null?void 0:G.limit)??E,beforeId:Y});O(ye,"prepend")}finally{M(!1)}}},[a,z,Q,B,P,F,O]),ge={baseUrl:a.baseUrl,token:m,setToken:g,api:a,threads:ne,currentThreadId:z,setCurrentThreadId:k,messages:h.messages,isStreaming:c,error:d,lastCheckpointId:h.lastCheckpointId,lastBranchEvent:h.lastBranch,streamingAssistantId:h.assemblingId,hasMoreHistory:P,isLoadingHistory:F,loadOlderMessages:be,historyPageSize:E,refreshThreads:I,createThread:R,deleteThread:le,renameThread:he,loadThread:te,listCheckpoints:D,navigateToCheckpoint:W,returnToLatest:xe,send:de,stop:u};return i.jsx(xa.Provider,{value:ge,children:e})}function io(){const e=N.useContext(xa);if(!e)throw new Error("useChat must be used within ChatProvider");return e}function A(...e){return tu.twMerge(eu.clsx(e))}const Ff=Yt.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),we=l.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const a=r?Be.Slot:"button";return i.jsx(a,{className:A(Ff({variant:t,size:n,className:e})),ref:s,...o})});we.displayName="Button";const Sa=l.forwardRef(({className:e,...t},n)=>i.jsx("textarea",{className:A("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Sa.displayName="Textarea";const $f=Yt.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ca({className:e,variant:t,...n}){return i.jsx("div",{className:A($f({variant:t}),e),...n})}function U(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Bf(e,t){const n=l.createContext(t),r=s=>{const{children:a,...c}=s,d=l.useMemo(()=>c,Object.values(c));return i.jsx(n.Provider,{value:d,children:a})};r.displayName=e+"Provider";function o(s){const a=l.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function Re(e,t=[]){let n=[];function r(s,a){const c=l.createContext(a),d=n.length;n=[...n,a];const f=p=>{var w;const{scope:m,children:v,...g}=p,h=((w=m==null?void 0:m[e])==null?void 0:w[d])||c,b=l.useMemo(()=>g,Object.values(g));return i.jsx(h.Provider,{value:b,children:v})};f.displayName=s+"Provider";function u(p,m){var h;const v=((h=m==null?void 0:m[e])==null?void 0:h[d])||c,g=l.useContext(v);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[f,u]}const o=()=>{const s=n.map(a=>l.createContext(a));return function(c){const d=(c==null?void 0:c[e])||s;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[r,Uf(o,...t)]}function Uf(...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 a=r.reduce((c,{useScope:d,scopeName:f})=>{const p=d(s)[`__scope${f}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var Ne=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},Hf=l[" useInsertionEffect ".trim().toString()]||Ne;function gt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,a]=zf({defaultProp:t,onChange:n}),c=e!==void 0,d=c?e:o;{const u=l.useRef(e!==void 0);l.useEffect(()=>{const p=u.current;p!==c&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${c?"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.`),u.current=c},[c,r])}const f=l.useCallback(u=>{var p;if(c){const m=Wf(u)?u(e):u;m!==e&&((p=a.current)==null||p.call(a,m))}else s(u)},[c,e,s,a]);return[d,f]}function zf({defaultProp:e,onChange:t}){const[n,r]=l.useState(e),o=l.useRef(n),s=l.useRef(t);return Hf(()=>{s.current=t},[t]),l.useEffect(()=>{var a;o.current!==n&&((a=s.current)==null||a.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Wf(e){return typeof e=="function"}function Ea(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function co(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Ea(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():Ea(e[o],null)}}}}function ue(...e){return l.useCallback(co(...e),e)}var jf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],oe=jf.reduce((e,t)=>{const n=Be.createSlot(`Primitive.${t}`),r=l.forwardRef((o,s)=>{const{asChild:a,...c}=o,d=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(d,{...c,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Na(e,t){e&&Nn.flushSync(()=>e.dispatchEvent(t))}function Vf(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var Le=e=>{const{present:t,children:n}=e,r=Rf(t),o=typeof n=="function"?n({present:r.isPresent}):l.Children.only(n),s=ue(r.ref,Kf(o));return typeof n=="function"||r.isPresent?l.cloneElement(o,{ref:s}):null};Le.displayName="Presence";function Rf(e){const[t,n]=l.useState(),r=l.useRef(null),o=l.useRef(e),s=l.useRef("none"),a=e?"mounted":"unmounted",[c,d]=Vf(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const f=Bn(r.current);s.current=c==="mounted"?f:"none"},[c]),Ne(()=>{const f=r.current,u=o.current;if(u!==e){const m=s.current,v=Bn(f);e?d("MOUNT"):v==="none"||(f==null?void 0:f.display)==="none"?d("UNMOUNT"):d(u&&m!==v?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),Ne(()=>{if(t){let f;const u=t.ownerDocument.defaultView??window,p=v=>{const h=Bn(r.current).includes(CSS.escape(v.animationName));if(v.target===t&&h&&(d("ANIMATION_END"),!o.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",f=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},m=v=>{v.target===t&&(s.current=Bn(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{u.clearTimeout(f),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:l.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function Bn(e){return(e==null?void 0:e.animationName)||"none"}function Kf(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Gf=l[" useId ".trim().toString()]||(()=>{}),qf=0;function Ke(e){const[t,n]=l.useState(Gf());return Ne(()=>{n(r=>r??String(qf++))},[e]),t?`radix-${t}`:""}var Un="Collapsible",[Xf,ry]=Re(Un),[Yf,lo]=Xf(Un),Ta=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:a,...c}=e,[d,f]=gt({prop:r,defaultProp:o??!1,onChange:a,caller:Un});return i.jsx(Yf,{scope:n,disabled:s,contentId:Ke(),open:d,onOpenToggle:l.useCallback(()=>f(u=>!u),[f]),children:i.jsx(oe.div,{"data-state":fo(d),"data-disabled":s?"":void 0,...c,ref:t})})});Ta.displayName=Un;var Aa="CollapsibleTrigger",Ia=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=lo(Aa,n);return i.jsx(oe.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":fo(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:U(e.onClick,o.onOpenToggle)})});Ia.displayName=Aa;var uo="CollapsibleContent",Jf=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=lo(uo,e.__scopeCollapsible);return i.jsx(Le,{present:n||o.open,children:({present:s})=>i.jsx(Zf,{...r,ref:t,present:s})})});Jf.displayName=uo;var Zf=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,a=lo(uo,n),[c,d]=l.useState(r),f=l.useRef(null),u=ue(t,f),p=l.useRef(0),m=p.current,v=l.useRef(0),g=v.current,h=a.open||c,b=l.useRef(h),w=l.useRef(void 0);return l.useEffect(()=>{const y=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(y)},[]),Ne(()=>{const y=f.current;if(y){w.current=w.current||{transitionDuration:y.style.transitionDuration,animationName:y.style.animationName},y.style.transitionDuration="0s",y.style.animationName="none";const x=y.getBoundingClientRect();p.current=x.height,v.current=x.width,b.current||(y.style.transitionDuration=w.current.transitionDuration,y.style.animationName=w.current.animationName),d(r)}},[a.open,r]),i.jsx(oe.div,{"data-state":fo(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!h,...s,ref:u,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:h&&o})});function fo(e){return e?"open":"closed"}var Qf=Ta;const ka=Qf,_a=Ia;function on({content:e,className:t=""}){const n=N.useMemo(()=>({table:({node:f,className:u,...p})=>i.jsx("div",{className:"max-w-full",children:i.jsx("table",{...p,className:A("w-full table-fixed border-collapse break-words",u)})}),th:({node:f,className:u,...p})=>i.jsx("th",{...p,className:A("break-words whitespace-normal border-b border-border/60 px-3 py-2 text-left align-top",u)}),td:({node:f,className:u,...p})=>i.jsx("td",{...p,className:A("break-words whitespace-normal border-b border-border/30 px-3 py-2 align-top",u)}),pre:({node:f,className:u,...p})=>i.jsx("pre",{...p,className:A("whitespace-pre-wrap break-words",u)}),code:({node:f,className:u,children:p,...m})=>{const{inline:v,...g}=m;return v?i.jsx("code",{...g,className:A("break-words whitespace-normal",u),children:p}):i.jsx("code",{...g,className:A("block break-words whitespace-pre-wrap",u),children:p})}}),[]),r=A("prose prose-sm max-w-none break-words dark:prose-invert leading-relaxed","prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words","prose-a:break-all prose-blockquote:break-words prose-strong:break-words prose-em:break-words","prose-code:break-words prose-pre:rounded prose-pre:border prose-pre:bg-background/50","prose-code:bg-background/50 prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-table:my-4 prose-th:px-2 prose-td:px-2",t);return i.jsx("div",{className:r,style:{wordBreak:"break-word",overflowWrap:"anywhere"},children:i.jsx(nu,{remarkPlugins:[ru],components:n,children:e})})}const Hn="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function ep({className:e}){const[t,n]=N.useState(0);return N.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),i.jsxs("span",{"aria-live":"polite",className:A("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Pa({message:e,messageIndex:t,isStreamingMessage:n=!1,streamingDebounceMs:r=40,isEditing:o=!1,showActions:s=!0,showTimestamp:a=!0,showAgentName:c=!0,layoutSize:d="desktop",truncateToolMessages:f=!0,toolMessagePreviewLength:u=200,truncateUserMessages:p=!0,userMessagePreviewLength:m=200,customStyles:v={},checkpointBranches:g=[],currentCheckpointId:h,onSwitchToCheckpoint:b,onReturnToMainThread:w,temporalNavigation:y,onNavigateToPreviousBranch:x,onNavigateToNextBranch:C,onEdit:E,onRegenerate:P,onEditFromCheckpoint:T,onCancelEdit:F,onCopy:M}){const[B,j]=N.useState(!1),[Q,H]=N.useState(!1),[O,ne]=N.useState(!1),[L,z]=N.useState(!1),k=d==="phone"||d==="half-screen",I=e.role,ee=I==="tool",V=N.useMemo(()=>{switch(I){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-foreground"}},[I]),te=N.useMemo(()=>tp(e.content),[e.content]),D=N.useMemo(()=>ip(e.content),[e.content]),W=N.useMemo(()=>e.content.filter(se=>se.type==="image_url"),[e.content]),xe=N.useMemo(()=>e.content.filter(se=>se.type==="file"),[e.content]),ie=dp(te,n?r:0),R=async()=>{try{const se=ee?Ft(e.content):te;await navigator.clipboard.writeText(se),j(!0),setTimeout(()=>j(!1),2e3),M==null||M(se)}catch(se){console.error("Failed to copy:",se)}},le=()=>{if(!E)return;const se=ee?Ft(e.content):te;E(e.id,se)},he=()=>P==null?void 0:P(t),de=()=>{const Se=A(k?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",V);switch(I){case"user":return i.jsx(q.User,{className:Se});case"assistant":return i.jsx(q.Bot,{className:Se});case"tool":return i.jsx(q.Wrench,{className:Se});default:return i.jsx(q.Bot,{className:Se})}},be=()=>{const se="group relative mb-4 flex w-full";switch(I){case"user":return A(se,"justify-end");case"assistant":case"tool":case"system":return A(se,"justify-start");default:return se}},ge=()=>{const se=A("rounded-lg px-4 py-3 relative transition-all duration-200 min-w-0 max-w-full break-words",k&&"px-3 py-2 text-sm");switch(I){case"user":return A(se,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return A(se,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return A(se,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return A(se,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return se}},G=se=>{if(!se)return"";try{return new Date(se).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}},Y=()=>{if(e.model==="reflection"){const fe=te.trim(),ve=po(fe);if(ve&&typeof ve=="object")return i.jsx(up,{data:ve})}if(ee&&D.name==="get_issues"){const fe=e.content.find(Fe=>Fe.type==="tool_result"),ve=(fe==null?void 0:fe.output)??Ft(e.content),_e=Ma(ve);if(_e)return i.jsx(fp,{issues:_e})}if(ee&&!O){const fe=Ft(e.content).slice(0,80).replace(/\s+/g," ");return i.jsx("div",{className:A("text-xs font-mono opacity-70 flex items-center justify-between gap-2 text-current",k&&"text-[10px]"),children:i.jsxs("span",{className:"truncate max-w-full text-current",children:[fe,fe.length>=80?"…":""]})})}if(ee&&f){const fe=Ft(e.content),ve=fe.length>u;return i.jsx(ka,{open:Q,onOpenChange:H,children:i.jsxs("div",{className:"font-mono text-sm text-current",children:[i.jsx("pre",{className:A("whitespace-pre-wrap break-words text-current",k&&"text-xs"),children:ve&&!Q?fe.substring(0,u)+"...":fe}),ve&&i.jsx(_a,{asChild:!0,children:i.jsx(we,{variant:"ghost",size:"sm",className:"h-6 text-xs text-current",children:Q?i.jsxs(i.Fragment,{children:[i.jsx(q.ChevronUp,{className:"h-3 w-3 mr-1"}),"Show less"]}):i.jsxs(i.Fragment,{children:[i.jsx(q.ChevronDown,{className:"h-3 w-3 mr-1"}),"Show more (",fe.length-u," chars)"]})})})]})})}if(ee&&O&&!f){const fe=ap(e.content);if(fe&&np(fe))return i.jsx(on,{content:fe.trim()});const ve=Ft(e.content);return i.jsx("div",{className:"font-mono text-sm text-current",children:i.jsx("pre",{className:A("whitespace-pre-wrap break-words text-current",k&&"text-xs"),children:ve})})}const se=W.length>0&&I!=="tool",Se=xe.length>0&&I!=="tool";return i.jsxs("div",{children:[n?i.jsxs("div",{className:"relative",children:[(()=>{const fe=po(ie);return fe!==null?i.jsx(Oa,{data:fe}):i.jsx(on,{content:op(rp(ie))})})(),i.jsx(ep,{className:A(V,k?"text-xs":"text-sm")})]}):(()=>{const fe=po(te.trim());if(fe!==null)return i.jsx(Oa,{data:fe});if(I==="user"&&p){const ve=te.trim();if(ve.length>m)return i.jsxs(ka,{open:L,onOpenChange:z,children:[i.jsx("div",{className:A("text-sm text-[hsl(var(--chat-bubble-user-text))]",k&&"text-xs"),children:L?i.jsx(on,{content:ve}):i.jsxs("pre",{className:A("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",k&&"text-xs"),children:[ve.substring(0,m),"..."]})}),i.jsx(_a,{asChild:!0,children:i.jsx(we,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:L?i.jsxs(i.Fragment,{children:[i.jsx(q.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):i.jsxs(i.Fragment,{children:[i.jsx(q.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",ve.length-m," chars)"]})})})]})}return i.jsx(on,{content:te.trim()})})(),se&&i.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:W.map((fe,ve)=>i.jsxs("div",{className:"relative border rounded overflow-hidden",children:[i.jsx("img",{src:fe.url,alt:fe.alt??"image",className:"w-full h-auto"}),i.jsxs("div",{className:"absolute top-1 right-1 bg-background/70 rounded px-1 py-0.5 text-[10px] flex items-center gap-1",children:[i.jsx(q.Image,{className:"h-3 w-3"}),i.jsx("span",{children:"image"})]})]},ve))}),Se&&i.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:xe.map((fe,ve)=>{const _e=fe,Fe=_e.name||"file";return i.jsxs("a",{href:_e.url,download:Fe,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-2 bg-gray-100 border border-gray-200 rounded px-2 py-1 text-xs hover:bg-gray-200",title:Fe,children:[i.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-gray-400"}),i.jsx("span",{className:"truncate max-w-[180px]",children:Fe})]},ve)})})]})},ye=N.useMemo(()=>cp(e),[e]);return N.useMemo(()=>lp(e,h),[e,h]),i.jsx("div",{className:A(be(),v.container),children:i.jsxs("div",{className:A(ge(),v.content),children:[(a||c||ee)&&i.jsxs("div",{className:A("flex items-center justify-between mb-2 pb-2 border-b border-current/10",k&&"mb-1 pb-1",V,v.header),children:[i.jsxs("div",{className:"flex items-center gap-2",children:[de(),c&&ye&&i.jsx("span",{className:A("font-medium",k?"text-xs":"text-sm"),children:ye}),ee&&D.name&&i.jsxs(Ca,{variant:"outline",className:A("text-xs flex items-center gap-1 cursor-pointer",V,"border border-current/40",k&&"text-xs h-4"),onClick:()=>ne(se=>!se),children:[i.jsx("span",{children:D.name}),i.jsx("span",{className:"inline-flex items-center",children:O?i.jsx(q.ChevronUp,{className:"h-3 w-3"}):i.jsx(q.ChevronDown,{className:"h-3 w-3"})})]}),ee&&!D.name&&i.jsx(we,{variant:"ghost",size:"sm",className:A("h-6 px-1",V,"hover:bg-foreground/10"),onClick:()=>ne(se=>!se),children:i.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",O?i.jsx(q.ChevronUp,{className:"h-3 w-3"}):i.jsx(q.ChevronDown,{className:"h-3 w-3"})]})})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[a&&i.jsx("span",{className:A("text-xs opacity-60",V,k&&"text-xs"),children:G(e.createdAt)}),s&&!o&&i.jsxs("div",{className:A("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[i.jsx(we,{variant:"ghost",size:"sm",onClick:R,className:A("h-6 w-6 p-0 hover:bg-foreground/10",V,k&&"h-5 w-5"),children:i.jsx(q.Copy,{className:A(B?"text-success":V,k?"h-3 w-3":"h-4 w-4")})}),I==="user"&&E&&i.jsx(we,{variant:"ghost",size:"sm",onClick:le,className:A("h-6 w-6 p-0 hover:bg-foreground/10",V,k&&"h-5 w-5"),children:i.jsx(q.Edit,{className:A(V,k?"h-3 w-3":"h-4 w-4")})}),I==="assistant"&&P&&i.jsx(we,{variant:"ghost",size:"sm",onClick:he,className:A("h-6 w-6 p-0 hover:bg-foreground/10",V,k&&"h-5 w-5"),children:i.jsx(q.RotateCcw,{className:A(V,k?"h-3 w-3":"h-4 w-4")})})]})]})]}),i.jsx("div",{className:"relative",children:Y()}),ee&&O&&(D.toolCallId||D.name)&&i.jsxs("div",{className:A("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",k&&"text-xs"),children:[D.name&&i.jsxs("div",{children:["Function: ",D.name]}),D.toolCallId&&i.jsxs("div",{children:["Call ID: ",D.toolCallId]})]}),s&&I==="user"&&y&&y.totalBranches>1&&i.jsxs("div",{className:"flex items-center gap-2 mt-2 p-2 bg-muted/30 rounded border",children:[i.jsx(q.GitBranch,{className:"h-3 w-3 text-muted-foreground"}),i.jsxs("span",{className:"text-xs text-muted-foreground",children:["Branch ",y.currentIndex+1," of ",y.totalBranches,y.currentLabel?` • ${y.currentLabel}`:""]}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx(we,{variant:"ghost",size:"sm",className:A("h-6 w-6 p-0",V),disabled:!y.canGoBack,onClick:()=>x==null?void 0:x(),title:"Go back to previous branch",children:i.jsx(q.ChevronLeft,{className:A("h-3 w-3",V)})}),i.jsx(we,{variant:"ghost",size:"sm",className:A("h-6 w-6 p-0",V),disabled:!y.canGoForward,onClick:()=>C==null?void 0:C(),title:"Go forward to next branch",children:i.jsx(q.ChevronRight,{className:A("h-3 w-3",V)})})]})]}),!(a||c||ee)&&s&&!o&&i.jsxs("div",{className:A("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[i.jsx(we,{variant:"ghost",size:"sm",onClick:R,className:A("h-6 w-6 p-0 hover:bg-background/50 text-current",k&&"h-5 w-5"),children:i.jsx(q.Copy,{className:A(B?"text-success":"text-current",k?"h-3 w-3":"h-4 w-4")})}),I==="user"&&E&&i.jsx(we,{variant:"ghost",size:"sm",onClick:le,className:A("h-6 w-6 p-0 hover:bg-background/50 text-current",k&&"h-5 w-5"),children:i.jsx(q.Edit,{className:A("text-current",k?"h-3 w-3":"h-4 w-4")})}),I==="assistant"&&P&&i.jsx(we,{variant:"ghost",size:"sm",onClick:he,className:A("h-6 w-6 p-0 hover:bg-background/50 text-current",k&&"h-5 w-5"),children:i.jsx(q.RotateCcw,{className:A("text-current",k?"h-3 w-3":"h-4 w-4")})})]})]})})}function tp(e){const t=e.filter(n=>n.type==="text").map(n=>n.text).join("");return t||JSON.stringify(e)}function np(e){return e.includes(`
10
- `)||e.includes("```")||/[-*] /.test(e)||/#+\s/.test(e)}function rp(e){let t=e;try{(t.match(/```/g)||[]).length%2===1&&(t+="\n```"),(t.replace(/```[\s\S]*?```/g,"").match(new RegExp("(?<!`)`(?!`)","g"))||[]).length%2===1&&(t+="`")}catch{}return t}function op(e){let t=e;try{const n=[],r=[],o="\0F",s="\0I";let a=t.replace(/```[\s\S]*?```/g,c=>(n.push(c),`${o}${n.length-1}\0`));a=a.replace(/`[^`]*`/g,c=>(r.push(c),`${s}${r.length-1}\0`)),a=a.replace(/\b([A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/\b([A-Za-z0-9_&\/-]+\s+[A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/([\.,;:!\?\-])\1+/g,"$1").replace(/([:;!\?\)])([A-Za-z])/g,"$1 $2").replace(/\s{3,}/g," "),a=a.replace(/\u0000F(\d+)\u0000/g,(c,d)=>n[Number(d)]??""),a=a.replace(/\u0000I(\d+)\u0000/g,(c,d)=>r[Number(d)]??""),t=a}catch{}return t}function po(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function Oa({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?i.jsx("div",{className:Hn,children:i.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>i.jsx("li",{children:String(n)},r))})}):i.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:sn(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return i.jsxs("div",{className:Hn,children:[typeof r=="boolean"&&i.jsxs("p",{children:[i.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&i.jsxs("div",{children:[i.jsx("p",{children:i.jsx("strong",{children:"Follow-up queries:"})}),i.jsx("ul",{className:"list-disc pl-5",children:n.map((s,a)=>i.jsx("li",{children:String(s)},a))})]}),t&&t.length>0&&i.jsxs("div",{children:[i.jsx("p",{children:i.jsx("strong",{children:"Facts:"})}),i.jsx("ul",{className:"list-disc pl-5",children:t.map((s,a)=>i.jsx("li",{children:String(s)},a))})]})]});const o=Object.entries(e);return i.jsx("div",{className:Hn,children:i.jsx("dl",{className:"mt-0",children:o.map(([s,a])=>i.jsxs("div",{className:"mb-1",children:[i.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),i.jsx("dd",{className:"inline",children:sp(a)})]},s))})})}return i.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:sn(e)})}function sp(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return i.jsx("code",{className:"text-xs",children:JSON.stringify(e)})}catch{return String(e)}}function Ft(e){const t=e.filter(n=>n.type==="tool_result");if(t.length)try{return t.length===1?sn(t[0].output):sn(t.map(n=>({toolCallId:n.toolCallId,output:n.output})))}catch{}return sn(e)}function ap(e){const t=e.find(r=>r.type==="tool_result");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function sn(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function ip(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_result");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function cp(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function lp(e,t){return e.checkpointId||t||null}function dp(e,t){const[n,r]=N.useState(e);return N.useEffect(()=>{if(!t){r(e);return}const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}function up({data:e}){return i.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>i.jsxs("div",{className:"flex",children:[i.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),i.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>i.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Ma(e){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){if(e.desirability||e.feasibility||e.viability||e.other)return{desirability:Array.isArray(e.desirability)?e.desirability:[],feasibility:Array.isArray(e.feasibility)?e.feasibility:[],viability:Array.isArray(e.viability)?e.viability:[],other:Array.isArray(e.other)?e.other:[]};if(e.output&&typeof e.output!="object")e=e.output;else if(e.output&&typeof e.output=="object")return Ma(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(a=>{const c=r.toLowerCase().indexOf(a);return c===-1?Number.MAX_SAFE_INTEGER:c}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const a of Object.keys(n)){const d=new RegExp(a+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!d)continue;const f=d[1],u=/Issue\(([\s\S]*?)\)(?:,|$)/g;let p=null;for(;(p=u.exec(f))!==null;){const m=p[1],v=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(m),g=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(m),h=v?v[2].trim():"",b=g?g[2].trim():"";n[a].push({title:h,description:b})}}return Object.values(n).some(a=>a.length>0)?n:null}function fp({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return i.jsx("div",{className:Hn,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:i.jsxs("div",{className:"mb-4",children:[i.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),i.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>i.jsxs("li",{children:[i.jsx("div",{className:"font-medium",children:o.title}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const $t=1e4;function pp(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
8
+ `))>=0;){const j=z.slice(0,Z);z=z.slice(Z+2);const te=_f(j);if(!te)continue;let D;try{D=JSON.parse(te)}catch{T&&console.debug("[use-chat] skip malformed SSE data:",te==null?void 0:te.slice(0,200));continue}const W=kf(D)?D.data:D;if(T&&console.debug("[use-chat] event:",W==null?void 0:W.type,W),C==null||C(W),W.type==="token")e.autoAppendAssistant!==!1&&p(xe=>xe+W.content);else if(W.type==="message_delta"){const xe=W.delta.filter(ie=>ie.type==="text").map(ie=>ie.text).join("");xe&&e.autoAppendAssistant!==!1&&p(ie=>ie+xe)}else W.type==="checkpoint"?v(W.checkpointId):W.type==="error"&&f(W.message)}}}catch(H){if((H==null?void 0:H.name)==="AbortError")return;const O=(H==null?void 0:H.message)||String(H);T&&console.debug("[use-chat] error:",O),f(O),(J=E==null?void 0:E.onError)==null||J.call(E,O)}finally{c(!1),g.current=null}})(),{close:()=>P.abort()}},[t,r,e.autoAppendAssistant]);return N.useEffect(()=>()=>{var x;return(x=g.current)==null?void 0:x.abort()},[]),{isStreaming:a,error:d,assistantText:u,lastCheckpointId:m,stream:y,stop:b,clear:w,setToken:h}}function kf(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function _f(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
9
+ `)}const Pf={messages:[],assemblingId:null,lastCheckpointId:null,toolIndex:{},lastBranch:null};function Of(e,t){var n,r;switch(t.type){case"reset":return{messages:ao(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,toolIndex:{},lastBranch:null};case"seed":return{...e,messages:ao(t.payload.messages)};case"prepend":{const o=ao(t.payload.messages);if(!o.length)return e;const s=new Set(e.messages.map(c=>c.id)),a=o.filter(c=>!s.has(c.id));return a.length?{...e,messages:[...a,...e.messages]}:e}case"user_message":{const o=t.payload.message;if(e.assemblingId){const s=e.messages.findIndex(a=>a.id===e.assemblingId&&a.role==="assistant");if(s>=0){const a=e.messages.slice(0,s),c=e.messages.slice(s);return{...e,messages:[...a,o,...c]}}}return{...e,messages:[...e.messages,o]}}case"event":{const o=t.payload.ev;if(o.type==="message_start"&&o.role==="assistant"){const s=o.id,a=Ff(o.model),c={id:s,role:"assistant",name:a||void 0,model:o.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,c]}}if(o.type==="token"){const s=e.assemblingId??io(e.messages);return s?{...e,messages:Mf(e.messages,s,o.content)}:e}if(o.type==="message_delta"){const s=e.assemblingId??io(e.messages);return s?{...e,messages:xa(e.messages,s,o.delta)}:e}if(o.type==="message_end"){const s=e.assemblingId??io(e.messages);if(!s)return{...e,assemblingId:null};const a=e.messages,c=a.findIndex(d=>d.id===s&&d.role==="assistant");if(c>=0&&!((r=a[c].content)==null?void 0:r.some(u=>{var p;return(u==null?void 0:u.type)==="text"&&((p=u.text)==null?void 0:p.trim())}))){const u=[...a.slice(0,c),...a.slice(c+1)];return{...e,assemblingId:null,messages:u}}return{...e,assemblingId:null}}if(o.type==="tool_start"){const s=`tool-${o.id}`,a={type:"tool_call",id:o.id,name:o.name,args:o.args},c={id:s,role:"tool",name:o.name,createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,c],toolIndex:{...e.toolIndex,[o.id]:s}}}if(o.type==="tool_result"){const s=e.toolIndex[o.id]??`tool-${o.id}`,a={type:"tool_result",toolCallId:o.id,output:o.output,error:o.error},c=e.messages.find(u=>u.id===s),d={id:s,role:"tool",content:[a],createdAt:new Date().toISOString()},f=c?xa(e.messages,s,[a]):[...e.messages,d];return{...e,messages:f}}if(o.type==="checkpoint"){const s=Lf(e.messages,o.checkpointId);return{...e,lastCheckpointId:o.checkpointId,messages:s}}if(o.type==="branch"){const s=o.checkpointId??e.lastCheckpointId;return{...e,lastBranch:o,lastCheckpointId:s??null}}if(o.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${o.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}return e}default:return e}}function ya(e=[]){const[t,n]=N.useReducer(Of,{...Pf,messages:e}),r=N.useCallback(s=>{n({type:"event",payload:{ev:s}})},[]),o=N.useMemo(()=>({reset:s=>n({type:"reset",payload:{messages:s}}),seed:s=>n({type:"seed",payload:{messages:s}}),prepend:s=>n({type:"prepend",payload:{messages:s}}),pushUser:s=>n({type:"user_message",payload:{message:s}}),onEvent:r}),[r]);return{state:t,dispatch:n,...o}}function ao(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function io(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function Mf(e,t,n){return e.map(r=>{if(r.id!==t)return r;const o=r.content.slice(),s=o[o.length-1];return s&&s.type==="text"?s.text+=n:o.push({type:"text",text:n}),{...r,content:o}})}function xa(e,t,n){return e.map(r=>r.id===t?{...r,content:Df(r.content,n)}:r)}function Df(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1];(o==null?void 0:o.type)==="text"?o.text+=r.text:n.push({type:"text",text:r.text})}else n.push(r);return n}function Lf(e,t){for(let n=e.length-1;n>=0;n--)if(e[n].role==="assistant"){const o={...e[n],checkpointId:t};return[...e.slice(0,n),o,...e.slice(n+1)]}return e}function Ff(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const Sa=N.createContext(null);function on({children:e,apiConfig:t,onError:n,onThreadChange:r,initialThreadId:o=null,historyPageSize:s}){const a=ut;N.useEffect(()=>{t&&a.updateConfig({baseUrl:t.baseUrl,authToken:t.apiKey})},[a,t]);const{isStreaming:c,error:d,stream:f,stop:u,setToken:p}=wa({baseUrl:a.baseUrl,token:null,headers:t==null?void 0:t.headers,streamPath:"/chat/stream"}),[m,v]=N.useState(()=>typeof a.getAuthToken=="function"?a.getAuthToken():null);N.useEffect(()=>{p(typeof a.getAuthToken=="function"?a.getAuthToken():null);const G=a.onTokenChange(X=>{v(X),p(X)});return()=>{G()}},[a,p]);const g=N.useCallback(G=>{a.setAuthToken(G)},[a]),{state:h,seed:b,prepend:w,pushUser:y,onEvent:x,reset:C}=ya(),E=s&&s>0?s:6,[P,T]=N.useState(!1),[F,M]=N.useState(!1),[B,V]=N.useState(null),[J,H]=N.useState(void 0),O=N.useCallback((G,X)=>{const ye=Array.isArray(G==null?void 0:G.messages)?G.messages:[];X==="replace"?b(ye):X==="prepend"&&ye.length&&w(ye),V((G==null?void 0:G.nextCursor)??null),T(!!(G!=null&&G.hasMore)),H(se=>(G==null?void 0:G.checkpointId)??se??void 0)},[b,w]),[ne,L]=N.useState([]),[z,k]=N.useState(null),I=N.useCallback(async()=>{const G=await a.listThreads();L(G)},[a]);N.useEffect(()=>{I().catch(()=>{})},[I]),N.useEffect(()=>{r==null||r(z)},[z,r]);const Z=N.useRef(null);N.useEffect(()=>{o&&Z.current!==o&&(Z.current=o,te(o).catch(()=>{}))},[o]);const j=N.useRef(null),te=N.useCallback(async(G,X,ye)=>{var se;if(j.current!==G){j.current=G;try{const Se=X??((se=(await a.listCheckpoints(G)).checkpoints.slice().sort((ve,_e)=>new Date(_e.createdAt).getTime()-new Date(ve.createdAt).getTime())[0])==null?void 0:se.checkpointId);T(!1),V(null),H(void 0);const fe=await a.getMessages({threadId:G,checkpointId:Se,checkpointNs:ye,limit:E});k(G),O(fe,"replace")}finally{j.current=null}}},[a,O]),D=N.useCallback(async G=>a.listCheckpoints(G),[a]),W=N.useCallback(async G=>{if(!z)throw new Error("No active thread");T(!1),V(null),H(void 0);const X=await a.getMessages({threadId:z,checkpointId:G,limit:E});O(X,"replace")},[a,z,O]),xe=N.useCallback(async()=>{if(!z)throw new Error("No active thread");await te(z)},[z,te]),ie=N.useRef(!1);N.useEffect(()=>{const G=ie.current;if(ie.current=c,G&&!c&&z){const X=h.lastCheckpointId??void 0;(async()=>{try{const ye=await a.getMessages({threadId:z,checkpointId:X,limit:E});O(ye,"replace")}catch{}try{await I()}catch{}})()}},[c,z,h.lastCheckpointId,a,O,I]);const R=N.useCallback(async G=>{const X=await a.createThread(G);return await I(),await te(X.threadId),X.threadId},[a,I,te]),le=N.useCallback(async G=>{await a.deleteThread(G),await I(),z===G&&(k(null),C([]),T(!1),V(null),H(void 0))},[a,I,z,C]),he=N.useCallback(async(G,X)=>{await a.updateThread(G,X),await I()},[a,I]),de=N.useCallback(async(G,X)=>{var $r;if(!z)throw new Error("No active thread");async function ye(me){return await new Promise((Ie,$e)=>{const Ze=new FileReader;Ze.onload=()=>Ie(String(Ze.result)),Ze.onerror=gt=>$e(gt),Ze.readAsDataURL(me)})}async function se(me){return await new Promise((Ie,$e)=>{const Ze=new FileReader;Ze.onload=()=>{try{const gt=Ze.result;let Br="";const _=new Uint8Array(gt),$=_.byteLength;for(let K=0;K<$;K++)Br+=String.fromCharCode(_[K]);Ie(btoa(Br))}catch(gt){$e(gt)}},Ze.onerror=gt=>$e(gt),Ze.readAsArrayBuffer(me)})}const Se=[];G&&Se.push({type:"text",text:G});const fe=(X==null?void 0:X.attachments)||[];let ve=[];if(fe.length>0)for(const me of fe)if(me.type&&me.type.startsWith("image/")){let Ie=null;try{const $e=await a.uploadImage(me,(t==null?void 0:t.uploadPath)||"/upload").catch(()=>null);Ie=($e==null?void 0:$e.url)||null}catch{}if(!Ie)try{Ie=await ye(me)}catch{Ie=null}if(Ie){const $e={type:"image_url",url:Ie,mimeType:me.type,alt:me.name};Se.push($e)}try{ve.push({filename:me.name,data:await se(me),mime_type:me.type||"application/octet-stream"})}catch{}}else{const Ie=await ye(me).catch(()=>null),$e={type:"file",url:String(Ie),mimeType:me.type||void 0,name:me.name,size:me.size};Se.push($e);try{ve.push({filename:me.name,data:await se(me),mime_type:me.type||"application/octet-stream"})}catch{}}const _e={id:(($r=crypto.randomUUID)==null?void 0:$r.call(crypto))||`user-${Date.now()}`,role:"user",content:Se,createdAt:new Date().toISOString(),checkpointId:(X==null?void 0:X.checkpointId)??h.lastCheckpointId??void 0};y(_e);const Fe={..._e,content:_e.content.filter(me=>me.type==="text"||me.type==="image_url")},ht={...(X==null?void 0:X.payloadExtras)??{}},Es=!!ht.edit,En=ht.originalMessageId,Ns=typeof En=="string"?En:void 0,Fr=ht.branchLabel,Nn=typeof Fr=="string"?Fr:void 0,Ts={threadId:z,payload:{messages:[Fe],attachments:_e.content.filter(me=>me.type==="file").map(me=>({type:"file",url:me.url,mimeType:me.mimeType,name:me.name,size:me.size})),files_info:ve,...ht},checkpointId:(X==null?void 0:X.checkpointId)??h.lastCheckpointId??void 0,checkpointNs:X==null?void 0:X.checkpointNs,nodeFilter:X==null?void 0:X.nodeFilter,config:X==null?void 0:X.config,edit:Es,originalMessageId:Ns,branchLabel:Nn};f(Ts,me=>x(me),{onError:me=>console.warn("stream error",me)})},[z,y,f,x,h.lastCheckpointId,a,t==null?void 0:t.uploadPath]),be=N.useCallback(async G=>{if(!z)throw new Error("No active thread");if(F||!P)return;const X=B;if(X){M(!0);try{const ye=await a.getMessages({threadId:z,checkpointId:J,limit:(G==null?void 0:G.limit)??E,beforeId:X});O(ye,"prepend")}finally{M(!1)}}},[a,z,J,B,P,F,O]),ge={baseUrl:a.baseUrl,token:m,setToken:g,api:a,threads:ne,currentThreadId:z,setCurrentThreadId:k,messages:h.messages,isStreaming:c,error:d,lastCheckpointId:h.lastCheckpointId,lastBranchEvent:h.lastBranch,streamingAssistantId:h.assemblingId,hasMoreHistory:P,isLoadingHistory:F,loadOlderMessages:be,historyPageSize:E,refreshThreads:I,createThread:R,deleteThread:le,renameThread:he,loadThread:te,listCheckpoints:D,navigateToCheckpoint:W,returnToLatest:xe,send:de,stop:u};return i.jsx(Sa.Provider,{value:ge,children:e})}function co(){const e=N.useContext(Sa);if(!e)throw new Error("useChat must be used within ChatProvider");return e}function A(...e){return nu.twMerge(tu.clsx(e))}const $f=Jt.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),we=l.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const a=r?Be.Slot:"button";return i.jsx(a,{className:A($f({variant:t,size:n,className:e})),ref:s,...o})});we.displayName="Button";const Ca=l.forwardRef(({className:e,...t},n)=>i.jsx("textarea",{className:A("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ca.displayName="Textarea";const Bf=Jt.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ea({className:e,variant:t,...n}){return i.jsx("div",{className:A(Bf({variant:t}),e),...n})}function U(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Uf(e,t){const n=l.createContext(t),r=s=>{const{children:a,...c}=s,d=l.useMemo(()=>c,Object.values(c));return i.jsx(n.Provider,{value:d,children:a})};r.displayName=e+"Provider";function o(s){const a=l.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function Ke(e,t=[]){let n=[];function r(s,a){const c=l.createContext(a),d=n.length;n=[...n,a];const f=p=>{var w;const{scope:m,children:v,...g}=p,h=((w=m==null?void 0:m[e])==null?void 0:w[d])||c,b=l.useMemo(()=>g,Object.values(g));return i.jsx(h.Provider,{value:b,children:v})};f.displayName=s+"Provider";function u(p,m){var h;const v=((h=m==null?void 0:m[e])==null?void 0:h[d])||c,g=l.useContext(v);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[f,u]}const o=()=>{const s=n.map(a=>l.createContext(a));return function(c){const d=(c==null?void 0:c[e])||s;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[r,Hf(o,...t)]}function Hf(...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 a=r.reduce((c,{useScope:d,scopeName:f})=>{const p=d(s)[`__scope${f}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var Ne=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},zf=l[" useInsertionEffect ".trim().toString()]||Ne;function mt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,a]=Wf({defaultProp:t,onChange:n}),c=e!==void 0,d=c?e:o;{const u=l.useRef(e!==void 0);l.useEffect(()=>{const p=u.current;p!==c&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${c?"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.`),u.current=c},[c,r])}const f=l.useCallback(u=>{var p;if(c){const m=Vf(u)?u(e):u;m!==e&&((p=a.current)==null||p.call(a,m))}else s(u)},[c,e,s,a]);return[d,f]}function Wf({defaultProp:e,onChange:t}){const[n,r]=l.useState(e),o=l.useRef(n),s=l.useRef(t);return zf(()=>{s.current=t},[t]),l.useEffect(()=>{var a;o.current!==n&&((a=s.current)==null||a.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Vf(e){return typeof e=="function"}function Na(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function lo(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Na(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():Na(e[o],null)}}}}function ue(...e){return l.useCallback(lo(...e),e)}var jf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],oe=jf.reduce((e,t)=>{const n=Be.createSlot(`Primitive.${t}`),r=l.forwardRef((o,s)=>{const{asChild:a,...c}=o,d=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(d,{...c,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ta(e,t){e&&Tn.flushSync(()=>e.dispatchEvent(t))}function Rf(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var Le=e=>{const{present:t,children:n}=e,r=Kf(t),o=typeof n=="function"?n({present:r.isPresent}):l.Children.only(n),s=ue(r.ref,Gf(o));return typeof n=="function"||r.isPresent?l.cloneElement(o,{ref:s}):null};Le.displayName="Presence";function Kf(e){const[t,n]=l.useState(),r=l.useRef(null),o=l.useRef(e),s=l.useRef("none"),a=e?"mounted":"unmounted",[c,d]=Rf(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const f=Un(r.current);s.current=c==="mounted"?f:"none"},[c]),Ne(()=>{const f=r.current,u=o.current;if(u!==e){const m=s.current,v=Un(f);e?d("MOUNT"):v==="none"||(f==null?void 0:f.display)==="none"?d("UNMOUNT"):d(u&&m!==v?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),Ne(()=>{if(t){let f;const u=t.ownerDocument.defaultView??window,p=v=>{const h=Un(r.current).includes(CSS.escape(v.animationName));if(v.target===t&&h&&(d("ANIMATION_END"),!o.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",f=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},m=v=>{v.target===t&&(s.current=Un(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{u.clearTimeout(f),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:l.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function Un(e){return(e==null?void 0:e.animationName)||"none"}function Gf(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var qf=l[" useId ".trim().toString()]||(()=>{}),Xf=0;function Ge(e){const[t,n]=l.useState(qf());return Ne(()=>{n(r=>r??String(Xf++))},[e]),t?`radix-${t}`:""}var Hn="Collapsible",[Yf,sy]=Ke(Hn),[Jf,uo]=Yf(Hn),Aa=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:a,...c}=e,[d,f]=mt({prop:r,defaultProp:o??!1,onChange:a,caller:Hn});return i.jsx(Jf,{scope:n,disabled:s,contentId:Ge(),open:d,onOpenToggle:l.useCallback(()=>f(u=>!u),[f]),children:i.jsx(oe.div,{"data-state":po(d),"data-disabled":s?"":void 0,...c,ref:t})})});Aa.displayName=Hn;var Ia="CollapsibleTrigger",ka=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=uo(Ia,n);return i.jsx(oe.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":po(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:U(e.onClick,o.onOpenToggle)})});ka.displayName=Ia;var fo="CollapsibleContent",Zf=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=uo(fo,e.__scopeCollapsible);return i.jsx(Le,{present:n||o.open,children:({present:s})=>i.jsx(Qf,{...r,ref:t,present:s})})});Zf.displayName=fo;var Qf=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,a=uo(fo,n),[c,d]=l.useState(r),f=l.useRef(null),u=ue(t,f),p=l.useRef(0),m=p.current,v=l.useRef(0),g=v.current,h=a.open||c,b=l.useRef(h),w=l.useRef(void 0);return l.useEffect(()=>{const y=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(y)},[]),Ne(()=>{const y=f.current;if(y){w.current=w.current||{transitionDuration:y.style.transitionDuration,animationName:y.style.animationName},y.style.transitionDuration="0s",y.style.animationName="none";const x=y.getBoundingClientRect();p.current=x.height,v.current=x.width,b.current||(y.style.transitionDuration=w.current.transitionDuration,y.style.animationName=w.current.animationName),d(r)}},[a.open,r]),i.jsx(oe.div,{"data-state":po(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!h,...s,ref:u,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:h&&o})});function po(e){return e?"open":"closed"}var ep=Aa;const _a=ep,Pa=ka;function sn({content:e,className:t=""}){const n=N.useMemo(()=>({table:({node:f,className:u,...p})=>i.jsx("div",{className:"max-w-full",children:i.jsx("table",{...p,className:A("w-full table-fixed border-collapse break-words",u)})}),th:({node:f,className:u,...p})=>i.jsx("th",{...p,className:A("break-words whitespace-normal border-b border-border/60 px-3 py-2 text-left align-top",u)}),td:({node:f,className:u,...p})=>i.jsx("td",{...p,className:A("break-words whitespace-normal border-b border-border/30 px-3 py-2 align-top",u)}),pre:({node:f,className:u,...p})=>i.jsx("pre",{...p,className:A("whitespace-pre-wrap break-words",u)}),code:({node:f,className:u,children:p,...m})=>{const{inline:v,...g}=m;return v?i.jsx("code",{...g,className:A("break-words whitespace-normal",u),children:p}):i.jsx("code",{...g,className:A("block break-words whitespace-pre-wrap",u),children:p})}}),[]),r=A("prose prose-sm max-w-none break-words dark:prose-invert leading-relaxed","prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words","prose-a:break-all prose-blockquote:break-words prose-strong:break-words prose-em:break-words","prose-code:break-words prose-pre:rounded prose-pre:border prose-pre:bg-background/50","prose-code:bg-background/50 prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-table:my-4 prose-th:px-2 prose-td:px-2",t);return i.jsx("div",{className:r,style:{wordBreak:"break-word",overflowWrap:"anywhere"},children:i.jsx(ru,{remarkPlugins:[ou],components:n,children:e})})}const zn="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function tp({className:e}){const[t,n]=N.useState(0);return N.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),i.jsxs("span",{"aria-live":"polite",className:A("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Oa({message:e,messageIndex:t,isStreamingMessage:n=!1,streamingDebounceMs:r=40,isEditing:o=!1,showActions:s=!0,showTimestamp:a=!0,showAgentName:c=!0,layoutSize:d="desktop",truncateToolMessages:f=!0,toolMessagePreviewLength:u=200,truncateUserMessages:p=!0,userMessagePreviewLength:m=200,customStyles:v={},checkpointBranches:g=[],currentCheckpointId:h,onSwitchToCheckpoint:b,onReturnToMainThread:w,temporalNavigation:y,onNavigateToPreviousBranch:x,onNavigateToNextBranch:C,onEdit:E,onRegenerate:P,onEditFromCheckpoint:T,onCancelEdit:F,onCopy:M}){const[B,V]=N.useState(!1),[J,H]=N.useState(!1),[O,ne]=N.useState(!1),[L,z]=N.useState(!1),k=d==="phone"||d==="half-screen",I=e.role,Z=I==="tool",j=N.useMemo(()=>{switch(I){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-foreground"}},[I]),te=N.useMemo(()=>np(e.content),[e.content]),D=N.useMemo(()=>cp(e.content),[e.content]),W=N.useMemo(()=>e.content.filter(se=>se.type==="image_url"),[e.content]),xe=N.useMemo(()=>e.content.filter(se=>se.type==="file"),[e.content]),ie=up(te,n?r:0),R=async()=>{try{const se=Z?$t(e.content):te;await navigator.clipboard.writeText(se),V(!0),setTimeout(()=>V(!1),2e3),M==null||M(se)}catch(se){console.error("Failed to copy:",se)}},le=()=>{if(!E)return;const se=Z?$t(e.content):te;E(e.id,se)},he=()=>P==null?void 0:P(t),de=()=>{const Se=A(k?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",j);switch(I){case"user":return i.jsx(q.User,{className:Se});case"assistant":return i.jsx(q.Bot,{className:Se});case"tool":return i.jsx(q.Wrench,{className:Se});default:return i.jsx(q.Bot,{className:Se})}},be=()=>{const se="group relative mb-4 flex w-full";switch(I){case"user":return A(se,"justify-end");case"assistant":case"tool":case"system":return A(se,"justify-start");default:return se}},ge=()=>{const se=A("rounded-lg px-4 py-3 relative transition-all duration-200 min-w-0 max-w-full break-words",k&&"px-3 py-2 text-sm");switch(I){case"user":return A(se,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return A(se,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return A(se,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return A(se,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return se}},G=se=>{if(!se)return"";try{return new Date(se).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}},X=()=>{if(e.model==="reflection"){const fe=te.trim(),ve=ho(fe);if(ve&&typeof ve=="object")return i.jsx(fp,{data:ve})}if(Z&&D.name==="get_issues"){const fe=e.content.find(Fe=>Fe.type==="tool_result"),ve=(fe==null?void 0:fe.output)??$t(e.content),_e=Da(ve);if(_e)return i.jsx(pp,{issues:_e})}if(Z&&!O){const fe=$t(e.content).slice(0,80).replace(/\s+/g," ");return i.jsx("div",{className:A("text-xs font-mono opacity-70 flex items-center justify-between gap-2 text-current",k&&"text-[10px]"),children:i.jsxs("span",{className:"truncate max-w-full text-current",children:[fe,fe.length>=80?"…":""]})})}if(Z&&f){const fe=$t(e.content),ve=fe.length>u;return i.jsx(_a,{open:J,onOpenChange:H,children:i.jsxs("div",{className:"font-mono text-sm text-current",children:[i.jsx("pre",{className:A("whitespace-pre-wrap break-words text-current",k&&"text-xs"),children:ve&&!J?fe.substring(0,u)+"...":fe}),ve&&i.jsx(Pa,{asChild:!0,children:i.jsx(we,{variant:"ghost",size:"sm",className:"h-6 text-xs text-current",children:J?i.jsxs(i.Fragment,{children:[i.jsx(q.ChevronUp,{className:"h-3 w-3 mr-1"}),"Show less"]}):i.jsxs(i.Fragment,{children:[i.jsx(q.ChevronDown,{className:"h-3 w-3 mr-1"}),"Show more (",fe.length-u," chars)"]})})})]})})}if(Z&&O&&!f){const fe=ip(e.content);if(fe&&rp(fe))return i.jsx(sn,{content:fe.trim()});const ve=$t(e.content);return i.jsx("div",{className:"font-mono text-sm text-current",children:i.jsx("pre",{className:A("whitespace-pre-wrap break-words text-current",k&&"text-xs"),children:ve})})}const se=W.length>0&&I!=="tool",Se=xe.length>0&&I!=="tool";return i.jsxs("div",{children:[n?i.jsxs("div",{className:"relative",children:[(()=>{const fe=ho(ie);return fe!==null?i.jsx(Ma,{data:fe}):i.jsx(sn,{content:sp(op(ie))})})(),i.jsx(tp,{className:A(j,k?"text-xs":"text-sm")})]}):(()=>{const fe=ho(te.trim());if(fe!==null)return i.jsx(Ma,{data:fe});if(I==="user"&&p){const ve=te.trim();if(ve.length>m)return i.jsxs(_a,{open:L,onOpenChange:z,children:[i.jsx("div",{className:A("text-sm text-[hsl(var(--chat-bubble-user-text))]",k&&"text-xs"),children:L?i.jsx(sn,{content:ve}):i.jsxs("pre",{className:A("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",k&&"text-xs"),children:[ve.substring(0,m),"..."]})}),i.jsx(Pa,{asChild:!0,children:i.jsx(we,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:L?i.jsxs(i.Fragment,{children:[i.jsx(q.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):i.jsxs(i.Fragment,{children:[i.jsx(q.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",ve.length-m," chars)"]})})})]})}return i.jsx(sn,{content:te.trim()})})(),se&&i.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:W.map((fe,ve)=>i.jsxs("div",{className:"relative border rounded overflow-hidden",children:[i.jsx("img",{src:fe.url,alt:fe.alt??"image",className:"w-full h-auto"}),i.jsxs("div",{className:"absolute top-1 right-1 bg-background/70 rounded px-1 py-0.5 text-[10px] flex items-center gap-1",children:[i.jsx(q.Image,{className:"h-3 w-3"}),i.jsx("span",{children:"image"})]})]},ve))}),Se&&i.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:xe.map((fe,ve)=>{const _e=fe,Fe=_e.name||"file";return i.jsxs("a",{href:_e.url,download:Fe,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-2 bg-gray-100 border border-gray-200 rounded px-2 py-1 text-xs hover:bg-gray-200",title:Fe,children:[i.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-gray-400"}),i.jsx("span",{className:"truncate max-w-[180px]",children:Fe})]},ve)})})]})},ye=N.useMemo(()=>lp(e),[e]);return N.useMemo(()=>dp(e,h),[e,h]),i.jsx("div",{className:A(be(),v.container),children:i.jsxs("div",{className:A(ge(),v.content),children:[(a||c||Z)&&i.jsxs("div",{className:A("flex items-center justify-between mb-2 pb-2 border-b border-current/10",k&&"mb-1 pb-1",j,v.header),children:[i.jsxs("div",{className:"flex items-center gap-2",children:[de(),c&&ye&&i.jsx("span",{className:A("font-medium",k?"text-xs":"text-sm"),children:ye}),Z&&D.name&&i.jsxs(Ea,{variant:"outline",className:A("text-xs flex items-center gap-1 cursor-pointer",j,"border border-current/40",k&&"text-xs h-4"),onClick:()=>ne(se=>!se),children:[i.jsx("span",{children:D.name}),i.jsx("span",{className:"inline-flex items-center",children:O?i.jsx(q.ChevronUp,{className:"h-3 w-3"}):i.jsx(q.ChevronDown,{className:"h-3 w-3"})})]}),Z&&!D.name&&i.jsx(we,{variant:"ghost",size:"sm",className:A("h-6 px-1",j,"hover:bg-foreground/10"),onClick:()=>ne(se=>!se),children:i.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",O?i.jsx(q.ChevronUp,{className:"h-3 w-3"}):i.jsx(q.ChevronDown,{className:"h-3 w-3"})]})})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[a&&i.jsx("span",{className:A("text-xs opacity-60",j,k&&"text-xs"),children:G(e.createdAt)}),s&&!o&&i.jsxs("div",{className:A("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[i.jsx(we,{variant:"ghost",size:"sm",onClick:R,className:A("h-6 w-6 p-0 hover:bg-foreground/10",j,k&&"h-5 w-5"),children:i.jsx(q.Copy,{className:A(B?"text-success":j,k?"h-3 w-3":"h-4 w-4")})}),I==="user"&&E&&i.jsx(we,{variant:"ghost",size:"sm",onClick:le,className:A("h-6 w-6 p-0 hover:bg-foreground/10",j,k&&"h-5 w-5"),children:i.jsx(q.Edit,{className:A(j,k?"h-3 w-3":"h-4 w-4")})}),I==="assistant"&&P&&i.jsx(we,{variant:"ghost",size:"sm",onClick:he,className:A("h-6 w-6 p-0 hover:bg-foreground/10",j,k&&"h-5 w-5"),children:i.jsx(q.RotateCcw,{className:A(j,k?"h-3 w-3":"h-4 w-4")})})]})]})]}),i.jsx("div",{className:"relative",children:X()}),Z&&O&&(D.toolCallId||D.name)&&i.jsxs("div",{className:A("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",k&&"text-xs"),children:[D.name&&i.jsxs("div",{children:["Function: ",D.name]}),D.toolCallId&&i.jsxs("div",{children:["Call ID: ",D.toolCallId]})]}),s&&I==="user"&&y&&y.totalBranches>1&&i.jsxs("div",{className:"flex items-center gap-2 mt-2 p-2 bg-muted/30 rounded border",children:[i.jsx(q.GitBranch,{className:"h-3 w-3 text-muted-foreground"}),i.jsxs("span",{className:"text-xs text-muted-foreground",children:["Branch ",y.currentIndex+1," of ",y.totalBranches,y.currentLabel?` • ${y.currentLabel}`:""]}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx(we,{variant:"ghost",size:"sm",className:A("h-6 w-6 p-0",j),disabled:!y.canGoBack,onClick:()=>x==null?void 0:x(),title:"Go back to previous branch",children:i.jsx(q.ChevronLeft,{className:A("h-3 w-3",j)})}),i.jsx(we,{variant:"ghost",size:"sm",className:A("h-6 w-6 p-0",j),disabled:!y.canGoForward,onClick:()=>C==null?void 0:C(),title:"Go forward to next branch",children:i.jsx(q.ChevronRight,{className:A("h-3 w-3",j)})})]})]}),!(a||c||Z)&&s&&!o&&i.jsxs("div",{className:A("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[i.jsx(we,{variant:"ghost",size:"sm",onClick:R,className:A("h-6 w-6 p-0 hover:bg-background/50 text-current",k&&"h-5 w-5"),children:i.jsx(q.Copy,{className:A(B?"text-success":"text-current",k?"h-3 w-3":"h-4 w-4")})}),I==="user"&&E&&i.jsx(we,{variant:"ghost",size:"sm",onClick:le,className:A("h-6 w-6 p-0 hover:bg-background/50 text-current",k&&"h-5 w-5"),children:i.jsx(q.Edit,{className:A("text-current",k?"h-3 w-3":"h-4 w-4")})}),I==="assistant"&&P&&i.jsx(we,{variant:"ghost",size:"sm",onClick:he,className:A("h-6 w-6 p-0 hover:bg-background/50 text-current",k&&"h-5 w-5"),children:i.jsx(q.RotateCcw,{className:A("text-current",k?"h-3 w-3":"h-4 w-4")})})]})]})})}function np(e){const t=e.filter(n=>n.type==="text").map(n=>n.text).join("");return t||JSON.stringify(e)}function rp(e){return e.includes(`
10
+ `)||e.includes("```")||/[-*] /.test(e)||/#+\s/.test(e)}function op(e){let t=e;try{(t.match(/```/g)||[]).length%2===1&&(t+="\n```"),(t.replace(/```[\s\S]*?```/g,"").match(new RegExp("(?<!`)`(?!`)","g"))||[]).length%2===1&&(t+="`")}catch{}return t}function sp(e){let t=e;try{const n=[],r=[],o="\0F",s="\0I";let a=t.replace(/```[\s\S]*?```/g,c=>(n.push(c),`${o}${n.length-1}\0`));a=a.replace(/`[^`]*`/g,c=>(r.push(c),`${s}${r.length-1}\0`)),a=a.replace(/\b([A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/\b([A-Za-z0-9_&\/-]+\s+[A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/([\.,;:!\?\-])\1+/g,"$1").replace(/([:;!\?\)])([A-Za-z])/g,"$1 $2").replace(/\s{3,}/g," "),a=a.replace(/\u0000F(\d+)\u0000/g,(c,d)=>n[Number(d)]??""),a=a.replace(/\u0000I(\d+)\u0000/g,(c,d)=>r[Number(d)]??""),t=a}catch{}return t}function ho(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function Ma({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?i.jsx("div",{className:zn,children:i.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>i.jsx("li",{children:String(n)},r))})}):i.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:an(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return i.jsxs("div",{className:zn,children:[typeof r=="boolean"&&i.jsxs("p",{children:[i.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&i.jsxs("div",{children:[i.jsx("p",{children:i.jsx("strong",{children:"Follow-up queries:"})}),i.jsx("ul",{className:"list-disc pl-5",children:n.map((s,a)=>i.jsx("li",{children:String(s)},a))})]}),t&&t.length>0&&i.jsxs("div",{children:[i.jsx("p",{children:i.jsx("strong",{children:"Facts:"})}),i.jsx("ul",{className:"list-disc pl-5",children:t.map((s,a)=>i.jsx("li",{children:String(s)},a))})]})]});const o=Object.entries(e);return i.jsx("div",{className:zn,children:i.jsx("dl",{className:"mt-0",children:o.map(([s,a])=>i.jsxs("div",{className:"mb-1",children:[i.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),i.jsx("dd",{className:"inline",children:ap(a)})]},s))})})}return i.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:an(e)})}function ap(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return i.jsx("code",{className:"text-xs",children:JSON.stringify(e)})}catch{return String(e)}}function $t(e){const t=e.filter(n=>n.type==="tool_result");if(t.length)try{return t.length===1?an(t[0].output):an(t.map(n=>({toolCallId:n.toolCallId,output:n.output})))}catch{}return an(e)}function ip(e){const t=e.find(r=>r.type==="tool_result");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function an(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function cp(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_result");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function lp(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function dp(e,t){return e.checkpointId||t||null}function up(e,t){const[n,r]=N.useState(e);return N.useEffect(()=>{if(!t){r(e);return}const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}function fp({data:e}){return i.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>i.jsxs("div",{className:"flex",children:[i.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),i.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>i.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Da(e){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){if(e.desirability||e.feasibility||e.viability||e.other)return{desirability:Array.isArray(e.desirability)?e.desirability:[],feasibility:Array.isArray(e.feasibility)?e.feasibility:[],viability:Array.isArray(e.viability)?e.viability:[],other:Array.isArray(e.other)?e.other:[]};if(e.output&&typeof e.output!="object")e=e.output;else if(e.output&&typeof e.output=="object")return Da(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(a=>{const c=r.toLowerCase().indexOf(a);return c===-1?Number.MAX_SAFE_INTEGER:c}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const a of Object.keys(n)){const d=new RegExp(a+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!d)continue;const f=d[1],u=/Issue\(([\s\S]*?)\)(?:,|$)/g;let p=null;for(;(p=u.exec(f))!==null;){const m=p[1],v=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(m),g=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(m),h=v?v[2].trim():"",b=g?g[2].trim():"";n[a].push({title:h,description:b})}}return Object.values(n).some(a=>a.length>0)?n:null}function pp({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return i.jsx("div",{className:zn,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:i.jsxs("div",{className:"mb-4",children:[i.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),i.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>i.jsxs("li",{children:[i.jsx("div",{className:"font-medium",children:o.title}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const Bt=1e4;function hp(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
11
11
  `).replace(/<p>(.*?)<\/p>/gi,`$1
12
12
 
13
13
  `).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,a)=>`${"#".repeat(parseInt(s))} ${a}
@@ -15,12 +15,12 @@
15
15
  `).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
16
16
  `).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
17
17
  `).replace(/<li>(.*?)<\/li>/gi,`- $1
18
- `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function hp(e,t=$t){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function gp(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),hp(t),pp(t)}function ho(e){const t=e+"CollectionProvider",[n,r]=Re(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=h=>{const{scope:b,children:w}=h,y=N.useRef(null),x=N.useRef(new Map).current;return i.jsx(o,{scope:b,itemMap:x,collectionRef:y,children:w})};a.displayName=t;const c=e+"CollectionSlot",d=Be.createSlot(c),f=N.forwardRef((h,b)=>{const{scope:w,children:y}=h,x=s(c,w),C=ue(b,x.collectionRef);return i.jsx(d,{ref:C,children:y})});f.displayName=c;const u=e+"CollectionItemSlot",p="data-radix-collection-item",m=Be.createSlot(u),v=N.forwardRef((h,b)=>{const{scope:w,children:y,...x}=h,C=N.useRef(null),E=ue(b,C),P=s(u,w);return N.useEffect(()=>(P.itemMap.set(C,{ref:C,...x}),()=>void P.itemMap.delete(C))),i.jsx(m,{[p]:"",ref:E,children:y})});v.displayName=u;function g(h){const b=s(e+"CollectionConsumer",h);return N.useCallback(()=>{const y=b.collectionRef.current;if(!y)return[];const x=Array.from(y.querySelectorAll(`[${p}]`));return Array.from(b.itemMap.values()).sort((P,T)=>x.indexOf(P.ref.current)-x.indexOf(T.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:a,Slot:f,ItemSlot:v},g,r]}var mp=l.createContext(void 0);function zn(e){const t=l.useContext(mp);return e||t||"ltr"}function Ae(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function bp(e,t=globalThis==null?void 0:globalThis.document){const n=Ae(e);l.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 vp="DismissableLayer",go="dismissableLayer.update",wp="dismissableLayer.pointerDownOutside",yp="dismissableLayer.focusOutside",Da,La=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),an=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:c,...d}=e,f=l.useContext(La),[u,p]=l.useState(null),m=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,v]=l.useState({}),g=ue(t,T=>p(T)),h=Array.from(f.layers),[b]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),w=h.indexOf(b),y=u?h.indexOf(u):-1,x=f.layersWithOutsidePointerEventsDisabled.size>0,C=y>=w,E=Cp(T=>{const F=T.target,M=[...f.branches].some(B=>B.contains(F));!C||M||(o==null||o(T),a==null||a(T),T.defaultPrevented||c==null||c())},m),P=Ep(T=>{const F=T.target;[...f.branches].some(B=>B.contains(F))||(s==null||s(T),a==null||a(T),T.defaultPrevented||c==null||c())},m);return bp(T=>{y===f.layers.size-1&&(r==null||r(T),!T.defaultPrevented&&c&&(T.preventDefault(),c()))},m),l.useEffect(()=>{if(u)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Da=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(u)),f.layers.add(u),Fa(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Da)}},[u,m,n,f]),l.useEffect(()=>()=>{u&&(f.layers.delete(u),f.layersWithOutsidePointerEventsDisabled.delete(u),Fa())},[u,f]),l.useEffect(()=>{const T=()=>v({});return document.addEventListener(go,T),()=>document.removeEventListener(go,T)},[]),i.jsx(oe.div,{...d,ref:g,style:{pointerEvents:x?C?"auto":"none":void 0,...e.style},onFocusCapture:U(e.onFocusCapture,P.onFocusCapture),onBlurCapture:U(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:U(e.onPointerDownCapture,E.onPointerDownCapture)})});an.displayName=vp;var xp="DismissableLayerBranch",Sp=l.forwardRef((e,t)=>{const n=l.useContext(La),r=l.useRef(null),o=ue(t,r);return l.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),i.jsx(oe.div,{...e,ref:o})});Sp.displayName=xp;function Cp(e,t=globalThis==null?void 0:globalThis.document){const n=Ae(e),r=l.useRef(!1),o=l.useRef(()=>{});return l.useEffect(()=>{const s=c=>{if(c.target&&!r.current){let d=function(){$a(wp,n,f,{discrete:!0})};const f={originalEvent:c};c.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Ep(e,t=globalThis==null?void 0:globalThis.document){const n=Ae(e),r=l.useRef(!1);return l.useEffect(()=>{const o=s=>{s.target&&!r.current&&$a(yp,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 Fa(){const e=new CustomEvent(go);document.dispatchEvent(e)}function $a(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?Na(o,s):o.dispatchEvent(s)}var mo=0;function bo(){l.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ba()),document.body.insertAdjacentElement("beforeend",e[1]??Ba()),mo++,()=>{mo===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),mo--}},[])}function Ba(){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 vo="focusScope.autoFocusOnMount",wo="focusScope.autoFocusOnUnmount",Ua={bubbles:!1,cancelable:!0},Np="FocusScope",Wn=l.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=e,[c,d]=l.useState(null),f=Ae(o),u=Ae(s),p=l.useRef(null),m=ue(t,h=>d(h)),v=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(r){let h=function(x){if(v.paused||!c)return;const C=x.target;c.contains(C)?p.current=C:mt(p.current,{select:!0})},b=function(x){if(v.paused||!c)return;const C=x.relatedTarget;C!==null&&(c.contains(C)||mt(p.current,{select:!0}))},w=function(x){if(document.activeElement===document.body)for(const E of x)E.removedNodes.length>0&&mt(c)};document.addEventListener("focusin",h),document.addEventListener("focusout",b);const y=new MutationObserver(w);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",b),y.disconnect()}}},[r,c,v.paused]),l.useEffect(()=>{if(c){Wa.add(v);const h=document.activeElement;if(!c.contains(h)){const w=new CustomEvent(vo,Ua);c.addEventListener(vo,f),c.dispatchEvent(w),w.defaultPrevented||(Tp(Pp(Ha(c)),{select:!0}),document.activeElement===h&&mt(c))}return()=>{c.removeEventListener(vo,f),setTimeout(()=>{const w=new CustomEvent(wo,Ua);c.addEventListener(wo,u),c.dispatchEvent(w),w.defaultPrevented||mt(h??document.body,{select:!0}),c.removeEventListener(wo,u),Wa.remove(v)},0)}}},[c,f,u,v]);const g=l.useCallback(h=>{if(!n&&!r||v.paused)return;const b=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,w=document.activeElement;if(b&&w){const y=h.currentTarget,[x,C]=Ap(y);x&&C?!h.shiftKey&&w===C?(h.preventDefault(),n&&mt(x,{select:!0})):h.shiftKey&&w===x&&(h.preventDefault(),n&&mt(C,{select:!0})):w===y&&h.preventDefault()}},[n,r,v.paused]);return i.jsx(oe.div,{tabIndex:-1,...a,ref:m,onKeyDown:g})});Wn.displayName=Np;function Tp(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(mt(r,{select:t}),document.activeElement!==n)return}function Ap(e){const t=Ha(e),n=za(t,e),r=za(t.reverse(),e);return[n,r]}function Ha(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 za(e,t){for(const n of e)if(!Ip(n,{upTo:t}))return n}function Ip(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 kp(e){return e instanceof HTMLInputElement&&"select"in e}function mt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&kp(e)&&t&&e.select()}}var Wa=_p();function _p(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ja(e,t),e.unshift(t)},remove(t){var n;e=ja(e,t),(n=e[0])==null||n.resume()}}}function ja(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Pp(e){return e.filter(t=>t.tagName!=="A")}const Op=["top","right","bottom","left"],bt=Math.min,Ue=Math.max,jn=Math.round,Vn=Math.floor,ot=e=>({x:e,y:e}),Mp={left:"right",right:"left",bottom:"top",top:"bottom"},Dp={start:"end",end:"start"};function yo(e,t,n){return Ue(e,bt(t,n))}function ut(e,t){return typeof e=="function"?e(t):e}function ft(e){return e.split("-")[0]}function Bt(e){return e.split("-")[1]}function xo(e){return e==="x"?"y":"x"}function So(e){return e==="y"?"height":"width"}const Lp=new Set(["top","bottom"]);function st(e){return Lp.has(ft(e))?"y":"x"}function Co(e){return xo(st(e))}function Fp(e,t,n){n===void 0&&(n=!1);const r=Bt(e),o=Co(e),s=So(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Rn(a)),[a,Rn(a)]}function $p(e){const t=Rn(e);return[Eo(e),t,Eo(t)]}function Eo(e){return e.replace(/start|end/g,t=>Dp[t])}const Va=["left","right"],Ra=["right","left"],Bp=["top","bottom"],Up=["bottom","top"];function Hp(e,t,n){switch(e){case"top":case"bottom":return n?t?Ra:Va:t?Va:Ra;case"left":case"right":return t?Bp:Up;default:return[]}}function zp(e,t,n,r){const o=Bt(e);let s=Hp(ft(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(Eo)))),s}function Rn(e){return e.replace(/left|right|bottom|top/g,t=>Mp[t])}function Wp(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ka(e){return typeof e!="number"?Wp(e):{top:e,right:e,bottom:e,left:e}}function Kn(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Ga(e,t,n){let{reference:r,floating:o}=e;const s=st(t),a=Co(t),c=So(a),d=ft(t),f=s==="y",u=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[c]/2-o[c]/2;let v;switch(d){case"top":v={x:u,y:r.y-o.height};break;case"bottom":v={x:u,y:r.y+r.height};break;case"right":v={x:r.x+r.width,y:p};break;case"left":v={x:r.x-o.width,y:p};break;default:v={x:r.x,y:r.y}}switch(Bt(t)){case"start":v[a]-=m*(n&&f?-1:1);break;case"end":v[a]+=m*(n&&f?-1:1);break}return v}const jp=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:a}=n,c=s.filter(Boolean),d=await(a.isRTL==null?void 0:a.isRTL(t));let f=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:p}=Ga(f,r,d),m=r,v={},g=0;for(let h=0;h<c.length;h++){const{name:b,fn:w}=c[h],{x:y,y:x,data:C,reset:E}=await w({x:u,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:v,rects:f,platform:a,elements:{reference:e,floating:t}});u=y??u,p=x??p,v={...v,[b]:{...v[b],...C}},E&&g<=50&&(g++,typeof E=="object"&&(E.placement&&(m=E.placement),E.rects&&(f=E.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):E.rects),{x:u,y:p}=Ga(f,m,d)),h=-1)}return{x:u,y:p,placement:m,strategy:o,middlewareData:v}};async function cn(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:a,elements:c,strategy:d}=e,{boundary:f="clippingAncestors",rootBoundary:u="viewport",elementContext:p="floating",altBoundary:m=!1,padding:v=0}=ut(t,e),g=Ka(v),b=c[m?p==="floating"?"reference":"floating":p],w=Kn(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:f,rootBoundary:u,strategy:d})),y=p==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),C=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},E=Kn(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:y,offsetParent:x,strategy:d}):y);return{top:(w.top-E.top+g.top)/C.y,bottom:(E.bottom-w.bottom+g.bottom)/C.y,left:(w.left-E.left+g.left)/C.x,right:(E.right-w.right+g.right)/C.x}}const Vp=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:a,elements:c,middlewareData:d}=t,{element:f,padding:u=0}=ut(e,t)||{};if(f==null)return{};const p=Ka(u),m={x:n,y:r},v=Co(o),g=So(v),h=await a.getDimensions(f),b=v==="y",w=b?"top":"left",y=b?"bottom":"right",x=b?"clientHeight":"clientWidth",C=s.reference[g]+s.reference[v]-m[v]-s.floating[g],E=m[v]-s.reference[v],P=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f));let T=P?P[x]:0;(!T||!await(a.isElement==null?void 0:a.isElement(P)))&&(T=c.floating[x]||s.floating[g]);const F=C/2-E/2,M=T/2-h[g]/2-1,B=bt(p[w],M),j=bt(p[y],M),Q=B,H=T-h[g]-j,O=T/2-h[g]/2+F,ne=yo(Q,O,H),L=!d.arrow&&Bt(o)!=null&&O!==ne&&s.reference[g]/2-(O<Q?B:j)-h[g]/2<0,z=L?O<Q?O-Q:O-H:0;return{[v]:m[v]+z,data:{[v]:ne,centerOffset:O-ne-z,...L&&{alignmentOffset:z}},reset:L}}}),Rp=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:a,initialPlacement:c,platform:d,elements:f}=t,{mainAxis:u=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...b}=ut(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=ft(o),y=st(c),x=ft(c)===c,C=await(d.isRTL==null?void 0:d.isRTL(f.floating)),E=m||(x||!h?[Rn(c)]:$p(c)),P=g!=="none";!m&&P&&E.push(...zp(c,h,g,C));const T=[c,...E],F=await cn(t,b),M=[];let B=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&M.push(F[w]),p){const O=Fp(o,a,C);M.push(F[O[0]],F[O[1]])}if(B=[...B,{placement:o,overflows:M}],!M.every(O=>O<=0)){var j,Q;const O=(((j=s.flip)==null?void 0:j.index)||0)+1,ne=T[O];if(ne&&(!(p==="alignment"?y!==st(ne):!1)||B.every(k=>st(k.placement)===y?k.overflows[0]>0:!0)))return{data:{index:O,overflows:B},reset:{placement:ne}};let L=(Q=B.filter(z=>z.overflows[0]<=0).sort((z,k)=>z.overflows[1]-k.overflows[1])[0])==null?void 0:Q.placement;if(!L)switch(v){case"bestFit":{var H;const z=(H=B.filter(k=>{if(P){const I=st(k.placement);return I===y||I==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(I=>I>0).reduce((I,ee)=>I+ee,0)]).sort((k,I)=>k[1]-I[1])[0])==null?void 0:H[0];z&&(L=z);break}case"initialPlacement":L=c;break}if(o!==L)return{reset:{placement:L}}}return{}}}};function qa(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Xa(e){return Op.some(t=>e[t]>=0)}const Kp=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=ut(e,t);switch(r){case"referenceHidden":{const s=await cn(t,{...o,elementContext:"reference"}),a=qa(s,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Xa(a)}}}case"escaped":{const s=await cn(t,{...o,altBoundary:!0}),a=qa(s,n.floating);return{data:{escapedOffsets:a,escaped:Xa(a)}}}default:return{}}}}},Ya=new Set(["left","top"]);async function Gp(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=ft(n),c=Bt(n),d=st(n)==="y",f=Ya.has(a)?-1:1,u=s&&d?-1:1,p=ut(t,e);let{mainAxis:m,crossAxis:v,alignmentAxis:g}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return c&&typeof g=="number"&&(v=c==="end"?g*-1:g),d?{x:v*u,y:m*f}:{x:m*f,y:v*u}}const qp=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:a,middlewareData:c}=t,d=await Gp(t,e);return a===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:o+d.x,y:s+d.y,data:{...d,placement:a}}}}},Xp=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:a=!1,limiter:c={fn:b=>{let{x:w,y}=b;return{x:w,y}}},...d}=ut(e,t),f={x:n,y:r},u=await cn(t,d),p=st(ft(o)),m=xo(p);let v=f[m],g=f[p];if(s){const b=m==="y"?"top":"left",w=m==="y"?"bottom":"right",y=v+u[b],x=v-u[w];v=yo(y,v,x)}if(a){const b=p==="y"?"top":"left",w=p==="y"?"bottom":"right",y=g+u[b],x=g-u[w];g=yo(y,g,x)}const h=c.fn({...t,[m]:v,[p]:g});return{...h,data:{x:h.x-n,y:h.y-r,enabled:{[m]:s,[p]:a}}}}}},Yp=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:a}=t,{offset:c=0,mainAxis:d=!0,crossAxis:f=!0}=ut(e,t),u={x:n,y:r},p=st(o),m=xo(p);let v=u[m],g=u[p];const h=ut(c,t),b=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(d){const x=m==="y"?"height":"width",C=s.reference[m]-s.floating[x]+b.mainAxis,E=s.reference[m]+s.reference[x]-b.mainAxis;v<C?v=C:v>E&&(v=E)}if(f){var w,y;const x=m==="y"?"width":"height",C=Ya.has(ft(o)),E=s.reference[p]-s.floating[x]+(C&&((w=a.offset)==null?void 0:w[p])||0)+(C?0:b.crossAxis),P=s.reference[p]+s.reference[x]+(C?0:((y=a.offset)==null?void 0:y[p])||0)-(C?b.crossAxis:0);g<E?g=E:g>P&&(g=P)}return{[m]:v,[p]:g}}}},Jp=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:a,elements:c}=t,{apply:d=()=>{},...f}=ut(e,t),u=await cn(t,f),p=ft(o),m=Bt(o),v=st(o)==="y",{width:g,height:h}=s.floating;let b,w;p==="top"||p==="bottom"?(b=p,w=m===(await(a.isRTL==null?void 0:a.isRTL(c.floating))?"start":"end")?"left":"right"):(w=p,b=m==="end"?"top":"bottom");const y=h-u.top-u.bottom,x=g-u.left-u.right,C=bt(h-u[b],y),E=bt(g-u[w],x),P=!t.middlewareData.shift;let T=C,F=E;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(F=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(T=y),P&&!m){const B=Ue(u.left,0),j=Ue(u.right,0),Q=Ue(u.top,0),H=Ue(u.bottom,0);v?F=g-2*(B!==0||j!==0?B+j:Ue(u.left,u.right)):T=h-2*(Q!==0||H!==0?Q+H:Ue(u.top,u.bottom))}await d({...t,availableWidth:F,availableHeight:T});const M=await a.getDimensions(c.floating);return g!==M.width||h!==M.height?{reset:{rects:!0}}:{}}}};function Gn(){return typeof window<"u"}function Ut(e){return Ja(e)?(e.nodeName||"").toLowerCase():"#document"}function He(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function at(e){var t;return(t=(Ja(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ja(e){return Gn()?e instanceof Node||e instanceof He(e).Node:!1}function Ge(e){return Gn()?e instanceof Element||e instanceof He(e).Element:!1}function it(e){return Gn()?e instanceof HTMLElement||e instanceof He(e).HTMLElement:!1}function Za(e){return!Gn()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof He(e).ShadowRoot}const Zp=new Set(["inline","contents"]);function ln(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=qe(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Zp.has(o)}const Qp=new Set(["table","td","th"]);function eh(e){return Qp.has(Ut(e))}const th=[":popover-open",":modal"];function qn(e){return th.some(t=>{try{return e.matches(t)}catch{return!1}})}const nh=["transform","translate","scale","rotate","perspective"],rh=["transform","translate","scale","rotate","perspective","filter"],oh=["paint","layout","strict","content"];function No(e){const t=To(),n=Ge(e)?qe(e):e;return nh.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||rh.some(r=>(n.willChange||"").includes(r))||oh.some(r=>(n.contain||"").includes(r))}function sh(e){let t=vt(e);for(;it(t)&&!Ht(t);){if(No(t))return t;if(qn(t))return null;t=vt(t)}return null}function To(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const ah=new Set(["html","body","#document"]);function Ht(e){return ah.has(Ut(e))}function qe(e){return He(e).getComputedStyle(e)}function Xn(e){return Ge(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function vt(e){if(Ut(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Za(e)&&e.host||at(e);return Za(t)?t.host:t}function Qa(e){const t=vt(e);return Ht(t)?e.ownerDocument?e.ownerDocument.body:e.body:it(t)&&ln(t)?t:Qa(t)}function dn(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Qa(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),a=He(o);if(s){const c=Ao(a);return t.concat(a,a.visualViewport||[],ln(o)?o:[],c&&n?dn(c):[])}return t.concat(o,dn(o,[],n))}function Ao(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ei(e){const t=qe(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=it(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,c=jn(n)!==s||jn(r)!==a;return c&&(n=s,r=a),{width:n,height:r,$:c}}function Io(e){return Ge(e)?e:e.contextElement}function zt(e){const t=Io(e);if(!it(t))return ot(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=ei(t);let a=(s?jn(n.width):n.width)/r,c=(s?jn(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!c||!Number.isFinite(c))&&(c=1),{x:a,y:c}}const ih=ot(0);function ti(e){const t=He(e);return!To()||!t.visualViewport?ih:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ch(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==He(e)?!1:t}function Tt(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Io(e);let a=ot(1);t&&(r?Ge(r)&&(a=zt(r)):a=zt(e));const c=ch(s,n,r)?ti(s):ot(0);let d=(o.left+c.x)/a.x,f=(o.top+c.y)/a.y,u=o.width/a.x,p=o.height/a.y;if(s){const m=He(s),v=r&&Ge(r)?He(r):r;let g=m,h=Ao(g);for(;h&&r&&v!==g;){const b=zt(h),w=h.getBoundingClientRect(),y=qe(h),x=w.left+(h.clientLeft+parseFloat(y.paddingLeft))*b.x,C=w.top+(h.clientTop+parseFloat(y.paddingTop))*b.y;d*=b.x,f*=b.y,u*=b.x,p*=b.y,d+=x,f+=C,g=He(h),h=Ao(g)}}return Kn({width:u,height:p,x:d,y:f})}function Yn(e,t){const n=Xn(e).scrollLeft;return t?t.left+n:Tt(at(e)).left+n}function ni(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Yn(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function lh(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=at(r),c=t?qn(t.floating):!1;if(r===a||c&&s)return n;let d={scrollLeft:0,scrollTop:0},f=ot(1);const u=ot(0),p=it(r);if((p||!p&&!s)&&((Ut(r)!=="body"||ln(a))&&(d=Xn(r)),it(r))){const v=Tt(r);f=zt(r),u.x=v.x+r.clientLeft,u.y=v.y+r.clientTop}const m=a&&!p&&!s?ni(a,d):ot(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+u.x+m.x,y:n.y*f.y-d.scrollTop*f.y+u.y+m.y}}function dh(e){return Array.from(e.getClientRects())}function uh(e){const t=at(e),n=Xn(e),r=e.ownerDocument.body,o=Ue(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ue(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Yn(e);const c=-n.scrollTop;return qe(r).direction==="rtl"&&(a+=Ue(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:c}}const ri=25;function fh(e,t){const n=He(e),r=at(e),o=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,c=0,d=0;if(o){s=o.width,a=o.height;const u=To();(!u||u&&t==="fixed")&&(c=o.offsetLeft,d=o.offsetTop)}const f=Yn(r);if(f<=0){const u=r.ownerDocument,p=u.body,m=getComputedStyle(p),v=u.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(r.clientWidth-p.clientWidth-v);g<=ri&&(s-=g)}else f<=ri&&(s+=f);return{width:s,height:a,x:c,y:d}}const ph=new Set(["absolute","fixed"]);function hh(e,t){const n=Tt(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=it(e)?zt(e):ot(1),a=e.clientWidth*s.x,c=e.clientHeight*s.y,d=o*s.x,f=r*s.y;return{width:a,height:c,x:d,y:f}}function oi(e,t,n){let r;if(t==="viewport")r=fh(e,n);else if(t==="document")r=uh(at(e));else if(Ge(t))r=hh(t,n);else{const o=ti(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Kn(r)}function si(e,t){const n=vt(e);return n===t||!Ge(n)||Ht(n)?!1:qe(n).position==="fixed"||si(n,t)}function gh(e,t){const n=t.get(e);if(n)return n;let r=dn(e,[],!1).filter(c=>Ge(c)&&Ut(c)!=="body"),o=null;const s=qe(e).position==="fixed";let a=s?vt(e):e;for(;Ge(a)&&!Ht(a);){const c=qe(a),d=No(a);!d&&c.position==="fixed"&&(o=null),(s?!d&&!o:!d&&c.position==="static"&&!!o&&ph.has(o.position)||ln(a)&&!d&&si(e,a))?r=r.filter(u=>u!==a):o=c,a=vt(a)}return t.set(e,r),r}function mh(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?qn(t)?[]:gh(t,this._c):[].concat(n),r],c=a[0],d=a.reduce((f,u)=>{const p=oi(t,u,o);return f.top=Ue(p.top,f.top),f.right=bt(p.right,f.right),f.bottom=bt(p.bottom,f.bottom),f.left=Ue(p.left,f.left),f},oi(t,c,o));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function bh(e){const{width:t,height:n}=ei(e);return{width:t,height:n}}function vh(e,t,n){const r=it(t),o=at(t),s=n==="fixed",a=Tt(e,!0,s,t);let c={scrollLeft:0,scrollTop:0};const d=ot(0);function f(){d.x=Yn(o)}if(r||!r&&!s)if((Ut(t)!=="body"||ln(o))&&(c=Xn(t)),r){const v=Tt(t,!0,s,t);d.x=v.x+t.clientLeft,d.y=v.y+t.clientTop}else o&&f();s&&!r&&o&&f();const u=o&&!r&&!s?ni(o,c):ot(0),p=a.left+c.scrollLeft-d.x-u.x,m=a.top+c.scrollTop-d.y-u.y;return{x:p,y:m,width:a.width,height:a.height}}function ko(e){return qe(e).position==="static"}function ai(e,t){if(!it(e)||qe(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return at(e)===n&&(n=n.ownerDocument.body),n}function ii(e,t){const n=He(e);if(qn(e))return n;if(!it(e)){let o=vt(e);for(;o&&!Ht(o);){if(Ge(o)&&!ko(o))return o;o=vt(o)}return n}let r=ai(e,t);for(;r&&eh(r)&&ko(r);)r=ai(r,t);return r&&Ht(r)&&ko(r)&&!No(r)?n:r||sh(e)||n}const wh=async function(e){const t=this.getOffsetParent||ii,n=this.getDimensions,r=await n(e.floating);return{reference:vh(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function yh(e){return qe(e).direction==="rtl"}const xh={convertOffsetParentRelativeRectToViewportRelativeRect:lh,getDocumentElement:at,getClippingRect:mh,getOffsetParent:ii,getElementRects:wh,getClientRects:dh,getDimensions:bh,getScale:zt,isElement:Ge,isRTL:yh};function ci(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Sh(e,t){let n=null,r;const o=at(e);function s(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function a(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),s();const f=e.getBoundingClientRect(),{left:u,top:p,width:m,height:v}=f;if(c||t(),!m||!v)return;const g=Vn(p),h=Vn(o.clientWidth-(u+m)),b=Vn(o.clientHeight-(p+v)),w=Vn(u),x={rootMargin:-g+"px "+-h+"px "+-b+"px "+-w+"px",threshold:Ue(0,bt(1,d))||1};let C=!0;function E(P){const T=P[0].intersectionRatio;if(T!==d){if(!C)return a();T?a(!1,T):r=setTimeout(()=>{a(!1,1e-7)},1e3)}T===1&&!ci(f,e.getBoundingClientRect())&&a(),C=!1}try{n=new IntersectionObserver(E,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(E,x)}n.observe(e)}return a(!0),s}function Ch(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,f=Io(e),u=o||s?[...f?dn(f):[],...dn(t)]:[];u.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const p=f&&c?Sh(f,n):null;let m=-1,v=null;a&&(v=new ResizeObserver(w=>{let[y]=w;y&&y.target===f&&v&&(v.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var x;(x=v)==null||x.observe(t)})),n()}),f&&!d&&v.observe(f),v.observe(t));let g,h=d?Tt(e):null;d&&b();function b(){const w=Tt(e);h&&!ci(h,w)&&n(),h=w,g=requestAnimationFrame(b)}return n(),()=>{var w;u.forEach(y=>{o&&y.removeEventListener("scroll",n),s&&y.removeEventListener("resize",n)}),p==null||p(),(w=v)==null||w.disconnect(),v=null,d&&cancelAnimationFrame(g)}}const Eh=qp,Nh=Xp,Th=Rp,Ah=Jp,Ih=Kp,li=Vp,kh=Yp,_h=(e,t,n)=>{const r=new Map,o={platform:xh,...n},s={...o.platform,_c:r};return jp(e,t,{...o,platform:s})};var Ph=typeof document<"u",Oh=function(){},Jn=Ph?N.useLayoutEffect:Oh;function Zn(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Zn(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Zn(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function di(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ui(e,t){const n=di(e);return Math.round(t*n)/n}function _o(e){const t=l.useRef(e);return Jn(()=>{t.current=e}),t}function Mh(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:a}={},transform:c=!0,whileElementsMounted:d,open:f}=e,[u,p]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,v]=l.useState(r);Zn(m,r)||v(r);const[g,h]=l.useState(null),[b,w]=l.useState(null),y=l.useCallback(k=>{k!==P.current&&(P.current=k,h(k))},[]),x=l.useCallback(k=>{k!==T.current&&(T.current=k,w(k))},[]),C=s||g,E=a||b,P=l.useRef(null),T=l.useRef(null),F=l.useRef(u),M=d!=null,B=_o(d),j=_o(o),Q=_o(f),H=l.useCallback(()=>{if(!P.current||!T.current)return;const k={placement:t,strategy:n,middleware:m};j.current&&(k.platform=j.current),_h(P.current,T.current,k).then(I=>{const ee={...I,isPositioned:Q.current!==!1};O.current&&!Zn(F.current,ee)&&(F.current=ee,Nn.flushSync(()=>{p(ee)}))})},[m,t,n,j,Q]);Jn(()=>{f===!1&&F.current.isPositioned&&(F.current.isPositioned=!1,p(k=>({...k,isPositioned:!1})))},[f]);const O=l.useRef(!1);Jn(()=>(O.current=!0,()=>{O.current=!1}),[]),Jn(()=>{if(C&&(P.current=C),E&&(T.current=E),C&&E){if(B.current)return B.current(C,E,H);H()}},[C,E,H,B,M]);const ne=l.useMemo(()=>({reference:P,floating:T,setReference:y,setFloating:x}),[y,x]),L=l.useMemo(()=>({reference:C,floating:E}),[C,E]),z=l.useMemo(()=>{const k={position:n,left:0,top:0};if(!L.floating)return k;const I=ui(L.floating,u.x),ee=ui(L.floating,u.y);return c?{...k,transform:"translate("+I+"px, "+ee+"px)",...di(L.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:ee}},[n,c,L.floating,u.x,u.y]);return l.useMemo(()=>({...u,update:H,refs:ne,elements:L,floatingStyles:z}),[u,H,ne,L,z])}const Dh=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?li({element:r.current,padding:o}).fn(n):{}:r?li({element:r,padding:o}).fn(n):{}}}},Lh=(e,t)=>({...Eh(e),options:[e,t]}),Fh=(e,t)=>({...Nh(e),options:[e,t]}),$h=(e,t)=>({...kh(e),options:[e,t]}),Bh=(e,t)=>({...Th(e),options:[e,t]}),Uh=(e,t)=>({...Ah(e),options:[e,t]}),Hh=(e,t)=>({...Ih(e),options:[e,t]}),zh=(e,t)=>({...Dh(e),options:[e,t]});var Wh="Arrow",fi=l.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return i.jsx(oe.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:i.jsx("polygon",{points:"0,0 30,0 15,10"})})});fi.displayName=Wh;var jh=fi;function pi(e){const[t,n]=l.useState(void 0);return Ne(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let a,c;if("borderBoxSize"in s){const d=s.borderBoxSize,f=Array.isArray(d)?d[0]:d;a=f.inlineSize,c=f.blockSize}else a=e.offsetWidth,c=e.offsetHeight;n({width:a,height:c})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Po="Popper",[hi,Wt]=Re(Po),[Vh,gi]=hi(Po),mi=e=>{const{__scopePopper:t,children:n}=e,[r,o]=l.useState(null);return i.jsx(Vh,{scope:t,anchor:r,onAnchorChange:o,children:n})};mi.displayName=Po;var bi="PopperAnchor",vi=l.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=gi(bi,n),a=l.useRef(null),c=ue(t,a),d=l.useRef(null);return l.useEffect(()=>{const f=d.current;d.current=(r==null?void 0:r.current)||a.current,f!==d.current&&s.onAnchorChange(d.current)}),r?null:i.jsx(oe.div,{...o,ref:c})});vi.displayName=bi;var Oo="PopperContent",[Rh,Kh]=hi(Oo),wi=l.forwardRef((e,t)=>{var R,le,he,de,be,ge;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:u=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:v="optimized",onPlaced:g,...h}=e,b=gi(Oo,n),[w,y]=l.useState(null),x=ue(t,G=>y(G)),[C,E]=l.useState(null),P=pi(C),T=(P==null?void 0:P.width)??0,F=(P==null?void 0:P.height)??0,M=r+(s!=="center"?"-"+s:""),B=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},j=Array.isArray(f)?f:[f],Q=j.length>0,H={padding:B,boundary:j.filter(qh),altBoundary:Q},{refs:O,floatingStyles:ne,placement:L,isPositioned:z,middlewareData:k}=Mh({strategy:"fixed",placement:M,whileElementsMounted:(...G)=>Ch(...G,{animationFrame:v==="always"}),elements:{reference:b.anchor},middleware:[Lh({mainAxis:o+F,alignmentAxis:a}),d&&Fh({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?$h():void 0,...H}),d&&Bh({...H}),Uh({...H,apply:({elements:G,rects:Y,availableWidth:ye,availableHeight:se})=>{const{width:Se,height:fe}=Y.reference,ve=G.floating.style;ve.setProperty("--radix-popper-available-width",`${ye}px`),ve.setProperty("--radix-popper-available-height",`${se}px`),ve.setProperty("--radix-popper-anchor-width",`${Se}px`),ve.setProperty("--radix-popper-anchor-height",`${fe}px`)}}),C&&zh({element:C,padding:c}),Xh({arrowWidth:T,arrowHeight:F}),m&&Hh({strategy:"referenceHidden",...H})]}),[I,ee]=Si(L),V=Ae(g);Ne(()=>{z&&(V==null||V())},[z,V]);const te=(R=k.arrow)==null?void 0:R.x,D=(le=k.arrow)==null?void 0:le.y,W=((he=k.arrow)==null?void 0:he.centerOffset)!==0,[xe,ie]=l.useState();return Ne(()=>{w&&ie(window.getComputedStyle(w).zIndex)},[w]),i.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...ne,transform:z?ne.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:xe,"--radix-popper-transform-origin":[(de=k.transformOrigin)==null?void 0:de.x,(be=k.transformOrigin)==null?void 0:be.y].join(" "),...((ge=k.hide)==null?void 0:ge.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:i.jsx(Rh,{scope:n,placedSide:I,onArrowChange:E,arrowX:te,arrowY:D,shouldHideArrow:W,children:i.jsx(oe.div,{"data-side":I,"data-align":ee,...h,ref:x,style:{...h.style,animation:z?void 0:"none"}})})})});wi.displayName=Oo;var yi="PopperArrow",Gh={top:"bottom",right:"left",bottom:"top",left:"right"},xi=l.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Kh(yi,r),a=Gh[s.placedSide];return i.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:i.jsx(jh,{...o,ref:n,style:{...o.style,display:"block"}})})});xi.displayName=yi;function qh(e){return e!==null}var Xh=e=>({name:"transformOrigin",options:e,fn(t){var b,w,y;const{placement:n,rects:r,middlewareData:o}=t,a=((b=o.arrow)==null?void 0:b.centerOffset)!==0,c=a?0:e.arrowWidth,d=a?0:e.arrowHeight,[f,u]=Si(n),p={start:"0%",center:"50%",end:"100%"}[u],m=(((w=o.arrow)==null?void 0:w.x)??0)+c/2,v=(((y=o.arrow)==null?void 0:y.y)??0)+d/2;let g="",h="";return f==="bottom"?(g=a?p:`${m}px`,h=`${-d}px`):f==="top"?(g=a?p:`${m}px`,h=`${r.floating.height+d}px`):f==="right"?(g=`${-d}px`,h=a?p:`${v}px`):f==="left"&&(g=`${r.floating.width+d}px`,h=a?p:`${v}px`),{data:{x:g,y:h}}}});function Si(e){const[t,n="center"]=e.split("-");return[t,n]}var Mo=mi,Do=vi,Lo=wi,Fo=xi,Yh="Portal",Qn=l.forwardRef((e,t)=>{var c;const{container:n,...r}=e,[o,s]=l.useState(!1);Ne(()=>s(!0),[]);const a=n||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return a?Ts.createPortal(i.jsx(oe.div,{...r,ref:t}),a):null});Qn.displayName=Yh;var $o="rovingFocusGroup.onEntryFocus",Jh={bubbles:!1,cancelable:!0},un="RovingFocusGroup",[Bo,Ci,Zh]=ho(un),[Qh,Ei]=Re(un,[Zh]),[eg,tg]=Qh(un),Ni=l.forwardRef((e,t)=>i.jsx(Bo.Provider,{scope:e.__scopeRovingFocusGroup,children:i.jsx(Bo.Slot,{scope:e.__scopeRovingFocusGroup,children:i.jsx(ng,{...e,ref:t})})}));Ni.displayName=un;var ng=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:u=!1,...p}=e,m=l.useRef(null),v=ue(t,m),g=zn(s),[h,b]=gt({prop:a,defaultProp:c??null,onChange:d,caller:un}),[w,y]=l.useState(!1),x=Ae(f),C=Ci(n),E=l.useRef(!1),[P,T]=l.useState(0);return l.useEffect(()=>{const F=m.current;if(F)return F.addEventListener($o,x),()=>F.removeEventListener($o,x)},[x]),i.jsx(eg,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:h,onItemFocus:l.useCallback(F=>b(F),[b]),onItemShiftTab:l.useCallback(()=>y(!0),[]),onFocusableItemAdd:l.useCallback(()=>T(F=>F+1),[]),onFocusableItemRemove:l.useCallback(()=>T(F=>F-1),[]),children:i.jsx(oe.div,{tabIndex:w||P===0?-1:0,"data-orientation":r,...p,ref:v,style:{outline:"none",...e.style},onMouseDown:U(e.onMouseDown,()=>{E.current=!0}),onFocus:U(e.onFocus,F=>{const M=!E.current;if(F.target===F.currentTarget&&M&&!w){const B=new CustomEvent($o,Jh);if(F.currentTarget.dispatchEvent(B),!B.defaultPrevented){const j=C().filter(L=>L.focusable),Q=j.find(L=>L.active),H=j.find(L=>L.id===h),ne=[Q,H,...j].filter(Boolean).map(L=>L.ref.current);Ii(ne,u)}}E.current=!1}),onBlur:U(e.onBlur,()=>y(!1))})})}),Ti="RovingFocusGroupItem",Ai=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:a,...c}=e,d=Ke(),f=s||d,u=tg(Ti,n),p=u.currentTabStopId===f,m=Ci(n),{onFocusableItemAdd:v,onFocusableItemRemove:g,currentTabStopId:h}=u;return l.useEffect(()=>{if(r)return v(),()=>g()},[r,v,g]),i.jsx(Bo.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:i.jsx(oe.span,{tabIndex:p?0:-1,"data-orientation":u.orientation,...c,ref:t,onMouseDown:U(e.onMouseDown,b=>{r?u.onItemFocus(f):b.preventDefault()}),onFocus:U(e.onFocus,()=>u.onItemFocus(f)),onKeyDown:U(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){u.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const w=sg(b,u.orientation,u.dir);if(w!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let x=m().filter(C=>C.focusable).map(C=>C.ref.current);if(w==="last")x.reverse();else if(w==="prev"||w==="next"){w==="prev"&&x.reverse();const C=x.indexOf(b.currentTarget);x=u.loop?ag(x,C+1):x.slice(C+1)}setTimeout(()=>Ii(x))}}),children:typeof a=="function"?a({isCurrentTabStop:p,hasTabStop:h!=null}):a})})});Ai.displayName=Ti;var rg={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function og(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function sg(e,t,n){const r=og(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return rg[r]}function Ii(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function ag(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ig=Ni,cg=Ai,lg=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},jt=new WeakMap,er=new WeakMap,tr={},Uo=0,ki=function(e){return e&&(e.host||ki(e.parentNode))},dg=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=ki(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},ug=function(e,t,n,r){var o=dg(t,Array.isArray(e)?e:[e]);tr[n]||(tr[n]=new WeakMap);var s=tr[n],a=[],c=new Set,d=new Set(o),f=function(p){!p||c.has(p)||(c.add(p),f(p.parentNode))};o.forEach(f);var u=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(m){if(c.has(m))u(m);else try{var v=m.getAttribute(r),g=v!==null&&v!=="false",h=(jt.get(m)||0)+1,b=(s.get(m)||0)+1;jt.set(m,h),s.set(m,b),a.push(m),h===1&&g&&er.set(m,!0),b===1&&m.setAttribute(n,"true"),g||m.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",m,w)}})};return u(t),c.clear(),Uo++,function(){a.forEach(function(p){var m=jt.get(p)-1,v=s.get(p)-1;jt.set(p,m),s.set(p,v),m||(er.has(p)||p.removeAttribute(r),er.delete(p)),v||p.removeAttribute(n)}),Uo--,Uo||(jt=new WeakMap,jt=new WeakMap,er=new WeakMap,tr={})}},Ho=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=lg(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),ug(r,o,n,"aria-hidden")):function(){return null}},ct=function(){return ct=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},ct.apply(this,arguments)};function _i(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 fg(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))}typeof SuppressedError=="function"&&SuppressedError;var nr="right-scroll-bar-position",rr="width-before-scroll-bar",pg="with-scroll-bars-hidden",hg="--removed-body-scroll-bar-size";function zo(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function gg(e,t){var n=N.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 mg=typeof window<"u"?l.useLayoutEffect:l.useEffect,Pi=new WeakMap;function bg(e,t){var n=gg(null,function(r){return e.forEach(function(o){return zo(o,r)})});return mg(function(){var r=Pi.get(n);if(r){var o=new Set(r),s=new Set(e),a=n.current;o.forEach(function(c){s.has(c)||zo(c,null)}),s.forEach(function(c){o.has(c)||zo(c,a)})}Pi.set(n,e)},[e]),n}function vg(e){return e}function wg(e,t){t===void 0&&(t=vg);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 a=t(s,r);return n.push(a),function(){n=n.filter(function(c){return c!==a})}},assignSyncMedium:function(s){for(r=!0;n.length;){var a=n;n=[],a.forEach(s)}n={push:function(c){return s(c)},filter:function(){return n}}},assignMedium:function(s){r=!0;var a=[];if(n.length){var c=n;n=[],c.forEach(s),a=n}var d=function(){var u=a;a=[],u.forEach(s)},f=function(){return Promise.resolve().then(d)};f(),n={push:function(u){a.push(u),f()},filter:function(u){return a=a.filter(u),n}}}};return o}function yg(e){e===void 0&&(e={});var t=wg(null);return t.options=ct({async:!0,ssr:!1},e),t}var Oi=function(e){var t=e.sideCar,n=_i(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 l.createElement(r,ct({},n))};Oi.isSideCarExport=!0;function xg(e,t){return e.useMedium(t),Oi}var Mi=yg(),Wo=function(){},or=l.forwardRef(function(e,t){var n=l.useRef(null),r=l.useState({onScrollCapture:Wo,onWheelCapture:Wo,onTouchMoveCapture:Wo}),o=r[0],s=r[1],a=e.forwardProps,c=e.children,d=e.className,f=e.removeScrollBar,u=e.enabled,p=e.shards,m=e.sideCar,v=e.noRelative,g=e.noIsolation,h=e.inert,b=e.allowPinchZoom,w=e.as,y=w===void 0?"div":w,x=e.gapMode,C=_i(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),E=m,P=bg([n,t]),T=ct(ct({},C),o);return l.createElement(l.Fragment,null,u&&l.createElement(E,{sideCar:Mi,removeScrollBar:f,shards:p,noRelative:v,noIsolation:g,inert:h,setCallbacks:s,allowPinchZoom:!!b,lockRef:n,gapMode:x}),a?l.cloneElement(l.Children.only(c),ct(ct({},T),{ref:P})):l.createElement(y,ct({},T,{className:d,ref:P}),c))});or.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},or.classNames={fullWidth:rr,zeroRight:nr};var Sg=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Cg(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Sg();return t&&e.setAttribute("nonce",t),e}function Eg(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ng(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Tg=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Cg())&&(Eg(t,n),Ng(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ag=function(){var e=Tg();return function(t,n){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Di=function(){var e=Ag(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Ig={left:0,top:0,right:0,gap:0},jo=function(e){return parseInt(e||"",10)||0},kg=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[jo(n),jo(r),jo(o)]},_g=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ig;var t=kg(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])}},Pg=Di(),Vt="data-scroll-locked",Og=function(e,t,n,r){var o=e.left,s=e.top,a=e.right,c=e.gap;return n===void 0&&(n="margin"),`
19
- .`.concat(pg,` {
18
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function gp(e,t=Bt){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function mp(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),gp(t),hp(t)}function go(e){const t=e+"CollectionProvider",[n,r]=Ke(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=h=>{const{scope:b,children:w}=h,y=N.useRef(null),x=N.useRef(new Map).current;return i.jsx(o,{scope:b,itemMap:x,collectionRef:y,children:w})};a.displayName=t;const c=e+"CollectionSlot",d=Be.createSlot(c),f=N.forwardRef((h,b)=>{const{scope:w,children:y}=h,x=s(c,w),C=ue(b,x.collectionRef);return i.jsx(d,{ref:C,children:y})});f.displayName=c;const u=e+"CollectionItemSlot",p="data-radix-collection-item",m=Be.createSlot(u),v=N.forwardRef((h,b)=>{const{scope:w,children:y,...x}=h,C=N.useRef(null),E=ue(b,C),P=s(u,w);return N.useEffect(()=>(P.itemMap.set(C,{ref:C,...x}),()=>void P.itemMap.delete(C))),i.jsx(m,{[p]:"",ref:E,children:y})});v.displayName=u;function g(h){const b=s(e+"CollectionConsumer",h);return N.useCallback(()=>{const y=b.collectionRef.current;if(!y)return[];const x=Array.from(y.querySelectorAll(`[${p}]`));return Array.from(b.itemMap.values()).sort((P,T)=>x.indexOf(P.ref.current)-x.indexOf(T.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:a,Slot:f,ItemSlot:v},g,r]}var bp=l.createContext(void 0);function Wn(e){const t=l.useContext(bp);return e||t||"ltr"}function Ae(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function vp(e,t=globalThis==null?void 0:globalThis.document){const n=Ae(e);l.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 wp="DismissableLayer",mo="dismissableLayer.update",yp="dismissableLayer.pointerDownOutside",xp="dismissableLayer.focusOutside",La,Fa=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),cn=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:c,...d}=e,f=l.useContext(Fa),[u,p]=l.useState(null),m=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,v]=l.useState({}),g=ue(t,T=>p(T)),h=Array.from(f.layers),[b]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),w=h.indexOf(b),y=u?h.indexOf(u):-1,x=f.layersWithOutsidePointerEventsDisabled.size>0,C=y>=w,E=Ep(T=>{const F=T.target,M=[...f.branches].some(B=>B.contains(F));!C||M||(o==null||o(T),a==null||a(T),T.defaultPrevented||c==null||c())},m),P=Np(T=>{const F=T.target;[...f.branches].some(B=>B.contains(F))||(s==null||s(T),a==null||a(T),T.defaultPrevented||c==null||c())},m);return vp(T=>{y===f.layers.size-1&&(r==null||r(T),!T.defaultPrevented&&c&&(T.preventDefault(),c()))},m),l.useEffect(()=>{if(u)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(La=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(u)),f.layers.add(u),$a(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=La)}},[u,m,n,f]),l.useEffect(()=>()=>{u&&(f.layers.delete(u),f.layersWithOutsidePointerEventsDisabled.delete(u),$a())},[u,f]),l.useEffect(()=>{const T=()=>v({});return document.addEventListener(mo,T),()=>document.removeEventListener(mo,T)},[]),i.jsx(oe.div,{...d,ref:g,style:{pointerEvents:x?C?"auto":"none":void 0,...e.style},onFocusCapture:U(e.onFocusCapture,P.onFocusCapture),onBlurCapture:U(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:U(e.onPointerDownCapture,E.onPointerDownCapture)})});cn.displayName=wp;var Sp="DismissableLayerBranch",Cp=l.forwardRef((e,t)=>{const n=l.useContext(Fa),r=l.useRef(null),o=ue(t,r);return l.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),i.jsx(oe.div,{...e,ref:o})});Cp.displayName=Sp;function Ep(e,t=globalThis==null?void 0:globalThis.document){const n=Ae(e),r=l.useRef(!1),o=l.useRef(()=>{});return l.useEffect(()=>{const s=c=>{if(c.target&&!r.current){let d=function(){Ba(yp,n,f,{discrete:!0})};const f={originalEvent:c};c.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Np(e,t=globalThis==null?void 0:globalThis.document){const n=Ae(e),r=l.useRef(!1);return l.useEffect(()=>{const o=s=>{s.target&&!r.current&&Ba(xp,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 $a(){const e=new CustomEvent(mo);document.dispatchEvent(e)}function Ba(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?Ta(o,s):o.dispatchEvent(s)}var bo=0;function vo(){l.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ua()),document.body.insertAdjacentElement("beforeend",e[1]??Ua()),bo++,()=>{bo===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),bo--}},[])}function Ua(){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 wo="focusScope.autoFocusOnMount",yo="focusScope.autoFocusOnUnmount",Ha={bubbles:!1,cancelable:!0},Tp="FocusScope",Vn=l.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=e,[c,d]=l.useState(null),f=Ae(o),u=Ae(s),p=l.useRef(null),m=ue(t,h=>d(h)),v=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(r){let h=function(x){if(v.paused||!c)return;const C=x.target;c.contains(C)?p.current=C:bt(p.current,{select:!0})},b=function(x){if(v.paused||!c)return;const C=x.relatedTarget;C!==null&&(c.contains(C)||bt(p.current,{select:!0}))},w=function(x){if(document.activeElement===document.body)for(const E of x)E.removedNodes.length>0&&bt(c)};document.addEventListener("focusin",h),document.addEventListener("focusout",b);const y=new MutationObserver(w);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",b),y.disconnect()}}},[r,c,v.paused]),l.useEffect(()=>{if(c){Va.add(v);const h=document.activeElement;if(!c.contains(h)){const w=new CustomEvent(wo,Ha);c.addEventListener(wo,f),c.dispatchEvent(w),w.defaultPrevented||(Ap(Op(za(c)),{select:!0}),document.activeElement===h&&bt(c))}return()=>{c.removeEventListener(wo,f),setTimeout(()=>{const w=new CustomEvent(yo,Ha);c.addEventListener(yo,u),c.dispatchEvent(w),w.defaultPrevented||bt(h??document.body,{select:!0}),c.removeEventListener(yo,u),Va.remove(v)},0)}}},[c,f,u,v]);const g=l.useCallback(h=>{if(!n&&!r||v.paused)return;const b=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,w=document.activeElement;if(b&&w){const y=h.currentTarget,[x,C]=Ip(y);x&&C?!h.shiftKey&&w===C?(h.preventDefault(),n&&bt(x,{select:!0})):h.shiftKey&&w===x&&(h.preventDefault(),n&&bt(C,{select:!0})):w===y&&h.preventDefault()}},[n,r,v.paused]);return i.jsx(oe.div,{tabIndex:-1,...a,ref:m,onKeyDown:g})});Vn.displayName=Tp;function Ap(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(bt(r,{select:t}),document.activeElement!==n)return}function Ip(e){const t=za(e),n=Wa(t,e),r=Wa(t.reverse(),e);return[n,r]}function za(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 Wa(e,t){for(const n of e)if(!kp(n,{upTo:t}))return n}function kp(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 _p(e){return e instanceof HTMLInputElement&&"select"in e}function bt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&_p(e)&&t&&e.select()}}var Va=Pp();function Pp(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ja(e,t),e.unshift(t)},remove(t){var n;e=ja(e,t),(n=e[0])==null||n.resume()}}}function ja(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Op(e){return e.filter(t=>t.tagName!=="A")}const Mp=["top","right","bottom","left"],vt=Math.min,Ue=Math.max,jn=Math.round,Rn=Math.floor,st=e=>({x:e,y:e}),Dp={left:"right",right:"left",bottom:"top",top:"bottom"},Lp={start:"end",end:"start"};function xo(e,t,n){return Ue(e,vt(t,n))}function ft(e,t){return typeof e=="function"?e(t):e}function pt(e){return e.split("-")[0]}function Ut(e){return e.split("-")[1]}function So(e){return e==="x"?"y":"x"}function Co(e){return e==="y"?"height":"width"}const Fp=new Set(["top","bottom"]);function at(e){return Fp.has(pt(e))?"y":"x"}function Eo(e){return So(at(e))}function $p(e,t,n){n===void 0&&(n=!1);const r=Ut(e),o=Eo(e),s=Co(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Kn(a)),[a,Kn(a)]}function Bp(e){const t=Kn(e);return[No(e),t,No(t)]}function No(e){return e.replace(/start|end/g,t=>Lp[t])}const Ra=["left","right"],Ka=["right","left"],Up=["top","bottom"],Hp=["bottom","top"];function zp(e,t,n){switch(e){case"top":case"bottom":return n?t?Ka:Ra:t?Ra:Ka;case"left":case"right":return t?Up:Hp;default:return[]}}function Wp(e,t,n,r){const o=Ut(e);let s=zp(pt(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(No)))),s}function Kn(e){return e.replace(/left|right|bottom|top/g,t=>Dp[t])}function Vp(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ga(e){return typeof e!="number"?Vp(e):{top:e,right:e,bottom:e,left:e}}function Gn(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function qa(e,t,n){let{reference:r,floating:o}=e;const s=at(t),a=Eo(t),c=Co(a),d=pt(t),f=s==="y",u=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[c]/2-o[c]/2;let v;switch(d){case"top":v={x:u,y:r.y-o.height};break;case"bottom":v={x:u,y:r.y+r.height};break;case"right":v={x:r.x+r.width,y:p};break;case"left":v={x:r.x-o.width,y:p};break;default:v={x:r.x,y:r.y}}switch(Ut(t)){case"start":v[a]-=m*(n&&f?-1:1);break;case"end":v[a]+=m*(n&&f?-1:1);break}return v}const jp=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:a}=n,c=s.filter(Boolean),d=await(a.isRTL==null?void 0:a.isRTL(t));let f=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:p}=qa(f,r,d),m=r,v={},g=0;for(let h=0;h<c.length;h++){const{name:b,fn:w}=c[h],{x:y,y:x,data:C,reset:E}=await w({x:u,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:v,rects:f,platform:a,elements:{reference:e,floating:t}});u=y??u,p=x??p,v={...v,[b]:{...v[b],...C}},E&&g<=50&&(g++,typeof E=="object"&&(E.placement&&(m=E.placement),E.rects&&(f=E.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):E.rects),{x:u,y:p}=qa(f,m,d)),h=-1)}return{x:u,y:p,placement:m,strategy:o,middlewareData:v}};async function ln(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:a,elements:c,strategy:d}=e,{boundary:f="clippingAncestors",rootBoundary:u="viewport",elementContext:p="floating",altBoundary:m=!1,padding:v=0}=ft(t,e),g=Ga(v),b=c[m?p==="floating"?"reference":"floating":p],w=Gn(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:f,rootBoundary:u,strategy:d})),y=p==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),C=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},E=Gn(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:y,offsetParent:x,strategy:d}):y);return{top:(w.top-E.top+g.top)/C.y,bottom:(E.bottom-w.bottom+g.bottom)/C.y,left:(w.left-E.left+g.left)/C.x,right:(E.right-w.right+g.right)/C.x}}const Rp=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:a,elements:c,middlewareData:d}=t,{element:f,padding:u=0}=ft(e,t)||{};if(f==null)return{};const p=Ga(u),m={x:n,y:r},v=Eo(o),g=Co(v),h=await a.getDimensions(f),b=v==="y",w=b?"top":"left",y=b?"bottom":"right",x=b?"clientHeight":"clientWidth",C=s.reference[g]+s.reference[v]-m[v]-s.floating[g],E=m[v]-s.reference[v],P=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f));let T=P?P[x]:0;(!T||!await(a.isElement==null?void 0:a.isElement(P)))&&(T=c.floating[x]||s.floating[g]);const F=C/2-E/2,M=T/2-h[g]/2-1,B=vt(p[w],M),V=vt(p[y],M),J=B,H=T-h[g]-V,O=T/2-h[g]/2+F,ne=xo(J,O,H),L=!d.arrow&&Ut(o)!=null&&O!==ne&&s.reference[g]/2-(O<J?B:V)-h[g]/2<0,z=L?O<J?O-J:O-H:0;return{[v]:m[v]+z,data:{[v]:ne,centerOffset:O-ne-z,...L&&{alignmentOffset:z}},reset:L}}}),Kp=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:a,initialPlacement:c,platform:d,elements:f}=t,{mainAxis:u=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...b}=ft(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=pt(o),y=at(c),x=pt(c)===c,C=await(d.isRTL==null?void 0:d.isRTL(f.floating)),E=m||(x||!h?[Kn(c)]:Bp(c)),P=g!=="none";!m&&P&&E.push(...Wp(c,h,g,C));const T=[c,...E],F=await ln(t,b),M=[];let B=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&M.push(F[w]),p){const O=$p(o,a,C);M.push(F[O[0]],F[O[1]])}if(B=[...B,{placement:o,overflows:M}],!M.every(O=>O<=0)){var V,J;const O=(((V=s.flip)==null?void 0:V.index)||0)+1,ne=T[O];if(ne&&(!(p==="alignment"?y!==at(ne):!1)||B.every(k=>at(k.placement)===y?k.overflows[0]>0:!0)))return{data:{index:O,overflows:B},reset:{placement:ne}};let L=(J=B.filter(z=>z.overflows[0]<=0).sort((z,k)=>z.overflows[1]-k.overflows[1])[0])==null?void 0:J.placement;if(!L)switch(v){case"bestFit":{var H;const z=(H=B.filter(k=>{if(P){const I=at(k.placement);return I===y||I==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(I=>I>0).reduce((I,Z)=>I+Z,0)]).sort((k,I)=>k[1]-I[1])[0])==null?void 0:H[0];z&&(L=z);break}case"initialPlacement":L=c;break}if(o!==L)return{reset:{placement:L}}}return{}}}};function Xa(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ya(e){return Mp.some(t=>e[t]>=0)}const Gp=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=ft(e,t);switch(r){case"referenceHidden":{const s=await ln(t,{...o,elementContext:"reference"}),a=Xa(s,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Ya(a)}}}case"escaped":{const s=await ln(t,{...o,altBoundary:!0}),a=Xa(s,n.floating);return{data:{escapedOffsets:a,escaped:Ya(a)}}}default:return{}}}}},Ja=new Set(["left","top"]);async function qp(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=pt(n),c=Ut(n),d=at(n)==="y",f=Ja.has(a)?-1:1,u=s&&d?-1:1,p=ft(t,e);let{mainAxis:m,crossAxis:v,alignmentAxis:g}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return c&&typeof g=="number"&&(v=c==="end"?g*-1:g),d?{x:v*u,y:m*f}:{x:m*f,y:v*u}}const Xp=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:a,middlewareData:c}=t,d=await qp(t,e);return a===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:o+d.x,y:s+d.y,data:{...d,placement:a}}}}},Yp=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:a=!1,limiter:c={fn:b=>{let{x:w,y}=b;return{x:w,y}}},...d}=ft(e,t),f={x:n,y:r},u=await ln(t,d),p=at(pt(o)),m=So(p);let v=f[m],g=f[p];if(s){const b=m==="y"?"top":"left",w=m==="y"?"bottom":"right",y=v+u[b],x=v-u[w];v=xo(y,v,x)}if(a){const b=p==="y"?"top":"left",w=p==="y"?"bottom":"right",y=g+u[b],x=g-u[w];g=xo(y,g,x)}const h=c.fn({...t,[m]:v,[p]:g});return{...h,data:{x:h.x-n,y:h.y-r,enabled:{[m]:s,[p]:a}}}}}},Jp=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:a}=t,{offset:c=0,mainAxis:d=!0,crossAxis:f=!0}=ft(e,t),u={x:n,y:r},p=at(o),m=So(p);let v=u[m],g=u[p];const h=ft(c,t),b=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(d){const x=m==="y"?"height":"width",C=s.reference[m]-s.floating[x]+b.mainAxis,E=s.reference[m]+s.reference[x]-b.mainAxis;v<C?v=C:v>E&&(v=E)}if(f){var w,y;const x=m==="y"?"width":"height",C=Ja.has(pt(o)),E=s.reference[p]-s.floating[x]+(C&&((w=a.offset)==null?void 0:w[p])||0)+(C?0:b.crossAxis),P=s.reference[p]+s.reference[x]+(C?0:((y=a.offset)==null?void 0:y[p])||0)-(C?b.crossAxis:0);g<E?g=E:g>P&&(g=P)}return{[m]:v,[p]:g}}}},Zp=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:a,elements:c}=t,{apply:d=()=>{},...f}=ft(e,t),u=await ln(t,f),p=pt(o),m=Ut(o),v=at(o)==="y",{width:g,height:h}=s.floating;let b,w;p==="top"||p==="bottom"?(b=p,w=m===(await(a.isRTL==null?void 0:a.isRTL(c.floating))?"start":"end")?"left":"right"):(w=p,b=m==="end"?"top":"bottom");const y=h-u.top-u.bottom,x=g-u.left-u.right,C=vt(h-u[b],y),E=vt(g-u[w],x),P=!t.middlewareData.shift;let T=C,F=E;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(F=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(T=y),P&&!m){const B=Ue(u.left,0),V=Ue(u.right,0),J=Ue(u.top,0),H=Ue(u.bottom,0);v?F=g-2*(B!==0||V!==0?B+V:Ue(u.left,u.right)):T=h-2*(J!==0||H!==0?J+H:Ue(u.top,u.bottom))}await d({...t,availableWidth:F,availableHeight:T});const M=await a.getDimensions(c.floating);return g!==M.width||h!==M.height?{reset:{rects:!0}}:{}}}};function qn(){return typeof window<"u"}function Ht(e){return Za(e)?(e.nodeName||"").toLowerCase():"#document"}function He(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function it(e){var t;return(t=(Za(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Za(e){return qn()?e instanceof Node||e instanceof He(e).Node:!1}function qe(e){return qn()?e instanceof Element||e instanceof He(e).Element:!1}function ct(e){return qn()?e instanceof HTMLElement||e instanceof He(e).HTMLElement:!1}function Qa(e){return!qn()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof He(e).ShadowRoot}const Qp=new Set(["inline","contents"]);function dn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Xe(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Qp.has(o)}const eh=new Set(["table","td","th"]);function th(e){return eh.has(Ht(e))}const nh=[":popover-open",":modal"];function Xn(e){return nh.some(t=>{try{return e.matches(t)}catch{return!1}})}const rh=["transform","translate","scale","rotate","perspective"],oh=["transform","translate","scale","rotate","perspective","filter"],sh=["paint","layout","strict","content"];function To(e){const t=Ao(),n=qe(e)?Xe(e):e;return rh.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||oh.some(r=>(n.willChange||"").includes(r))||sh.some(r=>(n.contain||"").includes(r))}function ah(e){let t=wt(e);for(;ct(t)&&!zt(t);){if(To(t))return t;if(Xn(t))return null;t=wt(t)}return null}function Ao(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const ih=new Set(["html","body","#document"]);function zt(e){return ih.has(Ht(e))}function Xe(e){return He(e).getComputedStyle(e)}function Yn(e){return qe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function wt(e){if(Ht(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Qa(e)&&e.host||it(e);return Qa(t)?t.host:t}function ei(e){const t=wt(e);return zt(t)?e.ownerDocument?e.ownerDocument.body:e.body:ct(t)&&dn(t)?t:ei(t)}function un(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ei(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),a=He(o);if(s){const c=Io(a);return t.concat(a,a.visualViewport||[],dn(o)?o:[],c&&n?un(c):[])}return t.concat(o,un(o,[],n))}function Io(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ti(e){const t=Xe(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=ct(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,c=jn(n)!==s||jn(r)!==a;return c&&(n=s,r=a),{width:n,height:r,$:c}}function ko(e){return qe(e)?e:e.contextElement}function Wt(e){const t=ko(e);if(!ct(t))return st(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=ti(t);let a=(s?jn(n.width):n.width)/r,c=(s?jn(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!c||!Number.isFinite(c))&&(c=1),{x:a,y:c}}const ch=st(0);function ni(e){const t=He(e);return!Ao()||!t.visualViewport?ch:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function lh(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==He(e)?!1:t}function At(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ko(e);let a=st(1);t&&(r?qe(r)&&(a=Wt(r)):a=Wt(e));const c=lh(s,n,r)?ni(s):st(0);let d=(o.left+c.x)/a.x,f=(o.top+c.y)/a.y,u=o.width/a.x,p=o.height/a.y;if(s){const m=He(s),v=r&&qe(r)?He(r):r;let g=m,h=Io(g);for(;h&&r&&v!==g;){const b=Wt(h),w=h.getBoundingClientRect(),y=Xe(h),x=w.left+(h.clientLeft+parseFloat(y.paddingLeft))*b.x,C=w.top+(h.clientTop+parseFloat(y.paddingTop))*b.y;d*=b.x,f*=b.y,u*=b.x,p*=b.y,d+=x,f+=C,g=He(h),h=Io(g)}}return Gn({width:u,height:p,x:d,y:f})}function Jn(e,t){const n=Yn(e).scrollLeft;return t?t.left+n:At(it(e)).left+n}function ri(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Jn(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function dh(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=it(r),c=t?Xn(t.floating):!1;if(r===a||c&&s)return n;let d={scrollLeft:0,scrollTop:0},f=st(1);const u=st(0),p=ct(r);if((p||!p&&!s)&&((Ht(r)!=="body"||dn(a))&&(d=Yn(r)),ct(r))){const v=At(r);f=Wt(r),u.x=v.x+r.clientLeft,u.y=v.y+r.clientTop}const m=a&&!p&&!s?ri(a,d):st(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+u.x+m.x,y:n.y*f.y-d.scrollTop*f.y+u.y+m.y}}function uh(e){return Array.from(e.getClientRects())}function fh(e){const t=it(e),n=Yn(e),r=e.ownerDocument.body,o=Ue(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ue(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Jn(e);const c=-n.scrollTop;return Xe(r).direction==="rtl"&&(a+=Ue(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:c}}const oi=25;function ph(e,t){const n=He(e),r=it(e),o=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,c=0,d=0;if(o){s=o.width,a=o.height;const u=Ao();(!u||u&&t==="fixed")&&(c=o.offsetLeft,d=o.offsetTop)}const f=Jn(r);if(f<=0){const u=r.ownerDocument,p=u.body,m=getComputedStyle(p),v=u.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(r.clientWidth-p.clientWidth-v);g<=oi&&(s-=g)}else f<=oi&&(s+=f);return{width:s,height:a,x:c,y:d}}const hh=new Set(["absolute","fixed"]);function gh(e,t){const n=At(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=ct(e)?Wt(e):st(1),a=e.clientWidth*s.x,c=e.clientHeight*s.y,d=o*s.x,f=r*s.y;return{width:a,height:c,x:d,y:f}}function si(e,t,n){let r;if(t==="viewport")r=ph(e,n);else if(t==="document")r=fh(it(e));else if(qe(t))r=gh(t,n);else{const o=ni(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Gn(r)}function ai(e,t){const n=wt(e);return n===t||!qe(n)||zt(n)?!1:Xe(n).position==="fixed"||ai(n,t)}function mh(e,t){const n=t.get(e);if(n)return n;let r=un(e,[],!1).filter(c=>qe(c)&&Ht(c)!=="body"),o=null;const s=Xe(e).position==="fixed";let a=s?wt(e):e;for(;qe(a)&&!zt(a);){const c=Xe(a),d=To(a);!d&&c.position==="fixed"&&(o=null),(s?!d&&!o:!d&&c.position==="static"&&!!o&&hh.has(o.position)||dn(a)&&!d&&ai(e,a))?r=r.filter(u=>u!==a):o=c,a=wt(a)}return t.set(e,r),r}function bh(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?Xn(t)?[]:mh(t,this._c):[].concat(n),r],c=a[0],d=a.reduce((f,u)=>{const p=si(t,u,o);return f.top=Ue(p.top,f.top),f.right=vt(p.right,f.right),f.bottom=vt(p.bottom,f.bottom),f.left=Ue(p.left,f.left),f},si(t,c,o));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function vh(e){const{width:t,height:n}=ti(e);return{width:t,height:n}}function wh(e,t,n){const r=ct(t),o=it(t),s=n==="fixed",a=At(e,!0,s,t);let c={scrollLeft:0,scrollTop:0};const d=st(0);function f(){d.x=Jn(o)}if(r||!r&&!s)if((Ht(t)!=="body"||dn(o))&&(c=Yn(t)),r){const v=At(t,!0,s,t);d.x=v.x+t.clientLeft,d.y=v.y+t.clientTop}else o&&f();s&&!r&&o&&f();const u=o&&!r&&!s?ri(o,c):st(0),p=a.left+c.scrollLeft-d.x-u.x,m=a.top+c.scrollTop-d.y-u.y;return{x:p,y:m,width:a.width,height:a.height}}function _o(e){return Xe(e).position==="static"}function ii(e,t){if(!ct(e)||Xe(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return it(e)===n&&(n=n.ownerDocument.body),n}function ci(e,t){const n=He(e);if(Xn(e))return n;if(!ct(e)){let o=wt(e);for(;o&&!zt(o);){if(qe(o)&&!_o(o))return o;o=wt(o)}return n}let r=ii(e,t);for(;r&&th(r)&&_o(r);)r=ii(r,t);return r&&zt(r)&&_o(r)&&!To(r)?n:r||ah(e)||n}const yh=async function(e){const t=this.getOffsetParent||ci,n=this.getDimensions,r=await n(e.floating);return{reference:wh(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function xh(e){return Xe(e).direction==="rtl"}const Sh={convertOffsetParentRelativeRectToViewportRelativeRect:dh,getDocumentElement:it,getClippingRect:bh,getOffsetParent:ci,getElementRects:yh,getClientRects:uh,getDimensions:vh,getScale:Wt,isElement:qe,isRTL:xh};function li(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ch(e,t){let n=null,r;const o=it(e);function s(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function a(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),s();const f=e.getBoundingClientRect(),{left:u,top:p,width:m,height:v}=f;if(c||t(),!m||!v)return;const g=Rn(p),h=Rn(o.clientWidth-(u+m)),b=Rn(o.clientHeight-(p+v)),w=Rn(u),x={rootMargin:-g+"px "+-h+"px "+-b+"px "+-w+"px",threshold:Ue(0,vt(1,d))||1};let C=!0;function E(P){const T=P[0].intersectionRatio;if(T!==d){if(!C)return a();T?a(!1,T):r=setTimeout(()=>{a(!1,1e-7)},1e3)}T===1&&!li(f,e.getBoundingClientRect())&&a(),C=!1}try{n=new IntersectionObserver(E,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(E,x)}n.observe(e)}return a(!0),s}function Eh(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,f=ko(e),u=o||s?[...f?un(f):[],...un(t)]:[];u.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const p=f&&c?Ch(f,n):null;let m=-1,v=null;a&&(v=new ResizeObserver(w=>{let[y]=w;y&&y.target===f&&v&&(v.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var x;(x=v)==null||x.observe(t)})),n()}),f&&!d&&v.observe(f),v.observe(t));let g,h=d?At(e):null;d&&b();function b(){const w=At(e);h&&!li(h,w)&&n(),h=w,g=requestAnimationFrame(b)}return n(),()=>{var w;u.forEach(y=>{o&&y.removeEventListener("scroll",n),s&&y.removeEventListener("resize",n)}),p==null||p(),(w=v)==null||w.disconnect(),v=null,d&&cancelAnimationFrame(g)}}const Nh=Xp,Th=Yp,Ah=Kp,Ih=Zp,kh=Gp,di=Rp,_h=Jp,Ph=(e,t,n)=>{const r=new Map,o={platform:Sh,...n},s={...o.platform,_c:r};return jp(e,t,{...o,platform:s})};var Oh=typeof document<"u",Mh=function(){},Zn=Oh?N.useLayoutEffect:Mh;function Qn(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Qn(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Qn(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function ui(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fi(e,t){const n=ui(e);return Math.round(t*n)/n}function Po(e){const t=l.useRef(e);return Zn(()=>{t.current=e}),t}function Dh(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:a}={},transform:c=!0,whileElementsMounted:d,open:f}=e,[u,p]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,v]=l.useState(r);Qn(m,r)||v(r);const[g,h]=l.useState(null),[b,w]=l.useState(null),y=l.useCallback(k=>{k!==P.current&&(P.current=k,h(k))},[]),x=l.useCallback(k=>{k!==T.current&&(T.current=k,w(k))},[]),C=s||g,E=a||b,P=l.useRef(null),T=l.useRef(null),F=l.useRef(u),M=d!=null,B=Po(d),V=Po(o),J=Po(f),H=l.useCallback(()=>{if(!P.current||!T.current)return;const k={placement:t,strategy:n,middleware:m};V.current&&(k.platform=V.current),Ph(P.current,T.current,k).then(I=>{const Z={...I,isPositioned:J.current!==!1};O.current&&!Qn(F.current,Z)&&(F.current=Z,Tn.flushSync(()=>{p(Z)}))})},[m,t,n,V,J]);Zn(()=>{f===!1&&F.current.isPositioned&&(F.current.isPositioned=!1,p(k=>({...k,isPositioned:!1})))},[f]);const O=l.useRef(!1);Zn(()=>(O.current=!0,()=>{O.current=!1}),[]),Zn(()=>{if(C&&(P.current=C),E&&(T.current=E),C&&E){if(B.current)return B.current(C,E,H);H()}},[C,E,H,B,M]);const ne=l.useMemo(()=>({reference:P,floating:T,setReference:y,setFloating:x}),[y,x]),L=l.useMemo(()=>({reference:C,floating:E}),[C,E]),z=l.useMemo(()=>{const k={position:n,left:0,top:0};if(!L.floating)return k;const I=fi(L.floating,u.x),Z=fi(L.floating,u.y);return c?{...k,transform:"translate("+I+"px, "+Z+"px)",...ui(L.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:Z}},[n,c,L.floating,u.x,u.y]);return l.useMemo(()=>({...u,update:H,refs:ne,elements:L,floatingStyles:z}),[u,H,ne,L,z])}const Lh=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?di({element:r.current,padding:o}).fn(n):{}:r?di({element:r,padding:o}).fn(n):{}}}},Fh=(e,t)=>({...Nh(e),options:[e,t]}),$h=(e,t)=>({...Th(e),options:[e,t]}),Bh=(e,t)=>({..._h(e),options:[e,t]}),Uh=(e,t)=>({...Ah(e),options:[e,t]}),Hh=(e,t)=>({...Ih(e),options:[e,t]}),zh=(e,t)=>({...kh(e),options:[e,t]}),Wh=(e,t)=>({...Lh(e),options:[e,t]});var Vh="Arrow",pi=l.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return i.jsx(oe.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:i.jsx("polygon",{points:"0,0 30,0 15,10"})})});pi.displayName=Vh;var jh=pi;function hi(e){const[t,n]=l.useState(void 0);return Ne(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let a,c;if("borderBoxSize"in s){const d=s.borderBoxSize,f=Array.isArray(d)?d[0]:d;a=f.inlineSize,c=f.blockSize}else a=e.offsetWidth,c=e.offsetHeight;n({width:a,height:c})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Oo="Popper",[gi,Vt]=Ke(Oo),[Rh,mi]=gi(Oo),bi=e=>{const{__scopePopper:t,children:n}=e,[r,o]=l.useState(null);return i.jsx(Rh,{scope:t,anchor:r,onAnchorChange:o,children:n})};bi.displayName=Oo;var vi="PopperAnchor",wi=l.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=mi(vi,n),a=l.useRef(null),c=ue(t,a),d=l.useRef(null);return l.useEffect(()=>{const f=d.current;d.current=(r==null?void 0:r.current)||a.current,f!==d.current&&s.onAnchorChange(d.current)}),r?null:i.jsx(oe.div,{...o,ref:c})});wi.displayName=vi;var Mo="PopperContent",[Kh,Gh]=gi(Mo),yi=l.forwardRef((e,t)=>{var R,le,he,de,be,ge;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:u=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:v="optimized",onPlaced:g,...h}=e,b=mi(Mo,n),[w,y]=l.useState(null),x=ue(t,G=>y(G)),[C,E]=l.useState(null),P=hi(C),T=(P==null?void 0:P.width)??0,F=(P==null?void 0:P.height)??0,M=r+(s!=="center"?"-"+s:""),B=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},V=Array.isArray(f)?f:[f],J=V.length>0,H={padding:B,boundary:V.filter(Xh),altBoundary:J},{refs:O,floatingStyles:ne,placement:L,isPositioned:z,middlewareData:k}=Dh({strategy:"fixed",placement:M,whileElementsMounted:(...G)=>Eh(...G,{animationFrame:v==="always"}),elements:{reference:b.anchor},middleware:[Fh({mainAxis:o+F,alignmentAxis:a}),d&&$h({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Bh():void 0,...H}),d&&Uh({...H}),Hh({...H,apply:({elements:G,rects:X,availableWidth:ye,availableHeight:se})=>{const{width:Se,height:fe}=X.reference,ve=G.floating.style;ve.setProperty("--radix-popper-available-width",`${ye}px`),ve.setProperty("--radix-popper-available-height",`${se}px`),ve.setProperty("--radix-popper-anchor-width",`${Se}px`),ve.setProperty("--radix-popper-anchor-height",`${fe}px`)}}),C&&Wh({element:C,padding:c}),Yh({arrowWidth:T,arrowHeight:F}),m&&zh({strategy:"referenceHidden",...H})]}),[I,Z]=Ci(L),j=Ae(g);Ne(()=>{z&&(j==null||j())},[z,j]);const te=(R=k.arrow)==null?void 0:R.x,D=(le=k.arrow)==null?void 0:le.y,W=((he=k.arrow)==null?void 0:he.centerOffset)!==0,[xe,ie]=l.useState();return Ne(()=>{w&&ie(window.getComputedStyle(w).zIndex)},[w]),i.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...ne,transform:z?ne.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:xe,"--radix-popper-transform-origin":[(de=k.transformOrigin)==null?void 0:de.x,(be=k.transformOrigin)==null?void 0:be.y].join(" "),...((ge=k.hide)==null?void 0:ge.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:i.jsx(Kh,{scope:n,placedSide:I,onArrowChange:E,arrowX:te,arrowY:D,shouldHideArrow:W,children:i.jsx(oe.div,{"data-side":I,"data-align":Z,...h,ref:x,style:{...h.style,animation:z?void 0:"none"}})})})});yi.displayName=Mo;var xi="PopperArrow",qh={top:"bottom",right:"left",bottom:"top",left:"right"},Si=l.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Gh(xi,r),a=qh[s.placedSide];return i.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:i.jsx(jh,{...o,ref:n,style:{...o.style,display:"block"}})})});Si.displayName=xi;function Xh(e){return e!==null}var Yh=e=>({name:"transformOrigin",options:e,fn(t){var b,w,y;const{placement:n,rects:r,middlewareData:o}=t,a=((b=o.arrow)==null?void 0:b.centerOffset)!==0,c=a?0:e.arrowWidth,d=a?0:e.arrowHeight,[f,u]=Ci(n),p={start:"0%",center:"50%",end:"100%"}[u],m=(((w=o.arrow)==null?void 0:w.x)??0)+c/2,v=(((y=o.arrow)==null?void 0:y.y)??0)+d/2;let g="",h="";return f==="bottom"?(g=a?p:`${m}px`,h=`${-d}px`):f==="top"?(g=a?p:`${m}px`,h=`${r.floating.height+d}px`):f==="right"?(g=`${-d}px`,h=a?p:`${v}px`):f==="left"&&(g=`${r.floating.width+d}px`,h=a?p:`${v}px`),{data:{x:g,y:h}}}});function Ci(e){const[t,n="center"]=e.split("-");return[t,n]}var Do=bi,Lo=wi,Fo=yi,$o=Si,Jh="Portal",er=l.forwardRef((e,t)=>{var c;const{container:n,...r}=e,[o,s]=l.useState(!1);Ne(()=>s(!0),[]);const a=n||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return a?As.createPortal(i.jsx(oe.div,{...r,ref:t}),a):null});er.displayName=Jh;var Bo="rovingFocusGroup.onEntryFocus",Zh={bubbles:!1,cancelable:!0},fn="RovingFocusGroup",[Uo,Ei,Qh]=go(fn),[eg,Ni]=Ke(fn,[Qh]),[tg,ng]=eg(fn),Ti=l.forwardRef((e,t)=>i.jsx(Uo.Provider,{scope:e.__scopeRovingFocusGroup,children:i.jsx(Uo.Slot,{scope:e.__scopeRovingFocusGroup,children:i.jsx(rg,{...e,ref:t})})}));Ti.displayName=fn;var rg=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:u=!1,...p}=e,m=l.useRef(null),v=ue(t,m),g=Wn(s),[h,b]=mt({prop:a,defaultProp:c??null,onChange:d,caller:fn}),[w,y]=l.useState(!1),x=Ae(f),C=Ei(n),E=l.useRef(!1),[P,T]=l.useState(0);return l.useEffect(()=>{const F=m.current;if(F)return F.addEventListener(Bo,x),()=>F.removeEventListener(Bo,x)},[x]),i.jsx(tg,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:h,onItemFocus:l.useCallback(F=>b(F),[b]),onItemShiftTab:l.useCallback(()=>y(!0),[]),onFocusableItemAdd:l.useCallback(()=>T(F=>F+1),[]),onFocusableItemRemove:l.useCallback(()=>T(F=>F-1),[]),children:i.jsx(oe.div,{tabIndex:w||P===0?-1:0,"data-orientation":r,...p,ref:v,style:{outline:"none",...e.style},onMouseDown:U(e.onMouseDown,()=>{E.current=!0}),onFocus:U(e.onFocus,F=>{const M=!E.current;if(F.target===F.currentTarget&&M&&!w){const B=new CustomEvent(Bo,Zh);if(F.currentTarget.dispatchEvent(B),!B.defaultPrevented){const V=C().filter(L=>L.focusable),J=V.find(L=>L.active),H=V.find(L=>L.id===h),ne=[J,H,...V].filter(Boolean).map(L=>L.ref.current);ki(ne,u)}}E.current=!1}),onBlur:U(e.onBlur,()=>y(!1))})})}),Ai="RovingFocusGroupItem",Ii=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:a,...c}=e,d=Ge(),f=s||d,u=ng(Ai,n),p=u.currentTabStopId===f,m=Ei(n),{onFocusableItemAdd:v,onFocusableItemRemove:g,currentTabStopId:h}=u;return l.useEffect(()=>{if(r)return v(),()=>g()},[r,v,g]),i.jsx(Uo.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:i.jsx(oe.span,{tabIndex:p?0:-1,"data-orientation":u.orientation,...c,ref:t,onMouseDown:U(e.onMouseDown,b=>{r?u.onItemFocus(f):b.preventDefault()}),onFocus:U(e.onFocus,()=>u.onItemFocus(f)),onKeyDown:U(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){u.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const w=ag(b,u.orientation,u.dir);if(w!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let x=m().filter(C=>C.focusable).map(C=>C.ref.current);if(w==="last")x.reverse();else if(w==="prev"||w==="next"){w==="prev"&&x.reverse();const C=x.indexOf(b.currentTarget);x=u.loop?ig(x,C+1):x.slice(C+1)}setTimeout(()=>ki(x))}}),children:typeof a=="function"?a({isCurrentTabStop:p,hasTabStop:h!=null}):a})})});Ii.displayName=Ai;var og={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function sg(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ag(e,t,n){const r=sg(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return og[r]}function ki(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function ig(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var cg=Ti,lg=Ii,dg=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},jt=new WeakMap,tr=new WeakMap,nr={},Ho=0,_i=function(e){return e&&(e.host||_i(e.parentNode))},ug=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=_i(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},fg=function(e,t,n,r){var o=ug(t,Array.isArray(e)?e:[e]);nr[n]||(nr[n]=new WeakMap);var s=nr[n],a=[],c=new Set,d=new Set(o),f=function(p){!p||c.has(p)||(c.add(p),f(p.parentNode))};o.forEach(f);var u=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(m){if(c.has(m))u(m);else try{var v=m.getAttribute(r),g=v!==null&&v!=="false",h=(jt.get(m)||0)+1,b=(s.get(m)||0)+1;jt.set(m,h),s.set(m,b),a.push(m),h===1&&g&&tr.set(m,!0),b===1&&m.setAttribute(n,"true"),g||m.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",m,w)}})};return u(t),c.clear(),Ho++,function(){a.forEach(function(p){var m=jt.get(p)-1,v=s.get(p)-1;jt.set(p,m),s.set(p,v),m||(tr.has(p)||p.removeAttribute(r),tr.delete(p)),v||p.removeAttribute(n)}),Ho--,Ho||(jt=new WeakMap,jt=new WeakMap,tr=new WeakMap,nr={})}},zo=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=dg(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),fg(r,o,n,"aria-hidden")):function(){return null}},lt=function(){return lt=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},lt.apply(this,arguments)};function Pi(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 pg(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))}typeof SuppressedError=="function"&&SuppressedError;var rr="right-scroll-bar-position",or="width-before-scroll-bar",hg="with-scroll-bars-hidden",gg="--removed-body-scroll-bar-size";function Wo(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function mg(e,t){var n=N.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 bg=typeof window<"u"?l.useLayoutEffect:l.useEffect,Oi=new WeakMap;function vg(e,t){var n=mg(null,function(r){return e.forEach(function(o){return Wo(o,r)})});return bg(function(){var r=Oi.get(n);if(r){var o=new Set(r),s=new Set(e),a=n.current;o.forEach(function(c){s.has(c)||Wo(c,null)}),s.forEach(function(c){o.has(c)||Wo(c,a)})}Oi.set(n,e)},[e]),n}function wg(e){return e}function yg(e,t){t===void 0&&(t=wg);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 a=t(s,r);return n.push(a),function(){n=n.filter(function(c){return c!==a})}},assignSyncMedium:function(s){for(r=!0;n.length;){var a=n;n=[],a.forEach(s)}n={push:function(c){return s(c)},filter:function(){return n}}},assignMedium:function(s){r=!0;var a=[];if(n.length){var c=n;n=[],c.forEach(s),a=n}var d=function(){var u=a;a=[],u.forEach(s)},f=function(){return Promise.resolve().then(d)};f(),n={push:function(u){a.push(u),f()},filter:function(u){return a=a.filter(u),n}}}};return o}function xg(e){e===void 0&&(e={});var t=yg(null);return t.options=lt({async:!0,ssr:!1},e),t}var Mi=function(e){var t=e.sideCar,n=Pi(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 l.createElement(r,lt({},n))};Mi.isSideCarExport=!0;function Sg(e,t){return e.useMedium(t),Mi}var Di=xg(),Vo=function(){},sr=l.forwardRef(function(e,t){var n=l.useRef(null),r=l.useState({onScrollCapture:Vo,onWheelCapture:Vo,onTouchMoveCapture:Vo}),o=r[0],s=r[1],a=e.forwardProps,c=e.children,d=e.className,f=e.removeScrollBar,u=e.enabled,p=e.shards,m=e.sideCar,v=e.noRelative,g=e.noIsolation,h=e.inert,b=e.allowPinchZoom,w=e.as,y=w===void 0?"div":w,x=e.gapMode,C=Pi(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),E=m,P=vg([n,t]),T=lt(lt({},C),o);return l.createElement(l.Fragment,null,u&&l.createElement(E,{sideCar:Di,removeScrollBar:f,shards:p,noRelative:v,noIsolation:g,inert:h,setCallbacks:s,allowPinchZoom:!!b,lockRef:n,gapMode:x}),a?l.cloneElement(l.Children.only(c),lt(lt({},T),{ref:P})):l.createElement(y,lt({},T,{className:d,ref:P}),c))});sr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},sr.classNames={fullWidth:or,zeroRight:rr};var Cg=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Eg(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Cg();return t&&e.setAttribute("nonce",t),e}function Ng(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Tg(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Ag=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Eg())&&(Ng(t,n),Tg(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ig=function(){var e=Ag();return function(t,n){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Li=function(){var e=Ig(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},kg={left:0,top:0,right:0,gap:0},jo=function(e){return parseInt(e||"",10)||0},_g=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[jo(n),jo(r),jo(o)]},Pg=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return kg;var t=_g(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])}},Og=Li(),Rt="data-scroll-locked",Mg=function(e,t,n,r){var o=e.left,s=e.top,a=e.right,c=e.gap;return n===void 0&&(n="margin"),`
19
+ .`.concat(hg,` {
20
20
  overflow: hidden `).concat(r,`;
21
21
  padding-right: `).concat(c,"px ").concat(r,`;
22
22
  }
23
- body[`).concat(Vt,`] {
23
+ body[`).concat(Rt,`] {
24
24
  overflow: hidden `).concat(r,`;
25
25
  overscroll-behavior: contain;
26
26
  `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
@@ -33,30 +33,30 @@
33
33
  `),n==="padding"&&"padding-right: ".concat(c,"px ").concat(r,";")].filter(Boolean).join(""),`
34
34
  }
35
35
 
36
- .`).concat(nr,` {
36
+ .`).concat(rr,` {
37
37
  right: `).concat(c,"px ").concat(r,`;
38
38
  }
39
39
 
40
- .`).concat(rr,` {
40
+ .`).concat(or,` {
41
41
  margin-right: `).concat(c,"px ").concat(r,`;
42
42
  }
43
43
 
44
- .`).concat(nr," .").concat(nr,` {
44
+ .`).concat(rr," .").concat(rr,` {
45
45
  right: 0 `).concat(r,`;
46
46
  }
47
47
 
48
- .`).concat(rr," .").concat(rr,` {
48
+ .`).concat(or," .").concat(or,` {
49
49
  margin-right: 0 `).concat(r,`;
50
50
  }
51
51
 
52
- body[`).concat(Vt,`] {
53
- `).concat(hg,": ").concat(c,`px;
52
+ body[`).concat(Rt,`] {
53
+ `).concat(gg,": ").concat(c,`px;
54
54
  }
55
- `)},Li=function(){var e=parseInt(document.body.getAttribute(Vt)||"0",10);return isFinite(e)?e:0},Mg=function(){l.useEffect(function(){return document.body.setAttribute(Vt,(Li()+1).toString()),function(){var e=Li()-1;e<=0?document.body.removeAttribute(Vt):document.body.setAttribute(Vt,e.toString())}},[])},Dg=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Mg();var s=l.useMemo(function(){return _g(o)},[o]);return l.createElement(Pg,{styles:Og(s,!t,o,n?"":"!important")})},Vo=!1;if(typeof window<"u")try{var sr=Object.defineProperty({},"passive",{get:function(){return Vo=!0,!0}});window.addEventListener("test",sr,sr),window.removeEventListener("test",sr,sr)}catch{Vo=!1}var Rt=Vo?{passive:!1}:!1,Lg=function(e){return e.tagName==="TEXTAREA"},Fi=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Lg(e)&&n[t]==="visible")},Fg=function(e){return Fi(e,"overflowY")},$g=function(e){return Fi(e,"overflowX")},$i=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Bi(e,r);if(o){var s=Ui(e,r),a=s[1],c=s[2];if(a>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Bg=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Ug=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Bi=function(e,t){return e==="v"?Fg(t):$g(t)},Ui=function(e,t){return e==="v"?Bg(t):Ug(t)},Hg=function(e,t){return e==="h"&&t==="rtl"?-1:1},zg=function(e,t,n,r,o){var s=Hg(e,window.getComputedStyle(t).direction),a=s*r,c=n.target,d=t.contains(c),f=!1,u=a>0,p=0,m=0;do{if(!c)break;var v=Ui(e,c),g=v[0],h=v[1],b=v[2],w=h-b-s*g;(g||w)&&Bi(e,c)&&(p+=w,m+=g);var y=c.parentNode;c=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!d&&c!==document.body||d&&(t.contains(c)||t===c));return(u&&Math.abs(p)<1||!u&&Math.abs(m)<1)&&(f=!0),f},ar=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Hi=function(e){return[e.deltaX,e.deltaY]},zi=function(e){return e&&"current"in e?e.current:e},Wg=function(e,t){return e[0]===t[0]&&e[1]===t[1]},jg=function(e){return`
55
+ `)},Fi=function(){var e=parseInt(document.body.getAttribute(Rt)||"0",10);return isFinite(e)?e:0},Dg=function(){l.useEffect(function(){return document.body.setAttribute(Rt,(Fi()+1).toString()),function(){var e=Fi()-1;e<=0?document.body.removeAttribute(Rt):document.body.setAttribute(Rt,e.toString())}},[])},Lg=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Dg();var s=l.useMemo(function(){return Pg(o)},[o]);return l.createElement(Og,{styles:Mg(s,!t,o,n?"":"!important")})},Ro=!1;if(typeof window<"u")try{var ar=Object.defineProperty({},"passive",{get:function(){return Ro=!0,!0}});window.addEventListener("test",ar,ar),window.removeEventListener("test",ar,ar)}catch{Ro=!1}var Kt=Ro?{passive:!1}:!1,Fg=function(e){return e.tagName==="TEXTAREA"},$i=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Fg(e)&&n[t]==="visible")},$g=function(e){return $i(e,"overflowY")},Bg=function(e){return $i(e,"overflowX")},Bi=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Ui(e,r);if(o){var s=Hi(e,r),a=s[1],c=s[2];if(a>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ug=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Hg=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Ui=function(e,t){return e==="v"?$g(t):Bg(t)},Hi=function(e,t){return e==="v"?Ug(t):Hg(t)},zg=function(e,t){return e==="h"&&t==="rtl"?-1:1},Wg=function(e,t,n,r,o){var s=zg(e,window.getComputedStyle(t).direction),a=s*r,c=n.target,d=t.contains(c),f=!1,u=a>0,p=0,m=0;do{if(!c)break;var v=Hi(e,c),g=v[0],h=v[1],b=v[2],w=h-b-s*g;(g||w)&&Ui(e,c)&&(p+=w,m+=g);var y=c.parentNode;c=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!d&&c!==document.body||d&&(t.contains(c)||t===c));return(u&&Math.abs(p)<1||!u&&Math.abs(m)<1)&&(f=!0),f},ir=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},zi=function(e){return[e.deltaX,e.deltaY]},Wi=function(e){return e&&"current"in e?e.current:e},Vg=function(e,t){return e[0]===t[0]&&e[1]===t[1]},jg=function(e){return`
56
56
  .block-interactivity-`.concat(e,` {pointer-events: none;}
57
57
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
58
- `)},Vg=0,Kt=[];function Rg(e){var t=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),o=l.useState(Vg++)[0],s=l.useState(Di)[0],a=l.useRef(e);l.useEffect(function(){a.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=fg([e.lockRef.current],(e.shards||[]).map(zi),!0).filter(Boolean);return h.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(h,b){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!a.current.allowPinchZoom;var w=ar(h),y=n.current,x="deltaX"in h?h.deltaX:y[0]-w[0],C="deltaY"in h?h.deltaY:y[1]-w[1],E,P=h.target,T=Math.abs(x)>Math.abs(C)?"h":"v";if("touches"in h&&T==="h"&&P.type==="range")return!1;var F=$i(T,P);if(!F)return!0;if(F?E=T:(E=T==="v"?"h":"v",F=$i(T,P)),!F)return!1;if(!r.current&&"changedTouches"in h&&(x||C)&&(r.current=E),!E)return!0;var M=r.current||E;return zg(M,b,h,M==="h"?x:C)},[]),d=l.useCallback(function(h){var b=h;if(!(!Kt.length||Kt[Kt.length-1]!==s)){var w="deltaY"in b?Hi(b):ar(b),y=t.current.filter(function(E){return E.name===b.type&&(E.target===b.target||b.target===E.shadowParent)&&Wg(E.delta,w)})[0];if(y&&y.should){b.cancelable&&b.preventDefault();return}if(!y){var x=(a.current.shards||[]).map(zi).filter(Boolean).filter(function(E){return E.contains(b.target)}),C=x.length>0?c(b,x[0]):!a.current.noIsolation;C&&b.cancelable&&b.preventDefault()}}},[]),f=l.useCallback(function(h,b,w,y){var x={name:h,delta:b,target:w,should:y,shadowParent:Kg(w)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(C){return C!==x})},1)},[]),u=l.useCallback(function(h){n.current=ar(h),r.current=void 0},[]),p=l.useCallback(function(h){f(h.type,Hi(h),h.target,c(h,e.lockRef.current))},[]),m=l.useCallback(function(h){f(h.type,ar(h),h.target,c(h,e.lockRef.current))},[]);l.useEffect(function(){return Kt.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",d,Rt),document.addEventListener("touchmove",d,Rt),document.addEventListener("touchstart",u,Rt),function(){Kt=Kt.filter(function(h){return h!==s}),document.removeEventListener("wheel",d,Rt),document.removeEventListener("touchmove",d,Rt),document.removeEventListener("touchstart",u,Rt)}},[]);var v=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(s,{styles:jg(o)}):null,v?l.createElement(Dg,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Kg(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Gg=xg(Mi,Rg);var ir=l.forwardRef(function(e,t){return l.createElement(or,ct({},e,{ref:t,sideCar:Gg}))});ir.classNames=or.classNames;var Ro=["Enter"," "],qg=["ArrowDown","PageUp","Home"],Wi=["ArrowUp","PageDown","End"],Xg=[...qg,...Wi],Yg={ltr:[...Ro,"ArrowRight"],rtl:[...Ro,"ArrowLeft"]},Jg={ltr:["ArrowLeft"],rtl:["ArrowRight"]},fn="Menu",[pn,Zg,Qg]=ho(fn),[At,ji]=Re(fn,[Qg,Wt,Ei]),cr=Wt(),Vi=Ei(),[em,It]=At(fn),[tm,hn]=At(fn),Ri=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:a=!0}=e,c=cr(t),[d,f]=l.useState(null),u=l.useRef(!1),p=Ae(s),m=zn(o);return l.useEffect(()=>{const v=()=>{u.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>u.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),i.jsx(Mo,{...c,children:i.jsx(em,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:f,children:i.jsx(tm,{scope:t,onClose:l.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:u,dir:m,modal:a,children:r})})})};Ri.displayName=fn;var nm="MenuAnchor",Ko=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=cr(n);return i.jsx(Do,{...o,...r,ref:t})});Ko.displayName=nm;var Go="MenuPortal",[rm,Ki]=At(Go,{forceMount:void 0}),Gi=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=It(Go,t);return i.jsx(rm,{scope:t,forceMount:n,children:i.jsx(Le,{present:n||s.open,children:i.jsx(Qn,{asChild:!0,container:o,children:r})})})};Gi.displayName=Go;var ze="MenuContent",[om,qo]=At(ze),qi=l.forwardRef((e,t)=>{const n=Ki(ze,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=It(ze,e.__scopeMenu),a=hn(ze,e.__scopeMenu);return i.jsx(pn.Provider,{scope:e.__scopeMenu,children:i.jsx(Le,{present:r||s.open,children:i.jsx(pn.Slot,{scope:e.__scopeMenu,children:a.modal?i.jsx(sm,{...o,ref:t}):i.jsx(am,{...o,ref:t})})})})}),sm=l.forwardRef((e,t)=>{const n=It(ze,e.__scopeMenu),r=l.useRef(null),o=ue(t,r);return l.useEffect(()=>{const s=r.current;if(s)return Ho(s)},[]),i.jsx(Xo,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:U(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),am=l.forwardRef((e,t)=>{const n=It(ze,e.__scopeMenu);return i.jsx(Xo,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),im=Be.createSlot("MenuContent.ScrollLock"),Xo=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:m,onDismiss:v,disableOutsideScroll:g,...h}=e,b=It(ze,n),w=hn(ze,n),y=cr(n),x=Vi(n),C=Zg(n),[E,P]=l.useState(null),T=l.useRef(null),F=ue(t,T,b.onContentChange),M=l.useRef(0),B=l.useRef(""),j=l.useRef(0),Q=l.useRef(null),H=l.useRef("right"),O=l.useRef(0),ne=g?ir:l.Fragment,L=g?{as:im,allowPinchZoom:!0}:void 0,z=I=>{var R,le;const ee=B.current+I,V=C().filter(he=>!he.disabled),te=document.activeElement,D=(R=V.find(he=>he.ref.current===te))==null?void 0:R.textValue,W=V.map(he=>he.textValue),xe=wm(W,ee,D),ie=(le=V.find(he=>he.textValue===xe))==null?void 0:le.ref.current;(function he(de){B.current=de,window.clearTimeout(M.current),de!==""&&(M.current=window.setTimeout(()=>he(""),1e3))})(ee),ie&&setTimeout(()=>ie.focus())};l.useEffect(()=>()=>window.clearTimeout(M.current),[]),bo();const k=l.useCallback(I=>{var V,te;return H.current===((V=Q.current)==null?void 0:V.side)&&xm(I,(te=Q.current)==null?void 0:te.area)},[]);return i.jsx(om,{scope:n,searchRef:B,onItemEnter:l.useCallback(I=>{k(I)&&I.preventDefault()},[k]),onItemLeave:l.useCallback(I=>{var ee;k(I)||((ee=T.current)==null||ee.focus(),P(null))},[k]),onTriggerLeave:l.useCallback(I=>{k(I)&&I.preventDefault()},[k]),pointerGraceTimerRef:j,onPointerGraceIntentChange:l.useCallback(I=>{Q.current=I},[]),children:i.jsx(ne,{...L,children:i.jsx(Wn,{asChild:!0,trapped:o,onMountAutoFocus:U(s,I=>{var ee;I.preventDefault(),(ee=T.current)==null||ee.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:i.jsx(an,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:m,onDismiss:v,children:i.jsx(ig,{asChild:!0,...x,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:P,onEntryFocus:U(d,I=>{w.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:i.jsx(Lo,{role:"menu","aria-orientation":"vertical","data-state":uc(b.open),"data-radix-menu-content":"",dir:w.dir,...y,...h,ref:F,style:{outline:"none",...h.style},onKeyDown:U(h.onKeyDown,I=>{const V=I.target.closest("[data-radix-menu-content]")===I.currentTarget,te=I.ctrlKey||I.altKey||I.metaKey,D=I.key.length===1;V&&(I.key==="Tab"&&I.preventDefault(),!te&&D&&z(I.key));const W=T.current;if(I.target!==W||!Xg.includes(I.key))return;I.preventDefault();const ie=C().filter(R=>!R.disabled).map(R=>R.ref.current);Wi.includes(I.key)&&ie.reverse(),bm(ie)}),onBlur:U(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(M.current),B.current="")}),onPointerMove:U(e.onPointerMove,mn(I=>{const ee=I.target,V=O.current!==I.clientX;if(I.currentTarget.contains(ee)&&V){const te=I.clientX>O.current?"right":"left";H.current=te,O.current=I.clientX}}))})})})})})})});qi.displayName=ze;var cm="MenuGroup",Yo=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(oe.div,{role:"group",...r,ref:t})});Yo.displayName=cm;var lm="MenuLabel",Xi=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(oe.div,{...r,ref:t})});Xi.displayName=lm;var lr="MenuItem",Yi="menu.itemSelect",dr=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=l.useRef(null),a=hn(lr,e.__scopeMenu),c=qo(lr,e.__scopeMenu),d=ue(t,s),f=l.useRef(!1),u=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(Yi,{bubbles:!0,cancelable:!0});p.addEventListener(Yi,v=>r==null?void 0:r(v),{once:!0}),Na(p,m),m.defaultPrevented?f.current=!1:a.onClose()}};return i.jsx(Ji,{...o,ref:d,disabled:n,onClick:U(e.onClick,u),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),f.current=!0},onPointerUp:U(e.onPointerUp,p=>{var m;f.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:U(e.onKeyDown,p=>{const m=c.searchRef.current!=="";n||m&&p.key===" "||Ro.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});dr.displayName=lr;var Ji=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,a=qo(lr,n),c=Vi(n),d=l.useRef(null),f=ue(t,d),[u,p]=l.useState(!1),[m,v]=l.useState("");return l.useEffect(()=>{const g=d.current;g&&v((g.textContent??"").trim())},[s.children]),i.jsx(pn.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:i.jsx(cg,{asChild:!0,...c,focusable:!r,children:i.jsx(oe.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:f,onPointerMove:U(e.onPointerMove,mn(g=>{r?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:U(e.onPointerLeave,mn(g=>a.onItemLeave(g))),onFocus:U(e.onFocus,()=>p(!0)),onBlur:U(e.onBlur,()=>p(!1))})})})}),dm="MenuCheckboxItem",Zi=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return i.jsx(rc,{scope:e.__scopeMenu,checked:n,children:i.jsx(dr,{role:"menuitemcheckbox","aria-checked":ur(n)?"mixed":n,...o,ref:t,"data-state":Zo(n),onSelect:U(o.onSelect,()=>r==null?void 0:r(ur(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Zi.displayName=dm;var Qi="MenuRadioGroup",[um,fm]=At(Qi,{value:void 0,onValueChange:()=>{}}),ec=l.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Ae(r);return i.jsx(um,{scope:e.__scopeMenu,value:n,onValueChange:s,children:i.jsx(Yo,{...o,ref:t})})});ec.displayName=Qi;var tc="MenuRadioItem",nc=l.forwardRef((e,t)=>{const{value:n,...r}=e,o=fm(tc,e.__scopeMenu),s=n===o.value;return i.jsx(rc,{scope:e.__scopeMenu,checked:s,children:i.jsx(dr,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Zo(s),onSelect:U(r.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,n)},{checkForDefaultPrevented:!1})})})});nc.displayName=tc;var Jo="MenuItemIndicator",[rc,pm]=At(Jo,{checked:!1}),oc=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=pm(Jo,n);return i.jsx(Le,{present:r||ur(s.checked)||s.checked===!0,children:i.jsx(oe.span,{...o,ref:t,"data-state":Zo(s.checked)})})});oc.displayName=Jo;var hm="MenuSeparator",sc=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(oe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});sc.displayName=hm;var gm="MenuArrow",ac=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=cr(n);return i.jsx(Fo,{...o,...r,ref:t})});ac.displayName=gm;var mm="MenuSub",[oy,ic]=At(mm),gn="MenuSubTrigger",cc=l.forwardRef((e,t)=>{const n=It(gn,e.__scopeMenu),r=hn(gn,e.__scopeMenu),o=ic(gn,e.__scopeMenu),s=qo(gn,e.__scopeMenu),a=l.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=s,f={__scopeMenu:e.__scopeMenu},u=l.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return l.useEffect(()=>u,[u]),l.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),d(null)}},[c,d]),i.jsx(Ko,{asChild:!0,...f,children:i.jsx(Ji,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":uc(n.open),...e,ref:co(t,o.onTriggerChange),onClick:p=>{var m;(m=e.onClick)==null||m.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:U(e.onPointerMove,mn(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!a.current&&(s.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:U(e.onPointerLeave,mn(p=>{var v,g;u();const m=(v=n.content)==null?void 0:v.getBoundingClientRect();if(m){const h=(g=n.content)==null?void 0:g.dataset.side,b=h==="right",w=b?-5:5,y=m[b?"left":"right"],x=m[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+w,y:p.clientY},{x:y,y:m.top},{x,y:m.top},{x,y:m.bottom},{x:y,y:m.bottom}],side:h}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:U(e.onKeyDown,p=>{var v;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||Yg[r.dir].includes(p.key)&&(n.onOpenChange(!0),(v=n.content)==null||v.focus(),p.preventDefault())})})})});cc.displayName=gn;var lc="MenuSubContent",dc=l.forwardRef((e,t)=>{const n=Ki(ze,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=It(ze,e.__scopeMenu),a=hn(ze,e.__scopeMenu),c=ic(lc,e.__scopeMenu),d=l.useRef(null),f=ue(t,d);return i.jsx(pn.Provider,{scope:e.__scopeMenu,children:i.jsx(Le,{present:r||s.open,children:i.jsx(pn.Slot,{scope:e.__scopeMenu,children:i.jsx(Xo,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:f,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var p;a.isUsingKeyboardRef.current&&((p=d.current)==null||p.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:U(e.onFocusOutside,u=>{u.target!==c.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:U(e.onEscapeKeyDown,u=>{a.onClose(),u.preventDefault()}),onKeyDown:U(e.onKeyDown,u=>{var v;const p=u.currentTarget.contains(u.target),m=Jg[a.dir].includes(u.key);p&&m&&(s.onOpenChange(!1),(v=c.trigger)==null||v.focus(),u.preventDefault())})})})})})});dc.displayName=lc;function uc(e){return e?"open":"closed"}function ur(e){return e==="indeterminate"}function Zo(e){return ur(e)?"indeterminate":e?"checked":"unchecked"}function bm(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function vm(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function wm(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let a=vm(e,Math.max(s,0));o.length===1&&(a=a.filter(f=>f!==n));const d=a.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function ym(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const c=t[s],d=t[a],f=c.x,u=c.y,p=d.x,m=d.y;u>r!=m>r&&n<(p-f)*(r-u)/(m-u)+f&&(o=!o)}return o}function xm(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return ym(n,t)}function mn(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Sm=Ri,Cm=Ko,Em=Gi,Nm=qi,Tm=Yo,Am=Xi,Im=dr,km=Zi,_m=ec,Pm=nc,Om=oc,Mm=sc,Dm=ac,Lm=cc,Fm=dc,fr="DropdownMenu",[$m,sy]=Re(fr,[ji]),Oe=ji(),[Bm,fc]=$m(fr),pc=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:a,modal:c=!0}=e,d=Oe(t),f=l.useRef(null),[u,p]=gt({prop:o,defaultProp:s??!1,onChange:a,caller:fr});return i.jsx(Bm,{scope:t,triggerId:Ke(),triggerRef:f,contentId:Ke(),open:u,onOpenChange:p,onOpenToggle:l.useCallback(()=>p(m=>!m),[p]),modal:c,children:i.jsx(Sm,{...d,open:u,onOpenChange:p,dir:r,modal:c,children:n})})};pc.displayName=fr;var hc="DropdownMenuTrigger",gc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=fc(hc,n),a=Oe(n);return i.jsx(Cm,{asChild:!0,...a,children:i.jsx(oe.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:co(t,s.triggerRef),onPointerDown:U(e.onPointerDown,c=>{!r&&c.button===0&&c.ctrlKey===!1&&(s.onOpenToggle(),s.open||c.preventDefault())}),onKeyDown:U(e.onKeyDown,c=>{r||(["Enter"," "].includes(c.key)&&s.onOpenToggle(),c.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});gc.displayName=hc;var Um="DropdownMenuPortal",mc=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Oe(t);return i.jsx(Em,{...r,...n})};mc.displayName=Um;var bc="DropdownMenuContent",vc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=fc(bc,n),s=Oe(n),a=l.useRef(!1);return i.jsx(Nm,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:U(e.onCloseAutoFocus,c=>{var d;a.current||(d=o.triggerRef.current)==null||d.focus(),a.current=!1,c.preventDefault()}),onInteractOutside:U(e.onInteractOutside,c=>{const d=c.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,u=d.button===2||f;(!o.modal||u)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});vc.displayName=bc;var Hm="DropdownMenuGroup",zm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Tm,{...o,...r,ref:t})});zm.displayName=Hm;var Wm="DropdownMenuLabel",wc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Am,{...o,...r,ref:t})});wc.displayName=Wm;var jm="DropdownMenuItem",yc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Im,{...o,...r,ref:t})});yc.displayName=jm;var Vm="DropdownMenuCheckboxItem",xc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(km,{...o,...r,ref:t})});xc.displayName=Vm;var Rm="DropdownMenuRadioGroup",Km=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(_m,{...o,...r,ref:t})});Km.displayName=Rm;var Gm="DropdownMenuRadioItem",Sc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Pm,{...o,...r,ref:t})});Sc.displayName=Gm;var qm="DropdownMenuItemIndicator",Cc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Om,{...o,...r,ref:t})});Cc.displayName=qm;var Xm="DropdownMenuSeparator",Ec=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Mm,{...o,...r,ref:t})});Ec.displayName=Xm;var Ym="DropdownMenuArrow",Jm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Dm,{...o,...r,ref:t})});Jm.displayName=Ym;var Zm="DropdownMenuSubTrigger",Nc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Lm,{...o,...r,ref:t})});Nc.displayName=Zm;var Qm="DropdownMenuSubContent",Tc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Fm,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Tc.displayName=Qm;var eb=pc,tb=gc,nb=mc,Ac=vc,Ic=wc,kc=yc,_c=xc,Pc=Sc,Oc=Cc,Mc=Ec,Dc=Nc,Lc=Tc;const rb=eb,ob=tb,sb=l.forwardRef(({className:e,inset:t,children:n,...r},o)=>i.jsxs(Dc,{ref:o,className:A("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,i.jsx(q.ChevronRight,{className:"ml-auto h-4 w-4"})]}));sb.displayName=Dc.displayName;const ab=l.forwardRef(({className:e,...t},n)=>i.jsx(Lc,{ref:n,className:A("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",e),...t}));ab.displayName=Lc.displayName;const Fc=l.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(nb,{children:i.jsx(Ac,{ref:r,sideOffset:t,className:A("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",e),...n})}));Fc.displayName=Ac.displayName;const $c=l.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(kc,{ref:r,className:A("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));$c.displayName=kc.displayName;const ib=l.forwardRef(({className:e,children:t,checked:n,...r},o)=>i.jsxs(_c,{ref:o,className:A("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Oc,{children:i.jsx(q.Check,{className:"h-4 w-4"})})}),t]}));ib.displayName=_c.displayName;const cb=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(Pc,{ref:r,className:A("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Oc,{children:i.jsx(q.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));cb.displayName=Pc.displayName;const lb=l.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(Ic,{ref:r,className:A("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));lb.displayName=Ic.displayName;const db=l.forwardRef(({className:e,...t},n)=>i.jsx(Mc,{ref:n,className:A("-mx-1 my-1 h-px bg-muted",e),...t}));db.displayName=Mc.displayName;function bn({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=40,enableFileUpload:s=!0,enableMessageEditing:a=!0,customStyles:c={},onMessageSent:d,onError:f}){const{currentThreadId:u,messages:p,isStreaming:m,streamingAssistantId:v,error:g,send:h,stop:b,lastCheckpointId:w,lastBranchEvent:y,listCheckpoints:x,navigateToCheckpoint:C,returnToLatest:E,hasMoreHistory:P,isLoadingHistory:T,loadOlderMessages:F}=io(),[M,B]=N.useState(""),[j,Q]=N.useState(null),[H,O]=N.useState(null),[ne,L]=N.useState([]),[z,k]=N.useState(!1),[I,ee]=N.useState([]),[V,te]=N.useState(null),[D,W]=N.useState({}),xe=N.useRef(null),ie=N.useRef(null),R=N.useRef(null),le=N.useRef(null),he=N.useRef(!1),de=N.useRef(!0),be=N.useRef(0),ge=N.useRef(null),[G,Y]=N.useState("desktop");N.useEffect(()=>{const _=()=>{const $=window.innerWidth;Y($<640?"phone":$<1024?"tablet":"desktop")};return _(),window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]),N.useEffect(()=>{W({}),ge.current=null},[u]);const ye=N.useCallback(_=>{if(!_.length)return[];let $=null,K=-1/0,J=null,re=-1/0;for(const X of _){const Te=typeof X.createdAt=="number"?X.createdAt:null;if(X.parentCheckpointId===null){($==null||(Te??-1/0)>K)&&($=X,K=Te??-1/0);continue}if(X.parentCheckpointId!==null){const pe=Te??(X.checkpointId?Number.MAX_SAFE_INTEGER:-1/0);(J==null||pe>re)&&(J=X,re=pe)}}const Z=[];return $&&Z.push({...$}),J&&Z.push({...J}),Z},[]),se=N.useCallback(_=>{const $=new Map;for(const Z of _)Z.checkpointId&&$.set(Z.checkpointId,Z);const K={},J=Z=>(K[Z]||(K[Z]=[]),K[Z]),re=(Z,X)=>{const Te=X.checkpointId??"__root__",pe=Z.find(Ee=>(Ee.checkpointId??"__root__")===Te);if(pe){X.parentCheckpointId!==void 0&&pe.parentCheckpointId==null&&(pe.parentCheckpointId=X.parentCheckpointId),X.branchLabel&&!pe.branchLabel&&(pe.branchLabel=X.branchLabel),X.createdAt!==void 0&&X.createdAt!==null&&(pe.createdAt=X.createdAt);return}Z.push({...X})};for(const Z of _){const X=Z.editedMessageId??void 0;if(!X)continue;const Te=J(X),pe=Z.parentId??null,Ee=pe?$.get(pe):void 0,Ze=(Ee==null?void 0:Ee.branchLabel)??(Ee==null?void 0:Ee.preview)??"Original",Br=Ee!=null&&Ee.createdAt?new Date(Ee.createdAt).getTime():null;re(Te,{checkpointId:pe,parentCheckpointId:null,branchLabel:Ze,createdAt:Br});const Pe=Z.branchLabel??Z.preview??void 0,Qe=Z.createdAt?new Date(Z.createdAt).getTime():null;re(Te,{checkpointId:Z.checkpointId??null,parentCheckpointId:pe,branchLabel:Pe,createdAt:Qe})}for(const Z of Object.keys(K))K[Z]=ye(K[Z]);return K},[ye]),Se=N.useCallback((_,$)=>{const K={},J=(re,Z)=>{if(!(Z!=null&&Z.length))return;const X=K[re]??[],Te=new Map;for(const pe of X)Te.set(pe.checkpointId??"__root__",pe);for(const pe of Z){const Ee=pe.checkpointId??"__root__",Ze=Te.get(Ee);Ze?(pe.parentCheckpointId!==void 0&&Ze.parentCheckpointId==null&&(Ze.parentCheckpointId=pe.parentCheckpointId),pe.branchLabel&&!Ze.branchLabel&&(Ze.branchLabel=pe.branchLabel),pe.createdAt!==void 0&&pe.createdAt!==null&&(Ze.createdAt=pe.createdAt)):(X.push({...pe}),Te.set(Ee,X[X.length-1]))}K[re]=X};for(const[re,Z]of Object.entries(_))J(re,Z);for(const[re,Z]of Object.entries($))J(re,Z);for(const re of Object.keys(K))K[re]=ye(K[re]);return K},[ye]),fe=N.useCallback(async()=>{if(!P||T)return;const _=le.current;if(!_)return;const $=_.scrollHeight,K=_.scrollTop;he.current=!0;try{await F()}catch(J){console.warn("loadOlderMessages failed",J)}finally{requestAnimationFrame(()=>{const J=le.current;if(!J){he.current=!1;return}const re=J.scrollHeight;J.scrollTop=K+(re-$);const Z=re-J.scrollTop-J.clientHeight;de.current=Z<=32,he.current=!1})}},[P,T,F]);N.useEffect(()=>{const _=le.current;if(!_)return;const $=()=>{_.scrollTop<=80&&fe();const re=_.scrollHeight-_.scrollTop-_.clientHeight;de.current=re<=80};return _.addEventListener("scroll",$),()=>_.removeEventListener("scroll",$)},[fe]),N.useEffect(()=>{p.length<be.current&&(de.current=!0),be.current=p.length},[p.length]),N.useEffect(()=>{const _=le.current;_&&(he.current||de.current&&(_.scrollTop=_.scrollHeight,de.current=!0))},[p]),N.useEffect(()=>{var _;n&&((_=ie.current)==null||_.focus())},[n]),N.useEffect(()=>{g&&!z&&(f==null||f(g))},[g,z,f]),N.useEffect(()=>{let _=!0;if(!u){ee([]),te(null),W({});return}return x(u).then($=>{var Z;if(!_)return;const K=$.checkpoints||[];ee(K);const J=se(K);W(X=>Se(J,X));const re=((Z=K.slice().sort((X,Te)=>new Date(Te.createdAt).getTime()-new Date(X.createdAt).getTime())[0])==null?void 0:Z.checkpointId)||null;te(X=>X??re)}).catch(()=>{}),()=>{_=!1}},[u,x,se,Se]),N.useEffect(()=>{w&&te(w)},[w]);const ve=_=>{if(_.length>$t)return`Message too long (${_.length}/${$t} characters)`;try{return gp(_),null}catch($){return($==null?void 0:$.message)||"Invalid message"}},_e=_=>{const $=_.content||[],K=$.filter(J=>J.type==="text").map(J=>J.text).join("");if(K)return K;try{return JSON.stringify($,null,2)}catch{return String($)}},Fe=N.useMemo(()=>{const _=new Map;for(const $ of I)$!=null&&$.checkpointId&&_.set($.checkpointId,$);return _},[I]);N.useEffect(()=>{if(!y)return;const _=[y.editedMessageId??"",y.parentCheckpointId??"",y.checkpointId??""].join("::");if(ge.current===_)return;ge.current=_;const $=y.editedMessageId;$&&W(K=>{const J=K[$]??[],re=new Map;for(const Pe of J){const Qe=Pe.checkpointId??"__root__";re.set(Qe,Pe)}const Z=(Pe,Qe,Ur,Hr)=>{if(Pe===void 0)return;const zr=Pe??"__root__",et=re.get(zr);re.set(zr,{checkpointId:Pe,parentCheckpointId:Qe??(et==null?void 0:et.parentCheckpointId)??null,branchLabel:Ur??(et==null?void 0:et.branchLabel)??null,createdAt:Hr??(et==null?void 0:et.createdAt)??null})},X=y.parentCheckpointId?Fe.get(y.parentCheckpointId):void 0,Te=X!=null&&X.createdAt?new Date(X.createdAt).getTime():null;if(y.parentCheckpointId){const Pe=re.get(y.parentCheckpointId),Qe=(Pe==null?void 0:Pe.branchLabel)??(X==null?void 0:X.preview)??"Original";Z(y.parentCheckpointId,null,Qe,Te)}const pe=y.checkpointId?Fe.get(y.checkpointId):void 0,Ee=pe!=null&&pe.createdAt?new Date(pe.createdAt).getTime():Date.now();Z(y.checkpointId??null,y.parentCheckpointId??null,y.branchLabel??(pe==null?void 0:pe.preview)??null,Ee);const Ze=Array.from(re.values()),Br=y.parentCheckpointId??null;return Ze.sort((Pe,Qe)=>{if(Pe.checkpointId===Br)return-1;if(Qe.checkpointId===Br)return 1;const Ur=Pe.checkpointId?Fe.get(Pe.checkpointId):void 0,Hr=Qe.checkpointId?Fe.get(Qe.checkpointId):void 0,zr=Ur?new Date(Ur.createdAt).getTime():Number.MAX_SAFE_INTEGER,et=Hr?new Date(Hr.createdAt).getTime():Number.MAX_SAFE_INTEGER;return zr-et}),{...K,[$]:ye(Ze)}})},[y,Fe,ye]);const pt=_=>{const $=p[_],K=$==null?void 0:$.id;if(!K)return[];const J=D[K];return J!=null&&J.length?J.map((re,Z)=>{const X=re.checkpointId?Fe.get(re.checkpointId):void 0,Te=X?new Date(X.createdAt).getTime():void 0,pe=re.checkpointId?re.checkpointId===V:!V,Ee=Z===0?"Original":`Branch ${Z}`;return{checkpoint_id:re.checkpointId,checkpoint_ns:X==null?void 0:X.checkpointNs,message_count:(X==null?void 0:X.messagesLen)??0,last_message_preview:(X==null?void 0:X.preview)??void 0,ts:Te,isCurrent:pe,label:re.branchLabel??(X==null?void 0:X.preview)??Ee}}):[]},Cs=_=>{var Z;if(_===void 0)return{canGoBack:!1,canGoForward:!1,currentIndex:0,totalBranches:0,currentLabel:null};const $=pt(_);if($.length<=1)return{canGoBack:!1,canGoForward:!1,currentIndex:0,totalBranches:$.length,currentLabel:((Z=$[0])==null?void 0:Z.label)??null};const K=$.findIndex(X=>X.isCurrent),J=K>=0?K:0,re=$[J]??null;return{canGoBack:J>0,canGoForward:J<$.length-1,currentIndex:J,totalBranches:$.length,currentLabel:(re==null?void 0:re.label)??null}},Cn=async()=>{const _=M.trim();if(!_&&ne.length===0)return;const $=ve(_);if($){O($);return}try{const K=window.__editingCheckpointId||V||void 0;await h(_,{checkpointId:K,payloadExtras:j?{edit:!0,originalMessageId:j}:void 0,attachments:ne}),d==null||d(_),B(""),O(null),L([]),delete window.__editingCheckpointId,Q(null),ie.current&&(ie.current.style.height="auto")}catch(K){const J=(K==null?void 0:K.message)||"Failed to send message";O(J),f==null||f(J)}},Es=(_,$)=>{a&&(Q(_),B($),O(null),setTimeout(()=>{ie.current&&(ie.current.focus(),ie.current.style.height="auto",ie.current.style.height=ie.current.scrollHeight+"px")},0))},Lr=async(_,$)=>{const K=p.find(re=>re.id===_);if(!K){O("Message not found");return}const J=_e(K);Q(_),B(J),window.__editingCheckpointId=$,setTimeout(()=>{var re;return(re=ie.current)==null?void 0:re.focus()},0)},En=()=>{Q(null),B(""),O(null),delete window.__editingCheckpointId,ie.current&&(ie.current.style.height="auto")},Ns=_=>{_.key==="Enter"&&!_.shiftKey?(_.preventDefault(),Cn()):_.key==="Escape"&&j&&(_.preventDefault(),En())},Fr=_=>{const $=Array.from(_.target.files||[]);L(K=>[...K,...$])},me=_=>L($=>$.filter((K,J)=>_!==J)),Ie=async _=>{if(u){if(!_){await E(),te(null);return}await C(_),te(_)}},$e=async()=>{await E(),te(null)},Je=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${c.container||""}`,ht=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-y-auto overflow-x-auto overscroll-contain break-words break-anywhere p-4 space-y-4 bg-transparent ${c.messagesArea||""}`,$r=`flex-shrink-0 w-full border-t p-4 bg-transparent ${c.inputArea||""}`;return i.jsxs("div",{className:Je,children:[!!g&&!z&&i.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[i.jsx("span",{children:g}),i.jsx(we,{variant:"ghost",size:"sm",onClick:()=>k(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:i.jsx(q.X,{size:16})})]}),u&&I.length>0&&i.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[i.jsx(q.GitBranch,{className:"h-4 w-4 opacity-70"}),i.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),i.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:V??"",onChange:_=>{const $=_.target.value||null;Ie($)},children:[i.jsx("option",{value:"",children:"Latest"}),I.slice().sort((_,$)=>new Date($.createdAt).getTime()-new Date(_.createdAt).getTime()).map(_=>i.jsxs("option",{value:_.checkpointId,children:[new Date(_.createdAt).toLocaleString(),_.preview?` — ${_.preview.slice(0,30)}`:""]},_.checkpointId))]})]}),i.jsxs("div",{ref:le,className:ht,style:r?{maxHeight:r}:void 0,children:[p.length===0?i.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:"No messages yet. Start a conversation!"}):i.jsxs(i.Fragment,{children:[(T||!P)&&i.jsx("div",{className:"flex justify-center py-2 text-xs text-muted-foreground",children:T?i.jsx(q.Loader2,{className:"h-4 w-4 animate-spin"}):"You've reached the beginning"}),p.map((_,$)=>i.jsx(Pa,{message:_,messageIndex:$,isStreamingMessage:m&&v===_.id,streamingDebounceMs:o,isEditing:j===_.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:G,truncateToolMessages:!1,toolMessagePreviewLength:200,checkpointBranches:pt($),currentCheckpointId:V??void 0,temporalNavigation:Cs($),onSwitchToCheckpoint:Ie,onReturnToMainThread:$e,onNavigateToPreviousBranch:()=>{var re;const K=pt($),J=Math.max(0,K.findIndex(Z=>Z.isCurrent));if(J>0){const Z=((re=K[J-1])==null?void 0:re.checkpoint_id)??null;Ie(Z??null)}},onNavigateToNextBranch:()=>{var re;const K=pt($),J=Math.max(0,K.findIndex(Z=>Z.isCurrent));if(J>=0&&J<K.length-1){const Z=((re=K[J+1])==null?void 0:re.checkpoint_id)??null;Ie(Z??null)}},onEdit:(K,J)=>Es(K,J),onEditFromCheckpoint:Lr,onRegenerate:()=>{const K=[...p].reverse().find(re=>re.role==="user"),J=K?_e(K):"";J&&h(J,{checkpointId:V??void 0})},onCancelEdit:En},_.id||$))]}),i.jsx("div",{ref:xe})]}),i.jsxs("div",{className:$r,children:[j&&i.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(q.Edit3,{size:16,className:"text-blue-600"}),i.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),i.jsx(we,{variant:"ghost",size:"sm",onClick:En,className:"text-blue-600 hover:bg-blue-100",children:i.jsx(q.X,{size:16})})]})}),s&&i.jsxs("div",{className:"mb-3",children:[i.jsx("input",{ref:R,type:"file",multiple:!0,onChange:_=>Fr(_),className:"hidden"}),ne.length>0&&i.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:ne.map((_,$)=>i.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 rounded-lg px-3 py-2 text-sm",children:[i.jsx(q.Paperclip,{size:14}),i.jsx("span",{className:"truncate max-w-[150px]",children:_.name}),i.jsx(we,{variant:"ghost",size:"sm",onClick:()=>me($),className:"h-4 w-4 p-0 text-gray-500 hover:text-red-500","aria-label":`Remove ${_.name}`,children:i.jsx(q.X,{size:12})})]},$))})]}),H&&i.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:H}),i.jsxs("div",{className:"flex items-end gap-2",children:[s&&i.jsxs(rb,{children:[i.jsx(ob,{asChild:!0,children:i.jsx(we,{type:"button",size:"icon",variant:"outline",disabled:m,title:"More input actions",className:c.moreButton||"",children:i.jsx(q.Plus,{size:16})})}),i.jsx(Fc,{align:"start",sideOffset:6,className:"w-52",children:i.jsxs($c,{onClick:()=>{var _;return(_=R.current)==null?void 0:_.click()},className:"cursor-pointer",children:[i.jsx(q.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]})})]}),i.jsx("div",{className:"flex-1",children:i.jsx(Sa,{ref:ie,value:M,onChange:_=>{B(_.target.value),O(null),ie.current&&(ie.current.style.height="auto",ie.current.style.height=`${ie.current.scrollHeight}px`)},onKeyDown:Ns,placeholder:j?"Edit your message...":t,className:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${j?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${H?"border-red-400":""} ${c.textarea||""}`,disabled:!1,maxLength:$t,rows:1})}),i.jsx("div",{children:m?i.jsx(we,{type:"button",onClick:b,size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",children:i.jsx(q.Square,{size:16})}):i.jsx(we,{type:"button",onClick:Cn,size:"icon",disabled:!M.trim()&&ne.length===0,className:`shrink-0 ${c.sendButton||""}`,title:j?"Save changes":"Send message",children:i.jsx(q.Send,{size:16})})})]}),M.length>$t*.8&&i.jsxs("div",{className:"mt-2 text-xs text-gray-500 text-right",children:[M.length,"/",$t]})]})]})}const vn=l.forwardRef(({className:e,type:t,...n},r)=>i.jsx("input",{type:t,className:A("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));vn.displayName="Input";function Qo(e,[t,n]){return Math.min(n,Math.max(t,e))}function ub(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var es="ScrollArea",[Bc,ay]=Re(es),[fb,We]=Bc(es),Uc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...a}=e,[c,d]=l.useState(null),[f,u]=l.useState(null),[p,m]=l.useState(null),[v,g]=l.useState(null),[h,b]=l.useState(null),[w,y]=l.useState(0),[x,C]=l.useState(0),[E,P]=l.useState(!1),[T,F]=l.useState(!1),M=ue(t,j=>d(j)),B=zn(o);return i.jsx(fb,{scope:n,type:r,dir:B,scrollHideDelay:s,scrollArea:c,viewport:f,onViewportChange:u,content:p,onContentChange:m,scrollbarX:v,onScrollbarXChange:g,scrollbarXEnabled:E,onScrollbarXEnabledChange:P,scrollbarY:h,onScrollbarYChange:b,scrollbarYEnabled:T,onScrollbarYEnabledChange:F,onCornerWidthChange:y,onCornerHeightChange:C,children:i.jsx(oe.div,{dir:B,...a,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":x+"px",...e.style}})})});Uc.displayName=es;var Hc="ScrollAreaViewport",zc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,a=We(Hc,n),c=l.useRef(null),d=ue(t,c,a.onViewportChange);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),i.jsx(oe.div,{"data-radix-scroll-area-viewport":"",...s,ref:d,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:i.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});zc.displayName=Hc;var lt="ScrollAreaScrollbar",ts=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=We(lt,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:a}=o,c=e.orientation==="horizontal";return l.useEffect(()=>(c?s(!0):a(!0),()=>{c?s(!1):a(!1)}),[c,s,a]),o.type==="hover"?i.jsx(pb,{...r,ref:t,forceMount:n}):o.type==="scroll"?i.jsx(hb,{...r,ref:t,forceMount:n}):o.type==="auto"?i.jsx(Wc,{...r,ref:t,forceMount:n}):o.type==="always"?i.jsx(ns,{...r,ref:t}):null});ts.displayName=lt;var pb=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=We(lt,e.__scopeScrollArea),[s,a]=l.useState(!1);return l.useEffect(()=>{const c=o.scrollArea;let d=0;if(c){const f=()=>{window.clearTimeout(d),a(!0)},u=()=>{d=window.setTimeout(()=>a(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",f),c.addEventListener("pointerleave",u),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",f),c.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),i.jsx(Le,{present:n||s,children:i.jsx(Wc,{"data-state":s?"visible":"hidden",...r,ref:t})})}),hb=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=We(lt,e.__scopeScrollArea),s=e.orientation==="horizontal",a=mr(()=>d("SCROLL_END"),100),[c,d]=ub("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return l.useEffect(()=>{if(c==="idle"){const f=window.setTimeout(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(f)}},[c,o.scrollHideDelay,d]),l.useEffect(()=>{const f=o.viewport,u=s?"scrollLeft":"scrollTop";if(f){let p=f[u];const m=()=>{const v=f[u];p!==v&&(d("SCROLL"),a()),p=v};return f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[o.viewport,s,d,a]),i.jsx(Le,{present:n||c!=="hidden",children:i.jsx(ns,{"data-state":c==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:U(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:U(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Wc=l.forwardRef((e,t)=>{const n=We(lt,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,a]=l.useState(!1),c=e.orientation==="horizontal",d=mr(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;a(c?f:u)}},10);return Gt(n.viewport,d),Gt(n.content,d),i.jsx(Le,{present:r||s,children:i.jsx(ns,{"data-state":s?"visible":"hidden",...o,ref:t})})}),ns=l.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=We(lt,e.__scopeScrollArea),s=l.useRef(null),a=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=Gc(c.viewport,c.content),u={...r,sizes:c,onSizesChange:d,hasThumb:f>0&&f<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:m=>a.current=m};function p(m,v){return yb(m,a.current,c,v)}return n==="horizontal"?i.jsx(gb,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,v=qc(m,c,o.dir);s.current.style.transform=`translate3d(${v}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?i.jsx(mb,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,v=qc(m,c);s.current.style.transform=`translate3d(0, ${v}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),gb=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=We(lt,e.__scopeScrollArea),[a,c]=l.useState(),d=l.useRef(null),f=ue(t,d,s.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),i.jsx(Vc,{"data-orientation":"horizontal",...o,ref:f,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":gr(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(m),Yc(m,p)&&u.preventDefault()}},onResize:()=>{d.current&&s.viewport&&a&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:hr(a.paddingLeft),paddingEnd:hr(a.paddingRight)}})}})}),mb=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=We(lt,e.__scopeScrollArea),[a,c]=l.useState(),d=l.useRef(null),f=ue(t,d,s.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),i.jsx(Vc,{"data-orientation":"vertical",...o,ref:f,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":gr(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,p)=>{if(s.viewport){const m=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(m),Yc(m,p)&&u.preventDefault()}},onResize:()=>{d.current&&s.viewport&&a&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:hr(a.paddingTop),paddingEnd:hr(a.paddingBottom)}})}})}),[bb,jc]=Bc(lt),Vc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:a,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:f,onWheelScroll:u,onResize:p,...m}=e,v=We(lt,n),[g,h]=l.useState(null),b=ue(t,M=>h(M)),w=l.useRef(null),y=l.useRef(""),x=v.viewport,C=r.content-r.viewport,E=Ae(u),P=Ae(d),T=mr(p,10);function F(M){if(w.current){const B=M.clientX-w.current.left,j=M.clientY-w.current.top;f({x:B,y:j})}}return l.useEffect(()=>{const M=B=>{const j=B.target;(g==null?void 0:g.contains(j))&&E(B,C)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[x,g,C,E]),l.useEffect(P,[r,P]),Gt(g,T),Gt(v.content,T),i.jsx(bb,{scope:n,scrollbar:g,hasThumb:o,onThumbChange:Ae(s),onThumbPointerUp:Ae(a),onThumbPositionChange:P,onThumbPointerDown:Ae(c),children:i.jsx(oe.div,{...m,ref:b,style:{position:"absolute",...m.style},onPointerDown:U(e.onPointerDown,M=>{M.button===0&&(M.target.setPointerCapture(M.pointerId),w.current=g.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",v.viewport&&(v.viewport.style.scrollBehavior="auto"),F(M))}),onPointerMove:U(e.onPointerMove,F),onPointerUp:U(e.onPointerUp,M=>{const B=M.target;B.hasPointerCapture(M.pointerId)&&B.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=y.current,v.viewport&&(v.viewport.style.scrollBehavior=""),w.current=null})})})}),pr="ScrollAreaThumb",Rc=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=jc(pr,e.__scopeScrollArea);return i.jsx(Le,{present:n||o.hasThumb,children:i.jsx(vb,{ref:t,...r})})}),vb=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=We(pr,n),a=jc(pr,n),{onThumbPositionChange:c}=a,d=ue(t,p=>a.onThumbChange(p)),f=l.useRef(void 0),u=mr(()=>{f.current&&(f.current(),f.current=void 0)},100);return l.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(u(),!f.current){const v=xb(p,c);f.current=v,c()}};return c(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,u,c]),i.jsx(oe.div,{"data-state":a.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:U(e.onPointerDownCapture,p=>{const v=p.target.getBoundingClientRect(),g=p.clientX-v.left,h=p.clientY-v.top;a.onThumbPointerDown({x:g,y:h})}),onPointerUp:U(e.onPointerUp,a.onThumbPointerUp)})});Rc.displayName=pr;var rs="ScrollAreaCorner",Kc=l.forwardRef((e,t)=>{const n=We(rs,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?i.jsx(wb,{...e,ref:t}):null});Kc.displayName=rs;var wb=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=We(rs,n),[s,a]=l.useState(0),[c,d]=l.useState(0),f=!!(s&&c);return Gt(o.scrollbarX,()=>{var p;const u=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(u),d(u)}),Gt(o.scrollbarY,()=>{var p;const u=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(u),a(u)}),f?i.jsx(oe.div,{...r,ref:t,style:{width:s,height:c,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function hr(e){return e?parseInt(e,10):0}function Gc(e,t){const n=e/t;return isNaN(n)?0:n}function gr(e){const t=Gc(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function yb(e,t,n,r="ltr"){const o=gr(n),s=o/2,a=t||s,c=o-a,d=n.scrollbar.paddingStart+a,f=n.scrollbar.size-n.scrollbar.paddingEnd-c,u=n.content-n.viewport,p=r==="ltr"?[0,u]:[u*-1,0];return Xc([d,f],p)(e)}function qc(e,t,n="ltr"){const r=gr(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,a=t.content-t.viewport,c=s-r,d=n==="ltr"?[0,a]:[a*-1,0],f=Qo(e,d);return Xc([0,a],[0,c])(f)}function Xc(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Yc(e,t){return e>0&&e<t}var xb=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},a=n.left!==s.left,c=n.top!==s.top;(a||c)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function mr(e,t){const n=Ae(e),r=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(r.current),[]),l.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Gt(e,t){const n=Ae(t);Ne(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var Jc=Uc,Sb=zc,Cb=Kc;const Zc=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(Jc,{ref:r,className:A("relative overflow-hidden",e),...n,children:[i.jsx(Sb,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),i.jsx(Qc,{}),i.jsx(Cb,{})]}));Zc.displayName=Jc.displayName;const Qc=l.forwardRef(({className:e,orientation:t="vertical",...n},r)=>i.jsx(ts,{ref:r,orientation:t,className:A("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:i.jsx(Rc,{className:"relative flex-1 rounded-full bg-border"})}));Qc.displayName=ts.displayName;function br({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:a=null,navigateToThread:c,onThreadSelect:d,onThreadCreate:f,onThreadDelete:u}){const{loadThread:p,threads:m,refreshThreads:v,currentThreadId:g,createThread:h,deleteThread:b,renameThread:w}=io(),[y,x]=N.useState(m??[]),[C,E]=N.useState(!1),[P,T]=N.useState(null),[F,M]=N.useState(null),[B,j]=N.useState(""),[Q,H]=N.useState(!1);N.useEffect(()=>{x(m??[])},[m]);const O=async D=>{try{await p(D),c==null||c(D),d==null||d(D)}catch(W){console.error("Failed to select thread:",W)}},ne=async()=>{try{H(!0);const D=await h();f==null||f(D),c==null||c(D)}catch(D){console.error("Failed to create thread:",D)}finally{H(!1)}},L=async(D,W)=>{if(W.stopPropagation(),!!confirm("Delete this thread?"))try{await b(D),u==null||u(D)}catch(xe){console.error("Failed to delete thread:",xe)}},z=(D,W)=>{W.stopPropagation(),M(D.threadId),j(D.title||`Thread ${D.threadId.slice(0,8)}`)},k=async D=>{if(B.trim())try{await w(D,B.trim()),M(null),j("")}catch(W){console.error("Failed to update title:",W)}},I=()=>{M(null),j("")},ee=(D,W)=>{D.key==="Enter"?k(W):D.key==="Escape"&&I()},V=D=>{if(!D)return"";try{const W=new Date(D),ie=new Date().getTime()-W.getTime(),R=Math.floor(ie/(1e3*60*60*24));return R===0?W.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):R===1?"Yesterday":R<7?`${R} days ago`:W.toLocaleDateString()}catch{return""}},te=D=>D.title||`Thread ${D.threadId.slice(0,8)}`;return i.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&i.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:i.jsx(we,{onClick:ne,disabled:Q||C,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:Q?"Creating...":"New Chat",children:i.jsx(q.MessageSquarePlus,{size:20})})}),i.jsx(Zc,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:i.jsx("div",{className:"p-2 space-y-1 pb-4",children:C?i.jsx("div",{className:"text-center py-8 text-slate-400",children:"Loading…"}):y.length===0?i.jsxs("div",{className:"text-center py-8 text-slate-400",children:[i.jsx(q.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),i.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):y.slice().sort((D,W)=>new Date(W.updatedAt||W.createdAt||"").getTime()-new Date(D.updatedAt||D.createdAt||"").getTime()).map(D=>i.jsxs("div",{onClick:()=>O(D.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(a??g)===D.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{className:"flex-1 min-w-0",children:F===D.threadId?i.jsxs("div",{className:"flex items-center gap-2",onClick:W=>W.stopPropagation(),children:[i.jsx(vn,{value:B,onChange:W=>j(W.target.value),onKeyDown:W=>ee(W,D.threadId),className:"h-6 text-sm",autoFocus:!0}),i.jsx(we,{variant:"ghost",size:"sm",onClick:()=>k(D.threadId),className:"h-6 w-6 p-0",children:i.jsx(q.Check,{size:12})}),i.jsx(we,{variant:"ghost",size:"sm",onClick:I,className:"h-6 w-6 p-0",children:i.jsx(q.X,{size:12})})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:te(D)}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[i.jsx(q.Calendar,{size:10}),i.jsx("span",{children:V(D.updatedAt||D.createdAt)})]})]})}),i.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&F!==D.threadId&&i.jsx(we,{variant:"ghost",size:"sm",onClick:W=>z(D,W),className:"h-6 w-6 p-0",title:"Edit title",children:i.jsx(q.Edit3,{size:12})}),n&&i.jsx(we,{variant:"ghost",size:"sm",onClick:W=>L(D.threadId,W),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:i.jsx(q.Trash2,{size:12})})]})]}),a===D.threadId&&i.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},D.threadId))})})]})}const el=N.createContext(null);function Eb({children:e,basePath:t="/chat"}){const n=N.useMemo(()=>t?t==="/"?"":t.endsWith("/")?t.slice(0,-1):t:"/chat",[t]),r={basePath:n,buildThreadPath:o=>`${n}/${o}`,buildBasePath:()=>n};return i.jsx(el.Provider,{value:r,children:e})}function Nb(){const e=N.useContext(el);return e||{basePath:"/chat",buildThreadPath:t=>`/chat/${t}`,buildBasePath:()=>"/chat"}}const tl={BASE_URL:"/",DEV:!1,MODE:"library",PROD:!0,SSR:!1};function wn(e){var o;const t=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Wr&&Wr.tagName.toUpperCase()==="SCRIPT"&&Wr.src||new URL("index.umd.js",document.baseURI).href}<"u"&&tl?tl[e]:void 0,n=(o=globalThis==null?void 0:globalThis.process)==null?void 0:o.env,r=n?n[e]:void 0;return(t??r)||void 0}function Tb(){return wn("VITE_API_BASE_URL")||wn("NEXT_PUBLIC_API_BASE_URL")||void 0}function Ab(){return wn("VITE_API_KEY")||wn("NEXT_PUBLIC_API_KEY")||wn("VITE_AUTH_TOKEN")||void 0}function nl(){const e=Tb(),t=Ab(),n={};return e&&(n.baseUrl=e),t&&(n.apiKey=t),n}function rl(){const e=nl(),t=dt.getAuthToken();return{apiBaseUrl:e.baseUrl||dt.baseUrl||"http://localhost:8000",apiKey:t||e.apiKey||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const ol="chat-settings";function Ib(){try{const e=localStorage.getItem(ol);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function kb(e){try{localStorage.setItem(ol,JSON.stringify(e)),e.apiKey&&dt.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function _b(){const e=rl(),t=Ib(),n=dt.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:dt.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function Pb(e){e.apiKey&&dt.setAuthToken(e.apiKey),kb(e)}const os=768;function Ob(){const[e,t]=l.useState(void 0);return l.useEffect(()=>{const n=window.matchMedia(`(max-width: ${os-1}px)`),r=()=>{t(window.innerWidth<os)};return n.addEventListener("change",r),t(window.innerWidth<os),()=>n.removeEventListener("change",r)},[]),!!e}var Mb="Separator",sl="horizontal",Db=["horizontal","vertical"],al=l.forwardRef((e,t)=>{const{decorative:n,orientation:r=sl,...o}=e,s=Lb(r)?r:sl,c=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return i.jsx(oe.div,{"data-orientation":s,...c,...o,ref:t})});al.displayName=Mb;function Lb(e){return Db.includes(e)}var il=al;const ss=l.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>i.jsx(il,{ref:o,decorative:n,orientation:t,className:A("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ss.displayName=il.displayName;var vr="Dialog",[cl,iy]=Re(vr),[Fb,Xe]=cl(vr),ll=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:a=!0}=e,c=l.useRef(null),d=l.useRef(null),[f,u]=gt({prop:r,defaultProp:o??!1,onChange:s,caller:vr});return i.jsx(Fb,{scope:t,triggerRef:c,contentRef:d,contentId:Ke(),titleId:Ke(),descriptionId:Ke(),open:f,onOpenChange:u,onOpenToggle:l.useCallback(()=>u(p=>!p),[u]),modal:a,children:n})};ll.displayName=vr;var dl="DialogTrigger",ul=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Xe(dl,n),s=ue(t,o.triggerRef);return i.jsx(oe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":cs(o.open),...r,ref:s,onClick:U(e.onClick,o.onOpenToggle)})});ul.displayName=dl;var as="DialogPortal",[$b,fl]=cl(as,{forceMount:void 0}),pl=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Xe(as,t);return i.jsx($b,{scope:t,forceMount:n,children:l.Children.map(r,a=>i.jsx(Le,{present:n||s.open,children:i.jsx(Qn,{asChild:!0,container:o,children:a})}))})};pl.displayName=as;var wr="DialogOverlay",hl=l.forwardRef((e,t)=>{const n=fl(wr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Xe(wr,e.__scopeDialog);return s.modal?i.jsx(Le,{present:r||s.open,children:i.jsx(Ub,{...o,ref:t})}):null});hl.displayName=wr;var Bb=Be.createSlot("DialogOverlay.RemoveScroll"),Ub=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Xe(wr,n);return i.jsx(ir,{as:Bb,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(oe.div,{"data-state":cs(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),kt="DialogContent",gl=l.forwardRef((e,t)=>{const n=fl(kt,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Xe(kt,e.__scopeDialog);return i.jsx(Le,{present:r||s.open,children:s.modal?i.jsx(Hb,{...o,ref:t}):i.jsx(zb,{...o,ref:t})})});gl.displayName=kt;var Hb=l.forwardRef((e,t)=>{const n=Xe(kt,e.__scopeDialog),r=l.useRef(null),o=ue(t,n.contentRef,r);return l.useEffect(()=>{const s=r.current;if(s)return Ho(s)},[]),i.jsx(ml,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:U(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:U(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0;(a.button===2||c)&&s.preventDefault()}),onFocusOutside:U(e.onFocusOutside,s=>s.preventDefault())})}),zb=l.forwardRef((e,t)=>{const n=Xe(kt,e.__scopeDialog),r=l.useRef(!1),o=l.useRef(!1);return i.jsx(ml,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,c;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var d,f;(d=e.onInteractOutside)==null||d.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=s.target;((f=n.triggerRef.current)==null?void 0:f.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),ml=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=e,c=Xe(kt,n),d=l.useRef(null),f=ue(t,d);return bo(),i.jsxs(i.Fragment,{children:[i.jsx(Wn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:i.jsx(an,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":cs(c.open),...a,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(Wb,{titleId:c.titleId}),i.jsx(Vb,{contentRef:d,descriptionId:c.descriptionId})]})]})}),is="DialogTitle",bl=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Xe(is,n);return i.jsx(oe.h2,{id:o.titleId,...r,ref:t})});bl.displayName=is;var vl="DialogDescription",wl=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Xe(vl,n);return i.jsx(oe.p,{id:o.descriptionId,...r,ref:t})});wl.displayName=vl;var yl="DialogClose",xl=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Xe(yl,n);return i.jsx(oe.button,{type:"button",...r,ref:t,onClick:U(e.onClick,()=>o.onOpenChange(!1))})});xl.displayName=yl;function cs(e){return e?"open":"closed"}var Sl="DialogTitleWarning",[cy,Cl]=Bf(Sl,{contentName:kt,titleName:is,docsSlug:"dialog"}),Wb=({titleId:e})=>{const t=Cl(Sl),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
58
+ `)},Rg=0,Gt=[];function Kg(e){var t=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),o=l.useState(Rg++)[0],s=l.useState(Li)[0],a=l.useRef(e);l.useEffect(function(){a.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=pg([e.lockRef.current],(e.shards||[]).map(Wi),!0).filter(Boolean);return h.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(h,b){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!a.current.allowPinchZoom;var w=ir(h),y=n.current,x="deltaX"in h?h.deltaX:y[0]-w[0],C="deltaY"in h?h.deltaY:y[1]-w[1],E,P=h.target,T=Math.abs(x)>Math.abs(C)?"h":"v";if("touches"in h&&T==="h"&&P.type==="range")return!1;var F=Bi(T,P);if(!F)return!0;if(F?E=T:(E=T==="v"?"h":"v",F=Bi(T,P)),!F)return!1;if(!r.current&&"changedTouches"in h&&(x||C)&&(r.current=E),!E)return!0;var M=r.current||E;return Wg(M,b,h,M==="h"?x:C)},[]),d=l.useCallback(function(h){var b=h;if(!(!Gt.length||Gt[Gt.length-1]!==s)){var w="deltaY"in b?zi(b):ir(b),y=t.current.filter(function(E){return E.name===b.type&&(E.target===b.target||b.target===E.shadowParent)&&Vg(E.delta,w)})[0];if(y&&y.should){b.cancelable&&b.preventDefault();return}if(!y){var x=(a.current.shards||[]).map(Wi).filter(Boolean).filter(function(E){return E.contains(b.target)}),C=x.length>0?c(b,x[0]):!a.current.noIsolation;C&&b.cancelable&&b.preventDefault()}}},[]),f=l.useCallback(function(h,b,w,y){var x={name:h,delta:b,target:w,should:y,shadowParent:Gg(w)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(C){return C!==x})},1)},[]),u=l.useCallback(function(h){n.current=ir(h),r.current=void 0},[]),p=l.useCallback(function(h){f(h.type,zi(h),h.target,c(h,e.lockRef.current))},[]),m=l.useCallback(function(h){f(h.type,ir(h),h.target,c(h,e.lockRef.current))},[]);l.useEffect(function(){return Gt.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",d,Kt),document.addEventListener("touchmove",d,Kt),document.addEventListener("touchstart",u,Kt),function(){Gt=Gt.filter(function(h){return h!==s}),document.removeEventListener("wheel",d,Kt),document.removeEventListener("touchmove",d,Kt),document.removeEventListener("touchstart",u,Kt)}},[]);var v=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(s,{styles:jg(o)}):null,v?l.createElement(Lg,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Gg(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const qg=Sg(Di,Kg);var cr=l.forwardRef(function(e,t){return l.createElement(sr,lt({},e,{ref:t,sideCar:qg}))});cr.classNames=sr.classNames;var Ko=["Enter"," "],Xg=["ArrowDown","PageUp","Home"],Vi=["ArrowUp","PageDown","End"],Yg=[...Xg,...Vi],Jg={ltr:[...Ko,"ArrowRight"],rtl:[...Ko,"ArrowLeft"]},Zg={ltr:["ArrowLeft"],rtl:["ArrowRight"]},pn="Menu",[hn,Qg,em]=go(pn),[It,ji]=Ke(pn,[em,Vt,Ni]),lr=Vt(),Ri=Ni(),[tm,kt]=It(pn),[nm,gn]=It(pn),Ki=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:a=!0}=e,c=lr(t),[d,f]=l.useState(null),u=l.useRef(!1),p=Ae(s),m=Wn(o);return l.useEffect(()=>{const v=()=>{u.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>u.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),i.jsx(Do,{...c,children:i.jsx(tm,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:f,children:i.jsx(nm,{scope:t,onClose:l.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:u,dir:m,modal:a,children:r})})})};Ki.displayName=pn;var rm="MenuAnchor",Go=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=lr(n);return i.jsx(Lo,{...o,...r,ref:t})});Go.displayName=rm;var qo="MenuPortal",[om,Gi]=It(qo,{forceMount:void 0}),qi=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=kt(qo,t);return i.jsx(om,{scope:t,forceMount:n,children:i.jsx(Le,{present:n||s.open,children:i.jsx(er,{asChild:!0,container:o,children:r})})})};qi.displayName=qo;var ze="MenuContent",[sm,Xo]=It(ze),Xi=l.forwardRef((e,t)=>{const n=Gi(ze,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=kt(ze,e.__scopeMenu),a=gn(ze,e.__scopeMenu);return i.jsx(hn.Provider,{scope:e.__scopeMenu,children:i.jsx(Le,{present:r||s.open,children:i.jsx(hn.Slot,{scope:e.__scopeMenu,children:a.modal?i.jsx(am,{...o,ref:t}):i.jsx(im,{...o,ref:t})})})})}),am=l.forwardRef((e,t)=>{const n=kt(ze,e.__scopeMenu),r=l.useRef(null),o=ue(t,r);return l.useEffect(()=>{const s=r.current;if(s)return zo(s)},[]),i.jsx(Yo,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:U(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),im=l.forwardRef((e,t)=>{const n=kt(ze,e.__scopeMenu);return i.jsx(Yo,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),cm=Be.createSlot("MenuContent.ScrollLock"),Yo=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:m,onDismiss:v,disableOutsideScroll:g,...h}=e,b=kt(ze,n),w=gn(ze,n),y=lr(n),x=Ri(n),C=Qg(n),[E,P]=l.useState(null),T=l.useRef(null),F=ue(t,T,b.onContentChange),M=l.useRef(0),B=l.useRef(""),V=l.useRef(0),J=l.useRef(null),H=l.useRef("right"),O=l.useRef(0),ne=g?cr:l.Fragment,L=g?{as:cm,allowPinchZoom:!0}:void 0,z=I=>{var R,le;const Z=B.current+I,j=C().filter(he=>!he.disabled),te=document.activeElement,D=(R=j.find(he=>he.ref.current===te))==null?void 0:R.textValue,W=j.map(he=>he.textValue),xe=ym(W,Z,D),ie=(le=j.find(he=>he.textValue===xe))==null?void 0:le.ref.current;(function he(de){B.current=de,window.clearTimeout(M.current),de!==""&&(M.current=window.setTimeout(()=>he(""),1e3))})(Z),ie&&setTimeout(()=>ie.focus())};l.useEffect(()=>()=>window.clearTimeout(M.current),[]),vo();const k=l.useCallback(I=>{var j,te;return H.current===((j=J.current)==null?void 0:j.side)&&Sm(I,(te=J.current)==null?void 0:te.area)},[]);return i.jsx(sm,{scope:n,searchRef:B,onItemEnter:l.useCallback(I=>{k(I)&&I.preventDefault()},[k]),onItemLeave:l.useCallback(I=>{var Z;k(I)||((Z=T.current)==null||Z.focus(),P(null))},[k]),onTriggerLeave:l.useCallback(I=>{k(I)&&I.preventDefault()},[k]),pointerGraceTimerRef:V,onPointerGraceIntentChange:l.useCallback(I=>{J.current=I},[]),children:i.jsx(ne,{...L,children:i.jsx(Vn,{asChild:!0,trapped:o,onMountAutoFocus:U(s,I=>{var Z;I.preventDefault(),(Z=T.current)==null||Z.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:i.jsx(cn,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:m,onDismiss:v,children:i.jsx(cg,{asChild:!0,...x,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:P,onEntryFocus:U(d,I=>{w.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:i.jsx(Fo,{role:"menu","aria-orientation":"vertical","data-state":fc(b.open),"data-radix-menu-content":"",dir:w.dir,...y,...h,ref:F,style:{outline:"none",...h.style},onKeyDown:U(h.onKeyDown,I=>{const j=I.target.closest("[data-radix-menu-content]")===I.currentTarget,te=I.ctrlKey||I.altKey||I.metaKey,D=I.key.length===1;j&&(I.key==="Tab"&&I.preventDefault(),!te&&D&&z(I.key));const W=T.current;if(I.target!==W||!Yg.includes(I.key))return;I.preventDefault();const ie=C().filter(R=>!R.disabled).map(R=>R.ref.current);Vi.includes(I.key)&&ie.reverse(),vm(ie)}),onBlur:U(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(M.current),B.current="")}),onPointerMove:U(e.onPointerMove,bn(I=>{const Z=I.target,j=O.current!==I.clientX;if(I.currentTarget.contains(Z)&&j){const te=I.clientX>O.current?"right":"left";H.current=te,O.current=I.clientX}}))})})})})})})});Xi.displayName=ze;var lm="MenuGroup",Jo=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(oe.div,{role:"group",...r,ref:t})});Jo.displayName=lm;var dm="MenuLabel",Yi=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(oe.div,{...r,ref:t})});Yi.displayName=dm;var dr="MenuItem",Ji="menu.itemSelect",ur=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=l.useRef(null),a=gn(dr,e.__scopeMenu),c=Xo(dr,e.__scopeMenu),d=ue(t,s),f=l.useRef(!1),u=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(Ji,{bubbles:!0,cancelable:!0});p.addEventListener(Ji,v=>r==null?void 0:r(v),{once:!0}),Ta(p,m),m.defaultPrevented?f.current=!1:a.onClose()}};return i.jsx(Zi,{...o,ref:d,disabled:n,onClick:U(e.onClick,u),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),f.current=!0},onPointerUp:U(e.onPointerUp,p=>{var m;f.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:U(e.onKeyDown,p=>{const m=c.searchRef.current!=="";n||m&&p.key===" "||Ko.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});ur.displayName=dr;var Zi=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,a=Xo(dr,n),c=Ri(n),d=l.useRef(null),f=ue(t,d),[u,p]=l.useState(!1),[m,v]=l.useState("");return l.useEffect(()=>{const g=d.current;g&&v((g.textContent??"").trim())},[s.children]),i.jsx(hn.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:i.jsx(lg,{asChild:!0,...c,focusable:!r,children:i.jsx(oe.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:f,onPointerMove:U(e.onPointerMove,bn(g=>{r?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:U(e.onPointerLeave,bn(g=>a.onItemLeave(g))),onFocus:U(e.onFocus,()=>p(!0)),onBlur:U(e.onBlur,()=>p(!1))})})})}),um="MenuCheckboxItem",Qi=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return i.jsx(oc,{scope:e.__scopeMenu,checked:n,children:i.jsx(ur,{role:"menuitemcheckbox","aria-checked":fr(n)?"mixed":n,...o,ref:t,"data-state":Qo(n),onSelect:U(o.onSelect,()=>r==null?void 0:r(fr(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Qi.displayName=um;var ec="MenuRadioGroup",[fm,pm]=It(ec,{value:void 0,onValueChange:()=>{}}),tc=l.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Ae(r);return i.jsx(fm,{scope:e.__scopeMenu,value:n,onValueChange:s,children:i.jsx(Jo,{...o,ref:t})})});tc.displayName=ec;var nc="MenuRadioItem",rc=l.forwardRef((e,t)=>{const{value:n,...r}=e,o=pm(nc,e.__scopeMenu),s=n===o.value;return i.jsx(oc,{scope:e.__scopeMenu,checked:s,children:i.jsx(ur,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Qo(s),onSelect:U(r.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,n)},{checkForDefaultPrevented:!1})})})});rc.displayName=nc;var Zo="MenuItemIndicator",[oc,hm]=It(Zo,{checked:!1}),sc=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=hm(Zo,n);return i.jsx(Le,{present:r||fr(s.checked)||s.checked===!0,children:i.jsx(oe.span,{...o,ref:t,"data-state":Qo(s.checked)})})});sc.displayName=Zo;var gm="MenuSeparator",ac=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(oe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ac.displayName=gm;var mm="MenuArrow",ic=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=lr(n);return i.jsx($o,{...o,...r,ref:t})});ic.displayName=mm;var bm="MenuSub",[ay,cc]=It(bm),mn="MenuSubTrigger",lc=l.forwardRef((e,t)=>{const n=kt(mn,e.__scopeMenu),r=gn(mn,e.__scopeMenu),o=cc(mn,e.__scopeMenu),s=Xo(mn,e.__scopeMenu),a=l.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=s,f={__scopeMenu:e.__scopeMenu},u=l.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return l.useEffect(()=>u,[u]),l.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),d(null)}},[c,d]),i.jsx(Go,{asChild:!0,...f,children:i.jsx(Zi,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":fc(n.open),...e,ref:lo(t,o.onTriggerChange),onClick:p=>{var m;(m=e.onClick)==null||m.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:U(e.onPointerMove,bn(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!a.current&&(s.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:U(e.onPointerLeave,bn(p=>{var v,g;u();const m=(v=n.content)==null?void 0:v.getBoundingClientRect();if(m){const h=(g=n.content)==null?void 0:g.dataset.side,b=h==="right",w=b?-5:5,y=m[b?"left":"right"],x=m[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+w,y:p.clientY},{x:y,y:m.top},{x,y:m.top},{x,y:m.bottom},{x:y,y:m.bottom}],side:h}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:U(e.onKeyDown,p=>{var v;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||Jg[r.dir].includes(p.key)&&(n.onOpenChange(!0),(v=n.content)==null||v.focus(),p.preventDefault())})})})});lc.displayName=mn;var dc="MenuSubContent",uc=l.forwardRef((e,t)=>{const n=Gi(ze,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=kt(ze,e.__scopeMenu),a=gn(ze,e.__scopeMenu),c=cc(dc,e.__scopeMenu),d=l.useRef(null),f=ue(t,d);return i.jsx(hn.Provider,{scope:e.__scopeMenu,children:i.jsx(Le,{present:r||s.open,children:i.jsx(hn.Slot,{scope:e.__scopeMenu,children:i.jsx(Yo,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:f,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var p;a.isUsingKeyboardRef.current&&((p=d.current)==null||p.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:U(e.onFocusOutside,u=>{u.target!==c.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:U(e.onEscapeKeyDown,u=>{a.onClose(),u.preventDefault()}),onKeyDown:U(e.onKeyDown,u=>{var v;const p=u.currentTarget.contains(u.target),m=Zg[a.dir].includes(u.key);p&&m&&(s.onOpenChange(!1),(v=c.trigger)==null||v.focus(),u.preventDefault())})})})})})});uc.displayName=dc;function fc(e){return e?"open":"closed"}function fr(e){return e==="indeterminate"}function Qo(e){return fr(e)?"indeterminate":e?"checked":"unchecked"}function vm(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function wm(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function ym(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let a=wm(e,Math.max(s,0));o.length===1&&(a=a.filter(f=>f!==n));const d=a.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function xm(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const c=t[s],d=t[a],f=c.x,u=c.y,p=d.x,m=d.y;u>r!=m>r&&n<(p-f)*(r-u)/(m-u)+f&&(o=!o)}return o}function Sm(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return xm(n,t)}function bn(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Cm=Ki,Em=Go,Nm=qi,Tm=Xi,Am=Jo,Im=Yi,km=ur,_m=Qi,Pm=tc,Om=rc,Mm=sc,Dm=ac,Lm=ic,Fm=lc,$m=uc,pr="DropdownMenu",[Bm,iy]=Ke(pr,[ji]),Oe=ji(),[Um,pc]=Bm(pr),hc=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:a,modal:c=!0}=e,d=Oe(t),f=l.useRef(null),[u,p]=mt({prop:o,defaultProp:s??!1,onChange:a,caller:pr});return i.jsx(Um,{scope:t,triggerId:Ge(),triggerRef:f,contentId:Ge(),open:u,onOpenChange:p,onOpenToggle:l.useCallback(()=>p(m=>!m),[p]),modal:c,children:i.jsx(Cm,{...d,open:u,onOpenChange:p,dir:r,modal:c,children:n})})};hc.displayName=pr;var gc="DropdownMenuTrigger",mc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=pc(gc,n),a=Oe(n);return i.jsx(Em,{asChild:!0,...a,children:i.jsx(oe.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:lo(t,s.triggerRef),onPointerDown:U(e.onPointerDown,c=>{!r&&c.button===0&&c.ctrlKey===!1&&(s.onOpenToggle(),s.open||c.preventDefault())}),onKeyDown:U(e.onKeyDown,c=>{r||(["Enter"," "].includes(c.key)&&s.onOpenToggle(),c.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});mc.displayName=gc;var Hm="DropdownMenuPortal",bc=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Oe(t);return i.jsx(Nm,{...r,...n})};bc.displayName=Hm;var vc="DropdownMenuContent",wc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=pc(vc,n),s=Oe(n),a=l.useRef(!1);return i.jsx(Tm,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:U(e.onCloseAutoFocus,c=>{var d;a.current||(d=o.triggerRef.current)==null||d.focus(),a.current=!1,c.preventDefault()}),onInteractOutside:U(e.onInteractOutside,c=>{const d=c.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,u=d.button===2||f;(!o.modal||u)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});wc.displayName=vc;var zm="DropdownMenuGroup",Wm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Am,{...o,...r,ref:t})});Wm.displayName=zm;var Vm="DropdownMenuLabel",yc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Im,{...o,...r,ref:t})});yc.displayName=Vm;var jm="DropdownMenuItem",xc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(km,{...o,...r,ref:t})});xc.displayName=jm;var Rm="DropdownMenuCheckboxItem",Sc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(_m,{...o,...r,ref:t})});Sc.displayName=Rm;var Km="DropdownMenuRadioGroup",Gm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Pm,{...o,...r,ref:t})});Gm.displayName=Km;var qm="DropdownMenuRadioItem",Cc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Om,{...o,...r,ref:t})});Cc.displayName=qm;var Xm="DropdownMenuItemIndicator",Ec=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Mm,{...o,...r,ref:t})});Ec.displayName=Xm;var Ym="DropdownMenuSeparator",Nc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Dm,{...o,...r,ref:t})});Nc.displayName=Ym;var Jm="DropdownMenuArrow",Zm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Lm,{...o,...r,ref:t})});Zm.displayName=Jm;var Qm="DropdownMenuSubTrigger",Tc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Fm,{...o,...r,ref:t})});Tc.displayName=Qm;var eb="DropdownMenuSubContent",Ac=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx($m,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ac.displayName=eb;var tb=hc,nb=mc,rb=bc,Ic=wc,kc=yc,_c=xc,Pc=Sc,Oc=Cc,Mc=Ec,Dc=Nc,Lc=Tc,Fc=Ac;const ob=tb,sb=nb,ab=l.forwardRef(({className:e,inset:t,children:n,...r},o)=>i.jsxs(Lc,{ref:o,className:A("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,i.jsx(q.ChevronRight,{className:"ml-auto h-4 w-4"})]}));ab.displayName=Lc.displayName;const ib=l.forwardRef(({className:e,...t},n)=>i.jsx(Fc,{ref:n,className:A("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",e),...t}));ib.displayName=Fc.displayName;const $c=l.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(rb,{children:i.jsx(Ic,{ref:r,sideOffset:t,className:A("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",e),...n})}));$c.displayName=Ic.displayName;const Bc=l.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(_c,{ref:r,className:A("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Bc.displayName=_c.displayName;const cb=l.forwardRef(({className:e,children:t,checked:n,...r},o)=>i.jsxs(Pc,{ref:o,className:A("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Mc,{children:i.jsx(q.Check,{className:"h-4 w-4"})})}),t]}));cb.displayName=Pc.displayName;const lb=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(Oc,{ref:r,className:A("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Mc,{children:i.jsx(q.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));lb.displayName=Oc.displayName;const db=l.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(kc,{ref:r,className:A("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));db.displayName=kc.displayName;const ub=l.forwardRef(({className:e,...t},n)=>i.jsx(Dc,{ref:n,className:A("-mx-1 my-1 h-px bg-muted",e),...t}));ub.displayName=Dc.displayName;const We=e=>{if(!e)return null;const t=Date.parse(e);return Number.isFinite(t)?t:null},fb=e=>{const t=We(e);return t!==null?new Date(t).toLocaleString():e??"Unknown"};function vn({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=40,enableFileUpload:s=!0,enableMessageEditing:a=!0,customStyles:c={},onMessageSent:d,onError:f}){const{currentThreadId:u,messages:p,isStreaming:m,streamingAssistantId:v,error:g,send:h,stop:b,lastCheckpointId:w,lastBranchEvent:y,listCheckpoints:x,navigateToCheckpoint:C,returnToLatest:E,hasMoreHistory:P,isLoadingHistory:T,loadOlderMessages:F}=co(),[M,B]=N.useState(""),[V,J]=N.useState(null),[H,O]=N.useState(null),[ne,L]=N.useState([]),[z,k]=N.useState(!1),[I,Z]=N.useState([]),[j,te]=N.useState(null),[D,W]=N.useState({}),xe=N.useRef(null),ie=N.useRef(null),R=N.useRef(null),le=N.useRef(null),he=N.useRef(!1),de=N.useRef(!0),be=N.useRef(0),ge=N.useRef(null),[G,X]=N.useState("desktop");N.useEffect(()=>{const _=()=>{const $=window.innerWidth;X($<640?"phone":$<1024?"tablet":"desktop")};return _(),window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]),N.useEffect(()=>{W({}),ge.current=null},[u]);const ye=N.useCallback(_=>{if(!_.length)return[];let $=null,K=-1/0,Y=null,re=-1/0;for(const ee of _){const Te=ee.createdAt??null,pe=typeof Te=="number"&&Number.isFinite(Te)?Te:null;if(ee.parentCheckpointId===null){($==null||(pe??-1/0)>K)&&($=ee,K=pe??-1/0);continue}if(ee.parentCheckpointId!==null){const Ee=pe??(ee.checkpointId?Number.MAX_SAFE_INTEGER:-1/0);(Y==null||Ee>re)&&(Y=ee,re=Ee)}}const Q=[];return $&&Q.push({...$}),Y&&Q.push({...Y}),Q},[]),se=N.useCallback(_=>{const $=new Map;for(const Q of _)Q.checkpointId&&$.set(Q.checkpointId,Q);const K={},Y=Q=>(K[Q]||(K[Q]=[]),K[Q]),re=(Q,ee)=>{const Te=ee.checkpointId??"__root__",pe=Q.find(Ee=>(Ee.checkpointId??"__root__")===Te);if(pe){ee.parentCheckpointId!==void 0&&pe.parentCheckpointId==null&&(pe.parentCheckpointId=ee.parentCheckpointId),ee.branchLabel&&!pe.branchLabel&&(pe.branchLabel=ee.branchLabel),ee.createdAt!==void 0&&ee.createdAt!==null&&(pe.createdAt=ee.createdAt);return}Q.push({...ee})};for(const Q of _){const ee=Q.editedMessageId??void 0;if(!ee)continue;const Te=Y(ee),pe=Q.parentId??null,Ee=pe?$.get(pe):void 0,Qe=(Ee==null?void 0:Ee.branchLabel)??(Ee==null?void 0:Ee.preview)??"Original",Ur=We(Ee==null?void 0:Ee.createdAt);re(Te,{checkpointId:pe,parentCheckpointId:null,branchLabel:Qe,createdAt:Ur});const Pe=Q.branchLabel??Q.preview??void 0,et=We(Q.createdAt);re(Te,{checkpointId:Q.checkpointId??null,parentCheckpointId:pe,branchLabel:Pe,createdAt:et})}for(const Q of Object.keys(K))K[Q]=ye(K[Q]);return K},[ye]),Se=N.useCallback((_,$)=>{const K={},Y=(re,Q)=>{if(!(Q!=null&&Q.length))return;const ee=K[re]??[],Te=new Map;for(const pe of ee)Te.set(pe.checkpointId??"__root__",pe);for(const pe of Q){const Ee=pe.checkpointId??"__root__",Qe=Te.get(Ee);Qe?(pe.parentCheckpointId!==void 0&&Qe.parentCheckpointId==null&&(Qe.parentCheckpointId=pe.parentCheckpointId),pe.branchLabel&&!Qe.branchLabel&&(Qe.branchLabel=pe.branchLabel),pe.createdAt!==void 0&&pe.createdAt!==null&&(Qe.createdAt=pe.createdAt)):(ee.push({...pe}),Te.set(Ee,ee[ee.length-1]))}K[re]=ee};for(const[re,Q]of Object.entries(_))Y(re,Q);for(const[re,Q]of Object.entries($))Y(re,Q);for(const re of Object.keys(K))K[re]=ye(K[re]);return K},[ye]),fe=N.useCallback(async()=>{if(!P||T)return;const _=le.current;if(!_)return;const $=_.scrollHeight,K=_.scrollTop;he.current=!0;try{await F()}catch(Y){console.warn("loadOlderMessages failed",Y)}finally{requestAnimationFrame(()=>{const Y=le.current;if(!Y){he.current=!1;return}const re=Y.scrollHeight;Y.scrollTop=K+(re-$);const Q=re-Y.scrollTop-Y.clientHeight;de.current=Q<=32,he.current=!1})}},[P,T,F]);N.useEffect(()=>{const _=le.current;if(!_)return;const $=()=>{_.scrollTop<=80&&fe();const re=_.scrollHeight-_.scrollTop-_.clientHeight;de.current=re<=80};return _.addEventListener("scroll",$),()=>_.removeEventListener("scroll",$)},[fe]),N.useEffect(()=>{p.length<be.current&&(de.current=!0),be.current=p.length},[p.length]),N.useEffect(()=>{const _=le.current;_&&(he.current||de.current&&(_.scrollTop=_.scrollHeight,de.current=!0))},[p]),N.useEffect(()=>{var _;n&&((_=ie.current)==null||_.focus())},[n]),N.useEffect(()=>{g&&!z&&(f==null||f(g))},[g,z,f]),N.useEffect(()=>{let _=!0;if(!u){Z([]),te(null),W({});return}return x(u).then($=>{var Q;if(!_)return;const K=$.checkpoints||[];Z(K);const Y=se(K);W(ee=>Se(Y,ee));const re=((Q=K.slice().sort((ee,Te)=>(We(Te.createdAt)??-1/0)-(We(ee.createdAt)??-1/0))[0])==null?void 0:Q.checkpointId)||null;te(ee=>ee??re)}).catch(()=>{}),()=>{_=!1}},[u,x,se,Se]),N.useEffect(()=>{w&&te(w)},[w]);const ve=_=>{if(_.length>Bt)return`Message too long (${_.length}/${Bt} characters)`;try{return mp(_),null}catch($){return($==null?void 0:$.message)||"Invalid message"}},_e=_=>{const $=_.content||[],K=$.filter(Y=>Y.type==="text").map(Y=>Y.text).join("");if(K)return K;try{return JSON.stringify($,null,2)}catch{return String($)}},Fe=N.useMemo(()=>{const _=new Map;for(const $ of I)$!=null&&$.checkpointId&&_.set($.checkpointId,$);return _},[I]);N.useEffect(()=>{if(!y)return;const _=[y.editedMessageId??"",y.parentCheckpointId??"",y.checkpointId??""].join("::");if(ge.current===_)return;ge.current=_;const $=y.editedMessageId;$&&W(K=>{const Y=K[$]??[],re=new Map;for(const Pe of Y){const et=Pe.checkpointId??"__root__";re.set(et,Pe)}const Q=(Pe,et,Hr,zr)=>{if(Pe===void 0)return;const Wr=Pe??"__root__",tt=re.get(Wr);re.set(Wr,{checkpointId:Pe,parentCheckpointId:et??(tt==null?void 0:tt.parentCheckpointId)??null,branchLabel:Hr??(tt==null?void 0:tt.branchLabel)??null,createdAt:zr??(tt==null?void 0:tt.createdAt)??null})},ee=y.parentCheckpointId?Fe.get(y.parentCheckpointId):void 0,Te=We(ee==null?void 0:ee.createdAt);if(y.parentCheckpointId){const Pe=re.get(y.parentCheckpointId),et=(Pe==null?void 0:Pe.branchLabel)??(ee==null?void 0:ee.preview)??"Original";Q(y.parentCheckpointId,null,et,Te)}const pe=y.checkpointId?Fe.get(y.checkpointId):void 0,Ee=We(pe==null?void 0:pe.createdAt)??Date.now();Q(y.checkpointId??null,y.parentCheckpointId??null,y.branchLabel??(pe==null?void 0:pe.preview)??null,Ee);const Qe=Array.from(re.values()),Ur=y.parentCheckpointId??null;return Qe.sort((Pe,et)=>{if(Pe.checkpointId===Ur)return-1;if(et.checkpointId===Ur)return 1;const Hr=Pe.checkpointId?Fe.get(Pe.checkpointId):void 0,zr=et.checkpointId?Fe.get(et.checkpointId):void 0,Wr=Hr?We(Hr.createdAt)??Number.MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,tt=zr?We(zr.createdAt)??Number.MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER;return Wr-tt}),{...K,[$]:ye(Qe)}})},[y,Fe,ye]);const ht=_=>{const $=p[_],K=$==null?void 0:$.id;if(!K)return[];const Y=D[K];return Y!=null&&Y.length?Y.map((re,Q)=>{const ee=re.checkpointId?Fe.get(re.checkpointId):void 0,Te=ee?We(ee.createdAt)??void 0:void 0,pe=re.checkpointId?re.checkpointId===j:!j,Ee=Q===0?"Original":`Branch ${Q}`;return{checkpoint_id:re.checkpointId,checkpoint_ns:ee==null?void 0:ee.checkpointNs,message_count:(ee==null?void 0:ee.messagesLen)??0,last_message_preview:(ee==null?void 0:ee.preview)??void 0,ts:Te,isCurrent:pe,label:re.branchLabel??(ee==null?void 0:ee.preview)??Ee}}):[]},Es=_=>{var Q;if(_===void 0)return{canGoBack:!1,canGoForward:!1,currentIndex:0,totalBranches:0,currentLabel:null};const $=ht(_);if($.length<=1)return{canGoBack:!1,canGoForward:!1,currentIndex:0,totalBranches:$.length,currentLabel:((Q=$[0])==null?void 0:Q.label)??null};const K=$.findIndex(ee=>ee.isCurrent),Y=K>=0?K:0,re=$[Y]??null;return{canGoBack:Y>0,canGoForward:Y<$.length-1,currentIndex:Y,totalBranches:$.length,currentLabel:(re==null?void 0:re.label)??null}},En=async()=>{const _=M.trim();if(!_&&ne.length===0)return;const $=ve(_);if($){O($);return}try{const K=window.__editingCheckpointId||j||void 0;await h(_,{checkpointId:K,payloadExtras:V?{edit:!0,originalMessageId:V}:void 0,attachments:ne}),d==null||d(_),B(""),O(null),L([]),delete window.__editingCheckpointId,J(null),ie.current&&(ie.current.style.height="auto")}catch(K){const Y=(K==null?void 0:K.message)||"Failed to send message";O(Y),f==null||f(Y)}},Ns=(_,$)=>{a&&(J(_),B($),O(null),setTimeout(()=>{ie.current&&(ie.current.focus(),ie.current.style.height="auto",ie.current.style.height=ie.current.scrollHeight+"px")},0))},Fr=async(_,$)=>{const K=p.find(re=>re.id===_);if(!K){O("Message not found");return}const Y=_e(K);J(_),B(Y),window.__editingCheckpointId=$,setTimeout(()=>{var re;return(re=ie.current)==null?void 0:re.focus()},0)},Nn=()=>{J(null),B(""),O(null),delete window.__editingCheckpointId,ie.current&&(ie.current.style.height="auto")},Ts=_=>{_.key==="Enter"&&!_.shiftKey?(_.preventDefault(),En()):_.key==="Escape"&&V&&(_.preventDefault(),Nn())},$r=_=>{const $=Array.from(_.target.files||[]);L(K=>[...K,...$])},me=_=>L($=>$.filter((K,Y)=>_!==Y)),Ie=async _=>{if(u){if(!_){await E(),te(null);return}await C(_),te(_)}},$e=async()=>{await E(),te(null)},Ze=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${c.container||""}`,gt=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-y-auto overflow-x-auto overscroll-contain break-words break-anywhere p-4 space-y-4 bg-transparent ${c.messagesArea||""}`,Br=`flex-shrink-0 w-full border-t p-4 bg-transparent ${c.inputArea||""}`;return i.jsxs("div",{className:Ze,children:[!!g&&!z&&i.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[i.jsx("span",{children:g}),i.jsx(we,{variant:"ghost",size:"sm",onClick:()=>k(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:i.jsx(q.X,{size:16})})]}),u&&I.length>0&&i.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[i.jsx(q.GitBranch,{className:"h-4 w-4 opacity-70"}),i.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),i.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:j??"",onChange:_=>{const $=_.target.value||null;Ie($)},children:[i.jsx("option",{value:"",children:"Latest"}),I.slice().sort((_,$)=>(We($.createdAt)??-1/0)-(We(_.createdAt)??-1/0)).map(_=>i.jsxs("option",{value:_.checkpointId,children:[fb(_.createdAt),_.preview?` — ${_.preview.slice(0,30)}`:""]},_.checkpointId))]})]}),i.jsxs("div",{ref:le,className:gt,style:r?{maxHeight:r}:void 0,children:[p.length===0?i.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:"No messages yet. Start a conversation!"}):i.jsxs(i.Fragment,{children:[(T||!P)&&i.jsx("div",{className:"flex justify-center py-2 text-xs text-muted-foreground",children:T?i.jsx(q.Loader2,{className:"h-4 w-4 animate-spin"}):"You've reached the beginning"}),p.map((_,$)=>i.jsx(Oa,{message:_,messageIndex:$,isStreamingMessage:m&&v===_.id,streamingDebounceMs:o,isEditing:V===_.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:G,truncateToolMessages:!1,toolMessagePreviewLength:200,checkpointBranches:ht($),currentCheckpointId:j??void 0,temporalNavigation:Es($),onSwitchToCheckpoint:Ie,onReturnToMainThread:$e,onNavigateToPreviousBranch:()=>{var re;const K=ht($),Y=Math.max(0,K.findIndex(Q=>Q.isCurrent));if(Y>0){const Q=((re=K[Y-1])==null?void 0:re.checkpoint_id)??null;Ie(Q??null)}},onNavigateToNextBranch:()=>{var re;const K=ht($),Y=Math.max(0,K.findIndex(Q=>Q.isCurrent));if(Y>=0&&Y<K.length-1){const Q=((re=K[Y+1])==null?void 0:re.checkpoint_id)??null;Ie(Q??null)}},onEdit:(K,Y)=>Ns(K,Y),onEditFromCheckpoint:Fr,onRegenerate:()=>{const K=[...p].reverse().find(re=>re.role==="user"),Y=K?_e(K):"";Y&&h(Y,{checkpointId:j??void 0})},onCancelEdit:Nn},_.id||$))]}),i.jsx("div",{ref:xe})]}),i.jsxs("div",{className:Br,children:[V&&i.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(q.Edit3,{size:16,className:"text-blue-600"}),i.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),i.jsx(we,{variant:"ghost",size:"sm",onClick:Nn,className:"text-blue-600 hover:bg-blue-100",children:i.jsx(q.X,{size:16})})]})}),s&&i.jsxs("div",{className:"mb-3",children:[i.jsx("input",{ref:R,type:"file",multiple:!0,onChange:_=>$r(_),className:"hidden"}),ne.length>0&&i.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:ne.map((_,$)=>i.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 rounded-lg px-3 py-2 text-sm",children:[i.jsx(q.Paperclip,{size:14}),i.jsx("span",{className:"truncate max-w-[150px]",children:_.name}),i.jsx(we,{variant:"ghost",size:"sm",onClick:()=>me($),className:"h-4 w-4 p-0 text-gray-500 hover:text-red-500","aria-label":`Remove ${_.name}`,children:i.jsx(q.X,{size:12})})]},$))})]}),H&&i.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:H}),i.jsxs("div",{className:"flex items-end gap-2",children:[s&&i.jsxs(ob,{children:[i.jsx(sb,{asChild:!0,children:i.jsx(we,{type:"button",size:"icon",variant:"outline",disabled:m,title:"More input actions",className:c.moreButton||"",children:i.jsx(q.Plus,{size:16})})}),i.jsx($c,{align:"start",sideOffset:6,className:"w-52",children:i.jsxs(Bc,{onClick:()=>{var _;return(_=R.current)==null?void 0:_.click()},className:"cursor-pointer",children:[i.jsx(q.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]})})]}),i.jsx("div",{className:"flex-1",children:i.jsx(Ca,{ref:ie,value:M,onChange:_=>{B(_.target.value),O(null),ie.current&&(ie.current.style.height="auto",ie.current.style.height=`${ie.current.scrollHeight}px`)},onKeyDown:Ts,placeholder:V?"Edit your message...":t,className:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${V?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${H?"border-red-400":""} ${c.textarea||""}`,disabled:!1,maxLength:Bt,rows:1})}),i.jsx("div",{children:m?i.jsx(we,{type:"button",onClick:b,size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",children:i.jsx(q.Square,{size:16})}):i.jsx(we,{type:"button",onClick:En,size:"icon",disabled:!M.trim()&&ne.length===0,className:`shrink-0 ${c.sendButton||""}`,title:V?"Save changes":"Send message",children:i.jsx(q.Send,{size:16})})})]}),M.length>Bt*.8&&i.jsxs("div",{className:"mt-2 text-xs text-gray-500 text-right",children:[M.length,"/",Bt]})]})]})}const wn=l.forwardRef(({className:e,type:t,...n},r)=>i.jsx("input",{type:t,className:A("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));wn.displayName="Input";function es(e,[t,n]){return Math.min(n,Math.max(t,e))}function pb(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var ts="ScrollArea",[Uc,cy]=Ke(ts),[hb,Ve]=Uc(ts),Hc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...a}=e,[c,d]=l.useState(null),[f,u]=l.useState(null),[p,m]=l.useState(null),[v,g]=l.useState(null),[h,b]=l.useState(null),[w,y]=l.useState(0),[x,C]=l.useState(0),[E,P]=l.useState(!1),[T,F]=l.useState(!1),M=ue(t,V=>d(V)),B=Wn(o);return i.jsx(hb,{scope:n,type:r,dir:B,scrollHideDelay:s,scrollArea:c,viewport:f,onViewportChange:u,content:p,onContentChange:m,scrollbarX:v,onScrollbarXChange:g,scrollbarXEnabled:E,onScrollbarXEnabledChange:P,scrollbarY:h,onScrollbarYChange:b,scrollbarYEnabled:T,onScrollbarYEnabledChange:F,onCornerWidthChange:y,onCornerHeightChange:C,children:i.jsx(oe.div,{dir:B,...a,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":x+"px",...e.style}})})});Hc.displayName=ts;var zc="ScrollAreaViewport",Wc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,a=Ve(zc,n),c=l.useRef(null),d=ue(t,c,a.onViewportChange);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),i.jsx(oe.div,{"data-radix-scroll-area-viewport":"",...s,ref:d,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:i.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Wc.displayName=zc;var dt="ScrollAreaScrollbar",ns=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ve(dt,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:a}=o,c=e.orientation==="horizontal";return l.useEffect(()=>(c?s(!0):a(!0),()=>{c?s(!1):a(!1)}),[c,s,a]),o.type==="hover"?i.jsx(gb,{...r,ref:t,forceMount:n}):o.type==="scroll"?i.jsx(mb,{...r,ref:t,forceMount:n}):o.type==="auto"?i.jsx(Vc,{...r,ref:t,forceMount:n}):o.type==="always"?i.jsx(rs,{...r,ref:t}):null});ns.displayName=dt;var gb=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ve(dt,e.__scopeScrollArea),[s,a]=l.useState(!1);return l.useEffect(()=>{const c=o.scrollArea;let d=0;if(c){const f=()=>{window.clearTimeout(d),a(!0)},u=()=>{d=window.setTimeout(()=>a(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",f),c.addEventListener("pointerleave",u),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",f),c.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),i.jsx(Le,{present:n||s,children:i.jsx(Vc,{"data-state":s?"visible":"hidden",...r,ref:t})})}),mb=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ve(dt,e.__scopeScrollArea),s=e.orientation==="horizontal",a=br(()=>d("SCROLL_END"),100),[c,d]=pb("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return l.useEffect(()=>{if(c==="idle"){const f=window.setTimeout(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(f)}},[c,o.scrollHideDelay,d]),l.useEffect(()=>{const f=o.viewport,u=s?"scrollLeft":"scrollTop";if(f){let p=f[u];const m=()=>{const v=f[u];p!==v&&(d("SCROLL"),a()),p=v};return f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[o.viewport,s,d,a]),i.jsx(Le,{present:n||c!=="hidden",children:i.jsx(rs,{"data-state":c==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:U(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:U(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Vc=l.forwardRef((e,t)=>{const n=Ve(dt,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,a]=l.useState(!1),c=e.orientation==="horizontal",d=br(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;a(c?f:u)}},10);return qt(n.viewport,d),qt(n.content,d),i.jsx(Le,{present:r||s,children:i.jsx(rs,{"data-state":s?"visible":"hidden",...o,ref:t})})}),rs=l.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Ve(dt,e.__scopeScrollArea),s=l.useRef(null),a=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=qc(c.viewport,c.content),u={...r,sizes:c,onSizesChange:d,hasThumb:f>0&&f<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:m=>a.current=m};function p(m,v){return Sb(m,a.current,c,v)}return n==="horizontal"?i.jsx(bb,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,v=Xc(m,c,o.dir);s.current.style.transform=`translate3d(${v}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?i.jsx(vb,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,v=Xc(m,c);s.current.style.transform=`translate3d(0, ${v}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),bb=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Ve(dt,e.__scopeScrollArea),[a,c]=l.useState(),d=l.useRef(null),f=ue(t,d,s.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),i.jsx(Rc,{"data-orientation":"horizontal",...o,ref:f,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":mr(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(m),Jc(m,p)&&u.preventDefault()}},onResize:()=>{d.current&&s.viewport&&a&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:gr(a.paddingLeft),paddingEnd:gr(a.paddingRight)}})}})}),vb=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Ve(dt,e.__scopeScrollArea),[a,c]=l.useState(),d=l.useRef(null),f=ue(t,d,s.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),i.jsx(Rc,{"data-orientation":"vertical",...o,ref:f,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":mr(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,p)=>{if(s.viewport){const m=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(m),Jc(m,p)&&u.preventDefault()}},onResize:()=>{d.current&&s.viewport&&a&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:gr(a.paddingTop),paddingEnd:gr(a.paddingBottom)}})}})}),[wb,jc]=Uc(dt),Rc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:a,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:f,onWheelScroll:u,onResize:p,...m}=e,v=Ve(dt,n),[g,h]=l.useState(null),b=ue(t,M=>h(M)),w=l.useRef(null),y=l.useRef(""),x=v.viewport,C=r.content-r.viewport,E=Ae(u),P=Ae(d),T=br(p,10);function F(M){if(w.current){const B=M.clientX-w.current.left,V=M.clientY-w.current.top;f({x:B,y:V})}}return l.useEffect(()=>{const M=B=>{const V=B.target;(g==null?void 0:g.contains(V))&&E(B,C)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[x,g,C,E]),l.useEffect(P,[r,P]),qt(g,T),qt(v.content,T),i.jsx(wb,{scope:n,scrollbar:g,hasThumb:o,onThumbChange:Ae(s),onThumbPointerUp:Ae(a),onThumbPositionChange:P,onThumbPointerDown:Ae(c),children:i.jsx(oe.div,{...m,ref:b,style:{position:"absolute",...m.style},onPointerDown:U(e.onPointerDown,M=>{M.button===0&&(M.target.setPointerCapture(M.pointerId),w.current=g.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",v.viewport&&(v.viewport.style.scrollBehavior="auto"),F(M))}),onPointerMove:U(e.onPointerMove,F),onPointerUp:U(e.onPointerUp,M=>{const B=M.target;B.hasPointerCapture(M.pointerId)&&B.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=y.current,v.viewport&&(v.viewport.style.scrollBehavior=""),w.current=null})})})}),hr="ScrollAreaThumb",Kc=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=jc(hr,e.__scopeScrollArea);return i.jsx(Le,{present:n||o.hasThumb,children:i.jsx(yb,{ref:t,...r})})}),yb=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Ve(hr,n),a=jc(hr,n),{onThumbPositionChange:c}=a,d=ue(t,p=>a.onThumbChange(p)),f=l.useRef(void 0),u=br(()=>{f.current&&(f.current(),f.current=void 0)},100);return l.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(u(),!f.current){const v=Cb(p,c);f.current=v,c()}};return c(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,u,c]),i.jsx(oe.div,{"data-state":a.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:U(e.onPointerDownCapture,p=>{const v=p.target.getBoundingClientRect(),g=p.clientX-v.left,h=p.clientY-v.top;a.onThumbPointerDown({x:g,y:h})}),onPointerUp:U(e.onPointerUp,a.onThumbPointerUp)})});Kc.displayName=hr;var os="ScrollAreaCorner",Gc=l.forwardRef((e,t)=>{const n=Ve(os,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?i.jsx(xb,{...e,ref:t}):null});Gc.displayName=os;var xb=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Ve(os,n),[s,a]=l.useState(0),[c,d]=l.useState(0),f=!!(s&&c);return qt(o.scrollbarX,()=>{var p;const u=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(u),d(u)}),qt(o.scrollbarY,()=>{var p;const u=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(u),a(u)}),f?i.jsx(oe.div,{...r,ref:t,style:{width:s,height:c,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function gr(e){return e?parseInt(e,10):0}function qc(e,t){const n=e/t;return isNaN(n)?0:n}function mr(e){const t=qc(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Sb(e,t,n,r="ltr"){const o=mr(n),s=o/2,a=t||s,c=o-a,d=n.scrollbar.paddingStart+a,f=n.scrollbar.size-n.scrollbar.paddingEnd-c,u=n.content-n.viewport,p=r==="ltr"?[0,u]:[u*-1,0];return Yc([d,f],p)(e)}function Xc(e,t,n="ltr"){const r=mr(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,a=t.content-t.viewport,c=s-r,d=n==="ltr"?[0,a]:[a*-1,0],f=es(e,d);return Yc([0,a],[0,c])(f)}function Yc(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Jc(e,t){return e>0&&e<t}var Cb=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},a=n.left!==s.left,c=n.top!==s.top;(a||c)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function br(e,t){const n=Ae(e),r=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(r.current),[]),l.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function qt(e,t){const n=Ae(t);Ne(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var Zc=Hc,Eb=Wc,Nb=Gc;const Qc=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(Zc,{ref:r,className:A("relative overflow-hidden",e),...n,children:[i.jsx(Eb,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),i.jsx(el,{}),i.jsx(Nb,{})]}));Qc.displayName=Zc.displayName;const el=l.forwardRef(({className:e,orientation:t="vertical",...n},r)=>i.jsx(ns,{ref:r,orientation:t,className:A("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:i.jsx(Kc,{className:"relative flex-1 rounded-full bg-border"})}));el.displayName=ns.displayName;function vr({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:a=null,navigateToThread:c,onThreadSelect:d,onThreadCreate:f,onThreadDelete:u}){const{loadThread:p,threads:m,refreshThreads:v,currentThreadId:g,createThread:h,deleteThread:b,renameThread:w}=co(),[y,x]=N.useState(m??[]),[C,E]=N.useState(!1),[P,T]=N.useState(null),[F,M]=N.useState(null),[B,V]=N.useState(""),[J,H]=N.useState(!1);N.useEffect(()=>{x(m??[])},[m]);const O=async D=>{try{await p(D),c==null||c(D),d==null||d(D)}catch(W){console.error("Failed to select thread:",W)}},ne=async()=>{try{H(!0);const D=await h();f==null||f(D),c==null||c(D)}catch(D){console.error("Failed to create thread:",D)}finally{H(!1)}},L=async(D,W)=>{if(W.stopPropagation(),!!confirm("Delete this thread?"))try{await b(D),u==null||u(D)}catch(xe){console.error("Failed to delete thread:",xe)}},z=(D,W)=>{W.stopPropagation(),M(D.threadId),V(D.title||`Thread ${D.threadId.slice(0,8)}`)},k=async D=>{if(B.trim())try{await w(D,B.trim()),M(null),V("")}catch(W){console.error("Failed to update title:",W)}},I=()=>{M(null),V("")},Z=(D,W)=>{D.key==="Enter"?k(W):D.key==="Escape"&&I()},j=D=>{if(!D)return"";try{const W=new Date(D),ie=new Date().getTime()-W.getTime(),R=Math.floor(ie/(1e3*60*60*24));return R===0?W.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):R===1?"Yesterday":R<7?`${R} days ago`:W.toLocaleDateString()}catch{return""}},te=D=>D.title||`Thread ${D.threadId.slice(0,8)}`;return i.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&i.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:i.jsx(we,{onClick:ne,disabled:J||C,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:J?"Creating...":"New Chat",children:i.jsx(q.MessageSquarePlus,{size:20})})}),i.jsx(Qc,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:i.jsx("div",{className:"p-2 space-y-1 pb-4",children:C?i.jsx("div",{className:"text-center py-8 text-slate-400",children:"Loading…"}):y.length===0?i.jsxs("div",{className:"text-center py-8 text-slate-400",children:[i.jsx(q.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),i.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):y.slice().sort((D,W)=>new Date(W.updatedAt||W.createdAt||"").getTime()-new Date(D.updatedAt||D.createdAt||"").getTime()).map(D=>i.jsxs("div",{onClick:()=>O(D.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(a??g)===D.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{className:"flex-1 min-w-0",children:F===D.threadId?i.jsxs("div",{className:"flex items-center gap-2",onClick:W=>W.stopPropagation(),children:[i.jsx(wn,{value:B,onChange:W=>V(W.target.value),onKeyDown:W=>Z(W,D.threadId),className:"h-6 text-sm",autoFocus:!0}),i.jsx(we,{variant:"ghost",size:"sm",onClick:()=>k(D.threadId),className:"h-6 w-6 p-0",children:i.jsx(q.Check,{size:12})}),i.jsx(we,{variant:"ghost",size:"sm",onClick:I,className:"h-6 w-6 p-0",children:i.jsx(q.X,{size:12})})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:te(D)}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[i.jsx(q.Calendar,{size:10}),i.jsx("span",{children:j(D.updatedAt||D.createdAt)})]})]})}),i.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&F!==D.threadId&&i.jsx(we,{variant:"ghost",size:"sm",onClick:W=>z(D,W),className:"h-6 w-6 p-0",title:"Edit title",children:i.jsx(q.Edit3,{size:12})}),n&&i.jsx(we,{variant:"ghost",size:"sm",onClick:W=>L(D.threadId,W),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:i.jsx(q.Trash2,{size:12})})]})]}),a===D.threadId&&i.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},D.threadId))})})]})}const tl=N.createContext(null);function Tb({children:e,basePath:t="/chat"}){const n=N.useMemo(()=>t?t==="/"?"":t.endsWith("/")?t.slice(0,-1):t:"/chat",[t]),r={basePath:n,buildThreadPath:o=>`${n}/${o}`,buildBasePath:()=>n};return i.jsx(tl.Provider,{value:r,children:e})}function Ab(){const e=N.useContext(tl);return e||{basePath:"/chat",buildThreadPath:t=>`/chat/${t}`,buildBasePath:()=>"/chat"}}const nl={BASE_URL:"/",DEV:!1,MODE:"library",PROD:!0,SSR:!1};function yn(e){var o;const t=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Vr&&Vr.tagName.toUpperCase()==="SCRIPT"&&Vr.src||new URL("index.umd.js",document.baseURI).href}<"u"&&nl?nl[e]:void 0,n=(o=globalThis==null?void 0:globalThis.process)==null?void 0:o.env,r=n?n[e]:void 0;return(t??r)||void 0}function Ib(){return yn("VITE_API_BASE_URL")||yn("NEXT_PUBLIC_API_BASE_URL")||void 0}function kb(){return yn("VITE_API_KEY")||yn("NEXT_PUBLIC_API_KEY")||yn("VITE_AUTH_TOKEN")||void 0}function rl(){const e=Ib(),t=kb(),n={};return e&&(n.baseUrl=e),t&&(n.apiKey=t),n}function ol(){const e=rl(),t=ut.getAuthToken();return{apiBaseUrl:e.baseUrl||ut.baseUrl||"http://localhost:8000",apiKey:t||e.apiKey||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const sl="chat-settings";function _b(){try{const e=localStorage.getItem(sl);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Pb(e){try{localStorage.setItem(sl,JSON.stringify(e)),e.apiKey&&ut.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Ob(){const e=ol(),t=_b(),n=ut.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:ut.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function Mb(e){e.apiKey&&ut.setAuthToken(e.apiKey),Pb(e)}const ss=768;function Db(){const[e,t]=l.useState(void 0);return l.useEffect(()=>{const n=window.matchMedia(`(max-width: ${ss-1}px)`),r=()=>{t(window.innerWidth<ss)};return n.addEventListener("change",r),t(window.innerWidth<ss),()=>n.removeEventListener("change",r)},[]),!!e}var Lb="Separator",al="horizontal",Fb=["horizontal","vertical"],il=l.forwardRef((e,t)=>{const{decorative:n,orientation:r=al,...o}=e,s=$b(r)?r:al,c=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return i.jsx(oe.div,{"data-orientation":s,...c,...o,ref:t})});il.displayName=Lb;function $b(e){return Fb.includes(e)}var cl=il;const as=l.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>i.jsx(cl,{ref:o,decorative:n,orientation:t,className:A("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));as.displayName=cl.displayName;var wr="Dialog",[ll,ly]=Ke(wr),[Bb,Ye]=ll(wr),dl=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:a=!0}=e,c=l.useRef(null),d=l.useRef(null),[f,u]=mt({prop:r,defaultProp:o??!1,onChange:s,caller:wr});return i.jsx(Bb,{scope:t,triggerRef:c,contentRef:d,contentId:Ge(),titleId:Ge(),descriptionId:Ge(),open:f,onOpenChange:u,onOpenToggle:l.useCallback(()=>u(p=>!p),[u]),modal:a,children:n})};dl.displayName=wr;var ul="DialogTrigger",fl=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ye(ul,n),s=ue(t,o.triggerRef);return i.jsx(oe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ls(o.open),...r,ref:s,onClick:U(e.onClick,o.onOpenToggle)})});fl.displayName=ul;var is="DialogPortal",[Ub,pl]=ll(is,{forceMount:void 0}),hl=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Ye(is,t);return i.jsx(Ub,{scope:t,forceMount:n,children:l.Children.map(r,a=>i.jsx(Le,{present:n||s.open,children:i.jsx(er,{asChild:!0,container:o,children:a})}))})};hl.displayName=is;var yr="DialogOverlay",gl=l.forwardRef((e,t)=>{const n=pl(yr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Ye(yr,e.__scopeDialog);return s.modal?i.jsx(Le,{present:r||s.open,children:i.jsx(zb,{...o,ref:t})}):null});gl.displayName=yr;var Hb=Be.createSlot("DialogOverlay.RemoveScroll"),zb=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ye(yr,n);return i.jsx(cr,{as:Hb,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(oe.div,{"data-state":ls(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),_t="DialogContent",ml=l.forwardRef((e,t)=>{const n=pl(_t,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Ye(_t,e.__scopeDialog);return i.jsx(Le,{present:r||s.open,children:s.modal?i.jsx(Wb,{...o,ref:t}):i.jsx(Vb,{...o,ref:t})})});ml.displayName=_t;var Wb=l.forwardRef((e,t)=>{const n=Ye(_t,e.__scopeDialog),r=l.useRef(null),o=ue(t,n.contentRef,r);return l.useEffect(()=>{const s=r.current;if(s)return zo(s)},[]),i.jsx(bl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:U(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:U(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0;(a.button===2||c)&&s.preventDefault()}),onFocusOutside:U(e.onFocusOutside,s=>s.preventDefault())})}),Vb=l.forwardRef((e,t)=>{const n=Ye(_t,e.__scopeDialog),r=l.useRef(!1),o=l.useRef(!1);return i.jsx(bl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,c;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var d,f;(d=e.onInteractOutside)==null||d.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=s.target;((f=n.triggerRef.current)==null?void 0:f.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),bl=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=e,c=Ye(_t,n),d=l.useRef(null),f=ue(t,d);return vo(),i.jsxs(i.Fragment,{children:[i.jsx(Vn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:i.jsx(cn,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":ls(c.open),...a,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(jb,{titleId:c.titleId}),i.jsx(Kb,{contentRef:d,descriptionId:c.descriptionId})]})]})}),cs="DialogTitle",vl=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ye(cs,n);return i.jsx(oe.h2,{id:o.titleId,...r,ref:t})});vl.displayName=cs;var wl="DialogDescription",yl=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ye(wl,n);return i.jsx(oe.p,{id:o.descriptionId,...r,ref:t})});yl.displayName=wl;var xl="DialogClose",Sl=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ye(xl,n);return i.jsx(oe.button,{type:"button",...r,ref:t,onClick:U(e.onClick,()=>o.onOpenChange(!1))})});Sl.displayName=xl;function ls(e){return e?"open":"closed"}var Cl="DialogTitleWarning",[dy,El]=Uf(Cl,{contentName:_t,titleName:cs,docsSlug:"dialog"}),jb=({titleId:e})=>{const t=El(Cl),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
59
59
 
60
60
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
61
61
 
62
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return l.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},jb="DialogDescriptionWarning",Vb=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Cl(jb).contentName}}.`;return l.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Rb=ll,Kb=ul,Gb=pl,El=hl,Nl=gl,Tl=bl,Al=wl,qb=xl;const Il=Rb,Xb=Kb,Yb=Gb,kl=l.forwardRef(({className:e,...t},n)=>i.jsx(El,{className:A("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));kl.displayName=El.displayName;const Jb=Yt.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),ls=l.forwardRef(({side:e="right",className:t,children:n,...r},o)=>i.jsxs(Yb,{children:[i.jsx(kl,{}),i.jsxs(Nl,{ref:o,className:A(Jb({side:e}),t),...r,children:[n,i.jsxs(qb,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[i.jsx(q.X,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ls.displayName=Nl.displayName;const _l=({className:e,...t})=>i.jsx("div",{className:A("flex flex-col space-y-2 text-center sm:text-left",e),...t});_l.displayName="SheetHeader";const Pl=l.forwardRef(({className:e,...t},n)=>i.jsx(Tl,{ref:n,className:A("text-lg font-semibold text-foreground",e),...t}));Pl.displayName=Tl.displayName;const Ol=l.forwardRef(({className:e,...t},n)=>i.jsx(Al,{ref:n,className:A("text-sm text-muted-foreground",e),...t}));Ol.displayName=Al.displayName;function Ml({className:e,...t}){return i.jsx("div",{className:A("animate-pulse rounded-md bg-muted",e),...t})}var Dl=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"}),Zb="VisuallyHidden",Ll=l.forwardRef((e,t)=>i.jsx(oe.span,{...e,ref:t,style:{...Dl,...e.style}}));Ll.displayName=Zb;var Qb=Ll,[yr,ly]=Re("Tooltip",[Wt]),xr=Wt(),Fl="TooltipProvider",ev=700,ds="tooltip.open",[tv,us]=yr(Fl),$l=e=>{const{__scopeTooltip:t,delayDuration:n=ev,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,a=l.useRef(!0),c=l.useRef(!1),d=l.useRef(0);return l.useEffect(()=>{const f=d.current;return()=>window.clearTimeout(f)},[]),i.jsx(tv,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:l.useCallback(()=>{window.clearTimeout(d.current),a.current=!1},[]),onClose:l.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:l.useCallback(f=>{c.current=f},[]),disableHoverableContent:o,children:s})};$l.displayName=Fl;var yn="Tooltip",[nv,Sr]=yr(yn),Bl=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:a,delayDuration:c}=e,d=us(yn,e.__scopeTooltip),f=xr(t),[u,p]=l.useState(null),m=Ke(),v=l.useRef(0),g=a??d.disableHoverableContent,h=c??d.delayDuration,b=l.useRef(!1),[w,y]=gt({prop:r,defaultProp:o??!1,onChange:T=>{T?(d.onOpen(),document.dispatchEvent(new CustomEvent(ds))):d.onClose(),s==null||s(T)},caller:yn}),x=l.useMemo(()=>w?b.current?"delayed-open":"instant-open":"closed",[w]),C=l.useCallback(()=>{window.clearTimeout(v.current),v.current=0,b.current=!1,y(!0)},[y]),E=l.useCallback(()=>{window.clearTimeout(v.current),v.current=0,y(!1)},[y]),P=l.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{b.current=!0,y(!0),v.current=0},h)},[h,y]);return l.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),i.jsx(Mo,{...f,children:i.jsx(nv,{scope:t,contentId:m,open:w,stateAttribute:x,trigger:u,onTriggerChange:p,onTriggerEnter:l.useCallback(()=>{d.isOpenDelayedRef.current?P():C()},[d.isOpenDelayedRef,P,C]),onTriggerLeave:l.useCallback(()=>{g?E():(window.clearTimeout(v.current),v.current=0)},[E,g]),onOpen:C,onClose:E,disableHoverableContent:g,children:n})})};Bl.displayName=yn;var fs="TooltipTrigger",Ul=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Sr(fs,n),s=us(fs,n),a=xr(n),c=l.useRef(null),d=ue(t,c,o.onTriggerChange),f=l.useRef(!1),u=l.useRef(!1),p=l.useCallback(()=>f.current=!1,[]);return l.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),i.jsx(Do,{asChild:!0,...a,children:i.jsx(oe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:d,onPointerMove:U(e.onPointerMove,m=>{m.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),u.current=!0)}),onPointerLeave:U(e.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:U(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:U(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:U(e.onBlur,o.onClose),onClick:U(e.onClick,o.onClose)})})});Ul.displayName=fs;var rv="TooltipPortal",[dy,ov]=yr(rv,{forceMount:void 0}),qt="TooltipContent",Hl=l.forwardRef((e,t)=>{const n=ov(qt,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,a=Sr(qt,e.__scopeTooltip);return i.jsx(Le,{present:r||a.open,children:a.disableHoverableContent?i.jsx(zl,{side:o,...s,ref:t}):i.jsx(sv,{side:o,...s,ref:t})})}),sv=l.forwardRef((e,t)=>{const n=Sr(qt,e.__scopeTooltip),r=us(qt,e.__scopeTooltip),o=l.useRef(null),s=ue(t,o),[a,c]=l.useState(null),{trigger:d,onClose:f}=n,u=o.current,{onPointerInTransitChange:p}=r,m=l.useCallback(()=>{c(null),p(!1)},[p]),v=l.useCallback((g,h)=>{const b=g.currentTarget,w={x:g.clientX,y:g.clientY},y=dv(w,b.getBoundingClientRect()),x=uv(w,y),C=fv(h.getBoundingClientRect()),E=hv([...x,...C]);c(E),p(!0)},[p]);return l.useEffect(()=>()=>m(),[m]),l.useEffect(()=>{if(d&&u){const g=b=>v(b,u),h=b=>v(b,d);return d.addEventListener("pointerleave",g),u.addEventListener("pointerleave",h),()=>{d.removeEventListener("pointerleave",g),u.removeEventListener("pointerleave",h)}}},[d,u,v,m]),l.useEffect(()=>{if(a){const g=h=>{const b=h.target,w={x:h.clientX,y:h.clientY},y=(d==null?void 0:d.contains(b))||(u==null?void 0:u.contains(b)),x=!pv(w,a);y?m():x&&(m(),f())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[d,u,a,f,m]),i.jsx(zl,{...e,ref:s})}),[av,iv]=yr(yn,{isInside:!1}),cv=Be.createSlottable("TooltipContent"),zl=l.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:a,...c}=e,d=Sr(qt,n),f=xr(n),{onClose:u}=d;return l.useEffect(()=>(document.addEventListener(ds,u),()=>document.removeEventListener(ds,u)),[u]),l.useEffect(()=>{if(d.trigger){const p=m=>{const v=m.target;v!=null&&v.contains(d.trigger)&&u()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[d.trigger,u]),i.jsx(an,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:p=>p.preventDefault(),onDismiss:u,children:i.jsxs(Lo,{"data-state":d.stateAttribute,...f,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[i.jsx(cv,{children:r}),i.jsx(av,{scope:n,isInside:!0,children:i.jsx(Qb,{id:d.contentId,role:"tooltip",children:o||r})})]})})});Hl.displayName=qt;var Wl="TooltipArrow",lv=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=xr(n);return iv(Wl,n).isInside?null:i.jsx(Fo,{...o,...r,ref:t})});lv.displayName=Wl;function dv(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function uv(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function fv(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function pv(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const c=t[s],d=t[a],f=c.x,u=c.y,p=d.x,m=d.y;u>r!=m>r&&n<(p-f)*(r-u)/(m-u)+f&&(o=!o)}return o}function hv(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),gv(t)}function gv(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(o.y-a.y)>=(s.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(o.y-a.y)>=(s.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var mv=$l,bv=Bl,vv=Ul,jl=Hl;const wv=mv,yv=bv,xv=vv,Vl=l.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(jl,{ref:r,sideOffset:t,className:A("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Vl.displayName=jl.displayName;const Sv="sidebar:state",Cv=60*60*24*7,Ev="16rem",Nv="18rem",Tv="3rem",Av="b",Rl=l.createContext(null);function Cr(){const e=l.useContext(Rl);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Kl=l.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:o,children:s,...a},c)=>{const d=Ob(),[f,u]=l.useState(!1),[p,m]=l.useState(e),v=t??p,g=l.useCallback(y=>{const x=typeof y=="function"?y(v):y;n?n(x):m(x),document.cookie=`${Sv}=${x}; path=/; max-age=${Cv}`},[n,v]),h=l.useCallback(()=>d?u(y=>!y):g(y=>!y),[d,g,u]);l.useEffect(()=>{const y=x=>{x.key===Av&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),h())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[h]);const b=v?"expanded":"collapsed",w=l.useMemo(()=>({state:b,open:v,setOpen:g,isMobile:d,openMobile:f,setOpenMobile:u,toggleSidebar:h}),[b,v,g,d,f,u,h]);return i.jsx(Rl.Provider,{value:w,children:i.jsx(wv,{delayDuration:0,children:i.jsx("div",{style:{"--sidebar-width":Ev,"--sidebar-width-icon":Tv,...o},className:A("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:c,...a,children:s})})})});Kl.displayName="SidebarProvider";const Gl=l.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:o,...s},a)=>{const{isMobile:c,state:d,openMobile:f,setOpenMobile:u}=Cr();return n==="none"?i.jsx("div",{className:A("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:a,...s,children:o}):c?i.jsx(Il,{open:f,onOpenChange:u,...s,children:i.jsx(ls,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":Nv},side:e,children:i.jsx("div",{className:"flex h-full w-full flex-col",children:o})})}):i.jsxs("div",{ref:a,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":d==="collapsed"?n:"","data-variant":t,"data-side":e,children:[i.jsx("div",{className:A("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),i.jsx("div",{className:A("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:i.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:o})})]})});Gl.displayName="Sidebar";const ql=l.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:o}=Cr();return i.jsxs(we,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:A("h-7 w-7",e),onClick:s=>{t==null||t(s),o()},...n,children:[i.jsx(q.PanelLeft,{}),i.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});ql.displayName="SidebarTrigger";const Iv=l.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Cr();return i.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:A("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});Iv.displayName="SidebarRail";const Xl=l.forwardRef(({className:e,...t},n)=>i.jsx("main",{ref:n,className:A("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));Xl.displayName="SidebarInset";const kv=l.forwardRef(({className:e,...t},n)=>i.jsx(vn,{ref:n,"data-sidebar":"input",className:A("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));kv.displayName="SidebarInput";const Yl=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"header",className:A("flex flex-col gap-2 p-2",e),...t}));Yl.displayName="SidebarHeader";const _v=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"footer",className:A("flex flex-col gap-2 p-2",e),...t}));_v.displayName="SidebarFooter";const Pv=l.forwardRef(({className:e,...t},n)=>i.jsx(ss,{ref:n,"data-sidebar":"separator",className:A("mx-2 w-auto bg-sidebar-border",e),...t}));Pv.displayName="SidebarSeparator";const Jl=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"content",className:A("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Jl.displayName="SidebarContent";const Zl=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"group",className:A("relative flex w-full min-w-0 flex-col p-2",e),...t}));Zl.displayName="SidebarGroup";const Ql=l.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Be.Slot:"div";return i.jsx(o,{ref:r,"data-sidebar":"group-label",className:A("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});Ql.displayName="SidebarGroupLabel";const Ov=l.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Be.Slot:"button";return i.jsx(o,{ref:r,"data-sidebar":"group-action",className:A("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});Ov.displayName="SidebarGroupAction";const ed=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"group-content",className:A("w-full text-sm",e),...t}));ed.displayName="SidebarGroupContent";const td=l.forwardRef(({className:e,...t},n)=>i.jsx("ul",{ref:n,"data-sidebar":"menu",className:A("flex w-full min-w-0 flex-col gap-1",e),...t}));td.displayName="SidebarMenu";const nd=l.forwardRef(({className:e,...t},n)=>i.jsx("li",{ref:n,"data-sidebar":"menu-item",className:A("group/menu-item relative",e),...t}));nd.displayName="SidebarMenuItem";const Mv=Yt.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),rd=l.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:o,className:s,...a},c)=>{const d=e?Be.Slot:"button",{isMobile:f,state:u}=Cr(),p=i.jsx(d,{ref:c,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:A(Mv({variant:n,size:r}),s),...a});return o?(typeof o=="string"&&(o={children:o}),i.jsxs(yv,{children:[i.jsx(xv,{asChild:!0,children:p}),i.jsx(Vl,{side:"right",align:"center",hidden:u!=="collapsed"||f,...o})]})):p});rd.displayName="SidebarMenuButton";const Dv=l.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},o)=>{const s=t?Be.Slot:"button";return i.jsx(s,{ref:o,"data-sidebar":"menu-action",className:A("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...r})});Dv.displayName="SidebarMenuAction";const Lv=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:A("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));Lv.displayName="SidebarMenuBadge";const Fv=l.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const o=l.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return i.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:A("rounded-md h-8 flex gap-2 px-2 items-center",e),...n,children:[t&&i.jsx(Ml,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),i.jsx(Ml,{className:"h-4 flex-1 max-w-[--skeleton-width]","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});Fv.displayName="SidebarMenuSkeleton";const $v=l.forwardRef(({className:e,...t},n)=>i.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:A("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));$v.displayName="SidebarMenuSub";const Bv=l.forwardRef(({...e},t)=>i.jsx("li",{ref:t,...e}));Bv.displayName="SidebarMenuSubItem";const Uv=l.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...o},s)=>{const a=e?Be.Slot:"a";return i.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:A("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...o})});Uv.displayName="SidebarMenuSubButton";function Hv({header:e,sidebarTitle:t="Threads",showThreads:n=!0,className:r="",sidebarClassName:o="",chatClassName:s="",...a}){return i.jsx(rn,{...a,children:i.jsxs(Kl,{className:`w-full ${r}`,children:[i.jsxs(Gl,{className:`border-r ${o}`,children:[i.jsx(Yl,{children:i.jsx(td,{children:i.jsx(nd,{children:i.jsx(rd,{size:"lg",children:i.jsx("span",{className:"font-semibold",children:t})})})})}),i.jsx(Jl,{children:n&&i.jsxs(Zl,{children:[i.jsx(Ql,{children:"Conversations"}),i.jsx(ed,{children:i.jsx("div",{className:"px-2 py-1",children:i.jsx(br,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-[calc(100vh-12rem)]"})})})]})})]}),i.jsxs(Xl,{children:[i.jsxs("header",{className:"h-14 border-b bg-background/60 backdrop-blur flex items-center gap-2 px-4",children:[i.jsx(ql,{}),i.jsx("div",{className:"flex-1"}),e]}),i.jsx("main",{className:`flex-1 min-h-0 overflow-hidden ${s}`,children:i.jsx(bn,{})})]})]})})}var zv="Label",od=l.forwardRef((e,t)=>i.jsx(oe.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));od.displayName=zv;var sd=od;const Wv=Yt.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),je=l.forwardRef(({className:e,...t},n)=>i.jsx(sd,{ref:n,className:A(Wv(),e),...t}));je.displayName=sd.displayName;function ad(e){const t=l.useRef({value:e,previous:e});return l.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Er="Switch",[jv,uy]=Re(Er),[Vv,Rv]=jv(Er),id=l.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:a,disabled:c,value:d="on",onCheckedChange:f,form:u,...p}=e,[m,v]=l.useState(null),g=ue(t,x=>v(x)),h=l.useRef(!1),b=m?u||!!m.closest("form"):!0,[w,y]=gt({prop:o,defaultProp:s??!1,onChange:f,caller:Er});return i.jsxs(Vv,{scope:n,checked:w,disabled:c,children:[i.jsx(oe.button,{type:"button",role:"switch","aria-checked":w,"aria-required":a,"data-state":ud(w),"data-disabled":c?"":void 0,disabled:c,value:d,...p,ref:g,onClick:U(e.onClick,x=>{y(C=>!C),b&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})}),b&&i.jsx(dd,{control:m,bubbles:!h.current,name:r,value:d,checked:w,required:a,disabled:c,form:u,style:{transform:"translateX(-100%)"}})]})});id.displayName=Er;var cd="SwitchThumb",ld=l.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Rv(cd,n);return i.jsx(oe.span,{"data-state":ud(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ld.displayName=cd;var Kv="SwitchBubbleInput",dd=l.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const a=l.useRef(null),c=ue(a,s),d=ad(n),f=pi(t);return l.useEffect(()=>{const u=a.current;if(!u)return;const p=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(p,"checked").set;if(d!==n&&v){const g=new Event("click",{bubbles:r});v.call(u,n),u.dispatchEvent(g)}},[d,n,r]),i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:c,style:{...o.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});dd.displayName=Kv;function ud(e){return e?"checked":"unchecked"}var fd=id,Gv=ld;const wt=l.forwardRef(({className:e,...t},n)=>i.jsx(fd,{className:A("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:i.jsx(Gv,{className:A("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));wt.displayName=fd.displayName;var qv=[" ","Enter","ArrowUp","ArrowDown"],Xv=[" ","Enter"],_t="Select",[Nr,Tr,Yv]=ho(_t),[Xt,fy]=Re(_t,[Yv,Wt]),Ar=Wt(),[Jv,yt]=Xt(_t),[Zv,Qv]=Xt(_t),pd=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:a,defaultValue:c,onValueChange:d,dir:f,name:u,autoComplete:p,disabled:m,required:v,form:g}=e,h=Ar(t),[b,w]=l.useState(null),[y,x]=l.useState(null),[C,E]=l.useState(!1),P=zn(f),[T,F]=gt({prop:r,defaultProp:o??!1,onChange:s,caller:_t}),[M,B]=gt({prop:a,defaultProp:c,onChange:d,caller:_t}),j=l.useRef(null),Q=b?g||!!b.closest("form"):!0,[H,O]=l.useState(new Set),ne=Array.from(H).map(L=>L.props.value).join(";");return i.jsx(Mo,{...h,children:i.jsxs(Jv,{required:v,scope:t,trigger:b,onTriggerChange:w,valueNode:y,onValueNodeChange:x,valueNodeHasChildren:C,onValueNodeHasChildrenChange:E,contentId:Ke(),value:M,onValueChange:B,open:T,onOpenChange:F,dir:P,triggerPointerDownPosRef:j,disabled:m,children:[i.jsx(Nr.Provider,{scope:t,children:i.jsx(Zv,{scope:e.__scopeSelect,onNativeOptionAdd:l.useCallback(L=>{O(z=>new Set(z).add(L))},[]),onNativeOptionRemove:l.useCallback(L=>{O(z=>{const k=new Set(z);return k.delete(L),k})},[]),children:n})}),Q?i.jsxs($d,{"aria-hidden":!0,required:v,tabIndex:-1,name:u,autoComplete:p,value:M,onChange:L=>B(L.target.value),disabled:m,form:g,children:[M===void 0?i.jsx("option",{value:""}):null,Array.from(H)]},ne):null]})})};pd.displayName=_t;var hd="SelectTrigger",gd=l.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Ar(n),a=yt(hd,n),c=a.disabled||r,d=ue(t,a.onTriggerChange),f=Tr(n),u=l.useRef("touch"),[p,m,v]=Ud(h=>{const b=f().filter(x=>!x.disabled),w=b.find(x=>x.value===a.value),y=Hd(b,h,w);y!==void 0&&a.onValueChange(y.value)}),g=h=>{c||(a.onOpenChange(!0),v()),h&&(a.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return i.jsx(Do,{asChild:!0,...s,children:i.jsx(oe.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":Bd(a.value)?"":void 0,...o,ref:d,onClick:U(o.onClick,h=>{h.currentTarget.focus(),u.current!=="mouse"&&g(h)}),onPointerDown:U(o.onPointerDown,h=>{u.current=h.pointerType;const b=h.target;b.hasPointerCapture(h.pointerId)&&b.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(g(h),h.preventDefault())}),onKeyDown:U(o.onKeyDown,h=>{const b=p.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&m(h.key),!(b&&h.key===" ")&&qv.includes(h.key)&&(g(),h.preventDefault())})})})});gd.displayName=hd;var md="SelectValue",bd=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:a="",...c}=e,d=yt(md,n),{onValueNodeHasChildrenChange:f}=d,u=s!==void 0,p=ue(t,d.onValueNodeChange);return Ne(()=>{f(u)},[f,u]),i.jsx(oe.span,{...c,ref:p,style:{pointerEvents:"none"},children:Bd(d.value)?i.jsx(i.Fragment,{children:a}):s})});bd.displayName=md;var ew="SelectIcon",vd=l.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return i.jsx(oe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});vd.displayName=ew;var tw="SelectPortal",wd=e=>i.jsx(Qn,{asChild:!0,...e});wd.displayName=tw;var Pt="SelectContent",yd=l.forwardRef((e,t)=>{const n=yt(Pt,e.__scopeSelect),[r,o]=l.useState();if(Ne(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Nn.createPortal(i.jsx(xd,{scope:e.__scopeSelect,children:i.jsx(Nr.Slot,{scope:e.__scopeSelect,children:i.jsx("div",{children:e.children})})}),s):null}return i.jsx(Sd,{...e,ref:t})});yd.displayName=Pt;var Ye=10,[xd,xt]=Xt(Pt),nw="SelectContentImpl",rw=Be.createSlot("SelectContent.RemoveScroll"),Sd=l.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:a,side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:p,collisionBoundary:m,collisionPadding:v,sticky:g,hideWhenDetached:h,avoidCollisions:b,...w}=e,y=yt(Pt,n),[x,C]=l.useState(null),[E,P]=l.useState(null),T=ue(t,R=>C(R)),[F,M]=l.useState(null),[B,j]=l.useState(null),Q=Tr(n),[H,O]=l.useState(!1),ne=l.useRef(!1);l.useEffect(()=>{if(x)return Ho(x)},[x]),bo();const L=l.useCallback(R=>{const[le,...he]=Q().map(ge=>ge.ref.current),[de]=he.slice(-1),be=document.activeElement;for(const ge of R)if(ge===be||(ge==null||ge.scrollIntoView({block:"nearest"}),ge===le&&E&&(E.scrollTop=0),ge===de&&E&&(E.scrollTop=E.scrollHeight),ge==null||ge.focus(),document.activeElement!==be))return},[Q,E]),z=l.useCallback(()=>L([F,x]),[L,F,x]);l.useEffect(()=>{H&&z()},[H,z]);const{onOpenChange:k,triggerPointerDownPosRef:I}=y;l.useEffect(()=>{if(x){let R={x:0,y:0};const le=de=>{var be,ge;R={x:Math.abs(Math.round(de.pageX)-(((be=I.current)==null?void 0:be.x)??0)),y:Math.abs(Math.round(de.pageY)-(((ge=I.current)==null?void 0:ge.y)??0))}},he=de=>{R.x<=10&&R.y<=10?de.preventDefault():x.contains(de.target)||k(!1),document.removeEventListener("pointermove",le),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",le),document.addEventListener("pointerup",he,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",le),document.removeEventListener("pointerup",he,{capture:!0})}}},[x,k,I]),l.useEffect(()=>{const R=()=>k(!1);return window.addEventListener("blur",R),window.addEventListener("resize",R),()=>{window.removeEventListener("blur",R),window.removeEventListener("resize",R)}},[k]);const[ee,V]=Ud(R=>{const le=Q().filter(be=>!be.disabled),he=le.find(be=>be.ref.current===document.activeElement),de=Hd(le,R,he);de&&setTimeout(()=>de.ref.current.focus())}),te=l.useCallback((R,le,he)=>{const de=!ne.current&&!he;(y.value!==void 0&&y.value===le||de)&&(M(R),de&&(ne.current=!0))},[y.value]),D=l.useCallback(()=>x==null?void 0:x.focus(),[x]),W=l.useCallback((R,le,he)=>{const de=!ne.current&&!he;(y.value!==void 0&&y.value===le||de)&&j(R)},[y.value]),xe=r==="popper"?ps:Cd,ie=xe===ps?{side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:p,collisionBoundary:m,collisionPadding:v,sticky:g,hideWhenDetached:h,avoidCollisions:b}:{};return i.jsx(xd,{scope:n,content:x,viewport:E,onViewportChange:P,itemRefCallback:te,selectedItem:F,onItemLeave:D,itemTextRefCallback:W,focusSelectedItem:z,selectedItemText:B,position:r,isPositioned:H,searchRef:ee,children:i.jsx(ir,{as:rw,allowPinchZoom:!0,children:i.jsx(Wn,{asChild:!0,trapped:y.open,onMountAutoFocus:R=>{R.preventDefault()},onUnmountAutoFocus:U(o,R=>{var le;(le=y.trigger)==null||le.focus({preventScroll:!0}),R.preventDefault()}),children:i.jsx(an,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:R=>R.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:i.jsx(xe,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:R=>R.preventDefault(),...w,...ie,onPlaced:()=>O(!0),ref:T,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:U(w.onKeyDown,R=>{const le=R.ctrlKey||R.altKey||R.metaKey;if(R.key==="Tab"&&R.preventDefault(),!le&&R.key.length===1&&V(R.key),["ArrowUp","ArrowDown","Home","End"].includes(R.key)){let de=Q().filter(be=>!be.disabled).map(be=>be.ref.current);if(["ArrowUp","End"].includes(R.key)&&(de=de.slice().reverse()),["ArrowUp","ArrowDown"].includes(R.key)){const be=R.target,ge=de.indexOf(be);de=de.slice(ge+1)}setTimeout(()=>L(de)),R.preventDefault()}})})})})})})});Sd.displayName=nw;var ow="SelectItemAlignedPosition",Cd=l.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=yt(Pt,n),a=xt(Pt,n),[c,d]=l.useState(null),[f,u]=l.useState(null),p=ue(t,T=>u(T)),m=Tr(n),v=l.useRef(!1),g=l.useRef(!0),{viewport:h,selectedItem:b,selectedItemText:w,focusSelectedItem:y}=a,x=l.useCallback(()=>{if(s.trigger&&s.valueNode&&c&&f&&h&&b&&w){const T=s.trigger.getBoundingClientRect(),F=f.getBoundingClientRect(),M=s.valueNode.getBoundingClientRect(),B=w.getBoundingClientRect();if(s.dir!=="rtl"){const be=B.left-F.left,ge=M.left-be,G=T.left-ge,Y=T.width+G,ye=Math.max(Y,F.width),se=window.innerWidth-Ye,Se=Qo(ge,[Ye,Math.max(Ye,se-ye)]);c.style.minWidth=Y+"px",c.style.left=Se+"px"}else{const be=F.right-B.right,ge=window.innerWidth-M.right-be,G=window.innerWidth-T.right-ge,Y=T.width+G,ye=Math.max(Y,F.width),se=window.innerWidth-Ye,Se=Qo(ge,[Ye,Math.max(Ye,se-ye)]);c.style.minWidth=Y+"px",c.style.right=Se+"px"}const j=m(),Q=window.innerHeight-Ye*2,H=h.scrollHeight,O=window.getComputedStyle(f),ne=parseInt(O.borderTopWidth,10),L=parseInt(O.paddingTop,10),z=parseInt(O.borderBottomWidth,10),k=parseInt(O.paddingBottom,10),I=ne+L+H+k+z,ee=Math.min(b.offsetHeight*5,I),V=window.getComputedStyle(h),te=parseInt(V.paddingTop,10),D=parseInt(V.paddingBottom,10),W=T.top+T.height/2-Ye,xe=Q-W,ie=b.offsetHeight/2,R=b.offsetTop+ie,le=ne+L+R,he=I-le;if(le<=W){const be=j.length>0&&b===j[j.length-1].ref.current;c.style.bottom="0px";const ge=f.clientHeight-h.offsetTop-h.offsetHeight,G=Math.max(xe,ie+(be?D:0)+ge+z),Y=le+G;c.style.height=Y+"px"}else{const be=j.length>0&&b===j[0].ref.current;c.style.top="0px";const G=Math.max(W,ne+h.offsetTop+(be?te:0)+ie)+he;c.style.height=G+"px",h.scrollTop=le-W+h.offsetTop}c.style.margin=`${Ye}px 0`,c.style.minHeight=ee+"px",c.style.maxHeight=Q+"px",r==null||r(),requestAnimationFrame(()=>v.current=!0)}},[m,s.trigger,s.valueNode,c,f,h,b,w,s.dir,r]);Ne(()=>x(),[x]);const[C,E]=l.useState();Ne(()=>{f&&E(window.getComputedStyle(f).zIndex)},[f]);const P=l.useCallback(T=>{T&&g.current===!0&&(x(),y==null||y(),g.current=!1)},[x,y]);return i.jsx(aw,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:v,onScrollButtonChange:P,children:i.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:C},children:i.jsx(oe.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Cd.displayName=ow;var sw="SelectPopperPosition",ps=l.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Ye,...s}=e,a=Ar(n);return i.jsx(Lo,{...a,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});ps.displayName=sw;var[aw,hs]=Xt(Pt,{}),gs="SelectViewport",Ed=l.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=xt(gs,n),a=hs(gs,n),c=ue(t,s.onViewportChange),d=l.useRef(0);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),i.jsx(Nr.Slot,{scope:n,children:i.jsx(oe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:U(o.onScroll,f=>{const u=f.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=a;if(m!=null&&m.current&&p){const v=Math.abs(d.current-u.scrollTop);if(v>0){const g=window.innerHeight-Ye*2,h=parseFloat(p.style.minHeight),b=parseFloat(p.style.height),w=Math.max(h,b);if(w<g){const y=w+v,x=Math.min(g,y),C=y-x;p.style.height=x+"px",p.style.bottom==="0px"&&(u.scrollTop=C>0?C:0,p.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})});Ed.displayName=gs;var Nd="SelectGroup",[iw,cw]=Xt(Nd),lw=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ke();return i.jsx(iw,{scope:n,id:o,children:i.jsx(oe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});lw.displayName=Nd;var Td="SelectLabel",Ad=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=cw(Td,n);return i.jsx(oe.div,{id:o.id,...r,ref:t})});Ad.displayName=Td;var Ir="SelectItem",[dw,Id]=Xt(Ir),kd=l.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...a}=e,c=yt(Ir,n),d=xt(Ir,n),f=c.value===r,[u,p]=l.useState(s??""),[m,v]=l.useState(!1),g=ue(t,y=>{var x;return(x=d.itemRefCallback)==null?void 0:x.call(d,y,r,o)}),h=Ke(),b=l.useRef("touch"),w=()=>{o||(c.onValueChange(r),c.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return i.jsx(dw,{scope:n,value:r,disabled:o,textId:h,isSelected:f,onItemTextChange:l.useCallback(y=>{p(x=>x||((y==null?void 0:y.textContent)??"").trim())},[]),children:i.jsx(Nr.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:i.jsx(oe.div,{role:"option","aria-labelledby":h,"data-highlighted":m?"":void 0,"aria-selected":f&&m,"data-state":f?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:g,onFocus:U(a.onFocus,()=>v(!0)),onBlur:U(a.onBlur,()=>v(!1)),onClick:U(a.onClick,()=>{b.current!=="mouse"&&w()}),onPointerUp:U(a.onPointerUp,()=>{b.current==="mouse"&&w()}),onPointerDown:U(a.onPointerDown,y=>{b.current=y.pointerType}),onPointerMove:U(a.onPointerMove,y=>{var x;b.current=y.pointerType,o?(x=d.onItemLeave)==null||x.call(d):b.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:U(a.onPointerLeave,y=>{var x;y.currentTarget===document.activeElement&&((x=d.onItemLeave)==null||x.call(d))}),onKeyDown:U(a.onKeyDown,y=>{var C;((C=d.searchRef)==null?void 0:C.current)!==""&&y.key===" "||(Xv.includes(y.key)&&w(),y.key===" "&&y.preventDefault())})})})})});kd.displayName=Ir;var xn="SelectItemText",_d=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,a=yt(xn,n),c=xt(xn,n),d=Id(xn,n),f=Qv(xn,n),[u,p]=l.useState(null),m=ue(t,w=>p(w),d.onItemTextChange,w=>{var y;return(y=c.itemTextRefCallback)==null?void 0:y.call(c,w,d.value,d.disabled)}),v=u==null?void 0:u.textContent,g=l.useMemo(()=>i.jsx("option",{value:d.value,disabled:d.disabled,children:v},d.value),[d.disabled,d.value,v]),{onNativeOptionAdd:h,onNativeOptionRemove:b}=f;return Ne(()=>(h(g),()=>b(g)),[h,b,g]),i.jsxs(i.Fragment,{children:[i.jsx(oe.span,{id:d.textId,...s,ref:m}),d.isSelected&&a.valueNode&&!a.valueNodeHasChildren?Nn.createPortal(s.children,a.valueNode):null]})});_d.displayName=xn;var Pd="SelectItemIndicator",Od=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Id(Pd,n).isSelected?i.jsx(oe.span,{"aria-hidden":!0,...r,ref:t}):null});Od.displayName=Pd;var ms="SelectScrollUpButton",Md=l.forwardRef((e,t)=>{const n=xt(ms,e.__scopeSelect),r=hs(ms,e.__scopeSelect),[o,s]=l.useState(!1),a=ue(t,r.onScrollButtonChange);return Ne(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollTop>0;s(f)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?i.jsx(Ld,{...e,ref:a,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});Md.displayName=ms;var bs="SelectScrollDownButton",Dd=l.forwardRef((e,t)=>{const n=xt(bs,e.__scopeSelect),r=hs(bs,e.__scopeSelect),[o,s]=l.useState(!1),a=ue(t,r.onScrollButtonChange);return Ne(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollHeight-d.clientHeight,u=Math.ceil(d.scrollTop)<f;s(u)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?i.jsx(Ld,{...e,ref:a,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});Dd.displayName=bs;var Ld=l.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=xt("SelectScrollButton",n),a=l.useRef(null),c=Tr(n),d=l.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return l.useEffect(()=>()=>d(),[d]),Ne(()=>{var u;const f=c().find(p=>p.ref.current===document.activeElement);(u=f==null?void 0:f.ref.current)==null||u.scrollIntoView({block:"nearest"})},[c]),i.jsx(oe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:U(o.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(r,50))}),onPointerMove:U(o.onPointerMove,()=>{var f;(f=s.onItemLeave)==null||f.call(s),a.current===null&&(a.current=window.setInterval(r,50))}),onPointerLeave:U(o.onPointerLeave,()=>{d()})})}),uw="SelectSeparator",Fd=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return i.jsx(oe.div,{"aria-hidden":!0,...r,ref:t})});Fd.displayName=uw;var vs="SelectArrow",fw=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ar(n),s=yt(vs,n),a=xt(vs,n);return s.open&&a.position==="popper"?i.jsx(Fo,{...o,...r,ref:t}):null});fw.displayName=vs;var pw="SelectBubbleInput",$d=l.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=l.useRef(null),s=ue(r,o),a=ad(t);return l.useEffect(()=>{const c=o.current;if(!c)return;const d=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(d,"value").set;if(a!==t&&u){const p=new Event("change",{bubbles:!0});u.call(c,t),c.dispatchEvent(p)}},[a,t]),i.jsx(oe.select,{...n,style:{...Dl,...n.style},ref:s,defaultValue:t})});$d.displayName=pw;function Bd(e){return e===""||e===void 0}function Ud(e){const t=Ae(e),n=l.useRef(""),r=l.useRef(0),o=l.useCallback(a=>{const c=n.current+a;t(c),function d(f){n.current=f,window.clearTimeout(r.current),f!==""&&(r.current=window.setTimeout(()=>d(""),1e3))}(c)},[t]),s=l.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Hd(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let a=hw(e,Math.max(s,0));o.length===1&&(a=a.filter(f=>f!==n));const d=a.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function hw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var gw=pd,zd=gd,mw=bd,bw=vd,vw=wd,Wd=yd,ww=Ed,jd=Ad,Vd=kd,yw=_d,xw=Od,Rd=Md,Kd=Dd,Gd=Fd;const qd=gw,Xd=mw,ws=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(zd,{ref:r,className:A("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,i.jsx(bw,{asChild:!0,children:i.jsx(q.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ws.displayName=zd.displayName;const Yd=l.forwardRef(({className:e,...t},n)=>i.jsx(Rd,{ref:n,className:A("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(q.ChevronUp,{className:"h-4 w-4"})}));Yd.displayName=Rd.displayName;const Jd=l.forwardRef(({className:e,...t},n)=>i.jsx(Kd,{ref:n,className:A("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(q.ChevronDown,{className:"h-4 w-4"})}));Jd.displayName=Kd.displayName;const ys=l.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>i.jsx(vw,{children:i.jsxs(Wd,{ref:o,className:A("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",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,...r,children:[i.jsx(Yd,{}),i.jsx(ww,{className:A("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),i.jsx(Jd,{})]})}));ys.displayName=Wd.displayName;const Sw=l.forwardRef(({className:e,...t},n)=>i.jsx(jd,{ref:n,className:A("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Sw.displayName=jd.displayName;const Ot=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(Vd,{ref:r,className:A("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(xw,{children:i.jsx(q.Check,{className:"h-4 w-4"})})}),i.jsx(yw,{children:t})]}));Ot.displayName=Vd.displayName;const Cw=l.forwardRef(({className:e,...t},n)=>i.jsx(Gd,{ref:n,className:A("-mx-1 my-1 h-px bg-muted",e),...t}));Cw.displayName=Gd.displayName;const kr=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));kr.displayName="Card";const _r=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("flex flex-col space-y-1.5 p-6",e),...t}));_r.displayName="CardHeader";const Pr=l.forwardRef(({className:e,...t},n)=>i.jsx("h3",{ref:n,className:A("text-2xl font-semibold leading-none tracking-tight",e),...t}));Pr.displayName="CardTitle";const Ew=l.forwardRef(({className:e,...t},n)=>i.jsx("p",{ref:n,className:A("text-sm text-muted-foreground",e),...t}));Ew.displayName="CardDescription";const Or=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("p-6 pt-0",e),...t}));Or.displayName="CardContent";const Nw=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("flex items-center p-6 pt-0",e),...t}));Nw.displayName="CardFooter";const Tw=1,Aw=1e6;let xs=0;function Iw(){return xs=(xs+1)%Number.MAX_SAFE_INTEGER,xs.toString()}const Ss=new Map,Zd=e=>{if(Ss.has(e))return;const t=setTimeout(()=>{Ss.delete(e),Sn({type:"REMOVE_TOAST",toastId:e})},Aw);Ss.set(e,t)},kw=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Tw)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?Zd(n):e.toasts.forEach(r=>{Zd(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Mr=[];let Dr={toasts:[]};function Sn(e){Dr=kw(Dr,e),Mr.forEach(t=>{t(Dr)})}function _w({...e}){const t=Iw(),n=o=>Sn({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Sn({type:"DISMISS_TOAST",toastId:t});return Sn({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Pw(){const[e,t]=l.useState(Dr);return l.useEffect(()=>(Mr.push(t),()=>{const n=Mr.indexOf(t);n>-1&&Mr.splice(n,1)}),[e]),{...e,toast:_w,dismiss:n=>Sn({type:"DISMISS_TOAST",toastId:n})}}const Ow={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function Mw({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=N.useState(!1),[s,a]=N.useState(!1),[c,d]=N.useState(e),[f,u]=N.useState(!1),{toast:p}=Pw();N.useEffect(()=>{const b=JSON.stringify(c)!==JSON.stringify(e);u(b)},[c,e]),N.useEffect(()=>{d(e)},[e]);const m=()=>{t(c),u(!1),p({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},v=()=>{d(Ow),u(!0),p({title:"Settings reset",description:"Configuration has been reset to defaults."})},g=()=>{d(e),u(!1),o(!1)},h=async()=>{try{const w=await(await fetch(`${c.api.baseUrl}/health`)).json();p({title:"Connection successful",description:`API is ${w.status||"healthy"}`})}catch{p({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return i.jsxs(Il,{open:r,onOpenChange:o,children:[i.jsx(Xb,{asChild:!0,children:i.jsxs(we,{variant:"outline",size:"sm",className:n,children:[i.jsx(q.Settings,{className:"h-4 w-4 mr-2"}),"Settings",f&&i.jsx(Ca,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),i.jsxs(ls,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[i.jsxs(_l,{children:[i.jsx(Pl,{children:"Chat Settings"}),i.jsx(Ol,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),i.jsxs("div",{className:"space-y-6 py-6",children:[i.jsxs(kr,{children:[i.jsx(_r,{className:"pb-3",children:i.jsxs(Pr,{className:"text-lg flex items-center gap-2",children:[i.jsx(q.Server,{className:"h-5 w-5"}),"API Configuration"]})}),i.jsxs(Or,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(je,{htmlFor:"api-url",children:"API Base URL"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(vn,{id:"api-url",value:c.api.baseUrl,onChange:b=>d(w=>({...w,api:{...w.api,baseUrl:b.target.value}})),placeholder:"http://localhost:8000/api"}),i.jsx(we,{variant:"outline",onClick:h,children:"Test"})]})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(je,{htmlFor:"enable-auth",children:"Enable Authentication"}),i.jsx(wt,{id:"enable-auth",checked:c.api.enableAuth,onCheckedChange:b=>d(w=>({...w,api:{...w.api,enableAuth:b}}))})]}),c.api.enableAuth&&i.jsxs("div",{className:"space-y-2",children:[i.jsx(je,{htmlFor:"auth-token",children:"Authentication Token"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(vn,{id:"auth-token",type:s?"text":"password",value:c.api.authToken,onChange:b=>d(w=>({...w,api:{...w.api,authToken:b.target.value}})),placeholder:"Enter your Bearer token"}),i.jsx(we,{variant:"outline",size:"icon",onClick:()=>a(!s),children:s?i.jsx(q.EyeOff,{className:"h-4 w-4"}):i.jsx(q.Eye,{className:"h-4 w-4"})})]})]})]})]}),i.jsxs(kr,{children:[i.jsx(_r,{className:"pb-3",children:i.jsxs(Pr,{className:"text-lg flex items-center gap-2",children:[i.jsx(q.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),i.jsxs(Or,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(je,{htmlFor:"layout",children:"Layout Style"}),i.jsxs(qd,{value:c.ui.layout,onValueChange:b=>d(w=>({...w,ui:{...w.ui,layout:b}})),children:[i.jsx(ws,{children:i.jsx(Xd,{})}),i.jsxs(ys,{children:[i.jsx(Ot,{value:"sidebar",children:"Sidebar Layout"}),i.jsx(Ot,{value:"fullscreen",children:"Fullscreen"}),i.jsx(Ot,{value:"tabs",children:"Tabbed Interface"})]})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(je,{htmlFor:"theme",children:"Theme"}),i.jsxs(qd,{value:c.ui.theme,onValueChange:b=>d(w=>({...w,ui:{...w.ui,theme:b}})),children:[i.jsx(ws,{children:i.jsx(Xd,{})}),i.jsxs(ys,{children:[i.jsx(Ot,{value:"light",children:"Light"}),i.jsx(Ot,{value:"dark",children:"Dark"}),i.jsx(Ot,{value:"system",children:"System"})]})]})]}),i.jsx(ss,{}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(je,{htmlFor:"show-timestamps",children:"Show Timestamps"}),i.jsx(wt,{id:"show-timestamps",checked:c.ui.showTimestamps,onCheckedChange:b=>d(w=>({...w,ui:{...w.ui,showTimestamps:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(je,{htmlFor:"show-agent-names",children:"Show Agent Names"}),i.jsx(wt,{id:"show-agent-names",checked:c.ui.showAgentNames,onCheckedChange:b=>d(w=>({...w,ui:{...w.ui,showAgentNames:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(je,{htmlFor:"compact-messages",children:"Compact Messages"}),i.jsx(wt,{id:"compact-messages",checked:c.ui.compactMessages,onCheckedChange:b=>d(w=>({...w,ui:{...w.ui,compactMessages:b}}))})]})]})]})]}),i.jsxs(kr,{children:[i.jsx(_r,{className:"pb-3",children:i.jsxs(Pr,{className:"text-lg flex items-center gap-2",children:[i.jsx(q.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),i.jsxs(Or,{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(je,{htmlFor:"auto-save",children:"Auto-save Conversations"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),i.jsx(wt,{id:"auto-save",checked:c.behavior.autoSave,onCheckedChange:b=>d(w=>({...w,behavior:{...w.behavior,autoSave:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(je,{htmlFor:"enable-streaming",children:"Enable Streaming"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),i.jsx(wt,{id:"enable-streaming",checked:c.behavior.enableStreaming,onCheckedChange:b=>d(w=>({...w,behavior:{...w.behavior,enableStreaming:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(je,{htmlFor:"typing-indicator",children:"Typing Indicator"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),i.jsx(wt,{id:"typing-indicator",checked:c.behavior.showTypingIndicator,onCheckedChange:b=>d(w=>({...w,behavior:{...w.behavior,showTypingIndicator:b}}))})]})]})]})]}),i.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[i.jsxs(we,{variant:"outline",onClick:v,children:[i.jsx(q.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(we,{variant:"outline",onClick:g,children:"Cancel"}),i.jsxs(we,{onClick:m,disabled:!f,children:[i.jsx(q.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function Dw({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const a=f=>{const u="h-full";switch(f){case"phone":return`${u} max-w-none`;case"tablet":return`${u} max-w-4xl mx-auto`;case"half-screen":return`${u} max-w-2xl`;case"desktop":default:return`${u} max-w-7xl mx-auto`}},c=f=>({"--chat-sidebar-width":f==="phone"?"100%":f==="tablet"?"280px":f==="half-screen"?"240px":"320px","--chat-message-max-width":f==="phone"?"95%":f==="tablet"?"90%":f==="half-screen"?"85%":"80%","--chat-input-height":f==="phone"?"120px":"100px"}),d=N.useCallback(f=>{var u;(u=s.onThreadChange)==null||u.call(s,f)},[s.onThreadChange]);return e==="fullscreen"?i.jsx(rn,{...s,onThreadChange:d,children:i.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:c(t),children:i.jsx(bn,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?i.jsx(rn,{...s,onThreadChange:d,children:i.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:c(t),children:i.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&i.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:i.jsx(br,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),i.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:i.jsx(bn,{onError:s.onError,enableFileUpload:!0})})]})})}):i.jsx(rn,{...s,onThreadChange:d,children:i.jsxs("div",{className:`${a(t)} flex overflow-hidden ${r} ${o.container||""}`,style:c(t),children:[n&&i.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:i.jsx(br,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),i.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:i.jsx(bn,{onError:s.onError,enableFileUpload:!0})})]})})}ae.Api=$n,ae.ApiClient=$n,ae.ChatApi=$n,ae.ChatInterface=bn,ae.ChatMainLayout=Hv,ae.ChatProvider=rn,ae.ChatRoutingProvider=Eb,ae.ChatSettings=Mw,ae.MarkdownContent=on,ae.MessageComponent=Pa,ae.ThreadManager=br,ae.apiClient=dt,ae.applySettings=Pb,ae.chatApiClient=dt,ae.default=Dw,ae.del=ba,ae.get=Nt,ae.getChatToken=no,ae.getCurrentSettings=_b,ae.getDefaultApiConfig=nl,ae.getDefaultChatSettings=rl,ae.onChatTokenChanged=ga,ae.post=oo,ae.put=ma,ae.setChatToken=ro,ae.stream=Af,ae.useChat=io,ae.useChatRouting=Nb,ae.useChatStream=va,ae.useMessagesReducer=wa,Object.defineProperties(ae,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
62
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return l.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Rb="DialogDescriptionWarning",Kb=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${El(Rb).contentName}}.`;return l.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Gb=dl,qb=fl,Xb=hl,Nl=gl,Tl=ml,Al=vl,Il=yl,Yb=Sl;const kl=Gb,Jb=qb,Zb=Xb,_l=l.forwardRef(({className:e,...t},n)=>i.jsx(Nl,{className:A("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));_l.displayName=Nl.displayName;const Qb=Jt.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),ds=l.forwardRef(({side:e="right",className:t,children:n,...r},o)=>i.jsxs(Zb,{children:[i.jsx(_l,{}),i.jsxs(Tl,{ref:o,className:A(Qb({side:e}),t),...r,children:[n,i.jsxs(Yb,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[i.jsx(q.X,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ds.displayName=Tl.displayName;const Pl=({className:e,...t})=>i.jsx("div",{className:A("flex flex-col space-y-2 text-center sm:text-left",e),...t});Pl.displayName="SheetHeader";const Ol=l.forwardRef(({className:e,...t},n)=>i.jsx(Al,{ref:n,className:A("text-lg font-semibold text-foreground",e),...t}));Ol.displayName=Al.displayName;const Ml=l.forwardRef(({className:e,...t},n)=>i.jsx(Il,{ref:n,className:A("text-sm text-muted-foreground",e),...t}));Ml.displayName=Il.displayName;function Dl({className:e,...t}){return i.jsx("div",{className:A("animate-pulse rounded-md bg-muted",e),...t})}var Ll=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"}),ev="VisuallyHidden",Fl=l.forwardRef((e,t)=>i.jsx(oe.span,{...e,ref:t,style:{...Ll,...e.style}}));Fl.displayName=ev;var tv=Fl,[xr,uy]=Ke("Tooltip",[Vt]),Sr=Vt(),$l="TooltipProvider",nv=700,us="tooltip.open",[rv,fs]=xr($l),Bl=e=>{const{__scopeTooltip:t,delayDuration:n=nv,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,a=l.useRef(!0),c=l.useRef(!1),d=l.useRef(0);return l.useEffect(()=>{const f=d.current;return()=>window.clearTimeout(f)},[]),i.jsx(rv,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:l.useCallback(()=>{window.clearTimeout(d.current),a.current=!1},[]),onClose:l.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:l.useCallback(f=>{c.current=f},[]),disableHoverableContent:o,children:s})};Bl.displayName=$l;var xn="Tooltip",[ov,Cr]=xr(xn),Ul=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:a,delayDuration:c}=e,d=fs(xn,e.__scopeTooltip),f=Sr(t),[u,p]=l.useState(null),m=Ge(),v=l.useRef(0),g=a??d.disableHoverableContent,h=c??d.delayDuration,b=l.useRef(!1),[w,y]=mt({prop:r,defaultProp:o??!1,onChange:T=>{T?(d.onOpen(),document.dispatchEvent(new CustomEvent(us))):d.onClose(),s==null||s(T)},caller:xn}),x=l.useMemo(()=>w?b.current?"delayed-open":"instant-open":"closed",[w]),C=l.useCallback(()=>{window.clearTimeout(v.current),v.current=0,b.current=!1,y(!0)},[y]),E=l.useCallback(()=>{window.clearTimeout(v.current),v.current=0,y(!1)},[y]),P=l.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{b.current=!0,y(!0),v.current=0},h)},[h,y]);return l.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),i.jsx(Do,{...f,children:i.jsx(ov,{scope:t,contentId:m,open:w,stateAttribute:x,trigger:u,onTriggerChange:p,onTriggerEnter:l.useCallback(()=>{d.isOpenDelayedRef.current?P():C()},[d.isOpenDelayedRef,P,C]),onTriggerLeave:l.useCallback(()=>{g?E():(window.clearTimeout(v.current),v.current=0)},[E,g]),onOpen:C,onClose:E,disableHoverableContent:g,children:n})})};Ul.displayName=xn;var ps="TooltipTrigger",Hl=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Cr(ps,n),s=fs(ps,n),a=Sr(n),c=l.useRef(null),d=ue(t,c,o.onTriggerChange),f=l.useRef(!1),u=l.useRef(!1),p=l.useCallback(()=>f.current=!1,[]);return l.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),i.jsx(Lo,{asChild:!0,...a,children:i.jsx(oe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:d,onPointerMove:U(e.onPointerMove,m=>{m.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),u.current=!0)}),onPointerLeave:U(e.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:U(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:U(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:U(e.onBlur,o.onClose),onClick:U(e.onClick,o.onClose)})})});Hl.displayName=ps;var sv="TooltipPortal",[fy,av]=xr(sv,{forceMount:void 0}),Xt="TooltipContent",zl=l.forwardRef((e,t)=>{const n=av(Xt,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,a=Cr(Xt,e.__scopeTooltip);return i.jsx(Le,{present:r||a.open,children:a.disableHoverableContent?i.jsx(Wl,{side:o,...s,ref:t}):i.jsx(iv,{side:o,...s,ref:t})})}),iv=l.forwardRef((e,t)=>{const n=Cr(Xt,e.__scopeTooltip),r=fs(Xt,e.__scopeTooltip),o=l.useRef(null),s=ue(t,o),[a,c]=l.useState(null),{trigger:d,onClose:f}=n,u=o.current,{onPointerInTransitChange:p}=r,m=l.useCallback(()=>{c(null),p(!1)},[p]),v=l.useCallback((g,h)=>{const b=g.currentTarget,w={x:g.clientX,y:g.clientY},y=fv(w,b.getBoundingClientRect()),x=pv(w,y),C=hv(h.getBoundingClientRect()),E=mv([...x,...C]);c(E),p(!0)},[p]);return l.useEffect(()=>()=>m(),[m]),l.useEffect(()=>{if(d&&u){const g=b=>v(b,u),h=b=>v(b,d);return d.addEventListener("pointerleave",g),u.addEventListener("pointerleave",h),()=>{d.removeEventListener("pointerleave",g),u.removeEventListener("pointerleave",h)}}},[d,u,v,m]),l.useEffect(()=>{if(a){const g=h=>{const b=h.target,w={x:h.clientX,y:h.clientY},y=(d==null?void 0:d.contains(b))||(u==null?void 0:u.contains(b)),x=!gv(w,a);y?m():x&&(m(),f())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[d,u,a,f,m]),i.jsx(Wl,{...e,ref:s})}),[cv,lv]=xr(xn,{isInside:!1}),dv=Be.createSlottable("TooltipContent"),Wl=l.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:a,...c}=e,d=Cr(Xt,n),f=Sr(n),{onClose:u}=d;return l.useEffect(()=>(document.addEventListener(us,u),()=>document.removeEventListener(us,u)),[u]),l.useEffect(()=>{if(d.trigger){const p=m=>{const v=m.target;v!=null&&v.contains(d.trigger)&&u()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[d.trigger,u]),i.jsx(cn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:p=>p.preventDefault(),onDismiss:u,children:i.jsxs(Fo,{"data-state":d.stateAttribute,...f,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[i.jsx(dv,{children:r}),i.jsx(cv,{scope:n,isInside:!0,children:i.jsx(tv,{id:d.contentId,role:"tooltip",children:o||r})})]})})});zl.displayName=Xt;var Vl="TooltipArrow",uv=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Sr(n);return lv(Vl,n).isInside?null:i.jsx($o,{...o,...r,ref:t})});uv.displayName=Vl;function fv(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function pv(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function hv(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function gv(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const c=t[s],d=t[a],f=c.x,u=c.y,p=d.x,m=d.y;u>r!=m>r&&n<(p-f)*(r-u)/(m-u)+f&&(o=!o)}return o}function mv(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),bv(t)}function bv(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(o.y-a.y)>=(s.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(o.y-a.y)>=(s.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var vv=Bl,wv=Ul,yv=Hl,jl=zl;const xv=vv,Sv=wv,Cv=yv,Rl=l.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(jl,{ref:r,sideOffset:t,className:A("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Rl.displayName=jl.displayName;const Ev="sidebar:state",Nv=60*60*24*7,Tv="16rem",Av="18rem",Iv="3rem",kv="b",Kl=l.createContext(null);function Er(){const e=l.useContext(Kl);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Gl=l.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:o,children:s,...a},c)=>{const d=Db(),[f,u]=l.useState(!1),[p,m]=l.useState(e),v=t??p,g=l.useCallback(y=>{const x=typeof y=="function"?y(v):y;n?n(x):m(x),document.cookie=`${Ev}=${x}; path=/; max-age=${Nv}`},[n,v]),h=l.useCallback(()=>d?u(y=>!y):g(y=>!y),[d,g,u]);l.useEffect(()=>{const y=x=>{x.key===kv&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),h())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[h]);const b=v?"expanded":"collapsed",w=l.useMemo(()=>({state:b,open:v,setOpen:g,isMobile:d,openMobile:f,setOpenMobile:u,toggleSidebar:h}),[b,v,g,d,f,u,h]);return i.jsx(Kl.Provider,{value:w,children:i.jsx(xv,{delayDuration:0,children:i.jsx("div",{style:{"--sidebar-width":Tv,"--sidebar-width-icon":Iv,...o},className:A("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:c,...a,children:s})})})});Gl.displayName="SidebarProvider";const ql=l.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:o,...s},a)=>{const{isMobile:c,state:d,openMobile:f,setOpenMobile:u}=Er();return n==="none"?i.jsx("div",{className:A("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:a,...s,children:o}):c?i.jsx(kl,{open:f,onOpenChange:u,...s,children:i.jsx(ds,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":Av},side:e,children:i.jsx("div",{className:"flex h-full w-full flex-col",children:o})})}):i.jsxs("div",{ref:a,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":d==="collapsed"?n:"","data-variant":t,"data-side":e,children:[i.jsx("div",{className:A("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),i.jsx("div",{className:A("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:i.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:o})})]})});ql.displayName="Sidebar";const Xl=l.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:o}=Er();return i.jsxs(we,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:A("h-7 w-7",e),onClick:s=>{t==null||t(s),o()},...n,children:[i.jsx(q.PanelLeft,{}),i.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Xl.displayName="SidebarTrigger";const _v=l.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Er();return i.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:A("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});_v.displayName="SidebarRail";const Yl=l.forwardRef(({className:e,...t},n)=>i.jsx("main",{ref:n,className:A("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));Yl.displayName="SidebarInset";const Pv=l.forwardRef(({className:e,...t},n)=>i.jsx(wn,{ref:n,"data-sidebar":"input",className:A("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));Pv.displayName="SidebarInput";const Jl=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"header",className:A("flex flex-col gap-2 p-2",e),...t}));Jl.displayName="SidebarHeader";const Ov=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"footer",className:A("flex flex-col gap-2 p-2",e),...t}));Ov.displayName="SidebarFooter";const Mv=l.forwardRef(({className:e,...t},n)=>i.jsx(as,{ref:n,"data-sidebar":"separator",className:A("mx-2 w-auto bg-sidebar-border",e),...t}));Mv.displayName="SidebarSeparator";const Zl=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"content",className:A("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Zl.displayName="SidebarContent";const Ql=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"group",className:A("relative flex w-full min-w-0 flex-col p-2",e),...t}));Ql.displayName="SidebarGroup";const ed=l.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Be.Slot:"div";return i.jsx(o,{ref:r,"data-sidebar":"group-label",className:A("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});ed.displayName="SidebarGroupLabel";const Dv=l.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Be.Slot:"button";return i.jsx(o,{ref:r,"data-sidebar":"group-action",className:A("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});Dv.displayName="SidebarGroupAction";const td=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"group-content",className:A("w-full text-sm",e),...t}));td.displayName="SidebarGroupContent";const nd=l.forwardRef(({className:e,...t},n)=>i.jsx("ul",{ref:n,"data-sidebar":"menu",className:A("flex w-full min-w-0 flex-col gap-1",e),...t}));nd.displayName="SidebarMenu";const rd=l.forwardRef(({className:e,...t},n)=>i.jsx("li",{ref:n,"data-sidebar":"menu-item",className:A("group/menu-item relative",e),...t}));rd.displayName="SidebarMenuItem";const Lv=Jt.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),od=l.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:o,className:s,...a},c)=>{const d=e?Be.Slot:"button",{isMobile:f,state:u}=Er(),p=i.jsx(d,{ref:c,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:A(Lv({variant:n,size:r}),s),...a});return o?(typeof o=="string"&&(o={children:o}),i.jsxs(Sv,{children:[i.jsx(Cv,{asChild:!0,children:p}),i.jsx(Rl,{side:"right",align:"center",hidden:u!=="collapsed"||f,...o})]})):p});od.displayName="SidebarMenuButton";const Fv=l.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},o)=>{const s=t?Be.Slot:"button";return i.jsx(s,{ref:o,"data-sidebar":"menu-action",className:A("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...r})});Fv.displayName="SidebarMenuAction";const $v=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:A("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));$v.displayName="SidebarMenuBadge";const Bv=l.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const o=l.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return i.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:A("rounded-md h-8 flex gap-2 px-2 items-center",e),...n,children:[t&&i.jsx(Dl,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),i.jsx(Dl,{className:"h-4 flex-1 max-w-[--skeleton-width]","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});Bv.displayName="SidebarMenuSkeleton";const Uv=l.forwardRef(({className:e,...t},n)=>i.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:A("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));Uv.displayName="SidebarMenuSub";const Hv=l.forwardRef(({...e},t)=>i.jsx("li",{ref:t,...e}));Hv.displayName="SidebarMenuSubItem";const zv=l.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...o},s)=>{const a=e?Be.Slot:"a";return i.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:A("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...o})});zv.displayName="SidebarMenuSubButton";function Wv({header:e,sidebarTitle:t="Threads",showThreads:n=!0,className:r="",sidebarClassName:o="",chatClassName:s="",...a}){return i.jsx(on,{...a,children:i.jsxs(Gl,{className:`w-full ${r}`,children:[i.jsxs(ql,{className:`border-r ${o}`,children:[i.jsx(Jl,{children:i.jsx(nd,{children:i.jsx(rd,{children:i.jsx(od,{size:"lg",children:i.jsx("span",{className:"font-semibold",children:t})})})})}),i.jsx(Zl,{children:n&&i.jsxs(Ql,{children:[i.jsx(ed,{children:"Conversations"}),i.jsx(td,{children:i.jsx("div",{className:"px-2 py-1",children:i.jsx(vr,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-[calc(100vh-12rem)]"})})})]})})]}),i.jsxs(Yl,{children:[i.jsxs("header",{className:"h-14 border-b bg-background/60 backdrop-blur flex items-center gap-2 px-4",children:[i.jsx(Xl,{}),i.jsx("div",{className:"flex-1"}),e]}),i.jsx("main",{className:`flex-1 min-h-0 overflow-hidden ${s}`,children:i.jsx(vn,{})})]})]})})}var Vv="Label",sd=l.forwardRef((e,t)=>i.jsx(oe.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));sd.displayName=Vv;var ad=sd;const jv=Jt.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),je=l.forwardRef(({className:e,...t},n)=>i.jsx(ad,{ref:n,className:A(jv(),e),...t}));je.displayName=ad.displayName;function id(e){const t=l.useRef({value:e,previous:e});return l.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Nr="Switch",[Rv,py]=Ke(Nr),[Kv,Gv]=Rv(Nr),cd=l.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:a,disabled:c,value:d="on",onCheckedChange:f,form:u,...p}=e,[m,v]=l.useState(null),g=ue(t,x=>v(x)),h=l.useRef(!1),b=m?u||!!m.closest("form"):!0,[w,y]=mt({prop:o,defaultProp:s??!1,onChange:f,caller:Nr});return i.jsxs(Kv,{scope:n,checked:w,disabled:c,children:[i.jsx(oe.button,{type:"button",role:"switch","aria-checked":w,"aria-required":a,"data-state":fd(w),"data-disabled":c?"":void 0,disabled:c,value:d,...p,ref:g,onClick:U(e.onClick,x=>{y(C=>!C),b&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})}),b&&i.jsx(ud,{control:m,bubbles:!h.current,name:r,value:d,checked:w,required:a,disabled:c,form:u,style:{transform:"translateX(-100%)"}})]})});cd.displayName=Nr;var ld="SwitchThumb",dd=l.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Gv(ld,n);return i.jsx(oe.span,{"data-state":fd(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});dd.displayName=ld;var qv="SwitchBubbleInput",ud=l.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const a=l.useRef(null),c=ue(a,s),d=id(n),f=hi(t);return l.useEffect(()=>{const u=a.current;if(!u)return;const p=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(p,"checked").set;if(d!==n&&v){const g=new Event("click",{bubbles:r});v.call(u,n),u.dispatchEvent(g)}},[d,n,r]),i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:c,style:{...o.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});ud.displayName=qv;function fd(e){return e?"checked":"unchecked"}var pd=cd,Xv=dd;const yt=l.forwardRef(({className:e,...t},n)=>i.jsx(pd,{className:A("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:i.jsx(Xv,{className:A("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));yt.displayName=pd.displayName;var Yv=[" ","Enter","ArrowUp","ArrowDown"],Jv=[" ","Enter"],Pt="Select",[Tr,Ar,Zv]=go(Pt),[Yt,hy]=Ke(Pt,[Zv,Vt]),Ir=Vt(),[Qv,xt]=Yt(Pt),[ew,tw]=Yt(Pt),hd=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:a,defaultValue:c,onValueChange:d,dir:f,name:u,autoComplete:p,disabled:m,required:v,form:g}=e,h=Ir(t),[b,w]=l.useState(null),[y,x]=l.useState(null),[C,E]=l.useState(!1),P=Wn(f),[T,F]=mt({prop:r,defaultProp:o??!1,onChange:s,caller:Pt}),[M,B]=mt({prop:a,defaultProp:c,onChange:d,caller:Pt}),V=l.useRef(null),J=b?g||!!b.closest("form"):!0,[H,O]=l.useState(new Set),ne=Array.from(H).map(L=>L.props.value).join(";");return i.jsx(Do,{...h,children:i.jsxs(Qv,{required:v,scope:t,trigger:b,onTriggerChange:w,valueNode:y,onValueNodeChange:x,valueNodeHasChildren:C,onValueNodeHasChildrenChange:E,contentId:Ge(),value:M,onValueChange:B,open:T,onOpenChange:F,dir:P,triggerPointerDownPosRef:V,disabled:m,children:[i.jsx(Tr.Provider,{scope:t,children:i.jsx(ew,{scope:e.__scopeSelect,onNativeOptionAdd:l.useCallback(L=>{O(z=>new Set(z).add(L))},[]),onNativeOptionRemove:l.useCallback(L=>{O(z=>{const k=new Set(z);return k.delete(L),k})},[]),children:n})}),J?i.jsxs(Bd,{"aria-hidden":!0,required:v,tabIndex:-1,name:u,autoComplete:p,value:M,onChange:L=>B(L.target.value),disabled:m,form:g,children:[M===void 0?i.jsx("option",{value:""}):null,Array.from(H)]},ne):null]})})};hd.displayName=Pt;var gd="SelectTrigger",md=l.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Ir(n),a=xt(gd,n),c=a.disabled||r,d=ue(t,a.onTriggerChange),f=Ar(n),u=l.useRef("touch"),[p,m,v]=Hd(h=>{const b=f().filter(x=>!x.disabled),w=b.find(x=>x.value===a.value),y=zd(b,h,w);y!==void 0&&a.onValueChange(y.value)}),g=h=>{c||(a.onOpenChange(!0),v()),h&&(a.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return i.jsx(Lo,{asChild:!0,...s,children:i.jsx(oe.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":Ud(a.value)?"":void 0,...o,ref:d,onClick:U(o.onClick,h=>{h.currentTarget.focus(),u.current!=="mouse"&&g(h)}),onPointerDown:U(o.onPointerDown,h=>{u.current=h.pointerType;const b=h.target;b.hasPointerCapture(h.pointerId)&&b.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(g(h),h.preventDefault())}),onKeyDown:U(o.onKeyDown,h=>{const b=p.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&m(h.key),!(b&&h.key===" ")&&Yv.includes(h.key)&&(g(),h.preventDefault())})})})});md.displayName=gd;var bd="SelectValue",vd=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:a="",...c}=e,d=xt(bd,n),{onValueNodeHasChildrenChange:f}=d,u=s!==void 0,p=ue(t,d.onValueNodeChange);return Ne(()=>{f(u)},[f,u]),i.jsx(oe.span,{...c,ref:p,style:{pointerEvents:"none"},children:Ud(d.value)?i.jsx(i.Fragment,{children:a}):s})});vd.displayName=bd;var nw="SelectIcon",wd=l.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return i.jsx(oe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});wd.displayName=nw;var rw="SelectPortal",yd=e=>i.jsx(er,{asChild:!0,...e});yd.displayName=rw;var Ot="SelectContent",xd=l.forwardRef((e,t)=>{const n=xt(Ot,e.__scopeSelect),[r,o]=l.useState();if(Ne(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Tn.createPortal(i.jsx(Sd,{scope:e.__scopeSelect,children:i.jsx(Tr.Slot,{scope:e.__scopeSelect,children:i.jsx("div",{children:e.children})})}),s):null}return i.jsx(Cd,{...e,ref:t})});xd.displayName=Ot;var Je=10,[Sd,St]=Yt(Ot),ow="SelectContentImpl",sw=Be.createSlot("SelectContent.RemoveScroll"),Cd=l.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:a,side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:p,collisionBoundary:m,collisionPadding:v,sticky:g,hideWhenDetached:h,avoidCollisions:b,...w}=e,y=xt(Ot,n),[x,C]=l.useState(null),[E,P]=l.useState(null),T=ue(t,R=>C(R)),[F,M]=l.useState(null),[B,V]=l.useState(null),J=Ar(n),[H,O]=l.useState(!1),ne=l.useRef(!1);l.useEffect(()=>{if(x)return zo(x)},[x]),vo();const L=l.useCallback(R=>{const[le,...he]=J().map(ge=>ge.ref.current),[de]=he.slice(-1),be=document.activeElement;for(const ge of R)if(ge===be||(ge==null||ge.scrollIntoView({block:"nearest"}),ge===le&&E&&(E.scrollTop=0),ge===de&&E&&(E.scrollTop=E.scrollHeight),ge==null||ge.focus(),document.activeElement!==be))return},[J,E]),z=l.useCallback(()=>L([F,x]),[L,F,x]);l.useEffect(()=>{H&&z()},[H,z]);const{onOpenChange:k,triggerPointerDownPosRef:I}=y;l.useEffect(()=>{if(x){let R={x:0,y:0};const le=de=>{var be,ge;R={x:Math.abs(Math.round(de.pageX)-(((be=I.current)==null?void 0:be.x)??0)),y:Math.abs(Math.round(de.pageY)-(((ge=I.current)==null?void 0:ge.y)??0))}},he=de=>{R.x<=10&&R.y<=10?de.preventDefault():x.contains(de.target)||k(!1),document.removeEventListener("pointermove",le),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",le),document.addEventListener("pointerup",he,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",le),document.removeEventListener("pointerup",he,{capture:!0})}}},[x,k,I]),l.useEffect(()=>{const R=()=>k(!1);return window.addEventListener("blur",R),window.addEventListener("resize",R),()=>{window.removeEventListener("blur",R),window.removeEventListener("resize",R)}},[k]);const[Z,j]=Hd(R=>{const le=J().filter(be=>!be.disabled),he=le.find(be=>be.ref.current===document.activeElement),de=zd(le,R,he);de&&setTimeout(()=>de.ref.current.focus())}),te=l.useCallback((R,le,he)=>{const de=!ne.current&&!he;(y.value!==void 0&&y.value===le||de)&&(M(R),de&&(ne.current=!0))},[y.value]),D=l.useCallback(()=>x==null?void 0:x.focus(),[x]),W=l.useCallback((R,le,he)=>{const de=!ne.current&&!he;(y.value!==void 0&&y.value===le||de)&&V(R)},[y.value]),xe=r==="popper"?hs:Ed,ie=xe===hs?{side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:p,collisionBoundary:m,collisionPadding:v,sticky:g,hideWhenDetached:h,avoidCollisions:b}:{};return i.jsx(Sd,{scope:n,content:x,viewport:E,onViewportChange:P,itemRefCallback:te,selectedItem:F,onItemLeave:D,itemTextRefCallback:W,focusSelectedItem:z,selectedItemText:B,position:r,isPositioned:H,searchRef:Z,children:i.jsx(cr,{as:sw,allowPinchZoom:!0,children:i.jsx(Vn,{asChild:!0,trapped:y.open,onMountAutoFocus:R=>{R.preventDefault()},onUnmountAutoFocus:U(o,R=>{var le;(le=y.trigger)==null||le.focus({preventScroll:!0}),R.preventDefault()}),children:i.jsx(cn,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:R=>R.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:i.jsx(xe,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:R=>R.preventDefault(),...w,...ie,onPlaced:()=>O(!0),ref:T,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:U(w.onKeyDown,R=>{const le=R.ctrlKey||R.altKey||R.metaKey;if(R.key==="Tab"&&R.preventDefault(),!le&&R.key.length===1&&j(R.key),["ArrowUp","ArrowDown","Home","End"].includes(R.key)){let de=J().filter(be=>!be.disabled).map(be=>be.ref.current);if(["ArrowUp","End"].includes(R.key)&&(de=de.slice().reverse()),["ArrowUp","ArrowDown"].includes(R.key)){const be=R.target,ge=de.indexOf(be);de=de.slice(ge+1)}setTimeout(()=>L(de)),R.preventDefault()}})})})})})})});Cd.displayName=ow;var aw="SelectItemAlignedPosition",Ed=l.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=xt(Ot,n),a=St(Ot,n),[c,d]=l.useState(null),[f,u]=l.useState(null),p=ue(t,T=>u(T)),m=Ar(n),v=l.useRef(!1),g=l.useRef(!0),{viewport:h,selectedItem:b,selectedItemText:w,focusSelectedItem:y}=a,x=l.useCallback(()=>{if(s.trigger&&s.valueNode&&c&&f&&h&&b&&w){const T=s.trigger.getBoundingClientRect(),F=f.getBoundingClientRect(),M=s.valueNode.getBoundingClientRect(),B=w.getBoundingClientRect();if(s.dir!=="rtl"){const be=B.left-F.left,ge=M.left-be,G=T.left-ge,X=T.width+G,ye=Math.max(X,F.width),se=window.innerWidth-Je,Se=es(ge,[Je,Math.max(Je,se-ye)]);c.style.minWidth=X+"px",c.style.left=Se+"px"}else{const be=F.right-B.right,ge=window.innerWidth-M.right-be,G=window.innerWidth-T.right-ge,X=T.width+G,ye=Math.max(X,F.width),se=window.innerWidth-Je,Se=es(ge,[Je,Math.max(Je,se-ye)]);c.style.minWidth=X+"px",c.style.right=Se+"px"}const V=m(),J=window.innerHeight-Je*2,H=h.scrollHeight,O=window.getComputedStyle(f),ne=parseInt(O.borderTopWidth,10),L=parseInt(O.paddingTop,10),z=parseInt(O.borderBottomWidth,10),k=parseInt(O.paddingBottom,10),I=ne+L+H+k+z,Z=Math.min(b.offsetHeight*5,I),j=window.getComputedStyle(h),te=parseInt(j.paddingTop,10),D=parseInt(j.paddingBottom,10),W=T.top+T.height/2-Je,xe=J-W,ie=b.offsetHeight/2,R=b.offsetTop+ie,le=ne+L+R,he=I-le;if(le<=W){const be=V.length>0&&b===V[V.length-1].ref.current;c.style.bottom="0px";const ge=f.clientHeight-h.offsetTop-h.offsetHeight,G=Math.max(xe,ie+(be?D:0)+ge+z),X=le+G;c.style.height=X+"px"}else{const be=V.length>0&&b===V[0].ref.current;c.style.top="0px";const G=Math.max(W,ne+h.offsetTop+(be?te:0)+ie)+he;c.style.height=G+"px",h.scrollTop=le-W+h.offsetTop}c.style.margin=`${Je}px 0`,c.style.minHeight=Z+"px",c.style.maxHeight=J+"px",r==null||r(),requestAnimationFrame(()=>v.current=!0)}},[m,s.trigger,s.valueNode,c,f,h,b,w,s.dir,r]);Ne(()=>x(),[x]);const[C,E]=l.useState();Ne(()=>{f&&E(window.getComputedStyle(f).zIndex)},[f]);const P=l.useCallback(T=>{T&&g.current===!0&&(x(),y==null||y(),g.current=!1)},[x,y]);return i.jsx(cw,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:v,onScrollButtonChange:P,children:i.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:C},children:i.jsx(oe.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ed.displayName=aw;var iw="SelectPopperPosition",hs=l.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Je,...s}=e,a=Ir(n);return i.jsx(Fo,{...a,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});hs.displayName=iw;var[cw,gs]=Yt(Ot,{}),ms="SelectViewport",Nd=l.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=St(ms,n),a=gs(ms,n),c=ue(t,s.onViewportChange),d=l.useRef(0);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),i.jsx(Tr.Slot,{scope:n,children:i.jsx(oe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:U(o.onScroll,f=>{const u=f.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=a;if(m!=null&&m.current&&p){const v=Math.abs(d.current-u.scrollTop);if(v>0){const g=window.innerHeight-Je*2,h=parseFloat(p.style.minHeight),b=parseFloat(p.style.height),w=Math.max(h,b);if(w<g){const y=w+v,x=Math.min(g,y),C=y-x;p.style.height=x+"px",p.style.bottom==="0px"&&(u.scrollTop=C>0?C:0,p.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})});Nd.displayName=ms;var Td="SelectGroup",[lw,dw]=Yt(Td),uw=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ge();return i.jsx(lw,{scope:n,id:o,children:i.jsx(oe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});uw.displayName=Td;var Ad="SelectLabel",Id=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=dw(Ad,n);return i.jsx(oe.div,{id:o.id,...r,ref:t})});Id.displayName=Ad;var kr="SelectItem",[fw,kd]=Yt(kr),_d=l.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...a}=e,c=xt(kr,n),d=St(kr,n),f=c.value===r,[u,p]=l.useState(s??""),[m,v]=l.useState(!1),g=ue(t,y=>{var x;return(x=d.itemRefCallback)==null?void 0:x.call(d,y,r,o)}),h=Ge(),b=l.useRef("touch"),w=()=>{o||(c.onValueChange(r),c.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return i.jsx(fw,{scope:n,value:r,disabled:o,textId:h,isSelected:f,onItemTextChange:l.useCallback(y=>{p(x=>x||((y==null?void 0:y.textContent)??"").trim())},[]),children:i.jsx(Tr.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:i.jsx(oe.div,{role:"option","aria-labelledby":h,"data-highlighted":m?"":void 0,"aria-selected":f&&m,"data-state":f?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:g,onFocus:U(a.onFocus,()=>v(!0)),onBlur:U(a.onBlur,()=>v(!1)),onClick:U(a.onClick,()=>{b.current!=="mouse"&&w()}),onPointerUp:U(a.onPointerUp,()=>{b.current==="mouse"&&w()}),onPointerDown:U(a.onPointerDown,y=>{b.current=y.pointerType}),onPointerMove:U(a.onPointerMove,y=>{var x;b.current=y.pointerType,o?(x=d.onItemLeave)==null||x.call(d):b.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:U(a.onPointerLeave,y=>{var x;y.currentTarget===document.activeElement&&((x=d.onItemLeave)==null||x.call(d))}),onKeyDown:U(a.onKeyDown,y=>{var C;((C=d.searchRef)==null?void 0:C.current)!==""&&y.key===" "||(Jv.includes(y.key)&&w(),y.key===" "&&y.preventDefault())})})})})});_d.displayName=kr;var Sn="SelectItemText",Pd=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,a=xt(Sn,n),c=St(Sn,n),d=kd(Sn,n),f=tw(Sn,n),[u,p]=l.useState(null),m=ue(t,w=>p(w),d.onItemTextChange,w=>{var y;return(y=c.itemTextRefCallback)==null?void 0:y.call(c,w,d.value,d.disabled)}),v=u==null?void 0:u.textContent,g=l.useMemo(()=>i.jsx("option",{value:d.value,disabled:d.disabled,children:v},d.value),[d.disabled,d.value,v]),{onNativeOptionAdd:h,onNativeOptionRemove:b}=f;return Ne(()=>(h(g),()=>b(g)),[h,b,g]),i.jsxs(i.Fragment,{children:[i.jsx(oe.span,{id:d.textId,...s,ref:m}),d.isSelected&&a.valueNode&&!a.valueNodeHasChildren?Tn.createPortal(s.children,a.valueNode):null]})});Pd.displayName=Sn;var Od="SelectItemIndicator",Md=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return kd(Od,n).isSelected?i.jsx(oe.span,{"aria-hidden":!0,...r,ref:t}):null});Md.displayName=Od;var bs="SelectScrollUpButton",Dd=l.forwardRef((e,t)=>{const n=St(bs,e.__scopeSelect),r=gs(bs,e.__scopeSelect),[o,s]=l.useState(!1),a=ue(t,r.onScrollButtonChange);return Ne(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollTop>0;s(f)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?i.jsx(Fd,{...e,ref:a,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});Dd.displayName=bs;var vs="SelectScrollDownButton",Ld=l.forwardRef((e,t)=>{const n=St(vs,e.__scopeSelect),r=gs(vs,e.__scopeSelect),[o,s]=l.useState(!1),a=ue(t,r.onScrollButtonChange);return Ne(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollHeight-d.clientHeight,u=Math.ceil(d.scrollTop)<f;s(u)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?i.jsx(Fd,{...e,ref:a,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});Ld.displayName=vs;var Fd=l.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=St("SelectScrollButton",n),a=l.useRef(null),c=Ar(n),d=l.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return l.useEffect(()=>()=>d(),[d]),Ne(()=>{var u;const f=c().find(p=>p.ref.current===document.activeElement);(u=f==null?void 0:f.ref.current)==null||u.scrollIntoView({block:"nearest"})},[c]),i.jsx(oe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:U(o.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(r,50))}),onPointerMove:U(o.onPointerMove,()=>{var f;(f=s.onItemLeave)==null||f.call(s),a.current===null&&(a.current=window.setInterval(r,50))}),onPointerLeave:U(o.onPointerLeave,()=>{d()})})}),pw="SelectSeparator",$d=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return i.jsx(oe.div,{"aria-hidden":!0,...r,ref:t})});$d.displayName=pw;var ws="SelectArrow",hw=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ir(n),s=xt(ws,n),a=St(ws,n);return s.open&&a.position==="popper"?i.jsx($o,{...o,...r,ref:t}):null});hw.displayName=ws;var gw="SelectBubbleInput",Bd=l.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=l.useRef(null),s=ue(r,o),a=id(t);return l.useEffect(()=>{const c=o.current;if(!c)return;const d=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(d,"value").set;if(a!==t&&u){const p=new Event("change",{bubbles:!0});u.call(c,t),c.dispatchEvent(p)}},[a,t]),i.jsx(oe.select,{...n,style:{...Ll,...n.style},ref:s,defaultValue:t})});Bd.displayName=gw;function Ud(e){return e===""||e===void 0}function Hd(e){const t=Ae(e),n=l.useRef(""),r=l.useRef(0),o=l.useCallback(a=>{const c=n.current+a;t(c),function d(f){n.current=f,window.clearTimeout(r.current),f!==""&&(r.current=window.setTimeout(()=>d(""),1e3))}(c)},[t]),s=l.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function zd(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let a=mw(e,Math.max(s,0));o.length===1&&(a=a.filter(f=>f!==n));const d=a.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function mw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var bw=hd,Wd=md,vw=vd,ww=wd,yw=yd,Vd=xd,xw=Nd,jd=Id,Rd=_d,Sw=Pd,Cw=Md,Kd=Dd,Gd=Ld,qd=$d;const Xd=bw,Yd=vw,ys=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(Wd,{ref:r,className:A("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,i.jsx(ww,{asChild:!0,children:i.jsx(q.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ys.displayName=Wd.displayName;const Jd=l.forwardRef(({className:e,...t},n)=>i.jsx(Kd,{ref:n,className:A("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(q.ChevronUp,{className:"h-4 w-4"})}));Jd.displayName=Kd.displayName;const Zd=l.forwardRef(({className:e,...t},n)=>i.jsx(Gd,{ref:n,className:A("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(q.ChevronDown,{className:"h-4 w-4"})}));Zd.displayName=Gd.displayName;const xs=l.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>i.jsx(yw,{children:i.jsxs(Vd,{ref:o,className:A("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",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,...r,children:[i.jsx(Jd,{}),i.jsx(xw,{className:A("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),i.jsx(Zd,{})]})}));xs.displayName=Vd.displayName;const Ew=l.forwardRef(({className:e,...t},n)=>i.jsx(jd,{ref:n,className:A("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Ew.displayName=jd.displayName;const Mt=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(Rd,{ref:r,className:A("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Cw,{children:i.jsx(q.Check,{className:"h-4 w-4"})})}),i.jsx(Sw,{children:t})]}));Mt.displayName=Rd.displayName;const Nw=l.forwardRef(({className:e,...t},n)=>i.jsx(qd,{ref:n,className:A("-mx-1 my-1 h-px bg-muted",e),...t}));Nw.displayName=qd.displayName;const _r=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));_r.displayName="Card";const Pr=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("flex flex-col space-y-1.5 p-6",e),...t}));Pr.displayName="CardHeader";const Or=l.forwardRef(({className:e,...t},n)=>i.jsx("h3",{ref:n,className:A("text-2xl font-semibold leading-none tracking-tight",e),...t}));Or.displayName="CardTitle";const Tw=l.forwardRef(({className:e,...t},n)=>i.jsx("p",{ref:n,className:A("text-sm text-muted-foreground",e),...t}));Tw.displayName="CardDescription";const Mr=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("p-6 pt-0",e),...t}));Mr.displayName="CardContent";const Aw=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("flex items-center p-6 pt-0",e),...t}));Aw.displayName="CardFooter";const Iw=1,kw=1e6;let Ss=0;function _w(){return Ss=(Ss+1)%Number.MAX_SAFE_INTEGER,Ss.toString()}const Cs=new Map,Qd=e=>{if(Cs.has(e))return;const t=setTimeout(()=>{Cs.delete(e),Cn({type:"REMOVE_TOAST",toastId:e})},kw);Cs.set(e,t)},Pw=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Iw)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?Qd(n):e.toasts.forEach(r=>{Qd(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Dr=[];let Lr={toasts:[]};function Cn(e){Lr=Pw(Lr,e),Dr.forEach(t=>{t(Lr)})}function Ow({...e}){const t=_w(),n=o=>Cn({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Cn({type:"DISMISS_TOAST",toastId:t});return Cn({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Mw(){const[e,t]=l.useState(Lr);return l.useEffect(()=>(Dr.push(t),()=>{const n=Dr.indexOf(t);n>-1&&Dr.splice(n,1)}),[e]),{...e,toast:Ow,dismiss:n=>Cn({type:"DISMISS_TOAST",toastId:n})}}const Dw={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function Lw({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=N.useState(!1),[s,a]=N.useState(!1),[c,d]=N.useState(e),[f,u]=N.useState(!1),{toast:p}=Mw();N.useEffect(()=>{const b=JSON.stringify(c)!==JSON.stringify(e);u(b)},[c,e]),N.useEffect(()=>{d(e)},[e]);const m=()=>{t(c),u(!1),p({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},v=()=>{d(Dw),u(!0),p({title:"Settings reset",description:"Configuration has been reset to defaults."})},g=()=>{d(e),u(!1),o(!1)},h=async()=>{try{const w=await(await fetch(`${c.api.baseUrl}/health`)).json();p({title:"Connection successful",description:`API is ${w.status||"healthy"}`})}catch{p({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return i.jsxs(kl,{open:r,onOpenChange:o,children:[i.jsx(Jb,{asChild:!0,children:i.jsxs(we,{variant:"outline",size:"sm",className:n,children:[i.jsx(q.Settings,{className:"h-4 w-4 mr-2"}),"Settings",f&&i.jsx(Ea,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),i.jsxs(ds,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[i.jsxs(Pl,{children:[i.jsx(Ol,{children:"Chat Settings"}),i.jsx(Ml,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),i.jsxs("div",{className:"space-y-6 py-6",children:[i.jsxs(_r,{children:[i.jsx(Pr,{className:"pb-3",children:i.jsxs(Or,{className:"text-lg flex items-center gap-2",children:[i.jsx(q.Server,{className:"h-5 w-5"}),"API Configuration"]})}),i.jsxs(Mr,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(je,{htmlFor:"api-url",children:"API Base URL"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(wn,{id:"api-url",value:c.api.baseUrl,onChange:b=>d(w=>({...w,api:{...w.api,baseUrl:b.target.value}})),placeholder:"http://localhost:8000/api"}),i.jsx(we,{variant:"outline",onClick:h,children:"Test"})]})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(je,{htmlFor:"enable-auth",children:"Enable Authentication"}),i.jsx(yt,{id:"enable-auth",checked:c.api.enableAuth,onCheckedChange:b=>d(w=>({...w,api:{...w.api,enableAuth:b}}))})]}),c.api.enableAuth&&i.jsxs("div",{className:"space-y-2",children:[i.jsx(je,{htmlFor:"auth-token",children:"Authentication Token"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(wn,{id:"auth-token",type:s?"text":"password",value:c.api.authToken,onChange:b=>d(w=>({...w,api:{...w.api,authToken:b.target.value}})),placeholder:"Enter your Bearer token"}),i.jsx(we,{variant:"outline",size:"icon",onClick:()=>a(!s),children:s?i.jsx(q.EyeOff,{className:"h-4 w-4"}):i.jsx(q.Eye,{className:"h-4 w-4"})})]})]})]})]}),i.jsxs(_r,{children:[i.jsx(Pr,{className:"pb-3",children:i.jsxs(Or,{className:"text-lg flex items-center gap-2",children:[i.jsx(q.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),i.jsxs(Mr,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(je,{htmlFor:"layout",children:"Layout Style"}),i.jsxs(Xd,{value:c.ui.layout,onValueChange:b=>d(w=>({...w,ui:{...w.ui,layout:b}})),children:[i.jsx(ys,{children:i.jsx(Yd,{})}),i.jsxs(xs,{children:[i.jsx(Mt,{value:"sidebar",children:"Sidebar Layout"}),i.jsx(Mt,{value:"fullscreen",children:"Fullscreen"}),i.jsx(Mt,{value:"tabs",children:"Tabbed Interface"})]})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(je,{htmlFor:"theme",children:"Theme"}),i.jsxs(Xd,{value:c.ui.theme,onValueChange:b=>d(w=>({...w,ui:{...w.ui,theme:b}})),children:[i.jsx(ys,{children:i.jsx(Yd,{})}),i.jsxs(xs,{children:[i.jsx(Mt,{value:"light",children:"Light"}),i.jsx(Mt,{value:"dark",children:"Dark"}),i.jsx(Mt,{value:"system",children:"System"})]})]})]}),i.jsx(as,{}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(je,{htmlFor:"show-timestamps",children:"Show Timestamps"}),i.jsx(yt,{id:"show-timestamps",checked:c.ui.showTimestamps,onCheckedChange:b=>d(w=>({...w,ui:{...w.ui,showTimestamps:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(je,{htmlFor:"show-agent-names",children:"Show Agent Names"}),i.jsx(yt,{id:"show-agent-names",checked:c.ui.showAgentNames,onCheckedChange:b=>d(w=>({...w,ui:{...w.ui,showAgentNames:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(je,{htmlFor:"compact-messages",children:"Compact Messages"}),i.jsx(yt,{id:"compact-messages",checked:c.ui.compactMessages,onCheckedChange:b=>d(w=>({...w,ui:{...w.ui,compactMessages:b}}))})]})]})]})]}),i.jsxs(_r,{children:[i.jsx(Pr,{className:"pb-3",children:i.jsxs(Or,{className:"text-lg flex items-center gap-2",children:[i.jsx(q.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),i.jsxs(Mr,{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(je,{htmlFor:"auto-save",children:"Auto-save Conversations"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),i.jsx(yt,{id:"auto-save",checked:c.behavior.autoSave,onCheckedChange:b=>d(w=>({...w,behavior:{...w.behavior,autoSave:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(je,{htmlFor:"enable-streaming",children:"Enable Streaming"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),i.jsx(yt,{id:"enable-streaming",checked:c.behavior.enableStreaming,onCheckedChange:b=>d(w=>({...w,behavior:{...w.behavior,enableStreaming:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(je,{htmlFor:"typing-indicator",children:"Typing Indicator"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),i.jsx(yt,{id:"typing-indicator",checked:c.behavior.showTypingIndicator,onCheckedChange:b=>d(w=>({...w,behavior:{...w.behavior,showTypingIndicator:b}}))})]})]})]})]}),i.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[i.jsxs(we,{variant:"outline",onClick:v,children:[i.jsx(q.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(we,{variant:"outline",onClick:g,children:"Cancel"}),i.jsxs(we,{onClick:m,disabled:!f,children:[i.jsx(q.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function Fw({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const a=f=>{const u="h-full";switch(f){case"phone":return`${u} max-w-none`;case"tablet":return`${u} max-w-4xl mx-auto`;case"half-screen":return`${u} max-w-2xl`;case"desktop":default:return`${u} max-w-7xl mx-auto`}},c=f=>({"--chat-sidebar-width":f==="phone"?"100%":f==="tablet"?"280px":f==="half-screen"?"240px":"320px","--chat-message-max-width":f==="phone"?"95%":f==="tablet"?"90%":f==="half-screen"?"85%":"80%","--chat-input-height":f==="phone"?"120px":"100px"}),d=N.useCallback(f=>{var u;(u=s.onThreadChange)==null||u.call(s,f)},[s.onThreadChange]);return e==="fullscreen"?i.jsx(on,{...s,onThreadChange:d,children:i.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:c(t),children:i.jsx(vn,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?i.jsx(on,{...s,onThreadChange:d,children:i.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:c(t),children:i.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&i.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:i.jsx(vr,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),i.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:i.jsx(vn,{onError:s.onError,enableFileUpload:!0})})]})})}):i.jsx(on,{...s,onThreadChange:d,children:i.jsxs("div",{className:`${a(t)} flex overflow-hidden ${r} ${o.container||""}`,style:c(t),children:[n&&i.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:i.jsx(vr,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),i.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:i.jsx(vn,{onError:s.onError,enableFileUpload:!0})})]})})}ae.Api=Bn,ae.ApiClient=Bn,ae.ChatApi=Bn,ae.ChatInterface=vn,ae.ChatMainLayout=Wv,ae.ChatProvider=on,ae.ChatRoutingProvider=Tb,ae.ChatSettings=Lw,ae.MarkdownContent=sn,ae.MessageComponent=Oa,ae.ThreadManager=vr,ae.apiClient=ut,ae.applySettings=Mb,ae.chatApiClient=ut,ae.default=Fw,ae.del=va,ae.get=Tt,ae.getChatToken=ro,ae.getCurrentSettings=Ob,ae.getDefaultApiConfig=rl,ae.getDefaultChatSettings=ol,ae.onChatTokenChanged=ma,ae.post=so,ae.put=ba,ae.setChatToken=oo,ae.stream=If,ae.useChat=co,ae.useChatRouting=Ab,ae.useChatStream=wa,ae.useMessagesReducer=ya,Object.defineProperties(ae,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});