teodor-new-chat-ui 4.3.448 → 4.3.449
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +0 -2
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -14272,8 +14272,6 @@ function fE({ message: e, viewMode: t, isStreaming: n = !1 }) {
|
|
|
14272
14272
|
const { content: d, isMarkdown: p } = dw(c);
|
|
14273
14273
|
return p ? /* @__PURE__ */ u.jsx(Mo, { content: d, className: "text-current" }) : a(c);
|
|
14274
14274
|
}, l = () => {
|
|
14275
|
-
if (s)
|
|
14276
|
-
return null;
|
|
14277
14275
|
const c = e.content.find((m) => m.type !== "tool_call");
|
|
14278
14276
|
if (!c)
|
|
14279
14277
|
return /* @__PURE__ */ u.jsx("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: /* @__PURE__ */ u.jsxs("span", { children: [
|
package/dist/index.umd.js
CHANGED
|
@@ -125,6 +125,6 @@ ${t}</tr>
|
|
|
125
125
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
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=hh(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=hh(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 bh{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 wh{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 qn{constructor(t){this.options=t||cr,this.options.renderer=this.options.renderer||new ol,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new bh,this.slugger=new wh}static parse(t,n){return new qn(n).parse(t)}static parseInline(t,n){return new qn(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,ph(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 j='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}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 Gs{constructor(t){this.options=t||cr}preprocess(t){return t}postprocess(t){return t}}ex(Gs,"passThroughHooks",new Set(["preprocess","postprocess"]));function RT(e,t,n){return r=>{if(r.message+=`
|
|
128
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Ot(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 yh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...we.defaults,...s};const i=RT(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(jT(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&&we.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;we.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(we.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&&we.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function we(e,t,n){return yh(Kn.lex,qn.parse)(e,t,n)}we.options=we.setOptions=function(e){return we.defaults={...we.defaults,...e},xT(we.defaults),we},we.getDefaults=ch,we.defaults=cr,we.use=function(...e){const t=we.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=we.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=we.defaults.renderer||new ol;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=we.defaults.tokenizer||new rl;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=we.defaults.hooks||new Gs;for(const s in n.hooks){const i=o[s];Gs.passThroughHooks.has(s)?o[s]=a=>{if(we.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=we.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}}we.setOptions(r)})},we.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(we,r)),r.type){case"table":{for(const o of r.header)n=n.concat(we.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(we.walkTokens(s.tokens,t));break}case"list":{n=n.concat(we.walkTokens(r.items,t));break}default:we.defaults.extensions&&we.defaults.extensions.childTokens&&we.defaults.extensions.childTokens[r.type]?we.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(we.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(we.walkTokens(r.tokens,t)))}return n},we.parseInline=yh(Kn.lexInline,qn.parseInline),we.Parser=qn,we.parser=qn.parse,we.Renderer=ol,we.TextRenderer=bh,we.Lexer=Kn,we.lexer=Kn.lex,we.Tokenizer=rl,we.Slugger=wh,we.Hooks=Gs,we.parse=we,we.options,we.setOptions,we.use,we.walkTokens,we.parseInline,qn.parse,Kn.lex;function Mr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";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 we.parse=="function"?we.parse(i):we(i)}return typeof we.parse=="function"?we.parse(e):we(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 Sh({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})}})})]})}const Ch={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},MT=e=>{if(!e)return Ch.processing;const t=e.toLowerCase().trim();return Ch[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},OT=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Th({artifact:e}){const t=MT(e.status),n=e.task_url??e.taskUrl??"";return u.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:u.jsx(de.Search,{className:"h-4 w-4"})}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),u.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",u.jsx("span",{className:"font-mono",children:OT(e.task_id)})]})]})]}),t&&u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),u.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),u.jsx(Mr,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[u.jsx("span",{children:"Go to task"}),u.jsx(de.ExternalLink,{className:"h-3 w-3"})]}):u.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&u.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function sl({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>rb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Th,{artifact:{type:"research_task_info",task_id:e.task_id,task_url:e.task_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(Sh,{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 il=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}));il.displayName="Card";const al=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));al.displayName="CardHeader";const ll=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));ll.displayName="CardTitle";const cl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));cl.displayName="CardDescription";const ul=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));ul.displayName="CardContent";const kh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));kh.displayName="CardFooter";function Eh({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=vr(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(il,{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(al,{className:"pb-3",children:[u.jsx(ll,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(cl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(ul,{className:"pt-0 pb-3",children:a}),u.jsx(kh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Qe,{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(Qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const DT="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 dl({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:DT,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:vr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)})}function Ih({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(de.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 Nh({message:e,viewMode:t,isStreaming:n=!1}){const o=Mi(e).name||"tool",s=e.artifact??null,i=c=>{if(c==null)return null;const d=typeof c=="string"?Ri(c)??c:c;if(d&&typeof d=="object")return u.jsx(dl,{data:d});const p=typeof d=="string"?d:(()=>{try{return vr(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:p})},a=c=>{if(c==null)return null;const{content:d,isMarkdown:p}=Xv(c);return p?u.jsx(Mr,{content:d,className:"text-current"}):i(c)},l=()=>{if(s)return null;const c=e.content.find(m=>m.type!=="tool_call");if(!c)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(c.type==="text"){const f=(c.text??"").trim();if(!f)return null;const v=Qr(f);return a(v)}const d=Zr(c),p=Qr(d);return a(p)};return u.jsxs("div",{className:"space-y-2",children:[s&&u.jsx(sl,{artifact:s,idx:0}),u.jsx(Ih,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:l()})]})}function Ah({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 jh({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(Mr,{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(Qe,{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(de.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(de.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function _h({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:j,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(de.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),B=b.useCallback(({part:N,i:z})=>{if(N.type==="text"){const $=N.text??"",M=$.trim(),P=Ri(M);return P&&w!=="tool"?u.jsx(dl,{data:P},z):w==="user"&&S&&M.length>k?u.jsx(jh,{text:M,expanded:C,onExpandedChange:T,previewLength:k,isCompact:E},z):u.jsx(Mr,{content:$,allowHtml:!1},z)}if(N.type==="image_url"){const $=N;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:$.url,alt:$.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},z)}if(N.type==="file"){const $=N,M=$.name||"file";return u.jsxs("a",{href:$.url,onClick:P=>f(P.nativeEvent,$,z),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
128
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Ot(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 yh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...we.defaults,...s};const i=RT(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(jT(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&&we.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;we.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(we.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&&we.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function we(e,t,n){return yh(Kn.lex,qn.parse)(e,t,n)}we.options=we.setOptions=function(e){return we.defaults={...we.defaults,...e},xT(we.defaults),we},we.getDefaults=ch,we.defaults=cr,we.use=function(...e){const t=we.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=we.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=we.defaults.renderer||new ol;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=we.defaults.tokenizer||new rl;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=we.defaults.hooks||new Gs;for(const s in n.hooks){const i=o[s];Gs.passThroughHooks.has(s)?o[s]=a=>{if(we.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=we.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}}we.setOptions(r)})},we.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(we,r)),r.type){case"table":{for(const o of r.header)n=n.concat(we.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(we.walkTokens(s.tokens,t));break}case"list":{n=n.concat(we.walkTokens(r.items,t));break}default:we.defaults.extensions&&we.defaults.extensions.childTokens&&we.defaults.extensions.childTokens[r.type]?we.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(we.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(we.walkTokens(r.tokens,t)))}return n},we.parseInline=yh(Kn.lexInline,qn.parseInline),we.Parser=qn,we.parser=qn.parse,we.Renderer=ol,we.TextRenderer=bh,we.Lexer=Kn,we.lexer=Kn.lex,we.Tokenizer=rl,we.Slugger=wh,we.Hooks=Gs,we.parse=we,we.options,we.setOptions,we.use,we.walkTokens,we.parseInline,qn.parse,Kn.lex;function Mr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";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 we.parse=="function"?we.parse(i):we(i)}return typeof we.parse=="function"?we.parse(e):we(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 Sh({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})}})})]})}const Ch={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},MT=e=>{if(!e)return Ch.processing;const t=e.toLowerCase().trim();return Ch[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},OT=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Th({artifact:e}){const t=MT(e.status),n=e.task_url??e.taskUrl??"";return u.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:u.jsx(de.Search,{className:"h-4 w-4"})}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),u.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",u.jsx("span",{className:"font-mono",children:OT(e.task_id)})]})]})]}),t&&u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),u.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),u.jsx(Mr,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[u.jsx("span",{children:"Go to task"}),u.jsx(de.ExternalLink,{className:"h-3 w-3"})]}):u.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&u.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function sl({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>rb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Th,{artifact:{type:"research_task_info",task_id:e.task_id,task_url:e.task_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(Sh,{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 il=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}));il.displayName="Card";const al=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));al.displayName="CardHeader";const ll=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));ll.displayName="CardTitle";const cl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));cl.displayName="CardDescription";const ul=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));ul.displayName="CardContent";const kh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));kh.displayName="CardFooter";function Eh({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=vr(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(il,{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(al,{className:"pb-3",children:[u.jsx(ll,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(cl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(ul,{className:"pt-0 pb-3",children:a}),u.jsx(kh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Qe,{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(Qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const DT="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 dl({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:DT,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:vr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)})}function Ih({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(de.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 Nh({message:e,viewMode:t,isStreaming:n=!1}){const o=Mi(e).name||"tool",s=e.artifact??null,i=c=>{if(c==null)return null;const d=typeof c=="string"?Ri(c)??c:c;if(d&&typeof d=="object")return u.jsx(dl,{data:d});const p=typeof d=="string"?d:(()=>{try{return vr(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:p})},a=c=>{if(c==null)return null;const{content:d,isMarkdown:p}=Xv(c);return p?u.jsx(Mr,{content:d,className:"text-current"}):i(c)},l=()=>{const c=e.content.find(m=>m.type!=="tool_call");if(!c)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(c.type==="text"){const f=(c.text??"").trim();if(!f)return null;const v=Qr(f);return a(v)}const d=Zr(c),p=Qr(d);return a(p)};return u.jsxs("div",{className:"space-y-2",children:[s&&u.jsx(sl,{artifact:s,idx:0}),u.jsx(Ih,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:l()})]})}function Ah({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 jh({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(Mr,{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(Qe,{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(de.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(de.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function _h({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:j,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(de.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),B=b.useCallback(({part:N,i:z})=>{if(N.type==="text"){const $=N.text??"",M=$.trim(),P=Ri(M);return P&&w!=="tool"?u.jsx(dl,{data:P},z):w==="user"&&S&&M.length>k?u.jsx(jh,{text:M,expanded:C,onExpandedChange:T,previewLength:k,isCompact:E},z):u.jsx(Mr,{content:$,allowHtml:!1},z)}if(N.type==="image_url"){const $=N;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:$.url,alt:$.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},z)}if(N.type==="file"){const $=N,M=$.name||"file";return u.jsxs("a",{href:$.url,onClick:P=>f(P.nativeEvent,$,z),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
129
|
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[v[z]?u.jsx(de.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[M,v[z]?" (processing)":""]})]},z)}if(N.type==="interrupt"){const $=N,M=Go(($==null?void 0:$.id)??($==null?void 0:$.interrupt_id)),P=!!(j&&M&&M===j),I=P?R??($==null?void 0:$.value):$==null?void 0:$.value,V=M?{...$,id:M,interrupt_id:M}:$;return u.jsx(Eh,{interruptPart:V,onApprove:g,onReject:x,disabled:y,isActive:P,payload:I},z)}return null},[f,v,g,x,w,S,k,C,E,j,R,y]),q=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!p)return H();if(!t&&!q&&!p)return null;if(t)return!n&&r?null:n?u.jsx(Nh,{message:e,viewMode:o,isStreaming:s},e.id):null;if(!m){const N=u.jsx("div",{className:"space-y-2",children:i.map((z,$)=>u.jsx(B,{part:z,i:$},$))});return p?u.jsxs("div",{"aria-busy":"true",role:"status",children:[N,u.jsx(Ah,{className:L})]}):N}return null}function Ph(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=nl(),[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 Rh(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:Jv(r),toolMeta:Mi(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Zv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Ys=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,onCopy:x,activeInterrupt:y,disableInterruptActions:w=!1,onInterruptActionStart:S,onInterruptActionEnd:k,attemptCount:C=1,attemptIndex:T=0,onSelectCheckpoint:E,attemptMetas:j=[]}){const[R,L]=b.useState(!1),[H,B]=b.useState("preview"),[q,N]=b.useState(!1),{currentThreadId:z}=xr(),{respondToInterrupt:$}=eo(),M=l==="phone"||l==="half-screen",P=t.role,I=P==="tool",V=b.useMemo(()=>t.role==="default_message"?t:null,[t]),J=!!V,_=!(r&&P!=="user"),{uploadingFiles:O,handleFileClick:K,fileViewerOpen:Y,currentFileInfo:ae,closeFileViewer:W}=Ph({allowFileOpen:_,currentThreadId:z}),D=b.useMemo(()=>{switch(P){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))]"}},[P]),X=Rh(t,V),{contentParts:oe,imageParts:G,fileParts:Z,interruptParts:te,textContent:se,toolMeta:ue,toolRaw:ge,isToolStreaming:Me}=X,Oe=(y==null?void 0:y.id)??(y==null?void 0:y.interrupt_id),Te=Go(Oe),nt=y==null?void 0:y.value,pt=b.useMemo(()=>V||!m?null:t.artifact||null,[V,t,m]),Tt=b.useCallback(async()=>{const ke=I?ge:se;async function et(Ae){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ae);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Le=new Blob([Ae],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Le})]);return}throw new Error("Clipboard API not supported in this context.")}try{await et(ke),L(!0),setTimeout(()=>L(!1),2e3),x==null||x(ke)}catch(Ae){console.error("Failed to copy:",Ae)}},[I,ge,se,x]),Ke=b.useCallback(()=>{if(!v||!t.id)return;const ke=(I?ge:se)??"",et="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,ke,et)},[v,t.id,I,ge,se,t]),Ge=b.useCallback(()=>{g==null||g(n)},[g,n]),Ve=b.useCallback(()=>{const et=ne(M?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",D);switch(P){case"user":return u.jsx(de.User,{className:et});case"assistant":return u.jsx(de.Bot,{className:et});case"tool":return u.jsx(de.Wrench,{className:et});default:return u.jsx(de.Bot,{className:et})}},[M,D,P]),$e=b.useCallback(()=>{const ke="group relative mb-4 flex w-full";switch(P){case"user":return ne(ke,"justify-end");case"assistant":case"tool":case"system":return ne(ke,"justify-start");default:return ke}},[P]),He=b.useCallback(()=>{const ke=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",M&&"px-3 py-2 text-sm");if(J)return ne(ke,"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(P){case"user":return ne(ke,"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(ke,"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(ke,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(ke,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(ke,"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")}},[M,J,P]),mt=b.useCallback(async ke=>{if(w)return;const et=Go((ke==null?void 0:ke.id)??(ke==null?void 0:ke.interrupt_id));if(!et){console.warn("Interrupt part missing id",ke);return}try{S==null||S(),await $(et,!0)}catch(Ae){console.error("Failed to approve interrupt:",Ae)}finally{k==null||k()}},[w,k,S,$]),Dt=b.useCallback(async ke=>{if(w)return;const et=Go((ke==null?void 0:ke.id)??(ke==null?void 0:ke.interrupt_id));if(!et){console.warn("Interrupt part missing id",ke);return}try{S==null||S(),await $(et,!1)}catch(Ae){console.error("Failed to reject interrupt:",Ae)}finally{k==null||k()}},[w,k,S,$]),lt=b.useMemo(()=>V?"Assistant":Qv(t),[V,t]),kt=P==="user"&&(C??1)>1&&typeof E=="function",wt=(j==null?void 0:j.length)??0,gt=wt>0&&T<wt-1?j[T+1]:void 0,ht=wt>0&&T>0?j[T-1]:void 0,an=b.useCallback(()=>{!gt||!E||E(gt.id,void 0,!!gt.isLatestAttempt)},[gt,E]),dt=b.useCallback(()=>{!ht||!E||E(ht.id,void 0,!!ht.isLatestAttempt)},[ht,E]);return I&&!p&&!pt?null:J&&V?u.jsx("div",{className:ne($e(),f.container),children:u.jsxs("div",{className:ne(He(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(de.Bot,{className:ne("h-4 w-4",D)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Mr,{content:V.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne($e(),f.container),children:u.jsxs("div",{className:ne(He(),f.content),children:[(i||a||I)&&u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",M&&"mb-1 pb-1",D,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Ve(),a&<&&u.jsx("span",{className:ne("font-medium",M?"text-xs":"text-sm"),children:lt}),I&&u.jsxs(Hp,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",D,"border border-current/40",M&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":H==="expanded",onClick:()=>B(ke=>ke==="expanded"?"preview":"expanded"),onKeyDown:ke=>{(ke.key==="Enter"||ke.key===" ")&&(ke.preventDefault(),B(et=>et==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ue.name??"Tool Output"}),ue.toolCallId&&u.jsx("span",{className:"opacity-70",children:ue.toolCallId.slice(0,8)}),H==="expanded"?u.jsx(de.ChevronUp,{className:"h-3 w-3"}):u.jsx(de.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[kt&&C>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T<C-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T>=C-1||an()},"aria-label":"Older attempt (back in time)",disabled:T>=C-1,children:u.jsx(de.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[C-T," / ",C]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T<=0||dt()},"aria-label":"Newer attempt (forward in time)",disabled:T<=0,children:u.jsx(de.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:ne("text-xs opacity-60",D,M&&"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(Qe,{variant:"ghost",size:"sm",onClick:()=>Tt(),className:ne("h-6 w-6 p-0 hover:bg-foreground/10",D,M&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(de.Copy,{className:ne(R?"text-success":D,M?"h-3 w-3":"h-4 w-4")})})}),P==="user"&&v&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ke,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",D,M&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(de.Edit,{className:ne(D,M?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ge,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",D,M&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(de.RotateCcw,{className:ne(D,M?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(_h,{message:t,isToolMessage:I,showToolMessages:p,artifactToRender:pt,toolViewMode:H,isToolStreaming:Me,contentParts:oe,textContent:se,imageParts:G,fileParts:Z,interruptParts:te,isStreamingMessage:r,defaultMessage:V,handleFileClick:K,uploadingFiles:O,handleInterruptApprove:mt,handleInterruptReject:Dt,disableInterruptActions:w,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:q,setIsUserExpanded:N,isCompactLayout:M,activeInterruptId:Te,activeInterruptValue:nt,iconForeground:D}),m&&pt&&u.jsx("div",{className:"mt-3",children:u.jsx(sl,{artifact:pt,idx:0})})]}),I&&H==="expanded"&&(ue.toolCallId||ue.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",M&&"text-xs"),children:[ue.name&&u.jsxs("div",{children:["Function: ",ue.name]}),ue.toolCallId&&u.jsxs("div",{children:["Call ID: ",ue.toolCallId]})]}),!(i||a||I)&&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(Qe,{variant:"ghost",size:"sm",onClick:()=>Tt(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:u.jsx(de.Copy,{className:ne(R?"text-success":"text-current",M?"h-3 w-3":"h-4 w-4")})}),P==="user"&&v&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ke,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:u.jsx(de.Edit,{className:ne("text-current",M?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ge,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:u.jsx(de.RotateCcw,{className:ne("text-current",M?"h-3 w-3":"h-4 w-4")})})]})]})}),ae&&u.jsx(lh,{isOpen:Y,onClose:W,fileId:ae.id,fileName:ae.name,mimeType:ae.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&mu(e.message)===mu(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=gu(e.message),a=gu(t.message);return i.length===a.length});Ys.displayName="MessageComponent";const LT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},fl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,pl=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,onSelectCheckpoint:S}){const k=fl(t,n),C=t.role==="default_message",E=!!t.__syntheticStreaming,j=w??LT,R=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:L,attemptIndex:H,attempts:B}=b.useMemo(()=>tc(t.id,R,j),[t.id,R,j]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":k,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Ys,{message:t,messageIndex:n,isStreamingMessage:E||r&&o===t.id&&t.role==="assistant",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,attemptCount:L,attemptIndex:H,attemptMetas:B,onSelectCheckpoint:S})})});pl.displayName="MessageRow";const hl=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:j,activeCheckpointId:R,onSelectCheckpoint:L,createSyntheticThinkingMessage:H=!0,forceSyntheticThinking:B=!1},q)=>{const N=b.useRef(null),z=b.useRef(null),$=b.useRef(!1),M=b.useRef(!1),[P,I]=b.useState(!0),V=b.useMemo(()=>w?e.some(te=>te.role==="default_message"?!1:Array.isArray(te==null?void 0:te.content)&&te.content.some(se=>se&&se.type==="interrupt"&&(se.id??se.interrupt_id)===w.id)):!1,[w,e]),J=b.useMemo(()=>{if(!w||V)return null;const te=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let se;const ue=w.value;if(ue&&typeof ue=="object"&&!Array.isArray(ue)){const ge=ue.title;typeof ge=="string"&&ge.trim()&&(se=ge.trim())}return{id:`interrupt-${te}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:te,value:ue,title:se}]}},[w,V]),_=b.useMemo(()=>J?[...e,J]:e,[e,J]),O=b.useMemo(()=>{const te=n&&_.some(ue=>ue.id===n);return H&&(t||B)&&!te&&_.length>0?[..._,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:_},[_,t,n,H,B]),K=b.useMemo(()=>T?O:O.filter(te=>(te==null?void 0:te.role)!=="tool"),[O,T]),Y=b.useCallback(te=>{I(te),x&&x(!te),y&&y(te)},[x,y]),ae=b.useMemo(()=>{if(a)return async()=>{if(!$.current){$.current=!0;try{await a()}finally{$.current=!1}}}},[a]),W=b.useMemo(()=>!v||g?!1:P?"auto":!1,[P,v,g]),D=b.useMemo(()=>{if(typeof f!="string")return null;const te=f.trim();return!te||K&&K.length>0?null:{id:"default-message",role:"default_message",content:te,createdAt:new Date().toISOString()}},[f,K]),X=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),oe=()=>D?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Ys,{message:D,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!"}),G=K.length,Z=G>0;return b.useEffect(()=>{var te,se;if(G===0){M.current=!1;return}if(!M.current)if(M.current=!0,N.current&&K.length>0){const ue=K.length-1;(se=(te=N.current).scrollToIndex)==null||se.call(te,{index:ue,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},[G,K.length]),b.useImperativeHandle(q,()=>({scrollToLatest:()=>{var te,se;if(N.current&&K.length>0){const ue=K.length-1;(se=(te=N.current).scrollToIndex)==null||se.call(te,{index:ue,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},scrollToTop:()=>{var te,se;N.current&&K.length>0?(se=(te=N.current).scrollToIndex)==null||se.call(te,{index:0,align:"start",behavior:"auto"}):z.current&&(z.current.scrollTop=0)}}),[K]),u.jsx("div",{className:X,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:Z?u.jsx($C,{ref:te=>{N.current=te},scrollerRef:te=>{z.current=te instanceof HTMLDivElement?te:null},data:K,followOutput:W,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{ae&&ae()},atBottomStateChange:Y,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(te,se)=>fl(se,te),itemContent:(te,se)=>u.jsx(pl,{message:se,index:te,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:j,activeCheckpointId:R,onSelectCheckpoint:L})}):oe()})})});hl.displayName="MessageList";const Mh={value:""};function Or({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,payloadExtras:m={},customStyles:f={},onMessageSent:v,onExcelUploadSuccess:g,onError:x}){const{api:y}=Xr(),{currentThreadId:w}=xr(),{threadId:S,messages:k,isHistoryLoading:C,isLoading:T,navigateToCheckpoint:E,returnToLatest:j,checkpoint:R,checkpoints:L,interrupt:H,metadata:B,checkpointIndex:q}=eo(),{isStreaming:N,error:z,connectionState:$,submit:M,stop:P}=Li(),I=S??w??null,V=(R==null?void 0:R.id)??null,J=(R==null?void 0:R.namespace)??null,_=(B==null?void 0:B.assemblingMessageId)??null,O=H,[K,Y]=b.useState(!1),[ae,W]=b.useState(!1);b.useEffect(()=>{O||Y(!1)},[O]);const D=b.useCallback(()=>{Y(!0)},[]),X=b.useCallback(()=>{Y(!1)},[]),oe=!!O||K,[G,Z]=b.useState(null),[te,se]=b.useState(""),[ue,ge]=b.useState(null),[Me,Oe]=b.useState(null),[Te,nt]=b.useState([]),[pt,Tt]=b.useState(0),[Ke,Ge]=b.useState(0),[Ve,$e]=b.useState(!1),[He,mt]=b.useState(null),[Dt,lt]=b.useState(null),[kt,wt]=b.useState(!1),[gt,ht]=b.useState(null),an=b.useRef(!1),[dt,ke]=b.useState(()=>Mh.value),et=b.useRef(dt),Ae=b.useRef(null),Le=b.useCallback(le=>{Mh.value=le,ke(le)},[]),[Bt,re]=b.useState(!1),ye=b.useRef(null),rt=b.useRef(null),xe=b.useRef(null),Pe=b.useCallback(()=>{rt.current&&(rt.current.value=""),xe.current&&(xe.current.value=""),Tt(le=>le+1),Ge(le=>le+1)},[]),Xe=b.useCallback(le=>{Le(le)},[Le]),St=b.useRef(!1);b.useEffect(()=>{St.current&&!N&&(nt([]),Pe()),St.current=N},[N,Pe]),b.useEffect(()=>{N||W(!1)},[N]),b.useEffect(()=>{B!=null&&B.assemblingMessageId&&W(!1)},[B==null?void 0:B.assemblingMessageId]);const[Et,Nt]=b.useState("desktop");b.useEffect(()=>{const le=()=>{const Ce=window.innerWidth;Nt(Ce<640?"phone":Ce<1024?"tablet":"desktop")};return le(),window.addEventListener("resize",le),()=>window.removeEventListener("resize",le)},[]),b.useEffect(()=>{an.current=!1},[I]),b.useEffect(()=>{et.current=dt},[dt]),b.useEffect(()=>{if(!G){Ae.current=null;return}Ae.current===null&&(Ae.current=et.current),Le(te??"")},[te,G,Le]),b.useEffect(()=>{(async()=>{if(!y.baseUrl){ht(null);return}try{const be=(await y.getAgent("default")).uiDefaultMessage||"";ht(be||null)}catch(Ce){console.warn("Failed to fetch default message:",Ce),ht(null)}})()},[y.baseUrl]),b.useEffect(()=>{z&&!kt&&(x==null||x(z))},[z,kt,x]);const zt=async le=>{const Ce=le.trim();if(!(!Ce&&Te.length===0))try{const be=G?(ue==null?void 0:ue.checkpointId)??V??void 0:V??void 0,ze=G?(ue==null?void 0:ue.checkpointNs)??J??void 0:J??void 0;await M({text:Ce||"",attachments:Te,payload:m},{checkpointId:be,checkpointNs:ze,edit:!!G,originalMessageId:G??void 0}),v==null||v(Ce),W(!0),Le(""),Oe(null),nt([]),Pe(),Z(null),se(""),ge(null)}catch(be){const ze=(be==null?void 0:be.message)||"Failed to send message";Oe(ze),x==null||x(ze),W(!1)}},_e=b.useCallback((le,Ce,be)=>{c&&(Ae.current=dt,Z(le),se(Ce),Le(Ce),Oe(null),ge({checkpointId:(be==null?void 0:be.checkpointId)??null,checkpointNs:(be==null?void 0:be.checkpointNs)??null}))},[dt,c,Le]),ct=b.useCallback(()=>{Z(null),se(""),ge(null),Oe(null),Le(Ae.current??dt),Ae.current=null},[dt,Le]),Je=b.useCallback((le,Ce,be)=>{_e(le,Ce,be)},[_e]),ft=b.useCallback(le=>{let Ce=null;for(let jt=le-1;jt>=0;jt--)if(k[jt].role==="user"){Ce=k[jt];break}if(!Ce)return;const be=Array.isArray(Ce.content)?Ce.content:[],At=be.filter(jt=>(jt==null?void 0:jt.type)==="text").map(jt=>jt.text).join("")||(()=>{try{return JSON.stringify(be,null,2)}catch{return String(be)}})();At&&M({text:At,payload:m},{checkpointId:V??void 0,checkpointNs:J??void 0,edit:!0,originalMessageId:Ce.id})},[k,M,V,J,m]),ln=le=>{const Ce=Array.from(le.target.files||[]);nt(be=>[...be,...Ce]),le.target.value=""},A=le=>{nt(Ce=>{const be=Ce.filter((ze,At)=>le!==At);return be.length===0&&Pe(),be})},Q=async le=>{const Ce=(le.target.files||[])[0];if(Ce){mt(null),lt(null),$e(!0);try{await M({attachments:[Ce],payload:m},{checkpointId:V??void 0,checkpointNs:J??void 0});const be=`Uploaded ${Ce.name} - processing through chat stream`;lt(be)}catch(be){const ze=be instanceof Error?be.message:"Failed to upload Excel file";console.error("Excel upload failed",be),mt(ze),x==null||x(ze)}finally{$e(!1),le.target.value="",Pe()}}},fe=async le=>{if(w){re(!0);try{if(!le){await j(),requestAnimationFrame(()=>{var ze;(ze=ye.current)==null||ze.scrollToLatest()});return}const Ce=L.find(ze=>ze.checkpointId===le),be=(Ce==null?void 0:Ce.checkpointNs)??null;await E(le,be),requestAnimationFrame(()=>{var ze;(ze=ye.current)==null||ze.scrollToTop()})}finally{re(!1)}}},Ie=b.useCallback(async(le,Ce,be)=>{await fe(be?null:le)},[fe]),Ye=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,tt=`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 ${f.messagesArea||""}`,Ue=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`;return u.jsxs("div",{className:Ye,children:[!!z&&!kt&&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:z}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>wt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(de.X,{size:16})})]}),u.jsxs("div",{className:`relative ${tt}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(hl,{ref:ye,className:"h-full",style:{height:"100%"},messages:k,isStreaming:N,streamingAssistantId:_,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Et,enableMessageEditing:c,editingMessageId:G,onEdit:Je,onRegenerate:ft,onCancelEdit:ct,emptyMessage:gt??void 0,isNavigatingCheckpoint:Bt,activeInterrupt:O,disableInterruptActions:K,onInterruptActionStart:D,onInterruptActionEnd:X,showToolMessages:d,showArtifactPreviews:p,checkpointIndex:q,activeCheckpointId:V,onSelectCheckpoint:Ie,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ae}),($==="reconnecting"||$==="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(de.Loader2,{className:"h-3 w-3 animate-spin"}),$==="reconnecting"?"Reconnecting…":"Connecting…"]})}),$==="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"}),T&&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(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(C||Bt)&&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(de.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:Ue,children:[G&&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(de.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:ct,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(de.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:rt,type:"file",multiple:!0,onChange:le=>ln(le),className:"hidden"},pt),Te.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:Te.map((le,Ce)=>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(de.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:le.name}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>A(Ce),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 ${le.name}`,children:u.jsx(de.X,{size:12})})]},Ce))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:xe,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Q,className:"hidden"},Ke),Ve&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Dt&&!Ve&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Dt}),He&&!Ve&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:He})]})]}),Me&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Me}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{type:"button",size:"icon",variant:"outline",disabled:N||oe,title:"More input actions",className:f.moreButton||"",children:u.jsx(de.Plus,{size:16})})}),u.jsxs(po,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(zn,{onClick:()=>{var le;return(le=rt.current)==null?void 0:le.click()},className:"cursor-pointer",children:[u.jsx(de.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(zn,{onClick:()=>{var le;Ve||(le=xe.current)==null||le.click()},className:`cursor-pointer ${Ve?"opacity-60 pointer-events-none":""}`,children:[u.jsx(de.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(NS,{initialValue:te,editingMessageId:G,value:dt,onValueChange:Xe,placeholder:G?"Edit your message...":t,isStreaming:N,disabled:oe,onSend:zt,onCancelEdit:ct,onStop:P,allowEmptySend:Te.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${G?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${Me?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}var Oh=1,$T=.9,FT=.8,BT=.17,ml=.1,gl=.999,zT=.9999,HT=.99,UT=/[\\\/_+.#"@\[\(\{&]/,WT=/[\\\/_+.#"@\[\(\{&]/g,VT=/[\s-]/,Dh=/[\s-]/g;function xl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Oh:HT;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=xl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=Oh:UT.test(e.charAt(c-1))?(p*=FT,f=e.slice(o,c-1).match(WT),f&&o>0&&(p*=Math.pow(gl,f.length))):VT.test(e.charAt(c-1))?(p*=$T,v=e.slice(o,c-1).match(Dh),v&&o>0&&(p*=Math.pow(gl,v.length))):(p*=BT,o>0&&(p*=Math.pow(gl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=zT)),(p<ml&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=xl(e,t,n,r,c+1,s+2,i),m*ml>p&&(p=m*ml)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function Lh(e){return e.toLowerCase().replace(Dh," ")}function KT(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,xl(e,t,Lh(e),Lh(t),0,0,{})}var Io='[cmdk-group=""]',vl='[cmdk-group-items=""]',qT='[cmdk-group-heading=""]',$h='[cmdk-item=""]',Fh=`${$h}:not([aria-disabled="true"])`,bl="cmdk-item-select",Dr="data-value",GT=(e,t,n)=>KT(e,t,n),Bh=h.createContext(void 0),No=()=>h.useContext(Bh),zh=h.createContext(void 0),wl=()=>h.useContext(zh),Hh=h.createContext(void 0),Uh=h.forwardRef((e,t)=>{let n=Lr(()=>{var _,O;return{search:"",value:(O=(_=e.value)!=null?_:e.defaultValue)!=null?O:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Lr(()=>new Set),o=Lr(()=>new Map),s=Lr(()=>new Map),i=Lr(()=>new Set),a=Wh(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=Pt(),S=Pt(),k=Pt(),C=h.useRef(null),T=sk();ur(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,E.emit()}},[d]),ur(()=>{T(6,q)},[]);let E=h.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,O,K)=>{var Y,ae,W,D;if(!Object.is(n.current[_],O)){if(n.current[_]=O,_==="search")B(),L(),T(1,H);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(Y=document.getElementById(w))==null||Y.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=N())==null?void 0:X.id,E.emit()}),K||T(5,q),((ae=a.current)==null?void 0:ae.value)!==void 0){let X=O??"";(D=(W=a.current).onValueChange)==null||D.call(W,X);return}}E.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),j=h.useMemo(()=>({value:(_,O,K)=>{var Y;O!==((Y=s.current.get(_))==null?void 0:Y.value)&&(s.current.set(_,{value:O,keywords:K}),n.current.filtered.items.set(_,R(O,K)),T(2,()=>{L(),E.emit()}))},item:(_,O)=>(r.current.add(_),O&&(o.current.has(O)?o.current.get(O).add(_):o.current.set(O,new Set([_]))),T(3,()=>{B(),L(),n.current.value||H(),E.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let K=N();T(4,()=>{B(),(K==null?void 0:K.getAttribute("id"))===_&&H(),E.emit()})}),group:_=>(o.current.has(_)||o.current.set(_,new Set),()=>{s.current.delete(_),o.current.delete(_)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function R(_,O){var K,Y;let ae=(Y=(K=a.current)==null?void 0:K.filter)!=null?Y:GT;return _?ae(_,n.current.search,O):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,O=[];n.current.filtered.groups.forEach(Y=>{let ae=o.current.get(Y),W=0;ae.forEach(D=>{let X=_.get(D);W=Math.max(X,W)}),O.push([Y,W])});let K=C.current;z().sort((Y,ae)=>{var W,D;let X=Y.getAttribute("id"),oe=ae.getAttribute("id");return((W=_.get(oe))!=null?W:0)-((D=_.get(X))!=null?D:0)}).forEach(Y=>{let ae=Y.closest(vl);ae?ae.appendChild(Y.parentElement===ae?Y:Y.closest(`${vl} > *`)):K.appendChild(Y.parentElement===K?Y:Y.closest(`${vl} > *`))}),O.sort((Y,ae)=>ae[1]-Y[1]).forEach(Y=>{var ae;let W=(ae=C.current)==null?void 0:ae.querySelector(`${Io}[${Dr}="${encodeURIComponent(Y[0])}"]`);W==null||W.parentElement.appendChild(W)})}function H(){let _=z().find(K=>K.getAttribute("aria-disabled")!=="true"),O=_==null?void 0:_.getAttribute(Dr);E.setState("value",O||void 0)}function B(){var _,O,K,Y;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ae=0;for(let W of r.current){let D=(O=(_=s.current.get(W))==null?void 0:_.value)!=null?O:"",X=(Y=(K=s.current.get(W))==null?void 0:K.keywords)!=null?Y:[],oe=R(D,X);n.current.filtered.items.set(W,oe),oe>0&&ae++}for(let[W,D]of o.current)for(let X of D)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(W);break}n.current.filtered.count=ae}function q(){var _,O,K;let Y=N();Y&&(((_=Y.parentElement)==null?void 0:_.firstChild)===Y&&((K=(O=Y.closest(Io))==null?void 0:O.querySelector(qT))==null||K.scrollIntoView({block:"nearest"})),Y.scrollIntoView({block:"nearest"}))}function N(){var _;return(_=C.current)==null?void 0:_.querySelector(`${$h}[aria-selected="true"]`)}function z(){var _;return Array.from(((_=C.current)==null?void 0:_.querySelectorAll(Fh))||[])}function $(_){let O=z()[_];O&&E.setState("value",O.getAttribute(Dr))}function M(_){var O;let K=N(),Y=z(),ae=Y.findIndex(D=>D===K),W=Y[ae+_];(O=a.current)!=null&&O.loop&&(W=ae+_<0?Y[Y.length-1]:ae+_===Y.length?Y[0]:Y[ae+_]),W&&E.setState("value",W.getAttribute(Dr))}function P(_){let O=N(),K=O==null?void 0:O.closest(Io),Y;for(;K&&!Y;)K=_>0?rk(K,Io):ok(K,Io),Y=K==null?void 0:K.querySelector(Fh);Y?E.setState("value",Y.getAttribute(Dr)):M(_)}let I=()=>$(z().length-1),V=_=>{_.preventDefault(),_.metaKey?I():_.altKey?P(1):M(1)},J=_=>{_.preventDefault(),_.metaKey?$(0):_.altKey?P(-1):M(-1)};return h.createElement(me.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:_=>{var O;(O=y.onKeyDown)==null||O.call(y,_);let K=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||K))switch(_.key){case"n":case"j":{x&&_.ctrlKey&&V(_);break}case"ArrowDown":{V(_);break}case"p":case"k":{x&&_.ctrlKey&&J(_);break}case"ArrowUp":{J(_);break}case"Home":{_.preventDefault(),$(0);break}case"End":{_.preventDefault(),I();break}case"Enter":{_.preventDefault();let Y=N();if(Y){let ae=new Event(bl);Y.dispatchEvent(ae)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:ak},l),Xs(e,_=>h.createElement(zh.Provider,{value:E},h.createElement(Bh.Provider,{value:j},_))))}),YT=h.forwardRef((e,t)=>{var n,r;let o=Pt(),s=h.useRef(null),i=h.useContext(Hh),a=No(),l=Wh(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;ur(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Vh(o,s,[e.value,e.children,s],e.keywords),p=wl(),m=Gn(T=>T.value&&T.value===d.current),f=Gn(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(bl,v),()=>T.removeEventListener(bl,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(me.div,{ref:Dn(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)}),XT=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Pt(),a=h.useRef(null),l=h.useRef(null),c=Pt(),d=No(),p=Gn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),Vh(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(me.div,{ref:Dn(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),Xs(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Hh.Provider,{value:m},f))))}),JT=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Gn(i=>!i.search);return!n&&!s?null:h.createElement(me.div,{ref:Dn(o,t),...r,"cmdk-separator":"",role:"separator"})}),ZT=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=wl(),i=Gn(c=>c.search),a=Gn(c=>c.selectedItemId),l=No();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(me.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)}})}),QT=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Gn(c=>c.selectedItemId),l=No();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(me.div,{ref:Dn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Xs(e,c=>h.createElement("div",{ref:Dn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),ek=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(Ja,{open:n,onOpenChange:r},h.createElement(Za,{container:i},h.createElement(To,{"cmdk-overlay":"",className:o}),h.createElement(ko,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(Uh,{ref:t,...a}))))}),tk=h.forwardRef((e,t)=>Gn(n=>n.filtered.count===0)?h.createElement(me.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),nk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(me.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Xs(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Kt=Object.assign(Uh,{List:QT,Item:YT,Input:ZT,Group:XT,Separator:JT,Dialog:ek,Empty:tk,Loading:nk});function rk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function ok(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Wh(e){let t=h.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?h.useEffect:h.useLayoutEffect;function Lr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Gn(e){let t=wl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Vh(e,t,n,r=[]){let o=h.useRef(),s=No();return ur(()=>{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(Dr,a),o.current=a}),o}var sk=()=>{let[e,t]=h.useState(),n=Lr(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function ik(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Xs({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(ik(t),{ref:t.ref},n(t.props.children)):n(t)}var ak={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const yl=h.forwardRef(({className:e,...t},n)=>u.jsx(Kt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));yl.displayName=Kt.displayName;const Sl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(de.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Kt.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})]}));Sl.displayName=Kt.Input.displayName;const Cl=h.forwardRef(({className:e,...t},n)=>u.jsx(Kt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Cl.displayName=Kt.List.displayName;const Tl=h.forwardRef((e,t)=>u.jsx(Kt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Tl.displayName=Kt.Empty.displayName;const kl=h.forwardRef(({className:e,...t},n)=>u.jsx(Kt.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}));kl.displayName=Kt.Group.displayName;const lk=h.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));lk.displayName=Kt.Separator.displayName;const El=h.forwardRef(({className:e,...t},n)=>u.jsx(Kt.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}));El.displayName=Kt.Item.displayName;function Il(e,[t,n]){return Math.min(n,Math.max(t,e))}function ck(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Nl="ScrollArea",[Kh,EN]=un(Nl),[uk,sn]=Kh(Nl),qh=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,j]=h.useState(!1),R=Fe(t,H=>l(H)),L=Xo(o);return u.jsx(uk,{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:j,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(me.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}})})});qh.displayName=Nl;var Gh="ScrollAreaViewport",Yh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(Gh,n),a=h.useRef(null),l=Fe(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(me.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})})]})});Yh.displayName=Gh;var Nn="ScrollAreaScrollbar",Al=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,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(dk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(fk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Xh,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(jl,{...r,ref:t}):null});Al.displayName=Nn;var dk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,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(Wt,{present:n||s,children:u.jsx(Xh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),fk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ei(()=>l("SCROLL_END"),100),[a,l]=ck("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(Wt,{present:n||a!=="hidden",children:u.jsx(jl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ce(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ce(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Xh=h.forwardRef((e,t)=>{const n=sn(Nn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=ei(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return $r(n.viewport,l),$r(n.content,l),u.jsx(Wt,{present:r||s,children:u.jsx(jl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),jl=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(Nn,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=tm(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 vk(m,i.current,a,f)}return n==="horizontal"?u.jsx(pk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=nm(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(hk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=nm(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}),pk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(Nn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Fe(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Zh,{"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":Qs(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),om(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:Zs(i.paddingLeft),paddingEnd:Zs(i.paddingRight)}})}})}),hk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(Nn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Fe(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Zh,{"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":Qs(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),om(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:Zs(i.paddingTop),paddingEnd:Zs(i.paddingBottom)}})}})}),[mk,Jh]=Kh(Nn),Zh=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=sn(Nn,n),[v,g]=h.useState(null),x=Fe(t,R=>g(R)),y=h.useRef(null),w=h.useRef(""),S=f.viewport,k=r.content-r.viewport,C=vt(d),T=vt(l),E=ei(p,10);function j(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]),$r(v,E),$r(f.content,E),u.jsx(mk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:vt(s),onThumbPointerUp:vt(i),onThumbPositionChange:T,onThumbPointerDown:vt(a),children:u.jsx(me.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ce(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"),j(R))}),onPointerMove:ce(e.onPointerMove,j),onPointerUp:ce(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})})})}),Js="ScrollAreaThumb",Qh=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Jh(Js,e.__scopeScrollArea);return u.jsx(Wt,{present:n||o.hasThumb,children:u.jsx(gk,{ref:t,...r})})}),gk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Js,n),i=Jh(Js,n),{onThumbPositionChange:a}=i,l=Fe(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=ei(()=>{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=bk(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(me.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:ce(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:ce(e.onPointerUp,i.onThumbPointerUp)})});Qh.displayName=Js;var _l="ScrollAreaCorner",em=h.forwardRef((e,t)=>{const n=sn(_l,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(xk,{...e,ref:t}):null});em.displayName=_l;var xk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn(_l,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return $r(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),$r(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(me.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 Zs(e){return e?parseInt(e,10):0}function tm(e,t){const n=e/t;return isNaN(n)?0:n}function Qs(e){const t=tm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function vk(e,t,n,r="ltr"){const o=Qs(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 rm([l,c],p)(e)}function nm(e,t,n="ltr"){const r=Qs(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=Il(e,l);return rm([0,i],[0,a])(c)}function rm(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 om(e,t){return e>0&&e<t}var bk=(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 ei(e,t){const n=vt(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 $r(e,t){const n=vt(t);It(()=>{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 sm=qh,wk=Yh,yk=em;const Pl=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(sm,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[u.jsx(wk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(im,{}),u.jsx(yk,{})]}));Pl.displayName=sm.displayName;const im=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Al,{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(Qh,{className:"relative flex-1 rounded-full bg-border"})}));im.displayName=Al.displayName;const Rl=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}));Rl.displayName="Input";const Sk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Ck="bg-slate-700 border-slate-600 hover:bg-slate-600",Tk="bg-slate-600 border-slate-500";function am({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??Tk}`:`${x??Ck}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Sk} ${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(Rl,{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(Qe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(de.Check,{size:12})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(de.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(de.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(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(de.MoreHorizontal,{size:12})})}),u.jsxs(po,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(zn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(de.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(zn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(de.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(zn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(de.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 lm=25,cm="thread-manager-view",kk=e=>e==="default"||e==="shared",Ek=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(cm);if(kk(e))return e}catch{}return null};function um({defaultView:e}={}){const[t,n]=b.useState(()=>Ek()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(cm,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Ik=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ti({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:j,isLoadingSharedThreads:R,actions:L,shareInFlight:H,shareStatus:B,clearShareStatus:q}=xr(),{createThread:N,deleteThread:z,renameThread:$,shareThread:M}=L,{loadThread:P}=eo(),I=i??T,[V,J]=b.useState(Array.isArray(k)?k:[]),_=b.useRef(V.length>0),O=b.useRef(null),K=b.useRef(0),[Y,ae]=b.useState(null),[W,D]=b.useState(""),[X,oe]=b.useState(!1),[G,Z]=b.useState(!1),[te,se]=b.useState(null),[ue,ge]=b.useState(""),Me=v&&v.length>0?v:Ik,Oe=um({defaultView:m}),Te=g??Oe,nt=p??Te.view,pt=b.useCallback(re=>{p||Te.setView(re),f==null||f(re)},[p,f,Te]),Tt=Me.find(re=>re.key===nt)??Me[0],Ke=re=>{se(re),ge(""),Z(!0)},Ge=()=>{Z(!1),se(null),ge(""),q()},Ve=b.useCallback(async re=>{if(!(!te||H)&&re.id)try{await M(te,re.id),setTimeout(()=>Ge(),600)}catch(ye){console.error("Failed to share thread:",ye)}},[Ge,H,te,M]),$e=b.useMemo(()=>{const re=y??[],ye=ue.trim().toLowerCase();return ye?S?re.filter(rt=>S(rt,ye)):re.filter(rt=>`${rt.label} ${rt.secondaryLabel??""}`.toLowerCase().includes(ye)):re},[y,ue,S]),He=nt==="shared",mt=He?C:V,Dt=He?R:j,lt=He?"No shared conversations yet":"No conversations yet",kt=re=>{const ye=re.sharedAt?` • ${Ae(re.sharedAt)}`:"";return`Shared by ${re.sharedByUserId}${ye}`},wt=re=>"sharedByUserId"in re;b.useEffect(()=>{const re=Array.isArray(k)?k:[];if(re.length>0){_.current=!0,J(re);return}j||(_.current=!1,J(re))},[k,j]),b.useEffect(()=>{if(!O.current)return;const re=O.current.querySelector("[data-radix-scroll-area-viewport]");if(!re)return;let ye=null,rt=null;return ye=requestAnimationFrame(()=>{rt=requestAnimationFrame(()=>{re.scrollTop=K.current})}),()=>{ye!==null&&cancelAnimationFrame(ye),rt!==null&&cancelAnimationFrame(rt)}},[V]);const gt=async re=>{try{E(re),await P(re),a==null||a(re),l==null||l(re)}catch(ye){console.error("Failed to select thread:",ye)}},ht=async()=>{try{oe(!0);const re=await N();re&&(c==null||c(re),a==null||a(re))}catch(re){console.error("Failed to create thread:",re)}finally{oe(!1)}},an=async(re,ye)=>{if(ye.stopPropagation(),!!confirm("Delete this thread?")){if(O.current){const rt=O.current.querySelector("[data-radix-scroll-area-viewport]");rt&&(K.current=rt.scrollTop)}try{await z(re),d==null||d(re)}catch(rt){console.error("Failed to delete thread:",rt)}}},dt=(re,ye)=>{ye.stopPropagation(),ae(re.threadId),D(re.title||`Thread ${re.threadId.slice(0,8)}`)},ke=async re=>{if(W.trim())try{await $(re,W.trim()),ae(null),D("")}catch(ye){console.error("Failed to update title:",ye)}},et=()=>{ae(null),D("")},Ae=re=>{if(!re)return"";try{const ye=new Date(re),xe=new Date().getTime()-ye.getTime(),Pe=Math.floor(xe/(1e3*60*60*24));return Pe===0?ye.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Pe===1?"Yesterday":Pe<7?`${Pe} days ago`:ye.toLocaleDateString()}catch{return""}},Le=re=>re.title||`Thread ${re.threadId.slice(0,8)}`,Bt=re=>{const ye=Le(re);return ye.length<=lm?ye:`${ye.slice(0,lm)}...`};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(Qe,{onClick:ht,disabled:X||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(de.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(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{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:Tt.label})}),u.jsx(po,{align:"start",sideOffset:6,className:"w-40",children:Me.map(re=>u.jsxs(zn,{className:"justify-between text-[12px]",onClick:ye=>{ye.preventDefault(),pt(re.key)},children:[u.jsx("span",{children:re.label}),nt===re.key&&u.jsx(de.Check,{className:"h-3 w-3"})]},re.key))})]})]})]}),u.jsx(Pl,{ref:O,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:Dt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(de.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):mt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(de.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:lt})]}):mt.slice().sort((re,ye)=>new Date(ye.updatedAt||ye.createdAt||"").getTime()-new Date(re.updatedAt||re.createdAt||"").getTime()).map(re=>u.jsx(am,{thread:re,isActive:I===re.threadId,editingThreadId:Y,editingTitle:W,onSelect:gt,onStartEditing:dt,onEditingTitleChange:ye=>D(ye),onSaveEditing:ke,onCancelEditing:et,onShare:()=>Ke(re.threadId),onDelete:an,showEditTitle:r,showDeleteButton:n,formatDate:Ae,getDisplayThreadTitle:Bt,secondaryLine:He&&wt(re)?kt(re):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},re.threadId))})}),u.jsx(Qa,{open:G,onOpenChange:re=>!re&&Ge(),children:u.jsxs(Bs,{className:"max-w-md p-0",children:[u.jsx(zs,{children:u.jsx(Hs,{children:"Share thread"})}),u.jsxs(yl,{children:[u.jsx(Sl,{autoFocus:!0,value:ue,onValueChange:re=>ge(re),placeholder:"Search for recipients..."}),u.jsxs(Cl,{children:[B&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[H&&u.jsx(de.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:B.startsWith("Failed")?"text-red-500":B.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:B})]}),u.jsx(Tl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),$e.length>0&&u.jsx(kl,{heading:"Recipients",children:$e.map(re=>u.jsx(El,{onSelect:()=>Ve(re),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:re.label}),re.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:re.secondaryLabel})]})},re.id))})]})]})]})})]})}function Nk({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(br,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Or,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(br,{...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(ti,{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(Or,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(br,{...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(ti,{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(Or,{onError:s.onError,enableFileUpload:!0})})]})})}function Ak({apiConfig:e,className:t="",onError:n}){return u.jsx(br,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Or,{})})})}function jk({placeholder:e,onMessageSent:t}){const[n,r]=b.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(de.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(de.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Or,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ti,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function _k({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=b.useState(!1);return n?u.jsx(br,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(de.MoreHorizontal,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(de.Edit3,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(de.Maximize2,{size:14}):u.jsx(de.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(jk,{placeholder:t,onMessageSent:r})})]})})}):null}function Pk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Qe,{variant:r,size:o,className:ne("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(de.Edit3,{size:16}),t??e]})}var Rk="Label",dm=h.forwardRef((e,t)=>u.jsx(me.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())}}));dm.displayName=Rk;var fm=dm;const Mk=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),pm=h.forwardRef(({className:e,...t},n)=>u.jsx(fm,{ref:n,className:ne(Mk(),e),...t}));pm.displayName=fm.displayName;function hm(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 mm=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"}),Ok="VisuallyHidden",ni=h.forwardRef((e,t)=>u.jsx(me.span,{...e,ref:t,style:{...mm,...e.style}}));ni.displayName=Ok;var Dk=ni,Lk=[" ","Enter","ArrowUp","ArrowDown"],$k=[" ","Enter"],dr="Select",[ri,oi,Fk]=Yo(dr),[Fr,IN]=un(dr,[Fk,Er]),si=Er(),[Bk,Yn]=Fr(dr),[zk,Hk]=Fr(dr),gm=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=si(t),[x,y]=h.useState(null),[w,S]=h.useState(null),[k,C]=h.useState(!1),T=Xo(c),[E,j]=Ln({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[R,L]=Ln({prop:i,defaultProp:a,onChange:l,caller:dr}),H=h.useRef(null),B=x?v||!!x.closest("form"):!0,[q,N]=h.useState(new Set),z=Array.from(q).map($=>$.props.value).join(";");return u.jsx(oa,{...g,children:u.jsxs(Bk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Pt(),value:R,onValueChange:L,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:H,disabled:m,children:[u.jsx(ri.Provider,{scope:t,children:u.jsx(zk,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback($=>{N(M=>new Set(M).add($))},[]),onNativeOptionRemove:h.useCallback($=>{N(M=>{const P=new Set(M);return P.delete($),P})},[]),children:n})}),B?u.jsxs(Bm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:R,onChange:$=>L($.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(q)]},z):null]})})};gm.displayName=dr;var xm="SelectTrigger",vm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=si(n),i=Yn(xm,n),a=i.disabled||r,l=Fe(t,i.onTriggerChange),c=oi(n),d=h.useRef("touch"),[p,m,f]=Hm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=Um(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(sa,{asChild:!0,...s,children:u.jsx(me.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":zm(i.value)?"":void 0,...o,ref:l,onClick:ce(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ce(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:ce(o.onKeyDown,g=>{const x=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Lk.includes(g.key)&&(v(),g.preventDefault())})})})});vm.displayName=xm;var bm="SelectValue",wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Yn(bm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=Fe(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(me.span,{...a,ref:p,style:{pointerEvents:"none"},children:zm(l.value)?u.jsx(u.Fragment,{children:i}):s})});wm.displayName=bm;var Uk="SelectIcon",ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(me.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});ym.displayName=Uk;var Wk="SelectPortal",Sm=e=>u.jsx(so,{asChild:!0,...e});Sm.displayName=Wk;var fr="SelectContent",Cm=h.forwardRef((e,t)=>{const n=Yn(fr,e.__scopeSelect),[r,o]=h.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Tm,{scope:e.__scopeSelect,children:u.jsx(ri.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(km,{...e,ref:t})});Cm.displayName=fr;var gn=10,[Tm,Xn]=Fr(fr),Vk="SelectContentImpl",Kk=Yt.createSlot("SelectContent.RemoveScroll"),km=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=Yn(fr,n),[S,k]=h.useState(null),[C,T]=h.useState(null),E=Fe(t,W=>k(W)),[j,R]=h.useState(null),[L,H]=h.useState(null),B=oi(n),[q,N]=h.useState(!1),z=h.useRef(!1);h.useEffect(()=>{if(S)return da(S)},[S]),Hi();const $=h.useCallback(W=>{const[D,...X]=B().map(Z=>Z.ref.current),[oe]=X.slice(-1),G=document.activeElement;for(const Z of W)if(Z===G||(Z==null||Z.scrollIntoView({block:"nearest"}),Z===D&&C&&(C.scrollTop=0),Z===oe&&C&&(C.scrollTop=C.scrollHeight),Z==null||Z.focus(),document.activeElement!==G))return},[B,C]),M=h.useCallback(()=>$([j,S]),[$,j,S]);h.useEffect(()=>{q&&M()},[q,M]);const{onOpenChange:P,triggerPointerDownPosRef:I}=w;h.useEffect(()=>{if(S){let W={x:0,y:0};const D=oe=>{var G,Z;W={x:Math.abs(Math.round(oe.pageX)-(((G=I.current)==null?void 0:G.x)??0)),y:Math.abs(Math.round(oe.pageY)-(((Z=I.current)==null?void 0:Z.y)??0))}},X=oe=>{W.x<=10&&W.y<=10?oe.preventDefault():S.contains(oe.target)||P(!1),document.removeEventListener("pointermove",D),I.current=null};return I.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,P,I]),h.useEffect(()=>{const W=()=>P(!1);return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[P]);const[V,J]=Hm(W=>{const D=B().filter(G=>!G.disabled),X=D.find(G=>G.ref.current===document.activeElement),oe=Um(D,W,X);oe&&setTimeout(()=>oe.ref.current.focus())}),_=h.useCallback((W,D,X)=>{const oe=!z.current&&!X;(w.value!==void 0&&w.value===D||oe)&&(R(W),oe&&(z.current=!0))},[w.value]),O=h.useCallback(()=>S==null?void 0:S.focus(),[S]),K=h.useCallback((W,D,X)=>{const oe=!z.current&&!X;(w.value!==void 0&&w.value===D||oe)&&H(W)},[w.value]),Y=r==="popper"?Ml:Em,ae=Y===Ml?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Tm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:_,selectedItem:j,onItemLeave:O,itemTextRefCallback:K,focusSelectedItem:M,selectedItemText:L,position:r,isPositioned:q,searchRef:V,children:u.jsx(gs,{as:Kk,allowPinchZoom:!0,children:u.jsx(Jo,{asChild:!0,trapped:w.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:ce(o,W=>{var D;(D=w.trigger)==null||D.focus({preventScroll:!0}),W.preventDefault()}),children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(Y,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:W=>W.preventDefault(),...y,...ae,onPlaced:()=>N(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ce(y.onKeyDown,W=>{const D=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!D&&W.key.length===1&&J(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let oe=B().filter(G=>!G.disabled).map(G=>G.ref.current);if(["ArrowUp","End"].includes(W.key)&&(oe=oe.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const G=W.target,Z=oe.indexOf(G);oe=oe.slice(Z+1)}setTimeout(()=>$(oe)),W.preventDefault()}})})})})})})});km.displayName=Vk;var qk="SelectItemAlignedPosition",Em=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Yn(fr,n),i=Xn(fr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=Fe(t,E=>d(E)),m=oi(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(),j=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const G=L.left-j.left,Z=R.left-G,te=E.left-Z,se=E.width+te,ue=Math.max(se,j.width),ge=window.innerWidth-gn,Me=Il(Z,[gn,Math.max(gn,ge-ue)]);a.style.minWidth=se+"px",a.style.left=Me+"px"}else{const G=j.right-L.right,Z=window.innerWidth-R.right-G,te=window.innerWidth-E.right-Z,se=E.width+te,ue=Math.max(se,j.width),ge=window.innerWidth-gn,Me=Il(Z,[gn,Math.max(gn,ge-ue)]);a.style.minWidth=se+"px",a.style.right=Me+"px"}const H=m(),B=window.innerHeight-gn*2,q=g.scrollHeight,N=window.getComputedStyle(c),z=parseInt(N.borderTopWidth,10),$=parseInt(N.paddingTop,10),M=parseInt(N.borderBottomWidth,10),P=parseInt(N.paddingBottom,10),I=z+$+q+P+M,V=Math.min(x.offsetHeight*5,I),J=window.getComputedStyle(g),_=parseInt(J.paddingTop,10),O=parseInt(J.paddingBottom,10),K=E.top+E.height/2-gn,Y=B-K,ae=x.offsetHeight/2,W=x.offsetTop+ae,D=z+$+W,X=I-D;if(D<=K){const G=H.length>0&&x===H[H.length-1].ref.current;a.style.bottom="0px";const Z=c.clientHeight-g.offsetTop-g.offsetHeight,te=Math.max(Y,ae+(G?O:0)+Z+M),se=D+te;a.style.height=se+"px"}else{const G=H.length>0&&x===H[0].ref.current;a.style.top="0px";const te=Math.max(K,z+g.offsetTop+(G?_:0)+ae)+X;a.style.height=te+"px",g.scrollTop=D-K+g.offsetTop}a.style.margin=`${gn}px 0`,a.style.minHeight=V+"px",a.style.maxHeight=B+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);It(()=>S(),[S]);const[k,C]=h.useState();It(()=>{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(Yk,{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(me.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Em.displayName=qk;var Gk="SelectPopperPosition",Ml=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=gn,...s}=e,i=si(n);return u.jsx(ia,{...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)"}})});Ml.displayName=Gk;var[Yk,Ol]=Fr(fr,{}),Dl="SelectViewport",Im=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Xn(Dl,n),i=Ol(Dl,n),a=Fe(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(ri.Slot,{scope:n,children:u.jsx(me.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ce(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-gn*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})})})]})});Im.displayName=Dl;var Nm="SelectGroup",[Xk,Jk]=Fr(Nm),Zk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Pt();return u.jsx(Xk,{scope:n,id:o,children:u.jsx(me.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Zk.displayName=Nm;var Am="SelectLabel",jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Jk(Am,n);return u.jsx(me.div,{id:o.id,...r,ref:t})});jm.displayName=Am;var ii="SelectItem",[Qk,_m]=Fr(ii),Pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Yn(ii,n),l=Xn(ii,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=Fe(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=Pt(),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(Qk,{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(ri.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(me.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:ce(i.onFocus,()=>f(!0)),onBlur:ce(i.onBlur,()=>f(!1)),onClick:ce(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ce(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ce(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ce(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:ce(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ce(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||($k.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Pm.displayName=ii;var Ao="SelectItemText",Rm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Yn(Ao,n),a=Xn(Ao,n),l=_m(Ao,n),c=Hk(Ao,n),[d,p]=h.useState(null),m=Fe(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 It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(me.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Hr.createPortal(s.children,i.valueNode):null]})});Rm.displayName=Ao;var Mm="SelectItemIndicator",Om=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return _m(Mm,n).isSelected?u.jsx(me.span,{"aria-hidden":!0,...r,ref:t}):null});Om.displayName=Mm;var Ll="SelectScrollUpButton",Dm=h.forwardRef((e,t)=>{const n=Xn(Ll,e.__scopeSelect),r=Ol(Ll,e.__scopeSelect),[o,s]=h.useState(!1),i=Fe(t,r.onScrollButtonChange);return It(()=>{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($m,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Dm.displayName=Ll;var $l="SelectScrollDownButton",Lm=h.forwardRef((e,t)=>{const n=Xn($l,e.__scopeSelect),r=Ol($l,e.__scopeSelect),[o,s]=h.useState(!1),i=Fe(t,r.onScrollButtonChange);return It(()=>{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($m,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Lm.displayName=$l;var $m=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Xn("SelectScrollButton",n),i=h.useRef(null),a=oi(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),It(()=>{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(me.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ce(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ce(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ce(o.onPointerLeave,()=>{l()})})}),eE="SelectSeparator",Fm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(me.div,{"aria-hidden":!0,...r,ref:t})});Fm.displayName=eE;var Fl="SelectArrow",tE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=si(n),s=Yn(Fl,n),i=Xn(Fl,n);return s.open&&i.position==="popper"?u.jsx(aa,{...o,...r,ref:t}):null});tE.displayName=Fl;var nE="SelectBubbleInput",Bm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Fe(r,o),i=hm(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(me.select,{...n,style:{...mm,...n.style},ref:s,defaultValue:t})});Bm.displayName=nE;function zm(e){return e===""||e===void 0}function Hm(e){const t=vt(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 Um(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=rE(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 rE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var oE=gm,Wm=vm,sE=wm,iE=ym,aE=Sm,Vm=Cm,lE=Im,Km=jm,qm=Pm,cE=Rm,uE=Om,Gm=Dm,Ym=Lm,Xm=Fm;const dE=oE,fE=sE,Jm=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Wm,{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(iE,{asChild:!0,children:u.jsx(de.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Jm.displayName=Wm.displayName;const Zm=h.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronUp,{className:"h-4 w-4"})}));Zm.displayName=Gm.displayName;const Qm=h.forwardRef(({className:e,...t},n)=>u.jsx(Ym,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronDown,{className:"h-4 w-4"})}));Qm.displayName=Ym.displayName;const eg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(aE,{children:u.jsxs(Vm,{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(Zm,{}),u.jsx(lE,{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(Qm,{})]})}));eg.displayName=Vm.displayName;const pE=h.forwardRef(({className:e,...t},n)=>u.jsx(Km,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));pE.displayName=Km.displayName;const tg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(qm,{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(uE,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),u.jsx(cE,{children:t})]}));tg.displayName=qm.displayName;const hE=h.forwardRef(({className:e,...t},n)=>u.jsx(Xm,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));hE.displayName=Xm.displayName;var mE="Separator",ng="horizontal",gE=["horizontal","vertical"],rg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=ng,...o}=e,s=xE(r)?r:ng,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(me.div,{"data-orientation":s,...a,...o,ref:t})});rg.displayName=mE;function xE(e){return gE.includes(e)}var og=rg;const sg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(og,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));sg.displayName=og.displayName;var ai="Switch",[vE,NN]=un(ai),[bE,wE]=vE(ai),ig=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=Fe(t,S=>f(S)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=Ln({prop:o,defaultProp:s??!1,onChange:c,caller:ai});return u.jsxs(bE,{scope:n,checked:y,disabled:a,children:[u.jsx(me.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":ug(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:ce(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(cg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});ig.displayName=ai;var ag="SwitchThumb",lg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=wE(ag,n);return u.jsx(me.span,{"data-state":ug(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});lg.displayName=ag;var yE="SwitchBubbleInput",cg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Fe(i,s),l=hm(n),c=bd(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}})});cg.displayName=yE;function ug(e){return e?"checked":"unchecked"}var dg=ig,SE=lg;const fg=h.forwardRef(({className:e,...t},n)=>u.jsx(dg,{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(SE,{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")})}));fg.displayName=dg.displayName;const CE=Ja,TE=cT,kE=Za,pg=h.forwardRef(({className:e,...t},n)=>u.jsx(To,{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}));pg.displayName=To.displayName;const EE=zr.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"}}),hg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(kE,{children:[u.jsx(pg,{}),u.jsxs(ko,{ref:o,className:ne(EE({side:e}),t),...r,children:[n,u.jsxs(sh,{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(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hg.displayName=ko.displayName;const mg=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});mg.displayName="SheetHeader";const gg=h.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));gg.displayName=lr.displayName;const xg=h.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));xg.displayName=Fs.displayName;var[li,AN]=un("Tooltip",[Er]),ci=Er(),vg="TooltipProvider",IE=700,Bl="tooltip.open",[NE,zl]=li(vg),bg=e=>{const{__scopeTooltip:t,delayDuration:n=IE,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(NE,{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})};bg.displayName=vg;var jo="Tooltip",[AE,ui]=li(jo),wg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=zl(jo,e.__scopeTooltip),c=ci(t),[d,p]=h.useState(null),m=Pt(),f=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,w]=Ln({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Bl))):l.onClose(),s==null||s(E)},caller:jo}),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(oa,{...c,children:u.jsx(AE,{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})})};wg.displayName=jo;var Hl="TooltipTrigger",yg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ui(Hl,n),s=zl(Hl,n),i=ci(n),a=h.useRef(null),l=Fe(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(sa,{asChild:!0,...i,children:u.jsx(me.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ce(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ce(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ce(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ce(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ce(e.onBlur,o.onClose),onClick:ce(e.onClick,o.onClose)})})});yg.displayName=Hl;var jE="TooltipPortal",[jN,_E]=li(jE,{forceMount:void 0}),Br="TooltipContent",Sg=h.forwardRef((e,t)=>{const n=_E(Br,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ui(Br,e.__scopeTooltip);return u.jsx(Wt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Cg,{side:o,...s,ref:t}):u.jsx(PE,{side:o,...s,ref:t})})}),PE=h.forwardRef((e,t)=>{const n=ui(Br,e.__scopeTooltip),r=zl(Br,e.__scopeTooltip),o=h.useRef(null),s=Fe(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=LE(y,x.getBoundingClientRect()),S=$E(y,w),k=FE(g.getBoundingClientRect()),C=zE([...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=!BE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Cg,{...e,ref:s})}),[RE,ME]=li(jo,{isInside:!1}),OE=Yt.createSlottable("TooltipContent"),Cg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ui(Br,n),c=ci(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Bl,d),()=>document.removeEventListener(Bl,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(yr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(ia,{"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(OE,{children:r}),u.jsx(RE,{scope:n,isInside:!0,children:u.jsx(Dk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Sg.displayName=Br;var Tg="TooltipArrow",DE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ci(n);return ME(Tg,n).isInside?null:u.jsx(aa,{...o,...r,ref:t})});DE.displayName=Tg;function LE(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 $E(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 FE(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 BE(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 zE(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),HE(t)}function HE(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 UE=bg,WE=wg,VE=yg,kg=Sg;const KE=UE,qE=WE,GE=VE,Eg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(kg,{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}));Eg.displayName=kg.displayName;var Ul="ToastProvider",[Wl,YE,XE]=Yo("Toast"),[Ig,_N]=un("Toast",[XE]),[JE,di]=Ig(Ul),Ng=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 \`${Ul}\`. Expected non-empty \`string\`.`),u.jsx(Wl.Provider,{scope:t,children:u.jsx(JE,{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})})};Ng.displayName=Ul;var Ag="ToastViewport",ZE=["F8"],Vl="toast.viewportPause",Kl="toast.viewportResume",jg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=ZE,label:o="Notifications ({hotkey})",...s}=e,i=di(Ag,n),a=YE(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=Fe(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(Vl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Kl);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,...dI(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 j=document.activeElement,R=w.shiftKey;if(w.target===x&&R){(C=c.current)==null||C.focus();return}const B=g({tabbingDirection:R?"backwards":"forwards"}),q=B.findIndex(N=>N===j);Yl(B.slice(q+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(Lb,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(ql,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Yl(x)}}),u.jsx(Wl.Slot,{scope:n,children:u.jsx(me.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(ql,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Yl(x)}})]})});jg.displayName=Ag;var _g="ToastFocusProxy",ql=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=di(_g,n);return u.jsx(ni,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});ql.displayName=_g;var _o="Toast",QE="toast.swipeStart",eI="toast.swipeMove",tI="toast.swipeCancel",nI="toast.swipeEnd",Pg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Ln({prop:r,defaultProp:o??!0,onChange:s,caller:_o});return u.jsx(Wt,{present:n||a,children:u.jsx(sI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:vt(e.onPause),onResume:vt(e.onResume),onSwipeStart:ce(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ce(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:ce(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:ce(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)})})})});Pg.displayName=_o;var[rI,oI]=Ig(_o,{onClose(){}}),sI=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=di(_o,n),[x,y]=h.useState(null),w=Fe(t,N=>y(N)),S=h.useRef(null),k=h.useRef(null),C=o||g.duration,T=h.useRef(0),E=h.useRef(C),j=h.useRef(0),{onToastAdd:R,onToastRemove:L}=g,H=vt(()=>{var z;(x==null?void 0:x.contains(document.activeElement))&&((z=g.viewport)==null||z.focus()),i()}),B=h.useCallback(N=>{!N||N===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout(H,N))},[H]);h.useEffect(()=>{const N=g.viewport;if(N){const z=()=>{B(E.current),c==null||c()},$=()=>{const M=new Date().getTime()-T.current;E.current=E.current-M,window.clearTimeout(j.current),l==null||l()};return N.addEventListener(Vl,$),N.addEventListener(Kl,z),()=>{N.removeEventListener(Vl,$),N.removeEventListener(Kl,z)}}},[g.viewport,C,l,c,B]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&B(C)},[s,C,g.isClosePausedRef,B]),h.useEffect(()=>(R(),()=>L()),[R,L]);const q=h.useMemo(()=>x?Fg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[q&&u.jsx(iI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:q}),u.jsx(rI,{scope:n,onClose:H,children:Hr.createPortal(u.jsx(Wl.ItemSlot,{scope:n,children:u.jsx(Db,{asChild:!0,onEscapeKeyDown:ce(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||H(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(me.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ce(e.onKeyDown,N=>{N.key==="Escape"&&(a==null||a(N.nativeEvent),N.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,H()))}),onPointerDown:ce(e.onPointerDown,N=>{N.button===0&&(S.current={x:N.clientX,y:N.clientY})}),onPointerMove:ce(e.onPointerMove,N=>{if(!S.current)return;const z=N.clientX-S.current.x,$=N.clientY-S.current.y,M=!!k.current,P=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,V=P?I(0,z):0,J=P?0:I(0,$),_=N.pointerType==="touch"?10:2,O={x:V,y:J},K={originalEvent:N,delta:O};M?(k.current=O,fi(eI,p,K,{discrete:!1})):Bg(O,g.swipeDirection,_)?(k.current=O,fi(QE,d,K,{discrete:!1}),N.target.setPointerCapture(N.pointerId)):(Math.abs(z)>_||Math.abs($)>_)&&(S.current=null)}),onPointerUp:ce(e.onPointerUp,N=>{const z=k.current,$=N.target;if($.hasPointerCapture(N.pointerId)&&$.releasePointerCapture(N.pointerId),k.current=null,S.current=null,z){const M=N.currentTarget,P={originalEvent:N,delta:z};Bg(z,g.swipeDirection,g.swipeThreshold)?fi(nI,f,P,{discrete:!0}):fi(tI,m,P,{discrete:!0}),M.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),iI=e=>{const{__scopeToast:t,children:n,...r}=e,o=di(_o,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return cI(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ni,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},aI="ToastTitle",Rg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Rg.displayName=aI;var lI="ToastDescription",Mg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Mg.displayName=lI;var Og="ToastAction",Dg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx($g,{altText:n,asChild:!0,children:u.jsx(Gl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Og}\`. Expected non-empty \`string\`.`),null)});Dg.displayName=Og;var Lg="ToastClose",Gl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=oI(Lg,n);return u.jsx($g,{asChild:!0,children:u.jsx(me.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,o.onClose)})})});Gl.displayName=Lg;var $g=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(me.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Fg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),uI(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(...Fg(r))}}),t}function fi(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?Fi(o,s):o.dispatchEvent(s)}var Bg=(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 cI(e=()=>{}){const t=vt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function uI(e){return e.nodeType===e.ELEMENT_NODE}function dI(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 Yl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var fI=Ng,zg=jg,Hg=Pg,Ug=Rg,Wg=Mg,Vg=Dg,Kg=Gl;const pI=fI,qg=h.forwardRef(({className:e,...t},n)=>u.jsx(zg,{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}));qg.displayName=zg.displayName;const hI=zr.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"}}),Gg=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Hg,{ref:r,className:ne(hI({variant:t}),e),...n}));Gg.displayName=Hg.displayName;const mI=h.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{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}));mI.displayName=Vg.displayName;const Yg=h.forwardRef(({className:e,...t},n)=>u.jsx(Kg,{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(de.X,{className:"h-4 w-4"})}));Yg.displayName=Kg.displayName;const Xg=h.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:ne("text-sm font-semibold",e),...t}));Xg.displayName=Ug.displayName;const Jg=h.forwardRef(({className:e,...t},n)=>u.jsx(Wg,{ref:n,className:ne("text-sm opacity-90",e),...t}));Jg.displayName=Wg.displayName;function gI(){const{toasts:e}=nl();return u.jsxs(pI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Gg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Xg,{children:n}),r&&u.jsx(Jg,{children:r})]}),o,u.jsx(Yg,{})]},t)}),u.jsx(qg,{})]})}var xI=(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{}},vI=h.createContext(void 0),bI={setTheme:e=>{},themes:[]},wI=()=>{var e;return(e=h.useContext(vI))!=null?e:bI};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:`(${xI.toString()})(${d})`}})});var yI=e=>{switch(e){case"success":return TI;case"info":return EI;case"warning":return kI;case"error":return II;default:return null}},SI=Array(12).fill(0),CI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},SI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),TI=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"})),kI=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"})),EI=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"})),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:"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"})),NI=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"})),AI=()=>{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},Xl=1,jI=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:Xl++,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(PI(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)||Xl++;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}},qt=new jI,_I=(e,t)=>{let n=(t==null?void 0:t.id)||Xl++;return qt.addToast({title:e,...t,id:n}),n},PI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",RI=_I,MI=()=>qt.toasts,OI=()=>qt.getActiveToasts();Object.assign(RI,{success:qt.success,info:qt.info,warning:qt.warning,error:qt.error,custom:qt.custom,message:qt.message,promise:qt.promise,dismiss:qt.dismiss,loading:qt.loading},{getHistory:MI,getToasts:OI});function DI(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))}DI(`: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 pi(e){return e.label!==void 0}var LI=3,$I="32px",FI="16px",Zg=4e3,BI=356,zI=14,HI=20,UI=200;function xn(...e){return e.filter(Boolean).join(" ")}function WI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var VI=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:j,style:R,cancelButtonStyle:L,actionButtonStyle:H,className:B="",descriptionClassName:q="",duration:N,position:z,gap:$,loadingIcon:M,expandByDefault:P,classNames:I,icons:V,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:_}=e,[O,K]=b.useState(null),[Y,ae]=b.useState(null),[W,D]=b.useState(!1),[X,oe]=b.useState(!1),[G,Z]=b.useState(!1),[te,se]=b.useState(!1),[ue,ge]=b.useState(!1),[Me,Oe]=b.useState(0),[Te,nt]=b.useState(0),pt=b.useRef(f.duration||N||Zg),Tt=b.useRef(null),Ke=b.useRef(null),Ge=S===0,Ve=S+1<=y,$e=f.type,He=f.dismissible!==!1,mt=f.className||"",Dt=f.descriptionClassName||"",lt=b.useMemo(()=>w.findIndex(xe=>xe.toastId===f.id)||0,[w,f.id]),kt=b.useMemo(()=>{var xe;return(xe=f.closeButton)!=null?xe:j},[f.closeButton,j]),wt=b.useMemo(()=>f.duration||N||Zg,[f.duration,N]),gt=b.useRef(0),ht=b.useRef(0),an=b.useRef(0),dt=b.useRef(null),[ke,et]=z.split("-"),Ae=b.useMemo(()=>w.reduce((xe,Pe,Xe)=>Xe>=lt?xe:xe+Pe.height,0),[w,lt]),Le=AI(),Bt=f.invert||m,re=$e==="loading";ht.current=b.useMemo(()=>lt*$+Ae,[lt,Ae]),b.useEffect(()=>{pt.current=wt},[wt]),b.useEffect(()=>{D(!0)},[]),b.useEffect(()=>{let xe=Ke.current;if(xe){let Pe=xe.getBoundingClientRect().height;return nt(Pe),x(Xe=>[{toastId:f.id,height:Pe,position:f.position},...Xe]),()=>x(Xe=>Xe.filter(St=>St.toastId!==f.id))}},[x,f.id]),b.useLayoutEffect(()=>{if(!W)return;let xe=Ke.current,Pe=xe.style.height;xe.style.height="auto";let Xe=xe.getBoundingClientRect().height;xe.style.height=Pe,nt(Xe),x(St=>St.find(Et=>Et.toastId===f.id)?St.map(Et=>Et.toastId===f.id?{...Et,height:Xe}:Et):[{toastId:f.id,height:Xe,position:f.position},...St])},[W,f.title,f.description,x,f.id]);let ye=b.useCallback(()=>{oe(!0),Oe(ht.current),x(xe=>xe.filter(Pe=>Pe.toastId!==f.id)),setTimeout(()=>{T(f)},UI)},[f,T,x,ht]);b.useEffect(()=>{if(f.promise&&$e==="loading"||f.duration===1/0||f.type==="loading")return;let xe;return C||g||_&&Le?(()=>{if(an.current<gt.current){let Pe=new Date().getTime()-gt.current;pt.current=pt.current-Pe}an.current=new Date().getTime()})():pt.current!==1/0&&(gt.current=new Date().getTime(),xe=setTimeout(()=>{var Pe;(Pe=f.onAutoClose)==null||Pe.call(f,f),ye()},pt.current)),()=>clearTimeout(xe)},[C,g,f,$e,_,Le,ye]),b.useEffect(()=>{f.delete&&ye()},[ye,f.delete]);function rt(){var xe,Pe,Xe;return V!=null&&V.loading?b.createElement("div",{className:xn(I==null?void 0:I.loader,(xe=f==null?void 0:f.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":$e==="loading"},V.loading):M?b.createElement("div",{className:xn(I==null?void 0:I.loader,(Pe=f==null?void 0:f.classNames)==null?void 0:Pe.loader,"sonner-loader"),"data-visible":$e==="loading"},M):b.createElement(CI,{className:xn(I==null?void 0:I.loader,(Xe=f==null?void 0:f.classNames)==null?void 0:Xe.loader),visible:$e==="loading"})}return b.createElement("li",{tabIndex:0,ref:Ke,className:xn(B,mt,I==null?void 0:I.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[$e],(n=f==null?void 0:f.classNames)==null?void 0:n[$e]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":W,"data-promise":!!f.promise,"data-swiped":ue,"data-removed":X,"data-visible":Ve,"data-y-position":ke,"data-x-position":et,"data-index":S,"data-front":Ge,"data-swiping":G,"data-dismissible":He,"data-type":$e,"data-invert":Bt,"data-swipe-out":te,"data-swipe-direction":Y,"data-expanded":!!(C||P&&W),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Me:ht.current}px`,"--initial-height":P?"auto":`${Te}px`,...R,...f.style},onDragEnd:()=>{Z(!1),K(null),dt.current=null},onPointerDown:xe=>{re||!He||(Tt.current=new Date,Oe(ht.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(Z(!0),dt.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,Pe,Xe,St;if(te||!He)return;dt.current=null;let Et=Number(((xe=Ke.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Nt=Number(((Pe=Ke.current)==null?void 0:Pe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),zt=new Date().getTime()-((Xe=Tt.current)==null?void 0:Xe.getTime()),_e=O==="x"?Et:Nt,ct=Math.abs(_e)/zt;if(Math.abs(_e)>=HI||ct>.11){Oe(ht.current),(St=f.onDismiss)==null||St.call(f,f),ae(O==="x"?Et>0?"right":"left":Nt>0?"down":"up"),ye(),se(!0),ge(!1);return}Z(!1),K(null)},onPointerMove:xe=>{var Pe,Xe,St,Et;if(!dt.current||!He||((Pe=window.getSelection())==null?void 0:Pe.toString().length)>0)return;let Nt=xe.clientY-dt.current.y,zt=xe.clientX-dt.current.x,_e=(Xe=e.swipeDirections)!=null?Xe:WI(z);!O&&(Math.abs(zt)>1||Math.abs(Nt)>1)&&K(Math.abs(zt)>Math.abs(Nt)?"x":"y");let ct={x:0,y:0};O==="y"?(_e.includes("top")||_e.includes("bottom"))&&(_e.includes("top")&&Nt<0||_e.includes("bottom")&&Nt>0)&&(ct.y=Nt):O==="x"&&(_e.includes("left")||_e.includes("right"))&&(_e.includes("left")&&zt<0||_e.includes("right")&&zt>0)&&(ct.x=zt),(Math.abs(ct.x)>0||Math.abs(ct.y)>0)&&ge(!0),(St=Ke.current)==null||St.style.setProperty("--swipe-amount-x",`${ct.x}px`),(Et=Ke.current)==null||Et.style.setProperty("--swipe-amount-y",`${ct.y}px`)}},kt&&!f.jsx?b.createElement("button",{"aria-label":J,"data-disabled":re,"data-close-button":!0,onClick:re||!He?()=>{}:()=>{var xe;ye(),(xe=f.onDismiss)==null||xe.call(f,f)},className:xn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=V==null?void 0:V.close)!=null?s:NI):null,f.jsx||b.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:b.createElement(b.Fragment,null,$e||f.icon||f.promise?b.createElement("div",{"data-icon":"",className:xn(I==null?void 0:I.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||rt():null,f.type!=="loading"?f.icon||(V==null?void 0:V[$e])||yI($e):null):null,b.createElement("div",{"data-content":"",className:xn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:xn(I==null?void 0:I.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:xn(q,Dt,I==null?void 0:I.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&&pi(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||L,onClick:xe=>{var Pe,Xe;pi(f.cancel)&&He&&((Xe=(Pe=f.cancel).onClick)==null||Xe.call(Pe,xe),ye())},className:xn(I==null?void 0:I.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&&pi(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||H,onClick:xe=>{var Pe,Xe;pi(f.action)&&((Xe=(Pe=f.action).onClick)==null||Xe.call(Pe,xe),!xe.defaultPrevented&&ye())},className:xn(I==null?void 0:I.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function Qg(){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 KI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?FI:$I;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 qI=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=LI,toastOptions:g,dir:x=Qg(),gap:y=zI,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=b.useState([]),j=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(_=>_.position).map(_=>_.position)))),[T,r]),[R,L]=b.useState([]),[H,B]=b.useState(!1),[q,N]=b.useState(!1),[z,$]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),M=b.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=b.useRef(null),V=b.useRef(!1),J=b.useCallback(_=>{E(O=>{var K;return(K=O.find(Y=>Y.id===_.id))!=null&&K.delete||qt.dismiss(_.id),O.filter(({id:Y})=>Y!==_.id)})},[]);return b.useEffect(()=>qt.subscribe(_=>{if(_.dismiss){E(O=>O.map(K=>K.id===_.id?{...K,delete:!0}:K));return}setTimeout(()=>{Po.flushSync(()=>{E(O=>{let K=O.findIndex(Y=>Y.id===_.id);return K!==-1?[...O.slice(0,K),{...O[K],..._},...O.slice(K+1)]:[_,...O]})})})}),[]),b.useEffect(()=>{if(d!=="system"){$(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?$("dark"):$("light")),typeof window>"u")return;let _=window.matchMedia("(prefers-color-scheme: dark)");try{_.addEventListener("change",({matches:O})=>{$(O?"dark":"light")})}catch{_.addListener(({matches:K})=>{try{$(K?"dark":"light")}catch(Y){console.error(Y)}})}},[d]),b.useEffect(()=>{T.length<=1&&B(!1)},[T]),b.useEffect(()=>{let _=O=>{var K,Y;o.every(ae=>O[ae]||O.code===ae)&&(B(!0),(K=M.current)==null||K.focus()),O.code==="Escape"&&(document.activeElement===M.current||(Y=M.current)!=null&&Y.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[o]),b.useEffect(()=>{if(M.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,V.current=!1)}},[M.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${P}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((_,O)=>{var K;let[Y,ae]=_.split("-");return T.length?b.createElement("ol",{key:_,dir:x==="auto"?Qg():x,tabIndex:-1,ref:M,className:a,"data-sonner-toaster":!0,"data-theme":z,"data-y-position":Y,"data-lifted":H&&T.length>1&&!s,"data-x-position":ae,style:{"--front-toast-height":`${((K=R[0])==null?void 0:K.height)||0}px`,"--width":`${BI}px`,"--gap":`${y}px`,...f,...KI(l,c)},onBlur:W=>{V.current&&!W.currentTarget.contains(W.relatedTarget)&&(V.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||V.current||(V.current=!0,I.current=W.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{q||B(!1)},onDragEnd:()=>B(!1),onPointerDown:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||N(!0)},onPointerUp:()=>N(!1)},T.filter(W=>!W.position&&O===0||W.position===_).map((W,D)=>{var X,oe;return b.createElement(VI,{key:W.id,icons:S,index:D,toast:W,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:(oe=g==null?void 0:g.closeButton)!=null?oe:i,interacting:q,position:_,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(G=>G.position==W.position),heights:R.filter(G=>G.position==W.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:w,expanded:H,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const GI=({...e})=>{const{theme:t="system"}=wI();return u.jsx(qI,{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=Bv,F.ApiClient=Fv,F.ApiProvider=nu,F.ArtifactRenderer=sl,F.Badge=Hp,F.Button=Qe,F.Card=il,F.CardContent=ul,F.CardDescription=cl,F.CardHeader=al,F.CardTitle=ll,F.ChatApi=Ko,F.ChatApp=Nk,F.ChatInput=Uf,F.ChatInterface=Or,F.ChatProviders=br,F.ChatWidget=_k,F.Command=yl,F.CommandEmpty=Tl,F.CommandGroup=kl,F.CommandInput=Sl,F.CommandItem=El,F.CommandList=Cl,F.DEFAULT_TIMEOUT_MS=Xc,F.Dialog=Qa,F.DialogContent=Bs,F.DialogHeader=zs,F.DialogTitle=Hs,F.DropdownMenu=Ss,F.DropdownMenuContent=po,F.DropdownMenuItem=zn,F.DropdownMenuTrigger=Cs,F.FileViewerModal=lh,F.HISTORY_TIMEOUT_MS=Jc,F.Input=Rl,F.InterruptPartRenderer=Eh,F.Label=pm,F.MarkdownContent=Mr,F.MessageBody=_h,F.MessageComponent=Ys,F.MessageList=hl,F.MessageRow=pl,F.NewChatButton=Pk,F.PlotArtifact=Sh,F.ResearchTaskArtifact=Th,F.SETTINGS_STORAGE_KEY=$i,F.ScrollArea=Pl,F.Select=dE,F.SelectContent=eg,F.SelectItem=tg,F.SelectTrigger=Jm,F.SelectValue=fE,F.Separator=sg,F.Sheet=CE,F.SheetContent=hg,F.SheetDescription=xg,F.SheetHeader=mg,F.SheetTitle=gg,F.SheetTrigger=TE,F.SimpleChat=Ak,F.SimpleJsonView=dl,F.Sonner=GI,F.StreamProgress=Ih,F.Switch=fg,F.Textarea=Ta,F.ThinkingIndicator=Ah,F.ThreadListItem=am,F.ThreadManager=ti,F.ThreadStateProvider=ku,F.ThreadsProvider=pu,F.TimelineColumn=gx,F.Toaster=gI,F.ToolComponent=Nh,F.Tooltip=qE,F.TooltipContent=Eg,F.TooltipProvider=KE,F.TooltipTrigger=GE,F.UserTextContent=jh,F.applySettings=wb,F.buildCheckpointIndex=ec,F.buildCheckpointPreviewMap=sx,F.chatApiClient=On,F.del=Ai,F.downloadFileById=Qc,F.extractConfigFields=mi,F.fileToBase64=ru,F.get=Jt,F.getChatToken=Gc,F.getCheckpointForMessage=ix,F.getCurrentSettings=bb,F.getDefaultApiConfig=Mu,F.getDefaultChatSettings=Ou,F.getFileContent=_i,F.getFileInfo=Hv,F.getMessageAttemptInfo=tc,F.getMessageDomKey=fl,F.getPreviewForMessage=hi,F.httpClient=Xt,F.hydrateHistorySnapshots=Mn,F.isEnvelope=su,F.listFiles=eu,F.loadStoredSettings=Du,F.onChatTokenChanged=Yc,F.post=Vo,F.processAttachments=ou,F.put=Zc,F.readNumber=rc,F.readString=Rn,F.resolveChatBaseUrl=bn,F.saveSettings=Lu,F.setChatToken=Wo,F.toPlainObject=Pn,F.unwrap=Lt,F.useApi=Xr,F.useCheckpointIndex=nc,F.useFilePreview=Ph,F.useHasChatSession=gb,F.useParsedMessageContent=Rh,F.useShallowStableValue=ju,F.useStream=Li,F.useStreamingHook=Li,F.useThreadHistoryState=yu,F.useThreadManagerViewState=um,F.useThreadState=eo,F.useThreadStateUpdater=Tu,F.useThreads=xr,F.useThreadsState=du,F.viewFileById=zv,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED