teodor-new-chat-ui 4.3.413 → 4.3.414
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/features/checkpoint/hooks/useMessageMetadata.d.ts +1 -2
- package/dist/features/checkpoint/{types.d.ts → types/index.d.ts} +15 -5
- package/dist/features/checkpoint/types/models.d.ts +45 -0
- package/dist/features/checkpoint/utils/attemptDetection.d.ts +1 -1
- package/dist/features/checkpoint/utils/checkpointIndex.d.ts +2 -4
- package/dist/features/checkpoint/utils/messageMetadataResolver.d.ts +5 -13
- package/dist/features/checkpoint/utils/messagePreviews.d.ts +1 -1
- package/dist/features/core/api/clients/chatClient.d.ts +2 -2
- package/dist/features/core/types/models.d.ts +3 -168
- package/dist/features/messaging/index.d.ts +1 -0
- package/dist/features/messaging/types/index.d.ts +4 -0
- package/dist/features/messaging/types/models.d.ts +84 -0
- package/dist/features/thread/index.d.ts +1 -0
- package/dist/features/thread/types/index.d.ts +4 -0
- package/dist/features/thread/types/models.d.ts +37 -0
- package/dist/features/ui/components/ui/resizable.d.ts +1 -1
- package/dist/index.esm.js +58 -95
- package/dist/index.umd.js +2 -2
- package/dist/lib/index.d.ts +5 -1
- package/dist/types/models.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(F,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","lucide-react"],b):(F=typeof globalThis<"u"?globalThis:F||self,b(F.NewChatUI={},F.React,F.reactSlot,F.classVarianceAuthority,F.clsx,F.tailwindMerge,F.ReactDOM,F.LucideReact))})(this,function(F,b,Vt,Dr,Jg,Zg,No,ue){"use strict";var MI=Object.defineProperty;var RI=(F,b,Vt)=>b in F?MI(F,b,{enumerable:!0,configurable:!0,writable:!0,value:Vt}):F[b]=Vt;var Yg=(F,b,Vt)=>RI(F,typeof b!="symbol"?b+"":b,Vt);function Xl(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 h=Xl(b),Lr=Xl(No);function Jl(e,t){
|
|
1
|
+
(function(F,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","lucide-react"],b):(F=typeof globalThis<"u"?globalThis:F||self,b(F.NewChatUI={},F.React,F.reactSlot,F.classVarianceAuthority,F.clsx,F.tailwindMerge,F.ReactDOM,F.LucideReact))})(this,function(F,b,Vt,Dr,Jg,Zg,No,ue){"use strict";var MI=Object.defineProperty;var RI=(F,b,Vt)=>b in F?MI(F,b,{enumerable:!0,configurable:!0,writable:!0,value:Vt}):F[b]=Vt;var Yg=(F,b,Vt)=>RI(F,typeof b!="symbol"?b+"":b,Vt);function Xl(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 h=Xl(b),Lr=Xl(No);function Jl(e,t){let n=[],r=null,o=null;if(!(e&&"type"in e&&e.type==="default_message")&&e){const a=e.checkpointId??null;if(a){const l=t.checkpointMetaByCheckpointId.get(a)??null;l&&(n=[l],r=a,o=l)}if(o&&(o.attemptCount??1)>1){const l=o.baseUserMessageId??null;if(l){const c=[];for(const[d,p]of t.checkpointMetaByCheckpointId.entries())if(p.baseUserMessageId===l){const m=t.checkpointMetaByCheckpointId.get(d);m&&c.push(m)}c.length>0&&(c.sort((d,p)=>{const m=d.createdAt?Date.parse(d.createdAt):0;return(p.createdAt?Date.parse(p.createdAt):0)-m}),n=c)}}}return{checkpointCandidates:n,defaultCheckpointId:r}}function Zl(e,t){return b.useMemo(()=>Jl(e,t),[e,t])}function Ql(e){const t=new Map;for(const o of e){const s=o.messages??[];if(!o.checkpointId)continue;let i;for(let l=s.length-1;l>=0;l--){const c=s[l];if(c.role==="user"&&c.id){i=c.id;break}}if(!i)continue;const a=t.get(i)??[];a.push({checkpoint:o,timestamp:Date.parse(o.createdAt??"0")}),t.set(i,a)}const n=new Map,r=new Map;for(const[o,s]of t.entries()){if(!s.length)continue;const i=s.length;i>1&&s.sort((l,c)=>c.timestamp-l.timestamp);const a=[];for(let l=0;l<s.length;l++){const{checkpoint:c}=s[l],d=c.checkpointId;if(!d)continue;const p={attemptIndex:l,attemptCount:i,isLatestAttempt:l===0,baseUserMessageId:o};n.set(d,p),i>1&&a.push({checkpointId:d,attemptIndex:p.attemptIndex,attemptCount:p.attemptCount,isLatestAttempt:p.isLatestAttempt})}a.length&&r.set(o,a)}return{attemptMetaById:n,userMessageIdToAttempts:r}}const ec=120;function Qg(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>ec?`${n.slice(0,ec-3)}…`:n:""}function ui(e){return Qg(e.content)||""}function ex(e){var n;const t=new Map;for(const r of e){if(!r.checkpointId)continue;const o=(n=r.messages)==null?void 0:n.find(s=>s.role==="user");if(o){const s=ui(o);s&&t.set(r.checkpointId,s)}}return t}function tc(e){const t=new Map,n=[],r=new Map,{attemptMetaById:o,userMessageIdToAttempts:s}=Ql(e);for(let c=0;c<e.length;c++){const d=e[c],p=d.checkpointId,m=p??`cp-${c}`,f=d.metadata??{},v=typeof f.step=="number"?f.step:null,g=typeof f.source=="string"?f.source:null;let x=null,y=null;const w=Array.isArray(d.messages)?d.messages:[];for(const E of w)E.role==="user"&&(y||(y=E),E.id&&(x=E.id));const S=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,C={id:m,step:v,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,messageId:x,next:S,parentConfig:k},T=p?o.get(p):null;if(C.attemptIndex=(T==null?void 0:T.attemptIndex)??0,C.attemptCount=(T==null?void 0:T.attemptCount)??1,C.isLatestAttempt=(T==null?void 0:T.isLatestAttempt)??!0,C.baseUserMessageId=(T==null?void 0:T.baseUserMessageId)??null,p&&t.set(p,C),p&&y){const E=ui(y);E&&r.set(p,E)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:S,parentConfig:k})}return{checkpoints:e,checkpointMetaByCheckpointId:t,userMessageIdToAttempts:s,timeline:n,messagePreviews:r,getLatest:()=>{const c=n[0];if(c)return t.get(c.id)},getCheckpoint:c=>t.get(c),getAttempts:c=>s.get(c)??[]}}function nc(e){return b.useMemo(()=>tc(e),[e])}function cr(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Vn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function rc(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function di(e){const t=cr(e);if(t)return cr(t.configurable)??t}function Nn(e){const r=[...(Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[]).map((s,i)=>tx(s,i)).filter(s=>!!s)].sort((s,i)=>oc(i.createdAt)-oc(s.createdAt)),o=r[0]??null;return{threadId:(e==null?void 0:e.threadId)??"",latest:o,checkpoints:r,interrupt:(o==null?void 0:o.interrupt)??null}}function tx(e,t){var w;if(!e)return null;const r=(Array.isArray((w=e.values)==null?void 0:w.messages)?e.values.messages:[]).filter(S=>!!(S&&typeof S=="object"&&typeof S.role=="string")),o=cr(e.metadata)??{},s=di(e.config),i=cr(e.parent_config??e.parentConfig),a=di(i),l=Vn(s,["checkpoint_id","checkpointId"]),c=Vn(s,["checkpoint_ns","checkpointNs"]),d=Vn(a,["checkpoint_id","checkpointId"]),p=Vn(a,["checkpoint_id","checkpointId"])??null,m=Vn(a,["checkpoint_ns","checkpointNs"])??null,f=cr(e.config),v=Array.isArray(e.tasks)?e.tasks.map(S=>({...S})):e.tasks??null,g=Array.isArray(e.next)?[...e.next]:e.next??null,x=typeof e.created_at=="string"&&e.created_at.trim()?e.created_at:typeof e.createdAt=="string"&&e.createdAt.trim()?e.createdAt:new Date(Date.now()-t).toISOString(),y={...o,step:rc(o,["step"])??0,source:Vn(o,["source"])??null};return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:r,nextCursor:p,nextCursorNs:m,interrupt:nx(r,t),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function nx(e,t){return rx(e,t)}function rx(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function oc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var fi={exports:{}},$r={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -126,5 +126,5 @@ ${t}</tr>
|
|
|
126
126
|
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=ch(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o='<a href="'+t+'"';return n&&(o+=' title="'+n+'"'),o+=">"+r+"</a>",o}image(t,n,r){if(t=ch(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o=`<img src="${t}" alt="${r}"`;return n&&(o+=` title="${n}"`),o+=this.options.xhtml?"/>":">",o}text(t){return t}}class hh{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class mh{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,n){let r=t,o=0;if(this.seen.hasOwnProperty(r)){o=this.seen[t];do o++,r=t+"-"+o;while(this.seen.hasOwnProperty(r))}return n||(this.seen[t]=o,this.seen[r]=0),r}slug(t,n={}){const r=this.serialize(t);return this.getNextSafeSlug(r,n.dryrun)}}class zn{constructor(t){this.options=t||or,this.options.renderer=this.options.renderer||new el,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new hh,this.slugger=new mh}static parse(t,n){return new zn(n).parse(t)}static parseInline(t,n){return new zn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,p,m,f,v,g,x,y,w,S,k,C,T;const E=t.length;for(o=0;o<E;o++){if(f=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[f.type]&&(T=this.options.extensions.renderers[f.type].call({parser:this},f),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){r+=T||"";continue}switch(f.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(f.tokens),f.depth,lh(this.parseInline(f.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(f.text,f.lang,f.escaped);continue}case"table":{for(p="",d="",a=f.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(f.header[s].tokens),{header:!0,align:f.align[s]});for(p+=this.renderer.tablerow(d),m="",a=f.rows.length,s=0;s<a;s++){for(c=f.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:f.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(p,m);continue}case"blockquote":{m=this.parse(f.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=f.ordered,g=f.start,x=f.loose,a=f.items.length,m="",s=0;s<a;s++)w=f.items[s],S=w.checked,k=w.task,y="",w.task&&(C=this.renderer.checkbox(S),x?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=C+" "+w.tokens[0].text,w.tokens[0].tokens&&w.tokens[0].tokens.length>0&&w.tokens[0].tokens[0].type==="text"&&(w.tokens[0].tokens[0].text=C+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:C}):y+=C),y+=this.parse(w.tokens,x),m+=this.renderer.listitem(y,k,S);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(f.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(f.tokens));continue}case"text":{for(m=f.tokens?this.parseInline(f.tokens):f.text;o+1<E&&t[o+1].type==="text";)f=t[++o],m+=`
|
|
127
127
|
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const _='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(_);return}else throw new Error(_)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Ws{constructor(t){this.options=t||or}preprocess(t){return t}postprocess(t){return t}}Yg(Ws,"passThroughHooks",new Set(["preprocess","postprocess"]));function yT(e,t,n){return r=>{if(r.message+=`
|
|
128
128
|
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+_t(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function gh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Se.defaults,...s};const i=yT(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(vT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(p){return i(p)}const c=function(p){let m;if(!p)try{r.walkTokens&&Se.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){p=f}return r.highlight=a,p?i(p):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;Se.walkTokens(l,function(p){p.type==="code"&&(d++,setTimeout(()=>{a(p.text,p.lang,function(m,f){if(m)return c(m);f!=null&&f!==p.text&&(p.text=f,p.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(Se.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&Se.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function Se(e,t,n){return gh(Bn.lex,zn.parse)(e,t,n)}Se.options=Se.setOptions=function(e){return Se.defaults={...Se.defaults,...e},sT(Se.defaults),Se},Se.getDefaults=oh,Se.defaults=or,Se.use=function(...e){const t=Se.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=Se.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=Se.defaults.renderer||new el;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=Se.defaults.tokenizer||new Qa;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=Se.defaults.hooks||new Ws;for(const s in n.hooks){const i=o[s];Ws.passThroughHooks.has(s)?o[s]=a=>{if(Se.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=Se.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}Se.setOptions(r)})},Se.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(Se,r)),r.type){case"table":{for(const o of r.header)n=n.concat(Se.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(Se.walkTokens(s.tokens,t));break}case"list":{n=n.concat(Se.walkTokens(r.items,t));break}default:Se.defaults.extensions&&Se.defaults.extensions.childTokens&&Se.defaults.extensions.childTokens[r.type]?Se.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(Se.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(Se.walkTokens(r.tokens,t)))}return n},Se.parseInline=gh(Bn.lexInline,zn.parseInline),Se.Parser=zn,Se.parser=zn.parse,Se.Renderer=el,Se.TextRenderer=hh,Se.Lexer=Bn,Se.lexer=Bn.lex,Se.Tokenizer=Qa,Se.Slugger=mh,Se.Hooks=Ws,Se.parse=Se,Se.options,Se.setOptions,Se.use,Se.walkTokens,Se.parseInline,zn.parse,Bn.lex;function Ar({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof Se.parse=="function"?Se.parse(i):Se(i)}return typeof Se.parse=="function"?Se.parse(e):Se(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:ne("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function xh({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function vh({artifact:e}){const[t,n]=b.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=b.useState(u.jsx(ue.Clock,{className:"w-4 h-4"})),[s,i]=b.useState("Processing");return b.useEffect(()=>{switch(e.status||"processing"){case"completed":n("bg-green-500/20 text-green-700 dark:text-green-300"),o(u.jsx(ue.CheckCircle,{className:"w-4 h-4"})),i("Completed");break;case"failed":n("bg-red-500/20 text-red-700 dark:text-red-300"),o(u.jsx(ue.ExternalLink,{className:"w-4 h-4 rotate-45"})),i("Failed");break;case"pending":n("bg-blue-500/20 text-blue-700 dark:text-blue-300"),o(u.jsx(ue.Clock,{className:"w-4 h-4"})),i("Pending");break;default:n("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),o(u.jsx(ue.Clock,{className:"w-4 h-4"})),i("Processing")}},[e.status]),u.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-900/50 bg-blue-50 dark:bg-blue-950/20 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"mt-1 flex-shrink-0",children:u.jsx(ue.Search,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100",children:"Research Task"}),u.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300 mt-1",children:["Task ID: ",u.jsxs("code",{className:"font-mono text-xs bg-blue-100 dark:bg-blue-900/30 px-2 py-1 rounded",children:[e.task_id.slice(0,8),"..."]})]})]})]}),u.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium ${t}`,children:[r,u.jsx("span",{children:s})]}),e.query&&u.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200 bg-white dark:bg-blue-900/30 rounded px-3 py-2",children:[u.jsx("p",{className:"font-medium text-xs text-blue-600 dark:text-blue-400 mb-1",children:"Query:"}),u.jsx("p",{className:"line-clamp-2",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"text-sm text-blue-900 dark:text-blue-100 bg-white dark:bg-blue-900/30 rounded px-3 py-2 space-y-2",children:[u.jsx("p",{className:"font-semibold text-xs text-blue-600 dark:text-blue-400",children:"Results:"}),u.jsx(Ar,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),e.progress_url&&u.jsx("div",{className:"pt-2",children:u.jsxs("a",{href:e.progress_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white dark:bg-blue-700 dark:hover:bg-blue-600 rounded-md text-sm font-medium transition-colors",children:[u.jsx("span",{children:"Monitor Progress"}),u.jsx(ue.ExternalLink,{className:"w-3.5 h-3.5"})]})}),e.createdAt&&u.jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})}function wh({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Wv(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(vh,{artifact:{type:"research_task_info",task_id:e.task_id,progress_url:e.progress_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(xh,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const tl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));tl.displayName="Card";const nl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));nl.displayName="CardHeader";const rl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));rl.displayName="CardTitle";const ol=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));ol.displayName="CardDescription";const sl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));sl.displayName="CardContent";const bh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));bh.displayName="CardFooter";function yh({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=hr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(tl,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(nl,{className:"pb-3",children:[u.jsx(rl,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ol,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(sl,{className:"pt-0 pb-3",children:a}),u.jsx(bh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(at,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(at,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const ST="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function il({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:ST,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:hr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:hr(e)})}function Sh({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=b.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(ue.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function Ch({message:e,viewMode:t,isStreaming:n=!1}){const o=Ai(e).name||"tool",s=l=>{if(l==null)return null;const c=typeof l=="string"?Ni(l)??l:l;if(c&&typeof c=="object")return u.jsx(il,{data:c});const d=typeof c=="string"?c:(()=>{try{return hr(c)}catch{return String(c??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:d})},i=l=>{if(l==null)return null;const{content:c,isMarkdown:d}=Lv(l);return d?u.jsx(Ar,{content:c,className:"text-current"}):s(l)},a=()=>{const l=e.content.find(p=>p.type!=="tool_call");if(!l)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(l.type==="text"){const m=(l.text??"").trim();if(!m)return null;const f=qr(m);return i(f)}const c=Kr(l),d=qr(c);return i(d)};return u.jsxs("div",{className:"space-y-2",children:[u.jsx(Sh,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function Th({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function kh({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:ne("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(Ar,{content:e,allowHtml:!1}):u.jsxs("pre",{className:ne("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(at,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Eh({message:e,isToolMessage:t,showToolMessages:n,artifactToRender:r,toolViewMode:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptParts:d,isStreamingMessage:p,defaultMessage:m,handleFileClick:f,uploadingFiles:v,handleInterruptApprove:g,handleInterruptReject:x,disableInterruptActions:y,messageRole:w,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:C,setIsUserExpanded:T,isCompactLayout:E,activeInterruptId:_,activeInterruptValue:R,iconForeground:L}){const H=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),K=b.useCallback(({part:I,i:W})=>{if(I.type==="text"){const N=I.text??"",U=N.trim(),O=Ni(U);return O&&w!=="tool"?u.jsx(il,{data:O},W):w==="user"&&S&&U.length>k?u.jsx(kh,{text:U,expanded:C,onExpandedChange:T,previewLength:k,isCompact:E},W):u.jsx(Ar,{content:N,allowHtml:!1},W)}if(I.type==="image_url"){const N=I;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:N.url,alt:N.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},W)}if(I.type==="file"){const N=I,U=N.name||"file";return u.jsxs("a",{href:N.url,onClick:O=>f(O.nativeEvent,N,W),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[v[W]?u.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[U,v[W]?" (processing)":""]})]},W)}if(I.type==="interrupt"){const N=I,U=Wo((N==null?void 0:N.id)??(N==null?void 0:N.interrupt_id)),O=!!(_&&U&&U===_),j=O?R??(N==null?void 0:N.value):N==null?void 0:N.value,q=U?{...N,id:U,interrupt_id:U}:N;return u.jsx(yh,{interruptPart:q,onApprove:g,onReject:x,disabled:y,isActive:O,payload:j},W)}return null},[f,v,g,x,w,S,k,C,E,_,R,y]),B=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!p)return H();if(!t&&!B&&!p)return null;if(t)return!n&&r?null:n?u.jsx(Ch,{message:e,viewMode:o,isStreaming:s},e.id):null;if(!m){const I=u.jsx("div",{className:"space-y-2",children:i.map((W,N)=>u.jsx(K,{part:W,i:N},N))});return p?u.jsxs("div",{"aria-busy":"true",role:"status",children:[I,u.jsx(Th,{className:L})]}):I}return null}function Ih(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Za(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),p=b.useCallback(f=>{a(f),c(!0)},[]),m=b.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";p({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await eu(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");p({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,p]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Nh(e,t){return b.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:$v(r),toolMeta:Ai(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Fv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Vs=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:p=!0,showArtifactPreviews:m=!0,customStyles:f={},onEdit:v,onRegenerate:g,onCancelEdit:x,onCopy:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,checkpointCandidates:T=[],activeCheckpointId:E=null,onSelectCheckpoint:_,defaultCheckpointId:R=null,messageParentCheckpointId:L=null}){const[H,K]=b.useState(!1),[B,I]=b.useState("preview"),[W,N]=b.useState(!1),{currentThreadId:U}=pr(),{respondToInterrupt:O}=Yr(),j=l==="phone"||l==="half-screen",q=t.role,J=q==="tool",P=b.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),M=!!P,G=!(r&&q!=="user"),{uploadingFiles:Z,handleFileClick:se,fileViewerOpen:V,currentFileInfo:D,closeFileViewer:X}=Ih({allowFileOpen:G,currentThreadId:U}),Q=b.useMemo(()=>{switch(q){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[q]),ae=Nh(t,P),{contentParts:$,imageParts:re,fileParts:we,interruptParts:de,textContent:xe,toolMeta:Ee,toolRaw:Be,isToolStreaming:We}=ae,je=(w==null?void 0:w.id)??(w==null?void 0:w.interrupt_id),Ve=Wo(je),Xe=w==null?void 0:w.value,ze=b.useMemo(()=>P||!m?null:t.artifact||null,[P,t,m]),Ge=b.useCallback(async()=>{const le=J?Be:xe;async function Y(ge){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ge);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const it=new Blob([ge],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":it})]);return}throw new Error("Clipboard API not supported in this context.")}try{await Y(le),K(!0),setTimeout(()=>K(!1),2e3),y==null||y(le)}catch(ge){console.error("Failed to copy:",ge)}},[J,Be,xe,y]),rt=b.useCallback(()=>{if(!v||!t.id)return;const le=(J?Be:xe)??"",Y="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,le,Y)},[v,t.id,J,Be,xe,t]),nt=b.useCallback(()=>{g==null||g(n)},[g,n]),et=b.useCallback(()=>{const Y=ne(j?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Q);switch(q){case"user":return u.jsx(ue.User,{className:Y});case"assistant":return u.jsx(ue.Bot,{className:Y});case"tool":return u.jsx(ue.Wrench,{className:Y});default:return u.jsx(ue.Bot,{className:Y})}},[j,Q,q]),xt=b.useCallback(()=>{const le="group relative mb-4 flex w-full";switch(q){case"user":return ne(le,"justify-end");case"assistant":case"tool":case"system":return ne(le,"justify-start");default:return le}},[q]),vt=b.useCallback(()=>{const le=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",j&&"px-3 py-2 text-sm");if(M)return ne(le,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(q){case"user":return ne(le,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return ne(le,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return ne(le,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(le,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(le,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[j,M,q]),dt=b.useCallback(async le=>{if(S)return;const Y=Wo((le==null?void 0:le.id)??(le==null?void 0:le.interrupt_id));if(!Y){console.warn("Interrupt part missing id",le);return}try{k==null||k(),await O(Y,!0)}catch(ge){console.error("Failed to approve interrupt:",ge)}finally{C==null||C()}},[S,C,k,O]),Et=b.useCallback(async le=>{if(S)return;const Y=Wo((le==null?void 0:le.id)??(le==null?void 0:le.interrupt_id));if(!Y){console.warn("Interrupt part missing id",le);return}try{k==null||k(),await O(Y,!1)}catch(ge){console.error("Failed to reject interrupt:",ge)}finally{C==null||C()}},[S,C,k,O]),Dt=b.useMemo(()=>P?"Assistant":Bv(t),[P,t]),$e=b.useMemo(()=>P?[]:Array.isArray(T)?T:[],[T,P]),Pt=b.useMemo(()=>{var le;return $e.length?R&&$e.some(Y=>Y.id===R)?R:((le=$e[0])==null?void 0:le.id)??null:null},[R,$e]),Me=b.useMemo(()=>!$e.length||!E?null:$e.some(le=>le.id===E)?E:null,[E,$e])??Pt,Ke=q==="user"&&$e.length>0&&typeof _=="function",Ct=b.useCallback((le,Y=!1)=>{if(!_)return;const ge=(le==null?void 0:le.id)??null,it=(le==null?void 0:le.parentId)??L??null;_(ge,it,Y)},[L,_]),Ze=b.useMemo(()=>Me?$e.findIndex(le=>le.id===Me):-1,[Me,$e]),pt=b.useMemo(()=>Ze<0?null:$e[Ze]??null,[Ze,$e]);return J&&!p&&!ze?null:M&&P?u.jsx("div",{className:ne(xt(),f.container),children:u.jsxs("div",{className:ne(vt(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ue.Bot,{className:ne("h-4 w-4",Q)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Ar,{content:P.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne(xt(),f.container),children:u.jsxs("div",{className:ne(vt(),f.content),children:[(i||a||J)&&u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",j&&"mb-1 pb-1",Q,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[et(),a&&Dt&&u.jsx("span",{className:ne("font-medium",j?"text-xs":"text-sm"),children:Dt}),J&&u.jsxs(Lp,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",Q,"border border-current/40",j&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":B==="expanded",onClick:()=>I(le=>le==="expanded"?"preview":"expanded"),onKeyDown:le=>{(le.key==="Enter"||le.key===" ")&&(le.preventDefault(),I(Y=>Y==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:Ee.name??"Tool Output"}),Ee.toolCallId&&u.jsx("span",{className:"opacity-70",children:Ee.toolCallId.slice(0,8)}),B==="expanded"?u.jsx(ue.ChevronUp,{className:"h-3 w-3"}):u.jsx(ue.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[Ke&&pt&&Ze>=0&&u.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ze<$e.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ze>=$e.length-1)return;const le=$e[Ze+1];le&&Ct(le)},"aria-label":"Older checkpoint (back in time)",disabled:Ze>=$e.length-1,children:u.jsx(ue.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[$e.length-Ze," / ",$e.length]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ze>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(!(Ze<=0))if(Ze===1)Ct(null,!0);else{const le=$e[Ze-1];le&&Ct(le,!1)}},"aria-label":"Newer checkpoint (forward in time)",disabled:Ze<=0,children:u.jsx(ue.ChevronRight,{className:"h-3 w-3"})})]})}),i&&t.createdAt&&u.jsx("time",{className:ne("text-xs opacity-60",Q,j&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>Ge(),className:ne("h-6 w-6 p-0 hover:bg-foreground/10",Q,j&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ue.Copy,{className:ne(H?"text-success":Q,j?"h-3 w-3":"h-4 w-4")})})}),q==="user"&&v&&u.jsx(at,{variant:"ghost",size:"sm",onClick:rt,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",Q,j&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ue.Edit,{className:ne(Q,j?"h-3 w-3":"h-4 w-4")})}),q==="assistant"&&g&&u.jsx(at,{variant:"ghost",size:"sm",onClick:nt,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",Q,j&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ue.RotateCcw,{className:ne(Q,j?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(Eh,{message:t,isToolMessage:J,showToolMessages:p,artifactToRender:ze,toolViewMode:B,isToolStreaming:We,contentParts:$,textContent:xe,imageParts:re,fileParts:we,interruptParts:de,isStreamingMessage:r,defaultMessage:P,handleFileClick:se,uploadingFiles:Z,handleInterruptApprove:dt,handleInterruptReject:Et,disableInterruptActions:S,messageRole:q,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:W,setIsUserExpanded:N,isCompactLayout:j,activeInterruptId:Ve,activeInterruptValue:Xe,iconForeground:Q}),m&&ze&&u.jsx("div",{className:"mt-3",children:u.jsx(wh,{artifact:ze,idx:0})})]}),J&&B==="expanded"&&(Ee.toolCallId||Ee.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",j&&"text-xs"),children:[Ee.name&&u.jsxs("div",{children:["Function: ",Ee.name]}),Ee.toolCallId&&u.jsxs("div",{children:["Call ID: ",Ee.toolCallId]})]}),!(i||a||J)&&s&&!o&&u.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>Ge(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:u.jsx(ue.Copy,{className:ne(H?"text-success":"text-current",j?"h-3 w-3":"h-4 w-4")})}),q==="user"&&v&&u.jsx(at,{variant:"ghost",size:"sm",onClick:rt,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:u.jsx(ue.Edit,{className:ne("text-current",j?"h-3 w-3":"h-4 w-4")})}),q==="assistant"&&g&&u.jsx(at,{variant:"ghost",size:"sm",onClick:nt,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:u.jsx(ue.RotateCcw,{className:ne("text-current",j?"h-3 w-3":"h-4 w-4")})})]})]})}),D&&u.jsx(rh,{isOpen:V,onClose:X,fileId:D.id,fileName:D.name,mimeType:D.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&uu(e.message)===uu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((p=t.customStyles)==null?void 0:p.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=du(e.message),a=du(t.message);return i.length===a.length});Vs.displayName="MessageComponent";const al=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,ll=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointIndex:w,activeCheckpointId:S,onSelectCheckpoint:k}){const C=al(t,n),T="type"in t&&t.type==="default_message",_=!!t.__syntheticStreaming,{checkpointCandidates:R,defaultCheckpointId:L}=Zl(t,w??{checkpoints:[],checkpointMetaById:new Map,checkpointIndexByKey:new Map,attemptMetaById:new Map,userMessageIdToAttempts:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getAttempts:()=>[]}),H=t&&!T?t.additionalKwargs??{}:{},K=t&&!T?t.responseMetadata??{}:{},B=(()=>{if(typeof H.parentCheckpointId=="string")return H.parentCheckpointId;if(typeof K.parentCheckpointId=="string")return K.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":C,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Vs,{message:t,messageIndex:n,isStreamingMessage:_||r&&o===t.id,streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointCandidates:R,activeCheckpointId:S??null,onSelectCheckpoint:k,defaultCheckpointId:L,messageParentCheckpointId:B})})});ll.displayName="MessageRow";const cl=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:p,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,showArtifactPreviews:E=!0,checkpointIndex:_,activeCheckpointId:R,onSelectCheckpoint:L,createSyntheticThinkingMessage:H=!0},K)=>{const B=b.useRef(null),I=b.useRef(null),W=b.useRef(!1),N=b.useRef(!1),[U,O]=b.useState(!0),j=b.useMemo(()=>w?e.some($=>"type"in $&&$.type==="default_message"?!1:Array.isArray($==null?void 0:$.content)&&$.content.some(re=>re&&re.type==="interrupt"&&(re.id??re.interrupt_id)===w.id)):!1,[w,e]),q=b.useMemo(()=>{if(!w||j)return null;const $=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let re;const we=w.value;if(we&&typeof we=="object"&&!Array.isArray(we)){const de=we.title;typeof de=="string"&&de.trim()&&(re=de.trim())}return{id:`interrupt-${$}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:$,value:we,title:re}]}},[w,j]),J=b.useMemo(()=>q?[...e,q]:e,[e,q]),P=b.useMemo(()=>!H||!t?J:!J.some(re=>re.role==="assistant")&&J.length>0?[...J,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:J,[J,t,H]),M=b.useMemo(()=>T?P:P.filter($=>($==null?void 0:$.role)!=="tool"),[P,T]),G=b.useCallback($=>{O($),x&&x(!$),y&&y($)},[x,y]),Z=b.useMemo(()=>{if(a)return async()=>{if(!W.current){W.current=!0;try{await a()}finally{W.current=!1}}}},[a]),se=b.useMemo(()=>!v||g?!1:U?"auto":!1,[U,v,g]),V=b.useMemo(()=>{if(typeof f!="string")return null;const $=f.trim();return $?{id:"default-message",role:"assistant",type:"default_message",content:$,createdAt:new Date().toISOString()}:null},[f]),D=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),X=()=>V?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Vs,{message:V,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),Q=M.length,ae=Q>0;return b.useEffect(()=>{var $,re;if(Q===0){N.current=!1;return}if(!N.current)if(N.current=!0,B.current&&M.length>0){const we=M.length-1;(re=($=B.current).scrollToIndex)==null||re.call($,{index:we,align:"end",behavior:"auto"})}else I.current&&(I.current.scrollTop=I.current.scrollHeight)},[Q,M.length]),b.useImperativeHandle(K,()=>({scrollToLatest:()=>{var $,re;if(B.current&&M.length>0){const we=M.length-1;(re=($=B.current).scrollToIndex)==null||re.call($,{index:we,align:"end",behavior:"auto"})}else I.current&&(I.current.scrollTop=I.current.scrollHeight)},scrollToTop:()=>{var $,re;B.current&&M.length>0?(re=($=B.current).scrollToIndex)==null||re.call($,{index:0,align:"start",behavior:"auto"}):I.current&&(I.current.scrollTop=0)}}),[M]),u.jsx("div",{className:D,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ae?u.jsx(EC,{ref:$=>{B.current=$},scrollerRef:$=>{I.current=$ instanceof HTMLDivElement?$:null},data:M,followOutput:se,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{Z&&Z()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:($,re)=>al(re,$),itemContent:($,re)=>u.jsx(ll,{message:re,index:$,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,showArtifactPreviews:E,checkpointIndex:_,activeCheckpointId:R,onSelectCheckpoint:L})}):X()})})});cl.displayName="MessageList";const Ah={value:""};function So({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:p=!0,customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Vr(),{currentThreadId:y}=pr(),{threadId:w,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:E,checkpoint:_,checkpoints:R,interrupt:L,metadata:H,checkpointIndex:K}=Yr(),{isStreaming:B,error:I,connectionState:W,submit:N,stop:U}=Mi(),O=w??y??null,j=(_==null?void 0:_.id)??null,q=(_==null?void 0:_.namespace)??null,J=(H==null?void 0:H.assemblingMessageId)??null,P=L,[M,G]=b.useState(!1);b.useEffect(()=>{P||G(!1)},[P]);const Z=b.useCallback(()=>{G(!0)},[]),se=b.useCallback(()=>{G(!1)},[]),V=!!P||M,[D,X]=b.useState(null),[Q,ae]=b.useState(""),[$,re]=b.useState(null),[we,de]=b.useState(null),[xe,Ee]=b.useState([]),[Be,We]=b.useState(0),[je,Ve]=b.useState(0),[Xe,ze]=b.useState(!1),[Ge,rt]=b.useState(null),[nt,et]=b.useState(null),[xt,vt]=b.useState(!1),[dt,Et]=b.useState(null),Dt=b.useRef(!1),[$e,Pt]=b.useState(()=>Ah.value),nn=b.useRef($e),Me=b.useRef(null),Ke=b.useCallback(ce=>{Ah.value=ce,Pt(ce)},[]),[Ct,Ze]=b.useState(!1),pt=b.useRef(null),le=b.useRef(null),Y=b.useRef(null),ge=b.useCallback(()=>{le.current&&(le.current.value=""),Y.current&&(Y.current.value=""),We(ce=>ce+1),Ve(ce=>ce+1)},[]),it=b.useCallback(ce=>{Ke(ce)},[Ke]),Ce=b.useRef(!1);b.useEffect(()=>{Ce.current&&!B&&(Ee([]),ge()),Ce.current=B},[B,ge]);const[Oe,qe]=b.useState("desktop");b.useEffect(()=>{const ce=()=>{const ve=window.innerWidth;qe(ve<640?"phone":ve<1024?"tablet":"desktop")};return ce(),window.addEventListener("resize",ce),()=>window.removeEventListener("resize",ce)},[]),b.useEffect(()=>{Dt.current=!1},[O]),b.useEffect(()=>{nn.current=$e},[$e]),b.useEffect(()=>{if(!D){Me.current=null;return}Me.current===null&&(Me.current=nn.current),Ke(Q??"")},[Q,D,Ke]),b.useEffect(()=>{(async()=>{if(!x.baseUrl){Et(null);return}try{const pe=(await x.getAgent("default")).uiDefaultMessage||"";Et(pe||null)}catch(ve){console.warn("Failed to fetch default message:",ve),Et(null)}})()},[x.baseUrl]),b.useEffect(()=>{I&&!xt&&(g==null||g(I))},[I,xt,g]);const Tt=async ce=>{const ve=ce.trim();if(!(!ve&&xe.length===0))try{const pe=D?($==null?void 0:$.checkpointId)??j??void 0:j??void 0,Te=D?($==null?void 0:$.checkpointNs)??q??void 0:q??void 0;await N({text:ve||"",attachments:xe},{checkpointId:pe,checkpointNs:Te,edit:!!D,originalMessageId:D??void 0}),f==null||f(ve),Ke(""),de(null),Ee([]),ge(),X(null),ae(""),re(null)}catch(pe){const Te=(pe==null?void 0:pe.message)||"Failed to send message";de(Te),g==null||g(Te)}},He=b.useCallback((ce,ve,pe)=>{c&&(Me.current=$e,X(ce),ae(ve),Ke(ve),de(null),re({checkpointId:(pe==null?void 0:pe.checkpointId)??null,checkpointNs:(pe==null?void 0:pe.checkpointNs)??null}))},[$e,c,Ke]),ft=b.useCallback(()=>{X(null),ae(""),re(null),de(null),Ke(Me.current??$e),Me.current=null},[$e,Ke]),Fe=b.useCallback((ce,ve,pe)=>{He(ce,ve,pe)},[He]),tt=b.useCallback(ce=>{let ve=null;for(let Je=ce-1;Je>=0;Je--)if(S[Je].role==="user"){ve=S[Je];break}if(!ve)return;const pe=Array.isArray(ve.content)?ve.content:[],bt=pe.filter(Je=>(Je==null?void 0:Je.type)==="text").map(Je=>Je.text).join("")||(()=>{try{return JSON.stringify(pe,null,2)}catch{return String(pe)}})();bt&&N({text:bt},{checkpointId:j??void 0,checkpointNs:q??void 0,edit:!0,originalMessageId:ve.id})},[S,N,j,q]),Ut=ce=>{const ve=Array.from(ce.target.files||[]);Ee(pe=>[...pe,...ve]),ce.target.value=""},ql=ce=>{Ee(ve=>{const pe=ve.filter((Te,bt)=>ce!==bt);return pe.length===0&&ge(),pe})},Gl=async ce=>{const ve=(ce.target.files||[])[0];if(ve){rt(null),et(null),ze(!0);try{await N({attachments:[ve]},{checkpointId:j??void 0,checkpointNs:q??void 0});const pe=`Uploaded ${ve.name} - processing through chat stream`;et(pe)}catch(pe){const Te=pe instanceof Error?pe.message:"Failed to upload Excel file";console.error("Excel upload failed",pe),rt(Te),g==null||g(Te)}finally{ze(!1),ce.target.value="",ge()}}},ci=async ce=>{if(y){Ze(!0);try{if(!ce){await E(),requestAnimationFrame(()=>{var Te;(Te=pt.current)==null||Te.scrollToLatest()});return}const ve=R.find(Te=>Te.checkpointId===ce),pe=(ve==null?void 0:ve.checkpointNs)??null;await T(ce,pe),requestAnimationFrame(()=>{var Te;(Te=pt.current)==null||Te.scrollToTop()})}finally{Ze(!1)}}},A=b.useCallback(async(ce,ve,pe)=>{await ci(pe?null:ce)},[ci]),te=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,fe=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${m.messagesArea||""}`,Ne=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:te,children:[!!I&&!xt&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:I}),u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>vt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ue.X,{size:16})})]}),u.jsxs("div",{className:`relative ${fe}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(cl,{ref:pt,className:"h-full",style:{height:"100%"},messages:S,isStreaming:B,streamingAssistantId:J,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Oe,enableMessageEditing:c,editingMessageId:D,onEdit:Fe,onRegenerate:tt,onCancelEdit:ft,emptyMessage:dt??void 0,isNavigatingCheckpoint:Ct,activeInterrupt:P,disableInterruptActions:M,onInterruptActionStart:Z,onInterruptActionEnd:se,showToolMessages:d,showArtifactPreviews:p,checkpointIndex:K,activeCheckpointId:j,onSelectCheckpoint:A,createSyntheticThinkingMessage:!0}),(W==="reconnecting"||W==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),W==="reconnecting"?"Reconnecting…":"Connecting…"]})}),W==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),C&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||Ct)&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:Ne,children:[D&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ue.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(at,{variant:"ghost",size:"sm",onClick:ft,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ue.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:le,type:"file",multiple:!0,onChange:ce=>Ut(ce),className:"hidden"},Be),xe.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:xe.map((ce,ve)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(ue.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:ce.name}),u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>ql(ve),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${ce.name}`,children:u.jsx(ue.X,{size:12})})]},ve))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:Y,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Gl,className:"hidden"},je),Xe&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),nt&&!Xe&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:nt}),Ge&&!Xe&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Ge})]})]}),we&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:we}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(vs,{children:[u.jsx(ws,{asChild:!0,children:u.jsx(at,{type:"button",size:"icon",variant:"outline",disabled:B||V,title:"More input actions",className:m.moreButton||"",children:u.jsx(ue.Plus,{size:16})})}),u.jsxs(ao,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(On,{onClick:()=>{var ce;return(ce=le.current)==null?void 0:ce.click()},className:"cursor-pointer",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(On,{onClick:()=>{var ce;Xe||(ce=Y.current)==null||ce.click()},className:`cursor-pointer ${Xe?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(gS,{initialValue:Q,editingMessageId:D,value:$e,onValueChange:it,placeholder:D?"Edit your message...":t,isStreaming:B,disabled:V,onSend:Tt,onCancelEdit:ft,onStop:U,allowEmptySend:xe.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${D?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${we?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}var jh=1,CT=.9,TT=.8,kT=.17,ul=.1,dl=.999,ET=.9999,IT=.99,NT=/[\\\/_+.#"@\[\(\{&]/,AT=/[\\\/_+.#"@\[\(\{&]/g,jT=/[\s-]/,_h=/[\s-]/g;function fl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?jh:IT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,p,m,f,v;c>=0;)p=fl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=jh:NT.test(e.charAt(c-1))?(p*=TT,f=e.slice(o,c-1).match(AT),f&&o>0&&(p*=Math.pow(dl,f.length))):jT.test(e.charAt(c-1))?(p*=CT,v=e.slice(o,c-1).match(_h),v&&o>0&&(p*=Math.pow(dl,v.length))):(p*=kT,o>0&&(p*=Math.pow(dl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=ET)),(p<ul&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=fl(e,t,n,r,c+1,s+2,i),m*ul>p&&(p=m*ul)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function Ph(e){return e.toLowerCase().replace(_h," ")}function _T(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,fl(e,t,Ph(e),Ph(t),0,0,{})}var Co='[cmdk-group=""]',pl='[cmdk-group-items=""]',PT='[cmdk-group-heading=""]',Mh='[cmdk-item=""]',Rh=`${Mh}:not([aria-disabled="true"])`,hl="cmdk-item-select",jr="data-value",MT=(e,t,n)=>_T(e,t,n),Oh=h.createContext(void 0),To=()=>h.useContext(Oh),Dh=h.createContext(void 0),ml=()=>h.useContext(Dh),Lh=h.createContext(void 0),$h=h.forwardRef((e,t)=>{let n=_r(()=>{var P,M;return{search:"",value:(M=(P=e.value)!=null?P:e.defaultValue)!=null?M:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=_r(()=>new Set),o=_r(()=>new Map),s=_r(()=>new Map),i=_r(()=>new Set),a=Fh(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=Nt(),S=Nt(),k=Nt(),C=h.useRef(null),T=WT();sr(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,E.emit()}},[d]),sr(()=>{T(6,B)},[]);let E=h.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,M,G)=>{var Z,se,V,D;if(!Object.is(n.current[P],M)){if(n.current[P]=M,P==="search")K(),L(),T(1,H);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(Z=document.getElementById(w))==null||Z.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=I())==null?void 0:X.id,E.emit()}),G||T(5,B),((se=a.current)==null?void 0:se.value)!==void 0){let X=M??"";(D=(V=a.current).onValueChange)==null||D.call(V,X);return}}E.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),_=h.useMemo(()=>({value:(P,M,G)=>{var Z;M!==((Z=s.current.get(P))==null?void 0:Z.value)&&(s.current.set(P,{value:M,keywords:G}),n.current.filtered.items.set(P,R(M,G)),T(2,()=>{L(),E.emit()}))},item:(P,M)=>(r.current.add(P),M&&(o.current.has(M)?o.current.get(M).add(P):o.current.set(M,new Set([P]))),T(3,()=>{K(),L(),n.current.value||H(),E.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let G=I();T(4,()=>{K(),(G==null?void 0:G.getAttribute("id"))===P&&H(),E.emit()})}),group:P=>(o.current.has(P)||o.current.set(P,new Set),()=>{s.current.delete(P),o.current.delete(P)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function R(P,M){var G,Z;let se=(Z=(G=a.current)==null?void 0:G.filter)!=null?Z:MT;return P?se(P,n.current.search,M):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,M=[];n.current.filtered.groups.forEach(Z=>{let se=o.current.get(Z),V=0;se.forEach(D=>{let X=P.get(D);V=Math.max(X,V)}),M.push([Z,V])});let G=C.current;W().sort((Z,se)=>{var V,D;let X=Z.getAttribute("id"),Q=se.getAttribute("id");return((V=P.get(Q))!=null?V:0)-((D=P.get(X))!=null?D:0)}).forEach(Z=>{let se=Z.closest(pl);se?se.appendChild(Z.parentElement===se?Z:Z.closest(`${pl} > *`)):G.appendChild(Z.parentElement===G?Z:Z.closest(`${pl} > *`))}),M.sort((Z,se)=>se[1]-Z[1]).forEach(Z=>{var se;let V=(se=C.current)==null?void 0:se.querySelector(`${Co}[${jr}="${encodeURIComponent(Z[0])}"]`);V==null||V.parentElement.appendChild(V)})}function H(){let P=W().find(G=>G.getAttribute("aria-disabled")!=="true"),M=P==null?void 0:P.getAttribute(jr);E.setState("value",M||void 0)}function K(){var P,M,G,Z;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let se=0;for(let V of r.current){let D=(M=(P=s.current.get(V))==null?void 0:P.value)!=null?M:"",X=(Z=(G=s.current.get(V))==null?void 0:G.keywords)!=null?Z:[],Q=R(D,X);n.current.filtered.items.set(V,Q),Q>0&&se++}for(let[V,D]of o.current)for(let X of D)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(V);break}n.current.filtered.count=se}function B(){var P,M,G;let Z=I();Z&&(((P=Z.parentElement)==null?void 0:P.firstChild)===Z&&((G=(M=Z.closest(Co))==null?void 0:M.querySelector(PT))==null||G.scrollIntoView({block:"nearest"})),Z.scrollIntoView({block:"nearest"}))}function I(){var P;return(P=C.current)==null?void 0:P.querySelector(`${Mh}[aria-selected="true"]`)}function W(){var P;return Array.from(((P=C.current)==null?void 0:P.querySelectorAll(Rh))||[])}function N(P){let M=W()[P];M&&E.setState("value",M.getAttribute(jr))}function U(P){var M;let G=I(),Z=W(),se=Z.findIndex(D=>D===G),V=Z[se+P];(M=a.current)!=null&&M.loop&&(V=se+P<0?Z[Z.length-1]:se+P===Z.length?Z[0]:Z[se+P]),V&&E.setState("value",V.getAttribute(jr))}function O(P){let M=I(),G=M==null?void 0:M.closest(Co),Z;for(;G&&!Z;)G=P>0?HT(G,Co):UT(G,Co),Z=G==null?void 0:G.querySelector(Rh);Z?E.setState("value",Z.getAttribute(jr)):U(P)}let j=()=>N(W().length-1),q=P=>{P.preventDefault(),P.metaKey?j():P.altKey?O(1):U(1)},J=P=>{P.preventDefault(),P.metaKey?N(0):P.altKey?O(-1):U(-1)};return h.createElement(be.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:P=>{var M;(M=y.onKeyDown)==null||M.call(y,P);let G=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||G))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&q(P);break}case"ArrowDown":{q(P);break}case"p":case"k":{x&&P.ctrlKey&&J(P);break}case"ArrowUp":{J(P);break}case"Home":{P.preventDefault(),N(0);break}case"End":{P.preventDefault(),j();break}case"Enter":{P.preventDefault();let Z=I();if(Z){let se=new Event(hl);Z.dispatchEvent(se)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:_.inputId,id:_.labelId,style:KT},l),Ks(e,P=>h.createElement(Dh.Provider,{value:E},h.createElement(Oh.Provider,{value:_},P))))}),RT=h.forwardRef((e,t)=>{var n,r;let o=Nt(),s=h.useRef(null),i=h.useContext(Lh),a=To(),l=Fh(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;sr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Bh(o,s,[e.value,e.children,s],e.keywords),p=ml(),m=Hn(T=>T.value&&T.value===d.current),f=Hn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(hl,v),()=>T.removeEventListener(hl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return h.createElement(be.div,{ref:jn(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),OT=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Nt(),a=h.useRef(null),l=h.useRef(null),c=Nt(),d=To(),p=Hn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);sr(()=>d.group(i),[]),Bh(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(be.div,{ref:jn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Ks(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Lh.Provider,{value:m},f))))}),DT=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Hn(i=>!i.search);return!n&&!s?null:h.createElement(be.div,{ref:jn(o,t),...r,"cmdk-separator":"",role:"separator"})}),LT=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=ml(),i=Hn(c=>c.search),a=Hn(c=>c.selectedItemId),l=To();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(be.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),$T=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Hn(c=>c.selectedItemId),l=To();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(p),m.unobserve(c)}}},[]),h.createElement(be.div,{ref:jn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Ks(e,c=>h.createElement("div",{ref:jn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),FT=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(qa,{open:n,onOpenChange:r},h.createElement(Ga,{container:i},h.createElement(wo,{"cmdk-overlay":"",className:o}),h.createElement(bo,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement($h,{ref:t,...a}))))}),BT=h.forwardRef((e,t)=>Hn(n=>n.filtered.count===0)?h.createElement(be.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),zT=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(be.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Ks(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),zt=Object.assign($h,{List:$T,Item:RT,Input:LT,Group:OT,Separator:DT,Dialog:FT,Empty:BT,Loading:zT});function HT(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function UT(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Fh(e){let t=h.useRef(e);return sr(()=>{t.current=e}),t}var sr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function _r(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Hn(e){let t=ml(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Bh(e,t,n,r=[]){let o=h.useRef(),s=To();return sr(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(jr,a),o.current=a}),o}var WT=()=>{let[e,t]=h.useState(),n=_r(()=>new Map);return sr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function VT(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Ks({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(VT(t),{ref:t.ref},n(t.props.children)):n(t)}var KT={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const gl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));gl.displayName=zt.displayName;const xl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ue.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(zt.Input,{ref:n,className:ne("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));xl.displayName=zt.Input.displayName;const vl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));vl.displayName=zt.List.displayName;const wl=h.forwardRef((e,t)=>u.jsx(zt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));wl.displayName=zt.Empty.displayName;const bl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.Group,{ref:n,className:ne("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));bl.displayName=zt.Group.displayName;const qT=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));qT.displayName=zt.Separator.displayName;const yl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.Item,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));yl.displayName=zt.Item.displayName;function Sl(e,[t,n]){return Math.min(n,Math.max(t,e))}function GT(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Cl="ScrollArea",[zh,l1]=sn(Cl),[YT,tn]=zh(Cl),Hh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[p,m]=h.useState(null),[f,v]=h.useState(null),[g,x]=h.useState(null),[y,w]=h.useState(0),[S,k]=h.useState(0),[C,T]=h.useState(!1),[E,_]=h.useState(!1),R=De(t,H=>l(H)),L=Ko(o);return u.jsx(YT,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:_,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(be.div,{dir:L,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Hh.displayName=Cl;var Uh="ScrollAreaViewport",Wh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=tn(Uh,n),a=h.useRef(null),l=De(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.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}),u.jsx(be.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Wh.displayName=Uh;var Tn="ScrollAreaScrollbar",Tl=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(Tn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(XT,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(JT,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Vh,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(kl,{...r,ref:t}):null});Tl.displayName=Tn;var XT=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(Tn,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ft,{present:n||s,children:u.jsx(Vh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),JT=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(Tn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Xs(()=>l("SCROLL_END"),100),[a,l]=GT("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 h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let p=c[d];const m=()=>{const f=c[d];p!==f&&(l("SCROLL"),i()),p=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Ft,{present:n||a!=="hidden",children:u.jsx(kl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ie(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ie(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Vh=h.forwardRef((e,t)=>{const n=tn(Tn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=Xs(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Pr(n.viewport,l),Pr(n.content,l),u.jsx(Ft,{present:r||s,children:u.jsx(kl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),kl=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=tn(Tn,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Xh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function p(m,f){return rk(m,i.current,a,f)}return n==="horizontal"?u.jsx(ZT,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=Jh(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?u.jsx(QT,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=Jh(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),ZT=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=tn(Tn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=De(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(qh,{"data-orientation":"horizontal",...o,ref:c,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":Ys(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),Qh(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Gs(i.paddingLeft),paddingEnd:Gs(i.paddingRight)}})}})}),QT=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=tn(Tn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=De(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(qh,{"data-orientation":"vertical",...o,ref:c,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":Ys(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),Qh(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Gs(i.paddingTop),paddingEnd:Gs(i.paddingBottom)}})}})}),[ek,Kh]=zh(Tn),qh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:p,...m}=e,f=tn(Tn,n),[v,g]=h.useState(null),x=De(t,R=>g(R)),y=h.useRef(null),w=h.useRef(""),S=f.viewport,k=r.content-r.viewport,C=mt(d),T=mt(l),E=Xs(p,10);function _(R){if(y.current){const L=R.clientX-y.current.left,H=R.clientY-y.current.top;c({x:L,y:H})}}return h.useEffect(()=>{const R=L=>{const H=L.target;(v==null?void 0:v.contains(H))&&C(L,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,k,C]),h.useEffect(T,[r,T]),Pr(v,E),Pr(f.content,E),u.jsx(ek,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:mt(s),onThumbPointerUp:mt(i),onThumbPositionChange:T,onThumbPointerDown:mt(a),children:u.jsx(be.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ie(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),_(R))}),onPointerMove:ie(e.onPointerMove,_),onPointerUp:ie(e.onPointerUp,R=>{const L=R.target;L.hasPointerCapture(R.pointerId)&&L.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),qs="ScrollAreaThumb",Gh=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Kh(qs,e.__scopeScrollArea);return u.jsx(Ft,{present:n||o.hasThumb,children:u.jsx(tk,{ref:t,...r})})}),tk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=tn(qs,n),i=Kh(qs,n),{onThumbPositionChange:a}=i,l=De(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=Xs(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(d(),!c.current){const f=ok(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(be.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ie(e.onPointerDownCapture,p=>{const f=p.target.getBoundingClientRect(),v=p.clientX-f.left,g=p.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ie(e.onPointerUp,i.onThumbPointerUp)})});Gh.displayName=qs;var El="ScrollAreaCorner",Yh=h.forwardRef((e,t)=>{const n=tn(El,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(nk,{...e,ref:t}):null});Yh.displayName=El;var nk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=tn(El,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Pr(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Pr(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(be.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Gs(e){return e?parseInt(e,10):0}function Xh(e,t){const n=e/t;return isNaN(n)?0:n}function Ys(e){const t=Xh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function rk(e,t,n,r="ltr"){const o=Ys(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,p=r==="ltr"?[0,d]:[d*-1,0];return Zh([l,c],p)(e)}function Jh(e,t,n="ltr"){const r=Ys(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=Sl(e,l);return Zh([0,i],[0,a])(c)}function Zh(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 Qh(e,t){return e>0&&e<t}var ok=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Xs(e,t){const n=mt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Pr(e,t){const n=mt(t);kt(()=>{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 em=Hh,sk=Wh,ik=Yh;const Il=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(em,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[u.jsx(sk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(tm,{}),u.jsx(ik,{})]}));Il.displayName=em.displayName;const tm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Tl,{ref:r,orientation:t,className:ne("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:u.jsx(Gh,{className:"relative flex-1 rounded-full bg-border"})}));tm.displayName=Tl.displayName;const Nl=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:ne("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}));Nl.displayName="Input";const ak="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",lk="bg-slate-700 border-slate-600 hover:bg-slate-600",ck="bg-slate-600 border-slate-500";function nm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:p,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??ck}`:`${x??lk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${ak} ${S}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:w?u.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[u.jsx(Nl,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ue.Check,{size:12})}),u.jsx(at,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ue.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(ue.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(vs,{children:[u.jsx(ws,{asChild:!0,children:u.jsx(at,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ue.MoreHorizontal,{size:12})})}),u.jsxs(ao,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(On,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(ue.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(On,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(ue.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(On,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(ue.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const rm=25,om="thread-manager-view",uk=e=>e==="default"||e==="shared",dk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(om);if(uk(e))return e}catch{}return null};function sm({defaultView:e}={}){const[t,n]=b.useState(()=>dk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(om,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const fk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function Al({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:p,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:_,isLoadingSharedThreads:R,actions:L,shareInFlight:H,shareStatus:K,clearShareStatus:B}=pr(),{createThread:I,deleteThread:W,renameThread:N,shareThread:U}=L,{loadThread:O}=Yr(),j=i??T,[q,J]=b.useState(Array.isArray(k)?k:[]),P=b.useRef(q.length>0),M=b.useRef(null),G=b.useRef(0),[Z,se]=b.useState(null),[V,D]=b.useState(""),[X,Q]=b.useState(!1),[ae,$]=b.useState(!1),[re,we]=b.useState(null),[de,xe]=b.useState(""),Ee=v&&v.length>0?v:fk,Be=sm({defaultView:m}),We=g??Be,je=p??We.view,Ve=b.useCallback(Y=>{p||We.setView(Y),f==null||f(Y)},[p,f,We]),Xe=Ee.find(Y=>Y.key===je)??Ee[0],ze=Y=>{we(Y),xe(""),$(!0)},Ge=()=>{$(!1),we(null),xe(""),B()},rt=b.useCallback(async Y=>{if(!(!re||H)&&Y.id)try{await U(re,Y.id),setTimeout(()=>Ge(),600)}catch(ge){console.error("Failed to share thread:",ge)}},[Ge,H,re,U]),nt=b.useMemo(()=>{const Y=y??[],ge=de.trim().toLowerCase();return ge?S?Y.filter(it=>S(it,ge)):Y.filter(it=>`${it.label} ${it.secondaryLabel??""}`.toLowerCase().includes(ge)):Y},[y,de,S]),et=je==="shared",xt=et?C:q,vt=et?R:_,dt=et?"No shared conversations yet":"No conversations yet",Et=Y=>{const ge=Y.sharedAt?` • ${Ze(Y.sharedAt)}`:"";return`Shared by ${Y.sharedByUserId}${ge}`},Dt=Y=>"sharedByUserId"in Y;b.useEffect(()=>{const Y=Array.isArray(k)?k:[];if(Y.length>0){P.current=!0,J(Y);return}_||(P.current=!1,J(Y))},[k,_]),b.useEffect(()=>{if(!M.current)return;const Y=M.current.querySelector("[data-radix-scroll-area-viewport]");if(!Y)return;let ge=null,it=null;return ge=requestAnimationFrame(()=>{it=requestAnimationFrame(()=>{Y.scrollTop=G.current})}),()=>{ge!==null&&cancelAnimationFrame(ge),it!==null&&cancelAnimationFrame(it)}},[q]);const $e=async Y=>{try{E(Y),await O(Y),a==null||a(Y),l==null||l(Y)}catch(ge){console.error("Failed to select thread:",ge)}},Pt=async()=>{try{Q(!0);const Y=await I();Y&&(c==null||c(Y),a==null||a(Y))}catch(Y){console.error("Failed to create thread:",Y)}finally{Q(!1)}},nn=async(Y,ge)=>{if(ge.stopPropagation(),!!confirm("Delete this thread?")){if(M.current){const it=M.current.querySelector("[data-radix-scroll-area-viewport]");it&&(G.current=it.scrollTop)}try{await W(Y),d==null||d(Y)}catch(it){console.error("Failed to delete thread:",it)}}},Me=(Y,ge)=>{ge.stopPropagation(),se(Y.threadId),D(Y.title||`Thread ${Y.threadId.slice(0,8)}`)},Ke=async Y=>{if(V.trim())try{await N(Y,V.trim()),se(null),D("")}catch(ge){console.error("Failed to update title:",ge)}},Ct=()=>{se(null),D("")},Ze=Y=>{if(!Y)return"";try{const ge=new Date(Y),Ce=new Date().getTime()-ge.getTime(),Oe=Math.floor(Ce/(1e3*60*60*24));return Oe===0?ge.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Oe===1?"Yesterday":Oe<7?`${Oe} days ago`:ge.toLocaleDateString()}catch{return""}},pt=Y=>Y.title||`Thread ${Y.threadId.slice(0,8)}`,le=Y=>{const ge=pt(Y);return ge.length<=rm?ge:`${ge.slice(0,rm)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(at,{onClick:Pt,disabled:X||_,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(ue.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(vs,{children:[u.jsx(ws,{asChild:!0,children:u.jsx(at,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:Xe.label})}),u.jsx(ao,{align:"start",sideOffset:6,className:"w-40",children:Ee.map(Y=>u.jsxs(On,{className:"justify-between text-[12px]",onClick:ge=>{ge.preventDefault(),Ve(Y.key)},children:[u.jsx("span",{children:Y.label}),je===Y.key&&u.jsx(ue.Check,{className:"h-3 w-3"})]},Y.key))})]})]})]}),u.jsx(Il,{ref:M,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:vt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):xt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ue.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:dt})]}):xt.slice().sort((Y,ge)=>new Date(ge.updatedAt||ge.createdAt||"").getTime()-new Date(Y.updatedAt||Y.createdAt||"").getTime()).map(Y=>u.jsx(nm,{thread:Y,isActive:j===Y.threadId,editingThreadId:Z,editingTitle:V,onSelect:$e,onStartEditing:Me,onEditingTitleChange:ge=>D(ge),onSaveEditing:Ke,onCancelEditing:Ct,onShare:()=>ze(Y.threadId),onDelete:nn,showEditTitle:r,showDeleteButton:n,formatDate:Ze,getDisplayThreadTitle:le,secondaryLine:et&&Dt(Y)?Et(Y):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Y.threadId))})}),u.jsx(Ya,{open:ae,onOpenChange:Y=>!Y&&Ge(),children:u.jsxs(Ds,{className:"max-w-md p-0",children:[u.jsx(Ls,{children:u.jsx($s,{children:"Share thread"})}),u.jsxs(gl,{children:[u.jsx(xl,{autoFocus:!0,value:de,onValueChange:Y=>xe(Y),placeholder:"Search for recipients..."}),u.jsxs(vl,{children:[K&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[H&&u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:K.startsWith("Failed")?"text-red-500":K.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:K})]}),u.jsx(wl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),nt.length>0&&u.jsx(bl,{heading:"Recipients",children:nt.map(Y=>u.jsx(yl,{onSelect:()=>rt(Y),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:Y.label}),Y.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:Y.secondaryLabel})]})},Y.id))})]})]})]})})]})}function pk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(Xr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(So,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Xr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(Al,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(So,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Xr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(Al,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(So,{onError:s.onError,enableFileUpload:!0})})]})})}function hk({apiConfig:e,className:t="",onError:n}){return u.jsx(Xr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(So,{})})})}var mk="Label",im=h.forwardRef((e,t)=>u.jsx(be.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())}}));im.displayName=mk;var am=im;const gk=Dr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),lm=h.forwardRef(({className:e,...t},n)=>u.jsx(am,{ref:n,className:ne(gk(),e),...t}));lm.displayName=am.displayName;function cm(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var um=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"}),xk="VisuallyHidden",Js=h.forwardRef((e,t)=>u.jsx(be.span,{...e,ref:t,style:{...um,...e.style}}));Js.displayName=xk;var vk=Js,wk=[" ","Enter","ArrowUp","ArrowDown"],bk=[" ","Enter"],ir="Select",[Zs,Qs,yk]=Vo(ir),[Mr,c1]=sn(ir,[yk,yr]),ei=yr(),[Sk,Un]=Mr(ir),[Ck,Tk]=Mr(ir),dm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:p,disabled:m,required:f,form:v}=e,g=ei(t),[x,y]=h.useState(null),[w,S]=h.useState(null),[k,C]=h.useState(!1),T=Ko(c),[E,_]=_n({prop:r,defaultProp:o??!1,onChange:s,caller:ir}),[R,L]=_n({prop:i,defaultProp:a,onChange:l,caller:ir}),H=h.useRef(null),K=x?v||!!x.closest("form"):!0,[B,I]=h.useState(new Set),W=Array.from(B).map(N=>N.props.value).join(";");return u.jsx(ea,{...g,children:u.jsxs(Sk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Nt(),value:R,onValueChange:L,open:E,onOpenChange:_,dir:T,triggerPointerDownPosRef:H,disabled:m,children:[u.jsx(Zs.Provider,{scope:t,children:u.jsx(Ck,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(N=>{I(U=>new Set(U).add(N))},[]),onNativeOptionRemove:h.useCallback(N=>{I(U=>{const O=new Set(U);return O.delete(N),O})},[]),children:n})}),K?u.jsxs(Om,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:R,onChange:N=>L(N.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(B)]},W):null]})})};dm.displayName=ir;var fm="SelectTrigger",pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ei(n),i=Un(fm,n),a=i.disabled||r,l=De(t,i.onTriggerChange),c=Qs(n),d=h.useRef("touch"),[p,m,f]=Lm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=$m(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ta,{asChild:!0,...s,children:u.jsx(be.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Dm(i.value)?"":void 0,...o,ref:l,onClick:ie(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ie(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ie(o.onKeyDown,g=>{const x=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&wk.includes(g.key)&&(v(),g.preventDefault())})})})});pm.displayName=fm;var hm="SelectValue",mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Un(hm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=De(t,l.onValueNodeChange);return kt(()=>{c(d)},[c,d]),u.jsx(be.span,{...a,ref:p,style:{pointerEvents:"none"},children:Dm(l.value)?u.jsx(u.Fragment,{children:i}):s})});mm.displayName=hm;var kk="SelectIcon",gm=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(be.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});gm.displayName=kk;var Ek="SelectPortal",xm=e=>u.jsx(eo,{asChild:!0,...e});xm.displayName=Ek;var ar="SelectContent",vm=h.forwardRef((e,t)=>{const n=Un(ar,e.__scopeSelect),[r,o]=h.useState();if(kt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Lr.createPortal(u.jsx(wm,{scope:e.__scopeSelect,children:u.jsx(Zs.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(bm,{...e,ref:t})});vm.displayName=ar;var fn=10,[wm,Wn]=Mr(ar),Ik="SelectContentImpl",Nk=Vt.createSlot("SelectContent.RemoveScroll"),bm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Un(ar,n),[S,k]=h.useState(null),[C,T]=h.useState(null),E=De(t,V=>k(V)),[_,R]=h.useState(null),[L,H]=h.useState(null),K=Qs(n),[B,I]=h.useState(!1),W=h.useRef(!1);h.useEffect(()=>{if(S)return aa(S)},[S]),$i();const N=h.useCallback(V=>{const[D,...X]=K().map($=>$.ref.current),[Q]=X.slice(-1),ae=document.activeElement;for(const $ of V)if($===ae||($==null||$.scrollIntoView({block:"nearest"}),$===D&&C&&(C.scrollTop=0),$===Q&&C&&(C.scrollTop=C.scrollHeight),$==null||$.focus(),document.activeElement!==ae))return},[K,C]),U=h.useCallback(()=>N([_,S]),[N,_,S]);h.useEffect(()=>{B&&U()},[B,U]);const{onOpenChange:O,triggerPointerDownPosRef:j}=w;h.useEffect(()=>{if(S){let V={x:0,y:0};const D=Q=>{var ae,$;V={x:Math.abs(Math.round(Q.pageX)-(((ae=j.current)==null?void 0:ae.x)??0)),y:Math.abs(Math.round(Q.pageY)-((($=j.current)==null?void 0:$.y)??0))}},X=Q=>{V.x<=10&&V.y<=10?Q.preventDefault():S.contains(Q.target)||O(!1),document.removeEventListener("pointermove",D),j.current=null};return j.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,O,j]),h.useEffect(()=>{const V=()=>O(!1);return window.addEventListener("blur",V),window.addEventListener("resize",V),()=>{window.removeEventListener("blur",V),window.removeEventListener("resize",V)}},[O]);const[q,J]=Lm(V=>{const D=K().filter(ae=>!ae.disabled),X=D.find(ae=>ae.ref.current===document.activeElement),Q=$m(D,V,X);Q&&setTimeout(()=>Q.ref.current.focus())}),P=h.useCallback((V,D,X)=>{const Q=!W.current&&!X;(w.value!==void 0&&w.value===D||Q)&&(R(V),Q&&(W.current=!0))},[w.value]),M=h.useCallback(()=>S==null?void 0:S.focus(),[S]),G=h.useCallback((V,D,X)=>{const Q=!W.current&&!X;(w.value!==void 0&&w.value===D||Q)&&H(V)},[w.value]),Z=r==="popper"?jl:ym,se=Z===jl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(wm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:P,selectedItem:_,onItemLeave:M,itemTextRefCallback:G,focusSelectedItem:U,selectedItemText:L,position:r,isPositioned:B,searchRef:q,children:u.jsx(fs,{as:Nk,allowPinchZoom:!0,children:u.jsx(qo,{asChild:!0,trapped:w.open,onMountAutoFocus:V=>{V.preventDefault()},onUnmountAutoFocus:ie(o,V=>{var D;(D=w.trigger)==null||D.focus({preventScroll:!0}),V.preventDefault()}),children:u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:V=>V.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(Z,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:V=>V.preventDefault(),...y,...se,onPlaced:()=>I(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ie(y.onKeyDown,V=>{const D=V.ctrlKey||V.altKey||V.metaKey;if(V.key==="Tab"&&V.preventDefault(),!D&&V.key.length===1&&J(V.key),["ArrowUp","ArrowDown","Home","End"].includes(V.key)){let Q=K().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);if(["ArrowUp","End"].includes(V.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(V.key)){const ae=V.target,$=Q.indexOf(ae);Q=Q.slice($+1)}setTimeout(()=>N(Q)),V.preventDefault()}})})})})})})});bm.displayName=Ik;var Ak="SelectItemAlignedPosition",ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Un(ar,n),i=Wn(ar,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=De(t,E=>d(E)),m=Qs(n),f=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),_=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const ae=L.left-_.left,$=R.left-ae,re=E.left-$,we=E.width+re,de=Math.max(we,_.width),xe=window.innerWidth-fn,Ee=Sl($,[fn,Math.max(fn,xe-de)]);a.style.minWidth=we+"px",a.style.left=Ee+"px"}else{const ae=_.right-L.right,$=window.innerWidth-R.right-ae,re=window.innerWidth-E.right-$,we=E.width+re,de=Math.max(we,_.width),xe=window.innerWidth-fn,Ee=Sl($,[fn,Math.max(fn,xe-de)]);a.style.minWidth=we+"px",a.style.right=Ee+"px"}const H=m(),K=window.innerHeight-fn*2,B=g.scrollHeight,I=window.getComputedStyle(c),W=parseInt(I.borderTopWidth,10),N=parseInt(I.paddingTop,10),U=parseInt(I.borderBottomWidth,10),O=parseInt(I.paddingBottom,10),j=W+N+B+O+U,q=Math.min(x.offsetHeight*5,j),J=window.getComputedStyle(g),P=parseInt(J.paddingTop,10),M=parseInt(J.paddingBottom,10),G=E.top+E.height/2-fn,Z=K-G,se=x.offsetHeight/2,V=x.offsetTop+se,D=W+N+V,X=j-D;if(D<=G){const ae=H.length>0&&x===H[H.length-1].ref.current;a.style.bottom="0px";const $=c.clientHeight-g.offsetTop-g.offsetHeight,re=Math.max(Z,se+(ae?M:0)+$+U),we=D+re;a.style.height=we+"px"}else{const ae=H.length>0&&x===H[0].ref.current;a.style.top="0px";const re=Math.max(G,W+g.offsetTop+(ae?P:0)+se)+X;a.style.height=re+"px",g.scrollTop=D-G+g.offsetTop}a.style.margin=`${fn}px 0`,a.style.minHeight=q+"px",a.style.maxHeight=K+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);kt(()=>S(),[S]);const[k,C]=h.useState();kt(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(E=>{E&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);return u.jsx(_k,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(be.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});ym.displayName=Ak;var jk="SelectPopperPosition",jl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=fn,...s}=e,i=ei(n);return u.jsx(na,{...i,...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)"}})});jl.displayName=jk;var[_k,_l]=Mr(ar,{}),Pl="SelectViewport",Sm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Wn(Pl,n),i=_l(Pl,n),a=De(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.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}),u.jsx(Zs.Slot,{scope:n,children:u.jsx(be.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ie(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-fn*2,g=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),y=Math.max(g,x);if(y<v){const w=y+f,S=Math.min(v,w),k=w-S;p.style.height=S+"px",p.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,p.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Sm.displayName=Pl;var Cm="SelectGroup",[Pk,Mk]=Mr(Cm),Rk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nt();return u.jsx(Pk,{scope:n,id:o,children:u.jsx(be.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Rk.displayName=Cm;var Tm="SelectLabel",km=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Mk(Tm,n);return u.jsx(be.div,{id:o.id,...r,ref:t})});km.displayName=Tm;var ti="SelectItem",[Ok,Em]=Mr(ti),Im=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Un(ti,n),l=Wn(ti,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=De(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=Nt(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.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 u.jsx(Ok,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(w=>{p(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(Zs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(be.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ie(i.onFocus,()=>f(!0)),onBlur:ie(i.onBlur,()=>f(!1)),onClick:ie(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ie(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ie(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ie(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ie(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ie(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(bk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Im.displayName=ti;var ko="SelectItemText",Nm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Un(ko,n),a=Wn(ko,n),l=Em(ko,n),c=Tk(ko,n),[d,p]=h.useState(null),m=De(t,y=>p(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return kt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(be.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Lr.createPortal(s.children,i.valueNode):null]})});Nm.displayName=ko;var Am="SelectItemIndicator",jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Em(Am,n).isSelected?u.jsx(be.span,{"aria-hidden":!0,...r,ref:t}):null});jm.displayName=Am;var Ml="SelectScrollUpButton",_m=h.forwardRef((e,t)=>{const n=Wn(Ml,e.__scopeSelect),r=_l(Ml,e.__scopeSelect),[o,s]=h.useState(!1),i=De(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Mm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});_m.displayName=Ml;var Rl="SelectScrollDownButton",Pm=h.forwardRef((e,t)=>{const n=Wn(Rl,e.__scopeSelect),r=_l(Rl,e.__scopeSelect),[o,s]=h.useState(!1),i=De(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Mm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Pm.displayName=Rl;var Mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Wn("SelectScrollButton",n),i=h.useRef(null),a=Qs(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),kt(()=>{var d;const c=a().find(p=>p.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(be.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ie(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ie(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ie(o.onPointerLeave,()=>{l()})})}),Dk="SelectSeparator",Rm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(be.div,{"aria-hidden":!0,...r,ref:t})});Rm.displayName=Dk;var Ol="SelectArrow",Lk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ei(n),s=Un(Ol,n),i=Wn(Ol,n);return s.open&&i.position==="popper"?u.jsx(ra,{...o,...r,ref:t}):null});Lk.displayName=Ol;var $k="SelectBubbleInput",Om=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=De(r,o),i=cm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(p)}},[i,t]),u.jsx(be.select,{...n,style:{...um,...n.style},ref:s,defaultValue:t})});Om.displayName=$k;function Dm(e){return e===""||e===void 0}function Lm(e){const t=mt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function $m(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Fk(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Fk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Bk=dm,Fm=pm,zk=mm,Hk=gm,Uk=xm,Bm=vm,Wk=Sm,zm=km,Hm=Im,Vk=Nm,Kk=jm,Um=_m,Wm=Pm,Vm=Rm;const qk=Bk,Gk=zk,Km=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Fm,{ref:r,className:ne("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,u.jsx(Hk,{asChild:!0,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Km.displayName=Fm.displayName;const qm=h.forwardRef(({className:e,...t},n)=>u.jsx(Um,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));qm.displayName=Um.displayName;const Gm=h.forwardRef(({className:e,...t},n)=>u.jsx(Wm,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4"})}));Gm.displayName=Wm.displayName;const Ym=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(Uk,{children:u.jsxs(Bm,{ref:o,className:ne("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:[u.jsx(qm,{}),u.jsx(Wk,{className:ne("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Gm,{})]})}));Ym.displayName=Bm.displayName;const Yk=h.forwardRef(({className:e,...t},n)=>u.jsx(zm,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Yk.displayName=zm.displayName;const Xm=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Hm,{ref:r,className:ne("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Kk,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),u.jsx(Vk,{children:t})]}));Xm.displayName=Hm.displayName;const Xk=h.forwardRef(({className:e,...t},n)=>u.jsx(Vm,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));Xk.displayName=Vm.displayName;var Jk="Separator",Jm="horizontal",Zk=["horizontal","vertical"],Zm=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=Jm,...o}=e,s=Qk(r)?r:Jm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(be.div,{"data-orientation":s,...a,...o,ref:t})});Zm.displayName=Jk;function Qk(e){return Zk.includes(e)}var Qm=Zm;const eg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(Qm,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));eg.displayName=Qm.displayName;var ni="Switch",[eE,u1]=sn(ni),[tE,nE]=eE(ni),tg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...p}=e,[m,f]=h.useState(null),v=De(t,S=>f(S)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=_n({prop:o,defaultProp:s??!1,onChange:c,caller:ni});return u.jsxs(tE,{scope:n,checked:y,disabled:a,children:[u.jsx(be.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":sg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:ie(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(og,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});tg.displayName=ni;var ng="SwitchThumb",rg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=nE(ng,n);return u.jsx(be.span,{"data-state":sg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});rg.displayName=ng;var rE="SwitchBubbleInput",og=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=De(i,s),l=cm(n),c=hd(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});og.displayName=rE;function sg(e){return e?"checked":"unchecked"}var ig=tg,oE=rg;const ag=h.forwardRef(({className:e,...t},n)=>u.jsx(ig,{className:ne("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:u.jsx(oE,{className:ne("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")})}));ag.displayName=ig.displayName;const sE=qa,iE=JC,aE=Ga,lg=h.forwardRef(({className:e,...t},n)=>u.jsx(wo,{className:ne("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}));lg.displayName=wo.displayName;const lE=Dr.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"}}),cg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(aE,{children:[u.jsx(lg,{}),u.jsxs(bo,{ref:o,className:ne(lE({side:e}),t),...r,children:[n,u.jsxs(eh,{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:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));cg.displayName=bo.displayName;const ug=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});ug.displayName="SheetHeader";const dg=h.forwardRef(({className:e,...t},n)=>u.jsx(rr,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));dg.displayName=rr.displayName;const fg=h.forwardRef(({className:e,...t},n)=>u.jsx(Os,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));fg.displayName=Os.displayName;var[ri,d1]=sn("Tooltip",[yr]),oi=yr(),pg="TooltipProvider",cE=700,Dl="tooltip.open",[uE,Ll]=ri(pg),hg=e=>{const{__scopeTooltip:t,delayDuration:n=cE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(uE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};hg.displayName=pg;var Eo="Tooltip",[dE,si]=ri(Eo),mg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Ll(Eo,e.__scopeTooltip),c=oi(t),[d,p]=h.useState(null),m=Nt(),f=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,w]=_n({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Dl))):l.onClose(),s==null||s(E)},caller:Eo}),S=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,w(!0)},[w]),C=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,w(!1)},[w]),T=h.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,w(!0),f.current=0},g)},[g,w]);return h.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(ea,{...c,children:u.jsx(dE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};mg.displayName=Eo;var $l="TooltipTrigger",gg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=si($l,n),s=Ll($l,n),i=oi(n),a=h.useRef(null),l=De(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),p=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),u.jsx(ta,{asChild:!0,...i,children:u.jsx(be.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ie(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ie(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ie(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ie(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ie(e.onBlur,o.onClose),onClick:ie(e.onClick,o.onClose)})})});gg.displayName=$l;var fE="TooltipPortal",[f1,pE]=ri(fE,{forceMount:void 0}),Rr="TooltipContent",xg=h.forwardRef((e,t)=>{const n=pE(Rr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=si(Rr,e.__scopeTooltip);return u.jsx(Ft,{present:r||i.open,children:i.disableHoverableContent?u.jsx(vg,{side:o,...s,ref:t}):u.jsx(hE,{side:o,...s,ref:t})})}),hE=h.forwardRef((e,t)=>{const n=si(Rr,e.__scopeTooltip),r=Ll(Rr,e.__scopeTooltip),o=h.useRef(null),s=De(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:p}=r,m=h.useCallback(()=>{a(null),p(!1)},[p]),f=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=wE(y,x.getBoundingClientRect()),S=bE(y,w),k=yE(g.getBoundingClientRect()),C=CE([...S,...k]);a(C),p(!0)},[p]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!SE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(vg,{...e,ref:s})}),[mE,gE]=ri(Eo,{isInside:!1}),xE=Vt.createSlottable("TooltipContent"),vg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=si(Rr,n),c=oi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Dl,d),()=>document.removeEventListener(Dl,d)),[d]),h.useEffect(()=>{if(l.trigger){const p=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[l.trigger,d]),u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(na,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.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:[u.jsx(xE,{children:r}),u.jsx(mE,{scope:n,isInside:!0,children:u.jsx(vk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});xg.displayName=Rr;var wg="TooltipArrow",vE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=oi(n);return gE(wg,n).isInside?null:u.jsx(ra,{...o,...r,ref:t})});vE.displayName=wg;function wE(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 bE(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 yE(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 SE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function CE(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),TE(t)}function TE(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],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.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],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.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 kE=hg,EE=mg,IE=gg,bg=xg;const NE=kE,AE=EE,jE=IE,yg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(bg,{ref:r,sideOffset:t,className:ne("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}));yg.displayName=bg.displayName;var Fl="ToastProvider",[Bl,_E,PE]=Vo("Toast"),[Sg,p1]=sn("Toast",[PE]),[ME,ii]=Sg(Fl),Cg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),p=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Fl}\`. Expected non-empty \`string\`.`),u.jsx(Bl.Provider,{scope:t,children:u.jsx(ME,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(f=>f+1),[]),onToastRemove:h.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};Cg.displayName=Fl;var Tg="ToastViewport",RE=["F8"],zl="toast.viewportPause",Hl="toast.viewportResume",kg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=RE,label:o="Notifications ({hotkey})",...s}=e,i=ii(Tg,n),a=_E(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=De(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=p.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=p.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(zl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Hl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",w),x.addEventListener("focusout",k),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",C),window.addEventListener("blur",w),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",w),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...qE(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return h.useEffect(()=>{const x=p.current;if(x){const y=w=>{var C,T,E;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const _=document.activeElement,R=w.shiftKey;if(w.target===x&&R){(C=c.current)==null||C.focus();return}const K=g({tabbingDirection:R?"backwards":"forwards"}),B=K.findIndex(I=>I===_);Vl(K.slice(B+1))?w.preventDefault():R?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(kw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Ul,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Vl(x)}}),u.jsx(Bl.Slot,{scope:n,children:u.jsx(be.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Ul,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Vl(x)}})]})});kg.displayName=Tg;var Eg="ToastFocusProxy",Ul=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=ii(Eg,n);return u.jsx(Js,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Ul.displayName=Eg;var Io="Toast",OE="toast.swipeStart",DE="toast.swipeMove",LE="toast.swipeCancel",$E="toast.swipeEnd",Ig=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=_n({prop:r,defaultProp:o??!0,onChange:s,caller:Io});return u.jsx(Ft,{present:n||a,children:u.jsx(zE,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:mt(e.onPause),onResume:mt(e.onResume),onSwipeStart:ie(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ie(e.onSwipeMove,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel:ie(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ie(e.onSwipeEnd,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),l(!1)})})})});Ig.displayName=Io;var[FE,BE]=Sg(Io,{onClose(){}}),zE=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:p,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=ii(Io,n),[x,y]=h.useState(null),w=De(t,I=>y(I)),S=h.useRef(null),k=h.useRef(null),C=o||g.duration,T=h.useRef(0),E=h.useRef(C),_=h.useRef(0),{onToastAdd:R,onToastRemove:L}=g,H=mt(()=>{var W;(x==null?void 0:x.contains(document.activeElement))&&((W=g.viewport)==null||W.focus()),i()}),K=h.useCallback(I=>{!I||I===1/0||(window.clearTimeout(_.current),T.current=new Date().getTime(),_.current=window.setTimeout(H,I))},[H]);h.useEffect(()=>{const I=g.viewport;if(I){const W=()=>{K(E.current),c==null||c()},N=()=>{const U=new Date().getTime()-T.current;E.current=E.current-U,window.clearTimeout(_.current),l==null||l()};return I.addEventListener(zl,N),I.addEventListener(Hl,W),()=>{I.removeEventListener(zl,N),I.removeEventListener(Hl,W)}}},[g.viewport,C,l,c,K]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&K(C)},[s,C,g.isClosePausedRef,K]),h.useEffect(()=>(R(),()=>L()),[R,L]);const B=h.useMemo(()=>x?Rg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[B&&u.jsx(HE,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:B}),u.jsx(FE,{scope:n,onClose:H,children:Lr.createPortal(u.jsx(Bl.ItemSlot,{scope:n,children:u.jsx(Tw,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||H(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(be.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,I=>{I.key==="Escape"&&(a==null||a(I.nativeEvent),I.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,H()))}),onPointerDown:ie(e.onPointerDown,I=>{I.button===0&&(S.current={x:I.clientX,y:I.clientY})}),onPointerMove:ie(e.onPointerMove,I=>{if(!S.current)return;const W=I.clientX-S.current.x,N=I.clientY-S.current.y,U=!!k.current,O=["left","right"].includes(g.swipeDirection),j=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,q=O?j(0,W):0,J=O?0:j(0,N),P=I.pointerType==="touch"?10:2,M={x:q,y:J},G={originalEvent:I,delta:M};U?(k.current=M,ai(DE,p,G,{discrete:!1})):Og(M,g.swipeDirection,P)?(k.current=M,ai(OE,d,G,{discrete:!1}),I.target.setPointerCapture(I.pointerId)):(Math.abs(W)>P||Math.abs(N)>P)&&(S.current=null)}),onPointerUp:ie(e.onPointerUp,I=>{const W=k.current,N=I.target;if(N.hasPointerCapture(I.pointerId)&&N.releasePointerCapture(I.pointerId),k.current=null,S.current=null,W){const U=I.currentTarget,O={originalEvent:I,delta:W};Og(W,g.swipeDirection,g.swipeThreshold)?ai($E,f,O,{discrete:!0}):ai(LE,m,O,{discrete:!0}),U.addEventListener("click",j=>j.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),HE=e=>{const{__scopeToast:t,children:n,...r}=e,o=ii(Io,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return VE(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(eo,{asChild:!0,children:u.jsx(Js,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},UE="ToastTitle",Ng=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(be.div,{...r,ref:t})});Ng.displayName=UE;var WE="ToastDescription",Ag=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(be.div,{...r,ref:t})});Ag.displayName=WE;var jg="ToastAction",_g=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Mg,{altText:n,asChild:!0,children:u.jsx(Wl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${jg}\`. Expected non-empty \`string\`.`),null)});_g.displayName=jg;var Pg="ToastClose",Wl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=BE(Pg,n);return u.jsx(Mg,{asChild:!0,children:u.jsx(be.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,o.onClose)})})});Wl.displayName=Pg;var Mg=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(be.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Rg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),KE(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...Rg(r))}}),t}function ai(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Oi(o,s):o.dispatchEvent(s)}var Og=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function VE(e=()=>{}){const t=mt(e);kt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function KE(e){return e.nodeType===e.ELEMENT_NODE}function qE(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 Vl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var GE=Cg,Dg=kg,Lg=Ig,$g=Ng,Fg=Ag,Bg=_g,zg=Wl;const YE=GE,Hg=h.forwardRef(({className:e,...t},n)=>u.jsx(Dg,{ref:n,className:ne("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Hg.displayName=Dg.displayName;const XE=Dr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Ug=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Lg,{ref:r,className:ne(XE({variant:t}),e),...n}));Ug.displayName=Lg.displayName;const JE=h.forwardRef(({className:e,...t},n)=>u.jsx(Bg,{ref:n,className:ne("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));JE.displayName=Bg.displayName;const Wg=h.forwardRef(({className:e,...t},n)=>u.jsx(zg,{ref:n,className:ne("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(ue.X,{className:"h-4 w-4"})}));Wg.displayName=zg.displayName;const Vg=h.forwardRef(({className:e,...t},n)=>u.jsx($g,{ref:n,className:ne("text-sm font-semibold",e),...t}));Vg.displayName=$g.displayName;const Kg=h.forwardRef(({className:e,...t},n)=>u.jsx(Fg,{ref:n,className:ne("text-sm opacity-90",e),...t}));Kg.displayName=Fg.displayName;function ZE(){const{toasts:e}=Za();return u.jsxs(YE,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Ug,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Vg,{children:n}),r&&u.jsx(Kg,{children:r})]}),o,u.jsx(Wg,{})]},t)}),u.jsx(Hg,{})]})}var QE=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),p(f)}function p(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},eI=h.createContext(void 0),tI={setTheme:e=>{},themes:[]},nI=()=>{var e;return(e=h.useContext(eI))!=null?e:tI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${QE.toString()})(${d})`}})});var rI=e=>{switch(e){case"success":return iI;case"info":return lI;case"warning":return aI;case"error":return cI;default:return null}},oI=Array(12).fill(0),sI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},oI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),iI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),aI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),lI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),cI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),uI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),dI=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Kl=1,fI=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Kl++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],b.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(hI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Kl++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Ht=new fI,pI=(e,t)=>{let n=(t==null?void 0:t.id)||Kl++;return Ht.addToast({title:e,...t,id:n}),n},hI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",mI=pI,gI=()=>Ht.toasts,xI=()=>Ht.getActiveToasts();Object.assign(mI,{success:Ht.success,info:Ht.info,warning:Ht.warning,error:Ht.error,custom:Ht.custom,message:Ht.message,promise:Ht.promise,dismiss:Ht.dismiss,loading:Ht.loading},{getHistory:gI,getToasts:xI});function vI(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}vI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
129
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[v[W]?u.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[U,v[W]?" (processing)":""]})]},W)}if(I.type==="interrupt"){const N=I,U=Wo((N==null?void 0:N.id)??(N==null?void 0:N.interrupt_id)),O=!!(_&&U&&U===_),j=O?R??(N==null?void 0:N.value):N==null?void 0:N.value,q=U?{...N,id:U,interrupt_id:U}:N;return u.jsx(yh,{interruptPart:q,onApprove:g,onReject:x,disabled:y,isActive:O,payload:j},W)}return null},[f,v,g,x,w,S,k,C,E,_,R,y]),B=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!p)return H();if(!t&&!B&&!p)return null;if(t)return!n&&r?null:n?u.jsx(Ch,{message:e,viewMode:o,isStreaming:s},e.id):null;if(!m){const I=u.jsx("div",{className:"space-y-2",children:i.map((W,N)=>u.jsx(K,{part:W,i:N},N))});return p?u.jsxs("div",{"aria-busy":"true",role:"status",children:[I,u.jsx(Th,{className:L})]}):I}return null}function Ih(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Za(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),p=b.useCallback(f=>{a(f),c(!0)},[]),m=b.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";p({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await eu(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");p({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,p]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Nh(e,t){return b.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:$v(r),toolMeta:Ai(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Fv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Vs=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:p=!0,showArtifactPreviews:m=!0,customStyles:f={},onEdit:v,onRegenerate:g,onCancelEdit:x,onCopy:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,checkpointCandidates:T=[],activeCheckpointId:E=null,onSelectCheckpoint:_,defaultCheckpointId:R=null,messageParentCheckpointId:L=null}){const[H,K]=b.useState(!1),[B,I]=b.useState("preview"),[W,N]=b.useState(!1),{currentThreadId:U}=pr(),{respondToInterrupt:O}=Yr(),j=l==="phone"||l==="half-screen",q=t.role,J=q==="tool",P=b.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),M=!!P,G=!(r&&q!=="user"),{uploadingFiles:Z,handleFileClick:se,fileViewerOpen:V,currentFileInfo:D,closeFileViewer:X}=Ih({allowFileOpen:G,currentThreadId:U}),Q=b.useMemo(()=>{switch(q){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[q]),ae=Nh(t,P),{contentParts:$,imageParts:re,fileParts:we,interruptParts:de,textContent:xe,toolMeta:Ee,toolRaw:Be,isToolStreaming:We}=ae,je=(w==null?void 0:w.id)??(w==null?void 0:w.interrupt_id),Ve=Wo(je),Xe=w==null?void 0:w.value,ze=b.useMemo(()=>P||!m?null:t.artifact||null,[P,t,m]),Ge=b.useCallback(async()=>{const le=J?Be:xe;async function Y(ge){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ge);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const it=new Blob([ge],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":it})]);return}throw new Error("Clipboard API not supported in this context.")}try{await Y(le),K(!0),setTimeout(()=>K(!1),2e3),y==null||y(le)}catch(ge){console.error("Failed to copy:",ge)}},[J,Be,xe,y]),rt=b.useCallback(()=>{if(!v||!t.id)return;const le=(J?Be:xe)??"",Y="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,le,Y)},[v,t.id,J,Be,xe,t]),nt=b.useCallback(()=>{g==null||g(n)},[g,n]),et=b.useCallback(()=>{const Y=ne(j?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Q);switch(q){case"user":return u.jsx(ue.User,{className:Y});case"assistant":return u.jsx(ue.Bot,{className:Y});case"tool":return u.jsx(ue.Wrench,{className:Y});default:return u.jsx(ue.Bot,{className:Y})}},[j,Q,q]),xt=b.useCallback(()=>{const le="group relative mb-4 flex w-full";switch(q){case"user":return ne(le,"justify-end");case"assistant":case"tool":case"system":return ne(le,"justify-start");default:return le}},[q]),vt=b.useCallback(()=>{const le=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",j&&"px-3 py-2 text-sm");if(M)return ne(le,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(q){case"user":return ne(le,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return ne(le,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return ne(le,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(le,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(le,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[j,M,q]),dt=b.useCallback(async le=>{if(S)return;const Y=Wo((le==null?void 0:le.id)??(le==null?void 0:le.interrupt_id));if(!Y){console.warn("Interrupt part missing id",le);return}try{k==null||k(),await O(Y,!0)}catch(ge){console.error("Failed to approve interrupt:",ge)}finally{C==null||C()}},[S,C,k,O]),Et=b.useCallback(async le=>{if(S)return;const Y=Wo((le==null?void 0:le.id)??(le==null?void 0:le.interrupt_id));if(!Y){console.warn("Interrupt part missing id",le);return}try{k==null||k(),await O(Y,!1)}catch(ge){console.error("Failed to reject interrupt:",ge)}finally{C==null||C()}},[S,C,k,O]),Dt=b.useMemo(()=>P?"Assistant":Bv(t),[P,t]),$e=b.useMemo(()=>P?[]:Array.isArray(T)?T:[],[T,P]),Pt=b.useMemo(()=>{var le;return $e.length?R&&$e.some(Y=>Y.id===R)?R:((le=$e[0])==null?void 0:le.id)??null:null},[R,$e]),Me=b.useMemo(()=>!$e.length||!E?null:$e.some(le=>le.id===E)?E:null,[E,$e])??Pt,Ke=q==="user"&&$e.length>0&&typeof _=="function",Ct=b.useCallback((le,Y=!1)=>{if(!_)return;const ge=(le==null?void 0:le.id)??null,it=(le==null?void 0:le.parentId)??L??null;_(ge,it,Y)},[L,_]),Ze=b.useMemo(()=>Me?$e.findIndex(le=>le.id===Me):-1,[Me,$e]),pt=b.useMemo(()=>Ze<0?null:$e[Ze]??null,[Ze,$e]);return J&&!p&&!ze?null:M&&P?u.jsx("div",{className:ne(xt(),f.container),children:u.jsxs("div",{className:ne(vt(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ue.Bot,{className:ne("h-4 w-4",Q)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Ar,{content:P.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne(xt(),f.container),children:u.jsxs("div",{className:ne(vt(),f.content),children:[(i||a||J)&&u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",j&&"mb-1 pb-1",Q,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[et(),a&&Dt&&u.jsx("span",{className:ne("font-medium",j?"text-xs":"text-sm"),children:Dt}),J&&u.jsxs(Lp,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",Q,"border border-current/40",j&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":B==="expanded",onClick:()=>I(le=>le==="expanded"?"preview":"expanded"),onKeyDown:le=>{(le.key==="Enter"||le.key===" ")&&(le.preventDefault(),I(Y=>Y==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:Ee.name??"Tool Output"}),Ee.toolCallId&&u.jsx("span",{className:"opacity-70",children:Ee.toolCallId.slice(0,8)}),B==="expanded"?u.jsx(ue.ChevronUp,{className:"h-3 w-3"}):u.jsx(ue.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[Ke&&pt&&Ze>=0&&u.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ze<$e.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ze>=$e.length-1)return;const le=$e[Ze+1];le&&Ct(le)},"aria-label":"Older checkpoint (back in time)",disabled:Ze>=$e.length-1,children:u.jsx(ue.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[$e.length-Ze," / ",$e.length]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ze>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(!(Ze<=0))if(Ze===1)Ct(null,!0);else{const le=$e[Ze-1];le&&Ct(le,!1)}},"aria-label":"Newer checkpoint (forward in time)",disabled:Ze<=0,children:u.jsx(ue.ChevronRight,{className:"h-3 w-3"})})]})}),i&&t.createdAt&&u.jsx("time",{className:ne("text-xs opacity-60",Q,j&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>Ge(),className:ne("h-6 w-6 p-0 hover:bg-foreground/10",Q,j&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ue.Copy,{className:ne(H?"text-success":Q,j?"h-3 w-3":"h-4 w-4")})})}),q==="user"&&v&&u.jsx(at,{variant:"ghost",size:"sm",onClick:rt,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",Q,j&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ue.Edit,{className:ne(Q,j?"h-3 w-3":"h-4 w-4")})}),q==="assistant"&&g&&u.jsx(at,{variant:"ghost",size:"sm",onClick:nt,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",Q,j&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ue.RotateCcw,{className:ne(Q,j?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(Eh,{message:t,isToolMessage:J,showToolMessages:p,artifactToRender:ze,toolViewMode:B,isToolStreaming:We,contentParts:$,textContent:xe,imageParts:re,fileParts:we,interruptParts:de,isStreamingMessage:r,defaultMessage:P,handleFileClick:se,uploadingFiles:Z,handleInterruptApprove:dt,handleInterruptReject:Et,disableInterruptActions:S,messageRole:q,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:W,setIsUserExpanded:N,isCompactLayout:j,activeInterruptId:Ve,activeInterruptValue:Xe,iconForeground:Q}),m&&ze&&u.jsx("div",{className:"mt-3",children:u.jsx(wh,{artifact:ze,idx:0})})]}),J&&B==="expanded"&&(Ee.toolCallId||Ee.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",j&&"text-xs"),children:[Ee.name&&u.jsxs("div",{children:["Function: ",Ee.name]}),Ee.toolCallId&&u.jsxs("div",{children:["Call ID: ",Ee.toolCallId]})]}),!(i||a||J)&&s&&!o&&u.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>Ge(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:u.jsx(ue.Copy,{className:ne(H?"text-success":"text-current",j?"h-3 w-3":"h-4 w-4")})}),q==="user"&&v&&u.jsx(at,{variant:"ghost",size:"sm",onClick:rt,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:u.jsx(ue.Edit,{className:ne("text-current",j?"h-3 w-3":"h-4 w-4")})}),q==="assistant"&&g&&u.jsx(at,{variant:"ghost",size:"sm",onClick:nt,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:u.jsx(ue.RotateCcw,{className:ne("text-current",j?"h-3 w-3":"h-4 w-4")})})]})]})}),D&&u.jsx(rh,{isOpen:V,onClose:X,fileId:D.id,fileName:D.name,mimeType:D.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&uu(e.message)===uu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((p=t.customStyles)==null?void 0:p.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=du(e.message),a=du(t.message);return i.length===a.length});Vs.displayName="MessageComponent";const al=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,ll=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointIndex:w,activeCheckpointId:S,onSelectCheckpoint:k}){const C=al(t,n),T="type"in t&&t.type==="default_message",_=!!t.__syntheticStreaming,{checkpointCandidates:R,defaultCheckpointId:L}=Zl(t,w??{checkpoints:[],checkpointMetaByCheckpointId:new Map,userMessageIdToAttempts:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getAttempts:()=>[]}),H=t&&!T?t.additionalKwargs??{}:{},K=t&&!T?t.responseMetadata??{}:{},B=(()=>{if(typeof H.parentCheckpointId=="string")return H.parentCheckpointId;if(typeof K.parentCheckpointId=="string")return K.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":C,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Vs,{message:t,messageIndex:n,isStreamingMessage:_||r&&o===t.id,streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointCandidates:R,activeCheckpointId:S??null,onSelectCheckpoint:k,defaultCheckpointId:L,messageParentCheckpointId:B})})});ll.displayName="MessageRow";const cl=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:p,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,showArtifactPreviews:E=!0,checkpointIndex:_,activeCheckpointId:R,onSelectCheckpoint:L,createSyntheticThinkingMessage:H=!0},K)=>{const B=b.useRef(null),I=b.useRef(null),W=b.useRef(!1),N=b.useRef(!1),[U,O]=b.useState(!0),j=b.useMemo(()=>w?e.some($=>"type"in $&&$.type==="default_message"?!1:Array.isArray($==null?void 0:$.content)&&$.content.some(re=>re&&re.type==="interrupt"&&(re.id??re.interrupt_id)===w.id)):!1,[w,e]),q=b.useMemo(()=>{if(!w||j)return null;const $=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let re;const we=w.value;if(we&&typeof we=="object"&&!Array.isArray(we)){const de=we.title;typeof de=="string"&&de.trim()&&(re=de.trim())}return{id:`interrupt-${$}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:$,value:we,title:re}]}},[w,j]),J=b.useMemo(()=>q?[...e,q]:e,[e,q]),P=b.useMemo(()=>!H||!t?J:!J.some(re=>re.role==="assistant")&&J.length>0?[...J,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:J,[J,t,H]),M=b.useMemo(()=>T?P:P.filter($=>($==null?void 0:$.role)!=="tool"),[P,T]),G=b.useCallback($=>{O($),x&&x(!$),y&&y($)},[x,y]),Z=b.useMemo(()=>{if(a)return async()=>{if(!W.current){W.current=!0;try{await a()}finally{W.current=!1}}}},[a]),se=b.useMemo(()=>!v||g?!1:U?"auto":!1,[U,v,g]),V=b.useMemo(()=>{if(typeof f!="string")return null;const $=f.trim();return $?{id:"default-message",role:"assistant",type:"default_message",content:$,createdAt:new Date().toISOString()}:null},[f]),D=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),X=()=>V?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Vs,{message:V,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),Q=M.length,ae=Q>0;return b.useEffect(()=>{var $,re;if(Q===0){N.current=!1;return}if(!N.current)if(N.current=!0,B.current&&M.length>0){const we=M.length-1;(re=($=B.current).scrollToIndex)==null||re.call($,{index:we,align:"end",behavior:"auto"})}else I.current&&(I.current.scrollTop=I.current.scrollHeight)},[Q,M.length]),b.useImperativeHandle(K,()=>({scrollToLatest:()=>{var $,re;if(B.current&&M.length>0){const we=M.length-1;(re=($=B.current).scrollToIndex)==null||re.call($,{index:we,align:"end",behavior:"auto"})}else I.current&&(I.current.scrollTop=I.current.scrollHeight)},scrollToTop:()=>{var $,re;B.current&&M.length>0?(re=($=B.current).scrollToIndex)==null||re.call($,{index:0,align:"start",behavior:"auto"}):I.current&&(I.current.scrollTop=0)}}),[M]),u.jsx("div",{className:D,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ae?u.jsx(EC,{ref:$=>{B.current=$},scrollerRef:$=>{I.current=$ instanceof HTMLDivElement?$:null},data:M,followOutput:se,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{Z&&Z()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:($,re)=>al(re,$),itemContent:($,re)=>u.jsx(ll,{message:re,index:$,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,showArtifactPreviews:E,checkpointIndex:_,activeCheckpointId:R,onSelectCheckpoint:L})}):X()})})});cl.displayName="MessageList";const Ah={value:""};function So({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:p=!0,customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Vr(),{currentThreadId:y}=pr(),{threadId:w,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:E,checkpoint:_,checkpoints:R,interrupt:L,metadata:H,checkpointIndex:K}=Yr(),{isStreaming:B,error:I,connectionState:W,submit:N,stop:U}=Mi(),O=w??y??null,j=(_==null?void 0:_.id)??null,q=(_==null?void 0:_.namespace)??null,J=(H==null?void 0:H.assemblingMessageId)??null,P=L,[M,G]=b.useState(!1);b.useEffect(()=>{P||G(!1)},[P]);const Z=b.useCallback(()=>{G(!0)},[]),se=b.useCallback(()=>{G(!1)},[]),V=!!P||M,[D,X]=b.useState(null),[Q,ae]=b.useState(""),[$,re]=b.useState(null),[we,de]=b.useState(null),[xe,Ee]=b.useState([]),[Be,We]=b.useState(0),[je,Ve]=b.useState(0),[Xe,ze]=b.useState(!1),[Ge,rt]=b.useState(null),[nt,et]=b.useState(null),[xt,vt]=b.useState(!1),[dt,Et]=b.useState(null),Dt=b.useRef(!1),[$e,Pt]=b.useState(()=>Ah.value),nn=b.useRef($e),Me=b.useRef(null),Ke=b.useCallback(ce=>{Ah.value=ce,Pt(ce)},[]),[Ct,Ze]=b.useState(!1),pt=b.useRef(null),le=b.useRef(null),Y=b.useRef(null),ge=b.useCallback(()=>{le.current&&(le.current.value=""),Y.current&&(Y.current.value=""),We(ce=>ce+1),Ve(ce=>ce+1)},[]),it=b.useCallback(ce=>{Ke(ce)},[Ke]),Ce=b.useRef(!1);b.useEffect(()=>{Ce.current&&!B&&(Ee([]),ge()),Ce.current=B},[B,ge]);const[Oe,qe]=b.useState("desktop");b.useEffect(()=>{const ce=()=>{const ve=window.innerWidth;qe(ve<640?"phone":ve<1024?"tablet":"desktop")};return ce(),window.addEventListener("resize",ce),()=>window.removeEventListener("resize",ce)},[]),b.useEffect(()=>{Dt.current=!1},[O]),b.useEffect(()=>{nn.current=$e},[$e]),b.useEffect(()=>{if(!D){Me.current=null;return}Me.current===null&&(Me.current=nn.current),Ke(Q??"")},[Q,D,Ke]),b.useEffect(()=>{(async()=>{if(!x.baseUrl){Et(null);return}try{const pe=(await x.getAgent("default")).uiDefaultMessage||"";Et(pe||null)}catch(ve){console.warn("Failed to fetch default message:",ve),Et(null)}})()},[x.baseUrl]),b.useEffect(()=>{I&&!xt&&(g==null||g(I))},[I,xt,g]);const Tt=async ce=>{const ve=ce.trim();if(!(!ve&&xe.length===0))try{const pe=D?($==null?void 0:$.checkpointId)??j??void 0:j??void 0,Te=D?($==null?void 0:$.checkpointNs)??q??void 0:q??void 0;await N({text:ve||"",attachments:xe},{checkpointId:pe,checkpointNs:Te,edit:!!D,originalMessageId:D??void 0}),f==null||f(ve),Ke(""),de(null),Ee([]),ge(),X(null),ae(""),re(null)}catch(pe){const Te=(pe==null?void 0:pe.message)||"Failed to send message";de(Te),g==null||g(Te)}},He=b.useCallback((ce,ve,pe)=>{c&&(Me.current=$e,X(ce),ae(ve),Ke(ve),de(null),re({checkpointId:(pe==null?void 0:pe.checkpointId)??null,checkpointNs:(pe==null?void 0:pe.checkpointNs)??null}))},[$e,c,Ke]),ft=b.useCallback(()=>{X(null),ae(""),re(null),de(null),Ke(Me.current??$e),Me.current=null},[$e,Ke]),Fe=b.useCallback((ce,ve,pe)=>{He(ce,ve,pe)},[He]),tt=b.useCallback(ce=>{let ve=null;for(let Je=ce-1;Je>=0;Je--)if(S[Je].role==="user"){ve=S[Je];break}if(!ve)return;const pe=Array.isArray(ve.content)?ve.content:[],bt=pe.filter(Je=>(Je==null?void 0:Je.type)==="text").map(Je=>Je.text).join("")||(()=>{try{return JSON.stringify(pe,null,2)}catch{return String(pe)}})();bt&&N({text:bt},{checkpointId:j??void 0,checkpointNs:q??void 0,edit:!0,originalMessageId:ve.id})},[S,N,j,q]),Ut=ce=>{const ve=Array.from(ce.target.files||[]);Ee(pe=>[...pe,...ve]),ce.target.value=""},ql=ce=>{Ee(ve=>{const pe=ve.filter((Te,bt)=>ce!==bt);return pe.length===0&&ge(),pe})},Gl=async ce=>{const ve=(ce.target.files||[])[0];if(ve){rt(null),et(null),ze(!0);try{await N({attachments:[ve]},{checkpointId:j??void 0,checkpointNs:q??void 0});const pe=`Uploaded ${ve.name} - processing through chat stream`;et(pe)}catch(pe){const Te=pe instanceof Error?pe.message:"Failed to upload Excel file";console.error("Excel upload failed",pe),rt(Te),g==null||g(Te)}finally{ze(!1),ce.target.value="",ge()}}},ci=async ce=>{if(y){Ze(!0);try{if(!ce){await E(),requestAnimationFrame(()=>{var Te;(Te=pt.current)==null||Te.scrollToLatest()});return}const ve=R.find(Te=>Te.checkpointId===ce),pe=(ve==null?void 0:ve.checkpointNs)??null;await T(ce,pe),requestAnimationFrame(()=>{var Te;(Te=pt.current)==null||Te.scrollToTop()})}finally{Ze(!1)}}},A=b.useCallback(async(ce,ve,pe)=>{await ci(pe?null:ce)},[ci]),te=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,fe=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${m.messagesArea||""}`,Ne=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:te,children:[!!I&&!xt&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:I}),u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>vt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ue.X,{size:16})})]}),u.jsxs("div",{className:`relative ${fe}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(cl,{ref:pt,className:"h-full",style:{height:"100%"},messages:S,isStreaming:B,streamingAssistantId:J,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Oe,enableMessageEditing:c,editingMessageId:D,onEdit:Fe,onRegenerate:tt,onCancelEdit:ft,emptyMessage:dt??void 0,isNavigatingCheckpoint:Ct,activeInterrupt:P,disableInterruptActions:M,onInterruptActionStart:Z,onInterruptActionEnd:se,showToolMessages:d,showArtifactPreviews:p,checkpointIndex:K,activeCheckpointId:j,onSelectCheckpoint:A,createSyntheticThinkingMessage:!0}),(W==="reconnecting"||W==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),W==="reconnecting"?"Reconnecting…":"Connecting…"]})}),W==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),C&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||Ct)&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:Ne,children:[D&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ue.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(at,{variant:"ghost",size:"sm",onClick:ft,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ue.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:le,type:"file",multiple:!0,onChange:ce=>Ut(ce),className:"hidden"},Be),xe.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:xe.map((ce,ve)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(ue.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:ce.name}),u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>ql(ve),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${ce.name}`,children:u.jsx(ue.X,{size:12})})]},ve))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:Y,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Gl,className:"hidden"},je),Xe&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),nt&&!Xe&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:nt}),Ge&&!Xe&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Ge})]})]}),we&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:we}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(vs,{children:[u.jsx(ws,{asChild:!0,children:u.jsx(at,{type:"button",size:"icon",variant:"outline",disabled:B||V,title:"More input actions",className:m.moreButton||"",children:u.jsx(ue.Plus,{size:16})})}),u.jsxs(ao,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(On,{onClick:()=>{var ce;return(ce=le.current)==null?void 0:ce.click()},className:"cursor-pointer",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(On,{onClick:()=>{var ce;Xe||(ce=Y.current)==null||ce.click()},className:`cursor-pointer ${Xe?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(gS,{initialValue:Q,editingMessageId:D,value:$e,onValueChange:it,placeholder:D?"Edit your message...":t,isStreaming:B,disabled:V,onSend:Tt,onCancelEdit:ft,onStop:U,allowEmptySend:xe.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${D?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${we?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}var jh=1,CT=.9,TT=.8,kT=.17,ul=.1,dl=.999,ET=.9999,IT=.99,NT=/[\\\/_+.#"@\[\(\{&]/,AT=/[\\\/_+.#"@\[\(\{&]/g,jT=/[\s-]/,_h=/[\s-]/g;function fl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?jh:IT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,p,m,f,v;c>=0;)p=fl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=jh:NT.test(e.charAt(c-1))?(p*=TT,f=e.slice(o,c-1).match(AT),f&&o>0&&(p*=Math.pow(dl,f.length))):jT.test(e.charAt(c-1))?(p*=CT,v=e.slice(o,c-1).match(_h),v&&o>0&&(p*=Math.pow(dl,v.length))):(p*=kT,o>0&&(p*=Math.pow(dl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=ET)),(p<ul&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=fl(e,t,n,r,c+1,s+2,i),m*ul>p&&(p=m*ul)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function Ph(e){return e.toLowerCase().replace(_h," ")}function _T(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,fl(e,t,Ph(e),Ph(t),0,0,{})}var Co='[cmdk-group=""]',pl='[cmdk-group-items=""]',PT='[cmdk-group-heading=""]',Mh='[cmdk-item=""]',Rh=`${Mh}:not([aria-disabled="true"])`,hl="cmdk-item-select",jr="data-value",MT=(e,t,n)=>_T(e,t,n),Oh=h.createContext(void 0),To=()=>h.useContext(Oh),Dh=h.createContext(void 0),ml=()=>h.useContext(Dh),Lh=h.createContext(void 0),$h=h.forwardRef((e,t)=>{let n=_r(()=>{var P,M;return{search:"",value:(M=(P=e.value)!=null?P:e.defaultValue)!=null?M:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=_r(()=>new Set),o=_r(()=>new Map),s=_r(()=>new Map),i=_r(()=>new Set),a=Fh(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=Nt(),S=Nt(),k=Nt(),C=h.useRef(null),T=WT();sr(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,E.emit()}},[d]),sr(()=>{T(6,B)},[]);let E=h.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,M,G)=>{var Z,se,V,D;if(!Object.is(n.current[P],M)){if(n.current[P]=M,P==="search")K(),L(),T(1,H);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(Z=document.getElementById(w))==null||Z.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=I())==null?void 0:X.id,E.emit()}),G||T(5,B),((se=a.current)==null?void 0:se.value)!==void 0){let X=M??"";(D=(V=a.current).onValueChange)==null||D.call(V,X);return}}E.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),_=h.useMemo(()=>({value:(P,M,G)=>{var Z;M!==((Z=s.current.get(P))==null?void 0:Z.value)&&(s.current.set(P,{value:M,keywords:G}),n.current.filtered.items.set(P,R(M,G)),T(2,()=>{L(),E.emit()}))},item:(P,M)=>(r.current.add(P),M&&(o.current.has(M)?o.current.get(M).add(P):o.current.set(M,new Set([P]))),T(3,()=>{K(),L(),n.current.value||H(),E.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let G=I();T(4,()=>{K(),(G==null?void 0:G.getAttribute("id"))===P&&H(),E.emit()})}),group:P=>(o.current.has(P)||o.current.set(P,new Set),()=>{s.current.delete(P),o.current.delete(P)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function R(P,M){var G,Z;let se=(Z=(G=a.current)==null?void 0:G.filter)!=null?Z:MT;return P?se(P,n.current.search,M):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,M=[];n.current.filtered.groups.forEach(Z=>{let se=o.current.get(Z),V=0;se.forEach(D=>{let X=P.get(D);V=Math.max(X,V)}),M.push([Z,V])});let G=C.current;W().sort((Z,se)=>{var V,D;let X=Z.getAttribute("id"),Q=se.getAttribute("id");return((V=P.get(Q))!=null?V:0)-((D=P.get(X))!=null?D:0)}).forEach(Z=>{let se=Z.closest(pl);se?se.appendChild(Z.parentElement===se?Z:Z.closest(`${pl} > *`)):G.appendChild(Z.parentElement===G?Z:Z.closest(`${pl} > *`))}),M.sort((Z,se)=>se[1]-Z[1]).forEach(Z=>{var se;let V=(se=C.current)==null?void 0:se.querySelector(`${Co}[${jr}="${encodeURIComponent(Z[0])}"]`);V==null||V.parentElement.appendChild(V)})}function H(){let P=W().find(G=>G.getAttribute("aria-disabled")!=="true"),M=P==null?void 0:P.getAttribute(jr);E.setState("value",M||void 0)}function K(){var P,M,G,Z;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let se=0;for(let V of r.current){let D=(M=(P=s.current.get(V))==null?void 0:P.value)!=null?M:"",X=(Z=(G=s.current.get(V))==null?void 0:G.keywords)!=null?Z:[],Q=R(D,X);n.current.filtered.items.set(V,Q),Q>0&&se++}for(let[V,D]of o.current)for(let X of D)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(V);break}n.current.filtered.count=se}function B(){var P,M,G;let Z=I();Z&&(((P=Z.parentElement)==null?void 0:P.firstChild)===Z&&((G=(M=Z.closest(Co))==null?void 0:M.querySelector(PT))==null||G.scrollIntoView({block:"nearest"})),Z.scrollIntoView({block:"nearest"}))}function I(){var P;return(P=C.current)==null?void 0:P.querySelector(`${Mh}[aria-selected="true"]`)}function W(){var P;return Array.from(((P=C.current)==null?void 0:P.querySelectorAll(Rh))||[])}function N(P){let M=W()[P];M&&E.setState("value",M.getAttribute(jr))}function U(P){var M;let G=I(),Z=W(),se=Z.findIndex(D=>D===G),V=Z[se+P];(M=a.current)!=null&&M.loop&&(V=se+P<0?Z[Z.length-1]:se+P===Z.length?Z[0]:Z[se+P]),V&&E.setState("value",V.getAttribute(jr))}function O(P){let M=I(),G=M==null?void 0:M.closest(Co),Z;for(;G&&!Z;)G=P>0?HT(G,Co):UT(G,Co),Z=G==null?void 0:G.querySelector(Rh);Z?E.setState("value",Z.getAttribute(jr)):U(P)}let j=()=>N(W().length-1),q=P=>{P.preventDefault(),P.metaKey?j():P.altKey?O(1):U(1)},J=P=>{P.preventDefault(),P.metaKey?N(0):P.altKey?O(-1):U(-1)};return h.createElement(be.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:P=>{var M;(M=y.onKeyDown)==null||M.call(y,P);let G=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||G))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&q(P);break}case"ArrowDown":{q(P);break}case"p":case"k":{x&&P.ctrlKey&&J(P);break}case"ArrowUp":{J(P);break}case"Home":{P.preventDefault(),N(0);break}case"End":{P.preventDefault(),j();break}case"Enter":{P.preventDefault();let Z=I();if(Z){let se=new Event(hl);Z.dispatchEvent(se)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:_.inputId,id:_.labelId,style:KT},l),Ks(e,P=>h.createElement(Dh.Provider,{value:E},h.createElement(Oh.Provider,{value:_},P))))}),RT=h.forwardRef((e,t)=>{var n,r;let o=Nt(),s=h.useRef(null),i=h.useContext(Lh),a=To(),l=Fh(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;sr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Bh(o,s,[e.value,e.children,s],e.keywords),p=ml(),m=Hn(T=>T.value&&T.value===d.current),f=Hn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(hl,v),()=>T.removeEventListener(hl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return h.createElement(be.div,{ref:jn(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),OT=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Nt(),a=h.useRef(null),l=h.useRef(null),c=Nt(),d=To(),p=Hn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);sr(()=>d.group(i),[]),Bh(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(be.div,{ref:jn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Ks(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Lh.Provider,{value:m},f))))}),DT=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Hn(i=>!i.search);return!n&&!s?null:h.createElement(be.div,{ref:jn(o,t),...r,"cmdk-separator":"",role:"separator"})}),LT=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=ml(),i=Hn(c=>c.search),a=Hn(c=>c.selectedItemId),l=To();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(be.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),$T=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Hn(c=>c.selectedItemId),l=To();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(p),m.unobserve(c)}}},[]),h.createElement(be.div,{ref:jn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Ks(e,c=>h.createElement("div",{ref:jn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),FT=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(qa,{open:n,onOpenChange:r},h.createElement(Ga,{container:i},h.createElement(wo,{"cmdk-overlay":"",className:o}),h.createElement(bo,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement($h,{ref:t,...a}))))}),BT=h.forwardRef((e,t)=>Hn(n=>n.filtered.count===0)?h.createElement(be.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),zT=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(be.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Ks(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),zt=Object.assign($h,{List:$T,Item:RT,Input:LT,Group:OT,Separator:DT,Dialog:FT,Empty:BT,Loading:zT});function HT(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function UT(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Fh(e){let t=h.useRef(e);return sr(()=>{t.current=e}),t}var sr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function _r(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Hn(e){let t=ml(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Bh(e,t,n,r=[]){let o=h.useRef(),s=To();return sr(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(jr,a),o.current=a}),o}var WT=()=>{let[e,t]=h.useState(),n=_r(()=>new Map);return sr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function VT(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Ks({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(VT(t),{ref:t.ref},n(t.props.children)):n(t)}var KT={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const gl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));gl.displayName=zt.displayName;const xl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ue.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(zt.Input,{ref:n,className:ne("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));xl.displayName=zt.Input.displayName;const vl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));vl.displayName=zt.List.displayName;const wl=h.forwardRef((e,t)=>u.jsx(zt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));wl.displayName=zt.Empty.displayName;const bl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.Group,{ref:n,className:ne("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));bl.displayName=zt.Group.displayName;const qT=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));qT.displayName=zt.Separator.displayName;const yl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.Item,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));yl.displayName=zt.Item.displayName;function Sl(e,[t,n]){return Math.min(n,Math.max(t,e))}function GT(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Cl="ScrollArea",[zh,l1]=sn(Cl),[YT,tn]=zh(Cl),Hh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[p,m]=h.useState(null),[f,v]=h.useState(null),[g,x]=h.useState(null),[y,w]=h.useState(0),[S,k]=h.useState(0),[C,T]=h.useState(!1),[E,_]=h.useState(!1),R=De(t,H=>l(H)),L=Ko(o);return u.jsx(YT,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:_,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(be.div,{dir:L,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Hh.displayName=Cl;var Uh="ScrollAreaViewport",Wh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=tn(Uh,n),a=h.useRef(null),l=De(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.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}),u.jsx(be.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Wh.displayName=Uh;var Tn="ScrollAreaScrollbar",Tl=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(Tn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(XT,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(JT,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Vh,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(kl,{...r,ref:t}):null});Tl.displayName=Tn;var XT=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(Tn,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ft,{present:n||s,children:u.jsx(Vh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),JT=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(Tn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Xs(()=>l("SCROLL_END"),100),[a,l]=GT("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 h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let p=c[d];const m=()=>{const f=c[d];p!==f&&(l("SCROLL"),i()),p=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Ft,{present:n||a!=="hidden",children:u.jsx(kl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ie(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ie(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Vh=h.forwardRef((e,t)=>{const n=tn(Tn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=Xs(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Pr(n.viewport,l),Pr(n.content,l),u.jsx(Ft,{present:r||s,children:u.jsx(kl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),kl=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=tn(Tn,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Xh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function p(m,f){return rk(m,i.current,a,f)}return n==="horizontal"?u.jsx(ZT,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=Jh(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?u.jsx(QT,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=Jh(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),ZT=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=tn(Tn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=De(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(qh,{"data-orientation":"horizontal",...o,ref:c,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":Ys(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),Qh(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Gs(i.paddingLeft),paddingEnd:Gs(i.paddingRight)}})}})}),QT=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=tn(Tn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=De(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(qh,{"data-orientation":"vertical",...o,ref:c,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":Ys(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),Qh(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Gs(i.paddingTop),paddingEnd:Gs(i.paddingBottom)}})}})}),[ek,Kh]=zh(Tn),qh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:p,...m}=e,f=tn(Tn,n),[v,g]=h.useState(null),x=De(t,R=>g(R)),y=h.useRef(null),w=h.useRef(""),S=f.viewport,k=r.content-r.viewport,C=mt(d),T=mt(l),E=Xs(p,10);function _(R){if(y.current){const L=R.clientX-y.current.left,H=R.clientY-y.current.top;c({x:L,y:H})}}return h.useEffect(()=>{const R=L=>{const H=L.target;(v==null?void 0:v.contains(H))&&C(L,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,k,C]),h.useEffect(T,[r,T]),Pr(v,E),Pr(f.content,E),u.jsx(ek,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:mt(s),onThumbPointerUp:mt(i),onThumbPositionChange:T,onThumbPointerDown:mt(a),children:u.jsx(be.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ie(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),_(R))}),onPointerMove:ie(e.onPointerMove,_),onPointerUp:ie(e.onPointerUp,R=>{const L=R.target;L.hasPointerCapture(R.pointerId)&&L.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),qs="ScrollAreaThumb",Gh=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Kh(qs,e.__scopeScrollArea);return u.jsx(Ft,{present:n||o.hasThumb,children:u.jsx(tk,{ref:t,...r})})}),tk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=tn(qs,n),i=Kh(qs,n),{onThumbPositionChange:a}=i,l=De(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=Xs(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(d(),!c.current){const f=ok(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(be.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ie(e.onPointerDownCapture,p=>{const f=p.target.getBoundingClientRect(),v=p.clientX-f.left,g=p.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ie(e.onPointerUp,i.onThumbPointerUp)})});Gh.displayName=qs;var El="ScrollAreaCorner",Yh=h.forwardRef((e,t)=>{const n=tn(El,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(nk,{...e,ref:t}):null});Yh.displayName=El;var nk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=tn(El,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Pr(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Pr(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(be.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Gs(e){return e?parseInt(e,10):0}function Xh(e,t){const n=e/t;return isNaN(n)?0:n}function Ys(e){const t=Xh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function rk(e,t,n,r="ltr"){const o=Ys(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,p=r==="ltr"?[0,d]:[d*-1,0];return Zh([l,c],p)(e)}function Jh(e,t,n="ltr"){const r=Ys(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=Sl(e,l);return Zh([0,i],[0,a])(c)}function Zh(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 Qh(e,t){return e>0&&e<t}var ok=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Xs(e,t){const n=mt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Pr(e,t){const n=mt(t);kt(()=>{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 em=Hh,sk=Wh,ik=Yh;const Il=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(em,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[u.jsx(sk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(tm,{}),u.jsx(ik,{})]}));Il.displayName=em.displayName;const tm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Tl,{ref:r,orientation:t,className:ne("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:u.jsx(Gh,{className:"relative flex-1 rounded-full bg-border"})}));tm.displayName=Tl.displayName;const Nl=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:ne("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}));Nl.displayName="Input";const ak="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",lk="bg-slate-700 border-slate-600 hover:bg-slate-600",ck="bg-slate-600 border-slate-500";function nm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:p,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??ck}`:`${x??lk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${ak} ${S}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:w?u.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[u.jsx(Nl,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ue.Check,{size:12})}),u.jsx(at,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ue.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(ue.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(vs,{children:[u.jsx(ws,{asChild:!0,children:u.jsx(at,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ue.MoreHorizontal,{size:12})})}),u.jsxs(ao,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(On,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(ue.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(On,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(ue.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(On,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(ue.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const rm=25,om="thread-manager-view",uk=e=>e==="default"||e==="shared",dk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(om);if(uk(e))return e}catch{}return null};function sm({defaultView:e}={}){const[t,n]=b.useState(()=>dk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(om,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const fk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function Al({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:p,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:_,isLoadingSharedThreads:R,actions:L,shareInFlight:H,shareStatus:K,clearShareStatus:B}=pr(),{createThread:I,deleteThread:W,renameThread:N,shareThread:U}=L,{loadThread:O}=Yr(),j=i??T,[q,J]=b.useState(Array.isArray(k)?k:[]),P=b.useRef(q.length>0),M=b.useRef(null),G=b.useRef(0),[Z,se]=b.useState(null),[V,D]=b.useState(""),[X,Q]=b.useState(!1),[ae,$]=b.useState(!1),[re,we]=b.useState(null),[de,xe]=b.useState(""),Ee=v&&v.length>0?v:fk,Be=sm({defaultView:m}),We=g??Be,je=p??We.view,Ve=b.useCallback(Y=>{p||We.setView(Y),f==null||f(Y)},[p,f,We]),Xe=Ee.find(Y=>Y.key===je)??Ee[0],ze=Y=>{we(Y),xe(""),$(!0)},Ge=()=>{$(!1),we(null),xe(""),B()},rt=b.useCallback(async Y=>{if(!(!re||H)&&Y.id)try{await U(re,Y.id),setTimeout(()=>Ge(),600)}catch(ge){console.error("Failed to share thread:",ge)}},[Ge,H,re,U]),nt=b.useMemo(()=>{const Y=y??[],ge=de.trim().toLowerCase();return ge?S?Y.filter(it=>S(it,ge)):Y.filter(it=>`${it.label} ${it.secondaryLabel??""}`.toLowerCase().includes(ge)):Y},[y,de,S]),et=je==="shared",xt=et?C:q,vt=et?R:_,dt=et?"No shared conversations yet":"No conversations yet",Et=Y=>{const ge=Y.sharedAt?` • ${Ze(Y.sharedAt)}`:"";return`Shared by ${Y.sharedByUserId}${ge}`},Dt=Y=>"sharedByUserId"in Y;b.useEffect(()=>{const Y=Array.isArray(k)?k:[];if(Y.length>0){P.current=!0,J(Y);return}_||(P.current=!1,J(Y))},[k,_]),b.useEffect(()=>{if(!M.current)return;const Y=M.current.querySelector("[data-radix-scroll-area-viewport]");if(!Y)return;let ge=null,it=null;return ge=requestAnimationFrame(()=>{it=requestAnimationFrame(()=>{Y.scrollTop=G.current})}),()=>{ge!==null&&cancelAnimationFrame(ge),it!==null&&cancelAnimationFrame(it)}},[q]);const $e=async Y=>{try{E(Y),await O(Y),a==null||a(Y),l==null||l(Y)}catch(ge){console.error("Failed to select thread:",ge)}},Pt=async()=>{try{Q(!0);const Y=await I();Y&&(c==null||c(Y),a==null||a(Y))}catch(Y){console.error("Failed to create thread:",Y)}finally{Q(!1)}},nn=async(Y,ge)=>{if(ge.stopPropagation(),!!confirm("Delete this thread?")){if(M.current){const it=M.current.querySelector("[data-radix-scroll-area-viewport]");it&&(G.current=it.scrollTop)}try{await W(Y),d==null||d(Y)}catch(it){console.error("Failed to delete thread:",it)}}},Me=(Y,ge)=>{ge.stopPropagation(),se(Y.threadId),D(Y.title||`Thread ${Y.threadId.slice(0,8)}`)},Ke=async Y=>{if(V.trim())try{await N(Y,V.trim()),se(null),D("")}catch(ge){console.error("Failed to update title:",ge)}},Ct=()=>{se(null),D("")},Ze=Y=>{if(!Y)return"";try{const ge=new Date(Y),Ce=new Date().getTime()-ge.getTime(),Oe=Math.floor(Ce/(1e3*60*60*24));return Oe===0?ge.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Oe===1?"Yesterday":Oe<7?`${Oe} days ago`:ge.toLocaleDateString()}catch{return""}},pt=Y=>Y.title||`Thread ${Y.threadId.slice(0,8)}`,le=Y=>{const ge=pt(Y);return ge.length<=rm?ge:`${ge.slice(0,rm)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(at,{onClick:Pt,disabled:X||_,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(ue.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(vs,{children:[u.jsx(ws,{asChild:!0,children:u.jsx(at,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:Xe.label})}),u.jsx(ao,{align:"start",sideOffset:6,className:"w-40",children:Ee.map(Y=>u.jsxs(On,{className:"justify-between text-[12px]",onClick:ge=>{ge.preventDefault(),Ve(Y.key)},children:[u.jsx("span",{children:Y.label}),je===Y.key&&u.jsx(ue.Check,{className:"h-3 w-3"})]},Y.key))})]})]})]}),u.jsx(Il,{ref:M,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:vt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):xt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ue.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:dt})]}):xt.slice().sort((Y,ge)=>new Date(ge.updatedAt||ge.createdAt||"").getTime()-new Date(Y.updatedAt||Y.createdAt||"").getTime()).map(Y=>u.jsx(nm,{thread:Y,isActive:j===Y.threadId,editingThreadId:Z,editingTitle:V,onSelect:$e,onStartEditing:Me,onEditingTitleChange:ge=>D(ge),onSaveEditing:Ke,onCancelEditing:Ct,onShare:()=>ze(Y.threadId),onDelete:nn,showEditTitle:r,showDeleteButton:n,formatDate:Ze,getDisplayThreadTitle:le,secondaryLine:et&&Dt(Y)?Et(Y):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Y.threadId))})}),u.jsx(Ya,{open:ae,onOpenChange:Y=>!Y&&Ge(),children:u.jsxs(Ds,{className:"max-w-md p-0",children:[u.jsx(Ls,{children:u.jsx($s,{children:"Share thread"})}),u.jsxs(gl,{children:[u.jsx(xl,{autoFocus:!0,value:de,onValueChange:Y=>xe(Y),placeholder:"Search for recipients..."}),u.jsxs(vl,{children:[K&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[H&&u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:K.startsWith("Failed")?"text-red-500":K.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:K})]}),u.jsx(wl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),nt.length>0&&u.jsx(bl,{heading:"Recipients",children:nt.map(Y=>u.jsx(yl,{onSelect:()=>rt(Y),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:Y.label}),Y.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:Y.secondaryLabel})]})},Y.id))})]})]})]})})]})}function pk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(Xr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(So,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Xr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(Al,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(So,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Xr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(Al,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(So,{onError:s.onError,enableFileUpload:!0})})]})})}function hk({apiConfig:e,className:t="",onError:n}){return u.jsx(Xr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(So,{})})})}var mk="Label",im=h.forwardRef((e,t)=>u.jsx(be.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())}}));im.displayName=mk;var am=im;const gk=Dr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),lm=h.forwardRef(({className:e,...t},n)=>u.jsx(am,{ref:n,className:ne(gk(),e),...t}));lm.displayName=am.displayName;function cm(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var um=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"}),xk="VisuallyHidden",Js=h.forwardRef((e,t)=>u.jsx(be.span,{...e,ref:t,style:{...um,...e.style}}));Js.displayName=xk;var vk=Js,wk=[" ","Enter","ArrowUp","ArrowDown"],bk=[" ","Enter"],ir="Select",[Zs,Qs,yk]=Vo(ir),[Mr,c1]=sn(ir,[yk,yr]),ei=yr(),[Sk,Un]=Mr(ir),[Ck,Tk]=Mr(ir),dm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:p,disabled:m,required:f,form:v}=e,g=ei(t),[x,y]=h.useState(null),[w,S]=h.useState(null),[k,C]=h.useState(!1),T=Ko(c),[E,_]=_n({prop:r,defaultProp:o??!1,onChange:s,caller:ir}),[R,L]=_n({prop:i,defaultProp:a,onChange:l,caller:ir}),H=h.useRef(null),K=x?v||!!x.closest("form"):!0,[B,I]=h.useState(new Set),W=Array.from(B).map(N=>N.props.value).join(";");return u.jsx(ea,{...g,children:u.jsxs(Sk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Nt(),value:R,onValueChange:L,open:E,onOpenChange:_,dir:T,triggerPointerDownPosRef:H,disabled:m,children:[u.jsx(Zs.Provider,{scope:t,children:u.jsx(Ck,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(N=>{I(U=>new Set(U).add(N))},[]),onNativeOptionRemove:h.useCallback(N=>{I(U=>{const O=new Set(U);return O.delete(N),O})},[]),children:n})}),K?u.jsxs(Om,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:R,onChange:N=>L(N.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(B)]},W):null]})})};dm.displayName=ir;var fm="SelectTrigger",pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ei(n),i=Un(fm,n),a=i.disabled||r,l=De(t,i.onTriggerChange),c=Qs(n),d=h.useRef("touch"),[p,m,f]=Lm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=$m(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ta,{asChild:!0,...s,children:u.jsx(be.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Dm(i.value)?"":void 0,...o,ref:l,onClick:ie(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ie(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ie(o.onKeyDown,g=>{const x=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&wk.includes(g.key)&&(v(),g.preventDefault())})})})});pm.displayName=fm;var hm="SelectValue",mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Un(hm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=De(t,l.onValueNodeChange);return kt(()=>{c(d)},[c,d]),u.jsx(be.span,{...a,ref:p,style:{pointerEvents:"none"},children:Dm(l.value)?u.jsx(u.Fragment,{children:i}):s})});mm.displayName=hm;var kk="SelectIcon",gm=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(be.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});gm.displayName=kk;var Ek="SelectPortal",xm=e=>u.jsx(eo,{asChild:!0,...e});xm.displayName=Ek;var ar="SelectContent",vm=h.forwardRef((e,t)=>{const n=Un(ar,e.__scopeSelect),[r,o]=h.useState();if(kt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Lr.createPortal(u.jsx(wm,{scope:e.__scopeSelect,children:u.jsx(Zs.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(bm,{...e,ref:t})});vm.displayName=ar;var fn=10,[wm,Wn]=Mr(ar),Ik="SelectContentImpl",Nk=Vt.createSlot("SelectContent.RemoveScroll"),bm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Un(ar,n),[S,k]=h.useState(null),[C,T]=h.useState(null),E=De(t,V=>k(V)),[_,R]=h.useState(null),[L,H]=h.useState(null),K=Qs(n),[B,I]=h.useState(!1),W=h.useRef(!1);h.useEffect(()=>{if(S)return aa(S)},[S]),$i();const N=h.useCallback(V=>{const[D,...X]=K().map($=>$.ref.current),[Q]=X.slice(-1),ae=document.activeElement;for(const $ of V)if($===ae||($==null||$.scrollIntoView({block:"nearest"}),$===D&&C&&(C.scrollTop=0),$===Q&&C&&(C.scrollTop=C.scrollHeight),$==null||$.focus(),document.activeElement!==ae))return},[K,C]),U=h.useCallback(()=>N([_,S]),[N,_,S]);h.useEffect(()=>{B&&U()},[B,U]);const{onOpenChange:O,triggerPointerDownPosRef:j}=w;h.useEffect(()=>{if(S){let V={x:0,y:0};const D=Q=>{var ae,$;V={x:Math.abs(Math.round(Q.pageX)-(((ae=j.current)==null?void 0:ae.x)??0)),y:Math.abs(Math.round(Q.pageY)-((($=j.current)==null?void 0:$.y)??0))}},X=Q=>{V.x<=10&&V.y<=10?Q.preventDefault():S.contains(Q.target)||O(!1),document.removeEventListener("pointermove",D),j.current=null};return j.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,O,j]),h.useEffect(()=>{const V=()=>O(!1);return window.addEventListener("blur",V),window.addEventListener("resize",V),()=>{window.removeEventListener("blur",V),window.removeEventListener("resize",V)}},[O]);const[q,J]=Lm(V=>{const D=K().filter(ae=>!ae.disabled),X=D.find(ae=>ae.ref.current===document.activeElement),Q=$m(D,V,X);Q&&setTimeout(()=>Q.ref.current.focus())}),P=h.useCallback((V,D,X)=>{const Q=!W.current&&!X;(w.value!==void 0&&w.value===D||Q)&&(R(V),Q&&(W.current=!0))},[w.value]),M=h.useCallback(()=>S==null?void 0:S.focus(),[S]),G=h.useCallback((V,D,X)=>{const Q=!W.current&&!X;(w.value!==void 0&&w.value===D||Q)&&H(V)},[w.value]),Z=r==="popper"?jl:ym,se=Z===jl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(wm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:P,selectedItem:_,onItemLeave:M,itemTextRefCallback:G,focusSelectedItem:U,selectedItemText:L,position:r,isPositioned:B,searchRef:q,children:u.jsx(fs,{as:Nk,allowPinchZoom:!0,children:u.jsx(qo,{asChild:!0,trapped:w.open,onMountAutoFocus:V=>{V.preventDefault()},onUnmountAutoFocus:ie(o,V=>{var D;(D=w.trigger)==null||D.focus({preventScroll:!0}),V.preventDefault()}),children:u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:V=>V.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(Z,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:V=>V.preventDefault(),...y,...se,onPlaced:()=>I(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ie(y.onKeyDown,V=>{const D=V.ctrlKey||V.altKey||V.metaKey;if(V.key==="Tab"&&V.preventDefault(),!D&&V.key.length===1&&J(V.key),["ArrowUp","ArrowDown","Home","End"].includes(V.key)){let Q=K().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);if(["ArrowUp","End"].includes(V.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(V.key)){const ae=V.target,$=Q.indexOf(ae);Q=Q.slice($+1)}setTimeout(()=>N(Q)),V.preventDefault()}})})})})})})});bm.displayName=Ik;var Ak="SelectItemAlignedPosition",ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Un(ar,n),i=Wn(ar,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=De(t,E=>d(E)),m=Qs(n),f=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),_=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const ae=L.left-_.left,$=R.left-ae,re=E.left-$,we=E.width+re,de=Math.max(we,_.width),xe=window.innerWidth-fn,Ee=Sl($,[fn,Math.max(fn,xe-de)]);a.style.minWidth=we+"px",a.style.left=Ee+"px"}else{const ae=_.right-L.right,$=window.innerWidth-R.right-ae,re=window.innerWidth-E.right-$,we=E.width+re,de=Math.max(we,_.width),xe=window.innerWidth-fn,Ee=Sl($,[fn,Math.max(fn,xe-de)]);a.style.minWidth=we+"px",a.style.right=Ee+"px"}const H=m(),K=window.innerHeight-fn*2,B=g.scrollHeight,I=window.getComputedStyle(c),W=parseInt(I.borderTopWidth,10),N=parseInt(I.paddingTop,10),U=parseInt(I.borderBottomWidth,10),O=parseInt(I.paddingBottom,10),j=W+N+B+O+U,q=Math.min(x.offsetHeight*5,j),J=window.getComputedStyle(g),P=parseInt(J.paddingTop,10),M=parseInt(J.paddingBottom,10),G=E.top+E.height/2-fn,Z=K-G,se=x.offsetHeight/2,V=x.offsetTop+se,D=W+N+V,X=j-D;if(D<=G){const ae=H.length>0&&x===H[H.length-1].ref.current;a.style.bottom="0px";const $=c.clientHeight-g.offsetTop-g.offsetHeight,re=Math.max(Z,se+(ae?M:0)+$+U),we=D+re;a.style.height=we+"px"}else{const ae=H.length>0&&x===H[0].ref.current;a.style.top="0px";const re=Math.max(G,W+g.offsetTop+(ae?P:0)+se)+X;a.style.height=re+"px",g.scrollTop=D-G+g.offsetTop}a.style.margin=`${fn}px 0`,a.style.minHeight=q+"px",a.style.maxHeight=K+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);kt(()=>S(),[S]);const[k,C]=h.useState();kt(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(E=>{E&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);return u.jsx(_k,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(be.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});ym.displayName=Ak;var jk="SelectPopperPosition",jl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=fn,...s}=e,i=ei(n);return u.jsx(na,{...i,...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)"}})});jl.displayName=jk;var[_k,_l]=Mr(ar,{}),Pl="SelectViewport",Sm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Wn(Pl,n),i=_l(Pl,n),a=De(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.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}),u.jsx(Zs.Slot,{scope:n,children:u.jsx(be.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ie(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-fn*2,g=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),y=Math.max(g,x);if(y<v){const w=y+f,S=Math.min(v,w),k=w-S;p.style.height=S+"px",p.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,p.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Sm.displayName=Pl;var Cm="SelectGroup",[Pk,Mk]=Mr(Cm),Rk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nt();return u.jsx(Pk,{scope:n,id:o,children:u.jsx(be.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Rk.displayName=Cm;var Tm="SelectLabel",km=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Mk(Tm,n);return u.jsx(be.div,{id:o.id,...r,ref:t})});km.displayName=Tm;var ti="SelectItem",[Ok,Em]=Mr(ti),Im=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Un(ti,n),l=Wn(ti,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=De(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=Nt(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.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 u.jsx(Ok,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(w=>{p(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(Zs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(be.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ie(i.onFocus,()=>f(!0)),onBlur:ie(i.onBlur,()=>f(!1)),onClick:ie(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ie(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ie(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ie(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ie(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ie(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(bk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Im.displayName=ti;var ko="SelectItemText",Nm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Un(ko,n),a=Wn(ko,n),l=Em(ko,n),c=Tk(ko,n),[d,p]=h.useState(null),m=De(t,y=>p(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return kt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(be.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Lr.createPortal(s.children,i.valueNode):null]})});Nm.displayName=ko;var Am="SelectItemIndicator",jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Em(Am,n).isSelected?u.jsx(be.span,{"aria-hidden":!0,...r,ref:t}):null});jm.displayName=Am;var Ml="SelectScrollUpButton",_m=h.forwardRef((e,t)=>{const n=Wn(Ml,e.__scopeSelect),r=_l(Ml,e.__scopeSelect),[o,s]=h.useState(!1),i=De(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Mm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});_m.displayName=Ml;var Rl="SelectScrollDownButton",Pm=h.forwardRef((e,t)=>{const n=Wn(Rl,e.__scopeSelect),r=_l(Rl,e.__scopeSelect),[o,s]=h.useState(!1),i=De(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Mm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Pm.displayName=Rl;var Mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Wn("SelectScrollButton",n),i=h.useRef(null),a=Qs(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),kt(()=>{var d;const c=a().find(p=>p.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(be.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ie(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ie(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ie(o.onPointerLeave,()=>{l()})})}),Dk="SelectSeparator",Rm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(be.div,{"aria-hidden":!0,...r,ref:t})});Rm.displayName=Dk;var Ol="SelectArrow",Lk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ei(n),s=Un(Ol,n),i=Wn(Ol,n);return s.open&&i.position==="popper"?u.jsx(ra,{...o,...r,ref:t}):null});Lk.displayName=Ol;var $k="SelectBubbleInput",Om=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=De(r,o),i=cm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(p)}},[i,t]),u.jsx(be.select,{...n,style:{...um,...n.style},ref:s,defaultValue:t})});Om.displayName=$k;function Dm(e){return e===""||e===void 0}function Lm(e){const t=mt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function $m(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Fk(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Fk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Bk=dm,Fm=pm,zk=mm,Hk=gm,Uk=xm,Bm=vm,Wk=Sm,zm=km,Hm=Im,Vk=Nm,Kk=jm,Um=_m,Wm=Pm,Vm=Rm;const qk=Bk,Gk=zk,Km=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Fm,{ref:r,className:ne("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,u.jsx(Hk,{asChild:!0,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Km.displayName=Fm.displayName;const qm=h.forwardRef(({className:e,...t},n)=>u.jsx(Um,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));qm.displayName=Um.displayName;const Gm=h.forwardRef(({className:e,...t},n)=>u.jsx(Wm,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4"})}));Gm.displayName=Wm.displayName;const Ym=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(Uk,{children:u.jsxs(Bm,{ref:o,className:ne("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:[u.jsx(qm,{}),u.jsx(Wk,{className:ne("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Gm,{})]})}));Ym.displayName=Bm.displayName;const Yk=h.forwardRef(({className:e,...t},n)=>u.jsx(zm,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Yk.displayName=zm.displayName;const Xm=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Hm,{ref:r,className:ne("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Kk,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),u.jsx(Vk,{children:t})]}));Xm.displayName=Hm.displayName;const Xk=h.forwardRef(({className:e,...t},n)=>u.jsx(Vm,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));Xk.displayName=Vm.displayName;var Jk="Separator",Jm="horizontal",Zk=["horizontal","vertical"],Zm=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=Jm,...o}=e,s=Qk(r)?r:Jm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(be.div,{"data-orientation":s,...a,...o,ref:t})});Zm.displayName=Jk;function Qk(e){return Zk.includes(e)}var Qm=Zm;const eg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(Qm,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));eg.displayName=Qm.displayName;var ni="Switch",[eE,u1]=sn(ni),[tE,nE]=eE(ni),tg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...p}=e,[m,f]=h.useState(null),v=De(t,S=>f(S)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=_n({prop:o,defaultProp:s??!1,onChange:c,caller:ni});return u.jsxs(tE,{scope:n,checked:y,disabled:a,children:[u.jsx(be.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":sg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:ie(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(og,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});tg.displayName=ni;var ng="SwitchThumb",rg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=nE(ng,n);return u.jsx(be.span,{"data-state":sg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});rg.displayName=ng;var rE="SwitchBubbleInput",og=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=De(i,s),l=cm(n),c=hd(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});og.displayName=rE;function sg(e){return e?"checked":"unchecked"}var ig=tg,oE=rg;const ag=h.forwardRef(({className:e,...t},n)=>u.jsx(ig,{className:ne("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:u.jsx(oE,{className:ne("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")})}));ag.displayName=ig.displayName;const sE=qa,iE=JC,aE=Ga,lg=h.forwardRef(({className:e,...t},n)=>u.jsx(wo,{className:ne("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}));lg.displayName=wo.displayName;const lE=Dr.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"}}),cg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(aE,{children:[u.jsx(lg,{}),u.jsxs(bo,{ref:o,className:ne(lE({side:e}),t),...r,children:[n,u.jsxs(eh,{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:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));cg.displayName=bo.displayName;const ug=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});ug.displayName="SheetHeader";const dg=h.forwardRef(({className:e,...t},n)=>u.jsx(rr,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));dg.displayName=rr.displayName;const fg=h.forwardRef(({className:e,...t},n)=>u.jsx(Os,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));fg.displayName=Os.displayName;var[ri,d1]=sn("Tooltip",[yr]),oi=yr(),pg="TooltipProvider",cE=700,Dl="tooltip.open",[uE,Ll]=ri(pg),hg=e=>{const{__scopeTooltip:t,delayDuration:n=cE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(uE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};hg.displayName=pg;var Eo="Tooltip",[dE,si]=ri(Eo),mg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Ll(Eo,e.__scopeTooltip),c=oi(t),[d,p]=h.useState(null),m=Nt(),f=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,w]=_n({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Dl))):l.onClose(),s==null||s(E)},caller:Eo}),S=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,w(!0)},[w]),C=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,w(!1)},[w]),T=h.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,w(!0),f.current=0},g)},[g,w]);return h.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(ea,{...c,children:u.jsx(dE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};mg.displayName=Eo;var $l="TooltipTrigger",gg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=si($l,n),s=Ll($l,n),i=oi(n),a=h.useRef(null),l=De(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),p=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),u.jsx(ta,{asChild:!0,...i,children:u.jsx(be.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ie(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ie(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ie(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ie(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ie(e.onBlur,o.onClose),onClick:ie(e.onClick,o.onClose)})})});gg.displayName=$l;var fE="TooltipPortal",[f1,pE]=ri(fE,{forceMount:void 0}),Rr="TooltipContent",xg=h.forwardRef((e,t)=>{const n=pE(Rr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=si(Rr,e.__scopeTooltip);return u.jsx(Ft,{present:r||i.open,children:i.disableHoverableContent?u.jsx(vg,{side:o,...s,ref:t}):u.jsx(hE,{side:o,...s,ref:t})})}),hE=h.forwardRef((e,t)=>{const n=si(Rr,e.__scopeTooltip),r=Ll(Rr,e.__scopeTooltip),o=h.useRef(null),s=De(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:p}=r,m=h.useCallback(()=>{a(null),p(!1)},[p]),f=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=wE(y,x.getBoundingClientRect()),S=bE(y,w),k=yE(g.getBoundingClientRect()),C=CE([...S,...k]);a(C),p(!0)},[p]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!SE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(vg,{...e,ref:s})}),[mE,gE]=ri(Eo,{isInside:!1}),xE=Vt.createSlottable("TooltipContent"),vg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=si(Rr,n),c=oi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Dl,d),()=>document.removeEventListener(Dl,d)),[d]),h.useEffect(()=>{if(l.trigger){const p=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[l.trigger,d]),u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(na,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.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:[u.jsx(xE,{children:r}),u.jsx(mE,{scope:n,isInside:!0,children:u.jsx(vk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});xg.displayName=Rr;var wg="TooltipArrow",vE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=oi(n);return gE(wg,n).isInside?null:u.jsx(ra,{...o,...r,ref:t})});vE.displayName=wg;function wE(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 bE(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 yE(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 SE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function CE(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),TE(t)}function TE(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],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.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],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.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 kE=hg,EE=mg,IE=gg,bg=xg;const NE=kE,AE=EE,jE=IE,yg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(bg,{ref:r,sideOffset:t,className:ne("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}));yg.displayName=bg.displayName;var Fl="ToastProvider",[Bl,_E,PE]=Vo("Toast"),[Sg,p1]=sn("Toast",[PE]),[ME,ii]=Sg(Fl),Cg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),p=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Fl}\`. Expected non-empty \`string\`.`),u.jsx(Bl.Provider,{scope:t,children:u.jsx(ME,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(f=>f+1),[]),onToastRemove:h.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};Cg.displayName=Fl;var Tg="ToastViewport",RE=["F8"],zl="toast.viewportPause",Hl="toast.viewportResume",kg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=RE,label:o="Notifications ({hotkey})",...s}=e,i=ii(Tg,n),a=_E(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=De(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=p.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=p.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(zl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Hl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",w),x.addEventListener("focusout",k),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",C),window.addEventListener("blur",w),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",w),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...qE(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return h.useEffect(()=>{const x=p.current;if(x){const y=w=>{var C,T,E;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const _=document.activeElement,R=w.shiftKey;if(w.target===x&&R){(C=c.current)==null||C.focus();return}const K=g({tabbingDirection:R?"backwards":"forwards"}),B=K.findIndex(I=>I===_);Vl(K.slice(B+1))?w.preventDefault():R?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(kw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Ul,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Vl(x)}}),u.jsx(Bl.Slot,{scope:n,children:u.jsx(be.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Ul,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Vl(x)}})]})});kg.displayName=Tg;var Eg="ToastFocusProxy",Ul=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=ii(Eg,n);return u.jsx(Js,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Ul.displayName=Eg;var Io="Toast",OE="toast.swipeStart",DE="toast.swipeMove",LE="toast.swipeCancel",$E="toast.swipeEnd",Ig=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=_n({prop:r,defaultProp:o??!0,onChange:s,caller:Io});return u.jsx(Ft,{present:n||a,children:u.jsx(zE,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:mt(e.onPause),onResume:mt(e.onResume),onSwipeStart:ie(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ie(e.onSwipeMove,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel:ie(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ie(e.onSwipeEnd,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),l(!1)})})})});Ig.displayName=Io;var[FE,BE]=Sg(Io,{onClose(){}}),zE=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:p,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=ii(Io,n),[x,y]=h.useState(null),w=De(t,I=>y(I)),S=h.useRef(null),k=h.useRef(null),C=o||g.duration,T=h.useRef(0),E=h.useRef(C),_=h.useRef(0),{onToastAdd:R,onToastRemove:L}=g,H=mt(()=>{var W;(x==null?void 0:x.contains(document.activeElement))&&((W=g.viewport)==null||W.focus()),i()}),K=h.useCallback(I=>{!I||I===1/0||(window.clearTimeout(_.current),T.current=new Date().getTime(),_.current=window.setTimeout(H,I))},[H]);h.useEffect(()=>{const I=g.viewport;if(I){const W=()=>{K(E.current),c==null||c()},N=()=>{const U=new Date().getTime()-T.current;E.current=E.current-U,window.clearTimeout(_.current),l==null||l()};return I.addEventListener(zl,N),I.addEventListener(Hl,W),()=>{I.removeEventListener(zl,N),I.removeEventListener(Hl,W)}}},[g.viewport,C,l,c,K]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&K(C)},[s,C,g.isClosePausedRef,K]),h.useEffect(()=>(R(),()=>L()),[R,L]);const B=h.useMemo(()=>x?Rg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[B&&u.jsx(HE,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:B}),u.jsx(FE,{scope:n,onClose:H,children:Lr.createPortal(u.jsx(Bl.ItemSlot,{scope:n,children:u.jsx(Tw,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||H(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(be.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,I=>{I.key==="Escape"&&(a==null||a(I.nativeEvent),I.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,H()))}),onPointerDown:ie(e.onPointerDown,I=>{I.button===0&&(S.current={x:I.clientX,y:I.clientY})}),onPointerMove:ie(e.onPointerMove,I=>{if(!S.current)return;const W=I.clientX-S.current.x,N=I.clientY-S.current.y,U=!!k.current,O=["left","right"].includes(g.swipeDirection),j=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,q=O?j(0,W):0,J=O?0:j(0,N),P=I.pointerType==="touch"?10:2,M={x:q,y:J},G={originalEvent:I,delta:M};U?(k.current=M,ai(DE,p,G,{discrete:!1})):Og(M,g.swipeDirection,P)?(k.current=M,ai(OE,d,G,{discrete:!1}),I.target.setPointerCapture(I.pointerId)):(Math.abs(W)>P||Math.abs(N)>P)&&(S.current=null)}),onPointerUp:ie(e.onPointerUp,I=>{const W=k.current,N=I.target;if(N.hasPointerCapture(I.pointerId)&&N.releasePointerCapture(I.pointerId),k.current=null,S.current=null,W){const U=I.currentTarget,O={originalEvent:I,delta:W};Og(W,g.swipeDirection,g.swipeThreshold)?ai($E,f,O,{discrete:!0}):ai(LE,m,O,{discrete:!0}),U.addEventListener("click",j=>j.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),HE=e=>{const{__scopeToast:t,children:n,...r}=e,o=ii(Io,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return VE(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(eo,{asChild:!0,children:u.jsx(Js,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},UE="ToastTitle",Ng=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(be.div,{...r,ref:t})});Ng.displayName=UE;var WE="ToastDescription",Ag=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(be.div,{...r,ref:t})});Ag.displayName=WE;var jg="ToastAction",_g=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Mg,{altText:n,asChild:!0,children:u.jsx(Wl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${jg}\`. Expected non-empty \`string\`.`),null)});_g.displayName=jg;var Pg="ToastClose",Wl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=BE(Pg,n);return u.jsx(Mg,{asChild:!0,children:u.jsx(be.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,o.onClose)})})});Wl.displayName=Pg;var Mg=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(be.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Rg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),KE(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...Rg(r))}}),t}function ai(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Oi(o,s):o.dispatchEvent(s)}var Og=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function VE(e=()=>{}){const t=mt(e);kt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function KE(e){return e.nodeType===e.ELEMENT_NODE}function qE(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 Vl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var GE=Cg,Dg=kg,Lg=Ig,$g=Ng,Fg=Ag,Bg=_g,zg=Wl;const YE=GE,Hg=h.forwardRef(({className:e,...t},n)=>u.jsx(Dg,{ref:n,className:ne("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Hg.displayName=Dg.displayName;const XE=Dr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Ug=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Lg,{ref:r,className:ne(XE({variant:t}),e),...n}));Ug.displayName=Lg.displayName;const JE=h.forwardRef(({className:e,...t},n)=>u.jsx(Bg,{ref:n,className:ne("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));JE.displayName=Bg.displayName;const Wg=h.forwardRef(({className:e,...t},n)=>u.jsx(zg,{ref:n,className:ne("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(ue.X,{className:"h-4 w-4"})}));Wg.displayName=zg.displayName;const Vg=h.forwardRef(({className:e,...t},n)=>u.jsx($g,{ref:n,className:ne("text-sm font-semibold",e),...t}));Vg.displayName=$g.displayName;const Kg=h.forwardRef(({className:e,...t},n)=>u.jsx(Fg,{ref:n,className:ne("text-sm opacity-90",e),...t}));Kg.displayName=Fg.displayName;function ZE(){const{toasts:e}=Za();return u.jsxs(YE,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Ug,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Vg,{children:n}),r&&u.jsx(Kg,{children:r})]}),o,u.jsx(Wg,{})]},t)}),u.jsx(Hg,{})]})}var QE=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),p(f)}function p(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},eI=h.createContext(void 0),tI={setTheme:e=>{},themes:[]},nI=()=>{var e;return(e=h.useContext(eI))!=null?e:tI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${QE.toString()})(${d})`}})});var rI=e=>{switch(e){case"success":return iI;case"info":return lI;case"warning":return aI;case"error":return cI;default:return null}},oI=Array(12).fill(0),sI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},oI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),iI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),aI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),lI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),cI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),uI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),dI=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Kl=1,fI=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Kl++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],b.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(hI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Kl++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Ht=new fI,pI=(e,t)=>{let n=(t==null?void 0:t.id)||Kl++;return Ht.addToast({title:e,...t,id:n}),n},hI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",mI=pI,gI=()=>Ht.toasts,xI=()=>Ht.getActiveToasts();Object.assign(mI,{success:Ht.success,info:Ht.info,warning:Ht.warning,error:Ht.error,custom:Ht.custom,message:Ht.message,promise:Ht.promise,dismiss:Ht.dismiss,loading:Ht.loading},{getHistory:gI,getToasts:xI});function vI(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}vI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
130
130
|
`);function li(e){return e.label!==void 0}var wI=3,bI="32px",yI="16px",qg=4e3,SI=356,CI=14,TI=20,kI=200;function pn(...e){return e.filter(Boolean).join(" ")}function EI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var II=e=>{var t,n,r,o,s,i,a,l,c,d,p;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:_,style:R,cancelButtonStyle:L,actionButtonStyle:H,className:K="",descriptionClassName:B="",duration:I,position:W,gap:N,loadingIcon:U,expandByDefault:O,classNames:j,icons:q,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:P}=e,[M,G]=b.useState(null),[Z,se]=b.useState(null),[V,D]=b.useState(!1),[X,Q]=b.useState(!1),[ae,$]=b.useState(!1),[re,we]=b.useState(!1),[de,xe]=b.useState(!1),[Ee,Be]=b.useState(0),[We,je]=b.useState(0),Ve=b.useRef(f.duration||I||qg),Xe=b.useRef(null),ze=b.useRef(null),Ge=S===0,rt=S+1<=y,nt=f.type,et=f.dismissible!==!1,xt=f.className||"",vt=f.descriptionClassName||"",dt=b.useMemo(()=>w.findIndex(Ce=>Ce.toastId===f.id)||0,[w,f.id]),Et=b.useMemo(()=>{var Ce;return(Ce=f.closeButton)!=null?Ce:_},[f.closeButton,_]),Dt=b.useMemo(()=>f.duration||I||qg,[f.duration,I]),$e=b.useRef(0),Pt=b.useRef(0),nn=b.useRef(0),Me=b.useRef(null),[Ke,Ct]=W.split("-"),Ze=b.useMemo(()=>w.reduce((Ce,Oe,qe)=>qe>=dt?Ce:Ce+Oe.height,0),[w,dt]),pt=dI(),le=f.invert||m,Y=nt==="loading";Pt.current=b.useMemo(()=>dt*N+Ze,[dt,Ze]),b.useEffect(()=>{Ve.current=Dt},[Dt]),b.useEffect(()=>{D(!0)},[]),b.useEffect(()=>{let Ce=ze.current;if(Ce){let Oe=Ce.getBoundingClientRect().height;return je(Oe),x(qe=>[{toastId:f.id,height:Oe,position:f.position},...qe]),()=>x(qe=>qe.filter(Tt=>Tt.toastId!==f.id))}},[x,f.id]),b.useLayoutEffect(()=>{if(!V)return;let Ce=ze.current,Oe=Ce.style.height;Ce.style.height="auto";let qe=Ce.getBoundingClientRect().height;Ce.style.height=Oe,je(qe),x(Tt=>Tt.find(He=>He.toastId===f.id)?Tt.map(He=>He.toastId===f.id?{...He,height:qe}:He):[{toastId:f.id,height:qe,position:f.position},...Tt])},[V,f.title,f.description,x,f.id]);let ge=b.useCallback(()=>{Q(!0),Be(Pt.current),x(Ce=>Ce.filter(Oe=>Oe.toastId!==f.id)),setTimeout(()=>{T(f)},kI)},[f,T,x,Pt]);b.useEffect(()=>{if(f.promise&&nt==="loading"||f.duration===1/0||f.type==="loading")return;let Ce;return C||g||P&&pt?(()=>{if(nn.current<$e.current){let Oe=new Date().getTime()-$e.current;Ve.current=Ve.current-Oe}nn.current=new Date().getTime()})():Ve.current!==1/0&&($e.current=new Date().getTime(),Ce=setTimeout(()=>{var Oe;(Oe=f.onAutoClose)==null||Oe.call(f,f),ge()},Ve.current)),()=>clearTimeout(Ce)},[C,g,f,nt,P,pt,ge]),b.useEffect(()=>{f.delete&&ge()},[ge,f.delete]);function it(){var Ce,Oe,qe;return q!=null&&q.loading?b.createElement("div",{className:pn(j==null?void 0:j.loader,(Ce=f==null?void 0:f.classNames)==null?void 0:Ce.loader,"sonner-loader"),"data-visible":nt==="loading"},q.loading):U?b.createElement("div",{className:pn(j==null?void 0:j.loader,(Oe=f==null?void 0:f.classNames)==null?void 0:Oe.loader,"sonner-loader"),"data-visible":nt==="loading"},U):b.createElement(sI,{className:pn(j==null?void 0:j.loader,(qe=f==null?void 0:f.classNames)==null?void 0:qe.loader),visible:nt==="loading"})}return b.createElement("li",{tabIndex:0,ref:ze,className:pn(K,xt,j==null?void 0:j.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,j==null?void 0:j.default,j==null?void 0:j[nt],(n=f==null?void 0:f.classNames)==null?void 0:n[nt]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":V,"data-promise":!!f.promise,"data-swiped":de,"data-removed":X,"data-visible":rt,"data-y-position":Ke,"data-x-position":Ct,"data-index":S,"data-front":Ge,"data-swiping":ae,"data-dismissible":et,"data-type":nt,"data-invert":le,"data-swipe-out":re,"data-swipe-direction":Z,"data-expanded":!!(C||O&&V),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Ee:Pt.current}px`,"--initial-height":O?"auto":`${We}px`,...R,...f.style},onDragEnd:()=>{$(!1),G(null),Me.current=null},onPointerDown:Ce=>{Y||!et||(Xe.current=new Date,Be(Pt.current),Ce.target.setPointerCapture(Ce.pointerId),Ce.target.tagName!=="BUTTON"&&($(!0),Me.current={x:Ce.clientX,y:Ce.clientY}))},onPointerUp:()=>{var Ce,Oe,qe,Tt;if(re||!et)return;Me.current=null;let He=Number(((Ce=ze.current)==null?void 0:Ce.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ft=Number(((Oe=ze.current)==null?void 0:Oe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Fe=new Date().getTime()-((qe=Xe.current)==null?void 0:qe.getTime()),tt=M==="x"?He:ft,Ut=Math.abs(tt)/Fe;if(Math.abs(tt)>=TI||Ut>.11){Be(Pt.current),(Tt=f.onDismiss)==null||Tt.call(f,f),se(M==="x"?He>0?"right":"left":ft>0?"down":"up"),ge(),we(!0),xe(!1);return}$(!1),G(null)},onPointerMove:Ce=>{var Oe,qe,Tt,He;if(!Me.current||!et||((Oe=window.getSelection())==null?void 0:Oe.toString().length)>0)return;let ft=Ce.clientY-Me.current.y,Fe=Ce.clientX-Me.current.x,tt=(qe=e.swipeDirections)!=null?qe:EI(W);!M&&(Math.abs(Fe)>1||Math.abs(ft)>1)&&G(Math.abs(Fe)>Math.abs(ft)?"x":"y");let Ut={x:0,y:0};M==="y"?(tt.includes("top")||tt.includes("bottom"))&&(tt.includes("top")&&ft<0||tt.includes("bottom")&&ft>0)&&(Ut.y=ft):M==="x"&&(tt.includes("left")||tt.includes("right"))&&(tt.includes("left")&&Fe<0||tt.includes("right")&&Fe>0)&&(Ut.x=Fe),(Math.abs(Ut.x)>0||Math.abs(Ut.y)>0)&&xe(!0),(Tt=ze.current)==null||Tt.style.setProperty("--swipe-amount-x",`${Ut.x}px`),(He=ze.current)==null||He.style.setProperty("--swipe-amount-y",`${Ut.y}px`)}},Et&&!f.jsx?b.createElement("button",{"aria-label":J,"data-disabled":Y,"data-close-button":!0,onClick:Y||!et?()=>{}:()=>{var Ce;ge(),(Ce=f.onDismiss)==null||Ce.call(f,f)},className:pn(j==null?void 0:j.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=q==null?void 0:q.close)!=null?s:uI):null,f.jsx||b.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:b.createElement(b.Fragment,null,nt||f.icon||f.promise?b.createElement("div",{"data-icon":"",className:pn(j==null?void 0:j.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||it():null,f.type!=="loading"?f.icon||(q==null?void 0:q[nt])||rI(nt):null):null,b.createElement("div",{"data-content":"",className:pn(j==null?void 0:j.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:pn(j==null?void 0:j.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?b.createElement("div",{"data-description":"",className:pn(B,vt,j==null?void 0:j.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),b.isValidElement(f.cancel)?f.cancel:f.cancel&&li(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||L,onClick:Ce=>{var Oe,qe;li(f.cancel)&&et&&((qe=(Oe=f.cancel).onClick)==null||qe.call(Oe,Ce),ge())},className:pn(j==null?void 0:j.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,b.isValidElement(f.action)?f.action:f.action&&li(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||H,onClick:Ce=>{var Oe,qe;li(f.action)&&((qe=(Oe=f.action).onClick)==null||qe.call(Oe,Ce),!Ce.defaultPrevented&&ge())},className:pn(j==null?void 0:j.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function Gg(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function NI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?yI:bI;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var AI=b.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:p,duration:m,style:f,visibleToasts:v=wI,toastOptions:g,dir:x=Gg(),gap:y=CI,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=b.useState([]),_=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,r]),[R,L]=b.useState([]),[H,K]=b.useState(!1),[B,I]=b.useState(!1),[W,N]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),U=b.useRef(null),O=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),j=b.useRef(null),q=b.useRef(!1),J=b.useCallback(P=>{E(M=>{var G;return(G=M.find(Z=>Z.id===P.id))!=null&&G.delete||Ht.dismiss(P.id),M.filter(({id:Z})=>Z!==P.id)})},[]);return b.useEffect(()=>Ht.subscribe(P=>{if(P.dismiss){E(M=>M.map(G=>G.id===P.id?{...G,delete:!0}:G));return}setTimeout(()=>{No.flushSync(()=>{E(M=>{let G=M.findIndex(Z=>Z.id===P.id);return G!==-1?[...M.slice(0,G),{...M[G],...P},...M.slice(G+1)]:[P,...M]})})})}),[]),b.useEffect(()=>{if(d!=="system"){N(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?N("dark"):N("light")),typeof window>"u")return;let P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:M})=>{N(M?"dark":"light")})}catch{P.addListener(({matches:G})=>{try{N(G?"dark":"light")}catch(Z){console.error(Z)}})}},[d]),b.useEffect(()=>{T.length<=1&&K(!1)},[T]),b.useEffect(()=>{let P=M=>{var G,Z;o.every(se=>M[se]||M.code===se)&&(K(!0),(G=U.current)==null||G.focus()),M.code==="Escape"&&(document.activeElement===U.current||(Z=U.current)!=null&&Z.contains(document.activeElement))&&K(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[o]),b.useEffect(()=>{if(U.current)return()=>{j.current&&(j.current.focus({preventScroll:!0}),j.current=null,q.current=!1)}},[U.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${O}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},_.map((P,M)=>{var G;let[Z,se]=P.split("-");return T.length?b.createElement("ol",{key:P,dir:x==="auto"?Gg():x,tabIndex:-1,ref:U,className:a,"data-sonner-toaster":!0,"data-theme":W,"data-y-position":Z,"data-lifted":H&&T.length>1&&!s,"data-x-position":se,style:{"--front-toast-height":`${((G=R[0])==null?void 0:G.height)||0}px`,"--width":`${SI}px`,"--gap":`${y}px`,...f,...NI(l,c)},onBlur:V=>{q.current&&!V.currentTarget.contains(V.relatedTarget)&&(q.current=!1,j.current&&(j.current.focus({preventScroll:!0}),j.current=null))},onFocus:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||q.current||(q.current=!0,j.current=V.relatedTarget)},onMouseEnter:()=>K(!0),onMouseMove:()=>K(!0),onMouseLeave:()=>{B||K(!1)},onDragEnd:()=>K(!1),onPointerDown:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||I(!0)},onPointerUp:()=>I(!1)},T.filter(V=>!V.position&&M===0||V.position===P).map((V,D)=>{var X,Q;return b.createElement(II,{key:V.id,icons:S,index:D,toast:V,defaultRichColors:p,duration:(X=g==null?void 0:g.duration)!=null?X:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Q=g==null?void 0:g.closeButton)!=null?Q:i,interacting:B,position:P,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(ae=>ae.position==V.position),heights:R.filter(ae=>ae.position==V.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:w,expanded:H,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const jI=({...e})=>{const{theme:t="system"}=nI();return u.jsx(AI,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};F.Api=jv,F.ApiClient=Av,F.ApiProvider=nu,F.ArtifactRenderer=wh,F.Badge=Lp,F.Button=at,F.Card=tl,F.CardContent=sl,F.CardDescription=ol,F.CardHeader=nl,F.CardTitle=rl,F.ChatApi=Ho,F.ChatApp=pk,F.ChatInput=$f,F.ChatInterface=So,F.ChatProviders=Xr,F.Command=gl,F.CommandEmpty=wl,F.CommandGroup=bl,F.CommandInput=xl,F.CommandItem=yl,F.CommandList=vl,F.DEFAULT_TIMEOUT_MS=Xc,F.Dialog=Ya,F.DialogContent=Ds,F.DialogHeader=Ls,F.DialogTitle=$s,F.DropdownMenu=vs,F.DropdownMenuContent=ao,F.DropdownMenuItem=On,F.DropdownMenuTrigger=ws,F.FileViewerModal=rh,F.HISTORY_TIMEOUT_MS=Jc,F.Input=Nl,F.InterruptPartRenderer=yh,F.Label=lm,F.MarkdownContent=Ar,F.MessageBody=Eh,F.MessageComponent=Vs,F.MessageList=cl,F.MessageRow=ll,F.PlotArtifact=xh,F.ResearchTaskArtifact=vh,F.SETTINGS_STORAGE_KEY=Ri,F.ScrollArea=Il,F.Select=qk,F.SelectContent=Ym,F.SelectItem=Xm,F.SelectTrigger=Km,F.SelectValue=Gk,F.Separator=eg,F.Sheet=sE,F.SheetContent=cg,F.SheetDescription=fg,F.SheetHeader=ug,F.SheetTitle=dg,F.SheetTrigger=iE,F.SimpleChat=hk,F.SimpleJsonView=il,F.Sonner=jI,F.StreamProgress=Sh,F.Switch=ag,F.Textarea=ba,F.ThinkingIndicator=Th,F.ThreadListItem=nm,F.ThreadManager=Al,F.ThreadStateProvider=Cu,F.ThreadsProvider=lu,F.TimelineColumn=ix,F.Toaster=ZE,F.ToolComponent=Ch,F.Tooltip=AE,F.TooltipContent=yg,F.TooltipProvider=NE,F.TooltipTrigger=jE,F.UserTextContent=kh,F.applySettings=lw,F.buildAttemptMaps=Ql,F.buildCheckpointIndex=tc,F.buildCheckpointPreviewMap=ex,F.chatApiClient=An,F.del=ki,F.downloadFileById=Qc,F.extractConfigFields=di,F.fileToBase64=ru,F.get=qt,F.getChatToken=Gc,F.getCurrentSettings=aw,F.getDefaultApiConfig=Au,F.getDefaultChatSettings=ju,F.getFileContent=Ii,F.getFileInfo=Pv,F.getMessageDomKey=al,F.getPreviewForMessage=ui,F.httpClient=Kt,F.hydrateHistorySnapshots=Nn,F.isEnvelope=su,F.listFiles=eu,F.loadStoredSettings=_u,F.onChatTokenChanged=Yc,F.post=zo,F.processAttachments=ou,F.put=Zc,F.readNumber=rc,F.readString=Vn,F.resolveChatBaseUrl=mn,F.resolveMessageMetadata=Jl,F.saveSettings=Pu,F.setChatToken=Bo,F.toPlainObject=cr,F.unwrap=Mt,F.useApi=Vr,F.useCheckpointIndex=nc,F.useFilePreview=Ih,F.useHasChatSession=sw,F.useMessageMetadata=Zl,F.useParsedMessageContent=Nh,F.useStream=Mi,F.useStreamingHook=Mi,F.useThreadHistoryState=wu,F.useThreadManagerViewState=sm,F.useThreadState=Yr,F.useThreadStateUpdater=Su,F.useThreads=pr,F.useThreadsState=iu,F.viewFileById=_v,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
|