teodor-new-chat-ui 2.0.12 → 2.0.13
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/components/ui/resizable.d.ts +1 -1
- package/dist/index.esm.js +1701 -1642
- package/dist/index.umd.js +17 -17
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
(function(Q,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):(Q=typeof globalThis<"u"?globalThis:Q||self,i(Q.NewChatUI={},Q.jsxRuntime,Q.React,Q.LucideReact,Q.reactSlot,Q.classVarianceAuthority,Q.clsx,Q.tailwindMerge,Q.ReactDOM,Q.ReactMarkdown,Q.remarkGfm))})(this,function(Q,i,P,K,Pe,Dt,Nd,Td,Jo,Ad,Pd){"use strict";var vr=typeof document<"u"?document.currentScript:null;function Zo(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=Zo(P),cn=Zo(Jo);function Qo(e,t){return function(){return e.apply(t,arguments)}}const{toString:_d}=Object.prototype,{getPrototypeOf:br}=Object,{iterator:ln,toStringTag:es}=Symbol,dn=(e=>t=>{const n=_d.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),De=e=>(e=e.toLowerCase(),t=>dn(t)===e),un=e=>t=>typeof t===e,{isArray:vt}=Array,bt=un("undefined");function Lt(e){return e!==null&&!bt(e)&&e.constructor!==null&&!bt(e.constructor)&&Ce(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ts=De("ArrayBuffer");function Id(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ts(e.buffer),t}const Od=un("string"),Ce=un("function"),ns=un("number"),Ft=e=>e!==null&&typeof e=="object",Md=e=>e===!0||e===!1,fn=e=>{if(dn(e)!=="object")return!1;const t=br(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(es in e)&&!(ln in e)},kd=e=>{if(!Ft(e)||Lt(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Dd=De("Date"),Ld=De("File"),Fd=De("Blob"),$d=De("FileList"),Bd=e=>Ft(e)&&Ce(e.pipe),Ud=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ce(e.append)&&((t=dn(e))==="formdata"||t==="object"&&Ce(e.toString)&&e.toString()==="[object FormData]"))},zd=De("URLSearchParams"),[Hd,Wd,Rd,Vd]=["ReadableStream","Request","Response","Headers"].map(De),jd=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function $t(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),vt(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Lt(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 rs(e,t){if(Lt(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 at=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,os=e=>!bt(e)&&e!==at;function wr(){const{caseless:e,skipUndefined:t}=os(this)&&this||{},n={},r=(o,s)=>{const a=e&&rs(n,s)||s;fn(n[a])&&fn(o)?n[a]=wr(n[a],o):fn(o)?n[a]=wr({},o):vt(o)?n[a]=o.slice():(!t||!bt(o))&&(n[a]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&$t(arguments[o],r);return n}const Kd=(e,t,n,{allOwnKeys:r}={})=>($t(t,(o,s)=>{n&&Ce(o)?e[s]=Qo(o,n):e[s]=o},{allOwnKeys:r}),e),Gd=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),qd=(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)},Xd=(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&&br(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Yd=(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},Jd=e=>{if(!e)return null;if(vt(e))return e;let t=e.length;if(!ns(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Zd=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&br(Uint8Array)),Qd=(e,t)=>{const r=(e&&e[ln]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},eu=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},tu=De("HTMLFormElement"),nu=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),ss=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ru=De("RegExp"),as=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};$t(n,(o,s)=>{let a;(a=t(o,s,e))!==!1&&(r[s]=a||o)}),Object.defineProperties(e,r)},ou=e=>{as(e,(t,n)=>{if(Ce(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ce(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+"'")})}})},su=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return vt(e)?r(e):r(String(e).split(t)),n},au=()=>{},iu=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function cu(e){return!!(e&&Ce(e.append)&&e[es]==="FormData"&&e[ln])}const lu=e=>{const t=new Array(10),n=(r,o)=>{if(Ft(r)){if(t.indexOf(r)>=0)return;if(Lt(r))return r;if(!("toJSON"in r)){t[o]=r;const s=vt(r)?[]:{};return $t(r,(a,c)=>{const d=n(a,o+1);!bt(d)&&(s[c]=d)}),t[o]=void 0,s}}return r};return n(e,0)},du=De("AsyncFunction"),uu=e=>e&&(Ft(e)||Ce(e))&&Ce(e.then)&&Ce(e.catch),is=((e,t)=>e?setImmediate:t?((n,r)=>(at.addEventListener("message",({source:o,data:s})=>{o===at&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),at.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ce(at.postMessage)),fu=typeof queueMicrotask<"u"?queueMicrotask.bind(at):typeof process<"u"&&process.nextTick||is,S={isArray:vt,isArrayBuffer:ts,isBuffer:Lt,isFormData:Ud,isArrayBufferView:Id,isString:Od,isNumber:ns,isBoolean:Md,isObject:Ft,isPlainObject:fn,isEmptyObject:kd,isReadableStream:Hd,isRequest:Wd,isResponse:Rd,isHeaders:Vd,isUndefined:bt,isDate:Dd,isFile:Ld,isBlob:Fd,isRegExp:ru,isFunction:Ce,isStream:Bd,isURLSearchParams:zd,isTypedArray:Zd,isFileList:$d,forEach:$t,merge:wr,extend:Kd,trim:jd,stripBOM:Gd,inherits:qd,toFlatObject:Xd,kindOf:dn,kindOfTest:De,endsWith:Yd,toArray:Jd,forEachEntry:Qd,matchAll:eu,isHTMLForm:tu,hasOwnProperty:ss,hasOwnProp:ss,reduceDescriptors:as,freezeMethods:ou,toObjectSet:su,toCamelCase:nu,noop:au,toFiniteNumber:iu,findKey:rs,global:at,isContextDefined:os,isSpecCompliantForm:cu,toJSONObject:lu,isAsyncFn:du,isThenable:uu,setImmediate:is,asap:fu,isIterable:e=>e!=null&&Ce(e[ln])};function ne(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(ne,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 cs=ne.prototype,ls={};["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=>{ls[e]={value:e}}),Object.defineProperties(ne,ls),Object.defineProperty(cs,"isAxiosError",{value:!0}),ne.from=(e,t,n,r,o,s)=>{const a=Object.create(cs);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 ne.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 pu=null;function yr(e){return S.isPlainObject(e)||S.isArray(e)}function ds(e){return S.endsWith(e,"[]")?e.slice(0,-2):e}function us(e,t,n){return e?e.concat(t).map(function(o,s){return o=ds(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function hu(e){return S.isArray(e)&&!e.some(yr)}const gu=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,v){return!S.isUndefined(v[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 ne("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,v){let w=g;if(g&&!v&&typeof g=="object"){if(S.endsWith(h,"{}"))h=r?h:h.slice(0,-2),g=JSON.stringify(g);else if(S.isArray(g)&&hu(g)||(S.isFileList(g)||S.endsWith(h,"[]"))&&(w=S.toArray(g)))return h=ds(h),w.forEach(function(x,E){!(S.isUndefined(x)||x===null)&&t.append(a===!0?us([h],E,s):a===null?h:h+"[]",f(x))}),!1}return yr(g)?!0:(t.append(us(v,h,s),f(g)),!1)}const p=[],m=Object.assign(gu,{defaultVisitor:u,convertValue:f,isVisitable:yr});function b(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&&b(w,h?h.concat(y):[y])}),p.pop()}}if(!S.isObject(e))throw new TypeError("data must be an object");return b(e),t}function fs(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function xr(e,t){this._pairs=[],e&&pn(e,this,t)}const ps=xr.prototype;ps.append=function(t,n){this._pairs.push([t,n])},ps.toString=function(t){const n=t?function(r){return t.call(this,r,fs)}:fs;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function mu(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function hs(e,t,n){if(!t)return e;const r=n&&n.encode||mu;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 xr(t,n).toString(r),s){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class gs{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 ms={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},vu={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:xr,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Sr=typeof window<"u"&&typeof document<"u",Cr=typeof navigator=="object"&&navigator||void 0,bu=Sr&&(!Cr||["ReactNative","NativeScript","NS"].indexOf(Cr.product)<0),wu=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",yu=Sr&&window.location.href||"http://localhost",ye={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Sr,hasStandardBrowserEnv:bu,hasStandardBrowserWebWorkerEnv:wu,navigator:Cr,origin:yu},Symbol.toStringTag,{value:"Module"})),...vu};function xu(e,t){return pn(e,new ye.classes.URLSearchParams,{visitor:function(n,r,o,s){return ye.isNode&&S.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Su(e){return S.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Cu(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 vs(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]=Cu(o[a])),!c)}if(S.isFormData(e)&&S.isFunction(e.entries)){const n={};return S.forEachEntry(e,(r,o)=>{t(Su(r),o,n,0)}),n}return null}function Eu(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 Bt={transitional:ms,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(vs(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 xu(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),Eu(t)):t}],transformResponse:[function(t){const n=this.transitional||Bt.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"?ne.from(c,ne.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:ye.classes.FormData,Blob:ye.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=>{Bt.headers[e]={}});const Nu=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"]),Tu=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]&&
|
|
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[bs]=this[bs]={accessors:{}}).accessors,o=this.prototype;function s(a){const c=Ut(a);r[c]||(Iu(o,a),r[c]=!0)}return S.isArray(t)?t.forEach(s):s(t),this}};Ee.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),S.reduceDescriptors(Ee.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),S.freezeMethods(Ee);function Nr(e,t){const n=this||Bt,r=t||n,o=Ee.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 ws(e){return!!(e&&e.__CANCEL__)}function wt(e,t,n){ne.call(this,e??"canceled",ne.ERR_CANCELED,t,n),this.name="CanceledError"}S.inherits(wt,ne,{__CANCEL__:!0});function ys(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new ne("Request failed with status code "+n.status,[ne.ERR_BAD_REQUEST,ne.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Ou(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Mu(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 b=u&&f-u;return b?Math.round(m*1e3/b):void 0}}function ku(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 gn=(e,t,n=3)=>{let r=0;const o=Mu(50,250);return ku(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)},xs=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ss=e=>(...t)=>S.asap(()=>e(...t)),Du=ye.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ye.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ye.origin),ye.navigator&&/(msie|trident)/i.test(ye.navigator.userAgent)):()=>!0,Lu=ye.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 Fu(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function $u(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Cs(e,t,n){let r=!Fu(t);return e&&(r||n==!1)?$u(e,t):t}const Es=e=>e instanceof Ee?{...e}:e;function it(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(Es(f),Es(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 Ns=e=>{const t=it({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:a,auth:c}=t;if(t.headers=a=Ee.from(a),t.url=hs(Cs(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(ye.hasStandardBrowserEnv||ye.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(ye.hasStandardBrowserEnv&&(r&&S.isFunction(r)&&(r=r(t)),r||r!==!1&&Du(t.url))){const d=o&&s&&Lu.read(s);d&&a.set(o,d)}return t},Bu=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Ns(e);let s=o.data;const a=Ee.from(o.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:f}=o,u,p,m,b,g;function h(){b&&b(),g&&g(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let v=new XMLHttpRequest;v.open(o.method.toUpperCase(),o.url,!0),v.timeout=o.timeout;function w(){if(!v)return;const x=Ee.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders()),C={data:!c||c==="text"||c==="json"?v.responseText:v.response,status:v.status,statusText:v.statusText,headers:x,config:e,request:v};ys(function(N){n(N),h()},function(N){r(N),h()},C),v=null}"onloadend"in v?v.onloadend=w:v.onreadystatechange=function(){!v||v.readyState!==4||v.status===0&&!(v.responseURL&&v.responseURL.indexOf("file:")===0)||setTimeout(w)},v.onabort=function(){v&&(r(new ne("Request aborted",ne.ECONNABORTED,e,v)),v=null)},v.onerror=function(E){const C=E&&E.message?E.message:"Network Error",O=new ne(C,ne.ERR_NETWORK,e,v);O.event=E||null,r(O),v=null},v.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||ms;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new ne(E,C.clarifyTimeoutError?ne.ETIMEDOUT:ne.ECONNABORTED,e,v)),v=null},s===void 0&&a.setContentType(null),"setRequestHeader"in v&&S.forEach(a.toJSON(),function(E,C){v.setRequestHeader(C,E)}),S.isUndefined(o.withCredentials)||(v.withCredentials=!!o.withCredentials),c&&c!=="json"&&(v.responseType=o.responseType),f&&([m,g]=gn(f,!0),v.addEventListener("progress",m)),d&&v.upload&&([p,b]=gn(d),v.upload.addEventListener("progress",p),v.upload.addEventListener("loadend",b)),(o.cancelToken||o.signal)&&(u=x=>{v&&(r(!x||x.type?new wt(null,e,v):x),v.abort(),v=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const y=Ou(o.url);if(y&&ye.protocols.indexOf(y)===-1){r(new ne("Unsupported protocol "+y+":",ne.ERR_BAD_REQUEST,e));return}v.send(s||null)})},Uu=(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 ne?u:new wt(u instanceof Error?u.message:u))}};let a=t&&setTimeout(()=>{a=null,s(new ne(`timeout ${t} of ms exceeded`,ne.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}},zu=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},Hu=async function*(e,t){for await(const n of Wu(e))yield*zu(n,t)},Wu=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()}},Ts=(e,t,n,r)=>{const o=Hu(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})},As=64*1024,{isFunction:mn}=S,Ru=(({Request:e,Response:t})=>({Request:e,Response:t}))(S.global),{ReadableStream:Ps,TextEncoder:_s}=S.global,Is=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Vu=e=>{e=S.merge.call({skipUndefined:!0},Ru,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(Ps),d=o&&(typeof _s=="function"?(g=>h=>g.encode(h))(new _s):async g=>new Uint8Array(await new n(g).arrayBuffer())),f=s&&c&&Is(()=>{let g=!1;const h=new n(ye.origin,{body:new Ps,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return g&&!h}),u=a&&c&&Is(()=>S.isReadableStream(new r("").body)),p={stream:u&&(g=>g.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(g=>{!p[g]&&(p[g]=(h,v)=>{let w=h&&h[g];if(w)return w.call(h);throw new ne(`Response type '${g}' is not supported`,ne.ERR_NOT_SUPPORT,v)})});const m=async g=>{if(g==null)return 0;if(S.isBlob(g))return g.size;if(S.isSpecCompliantForm(g))return(await new n(ye.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},b=async(g,h)=>{const v=S.toFiniteNumber(g.getContentLength());return v??m(h)};return async g=>{let{url:h,method:v,data:w,signal:y,cancelToken:x,timeout:E,onDownloadProgress:C,onUploadProgress:O,responseType:N,headers:L,withCredentials:k="same-origin",fetchOptions:D}=Ns(g),j=t||fetch;N=N?(N+"").toLowerCase():"text";let G=Uu([y,x&&x.toAbortSignal()],E),R=null;const z=G&&G.unsubscribe&&(()=>{G.unsubscribe()});let X;try{if(O&&f&&v!=="get"&&v!=="head"&&(X=await b(L,w))!==0){let M=new n(h,{method:"POST",body:w,duplex:"half"}),Y;if(S.isFormData(w)&&(Y=M.headers.get("content-type"))&&L.setContentType(Y),M.body){const[B,H]=xs(X,gn(Ss(O)));w=Ts(M.body,As,B,H)}}S.isString(k)||(k=k?"include":"omit");const F=s&&"credentials"in n.prototype,q={...D,signal:G,method:v.toUpperCase(),headers:L.normalize().toJSON(),body:w,duplex:"half",credentials:F?k:void 0};R=s&&new n(h,q);let T=await(s?j(R,D):j(h,q));const _=u&&(N==="stream"||N==="response");if(u&&(C||_&&z)){const M={};["status","statusText","headers"].forEach(de=>{M[de]=T[de]});const Y=S.toFiniteNumber(T.headers.get("content-length")),[B,H]=C&&xs(Y,gn(Ss(C),!0))||[];T=new r(Ts(T.body,As,B,()=>{H&&H(),z&&z()}),M)}N=N||"text";let I=await p[S.findKey(p,N)||"text"](T,g);return!_&&z&&z(),await new Promise((M,Y)=>{ys(M,Y,{data:I,headers:Ee.from(T.headers),status:T.status,statusText:T.statusText,config:g,request:R})})}catch(F){throw z&&z(),F&&F.name==="TypeError"&&/Load failed|fetch/i.test(F.message)?Object.assign(new ne("Network Error",ne.ERR_NETWORK,g,R),{cause:F.cause||F}):ne.from(F,F&&F.code,g,R)}}},ju=new Map,Os=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=ju;for(;c--;)d=s[c],f=u.get(d),f===void 0&&u.set(d,f=c?new Map:Vu(t)),u=f;return f};Os();const Tr={http:pu,xhr:Bu,fetch:{get:Os}};S.forEach(Tr,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Ms=e=>`- ${e}`,Ku=e=>S.isFunction(e)||e===null||e===!1,ks={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,!Ku(r)&&(o=Tr[(c=String(r)).toLowerCase()],o===void 0))throw new ne(`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(
|
|
5
|
-
`):" "+
|
|
6
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=it(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&bn.assertOptions(r,{silentJSONParsing:He.transitional(He.boolean),forcedJSONParsing:He.transitional(He.boolean),clarifyTimeoutError:He.transitional(He.boolean)},!1),o!=null&&(S.isFunction(o)?n.paramsSerializer={serialize:o}:bn.assertOptions(o,{encode:He.function,serialize:He.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),bn.assertOptions(n,{baseUrl:He.spelling("baseURL"),withXsrfToken:He.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=Ee.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=[Ds.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 b=n;for(;p<m;){const g=c[p++],h=c[p++];try{b=g(b)}catch(v){h.call(this,v);break}}try{u=Ds.call(this,b)}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=it(this.defaults,t);const n=Cs(t.baseURL,t.url,t.allowAbsoluteUrls);return hs(n,t.params,t.paramsSerializer)}};S.forEach(["delete","get","head","options"],function(t){ct.prototype[t]=function(n,r){return this.request(it(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(it(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}ct.prototype[t]=n(),ct.prototype[t+"Form"]=n(!0)});let qu=class Ed{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 wt(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 Ed(function(o){t=o}),cancel:t}}};function Xu(e){return function(n){return e.apply(null,n)}}function Yu(e){return S.isObject(e)&&e.isAxiosError===!0}const Pr={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(Pr).forEach(([e,t])=>{Pr[t]=e});function $s(e){const t=new ct(e),n=Qo(ct.prototype.request,t);return S.extend(n,ct.prototype,t,{allOwnKeys:!0}),S.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return $s(it(e,o))},n}const me=$s(Bt);me.Axios=ct,me.CanceledError=wt,me.CancelToken=qu,me.isCancel=ws,me.VERSION=Ls,me.toFormData=pn,me.AxiosError=ne,me.Cancel=me.CanceledError,me.all=function(t){return Promise.all(t)},me.spread=Xu,me.isAxiosError=Yu,me.mergeConfig=it,me.AxiosHeaders=Ee,me.formToJSON=e=>vs(S.isHTMLForm(e)?new FormData(e):e),me.getAdapter=ks.getAdapter,me.HttpStatusCode=Pr,me.default=me;const{Axios:uw,AxiosError:fw,CanceledError:pw,isCancel:hw,CancelToken:gw,VERSION:mw,all:vw,Cancel:bw,isAxiosError:ww,spread:yw,toFormData:xw,AxiosHeaders:Sw,HttpStatusCode:Cw,formToJSON:Ew,getAdapter:Nw,mergeConfig:Tw}=me,_r={};function zt(){var e;try{return typeof window<"u"&&((e=window.localStorage)==null?void 0:e.getItem("chat-debug"))==="1"}catch{return!1}}const Bs=_r==null?void 0:_r.VITE_API_BASE_URL,Us=Bs?Bs.replace(/\/+$/,""):void 0;!Us&&typeof window<"u"&&console.warn("VITE_API_BASE_URL is not set. The API client will need to be configured via apiConfig prop.");let wn=null;const Ir=new Set;function Or(){return wn}function Mr(e){wn=e,Ir.forEach(t=>t(e))}function zs(e){return Ir.add(e),()=>Ir.delete(e)}const We=me.create({baseURL:Us||"http://localhost:8000",timeout:3e4,withCredentials:!0});We.interceptors.request.use(e=>(wn&&(e.headers.Authorization=`Bearer ${wn}`),e)),We.interceptors.response.use(e=>e,e=>Promise.reject(e));async function lt(e,t){return(await We.get(e,t)).data}async function kr(e,t,n){return(await We.post(e,t,n)).data}async function Hs(e,t,n){return(await We.put(e,t,n)).data}async function Ws(e,t){return(await We.delete(e,t)).data}async function Ju(e,t){var m;if(zt()){let b=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}))),b=g}catch{}console.debug("[api.stream]",t.method,`${We.defaults.baseURL}${e}`,b)}const r=(We.defaults.baseURL||"").replace(/\/+$|^\s+|\s+$/g,""),o=t.method??"POST",s=Or(),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 b=await f.text().catch(()=>"");throw zt()&&console.debug("[api.stream] non-OK",f.status,b==null?void 0:b.slice(0,500)),new Error(`Stream failed: ${f.status} ${f.statusText}${b?": "+b:""}`)}const u=f.body.getReader(),p=new TextDecoder;for(;;){const{done:b,value:g}=await u.read();if(b)break;const h=p.decode(g,{stream:!0});zt()&&console.debug("[api.stream] chunk",h.slice(0,200)),t.onChunk(h)}}function Re(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class yn{get baseUrl(){const t=We.defaults.baseURL||"";return String(t).replace(/\/+$|^\s+|\s+$/g,"")}updateConfig(t){t.baseUrl&&(We.defaults.baseURL=String(t.baseUrl).replace(/\/+$/g,"")),t.authToken!==void 0&&Mr(t.authToken)}getAuthToken(){return Or()}setAuthToken(t){Mr(t)}onTokenChange(t){return zs(t)}async listThreads(){const t=await lt("/chat/threads"),n=Re(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await kr("/chat/threads",t?{title:t}:void 0);return Re(r)}async updateThread(t,n){const r=await Hs(`/chat/threads/${t}`,{title:n});return Re(r)}async deleteThread(t){const n=await Ws(`/chat/threads/${t}`);return Re(n)}async threadInfo(t){const n=await lt(`/chat/threads/${t}/info`);return Re(n)}async getMessages(t){const n=await lt("/chat/messages",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Re(n)}async getState(t){const n=await lt("/chat/state",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Re(n)}async getStateHistory(t){const n=await lt("/chat/state/history",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Re(n)}async listCheckpoints(t){const n=await lt("/chat/checkpoints",{params:{thread_id:t}});return Re(n)}async uploadImage(t,n="/upload"){const r=new FormData;r.append("file",t,t.name),zt()&&console.debug("[api.uploadImage] ->",n,{name:t.name,type:t.type,size:t.size});const o=await kr(n,r,{headers:{Accept:"application/json"},maxBodyLength:1/0}),s=Re(o);if(zt()&&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 Ye=new yn;function Rs(e={}){const t=e.baseUrl??"/api/chat",n=e.streamPath??"/stream",[r,o]=P.useState(e.token??null),s=P.useRef(e.headers??{}),[a,c]=P.useState(!1),[d,f]=P.useState(null),[u,p]=P.useState(""),[m,b]=P.useState(null),g=P.useRef(null),h=P.useCallback(x=>{o(x)},[]),v=P.useCallback(()=>{var x;(x=g.current)==null||x.abort(),g.current=null,c(!1)},[]),w=P.useCallback(()=>{p(""),b(null),f(null)},[]),y=P.useCallback((x,E,C)=>{g.current&&(g.current.abort(),g.current=null),c(!0),f(null),e.autoAppendAssistant!==!1&&p("");const O=new AbortController;return g.current=O,(async()=>{var k,D,j,G;const N=(()=>{var R;try{return typeof window<"u"&&((R=window.localStorage)==null?void 0:R.getItem("chat-debug"))==="1"}catch{return!1}})(),L=R=>{var z;try{const X=JSON.parse(JSON.stringify(R));return(z=X==null?void 0:X.payload)!=null&&z.files_info&&Array.isArray(X.payload.files_info)&&(X.payload.files_info=X.payload.files_info.map(F=>({...F,data:F!=null&&F.data?`<base64 ${String(F.data).length} chars>`:F==null?void 0:F.data}))),X}catch{return R}};try{let R={};try{if(r)R={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const _=window.__AUTH_TOKEN__,I=((k=window.localStorage)==null?void 0:k.getItem("authToken"))||null;let M=null;try{const B=(D=window.localStorage)==null?void 0:D.getItem("chat-settings");B&&(M=((j=JSON.parse(B))==null?void 0:j.apiKey)||null)}catch{}const Y=_||I||M||null;Y&&(R={Authorization:`Bearer ${Y}`})}}catch{}N&&console.debug("[use-chat] POST",t+n,L(x));const z=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...R,...s.current},body:JSON.stringify(x),signal:O.signal});if(!z.ok||!z.body){const T=await z.text().catch(()=>"");throw N&&console.debug("[use-chat] non-OK response",z.status,T==null?void 0:T.slice(0,500)),new Error(`stream ${z.status}${T?": "+T:""}`)}const X=z.body.getReader(),F=new TextDecoder;let q="";for(;;){const{value:T,done:_}=await X.read();if(_)break;q+=F.decode(T,{stream:!0});let I;for(;(I=q.indexOf(`
|
|
1
|
+
(function(Q,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):(Q=typeof globalThis<"u"?globalThis:Q||self,i(Q.NewChatUI={},Q.jsxRuntime,Q.React,Q.LucideReact,Q.reactSlot,Q.classVarianceAuthority,Q.clsx,Q.tailwindMerge,Q.ReactDOM,Q.ReactMarkdown,Q.remarkGfm))})(this,function(Q,i,P,K,Pe,Lt,Td,Ad,Jo,Pd,_d){"use strict";var br=typeof document<"u"?document.currentScript:null;function Zo(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=Zo(P),cn=Zo(Jo);function Qo(e,t){return function(){return e.apply(t,arguments)}}const{toString:Id}=Object.prototype,{getPrototypeOf:vr}=Object,{iterator:ln,toStringTag:es}=Symbol,dn=(e=>t=>{const n=Id.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),De=e=>(e=e.toLowerCase(),t=>dn(t)===e),un=e=>t=>typeof t===e,{isArray:bt}=Array,vt=un("undefined");function Ft(e){return e!==null&&!vt(e)&&e.constructor!==null&&!vt(e.constructor)&&Ee(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ts=De("ArrayBuffer");function Od(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ts(e.buffer),t}const kd=un("string"),Ee=un("function"),ns=un("number"),$t=e=>e!==null&&typeof e=="object",Md=e=>e===!0||e===!1,fn=e=>{if(dn(e)!=="object")return!1;const t=vr(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(es in e)&&!(ln in e)},Dd=e=>{if(!$t(e)||Ft(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Ld=De("Date"),Fd=De("File"),$d=De("Blob"),Bd=De("FileList"),Ud=e=>$t(e)&&Ee(e.pipe),zd=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ee(e.append)&&((t=dn(e))==="formdata"||t==="object"&&Ee(e.toString)&&e.toString()==="[object FormData]"))},Hd=De("URLSearchParams"),[Wd,Vd,jd,Rd]=["ReadableStream","Request","Response","Headers"].map(De),Kd=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Bt(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),bt(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Ft(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 rs(e,t){if(Ft(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 at=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,os=e=>!vt(e)&&e!==at;function wr(){const{caseless:e,skipUndefined:t}=os(this)&&this||{},n={},r=(o,s)=>{const a=e&&rs(n,s)||s;fn(n[a])&&fn(o)?n[a]=wr(n[a],o):fn(o)?n[a]=wr({},o):bt(o)?n[a]=o.slice():(!t||!vt(o))&&(n[a]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Bt(arguments[o],r);return n}const Gd=(e,t,n,{allOwnKeys:r}={})=>(Bt(t,(o,s)=>{n&&Ee(o)?e[s]=Qo(o,n):e[s]=o},{allOwnKeys:r}),e),qd=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Xd=(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)},Yd=(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&&vr(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Jd=(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},Zd=e=>{if(!e)return null;if(bt(e))return e;let t=e.length;if(!ns(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Qd=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&vr(Uint8Array)),eu=(e,t)=>{const r=(e&&e[ln]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},tu=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},nu=De("HTMLFormElement"),ru=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),ss=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ou=De("RegExp"),as=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Bt(n,(o,s)=>{let a;(a=t(o,s,e))!==!1&&(r[s]=a||o)}),Object.defineProperties(e,r)},su=e=>{as(e,(t,n)=>{if(Ee(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ee(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+"'")})}})},au=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return bt(e)?r(e):r(String(e).split(t)),n},iu=()=>{},cu=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function lu(e){return!!(e&&Ee(e.append)&&e[es]==="FormData"&&e[ln])}const du=e=>{const t=new Array(10),n=(r,o)=>{if($t(r)){if(t.indexOf(r)>=0)return;if(Ft(r))return r;if(!("toJSON"in r)){t[o]=r;const s=bt(r)?[]:{};return Bt(r,(a,c)=>{const d=n(a,o+1);!vt(d)&&(s[c]=d)}),t[o]=void 0,s}}return r};return n(e,0)},uu=De("AsyncFunction"),fu=e=>e&&($t(e)||Ee(e))&&Ee(e.then)&&Ee(e.catch),is=((e,t)=>e?setImmediate:t?((n,r)=>(at.addEventListener("message",({source:o,data:s})=>{o===at&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),at.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ee(at.postMessage)),pu=typeof queueMicrotask<"u"?queueMicrotask.bind(at):typeof process<"u"&&process.nextTick||is,S={isArray:bt,isArrayBuffer:ts,isBuffer:Ft,isFormData:zd,isArrayBufferView:Od,isString:kd,isNumber:ns,isBoolean:Md,isObject:$t,isPlainObject:fn,isEmptyObject:Dd,isReadableStream:Wd,isRequest:Vd,isResponse:jd,isHeaders:Rd,isUndefined:vt,isDate:Ld,isFile:Fd,isBlob:$d,isRegExp:ou,isFunction:Ee,isStream:Ud,isURLSearchParams:Hd,isTypedArray:Qd,isFileList:Bd,forEach:Bt,merge:wr,extend:Gd,trim:Kd,stripBOM:qd,inherits:Xd,toFlatObject:Yd,kindOf:dn,kindOfTest:De,endsWith:Jd,toArray:Zd,forEachEntry:eu,matchAll:tu,isHTMLForm:nu,hasOwnProperty:ss,hasOwnProp:ss,reduceDescriptors:as,freezeMethods:su,toObjectSet:au,toCamelCase:ru,noop:iu,toFiniteNumber:cu,findKey:rs,global:at,isContextDefined:os,isSpecCompliantForm:lu,toJSONObject:du,isAsyncFn:uu,isThenable:fu,setImmediate:is,asap:pu,isIterable:e=>e!=null&&Ee(e[ln])};function ne(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(ne,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 cs=ne.prototype,ls={};["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=>{ls[e]={value:e}}),Object.defineProperties(ne,ls),Object.defineProperty(cs,"isAxiosError",{value:!0}),ne.from=(e,t,n,r,o,s)=>{const a=Object.create(cs);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 ne.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 hu=null;function yr(e){return S.isPlainObject(e)||S.isArray(e)}function ds(e){return S.endsWith(e,"[]")?e.slice(0,-2):e}function us(e,t,n){return e?e.concat(t).map(function(o,s){return o=ds(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function gu(e){return S.isArray(e)&&!e.some(yr)}const mu=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 ne("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)&&gu(g)||(S.isFileList(g)||S.endsWith(h,"[]"))&&(w=S.toArray(g)))return h=ds(h),w.forEach(function(x,E){!(S.isUndefined(x)||x===null)&&t.append(a===!0?us([h],E,s):a===null?h:h+"[]",f(x))}),!1}return yr(g)?!0:(t.append(us(b,h,s),f(g)),!1)}const p=[],m=Object.assign(mu,{defaultVisitor:u,convertValue:f,isVisitable:yr});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 fs(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function xr(e,t){this._pairs=[],e&&pn(e,this,t)}const ps=xr.prototype;ps.append=function(t,n){this._pairs.push([t,n])},ps.toString=function(t){const n=t?function(r){return t.call(this,r,fs)}:fs;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function bu(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function hs(e,t,n){if(!t)return e;const r=n&&n.encode||bu;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 xr(t,n).toString(r),s){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class gs{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 ms={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},vu={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:xr,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Sr=typeof window<"u"&&typeof document<"u",Cr=typeof navigator=="object"&&navigator||void 0,wu=Sr&&(!Cr||["ReactNative","NativeScript","NS"].indexOf(Cr.product)<0),yu=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",xu=Sr&&window.location.href||"http://localhost",xe={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Sr,hasStandardBrowserEnv:wu,hasStandardBrowserWebWorkerEnv:yu,navigator:Cr,origin:xu},Symbol.toStringTag,{value:"Module"})),...vu};function Su(e,t){return pn(e,new xe.classes.URLSearchParams,{visitor:function(n,r,o,s){return xe.isNode&&S.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Cu(e){return S.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Eu(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 bs(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]=Eu(o[a])),!c)}if(S.isFormData(e)&&S.isFunction(e.entries)){const n={};return S.forEachEntry(e,(r,o)=>{t(Cu(r),o,n,0)}),n}return null}function Nu(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 Ut={transitional:ms,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(bs(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 Su(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),Nu(t)):t}],transformResponse:[function(t){const n=this.transitional||Ut.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"?ne.from(c,ne.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:xe.classes.FormData,Blob:xe.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=>{Ut.headers[e]={}});const Tu=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"]),Au=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]&&Tu[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},vs=Symbol("internals");function zt(e){return e&&String(e).trim().toLowerCase()}function hn(e){return e===!1||e==null?e:S.isArray(e)?e.map(hn):String(e)}function Pu(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 _u=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Er(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 Iu(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Ou(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 Ne=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(c,d,f){const u=zt(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]=hn(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())&&!_u(t))a(Au(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=zt(t),t){const r=S.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Pu(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=zt(t),t){const r=S.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Er(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(a){if(a=zt(a),a){const c=S.findKey(r,a);c&&(!n||Er(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||Er(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]=hn(o),delete n[s];return}const c=t?Iu(s):String(s).trim();c!==s&&delete n[s],n[c]=hn(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[vs]=this[vs]={accessors:{}}).accessors,o=this.prototype;function s(a){const c=zt(a);r[c]||(Ou(o,a),r[c]=!0)}return S.isArray(t)?t.forEach(s):s(t),this}};Ne.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),S.reduceDescriptors(Ne.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),S.freezeMethods(Ne);function Nr(e,t){const n=this||Ut,r=t||n,o=Ne.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 ws(e){return!!(e&&e.__CANCEL__)}function wt(e,t,n){ne.call(this,e??"canceled",ne.ERR_CANCELED,t,n),this.name="CanceledError"}S.inherits(wt,ne,{__CANCEL__:!0});function ys(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new ne("Request failed with status code "+n.status,[ne.ERR_BAD_REQUEST,ne.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function ku(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Mu(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 Du(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 gn=(e,t,n=3)=>{let r=0;const o=Mu(50,250);return Du(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)},xs=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ss=e=>(...t)=>S.asap(()=>e(...t)),Lu=xe.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,xe.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(xe.origin),xe.navigator&&/(msie|trident)/i.test(xe.navigator.userAgent)):()=>!0,Fu=xe.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 $u(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Bu(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Cs(e,t,n){let r=!$u(t);return e&&(r||n==!1)?Bu(e,t):t}const Es=e=>e instanceof Ne?{...e}:e;function it(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(Es(f),Es(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 Ns=e=>{const t=it({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:a,auth:c}=t;if(t.headers=a=Ne.from(a),t.url=hs(Cs(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(xe.hasStandardBrowserEnv||xe.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(xe.hasStandardBrowserEnv&&(r&&S.isFunction(r)&&(r=r(t)),r||r!==!1&&Lu(t.url))){const d=o&&s&&Fu.read(s);d&&a.set(o,d)}return t},Uu=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Ns(e);let s=o.data;const a=Ne.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=Ne.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),C={data:!c||c==="text"||c==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:x,config:e,request:b};ys(function(N){n(N),h()},function(N){r(N),h()},C),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 ne("Request aborted",ne.ECONNABORTED,e,b)),b=null)},b.onerror=function(E){const C=E&&E.message?E.message:"Network Error",O=new ne(C,ne.ERR_NETWORK,e,b);O.event=E||null,r(O),b=null},b.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||ms;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new ne(E,C.clarifyTimeoutError?ne.ETIMEDOUT:ne.ECONNABORTED,e,b)),b=null},s===void 0&&a.setContentType(null),"setRequestHeader"in b&&S.forEach(a.toJSON(),function(E,C){b.setRequestHeader(C,E)}),S.isUndefined(o.withCredentials)||(b.withCredentials=!!o.withCredentials),c&&c!=="json"&&(b.responseType=o.responseType),f&&([m,g]=gn(f,!0),b.addEventListener("progress",m)),d&&b.upload&&([p,v]=gn(d),b.upload.addEventListener("progress",p),b.upload.addEventListener("loadend",v)),(o.cancelToken||o.signal)&&(u=x=>{b&&(r(!x||x.type?new wt(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=ku(o.url);if(y&&xe.protocols.indexOf(y)===-1){r(new ne("Unsupported protocol "+y+":",ne.ERR_BAD_REQUEST,e));return}b.send(s||null)})},zu=(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 ne?u:new wt(u instanceof Error?u.message:u))}};let a=t&&setTimeout(()=>{a=null,s(new ne(`timeout ${t} of ms exceeded`,ne.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}},Hu=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},Wu=async function*(e,t){for await(const n of Vu(e))yield*Hu(n,t)},Vu=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()}},Ts=(e,t,n,r)=>{const o=Wu(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})},As=64*1024,{isFunction:mn}=S,ju=(({Request:e,Response:t})=>({Request:e,Response:t}))(S.global),{ReadableStream:Ps,TextEncoder:_s}=S.global,Is=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Ru=e=>{e=S.merge.call({skipUndefined:!0},ju,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(Ps),d=o&&(typeof _s=="function"?(g=>h=>g.encode(h))(new _s):async g=>new Uint8Array(await new n(g).arrayBuffer())),f=s&&c&&Is(()=>{let g=!1;const h=new n(xe.origin,{body:new Ps,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return g&&!h}),u=a&&c&&Is(()=>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 ne(`Response type '${g}' is not supported`,ne.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(xe.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:E,onDownloadProgress:C,onUploadProgress:O,responseType:N,headers:F,withCredentials:M="same-origin",fetchOptions:L}=Ns(g),R=t||fetch;N=N?(N+"").toLowerCase():"text";let G=zu([y,x&&x.toAbortSignal()],E),V=null;const z=G&&G.unsubscribe&&(()=>{G.unsubscribe()});let X;try{if(O&&f&&b!=="get"&&b!=="head"&&(X=await v(F,w))!==0){let k=new n(h,{method:"POST",body:w,duplex:"half"}),Y;if(S.isFormData(w)&&(Y=k.headers.get("content-type"))&&F.setContentType(Y),k.body){const[B,H]=xs(X,gn(Ss(O)));w=Ts(k.body,As,B,H)}}S.isString(M)||(M=M?"include":"omit");const $=s&&"credentials"in n.prototype,q={...L,signal:G,method:b.toUpperCase(),headers:F.normalize().toJSON(),body:w,duplex:"half",credentials:$?M:void 0};V=s&&new n(h,q);let T=await(s?R(V,L):R(h,q));const _=u&&(N==="stream"||N==="response");if(u&&(C||_&&z)){const k={};["status","statusText","headers"].forEach(de=>{k[de]=T[de]});const Y=S.toFiniteNumber(T.headers.get("content-length")),[B,H]=C&&xs(Y,gn(Ss(C),!0))||[];T=new r(Ts(T.body,As,B,()=>{H&&H(),z&&z()}),k)}N=N||"text";let I=await p[S.findKey(p,N)||"text"](T,g);return!_&&z&&z(),await new Promise((k,Y)=>{ys(k,Y,{data:I,headers:Ne.from(T.headers),status:T.status,statusText:T.statusText,config:g,request:V})})}catch($){throw z&&z(),$&&$.name==="TypeError"&&/Load failed|fetch/i.test($.message)?Object.assign(new ne("Network Error",ne.ERR_NETWORK,g,V),{cause:$.cause||$}):ne.from($,$&&$.code,g,V)}}},Ku=new Map,Os=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=Ku;for(;c--;)d=s[c],f=u.get(d),f===void 0&&u.set(d,f=c?new Map:Ru(t)),u=f;return f};Os();const Tr={http:hu,xhr:Uu,fetch:{get:Os}};S.forEach(Tr,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const ks=e=>`- ${e}`,Gu=e=>S.isFunction(e)||e===null||e===!1,Ms={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,!Gu(r)&&(o=Tr[(c=String(r)).toLowerCase()],o===void 0))throw new ne(`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(ks).join(`
|
|
5
|
+
`):" "+ks(a[0]):"as no adapter specified";throw new ne("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return o},adapters:Tr};function Ar(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new wt(null,e)}function Ds(e){return Ar(e),e.headers=Ne.from(e.headers),e.data=Nr.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ms.getAdapter(e.adapter||Ut.adapter,e)(e).then(function(r){return Ar(e),r.data=Nr.call(e,e.transformResponse,r),r.headers=Ne.from(r.headers),r},function(r){return ws(r)||(Ar(e),r&&r.response&&(r.response.data=Nr.call(e,e.transformResponse,r.response),r.response.headers=Ne.from(r.response.headers))),Promise.reject(r)})}const Ls="1.12.2",bn={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{bn[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Fs={};bn.transitional=function(t,n,r){function o(s,a){return"[Axios v"+Ls+"] Transitional option '"+s+"'"+a+(r?". "+r:"")}return(s,a,c)=>{if(t===!1)throw new ne(o(a," has been removed"+(n?" in "+n:"")),ne.ERR_DEPRECATED);return n&&!Fs[a]&&(Fs[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}},bn.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function qu(e,t,n){if(typeof e!="object")throw new ne("options must be an object",ne.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 ne("option "+s+" must be "+d,ne.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new ne("Unknown option "+s,ne.ERR_BAD_OPTION)}}const vn={assertOptions:qu,validators:bn},He=vn.validators;let ct=class{constructor(t){this.defaults=t||{},this.interceptors={request:new gs,response:new gs}}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=it(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&vn.assertOptions(r,{silentJSONParsing:He.transitional(He.boolean),forcedJSONParsing:He.transitional(He.boolean),clarifyTimeoutError:He.transitional(He.boolean)},!1),o!=null&&(S.isFunction(o)?n.paramsSerializer={serialize:o}:vn.assertOptions(o,{encode:He.function,serialize:He.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),vn.assertOptions(n,{baseUrl:He.spelling("baseURL"),withXsrfToken:He.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=Ne.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=[Ds.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=Ds.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=it(this.defaults,t);const n=Cs(t.baseURL,t.url,t.allowAbsoluteUrls);return hs(n,t.params,t.paramsSerializer)}};S.forEach(["delete","get","head","options"],function(t){ct.prototype[t]=function(n,r){return this.request(it(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(it(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}ct.prototype[t]=n(),ct.prototype[t+"Form"]=n(!0)});let Xu=class Nd{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 wt(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 Nd(function(o){t=o}),cancel:t}}};function Yu(e){return function(n){return e.apply(null,n)}}function Ju(e){return S.isObject(e)&&e.isAxiosError===!0}const Pr={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(Pr).forEach(([e,t])=>{Pr[t]=e});function $s(e){const t=new ct(e),n=Qo(ct.prototype.request,t);return S.extend(n,ct.prototype,t,{allOwnKeys:!0}),S.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return $s(it(e,o))},n}const me=$s(Ut);me.Axios=ct,me.CanceledError=wt,me.CancelToken=Xu,me.isCancel=ws,me.VERSION=Ls,me.toFormData=pn,me.AxiosError=ne,me.Cancel=me.CanceledError,me.all=function(t){return Promise.all(t)},me.spread=Yu,me.isAxiosError=Ju,me.mergeConfig=it,me.AxiosHeaders=Ne,me.formToJSON=e=>bs(S.isHTMLForm(e)?new FormData(e):e),me.getAdapter=Ms.getAdapter,me.HttpStatusCode=Pr,me.default=me;const{Axios:pw,AxiosError:hw,CanceledError:gw,isCancel:mw,CancelToken:bw,VERSION:vw,all:ww,Cancel:yw,isAxiosError:xw,spread:Sw,toFormData:Cw,AxiosHeaders:Ew,HttpStatusCode:Nw,formToJSON:Tw,getAdapter:Aw,mergeConfig:Pw}=me,_r={};function Ht(){var e;try{return typeof window<"u"&&((e=window.localStorage)==null?void 0:e.getItem("chat-debug"))==="1"}catch{return!1}}const Bs=_r==null?void 0:_r.VITE_API_BASE_URL,Us=Bs?Bs.replace(/\/+$/,""):void 0;!Us&&typeof window<"u"&&console.warn("VITE_API_BASE_URL is not set. The API client will need to be configured via apiConfig prop.");let wn=null;const Ir=new Set;function Or(){return wn}function kr(e){wn=e,Ir.forEach(t=>t(e))}function zs(e){return Ir.add(e),()=>Ir.delete(e)}const We=me.create({baseURL:Us||"http://localhost:8000",timeout:3e4,withCredentials:!0});We.interceptors.request.use(e=>(wn&&(e.headers.Authorization=`Bearer ${wn}`),e)),We.interceptors.response.use(e=>e,e=>Promise.reject(e));async function lt(e,t){return(await We.get(e,t)).data}async function Mr(e,t,n){return(await We.post(e,t,n)).data}async function Hs(e,t,n){return(await We.put(e,t,n)).data}async function Ws(e,t){return(await We.delete(e,t)).data}async function Zu(e,t){var m;if(Ht()){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,`${We.defaults.baseURL}${e}`,v)}const r=(We.defaults.baseURL||"").replace(/\/+$|^\s+|\s+$/g,""),o=t.method??"POST",s=Or(),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 Ht()&&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});Ht()&&console.debug("[api.stream] chunk",h.slice(0,200)),t.onChunk(h)}}function Ve(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class yn{get baseUrl(){const t=We.defaults.baseURL||"";return String(t).replace(/\/+$|^\s+|\s+$/g,"")}updateConfig(t){t.baseUrl&&(We.defaults.baseURL=String(t.baseUrl).replace(/\/+$/g,"")),t.authToken!==void 0&&kr(t.authToken)}getAuthToken(){return Or()}setAuthToken(t){kr(t)}onTokenChange(t){return zs(t)}async listThreads(){const t=await lt("/chat/threads"),n=Ve(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Mr("/chat/threads",t?{title:t}:void 0);return Ve(r)}async updateThread(t,n){const r=await Hs(`/chat/threads/${t}`,{title:n});return Ve(r)}async deleteThread(t){const n=await Ws(`/chat/threads/${t}`);return Ve(n)}async threadInfo(t){const n=await lt(`/chat/threads/${t}/info`);return Ve(n)}async getMessages(t){const n=await lt("/chat/messages",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ve(n)}async getState(t){const n=await lt("/chat/state",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ve(n)}async getStateHistory(t){const n=await lt("/chat/state/history",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ve(n)}async listCheckpoints(t){const n=await lt("/chat/checkpoints",{params:{thread_id:t}});return Ve(n)}async uploadImage(t,n="/upload"){const r=new FormData;r.append("file",t,t.name),Ht()&&console.debug("[api.uploadImage] ->",n,{name:t.name,type:t.type,size:t.size});const o=await Mr(n,r,{headers:{Accept:"application/json"},maxBodyLength:1/0}),s=Ve(o);if(Ht()&&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 Ye=new yn;function Vs(e={}){const t=e.baseUrl??"/api/chat",n=e.streamPath??"/stream",[r,o]=P.useState(e.token??null),s=P.useRef(e.headers??{}),[a,c]=P.useState(!1),[d,f]=P.useState(null),[u,p]=P.useState(""),[m,v]=P.useState(null),g=P.useRef(null),h=P.useCallback(x=>{o(x)},[]),b=P.useCallback(()=>{var x;(x=g.current)==null||x.abort(),g.current=null,c(!1)},[]),w=P.useCallback(()=>{p(""),v(null),f(null)},[]),y=P.useCallback((x,E,C)=>{g.current&&(g.current.abort(),g.current=null),c(!0),f(null),e.autoAppendAssistant!==!1&&p("");const O=new AbortController;return g.current=O,(async()=>{var M,L,R,G;const N=(()=>{var V;try{return typeof window<"u"&&((V=window.localStorage)==null?void 0:V.getItem("chat-debug"))==="1"}catch{return!1}})(),F=V=>{var z;try{const X=JSON.parse(JSON.stringify(V));return(z=X==null?void 0:X.payload)!=null&&z.files_info&&Array.isArray(X.payload.files_info)&&(X.payload.files_info=X.payload.files_info.map($=>({...$,data:$!=null&&$.data?`<base64 ${String($.data).length} chars>`:$==null?void 0:$.data}))),X}catch{return V}};try{let V={};try{if(r)V={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const _=window.__AUTH_TOKEN__,I=((M=window.localStorage)==null?void 0:M.getItem("authToken"))||null;let k=null;try{const B=(L=window.localStorage)==null?void 0:L.getItem("chat-settings");B&&(k=((R=JSON.parse(B))==null?void 0:R.apiKey)||null)}catch{}const Y=_||I||k||null;Y&&(V={Authorization:`Bearer ${Y}`})}}catch{}N&&console.debug("[use-chat] POST",t+n,F(x));const z=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...V,...s.current},body:JSON.stringify(x),signal:O.signal});if(!z.ok||!z.body){const T=await z.text().catch(()=>"");throw N&&console.debug("[use-chat] non-OK response",z.status,T==null?void 0:T.slice(0,500)),new Error(`stream ${z.status}${T?": "+T:""}`)}const X=z.body.getReader(),$=new TextDecoder;let q="";for(;;){const{value:T,done:_}=await X.read();if(_)break;q+=$.decode(T,{stream:!0});let I;for(;(I=q.indexOf(`
|
|
7
7
|
|
|
8
|
-
`))>=0;){const
|
|
9
|
-
`)}const ef={messages:[],assemblingId:null,lastCheckpointId:null,toolIndex:{}};function tf(e,t){var n,r;switch(t.type){case"reset":return{messages:js(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,toolIndex:{}};case"seed":return{...e,messages:js(t.payload.messages)};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=sf(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??Dr(e.messages);return s?{...e,messages:nf(e.messages,s,o.content)}:e}if(o.type==="message_delta"){const s=e.assemblingId??Dr(e.messages);return s?{...e,messages:Ks(e.messages,s,o.delta)}:e}if(o.type==="message_end"){const s=e.assemblingId??Dr(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?Ks(e.messages,s,[a]):[...e.messages,d];return{...e,messages:f}}if(o.type==="checkpoint"){const s=of(e.messages,o.checkpointId);return{...e,lastCheckpointId:o.checkpointId,messages:s}}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 Vs(e=[]){const[t,n]=P.useReducer(tf,{...ef,messages:e}),r=P.useCallback(s=>{n({type:"event",payload:{ev:s}})},[]),o=P.useMemo(()=>({reset:s=>n({type:"reset",payload:{messages:s}}),seed:s=>n({type:"seed",payload:{messages:s}}),pushUser:s=>n({type:"user_message",payload:{message:s}}),onEvent:r}),[r]);return{state:t,dispatch:n,...o}}function js(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 Dr(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function nf(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 Ks(e,t,n){return e.map(r=>r.id===t?{...r,content:rf(r.content,n)}:r)}function rf(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 of(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 sf(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const Gs=P.createContext(null);function Ht({children:e,apiConfig:t,onError:n,onThreadChange:r,initialThreadId:o=null}){const s=Ye;P.useEffect(()=>{t&&s.updateConfig({baseUrl:t.baseUrl,authToken:t.apiKey})},[s,t]);const{isStreaming:a,error:c,stream:d,stop:f,setToken:u}=Rs({baseUrl:s.baseUrl,token:null,headers:t==null?void 0:t.headers,streamPath:"/chat/stream"}),[p,m]=P.useState(()=>typeof s.getAuthToken=="function"?s.getAuthToken():null);P.useEffect(()=>{u(typeof s.getAuthToken=="function"?s.getAuthToken():null);const I=s.onTokenChange(M=>{m(M),u(M)});return()=>{I()}},[s,u]);const b=P.useCallback(I=>{s.setAuthToken(I)},[s]),{state:g,seed:h,pushUser:v,onEvent:w,reset:y}=Vs(),[x,E]=P.useState([]),[C,O]=P.useState(null),N=P.useCallback(async()=>{const I=await s.listThreads();E(I)},[s]);P.useEffect(()=>{N().catch(()=>{})},[N]),P.useEffect(()=>{r==null||r(C)},[C,r]);const L=P.useRef(null);P.useEffect(()=>{o&&L.current!==o&&(L.current=o,D(o).catch(()=>{}))},[o]);const k=P.useRef(null),D=P.useCallback(async(I,M,Y)=>{var B;if(k.current!==I){k.current=I;try{const H=M??((B=(await s.listCheckpoints(I)).checkpoints.slice().sort((ie,V)=>new Date(V.createdAt).getTime()-new Date(ie.createdAt).getTime())[0])==null?void 0:B.checkpointId),de=await s.getMessages({threadId:I,checkpointId:H,checkpointNs:Y});O(I),h(de.messages)}finally{k.current=null}}},[s,h]),j=P.useCallback(async I=>s.listCheckpoints(I),[s]),G=P.useCallback(async I=>{if(!C)throw new Error("No active thread");const M=await s.getMessages({threadId:C,checkpointId:I});h(M.messages)},[s,C,h]),R=P.useCallback(async()=>{if(!C)throw new Error("No active thread");await D(C)},[C,D]),z=P.useRef(!1);P.useEffect(()=>{const I=z.current;if(z.current=a,I&&!a&&C){const M=g.lastCheckpointId??void 0;s.getMessages({threadId:C,checkpointId:M}).then(Y=>h(Y.messages)).catch(()=>{})}},[a,C,g.lastCheckpointId,s,h]);const X=P.useCallback(async I=>{const M=await s.createThread(I);return await N(),await D(M.threadId),M.threadId},[s,N,D]),F=P.useCallback(async I=>{await s.deleteThread(I),await N(),C===I&&(O(null),y([]))},[s,N,C,y]),q=P.useCallback(async(I,M)=>{await s.updateThread(I,M),await N()},[s,N]),T=P.useCallback(async(I,M)=>{var ae;if(!C)throw new Error("No active thread");async function Y(W){return await new Promise((ee,pe)=>{const he=new FileReader;he.onload=()=>ee(String(he.result)),he.onerror=J=>pe(J),he.readAsDataURL(W)})}async function B(W){return await new Promise((ee,pe)=>{const he=new FileReader;he.onload=()=>{try{const J=he.result;let be="";const ce=new Uint8Array(J),ge=ce.byteLength;for(let Te=0;Te<ge;Te++)be+=String.fromCharCode(ce[Te]);ee(btoa(be))}catch(J){pe(J)}},he.onerror=J=>pe(J),he.readAsArrayBuffer(W)})}const H=[];I&&H.push({type:"text",text:I});const de=(M==null?void 0:M.attachments)||[];let ie=[];if(de.length>0)for(const W of de)if(W.type&&W.type.startsWith("image/")){let ee=null;try{const pe=await s.uploadImage(W,(t==null?void 0:t.uploadPath)||"/upload").catch(()=>null);ee=(pe==null?void 0:pe.url)||null}catch{}if(!ee)try{ee=await Y(W)}catch{ee=null}if(ee){const pe={type:"image_url",url:ee,mimeType:W.type,alt:W.name};H.push(pe)}try{ie.push({filename:W.name,data:await B(W),mime_type:W.type||"application/octet-stream"})}catch{}}else{const ee=await Y(W).catch(()=>null),pe={type:"file",url:String(ee),mimeType:W.type||void 0,name:W.name,size:W.size};H.push(pe);try{ie.push({filename:W.name,data:await B(W),mime_type:W.type||"application/octet-stream"})}catch{}}const V={id:((ae=crypto.randomUUID)==null?void 0:ae.call(crypto))||`user-${Date.now()}`,role:"user",content:H,createdAt:new Date().toISOString(),checkpointId:(M==null?void 0:M.checkpointId)??g.lastCheckpointId??void 0};v(V);const se={...V,content:V.content.filter(W=>W.type==="text"||W.type==="image_url")},le={threadId:C,payload:{messages:[se],attachments:V.content.filter(W=>W.type==="file").map(W=>({type:"file",url:W.url,mimeType:W.mimeType,name:W.name,size:W.size})),files_info:ie,...(M==null?void 0:M.payloadExtras)??{}},checkpointId:(M==null?void 0:M.checkpointId)??g.lastCheckpointId??void 0,checkpointNs:M==null?void 0:M.checkpointNs,nodeFilter:M==null?void 0:M.nodeFilter,config:M==null?void 0:M.config};d(le,W=>w(W),{onError:W=>console.warn("stream error",W)})},[C,v,d,w,g.lastCheckpointId,s,t==null?void 0:t.uploadPath]),_={baseUrl:s.baseUrl,token:p,setToken:b,api:s,threads:x,currentThreadId:C,setCurrentThreadId:O,messages:g.messages,isStreaming:a,error:c,lastCheckpointId:g.lastCheckpointId,streamingAssistantId:g.assemblingId,refreshThreads:N,createThread:X,deleteThread:F,renameThread:q,loadThread:D,listCheckpoints:j,navigateToCheckpoint:G,returnToLatest:R,send:T,stop:f};return i.jsx(Gs.Provider,{value:_,children:e})}function Lr(){const e=P.useContext(Gs);if(!e)throw new Error("useChat must be used within ChatProvider");return e}function A(...e){return Td.twMerge(Nd.clsx(e))}const af=Dt.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"}}),fe=l.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const a=r?Pe.Slot:"button";return i.jsx(a,{className:A(af({variant:t,size:n,className:e})),ref:s,...o})});fe.displayName="Button";const qs=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}));qs.displayName="Textarea";const cf=Dt.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 Xs({className:e,variant:t,...n}){return i.jsx("div",{className:A(cf({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 lf(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 Le(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:b,...g}=p,h=((w=m==null?void 0:m[e])==null?void 0:w[d])||c,v=l.useMemo(()=>g,Object.values(g));return i.jsx(h.Provider,{value:v,children:b})};f.displayName=s+"Provider";function u(p,m){var h;const b=((h=m==null?void 0:m[e])==null?void 0:h[d])||c,g=l.useContext(b);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,df(o,...t)]}function df(...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 ve=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},uf=l[" useInsertionEffect ".trim().toString()]||ve;function Qe({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,a]=ff({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=pf(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 ff({defaultProp:e,onChange:t}){const[n,r]=l.useState(e),o=l.useRef(n),s=l.useRef(t);return uf(()=>{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 pf(e){return typeof e=="function"}function Ys(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Fr(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Ys(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():Ys(e[o],null)}}}}function re(...e){return l.useCallback(Fr(...e),e)}var hf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Z=hf.reduce((e,t)=>{const n=Pe.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 Js(e,t){e&&cn.flushSync(()=>e.dispatchEvent(t))}function gf(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var Ne=e=>{const{present:t,children:n}=e,r=mf(t),o=typeof n=="function"?n({present:r.isPresent}):l.Children.only(n),s=re(r.ref,vf(o));return typeof n=="function"||r.isPresent?l.cloneElement(o,{ref:s}):null};Ne.displayName="Presence";function mf(e){const[t,n]=l.useState(),r=l.useRef(null),o=l.useRef(e),s=l.useRef("none"),a=e?"mounted":"unmounted",[c,d]=gf(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const f=xn(r.current);s.current=c==="mounted"?f:"none"},[c]),ve(()=>{const f=r.current,u=o.current;if(u!==e){const m=s.current,b=xn(f);e?d("MOUNT"):b==="none"||(f==null?void 0:f.display)==="none"?d("UNMOUNT"):d(u&&m!==b?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),ve(()=>{if(t){let f;const u=t.ownerDocument.defaultView??window,p=b=>{const h=xn(r.current).includes(CSS.escape(b.animationName));if(b.target===t&&h&&(d("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",f=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},m=b=>{b.target===t&&(s.current=xn(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 xn(e){return(e==null?void 0:e.animationName)||"none"}function vf(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 bf=l[" useId ".trim().toString()]||(()=>{}),wf=0;function Fe(e){const[t,n]=l.useState(bf());return ve(()=>{n(r=>r??String(wf++))},[e]),t?`radix-${t}`:""}var Sn="Collapsible",[yf,Aw]=Le(Sn),[xf,$r]=yf(Sn),Zs=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:a,...c}=e,[d,f]=Qe({prop:r,defaultProp:o??!1,onChange:a,caller:Sn});return i.jsx(xf,{scope:n,disabled:s,contentId:Fe(),open:d,onOpenToggle:l.useCallback(()=>f(u=>!u),[f]),children:i.jsx(Z.div,{"data-state":Ur(d),"data-disabled":s?"":void 0,...c,ref:t})})});Zs.displayName=Sn;var Qs="CollapsibleTrigger",ea=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=$r(Qs,n);return i.jsx(Z.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Ur(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:U(e.onClick,o.onOpenToggle)})});ea.displayName=Qs;var Br="CollapsibleContent",Sf=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=$r(Br,e.__scopeCollapsible);return i.jsx(Ne,{present:n||o.open,children:({present:s})=>i.jsx(Cf,{...r,ref:t,present:s})})});Sf.displayName=Br;var Cf=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,a=$r(Br,n),[c,d]=l.useState(r),f=l.useRef(null),u=re(t,f),p=l.useRef(0),m=p.current,b=l.useRef(0),g=b.current,h=a.open||c,v=l.useRef(h),w=l.useRef(void 0);return l.useEffect(()=>{const y=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(y)},[]),ve(()=>{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,b.current=x.width,v.current||(y.style.transitionDuration=w.current.transitionDuration,y.style.animationName=w.current.animationName),d(r)}},[a.open,r]),i.jsx(Z.div,{"data-state":Ur(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 Ur(e){return e?"open":"closed"}var Ef=Zs;const ta=Ef,na=ea;function Wt({content:e,className:t=""}){return i.jsx("div",{className:`prose prose-sm max-w-none break-words dark:prose-invert 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 leading-relaxed ${t}`,children:i.jsx(Ad,{remarkPlugins:[Pd],children:e})})}function ra({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:b={},checkpointBranches:g=[],currentCheckpointId:h,onSwitchToCheckpoint:v,onReturnToMainThread:w,temporalNavigation:y,onNavigateToPreviousBranch:x,onNavigateToNextBranch:E,onEdit:C,onRegenerate:O,onEditFromCheckpoint:N,onCancelEdit:L,onCopy:k}){const[D,j]=P.useState(!1),[G,R]=P.useState(!1),[z,X]=P.useState(!1),[F,q]=P.useState(!1),T=d==="phone"||d==="half-screen",_=e.role,I=_==="tool",M=P.useMemo(()=>Nf(e.content),[e.content]),Y=P.useMemo(()=>Of(e.content),[e.content]),B=P.useMemo(()=>e.content.filter(J=>J.type==="image_url"),[e.content]),H=P.useMemo(()=>e.content.filter(J=>J.type==="file"),[e.content]),de=Df(M,n?r:0),ie=async()=>{try{const J=I?Rt(e.content):M;await navigator.clipboard.writeText(J),j(!0),setTimeout(()=>j(!1),2e3),k==null||k(J)}catch(J){console.error("Failed to copy:",J)}},V=()=>{if(!C)return;const J=I?Rt(e.content):M;C(e.id,J)},se=()=>O==null?void 0:O(t),le=()=>{const be=A(T?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0");switch(_){case"user":return i.jsx(K.User,{className:be});case"assistant":return i.jsx(K.Bot,{className:be});case"tool":return i.jsx(K.Wrench,{className:be});default:return i.jsx(K.Bot,{className:be})}},ae=()=>{const J="group relative mb-4 max-w-full";switch(_){case"user":return A(J,"flex justify-end");case"assistant":case"tool":case"system":return A(J,"flex justify-start");default:return J}},W=()=>{const J=A("rounded-lg px-4 py-3 relative transition-all duration-200 min-w-0 break-words",T&&"px-3 py-2 text-sm");switch(_){case"user":return A(J,"bg-primary text-primary-foreground max-w-[95%]",d==="phone"&&"max-w-[98%]");case"assistant":return A(J,"bg-muted text-muted-foreground max-w-[95%] border",d==="phone"&&"max-w-[98%]");case"tool":return A(J,"bg-secondary/50 text-secondary-foreground border border-dashed max-w-[95%]",d==="phone"&&"max-w-[98%]");case"system":return A(J,"bg-accent/40 text-muted-foreground max-w-[85%] border");default:return J}},ee=J=>{if(!J)return"";try{return new Date(J).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}},pe=()=>{if(e.name==="reflection"){const ce=M.trim(),ge=zr(ce);if(ge&&typeof ge=="object")return i.jsx(Lf,{data:ge})}if(I&&!z){const ce=Rt(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",T&&"text-[10px]"),children:i.jsxs("span",{className:"truncate max-w-full",children:[ce,ce.length>=80?"…":""]})})}if(I&&f){const ce=Rt(e.content),ge=ce.length>u;return i.jsx(ta,{open:G,onOpenChange:R,children:i.jsxs("div",{className:"font-mono text-sm",children:[i.jsx("pre",{className:A("whitespace-pre-wrap break-words",T&&"text-xs"),children:ge&&!G?ce.substring(0,u)+"...":ce}),ge&&i.jsx(na,{asChild:!0,children:i.jsx(fe,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:G?i.jsxs(i.Fragment,{children:[i.jsx(K.ChevronUp,{className:"h-3 w-3 mr-1"}),"Show less"]}):i.jsxs(i.Fragment,{children:[i.jsx(K.ChevronDown,{className:"h-3 w-3 mr-1"}),"Show more (",ce.length-u," chars)"]})})})]})})}if(I&&z&&!f){const ce=If(e.content);if(ce&&Tf(ce))return i.jsx(Wt,{content:ce.trim()});const ge=Rt(e.content);return i.jsx("div",{className:"font-mono text-sm",children:i.jsx("pre",{className:A("whitespace-pre-wrap break-words",T&&"text-xs"),children:ge})})}const J=B.length>0&&_!=="tool",be=H.length>0&&_!=="tool";return i.jsxs("div",{children:[n?i.jsxs("div",{className:"relative",children:[(()=>{const ce=zr(de);return ce!==null?i.jsx(oa,{data:ce}):i.jsx(Wt,{content:Pf(Af(de))})})(),i.jsx("span",{className:"inline-block w-[6px] h-[14px] align-baseline ml-0.5 bg-foreground/40 animate-pulse",style:{verticalAlign:"text-bottom"}})]}):(()=>{const ce=zr(M.trim());if(ce!==null)return i.jsx(oa,{data:ce});if(_==="user"&&p){const ge=M.trim();if(ge.length>m)return i.jsxs(ta,{open:F,onOpenChange:q,children:[i.jsx("div",{className:A("text-sm",T&&"text-xs"),children:F?i.jsx(Wt,{content:ge}):i.jsxs("pre",{className:A("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0",T&&"text-xs"),children:[ge.substring(0,m),"..."]})}),i.jsx(na,{asChild:!0,children:i.jsx(fe,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:F?i.jsxs(i.Fragment,{children:[i.jsx(K.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):i.jsxs(i.Fragment,{children:[i.jsx(K.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",ge.length-m," chars)"]})})})]})}return i.jsx(Wt,{content:M.trim()})})(),J&&i.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:B.map((ce,ge)=>i.jsxs("div",{className:"relative border rounded overflow-hidden",children:[i.jsx("img",{src:ce.url,alt:ce.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(K.Image,{className:"h-3 w-3"}),i.jsx("span",{children:"image"})]})]},ge))}),be&&i.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:H.map((ce,ge)=>{const Te=ce,$=Te.name||"file";return i.jsxs("a",{href:Te.url,download:$,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:$,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:$})]},ge)})})]})},he=P.useMemo(()=>Mf(e),[e]);return P.useMemo(()=>kf(e,h),[e,h]),i.jsx("div",{className:A(ae(),b.container),children:i.jsxs("div",{className:A(W(),b.content),children:[(a||c||I)&&i.jsxs("div",{className:A("flex items-center justify-between mb-2 pb-2 border-b border-current/10",T&&"mb-1 pb-1",b.header),children:[i.jsxs("div",{className:"flex items-center gap-2",children:[le(),c&&he&&i.jsx("span",{className:A("font-medium",T?"text-xs":"text-sm"),children:he}),I&&Y.name&&i.jsxs(Xs,{variant:"outline",className:A("text-xs flex items-center gap-1 cursor-pointer",T&&"text-xs h-4"),onClick:()=>X(J=>!J),children:[i.jsx("span",{children:Y.name}),i.jsx("span",{className:"inline-flex items-center",children:z?i.jsx(K.ChevronUp,{className:"h-3 w-3"}):i.jsx(K.ChevronDown,{className:"h-3 w-3"})})]}),I&&!Y.name&&i.jsx(fe,{variant:"ghost",size:"sm",className:"h-6 px-1",onClick:()=>X(J=>!J),children:i.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",z?i.jsx(K.ChevronUp,{className:"h-3 w-3"}):i.jsx(K.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",T&&"text-xs"),children:ee(e.createdAt)}),s&&!o&&i.jsxs("div",{className:A("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",b.actions),children:[i.jsx(fe,{variant:"ghost",size:"sm",onClick:ie,className:A("h-6 w-6 p-0 hover:bg-background/50",T&&"h-5 w-5"),children:i.jsx(K.Copy,{className:A(D?"text-success":"",T?"h-3 w-3":"h-4 w-4")})}),_==="user"&&C&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:V,className:A("h-6 w-6 p-0 hover:bg-background/50",T&&"h-5 w-5"),children:i.jsx(K.Edit,{className:A(T?"h-3 w-3":"h-4 w-4")})}),_==="assistant"&&O&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:se,className:A("h-6 w-6 p-0 hover:bg-background/50",T&&"h-5 w-5"),children:i.jsx(K.RotateCcw,{className:A(T?"h-3 w-3":"h-4 w-4")})})]})]})]}),i.jsx("div",{className:"relative",children:pe()}),I&&z&&(Y.toolCallId||Y.name)&&i.jsxs("div",{className:A("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",T&&"text-xs"),children:[Y.name&&i.jsxs("div",{children:["Function: ",Y.name]}),Y.toolCallId&&i.jsxs("div",{children:["Call ID: ",Y.toolCallId]})]}),s&&_==="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(K.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]}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx(fe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",disabled:!y.canGoBack,onClick:()=>x==null?void 0:x(),title:"Go back to previous branch",children:i.jsx(K.ChevronLeft,{className:"h-3 w-3"})}),i.jsx(fe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",disabled:!y.canGoForward,onClick:()=>E==null?void 0:E(),title:"Go forward to next branch",children:i.jsx(K.ChevronRight,{className:"h-3 w-3"})})]})]}),!(a||c||I)&&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",b.actions),children:[i.jsx(fe,{variant:"ghost",size:"sm",onClick:ie,className:A("h-6 w-6 p-0 hover:bg-background/50",T&&"h-5 w-5"),children:i.jsx(K.Copy,{className:A(D?"text-success":"",T?"h-3 w-3":"h-4 w-4")})}),_==="user"&&C&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:V,className:A("h-6 w-6 p-0 hover:bg-background/50",T&&"h-5 w-5"),children:i.jsx(K.Edit,{className:A(T?"h-3 w-3":"h-4 w-4")})}),_==="assistant"&&O&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:se,className:A("h-6 w-6 p-0 hover:bg-background/50",T&&"h-5 w-5"),children:i.jsx(K.RotateCcw,{className:A(T?"h-3 w-3":"h-4 w-4")})})]})]})})}function Nf(e){const t=e.filter(n=>n.type==="text").map(n=>n.text).join("");return t||JSON.stringify(e)}function Tf(e){return e.includes(`
|
|
10
|
-
`)||e.includes("```")||/[-*] /.test(e)||/#+\s/.test(e)}function
|
|
8
|
+
`))>=0;){const k=q.slice(0,I);q=q.slice(I+2);const Y=ef(k);if(!Y)continue;let B;try{B=JSON.parse(Y)}catch{N&&console.debug("[use-chat] skip malformed SSE data:",Y==null?void 0:Y.slice(0,200));continue}const H=Qu(B)?B.data:B;if(N&&console.debug("[use-chat] event:",H==null?void 0:H.type,H),E==null||E(H),H.type==="token")e.autoAppendAssistant!==!1&&p(de=>de+H.content);else if(H.type==="message_delta"){const de=H.delta.filter(ce=>ce.type==="text").map(ce=>ce.text).join("");de&&e.autoAppendAssistant!==!1&&p(ce=>ce+de)}else H.type==="checkpoint"?v(H.checkpointId):H.type==="error"&&f(H.message)}}}catch(V){if((V==null?void 0:V.name)==="AbortError")return;const z=(V==null?void 0:V.message)||String(V);N&&console.debug("[use-chat] error:",z),f(z),(G=C==null?void 0:C.onError)==null||G.call(C,z)}finally{c(!1),g.current=null}})(),{close:()=>O.abort()}},[t,r,e.autoAppendAssistant]);return P.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 Qu(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function ef(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 tf={messages:[],assemblingId:null,lastCheckpointId:null,toolIndex:{}};function nf(e,t){var n,r;switch(t.type){case"reset":return{messages:Rs(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,toolIndex:{}};case"seed":return{...e,messages:Rs(t.payload.messages)};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=af(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??Dr(e.messages);return s?{...e,messages:rf(e.messages,s,o.content)}:e}if(o.type==="message_delta"){const s=e.assemblingId??Dr(e.messages);return s?{...e,messages:Ks(e.messages,s,o.delta)}:e}if(o.type==="message_end"){const s=e.assemblingId??Dr(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?Ks(e.messages,s,[a]):[...e.messages,d];return{...e,messages:f}}if(o.type==="checkpoint"){const s=sf(e.messages,o.checkpointId);return{...e,lastCheckpointId:o.checkpointId,messages:s}}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 js(e=[]){const[t,n]=P.useReducer(nf,{...tf,messages:e}),r=P.useCallback(s=>{n({type:"event",payload:{ev:s}})},[]),o=P.useMemo(()=>({reset:s=>n({type:"reset",payload:{messages:s}}),seed:s=>n({type:"seed",payload:{messages:s}}),pushUser:s=>n({type:"user_message",payload:{message:s}}),onEvent:r}),[r]);return{state:t,dispatch:n,...o}}function Rs(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 Dr(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function rf(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 Ks(e,t,n){return e.map(r=>r.id===t?{...r,content:of(r.content,n)}:r)}function of(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 sf(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 af(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const Gs=P.createContext(null);function Wt({children:e,apiConfig:t,onError:n,onThreadChange:r,initialThreadId:o=null}){const s=Ye;P.useEffect(()=>{t&&s.updateConfig({baseUrl:t.baseUrl,authToken:t.apiKey})},[s,t]);const{isStreaming:a,error:c,stream:d,stop:f,setToken:u}=Vs({baseUrl:s.baseUrl,token:null,headers:t==null?void 0:t.headers,streamPath:"/chat/stream"}),[p,m]=P.useState(()=>typeof s.getAuthToken=="function"?s.getAuthToken():null);P.useEffect(()=>{u(typeof s.getAuthToken=="function"?s.getAuthToken():null);const I=s.onTokenChange(k=>{m(k),u(k)});return()=>{I()}},[s,u]);const v=P.useCallback(I=>{s.setAuthToken(I)},[s]),{state:g,seed:h,pushUser:b,onEvent:w,reset:y}=js(),[x,E]=P.useState([]),[C,O]=P.useState(null),N=P.useCallback(async()=>{const I=await s.listThreads();E(I)},[s]);P.useEffect(()=>{N().catch(()=>{})},[N]),P.useEffect(()=>{r==null||r(C)},[C,r]);const F=P.useRef(null);P.useEffect(()=>{o&&F.current!==o&&(F.current=o,L(o).catch(()=>{}))},[o]);const M=P.useRef(null),L=P.useCallback(async(I,k,Y)=>{var B;if(M.current!==I){M.current=I;try{const H=k??((B=(await s.listCheckpoints(I)).checkpoints.slice().sort((ce,j)=>new Date(j.createdAt).getTime()-new Date(ce.createdAt).getTime())[0])==null?void 0:B.checkpointId),de=await s.getMessages({threadId:I,checkpointId:H,checkpointNs:Y});O(I),h(de.messages)}finally{M.current=null}}},[s,h]),R=P.useCallback(async I=>s.listCheckpoints(I),[s]),G=P.useCallback(async I=>{if(!C)throw new Error("No active thread");const k=await s.getMessages({threadId:C,checkpointId:I});h(k.messages)},[s,C,h]),V=P.useCallback(async()=>{if(!C)throw new Error("No active thread");await L(C)},[C,L]),z=P.useRef(!1);P.useEffect(()=>{const I=z.current;if(z.current=a,I&&!a&&C){const k=g.lastCheckpointId??void 0;s.getMessages({threadId:C,checkpointId:k}).then(Y=>h(Y.messages)).catch(()=>{})}},[a,C,g.lastCheckpointId,s,h]);const X=P.useCallback(async I=>{const k=await s.createThread(I);return await N(),await L(k.threadId),k.threadId},[s,N,L]),$=P.useCallback(async I=>{await s.deleteThread(I),await N(),C===I&&(O(null),y([]))},[s,N,C,y]),q=P.useCallback(async(I,k)=>{await s.updateThread(I,k),await N()},[s,N]),T=P.useCallback(async(I,k)=>{var ie;if(!C)throw new Error("No active thread");async function Y(W){return await new Promise((ee,pe)=>{const he=new FileReader;he.onload=()=>ee(String(he.result)),he.onerror=J=>pe(J),he.readAsDataURL(W)})}async function B(W){return await new Promise((ee,pe)=>{const he=new FileReader;he.onload=()=>{try{const J=he.result;let ve="";const re=new Uint8Array(J),ge=re.byteLength;for(let ye=0;ye<ge;ye++)ve+=String.fromCharCode(re[ye]);ee(btoa(ve))}catch(J){pe(J)}},he.onerror=J=>pe(J),he.readAsArrayBuffer(W)})}const H=[];I&&H.push({type:"text",text:I});const de=(k==null?void 0:k.attachments)||[];let ce=[];if(de.length>0)for(const W of de)if(W.type&&W.type.startsWith("image/")){let ee=null;try{const pe=await s.uploadImage(W,(t==null?void 0:t.uploadPath)||"/upload").catch(()=>null);ee=(pe==null?void 0:pe.url)||null}catch{}if(!ee)try{ee=await Y(W)}catch{ee=null}if(ee){const pe={type:"image_url",url:ee,mimeType:W.type,alt:W.name};H.push(pe)}try{ce.push({filename:W.name,data:await B(W),mime_type:W.type||"application/octet-stream"})}catch{}}else{const ee=await Y(W).catch(()=>null),pe={type:"file",url:String(ee),mimeType:W.type||void 0,name:W.name,size:W.size};H.push(pe);try{ce.push({filename:W.name,data:await B(W),mime_type:W.type||"application/octet-stream"})}catch{}}const j={id:((ie=crypto.randomUUID)==null?void 0:ie.call(crypto))||`user-${Date.now()}`,role:"user",content:H,createdAt:new Date().toISOString(),checkpointId:(k==null?void 0:k.checkpointId)??g.lastCheckpointId??void 0};b(j);const ae={...j,content:j.content.filter(W=>W.type==="text"||W.type==="image_url")},le={threadId:C,payload:{messages:[ae],attachments:j.content.filter(W=>W.type==="file").map(W=>({type:"file",url:W.url,mimeType:W.mimeType,name:W.name,size:W.size})),files_info:ce,...(k==null?void 0:k.payloadExtras)??{}},checkpointId:(k==null?void 0:k.checkpointId)??g.lastCheckpointId??void 0,checkpointNs:k==null?void 0:k.checkpointNs,nodeFilter:k==null?void 0:k.nodeFilter,config:k==null?void 0:k.config};d(le,W=>w(W),{onError:W=>console.warn("stream error",W)})},[C,b,d,w,g.lastCheckpointId,s,t==null?void 0:t.uploadPath]),_={baseUrl:s.baseUrl,token:p,setToken:v,api:s,threads:x,currentThreadId:C,setCurrentThreadId:O,messages:g.messages,isStreaming:a,error:c,lastCheckpointId:g.lastCheckpointId,streamingAssistantId:g.assemblingId,refreshThreads:N,createThread:X,deleteThread:$,renameThread:q,loadThread:L,listCheckpoints:R,navigateToCheckpoint:G,returnToLatest:V,send:T,stop:f};return i.jsx(Gs.Provider,{value:_,children:e})}function Lr(){const e=P.useContext(Gs);if(!e)throw new Error("useChat must be used within ChatProvider");return e}function A(...e){return Ad.twMerge(Td.clsx(e))}const cf=Lt.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"}}),fe=l.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const a=r?Pe.Slot:"button";return i.jsx(a,{className:A(cf({variant:t,size:n,className:e})),ref:s,...o})});fe.displayName="Button";const qs=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}));qs.displayName="Textarea";const lf=Lt.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 Xs({className:e,variant:t,...n}){return i.jsx("div",{className:A(lf({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 df(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 Le(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 be=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},ff=l[" useInsertionEffect ".trim().toString()]||be;function Qe({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,a]=pf({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=hf(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 pf({defaultProp:e,onChange:t}){const[n,r]=l.useState(e),o=l.useRef(n),s=l.useRef(t);return ff(()=>{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 hf(e){return typeof e=="function"}function Ys(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Fr(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Ys(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():Ys(e[o],null)}}}}function oe(...e){return l.useCallback(Fr(...e),e)}var gf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Z=gf.reduce((e,t)=>{const n=Pe.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 Js(e,t){e&&cn.flushSync(()=>e.dispatchEvent(t))}function mf(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var Te=e=>{const{present:t,children:n}=e,r=bf(t),o=typeof n=="function"?n({present:r.isPresent}):l.Children.only(n),s=oe(r.ref,vf(o));return typeof n=="function"||r.isPresent?l.cloneElement(o,{ref:s}):null};Te.displayName="Presence";function bf(e){const[t,n]=l.useState(),r=l.useRef(null),o=l.useRef(e),s=l.useRef("none"),a=e?"mounted":"unmounted",[c,d]=mf(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const f=xn(r.current);s.current=c==="mounted"?f:"none"},[c]),be(()=>{const f=r.current,u=o.current;if(u!==e){const m=s.current,v=xn(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]),be(()=>{if(t){let f;const u=t.ownerDocument.defaultView??window,p=v=>{const h=xn(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=xn(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 xn(e){return(e==null?void 0:e.animationName)||"none"}function vf(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 wf=l[" useId ".trim().toString()]||(()=>{}),yf=0;function Fe(e){const[t,n]=l.useState(wf());return be(()=>{n(r=>r??String(yf++))},[e]),t?`radix-${t}`:""}var Sn="Collapsible",[xf,_w]=Le(Sn),[Sf,$r]=xf(Sn),Zs=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:a,...c}=e,[d,f]=Qe({prop:r,defaultProp:o??!1,onChange:a,caller:Sn});return i.jsx(Sf,{scope:n,disabled:s,contentId:Fe(),open:d,onOpenToggle:l.useCallback(()=>f(u=>!u),[f]),children:i.jsx(Z.div,{"data-state":Ur(d),"data-disabled":s?"":void 0,...c,ref:t})})});Zs.displayName=Sn;var Qs="CollapsibleTrigger",ea=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=$r(Qs,n);return i.jsx(Z.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Ur(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:U(e.onClick,o.onOpenToggle)})});ea.displayName=Qs;var Br="CollapsibleContent",Cf=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=$r(Br,e.__scopeCollapsible);return i.jsx(Te,{present:n||o.open,children:({present:s})=>i.jsx(Ef,{...r,ref:t,present:s})})});Cf.displayName=Br;var Ef=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,a=$r(Br,n),[c,d]=l.useState(r),f=l.useRef(null),u=oe(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)},[]),be(()=>{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(Z.div,{"data-state":Ur(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 Ur(e){return e?"open":"closed"}var Nf=Zs;const ta=Nf,na=ea;function Vt({content:e,className:t=""}){return i.jsx("div",{className:`prose prose-sm max-w-none break-words dark:prose-invert 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 leading-relaxed ${t}`,children:i.jsx(Pd,{remarkPlugins:[_d],children:e})})}function ra({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:E,onEdit:C,onRegenerate:O,onEditFromCheckpoint:N,onCancelEdit:F,onCopy:M}){const[L,R]=P.useState(!1),[G,V]=P.useState(!1),[z,X]=P.useState(!1),[$,q]=P.useState(!1),T=d==="phone"||d==="half-screen",_=e.role,I=_==="tool",k=P.useMemo(()=>Tf(e.content),[e.content]),Y=P.useMemo(()=>kf(e.content),[e.content]),B=P.useMemo(()=>e.content.filter(J=>J.type==="image_url"),[e.content]),H=P.useMemo(()=>e.content.filter(J=>J.type==="file"),[e.content]),de=Lf(k,n?r:0),ce=async()=>{try{const J=I?yt(e.content):k;await navigator.clipboard.writeText(J),R(!0),setTimeout(()=>R(!1),2e3),M==null||M(J)}catch(J){console.error("Failed to copy:",J)}},j=()=>{if(!C)return;const J=I?yt(e.content):k;C(e.id,J)},ae=()=>O==null?void 0:O(t),le=()=>{const ve=A(T?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0");switch(_){case"user":return i.jsx(K.User,{className:ve});case"assistant":return i.jsx(K.Bot,{className:ve});case"tool":return i.jsx(K.Wrench,{className:ve});default:return i.jsx(K.Bot,{className:ve})}},ie=()=>{const J="group relative mb-4 max-w-full";switch(_){case"user":return A(J,"flex justify-end");case"assistant":case"tool":case"system":return A(J,"flex justify-start");default:return J}},W=()=>{const J=A("rounded-lg px-4 py-3 relative transition-all duration-200 min-w-0 break-words",T&&"px-3 py-2 text-sm");switch(_){case"user":return A(J,"bg-primary text-primary-foreground max-w-[95%]",d==="phone"&&"max-w-[98%]");case"assistant":return A(J,"bg-muted text-muted-foreground max-w-[95%] border",d==="phone"&&"max-w-[98%]");case"tool":return A(J,"bg-secondary/50 text-secondary-foreground border border-dashed max-w-[95%]",d==="phone"&&"max-w-[98%]");case"system":return A(J,"bg-accent/40 text-muted-foreground max-w-[85%] border");default:return J}},ee=J=>{if(!J)return"";try{return new Date(J).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}},pe=()=>{if(e.model==="reflection"){const re=k.trim(),ge=zr(re);if(ge&&typeof ge=="object")return i.jsx(Ff,{data:ge})}if(I&&Y.name==="get_issues"){const re=e.content.find(D=>D.type==="tool_result"),ge=(re==null?void 0:re.output)??yt(e.content),ye=sa(ge);if(ye)return i.jsx($f,{issues:ye})}if(I&&!z){const re=yt(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",T&&"text-[10px]"),children:i.jsxs("span",{className:"truncate max-w-full",children:[re,re.length>=80?"…":""]})})}if(I&&f){const re=yt(e.content),ge=re.length>u;return i.jsx(ta,{open:G,onOpenChange:V,children:i.jsxs("div",{className:"font-mono text-sm",children:[i.jsx("pre",{className:A("whitespace-pre-wrap break-words",T&&"text-xs"),children:ge&&!G?re.substring(0,u)+"...":re}),ge&&i.jsx(na,{asChild:!0,children:i.jsx(fe,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:G?i.jsxs(i.Fragment,{children:[i.jsx(K.ChevronUp,{className:"h-3 w-3 mr-1"}),"Show less"]}):i.jsxs(i.Fragment,{children:[i.jsx(K.ChevronDown,{className:"h-3 w-3 mr-1"}),"Show more (",re.length-u," chars)"]})})})]})})}if(I&&z&&!f){const re=Of(e.content);if(re&&Af(re))return i.jsx(Vt,{content:re.trim()});const ge=yt(e.content);return i.jsx("div",{className:"font-mono text-sm",children:i.jsx("pre",{className:A("whitespace-pre-wrap break-words",T&&"text-xs"),children:ge})})}const J=B.length>0&&_!=="tool",ve=H.length>0&&_!=="tool";return i.jsxs("div",{children:[n?i.jsxs("div",{className:"relative",children:[(()=>{const re=zr(de);return re!==null?i.jsx(oa,{data:re}):i.jsx(Vt,{content:_f(Pf(de))})})(),i.jsx("span",{className:"inline-block w-[6px] h-[14px] align-baseline ml-0.5 bg-foreground/40 animate-pulse",style:{verticalAlign:"text-bottom"}})]}):(()=>{const re=zr(k.trim());if(re!==null)return i.jsx(oa,{data:re});if(_==="user"&&p){const ge=k.trim();if(ge.length>m)return i.jsxs(ta,{open:$,onOpenChange:q,children:[i.jsx("div",{className:A("text-sm",T&&"text-xs"),children:$?i.jsx(Vt,{content:ge}):i.jsxs("pre",{className:A("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0",T&&"text-xs"),children:[ge.substring(0,m),"..."]})}),i.jsx(na,{asChild:!0,children:i.jsx(fe,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:$?i.jsxs(i.Fragment,{children:[i.jsx(K.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):i.jsxs(i.Fragment,{children:[i.jsx(K.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",ge.length-m," chars)"]})})})]})}return i.jsx(Vt,{content:k.trim()})})(),J&&i.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:B.map((re,ge)=>i.jsxs("div",{className:"relative border rounded overflow-hidden",children:[i.jsx("img",{src:re.url,alt:re.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(K.Image,{className:"h-3 w-3"}),i.jsx("span",{children:"image"})]})]},ge))}),ve&&i.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:H.map((re,ge)=>{const ye=re,D=ye.name||"file";return i.jsxs("a",{href:ye.url,download:D,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:D,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:D})]},ge)})})]})},he=P.useMemo(()=>Mf(e),[e]);return P.useMemo(()=>Df(e,h),[e,h]),i.jsx("div",{className:A(ie(),v.container),children:i.jsxs("div",{className:A(W(),v.content),children:[(a||c||I)&&i.jsxs("div",{className:A("flex items-center justify-between mb-2 pb-2 border-b border-current/10",T&&"mb-1 pb-1",v.header),children:[i.jsxs("div",{className:"flex items-center gap-2",children:[le(),c&&he&&i.jsx("span",{className:A("font-medium",T?"text-xs":"text-sm"),children:he}),I&&Y.name&&i.jsxs(Xs,{variant:"outline",className:A("text-xs flex items-center gap-1 cursor-pointer",T&&"text-xs h-4"),onClick:()=>X(J=>!J),children:[i.jsx("span",{children:Y.name}),i.jsx("span",{className:"inline-flex items-center",children:z?i.jsx(K.ChevronUp,{className:"h-3 w-3"}):i.jsx(K.ChevronDown,{className:"h-3 w-3"})})]}),I&&!Y.name&&i.jsx(fe,{variant:"ghost",size:"sm",className:"h-6 px-1",onClick:()=>X(J=>!J),children:i.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",z?i.jsx(K.ChevronUp,{className:"h-3 w-3"}):i.jsx(K.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",T&&"text-xs"),children:ee(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(fe,{variant:"ghost",size:"sm",onClick:ce,className:A("h-6 w-6 p-0 hover:bg-background/50",T&&"h-5 w-5"),children:i.jsx(K.Copy,{className:A(L?"text-success":"",T?"h-3 w-3":"h-4 w-4")})}),_==="user"&&C&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:j,className:A("h-6 w-6 p-0 hover:bg-background/50",T&&"h-5 w-5"),children:i.jsx(K.Edit,{className:A(T?"h-3 w-3":"h-4 w-4")})}),_==="assistant"&&O&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:ae,className:A("h-6 w-6 p-0 hover:bg-background/50",T&&"h-5 w-5"),children:i.jsx(K.RotateCcw,{className:A(T?"h-3 w-3":"h-4 w-4")})})]})]})]}),i.jsx("div",{className:"relative",children:pe()}),I&&z&&(Y.toolCallId||Y.name)&&i.jsxs("div",{className:A("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",T&&"text-xs"),children:[Y.name&&i.jsxs("div",{children:["Function: ",Y.name]}),Y.toolCallId&&i.jsxs("div",{children:["Call ID: ",Y.toolCallId]})]}),s&&_==="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(K.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]}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx(fe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",disabled:!y.canGoBack,onClick:()=>x==null?void 0:x(),title:"Go back to previous branch",children:i.jsx(K.ChevronLeft,{className:"h-3 w-3"})}),i.jsx(fe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",disabled:!y.canGoForward,onClick:()=>E==null?void 0:E(),title:"Go forward to next branch",children:i.jsx(K.ChevronRight,{className:"h-3 w-3"})})]})]}),!(a||c||I)&&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(fe,{variant:"ghost",size:"sm",onClick:ce,className:A("h-6 w-6 p-0 hover:bg-background/50",T&&"h-5 w-5"),children:i.jsx(K.Copy,{className:A(L?"text-success":"",T?"h-3 w-3":"h-4 w-4")})}),_==="user"&&C&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:j,className:A("h-6 w-6 p-0 hover:bg-background/50",T&&"h-5 w-5"),children:i.jsx(K.Edit,{className:A(T?"h-3 w-3":"h-4 w-4")})}),_==="assistant"&&O&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:ae,className:A("h-6 w-6 p-0 hover:bg-background/50",T&&"h-5 w-5"),children:i.jsx(K.RotateCcw,{className:A(T?"h-3 w-3":"h-4 w-4")})})]})]})})}function Tf(e){const t=e.filter(n=>n.type==="text").map(n=>n.text).join("");return t||JSON.stringify(e)}function Af(e){return e.includes(`
|
|
10
|
+
`)||e.includes("```")||/[-*] /.test(e)||/#+\s/.test(e)}function Pf(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 _f(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 zr(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:"prose prose-sm max-w-none dark:prose-invert",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 overflow-x-auto whitespace-pre-wrap break-words",children:jt(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:"prose prose-sm max-w-none dark:prose-invert",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:"prose prose-sm max-w-none dark:prose-invert",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:If(a)})]},s))})})}return i.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 overflow-x-auto whitespace-pre-wrap break-words",children:jt(e)})}function If(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 yt(e){const t=e.filter(n=>n.type==="tool_result");if(t.length)try{return t.length===1?jt(t[0].output):jt(t.map(n=>({toolCallId:n.toolCallId,output:n.output})))}catch{}return jt(e)}function Of(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 jt(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function kf(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 Mf(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Df(e,t){return e.checkpointId||t||null}function Lf(e,t){const[n,r]=P.useState(e);return P.useEffect(()=>{if(!t){r(e);return}const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}function Ff({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",children:Array.isArray(n)?n.map((r,o)=>i.jsxs("div",{className:"ml-4",children:["- ",String(r)]},o)):String(n)})]},t))})}function sa(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 sa(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};for(const o of Object.keys(n)){const a=new RegExp(o+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(t);if(!a)continue;const c=a[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(c))!==null;){const u=f[1],p=/title\s*=\s*'(.*?)'/.exec(u)||/title\s*=\s*"(.*?)"/.exec(u),m=/description\s*=\s*'(.*?)'/.exec(u)||/description\s*=\s*"(.*?)"/.exec(u),v=p?p[1].trim():"",g=m?m[1].trim():"";n[o].push({title:v,description:g})}}return Object.values(n).some(o=>o.length>0)?n:null}function $f({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:"prose prose-sm max-w-none dark:prose-invert",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 xt=1e4;function Bf(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,"<").replace(/>/g,">").trim()}function $f(e,t=yt){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 Bf(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),$f(t),Ff(t)}function Hr(e){const t=e+"CollectionProvider",[n,r]=Le(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=h=>{const{scope:v,children:w}=h,y=P.useRef(null),x=P.useRef(new Map).current;return i.jsx(o,{scope:v,itemMap:x,collectionRef:y,children:w})};a.displayName=t;const c=e+"CollectionSlot",d=Pe.createSlot(c),f=P.forwardRef((h,v)=>{const{scope:w,children:y}=h,x=s(c,w),E=re(v,x.collectionRef);return i.jsx(d,{ref:E,children:y})});f.displayName=c;const u=e+"CollectionItemSlot",p="data-radix-collection-item",m=Pe.createSlot(u),b=P.forwardRef((h,v)=>{const{scope:w,children:y,...x}=h,E=P.useRef(null),C=re(v,E),O=s(u,w);return P.useEffect(()=>(O.itemMap.set(E,{ref:E,...x}),()=>void O.itemMap.delete(E))),i.jsx(m,{[p]:"",ref:C,children:y})});b.displayName=u;function g(h){const v=s(e+"CollectionConsumer",h);return P.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const x=Array.from(y.querySelectorAll(`[${p}]`));return Array.from(v.itemMap.values()).sort((O,N)=>x.indexOf(O.ref.current)-x.indexOf(N.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:a,Slot:f,ItemSlot:b},g,r]}var Uf=l.createContext(void 0);function Cn(e){const t=l.useContext(Uf);return e||t||"ltr"}function we(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 zf(e,t=globalThis==null?void 0:globalThis.document){const n=we(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 Hf="DismissableLayer",Wr="dismissableLayer.update",Wf="dismissableLayer.pointerDownOutside",Rf="dismissableLayer.focusOutside",sa,aa=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),jt=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:c,...d}=e,f=l.useContext(aa),[u,p]=l.useState(null),m=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=l.useState({}),g=re(t,N=>p(N)),h=Array.from(f.layers),[v]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),w=h.indexOf(v),y=u?h.indexOf(u):-1,x=f.layersWithOutsidePointerEventsDisabled.size>0,E=y>=w,C=Kf(N=>{const L=N.target,k=[...f.branches].some(D=>D.contains(L));!E||k||(o==null||o(N),a==null||a(N),N.defaultPrevented||c==null||c())},m),O=Gf(N=>{const L=N.target;[...f.branches].some(D=>D.contains(L))||(s==null||s(N),a==null||a(N),N.defaultPrevented||c==null||c())},m);return zf(N=>{y===f.layers.size-1&&(r==null||r(N),!N.defaultPrevented&&c&&(N.preventDefault(),c()))},m),l.useEffect(()=>{if(u)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(sa=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(u)),f.layers.add(u),ia(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=sa)}},[u,m,n,f]),l.useEffect(()=>()=>{u&&(f.layers.delete(u),f.layersWithOutsidePointerEventsDisabled.delete(u),ia())},[u,f]),l.useEffect(()=>{const N=()=>b({});return document.addEventListener(Wr,N),()=>document.removeEventListener(Wr,N)},[]),i.jsx(Z.div,{...d,ref:g,style:{pointerEvents:x?E?"auto":"none":void 0,...e.style},onFocusCapture:U(e.onFocusCapture,O.onFocusCapture),onBlurCapture:U(e.onBlurCapture,O.onBlurCapture),onPointerDownCapture:U(e.onPointerDownCapture,C.onPointerDownCapture)})});jt.displayName=Hf;var Vf="DismissableLayerBranch",jf=l.forwardRef((e,t)=>{const n=l.useContext(aa),r=l.useRef(null),o=re(t,r);return l.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),i.jsx(Z.div,{...e,ref:o})});jf.displayName=Vf;function Kf(e,t=globalThis==null?void 0:globalThis.document){const n=we(e),r=l.useRef(!1),o=l.useRef(()=>{});return l.useEffect(()=>{const s=c=>{if(c.target&&!r.current){let d=function(){ca(Wf,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 Gf(e,t=globalThis==null?void 0:globalThis.document){const n=we(e),r=l.useRef(!1);return l.useEffect(()=>{const o=s=>{s.target&&!r.current&&ca(Rf,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 ia(){const e=new CustomEvent(Wr);document.dispatchEvent(e)}function ca(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?Js(o,s):o.dispatchEvent(s)}var Rr=0;function Vr(){l.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??la()),document.body.insertAdjacentElement("beforeend",e[1]??la()),Rr++,()=>{Rr===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Rr--}},[])}function la(){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 jr="focusScope.autoFocusOnMount",Kr="focusScope.autoFocusOnUnmount",da={bubbles:!1,cancelable:!0},qf="FocusScope",En=l.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=e,[c,d]=l.useState(null),f=we(o),u=we(s),p=l.useRef(null),m=re(t,h=>d(h)),b=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(r){let h=function(x){if(b.paused||!c)return;const E=x.target;c.contains(E)?p.current=E:et(p.current,{select:!0})},v=function(x){if(b.paused||!c)return;const E=x.relatedTarget;E!==null&&(c.contains(E)||et(p.current,{select:!0}))},w=function(x){if(document.activeElement===document.body)for(const C of x)C.removedNodes.length>0&&et(c)};document.addEventListener("focusin",h),document.addEventListener("focusout",v);const y=new MutationObserver(w);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",v),y.disconnect()}}},[r,c,b.paused]),l.useEffect(()=>{if(c){pa.add(b);const h=document.activeElement;if(!c.contains(h)){const w=new CustomEvent(jr,da);c.addEventListener(jr,f),c.dispatchEvent(w),w.defaultPrevented||(Xf(ep(ua(c)),{select:!0}),document.activeElement===h&&et(c))}return()=>{c.removeEventListener(jr,f),setTimeout(()=>{const w=new CustomEvent(Kr,da);c.addEventListener(Kr,u),c.dispatchEvent(w),w.defaultPrevented||et(h??document.body,{select:!0}),c.removeEventListener(Kr,u),pa.remove(b)},0)}}},[c,f,u,b]);const g=l.useCallback(h=>{if(!n&&!r||b.paused)return;const v=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,w=document.activeElement;if(v&&w){const y=h.currentTarget,[x,E]=Yf(y);x&&E?!h.shiftKey&&w===E?(h.preventDefault(),n&&et(x,{select:!0})):h.shiftKey&&w===x&&(h.preventDefault(),n&&et(E,{select:!0})):w===y&&h.preventDefault()}},[n,r,b.paused]);return i.jsx(Z.div,{tabIndex:-1,...a,ref:m,onKeyDown:g})});En.displayName=qf;function Xf(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(et(r,{select:t}),document.activeElement!==n)return}function Yf(e){const t=ua(e),n=fa(t,e),r=fa(t.reverse(),e);return[n,r]}function ua(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 fa(e,t){for(const n of e)if(!Jf(n,{upTo:t}))return n}function Jf(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 Zf(e){return e instanceof HTMLInputElement&&"select"in e}function et(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Zf(e)&&t&&e.select()}}var pa=Qf();function Qf(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ha(e,t),e.unshift(t)},remove(t){var n;e=ha(e,t),(n=e[0])==null||n.resume()}}}function ha(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ep(e){return e.filter(t=>t.tagName!=="A")}const tp=["top","right","bottom","left"],tt=Math.min,_e=Math.max,Nn=Math.round,Tn=Math.floor,Ve=e=>({x:e,y:e}),np={left:"right",right:"left",bottom:"top",top:"bottom"},rp={start:"end",end:"start"};function Gr(e,t,n){return _e(e,tt(t,n))}function Je(e,t){return typeof e=="function"?e(t):e}function Ze(e){return e.split("-")[0]}function xt(e){return e.split("-")[1]}function qr(e){return e==="x"?"y":"x"}function Xr(e){return e==="y"?"height":"width"}const op=new Set(["top","bottom"]);function je(e){return op.has(Ze(e))?"y":"x"}function Yr(e){return qr(je(e))}function sp(e,t,n){n===void 0&&(n=!1);const r=xt(e),o=Yr(e),s=Xr(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=An(a)),[a,An(a)]}function ap(e){const t=An(e);return[Jr(e),t,Jr(t)]}function Jr(e){return e.replace(/start|end/g,t=>rp[t])}const ga=["left","right"],ma=["right","left"],ip=["top","bottom"],cp=["bottom","top"];function lp(e,t,n){switch(e){case"top":case"bottom":return n?t?ma:ga:t?ga:ma;case"left":case"right":return t?ip:cp;default:return[]}}function dp(e,t,n,r){const o=xt(e);let s=lp(Ze(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(Jr)))),s}function An(e){return e.replace(/left|right|bottom|top/g,t=>np[t])}function up(e){return{top:0,right:0,bottom:0,left:0,...e}}function va(e){return typeof e!="number"?up(e):{top:e,right:e,bottom:e,left:e}}function Pn(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 ba(e,t,n){let{reference:r,floating:o}=e;const s=je(t),a=Yr(t),c=Xr(a),d=Ze(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 b;switch(d){case"top":b={x:u,y:r.y-o.height};break;case"bottom":b={x:u,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:p};break;case"left":b={x:r.x-o.width,y:p};break;default:b={x:r.x,y:r.y}}switch(xt(t)){case"start":b[a]-=m*(n&&f?-1:1);break;case"end":b[a]+=m*(n&&f?-1:1);break}return b}const fp=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}=ba(f,r,d),m=r,b={},g=0;for(let h=0;h<c.length;h++){const{name:v,fn:w}=c[h],{x:y,y:x,data:E,reset:C}=await w({x:u,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:b,rects:f,platform:a,elements:{reference:e,floating:t}});u=y??u,p=x??p,b={...b,[v]:{...b[v],...E}},C&&g<=50&&(g++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(f=C.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:u,y:p}=ba(f,m,d)),h=-1)}return{x:u,y:p,placement:m,strategy:o,middlewareData:b}};async function Kt(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:b=0}=Je(t,e),g=va(b),v=c[m?p==="floating"?"reference":"floating":p],w=Pn(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.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)),E=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},C=Pn(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:y,offsetParent:x,strategy:d}):y);return{top:(w.top-C.top+g.top)/E.y,bottom:(C.bottom-w.bottom+g.bottom)/E.y,left:(w.left-C.left+g.left)/E.x,right:(C.right-w.right+g.right)/E.x}}const pp=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}=Je(e,t)||{};if(f==null)return{};const p=va(u),m={x:n,y:r},b=Yr(o),g=Xr(b),h=await a.getDimensions(f),v=b==="y",w=v?"top":"left",y=v?"bottom":"right",x=v?"clientHeight":"clientWidth",E=s.reference[g]+s.reference[b]-m[b]-s.floating[g],C=m[b]-s.reference[b],O=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f));let N=O?O[x]:0;(!N||!await(a.isElement==null?void 0:a.isElement(O)))&&(N=c.floating[x]||s.floating[g]);const L=E/2-C/2,k=N/2-h[g]/2-1,D=tt(p[w],k),j=tt(p[y],k),G=D,R=N-h[g]-j,z=N/2-h[g]/2+L,X=Gr(G,z,R),F=!d.arrow&&xt(o)!=null&&z!==X&&s.reference[g]/2-(z<G?D:j)-h[g]/2<0,q=F?z<G?z-G:z-R:0;return{[b]:m[b]+q,data:{[b]:X,centerOffset:z-X-q,...F&&{alignmentOffset:q}},reset:F}}}),hp=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:b="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...v}=Je(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=Ze(o),y=je(c),x=Ze(c)===c,E=await(d.isRTL==null?void 0:d.isRTL(f.floating)),C=m||(x||!h?[An(c)]:ap(c)),O=g!=="none";!m&&O&&C.push(...dp(c,h,g,E));const N=[c,...C],L=await Kt(t,v),k=[];let D=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&k.push(L[w]),p){const z=sp(o,a,E);k.push(L[z[0]],L[z[1]])}if(D=[...D,{placement:o,overflows:k}],!k.every(z=>z<=0)){var j,G;const z=(((j=s.flip)==null?void 0:j.index)||0)+1,X=N[z];if(X&&(!(p==="alignment"?y!==je(X):!1)||D.every(T=>je(T.placement)===y?T.overflows[0]>0:!0)))return{data:{index:z,overflows:D},reset:{placement:X}};let F=(G=D.filter(q=>q.overflows[0]<=0).sort((q,T)=>q.overflows[1]-T.overflows[1])[0])==null?void 0:G.placement;if(!F)switch(b){case"bestFit":{var R;const q=(R=D.filter(T=>{if(O){const _=je(T.placement);return _===y||_==="y"}return!0}).map(T=>[T.placement,T.overflows.filter(_=>_>0).reduce((_,I)=>_+I,0)]).sort((T,_)=>T[1]-_[1])[0])==null?void 0:R[0];q&&(F=q);break}case"initialPlacement":F=c;break}if(o!==F)return{reset:{placement:F}}}return{}}}};function wa(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 tp.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}=Je(e,t);switch(r){case"referenceHidden":{const s=await Kt(t,{...o,elementContext:"reference"}),a=wa(s,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:ya(a)}}}case"escaped":{const s=await Kt(t,{...o,altBoundary:!0}),a=wa(s,n.floating);return{data:{escapedOffsets:a,escaped:ya(a)}}}default:return{}}}}},xa=new Set(["left","top"]);async function mp(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Ze(n),c=xt(n),d=je(n)==="y",f=xa.has(a)?-1:1,u=s&&d?-1:1,p=Je(t,e);let{mainAxis:m,crossAxis:b,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"&&(b=c==="end"?g*-1:g),d?{x:b*u,y:m*f}:{x:m*f,y:b*u}}const vp=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 mp(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}}}}},bp=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:v=>{let{x:w,y}=v;return{x:w,y}}},...d}=Je(e,t),f={x:n,y:r},u=await Kt(t,d),p=je(Ze(o)),m=qr(p);let b=f[m],g=f[p];if(s){const v=m==="y"?"top":"left",w=m==="y"?"bottom":"right",y=b+u[v],x=b-u[w];b=Gr(y,b,x)}if(a){const v=p==="y"?"top":"left",w=p==="y"?"bottom":"right",y=g+u[v],x=g-u[w];g=Gr(y,g,x)}const h=c.fn({...t,[m]:b,[p]:g});return{...h,data:{x:h.x-n,y:h.y-r,enabled:{[m]:s,[p]:a}}}}}},wp=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}=Je(e,t),u={x:n,y:r},p=je(o),m=qr(p);let b=u[m],g=u[p];const h=Je(c,t),v=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(d){const x=m==="y"?"height":"width",E=s.reference[m]-s.floating[x]+v.mainAxis,C=s.reference[m]+s.reference[x]-v.mainAxis;b<E?b=E:b>C&&(b=C)}if(f){var w,y;const x=m==="y"?"width":"height",E=xa.has(Ze(o)),C=s.reference[p]-s.floating[x]+(E&&((w=a.offset)==null?void 0:w[p])||0)+(E?0:v.crossAxis),O=s.reference[p]+s.reference[x]+(E?0:((y=a.offset)==null?void 0:y[p])||0)-(E?v.crossAxis:0);g<C?g=C:g>O&&(g=O)}return{[m]:b,[p]:g}}}},yp=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}=Je(e,t),u=await Kt(t,f),p=Ze(o),m=xt(o),b=je(o)==="y",{width:g,height:h}=s.floating;let v,w;p==="top"||p==="bottom"?(v=p,w=m===(await(a.isRTL==null?void 0:a.isRTL(c.floating))?"start":"end")?"left":"right"):(w=p,v=m==="end"?"top":"bottom");const y=h-u.top-u.bottom,x=g-u.left-u.right,E=tt(h-u[v],y),C=tt(g-u[w],x),O=!t.middlewareData.shift;let N=E,L=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(L=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(N=y),O&&!m){const D=_e(u.left,0),j=_e(u.right,0),G=_e(u.top,0),R=_e(u.bottom,0);b?L=g-2*(D!==0||j!==0?D+j:_e(u.left,u.right)):N=h-2*(G!==0||R!==0?G+R:_e(u.top,u.bottom))}await d({...t,availableWidth:L,availableHeight:N});const k=await a.getDimensions(c.floating);return g!==k.width||h!==k.height?{reset:{rects:!0}}:{}}}};function _n(){return typeof window<"u"}function St(e){return Sa(e)?(e.nodeName||"").toLowerCase():"#document"}function Ie(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ke(e){var t;return(t=(Sa(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Sa(e){return _n()?e instanceof Node||e instanceof Ie(e).Node:!1}function $e(e){return _n()?e instanceof Element||e instanceof Ie(e).Element:!1}function Ge(e){return _n()?e instanceof HTMLElement||e instanceof Ie(e).HTMLElement:!1}function Ca(e){return!_n()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ie(e).ShadowRoot}const xp=new Set(["inline","contents"]);function Gt(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Be(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!xp.has(o)}const Sp=new Set(["table","td","th"]);function Cp(e){return Sp.has(St(e))}const Ep=[":popover-open",":modal"];function In(e){return Ep.some(t=>{try{return e.matches(t)}catch{return!1}})}const Np=["transform","translate","scale","rotate","perspective"],Tp=["transform","translate","scale","rotate","perspective","filter"],Ap=["paint","layout","strict","content"];function Zr(e){const t=Qr(),n=$e(e)?Be(e):e;return Np.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)||Tp.some(r=>(n.willChange||"").includes(r))||Ap.some(r=>(n.contain||"").includes(r))}function Pp(e){let t=nt(e);for(;Ge(t)&&!Ct(t);){if(Zr(t))return t;if(In(t))return null;t=nt(t)}return null}function Qr(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const _p=new Set(["html","body","#document"]);function Ct(e){return _p.has(St(e))}function Be(e){return Ie(e).getComputedStyle(e)}function On(e){return $e(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function nt(e){if(St(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ca(e)&&e.host||Ke(e);return Ca(t)?t.host:t}function Ea(e){const t=nt(e);return Ct(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ge(t)&&Gt(t)?t:Ea(t)}function qt(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ea(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),a=Ie(o);if(s){const c=eo(a);return t.concat(a,a.visualViewport||[],Gt(o)?o:[],c&&n?qt(c):[])}return t.concat(o,qt(o,[],n))}function eo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Na(e){const t=Be(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ge(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,c=Nn(n)!==s||Nn(r)!==a;return c&&(n=s,r=a),{width:n,height:r,$:c}}function to(e){return $e(e)?e:e.contextElement}function Et(e){const t=to(e);if(!Ge(t))return Ve(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Na(t);let a=(s?Nn(n.width):n.width)/r,c=(s?Nn(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!c||!Number.isFinite(c))&&(c=1),{x:a,y:c}}const Ip=Ve(0);function Ta(e){const t=Ie(e);return!Qr()||!t.visualViewport?Ip:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Op(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ie(e)?!1:t}function dt(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=to(e);let a=Ve(1);t&&(r?$e(r)&&(a=Et(r)):a=Et(e));const c=Op(s,n,r)?Ta(s):Ve(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=Ie(s),b=r&&$e(r)?Ie(r):r;let g=m,h=eo(g);for(;h&&r&&b!==g;){const v=Et(h),w=h.getBoundingClientRect(),y=Be(h),x=w.left+(h.clientLeft+parseFloat(y.paddingLeft))*v.x,E=w.top+(h.clientTop+parseFloat(y.paddingTop))*v.y;d*=v.x,f*=v.y,u*=v.x,p*=v.y,d+=x,f+=E,g=Ie(h),h=eo(g)}}return Pn({width:u,height:p,x:d,y:f})}function Mn(e,t){const n=On(e).scrollLeft;return t?t.left+n:dt(Ke(e)).left+n}function Aa(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Mn(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Mp(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=Ke(r),c=t?In(t.floating):!1;if(r===a||c&&s)return n;let d={scrollLeft:0,scrollTop:0},f=Ve(1);const u=Ve(0),p=Ge(r);if((p||!p&&!s)&&((St(r)!=="body"||Gt(a))&&(d=On(r)),Ge(r))){const b=dt(r);f=Et(r),u.x=b.x+r.clientLeft,u.y=b.y+r.clientTop}const m=a&&!p&&!s?Aa(a,d):Ve(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 kp(e){return Array.from(e.getClientRects())}function Dp(e){const t=Ke(e),n=On(e),r=e.ownerDocument.body,o=_e(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=_e(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Mn(e);const c=-n.scrollTop;return Be(r).direction==="rtl"&&(a+=_e(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:c}}const Pa=25;function Lp(e,t){const n=Ie(e),r=Ke(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=Qr();(!u||u&&t==="fixed")&&(c=o.offsetLeft,d=o.offsetTop)}const f=Mn(r);if(f<=0){const u=r.ownerDocument,p=u.body,m=getComputedStyle(p),b=u.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(r.clientWidth-p.clientWidth-b);g<=Pa&&(s-=g)}else f<=Pa&&(s+=f);return{width:s,height:a,x:c,y:d}}const Fp=new Set(["absolute","fixed"]);function $p(e,t){const n=dt(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Ge(e)?Et(e):Ve(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 _a(e,t,n){let r;if(t==="viewport")r=Lp(e,n);else if(t==="document")r=Dp(Ke(e));else if($e(t))r=$p(t,n);else{const o=Ta(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Pn(r)}function Ia(e,t){const n=nt(e);return n===t||!$e(n)||Ct(n)?!1:Be(n).position==="fixed"||Ia(n,t)}function Bp(e,t){const n=t.get(e);if(n)return n;let r=qt(e,[],!1).filter(c=>$e(c)&&St(c)!=="body"),o=null;const s=Be(e).position==="fixed";let a=s?nt(e):e;for(;$e(a)&&!Ct(a);){const c=Be(a),d=Zr(a);!d&&c.position==="fixed"&&(o=null),(s?!d&&!o:!d&&c.position==="static"&&!!o&&Fp.has(o.position)||Gt(a)&&!d&&Ia(e,a))?r=r.filter(u=>u!==a):o=c,a=nt(a)}return t.set(e,r),r}function Up(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?In(t)?[]:Bp(t,this._c):[].concat(n),r],c=a[0],d=a.reduce((f,u)=>{const p=_a(t,u,o);return f.top=_e(p.top,f.top),f.right=tt(p.right,f.right),f.bottom=tt(p.bottom,f.bottom),f.left=_e(p.left,f.left),f},_a(t,c,o));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function zp(e){const{width:t,height:n}=Na(e);return{width:t,height:n}}function Hp(e,t,n){const r=Ge(t),o=Ke(t),s=n==="fixed",a=dt(e,!0,s,t);let c={scrollLeft:0,scrollTop:0};const d=Ve(0);function f(){d.x=Mn(o)}if(r||!r&&!s)if((St(t)!=="body"||Gt(o))&&(c=On(t)),r){const b=dt(t,!0,s,t);d.x=b.x+t.clientLeft,d.y=b.y+t.clientTop}else o&&f();s&&!r&&o&&f();const u=o&&!r&&!s?Aa(o,c):Ve(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 no(e){return Be(e).position==="static"}function Oa(e,t){if(!Ge(e)||Be(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ke(e)===n&&(n=n.ownerDocument.body),n}function Ma(e,t){const n=Ie(e);if(In(e))return n;if(!Ge(e)){let o=nt(e);for(;o&&!Ct(o);){if($e(o)&&!no(o))return o;o=nt(o)}return n}let r=Oa(e,t);for(;r&&Cp(r)&&no(r);)r=Oa(r,t);return r&&Ct(r)&&no(r)&&!Zr(r)?n:r||Pp(e)||n}const Wp=async function(e){const t=this.getOffsetParent||Ma,n=this.getDimensions,r=await n(e.floating);return{reference:Hp(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Rp(e){return Be(e).direction==="rtl"}const Vp={convertOffsetParentRelativeRectToViewportRelativeRect:Mp,getDocumentElement:Ke,getClippingRect:Up,getOffsetParent:Ma,getElementRects:Wp,getClientRects:kp,getDimensions:zp,getScale:Et,isElement:$e,isRTL:Rp};function ka(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function jp(e,t){let n=null,r;const o=Ke(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:b}=f;if(c||t(),!m||!b)return;const g=Tn(p),h=Tn(o.clientWidth-(u+m)),v=Tn(o.clientHeight-(p+b)),w=Tn(u),x={rootMargin:-g+"px "+-h+"px "+-v+"px "+-w+"px",threshold:_e(0,tt(1,d))||1};let E=!0;function C(O){const N=O[0].intersectionRatio;if(N!==d){if(!E)return a();N?a(!1,N):r=setTimeout(()=>{a(!1,1e-7)},1e3)}N===1&&!ka(f,e.getBoundingClientRect())&&a(),E=!1}try{n=new IntersectionObserver(C,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return a(!0),s}function Kp(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=to(e),u=o||s?[...f?qt(f):[],...qt(t)]:[];u.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const p=f&&c?jp(f,n):null;let m=-1,b=null;a&&(b=new ResizeObserver(w=>{let[y]=w;y&&y.target===f&&b&&(b.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var x;(x=b)==null||x.observe(t)})),n()}),f&&!d&&b.observe(f),b.observe(t));let g,h=d?dt(e):null;d&&v();function v(){const w=dt(e);h&&!ka(h,w)&&n(),h=w,g=requestAnimationFrame(v)}return n(),()=>{var w;u.forEach(y=>{o&&y.removeEventListener("scroll",n),s&&y.removeEventListener("resize",n)}),p==null||p(),(w=b)==null||w.disconnect(),b=null,d&&cancelAnimationFrame(g)}}const Gp=vp,qp=bp,Xp=hp,Yp=yp,Jp=gp,Da=pp,Zp=wp,Qp=(e,t,n)=>{const r=new Map,o={platform:Vp,...n},s={...o.platform,_c:r};return fp(e,t,{...o,platform:s})};var eh=typeof document<"u",th=function(){},kn=eh?P.useLayoutEffect:th;function Dn(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(!Dn(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)&&!Dn(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function La(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Fa(e,t){const n=La(e);return Math.round(t*n)/n}function ro(e){const t=l.useRef(e);return kn(()=>{t.current=e}),t}function nh(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,b]=l.useState(r);Dn(m,r)||b(r);const[g,h]=l.useState(null),[v,w]=l.useState(null),y=l.useCallback(T=>{T!==O.current&&(O.current=T,h(T))},[]),x=l.useCallback(T=>{T!==N.current&&(N.current=T,w(T))},[]),E=s||g,C=a||v,O=l.useRef(null),N=l.useRef(null),L=l.useRef(u),k=d!=null,D=ro(d),j=ro(o),G=ro(f),R=l.useCallback(()=>{if(!O.current||!N.current)return;const T={placement:t,strategy:n,middleware:m};j.current&&(T.platform=j.current),Qp(O.current,N.current,T).then(_=>{const I={..._,isPositioned:G.current!==!1};z.current&&!Dn(L.current,I)&&(L.current=I,cn.flushSync(()=>{p(I)}))})},[m,t,n,j,G]);kn(()=>{f===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,p(T=>({...T,isPositioned:!1})))},[f]);const z=l.useRef(!1);kn(()=>(z.current=!0,()=>{z.current=!1}),[]),kn(()=>{if(E&&(O.current=E),C&&(N.current=C),E&&C){if(D.current)return D.current(E,C,R);R()}},[E,C,R,D,k]);const X=l.useMemo(()=>({reference:O,floating:N,setReference:y,setFloating:x}),[y,x]),F=l.useMemo(()=>({reference:E,floating:C}),[E,C]),q=l.useMemo(()=>{const T={position:n,left:0,top:0};if(!F.floating)return T;const _=Fa(F.floating,u.x),I=Fa(F.floating,u.y);return c?{...T,transform:"translate("+_+"px, "+I+"px)",...La(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:_,top:I}},[n,c,F.floating,u.x,u.y]);return l.useMemo(()=>({...u,update:R,refs:X,elements:F,floatingStyles:q}),[u,R,X,F,q])}const rh=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?Da({element:r.current,padding:o}).fn(n):{}:r?Da({element:r,padding:o}).fn(n):{}}}},oh=(e,t)=>({...Gp(e),options:[e,t]}),sh=(e,t)=>({...qp(e),options:[e,t]}),ah=(e,t)=>({...Zp(e),options:[e,t]}),ih=(e,t)=>({...Xp(e),options:[e,t]}),ch=(e,t)=>({...Yp(e),options:[e,t]}),lh=(e,t)=>({...Jp(e),options:[e,t]}),dh=(e,t)=>({...rh(e),options:[e,t]});var uh="Arrow",$a=l.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return i.jsx(Z.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"})})});$a.displayName=uh;var fh=$a;function Ba(e){const[t,n]=l.useState(void 0);return ve(()=>{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",[Ua,Nt]=Le(oo),[ph,za]=Ua(oo),Ha=e=>{const{__scopePopper:t,children:n}=e,[r,o]=l.useState(null);return i.jsx(ph,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ha.displayName=oo;var Wa="PopperAnchor",Ra=l.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=za(Wa,n),a=l.useRef(null),c=re(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(Z.div,{...o,ref:c})});Ra.displayName=Wa;var so="PopperContent",[hh,gh]=Ua(so),Va=l.forwardRef((e,t)=>{var V,se,le,ae,W,ee;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:b="optimized",onPlaced:g,...h}=e,v=za(so,n),[w,y]=l.useState(null),x=re(t,pe=>y(pe)),[E,C]=l.useState(null),O=Ba(E),N=(O==null?void 0:O.width)??0,L=(O==null?void 0:O.height)??0,k=r+(s!=="center"?"-"+s:""),D=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},j=Array.isArray(f)?f:[f],G=j.length>0,R={padding:D,boundary:j.filter(vh),altBoundary:G},{refs:z,floatingStyles:X,placement:F,isPositioned:q,middlewareData:T}=nh({strategy:"fixed",placement:k,whileElementsMounted:(...pe)=>Kp(...pe,{animationFrame:b==="always"}),elements:{reference:v.anchor},middleware:[oh({mainAxis:o+L,alignmentAxis:a}),d&&sh({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?ah():void 0,...R}),d&&ih({...R}),ch({...R,apply:({elements:pe,rects:he,availableWidth:J,availableHeight:be})=>{const{width:ce,height:ge}=he.reference,Te=pe.floating.style;Te.setProperty("--radix-popper-available-width",`${J}px`),Te.setProperty("--radix-popper-available-height",`${be}px`),Te.setProperty("--radix-popper-anchor-width",`${ce}px`),Te.setProperty("--radix-popper-anchor-height",`${ge}px`)}}),E&&dh({element:E,padding:c}),bh({arrowWidth:N,arrowHeight:L}),m&&lh({strategy:"referenceHidden",...R})]}),[_,I]=Ga(F),M=we(g);ve(()=>{q&&(M==null||M())},[q,M]);const Y=(V=T.arrow)==null?void 0:V.x,B=(se=T.arrow)==null?void 0:se.y,H=((le=T.arrow)==null?void 0:le.centerOffset)!==0,[de,ie]=l.useState();return ve(()=>{w&&ie(window.getComputedStyle(w).zIndex)},[w]),i.jsx("div",{ref:z.setFloating,"data-radix-popper-content-wrapper":"",style:{...X,transform:q?X.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:de,"--radix-popper-transform-origin":[(ae=T.transformOrigin)==null?void 0:ae.x,(W=T.transformOrigin)==null?void 0:W.y].join(" "),...((ee=T.hide)==null?void 0:ee.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:i.jsx(hh,{scope:n,placedSide:_,onArrowChange:C,arrowX:Y,arrowY:B,shouldHideArrow:H,children:i.jsx(Z.div,{"data-side":_,"data-align":I,...h,ref:x,style:{...h.style,animation:q?void 0:"none"}})})})});Va.displayName=so;var ja="PopperArrow",mh={top:"bottom",right:"left",bottom:"top",left:"right"},Ka=l.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=gh(ja,r),a=mh[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(fh,{...o,ref:n,style:{...o.style,display:"block"}})})});Ka.displayName=ja;function vh(e){return e!==null}var bh=e=>({name:"transformOrigin",options:e,fn(t){var v,w,y;const{placement:n,rects:r,middlewareData:o}=t,a=((v=o.arrow)==null?void 0:v.centerOffset)!==0,c=a?0:e.arrowWidth,d=a?0:e.arrowHeight,[f,u]=Ga(n),p={start:"0%",center:"50%",end:"100%"}[u],m=(((w=o.arrow)==null?void 0:w.x)??0)+c/2,b=(((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:`${b}px`):f==="left"&&(g=`${r.floating.width+d}px`,h=a?p:`${b}px`),{data:{x:g,y:h}}}});function Ga(e){const[t,n="center"]=e.split("-");return[t,n]}var ao=Ha,io=Ra,co=Va,lo=Ka,wh="Portal",Ln=l.forwardRef((e,t)=>{var c;const{container:n,...r}=e,[o,s]=l.useState(!1);ve(()=>s(!0),[]);const a=n||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return a?Jo.createPortal(i.jsx(Z.div,{...r,ref:t}),a):null});Ln.displayName=wh;var uo="rovingFocusGroup.onEntryFocus",yh={bubbles:!1,cancelable:!0},Xt="RovingFocusGroup",[fo,qa,xh]=Hr(Xt),[Sh,Xa]=Le(Xt,[xh]),[Ch,Eh]=Sh(Xt),Ya=l.forwardRef((e,t)=>i.jsx(fo.Provider,{scope:e.__scopeRovingFocusGroup,children:i.jsx(fo.Slot,{scope:e.__scopeRovingFocusGroup,children:i.jsx(Nh,{...e,ref:t})})}));Ya.displayName=Xt;var Nh=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),b=re(t,m),g=Cn(s),[h,v]=Qe({prop:a,defaultProp:c??null,onChange:d,caller:Xt}),[w,y]=l.useState(!1),x=we(f),E=qa(n),C=l.useRef(!1),[O,N]=l.useState(0);return l.useEffect(()=>{const L=m.current;if(L)return L.addEventListener(uo,x),()=>L.removeEventListener(uo,x)},[x]),i.jsx(Ch,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:h,onItemFocus:l.useCallback(L=>v(L),[v]),onItemShiftTab:l.useCallback(()=>y(!0),[]),onFocusableItemAdd:l.useCallback(()=>N(L=>L+1),[]),onFocusableItemRemove:l.useCallback(()=>N(L=>L-1),[]),children:i.jsx(Z.div,{tabIndex:w||O===0?-1:0,"data-orientation":r,...p,ref:b,style:{outline:"none",...e.style},onMouseDown:U(e.onMouseDown,()=>{C.current=!0}),onFocus:U(e.onFocus,L=>{const k=!C.current;if(L.target===L.currentTarget&&k&&!w){const D=new CustomEvent(uo,yh);if(L.currentTarget.dispatchEvent(D),!D.defaultPrevented){const j=E().filter(F=>F.focusable),G=j.find(F=>F.active),R=j.find(F=>F.id===h),X=[G,R,...j].filter(Boolean).map(F=>F.ref.current);Qa(X,u)}}C.current=!1}),onBlur:U(e.onBlur,()=>y(!1))})})}),Ja="RovingFocusGroupItem",Za=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:a,...c}=e,d=Fe(),f=s||d,u=Eh(Ja,n),p=u.currentTabStopId===f,m=qa(n),{onFocusableItemAdd:b,onFocusableItemRemove:g,currentTabStopId:h}=u;return l.useEffect(()=>{if(r)return b(),()=>g()},[r,b,g]),i.jsx(fo.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:i.jsx(Z.span,{tabIndex:p?0:-1,"data-orientation":u.orientation,...c,ref:t,onMouseDown:U(e.onMouseDown,v=>{r?u.onItemFocus(f):v.preventDefault()}),onFocus:U(e.onFocus,()=>u.onItemFocus(f)),onKeyDown:U(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){u.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const w=Ph(v,u.orientation,u.dir);if(w!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let x=m().filter(E=>E.focusable).map(E=>E.ref.current);if(w==="last")x.reverse();else if(w==="prev"||w==="next"){w==="prev"&&x.reverse();const E=x.indexOf(v.currentTarget);x=u.loop?_h(x,E+1):x.slice(E+1)}setTimeout(()=>Qa(x))}}),children:typeof a=="function"?a({isCurrentTabStop:p,hasTabStop:h!=null}):a})})});Za.displayName=Ja;var Th={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ah(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ph(e,t,n){const r=Ah(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Th[r]}function Qa(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function _h(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ih=Ya,Oh=Za,Mh=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Tt=new WeakMap,Fn=new WeakMap,$n={},po=0,ei=function(e){return e&&(e.host||ei(e.parentNode))},kh=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=ei(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})},Dh=function(e,t,n,r){var o=kh(t,Array.isArray(e)?e:[e]);$n[n]||($n[n]=new WeakMap);var s=$n[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 b=m.getAttribute(r),g=b!==null&&b!=="false",h=(Tt.get(m)||0)+1,v=(s.get(m)||0)+1;Tt.set(m,h),s.set(m,v),a.push(m),h===1&&g&&Fn.set(m,!0),v===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(),po++,function(){a.forEach(function(p){var m=Tt.get(p)-1,b=s.get(p)-1;Tt.set(p,m),s.set(p,b),m||(Fn.has(p)||p.removeAttribute(r),Fn.delete(p)),b||p.removeAttribute(n)}),po--,po||(Tt=new WeakMap,Tt=new WeakMap,Fn=new WeakMap,$n={})}},ho=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Mh(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Dh(r,o,n,"aria-hidden")):function(){return null}},qe=function(){return qe=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},qe.apply(this,arguments)};function ti(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 Lh(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 Bn="right-scroll-bar-position",Un="width-before-scroll-bar",Fh="with-scroll-bars-hidden",$h="--removed-body-scroll-bar-size";function go(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Bh(e,t){var n=P.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Uh=typeof window<"u"?l.useLayoutEffect:l.useEffect,ni=new WeakMap;function zh(e,t){var n=Bh(null,function(r){return e.forEach(function(o){return go(o,r)})});return Uh(function(){var r=ni.get(n);if(r){var o=new Set(r),s=new Set(e),a=n.current;o.forEach(function(c){s.has(c)||go(c,null)}),s.forEach(function(c){o.has(c)||go(c,a)})}ni.set(n,e)},[e]),n}function Hh(e){return e}function Wh(e,t){t===void 0&&(t=Hh);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 Rh(e){e===void 0&&(e={});var t=Wh(null);return t.options=qe({async:!0,ssr:!1},e),t}var ri=function(e){var t=e.sideCar,n=ti(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,qe({},n))};ri.isSideCarExport=!0;function Vh(e,t){return e.useMedium(t),ri}var oi=Rh(),mo=function(){},zn=l.forwardRef(function(e,t){var n=l.useRef(null),r=l.useState({onScrollCapture:mo,onWheelCapture:mo,onTouchMoveCapture:mo}),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,b=e.noRelative,g=e.noIsolation,h=e.inert,v=e.allowPinchZoom,w=e.as,y=w===void 0?"div":w,x=e.gapMode,E=ti(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,O=zh([n,t]),N=qe(qe({},E),o);return l.createElement(l.Fragment,null,u&&l.createElement(C,{sideCar:oi,removeScrollBar:f,shards:p,noRelative:b,noIsolation:g,inert:h,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:x}),a?l.cloneElement(l.Children.only(c),qe(qe({},N),{ref:O})):l.createElement(y,qe({},N,{className:d,ref:O}),c))});zn.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},zn.classNames={fullWidth:Un,zeroRight:Bn};var jh=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Kh(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=jh();return t&&e.setAttribute("nonce",t),e}function Gh(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function qh(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Xh=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Kh())&&(Gh(t,n),qh(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Yh=function(){var e=Xh();return function(t,n){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},si=function(){var e=Yh(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Jh={left:0,top:0,right:0,gap:0},vo=function(e){return parseInt(e||"",10)||0},Zh=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[vo(n),vo(r),vo(o)]},Qh=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Jh;var t=Zh(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])}},eg=si(),At="data-scroll-locked",tg=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(
|
|
18
|
+
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function Uf(e,t=xt){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 zf(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Uf(t),Bf(t)}function Hr(e){const t=e+"CollectionProvider",[n,r]=Le(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=h=>{const{scope:b,children:w}=h,y=P.useRef(null),x=P.useRef(new Map).current;return i.jsx(o,{scope:b,itemMap:x,collectionRef:y,children:w})};a.displayName=t;const c=e+"CollectionSlot",d=Pe.createSlot(c),f=P.forwardRef((h,b)=>{const{scope:w,children:y}=h,x=s(c,w),E=oe(b,x.collectionRef);return i.jsx(d,{ref:E,children:y})});f.displayName=c;const u=e+"CollectionItemSlot",p="data-radix-collection-item",m=Pe.createSlot(u),v=P.forwardRef((h,b)=>{const{scope:w,children:y,...x}=h,E=P.useRef(null),C=oe(b,E),O=s(u,w);return P.useEffect(()=>(O.itemMap.set(E,{ref:E,...x}),()=>void O.itemMap.delete(E))),i.jsx(m,{[p]:"",ref:C,children:y})});v.displayName=u;function g(h){const b=s(e+"CollectionConsumer",h);return P.useCallback(()=>{const y=b.collectionRef.current;if(!y)return[];const x=Array.from(y.querySelectorAll(`[${p}]`));return Array.from(b.itemMap.values()).sort((O,N)=>x.indexOf(O.ref.current)-x.indexOf(N.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:a,Slot:f,ItemSlot:v},g,r]}var Hf=l.createContext(void 0);function Cn(e){const t=l.useContext(Hf);return e||t||"ltr"}function we(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 Wf(e,t=globalThis==null?void 0:globalThis.document){const n=we(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 Vf="DismissableLayer",Wr="dismissableLayer.update",jf="dismissableLayer.pointerDownOutside",Rf="dismissableLayer.focusOutside",aa,ia=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Rt=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:c,...d}=e,f=l.useContext(ia),[u,p]=l.useState(null),m=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,v]=l.useState({}),g=oe(t,N=>p(N)),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,E=y>=w,C=qf(N=>{const F=N.target,M=[...f.branches].some(L=>L.contains(F));!E||M||(o==null||o(N),a==null||a(N),N.defaultPrevented||c==null||c())},m),O=Xf(N=>{const F=N.target;[...f.branches].some(L=>L.contains(F))||(s==null||s(N),a==null||a(N),N.defaultPrevented||c==null||c())},m);return Wf(N=>{y===f.layers.size-1&&(r==null||r(N),!N.defaultPrevented&&c&&(N.preventDefault(),c()))},m),l.useEffect(()=>{if(u)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(aa=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(u)),f.layers.add(u),ca(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=aa)}},[u,m,n,f]),l.useEffect(()=>()=>{u&&(f.layers.delete(u),f.layersWithOutsidePointerEventsDisabled.delete(u),ca())},[u,f]),l.useEffect(()=>{const N=()=>v({});return document.addEventListener(Wr,N),()=>document.removeEventListener(Wr,N)},[]),i.jsx(Z.div,{...d,ref:g,style:{pointerEvents:x?E?"auto":"none":void 0,...e.style},onFocusCapture:U(e.onFocusCapture,O.onFocusCapture),onBlurCapture:U(e.onBlurCapture,O.onBlurCapture),onPointerDownCapture:U(e.onPointerDownCapture,C.onPointerDownCapture)})});Rt.displayName=Vf;var Kf="DismissableLayerBranch",Gf=l.forwardRef((e,t)=>{const n=l.useContext(ia),r=l.useRef(null),o=oe(t,r);return l.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),i.jsx(Z.div,{...e,ref:o})});Gf.displayName=Kf;function qf(e,t=globalThis==null?void 0:globalThis.document){const n=we(e),r=l.useRef(!1),o=l.useRef(()=>{});return l.useEffect(()=>{const s=c=>{if(c.target&&!r.current){let d=function(){la(jf,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 Xf(e,t=globalThis==null?void 0:globalThis.document){const n=we(e),r=l.useRef(!1);return l.useEffect(()=>{const o=s=>{s.target&&!r.current&&la(Rf,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 ca(){const e=new CustomEvent(Wr);document.dispatchEvent(e)}function la(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?Js(o,s):o.dispatchEvent(s)}var Vr=0;function jr(){l.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??da()),document.body.insertAdjacentElement("beforeend",e[1]??da()),Vr++,()=>{Vr===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Vr--}},[])}function da(){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 Rr="focusScope.autoFocusOnMount",Kr="focusScope.autoFocusOnUnmount",ua={bubbles:!1,cancelable:!0},Yf="FocusScope",En=l.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=e,[c,d]=l.useState(null),f=we(o),u=we(s),p=l.useRef(null),m=oe(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 E=x.target;c.contains(E)?p.current=E:et(p.current,{select:!0})},b=function(x){if(v.paused||!c)return;const E=x.relatedTarget;E!==null&&(c.contains(E)||et(p.current,{select:!0}))},w=function(x){if(document.activeElement===document.body)for(const C of x)C.removedNodes.length>0&&et(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){ha.add(v);const h=document.activeElement;if(!c.contains(h)){const w=new CustomEvent(Rr,ua);c.addEventListener(Rr,f),c.dispatchEvent(w),w.defaultPrevented||(Jf(np(fa(c)),{select:!0}),document.activeElement===h&&et(c))}return()=>{c.removeEventListener(Rr,f),setTimeout(()=>{const w=new CustomEvent(Kr,ua);c.addEventListener(Kr,u),c.dispatchEvent(w),w.defaultPrevented||et(h??document.body,{select:!0}),c.removeEventListener(Kr,u),ha.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,E]=Zf(y);x&&E?!h.shiftKey&&w===E?(h.preventDefault(),n&&et(x,{select:!0})):h.shiftKey&&w===x&&(h.preventDefault(),n&&et(E,{select:!0})):w===y&&h.preventDefault()}},[n,r,v.paused]);return i.jsx(Z.div,{tabIndex:-1,...a,ref:m,onKeyDown:g})});En.displayName=Yf;function Jf(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(et(r,{select:t}),document.activeElement!==n)return}function Zf(e){const t=fa(e),n=pa(t,e),r=pa(t.reverse(),e);return[n,r]}function fa(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 pa(e,t){for(const n of e)if(!Qf(n,{upTo:t}))return n}function Qf(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 ep(e){return e instanceof HTMLInputElement&&"select"in e}function et(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&ep(e)&&t&&e.select()}}var ha=tp();function tp(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ga(e,t),e.unshift(t)},remove(t){var n;e=ga(e,t),(n=e[0])==null||n.resume()}}}function ga(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function np(e){return e.filter(t=>t.tagName!=="A")}const rp=["top","right","bottom","left"],tt=Math.min,_e=Math.max,Nn=Math.round,Tn=Math.floor,je=e=>({x:e,y:e}),op={left:"right",right:"left",bottom:"top",top:"bottom"},sp={start:"end",end:"start"};function Gr(e,t,n){return _e(e,tt(t,n))}function Je(e,t){return typeof e=="function"?e(t):e}function Ze(e){return e.split("-")[0]}function St(e){return e.split("-")[1]}function qr(e){return e==="x"?"y":"x"}function Xr(e){return e==="y"?"height":"width"}const ap=new Set(["top","bottom"]);function Re(e){return ap.has(Ze(e))?"y":"x"}function Yr(e){return qr(Re(e))}function ip(e,t,n){n===void 0&&(n=!1);const r=St(e),o=Yr(e),s=Xr(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=An(a)),[a,An(a)]}function cp(e){const t=An(e);return[Jr(e),t,Jr(t)]}function Jr(e){return e.replace(/start|end/g,t=>sp[t])}const ma=["left","right"],ba=["right","left"],lp=["top","bottom"],dp=["bottom","top"];function up(e,t,n){switch(e){case"top":case"bottom":return n?t?ba:ma:t?ma:ba;case"left":case"right":return t?lp:dp;default:return[]}}function fp(e,t,n,r){const o=St(e);let s=up(Ze(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(Jr)))),s}function An(e){return e.replace(/left|right|bottom|top/g,t=>op[t])}function pp(e){return{top:0,right:0,bottom:0,left:0,...e}}function va(e){return typeof e!="number"?pp(e):{top:e,right:e,bottom:e,left:e}}function Pn(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 wa(e,t,n){let{reference:r,floating:o}=e;const s=Re(t),a=Yr(t),c=Xr(a),d=Ze(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(St(t)){case"start":v[a]-=m*(n&&f?-1:1);break;case"end":v[a]+=m*(n&&f?-1:1);break}return v}const hp=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}=wa(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:E,reset:C}=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],...E}},C&&g<=50&&(g++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(f=C.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:u,y:p}=wa(f,m,d)),h=-1)}return{x:u,y:p,placement:m,strategy:o,middlewareData:v}};async function Kt(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}=Je(t,e),g=va(v),b=c[m?p==="floating"?"reference":"floating":p],w=Pn(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)),E=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},C=Pn(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:y,offsetParent:x,strategy:d}):y);return{top:(w.top-C.top+g.top)/E.y,bottom:(C.bottom-w.bottom+g.bottom)/E.y,left:(w.left-C.left+g.left)/E.x,right:(C.right-w.right+g.right)/E.x}}const gp=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}=Je(e,t)||{};if(f==null)return{};const p=va(u),m={x:n,y:r},v=Yr(o),g=Xr(v),h=await a.getDimensions(f),b=v==="y",w=b?"top":"left",y=b?"bottom":"right",x=b?"clientHeight":"clientWidth",E=s.reference[g]+s.reference[v]-m[v]-s.floating[g],C=m[v]-s.reference[v],O=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f));let N=O?O[x]:0;(!N||!await(a.isElement==null?void 0:a.isElement(O)))&&(N=c.floating[x]||s.floating[g]);const F=E/2-C/2,M=N/2-h[g]/2-1,L=tt(p[w],M),R=tt(p[y],M),G=L,V=N-h[g]-R,z=N/2-h[g]/2+F,X=Gr(G,z,V),$=!d.arrow&&St(o)!=null&&z!==X&&s.reference[g]/2-(z<G?L:R)-h[g]/2<0,q=$?z<G?z-G:z-V:0;return{[v]:m[v]+q,data:{[v]:X,centerOffset:z-X-q,...$&&{alignmentOffset:q}},reset:$}}}),mp=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}=Je(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=Ze(o),y=Re(c),x=Ze(c)===c,E=await(d.isRTL==null?void 0:d.isRTL(f.floating)),C=m||(x||!h?[An(c)]:cp(c)),O=g!=="none";!m&&O&&C.push(...fp(c,h,g,E));const N=[c,...C],F=await Kt(t,b),M=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&M.push(F[w]),p){const z=ip(o,a,E);M.push(F[z[0]],F[z[1]])}if(L=[...L,{placement:o,overflows:M}],!M.every(z=>z<=0)){var R,G;const z=(((R=s.flip)==null?void 0:R.index)||0)+1,X=N[z];if(X&&(!(p==="alignment"?y!==Re(X):!1)||L.every(T=>Re(T.placement)===y?T.overflows[0]>0:!0)))return{data:{index:z,overflows:L},reset:{placement:X}};let $=(G=L.filter(q=>q.overflows[0]<=0).sort((q,T)=>q.overflows[1]-T.overflows[1])[0])==null?void 0:G.placement;if(!$)switch(v){case"bestFit":{var V;const q=(V=L.filter(T=>{if(O){const _=Re(T.placement);return _===y||_==="y"}return!0}).map(T=>[T.placement,T.overflows.filter(_=>_>0).reduce((_,I)=>_+I,0)]).sort((T,_)=>T[1]-_[1])[0])==null?void 0:V[0];q&&($=q);break}case"initialPlacement":$=c;break}if(o!==$)return{reset:{placement:$}}}return{}}}};function ya(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 rp.some(t=>e[t]>=0)}const bp=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Je(e,t);switch(r){case"referenceHidden":{const s=await Kt(t,{...o,elementContext:"reference"}),a=ya(s,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:xa(a)}}}case"escaped":{const s=await Kt(t,{...o,altBoundary:!0}),a=ya(s,n.floating);return{data:{escapedOffsets:a,escaped:xa(a)}}}default:return{}}}}},Sa=new Set(["left","top"]);async function vp(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Ze(n),c=St(n),d=Re(n)==="y",f=Sa.has(a)?-1:1,u=s&&d?-1:1,p=Je(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 wp=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 vp(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}=Je(e,t),f={x:n,y:r},u=await Kt(t,d),p=Re(Ze(o)),m=qr(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=Gr(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=Gr(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}}}}}},xp=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}=Je(e,t),u={x:n,y:r},p=Re(o),m=qr(p);let v=u[m],g=u[p];const h=Je(c,t),b=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(d){const x=m==="y"?"height":"width",E=s.reference[m]-s.floating[x]+b.mainAxis,C=s.reference[m]+s.reference[x]-b.mainAxis;v<E?v=E:v>C&&(v=C)}if(f){var w,y;const x=m==="y"?"width":"height",E=Sa.has(Ze(o)),C=s.reference[p]-s.floating[x]+(E&&((w=a.offset)==null?void 0:w[p])||0)+(E?0:b.crossAxis),O=s.reference[p]+s.reference[x]+(E?0:((y=a.offset)==null?void 0:y[p])||0)-(E?b.crossAxis:0);g<C?g=C:g>O&&(g=O)}return{[m]:v,[p]:g}}}},Sp=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}=Je(e,t),u=await Kt(t,f),p=Ze(o),m=St(o),v=Re(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,E=tt(h-u[b],y),C=tt(g-u[w],x),O=!t.middlewareData.shift;let N=E,F=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(F=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(N=y),O&&!m){const L=_e(u.left,0),R=_e(u.right,0),G=_e(u.top,0),V=_e(u.bottom,0);v?F=g-2*(L!==0||R!==0?L+R:_e(u.left,u.right)):N=h-2*(G!==0||V!==0?G+V:_e(u.top,u.bottom))}await d({...t,availableWidth:F,availableHeight:N});const M=await a.getDimensions(c.floating);return g!==M.width||h!==M.height?{reset:{rects:!0}}:{}}}};function _n(){return typeof window<"u"}function Ct(e){return Ca(e)?(e.nodeName||"").toLowerCase():"#document"}function Ie(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ke(e){var t;return(t=(Ca(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ca(e){return _n()?e instanceof Node||e instanceof Ie(e).Node:!1}function $e(e){return _n()?e instanceof Element||e instanceof Ie(e).Element:!1}function Ge(e){return _n()?e instanceof HTMLElement||e instanceof Ie(e).HTMLElement:!1}function Ea(e){return!_n()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ie(e).ShadowRoot}const Cp=new Set(["inline","contents"]);function Gt(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Be(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Cp.has(o)}const Ep=new Set(["table","td","th"]);function Np(e){return Ep.has(Ct(e))}const Tp=[":popover-open",":modal"];function In(e){return Tp.some(t=>{try{return e.matches(t)}catch{return!1}})}const Ap=["transform","translate","scale","rotate","perspective"],Pp=["transform","translate","scale","rotate","perspective","filter"],_p=["paint","layout","strict","content"];function Zr(e){const t=Qr(),n=$e(e)?Be(e):e;return Ap.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)||Pp.some(r=>(n.willChange||"").includes(r))||_p.some(r=>(n.contain||"").includes(r))}function Ip(e){let t=nt(e);for(;Ge(t)&&!Et(t);){if(Zr(t))return t;if(In(t))return null;t=nt(t)}return null}function Qr(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Op=new Set(["html","body","#document"]);function Et(e){return Op.has(Ct(e))}function Be(e){return Ie(e).getComputedStyle(e)}function On(e){return $e(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function nt(e){if(Ct(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ea(e)&&e.host||Ke(e);return Ea(t)?t.host:t}function Na(e){const t=nt(e);return Et(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ge(t)&&Gt(t)?t:Na(t)}function qt(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Na(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),a=Ie(o);if(s){const c=eo(a);return t.concat(a,a.visualViewport||[],Gt(o)?o:[],c&&n?qt(c):[])}return t.concat(o,qt(o,[],n))}function eo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ta(e){const t=Be(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ge(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,c=Nn(n)!==s||Nn(r)!==a;return c&&(n=s,r=a),{width:n,height:r,$:c}}function to(e){return $e(e)?e:e.contextElement}function Nt(e){const t=to(e);if(!Ge(t))return je(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Ta(t);let a=(s?Nn(n.width):n.width)/r,c=(s?Nn(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!c||!Number.isFinite(c))&&(c=1),{x:a,y:c}}const kp=je(0);function Aa(e){const t=Ie(e);return!Qr()||!t.visualViewport?kp:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Mp(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ie(e)?!1:t}function dt(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=to(e);let a=je(1);t&&(r?$e(r)&&(a=Nt(r)):a=Nt(e));const c=Mp(s,n,r)?Aa(s):je(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=Ie(s),v=r&&$e(r)?Ie(r):r;let g=m,h=eo(g);for(;h&&r&&v!==g;){const b=Nt(h),w=h.getBoundingClientRect(),y=Be(h),x=w.left+(h.clientLeft+parseFloat(y.paddingLeft))*b.x,E=w.top+(h.clientTop+parseFloat(y.paddingTop))*b.y;d*=b.x,f*=b.y,u*=b.x,p*=b.y,d+=x,f+=E,g=Ie(h),h=eo(g)}}return Pn({width:u,height:p,x:d,y:f})}function kn(e,t){const n=On(e).scrollLeft;return t?t.left+n:dt(Ke(e)).left+n}function Pa(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-kn(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Dp(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=Ke(r),c=t?In(t.floating):!1;if(r===a||c&&s)return n;let d={scrollLeft:0,scrollTop:0},f=je(1);const u=je(0),p=Ge(r);if((p||!p&&!s)&&((Ct(r)!=="body"||Gt(a))&&(d=On(r)),Ge(r))){const v=dt(r);f=Nt(r),u.x=v.x+r.clientLeft,u.y=v.y+r.clientTop}const m=a&&!p&&!s?Pa(a,d):je(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 Lp(e){return Array.from(e.getClientRects())}function Fp(e){const t=Ke(e),n=On(e),r=e.ownerDocument.body,o=_e(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=_e(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+kn(e);const c=-n.scrollTop;return Be(r).direction==="rtl"&&(a+=_e(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:c}}const _a=25;function $p(e,t){const n=Ie(e),r=Ke(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=Qr();(!u||u&&t==="fixed")&&(c=o.offsetLeft,d=o.offsetTop)}const f=kn(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<=_a&&(s-=g)}else f<=_a&&(s+=f);return{width:s,height:a,x:c,y:d}}const Bp=new Set(["absolute","fixed"]);function Up(e,t){const n=dt(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Ge(e)?Nt(e):je(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 Ia(e,t,n){let r;if(t==="viewport")r=$p(e,n);else if(t==="document")r=Fp(Ke(e));else if($e(t))r=Up(t,n);else{const o=Aa(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Pn(r)}function Oa(e,t){const n=nt(e);return n===t||!$e(n)||Et(n)?!1:Be(n).position==="fixed"||Oa(n,t)}function zp(e,t){const n=t.get(e);if(n)return n;let r=qt(e,[],!1).filter(c=>$e(c)&&Ct(c)!=="body"),o=null;const s=Be(e).position==="fixed";let a=s?nt(e):e;for(;$e(a)&&!Et(a);){const c=Be(a),d=Zr(a);!d&&c.position==="fixed"&&(o=null),(s?!d&&!o:!d&&c.position==="static"&&!!o&&Bp.has(o.position)||Gt(a)&&!d&&Oa(e,a))?r=r.filter(u=>u!==a):o=c,a=nt(a)}return t.set(e,r),r}function Hp(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?In(t)?[]:zp(t,this._c):[].concat(n),r],c=a[0],d=a.reduce((f,u)=>{const p=Ia(t,u,o);return f.top=_e(p.top,f.top),f.right=tt(p.right,f.right),f.bottom=tt(p.bottom,f.bottom),f.left=_e(p.left,f.left),f},Ia(t,c,o));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function Wp(e){const{width:t,height:n}=Ta(e);return{width:t,height:n}}function Vp(e,t,n){const r=Ge(t),o=Ke(t),s=n==="fixed",a=dt(e,!0,s,t);let c={scrollLeft:0,scrollTop:0};const d=je(0);function f(){d.x=kn(o)}if(r||!r&&!s)if((Ct(t)!=="body"||Gt(o))&&(c=On(t)),r){const v=dt(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?Pa(o,c):je(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 no(e){return Be(e).position==="static"}function ka(e,t){if(!Ge(e)||Be(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ke(e)===n&&(n=n.ownerDocument.body),n}function Ma(e,t){const n=Ie(e);if(In(e))return n;if(!Ge(e)){let o=nt(e);for(;o&&!Et(o);){if($e(o)&&!no(o))return o;o=nt(o)}return n}let r=ka(e,t);for(;r&&Np(r)&&no(r);)r=ka(r,t);return r&&Et(r)&&no(r)&&!Zr(r)?n:r||Ip(e)||n}const jp=async function(e){const t=this.getOffsetParent||Ma,n=this.getDimensions,r=await n(e.floating);return{reference:Vp(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Rp(e){return Be(e).direction==="rtl"}const Kp={convertOffsetParentRelativeRectToViewportRelativeRect:Dp,getDocumentElement:Ke,getClippingRect:Hp,getOffsetParent:Ma,getElementRects:jp,getClientRects:Lp,getDimensions:Wp,getScale:Nt,isElement:$e,isRTL:Rp};function Da(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Gp(e,t){let n=null,r;const o=Ke(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=Tn(p),h=Tn(o.clientWidth-(u+m)),b=Tn(o.clientHeight-(p+v)),w=Tn(u),x={rootMargin:-g+"px "+-h+"px "+-b+"px "+-w+"px",threshold:_e(0,tt(1,d))||1};let E=!0;function C(O){const N=O[0].intersectionRatio;if(N!==d){if(!E)return a();N?a(!1,N):r=setTimeout(()=>{a(!1,1e-7)},1e3)}N===1&&!Da(f,e.getBoundingClientRect())&&a(),E=!1}try{n=new IntersectionObserver(C,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return a(!0),s}function qp(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=to(e),u=o||s?[...f?qt(f):[],...qt(t)]:[];u.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const p=f&&c?Gp(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?dt(e):null;d&&b();function b(){const w=dt(e);h&&!Da(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 Xp=wp,Yp=yp,Jp=mp,Zp=Sp,Qp=bp,La=gp,eh=xp,th=(e,t,n)=>{const r=new Map,o={platform:Kp,...n},s={...o.platform,_c:r};return hp(e,t,{...o,platform:s})};var nh=typeof document<"u",rh=function(){},Mn=nh?P.useLayoutEffect:rh;function Dn(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(!Dn(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)&&!Dn(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Fa(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function $a(e,t){const n=Fa(e);return Math.round(t*n)/n}function ro(e){const t=l.useRef(e);return Mn(()=>{t.current=e}),t}function oh(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);Dn(m,r)||v(r);const[g,h]=l.useState(null),[b,w]=l.useState(null),y=l.useCallback(T=>{T!==O.current&&(O.current=T,h(T))},[]),x=l.useCallback(T=>{T!==N.current&&(N.current=T,w(T))},[]),E=s||g,C=a||b,O=l.useRef(null),N=l.useRef(null),F=l.useRef(u),M=d!=null,L=ro(d),R=ro(o),G=ro(f),V=l.useCallback(()=>{if(!O.current||!N.current)return;const T={placement:t,strategy:n,middleware:m};R.current&&(T.platform=R.current),th(O.current,N.current,T).then(_=>{const I={..._,isPositioned:G.current!==!1};z.current&&!Dn(F.current,I)&&(F.current=I,cn.flushSync(()=>{p(I)}))})},[m,t,n,R,G]);Mn(()=>{f===!1&&F.current.isPositioned&&(F.current.isPositioned=!1,p(T=>({...T,isPositioned:!1})))},[f]);const z=l.useRef(!1);Mn(()=>(z.current=!0,()=>{z.current=!1}),[]),Mn(()=>{if(E&&(O.current=E),C&&(N.current=C),E&&C){if(L.current)return L.current(E,C,V);V()}},[E,C,V,L,M]);const X=l.useMemo(()=>({reference:O,floating:N,setReference:y,setFloating:x}),[y,x]),$=l.useMemo(()=>({reference:E,floating:C}),[E,C]),q=l.useMemo(()=>{const T={position:n,left:0,top:0};if(!$.floating)return T;const _=$a($.floating,u.x),I=$a($.floating,u.y);return c?{...T,transform:"translate("+_+"px, "+I+"px)",...Fa($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:_,top:I}},[n,c,$.floating,u.x,u.y]);return l.useMemo(()=>({...u,update:V,refs:X,elements:$,floatingStyles:q}),[u,V,X,$,q])}const sh=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?La({element:r.current,padding:o}).fn(n):{}:r?La({element:r,padding:o}).fn(n):{}}}},ah=(e,t)=>({...Xp(e),options:[e,t]}),ih=(e,t)=>({...Yp(e),options:[e,t]}),ch=(e,t)=>({...eh(e),options:[e,t]}),lh=(e,t)=>({...Jp(e),options:[e,t]}),dh=(e,t)=>({...Zp(e),options:[e,t]}),uh=(e,t)=>({...Qp(e),options:[e,t]}),fh=(e,t)=>({...sh(e),options:[e,t]});var ph="Arrow",Ba=l.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return i.jsx(Z.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"})})});Ba.displayName=ph;var hh=Ba;function Ua(e){const[t,n]=l.useState(void 0);return be(()=>{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",[za,Tt]=Le(oo),[gh,Ha]=za(oo),Wa=e=>{const{__scopePopper:t,children:n}=e,[r,o]=l.useState(null);return i.jsx(gh,{scope:t,anchor:r,onAnchorChange:o,children:n})};Wa.displayName=oo;var Va="PopperAnchor",ja=l.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Ha(Va,n),a=l.useRef(null),c=oe(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(Z.div,{...o,ref:c})});ja.displayName=Va;var so="PopperContent",[mh,bh]=za(so),Ra=l.forwardRef((e,t)=>{var j,ae,le,ie,W,ee;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=Ha(so,n),[w,y]=l.useState(null),x=oe(t,pe=>y(pe)),[E,C]=l.useState(null),O=Ua(E),N=(O==null?void 0:O.width)??0,F=(O==null?void 0:O.height)??0,M=r+(s!=="center"?"-"+s:""),L=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},R=Array.isArray(f)?f:[f],G=R.length>0,V={padding:L,boundary:R.filter(wh),altBoundary:G},{refs:z,floatingStyles:X,placement:$,isPositioned:q,middlewareData:T}=oh({strategy:"fixed",placement:M,whileElementsMounted:(...pe)=>qp(...pe,{animationFrame:v==="always"}),elements:{reference:b.anchor},middleware:[ah({mainAxis:o+F,alignmentAxis:a}),d&&ih({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?ch():void 0,...V}),d&&lh({...V}),dh({...V,apply:({elements:pe,rects:he,availableWidth:J,availableHeight:ve})=>{const{width:re,height:ge}=he.reference,ye=pe.floating.style;ye.setProperty("--radix-popper-available-width",`${J}px`),ye.setProperty("--radix-popper-available-height",`${ve}px`),ye.setProperty("--radix-popper-anchor-width",`${re}px`),ye.setProperty("--radix-popper-anchor-height",`${ge}px`)}}),E&&fh({element:E,padding:c}),yh({arrowWidth:N,arrowHeight:F}),m&&uh({strategy:"referenceHidden",...V})]}),[_,I]=qa($),k=we(g);be(()=>{q&&(k==null||k())},[q,k]);const Y=(j=T.arrow)==null?void 0:j.x,B=(ae=T.arrow)==null?void 0:ae.y,H=((le=T.arrow)==null?void 0:le.centerOffset)!==0,[de,ce]=l.useState();return be(()=>{w&&ce(window.getComputedStyle(w).zIndex)},[w]),i.jsx("div",{ref:z.setFloating,"data-radix-popper-content-wrapper":"",style:{...X,transform:q?X.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:de,"--radix-popper-transform-origin":[(ie=T.transformOrigin)==null?void 0:ie.x,(W=T.transformOrigin)==null?void 0:W.y].join(" "),...((ee=T.hide)==null?void 0:ee.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:i.jsx(mh,{scope:n,placedSide:_,onArrowChange:C,arrowX:Y,arrowY:B,shouldHideArrow:H,children:i.jsx(Z.div,{"data-side":_,"data-align":I,...h,ref:x,style:{...h.style,animation:q?void 0:"none"}})})})});Ra.displayName=so;var Ka="PopperArrow",vh={top:"bottom",right:"left",bottom:"top",left:"right"},Ga=l.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=bh(Ka,r),a=vh[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(hh,{...o,ref:n,style:{...o.style,display:"block"}})})});Ga.displayName=Ka;function wh(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]=qa(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 qa(e){const[t,n="center"]=e.split("-");return[t,n]}var ao=Wa,io=ja,co=Ra,lo=Ga,xh="Portal",Ln=l.forwardRef((e,t)=>{var c;const{container:n,...r}=e,[o,s]=l.useState(!1);be(()=>s(!0),[]);const a=n||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return a?Jo.createPortal(i.jsx(Z.div,{...r,ref:t}),a):null});Ln.displayName=xh;var uo="rovingFocusGroup.onEntryFocus",Sh={bubbles:!1,cancelable:!0},Xt="RovingFocusGroup",[fo,Xa,Ch]=Hr(Xt),[Eh,Ya]=Le(Xt,[Ch]),[Nh,Th]=Eh(Xt),Ja=l.forwardRef((e,t)=>i.jsx(fo.Provider,{scope:e.__scopeRovingFocusGroup,children:i.jsx(fo.Slot,{scope:e.__scopeRovingFocusGroup,children:i.jsx(Ah,{...e,ref:t})})}));Ja.displayName=Xt;var Ah=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=oe(t,m),g=Cn(s),[h,b]=Qe({prop:a,defaultProp:c??null,onChange:d,caller:Xt}),[w,y]=l.useState(!1),x=we(f),E=Xa(n),C=l.useRef(!1),[O,N]=l.useState(0);return l.useEffect(()=>{const F=m.current;if(F)return F.addEventListener(uo,x),()=>F.removeEventListener(uo,x)},[x]),i.jsx(Nh,{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(()=>N(F=>F+1),[]),onFocusableItemRemove:l.useCallback(()=>N(F=>F-1),[]),children:i.jsx(Z.div,{tabIndex:w||O===0?-1:0,"data-orientation":r,...p,ref:v,style:{outline:"none",...e.style},onMouseDown:U(e.onMouseDown,()=>{C.current=!0}),onFocus:U(e.onFocus,F=>{const M=!C.current;if(F.target===F.currentTarget&&M&&!w){const L=new CustomEvent(uo,Sh);if(F.currentTarget.dispatchEvent(L),!L.defaultPrevented){const R=E().filter($=>$.focusable),G=R.find($=>$.active),V=R.find($=>$.id===h),X=[G,V,...R].filter(Boolean).map($=>$.ref.current);ei(X,u)}}C.current=!1}),onBlur:U(e.onBlur,()=>y(!1))})})}),Za="RovingFocusGroupItem",Qa=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:a,...c}=e,d=Fe(),f=s||d,u=Th(Za,n),p=u.currentTabStopId===f,m=Xa(n),{onFocusableItemAdd:v,onFocusableItemRemove:g,currentTabStopId:h}=u;return l.useEffect(()=>{if(r)return v(),()=>g()},[r,v,g]),i.jsx(fo.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:i.jsx(Z.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=Ih(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(E=>E.focusable).map(E=>E.ref.current);if(w==="last")x.reverse();else if(w==="prev"||w==="next"){w==="prev"&&x.reverse();const E=x.indexOf(b.currentTarget);x=u.loop?Oh(x,E+1):x.slice(E+1)}setTimeout(()=>ei(x))}}),children:typeof a=="function"?a({isCurrentTabStop:p,hasTabStop:h!=null}):a})})});Qa.displayName=Za;var Ph={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _h(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ih(e,t,n){const r=_h(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ph[r]}function ei(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Oh(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var kh=Ja,Mh=Qa,Dh=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},At=new WeakMap,Fn=new WeakMap,$n={},po=0,ti=function(e){return e&&(e.host||ti(e.parentNode))},Lh=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=ti(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})},Fh=function(e,t,n,r){var o=Lh(t,Array.isArray(e)?e:[e]);$n[n]||($n[n]=new WeakMap);var s=$n[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=(At.get(m)||0)+1,b=(s.get(m)||0)+1;At.set(m,h),s.set(m,b),a.push(m),h===1&&g&&Fn.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(),po++,function(){a.forEach(function(p){var m=At.get(p)-1,v=s.get(p)-1;At.set(p,m),s.set(p,v),m||(Fn.has(p)||p.removeAttribute(r),Fn.delete(p)),v||p.removeAttribute(n)}),po--,po||(At=new WeakMap,At=new WeakMap,Fn=new WeakMap,$n={})}},ho=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Dh(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Fh(r,o,n,"aria-hidden")):function(){return null}},qe=function(){return qe=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},qe.apply(this,arguments)};function ni(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 $h(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 Bn="right-scroll-bar-position",Un="width-before-scroll-bar",Bh="with-scroll-bars-hidden",Uh="--removed-body-scroll-bar-size";function go(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function zh(e,t){var n=P.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Hh=typeof window<"u"?l.useLayoutEffect:l.useEffect,ri=new WeakMap;function Wh(e,t){var n=zh(null,function(r){return e.forEach(function(o){return go(o,r)})});return Hh(function(){var r=ri.get(n);if(r){var o=new Set(r),s=new Set(e),a=n.current;o.forEach(function(c){s.has(c)||go(c,null)}),s.forEach(function(c){o.has(c)||go(c,a)})}ri.set(n,e)},[e]),n}function Vh(e){return e}function jh(e,t){t===void 0&&(t=Vh);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 Rh(e){e===void 0&&(e={});var t=jh(null);return t.options=qe({async:!0,ssr:!1},e),t}var oi=function(e){var t=e.sideCar,n=ni(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,qe({},n))};oi.isSideCarExport=!0;function Kh(e,t){return e.useMedium(t),oi}var si=Rh(),mo=function(){},zn=l.forwardRef(function(e,t){var n=l.useRef(null),r=l.useState({onScrollCapture:mo,onWheelCapture:mo,onTouchMoveCapture:mo}),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,E=ni(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,O=Wh([n,t]),N=qe(qe({},E),o);return l.createElement(l.Fragment,null,u&&l.createElement(C,{sideCar:si,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),qe(qe({},N),{ref:O})):l.createElement(y,qe({},N,{className:d,ref:O}),c))});zn.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},zn.classNames={fullWidth:Un,zeroRight:Bn};var Gh=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function qh(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Gh();return t&&e.setAttribute("nonce",t),e}function Xh(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Yh(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Jh=function(){var e=0,t=null;return{add:function(n){e==0&&(t=qh())&&(Xh(t,n),Yh(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Zh=function(){var e=Jh();return function(t,n){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ai=function(){var e=Zh(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Qh={left:0,top:0,right:0,gap:0},bo=function(e){return parseInt(e||"",10)||0},eg=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[bo(n),bo(r),bo(o)]},tg=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Qh;var t=eg(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])}},ng=ai(),Pt="data-scroll-locked",rg=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(Bh,` {
|
|
20
20
|
overflow: hidden `).concat(r,`;
|
|
21
21
|
padding-right: `).concat(c,"px ").concat(r,`;
|
|
22
22
|
}
|
|
23
|
-
body[`).concat(
|
|
23
|
+
body[`).concat(Pt,`] {
|
|
24
24
|
overflow: hidden `).concat(r,`;
|
|
25
25
|
overscroll-behavior: contain;
|
|
26
26
|
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
margin-right: 0 `).concat(r,`;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
body[`).concat(
|
|
53
|
-
`).concat(
|
|
52
|
+
body[`).concat(Pt,`] {
|
|
53
|
+
`).concat(Uh,": ").concat(c,`px;
|
|
54
54
|
}
|
|
55
|
-
`)},
|
|
55
|
+
`)},ii=function(){var e=parseInt(document.body.getAttribute(Pt)||"0",10);return isFinite(e)?e:0},og=function(){l.useEffect(function(){return document.body.setAttribute(Pt,(ii()+1).toString()),function(){var e=ii()-1;e<=0?document.body.removeAttribute(Pt):document.body.setAttribute(Pt,e.toString())}},[])},sg=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;og();var s=l.useMemo(function(){return tg(o)},[o]);return l.createElement(ng,{styles:rg(s,!t,o,n?"":"!important")})},vo=!1;if(typeof window<"u")try{var Hn=Object.defineProperty({},"passive",{get:function(){return vo=!0,!0}});window.addEventListener("test",Hn,Hn),window.removeEventListener("test",Hn,Hn)}catch{vo=!1}var _t=vo?{passive:!1}:!1,ag=function(e){return e.tagName==="TEXTAREA"},ci=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!ag(e)&&n[t]==="visible")},ig=function(e){return ci(e,"overflowY")},cg=function(e){return ci(e,"overflowX")},li=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=di(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},lg=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},dg=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},di=function(e,t){return e==="v"?ig(t):cg(t)},ui=function(e,t){return e==="v"?lg(t):dg(t)},ug=function(e,t){return e==="h"&&t==="rtl"?-1:1},fg=function(e,t,n,r,o){var s=ug(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)&&di(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},Wn=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},fi=function(e){return[e.deltaX,e.deltaY]},pi=function(e){return e&&"current"in e?e.current:e},pg=function(e,t){return e[0]===t[0]&&e[1]===t[1]},hg=function(e){return`
|
|
56
56
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
57
57
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
58
|
-
`)},pg=0,_t=[];function hg(e){var t=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),o=l.useState(pg++)[0],s=l.useState(si)[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=Lh([e.lockRef.current],(e.shards||[]).map(fi),!0).filter(Boolean);return h.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(h,v){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!a.current.allowPinchZoom;var w=Wn(h),y=n.current,x="deltaX"in h?h.deltaX:y[0]-w[0],E="deltaY"in h?h.deltaY:y[1]-w[1],C,O=h.target,N=Math.abs(x)>Math.abs(E)?"h":"v";if("touches"in h&&N==="h"&&O.type==="range")return!1;var L=ci(N,O);if(!L)return!0;if(L?C=N:(C=N==="v"?"h":"v",L=ci(N,O)),!L)return!1;if(!r.current&&"changedTouches"in h&&(x||E)&&(r.current=C),!C)return!0;var k=r.current||C;return dg(k,v,h,k==="h"?x:E)},[]),d=l.useCallback(function(h){var v=h;if(!(!_t.length||_t[_t.length-1]!==s)){var w="deltaY"in v?ui(v):Wn(v),y=t.current.filter(function(C){return C.name===v.type&&(C.target===v.target||v.target===C.shadowParent)&&ug(C.delta,w)})[0];if(y&&y.should){v.cancelable&&v.preventDefault();return}if(!y){var x=(a.current.shards||[]).map(fi).filter(Boolean).filter(function(C){return C.contains(v.target)}),E=x.length>0?c(v,x[0]):!a.current.noIsolation;E&&v.cancelable&&v.preventDefault()}}},[]),f=l.useCallback(function(h,v,w,y){var x={name:h,delta:v,target:w,should:y,shadowParent:gg(w)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(E){return E!==x})},1)},[]),u=l.useCallback(function(h){n.current=Wn(h),r.current=void 0},[]),p=l.useCallback(function(h){f(h.type,ui(h),h.target,c(h,e.lockRef.current))},[]),m=l.useCallback(function(h){f(h.type,Wn(h),h.target,c(h,e.lockRef.current))},[]);l.useEffect(function(){return _t.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",d,Pt),document.addEventListener("touchmove",d,Pt),document.addEventListener("touchstart",u,Pt),function(){_t=_t.filter(function(h){return h!==s}),document.removeEventListener("wheel",d,Pt),document.removeEventListener("touchmove",d,Pt),document.removeEventListener("touchstart",u,Pt)}},[]);var b=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(s,{styles:fg(o)}):null,b?l.createElement(rg,{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 mg=Vh(oi,hg);var Rn=l.forwardRef(function(e,t){return l.createElement(zn,qe({},e,{ref:t,sideCar:mg}))});Rn.classNames=zn.classNames;var wo=["Enter"," "],vg=["ArrowDown","PageUp","Home"],pi=["ArrowUp","PageDown","End"],bg=[...vg,...pi],wg={ltr:[...wo,"ArrowRight"],rtl:[...wo,"ArrowLeft"]},yg={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Yt="Menu",[Jt,xg,Sg]=Hr(Yt),[ut,hi]=Le(Yt,[Sg,Nt,Xa]),Vn=Nt(),gi=Xa(),[Cg,ft]=ut(Yt),[Eg,Zt]=ut(Yt),mi=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:a=!0}=e,c=Vn(t),[d,f]=l.useState(null),u=l.useRef(!1),p=we(s),m=Cn(o);return l.useEffect(()=>{const b=()=>{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",b,{capture:!0}),()=>{document.removeEventListener("keydown",b,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),i.jsx(ao,{...c,children:i.jsx(Cg,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:f,children:i.jsx(Eg,{scope:t,onClose:l.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:u,dir:m,modal:a,children:r})})})};mi.displayName=Yt;var Ng="MenuAnchor",yo=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Vn(n);return i.jsx(io,{...o,...r,ref:t})});yo.displayName=Ng;var xo="MenuPortal",[Tg,vi]=ut(xo,{forceMount:void 0}),bi=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=ft(xo,t);return i.jsx(Tg,{scope:t,forceMount:n,children:i.jsx(Ne,{present:n||s.open,children:i.jsx(Ln,{asChild:!0,container:o,children:r})})})};bi.displayName=xo;var Oe="MenuContent",[Ag,So]=ut(Oe),wi=l.forwardRef((e,t)=>{const n=vi(Oe,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=ft(Oe,e.__scopeMenu),a=Zt(Oe,e.__scopeMenu);return i.jsx(Jt.Provider,{scope:e.__scopeMenu,children:i.jsx(Ne,{present:r||s.open,children:i.jsx(Jt.Slot,{scope:e.__scopeMenu,children:a.modal?i.jsx(Pg,{...o,ref:t}):i.jsx(_g,{...o,ref:t})})})})}),Pg=l.forwardRef((e,t)=>{const n=ft(Oe,e.__scopeMenu),r=l.useRef(null),o=re(t,r);return l.useEffect(()=>{const s=r.current;if(s)return ho(s)},[]),i.jsx(Co,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:U(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),_g=l.forwardRef((e,t)=>{const n=ft(Oe,e.__scopeMenu);return i.jsx(Co,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Ig=Pe.createSlot("MenuContent.ScrollLock"),Co=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:b,disableOutsideScroll:g,...h}=e,v=ft(Oe,n),w=Zt(Oe,n),y=Vn(n),x=gi(n),E=xg(n),[C,O]=l.useState(null),N=l.useRef(null),L=re(t,N,v.onContentChange),k=l.useRef(0),D=l.useRef(""),j=l.useRef(0),G=l.useRef(null),R=l.useRef("right"),z=l.useRef(0),X=g?Rn:l.Fragment,F=g?{as:Ig,allowPinchZoom:!0}:void 0,q=_=>{var V,se;const I=D.current+_,M=E().filter(le=>!le.disabled),Y=document.activeElement,B=(V=M.find(le=>le.ref.current===Y))==null?void 0:V.textValue,H=M.map(le=>le.textValue),de=Wg(H,I,B),ie=(se=M.find(le=>le.textValue===de))==null?void 0:se.ref.current;(function le(ae){D.current=ae,window.clearTimeout(k.current),ae!==""&&(k.current=window.setTimeout(()=>le(""),1e3))})(I),ie&&setTimeout(()=>ie.focus())};l.useEffect(()=>()=>window.clearTimeout(k.current),[]),Vr();const T=l.useCallback(_=>{var M,Y;return R.current===((M=G.current)==null?void 0:M.side)&&Vg(_,(Y=G.current)==null?void 0:Y.area)},[]);return i.jsx(Ag,{scope:n,searchRef:D,onItemEnter:l.useCallback(_=>{T(_)&&_.preventDefault()},[T]),onItemLeave:l.useCallback(_=>{var I;T(_)||((I=N.current)==null||I.focus(),O(null))},[T]),onTriggerLeave:l.useCallback(_=>{T(_)&&_.preventDefault()},[T]),pointerGraceTimerRef:j,onPointerGraceIntentChange:l.useCallback(_=>{G.current=_},[]),children:i.jsx(X,{...F,children:i.jsx(En,{asChild:!0,trapped:o,onMountAutoFocus:U(s,_=>{var I;_.preventDefault(),(I=N.current)==null||I.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:i.jsx(jt,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:m,onDismiss:b,children:i.jsx(Ih,{asChild:!0,...x,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:O,onEntryFocus:U(d,_=>{w.isUsingKeyboardRef.current||_.preventDefault()}),preventScrollOnEntryFocus:!0,children:i.jsx(co,{role:"menu","aria-orientation":"vertical","data-state":Fi(v.open),"data-radix-menu-content":"",dir:w.dir,...y,...h,ref:L,style:{outline:"none",...h.style},onKeyDown:U(h.onKeyDown,_=>{const M=_.target.closest("[data-radix-menu-content]")===_.currentTarget,Y=_.ctrlKey||_.altKey||_.metaKey,B=_.key.length===1;M&&(_.key==="Tab"&&_.preventDefault(),!Y&&B&&q(_.key));const H=N.current;if(_.target!==H||!bg.includes(_.key))return;_.preventDefault();const ie=E().filter(V=>!V.disabled).map(V=>V.ref.current);pi.includes(_.key)&&ie.reverse(),zg(ie)}),onBlur:U(e.onBlur,_=>{_.currentTarget.contains(_.target)||(window.clearTimeout(k.current),D.current="")}),onPointerMove:U(e.onPointerMove,en(_=>{const I=_.target,M=z.current!==_.clientX;if(_.currentTarget.contains(I)&&M){const Y=_.clientX>z.current?"right":"left";R.current=Y,z.current=_.clientX}}))})})})})})})});wi.displayName=Oe;var Og="MenuGroup",Eo=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(Z.div,{role:"group",...r,ref:t})});Eo.displayName=Og;var Mg="MenuLabel",yi=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(Z.div,{...r,ref:t})});yi.displayName=Mg;var jn="MenuItem",xi="menu.itemSelect",Kn=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=l.useRef(null),a=Zt(jn,e.__scopeMenu),c=So(jn,e.__scopeMenu),d=re(t,s),f=l.useRef(!1),u=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(xi,{bubbles:!0,cancelable:!0});p.addEventListener(xi,b=>r==null?void 0:r(b),{once:!0}),Js(p,m),m.defaultPrevented?f.current=!1:a.onClose()}};return i.jsx(Si,{...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===" "||wo.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Kn.displayName=jn;var Si=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,a=So(jn,n),c=gi(n),d=l.useRef(null),f=re(t,d),[u,p]=l.useState(!1),[m,b]=l.useState("");return l.useEffect(()=>{const g=d.current;g&&b((g.textContent??"").trim())},[s.children]),i.jsx(Jt.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:i.jsx(Oh,{asChild:!0,...c,focusable:!r,children:i.jsx(Z.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,en(g=>{r?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:U(e.onPointerLeave,en(g=>a.onItemLeave(g))),onFocus:U(e.onFocus,()=>p(!0)),onBlur:U(e.onBlur,()=>p(!1))})})})}),kg="MenuCheckboxItem",Ci=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return i.jsx(Pi,{scope:e.__scopeMenu,checked:n,children:i.jsx(Kn,{role:"menuitemcheckbox","aria-checked":Gn(n)?"mixed":n,...o,ref:t,"data-state":To(n),onSelect:U(o.onSelect,()=>r==null?void 0:r(Gn(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Ci.displayName=kg;var Ei="MenuRadioGroup",[Dg,Lg]=ut(Ei,{value:void 0,onValueChange:()=>{}}),Ni=l.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=we(r);return i.jsx(Dg,{scope:e.__scopeMenu,value:n,onValueChange:s,children:i.jsx(Eo,{...o,ref:t})})});Ni.displayName=Ei;var Ti="MenuRadioItem",Ai=l.forwardRef((e,t)=>{const{value:n,...r}=e,o=Lg(Ti,e.__scopeMenu),s=n===o.value;return i.jsx(Pi,{scope:e.__scopeMenu,checked:s,children:i.jsx(Kn,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":To(s),onSelect:U(r.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,n)},{checkForDefaultPrevented:!1})})})});Ai.displayName=Ti;var No="MenuItemIndicator",[Pi,Fg]=ut(No,{checked:!1}),_i=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Fg(No,n);return i.jsx(Ne,{present:r||Gn(s.checked)||s.checked===!0,children:i.jsx(Z.span,{...o,ref:t,"data-state":To(s.checked)})})});_i.displayName=No;var $g="MenuSeparator",Ii=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(Z.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Ii.displayName=$g;var Bg="MenuArrow",Oi=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Vn(n);return i.jsx(lo,{...o,...r,ref:t})});Oi.displayName=Bg;var Ug="MenuSub",[Pw,Mi]=ut(Ug),Qt="MenuSubTrigger",ki=l.forwardRef((e,t)=>{const n=ft(Qt,e.__scopeMenu),r=Zt(Qt,e.__scopeMenu),o=Mi(Qt,e.__scopeMenu),s=So(Qt,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(yo,{asChild:!0,...f,children:i.jsx(Si,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Fi(n.open),...e,ref:Fr(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,en(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,en(p=>{var b,g;u();const m=(b=n.content)==null?void 0:b.getBoundingClientRect();if(m){const h=(g=n.content)==null?void 0:g.dataset.side,v=h==="right",w=v?-5:5,y=m[v?"left":"right"],x=m[v?"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 b;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||wg[r.dir].includes(p.key)&&(n.onOpenChange(!0),(b=n.content)==null||b.focus(),p.preventDefault())})})})});ki.displayName=Qt;var Di="MenuSubContent",Li=l.forwardRef((e,t)=>{const n=vi(Oe,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=ft(Oe,e.__scopeMenu),a=Zt(Oe,e.__scopeMenu),c=Mi(Di,e.__scopeMenu),d=l.useRef(null),f=re(t,d);return i.jsx(Jt.Provider,{scope:e.__scopeMenu,children:i.jsx(Ne,{present:r||s.open,children:i.jsx(Jt.Slot,{scope:e.__scopeMenu,children:i.jsx(Co,{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 b;const p=u.currentTarget.contains(u.target),m=yg[a.dir].includes(u.key);p&&m&&(s.onOpenChange(!1),(b=c.trigger)==null||b.focus(),u.preventDefault())})})})})})});Li.displayName=Di;function Fi(e){return e?"open":"closed"}function Gn(e){return e==="indeterminate"}function To(e){return Gn(e)?"indeterminate":e?"checked":"unchecked"}function zg(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Hg(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Wg(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=Hg(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 Rg(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 Vg(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Rg(n,t)}function en(e){return t=>t.pointerType==="mouse"?e(t):void 0}var jg=mi,Kg=yo,Gg=bi,qg=wi,Xg=Eo,Yg=yi,Jg=Kn,Zg=Ci,Qg=Ni,em=Ai,tm=_i,nm=Ii,rm=Oi,om=ki,sm=Li,qn="DropdownMenu",[am,_w]=Le(qn,[hi]),xe=hi(),[im,$i]=am(qn),Bi=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:a,modal:c=!0}=e,d=xe(t),f=l.useRef(null),[u,p]=Qe({prop:o,defaultProp:s??!1,onChange:a,caller:qn});return i.jsx(im,{scope:t,triggerId:Fe(),triggerRef:f,contentId:Fe(),open:u,onOpenChange:p,onOpenToggle:l.useCallback(()=>p(m=>!m),[p]),modal:c,children:i.jsx(jg,{...d,open:u,onOpenChange:p,dir:r,modal:c,children:n})})};Bi.displayName=qn;var Ui="DropdownMenuTrigger",zi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=$i(Ui,n),a=xe(n);return i.jsx(Kg,{asChild:!0,...a,children:i.jsx(Z.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:Fr(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())})})})});zi.displayName=Ui;var cm="DropdownMenuPortal",Hi=e=>{const{__scopeDropdownMenu:t,...n}=e,r=xe(t);return i.jsx(Gg,{...r,...n})};Hi.displayName=cm;var Wi="DropdownMenuContent",Ri=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$i(Wi,n),s=xe(n),a=l.useRef(!1);return i.jsx(qg,{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)"}})});Ri.displayName=Wi;var lm="DropdownMenuGroup",dm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xe(n);return i.jsx(Xg,{...o,...r,ref:t})});dm.displayName=lm;var um="DropdownMenuLabel",Vi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xe(n);return i.jsx(Yg,{...o,...r,ref:t})});Vi.displayName=um;var fm="DropdownMenuItem",ji=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xe(n);return i.jsx(Jg,{...o,...r,ref:t})});ji.displayName=fm;var pm="DropdownMenuCheckboxItem",Ki=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xe(n);return i.jsx(Zg,{...o,...r,ref:t})});Ki.displayName=pm;var hm="DropdownMenuRadioGroup",gm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xe(n);return i.jsx(Qg,{...o,...r,ref:t})});gm.displayName=hm;var mm="DropdownMenuRadioItem",Gi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xe(n);return i.jsx(em,{...o,...r,ref:t})});Gi.displayName=mm;var vm="DropdownMenuItemIndicator",qi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xe(n);return i.jsx(tm,{...o,...r,ref:t})});qi.displayName=vm;var bm="DropdownMenuSeparator",Xi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xe(n);return i.jsx(nm,{...o,...r,ref:t})});Xi.displayName=bm;var wm="DropdownMenuArrow",ym=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xe(n);return i.jsx(rm,{...o,...r,ref:t})});ym.displayName=wm;var xm="DropdownMenuSubTrigger",Yi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xe(n);return i.jsx(om,{...o,...r,ref:t})});Yi.displayName=xm;var Sm="DropdownMenuSubContent",Ji=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xe(n);return i.jsx(sm,{...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)"}})});Ji.displayName=Sm;var Cm=Bi,Em=zi,Nm=Hi,Zi=Ri,Qi=Vi,ec=ji,tc=Ki,nc=Gi,rc=qi,oc=Xi,sc=Yi,ac=Ji;const Tm=Cm,Am=Em,Pm=l.forwardRef(({className:e,inset:t,children:n,...r},o)=>i.jsxs(sc,{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(K.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Pm.displayName=sc.displayName;const _m=l.forwardRef(({className:e,...t},n)=>i.jsx(ac,{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}));_m.displayName=ac.displayName;const ic=l.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(Nm,{children:i.jsx(Zi,{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})}));ic.displayName=Zi.displayName;const cc=l.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(ec,{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}));cc.displayName=ec.displayName;const Im=l.forwardRef(({className:e,children:t,checked:n,...r},o)=>i.jsxs(tc,{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(rc,{children:i.jsx(K.Check,{className:"h-4 w-4"})})}),t]}));Im.displayName=tc.displayName;const Om=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(nc,{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(rc,{children:i.jsx(K.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Om.displayName=nc.displayName;const Mm=l.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(Qi,{ref:r,className:A("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Mm.displayName=Qi.displayName;const km=l.forwardRef(({className:e,...t},n)=>i.jsx(oc,{ref:n,className:A("-mx-1 my-1 h-px bg-muted",e),...t}));km.displayName=oc.displayName;function tn({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:b,error:g,send:h,stop:v,lastCheckpointId:w,listCheckpoints:y,navigateToCheckpoint:x,returnToLatest:E}=Lr(),[C,O]=P.useState(""),[N,L]=P.useState(null),[k,D]=P.useState(null),[j,G]=P.useState([]),[R,z]=P.useState(!1),[X,F]=P.useState([]),[q,T]=P.useState(null),_=P.useRef(null),I=P.useRef(null),M=P.useRef(null),[Y,B]=P.useState("desktop");P.useEffect(()=>{const $=()=>{const te=window.innerWidth;B(te<640?"phone":te<1024?"tablet":"desktop")};return $(),window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)},[]),P.useEffect(()=>{var $;($=_.current)==null||$.scrollIntoView({behavior:"smooth"})},[p]),P.useEffect(()=>{var $;n&&(($=I.current)==null||$.focus())},[n]),P.useEffect(()=>{g&&!R&&(f==null||f(g))},[g,R,f]),P.useEffect(()=>{let $=!0;if(!u){F([]),T(null);return}return y(u).then(te=>{var Ae;if(!$)return;const oe=te.checkpoints||[];F(oe);const ue=((Ae=oe.slice().sort((kt,Se)=>new Date(Se.createdAt).getTime()-new Date(kt.createdAt).getTime())[0])==null?void 0:Ae.checkpointId)||null;T(kt=>kt??ue)}).catch(()=>{}),()=>{$=!1}},[u,y]),P.useEffect(()=>{w&&T(w)},[w]);const H=$=>{if($.length>yt)return`Message too long (${$.length}/${yt} characters)`;try{return Bf($),null}catch(te){return(te==null?void 0:te.message)||"Invalid message"}},de=$=>{const te=$.content||[],oe=te.filter(ue=>ue.type==="text").map(ue=>ue.text).join("");if(oe)return oe;try{return JSON.stringify(te,null,2)}catch{return String(te)}},ie=$=>{var kt;if(!X.length)return[];const oe=(((kt=p[$])==null?void 0:kt.role)??"user")==="user",ue=oe?$+2:$+1;return X.filter(Se=>(Se.messagesLen??-1)>=(oe?ue:0)).filter(Se=>oe?(Se.messagesLen??0)>=ue:(Se.messagesLen??0)===ue).map(Se=>({checkpoint_id:Se.checkpointId,checkpoint_ns:Se.checkpointNs,message_count:Se.messagesLen??0,last_message_preview:Se.preview??void 0,ts:new Date(Se.createdAt).getTime(),isCurrent:Se.checkpointId===q})).sort((Se,ow)=>(Se.ts||0)-(ow.ts||0))},V=$=>{if($===void 0)return{canGoBack:!1,canGoForward:!1,currentIndex:0,totalBranches:0};const te=ie($);if(te.length<=1)return{canGoBack:!1,canGoForward:!1,currentIndex:0,totalBranches:te.length};const oe=Math.max(0,te.findIndex(ue=>ue.isCurrent));return{canGoBack:oe>0,canGoForward:oe<te.length-1,currentIndex:oe,totalBranches:te.length}},se=async()=>{const $=C.trim();if(!$&&j.length===0)return;const te=H($);if(te){D(te);return}try{const oe=window.__editingCheckpointId||q||void 0;await h($,{checkpointId:oe,payloadExtras:N?{edit:!0,originalMessageId:N}:void 0,attachments:j}),d==null||d($),O(""),D(null),G([]),delete window.__editingCheckpointId,L(null),I.current&&(I.current.style.height="auto")}catch(oe){const ue=(oe==null?void 0:oe.message)||"Failed to send message";D(ue),f==null||f(ue)}},le=($,te)=>{a&&(L($),O(te),D(null),setTimeout(()=>{I.current&&(I.current.focus(),I.current.style.height="auto",I.current.style.height=I.current.scrollHeight+"px")},0))},ae=async($,te)=>{const oe=p.find(Ae=>Ae.id===$);if(!oe){D("Message not found");return}const ue=de(oe);L($),O(ue),window.__editingCheckpointId=te,setTimeout(()=>{var Ae;return(Ae=I.current)==null?void 0:Ae.focus()},0)},W=()=>{L(null),O(""),D(null),delete window.__editingCheckpointId,I.current&&(I.current.style.height="auto")},ee=$=>{$.key==="Enter"&&!$.shiftKey?($.preventDefault(),se()):$.key==="Escape"&&N&&($.preventDefault(),W())},pe=$=>{const te=Array.from($.target.files||[]);G(oe=>[...oe,...te])},he=$=>G(te=>te.filter((oe,ue)=>$!==ue)),J=async $=>{u&&(await x($),T($))},be=async()=>{await E(),T(null)},ce=`flex flex-col h-full min-w-0 bg-transparent ${e} ${c.container||""}`,ge=`flex-1 min-h-0 min-w-0 overflow-y-auto p-4 space-y-4 bg-transparent ${c.messagesArea||""}`,Te=`flex-shrink-0 border-t p-4 bg-transparent ${c.inputArea||""}`;return i.jsxs("div",{className:ce,children:[!!g&&!R&&i.jsxs("div",{className:"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(fe,{variant:"ghost",size:"sm",onClick:()=>z(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:i.jsx(K.X,{size:16})})]}),u&&X.length>0&&i.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b bg-background/50 text-xs",children:[i.jsx(K.GitBranch,{className:"h-4 w-4 opacity-70"}),i.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),i.jsxs("select",{className:"border rounded px-2 py-1 text-xs",value:q??"",onChange:$=>{const te=$.target.value||null;te?J(te):be()},children:[i.jsx("option",{value:"",children:"Latest"}),X.slice().sort(($,te)=>new Date(te.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",{className:ge,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!"}):p.map(($,te)=>i.jsx(ra,{message:$,messageIndex:te,isStreamingMessage:m&&b===$.id,streamingDebounceMs:o,isEditing:N===$.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:Y,truncateToolMessages:!1,toolMessagePreviewLength:200,checkpointBranches:ie(te),currentCheckpointId:q??void 0,temporalNavigation:V(te),onSwitchToCheckpoint:J,onReturnToMainThread:be,onNavigateToPreviousBranch:()=>{const oe=ie(te),ue=Math.max(0,oe.findIndex(Ae=>Ae.isCurrent));ue>0&&J(oe[ue-1].checkpoint_id)},onNavigateToNextBranch:()=>{const oe=ie(te),ue=Math.max(0,oe.findIndex(Ae=>Ae.isCurrent));ue>=0&&ue<oe.length-1&&J(oe[ue+1].checkpoint_id)},onEdit:(oe,ue)=>le(oe,ue),onEditFromCheckpoint:ae,onRegenerate:()=>{const oe=[...p].reverse().find(Ae=>Ae.role==="user"),ue=oe?de(oe):"";ue&&h(ue,{checkpointId:q??void 0})},onCancelEdit:W},$.id||te)),i.jsx("div",{ref:_})]}),i.jsxs("div",{className:Te,children:[N&&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(K.Edit3,{size:16,className:"text-blue-600"}),i.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:W,className:"text-blue-600 hover:bg-blue-100",children:i.jsx(K.X,{size:16})})]})}),s&&i.jsxs("div",{className:"mb-3",children:[i.jsx("input",{ref:M,type:"file",multiple:!0,onChange:$=>pe($),className:"hidden"}),j.length>0&&i.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:j.map(($,te)=>i.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 rounded-lg px-3 py-2 text-sm",children:[i.jsx(K.Paperclip,{size:14}),i.jsx("span",{className:"truncate max-w-[150px]",children:$.name}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>he(te),className:"h-4 w-4 p-0 text-gray-500 hover:text-red-500","aria-label":`Remove ${$.name}`,children:i.jsx(K.X,{size:12})})]},te))})]}),k&&i.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:k}),i.jsxs("div",{className:"flex items-end gap-2",children:[s&&i.jsxs(Tm,{children:[i.jsx(Am,{asChild:!0,children:i.jsx(fe,{type:"button",size:"icon",variant:"outline",disabled:m,title:"More input actions",className:c.moreButton||"",children:i.jsx(K.Plus,{size:16})})}),i.jsx(ic,{align:"start",sideOffset:6,className:"w-52",children:i.jsxs(cc,{onClick:()=>{var $;return($=M.current)==null?void 0:$.click()},className:"cursor-pointer",children:[i.jsx(K.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]})})]}),i.jsx("div",{className:"flex-1",children:i.jsx(qs,{ref:I,value:C,onChange:$=>{O($.target.value),D(null),I.current&&(I.current.style.height="auto",I.current.style.height=`${I.current.scrollHeight}px`)},onKeyDown:ee,placeholder:N?"Edit your message...":t,className:`resize-none min-h-[44px] max-h-[20rem] w-full ${N?"border-blue-400 bg-blue-50":""} ${k?"border-red-400":""} ${c.textarea||""}`,disabled:!1,maxLength:yt,rows:1})}),i.jsx("div",{children:m?i.jsx(fe,{type:"button",onClick:v,size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",children:i.jsx(K.Square,{size:16})}):i.jsx(fe,{type:"button",onClick:se,size:"icon",disabled:!C.trim()&&j.length===0,className:`shrink-0 ${c.sendButton||""}`,title:N?"Save changes":"Send message",children:i.jsx(K.Send,{size:16})})})]}),C.length>yt*.8&&i.jsxs("div",{className:"mt-2 text-xs text-gray-500 text-right",children:[C.length,"/",yt]})]})]})}const nn=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}));nn.displayName="Input";function Ao(e,[t,n]){return Math.min(n,Math.max(t,e))}function Dm(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var Po="ScrollArea",[lc,Iw]=Le(Po),[Lm,Me]=lc(Po),dc=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),[b,g]=l.useState(null),[h,v]=l.useState(null),[w,y]=l.useState(0),[x,E]=l.useState(0),[C,O]=l.useState(!1),[N,L]=l.useState(!1),k=re(t,j=>d(j)),D=Cn(o);return i.jsx(Lm,{scope:n,type:r,dir:D,scrollHideDelay:s,scrollArea:c,viewport:f,onViewportChange:u,content:p,onContentChange:m,scrollbarX:b,onScrollbarXChange:g,scrollbarXEnabled:C,onScrollbarXEnabledChange:O,scrollbarY:h,onScrollbarYChange:v,scrollbarYEnabled:N,onScrollbarYEnabledChange:L,onCornerWidthChange:y,onCornerHeightChange:E,children:i.jsx(Z.div,{dir:D,...a,ref:k,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":x+"px",...e.style}})})});dc.displayName=Po;var uc="ScrollAreaViewport",fc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,a=Me(uc,n),c=l.useRef(null),d=re(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(Z.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})})]})});fc.displayName=uc;var Xe="ScrollAreaScrollbar",_o=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Me(Xe,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(Fm,{...r,ref:t,forceMount:n}):o.type==="scroll"?i.jsx($m,{...r,ref:t,forceMount:n}):o.type==="auto"?i.jsx(pc,{...r,ref:t,forceMount:n}):o.type==="always"?i.jsx(Io,{...r,ref:t}):null});_o.displayName=Xe;var Fm=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Me(Xe,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(Ne,{present:n||s,children:i.jsx(pc,{"data-state":s?"visible":"hidden",...r,ref:t})})}),$m=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Me(Xe,e.__scopeScrollArea),s=e.orientation==="horizontal",a=Zn(()=>d("SCROLL_END"),100),[c,d]=Dm("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 b=f[u];p!==b&&(d("SCROLL"),a()),p=b};return f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[o.viewport,s,d,a]),i.jsx(Ne,{present:n||c!=="hidden",children:i.jsx(Io,{"data-state":c==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:U(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:U(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),pc=l.forwardRef((e,t)=>{const n=Me(Xe,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,a]=l.useState(!1),c=e.orientation==="horizontal",d=Zn(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;a(c?f:u)}},10);return It(n.viewport,d),It(n.content,d),i.jsx(Ne,{present:r||s,children:i.jsx(Io,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Io=l.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Me(Xe,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=bc(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,b){return Rm(m,a.current,c,b)}return n==="horizontal"?i.jsx(Bm,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,b=wc(m,c,o.dir);s.current.style.transform=`translate3d(${b}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(Um,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,b=wc(m,c);s.current.style.transform=`translate3d(0, ${b}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),Bm=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Me(Xe,e.__scopeScrollArea),[a,c]=l.useState(),d=l.useRef(null),f=re(t,d,s.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),i.jsx(gc,{"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":Jn(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),xc(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:Yn(a.paddingLeft),paddingEnd:Yn(a.paddingRight)}})}})}),Um=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Me(Xe,e.__scopeScrollArea),[a,c]=l.useState(),d=l.useRef(null),f=re(t,d,s.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),i.jsx(gc,{"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":Jn(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),xc(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:Yn(a.paddingTop),paddingEnd:Yn(a.paddingBottom)}})}})}),[zm,hc]=lc(Xe),gc=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,b=Me(Xe,n),[g,h]=l.useState(null),v=re(t,k=>h(k)),w=l.useRef(null),y=l.useRef(""),x=b.viewport,E=r.content-r.viewport,C=we(u),O=we(d),N=Zn(p,10);function L(k){if(w.current){const D=k.clientX-w.current.left,j=k.clientY-w.current.top;f({x:D,y:j})}}return l.useEffect(()=>{const k=D=>{const j=D.target;(g==null?void 0:g.contains(j))&&C(D,E)};return document.addEventListener("wheel",k,{passive:!1}),()=>document.removeEventListener("wheel",k,{passive:!1})},[x,g,E,C]),l.useEffect(O,[r,O]),It(g,N),It(b.content,N),i.jsx(zm,{scope:n,scrollbar:g,hasThumb:o,onThumbChange:we(s),onThumbPointerUp:we(a),onThumbPositionChange:O,onThumbPointerDown:we(c),children:i.jsx(Z.div,{...m,ref:v,style:{position:"absolute",...m.style},onPointerDown:U(e.onPointerDown,k=>{k.button===0&&(k.target.setPointerCapture(k.pointerId),w.current=g.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",b.viewport&&(b.viewport.style.scrollBehavior="auto"),L(k))}),onPointerMove:U(e.onPointerMove,L),onPointerUp:U(e.onPointerUp,k=>{const D=k.target;D.hasPointerCapture(k.pointerId)&&D.releasePointerCapture(k.pointerId),document.body.style.webkitUserSelect=y.current,b.viewport&&(b.viewport.style.scrollBehavior=""),w.current=null})})})}),Xn="ScrollAreaThumb",mc=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=hc(Xn,e.__scopeScrollArea);return i.jsx(Ne,{present:n||o.hasThumb,children:i.jsx(Hm,{ref:t,...r})})}),Hm=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Me(Xn,n),a=hc(Xn,n),{onThumbPositionChange:c}=a,d=re(t,p=>a.onThumbChange(p)),f=l.useRef(void 0),u=Zn(()=>{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 b=Vm(p,c);f.current=b,c()}};return c(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,u,c]),i.jsx(Z.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 b=p.target.getBoundingClientRect(),g=p.clientX-b.left,h=p.clientY-b.top;a.onThumbPointerDown({x:g,y:h})}),onPointerUp:U(e.onPointerUp,a.onThumbPointerUp)})});mc.displayName=Xn;var Oo="ScrollAreaCorner",vc=l.forwardRef((e,t)=>{const n=Me(Oo,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?i.jsx(Wm,{...e,ref:t}):null});vc.displayName=Oo;var Wm=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Me(Oo,n),[s,a]=l.useState(0),[c,d]=l.useState(0),f=!!(s&&c);return It(o.scrollbarX,()=>{var p;const u=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(u),d(u)}),It(o.scrollbarY,()=>{var p;const u=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(u),a(u)}),f?i.jsx(Z.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 Yn(e){return e?parseInt(e,10):0}function bc(e,t){const n=e/t;return isNaN(n)?0:n}function Jn(e){const t=bc(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Rm(e,t,n,r="ltr"){const o=Jn(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 wc(e,t,n="ltr"){const r=Jn(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=Ao(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 xc(e,t){return e>0&&e<t}var Vm=(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 Zn(e,t){const n=we(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 It(e,t){const n=we(t);ve(()=>{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 Sc=dc,jm=fc,Km=vc;const Cc=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(Sc,{ref:r,className:A("relative overflow-hidden",e),...n,children:[i.jsx(jm,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),i.jsx(Ec,{}),i.jsx(Km,{})]}));Cc.displayName=Sc.displayName;const Ec=l.forwardRef(({className:e,orientation:t="vertical",...n},r)=>i.jsx(_o,{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(mc,{className:"relative flex-1 rounded-full bg-border"})}));Ec.displayName=_o.displayName;function Qn({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:b,currentThreadId:g,createThread:h,deleteThread:v,renameThread:w}=Lr(),[y,x]=P.useState(m??[]),[E,C]=P.useState(!1),[O,N]=P.useState(null),[L,k]=P.useState(null),[D,j]=P.useState(""),[G,R]=P.useState(!1);P.useEffect(()=>{x(m??[])},[m]);const z=async B=>{try{await p(B),c==null||c(B),d==null||d(B)}catch(H){console.error("Failed to select thread:",H)}},X=async()=>{try{R(!0);const B=await h();f==null||f(B),c==null||c(B)}catch(B){console.error("Failed to create thread:",B)}finally{R(!1)}},F=async(B,H)=>{if(H.stopPropagation(),!!confirm("Delete this thread?"))try{await v(B),u==null||u(B)}catch(de){console.error("Failed to delete thread:",de)}},q=(B,H)=>{H.stopPropagation(),k(B.threadId),j(B.title||`Thread ${B.threadId.slice(0,8)}`)},T=async B=>{if(D.trim())try{await w(B,D.trim()),k(null),j("")}catch(H){console.error("Failed to update title:",H)}},_=()=>{k(null),j("")},I=(B,H)=>{B.key==="Enter"?T(H):B.key==="Escape"&&_()},M=B=>{if(!B)return"";try{const H=new Date(B),ie=new Date().getTime()-H.getTime(),V=Math.floor(ie/(1e3*60*60*24));return V===0?H.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):V===1?"Yesterday":V<7?`${V} days ago`:H.toLocaleDateString()}catch{return""}},Y=B=>B.title||`Thread ${B.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(fe,{onClick:X,disabled:G||E,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:G?"Creating...":"New Chat",children:i.jsx(K.MessageSquarePlus,{size:20})})}),i.jsx(Cc,{className:`flex-1 ${s.threadList||""}`,style:{maxHeight:o},children:i.jsx("div",{className:"p-2 space-y-1 pb-4",children:E?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(K.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((B,H)=>new Date(H.updatedAt||H.createdAt||"").getTime()-new Date(B.updatedAt||B.createdAt||"").getTime()).map(B=>i.jsxs("div",{onClick:()=>z(B.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(a??g)===B.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:L===B.threadId?i.jsxs("div",{className:"flex items-center gap-2",onClick:H=>H.stopPropagation(),children:[i.jsx(nn,{value:D,onChange:H=>j(H.target.value),onKeyDown:H=>I(H,B.threadId),className:"h-6 text-sm",autoFocus:!0}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>T(B.threadId),className:"h-6 w-6 p-0",children:i.jsx(K.Check,{size:12})}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:_,className:"h-6 w-6 p-0",children:i.jsx(K.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:Y(B)}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[i.jsx(K.Calendar,{size:10}),i.jsx("span",{children:M(B.updatedAt||B.createdAt)})]})]})}),i.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&L!==B.threadId&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:H=>q(B,H),className:"h-6 w-6 p-0",title:"Edit title",children:i.jsx(K.Edit3,{size:12})}),n&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:H=>F(B.threadId,H),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(K.Trash2,{size:12})})]})]}),a===B.threadId&&i.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},B.threadId))})})]})}const Nc=P.createContext(null);function Gm({children:e,basePath:t="/chat"}){const n=P.useMemo(()=>t?t==="/"?"":t.endsWith("/")?t.slice(0,-1):t:"/chat",[t]),r={basePath:n,buildThreadPath:o=>`${n}/${o}`,buildBasePath:()=>n};return i.jsx(Nc.Provider,{value:r,children:e})}function qm(){const e=P.useContext(Nc);return e||{basePath:"/chat",buildThreadPath:t=>`/chat/${t}`,buildBasePath:()=>"/chat"}}const Tc={BASE_URL:"/",DEV:!1,MODE:"library",PROD:!0,SSR:!1};function rn(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"&&Tc?Tc[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 Xm(){return rn("VITE_API_BASE_URL")||rn("NEXT_PUBLIC_API_BASE_URL")||void 0}function Ym(){return rn("VITE_API_KEY")||rn("NEXT_PUBLIC_API_KEY")||rn("VITE_AUTH_TOKEN")||void 0}function Ac(){const e=Xm(),t=Ym(),n={};return e&&(n.baseUrl=e),t&&(n.apiKey=t),n}function Pc(){const e=Ac(),t=Ye.getAuthToken();return{apiBaseUrl:e.baseUrl||Ye.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 _c="chat-settings";function Jm(){try{const e=localStorage.getItem(_c);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Zm(e){try{localStorage.setItem(_c,JSON.stringify(e)),e.apiKey&&Ye.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Qm(){const e=Pc(),t=Jm(),n=Ye.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Ye.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function ev(e){e.apiKey&&Ye.setAuthToken(e.apiKey),Zm(e)}const Mo=768;function tv(){const[e,t]=l.useState(void 0);return l.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Mo-1}px)`),r=()=>{t(window.innerWidth<Mo)};return n.addEventListener("change",r),t(window.innerWidth<Mo),()=>n.removeEventListener("change",r)},[]),!!e}var nv="Separator",Ic="horizontal",rv=["horizontal","vertical"],Oc=l.forwardRef((e,t)=>{const{decorative:n,orientation:r=Ic,...o}=e,s=ov(r)?r:Ic,c=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return i.jsx(Z.div,{"data-orientation":s,...c,...o,ref:t})});Oc.displayName=nv;function ov(e){return rv.includes(e)}var Mc=Oc;const ko=l.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>i.jsx(Mc,{ref:o,decorative:n,orientation:t,className:A("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ko.displayName=Mc.displayName;var er="Dialog",[kc,Ow]=Le(er),[sv,Ue]=kc(er),Dc=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]=Qe({prop:r,defaultProp:o??!1,onChange:s,caller:er});return i.jsx(sv,{scope:t,triggerRef:c,contentRef:d,contentId:Fe(),titleId:Fe(),descriptionId:Fe(),open:f,onOpenChange:u,onOpenToggle:l.useCallback(()=>u(p=>!p),[u]),modal:a,children:n})};Dc.displayName=er;var Lc="DialogTrigger",Fc=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(Lc,n),s=re(t,o.triggerRef);return i.jsx(Z.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Fo(o.open),...r,ref:s,onClick:U(e.onClick,o.onOpenToggle)})});Fc.displayName=Lc;var Do="DialogPortal",[av,$c]=kc(Do,{forceMount:void 0}),Bc=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Ue(Do,t);return i.jsx(av,{scope:t,forceMount:n,children:l.Children.map(r,a=>i.jsx(Ne,{present:n||s.open,children:i.jsx(Ln,{asChild:!0,container:o,children:a})}))})};Bc.displayName=Do;var tr="DialogOverlay",Uc=l.forwardRef((e,t)=>{const n=$c(tr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Ue(tr,e.__scopeDialog);return s.modal?i.jsx(Ne,{present:r||s.open,children:i.jsx(cv,{...o,ref:t})}):null});Uc.displayName=tr;var iv=Pe.createSlot("DialogOverlay.RemoveScroll"),cv=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(tr,n);return i.jsx(Rn,{as:iv,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(Z.div,{"data-state":Fo(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),pt="DialogContent",zc=l.forwardRef((e,t)=>{const n=$c(pt,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Ue(pt,e.__scopeDialog);return i.jsx(Ne,{present:r||s.open,children:s.modal?i.jsx(lv,{...o,ref:t}):i.jsx(dv,{...o,ref:t})})});zc.displayName=pt;var lv=l.forwardRef((e,t)=>{const n=Ue(pt,e.__scopeDialog),r=l.useRef(null),o=re(t,n.contentRef,r);return l.useEffect(()=>{const s=r.current;if(s)return ho(s)},[]),i.jsx(Hc,{...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())})}),dv=l.forwardRef((e,t)=>{const n=Ue(pt,e.__scopeDialog),r=l.useRef(!1),o=l.useRef(!1);return i.jsx(Hc,{...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()}})}),Hc=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=e,c=Ue(pt,n),d=l.useRef(null),f=re(t,d);return Vr(),i.jsxs(i.Fragment,{children:[i.jsx(En,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:i.jsx(jt,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Fo(c.open),...a,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(uv,{titleId:c.titleId}),i.jsx(pv,{contentRef:d,descriptionId:c.descriptionId})]})]})}),Lo="DialogTitle",Wc=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(Lo,n);return i.jsx(Z.h2,{id:o.titleId,...r,ref:t})});Wc.displayName=Lo;var Rc="DialogDescription",Vc=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(Rc,n);return i.jsx(Z.p,{id:o.descriptionId,...r,ref:t})});Vc.displayName=Rc;var jc="DialogClose",Kc=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(jc,n);return i.jsx(Z.button,{type:"button",...r,ref:t,onClick:U(e.onClick,()=>o.onOpenChange(!1))})});Kc.displayName=jc;function Fo(e){return e?"open":"closed"}var Gc="DialogTitleWarning",[Mw,qc]=lf(Gc,{contentName:pt,titleName:Lo,docsSlug:"dialog"}),uv=({titleId:e})=>{const t=qc(Gc),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
58
|
+
`)},gg=0,It=[];function mg(e){var t=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),o=l.useState(gg++)[0],s=l.useState(ai)[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=$h([e.lockRef.current],(e.shards||[]).map(pi),!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=Wn(h),y=n.current,x="deltaX"in h?h.deltaX:y[0]-w[0],E="deltaY"in h?h.deltaY:y[1]-w[1],C,O=h.target,N=Math.abs(x)>Math.abs(E)?"h":"v";if("touches"in h&&N==="h"&&O.type==="range")return!1;var F=li(N,O);if(!F)return!0;if(F?C=N:(C=N==="v"?"h":"v",F=li(N,O)),!F)return!1;if(!r.current&&"changedTouches"in h&&(x||E)&&(r.current=C),!C)return!0;var M=r.current||C;return fg(M,b,h,M==="h"?x:E)},[]),d=l.useCallback(function(h){var b=h;if(!(!It.length||It[It.length-1]!==s)){var w="deltaY"in b?fi(b):Wn(b),y=t.current.filter(function(C){return C.name===b.type&&(C.target===b.target||b.target===C.shadowParent)&&pg(C.delta,w)})[0];if(y&&y.should){b.cancelable&&b.preventDefault();return}if(!y){var x=(a.current.shards||[]).map(pi).filter(Boolean).filter(function(C){return C.contains(b.target)}),E=x.length>0?c(b,x[0]):!a.current.noIsolation;E&&b.cancelable&&b.preventDefault()}}},[]),f=l.useCallback(function(h,b,w,y){var x={name:h,delta:b,target:w,should:y,shadowParent:bg(w)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(E){return E!==x})},1)},[]),u=l.useCallback(function(h){n.current=Wn(h),r.current=void 0},[]),p=l.useCallback(function(h){f(h.type,fi(h),h.target,c(h,e.lockRef.current))},[]),m=l.useCallback(function(h){f(h.type,Wn(h),h.target,c(h,e.lockRef.current))},[]);l.useEffect(function(){return It.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",d,_t),document.addEventListener("touchmove",d,_t),document.addEventListener("touchstart",u,_t),function(){It=It.filter(function(h){return h!==s}),document.removeEventListener("wheel",d,_t),document.removeEventListener("touchmove",d,_t),document.removeEventListener("touchstart",u,_t)}},[]);var v=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(s,{styles:hg(o)}):null,v?l.createElement(sg,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function bg(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const vg=Kh(si,mg);var Vn=l.forwardRef(function(e,t){return l.createElement(zn,qe({},e,{ref:t,sideCar:vg}))});Vn.classNames=zn.classNames;var wo=["Enter"," "],wg=["ArrowDown","PageUp","Home"],hi=["ArrowUp","PageDown","End"],yg=[...wg,...hi],xg={ltr:[...wo,"ArrowRight"],rtl:[...wo,"ArrowLeft"]},Sg={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Yt="Menu",[Jt,Cg,Eg]=Hr(Yt),[ut,gi]=Le(Yt,[Eg,Tt,Ya]),jn=Tt(),mi=Ya(),[Ng,ft]=ut(Yt),[Tg,Zt]=ut(Yt),bi=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:a=!0}=e,c=jn(t),[d,f]=l.useState(null),u=l.useRef(!1),p=we(s),m=Cn(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(ao,{...c,children:i.jsx(Ng,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:f,children:i.jsx(Tg,{scope:t,onClose:l.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:u,dir:m,modal:a,children:r})})})};bi.displayName=Yt;var Ag="MenuAnchor",yo=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=jn(n);return i.jsx(io,{...o,...r,ref:t})});yo.displayName=Ag;var xo="MenuPortal",[Pg,vi]=ut(xo,{forceMount:void 0}),wi=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=ft(xo,t);return i.jsx(Pg,{scope:t,forceMount:n,children:i.jsx(Te,{present:n||s.open,children:i.jsx(Ln,{asChild:!0,container:o,children:r})})})};wi.displayName=xo;var Oe="MenuContent",[_g,So]=ut(Oe),yi=l.forwardRef((e,t)=>{const n=vi(Oe,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=ft(Oe,e.__scopeMenu),a=Zt(Oe,e.__scopeMenu);return i.jsx(Jt.Provider,{scope:e.__scopeMenu,children:i.jsx(Te,{present:r||s.open,children:i.jsx(Jt.Slot,{scope:e.__scopeMenu,children:a.modal?i.jsx(Ig,{...o,ref:t}):i.jsx(Og,{...o,ref:t})})})})}),Ig=l.forwardRef((e,t)=>{const n=ft(Oe,e.__scopeMenu),r=l.useRef(null),o=oe(t,r);return l.useEffect(()=>{const s=r.current;if(s)return ho(s)},[]),i.jsx(Co,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:U(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Og=l.forwardRef((e,t)=>{const n=ft(Oe,e.__scopeMenu);return i.jsx(Co,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),kg=Pe.createSlot("MenuContent.ScrollLock"),Co=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=ft(Oe,n),w=Zt(Oe,n),y=jn(n),x=mi(n),E=Cg(n),[C,O]=l.useState(null),N=l.useRef(null),F=oe(t,N,b.onContentChange),M=l.useRef(0),L=l.useRef(""),R=l.useRef(0),G=l.useRef(null),V=l.useRef("right"),z=l.useRef(0),X=g?Vn:l.Fragment,$=g?{as:kg,allowPinchZoom:!0}:void 0,q=_=>{var j,ae;const I=L.current+_,k=E().filter(le=>!le.disabled),Y=document.activeElement,B=(j=k.find(le=>le.ref.current===Y))==null?void 0:j.textValue,H=k.map(le=>le.textValue),de=jg(H,I,B),ce=(ae=k.find(le=>le.textValue===de))==null?void 0:ae.ref.current;(function le(ie){L.current=ie,window.clearTimeout(M.current),ie!==""&&(M.current=window.setTimeout(()=>le(""),1e3))})(I),ce&&setTimeout(()=>ce.focus())};l.useEffect(()=>()=>window.clearTimeout(M.current),[]),jr();const T=l.useCallback(_=>{var k,Y;return V.current===((k=G.current)==null?void 0:k.side)&&Kg(_,(Y=G.current)==null?void 0:Y.area)},[]);return i.jsx(_g,{scope:n,searchRef:L,onItemEnter:l.useCallback(_=>{T(_)&&_.preventDefault()},[T]),onItemLeave:l.useCallback(_=>{var I;T(_)||((I=N.current)==null||I.focus(),O(null))},[T]),onTriggerLeave:l.useCallback(_=>{T(_)&&_.preventDefault()},[T]),pointerGraceTimerRef:R,onPointerGraceIntentChange:l.useCallback(_=>{G.current=_},[]),children:i.jsx(X,{...$,children:i.jsx(En,{asChild:!0,trapped:o,onMountAutoFocus:U(s,_=>{var I;_.preventDefault(),(I=N.current)==null||I.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:i.jsx(Rt,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:m,onDismiss:v,children:i.jsx(kh,{asChild:!0,...x,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:O,onEntryFocus:U(d,_=>{w.isUsingKeyboardRef.current||_.preventDefault()}),preventScrollOnEntryFocus:!0,children:i.jsx(co,{role:"menu","aria-orientation":"vertical","data-state":$i(b.open),"data-radix-menu-content":"",dir:w.dir,...y,...h,ref:F,style:{outline:"none",...h.style},onKeyDown:U(h.onKeyDown,_=>{const k=_.target.closest("[data-radix-menu-content]")===_.currentTarget,Y=_.ctrlKey||_.altKey||_.metaKey,B=_.key.length===1;k&&(_.key==="Tab"&&_.preventDefault(),!Y&&B&&q(_.key));const H=N.current;if(_.target!==H||!yg.includes(_.key))return;_.preventDefault();const ce=E().filter(j=>!j.disabled).map(j=>j.ref.current);hi.includes(_.key)&&ce.reverse(),Wg(ce)}),onBlur:U(e.onBlur,_=>{_.currentTarget.contains(_.target)||(window.clearTimeout(M.current),L.current="")}),onPointerMove:U(e.onPointerMove,en(_=>{const I=_.target,k=z.current!==_.clientX;if(_.currentTarget.contains(I)&&k){const Y=_.clientX>z.current?"right":"left";V.current=Y,z.current=_.clientX}}))})})})})})})});yi.displayName=Oe;var Mg="MenuGroup",Eo=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(Z.div,{role:"group",...r,ref:t})});Eo.displayName=Mg;var Dg="MenuLabel",xi=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(Z.div,{...r,ref:t})});xi.displayName=Dg;var Rn="MenuItem",Si="menu.itemSelect",Kn=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=l.useRef(null),a=Zt(Rn,e.__scopeMenu),c=So(Rn,e.__scopeMenu),d=oe(t,s),f=l.useRef(!1),u=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(Si,{bubbles:!0,cancelable:!0});p.addEventListener(Si,v=>r==null?void 0:r(v),{once:!0}),Js(p,m),m.defaultPrevented?f.current=!1:a.onClose()}};return i.jsx(Ci,{...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===" "||wo.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Kn.displayName=Rn;var Ci=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,a=So(Rn,n),c=mi(n),d=l.useRef(null),f=oe(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(Jt.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:i.jsx(Mh,{asChild:!0,...c,focusable:!r,children:i.jsx(Z.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,en(g=>{r?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:U(e.onPointerLeave,en(g=>a.onItemLeave(g))),onFocus:U(e.onFocus,()=>p(!0)),onBlur:U(e.onBlur,()=>p(!1))})})})}),Lg="MenuCheckboxItem",Ei=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return i.jsx(_i,{scope:e.__scopeMenu,checked:n,children:i.jsx(Kn,{role:"menuitemcheckbox","aria-checked":Gn(n)?"mixed":n,...o,ref:t,"data-state":To(n),onSelect:U(o.onSelect,()=>r==null?void 0:r(Gn(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Ei.displayName=Lg;var Ni="MenuRadioGroup",[Fg,$g]=ut(Ni,{value:void 0,onValueChange:()=>{}}),Ti=l.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=we(r);return i.jsx(Fg,{scope:e.__scopeMenu,value:n,onValueChange:s,children:i.jsx(Eo,{...o,ref:t})})});Ti.displayName=Ni;var Ai="MenuRadioItem",Pi=l.forwardRef((e,t)=>{const{value:n,...r}=e,o=$g(Ai,e.__scopeMenu),s=n===o.value;return i.jsx(_i,{scope:e.__scopeMenu,checked:s,children:i.jsx(Kn,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":To(s),onSelect:U(r.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,n)},{checkForDefaultPrevented:!1})})})});Pi.displayName=Ai;var No="MenuItemIndicator",[_i,Bg]=ut(No,{checked:!1}),Ii=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Bg(No,n);return i.jsx(Te,{present:r||Gn(s.checked)||s.checked===!0,children:i.jsx(Z.span,{...o,ref:t,"data-state":To(s.checked)})})});Ii.displayName=No;var Ug="MenuSeparator",Oi=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(Z.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Oi.displayName=Ug;var zg="MenuArrow",ki=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=jn(n);return i.jsx(lo,{...o,...r,ref:t})});ki.displayName=zg;var Hg="MenuSub",[Iw,Mi]=ut(Hg),Qt="MenuSubTrigger",Di=l.forwardRef((e,t)=>{const n=ft(Qt,e.__scopeMenu),r=Zt(Qt,e.__scopeMenu),o=Mi(Qt,e.__scopeMenu),s=So(Qt,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(yo,{asChild:!0,...f,children:i.jsx(Ci,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":$i(n.open),...e,ref:Fr(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,en(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,en(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===" "||xg[r.dir].includes(p.key)&&(n.onOpenChange(!0),(v=n.content)==null||v.focus(),p.preventDefault())})})})});Di.displayName=Qt;var Li="MenuSubContent",Fi=l.forwardRef((e,t)=>{const n=vi(Oe,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=ft(Oe,e.__scopeMenu),a=Zt(Oe,e.__scopeMenu),c=Mi(Li,e.__scopeMenu),d=l.useRef(null),f=oe(t,d);return i.jsx(Jt.Provider,{scope:e.__scopeMenu,children:i.jsx(Te,{present:r||s.open,children:i.jsx(Jt.Slot,{scope:e.__scopeMenu,children:i.jsx(Co,{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=Sg[a.dir].includes(u.key);p&&m&&(s.onOpenChange(!1),(v=c.trigger)==null||v.focus(),u.preventDefault())})})})})})});Fi.displayName=Li;function $i(e){return e?"open":"closed"}function Gn(e){return e==="indeterminate"}function To(e){return Gn(e)?"indeterminate":e?"checked":"unchecked"}function Wg(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Vg(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function jg(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=Vg(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 Rg(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 Kg(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Rg(n,t)}function en(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Gg=bi,qg=yo,Xg=wi,Yg=yi,Jg=Eo,Zg=xi,Qg=Kn,em=Ei,tm=Ti,nm=Pi,rm=Ii,om=Oi,sm=ki,am=Di,im=Fi,qn="DropdownMenu",[cm,Ow]=Le(qn,[gi]),Se=gi(),[lm,Bi]=cm(qn),Ui=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:a,modal:c=!0}=e,d=Se(t),f=l.useRef(null),[u,p]=Qe({prop:o,defaultProp:s??!1,onChange:a,caller:qn});return i.jsx(lm,{scope:t,triggerId:Fe(),triggerRef:f,contentId:Fe(),open:u,onOpenChange:p,onOpenToggle:l.useCallback(()=>p(m=>!m),[p]),modal:c,children:i.jsx(Gg,{...d,open:u,onOpenChange:p,dir:r,modal:c,children:n})})};Ui.displayName=qn;var zi="DropdownMenuTrigger",Hi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Bi(zi,n),a=Se(n);return i.jsx(qg,{asChild:!0,...a,children:i.jsx(Z.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:Fr(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())})})})});Hi.displayName=zi;var dm="DropdownMenuPortal",Wi=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Se(t);return i.jsx(Xg,{...r,...n})};Wi.displayName=dm;var Vi="DropdownMenuContent",ji=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bi(Vi,n),s=Se(n),a=l.useRef(!1);return i.jsx(Yg,{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)"}})});ji.displayName=Vi;var um="DropdownMenuGroup",fm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return i.jsx(Jg,{...o,...r,ref:t})});fm.displayName=um;var pm="DropdownMenuLabel",Ri=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return i.jsx(Zg,{...o,...r,ref:t})});Ri.displayName=pm;var hm="DropdownMenuItem",Ki=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return i.jsx(Qg,{...o,...r,ref:t})});Ki.displayName=hm;var gm="DropdownMenuCheckboxItem",Gi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return i.jsx(em,{...o,...r,ref:t})});Gi.displayName=gm;var mm="DropdownMenuRadioGroup",bm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return i.jsx(tm,{...o,...r,ref:t})});bm.displayName=mm;var vm="DropdownMenuRadioItem",qi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return i.jsx(nm,{...o,...r,ref:t})});qi.displayName=vm;var wm="DropdownMenuItemIndicator",Xi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return i.jsx(rm,{...o,...r,ref:t})});Xi.displayName=wm;var ym="DropdownMenuSeparator",Yi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return i.jsx(om,{...o,...r,ref:t})});Yi.displayName=ym;var xm="DropdownMenuArrow",Sm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return i.jsx(sm,{...o,...r,ref:t})});Sm.displayName=xm;var Cm="DropdownMenuSubTrigger",Ji=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return i.jsx(am,{...o,...r,ref:t})});Ji.displayName=Cm;var Em="DropdownMenuSubContent",Zi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Se(n);return i.jsx(im,{...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)"}})});Zi.displayName=Em;var Nm=Ui,Tm=Hi,Am=Wi,Qi=ji,ec=Ri,tc=Ki,nc=Gi,rc=qi,oc=Xi,sc=Yi,ac=Ji,ic=Zi;const Pm=Nm,_m=Tm,Im=l.forwardRef(({className:e,inset:t,children:n,...r},o)=>i.jsxs(ac,{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(K.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Im.displayName=ac.displayName;const Om=l.forwardRef(({className:e,...t},n)=>i.jsx(ic,{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}));Om.displayName=ic.displayName;const cc=l.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(Am,{children:i.jsx(Qi,{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})}));cc.displayName=Qi.displayName;const lc=l.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(tc,{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}));lc.displayName=tc.displayName;const km=l.forwardRef(({className:e,children:t,checked:n,...r},o)=>i.jsxs(nc,{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(K.Check,{className:"h-4 w-4"})})}),t]}));km.displayName=nc.displayName;const Mm=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(rc,{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(K.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Mm.displayName=rc.displayName;const Dm=l.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(ec,{ref:r,className:A("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Dm.displayName=ec.displayName;const Lm=l.forwardRef(({className:e,...t},n)=>i.jsx(sc,{ref:n,className:A("-mx-1 my-1 h-px bg-muted",e),...t}));Lm.displayName=sc.displayName;function tn({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,listCheckpoints:y,navigateToCheckpoint:x,returnToLatest:E}=Lr(),[C,O]=P.useState(""),[N,F]=P.useState(null),[M,L]=P.useState(null),[R,G]=P.useState([]),[V,z]=P.useState(!1),[X,$]=P.useState([]),[q,T]=P.useState(null),_=P.useRef(null),I=P.useRef(null),k=P.useRef(null),[Y,B]=P.useState("desktop");P.useEffect(()=>{const D=()=>{const te=window.innerWidth;B(te<640?"phone":te<1024?"tablet":"desktop")};return D(),window.addEventListener("resize",D),()=>window.removeEventListener("resize",D)},[]),P.useEffect(()=>{var D;(D=_.current)==null||D.scrollIntoView({behavior:"smooth"})},[p]),P.useEffect(()=>{var D;n&&((D=I.current)==null||D.focus())},[n]),P.useEffect(()=>{g&&!V&&(f==null||f(g))},[g,V,f]),P.useEffect(()=>{let D=!0;if(!u){$([]),T(null);return}return y(u).then(te=>{var Ae;if(!D)return;const se=te.checkpoints||[];$(se);const ue=((Ae=se.slice().sort((Dt,Ce)=>new Date(Ce.createdAt).getTime()-new Date(Dt.createdAt).getTime())[0])==null?void 0:Ae.checkpointId)||null;T(Dt=>Dt??ue)}).catch(()=>{}),()=>{D=!1}},[u,y]),P.useEffect(()=>{w&&T(w)},[w]);const H=D=>{if(D.length>xt)return`Message too long (${D.length}/${xt} characters)`;try{return zf(D),null}catch(te){return(te==null?void 0:te.message)||"Invalid message"}},de=D=>{const te=D.content||[],se=te.filter(ue=>ue.type==="text").map(ue=>ue.text).join("");if(se)return se;try{return JSON.stringify(te,null,2)}catch{return String(te)}},ce=D=>{var Dt;if(!X.length)return[];const se=(((Dt=p[D])==null?void 0:Dt.role)??"user")==="user",ue=se?D+2:D+1;return X.filter(Ce=>(Ce.messagesLen??-1)>=(se?ue:0)).filter(Ce=>se?(Ce.messagesLen??0)>=ue:(Ce.messagesLen??0)===ue).map(Ce=>({checkpoint_id:Ce.checkpointId,checkpoint_ns:Ce.checkpointNs,message_count:Ce.messagesLen??0,last_message_preview:Ce.preview??void 0,ts:new Date(Ce.createdAt).getTime(),isCurrent:Ce.checkpointId===q})).sort((Ce,aw)=>(Ce.ts||0)-(aw.ts||0))},j=D=>{if(D===void 0)return{canGoBack:!1,canGoForward:!1,currentIndex:0,totalBranches:0};const te=ce(D);if(te.length<=1)return{canGoBack:!1,canGoForward:!1,currentIndex:0,totalBranches:te.length};const se=Math.max(0,te.findIndex(ue=>ue.isCurrent));return{canGoBack:se>0,canGoForward:se<te.length-1,currentIndex:se,totalBranches:te.length}},ae=async()=>{const D=C.trim();if(!D&&R.length===0)return;const te=H(D);if(te){L(te);return}try{const se=window.__editingCheckpointId||q||void 0;await h(D,{checkpointId:se,payloadExtras:N?{edit:!0,originalMessageId:N}:void 0,attachments:R}),d==null||d(D),O(""),L(null),G([]),delete window.__editingCheckpointId,F(null),I.current&&(I.current.style.height="auto")}catch(se){const ue=(se==null?void 0:se.message)||"Failed to send message";L(ue),f==null||f(ue)}},le=(D,te)=>{a&&(F(D),O(te),L(null),setTimeout(()=>{I.current&&(I.current.focus(),I.current.style.height="auto",I.current.style.height=I.current.scrollHeight+"px")},0))},ie=async(D,te)=>{const se=p.find(Ae=>Ae.id===D);if(!se){L("Message not found");return}const ue=de(se);F(D),O(ue),window.__editingCheckpointId=te,setTimeout(()=>{var Ae;return(Ae=I.current)==null?void 0:Ae.focus()},0)},W=()=>{F(null),O(""),L(null),delete window.__editingCheckpointId,I.current&&(I.current.style.height="auto")},ee=D=>{D.key==="Enter"&&!D.shiftKey?(D.preventDefault(),ae()):D.key==="Escape"&&N&&(D.preventDefault(),W())},pe=D=>{const te=Array.from(D.target.files||[]);G(se=>[...se,...te])},he=D=>G(te=>te.filter((se,ue)=>D!==ue)),J=async D=>{u&&(await x(D),T(D))},ve=async()=>{await E(),T(null)},re=`flex flex-col h-full min-w-0 bg-transparent ${e} ${c.container||""}`,ge=`flex-1 min-h-0 min-w-0 overflow-y-auto p-4 space-y-4 bg-transparent ${c.messagesArea||""}`,ye=`flex-shrink-0 border-t p-4 bg-transparent ${c.inputArea||""}`;return i.jsxs("div",{className:re,children:[!!g&&!V&&i.jsxs("div",{className:"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(fe,{variant:"ghost",size:"sm",onClick:()=>z(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:i.jsx(K.X,{size:16})})]}),u&&X.length>0&&i.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b bg-background/50 text-xs",children:[i.jsx(K.GitBranch,{className:"h-4 w-4 opacity-70"}),i.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),i.jsxs("select",{className:"border rounded px-2 py-1 text-xs",value:q??"",onChange:D=>{const te=D.target.value||null;te?J(te):ve()},children:[i.jsx("option",{value:"",children:"Latest"}),X.slice().sort((D,te)=>new Date(te.createdAt).getTime()-new Date(D.createdAt).getTime()).map(D=>i.jsxs("option",{value:D.checkpointId,children:[new Date(D.createdAt).toLocaleString(),D.preview?` — ${D.preview.slice(0,30)}`:""]},D.checkpointId))]})]}),i.jsxs("div",{className:ge,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!"}):p.map((D,te)=>i.jsx(ra,{message:D,messageIndex:te,isStreamingMessage:m&&v===D.id,streamingDebounceMs:o,isEditing:N===D.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:Y,truncateToolMessages:!1,toolMessagePreviewLength:200,checkpointBranches:ce(te),currentCheckpointId:q??void 0,temporalNavigation:j(te),onSwitchToCheckpoint:J,onReturnToMainThread:ve,onNavigateToPreviousBranch:()=>{const se=ce(te),ue=Math.max(0,se.findIndex(Ae=>Ae.isCurrent));ue>0&&J(se[ue-1].checkpoint_id)},onNavigateToNextBranch:()=>{const se=ce(te),ue=Math.max(0,se.findIndex(Ae=>Ae.isCurrent));ue>=0&&ue<se.length-1&&J(se[ue+1].checkpoint_id)},onEdit:(se,ue)=>le(se,ue),onEditFromCheckpoint:ie,onRegenerate:()=>{const se=[...p].reverse().find(Ae=>Ae.role==="user"),ue=se?de(se):"";ue&&h(ue,{checkpointId:q??void 0})},onCancelEdit:W},D.id||te)),i.jsx("div",{ref:_})]}),i.jsxs("div",{className:ye,children:[N&&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(K.Edit3,{size:16,className:"text-blue-600"}),i.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:W,className:"text-blue-600 hover:bg-blue-100",children:i.jsx(K.X,{size:16})})]})}),s&&i.jsxs("div",{className:"mb-3",children:[i.jsx("input",{ref:k,type:"file",multiple:!0,onChange:D=>pe(D),className:"hidden"}),R.length>0&&i.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:R.map((D,te)=>i.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 rounded-lg px-3 py-2 text-sm",children:[i.jsx(K.Paperclip,{size:14}),i.jsx("span",{className:"truncate max-w-[150px]",children:D.name}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>he(te),className:"h-4 w-4 p-0 text-gray-500 hover:text-red-500","aria-label":`Remove ${D.name}`,children:i.jsx(K.X,{size:12})})]},te))})]}),M&&i.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:M}),i.jsxs("div",{className:"flex items-end gap-2",children:[s&&i.jsxs(Pm,{children:[i.jsx(_m,{asChild:!0,children:i.jsx(fe,{type:"button",size:"icon",variant:"outline",disabled:m,title:"More input actions",className:c.moreButton||"",children:i.jsx(K.Plus,{size:16})})}),i.jsx(cc,{align:"start",sideOffset:6,className:"w-52",children:i.jsxs(lc,{onClick:()=>{var D;return(D=k.current)==null?void 0:D.click()},className:"cursor-pointer",children:[i.jsx(K.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]})})]}),i.jsx("div",{className:"flex-1",children:i.jsx(qs,{ref:I,value:C,onChange:D=>{O(D.target.value),L(null),I.current&&(I.current.style.height="auto",I.current.style.height=`${I.current.scrollHeight}px`)},onKeyDown:ee,placeholder:N?"Edit your message...":t,className:`resize-none min-h-[44px] max-h-[20rem] w-full ${N?"border-blue-400 bg-blue-50":""} ${M?"border-red-400":""} ${c.textarea||""}`,disabled:!1,maxLength:xt,rows:1})}),i.jsx("div",{children:m?i.jsx(fe,{type:"button",onClick:b,size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",children:i.jsx(K.Square,{size:16})}):i.jsx(fe,{type:"button",onClick:ae,size:"icon",disabled:!C.trim()&&R.length===0,className:`shrink-0 ${c.sendButton||""}`,title:N?"Save changes":"Send message",children:i.jsx(K.Send,{size:16})})})]}),C.length>xt*.8&&i.jsxs("div",{className:"mt-2 text-xs text-gray-500 text-right",children:[C.length,"/",xt]})]})]})}const nn=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}));nn.displayName="Input";function Ao(e,[t,n]){return Math.min(n,Math.max(t,e))}function Fm(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var Po="ScrollArea",[dc,kw]=Le(Po),[$m,ke]=dc(Po),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,E]=l.useState(0),[C,O]=l.useState(!1),[N,F]=l.useState(!1),M=oe(t,R=>d(R)),L=Cn(o);return i.jsx($m,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:c,viewport:f,onViewportChange:u,content:p,onContentChange:m,scrollbarX:v,onScrollbarXChange:g,scrollbarXEnabled:C,onScrollbarXEnabledChange:O,scrollbarY:h,onScrollbarYChange:b,scrollbarYEnabled:N,onScrollbarYEnabledChange:F,onCornerWidthChange:y,onCornerHeightChange:E,children:i.jsx(Z.div,{dir:L,...a,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":x+"px",...e.style}})})});uc.displayName=Po;var fc="ScrollAreaViewport",pc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,a=ke(fc,n),c=l.useRef(null),d=oe(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(Z.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})})]})});pc.displayName=fc;var Xe="ScrollAreaScrollbar",_o=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ke(Xe,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(Bm,{...r,ref:t,forceMount:n}):o.type==="scroll"?i.jsx(Um,{...r,ref:t,forceMount:n}):o.type==="auto"?i.jsx(hc,{...r,ref:t,forceMount:n}):o.type==="always"?i.jsx(Io,{...r,ref:t}):null});_o.displayName=Xe;var Bm=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ke(Xe,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(Te,{present:n||s,children:i.jsx(hc,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Um=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ke(Xe,e.__scopeScrollArea),s=e.orientation==="horizontal",a=Zn(()=>d("SCROLL_END"),100),[c,d]=Fm("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(Te,{present:n||c!=="hidden",children:i.jsx(Io,{"data-state":c==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:U(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:U(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),hc=l.forwardRef((e,t)=>{const n=ke(Xe,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,a]=l.useState(!1),c=e.orientation==="horizontal",d=Zn(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;a(c?f:u)}},10);return Ot(n.viewport,d),Ot(n.content,d),i.jsx(Te,{present:r||s,children:i.jsx(Io,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Io=l.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=ke(Xe,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=wc(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 Rm(m,a.current,c,v)}return n==="horizontal"?i.jsx(zm,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,v=yc(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(Hm,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,v=yc(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}),zm=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=ke(Xe,e.__scopeScrollArea),[a,c]=l.useState(),d=l.useRef(null),f=oe(t,d,s.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),i.jsx(mc,{"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":Jn(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),Sc(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:Yn(a.paddingLeft),paddingEnd:Yn(a.paddingRight)}})}})}),Hm=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=ke(Xe,e.__scopeScrollArea),[a,c]=l.useState(),d=l.useRef(null),f=oe(t,d,s.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),i.jsx(mc,{"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":Jn(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),Sc(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:Yn(a.paddingTop),paddingEnd:Yn(a.paddingBottom)}})}})}),[Wm,gc]=dc(Xe),mc=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=ke(Xe,n),[g,h]=l.useState(null),b=oe(t,M=>h(M)),w=l.useRef(null),y=l.useRef(""),x=v.viewport,E=r.content-r.viewport,C=we(u),O=we(d),N=Zn(p,10);function F(M){if(w.current){const L=M.clientX-w.current.left,R=M.clientY-w.current.top;f({x:L,y:R})}}return l.useEffect(()=>{const M=L=>{const R=L.target;(g==null?void 0:g.contains(R))&&C(L,E)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[x,g,E,C]),l.useEffect(O,[r,O]),Ot(g,N),Ot(v.content,N),i.jsx(Wm,{scope:n,scrollbar:g,hasThumb:o,onThumbChange:we(s),onThumbPointerUp:we(a),onThumbPositionChange:O,onThumbPointerDown:we(c),children:i.jsx(Z.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 L=M.target;L.hasPointerCapture(M.pointerId)&&L.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=y.current,v.viewport&&(v.viewport.style.scrollBehavior=""),w.current=null})})})}),Xn="ScrollAreaThumb",bc=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=gc(Xn,e.__scopeScrollArea);return i.jsx(Te,{present:n||o.hasThumb,children:i.jsx(Vm,{ref:t,...r})})}),Vm=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=ke(Xn,n),a=gc(Xn,n),{onThumbPositionChange:c}=a,d=oe(t,p=>a.onThumbChange(p)),f=l.useRef(void 0),u=Zn(()=>{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=Km(p,c);f.current=v,c()}};return c(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,u,c]),i.jsx(Z.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)})});bc.displayName=Xn;var Oo="ScrollAreaCorner",vc=l.forwardRef((e,t)=>{const n=ke(Oo,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?i.jsx(jm,{...e,ref:t}):null});vc.displayName=Oo;var jm=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=ke(Oo,n),[s,a]=l.useState(0),[c,d]=l.useState(0),f=!!(s&&c);return Ot(o.scrollbarX,()=>{var p;const u=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(u),d(u)}),Ot(o.scrollbarY,()=>{var p;const u=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(u),a(u)}),f?i.jsx(Z.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 Yn(e){return e?parseInt(e,10):0}function wc(e,t){const n=e/t;return isNaN(n)?0:n}function Jn(e){const t=wc(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Rm(e,t,n,r="ltr"){const o=Jn(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 yc(e,t,n="ltr"){const r=Jn(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=Ao(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 Sc(e,t){return e>0&&e<t}var Km=(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 Zn(e,t){const n=we(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 Ot(e,t){const n=we(t);be(()=>{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 Cc=uc,Gm=pc,qm=vc;const Ec=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(Cc,{ref:r,className:A("relative overflow-hidden",e),...n,children:[i.jsx(Gm,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),i.jsx(Nc,{}),i.jsx(qm,{})]}));Ec.displayName=Cc.displayName;const Nc=l.forwardRef(({className:e,orientation:t="vertical",...n},r)=>i.jsx(_o,{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(bc,{className:"relative flex-1 rounded-full bg-border"})}));Nc.displayName=_o.displayName;function Qn({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}=Lr(),[y,x]=P.useState(m??[]),[E,C]=P.useState(!1),[O,N]=P.useState(null),[F,M]=P.useState(null),[L,R]=P.useState(""),[G,V]=P.useState(!1);P.useEffect(()=>{x(m??[])},[m]);const z=async B=>{try{await p(B),c==null||c(B),d==null||d(B)}catch(H){console.error("Failed to select thread:",H)}},X=async()=>{try{V(!0);const B=await h();f==null||f(B),c==null||c(B)}catch(B){console.error("Failed to create thread:",B)}finally{V(!1)}},$=async(B,H)=>{if(H.stopPropagation(),!!confirm("Delete this thread?"))try{await b(B),u==null||u(B)}catch(de){console.error("Failed to delete thread:",de)}},q=(B,H)=>{H.stopPropagation(),M(B.threadId),R(B.title||`Thread ${B.threadId.slice(0,8)}`)},T=async B=>{if(L.trim())try{await w(B,L.trim()),M(null),R("")}catch(H){console.error("Failed to update title:",H)}},_=()=>{M(null),R("")},I=(B,H)=>{B.key==="Enter"?T(H):B.key==="Escape"&&_()},k=B=>{if(!B)return"";try{const H=new Date(B),ce=new Date().getTime()-H.getTime(),j=Math.floor(ce/(1e3*60*60*24));return j===0?H.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):j===1?"Yesterday":j<7?`${j} days ago`:H.toLocaleDateString()}catch{return""}},Y=B=>B.title||`Thread ${B.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(fe,{onClick:X,disabled:G||E,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:G?"Creating...":"New Chat",children:i.jsx(K.MessageSquarePlus,{size:20})})}),i.jsx(Ec,{className:`flex-1 ${s.threadList||""}`,style:{maxHeight:o},children:i.jsx("div",{className:"p-2 space-y-1 pb-4",children:E?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(K.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((B,H)=>new Date(H.updatedAt||H.createdAt||"").getTime()-new Date(B.updatedAt||B.createdAt||"").getTime()).map(B=>i.jsxs("div",{onClick:()=>z(B.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(a??g)===B.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===B.threadId?i.jsxs("div",{className:"flex items-center gap-2",onClick:H=>H.stopPropagation(),children:[i.jsx(nn,{value:L,onChange:H=>R(H.target.value),onKeyDown:H=>I(H,B.threadId),className:"h-6 text-sm",autoFocus:!0}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>T(B.threadId),className:"h-6 w-6 p-0",children:i.jsx(K.Check,{size:12})}),i.jsx(fe,{variant:"ghost",size:"sm",onClick:_,className:"h-6 w-6 p-0",children:i.jsx(K.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:Y(B)}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[i.jsx(K.Calendar,{size:10}),i.jsx("span",{children:k(B.updatedAt||B.createdAt)})]})]})}),i.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&F!==B.threadId&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:H=>q(B,H),className:"h-6 w-6 p-0",title:"Edit title",children:i.jsx(K.Edit3,{size:12})}),n&&i.jsx(fe,{variant:"ghost",size:"sm",onClick:H=>$(B.threadId,H),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(K.Trash2,{size:12})})]})]}),a===B.threadId&&i.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},B.threadId))})})]})}const Tc=P.createContext(null);function Xm({children:e,basePath:t="/chat"}){const n=P.useMemo(()=>t?t==="/"?"":t.endsWith("/")?t.slice(0,-1):t:"/chat",[t]),r={basePath:n,buildThreadPath:o=>`${n}/${o}`,buildBasePath:()=>n};return i.jsx(Tc.Provider,{value:r,children:e})}function Ym(){const e=P.useContext(Tc);return e||{basePath:"/chat",buildThreadPath:t=>`/chat/${t}`,buildBasePath:()=>"/chat"}}const Ac={BASE_URL:"/",DEV:!1,MODE:"library",PROD:!0,SSR:!1};function rn(e){var o;const t=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:br&&br.tagName.toUpperCase()==="SCRIPT"&&br.src||new URL("index.umd.js",document.baseURI).href}<"u"&&Ac?Ac[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 Jm(){return rn("VITE_API_BASE_URL")||rn("NEXT_PUBLIC_API_BASE_URL")||void 0}function Zm(){return rn("VITE_API_KEY")||rn("NEXT_PUBLIC_API_KEY")||rn("VITE_AUTH_TOKEN")||void 0}function Pc(){const e=Jm(),t=Zm(),n={};return e&&(n.baseUrl=e),t&&(n.apiKey=t),n}function _c(){const e=Pc(),t=Ye.getAuthToken();return{apiBaseUrl:e.baseUrl||Ye.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 Ic="chat-settings";function Qm(){try{const e=localStorage.getItem(Ic);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function eb(e){try{localStorage.setItem(Ic,JSON.stringify(e)),e.apiKey&&Ye.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function tb(){const e=_c(),t=Qm(),n=Ye.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Ye.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function nb(e){e.apiKey&&Ye.setAuthToken(e.apiKey),eb(e)}const ko=768;function rb(){const[e,t]=l.useState(void 0);return l.useEffect(()=>{const n=window.matchMedia(`(max-width: ${ko-1}px)`),r=()=>{t(window.innerWidth<ko)};return n.addEventListener("change",r),t(window.innerWidth<ko),()=>n.removeEventListener("change",r)},[]),!!e}var ob="Separator",Oc="horizontal",sb=["horizontal","vertical"],kc=l.forwardRef((e,t)=>{const{decorative:n,orientation:r=Oc,...o}=e,s=ab(r)?r:Oc,c=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return i.jsx(Z.div,{"data-orientation":s,...c,...o,ref:t})});kc.displayName=ob;function ab(e){return sb.includes(e)}var Mc=kc;const Mo=l.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>i.jsx(Mc,{ref:o,decorative:n,orientation:t,className:A("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Mo.displayName=Mc.displayName;var er="Dialog",[Dc,Mw]=Le(er),[ib,Ue]=Dc(er),Lc=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]=Qe({prop:r,defaultProp:o??!1,onChange:s,caller:er});return i.jsx(ib,{scope:t,triggerRef:c,contentRef:d,contentId:Fe(),titleId:Fe(),descriptionId:Fe(),open:f,onOpenChange:u,onOpenToggle:l.useCallback(()=>u(p=>!p),[u]),modal:a,children:n})};Lc.displayName=er;var Fc="DialogTrigger",$c=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(Fc,n),s=oe(t,o.triggerRef);return i.jsx(Z.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Fo(o.open),...r,ref:s,onClick:U(e.onClick,o.onOpenToggle)})});$c.displayName=Fc;var Do="DialogPortal",[cb,Bc]=Dc(Do,{forceMount:void 0}),Uc=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Ue(Do,t);return i.jsx(cb,{scope:t,forceMount:n,children:l.Children.map(r,a=>i.jsx(Te,{present:n||s.open,children:i.jsx(Ln,{asChild:!0,container:o,children:a})}))})};Uc.displayName=Do;var tr="DialogOverlay",zc=l.forwardRef((e,t)=>{const n=Bc(tr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Ue(tr,e.__scopeDialog);return s.modal?i.jsx(Te,{present:r||s.open,children:i.jsx(db,{...o,ref:t})}):null});zc.displayName=tr;var lb=Pe.createSlot("DialogOverlay.RemoveScroll"),db=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(tr,n);return i.jsx(Vn,{as:lb,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(Z.div,{"data-state":Fo(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),pt="DialogContent",Hc=l.forwardRef((e,t)=>{const n=Bc(pt,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Ue(pt,e.__scopeDialog);return i.jsx(Te,{present:r||s.open,children:s.modal?i.jsx(ub,{...o,ref:t}):i.jsx(fb,{...o,ref:t})})});Hc.displayName=pt;var ub=l.forwardRef((e,t)=>{const n=Ue(pt,e.__scopeDialog),r=l.useRef(null),o=oe(t,n.contentRef,r);return l.useEffect(()=>{const s=r.current;if(s)return ho(s)},[]),i.jsx(Wc,{...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())})}),fb=l.forwardRef((e,t)=>{const n=Ue(pt,e.__scopeDialog),r=l.useRef(!1),o=l.useRef(!1);return i.jsx(Wc,{...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()}})}),Wc=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=e,c=Ue(pt,n),d=l.useRef(null),f=oe(t,d);return jr(),i.jsxs(i.Fragment,{children:[i.jsx(En,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:i.jsx(Rt,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Fo(c.open),...a,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(pb,{titleId:c.titleId}),i.jsx(gb,{contentRef:d,descriptionId:c.descriptionId})]})]})}),Lo="DialogTitle",Vc=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(Lo,n);return i.jsx(Z.h2,{id:o.titleId,...r,ref:t})});Vc.displayName=Lo;var jc="DialogDescription",Rc=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(jc,n);return i.jsx(Z.p,{id:o.descriptionId,...r,ref:t})});Rc.displayName=jc;var Kc="DialogClose",Gc=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ue(Kc,n);return i.jsx(Z.button,{type:"button",...r,ref:t,onClick:U(e.onClick,()=>o.onOpenChange(!1))})});Gc.displayName=Kc;function Fo(e){return e?"open":"closed"}var qc="DialogTitleWarning",[Dw,Xc]=df(qc,{contentName:pt,titleName:Lo,docsSlug:"dialog"}),pb=({titleId:e})=>{const t=Xc(qc),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},fv="DialogDescriptionWarning",pv=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${qc(fv).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},hv=Dc,gv=Fc,mv=Bc,Xc=Uc,Yc=zc,Jc=Wc,Zc=Vc,vv=Kc;const Qc=hv,bv=gv,wv=mv,el=l.forwardRef(({className:e,...t},n)=>i.jsx(Xc,{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}));el.displayName=Xc.displayName;const yv=Dt.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"}}),$o=l.forwardRef(({side:e="right",className:t,children:n,...r},o)=>i.jsxs(wv,{children:[i.jsx(el,{}),i.jsxs(Yc,{ref:o,className:A(yv({side:e}),t),...r,children:[n,i.jsxs(vv,{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(K.X,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));$o.displayName=Yc.displayName;const tl=({className:e,...t})=>i.jsx("div",{className:A("flex flex-col space-y-2 text-center sm:text-left",e),...t});tl.displayName="SheetHeader";const nl=l.forwardRef(({className:e,...t},n)=>i.jsx(Jc,{ref:n,className:A("text-lg font-semibold text-foreground",e),...t}));nl.displayName=Jc.displayName;const rl=l.forwardRef(({className:e,...t},n)=>i.jsx(Zc,{ref:n,className:A("text-sm text-muted-foreground",e),...t}));rl.displayName=Zc.displayName;function ol({className:e,...t}){return i.jsx("div",{className:A("animate-pulse rounded-md bg-muted",e),...t})}var sl=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"}),xv="VisuallyHidden",al=l.forwardRef((e,t)=>i.jsx(Z.span,{...e,ref:t,style:{...sl,...e.style}}));al.displayName=xv;var Sv=al,[nr,kw]=Le("Tooltip",[Nt]),rr=Nt(),il="TooltipProvider",Cv=700,Bo="tooltip.open",[Ev,Uo]=nr(il),cl=e=>{const{__scopeTooltip:t,delayDuration:n=Cv,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(Ev,{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})};cl.displayName=il;var on="Tooltip",[Nv,or]=nr(on),ll=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:a,delayDuration:c}=e,d=Uo(on,e.__scopeTooltip),f=rr(t),[u,p]=l.useState(null),m=Fe(),b=l.useRef(0),g=a??d.disableHoverableContent,h=c??d.delayDuration,v=l.useRef(!1),[w,y]=Qe({prop:r,defaultProp:o??!1,onChange:N=>{N?(d.onOpen(),document.dispatchEvent(new CustomEvent(Bo))):d.onClose(),s==null||s(N)},caller:on}),x=l.useMemo(()=>w?v.current?"delayed-open":"instant-open":"closed",[w]),E=l.useCallback(()=>{window.clearTimeout(b.current),b.current=0,v.current=!1,y(!0)},[y]),C=l.useCallback(()=>{window.clearTimeout(b.current),b.current=0,y(!1)},[y]),O=l.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{v.current=!0,y(!0),b.current=0},h)},[h,y]);return l.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),i.jsx(ao,{...f,children:i.jsx(Nv,{scope:t,contentId:m,open:w,stateAttribute:x,trigger:u,onTriggerChange:p,onTriggerEnter:l.useCallback(()=>{d.isOpenDelayedRef.current?O():E()},[d.isOpenDelayedRef,O,E]),onTriggerLeave:l.useCallback(()=>{g?C():(window.clearTimeout(b.current),b.current=0)},[C,g]),onOpen:E,onClose:C,disableHoverableContent:g,children:n})})};ll.displayName=on;var zo="TooltipTrigger",dl=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=or(zo,n),s=Uo(zo,n),a=rr(n),c=l.useRef(null),d=re(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(io,{asChild:!0,...a,children:i.jsx(Z.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)})})});dl.displayName=zo;var Tv="TooltipPortal",[Dw,Av]=nr(Tv,{forceMount:void 0}),Ot="TooltipContent",ul=l.forwardRef((e,t)=>{const n=Av(Ot,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,a=or(Ot,e.__scopeTooltip);return i.jsx(Ne,{present:r||a.open,children:a.disableHoverableContent?i.jsx(fl,{side:o,...s,ref:t}):i.jsx(Pv,{side:o,...s,ref:t})})}),Pv=l.forwardRef((e,t)=>{const n=or(Ot,e.__scopeTooltip),r=Uo(Ot,e.__scopeTooltip),o=l.useRef(null),s=re(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]),b=l.useCallback((g,h)=>{const v=g.currentTarget,w={x:g.clientX,y:g.clientY},y=kv(w,v.getBoundingClientRect()),x=Dv(w,y),E=Lv(h.getBoundingClientRect()),C=$v([...x,...E]);c(C),p(!0)},[p]);return l.useEffect(()=>()=>m(),[m]),l.useEffect(()=>{if(d&&u){const g=v=>b(v,u),h=v=>b(v,d);return d.addEventListener("pointerleave",g),u.addEventListener("pointerleave",h),()=>{d.removeEventListener("pointerleave",g),u.removeEventListener("pointerleave",h)}}},[d,u,b,m]),l.useEffect(()=>{if(a){const g=h=>{const v=h.target,w={x:h.clientX,y:h.clientY},y=(d==null?void 0:d.contains(v))||(u==null?void 0:u.contains(v)),x=!Fv(w,a);y?m():x&&(m(),f())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[d,u,a,f,m]),i.jsx(fl,{...e,ref:s})}),[_v,Iv]=nr(on,{isInside:!1}),Ov=Pe.createSlottable("TooltipContent"),fl=l.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:a,...c}=e,d=or(Ot,n),f=rr(n),{onClose:u}=d;return l.useEffect(()=>(document.addEventListener(Bo,u),()=>document.removeEventListener(Bo,u)),[u]),l.useEffect(()=>{if(d.trigger){const p=m=>{const b=m.target;b!=null&&b.contains(d.trigger)&&u()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[d.trigger,u]),i.jsx(jt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:p=>p.preventDefault(),onDismiss:u,children:i.jsxs(co,{"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(Ov,{children:r}),i.jsx(_v,{scope:n,isInside:!0,children:i.jsx(Sv,{id:d.contentId,role:"tooltip",children:o||r})})]})})});ul.displayName=Ot;var pl="TooltipArrow",Mv=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=rr(n);return Iv(pl,n).isInside?null:i.jsx(lo,{...o,...r,ref:t})});Mv.displayName=pl;function kv(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 Dv(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 Lv(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 Fv(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 $v(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 Uv=cl,zv=ll,Hv=dl,hl=ul;const Wv=Uv,Rv=zv,Vv=Hv,gl=l.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(hl,{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}));gl.displayName=hl.displayName;const jv="sidebar:state",Kv=60*60*24*7,Gv="16rem",qv="18rem",Xv="3rem",Yv="b",ml=l.createContext(null);function sr(){const e=l.useContext(ml);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const vl=l.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:o,children:s,...a},c)=>{const d=tv(),[f,u]=l.useState(!1),[p,m]=l.useState(e),b=t??p,g=l.useCallback(y=>{const x=typeof y=="function"?y(b):y;n?n(x):m(x),document.cookie=`${jv}=${x}; path=/; max-age=${Kv}`},[n,b]),h=l.useCallback(()=>d?u(y=>!y):g(y=>!y),[d,g,u]);l.useEffect(()=>{const y=x=>{x.key===Yv&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),h())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[h]);const v=b?"expanded":"collapsed",w=l.useMemo(()=>({state:v,open:b,setOpen:g,isMobile:d,openMobile:f,setOpenMobile:u,toggleSidebar:h}),[v,b,g,d,f,u,h]);return i.jsx(ml.Provider,{value:w,children:i.jsx(Wv,{delayDuration:0,children:i.jsx("div",{style:{"--sidebar-width":Gv,"--sidebar-width-icon":Xv,...o},className:A("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:c,...a,children:s})})})});vl.displayName="SidebarProvider";const bl=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}=sr();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(Qc,{open:f,onOpenChange:u,...s,children:i.jsx($o,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":qv},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})})]})});bl.displayName="Sidebar";const wl=l.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:o}=sr();return i.jsxs(fe,{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(K.PanelLeft,{}),i.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});wl.displayName="SidebarTrigger";const Jv=l.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=sr();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})});Jv.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 Zv=l.forwardRef(({className:e,...t},n)=>i.jsx(nn,{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}));Zv.displayName="SidebarInput";const xl=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}));xl.displayName="SidebarHeader";const Qv=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}));Qv.displayName="SidebarFooter";const eb=l.forwardRef(({className:e,...t},n)=>i.jsx(ko,{ref:n,"data-sidebar":"separator",className:A("mx-2 w-auto bg-sidebar-border",e),...t}));eb.displayName="SidebarSeparator";const Sl=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}));Sl.displayName="SidebarContent";const Cl=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}));Cl.displayName="SidebarGroup";const El=l.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Pe.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})});El.displayName="SidebarGroupLabel";const tb=l.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Pe.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})});tb.displayName="SidebarGroupAction";const Nl=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"group-content",className:A("w-full text-sm",e),...t}));Nl.displayName="SidebarGroupContent";const Tl=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}));Tl.displayName="SidebarMenu";const Al=l.forwardRef(({className:e,...t},n)=>i.jsx("li",{ref:n,"data-sidebar":"menu-item",className:A("group/menu-item relative",e),...t}));Al.displayName="SidebarMenuItem";const nb=Dt.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"}}),Pl=l.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:o,className:s,...a},c)=>{const d=e?Pe.Slot:"button",{isMobile:f,state:u}=sr(),p=i.jsx(d,{ref:c,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:A(nb({variant:n,size:r}),s),...a});return o?(typeof o=="string"&&(o={children:o}),i.jsxs(Rv,{children:[i.jsx(Vv,{asChild:!0,children:p}),i.jsx(gl,{side:"right",align:"center",hidden:u!=="collapsed"||f,...o})]})):p});Pl.displayName="SidebarMenuButton";const rb=l.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},o)=>{const s=t?Pe.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})});rb.displayName="SidebarMenuAction";const ob=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}));ob.displayName="SidebarMenuBadge";const sb=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(ol,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),i.jsx(ol,{className:"h-4 flex-1 max-w-[--skeleton-width]","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});sb.displayName="SidebarMenuSkeleton";const ab=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}));ab.displayName="SidebarMenuSub";const ib=l.forwardRef(({...e},t)=>i.jsx("li",{ref:t,...e}));ib.displayName="SidebarMenuSubItem";const cb=l.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...o},s)=>{const a=e?Pe.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})});cb.displayName="SidebarMenuSubButton";function lb({header:e,sidebarTitle:t="Threads",showThreads:n=!0,className:r="",sidebarClassName:o="",chatClassName:s="",...a}){return i.jsx(Ht,{...a,children:i.jsxs(vl,{className:`w-full ${r}`,children:[i.jsxs(bl,{className:`border-r ${o}`,children:[i.jsx(xl,{children:i.jsx(Tl,{children:i.jsx(Al,{children:i.jsx(Pl,{size:"lg",children:i.jsx("span",{className:"font-semibold",children:t})})})})}),i.jsx(Sl,{children:n&&i.jsxs(Cl,{children:[i.jsx(El,{children:"Conversations"}),i.jsx(Nl,{children:i.jsx("div",{className:"px-2 py-1",children:i.jsx(Qn,{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(wl,{}),i.jsx("div",{className:"flex-1"}),e]}),i.jsx("main",{className:`flex-1 min-h-0 overflow-hidden ${s}`,children:i.jsx(tn,{})})]})]})})}var db="Label",_l=l.forwardRef((e,t)=>i.jsx(Z.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())}}));_l.displayName=db;var Il=_l;const ub=Dt.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ke=l.forwardRef(({className:e,...t},n)=>i.jsx(Il,{ref:n,className:A(ub(),e),...t}));ke.displayName=Il.displayName;function Ol(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 ar="Switch",[fb,Lw]=Le(ar),[pb,hb]=fb(ar),Ml=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,b]=l.useState(null),g=re(t,x=>b(x)),h=l.useRef(!1),v=m?u||!!m.closest("form"):!0,[w,y]=Qe({prop:o,defaultProp:s??!1,onChange:f,caller:ar});return i.jsxs(pb,{scope:n,checked:w,disabled:c,children:[i.jsx(Z.button,{type:"button",role:"switch","aria-checked":w,"aria-required":a,"data-state":Fl(w),"data-disabled":c?"":void 0,disabled:c,value:d,...p,ref:g,onClick:U(e.onClick,x=>{y(E=>!E),v&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})}),v&&i.jsx(Ll,{control:m,bubbles:!h.current,name:r,value:d,checked:w,required:a,disabled:c,form:u,style:{transform:"translateX(-100%)"}})]})});Ml.displayName=ar;var kl="SwitchThumb",Dl=l.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=hb(kl,n);return i.jsx(Z.span,{"data-state":Fl(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Dl.displayName=kl;var gb="SwitchBubbleInput",Ll=l.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const a=l.useRef(null),c=re(a,s),d=Ol(n),f=Ba(t);return l.useEffect(()=>{const u=a.current;if(!u)return;const p=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(p,"checked").set;if(d!==n&&b){const g=new Event("click",{bubbles:r});b.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}})});Ll.displayName=gb;function Fl(e){return e?"checked":"unchecked"}var $l=Ml,mb=Dl;const rt=l.forwardRef(({className:e,...t},n)=>i.jsx($l,{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(mb,{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")})}));rt.displayName=$l.displayName;var vb=[" ","Enter","ArrowUp","ArrowDown"],bb=[" ","Enter"],ht="Select",[ir,cr,wb]=Hr(ht),[Mt,Fw]=Le(ht,[wb,Nt]),lr=Nt(),[yb,ot]=Mt(ht),[xb,Sb]=Mt(ht),Bl=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:b,form:g}=e,h=lr(t),[v,w]=l.useState(null),[y,x]=l.useState(null),[E,C]=l.useState(!1),O=Cn(f),[N,L]=Qe({prop:r,defaultProp:o??!1,onChange:s,caller:ht}),[k,D]=Qe({prop:a,defaultProp:c,onChange:d,caller:ht}),j=l.useRef(null),G=v?g||!!v.closest("form"):!0,[R,z]=l.useState(new Set),X=Array.from(R).map(F=>F.props.value).join(";");return i.jsx(ao,{...h,children:i.jsxs(yb,{required:b,scope:t,trigger:v,onTriggerChange:w,valueNode:y,onValueNodeChange:x,valueNodeHasChildren:E,onValueNodeHasChildrenChange:C,contentId:Fe(),value:k,onValueChange:D,open:N,onOpenChange:L,dir:O,triggerPointerDownPosRef:j,disabled:m,children:[i.jsx(ir.Provider,{scope:t,children:i.jsx(xb,{scope:e.__scopeSelect,onNativeOptionAdd:l.useCallback(F=>{z(q=>new Set(q).add(F))},[]),onNativeOptionRemove:l.useCallback(F=>{z(q=>{const T=new Set(q);return T.delete(F),T})},[]),children:n})}),G?i.jsxs(cd,{"aria-hidden":!0,required:b,tabIndex:-1,name:u,autoComplete:p,value:k,onChange:F=>D(F.target.value),disabled:m,form:g,children:[k===void 0?i.jsx("option",{value:""}):null,Array.from(R)]},X):null]})})};Bl.displayName=ht;var Ul="SelectTrigger",zl=l.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=lr(n),a=ot(Ul,n),c=a.disabled||r,d=re(t,a.onTriggerChange),f=cr(n),u=l.useRef("touch"),[p,m,b]=dd(h=>{const v=f().filter(x=>!x.disabled),w=v.find(x=>x.value===a.value),y=ud(v,h,w);y!==void 0&&a.onValueChange(y.value)}),g=h=>{c||(a.onOpenChange(!0),b()),h&&(a.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return i.jsx(io,{asChild:!0,...s,children:i.jsx(Z.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":ld(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 v=h.target;v.hasPointerCapture(h.pointerId)&&v.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(g(h),h.preventDefault())}),onKeyDown:U(o.onKeyDown,h=>{const v=p.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&m(h.key),!(v&&h.key===" ")&&vb.includes(h.key)&&(g(),h.preventDefault())})})})});zl.displayName=Ul;var Hl="SelectValue",Wl=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:a="",...c}=e,d=ot(Hl,n),{onValueNodeHasChildrenChange:f}=d,u=s!==void 0,p=re(t,d.onValueNodeChange);return ve(()=>{f(u)},[f,u]),i.jsx(Z.span,{...c,ref:p,style:{pointerEvents:"none"},children:ld(d.value)?i.jsx(i.Fragment,{children:a}):s})});Wl.displayName=Hl;var Cb="SelectIcon",Rl=l.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return i.jsx(Z.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Rl.displayName=Cb;var Eb="SelectPortal",Vl=e=>i.jsx(Ln,{asChild:!0,...e});Vl.displayName=Eb;var gt="SelectContent",jl=l.forwardRef((e,t)=>{const n=ot(gt,e.__scopeSelect),[r,o]=l.useState();if(ve(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?cn.createPortal(i.jsx(Kl,{scope:e.__scopeSelect,children:i.jsx(ir.Slot,{scope:e.__scopeSelect,children:i.jsx("div",{children:e.children})})}),s):null}return i.jsx(Gl,{...e,ref:t})});jl.displayName=gt;var ze=10,[Kl,st]=Mt(gt),Nb="SelectContentImpl",Tb=Pe.createSlot("SelectContent.RemoveScroll"),Gl=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:b,sticky:g,hideWhenDetached:h,avoidCollisions:v,...w}=e,y=ot(gt,n),[x,E]=l.useState(null),[C,O]=l.useState(null),N=re(t,V=>E(V)),[L,k]=l.useState(null),[D,j]=l.useState(null),G=cr(n),[R,z]=l.useState(!1),X=l.useRef(!1);l.useEffect(()=>{if(x)return ho(x)},[x]),Vr();const F=l.useCallback(V=>{const[se,...le]=G().map(ee=>ee.ref.current),[ae]=le.slice(-1),W=document.activeElement;for(const ee of V)if(ee===W||(ee==null||ee.scrollIntoView({block:"nearest"}),ee===se&&C&&(C.scrollTop=0),ee===ae&&C&&(C.scrollTop=C.scrollHeight),ee==null||ee.focus(),document.activeElement!==W))return},[G,C]),q=l.useCallback(()=>F([L,x]),[F,L,x]);l.useEffect(()=>{R&&q()},[R,q]);const{onOpenChange:T,triggerPointerDownPosRef:_}=y;l.useEffect(()=>{if(x){let V={x:0,y:0};const se=ae=>{var W,ee;V={x:Math.abs(Math.round(ae.pageX)-(((W=_.current)==null?void 0:W.x)??0)),y:Math.abs(Math.round(ae.pageY)-(((ee=_.current)==null?void 0:ee.y)??0))}},le=ae=>{V.x<=10&&V.y<=10?ae.preventDefault():x.contains(ae.target)||T(!1),document.removeEventListener("pointermove",se),_.current=null};return _.current!==null&&(document.addEventListener("pointermove",se),document.addEventListener("pointerup",le,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",se),document.removeEventListener("pointerup",le,{capture:!0})}}},[x,T,_]),l.useEffect(()=>{const V=()=>T(!1);return window.addEventListener("blur",V),window.addEventListener("resize",V),()=>{window.removeEventListener("blur",V),window.removeEventListener("resize",V)}},[T]);const[I,M]=dd(V=>{const se=G().filter(W=>!W.disabled),le=se.find(W=>W.ref.current===document.activeElement),ae=ud(se,V,le);ae&&setTimeout(()=>ae.ref.current.focus())}),Y=l.useCallback((V,se,le)=>{const ae=!X.current&&!le;(y.value!==void 0&&y.value===se||ae)&&(k(V),ae&&(X.current=!0))},[y.value]),B=l.useCallback(()=>x==null?void 0:x.focus(),[x]),H=l.useCallback((V,se,le)=>{const ae=!X.current&&!le;(y.value!==void 0&&y.value===se||ae)&&j(V)},[y.value]),de=r==="popper"?Ho:ql,ie=de===Ho?{side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:p,collisionBoundary:m,collisionPadding:b,sticky:g,hideWhenDetached:h,avoidCollisions:v}:{};return i.jsx(Kl,{scope:n,content:x,viewport:C,onViewportChange:O,itemRefCallback:Y,selectedItem:L,onItemLeave:B,itemTextRefCallback:H,focusSelectedItem:q,selectedItemText:D,position:r,isPositioned:R,searchRef:I,children:i.jsx(Rn,{as:Tb,allowPinchZoom:!0,children:i.jsx(En,{asChild:!0,trapped:y.open,onMountAutoFocus:V=>{V.preventDefault()},onUnmountAutoFocus:U(o,V=>{var se;(se=y.trigger)==null||se.focus({preventScroll:!0}),V.preventDefault()}),children:i.jsx(jt,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:V=>V.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:i.jsx(de,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:V=>V.preventDefault(),...w,...ie,onPlaced:()=>z(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:U(w.onKeyDown,V=>{const se=V.ctrlKey||V.altKey||V.metaKey;if(V.key==="Tab"&&V.preventDefault(),!se&&V.key.length===1&&M(V.key),["ArrowUp","ArrowDown","Home","End"].includes(V.key)){let ae=G().filter(W=>!W.disabled).map(W=>W.ref.current);if(["ArrowUp","End"].includes(V.key)&&(ae=ae.slice().reverse()),["ArrowUp","ArrowDown"].includes(V.key)){const W=V.target,ee=ae.indexOf(W);ae=ae.slice(ee+1)}setTimeout(()=>F(ae)),V.preventDefault()}})})})})})})});Gl.displayName=Nb;var Ab="SelectItemAlignedPosition",ql=l.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=ot(gt,n),a=st(gt,n),[c,d]=l.useState(null),[f,u]=l.useState(null),p=re(t,N=>u(N)),m=cr(n),b=l.useRef(!1),g=l.useRef(!0),{viewport:h,selectedItem:v,selectedItemText:w,focusSelectedItem:y}=a,x=l.useCallback(()=>{if(s.trigger&&s.valueNode&&c&&f&&h&&v&&w){const N=s.trigger.getBoundingClientRect(),L=f.getBoundingClientRect(),k=s.valueNode.getBoundingClientRect(),D=w.getBoundingClientRect();if(s.dir!=="rtl"){const W=D.left-L.left,ee=k.left-W,pe=N.left-ee,he=N.width+pe,J=Math.max(he,L.width),be=window.innerWidth-ze,ce=Ao(ee,[ze,Math.max(ze,be-J)]);c.style.minWidth=he+"px",c.style.left=ce+"px"}else{const W=L.right-D.right,ee=window.innerWidth-k.right-W,pe=window.innerWidth-N.right-ee,he=N.width+pe,J=Math.max(he,L.width),be=window.innerWidth-ze,ce=Ao(ee,[ze,Math.max(ze,be-J)]);c.style.minWidth=he+"px",c.style.right=ce+"px"}const j=m(),G=window.innerHeight-ze*2,R=h.scrollHeight,z=window.getComputedStyle(f),X=parseInt(z.borderTopWidth,10),F=parseInt(z.paddingTop,10),q=parseInt(z.borderBottomWidth,10),T=parseInt(z.paddingBottom,10),_=X+F+R+T+q,I=Math.min(v.offsetHeight*5,_),M=window.getComputedStyle(h),Y=parseInt(M.paddingTop,10),B=parseInt(M.paddingBottom,10),H=N.top+N.height/2-ze,de=G-H,ie=v.offsetHeight/2,V=v.offsetTop+ie,se=X+F+V,le=_-se;if(se<=H){const W=j.length>0&&v===j[j.length-1].ref.current;c.style.bottom="0px";const ee=f.clientHeight-h.offsetTop-h.offsetHeight,pe=Math.max(de,ie+(W?B:0)+ee+q),he=se+pe;c.style.height=he+"px"}else{const W=j.length>0&&v===j[0].ref.current;c.style.top="0px";const pe=Math.max(H,X+h.offsetTop+(W?Y:0)+ie)+le;c.style.height=pe+"px",h.scrollTop=se-H+h.offsetTop}c.style.margin=`${ze}px 0`,c.style.minHeight=I+"px",c.style.maxHeight=G+"px",r==null||r(),requestAnimationFrame(()=>b.current=!0)}},[m,s.trigger,s.valueNode,c,f,h,v,w,s.dir,r]);ve(()=>x(),[x]);const[E,C]=l.useState();ve(()=>{f&&C(window.getComputedStyle(f).zIndex)},[f]);const O=l.useCallback(N=>{N&&g.current===!0&&(x(),y==null||y(),g.current=!1)},[x,y]);return i.jsx(_b,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:b,onScrollButtonChange:O,children:i.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:i.jsx(Z.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});ql.displayName=Ab;var Pb="SelectPopperPosition",Ho=l.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=ze,...s}=e,a=lr(n);return i.jsx(co,{...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)"}})});Ho.displayName=Pb;var[_b,Wo]=Mt(gt,{}),Ro="SelectViewport",Xl=l.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=st(Ro,n),a=Wo(Ro,n),c=re(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(ir.Slot,{scope:n,children:i.jsx(Z.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 b=Math.abs(d.current-u.scrollTop);if(b>0){const g=window.innerHeight-ze*2,h=parseFloat(p.style.minHeight),v=parseFloat(p.style.height),w=Math.max(h,v);if(w<g){const y=w+b,x=Math.min(g,y),E=y-x;p.style.height=x+"px",p.style.bottom==="0px"&&(u.scrollTop=E>0?E:0,p.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})});Xl.displayName=Ro;var Yl="SelectGroup",[Ib,Ob]=Mt(Yl),Mb=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Fe();return i.jsx(Ib,{scope:n,id:o,children:i.jsx(Z.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Mb.displayName=Yl;var Jl="SelectLabel",Zl=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ob(Jl,n);return i.jsx(Z.div,{id:o.id,...r,ref:t})});Zl.displayName=Jl;var dr="SelectItem",[kb,Ql]=Mt(dr),ed=l.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...a}=e,c=ot(dr,n),d=st(dr,n),f=c.value===r,[u,p]=l.useState(s??""),[m,b]=l.useState(!1),g=re(t,y=>{var x;return(x=d.itemRefCallback)==null?void 0:x.call(d,y,r,o)}),h=Fe(),v=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(kb,{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(ir.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:i.jsx(Z.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,()=>b(!0)),onBlur:U(a.onBlur,()=>b(!1)),onClick:U(a.onClick,()=>{v.current!=="mouse"&&w()}),onPointerUp:U(a.onPointerUp,()=>{v.current==="mouse"&&w()}),onPointerDown:U(a.onPointerDown,y=>{v.current=y.pointerType}),onPointerMove:U(a.onPointerMove,y=>{var x;v.current=y.pointerType,o?(x=d.onItemLeave)==null||x.call(d):v.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 E;((E=d.searchRef)==null?void 0:E.current)!==""&&y.key===" "||(bb.includes(y.key)&&w(),y.key===" "&&y.preventDefault())})})})})});ed.displayName=dr;var sn="SelectItemText",td=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,a=ot(sn,n),c=st(sn,n),d=Ql(sn,n),f=Sb(sn,n),[u,p]=l.useState(null),m=re(t,w=>p(w),d.onItemTextChange,w=>{var y;return(y=c.itemTextRefCallback)==null?void 0:y.call(c,w,d.value,d.disabled)}),b=u==null?void 0:u.textContent,g=l.useMemo(()=>i.jsx("option",{value:d.value,disabled:d.disabled,children:b},d.value),[d.disabled,d.value,b]),{onNativeOptionAdd:h,onNativeOptionRemove:v}=f;return ve(()=>(h(g),()=>v(g)),[h,v,g]),i.jsxs(i.Fragment,{children:[i.jsx(Z.span,{id:d.textId,...s,ref:m}),d.isSelected&&a.valueNode&&!a.valueNodeHasChildren?cn.createPortal(s.children,a.valueNode):null]})});td.displayName=sn;var nd="SelectItemIndicator",rd=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Ql(nd,n).isSelected?i.jsx(Z.span,{"aria-hidden":!0,...r,ref:t}):null});rd.displayName=nd;var Vo="SelectScrollUpButton",od=l.forwardRef((e,t)=>{const n=st(Vo,e.__scopeSelect),r=Wo(Vo,e.__scopeSelect),[o,s]=l.useState(!1),a=re(t,r.onScrollButtonChange);return ve(()=>{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(ad,{...e,ref:a,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});od.displayName=Vo;var jo="SelectScrollDownButton",sd=l.forwardRef((e,t)=>{const n=st(jo,e.__scopeSelect),r=Wo(jo,e.__scopeSelect),[o,s]=l.useState(!1),a=re(t,r.onScrollButtonChange);return ve(()=>{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(ad,{...e,ref:a,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});sd.displayName=jo;var ad=l.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=st("SelectScrollButton",n),a=l.useRef(null),c=cr(n),d=l.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return l.useEffect(()=>()=>d(),[d]),ve(()=>{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(Z.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()})})}),Db="SelectSeparator",id=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return i.jsx(Z.div,{"aria-hidden":!0,...r,ref:t})});id.displayName=Db;var Ko="SelectArrow",Lb=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=lr(n),s=ot(Ko,n),a=st(Ko,n);return s.open&&a.position==="popper"?i.jsx(lo,{...o,...r,ref:t}):null});Lb.displayName=Ko;var Fb="SelectBubbleInput",cd=l.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=l.useRef(null),s=re(r,o),a=Ol(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(Z.select,{...n,style:{...sl,...n.style},ref:s,defaultValue:t})});cd.displayName=Fb;function ld(e){return e===""||e===void 0}function dd(e){const t=we(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 ud(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=$b(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 $b(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Bb=Bl,fd=zl,Ub=Wl,zb=Rl,Hb=Vl,pd=jl,Wb=Xl,hd=Zl,gd=ed,Rb=td,Vb=rd,md=od,vd=sd,bd=id;const wd=Bb,yd=Ub,Go=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(fd,{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(zb,{asChild:!0,children:i.jsx(K.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Go.displayName=fd.displayName;const xd=l.forwardRef(({className:e,...t},n)=>i.jsx(md,{ref:n,className:A("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(K.ChevronUp,{className:"h-4 w-4"})}));xd.displayName=md.displayName;const Sd=l.forwardRef(({className:e,...t},n)=>i.jsx(vd,{ref:n,className:A("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(K.ChevronDown,{className:"h-4 w-4"})}));Sd.displayName=vd.displayName;const qo=l.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>i.jsx(Hb,{children:i.jsxs(pd,{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(xd,{}),i.jsx(Wb,{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(Sd,{})]})}));qo.displayName=pd.displayName;const jb=l.forwardRef(({className:e,...t},n)=>i.jsx(hd,{ref:n,className:A("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));jb.displayName=hd.displayName;const mt=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(gd,{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(Vb,{children:i.jsx(K.Check,{className:"h-4 w-4"})})}),i.jsx(Rb,{children:t})]}));mt.displayName=gd.displayName;const Kb=l.forwardRef(({className:e,...t},n)=>i.jsx(bd,{ref:n,className:A("-mx-1 my-1 h-px bg-muted",e),...t}));Kb.displayName=bd.displayName;const ur=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}));ur.displayName="Card";const fr=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("flex flex-col space-y-1.5 p-6",e),...t}));fr.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 Gb=l.forwardRef(({className:e,...t},n)=>i.jsx("p",{ref:n,className:A("text-sm text-muted-foreground",e),...t}));Gb.displayName="CardDescription";const hr=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("p-6 pt-0",e),...t}));hr.displayName="CardContent";const qb=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("flex items-center p-6 pt-0",e),...t}));qb.displayName="CardFooter";const Xb=1,Yb=1e6;let Xo=0;function Jb(){return Xo=(Xo+1)%Number.MAX_SAFE_INTEGER,Xo.toString()}const Yo=new Map,Cd=e=>{if(Yo.has(e))return;const t=setTimeout(()=>{Yo.delete(e),an({type:"REMOVE_TOAST",toastId:e})},Yb);Yo.set(e,t)},Zb=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Xb)};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?Cd(n):e.toasts.forEach(r=>{Cd(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)}}},gr=[];let mr={toasts:[]};function an(e){mr=Zb(mr,e),gr.forEach(t=>{t(mr)})}function Qb({...e}){const t=Jb(),n=o=>an({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>an({type:"DISMISS_TOAST",toastId:t});return an({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function ew(){const[e,t]=l.useState(mr);return l.useEffect(()=>(gr.push(t),()=>{const n=gr.indexOf(t);n>-1&&gr.splice(n,1)}),[e]),{...e,toast:Qb,dismiss:n=>an({type:"DISMISS_TOAST",toastId:n})}}const tw={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 nw({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=P.useState(!1),[s,a]=P.useState(!1),[c,d]=P.useState(e),[f,u]=P.useState(!1),{toast:p}=ew();P.useEffect(()=>{const v=JSON.stringify(c)!==JSON.stringify(e);u(v)},[c,e]),P.useEffect(()=>{d(e)},[e]);const m=()=>{t(c),u(!1),p({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},b=()=>{d(tw),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(Qc,{open:r,onOpenChange:o,children:[i.jsx(bv,{asChild:!0,children:i.jsxs(fe,{variant:"outline",size:"sm",className:n,children:[i.jsx(K.Settings,{className:"h-4 w-4 mr-2"}),"Settings",f&&i.jsx(Xs,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),i.jsxs($o,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[i.jsxs(tl,{children:[i.jsx(nl,{children:"Chat Settings"}),i.jsx(rl,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),i.jsxs("div",{className:"space-y-6 py-6",children:[i.jsxs(ur,{children:[i.jsx(fr,{className:"pb-3",children:i.jsxs(pr,{className:"text-lg flex items-center gap-2",children:[i.jsx(K.Server,{className:"h-5 w-5"}),"API Configuration"]})}),i.jsxs(hr,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(ke,{htmlFor:"api-url",children:"API Base URL"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(nn,{id:"api-url",value:c.api.baseUrl,onChange:v=>d(w=>({...w,api:{...w.api,baseUrl:v.target.value}})),placeholder:"http://localhost:8000/api"}),i.jsx(fe,{variant:"outline",onClick:h,children:"Test"})]})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(ke,{htmlFor:"enable-auth",children:"Enable Authentication"}),i.jsx(rt,{id:"enable-auth",checked:c.api.enableAuth,onCheckedChange:v=>d(w=>({...w,api:{...w.api,enableAuth:v}}))})]}),c.api.enableAuth&&i.jsxs("div",{className:"space-y-2",children:[i.jsx(ke,{htmlFor:"auth-token",children:"Authentication Token"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(nn,{id:"auth-token",type:s?"text":"password",value:c.api.authToken,onChange:v=>d(w=>({...w,api:{...w.api,authToken:v.target.value}})),placeholder:"Enter your Bearer token"}),i.jsx(fe,{variant:"outline",size:"icon",onClick:()=>a(!s),children:s?i.jsx(K.EyeOff,{className:"h-4 w-4"}):i.jsx(K.Eye,{className:"h-4 w-4"})})]})]})]})]}),i.jsxs(ur,{children:[i.jsx(fr,{className:"pb-3",children:i.jsxs(pr,{className:"text-lg flex items-center gap-2",children:[i.jsx(K.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),i.jsxs(hr,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(ke,{htmlFor:"layout",children:"Layout Style"}),i.jsxs(wd,{value:c.ui.layout,onValueChange:v=>d(w=>({...w,ui:{...w.ui,layout:v}})),children:[i.jsx(Go,{children:i.jsx(yd,{})}),i.jsxs(qo,{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(ke,{htmlFor:"theme",children:"Theme"}),i.jsxs(wd,{value:c.ui.theme,onValueChange:v=>d(w=>({...w,ui:{...w.ui,theme:v}})),children:[i.jsx(Go,{children:i.jsx(yd,{})}),i.jsxs(qo,{children:[i.jsx(mt,{value:"light",children:"Light"}),i.jsx(mt,{value:"dark",children:"Dark"}),i.jsx(mt,{value:"system",children:"System"})]})]})]}),i.jsx(ko,{}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(ke,{htmlFor:"show-timestamps",children:"Show Timestamps"}),i.jsx(rt,{id:"show-timestamps",checked:c.ui.showTimestamps,onCheckedChange:v=>d(w=>({...w,ui:{...w.ui,showTimestamps:v}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(ke,{htmlFor:"show-agent-names",children:"Show Agent Names"}),i.jsx(rt,{id:"show-agent-names",checked:c.ui.showAgentNames,onCheckedChange:v=>d(w=>({...w,ui:{...w.ui,showAgentNames:v}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(ke,{htmlFor:"compact-messages",children:"Compact Messages"}),i.jsx(rt,{id:"compact-messages",checked:c.ui.compactMessages,onCheckedChange:v=>d(w=>({...w,ui:{...w.ui,compactMessages:v}}))})]})]})]})]}),i.jsxs(ur,{children:[i.jsx(fr,{className:"pb-3",children:i.jsxs(pr,{className:"text-lg flex items-center gap-2",children:[i.jsx(K.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),i.jsxs(hr,{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(ke,{htmlFor:"auto-save",children:"Auto-save Conversations"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),i.jsx(rt,{id:"auto-save",checked:c.behavior.autoSave,onCheckedChange:v=>d(w=>({...w,behavior:{...w.behavior,autoSave:v}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(ke,{htmlFor:"enable-streaming",children:"Enable Streaming"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),i.jsx(rt,{id:"enable-streaming",checked:c.behavior.enableStreaming,onCheckedChange:v=>d(w=>({...w,behavior:{...w.behavior,enableStreaming:v}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(ke,{htmlFor:"typing-indicator",children:"Typing Indicator"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),i.jsx(rt,{id:"typing-indicator",checked:c.behavior.showTypingIndicator,onCheckedChange:v=>d(w=>({...w,behavior:{...w.behavior,showTypingIndicator:v}}))})]})]})]})]}),i.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[i.jsxs(fe,{variant:"outline",onClick:b,children:[i.jsx(K.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(fe,{variant:"outline",onClick:g,children:"Cancel"}),i.jsxs(fe,{onClick:m,disabled:!f,children:[i.jsx(K.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function rw({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=P.useCallback(f=>{var u;(u=s.onThreadChange)==null||u.call(s,f)},[s.onThreadChange]);return e==="fullscreen"?i.jsx(Ht,{...s,onThreadChange:d,children:i.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:c(t),children:i.jsx(tn,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?i.jsx(Ht,{...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(Qn,{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(tn,{onError:s.onError,enableFileUpload:!0})})]})})}):i.jsx(Ht,{...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(Qn,{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(tn,{onError:s.onError,enableFileUpload:!0})})]})})}Q.Api=yn,Q.ApiClient=yn,Q.ChatApi=yn,Q.ChatInterface=tn,Q.ChatMainLayout=lb,Q.ChatProvider=Ht,Q.ChatRoutingProvider=Gm,Q.ChatSettings=nw,Q.MarkdownContent=Wt,Q.MessageComponent=ra,Q.ThreadManager=Qn,Q.apiClient=Ye,Q.applySettings=ev,Q.chatApiClient=Ye,Q.default=rw,Q.del=Ws,Q.get=lt,Q.getChatToken=Or,Q.getCurrentSettings=Qm,Q.getDefaultApiConfig=Ac,Q.getDefaultChatSettings=Pc,Q.onChatTokenChanged=zs,Q.post=kr,Q.put=Hs,Q.setChatToken=Mr,Q.stream=Ju,Q.useChat=Lr,Q.useChatRouting=qm,Q.useChatStream=Rs,Q.useMessagesReducer=Vs,Object.defineProperties(Q,{__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},hb="DialogDescriptionWarning",gb=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Xc(hb).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},mb=Lc,bb=$c,vb=Uc,Yc=zc,Jc=Hc,Zc=Vc,Qc=Rc,wb=Gc;const el=mb,yb=bb,xb=vb,tl=l.forwardRef(({className:e,...t},n)=>i.jsx(Yc,{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}));tl.displayName=Yc.displayName;const Sb=Lt.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"}}),$o=l.forwardRef(({side:e="right",className:t,children:n,...r},o)=>i.jsxs(xb,{children:[i.jsx(tl,{}),i.jsxs(Jc,{ref:o,className:A(Sb({side:e}),t),...r,children:[n,i.jsxs(wb,{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(K.X,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));$o.displayName=Jc.displayName;const nl=({className:e,...t})=>i.jsx("div",{className:A("flex flex-col space-y-2 text-center sm:text-left",e),...t});nl.displayName="SheetHeader";const rl=l.forwardRef(({className:e,...t},n)=>i.jsx(Zc,{ref:n,className:A("text-lg font-semibold text-foreground",e),...t}));rl.displayName=Zc.displayName;const ol=l.forwardRef(({className:e,...t},n)=>i.jsx(Qc,{ref:n,className:A("text-sm text-muted-foreground",e),...t}));ol.displayName=Qc.displayName;function sl({className:e,...t}){return i.jsx("div",{className:A("animate-pulse rounded-md bg-muted",e),...t})}var al=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"}),Cb="VisuallyHidden",il=l.forwardRef((e,t)=>i.jsx(Z.span,{...e,ref:t,style:{...al,...e.style}}));il.displayName=Cb;var Eb=il,[nr,Lw]=Le("Tooltip",[Tt]),rr=Tt(),cl="TooltipProvider",Nb=700,Bo="tooltip.open",[Tb,Uo]=nr(cl),ll=e=>{const{__scopeTooltip:t,delayDuration:n=Nb,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(Tb,{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})};ll.displayName=cl;var on="Tooltip",[Ab,or]=nr(on),dl=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:a,delayDuration:c}=e,d=Uo(on,e.__scopeTooltip),f=rr(t),[u,p]=l.useState(null),m=Fe(),v=l.useRef(0),g=a??d.disableHoverableContent,h=c??d.delayDuration,b=l.useRef(!1),[w,y]=Qe({prop:r,defaultProp:o??!1,onChange:N=>{N?(d.onOpen(),document.dispatchEvent(new CustomEvent(Bo))):d.onClose(),s==null||s(N)},caller:on}),x=l.useMemo(()=>w?b.current?"delayed-open":"instant-open":"closed",[w]),E=l.useCallback(()=>{window.clearTimeout(v.current),v.current=0,b.current=!1,y(!0)},[y]),C=l.useCallback(()=>{window.clearTimeout(v.current),v.current=0,y(!1)},[y]),O=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(ao,{...f,children:i.jsx(Ab,{scope:t,contentId:m,open:w,stateAttribute:x,trigger:u,onTriggerChange:p,onTriggerEnter:l.useCallback(()=>{d.isOpenDelayedRef.current?O():E()},[d.isOpenDelayedRef,O,E]),onTriggerLeave:l.useCallback(()=>{g?C():(window.clearTimeout(v.current),v.current=0)},[C,g]),onOpen:E,onClose:C,disableHoverableContent:g,children:n})})};dl.displayName=on;var zo="TooltipTrigger",ul=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=or(zo,n),s=Uo(zo,n),a=rr(n),c=l.useRef(null),d=oe(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(io,{asChild:!0,...a,children:i.jsx(Z.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=zo;var Pb="TooltipPortal",[Fw,_b]=nr(Pb,{forceMount:void 0}),kt="TooltipContent",fl=l.forwardRef((e,t)=>{const n=_b(kt,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,a=or(kt,e.__scopeTooltip);return i.jsx(Te,{present:r||a.open,children:a.disableHoverableContent?i.jsx(pl,{side:o,...s,ref:t}):i.jsx(Ib,{side:o,...s,ref:t})})}),Ib=l.forwardRef((e,t)=>{const n=or(kt,e.__scopeTooltip),r=Uo(kt,e.__scopeTooltip),o=l.useRef(null),s=oe(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=Lb(w,b.getBoundingClientRect()),x=Fb(w,y),E=$b(h.getBoundingClientRect()),C=Ub([...x,...E]);c(C),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=!Bb(w,a);y?m():x&&(m(),f())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[d,u,a,f,m]),i.jsx(pl,{...e,ref:s})}),[Ob,kb]=nr(on,{isInside:!1}),Mb=Pe.createSlottable("TooltipContent"),pl=l.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:a,...c}=e,d=or(kt,n),f=rr(n),{onClose:u}=d;return l.useEffect(()=>(document.addEventListener(Bo,u),()=>document.removeEventListener(Bo,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(Rt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:p=>p.preventDefault(),onDismiss:u,children:i.jsxs(co,{"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(Mb,{children:r}),i.jsx(Ob,{scope:n,isInside:!0,children:i.jsx(Eb,{id:d.contentId,role:"tooltip",children:o||r})})]})})});fl.displayName=kt;var hl="TooltipArrow",Db=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=rr(n);return kb(hl,n).isInside?null:i.jsx(lo,{...o,...r,ref:t})});Db.displayName=hl;function Lb(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 Fb(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 $b(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 Bb(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 Ub(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),zb(t)}function zb(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 Hb=ll,Wb=dl,Vb=ul,gl=fl;const jb=Hb,Rb=Wb,Kb=Vb,ml=l.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(gl,{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}));ml.displayName=gl.displayName;const Gb="sidebar:state",qb=60*60*24*7,Xb="16rem",Yb="18rem",Jb="3rem",Zb="b",bl=l.createContext(null);function sr(){const e=l.useContext(bl);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const vl=l.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:o,children:s,...a},c)=>{const d=rb(),[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=`${Gb}=${x}; path=/; max-age=${qb}`},[n,v]),h=l.useCallback(()=>d?u(y=>!y):g(y=>!y),[d,g,u]);l.useEffect(()=>{const y=x=>{x.key===Zb&&(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(bl.Provider,{value:w,children:i.jsx(jb,{delayDuration:0,children:i.jsx("div",{style:{"--sidebar-width":Xb,"--sidebar-width-icon":Jb,...o},className:A("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:c,...a,children:s})})})});vl.displayName="SidebarProvider";const wl=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}=sr();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(el,{open:f,onOpenChange:u,...s,children:i.jsx($o,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":Yb},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})})]})});wl.displayName="Sidebar";const yl=l.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:o}=sr();return i.jsxs(fe,{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(K.PanelLeft,{}),i.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});yl.displayName="SidebarTrigger";const Qb=l.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=sr();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})});Qb.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 ev=l.forwardRef(({className:e,...t},n)=>i.jsx(nn,{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}));ev.displayName="SidebarInput";const Sl=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}));Sl.displayName="SidebarHeader";const tv=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}));tv.displayName="SidebarFooter";const nv=l.forwardRef(({className:e,...t},n)=>i.jsx(Mo,{ref:n,"data-sidebar":"separator",className:A("mx-2 w-auto bg-sidebar-border",e),...t}));nv.displayName="SidebarSeparator";const Cl=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}));Cl.displayName="SidebarContent";const El=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}));El.displayName="SidebarGroup";const Nl=l.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Pe.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})});Nl.displayName="SidebarGroupLabel";const rv=l.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Pe.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})});rv.displayName="SidebarGroupAction";const Tl=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"group-content",className:A("w-full text-sm",e),...t}));Tl.displayName="SidebarGroupContent";const Al=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}));Al.displayName="SidebarMenu";const Pl=l.forwardRef(({className:e,...t},n)=>i.jsx("li",{ref:n,"data-sidebar":"menu-item",className:A("group/menu-item relative",e),...t}));Pl.displayName="SidebarMenuItem";const ov=Lt.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"}}),_l=l.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:o,className:s,...a},c)=>{const d=e?Pe.Slot:"button",{isMobile:f,state:u}=sr(),p=i.jsx(d,{ref:c,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:A(ov({variant:n,size:r}),s),...a});return o?(typeof o=="string"&&(o={children:o}),i.jsxs(Rb,{children:[i.jsx(Kb,{asChild:!0,children:p}),i.jsx(ml,{side:"right",align:"center",hidden:u!=="collapsed"||f,...o})]})):p});_l.displayName="SidebarMenuButton";const sv=l.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},o)=>{const s=t?Pe.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})});sv.displayName="SidebarMenuAction";const av=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}));av.displayName="SidebarMenuBadge";const iv=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(sl,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),i.jsx(sl,{className:"h-4 flex-1 max-w-[--skeleton-width]","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});iv.displayName="SidebarMenuSkeleton";const cv=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}));cv.displayName="SidebarMenuSub";const lv=l.forwardRef(({...e},t)=>i.jsx("li",{ref:t,...e}));lv.displayName="SidebarMenuSubItem";const dv=l.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...o},s)=>{const a=e?Pe.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})});dv.displayName="SidebarMenuSubButton";function uv({header:e,sidebarTitle:t="Threads",showThreads:n=!0,className:r="",sidebarClassName:o="",chatClassName:s="",...a}){return i.jsx(Wt,{...a,children:i.jsxs(vl,{className:`w-full ${r}`,children:[i.jsxs(wl,{className:`border-r ${o}`,children:[i.jsx(Sl,{children:i.jsx(Al,{children:i.jsx(Pl,{children:i.jsx(_l,{size:"lg",children:i.jsx("span",{className:"font-semibold",children:t})})})})}),i.jsx(Cl,{children:n&&i.jsxs(El,{children:[i.jsx(Nl,{children:"Conversations"}),i.jsx(Tl,{children:i.jsx("div",{className:"px-2 py-1",children:i.jsx(Qn,{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(yl,{}),i.jsx("div",{className:"flex-1"}),e]}),i.jsx("main",{className:`flex-1 min-h-0 overflow-hidden ${s}`,children:i.jsx(tn,{})})]})]})})}var fv="Label",Il=l.forwardRef((e,t)=>i.jsx(Z.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())}}));Il.displayName=fv;var Ol=Il;const pv=Lt.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Me=l.forwardRef(({className:e,...t},n)=>i.jsx(Ol,{ref:n,className:A(pv(),e),...t}));Me.displayName=Ol.displayName;function kl(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 ar="Switch",[hv,$w]=Le(ar),[gv,mv]=hv(ar),Ml=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=oe(t,x=>v(x)),h=l.useRef(!1),b=m?u||!!m.closest("form"):!0,[w,y]=Qe({prop:o,defaultProp:s??!1,onChange:f,caller:ar});return i.jsxs(gv,{scope:n,checked:w,disabled:c,children:[i.jsx(Z.button,{type:"button",role:"switch","aria-checked":w,"aria-required":a,"data-state":$l(w),"data-disabled":c?"":void 0,disabled:c,value:d,...p,ref:g,onClick:U(e.onClick,x=>{y(E=>!E),b&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})}),b&&i.jsx(Fl,{control:m,bubbles:!h.current,name:r,value:d,checked:w,required:a,disabled:c,form:u,style:{transform:"translateX(-100%)"}})]})});Ml.displayName=ar;var Dl="SwitchThumb",Ll=l.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=mv(Dl,n);return i.jsx(Z.span,{"data-state":$l(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Ll.displayName=Dl;var bv="SwitchBubbleInput",Fl=l.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const a=l.useRef(null),c=oe(a,s),d=kl(n),f=Ua(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}})});Fl.displayName=bv;function $l(e){return e?"checked":"unchecked"}var Bl=Ml,vv=Ll;const rt=l.forwardRef(({className:e,...t},n)=>i.jsx(Bl,{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(vv,{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")})}));rt.displayName=Bl.displayName;var wv=[" ","Enter","ArrowUp","ArrowDown"],yv=[" ","Enter"],ht="Select",[ir,cr,xv]=Hr(ht),[Mt,Bw]=Le(ht,[xv,Tt]),lr=Tt(),[Sv,ot]=Mt(ht),[Cv,Ev]=Mt(ht),Ul=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=lr(t),[b,w]=l.useState(null),[y,x]=l.useState(null),[E,C]=l.useState(!1),O=Cn(f),[N,F]=Qe({prop:r,defaultProp:o??!1,onChange:s,caller:ht}),[M,L]=Qe({prop:a,defaultProp:c,onChange:d,caller:ht}),R=l.useRef(null),G=b?g||!!b.closest("form"):!0,[V,z]=l.useState(new Set),X=Array.from(V).map($=>$.props.value).join(";");return i.jsx(ao,{...h,children:i.jsxs(Sv,{required:v,scope:t,trigger:b,onTriggerChange:w,valueNode:y,onValueNodeChange:x,valueNodeHasChildren:E,onValueNodeHasChildrenChange:C,contentId:Fe(),value:M,onValueChange:L,open:N,onOpenChange:F,dir:O,triggerPointerDownPosRef:R,disabled:m,children:[i.jsx(ir.Provider,{scope:t,children:i.jsx(Cv,{scope:e.__scopeSelect,onNativeOptionAdd:l.useCallback($=>{z(q=>new Set(q).add($))},[]),onNativeOptionRemove:l.useCallback($=>{z(q=>{const T=new Set(q);return T.delete($),T})},[]),children:n})}),G?i.jsxs(ld,{"aria-hidden":!0,required:v,tabIndex:-1,name:u,autoComplete:p,value:M,onChange:$=>L($.target.value),disabled:m,form:g,children:[M===void 0?i.jsx("option",{value:""}):null,Array.from(V)]},X):null]})})};Ul.displayName=ht;var zl="SelectTrigger",Hl=l.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=lr(n),a=ot(zl,n),c=a.disabled||r,d=oe(t,a.onTriggerChange),f=cr(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=fd(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(io,{asChild:!0,...s,children:i.jsx(Z.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":dd(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===" ")&&wv.includes(h.key)&&(g(),h.preventDefault())})})})});Hl.displayName=zl;var Wl="SelectValue",Vl=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:a="",...c}=e,d=ot(Wl,n),{onValueNodeHasChildrenChange:f}=d,u=s!==void 0,p=oe(t,d.onValueNodeChange);return be(()=>{f(u)},[f,u]),i.jsx(Z.span,{...c,ref:p,style:{pointerEvents:"none"},children:dd(d.value)?i.jsx(i.Fragment,{children:a}):s})});Vl.displayName=Wl;var Nv="SelectIcon",jl=l.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return i.jsx(Z.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});jl.displayName=Nv;var Tv="SelectPortal",Rl=e=>i.jsx(Ln,{asChild:!0,...e});Rl.displayName=Tv;var gt="SelectContent",Kl=l.forwardRef((e,t)=>{const n=ot(gt,e.__scopeSelect),[r,o]=l.useState();if(be(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?cn.createPortal(i.jsx(Gl,{scope:e.__scopeSelect,children:i.jsx(ir.Slot,{scope:e.__scopeSelect,children:i.jsx("div",{children:e.children})})}),s):null}return i.jsx(ql,{...e,ref:t})});Kl.displayName=gt;var ze=10,[Gl,st]=Mt(gt),Av="SelectContentImpl",Pv=Pe.createSlot("SelectContent.RemoveScroll"),ql=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=ot(gt,n),[x,E]=l.useState(null),[C,O]=l.useState(null),N=oe(t,j=>E(j)),[F,M]=l.useState(null),[L,R]=l.useState(null),G=cr(n),[V,z]=l.useState(!1),X=l.useRef(!1);l.useEffect(()=>{if(x)return ho(x)},[x]),jr();const $=l.useCallback(j=>{const[ae,...le]=G().map(ee=>ee.ref.current),[ie]=le.slice(-1),W=document.activeElement;for(const ee of j)if(ee===W||(ee==null||ee.scrollIntoView({block:"nearest"}),ee===ae&&C&&(C.scrollTop=0),ee===ie&&C&&(C.scrollTop=C.scrollHeight),ee==null||ee.focus(),document.activeElement!==W))return},[G,C]),q=l.useCallback(()=>$([F,x]),[$,F,x]);l.useEffect(()=>{V&&q()},[V,q]);const{onOpenChange:T,triggerPointerDownPosRef:_}=y;l.useEffect(()=>{if(x){let j={x:0,y:0};const ae=ie=>{var W,ee;j={x:Math.abs(Math.round(ie.pageX)-(((W=_.current)==null?void 0:W.x)??0)),y:Math.abs(Math.round(ie.pageY)-(((ee=_.current)==null?void 0:ee.y)??0))}},le=ie=>{j.x<=10&&j.y<=10?ie.preventDefault():x.contains(ie.target)||T(!1),document.removeEventListener("pointermove",ae),_.current=null};return _.current!==null&&(document.addEventListener("pointermove",ae),document.addEventListener("pointerup",le,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ae),document.removeEventListener("pointerup",le,{capture:!0})}}},[x,T,_]),l.useEffect(()=>{const j=()=>T(!1);return window.addEventListener("blur",j),window.addEventListener("resize",j),()=>{window.removeEventListener("blur",j),window.removeEventListener("resize",j)}},[T]);const[I,k]=ud(j=>{const ae=G().filter(W=>!W.disabled),le=ae.find(W=>W.ref.current===document.activeElement),ie=fd(ae,j,le);ie&&setTimeout(()=>ie.ref.current.focus())}),Y=l.useCallback((j,ae,le)=>{const ie=!X.current&&!le;(y.value!==void 0&&y.value===ae||ie)&&(M(j),ie&&(X.current=!0))},[y.value]),B=l.useCallback(()=>x==null?void 0:x.focus(),[x]),H=l.useCallback((j,ae,le)=>{const ie=!X.current&&!le;(y.value!==void 0&&y.value===ae||ie)&&R(j)},[y.value]),de=r==="popper"?Ho:Xl,ce=de===Ho?{side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:p,collisionBoundary:m,collisionPadding:v,sticky:g,hideWhenDetached:h,avoidCollisions:b}:{};return i.jsx(Gl,{scope:n,content:x,viewport:C,onViewportChange:O,itemRefCallback:Y,selectedItem:F,onItemLeave:B,itemTextRefCallback:H,focusSelectedItem:q,selectedItemText:L,position:r,isPositioned:V,searchRef:I,children:i.jsx(Vn,{as:Pv,allowPinchZoom:!0,children:i.jsx(En,{asChild:!0,trapped:y.open,onMountAutoFocus:j=>{j.preventDefault()},onUnmountAutoFocus:U(o,j=>{var ae;(ae=y.trigger)==null||ae.focus({preventScroll:!0}),j.preventDefault()}),children:i.jsx(Rt,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:j=>j.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:i.jsx(de,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:j=>j.preventDefault(),...w,...ce,onPlaced:()=>z(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:U(w.onKeyDown,j=>{const ae=j.ctrlKey||j.altKey||j.metaKey;if(j.key==="Tab"&&j.preventDefault(),!ae&&j.key.length===1&&k(j.key),["ArrowUp","ArrowDown","Home","End"].includes(j.key)){let ie=G().filter(W=>!W.disabled).map(W=>W.ref.current);if(["ArrowUp","End"].includes(j.key)&&(ie=ie.slice().reverse()),["ArrowUp","ArrowDown"].includes(j.key)){const W=j.target,ee=ie.indexOf(W);ie=ie.slice(ee+1)}setTimeout(()=>$(ie)),j.preventDefault()}})})})})})})});ql.displayName=Av;var _v="SelectItemAlignedPosition",Xl=l.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=ot(gt,n),a=st(gt,n),[c,d]=l.useState(null),[f,u]=l.useState(null),p=oe(t,N=>u(N)),m=cr(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 N=s.trigger.getBoundingClientRect(),F=f.getBoundingClientRect(),M=s.valueNode.getBoundingClientRect(),L=w.getBoundingClientRect();if(s.dir!=="rtl"){const W=L.left-F.left,ee=M.left-W,pe=N.left-ee,he=N.width+pe,J=Math.max(he,F.width),ve=window.innerWidth-ze,re=Ao(ee,[ze,Math.max(ze,ve-J)]);c.style.minWidth=he+"px",c.style.left=re+"px"}else{const W=F.right-L.right,ee=window.innerWidth-M.right-W,pe=window.innerWidth-N.right-ee,he=N.width+pe,J=Math.max(he,F.width),ve=window.innerWidth-ze,re=Ao(ee,[ze,Math.max(ze,ve-J)]);c.style.minWidth=he+"px",c.style.right=re+"px"}const R=m(),G=window.innerHeight-ze*2,V=h.scrollHeight,z=window.getComputedStyle(f),X=parseInt(z.borderTopWidth,10),$=parseInt(z.paddingTop,10),q=parseInt(z.borderBottomWidth,10),T=parseInt(z.paddingBottom,10),_=X+$+V+T+q,I=Math.min(b.offsetHeight*5,_),k=window.getComputedStyle(h),Y=parseInt(k.paddingTop,10),B=parseInt(k.paddingBottom,10),H=N.top+N.height/2-ze,de=G-H,ce=b.offsetHeight/2,j=b.offsetTop+ce,ae=X+$+j,le=_-ae;if(ae<=H){const W=R.length>0&&b===R[R.length-1].ref.current;c.style.bottom="0px";const ee=f.clientHeight-h.offsetTop-h.offsetHeight,pe=Math.max(de,ce+(W?B:0)+ee+q),he=ae+pe;c.style.height=he+"px"}else{const W=R.length>0&&b===R[0].ref.current;c.style.top="0px";const pe=Math.max(H,X+h.offsetTop+(W?Y:0)+ce)+le;c.style.height=pe+"px",h.scrollTop=ae-H+h.offsetTop}c.style.margin=`${ze}px 0`,c.style.minHeight=I+"px",c.style.maxHeight=G+"px",r==null||r(),requestAnimationFrame(()=>v.current=!0)}},[m,s.trigger,s.valueNode,c,f,h,b,w,s.dir,r]);be(()=>x(),[x]);const[E,C]=l.useState();be(()=>{f&&C(window.getComputedStyle(f).zIndex)},[f]);const O=l.useCallback(N=>{N&&g.current===!0&&(x(),y==null||y(),g.current=!1)},[x,y]);return i.jsx(Ov,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:v,onScrollButtonChange:O,children:i.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:i.jsx(Z.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Xl.displayName=_v;var Iv="SelectPopperPosition",Ho=l.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=ze,...s}=e,a=lr(n);return i.jsx(co,{...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)"}})});Ho.displayName=Iv;var[Ov,Wo]=Mt(gt,{}),Vo="SelectViewport",Yl=l.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=st(Vo,n),a=Wo(Vo,n),c=oe(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(ir.Slot,{scope:n,children:i.jsx(Z.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-ze*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),E=y-x;p.style.height=x+"px",p.style.bottom==="0px"&&(u.scrollTop=E>0?E:0,p.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})});Yl.displayName=Vo;var Jl="SelectGroup",[kv,Mv]=Mt(Jl),Dv=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Fe();return i.jsx(kv,{scope:n,id:o,children:i.jsx(Z.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Dv.displayName=Jl;var Zl="SelectLabel",Ql=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Mv(Zl,n);return i.jsx(Z.div,{id:o.id,...r,ref:t})});Ql.displayName=Zl;var dr="SelectItem",[Lv,ed]=Mt(dr),td=l.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...a}=e,c=ot(dr,n),d=st(dr,n),f=c.value===r,[u,p]=l.useState(s??""),[m,v]=l.useState(!1),g=oe(t,y=>{var x;return(x=d.itemRefCallback)==null?void 0:x.call(d,y,r,o)}),h=Fe(),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(Lv,{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(ir.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:i.jsx(Z.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 E;((E=d.searchRef)==null?void 0:E.current)!==""&&y.key===" "||(yv.includes(y.key)&&w(),y.key===" "&&y.preventDefault())})})})})});td.displayName=dr;var sn="SelectItemText",nd=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,a=ot(sn,n),c=st(sn,n),d=ed(sn,n),f=Ev(sn,n),[u,p]=l.useState(null),m=oe(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 be(()=>(h(g),()=>b(g)),[h,b,g]),i.jsxs(i.Fragment,{children:[i.jsx(Z.span,{id:d.textId,...s,ref:m}),d.isSelected&&a.valueNode&&!a.valueNodeHasChildren?cn.createPortal(s.children,a.valueNode):null]})});nd.displayName=sn;var rd="SelectItemIndicator",od=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return ed(rd,n).isSelected?i.jsx(Z.span,{"aria-hidden":!0,...r,ref:t}):null});od.displayName=rd;var jo="SelectScrollUpButton",sd=l.forwardRef((e,t)=>{const n=st(jo,e.__scopeSelect),r=Wo(jo,e.__scopeSelect),[o,s]=l.useState(!1),a=oe(t,r.onScrollButtonChange);return be(()=>{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(id,{...e,ref:a,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});sd.displayName=jo;var Ro="SelectScrollDownButton",ad=l.forwardRef((e,t)=>{const n=st(Ro,e.__scopeSelect),r=Wo(Ro,e.__scopeSelect),[o,s]=l.useState(!1),a=oe(t,r.onScrollButtonChange);return be(()=>{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(id,{...e,ref:a,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});ad.displayName=Ro;var id=l.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=st("SelectScrollButton",n),a=l.useRef(null),c=cr(n),d=l.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return l.useEffect(()=>()=>d(),[d]),be(()=>{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(Z.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()})})}),Fv="SelectSeparator",cd=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return i.jsx(Z.div,{"aria-hidden":!0,...r,ref:t})});cd.displayName=Fv;var Ko="SelectArrow",$v=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=lr(n),s=ot(Ko,n),a=st(Ko,n);return s.open&&a.position==="popper"?i.jsx(lo,{...o,...r,ref:t}):null});$v.displayName=Ko;var Bv="SelectBubbleInput",ld=l.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=l.useRef(null),s=oe(r,o),a=kl(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(Z.select,{...n,style:{...al,...n.style},ref:s,defaultValue:t})});ld.displayName=Bv;function dd(e){return e===""||e===void 0}function ud(e){const t=we(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 fd(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=Uv(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 Uv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var zv=Ul,pd=Hl,Hv=Vl,Wv=jl,Vv=Rl,hd=Kl,jv=Yl,gd=Ql,md=td,Rv=nd,Kv=od,bd=sd,vd=ad,wd=cd;const yd=zv,xd=Hv,Go=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(pd,{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(Wv,{asChild:!0,children:i.jsx(K.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Go.displayName=pd.displayName;const Sd=l.forwardRef(({className:e,...t},n)=>i.jsx(bd,{ref:n,className:A("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(K.ChevronUp,{className:"h-4 w-4"})}));Sd.displayName=bd.displayName;const Cd=l.forwardRef(({className:e,...t},n)=>i.jsx(vd,{ref:n,className:A("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(K.ChevronDown,{className:"h-4 w-4"})}));Cd.displayName=vd.displayName;const qo=l.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>i.jsx(Vv,{children:i.jsxs(hd,{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(Sd,{}),i.jsx(jv,{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(Cd,{})]})}));qo.displayName=hd.displayName;const Gv=l.forwardRef(({className:e,...t},n)=>i.jsx(gd,{ref:n,className:A("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Gv.displayName=gd.displayName;const mt=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(md,{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(Kv,{children:i.jsx(K.Check,{className:"h-4 w-4"})})}),i.jsx(Rv,{children:t})]}));mt.displayName=md.displayName;const qv=l.forwardRef(({className:e,...t},n)=>i.jsx(wd,{ref:n,className:A("-mx-1 my-1 h-px bg-muted",e),...t}));qv.displayName=wd.displayName;const ur=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}));ur.displayName="Card";const fr=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("flex flex-col space-y-1.5 p-6",e),...t}));fr.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 Xv=l.forwardRef(({className:e,...t},n)=>i.jsx("p",{ref:n,className:A("text-sm text-muted-foreground",e),...t}));Xv.displayName="CardDescription";const hr=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("p-6 pt-0",e),...t}));hr.displayName="CardContent";const Yv=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("flex items-center p-6 pt-0",e),...t}));Yv.displayName="CardFooter";const Jv=1,Zv=1e6;let Xo=0;function Qv(){return Xo=(Xo+1)%Number.MAX_SAFE_INTEGER,Xo.toString()}const Yo=new Map,Ed=e=>{if(Yo.has(e))return;const t=setTimeout(()=>{Yo.delete(e),an({type:"REMOVE_TOAST",toastId:e})},Zv);Yo.set(e,t)},ew=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Jv)};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?Ed(n):e.toasts.forEach(r=>{Ed(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)}}},gr=[];let mr={toasts:[]};function an(e){mr=ew(mr,e),gr.forEach(t=>{t(mr)})}function tw({...e}){const t=Qv(),n=o=>an({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>an({type:"DISMISS_TOAST",toastId:t});return an({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function nw(){const[e,t]=l.useState(mr);return l.useEffect(()=>(gr.push(t),()=>{const n=gr.indexOf(t);n>-1&&gr.splice(n,1)}),[e]),{...e,toast:tw,dismiss:n=>an({type:"DISMISS_TOAST",toastId:n})}}const rw={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 ow({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=P.useState(!1),[s,a]=P.useState(!1),[c,d]=P.useState(e),[f,u]=P.useState(!1),{toast:p}=nw();P.useEffect(()=>{const b=JSON.stringify(c)!==JSON.stringify(e);u(b)},[c,e]),P.useEffect(()=>{d(e)},[e]);const m=()=>{t(c),u(!1),p({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},v=()=>{d(rw),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(el,{open:r,onOpenChange:o,children:[i.jsx(yb,{asChild:!0,children:i.jsxs(fe,{variant:"outline",size:"sm",className:n,children:[i.jsx(K.Settings,{className:"h-4 w-4 mr-2"}),"Settings",f&&i.jsx(Xs,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),i.jsxs($o,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[i.jsxs(nl,{children:[i.jsx(rl,{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(ur,{children:[i.jsx(fr,{className:"pb-3",children:i.jsxs(pr,{className:"text-lg flex items-center gap-2",children:[i.jsx(K.Server,{className:"h-5 w-5"}),"API Configuration"]})}),i.jsxs(hr,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Me,{htmlFor:"api-url",children:"API Base URL"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(nn,{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(fe,{variant:"outline",onClick:h,children:"Test"})]})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(Me,{htmlFor:"enable-auth",children:"Enable Authentication"}),i.jsx(rt,{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(Me,{htmlFor:"auth-token",children:"Authentication Token"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(nn,{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(fe,{variant:"outline",size:"icon",onClick:()=>a(!s),children:s?i.jsx(K.EyeOff,{className:"h-4 w-4"}):i.jsx(K.Eye,{className:"h-4 w-4"})})]})]})]})]}),i.jsxs(ur,{children:[i.jsx(fr,{className:"pb-3",children:i.jsxs(pr,{className:"text-lg flex items-center gap-2",children:[i.jsx(K.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),i.jsxs(hr,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Me,{htmlFor:"layout",children:"Layout Style"}),i.jsxs(yd,{value:c.ui.layout,onValueChange:b=>d(w=>({...w,ui:{...w.ui,layout:b}})),children:[i.jsx(Go,{children:i.jsx(xd,{})}),i.jsxs(qo,{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(Me,{htmlFor:"theme",children:"Theme"}),i.jsxs(yd,{value:c.ui.theme,onValueChange:b=>d(w=>({...w,ui:{...w.ui,theme:b}})),children:[i.jsx(Go,{children:i.jsx(xd,{})}),i.jsxs(qo,{children:[i.jsx(mt,{value:"light",children:"Light"}),i.jsx(mt,{value:"dark",children:"Dark"}),i.jsx(mt,{value:"system",children:"System"})]})]})]}),i.jsx(Mo,{}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(Me,{htmlFor:"show-timestamps",children:"Show Timestamps"}),i.jsx(rt,{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(Me,{htmlFor:"show-agent-names",children:"Show Agent Names"}),i.jsx(rt,{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(Me,{htmlFor:"compact-messages",children:"Compact Messages"}),i.jsx(rt,{id:"compact-messages",checked:c.ui.compactMessages,onCheckedChange:b=>d(w=>({...w,ui:{...w.ui,compactMessages:b}}))})]})]})]})]}),i.jsxs(ur,{children:[i.jsx(fr,{className:"pb-3",children:i.jsxs(pr,{className:"text-lg flex items-center gap-2",children:[i.jsx(K.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),i.jsxs(hr,{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(Me,{htmlFor:"auto-save",children:"Auto-save Conversations"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),i.jsx(rt,{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(Me,{htmlFor:"enable-streaming",children:"Enable Streaming"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),i.jsx(rt,{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(Me,{htmlFor:"typing-indicator",children:"Typing Indicator"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),i.jsx(rt,{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(fe,{variant:"outline",onClick:v,children:[i.jsx(K.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(fe,{variant:"outline",onClick:g,children:"Cancel"}),i.jsxs(fe,{onClick:m,disabled:!f,children:[i.jsx(K.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function sw({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=P.useCallback(f=>{var u;(u=s.onThreadChange)==null||u.call(s,f)},[s.onThreadChange]);return e==="fullscreen"?i.jsx(Wt,{...s,onThreadChange:d,children:i.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:c(t),children:i.jsx(tn,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?i.jsx(Wt,{...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(Qn,{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(tn,{onError:s.onError,enableFileUpload:!0})})]})})}):i.jsx(Wt,{...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(Qn,{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(tn,{onError:s.onError,enableFileUpload:!0})})]})})}Q.Api=yn,Q.ApiClient=yn,Q.ChatApi=yn,Q.ChatInterface=tn,Q.ChatMainLayout=uv,Q.ChatProvider=Wt,Q.ChatRoutingProvider=Xm,Q.ChatSettings=ow,Q.MarkdownContent=Vt,Q.MessageComponent=ra,Q.ThreadManager=Qn,Q.apiClient=Ye,Q.applySettings=nb,Q.chatApiClient=Ye,Q.default=sw,Q.del=Ws,Q.get=lt,Q.getChatToken=Or,Q.getCurrentSettings=tb,Q.getDefaultApiConfig=Pc,Q.getDefaultChatSettings=_c,Q.onChatTokenChanged=zs,Q.post=Mr,Q.put=Hs,Q.setChatToken=kr,Q.stream=Zu,Q.useChat=Lr,Q.useChatRouting=Ym,Q.useChatStream=Vs,Q.useMessagesReducer=js,Object.defineProperties(Q,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|