teodor-new-chat-ui 3.0.161 → 3.0.163

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 CHANGED
@@ -14517,26 +14517,117 @@ function JR(e) {
14517
14517
  ...e.authToken ? { Authorization: `Bearer ${e.authToken}` } : {},
14518
14518
  ...e.headers ?? {}
14519
14519
  };
14520
+ let r = null, o = [];
14521
+ const s = (i) => {
14522
+ i ? n.Authorization = `Bearer ${i}` : delete n.Authorization;
14523
+ };
14520
14524
  return {
14521
- stream(r, o) {
14522
- const s = new AbortController();
14525
+ // Existing streaming method
14526
+ stream(i, a) {
14527
+ const c = new AbortController();
14523
14528
  return (async () => {
14524
- var i, a;
14529
+ var u, d;
14525
14530
  try {
14526
- const c = await fetch(`${t}/runs/stream`, {
14531
+ const f = await fetch(`${t}/runs/stream`, {
14527
14532
  method: "POST",
14528
14533
  headers: { "Content-Type": "application/json", Accept: "text/event-stream", ...n },
14529
- body: JSON.stringify(r),
14530
- signal: s.signal
14534
+ body: JSON.stringify(i),
14535
+ signal: c.signal
14531
14536
  });
14532
- (i = o.onOpen) == null || i.call(o, {
14533
- threadId: c.headers.get("x-thread-id"),
14534
- created: (c.headers.get("x-thread-created") || "").toLowerCase() === "true"
14537
+ (u = a.onOpen) == null || u.call(a, {
14538
+ threadId: f.headers.get("x-thread-id"),
14539
+ created: (f.headers.get("x-thread-created") || "").toLowerCase() === "true"
14535
14540
  });
14536
- } catch (c) {
14537
- (c == null ? void 0 : c.name) !== "AbortError" && ((a = o.onError) == null || a.call(o, String((c == null ? void 0 : c.message) || c)));
14541
+ } catch (f) {
14542
+ (f == null ? void 0 : f.name) !== "AbortError" && ((d = a.onError) == null || d.call(a, String((f == null ? void 0 : f.message) || f)));
14538
14543
  }
14539
- })(), { close: () => s.abort() };
14544
+ })(), { close: () => c.abort() };
14545
+ },
14546
+ // Thread state management
14547
+ getCurrentThreadId() {
14548
+ return r;
14549
+ },
14550
+ setCurrentThreadId(i) {
14551
+ r = i, i ? localStorage.setItem("currentThreadId", i) : localStorage.removeItem("currentThreadId");
14552
+ },
14553
+ getThreads() {
14554
+ return o;
14555
+ },
14556
+ setThreads(i) {
14557
+ o = i;
14558
+ },
14559
+ // Thread operations
14560
+ async loadThreads() {
14561
+ try {
14562
+ const a = await (await fetch(`${t}/chat/threads`, {
14563
+ headers: n
14564
+ })).json();
14565
+ o = a.items || a || [];
14566
+ } catch (i) {
14567
+ console.error("Failed to load threads:", i), o = [];
14568
+ }
14569
+ },
14570
+ async createThread(i) {
14571
+ const c = await (await fetch(`${t}/chat/threads`, {
14572
+ method: "POST",
14573
+ headers: { "Content-Type": "application/json", ...n },
14574
+ body: i ? JSON.stringify({ title: i }) : void 0
14575
+ })).json();
14576
+ return await this.loadThreads(), this.setCurrentThreadId(c.threadId), c.threadId;
14577
+ },
14578
+ async loadThread(i) {
14579
+ this.setCurrentThreadId(i);
14580
+ },
14581
+ async deleteThread(i) {
14582
+ await fetch(`${t}/chat/threads/${i}`, {
14583
+ method: "DELETE",
14584
+ headers: n
14585
+ }), await this.loadThreads(), r === i && this.setCurrentThreadId(null);
14586
+ },
14587
+ async updateThreadTitle(i, a) {
14588
+ await fetch(`${t}/chat/threads/${i}`, {
14589
+ method: "PUT",
14590
+ headers: { "Content-Type": "application/json", ...n },
14591
+ body: JSON.stringify({ title: a })
14592
+ }), await this.loadThreads();
14593
+ },
14594
+ // Message operations
14595
+ async getMessages(i) {
14596
+ const a = new URLSearchParams();
14597
+ return a.set("thread_id", i.threadId), i.checkpointId && a.set("checkpoint_id", i.checkpointId), i.checkpointNs && a.set("checkpoint_ns", i.checkpointNs), i.limit && a.set("limit", i.limit.toString()), i.beforeId && a.set("before_id", i.beforeId), await (await fetch(`${t}/chat/threads/${i.threadId}/messages?${a}`, {
14598
+ headers: n
14599
+ })).json();
14600
+ },
14601
+ async sendMessage(i, a) {
14602
+ return new Promise((c, u) => {
14603
+ var p;
14604
+ const d = {
14605
+ messages: [{
14606
+ id: ((p = crypto.randomUUID) == null ? void 0 : p.call(crypto)) || `user-${Date.now()}`,
14607
+ role: "user",
14608
+ content: [{ type: "text", text: i.trim() }],
14609
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
14610
+ }]
14611
+ }, f = {
14612
+ threadId: (a == null ? void 0 : a.threadId) || "",
14613
+ payload: d,
14614
+ checkpointId: a == null ? void 0 : a.checkpointId,
14615
+ checkpointNs: a == null ? void 0 : a.checkpointNs,
14616
+ nodeFilter: a == null ? void 0 : a.nodeFilter,
14617
+ config: a == null ? void 0 : a.config
14618
+ };
14619
+ this.stream(f, {
14620
+ onOpen: (m) => c(m),
14621
+ onError: (m) => u(new Error(m))
14622
+ });
14623
+ });
14624
+ },
14625
+ async getMessageHistory(i) {
14626
+ return this.getMessages(i);
14627
+ },
14628
+ // Auth management
14629
+ updateAuthToken(i) {
14630
+ s(i);
14540
14631
  }
14541
14632
  };
14542
14633
  }
package/dist/index.umd.js CHANGED
@@ -135,4 +135,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
135
135
  `).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
136
136
  `).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
137
137
  `).replace(/<li>(.*?)<\/li>/gi,`- $1
138
- `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function bw(e,t=es){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function vw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),bw(t),xw(t)}function qi(e){const t=e+"CollectionProvider",[n,r]=Kt(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=b=>{const{scope:g,children:x}=b,v=C.useRef(null),y=C.useRef(new Map).current;return l.jsx(o,{scope:g,itemMap:y,collectionRef:v,children:x})};i.displayName=t;const a=e+"CollectionSlot",c=It.createSlot(a),u=C.forwardRef((b,g)=>{const{scope:x,children:v}=b,y=s(a,x),E=Re(g,y.collectionRef);return l.jsx(c,{ref:E,children:v})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",p=It.createSlot(d),m=C.forwardRef((b,g)=>{const{scope:x,children:v,...y}=b,E=C.useRef(null),S=Re(g,E),T=s(d,x);return C.useEffect(()=>(T.itemMap.set(E,{ref:E,...y}),()=>void T.itemMap.delete(E))),l.jsx(p,{[f]:"",ref:S,children:v})});m.displayName=d;function w(b){const g=s(e+"CollectionConsumer",b);return C.useCallback(()=>{const v=g.collectionRef.current;if(!v)return[];const y=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>y.indexOf(T.ref.current)-y.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},w,r]}var ww=h.createContext(void 0);function ts(e){const t=h.useContext(ww);return e||t||"ltr"}const yw=["top","right","bottom","left"],Cn=Math.min,Rt=Math.max,ns=Math.round,rs=Math.floor,rn=e=>({x:e,y:e}),Sw={left:"right",right:"left",bottom:"top",top:"bottom"},Cw={start:"end",end:"start"};function Gi(e,t,n){return Rt(e,Cn(t,n))}function dn(e,t){return typeof e=="function"?e(t):e}function fn(e){return e.split("-")[0]}function sr(e){return e.split("-")[1]}function Yi(e){return e==="x"?"y":"x"}function Xi(e){return e==="y"?"height":"width"}const Tw=new Set(["top","bottom"]);function on(e){return Tw.has(fn(e))?"y":"x"}function Ji(e){return Yi(on(e))}function kw(e,t,n){n===void 0&&(n=!1);const r=sr(e),o=Ji(e),s=Xi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=os(i)),[i,os(i)]}function Ew(e){const t=os(e);return[Zi(e),t,Zi(t)]}function Zi(e){return e.replace(/start|end/g,t=>Cw[t])}const dd=["left","right"],fd=["right","left"],Iw=["top","bottom"],Nw=["bottom","top"];function jw(e,t,n){switch(e){case"top":case"bottom":return n?t?fd:dd:t?dd:fd;case"left":case"right":return t?Iw:Nw;default:return[]}}function Aw(e,t,n,r){const o=sr(e);let s=jw(fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Zi)))),s}function os(e){return e.replace(/left|right|bottom|top/g,t=>Sw[t])}function Rw(e){return{top:0,right:0,bottom:0,left:0,...e}}function hd(e){return typeof e!="number"?Rw(e):{top:e,right:e,bottom:e,left:e}}function ss(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function pd(e,t,n){let{reference:r,floating:o}=e;const s=on(t),i=Ji(t),a=Xi(i),c=fn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let m;switch(c){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(sr(t)){case"start":m[i]-=p*(n&&u?-1:1);break;case"end":m[i]+=p*(n&&u?-1:1);break}return m}const _w=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=pd(u,r,c),p=r,m={},w=0;for(let b=0;b<a.length;b++){const{name:g,fn:x}=a[b],{x:v,y,data:E,reset:S}=await x({x:d,y:f,initialPlacement:r,placement:p,strategy:o,middlewareData:m,rects:u,platform:i,elements:{reference:e,floating:t}});d=v??d,f=y??f,m={...m,[g]:{...m[g],...E}},S&&w<=50&&(w++,typeof S=="object"&&(S.placement&&(p=S.placement),S.rects&&(u=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:f}=pd(u,p,c)),b=-1)}return{x:d,y:f,placement:p,strategy:o,middlewareData:m}};async function Fr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=dn(t,e),w=hd(m),g=a[p?f==="floating"?"reference":"floating":f],x=ss(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:c})),v=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},S=ss(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:y,strategy:c}):v);return{top:(x.top-S.top+w.top)/E.y,bottom:(S.bottom-x.bottom+w.bottom)/E.y,left:(x.left-S.left+w.left)/E.x,right:(S.right-x.right+w.right)/E.x}}const Pw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:u,padding:d=0}=dn(e,t)||{};if(u==null)return{};const f=hd(d),p={x:n,y:r},m=Ji(o),w=Xi(m),b=await i.getDimensions(u),g=m==="y",x=g?"top":"left",v=g?"bottom":"right",y=g?"clientHeight":"clientWidth",E=s.reference[w]+s.reference[m]-p[m]-s.floating[w],S=p[m]-s.reference[m],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[y]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[y]||s.floating[w]);const N=E/2-S/2,j=I/2-b[w]/2-1,O=Cn(f[x],j),A=Cn(f[v],j),F=O,H=I-b[w]-A,D=I/2-b[w]/2+N,J=Gi(F,D,H),K=!c.arrow&&sr(o)!=null&&D!==J&&s.reference[w]/2-(D<F?O:A)-b[w]/2<0,re=K?D<F?D-F:D-H:0;return{[m]:p[m]+re,data:{[m]:J,centerOffset:D-J-re,...K&&{alignmentOffset:re}},reset:K}}}),Ow=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:b=!0,...g}=dn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=fn(o),v=on(a),y=fn(a)===a,E=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=p||(y||!b?[os(a)]:Ew(a)),T=w!=="none";!p&&T&&S.push(...Aw(a,b,w,E));const I=[a,...S],N=await Fr(t,g),j=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(N[x]),f){const D=kw(o,i,E);j.push(N[D[0]],N[D[1]])}if(O=[...O,{placement:o,overflows:j}],!j.every(D=>D<=0)){var A,F;const D=(((A=s.flip)==null?void 0:A.index)||0)+1,J=I[D];if(J&&(!(f==="alignment"?v!==on(J):!1)||O.every(W=>on(W.placement)===v?W.overflows[0]>0:!0)))return{data:{index:D,overflows:O},reset:{placement:J}};let K=(F=O.filter(re=>re.overflows[0]<=0).sort((re,W)=>re.overflows[1]-W.overflows[1])[0])==null?void 0:F.placement;if(!K)switch(m){case"bestFit":{var H;const re=(H=O.filter(W=>{if(T){const M=on(W.placement);return M===v||M==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(M=>M>0).reduce((M,X)=>M+X,0)]).sort((W,M)=>W[1]-M[1])[0])==null?void 0:H[0];re&&(K=re);break}case"initialPlacement":K=a;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function md(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function gd(e){return yw.some(t=>e[t]>=0)}const Mw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=dn(e,t);switch(r){case"referenceHidden":{const s=await Fr(t,{...o,elementContext:"reference"}),i=md(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:gd(i)}}}case"escaped":{const s=await Fr(t,{...o,altBoundary:!0}),i=md(s,n.floating);return{data:{escapedOffsets:i,escaped:gd(i)}}}default:return{}}}}},xd=new Set(["left","top"]);async function Dw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=fn(n),a=sr(n),c=on(n)==="y",u=xd.has(i)?-1:1,d=s&&c?-1:1,f=dn(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(m=a==="end"?w*-1:w),c?{x:m*d,y:p*u}:{x:p*u,y:m*d}}const Lw=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,c=await Dw(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},$w=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x,y:v}=g;return{x,y:v}}},...c}=dn(e,t),u={x:n,y:r},d=await Fr(t,c),f=on(fn(o)),p=Yi(f);let m=u[p],w=u[f];if(s){const g=p==="y"?"top":"left",x=p==="y"?"bottom":"right",v=m+d[g],y=m-d[x];m=Gi(v,m,y)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",v=w+d[g],y=w-d[x];w=Gi(v,w,y)}const b=a.fn({...t,[p]:m,[f]:w});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[p]:s,[f]:i}}}}}},Fw=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:c=!0,crossAxis:u=!0}=dn(e,t),d={x:n,y:r},f=on(o),p=Yi(f);let m=d[p],w=d[f];const b=dn(a,t),g=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:0,crossAxis:0,...b};if(c){const y=p==="y"?"height":"width",E=s.reference[p]-s.floating[y]+g.mainAxis,S=s.reference[p]+s.reference[y]-g.mainAxis;m<E?m=E:m>S&&(m=S)}if(u){var x,v;const y=p==="y"?"width":"height",E=xd.has(fn(o)),S=s.reference[f]-s.floating[y]+(E&&((x=i.offset)==null?void 0:x[f])||0)+(E?0:g.crossAxis),T=s.reference[f]+s.reference[y]+(E?0:((v=i.offset)==null?void 0:v[f])||0)-(E?g.crossAxis:0);w<S?w=S:w>T&&(w=T)}return{[p]:m,[f]:w}}}},zw=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:c=()=>{},...u}=dn(e,t),d=await Fr(t,u),f=fn(o),p=sr(o),m=on(o)==="y",{width:w,height:b}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=p==="end"?"top":"bottom");const v=b-d.top-d.bottom,y=w-d.left-d.right,E=Cn(b-d[g],v),S=Cn(w-d[x],y),T=!t.middlewareData.shift;let I=E,N=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=v),T&&!p){const O=Rt(d.left,0),A=Rt(d.right,0),F=Rt(d.top,0),H=Rt(d.bottom,0);m?N=w-2*(O!==0||A!==0?O+A:Rt(d.left,d.right)):I=b-2*(F!==0||H!==0?F+H:Rt(d.top,d.bottom))}await c({...t,availableWidth:N,availableHeight:I});const j=await i.getDimensions(a.floating);return w!==j.width||b!==j.height?{reset:{rects:!0}}:{}}}};function is(){return typeof window<"u"}function ir(e){return bd(e)?(e.nodeName||"").toLowerCase():"#document"}function _t(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function sn(e){var t;return(t=(bd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function bd(e){return is()?e instanceof Node||e instanceof _t(e).Node:!1}function Yt(e){return is()?e instanceof Element||e instanceof _t(e).Element:!1}function an(e){return is()?e instanceof HTMLElement||e instanceof _t(e).HTMLElement:!1}function vd(e){return!is()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof _t(e).ShadowRoot}const Bw=new Set(["inline","contents"]);function zr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Xt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Bw.has(o)}const Hw=new Set(["table","td","th"]);function Uw(e){return Hw.has(ir(e))}const Ww=[":popover-open",":modal"];function as(e){return Ww.some(t=>{try{return e.matches(t)}catch{return!1}})}const Vw=["transform","translate","scale","rotate","perspective"],Kw=["transform","translate","scale","rotate","perspective","filter"],qw=["paint","layout","strict","content"];function Qi(e){const t=ea(),n=Yt(e)?Xt(e):e;return Vw.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Kw.some(r=>(n.willChange||"").includes(r))||qw.some(r=>(n.contain||"").includes(r))}function Gw(e){let t=Tn(e);for(;an(t)&&!ar(t);){if(Qi(t))return t;if(as(t))return null;t=Tn(t)}return null}function ea(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Yw=new Set(["html","body","#document"]);function ar(e){return Yw.has(ir(e))}function Xt(e){return _t(e).getComputedStyle(e)}function ls(e){return Yt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Tn(e){if(ir(e)==="html")return e;const t=e.assignedSlot||e.parentNode||vd(e)&&e.host||sn(e);return vd(t)?t.host:t}function wd(e){const t=Tn(e);return ar(t)?e.ownerDocument?e.ownerDocument.body:e.body:an(t)&&zr(t)?t:wd(t)}function Br(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=wd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=_t(o);if(s){const a=ta(i);return t.concat(i,i.visualViewport||[],zr(o)?o:[],a&&n?Br(a):[])}return t.concat(o,Br(o,[],n))}function ta(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function yd(e){const t=Xt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=an(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ns(n)!==s||ns(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function na(e){return Yt(e)?e:e.contextElement}function lr(e){const t=na(e);if(!an(t))return rn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=yd(t);let i=(s?ns(n.width):n.width)/r,a=(s?ns(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Xw=rn(0);function Sd(e){const t=_t(e);return!ea()||!t.visualViewport?Xw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Jw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==_t(e)?!1:t}function zn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=na(e);let i=rn(1);t&&(r?Yt(r)&&(i=lr(r)):i=lr(e));const a=Jw(s,n,r)?Sd(s):rn(0);let c=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const p=_t(s),m=r&&Yt(r)?_t(r):r;let w=p,b=ta(w);for(;b&&r&&m!==w;){const g=lr(b),x=b.getBoundingClientRect(),v=Xt(b),y=x.left+(b.clientLeft+parseFloat(v.paddingLeft))*g.x,E=x.top+(b.clientTop+parseFloat(v.paddingTop))*g.y;c*=g.x,u*=g.y,d*=g.x,f*=g.y,c+=y,u+=E,w=_t(b),b=ta(w)}}return ss({width:d,height:f,x:c,y:u})}function ra(e,t){const n=ls(e).scrollLeft;return t?t.left+n:zn(sn(e)).left+n}function Cd(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:ra(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function Zw(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=sn(r),a=t?as(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},u=rn(1);const d=rn(0),f=an(r);if((f||!f&&!s)&&((ir(r)!=="body"||zr(i))&&(c=ls(r)),an(r))){const m=zn(r);u=lr(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const p=i&&!f&&!s?Cd(i,c,!0):rn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-c.scrollTop*u.y+d.y+p.y}}function Qw(e){return Array.from(e.getClientRects())}function ey(e){const t=sn(e),n=ls(e),r=e.ownerDocument.body,o=Rt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Rt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ra(e);const a=-n.scrollTop;return Xt(r).direction==="rtl"&&(i+=Rt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function ty(e,t){const n=_t(e),r=sn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const u=ea();(!u||u&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:s,height:i,x:a,y:c}}const ny=new Set(["absolute","fixed"]);function ry(e,t){const n=zn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=an(e)?lr(e):rn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,u=r*s.y;return{width:i,height:a,x:c,y:u}}function Td(e,t,n){let r;if(t==="viewport")r=ty(e,n);else if(t==="document")r=ey(sn(e));else if(Yt(t))r=ry(t,n);else{const o=Sd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ss(r)}function kd(e,t){const n=Tn(e);return n===t||!Yt(n)||ar(n)?!1:Xt(n).position==="fixed"||kd(n,t)}function oy(e,t){const n=t.get(e);if(n)return n;let r=Br(e,[],!1).filter(a=>Yt(a)&&ir(a)!=="body"),o=null;const s=Xt(e).position==="fixed";let i=s?Tn(e):e;for(;Yt(i)&&!ar(i);){const a=Xt(i),c=Qi(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&ny.has(o.position)||zr(i)&&!c&&kd(e,i))?r=r.filter(d=>d!==i):o=a,i=Tn(i)}return t.set(e,r),r}function sy(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?as(t)?[]:oy(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((u,d)=>{const f=Td(t,d,o);return u.top=Rt(f.top,u.top),u.right=Cn(f.right,u.right),u.bottom=Cn(f.bottom,u.bottom),u.left=Rt(f.left,u.left),u},Td(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function iy(e){const{width:t,height:n}=yd(e);return{width:t,height:n}}function ay(e,t,n){const r=an(t),o=sn(t),s=n==="fixed",i=zn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=rn(0);function u(){c.x=ra(o)}if(r||!r&&!s)if((ir(t)!=="body"||zr(o))&&(a=ls(t)),r){const m=zn(t,!0,s,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?Cd(o,a):rn(0),f=i.left+a.scrollLeft-c.x-d.x,p=i.top+a.scrollTop-c.y-d.y;return{x:f,y:p,width:i.width,height:i.height}}function oa(e){return Xt(e).position==="static"}function Ed(e,t){if(!an(e)||Xt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return sn(e)===n&&(n=n.ownerDocument.body),n}function Id(e,t){const n=_t(e);if(as(e))return n;if(!an(e)){let o=Tn(e);for(;o&&!ar(o);){if(Yt(o)&&!oa(o))return o;o=Tn(o)}return n}let r=Ed(e,t);for(;r&&Uw(r)&&oa(r);)r=Ed(r,t);return r&&ar(r)&&oa(r)&&!Qi(r)?n:r||Gw(e)||n}const ly=async function(e){const t=this.getOffsetParent||Id,n=this.getDimensions,r=await n(e.floating);return{reference:ay(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function cy(e){return Xt(e).direction==="rtl"}const uy={convertOffsetParentRelativeRectToViewportRelativeRect:Zw,getDocumentElement:sn,getClippingRect:sy,getOffsetParent:Id,getElementRects:ly,getClientRects:Qw,getDimensions:iy,getScale:lr,isElement:Yt,isRTL:cy};function Nd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function dy(e,t){let n=null,r;const o=sn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:p,height:m}=u;if(a||t(),!p||!m)return;const w=rs(f),b=rs(o.clientWidth-(d+p)),g=rs(o.clientHeight-(f+m)),x=rs(d),y={rootMargin:-w+"px "+-b+"px "+-g+"px "+-x+"px",threshold:Rt(0,Cn(1,c))||1};let E=!0;function S(T){const I=T[0].intersectionRatio;if(I!==c){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Nd(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(S,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,y)}n.observe(e)}return i(!0),s}function fy(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=na(e),d=o||s?[...u?Br(u):[],...Br(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?dy(u,n):null;let p=-1,m=null;i&&(m=new ResizeObserver(x=>{let[v]=x;v&&v.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var y;(y=m)==null||y.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let w,b=c?zn(e):null;c&&g();function g(){const x=zn(e);b&&!Nd(b,x)&&n(),b=x,w=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(v=>{o&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,c&&cancelAnimationFrame(w)}}const hy=Lw,py=$w,my=Ow,gy=zw,xy=Mw,jd=Pw,by=Fw,vy=(e,t,n)=>{const r=new Map,o={platform:uy,...n},s={...o.platform,_c:r};return _w(e,t,{...o,platform:s})};var wy=typeof document<"u",yy=function(){},cs=wy?C.useLayoutEffect:yy;function us(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!us(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!us(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ad(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Rd(e,t){const n=Ad(e);return Math.round(t*n)/n}function sa(e){const t=h.useRef(e);return cs(()=>{t.current=e}),t}function Sy(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[d,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=h.useState(r);us(p,r)||m(r);const[w,b]=h.useState(null),[g,x]=h.useState(null),v=h.useCallback(W=>{W!==T.current&&(T.current=W,b(W))},[]),y=h.useCallback(W=>{W!==I.current&&(I.current=W,x(W))},[]),E=s||w,S=i||g,T=h.useRef(null),I=h.useRef(null),N=h.useRef(d),j=c!=null,O=sa(c),A=sa(o),F=sa(u),H=h.useCallback(()=>{if(!T.current||!I.current)return;const W={placement:t,strategy:n,middleware:p};A.current&&(W.platform=A.current),vy(T.current,I.current,W).then(M=>{const X={...M,isPositioned:F.current!==!1};D.current&&!us(N.current,X)&&(N.current=X,eo.flushSync(()=>{f(X)}))})},[p,t,n,A,F]);cs(()=>{u===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(W=>({...W,isPositioned:!1})))},[u]);const D=h.useRef(!1);cs(()=>(D.current=!0,()=>{D.current=!1}),[]),cs(()=>{if(E&&(T.current=E),S&&(I.current=S),E&&S){if(O.current)return O.current(E,S,H);H()}},[E,S,H,O,j]);const J=h.useMemo(()=>({reference:T,floating:I,setReference:v,setFloating:y}),[v,y]),K=h.useMemo(()=>({reference:E,floating:S}),[E,S]),re=h.useMemo(()=>{const W={position:n,left:0,top:0};if(!K.floating)return W;const M=Rd(K.floating,d.x),X=Rd(K.floating,d.y);return a?{...W,transform:"translate("+M+"px, "+X+"px)",...Ad(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:X}},[n,a,K.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:H,refs:J,elements:K,floatingStyles:re}),[d,H,J,K,re])}const Cy=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?jd({element:r.current,padding:o}).fn(n):{}:r?jd({element:r,padding:o}).fn(n):{}}}},Ty=(e,t)=>({...hy(e),options:[e,t]}),ky=(e,t)=>({...py(e),options:[e,t]}),Ey=(e,t)=>({...by(e),options:[e,t]}),Iy=(e,t)=>({...my(e),options:[e,t]}),Ny=(e,t)=>({...gy(e),options:[e,t]}),jy=(e,t)=>({...xy(e),options:[e,t]}),Ay=(e,t)=>({...Cy(e),options:[e,t]});var Ry="Arrow",_d=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return l.jsx(Ce.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});_d.displayName=Ry;var _y=_d;function Pd(e){const[t,n]=h.useState(void 0);return lt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ia="Popper",[Od,cr]=Kt(ia),[Py,Md]=Od(ia),Dd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return l.jsx(Py,{scope:t,anchor:r,onAnchorChange:o,children:n})};Dd.displayName=ia;var Ld="PopperAnchor",$d=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Md(Ld,n),i=h.useRef(null),a=Re(t,i),c=h.useRef(null);return h.useEffect(()=>{const u=c.current;c.current=(r==null?void 0:r.current)||i.current,u!==c.current&&s.onAnchorChange(c.current)}),r?null:l.jsx(Ce.div,{...o,ref:a})});$d.displayName=Ld;var aa="PopperContent",[Oy,My]=Od(aa),Fd=h.forwardRef((e,t)=>{var z,_,Y,Q,de,ne;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:w,...b}=e,g=Md(aa,n),[x,v]=h.useState(null),y=Re(t,_e=>v(_e)),[E,S]=h.useState(null),T=Pd(E),I=(T==null?void 0:T.width)??0,N=(T==null?void 0:T.height)??0,j=r+(s!=="center"?"-"+s:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},A=Array.isArray(u)?u:[u],F=A.length>0,H={padding:O,boundary:A.filter(Ly),altBoundary:F},{refs:D,floatingStyles:J,placement:K,isPositioned:re,middlewareData:W}=Sy({strategy:"fixed",placement:j,whileElementsMounted:(..._e)=>fy(..._e,{animationFrame:m==="always"}),elements:{reference:g.anchor},middleware:[Ty({mainAxis:o+N,alignmentAxis:i}),c&&ky({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Ey():void 0,...H}),c&&Iy({...H}),Ny({...H,apply:({elements:_e,rects:Pe,availableWidth:Ue,availableHeight:Ee})=>{const{width:Ae,height:Qe}=Pe.reference,qe=_e.floating.style;qe.setProperty("--radix-popper-available-width",`${Ue}px`),qe.setProperty("--radix-popper-available-height",`${Ee}px`),qe.setProperty("--radix-popper-anchor-width",`${Ae}px`),qe.setProperty("--radix-popper-anchor-height",`${Qe}px`)}}),E&&Ay({element:E,padding:a}),$y({arrowWidth:I,arrowHeight:N}),p&&jy({strategy:"referenceHidden",...H})]}),[M,X]=Hd(K),Z=dt(w);lt(()=>{re&&(Z==null||Z())},[re,Z]);const pe=(z=W.arrow)==null?void 0:z.x,$=(_=W.arrow)==null?void 0:_.y,G=((Y=W.arrow)==null?void 0:Y.centerOffset)!==0,[ee,me]=h.useState();return lt(()=>{x&&me(window.getComputedStyle(x).zIndex)},[x]),l.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:re?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[(Q=W.transformOrigin)==null?void 0:Q.x,(de=W.transformOrigin)==null?void 0:de.y].join(" "),...((ne=W.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(Oy,{scope:n,placedSide:M,onArrowChange:S,arrowX:pe,arrowY:$,shouldHideArrow:G,children:l.jsx(Ce.div,{"data-side":M,"data-align":X,...b,ref:y,style:{...b.style,animation:re?void 0:"none"}})})})});Fd.displayName=aa;var zd="PopperArrow",Dy={top:"bottom",right:"left",bottom:"top",left:"right"},Bd=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=My(zd,r),i=Dy[s.placedSide];return l.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:l.jsx(_y,{...o,ref:n,style:{...o.style,display:"block"}})})});Bd.displayName=zd;function Ly(e){return e!==null}var $y=e=>({name:"transformOrigin",options:e,fn(t){var g,x,v;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,d]=Hd(n),f={start:"0%",center:"50%",end:"100%"}[d],p=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,m=(((v=o.arrow)==null?void 0:v.y)??0)+c/2;let w="",b="";return u==="bottom"?(w=i?f:`${p}px`,b=`${-c}px`):u==="top"?(w=i?f:`${p}px`,b=`${r.floating.height+c}px`):u==="right"?(w=`${-c}px`,b=i?f:`${m}px`):u==="left"&&(w=`${r.floating.width+c}px`,b=i?f:`${m}px`),{data:{x:w,y:b}}}});function Hd(e){const[t,n="center"]=e.split("-");return[t,n]}var la=Dd,ca=$d,ua=Fd,da=Bd,fa="rovingFocusGroup.onEntryFocus",Fy={bubbles:!1,cancelable:!0},Hr="RovingFocusGroup",[ha,Ud,zy]=qi(Hr),[By,Wd]=Kt(Hr,[zy]),[Hy,Uy]=By(Hr),Vd=h.forwardRef((e,t)=>l.jsx(ha.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(ha.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Wy,{...e,ref:t})})}));Vd.displayName=Hr;var Wy=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,p=h.useRef(null),m=Re(t,p),w=ts(s),[b,g]=vn({prop:i,defaultProp:a??null,onChange:c,caller:Hr}),[x,v]=h.useState(!1),y=dt(u),E=Ud(n),S=h.useRef(!1),[T,I]=h.useState(0);return h.useEffect(()=>{const N=p.current;if(N)return N.addEventListener(fa,y),()=>N.removeEventListener(fa,y)},[y]),l.jsx(Hy,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:b,onItemFocus:h.useCallback(N=>g(N),[g]),onItemShiftTab:h.useCallback(()=>v(!0),[]),onFocusableItemAdd:h.useCallback(()=>I(N=>N+1),[]),onFocusableItemRemove:h.useCallback(()=>I(N=>N-1),[]),children:l.jsx(Ce.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:te(e.onMouseDown,()=>{S.current=!0}),onFocus:te(e.onFocus,N=>{const j=!S.current;if(N.target===N.currentTarget&&j&&!x){const O=new CustomEvent(fa,Fy);if(N.currentTarget.dispatchEvent(O),!O.defaultPrevented){const A=E().filter(K=>K.focusable),F=A.find(K=>K.active),H=A.find(K=>K.id===b),J=[F,H,...A].filter(Boolean).map(K=>K.ref.current);Gd(J,d)}}S.current=!1}),onBlur:te(e.onBlur,()=>v(!1))})})}),Kd="RovingFocusGroupItem",qd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=qt(),u=s||c,d=Uy(Kd,n),f=d.currentTabStopId===u,p=Ud(n),{onFocusableItemAdd:m,onFocusableItemRemove:w,currentTabStopId:b}=d;return h.useEffect(()=>{if(r)return m(),()=>w()},[r,m,w]),l.jsx(ha.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:l.jsx(Ce.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:te(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:te(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:te(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=qy(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let y=p().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")y.reverse();else if(x==="prev"||x==="next"){x==="prev"&&y.reverse();const E=y.indexOf(g.currentTarget);y=d.loop?Gy(y,E+1):y.slice(E+1)}setTimeout(()=>Gd(y))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:b!=null}):i})})});qd.displayName=Kd;var Vy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ky(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function qy(e,t,n){const r=Ky(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Vy[r]}function Gd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Gy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Yy=Vd,Xy=qd,pa=["Enter"," "],Jy=["ArrowDown","PageUp","Home"],Yd=["ArrowUp","PageDown","End"],Zy=[...Jy,...Yd],Qy={ltr:[...pa,"ArrowRight"],rtl:[...pa,"ArrowLeft"]},e0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ur="Menu",[Wr,t0,n0]=qi(Ur),[Bn,Xd]=Kt(Ur,[n0,cr,Wd]),ds=cr(),Jd=Wd(),[r0,Hn]=Bn(Ur),[o0,Vr]=Bn(Ur),Zd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ds(t),[c,u]=h.useState(null),d=h.useRef(!1),f=dt(s),p=ts(o);return h.useEffect(()=>{const m=()=>{d.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),l.jsx(la,{...a,children:l.jsx(r0,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:l.jsx(o0,{scope:t,onClose:h.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:i,children:r})})})};Zd.displayName=Ur;var s0="MenuAnchor",ma=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ds(n);return l.jsx(ca,{...o,...r,ref:t})});ma.displayName=s0;var ga="MenuPortal",[i0,Qd]=Bn(ga,{forceMount:void 0}),ef=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Hn(ga,t);return l.jsx(i0,{scope:t,forceMount:n,children:l.jsx(kt,{present:n||s.open,children:l.jsx($o,{asChild:!0,container:o,children:r})})})};ef.displayName=ga;var Ft="MenuContent",[a0,xa]=Bn(Ft),tf=h.forwardRef((e,t)=>{const n=Qd(Ft,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Hn(Ft,e.__scopeMenu),i=Vr(Ft,e.__scopeMenu);return l.jsx(Wr.Provider,{scope:e.__scopeMenu,children:l.jsx(kt,{present:r||s.open,children:l.jsx(Wr.Slot,{scope:e.__scopeMenu,children:i.modal?l.jsx(l0,{...o,ref:t}):l.jsx(c0,{...o,ref:t})})})})}),l0=h.forwardRef((e,t)=>{const n=Hn(Ft,e.__scopeMenu),r=h.useRef(null),o=Re(t,r);return h.useEffect(()=>{const s=r.current;if(s)return Bi(s)},[]),l.jsx(ba,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:te(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),c0=h.forwardRef((e,t)=>{const n=Hn(Ft,e.__scopeMenu);return l.jsx(ba,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),u0=It.createSlot("MenuContent.ScrollLock"),ba=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:w,...b}=e,g=Hn(Ft,n),x=Vr(Ft,n),v=ds(n),y=Jd(n),E=t0(n),[S,T]=h.useState(null),I=h.useRef(null),N=Re(t,I,g.onContentChange),j=h.useRef(0),O=h.useRef(""),A=h.useRef(0),F=h.useRef(null),H=h.useRef("right"),D=h.useRef(0),J=w?Wo:h.Fragment,K=w?{as:u0,allowPinchZoom:!0}:void 0,re=M=>{var z,_;const X=O.current+M,Z=E().filter(Y=>!Y.disabled),pe=document.activeElement,$=(z=Z.find(Y=>Y.ref.current===pe))==null?void 0:z.textValue,G=Z.map(Y=>Y.textValue),ee=S0(G,X,$),me=(_=Z.find(Y=>Y.textValue===ee))==null?void 0:_.ref.current;(function Y(Q){O.current=Q,window.clearTimeout(j.current),Q!==""&&(j.current=window.setTimeout(()=>Y(""),1e3))})(X),me&&setTimeout(()=>me.focus())};h.useEffect(()=>()=>window.clearTimeout(j.current),[]),Mi();const W=h.useCallback(M=>{var Z,pe;return H.current===((Z=F.current)==null?void 0:Z.side)&&T0(M,(pe=F.current)==null?void 0:pe.area)},[]);return l.jsx(a0,{scope:n,searchRef:O,onItemEnter:h.useCallback(M=>{W(M)&&M.preventDefault()},[W]),onItemLeave:h.useCallback(M=>{var X;W(M)||((X=I.current)==null||X.focus(),T(null))},[W]),onTriggerLeave:h.useCallback(M=>{W(M)&&M.preventDefault()},[W]),pointerGraceTimerRef:A,onPointerGraceIntentChange:h.useCallback(M=>{F.current=M},[]),children:l.jsx(J,{...K,children:l.jsx(Lo,{asChild:!0,trapped:o,onMountAutoFocus:te(s,M=>{var X;M.preventDefault(),(X=I.current)==null||X.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:l.jsx(Lr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:l.jsx(Yy,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:T,onEntryFocus:te(c,M=>{x.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:l.jsx(ua,{role:"menu","aria-orientation":"vertical","data-state":vf(g.open),"data-radix-menu-content":"",dir:x.dir,...v,...b,ref:N,style:{outline:"none",...b.style},onKeyDown:te(b.onKeyDown,M=>{const Z=M.target.closest("[data-radix-menu-content]")===M.currentTarget,pe=M.ctrlKey||M.altKey||M.metaKey,$=M.key.length===1;Z&&(M.key==="Tab"&&M.preventDefault(),!pe&&$&&re(M.key));const G=I.current;if(M.target!==G||!Zy.includes(M.key))return;M.preventDefault();const me=E().filter(z=>!z.disabled).map(z=>z.ref.current);Yd.includes(M.key)&&me.reverse(),w0(me)}),onBlur:te(e.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(j.current),O.current="")}),onPointerMove:te(e.onPointerMove,qr(M=>{const X=M.target,Z=D.current!==M.clientX;if(M.currentTarget.contains(X)&&Z){const pe=M.clientX>D.current?"right":"left";H.current=pe,D.current=M.clientX}}))})})})})})})});tf.displayName=Ft;var d0="MenuGroup",va=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Ce.div,{role:"group",...r,ref:t})});va.displayName=d0;var f0="MenuLabel",nf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Ce.div,{...r,ref:t})});nf.displayName=f0;var fs="MenuItem",rf="menu.itemSelect",hs=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=Vr(fs,e.__scopeMenu),a=xa(fs,e.__scopeMenu),c=Re(t,s),u=h.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const p=new CustomEvent(rf,{bubbles:!0,cancelable:!0});f.addEventListener(rf,m=>r==null?void 0:r(m),{once:!0}),Uc(f,p),p.defaultPrevented?u.current=!1:i.onClose()}};return l.jsx(of,{...o,ref:c,disabled:n,onClick:te(e.onClick,d),onPointerDown:f=>{var p;(p=e.onPointerDown)==null||p.call(e,f),u.current=!0},onPointerUp:te(e.onPointerUp,f=>{var p;u.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:te(e.onKeyDown,f=>{const p=a.searchRef.current!=="";n||p&&f.key===" "||pa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});hs.displayName=fs;var of=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=xa(fs,n),a=Jd(n),c=h.useRef(null),u=Re(t,c),[d,f]=h.useState(!1),[p,m]=h.useState("");return h.useEffect(()=>{const w=c.current;w&&m((w.textContent??"").trim())},[s.children]),l.jsx(Wr.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:l.jsx(Xy,{asChild:!0,...a,focusable:!r,children:l.jsx(Ce.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:te(e.onPointerMove,qr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:te(e.onPointerLeave,qr(w=>i.onItemLeave(w))),onFocus:te(e.onFocus,()=>f(!0)),onBlur:te(e.onBlur,()=>f(!1))})})})}),h0="MenuCheckboxItem",sf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return l.jsx(df,{scope:e.__scopeMenu,checked:n,children:l.jsx(hs,{role:"menuitemcheckbox","aria-checked":ps(n)?"mixed":n,...o,ref:t,"data-state":ya(n),onSelect:te(o.onSelect,()=>r==null?void 0:r(ps(n)?!0:!n),{checkForDefaultPrevented:!1})})})});sf.displayName=h0;var af="MenuRadioGroup",[p0,m0]=Bn(af,{value:void 0,onValueChange:()=>{}}),lf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=dt(r);return l.jsx(p0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:l.jsx(va,{...o,ref:t})})});lf.displayName=af;var cf="MenuRadioItem",uf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=m0(cf,e.__scopeMenu),s=n===o.value;return l.jsx(df,{scope:e.__scopeMenu,checked:s,children:l.jsx(hs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ya(s),onSelect:te(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});uf.displayName=cf;var wa="MenuItemIndicator",[df,g0]=Bn(wa,{checked:!1}),ff=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=g0(wa,n);return l.jsx(kt,{present:r||ps(s.checked)||s.checked===!0,children:l.jsx(Ce.span,{...o,ref:t,"data-state":ya(s.checked)})})});ff.displayName=wa;var x0="MenuSeparator",hf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Ce.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});hf.displayName=x0;var b0="MenuArrow",pf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ds(n);return l.jsx(da,{...o,...r,ref:t})});pf.displayName=b0;var v0="MenuSub",[tk,mf]=Bn(v0),Kr="MenuSubTrigger",gf=h.forwardRef((e,t)=>{const n=Hn(Kr,e.__scopeMenu),r=Vr(Kr,e.__scopeMenu),o=mf(Kr,e.__scopeMenu),s=xa(Kr,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,u={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),c(null)}},[a,c]),l.jsx(ma,{asChild:!0,...u,children:l.jsx(of,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":vf(n.open),...e,ref:Si(t,o.onTriggerChange),onClick:f=>{var p;(p=e.onClick)==null||p.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:te(e.onPointerMove,qr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:te(e.onPointerLeave,qr(f=>{var m,w;d();const p=(m=n.content)==null?void 0:m.getBoundingClientRect();if(p){const b=(w=n.content)==null?void 0:w.dataset.side,g=b==="right",x=g?-5:5,v=p[g?"left":"right"],y=p[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:v,y:p.top},{x:y,y:p.top},{x:y,y:p.bottom},{x:v,y:p.bottom}],side:b}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:te(e.onKeyDown,f=>{var m;const p=s.searchRef.current!=="";e.disabled||p&&f.key===" "||Qy[r.dir].includes(f.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),f.preventDefault())})})})});gf.displayName=Kr;var xf="MenuSubContent",bf=h.forwardRef((e,t)=>{const n=Qd(Ft,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Hn(Ft,e.__scopeMenu),i=Vr(Ft,e.__scopeMenu),a=mf(xf,e.__scopeMenu),c=h.useRef(null),u=Re(t,c);return l.jsx(Wr.Provider,{scope:e.__scopeMenu,children:l.jsx(kt,{present:r||s.open,children:l.jsx(Wr.Slot,{scope:e.__scopeMenu,children:l.jsx(ba,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:te(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:te(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:te(e.onKeyDown,d=>{var m;const f=d.currentTarget.contains(d.target),p=e0[i.dir].includes(d.key);f&&p&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),d.preventDefault())})})})})})});bf.displayName=xf;function vf(e){return e?"open":"closed"}function ps(e){return e==="indeterminate"}function ya(e){return ps(e)?"indeterminate":e?"checked":"unchecked"}function w0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function y0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function S0(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=y0(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function C0(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],c=t[i],u=a.x,d=a.y,f=c.x,p=c.y;d>r!=p>r&&n<(f-u)*(r-d)/(p-d)+u&&(o=!o)}return o}function T0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return C0(n,t)}function qr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var k0=Zd,E0=ma,I0=ef,N0=tf,j0=va,A0=nf,R0=hs,_0=sf,P0=lf,O0=uf,M0=ff,D0=hf,L0=pf,$0=gf,F0=bf,ms="DropdownMenu",[z0,nk]=Kt(ms,[Xd]),vt=Xd(),[B0,wf]=z0(ms),yf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=vt(t),u=h.useRef(null),[d,f]=vn({prop:o,defaultProp:s??!1,onChange:i,caller:ms});return l.jsx(B0,{scope:t,triggerId:qt(),triggerRef:u,contentId:qt(),open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(p=>!p),[f]),modal:a,children:l.jsx(k0,{...c,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};yf.displayName=ms;var Sf="DropdownMenuTrigger",Cf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=wf(Sf,n),i=vt(n);return l.jsx(E0,{asChild:!0,...i,children:l.jsx(Ce.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Si(t,s.triggerRef),onPointerDown:te(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:te(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Cf.displayName=Sf;var H0="DropdownMenuPortal",Tf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=vt(t);return l.jsx(I0,{...r,...n})};Tf.displayName=H0;var kf="DropdownMenuContent",Ef=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=wf(kf,n),s=vt(n),i=h.useRef(!1);return l.jsx(N0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:te(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:te(e.onInteractOutside,a=>{const c=a.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ef.displayName=kf;var U0="DropdownMenuGroup",W0=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(j0,{...o,...r,ref:t})});W0.displayName=U0;var V0="DropdownMenuLabel",If=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(A0,{...o,...r,ref:t})});If.displayName=V0;var K0="DropdownMenuItem",Nf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(R0,{...o,...r,ref:t})});Nf.displayName=K0;var q0="DropdownMenuCheckboxItem",jf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(_0,{...o,...r,ref:t})});jf.displayName=q0;var G0="DropdownMenuRadioGroup",Y0=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(P0,{...o,...r,ref:t})});Y0.displayName=G0;var X0="DropdownMenuRadioItem",Af=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(O0,{...o,...r,ref:t})});Af.displayName=X0;var J0="DropdownMenuItemIndicator",Rf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(M0,{...o,...r,ref:t})});Rf.displayName=J0;var Z0="DropdownMenuSeparator",_f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(D0,{...o,...r,ref:t})});_f.displayName=Z0;var Q0="DropdownMenuArrow",eS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(L0,{...o,...r,ref:t})});eS.displayName=Q0;var tS="DropdownMenuSubTrigger",Pf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx($0,{...o,...r,ref:t})});Pf.displayName=tS;var nS="DropdownMenuSubContent",Of=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(F0,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Of.displayName=nS;var rS=yf,oS=Cf,sS=Tf,Mf=Ef,Df=If,Lf=Nf,$f=jf,Ff=Af,zf=Rf,Bf=_f,Hf=Pf,Uf=Of;const iS=rS,aS=oS,lS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>l.jsxs(Hf,{ref:o,className:L("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,l.jsx(oe.ChevronRight,{className:"ml-auto h-4 w-4"})]}));lS.displayName=Hf.displayName;const cS=h.forwardRef(({className:e,...t},n)=>l.jsx(Uf,{ref:n,className:L("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));cS.displayName=Uf.displayName;const Wf=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(sS,{children:l.jsx(Mf,{ref:r,sideOffset:t,className:L("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Wf.displayName=Mf.displayName;const Sa=h.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Lf,{ref:r,className:L("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Sa.displayName=Lf.displayName;const uS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>l.jsxs($f,{ref:o,className:L("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(zf,{children:l.jsx(oe.Check,{className:"h-4 w-4"})})}),t]}));uS.displayName=$f.displayName;const dS=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Ff,{ref:r,className:L("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(zf,{children:l.jsx(oe.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));dS.displayName=Ff.displayName;const fS=h.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Df,{ref:r,className:L("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));fS.displayName=Df.displayName;const hS=h.forwardRef(({className:e,...t},n)=>l.jsx(Bf,{ref:n,className:L("-mx-1 my-1 h-px bg-muted",e),...t}));hS.displayName=Bf.displayName;function Gr({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:c=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:p,onError:m}){const{currentThreadId:w,messages:b,isStreaming:g,streamingAssistantId:x,error:v,send:y,stop:E,lastCheckpointId:S,lastCheckpointNs:T,listCheckpoints:I,navigateToCheckpoint:N,returnToLatest:j,hasMoreHistory:O,isLoadingHistory:A,loadOlderMessages:F,api:H}=po(),[D,J]=C.useState(null),[K,re]=C.useState(""),[W,M]=C.useState(null),[X,Z]=C.useState([]),[pe,$]=C.useState(!1),[G,ee]=C.useState(null),[me,z]=C.useState(null),[_,Y]=C.useState(!1),[Q,de]=C.useState(null),[ne,_e]=C.useState([]),[Pe,Ue]=C.useState(null),[Ee,Ae]=C.useState(null),[Qe,qe]=C.useState(!1),ct=C.useRef(null),ut=C.useRef(null),ve=C.useRef(null),[ze,Ge]=C.useState("desktop");C.useEffect(()=>{const ce=()=>{const fe=window.innerWidth;Ge(fe<640?"phone":fe<1024?"tablet":"desktop")};return ce(),window.addEventListener("resize",ce),()=>window.removeEventListener("resize",ce)},[]),C.useEffect(()=>{let ce=!1;if(!w){_e([]),Ue(null),Ae(null),ve.current=null;return}const fe={threadId:w,checkpointId:S??null,checkpointNs:T??null},$e=ve.current;if(!($e&&$e.threadId===fe.threadId&&$e.checkpointId===fe.checkpointId&&$e.checkpointNs===fe.checkpointNs))return I(w).then(et=>{var Os;if(ce)return;const jn=((et==null?void 0:et.checkpoints)??[]).slice().sort((pn,mr)=>new Date(mr.createdAt).getTime()-new Date(pn.createdAt).getTime());_e(jn);const Zr=Pe,pr=Zr&&jn.some(pn=>pn.checkpointId===Zr)?Zr:((Os=jn[0])==null?void 0:Os.checkpointId)??null;let Qr=null;if(pr){const pn=jn.find(mr=>mr.checkpointId===pr);Qr=(pn==null?void 0:pn.checkpointNs)??null}Ue(pr),Ae(Qr),ve.current=fe}).catch(et=>{console.error("ChatInterface - listCheckpoints error:",et),ce||(_e([]),ve.current=null)}),()=>{ce=!0}},[w,S,T,Pe,I]),C.useEffect(()=>{S&&(Ue(S),Ae(T??null))},[S,T]);const P=C.useCallback(async()=>{if(!(!O||A))try{await F()}catch(ce){console.warn("loadOlderMessages failed",ce)}},[O,A,F]);C.useEffect(()=>{(async()=>{try{const fe=await H.getAgent("default");de(fe.uiDefaultMessage||null)}catch(fe){console.warn("Failed to fetch default message:",fe),de(null)}})()},[H]),C.useEffect(()=>{v&&!_&&(m==null||m(v))},[v,_,m]);const U=ce=>{if(ce.length>es)return`Message too long (${ce.length}/${es} characters)`;try{return vw(ce),null}catch(fe){return(fe==null?void 0:fe.message)||"Invalid message"}},ue=ce=>{const fe=ce.content||[],$e=fe.filter(et=>et.type==="text").map(et=>et.text).join("");if($e)return $e;try{return JSON.stringify(fe,null,2)}catch{return String(fe)}},we=async ce=>{const fe=ce.trim();if(!(!fe&&X.length===0)){if(fe){const $e=U(fe);if($e){M($e);return}}try{await y(fe||"",{checkpointId:Pe??S??void 0,checkpointNs:Ee??T??void 0,payloadExtras:D?{edit:!0,originalMessageId:D}:void 0,attachments:X}),f==null||f(fe),M(null),Z([]),J(null),re("")}catch($e){const et=($e==null?void 0:$e.message)||"Failed to send message";M(et),m==null||m(et)}}},le=C.useCallback((ce,fe)=>{u&&(J(ce),re(fe),M(null))},[u]),Le=C.useCallback(()=>{J(null),re(""),M(null)},[]),at=C.useCallback((ce,fe)=>{le(ce,fe)},[le]),hn=C.useCallback(ce=>{for(let fe=ce-1;fe>=0;fe--)if(b[fe].role==="user"){const $e=ue(b[fe]);$e&&y($e,{checkpointId:Pe??S??void 0,checkpointNs:Ee??T??void 0});break}},[b,y,Pe,Ee,S,T,ue]),xt=ce=>{const fe=Array.from(ce.target.files||[]);Z($e=>[...$e,...fe])},Pt=ce=>Z(fe=>fe.filter(($e,et)=>ce!==et)),ft=async ce=>{const fe=(ce.target.files||[])[0];if(fe){ee(null),z(null),$(!0);try{await y("",{checkpointId:Pe??S??void 0,checkpointNs:Ee??T??void 0,attachments:[fe]});const $e=`Uploaded ${fe.name} - processing through chat stream`;z($e)}catch($e){const et=$e instanceof Error?$e.message:"Failed to upload Excel file";console.error("Excel upload failed",$e),ee(et),m==null||m(et)}finally{$(!1),ce.target.value=""}}},Ot=ce=>{if(!ce)return"Unknown";const fe=Date.parse(ce);return Number.isNaN(fe)?ce:new Date(fe).toLocaleString()},Nn=async ce=>{if(w){qe(!0);try{if(!ce){await j(),Ue(null),Ae(null);return}const fe=ne.find(et=>et.checkpointId===ce),$e=(fe==null?void 0:fe.checkpointNs)??null;await N(ce,$e),Ue(ce),Ae($e)}finally{qe(!1)}}},Kn=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,qn=`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 ${d.messagesArea||""}`,wt=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return l.jsxs("div",{className:Kn,children:[!!v&&!_&&l.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:[l.jsx("span",{children:v}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:()=>Y(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:l.jsx(oe.X,{size:16})})]}),w&&ne.length>0&&l.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[l.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),l.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:Pe??"",onChange:ce=>{const fe=ce.target.value||null;Nn(fe)},children:[l.jsx("option",{value:"",children:"Latest"}),ne.map(ce=>l.jsxs("option",{value:ce.checkpointId,children:[Ot(ce.createdAt),ce.preview?` — ${ce.preview.slice(0,40)}`:""]},ce.checkpointId))]})]}),l.jsx(Ki,{className:qn,style:r?{maxHeight:r}:void 0,messages:b,isStreaming:g,streamingAssistantId:x,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:ze,enableMessageEditing:u,editingMessageId:D,onStartReached:()=>{P()},onEdit:at,onRegenerate:hn,onCancelEdit:Le,emptyMessage:Q??void 0,isNavigatingCheckpoint:Qe}),l.jsxs("div",{className:wt,children:[D&&l.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(oe.Edit3,{size:16,className:"text-blue-600"}),l.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:Le,className:"text-blue-600 hover:bg-blue-100",children:l.jsx(oe.X,{size:16})})]})}),(a||c)&&l.jsxs("div",{className:"mb-3 space-y-3",children:[a&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:ct,type:"file",multiple:!0,onChange:ce=>xt(ce),className:"hidden"}),X.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2",children:X.map((ce,fe)=>l.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:[l.jsx(oe.Paperclip,{size:14}),l.jsx("span",{className:"truncate max-w-[150px]",children:ce.name}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:()=>Pt(fe),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${ce.name}`,children:l.jsx(oe.X,{size:12})})]},fe))})]}),c&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:ut,type:"file",accept:".xls,.xlsx,.xlsm",onChange:ft,className:"hidden"}),pe&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(oe.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),me&&!pe&&l.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:me}),G&&!pe&&l.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:G})]})]}),W&&l.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:W}),l.jsxs("div",{className:"flex items-end gap-2",children:[(a||c)&&l.jsxs(iS,{children:[l.jsx(aS,{asChild:!0,children:l.jsx(Be,{type:"button",size:"icon",variant:"outline",disabled:g,title:"More input actions",className:d.moreButton||"",children:l.jsx(oe.Plus,{size:16})})}),l.jsxs(Wf,{align:"start",sideOffset:6,className:"w-52",children:[a&&l.jsxs(Sa,{onClick:()=>{var ce;return(ce=ct.current)==null?void 0:ce.click()},className:"cursor-pointer",children:[l.jsx(oe.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),c&&l.jsxs(Sa,{onClick:()=>{var ce;pe||(ce=ut.current)==null||ce.click()},className:`cursor-pointer ${pe?"opacity-60 pointer-events-none":""}`,children:[l.jsx(oe.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),l.jsx("div",{className:"flex-1",children:l.jsx(Ag,{initialValue:K,editingMessageId:D,placeholder:D?"Edit your message...":t,isStreaming:g,disabled:!1,maxLength:es,onSend:we,onCancelEdit:Le,onStop:E,allowEmptySend:X.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${D?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${W?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Yr=h.forwardRef(({className:e,type:t,...n},r)=>l.jsx("input",{type:t,className:L("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}));Yr.displayName="Input";function Ca(e,[t,n]){return Math.min(n,Math.max(t,e))}function pS(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ta="ScrollArea",[Vf,rk]=Kt(Ta),[mS,zt]=Vf(Ta),Kf=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=h.useState(null),[u,d]=h.useState(null),[f,p]=h.useState(null),[m,w]=h.useState(null),[b,g]=h.useState(null),[x,v]=h.useState(0),[y,E]=h.useState(0),[S,T]=h.useState(!1),[I,N]=h.useState(!1),j=Re(t,A=>c(A)),O=ts(o);return l.jsx(mS,{scope:n,type:r,dir:O,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:p,scrollbarX:m,onScrollbarXChange:w,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:b,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:N,onCornerWidthChange:v,onCornerHeightChange:E,children:l.jsx(Ce.div,{dir:O,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});Kf.displayName=Ta;var qf="ScrollAreaViewport",Gf=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=zt(qf,n),a=h.useRef(null),c=Re(t,a,i.onViewportChange);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(Ce.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:l.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Gf.displayName=qf;var ln="ScrollAreaScrollbar",ka=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,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"?l.jsx(gS,{...r,ref:t,forceMount:n}):o.type==="scroll"?l.jsx(xS,{...r,ref:t,forceMount:n}):o.type==="auto"?l.jsx(Yf,{...r,ref:t,forceMount:n}):o.type==="always"?l.jsx(Ea,{...r,ref:t}):null});ka.displayName=ln;var gS=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},d=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),l.jsx(kt,{present:n||s,children:l.jsx(Yf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),xS=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,e.__scopeScrollArea),s=e.orientation==="horizontal",i=vs(()=>c("SCROLL_END"),100),[a,c]=pS("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 u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),h.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const p=()=>{const m=u[d];f!==m&&(c("SCROLL"),i()),f=m};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,s,c,i]),l.jsx(kt,{present:n||a!=="hidden",children:l.jsx(Ea,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:te(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:te(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Yf=h.forwardRef((e,t)=>{const n=zt(ln,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",c=vs(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return ur(n.viewport,c),ur(n.content,c),l.jsx(kt,{present:r||s,children:l.jsx(Ea,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ea=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=zt(ln,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,c]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=eh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function f(p,m){return CS(p,i.current,a,m)}return n==="horizontal"?l.jsx(bS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,m=th(p,a,o.dir);s.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=f(p,o.dir))}}):n==="vertical"?l.jsx(vS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,m=th(p,a);s.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=f(p))}}):null}),bS=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=zt(ln,e.__scopeScrollArea),[i,a]=h.useState(),c=h.useRef(null),u=Re(t,c,s.onScrollbarXChange);return h.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Jf,{"data-orientation":"horizontal",...o,ref:u,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":bs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const p=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(p),rh(p,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:xs(i.paddingLeft),paddingEnd:xs(i.paddingRight)}})}})}),vS=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=zt(ln,e.__scopeScrollArea),[i,a]=h.useState(),c=h.useRef(null),u=Re(t,c,s.onScrollbarYChange);return h.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Jf,{"data-orientation":"vertical",...o,ref:u,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":bs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const p=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(p),rh(p,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:xs(i.paddingTop),paddingEnd:xs(i.paddingBottom)}})}})}),[wS,Xf]=Vf(ln),Jf=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...p}=e,m=zt(ln,n),[w,b]=h.useState(null),g=Re(t,j=>b(j)),x=h.useRef(null),v=h.useRef(""),y=m.viewport,E=r.content-r.viewport,S=dt(d),T=dt(c),I=vs(f,10);function N(j){if(x.current){const O=j.clientX-x.current.left,A=j.clientY-x.current.top;u({x:O,y:A})}}return h.useEffect(()=>{const j=O=>{const A=O.target;(w==null?void 0:w.contains(A))&&S(O,E)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[y,w,E,S]),h.useEffect(T,[r,T]),ur(w,I),ur(m.content,I),l.jsx(wS,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:dt(s),onThumbPointerUp:dt(i),onThumbPositionChange:T,onThumbPointerDown:dt(a),children:l.jsx(Ce.div,{...p,ref:g,style:{position:"absolute",...p.style},onPointerDown:te(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),x.current=w.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),N(j))}),onPointerMove:te(e.onPointerMove,N),onPointerUp:te(e.onPointerUp,j=>{const O=j.target;O.hasPointerCapture(j.pointerId)&&O.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=v.current,m.viewport&&(m.viewport.style.scrollBehavior=""),x.current=null})})})}),gs="ScrollAreaThumb",Zf=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xf(gs,e.__scopeScrollArea);return l.jsx(kt,{present:n||o.hasThumb,children:l.jsx(yS,{ref:t,...r})})}),yS=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=zt(gs,n),i=Xf(gs,n),{onThumbPositionChange:a}=i,c=Re(t,f=>i.onThumbChange(f)),u=h.useRef(void 0),d=vs(()=>{u.current&&(u.current(),u.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const p=()=>{if(d(),!u.current){const m=TS(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[s.viewport,d,a]),l.jsx(Ce.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:te(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),w=f.clientX-m.left,b=f.clientY-m.top;i.onThumbPointerDown({x:w,y:b})}),onPointerUp:te(e.onPointerUp,i.onThumbPointerUp)})});Zf.displayName=gs;var Ia="ScrollAreaCorner",Qf=h.forwardRef((e,t)=>{const n=zt(Ia,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?l.jsx(SS,{...e,ref:t}):null});Qf.displayName=Ia;var SS=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=zt(Ia,n),[s,i]=h.useState(0),[a,c]=h.useState(0),u=!!(s&&a);return ur(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),ur(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?l.jsx(Ce.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 xs(e){return e?parseInt(e,10):0}function eh(e,t){const n=e/t;return isNaN(n)?0:n}function bs(e){const t=eh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function CS(e,t,n,r="ltr"){const o=bs(n),s=o/2,i=t||s,a=o-i,c=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return nh([c,u],f)(e)}function th(e,t,n="ltr"){const r=bs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,c=n==="ltr"?[0,i]:[i*-1,0],u=Ca(e,c);return nh([0,i],[0,a])(u)}function nh(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 rh(e,t){return e>0&&e<t}var TS=(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 vs(e,t){const n=dt(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 ur(e,t){const n=dt(t);lt(()=>{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 oh=Kf,kS=Gf,ES=Qf;const sh=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(oh,{ref:r,className:L("relative overflow-hidden",e),...n,children:[l.jsx(kS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),l.jsx(ih,{}),l.jsx(ES,{})]}));sh.displayName=oh.displayName;const ih=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(ka,{ref:r,orientation:t,className:L("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:l.jsx(Zf,{className:"relative flex-1 rounded-full bg-border"})}));ih.displayName=ka.displayName;function ws({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:c,onThreadCreate:u,onThreadDelete:d}){const{loadThread:f,threads:p,refreshThreads:m,currentThreadId:w,createThread:b,deleteThread:g,renameThread:x}=po(),[v,y]=C.useState(p??[]),[E,S]=C.useState(!1),[T,I]=C.useState(null),[N,j]=C.useState(null),[O,A]=C.useState(""),[F,H]=C.useState(!1);C.useEffect(()=>{y(p??[])},[p]);const D=async $=>{try{await f($),a==null||a($),c==null||c($)}catch(G){console.error("Failed to select thread:",G)}},J=async()=>{try{H(!0);const $=await b();u==null||u($),a==null||a($)}catch($){console.error("Failed to create thread:",$)}finally{H(!1)}},K=async($,G)=>{if(G.stopPropagation(),!!confirm("Delete this thread?"))try{await g($),d==null||d($)}catch(ee){console.error("Failed to delete thread:",ee)}},re=($,G)=>{G.stopPropagation(),j($.threadId),A($.title||`Thread ${$.threadId.slice(0,8)}`)},W=async $=>{if(O.trim())try{await x($,O.trim()),j(null),A("")}catch(G){console.error("Failed to update title:",G)}},M=()=>{j(null),A("")},X=($,G)=>{$.key==="Enter"?W(G):$.key==="Escape"&&M()},Z=$=>{if(!$)return"";try{const G=new Date($),me=new Date().getTime()-G.getTime(),z=Math.floor(me/(1e3*60*60*24));return z===0?G.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):z===1?"Yesterday":z<7?`${z} days ago`:G.toLocaleDateString()}catch{return""}},pe=$=>$.title||`Thread ${$.threadId.slice(0,8)}`;return l.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&l.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:l.jsx(Be,{onClick:J,disabled:F||E,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:F?"Creating...":"New Chat",children:l.jsx(oe.MessageSquarePlus,{size:20})})}),l.jsx(sh,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:l.jsx("div",{className:"p-2 space-y-1 pb-4",children:E?l.jsx("div",{className:"text-center py-8 text-slate-400",children:"Loading…"}):v.length===0?l.jsxs("div",{className:"text-center py-8 text-slate-400",children:[l.jsx(oe.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),l.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):v.slice().sort(($,G)=>new Date(G.updatedAt||G.createdAt||"").getTime()-new Date($.updatedAt||$.createdAt||"").getTime()).map($=>l.jsxs("div",{onClick:()=>D($.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??w)===$.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex-1 min-w-0",children:N===$.threadId?l.jsxs("div",{className:"flex items-center gap-2",onClick:G=>G.stopPropagation(),children:[l.jsx(Yr,{value:O,onChange:G=>A(G.target.value),onKeyDown:G=>X(G,$.threadId),className:"h-6 text-sm",autoFocus:!0}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:()=>W($.threadId),className:"h-6 w-6 p-0",children:l.jsx(oe.Check,{size:12})}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:M,className:"h-6 w-6 p-0",children:l.jsx(oe.X,{size:12})})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:pe($)}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[l.jsx(oe.Calendar,{size:10}),l.jsx("span",{children:Z($.updatedAt||$.createdAt)})]})]})}),l.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&N!==$.threadId&&l.jsx(Be,{variant:"ghost",size:"sm",onClick:G=>re($,G),className:"h-6 w-6 p-0",title:"Edit title",children:l.jsx(oe.Edit3,{size:12})}),n&&l.jsx(Be,{variant:"ghost",size:"sm",onClick:G=>K($.threadId,G),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:l.jsx(oe.Trash2,{size:12})})]})]}),i===$.threadId&&l.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},$.threadId))})})]})}const ah=C.createContext(null);function IS({children:e,basePath:t="/chat"}){const n=C.useMemo(()=>t?t==="/"?"":t.endsWith("/")?t.slice(0,-1):t:"/chat",[t]),r={basePath:n,buildThreadPath:o=>`${n}/${o}`,buildBasePath:()=>n};return l.jsx(ah.Provider,{value:r,children:e})}function NS(){const e=C.useContext(ah);return e||{basePath:"/chat",buildThreadPath:t=>`/chat/${t}`,buildBasePath:()=>"/chat"}}function jS(e){const t=e.apiBase.replace(/\/$/,""),n={...e.authToken?{Authorization:`Bearer ${e.authToken}`}:{},...e.headers??{}};return{stream(r,o){const s=new AbortController;return(async()=>{var i,a;try{const c=await fetch(`${t}/runs/stream`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...n},body:JSON.stringify(r),signal:s.signal});(i=o.onOpen)==null||i.call(o,{threadId:c.headers.get("x-thread-id"),created:(c.headers.get("x-thread-created")||"").toLowerCase()==="true"})}catch(c){(c==null?void 0:c.name)!=="AbortError"&&((a=o.onError)==null||a.call(o,String((c==null?void 0:c.message)||c)))}})(),{close:()=>s.abort()}}}}const lh=C.createContext(null);function AS({client:e,children:t}){return l.jsx(lh.Provider,{value:e,children:t})}function RS(){const e=C.useContext(lh);if(!e)throw new Error("ChatProvider missing");return e}function dr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function _S(e){if(typeof e!="string")return;const t=e.trim();if(t)return t.replace(/\/+$/g,"")}function ch(){const e=[dr("__API_BASE_URL__"),dr("__CHAT_API_BASE_URL__"),dr("__CHAT_API_URL__")];for(const t of e){const n=_S(t);if(n)return n}}function uh(){const e=[dr("__API_AUTH_TOKEN__"),dr("__CHAT_API_KEY__"),dr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function dh(){const e={},t=ch(),n=uh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function fh(){const e=dh(),t=cn.getAuthToken(),n=ch();return{apiBaseUrl:e.baseUrl||cn.baseUrl||n||"http://localhost:8000",apiKey:t||e.apiKey||uh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const hh="chat-settings";function PS(){try{const e=localStorage.getItem(hh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function OS(e){try{localStorage.setItem(hh,JSON.stringify(e)),e.apiKey&&cn.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function MS(){const e=fh(),t=PS(),n=cn.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:cn.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function DS(e){e.apiKey&&cn.setAuthToken(e.apiKey),OS(e)}const Na=768;function LS(){const[e,t]=h.useState(void 0);return h.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Na-1}px)`),r=()=>{t(window.innerWidth<Na)};return n.addEventListener("change",r),t(window.innerWidth<Na),()=>n.removeEventListener("change",r)},[]),!!e}var $S="Separator",ph="horizontal",FS=["horizontal","vertical"],mh=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=ph,...o}=e,s=zS(r)?r:ph,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return l.jsx(Ce.div,{"data-orientation":s,...a,...o,ref:t})});mh.displayName=$S;function zS(e){return FS.includes(e)}var gh=mh;const ja=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>l.jsx(gh,{ref:o,decorative:n,orientation:t,className:L("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ja.displayName=gh.displayName;const xh=Xu,BS=Zv,HS=Ju,bh=h.forwardRef(({className:e,...t},n)=>l.jsx(Yo,{className:L("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}));bh.displayName=Yo.displayName;const US=xr.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"}}),Aa=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>l.jsxs(HS,{children:[l.jsx(bh,{}),l.jsxs(Xo,{ref:o,className:L(US({side:e}),t),...r,children:[n,l.jsxs(Zu,{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:[l.jsx(oe.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Aa.displayName=Xo.displayName;const vh=({className:e,...t})=>l.jsx("div",{className:L("flex flex-col space-y-2 text-center sm:text-left",e),...t});vh.displayName="SheetHeader";const wh=h.forwardRef(({className:e,...t},n)=>l.jsx(Fn,{ref:n,className:L("text-lg font-semibold text-foreground",e),...t}));wh.displayName=Fn.displayName;const yh=h.forwardRef(({className:e,...t},n)=>l.jsx(Jo,{ref:n,className:L("text-sm text-muted-foreground",e),...t}));yh.displayName=Jo.displayName;function Sh({className:e,...t}){return l.jsx("div",{className:L("animate-pulse rounded-md bg-muted",e),...t})}var Ch=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"}),WS="VisuallyHidden",Th=h.forwardRef((e,t)=>l.jsx(Ce.span,{...e,ref:t,style:{...Ch,...e.style}}));Th.displayName=WS;var VS=Th,[ys,ok]=Kt("Tooltip",[cr]),Ss=cr(),kh="TooltipProvider",KS=700,Ra="tooltip.open",[qS,_a]=ys(kh),Eh=e=>{const{__scopeTooltip:t,delayDuration:n=KS,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),c=h.useRef(0);return h.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),l.jsx(qS,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(u=>{a.current=u},[]),disableHoverableContent:o,children:s})};Eh.displayName=kh;var Xr="Tooltip",[GS,Cs]=ys(Xr),Ih=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,c=_a(Xr,e.__scopeTooltip),u=Ss(t),[d,f]=h.useState(null),p=qt(),m=h.useRef(0),w=i??c.disableHoverableContent,b=a??c.delayDuration,g=h.useRef(!1),[x,v]=vn({prop:r,defaultProp:o??!1,onChange:I=>{I?(c.onOpen(),document.dispatchEvent(new CustomEvent(Ra))):c.onClose(),s==null||s(I)},caller:Xr}),y=h.useMemo(()=>x?g.current?"delayed-open":"instant-open":"closed",[x]),E=h.useCallback(()=>{window.clearTimeout(m.current),m.current=0,g.current=!1,v(!0)},[v]),S=h.useCallback(()=>{window.clearTimeout(m.current),m.current=0,v(!1)},[v]),T=h.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{g.current=!0,v(!0),m.current=0},b)},[b,v]);return h.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),l.jsx(la,{...u,children:l.jsx(GS,{scope:t,contentId:p,open:x,stateAttribute:y,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{c.isOpenDelayedRef.current?T():E()},[c.isOpenDelayedRef,T,E]),onTriggerLeave:h.useCallback(()=>{w?S():(window.clearTimeout(m.current),m.current=0)},[S,w]),onOpen:E,onClose:S,disableHoverableContent:w,children:n})})};Ih.displayName=Xr;var Pa="TooltipTrigger",Nh=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Cs(Pa,n),s=_a(Pa,n),i=Ss(n),a=h.useRef(null),c=Re(t,a,o.onTriggerChange),u=h.useRef(!1),d=h.useRef(!1),f=h.useCallback(()=>u.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),l.jsx(ca,{asChild:!0,...i,children:l.jsx(Ce.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:te(e.onPointerMove,p=>{p.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:te(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:te(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:te(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:te(e.onBlur,o.onClose),onClick:te(e.onClick,o.onClose)})})});Nh.displayName=Pa;var YS="TooltipPortal",[sk,XS]=ys(YS,{forceMount:void 0}),fr="TooltipContent",jh=h.forwardRef((e,t)=>{const n=XS(fr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=Cs(fr,e.__scopeTooltip);return l.jsx(kt,{present:r||i.open,children:i.disableHoverableContent?l.jsx(Ah,{side:o,...s,ref:t}):l.jsx(JS,{side:o,...s,ref:t})})}),JS=h.forwardRef((e,t)=>{const n=Cs(fr,e.__scopeTooltip),r=_a(fr,e.__scopeTooltip),o=h.useRef(null),s=Re(t,o),[i,a]=h.useState(null),{trigger:c,onClose:u}=n,d=o.current,{onPointerInTransitChange:f}=r,p=h.useCallback(()=>{a(null),f(!1)},[f]),m=h.useCallback((w,b)=>{const g=w.currentTarget,x={x:w.clientX,y:w.clientY},v=nC(x,g.getBoundingClientRect()),y=rC(x,v),E=oC(b.getBoundingClientRect()),S=iC([...y,...E]);a(S),f(!0)},[f]);return h.useEffect(()=>()=>p(),[p]),h.useEffect(()=>{if(c&&d){const w=g=>m(g,d),b=g=>m(g,c);return c.addEventListener("pointerleave",w),d.addEventListener("pointerleave",b),()=>{c.removeEventListener("pointerleave",w),d.removeEventListener("pointerleave",b)}}},[c,d,m,p]),h.useEffect(()=>{if(i){const w=b=>{const g=b.target,x={x:b.clientX,y:b.clientY},v=(c==null?void 0:c.contains(g))||(d==null?void 0:d.contains(g)),y=!sC(x,i);v?p():y&&(p(),u())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[c,d,i,u,p]),l.jsx(Ah,{...e,ref:s})}),[ZS,QS]=ys(Xr,{isInside:!1}),eC=It.createSlottable("TooltipContent"),Ah=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,c=Cs(fr,n),u=Ss(n),{onClose:d}=c;return h.useEffect(()=>(document.addEventListener(Ra,d),()=>document.removeEventListener(Ra,d)),[d]),h.useEffect(()=>{if(c.trigger){const f=p=>{const m=p.target;m!=null&&m.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),l.jsx(Lr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:l.jsxs(ua,{"data-state":c.stateAttribute,...u,...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:[l.jsx(eC,{children:r}),l.jsx(ZS,{scope:n,isInside:!0,children:l.jsx(VS,{id:c.contentId,role:"tooltip",children:o||r})})]})})});jh.displayName=fr;var Rh="TooltipArrow",tC=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Ss(n);return QS(Rh,n).isInside?null:l.jsx(da,{...o,...r,ref:t})});tC.displayName=Rh;function nC(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 rC(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 oC(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 sC(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],c=t[i],u=a.x,d=a.y,f=c.x,p=c.y;d>r!=p>r&&n<(f-u)*(r-d)/(p-d)+u&&(o=!o)}return o}function iC(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),aC(t)}function aC(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 lC=Eh,cC=Ih,uC=Nh,_h=jh;const dC=lC,fC=cC,hC=uC,Ph=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(_h,{ref:r,sideOffset:t,className:L("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}));Ph.displayName=_h.displayName;const pC="sidebar:state",mC=60*60*24*7,gC="16rem",xC="18rem",bC="3rem",vC="b",Oh=h.createContext(null);function Ts(){const e=h.useContext(Oh);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Mh=h.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:o,children:s,...i},a)=>{const c=LS(),[u,d]=h.useState(!1),[f,p]=h.useState(e),m=t??f,w=h.useCallback(v=>{const y=typeof v=="function"?v(m):v;n?n(y):p(y),document.cookie=`${pC}=${y}; path=/; max-age=${mC}`},[n,m]),b=h.useCallback(()=>c?d(v=>!v):w(v=>!v),[c,w,d]);h.useEffect(()=>{const v=y=>{y.key===vC&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),b())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[b]);const g=m?"expanded":"collapsed",x=h.useMemo(()=>({state:g,open:m,setOpen:w,isMobile:c,openMobile:u,setOpenMobile:d,toggleSidebar:b}),[g,m,w,c,u,d,b]);return l.jsx(Oh.Provider,{value:x,children:l.jsx(dC,{delayDuration:0,children:l.jsx("div",{style:{"--sidebar-width":gC,"--sidebar-width-icon":bC,...o},className:L("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:a,...i,children:s})})})});Mh.displayName="SidebarProvider";const Dh=h.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:o,...s},i)=>{const{isMobile:a,state:c,openMobile:u,setOpenMobile:d}=Ts();return n==="none"?l.jsx("div",{className:L("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...s,children:o}):a?l.jsx(xh,{open:u,onOpenChange:d,...s,children:l.jsx(Aa,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":xC},side:e,children:l.jsx("div",{className:"flex h-full w-full flex-col",children:o})})}):l.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":c,"data-collapsible":c==="collapsed"?n:"","data-variant":t,"data-side":e,children:[l.jsx("div",{className:L("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),l.jsx("div",{className:L("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:l.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:o})})]})});Dh.displayName="Sidebar";const Lh=h.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:o}=Ts();return l.jsxs(Be,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:L("h-7 w-7",e),onClick:s=>{t==null||t(s),o()},...n,children:[l.jsx(oe.PanelLeft,{}),l.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Lh.displayName="SidebarTrigger";const wC=h.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Ts();return l.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:L("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});wC.displayName="SidebarRail";const $h=h.forwardRef(({className:e,...t},n)=>l.jsx("main",{ref:n,className:L("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));$h.displayName="SidebarInset";const yC=h.forwardRef(({className:e,...t},n)=>l.jsx(Yr,{ref:n,"data-sidebar":"input",className:L("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));yC.displayName="SidebarInput";const Fh=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"header",className:L("flex flex-col gap-2 p-2",e),...t}));Fh.displayName="SidebarHeader";const SC=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"footer",className:L("flex flex-col gap-2 p-2",e),...t}));SC.displayName="SidebarFooter";const CC=h.forwardRef(({className:e,...t},n)=>l.jsx(ja,{ref:n,"data-sidebar":"separator",className:L("mx-2 w-auto bg-sidebar-border",e),...t}));CC.displayName="SidebarSeparator";const zh=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"content",className:L("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));zh.displayName="SidebarContent";const Bh=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"group",className:L("relative flex w-full min-w-0 flex-col p-2",e),...t}));Bh.displayName="SidebarGroup";const Hh=h.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?It.Slot:"div";return l.jsx(o,{ref:r,"data-sidebar":"group-label",className:L("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});Hh.displayName="SidebarGroupLabel";const TC=h.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?It.Slot:"button";return l.jsx(o,{ref:r,"data-sidebar":"group-action",className:L("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});TC.displayName="SidebarGroupAction";const Uh=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"group-content",className:L("w-full text-sm",e),...t}));Uh.displayName="SidebarGroupContent";const Wh=h.forwardRef(({className:e,...t},n)=>l.jsx("ul",{ref:n,"data-sidebar":"menu",className:L("flex w-full min-w-0 flex-col gap-1",e),...t}));Wh.displayName="SidebarMenu";const Vh=h.forwardRef(({className:e,...t},n)=>l.jsx("li",{ref:n,"data-sidebar":"menu-item",className:L("group/menu-item relative",e),...t}));Vh.displayName="SidebarMenuItem";const kC=xr.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),Kh=h.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:o,className:s,...i},a)=>{const c=e?It.Slot:"button",{isMobile:u,state:d}=Ts(),f=l.jsx(c,{ref:a,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:L(kC({variant:n,size:r}),s),...i});return o?(typeof o=="string"&&(o={children:o}),l.jsxs(fC,{children:[l.jsx(hC,{asChild:!0,children:f}),l.jsx(Ph,{side:"right",align:"center",hidden:d!=="collapsed"||u,...o})]})):f});Kh.displayName="SidebarMenuButton";const EC=h.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},o)=>{const s=t?It.Slot:"button";return l.jsx(s,{ref:o,"data-sidebar":"menu-action",className:L("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...r})});EC.displayName="SidebarMenuAction";const IC=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:L("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));IC.displayName="SidebarMenuBadge";const NC=h.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const o=h.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return l.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:L("rounded-md h-8 flex gap-2 px-2 items-center",e),...n,children:[t&&l.jsx(Sh,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),l.jsx(Sh,{className:"h-4 flex-1 max-w-[--skeleton-width]","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});NC.displayName="SidebarMenuSkeleton";const jC=h.forwardRef(({className:e,...t},n)=>l.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:L("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));jC.displayName="SidebarMenuSub";const AC=h.forwardRef(({...e},t)=>l.jsx("li",{ref:t,...e}));AC.displayName="SidebarMenuSubItem";const RC=h.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...o},s)=>{const i=e?It.Slot:"a";return l.jsx(i,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:L("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...o})});RC.displayName="SidebarMenuSubButton";function _C({header:e,sidebarTitle:t="Threads",showThreads:n=!0,className:r="",sidebarClassName:o="",chatClassName:s="",...i}){return l.jsx(kr,{...i,children:l.jsxs(Mh,{className:`w-full ${r}`,children:[l.jsxs(Dh,{className:`border-r ${o}`,children:[l.jsx(Fh,{children:l.jsx(Wh,{children:l.jsx(Vh,{children:l.jsx(Kh,{asChild:!0,size:"lg",children:l.jsx("span",{className:"font-semibold",children:t})})})})}),l.jsx(zh,{children:n&&l.jsxs(Bh,{children:[l.jsx(Hh,{children:"Conversations"}),l.jsx(Uh,{children:l.jsx("div",{className:"px-2 py-1",children:l.jsx(ws,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-[calc(100vh-12rem)]"})})})]})})]}),l.jsxs($h,{children:[l.jsxs("header",{className:"h-14 border-b bg-background/60 backdrop-blur flex items-center gap-2 px-4",children:[l.jsx(Lh,{}),l.jsx("div",{className:"flex-1"}),e]}),l.jsx("main",{className:`flex-1 min-h-0 overflow-hidden ${s}`,children:l.jsx(Gr,{})})]})]})})}var PC="Label",qh=h.forwardRef((e,t)=>l.jsx(Ce.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())}}));qh.displayName=PC;var Gh=qh;const OC=xr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Bt=h.forwardRef(({className:e,...t},n)=>l.jsx(Gh,{ref:n,className:L(OC(),e),...t}));Bt.displayName=Gh.displayName;function Yh(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 ks="Switch",[MC,ik]=Kt(ks),[DC,LC]=MC(ks),Xh=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:u,form:d,...f}=e,[p,m]=h.useState(null),w=Re(t,y=>m(y)),b=h.useRef(!1),g=p?d||!!p.closest("form"):!0,[x,v]=vn({prop:o,defaultProp:s??!1,onChange:u,caller:ks});return l.jsxs(DC,{scope:n,checked:x,disabled:a,children:[l.jsx(Ce.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":ep(x),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:w,onClick:te(e.onClick,y=>{v(E=>!E),g&&(b.current=y.isPropagationStopped(),b.current||y.stopPropagation())})}),g&&l.jsx(Qh,{control:p,bubbles:!b.current,name:r,value:c,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Xh.displayName=ks;var Jh="SwitchThumb",Zh=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=LC(Jh,n);return l.jsx(Ce.span,{"data-state":ep(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Zh.displayName=Jh;var $C="SwitchBubbleInput",Qh=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Re(i,s),c=Yh(n),u=Pd(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const w=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(w)}},[c,n,r]),l.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Qh.displayName=$C;function ep(e){return e?"checked":"unchecked"}var tp=Xh,FC=Zh;const kn=h.forwardRef(({className:e,...t},n)=>l.jsx(tp,{className:L("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:l.jsx(FC,{className:L("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")})}));kn.displayName=tp.displayName;var zC=[" ","Enter","ArrowUp","ArrowDown"],BC=[" ","Enter"],Un="Select",[Es,Is,HC]=qi(Un),[hr,ak]=Kt(Un,[HC,cr]),Ns=cr(),[UC,En]=hr(Un),[WC,VC]=hr(Un),np=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:p,required:m,form:w}=e,b=Ns(t),[g,x]=h.useState(null),[v,y]=h.useState(null),[E,S]=h.useState(!1),T=ts(u),[I,N]=vn({prop:r,defaultProp:o??!1,onChange:s,caller:Un}),[j,O]=vn({prop:i,defaultProp:a,onChange:c,caller:Un}),A=h.useRef(null),F=g?w||!!g.closest("form"):!0,[H,D]=h.useState(new Set),J=Array.from(H).map(K=>K.props.value).join(";");return l.jsx(la,{...b,children:l.jsxs(UC,{required:m,scope:t,trigger:g,onTriggerChange:x,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:E,onValueNodeHasChildrenChange:S,contentId:qt(),value:j,onValueChange:O,open:I,onOpenChange:N,dir:T,triggerPointerDownPosRef:A,disabled:p,children:[l.jsx(Es.Provider,{scope:t,children:l.jsx(WC,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(K=>{D(re=>new Set(re).add(K))},[]),onNativeOptionRemove:h.useCallback(K=>{D(re=>{const W=new Set(re);return W.delete(K),W})},[]),children:n})}),F?l.jsxs(Ep,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:K=>O(K.target.value),disabled:p,form:w,children:[j===void 0?l.jsx("option",{value:""}):null,Array.from(H)]},J):null]})})};np.displayName=Un;var rp="SelectTrigger",op=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Ns(n),i=En(rp,n),a=i.disabled||r,c=Re(t,i.onTriggerChange),u=Is(n),d=h.useRef("touch"),[f,p,m]=Np(b=>{const g=u().filter(y=>!y.disabled),x=g.find(y=>y.value===i.value),v=jp(g,b,x);v!==void 0&&i.onValueChange(v.value)}),w=b=>{a||(i.onOpenChange(!0),m()),b&&(i.triggerPointerDownPosRef.current={x:Math.round(b.pageX),y:Math.round(b.pageY)})};return l.jsx(ca,{asChild:!0,...s,children:l.jsx(Ce.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":Ip(i.value)?"":void 0,...o,ref:c,onClick:te(o.onClick,b=>{b.currentTarget.focus(),d.current!=="mouse"&&w(b)}),onPointerDown:te(o.onPointerDown,b=>{d.current=b.pointerType;const g=b.target;g.hasPointerCapture(b.pointerId)&&g.releasePointerCapture(b.pointerId),b.button===0&&b.ctrlKey===!1&&b.pointerType==="mouse"&&(w(b),b.preventDefault())}),onKeyDown:te(o.onKeyDown,b=>{const g=f.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&p(b.key),!(g&&b.key===" ")&&zC.includes(b.key)&&(w(),b.preventDefault())})})})});op.displayName=rp;var sp="SelectValue",ip=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,c=En(sp,n),{onValueNodeHasChildrenChange:u}=c,d=s!==void 0,f=Re(t,c.onValueNodeChange);return lt(()=>{u(d)},[u,d]),l.jsx(Ce.span,{...a,ref:f,style:{pointerEvents:"none"},children:Ip(c.value)?l.jsx(l.Fragment,{children:i}):s})});ip.displayName=sp;var KC="SelectIcon",ap=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return l.jsx(Ce.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});ap.displayName=KC;var qC="SelectPortal",lp=e=>l.jsx($o,{asChild:!0,...e});lp.displayName=qC;var Wn="SelectContent",cp=h.forwardRef((e,t)=>{const n=En(Wn,e.__scopeSelect),[r,o]=h.useState();if(lt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?eo.createPortal(l.jsx(up,{scope:e.__scopeSelect,children:l.jsx(Es.Slot,{scope:e.__scopeSelect,children:l.jsx("div",{children:e.children})})}),s):null}return l.jsx(dp,{...e,ref:t})});cp.displayName=Wn;var Jt=10,[up,In]=hr(Wn),GC="SelectContentImpl",YC=It.createSlot("SelectContent.RemoveScroll"),dp=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:w,hideWhenDetached:b,avoidCollisions:g,...x}=e,v=En(Wn,n),[y,E]=h.useState(null),[S,T]=h.useState(null),I=Re(t,z=>E(z)),[N,j]=h.useState(null),[O,A]=h.useState(null),F=Is(n),[H,D]=h.useState(!1),J=h.useRef(!1);h.useEffect(()=>{if(y)return Bi(y)},[y]),Mi();const K=h.useCallback(z=>{const[_,...Y]=F().map(ne=>ne.ref.current),[Q]=Y.slice(-1),de=document.activeElement;for(const ne of z)if(ne===de||(ne==null||ne.scrollIntoView({block:"nearest"}),ne===_&&S&&(S.scrollTop=0),ne===Q&&S&&(S.scrollTop=S.scrollHeight),ne==null||ne.focus(),document.activeElement!==de))return},[F,S]),re=h.useCallback(()=>K([N,y]),[K,N,y]);h.useEffect(()=>{H&&re()},[H,re]);const{onOpenChange:W,triggerPointerDownPosRef:M}=v;h.useEffect(()=>{if(y){let z={x:0,y:0};const _=Q=>{var de,ne;z={x:Math.abs(Math.round(Q.pageX)-(((de=M.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((ne=M.current)==null?void 0:ne.y)??0))}},Y=Q=>{z.x<=10&&z.y<=10?Q.preventDefault():y.contains(Q.target)||W(!1),document.removeEventListener("pointermove",_),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",_),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",Y,{capture:!0})}}},[y,W,M]),h.useEffect(()=>{const z=()=>W(!1);return window.addEventListener("blur",z),window.addEventListener("resize",z),()=>{window.removeEventListener("blur",z),window.removeEventListener("resize",z)}},[W]);const[X,Z]=Np(z=>{const _=F().filter(de=>!de.disabled),Y=_.find(de=>de.ref.current===document.activeElement),Q=jp(_,z,Y);Q&&setTimeout(()=>Q.ref.current.focus())}),pe=h.useCallback((z,_,Y)=>{const Q=!J.current&&!Y;(v.value!==void 0&&v.value===_||Q)&&(j(z),Q&&(J.current=!0))},[v.value]),$=h.useCallback(()=>y==null?void 0:y.focus(),[y]),G=h.useCallback((z,_,Y)=>{const Q=!J.current&&!Y;(v.value!==void 0&&v.value===_||Q)&&A(z)},[v.value]),ee=r==="popper"?Oa:fp,me=ee===Oa?{side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:w,hideWhenDetached:b,avoidCollisions:g}:{};return l.jsx(up,{scope:n,content:y,viewport:S,onViewportChange:T,itemRefCallback:pe,selectedItem:N,onItemLeave:$,itemTextRefCallback:G,focusSelectedItem:re,selectedItemText:O,position:r,isPositioned:H,searchRef:X,children:l.jsx(Wo,{as:YC,allowPinchZoom:!0,children:l.jsx(Lo,{asChild:!0,trapped:v.open,onMountAutoFocus:z=>{z.preventDefault()},onUnmountAutoFocus:te(o,z=>{var _;(_=v.trigger)==null||_.focus({preventScroll:!0}),z.preventDefault()}),children:l.jsx(Lr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:z=>z.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:l.jsx(ee,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:z=>z.preventDefault(),...x,...me,onPlaced:()=>D(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:te(x.onKeyDown,z=>{const _=z.ctrlKey||z.altKey||z.metaKey;if(z.key==="Tab"&&z.preventDefault(),!_&&z.key.length===1&&Z(z.key),["ArrowUp","ArrowDown","Home","End"].includes(z.key)){let Q=F().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(z.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(z.key)){const de=z.target,ne=Q.indexOf(de);Q=Q.slice(ne+1)}setTimeout(()=>K(Q)),z.preventDefault()}})})})})})})});dp.displayName=GC;var XC="SelectItemAlignedPosition",fp=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=En(Wn,n),i=In(Wn,n),[a,c]=h.useState(null),[u,d]=h.useState(null),f=Re(t,I=>d(I)),p=Is(n),m=h.useRef(!1),w=h.useRef(!0),{viewport:b,selectedItem:g,selectedItemText:x,focusSelectedItem:v}=i,y=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&b&&g&&x){const I=s.trigger.getBoundingClientRect(),N=u.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),O=x.getBoundingClientRect();if(s.dir!=="rtl"){const de=O.left-N.left,ne=j.left-de,_e=I.left-ne,Pe=I.width+_e,Ue=Math.max(Pe,N.width),Ee=window.innerWidth-Jt,Ae=Ca(ne,[Jt,Math.max(Jt,Ee-Ue)]);a.style.minWidth=Pe+"px",a.style.left=Ae+"px"}else{const de=N.right-O.right,ne=window.innerWidth-j.right-de,_e=window.innerWidth-I.right-ne,Pe=I.width+_e,Ue=Math.max(Pe,N.width),Ee=window.innerWidth-Jt,Ae=Ca(ne,[Jt,Math.max(Jt,Ee-Ue)]);a.style.minWidth=Pe+"px",a.style.right=Ae+"px"}const A=p(),F=window.innerHeight-Jt*2,H=b.scrollHeight,D=window.getComputedStyle(u),J=parseInt(D.borderTopWidth,10),K=parseInt(D.paddingTop,10),re=parseInt(D.borderBottomWidth,10),W=parseInt(D.paddingBottom,10),M=J+K+H+W+re,X=Math.min(g.offsetHeight*5,M),Z=window.getComputedStyle(b),pe=parseInt(Z.paddingTop,10),$=parseInt(Z.paddingBottom,10),G=I.top+I.height/2-Jt,ee=F-G,me=g.offsetHeight/2,z=g.offsetTop+me,_=J+K+z,Y=M-_;if(_<=G){const de=A.length>0&&g===A[A.length-1].ref.current;a.style.bottom="0px";const ne=u.clientHeight-b.offsetTop-b.offsetHeight,_e=Math.max(ee,me+(de?$:0)+ne+re),Pe=_+_e;a.style.height=Pe+"px"}else{const de=A.length>0&&g===A[0].ref.current;a.style.top="0px";const _e=Math.max(G,J+b.offsetTop+(de?pe:0)+me)+Y;a.style.height=_e+"px",b.scrollTop=_-G+b.offsetTop}a.style.margin=`${Jt}px 0`,a.style.minHeight=X+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>m.current=!0)}},[p,s.trigger,s.valueNode,a,u,b,g,x,s.dir,r]);lt(()=>y(),[y]);const[E,S]=h.useState();lt(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const T=h.useCallback(I=>{I&&w.current===!0&&(y(),v==null||v(),w.current=!1)},[y,v]);return l.jsx(ZC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:T,children:l.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:l.jsx(Ce.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});fp.displayName=XC;var JC="SelectPopperPosition",Oa=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Jt,...s}=e,i=Ns(n);return l.jsx(ua,{...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)"}})});Oa.displayName=JC;var[ZC,Ma]=hr(Wn,{}),Da="SelectViewport",hp=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=In(Da,n),i=Ma(Da,n),a=Re(t,s.onViewportChange),c=h.useRef(0);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(Es.Slot,{scope:n,children:l.jsx(Ce.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:te(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=i;if(p!=null&&p.current&&f){const m=Math.abs(c.current-d.scrollTop);if(m>0){const w=window.innerHeight-Jt*2,b=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(b,g);if(x<w){const v=x+m,y=Math.min(w,v),E=v-y;f.style.height=y+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});hp.displayName=Da;var pp="SelectGroup",[QC,eT]=hr(pp),tT=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=qt();return l.jsx(QC,{scope:n,id:o,children:l.jsx(Ce.div,{role:"group","aria-labelledby":o,...r,ref:t})})});tT.displayName=pp;var mp="SelectLabel",gp=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=eT(mp,n);return l.jsx(Ce.div,{id:o.id,...r,ref:t})});gp.displayName=mp;var js="SelectItem",[nT,xp]=hr(js),bp=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=En(js,n),c=In(js,n),u=a.value===r,[d,f]=h.useState(s??""),[p,m]=h.useState(!1),w=Re(t,v=>{var y;return(y=c.itemRefCallback)==null?void 0:y.call(c,v,r,o)}),b=qt(),g=h.useRef("touch"),x=()=>{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 l.jsx(nT,{scope:n,value:r,disabled:o,textId:b,isSelected:u,onItemTextChange:h.useCallback(v=>{f(y=>y||((v==null?void 0:v.textContent)??"").trim())},[]),children:l.jsx(Es.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:l.jsx(Ce.div,{role:"option","aria-labelledby":b,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:w,onFocus:te(i.onFocus,()=>m(!0)),onBlur:te(i.onBlur,()=>m(!1)),onClick:te(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:te(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:te(i.onPointerDown,v=>{g.current=v.pointerType}),onPointerMove:te(i.onPointerMove,v=>{var y;g.current=v.pointerType,o?(y=c.onItemLeave)==null||y.call(c):g.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:te(i.onPointerLeave,v=>{var y;v.currentTarget===document.activeElement&&((y=c.onItemLeave)==null||y.call(c))}),onKeyDown:te(i.onKeyDown,v=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&v.key===" "||(BC.includes(v.key)&&x(),v.key===" "&&v.preventDefault())})})})})});bp.displayName=js;var Jr="SelectItemText",vp=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=En(Jr,n),a=In(Jr,n),c=xp(Jr,n),u=VC(Jr,n),[d,f]=h.useState(null),p=Re(t,x=>f(x),c.onItemTextChange,x=>{var v;return(v=a.itemTextRefCallback)==null?void 0:v.call(a,x,c.value,c.disabled)}),m=d==null?void 0:d.textContent,w=h.useMemo(()=>l.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:b,onNativeOptionRemove:g}=u;return lt(()=>(b(w),()=>g(w)),[b,g,w]),l.jsxs(l.Fragment,{children:[l.jsx(Ce.span,{id:c.textId,...s,ref:p}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?eo.createPortal(s.children,i.valueNode):null]})});vp.displayName=Jr;var wp="SelectItemIndicator",yp=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return xp(wp,n).isSelected?l.jsx(Ce.span,{"aria-hidden":!0,...r,ref:t}):null});yp.displayName=wp;var La="SelectScrollUpButton",Sp=h.forwardRef((e,t)=>{const n=In(La,e.__scopeSelect),r=Ma(La,e.__scopeSelect),[o,s]=h.useState(!1),i=Re(t,r.onScrollButtonChange);return lt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollTop>0;s(u)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Tp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});Sp.displayName=La;var $a="SelectScrollDownButton",Cp=h.forwardRef((e,t)=>{const n=In($a,e.__scopeSelect),r=Ma($a,e.__scopeSelect),[o,s]=h.useState(!1),i=Re(t,r.onScrollButtonChange);return lt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Tp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});Cp.displayName=$a;var Tp=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=In("SelectScrollButton",n),i=h.useRef(null),a=Is(n),c=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>c(),[c]),lt(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),l.jsx(Ce.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:te(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:te(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:te(o.onPointerLeave,()=>{c()})})}),rT="SelectSeparator",kp=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return l.jsx(Ce.div,{"aria-hidden":!0,...r,ref:t})});kp.displayName=rT;var Fa="SelectArrow",oT=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ns(n),s=En(Fa,n),i=In(Fa,n);return s.open&&i.position==="popper"?l.jsx(da,{...o,...r,ref:t}):null});oT.displayName=Fa;var sT="SelectBubbleInput",Ep=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Re(r,o),i=Yh(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(Ce.select,{...n,style:{...Ch,...n.style},ref:s,defaultValue:t})});Ep.displayName=sT;function Ip(e){return e===""||e===void 0}function Np(e){const t=dt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function jp(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=iT(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function iT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var aT=np,Ap=op,lT=ip,cT=ap,uT=lp,Rp=cp,dT=hp,_p=gp,Pp=bp,fT=vp,hT=yp,Op=Sp,Mp=Cp,Dp=kp;const Lp=aT,$p=lT,za=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Ap,{ref:r,className:L("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,l.jsx(cT,{asChild:!0,children:l.jsx(oe.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));za.displayName=Ap.displayName;const Fp=h.forwardRef(({className:e,...t},n)=>l.jsx(Op,{ref:n,className:L("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(oe.ChevronUp,{className:"h-4 w-4"})}));Fp.displayName=Op.displayName;const zp=h.forwardRef(({className:e,...t},n)=>l.jsx(Mp,{ref:n,className:L("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(oe.ChevronDown,{className:"h-4 w-4"})}));zp.displayName=Mp.displayName;const Ba=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>l.jsx(uT,{children:l.jsxs(Rp,{ref:o,className:L("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:[l.jsx(Fp,{}),l.jsx(dT,{className:L("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx(zp,{})]})}));Ba.displayName=Rp.displayName;const pT=h.forwardRef(({className:e,...t},n)=>l.jsx(_p,{ref:n,className:L("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));pT.displayName=_p.displayName;const Vn=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Pp,{ref:r,className:L("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(hT,{children:l.jsx(oe.Check,{className:"h-4 w-4"})})}),l.jsx(fT,{children:t})]}));Vn.displayName=Pp.displayName;const mT=h.forwardRef(({className:e,...t},n)=>l.jsx(Dp,{ref:n,className:L("-mx-1 my-1 h-px bg-muted",e),...t}));mT.displayName=Dp.displayName;const As=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));As.displayName="Card";const Rs=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("flex flex-col space-y-1.5 p-6",e),...t}));Rs.displayName="CardHeader";const _s=h.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:L("text-2xl font-semibold leading-none tracking-tight",e),...t}));_s.displayName="CardTitle";const gT=h.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:L("text-sm text-muted-foreground",e),...t}));gT.displayName="CardDescription";const Ps=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("p-6 pt-0",e),...t}));Ps.displayName="CardContent";const xT=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("flex items-center p-6 pt-0",e),...t}));xT.displayName="CardFooter";const bT={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function vT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=C.useState(!1),[s,i]=C.useState(!1),[a,c]=C.useState(e),[u,d]=C.useState(!1),{toast:f}=Ai();C.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),C.useEffect(()=>{c(e)},[e]);const p=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},m=()=>{c(bT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{c(e),d(!1),o(!1)},b=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return l.jsxs(xh,{open:r,onOpenChange:o,children:[l.jsx(BS,{asChild:!0,children:l.jsxs(Be,{variant:"outline",size:"sm",className:n,children:[l.jsx(oe.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&l.jsx(Bc,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),l.jsxs(Aa,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[l.jsxs(vh,{children:[l.jsx(wh,{children:"Chat Settings"}),l.jsx(yh,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),l.jsxs("div",{className:"space-y-6 py-6",children:[l.jsxs(As,{children:[l.jsx(Rs,{className:"pb-3",children:l.jsxs(_s,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.Server,{className:"h-5 w-5"}),"API Configuration"]})}),l.jsxs(Ps,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Bt,{htmlFor:"api-url",children:"API Base URL"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Yr,{id:"api-url",value:a.api.baseUrl,onChange:g=>c(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),l.jsx(Be,{variant:"outline",onClick:b,children:"Test"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Bt,{htmlFor:"enable-auth",children:"Enable Authentication"}),l.jsx(kn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>c(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(Bt,{htmlFor:"auth-token",children:"Authentication Token"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Yr,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>c(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),l.jsx(Be,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?l.jsx(oe.EyeOff,{className:"h-4 w-4"}):l.jsx(oe.Eye,{className:"h-4 w-4"})})]})]})]})]}),l.jsxs(As,{children:[l.jsx(Rs,{className:"pb-3",children:l.jsxs(_s,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),l.jsxs(Ps,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Bt,{htmlFor:"layout",children:"Layout Style"}),l.jsxs(Lp,{value:a.ui.layout,onValueChange:g=>c(x=>({...x,ui:{...x.ui,layout:g}})),children:[l.jsx(za,{children:l.jsx($p,{})}),l.jsxs(Ba,{children:[l.jsx(Vn,{value:"sidebar",children:"Sidebar Layout"}),l.jsx(Vn,{value:"fullscreen",children:"Fullscreen"}),l.jsx(Vn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(Bt,{htmlFor:"theme",children:"Theme"}),l.jsxs(Lp,{value:a.ui.theme,onValueChange:g=>c(x=>({...x,ui:{...x.ui,theme:g}})),children:[l.jsx(za,{children:l.jsx($p,{})}),l.jsxs(Ba,{children:[l.jsx(Vn,{value:"light",children:"Light"}),l.jsx(Vn,{value:"dark",children:"Dark"}),l.jsx(Vn,{value:"system",children:"System"})]})]})]}),l.jsx(ja,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Bt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),l.jsx(kn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Bt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),l.jsx(kn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Bt,{htmlFor:"compact-messages",children:"Compact Messages"}),l.jsx(kn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),l.jsxs(As,{children:[l.jsx(Rs,{className:"pb-3",children:l.jsxs(_s,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),l.jsxs(Ps,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Bt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),l.jsx(kn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Bt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),l.jsx(kn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Bt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),l.jsx(kn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[l.jsxs(Be,{variant:"outline",onClick:m,children:[l.jsx(oe.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Be,{variant:"outline",onClick:w,children:"Cancel"}),l.jsxs(Be,{onClick:p,disabled:!u,children:[l.jsx(oe.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function wT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){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=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),c=C.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s.onThreadChange]);return e==="fullscreen"?l.jsx(kr,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsx(Gr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?l.jsx(kr,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&l.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(ws,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(Gr,{onError:s.onError,enableFileUpload:!0})})]})})}):l.jsx(kr,{...s,onThreadChange:c,children:l.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&l.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(ws,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(Gr,{onError:s.onError,enableFileUpload:!0})})]})})}be.Api=ho,be.ApiClient=ho,be.ChatApi=ho,be.ChatContextProvider=AS,be.ChatInterface=Gr,be.ChatMainLayout=_C,be.ChatProviderFull=kr,be.ChatRoutingProvider=IS,be.ChatSettings=vT,be.MarkdownContent=Oo,be.MessageComponent=od,be.MessageList=Ki,be.ThreadManager=ws,be.apiClient=cn,be.applySettings=DS,be.chatApiClient=cn,be.createChatClient=jS,be.default=wT,be.del=Dl,be.get=Nt,be.getChatToken=_l,be.getCurrentSettings=MS,be.getDefaultApiConfig=dh,be.getDefaultChatSettings=fh,be.onChatTokenChanged=Pl,be.post=Ol,be.put=Ml,be.setChatToken=Xs,be.useChatClient=RS,be.useChatFull=po,be.useChatRouting=NS,be.useChatStream=Ll,be.useMessagesReducer=$l,Object.defineProperties(be,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
138
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function bw(e,t=es){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function vw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),bw(t),xw(t)}function qi(e){const t=e+"CollectionProvider",[n,r]=Kt(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=b=>{const{scope:g,children:x}=b,v=C.useRef(null),y=C.useRef(new Map).current;return l.jsx(o,{scope:g,itemMap:y,collectionRef:v,children:x})};i.displayName=t;const a=e+"CollectionSlot",c=It.createSlot(a),u=C.forwardRef((b,g)=>{const{scope:x,children:v}=b,y=s(a,x),E=Re(g,y.collectionRef);return l.jsx(c,{ref:E,children:v})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",p=It.createSlot(d),m=C.forwardRef((b,g)=>{const{scope:x,children:v,...y}=b,E=C.useRef(null),S=Re(g,E),T=s(d,x);return C.useEffect(()=>(T.itemMap.set(E,{ref:E,...y}),()=>void T.itemMap.delete(E))),l.jsx(p,{[f]:"",ref:S,children:v})});m.displayName=d;function w(b){const g=s(e+"CollectionConsumer",b);return C.useCallback(()=>{const v=g.collectionRef.current;if(!v)return[];const y=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>y.indexOf(T.ref.current)-y.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},w,r]}var ww=h.createContext(void 0);function ts(e){const t=h.useContext(ww);return e||t||"ltr"}const yw=["top","right","bottom","left"],Cn=Math.min,Rt=Math.max,ns=Math.round,rs=Math.floor,rn=e=>({x:e,y:e}),Sw={left:"right",right:"left",bottom:"top",top:"bottom"},Cw={start:"end",end:"start"};function Gi(e,t,n){return Rt(e,Cn(t,n))}function dn(e,t){return typeof e=="function"?e(t):e}function fn(e){return e.split("-")[0]}function sr(e){return e.split("-")[1]}function Yi(e){return e==="x"?"y":"x"}function Xi(e){return e==="y"?"height":"width"}const Tw=new Set(["top","bottom"]);function on(e){return Tw.has(fn(e))?"y":"x"}function Ji(e){return Yi(on(e))}function kw(e,t,n){n===void 0&&(n=!1);const r=sr(e),o=Ji(e),s=Xi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=os(i)),[i,os(i)]}function Ew(e){const t=os(e);return[Zi(e),t,Zi(t)]}function Zi(e){return e.replace(/start|end/g,t=>Cw[t])}const dd=["left","right"],fd=["right","left"],Iw=["top","bottom"],Nw=["bottom","top"];function jw(e,t,n){switch(e){case"top":case"bottom":return n?t?fd:dd:t?dd:fd;case"left":case"right":return t?Iw:Nw;default:return[]}}function Aw(e,t,n,r){const o=sr(e);let s=jw(fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Zi)))),s}function os(e){return e.replace(/left|right|bottom|top/g,t=>Sw[t])}function Rw(e){return{top:0,right:0,bottom:0,left:0,...e}}function hd(e){return typeof e!="number"?Rw(e):{top:e,right:e,bottom:e,left:e}}function ss(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function pd(e,t,n){let{reference:r,floating:o}=e;const s=on(t),i=Ji(t),a=Xi(i),c=fn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let m;switch(c){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(sr(t)){case"start":m[i]-=p*(n&&u?-1:1);break;case"end":m[i]+=p*(n&&u?-1:1);break}return m}const _w=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=pd(u,r,c),p=r,m={},w=0;for(let b=0;b<a.length;b++){const{name:g,fn:x}=a[b],{x:v,y,data:E,reset:S}=await x({x:d,y:f,initialPlacement:r,placement:p,strategy:o,middlewareData:m,rects:u,platform:i,elements:{reference:e,floating:t}});d=v??d,f=y??f,m={...m,[g]:{...m[g],...E}},S&&w<=50&&(w++,typeof S=="object"&&(S.placement&&(p=S.placement),S.rects&&(u=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:f}=pd(u,p,c)),b=-1)}return{x:d,y:f,placement:p,strategy:o,middlewareData:m}};async function Fr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=dn(t,e),w=hd(m),g=a[p?f==="floating"?"reference":"floating":f],x=ss(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:c})),v=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},S=ss(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:y,strategy:c}):v);return{top:(x.top-S.top+w.top)/E.y,bottom:(S.bottom-x.bottom+w.bottom)/E.y,left:(x.left-S.left+w.left)/E.x,right:(S.right-x.right+w.right)/E.x}}const Pw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:u,padding:d=0}=dn(e,t)||{};if(u==null)return{};const f=hd(d),p={x:n,y:r},m=Ji(o),w=Xi(m),b=await i.getDimensions(u),g=m==="y",x=g?"top":"left",v=g?"bottom":"right",y=g?"clientHeight":"clientWidth",E=s.reference[w]+s.reference[m]-p[m]-s.floating[w],S=p[m]-s.reference[m],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[y]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[y]||s.floating[w]);const N=E/2-S/2,j=I/2-b[w]/2-1,O=Cn(f[x],j),A=Cn(f[v],j),F=O,H=I-b[w]-A,D=I/2-b[w]/2+N,J=Gi(F,D,H),K=!c.arrow&&sr(o)!=null&&D!==J&&s.reference[w]/2-(D<F?O:A)-b[w]/2<0,re=K?D<F?D-F:D-H:0;return{[m]:p[m]+re,data:{[m]:J,centerOffset:D-J-re,...K&&{alignmentOffset:re}},reset:K}}}),Ow=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:b=!0,...g}=dn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=fn(o),v=on(a),y=fn(a)===a,E=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=p||(y||!b?[os(a)]:Ew(a)),T=w!=="none";!p&&T&&S.push(...Aw(a,b,w,E));const I=[a,...S],N=await Fr(t,g),j=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(N[x]),f){const D=kw(o,i,E);j.push(N[D[0]],N[D[1]])}if(O=[...O,{placement:o,overflows:j}],!j.every(D=>D<=0)){var A,F;const D=(((A=s.flip)==null?void 0:A.index)||0)+1,J=I[D];if(J&&(!(f==="alignment"?v!==on(J):!1)||O.every(W=>on(W.placement)===v?W.overflows[0]>0:!0)))return{data:{index:D,overflows:O},reset:{placement:J}};let K=(F=O.filter(re=>re.overflows[0]<=0).sort((re,W)=>re.overflows[1]-W.overflows[1])[0])==null?void 0:F.placement;if(!K)switch(m){case"bestFit":{var H;const re=(H=O.filter(W=>{if(T){const M=on(W.placement);return M===v||M==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(M=>M>0).reduce((M,X)=>M+X,0)]).sort((W,M)=>W[1]-M[1])[0])==null?void 0:H[0];re&&(K=re);break}case"initialPlacement":K=a;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function md(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function gd(e){return yw.some(t=>e[t]>=0)}const Mw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=dn(e,t);switch(r){case"referenceHidden":{const s=await Fr(t,{...o,elementContext:"reference"}),i=md(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:gd(i)}}}case"escaped":{const s=await Fr(t,{...o,altBoundary:!0}),i=md(s,n.floating);return{data:{escapedOffsets:i,escaped:gd(i)}}}default:return{}}}}},xd=new Set(["left","top"]);async function Dw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=fn(n),a=sr(n),c=on(n)==="y",u=xd.has(i)?-1:1,d=s&&c?-1:1,f=dn(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(m=a==="end"?w*-1:w),c?{x:m*d,y:p*u}:{x:p*u,y:m*d}}const Lw=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,c=await Dw(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},$w=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x,y:v}=g;return{x,y:v}}},...c}=dn(e,t),u={x:n,y:r},d=await Fr(t,c),f=on(fn(o)),p=Yi(f);let m=u[p],w=u[f];if(s){const g=p==="y"?"top":"left",x=p==="y"?"bottom":"right",v=m+d[g],y=m-d[x];m=Gi(v,m,y)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",v=w+d[g],y=w-d[x];w=Gi(v,w,y)}const b=a.fn({...t,[p]:m,[f]:w});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[p]:s,[f]:i}}}}}},Fw=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:c=!0,crossAxis:u=!0}=dn(e,t),d={x:n,y:r},f=on(o),p=Yi(f);let m=d[p],w=d[f];const b=dn(a,t),g=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:0,crossAxis:0,...b};if(c){const y=p==="y"?"height":"width",E=s.reference[p]-s.floating[y]+g.mainAxis,S=s.reference[p]+s.reference[y]-g.mainAxis;m<E?m=E:m>S&&(m=S)}if(u){var x,v;const y=p==="y"?"width":"height",E=xd.has(fn(o)),S=s.reference[f]-s.floating[y]+(E&&((x=i.offset)==null?void 0:x[f])||0)+(E?0:g.crossAxis),T=s.reference[f]+s.reference[y]+(E?0:((v=i.offset)==null?void 0:v[f])||0)-(E?g.crossAxis:0);w<S?w=S:w>T&&(w=T)}return{[p]:m,[f]:w}}}},zw=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:c=()=>{},...u}=dn(e,t),d=await Fr(t,u),f=fn(o),p=sr(o),m=on(o)==="y",{width:w,height:b}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=p==="end"?"top":"bottom");const v=b-d.top-d.bottom,y=w-d.left-d.right,E=Cn(b-d[g],v),S=Cn(w-d[x],y),T=!t.middlewareData.shift;let I=E,N=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=v),T&&!p){const O=Rt(d.left,0),A=Rt(d.right,0),F=Rt(d.top,0),H=Rt(d.bottom,0);m?N=w-2*(O!==0||A!==0?O+A:Rt(d.left,d.right)):I=b-2*(F!==0||H!==0?F+H:Rt(d.top,d.bottom))}await c({...t,availableWidth:N,availableHeight:I});const j=await i.getDimensions(a.floating);return w!==j.width||b!==j.height?{reset:{rects:!0}}:{}}}};function is(){return typeof window<"u"}function ir(e){return bd(e)?(e.nodeName||"").toLowerCase():"#document"}function _t(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function sn(e){var t;return(t=(bd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function bd(e){return is()?e instanceof Node||e instanceof _t(e).Node:!1}function Yt(e){return is()?e instanceof Element||e instanceof _t(e).Element:!1}function an(e){return is()?e instanceof HTMLElement||e instanceof _t(e).HTMLElement:!1}function vd(e){return!is()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof _t(e).ShadowRoot}const Bw=new Set(["inline","contents"]);function zr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Xt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Bw.has(o)}const Hw=new Set(["table","td","th"]);function Uw(e){return Hw.has(ir(e))}const Ww=[":popover-open",":modal"];function as(e){return Ww.some(t=>{try{return e.matches(t)}catch{return!1}})}const Vw=["transform","translate","scale","rotate","perspective"],Kw=["transform","translate","scale","rotate","perspective","filter"],qw=["paint","layout","strict","content"];function Qi(e){const t=ea(),n=Yt(e)?Xt(e):e;return Vw.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Kw.some(r=>(n.willChange||"").includes(r))||qw.some(r=>(n.contain||"").includes(r))}function Gw(e){let t=Tn(e);for(;an(t)&&!ar(t);){if(Qi(t))return t;if(as(t))return null;t=Tn(t)}return null}function ea(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Yw=new Set(["html","body","#document"]);function ar(e){return Yw.has(ir(e))}function Xt(e){return _t(e).getComputedStyle(e)}function ls(e){return Yt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Tn(e){if(ir(e)==="html")return e;const t=e.assignedSlot||e.parentNode||vd(e)&&e.host||sn(e);return vd(t)?t.host:t}function wd(e){const t=Tn(e);return ar(t)?e.ownerDocument?e.ownerDocument.body:e.body:an(t)&&zr(t)?t:wd(t)}function Br(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=wd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=_t(o);if(s){const a=ta(i);return t.concat(i,i.visualViewport||[],zr(o)?o:[],a&&n?Br(a):[])}return t.concat(o,Br(o,[],n))}function ta(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function yd(e){const t=Xt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=an(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ns(n)!==s||ns(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function na(e){return Yt(e)?e:e.contextElement}function lr(e){const t=na(e);if(!an(t))return rn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=yd(t);let i=(s?ns(n.width):n.width)/r,a=(s?ns(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Xw=rn(0);function Sd(e){const t=_t(e);return!ea()||!t.visualViewport?Xw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Jw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==_t(e)?!1:t}function zn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=na(e);let i=rn(1);t&&(r?Yt(r)&&(i=lr(r)):i=lr(e));const a=Jw(s,n,r)?Sd(s):rn(0);let c=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const p=_t(s),m=r&&Yt(r)?_t(r):r;let w=p,b=ta(w);for(;b&&r&&m!==w;){const g=lr(b),x=b.getBoundingClientRect(),v=Xt(b),y=x.left+(b.clientLeft+parseFloat(v.paddingLeft))*g.x,E=x.top+(b.clientTop+parseFloat(v.paddingTop))*g.y;c*=g.x,u*=g.y,d*=g.x,f*=g.y,c+=y,u+=E,w=_t(b),b=ta(w)}}return ss({width:d,height:f,x:c,y:u})}function ra(e,t){const n=ls(e).scrollLeft;return t?t.left+n:zn(sn(e)).left+n}function Cd(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:ra(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function Zw(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=sn(r),a=t?as(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},u=rn(1);const d=rn(0),f=an(r);if((f||!f&&!s)&&((ir(r)!=="body"||zr(i))&&(c=ls(r)),an(r))){const m=zn(r);u=lr(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const p=i&&!f&&!s?Cd(i,c,!0):rn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-c.scrollTop*u.y+d.y+p.y}}function Qw(e){return Array.from(e.getClientRects())}function ey(e){const t=sn(e),n=ls(e),r=e.ownerDocument.body,o=Rt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Rt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ra(e);const a=-n.scrollTop;return Xt(r).direction==="rtl"&&(i+=Rt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function ty(e,t){const n=_t(e),r=sn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const u=ea();(!u||u&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:s,height:i,x:a,y:c}}const ny=new Set(["absolute","fixed"]);function ry(e,t){const n=zn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=an(e)?lr(e):rn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,u=r*s.y;return{width:i,height:a,x:c,y:u}}function Td(e,t,n){let r;if(t==="viewport")r=ty(e,n);else if(t==="document")r=ey(sn(e));else if(Yt(t))r=ry(t,n);else{const o=Sd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ss(r)}function kd(e,t){const n=Tn(e);return n===t||!Yt(n)||ar(n)?!1:Xt(n).position==="fixed"||kd(n,t)}function oy(e,t){const n=t.get(e);if(n)return n;let r=Br(e,[],!1).filter(a=>Yt(a)&&ir(a)!=="body"),o=null;const s=Xt(e).position==="fixed";let i=s?Tn(e):e;for(;Yt(i)&&!ar(i);){const a=Xt(i),c=Qi(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&ny.has(o.position)||zr(i)&&!c&&kd(e,i))?r=r.filter(d=>d!==i):o=a,i=Tn(i)}return t.set(e,r),r}function sy(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?as(t)?[]:oy(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((u,d)=>{const f=Td(t,d,o);return u.top=Rt(f.top,u.top),u.right=Cn(f.right,u.right),u.bottom=Cn(f.bottom,u.bottom),u.left=Rt(f.left,u.left),u},Td(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function iy(e){const{width:t,height:n}=yd(e);return{width:t,height:n}}function ay(e,t,n){const r=an(t),o=sn(t),s=n==="fixed",i=zn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=rn(0);function u(){c.x=ra(o)}if(r||!r&&!s)if((ir(t)!=="body"||zr(o))&&(a=ls(t)),r){const m=zn(t,!0,s,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?Cd(o,a):rn(0),f=i.left+a.scrollLeft-c.x-d.x,p=i.top+a.scrollTop-c.y-d.y;return{x:f,y:p,width:i.width,height:i.height}}function oa(e){return Xt(e).position==="static"}function Ed(e,t){if(!an(e)||Xt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return sn(e)===n&&(n=n.ownerDocument.body),n}function Id(e,t){const n=_t(e);if(as(e))return n;if(!an(e)){let o=Tn(e);for(;o&&!ar(o);){if(Yt(o)&&!oa(o))return o;o=Tn(o)}return n}let r=Ed(e,t);for(;r&&Uw(r)&&oa(r);)r=Ed(r,t);return r&&ar(r)&&oa(r)&&!Qi(r)?n:r||Gw(e)||n}const ly=async function(e){const t=this.getOffsetParent||Id,n=this.getDimensions,r=await n(e.floating);return{reference:ay(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function cy(e){return Xt(e).direction==="rtl"}const uy={convertOffsetParentRelativeRectToViewportRelativeRect:Zw,getDocumentElement:sn,getClippingRect:sy,getOffsetParent:Id,getElementRects:ly,getClientRects:Qw,getDimensions:iy,getScale:lr,isElement:Yt,isRTL:cy};function Nd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function dy(e,t){let n=null,r;const o=sn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:p,height:m}=u;if(a||t(),!p||!m)return;const w=rs(f),b=rs(o.clientWidth-(d+p)),g=rs(o.clientHeight-(f+m)),x=rs(d),y={rootMargin:-w+"px "+-b+"px "+-g+"px "+-x+"px",threshold:Rt(0,Cn(1,c))||1};let E=!0;function S(T){const I=T[0].intersectionRatio;if(I!==c){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Nd(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(S,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,y)}n.observe(e)}return i(!0),s}function fy(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=na(e),d=o||s?[...u?Br(u):[],...Br(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?dy(u,n):null;let p=-1,m=null;i&&(m=new ResizeObserver(x=>{let[v]=x;v&&v.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var y;(y=m)==null||y.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let w,b=c?zn(e):null;c&&g();function g(){const x=zn(e);b&&!Nd(b,x)&&n(),b=x,w=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(v=>{o&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,c&&cancelAnimationFrame(w)}}const hy=Lw,py=$w,my=Ow,gy=zw,xy=Mw,jd=Pw,by=Fw,vy=(e,t,n)=>{const r=new Map,o={platform:uy,...n},s={...o.platform,_c:r};return _w(e,t,{...o,platform:s})};var wy=typeof document<"u",yy=function(){},cs=wy?C.useLayoutEffect:yy;function us(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!us(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!us(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ad(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Rd(e,t){const n=Ad(e);return Math.round(t*n)/n}function sa(e){const t=h.useRef(e);return cs(()=>{t.current=e}),t}function Sy(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[d,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=h.useState(r);us(p,r)||m(r);const[w,b]=h.useState(null),[g,x]=h.useState(null),v=h.useCallback(W=>{W!==T.current&&(T.current=W,b(W))},[]),y=h.useCallback(W=>{W!==I.current&&(I.current=W,x(W))},[]),E=s||w,S=i||g,T=h.useRef(null),I=h.useRef(null),N=h.useRef(d),j=c!=null,O=sa(c),A=sa(o),F=sa(u),H=h.useCallback(()=>{if(!T.current||!I.current)return;const W={placement:t,strategy:n,middleware:p};A.current&&(W.platform=A.current),vy(T.current,I.current,W).then(M=>{const X={...M,isPositioned:F.current!==!1};D.current&&!us(N.current,X)&&(N.current=X,eo.flushSync(()=>{f(X)}))})},[p,t,n,A,F]);cs(()=>{u===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(W=>({...W,isPositioned:!1})))},[u]);const D=h.useRef(!1);cs(()=>(D.current=!0,()=>{D.current=!1}),[]),cs(()=>{if(E&&(T.current=E),S&&(I.current=S),E&&S){if(O.current)return O.current(E,S,H);H()}},[E,S,H,O,j]);const J=h.useMemo(()=>({reference:T,floating:I,setReference:v,setFloating:y}),[v,y]),K=h.useMemo(()=>({reference:E,floating:S}),[E,S]),re=h.useMemo(()=>{const W={position:n,left:0,top:0};if(!K.floating)return W;const M=Rd(K.floating,d.x),X=Rd(K.floating,d.y);return a?{...W,transform:"translate("+M+"px, "+X+"px)",...Ad(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:X}},[n,a,K.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:H,refs:J,elements:K,floatingStyles:re}),[d,H,J,K,re])}const Cy=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?jd({element:r.current,padding:o}).fn(n):{}:r?jd({element:r,padding:o}).fn(n):{}}}},Ty=(e,t)=>({...hy(e),options:[e,t]}),ky=(e,t)=>({...py(e),options:[e,t]}),Ey=(e,t)=>({...by(e),options:[e,t]}),Iy=(e,t)=>({...my(e),options:[e,t]}),Ny=(e,t)=>({...gy(e),options:[e,t]}),jy=(e,t)=>({...xy(e),options:[e,t]}),Ay=(e,t)=>({...Cy(e),options:[e,t]});var Ry="Arrow",_d=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return l.jsx(Ce.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});_d.displayName=Ry;var _y=_d;function Pd(e){const[t,n]=h.useState(void 0);return lt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ia="Popper",[Od,cr]=Kt(ia),[Py,Md]=Od(ia),Dd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return l.jsx(Py,{scope:t,anchor:r,onAnchorChange:o,children:n})};Dd.displayName=ia;var Ld="PopperAnchor",$d=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Md(Ld,n),i=h.useRef(null),a=Re(t,i),c=h.useRef(null);return h.useEffect(()=>{const u=c.current;c.current=(r==null?void 0:r.current)||i.current,u!==c.current&&s.onAnchorChange(c.current)}),r?null:l.jsx(Ce.div,{...o,ref:a})});$d.displayName=Ld;var aa="PopperContent",[Oy,My]=Od(aa),Fd=h.forwardRef((e,t)=>{var z,_,Y,Q,de,ne;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:w,...b}=e,g=Md(aa,n),[x,v]=h.useState(null),y=Re(t,_e=>v(_e)),[E,S]=h.useState(null),T=Pd(E),I=(T==null?void 0:T.width)??0,N=(T==null?void 0:T.height)??0,j=r+(s!=="center"?"-"+s:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},A=Array.isArray(u)?u:[u],F=A.length>0,H={padding:O,boundary:A.filter(Ly),altBoundary:F},{refs:D,floatingStyles:J,placement:K,isPositioned:re,middlewareData:W}=Sy({strategy:"fixed",placement:j,whileElementsMounted:(..._e)=>fy(..._e,{animationFrame:m==="always"}),elements:{reference:g.anchor},middleware:[Ty({mainAxis:o+N,alignmentAxis:i}),c&&ky({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Ey():void 0,...H}),c&&Iy({...H}),Ny({...H,apply:({elements:_e,rects:Pe,availableWidth:Ue,availableHeight:Ee})=>{const{width:Ae,height:Qe}=Pe.reference,qe=_e.floating.style;qe.setProperty("--radix-popper-available-width",`${Ue}px`),qe.setProperty("--radix-popper-available-height",`${Ee}px`),qe.setProperty("--radix-popper-anchor-width",`${Ae}px`),qe.setProperty("--radix-popper-anchor-height",`${Qe}px`)}}),E&&Ay({element:E,padding:a}),$y({arrowWidth:I,arrowHeight:N}),p&&jy({strategy:"referenceHidden",...H})]}),[M,X]=Hd(K),Z=dt(w);lt(()=>{re&&(Z==null||Z())},[re,Z]);const pe=(z=W.arrow)==null?void 0:z.x,$=(_=W.arrow)==null?void 0:_.y,G=((Y=W.arrow)==null?void 0:Y.centerOffset)!==0,[ee,me]=h.useState();return lt(()=>{x&&me(window.getComputedStyle(x).zIndex)},[x]),l.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:re?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[(Q=W.transformOrigin)==null?void 0:Q.x,(de=W.transformOrigin)==null?void 0:de.y].join(" "),...((ne=W.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(Oy,{scope:n,placedSide:M,onArrowChange:S,arrowX:pe,arrowY:$,shouldHideArrow:G,children:l.jsx(Ce.div,{"data-side":M,"data-align":X,...b,ref:y,style:{...b.style,animation:re?void 0:"none"}})})})});Fd.displayName=aa;var zd="PopperArrow",Dy={top:"bottom",right:"left",bottom:"top",left:"right"},Bd=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=My(zd,r),i=Dy[s.placedSide];return l.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:l.jsx(_y,{...o,ref:n,style:{...o.style,display:"block"}})})});Bd.displayName=zd;function Ly(e){return e!==null}var $y=e=>({name:"transformOrigin",options:e,fn(t){var g,x,v;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,d]=Hd(n),f={start:"0%",center:"50%",end:"100%"}[d],p=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,m=(((v=o.arrow)==null?void 0:v.y)??0)+c/2;let w="",b="";return u==="bottom"?(w=i?f:`${p}px`,b=`${-c}px`):u==="top"?(w=i?f:`${p}px`,b=`${r.floating.height+c}px`):u==="right"?(w=`${-c}px`,b=i?f:`${m}px`):u==="left"&&(w=`${r.floating.width+c}px`,b=i?f:`${m}px`),{data:{x:w,y:b}}}});function Hd(e){const[t,n="center"]=e.split("-");return[t,n]}var la=Dd,ca=$d,ua=Fd,da=Bd,fa="rovingFocusGroup.onEntryFocus",Fy={bubbles:!1,cancelable:!0},Hr="RovingFocusGroup",[ha,Ud,zy]=qi(Hr),[By,Wd]=Kt(Hr,[zy]),[Hy,Uy]=By(Hr),Vd=h.forwardRef((e,t)=>l.jsx(ha.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(ha.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Wy,{...e,ref:t})})}));Vd.displayName=Hr;var Wy=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,p=h.useRef(null),m=Re(t,p),w=ts(s),[b,g]=vn({prop:i,defaultProp:a??null,onChange:c,caller:Hr}),[x,v]=h.useState(!1),y=dt(u),E=Ud(n),S=h.useRef(!1),[T,I]=h.useState(0);return h.useEffect(()=>{const N=p.current;if(N)return N.addEventListener(fa,y),()=>N.removeEventListener(fa,y)},[y]),l.jsx(Hy,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:b,onItemFocus:h.useCallback(N=>g(N),[g]),onItemShiftTab:h.useCallback(()=>v(!0),[]),onFocusableItemAdd:h.useCallback(()=>I(N=>N+1),[]),onFocusableItemRemove:h.useCallback(()=>I(N=>N-1),[]),children:l.jsx(Ce.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:te(e.onMouseDown,()=>{S.current=!0}),onFocus:te(e.onFocus,N=>{const j=!S.current;if(N.target===N.currentTarget&&j&&!x){const O=new CustomEvent(fa,Fy);if(N.currentTarget.dispatchEvent(O),!O.defaultPrevented){const A=E().filter(K=>K.focusable),F=A.find(K=>K.active),H=A.find(K=>K.id===b),J=[F,H,...A].filter(Boolean).map(K=>K.ref.current);Gd(J,d)}}S.current=!1}),onBlur:te(e.onBlur,()=>v(!1))})})}),Kd="RovingFocusGroupItem",qd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=qt(),u=s||c,d=Uy(Kd,n),f=d.currentTabStopId===u,p=Ud(n),{onFocusableItemAdd:m,onFocusableItemRemove:w,currentTabStopId:b}=d;return h.useEffect(()=>{if(r)return m(),()=>w()},[r,m,w]),l.jsx(ha.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:l.jsx(Ce.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:te(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:te(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:te(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=qy(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let y=p().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")y.reverse();else if(x==="prev"||x==="next"){x==="prev"&&y.reverse();const E=y.indexOf(g.currentTarget);y=d.loop?Gy(y,E+1):y.slice(E+1)}setTimeout(()=>Gd(y))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:b!=null}):i})})});qd.displayName=Kd;var Vy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ky(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function qy(e,t,n){const r=Ky(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Vy[r]}function Gd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Gy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Yy=Vd,Xy=qd,pa=["Enter"," "],Jy=["ArrowDown","PageUp","Home"],Yd=["ArrowUp","PageDown","End"],Zy=[...Jy,...Yd],Qy={ltr:[...pa,"ArrowRight"],rtl:[...pa,"ArrowLeft"]},e0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ur="Menu",[Wr,t0,n0]=qi(Ur),[Bn,Xd]=Kt(Ur,[n0,cr,Wd]),ds=cr(),Jd=Wd(),[r0,Hn]=Bn(Ur),[o0,Vr]=Bn(Ur),Zd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ds(t),[c,u]=h.useState(null),d=h.useRef(!1),f=dt(s),p=ts(o);return h.useEffect(()=>{const m=()=>{d.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),l.jsx(la,{...a,children:l.jsx(r0,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:l.jsx(o0,{scope:t,onClose:h.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:i,children:r})})})};Zd.displayName=Ur;var s0="MenuAnchor",ma=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ds(n);return l.jsx(ca,{...o,...r,ref:t})});ma.displayName=s0;var ga="MenuPortal",[i0,Qd]=Bn(ga,{forceMount:void 0}),ef=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Hn(ga,t);return l.jsx(i0,{scope:t,forceMount:n,children:l.jsx(kt,{present:n||s.open,children:l.jsx($o,{asChild:!0,container:o,children:r})})})};ef.displayName=ga;var Ft="MenuContent",[a0,xa]=Bn(Ft),tf=h.forwardRef((e,t)=>{const n=Qd(Ft,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Hn(Ft,e.__scopeMenu),i=Vr(Ft,e.__scopeMenu);return l.jsx(Wr.Provider,{scope:e.__scopeMenu,children:l.jsx(kt,{present:r||s.open,children:l.jsx(Wr.Slot,{scope:e.__scopeMenu,children:i.modal?l.jsx(l0,{...o,ref:t}):l.jsx(c0,{...o,ref:t})})})})}),l0=h.forwardRef((e,t)=>{const n=Hn(Ft,e.__scopeMenu),r=h.useRef(null),o=Re(t,r);return h.useEffect(()=>{const s=r.current;if(s)return Bi(s)},[]),l.jsx(ba,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:te(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),c0=h.forwardRef((e,t)=>{const n=Hn(Ft,e.__scopeMenu);return l.jsx(ba,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),u0=It.createSlot("MenuContent.ScrollLock"),ba=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:w,...b}=e,g=Hn(Ft,n),x=Vr(Ft,n),v=ds(n),y=Jd(n),E=t0(n),[S,T]=h.useState(null),I=h.useRef(null),N=Re(t,I,g.onContentChange),j=h.useRef(0),O=h.useRef(""),A=h.useRef(0),F=h.useRef(null),H=h.useRef("right"),D=h.useRef(0),J=w?Wo:h.Fragment,K=w?{as:u0,allowPinchZoom:!0}:void 0,re=M=>{var z,_;const X=O.current+M,Z=E().filter(Y=>!Y.disabled),pe=document.activeElement,$=(z=Z.find(Y=>Y.ref.current===pe))==null?void 0:z.textValue,G=Z.map(Y=>Y.textValue),ee=S0(G,X,$),me=(_=Z.find(Y=>Y.textValue===ee))==null?void 0:_.ref.current;(function Y(Q){O.current=Q,window.clearTimeout(j.current),Q!==""&&(j.current=window.setTimeout(()=>Y(""),1e3))})(X),me&&setTimeout(()=>me.focus())};h.useEffect(()=>()=>window.clearTimeout(j.current),[]),Mi();const W=h.useCallback(M=>{var Z,pe;return H.current===((Z=F.current)==null?void 0:Z.side)&&T0(M,(pe=F.current)==null?void 0:pe.area)},[]);return l.jsx(a0,{scope:n,searchRef:O,onItemEnter:h.useCallback(M=>{W(M)&&M.preventDefault()},[W]),onItemLeave:h.useCallback(M=>{var X;W(M)||((X=I.current)==null||X.focus(),T(null))},[W]),onTriggerLeave:h.useCallback(M=>{W(M)&&M.preventDefault()},[W]),pointerGraceTimerRef:A,onPointerGraceIntentChange:h.useCallback(M=>{F.current=M},[]),children:l.jsx(J,{...K,children:l.jsx(Lo,{asChild:!0,trapped:o,onMountAutoFocus:te(s,M=>{var X;M.preventDefault(),(X=I.current)==null||X.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:l.jsx(Lr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:l.jsx(Yy,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:T,onEntryFocus:te(c,M=>{x.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:l.jsx(ua,{role:"menu","aria-orientation":"vertical","data-state":vf(g.open),"data-radix-menu-content":"",dir:x.dir,...v,...b,ref:N,style:{outline:"none",...b.style},onKeyDown:te(b.onKeyDown,M=>{const Z=M.target.closest("[data-radix-menu-content]")===M.currentTarget,pe=M.ctrlKey||M.altKey||M.metaKey,$=M.key.length===1;Z&&(M.key==="Tab"&&M.preventDefault(),!pe&&$&&re(M.key));const G=I.current;if(M.target!==G||!Zy.includes(M.key))return;M.preventDefault();const me=E().filter(z=>!z.disabled).map(z=>z.ref.current);Yd.includes(M.key)&&me.reverse(),w0(me)}),onBlur:te(e.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(j.current),O.current="")}),onPointerMove:te(e.onPointerMove,qr(M=>{const X=M.target,Z=D.current!==M.clientX;if(M.currentTarget.contains(X)&&Z){const pe=M.clientX>D.current?"right":"left";H.current=pe,D.current=M.clientX}}))})})})})})})});tf.displayName=Ft;var d0="MenuGroup",va=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Ce.div,{role:"group",...r,ref:t})});va.displayName=d0;var f0="MenuLabel",nf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Ce.div,{...r,ref:t})});nf.displayName=f0;var fs="MenuItem",rf="menu.itemSelect",hs=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=Vr(fs,e.__scopeMenu),a=xa(fs,e.__scopeMenu),c=Re(t,s),u=h.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const p=new CustomEvent(rf,{bubbles:!0,cancelable:!0});f.addEventListener(rf,m=>r==null?void 0:r(m),{once:!0}),Uc(f,p),p.defaultPrevented?u.current=!1:i.onClose()}};return l.jsx(of,{...o,ref:c,disabled:n,onClick:te(e.onClick,d),onPointerDown:f=>{var p;(p=e.onPointerDown)==null||p.call(e,f),u.current=!0},onPointerUp:te(e.onPointerUp,f=>{var p;u.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:te(e.onKeyDown,f=>{const p=a.searchRef.current!=="";n||p&&f.key===" "||pa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});hs.displayName=fs;var of=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=xa(fs,n),a=Jd(n),c=h.useRef(null),u=Re(t,c),[d,f]=h.useState(!1),[p,m]=h.useState("");return h.useEffect(()=>{const w=c.current;w&&m((w.textContent??"").trim())},[s.children]),l.jsx(Wr.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:l.jsx(Xy,{asChild:!0,...a,focusable:!r,children:l.jsx(Ce.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:te(e.onPointerMove,qr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:te(e.onPointerLeave,qr(w=>i.onItemLeave(w))),onFocus:te(e.onFocus,()=>f(!0)),onBlur:te(e.onBlur,()=>f(!1))})})})}),h0="MenuCheckboxItem",sf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return l.jsx(df,{scope:e.__scopeMenu,checked:n,children:l.jsx(hs,{role:"menuitemcheckbox","aria-checked":ps(n)?"mixed":n,...o,ref:t,"data-state":ya(n),onSelect:te(o.onSelect,()=>r==null?void 0:r(ps(n)?!0:!n),{checkForDefaultPrevented:!1})})})});sf.displayName=h0;var af="MenuRadioGroup",[p0,m0]=Bn(af,{value:void 0,onValueChange:()=>{}}),lf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=dt(r);return l.jsx(p0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:l.jsx(va,{...o,ref:t})})});lf.displayName=af;var cf="MenuRadioItem",uf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=m0(cf,e.__scopeMenu),s=n===o.value;return l.jsx(df,{scope:e.__scopeMenu,checked:s,children:l.jsx(hs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ya(s),onSelect:te(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});uf.displayName=cf;var wa="MenuItemIndicator",[df,g0]=Bn(wa,{checked:!1}),ff=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=g0(wa,n);return l.jsx(kt,{present:r||ps(s.checked)||s.checked===!0,children:l.jsx(Ce.span,{...o,ref:t,"data-state":ya(s.checked)})})});ff.displayName=wa;var x0="MenuSeparator",hf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Ce.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});hf.displayName=x0;var b0="MenuArrow",pf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ds(n);return l.jsx(da,{...o,...r,ref:t})});pf.displayName=b0;var v0="MenuSub",[tk,mf]=Bn(v0),Kr="MenuSubTrigger",gf=h.forwardRef((e,t)=>{const n=Hn(Kr,e.__scopeMenu),r=Vr(Kr,e.__scopeMenu),o=mf(Kr,e.__scopeMenu),s=xa(Kr,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,u={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),c(null)}},[a,c]),l.jsx(ma,{asChild:!0,...u,children:l.jsx(of,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":vf(n.open),...e,ref:Si(t,o.onTriggerChange),onClick:f=>{var p;(p=e.onClick)==null||p.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:te(e.onPointerMove,qr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:te(e.onPointerLeave,qr(f=>{var m,w;d();const p=(m=n.content)==null?void 0:m.getBoundingClientRect();if(p){const b=(w=n.content)==null?void 0:w.dataset.side,g=b==="right",x=g?-5:5,v=p[g?"left":"right"],y=p[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:v,y:p.top},{x:y,y:p.top},{x:y,y:p.bottom},{x:v,y:p.bottom}],side:b}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:te(e.onKeyDown,f=>{var m;const p=s.searchRef.current!=="";e.disabled||p&&f.key===" "||Qy[r.dir].includes(f.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),f.preventDefault())})})})});gf.displayName=Kr;var xf="MenuSubContent",bf=h.forwardRef((e,t)=>{const n=Qd(Ft,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Hn(Ft,e.__scopeMenu),i=Vr(Ft,e.__scopeMenu),a=mf(xf,e.__scopeMenu),c=h.useRef(null),u=Re(t,c);return l.jsx(Wr.Provider,{scope:e.__scopeMenu,children:l.jsx(kt,{present:r||s.open,children:l.jsx(Wr.Slot,{scope:e.__scopeMenu,children:l.jsx(ba,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:te(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:te(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:te(e.onKeyDown,d=>{var m;const f=d.currentTarget.contains(d.target),p=e0[i.dir].includes(d.key);f&&p&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),d.preventDefault())})})})})})});bf.displayName=xf;function vf(e){return e?"open":"closed"}function ps(e){return e==="indeterminate"}function ya(e){return ps(e)?"indeterminate":e?"checked":"unchecked"}function w0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function y0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function S0(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=y0(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function C0(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],c=t[i],u=a.x,d=a.y,f=c.x,p=c.y;d>r!=p>r&&n<(f-u)*(r-d)/(p-d)+u&&(o=!o)}return o}function T0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return C0(n,t)}function qr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var k0=Zd,E0=ma,I0=ef,N0=tf,j0=va,A0=nf,R0=hs,_0=sf,P0=lf,O0=uf,M0=ff,D0=hf,L0=pf,$0=gf,F0=bf,ms="DropdownMenu",[z0,nk]=Kt(ms,[Xd]),vt=Xd(),[B0,wf]=z0(ms),yf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=vt(t),u=h.useRef(null),[d,f]=vn({prop:o,defaultProp:s??!1,onChange:i,caller:ms});return l.jsx(B0,{scope:t,triggerId:qt(),triggerRef:u,contentId:qt(),open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(p=>!p),[f]),modal:a,children:l.jsx(k0,{...c,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};yf.displayName=ms;var Sf="DropdownMenuTrigger",Cf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=wf(Sf,n),i=vt(n);return l.jsx(E0,{asChild:!0,...i,children:l.jsx(Ce.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Si(t,s.triggerRef),onPointerDown:te(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:te(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Cf.displayName=Sf;var H0="DropdownMenuPortal",Tf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=vt(t);return l.jsx(I0,{...r,...n})};Tf.displayName=H0;var kf="DropdownMenuContent",Ef=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=wf(kf,n),s=vt(n),i=h.useRef(!1);return l.jsx(N0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:te(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:te(e.onInteractOutside,a=>{const c=a.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ef.displayName=kf;var U0="DropdownMenuGroup",W0=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(j0,{...o,...r,ref:t})});W0.displayName=U0;var V0="DropdownMenuLabel",If=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(A0,{...o,...r,ref:t})});If.displayName=V0;var K0="DropdownMenuItem",Nf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(R0,{...o,...r,ref:t})});Nf.displayName=K0;var q0="DropdownMenuCheckboxItem",jf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(_0,{...o,...r,ref:t})});jf.displayName=q0;var G0="DropdownMenuRadioGroup",Y0=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(P0,{...o,...r,ref:t})});Y0.displayName=G0;var X0="DropdownMenuRadioItem",Af=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(O0,{...o,...r,ref:t})});Af.displayName=X0;var J0="DropdownMenuItemIndicator",Rf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(M0,{...o,...r,ref:t})});Rf.displayName=J0;var Z0="DropdownMenuSeparator",_f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(D0,{...o,...r,ref:t})});_f.displayName=Z0;var Q0="DropdownMenuArrow",eS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(L0,{...o,...r,ref:t})});eS.displayName=Q0;var tS="DropdownMenuSubTrigger",Pf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx($0,{...o,...r,ref:t})});Pf.displayName=tS;var nS="DropdownMenuSubContent",Of=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(F0,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Of.displayName=nS;var rS=yf,oS=Cf,sS=Tf,Mf=Ef,Df=If,Lf=Nf,$f=jf,Ff=Af,zf=Rf,Bf=_f,Hf=Pf,Uf=Of;const iS=rS,aS=oS,lS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>l.jsxs(Hf,{ref:o,className:L("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,l.jsx(oe.ChevronRight,{className:"ml-auto h-4 w-4"})]}));lS.displayName=Hf.displayName;const cS=h.forwardRef(({className:e,...t},n)=>l.jsx(Uf,{ref:n,className:L("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));cS.displayName=Uf.displayName;const Wf=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(sS,{children:l.jsx(Mf,{ref:r,sideOffset:t,className:L("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Wf.displayName=Mf.displayName;const Sa=h.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Lf,{ref:r,className:L("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Sa.displayName=Lf.displayName;const uS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>l.jsxs($f,{ref:o,className:L("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(zf,{children:l.jsx(oe.Check,{className:"h-4 w-4"})})}),t]}));uS.displayName=$f.displayName;const dS=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Ff,{ref:r,className:L("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(zf,{children:l.jsx(oe.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));dS.displayName=Ff.displayName;const fS=h.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Df,{ref:r,className:L("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));fS.displayName=Df.displayName;const hS=h.forwardRef(({className:e,...t},n)=>l.jsx(Bf,{ref:n,className:L("-mx-1 my-1 h-px bg-muted",e),...t}));hS.displayName=Bf.displayName;function Gr({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:c=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:p,onError:m}){const{currentThreadId:w,messages:b,isStreaming:g,streamingAssistantId:x,error:v,send:y,stop:E,lastCheckpointId:S,lastCheckpointNs:T,listCheckpoints:I,navigateToCheckpoint:N,returnToLatest:j,hasMoreHistory:O,isLoadingHistory:A,loadOlderMessages:F,api:H}=po(),[D,J]=C.useState(null),[K,re]=C.useState(""),[W,M]=C.useState(null),[X,Z]=C.useState([]),[pe,$]=C.useState(!1),[G,ee]=C.useState(null),[me,z]=C.useState(null),[_,Y]=C.useState(!1),[Q,de]=C.useState(null),[ne,_e]=C.useState([]),[Pe,Ue]=C.useState(null),[Ee,Ae]=C.useState(null),[Qe,qe]=C.useState(!1),ct=C.useRef(null),ut=C.useRef(null),ve=C.useRef(null),[ze,Ge]=C.useState("desktop");C.useEffect(()=>{const ce=()=>{const fe=window.innerWidth;Ge(fe<640?"phone":fe<1024?"tablet":"desktop")};return ce(),window.addEventListener("resize",ce),()=>window.removeEventListener("resize",ce)},[]),C.useEffect(()=>{let ce=!1;if(!w){_e([]),Ue(null),Ae(null),ve.current=null;return}const fe={threadId:w,checkpointId:S??null,checkpointNs:T??null},$e=ve.current;if(!($e&&$e.threadId===fe.threadId&&$e.checkpointId===fe.checkpointId&&$e.checkpointNs===fe.checkpointNs))return I(w).then(et=>{var Os;if(ce)return;const jn=((et==null?void 0:et.checkpoints)??[]).slice().sort((pn,mr)=>new Date(mr.createdAt).getTime()-new Date(pn.createdAt).getTime());_e(jn);const Zr=Pe,pr=Zr&&jn.some(pn=>pn.checkpointId===Zr)?Zr:((Os=jn[0])==null?void 0:Os.checkpointId)??null;let Qr=null;if(pr){const pn=jn.find(mr=>mr.checkpointId===pr);Qr=(pn==null?void 0:pn.checkpointNs)??null}Ue(pr),Ae(Qr),ve.current=fe}).catch(et=>{console.error("ChatInterface - listCheckpoints error:",et),ce||(_e([]),ve.current=null)}),()=>{ce=!0}},[w,S,T,Pe,I]),C.useEffect(()=>{S&&(Ue(S),Ae(T??null))},[S,T]);const P=C.useCallback(async()=>{if(!(!O||A))try{await F()}catch(ce){console.warn("loadOlderMessages failed",ce)}},[O,A,F]);C.useEffect(()=>{(async()=>{try{const fe=await H.getAgent("default");de(fe.uiDefaultMessage||null)}catch(fe){console.warn("Failed to fetch default message:",fe),de(null)}})()},[H]),C.useEffect(()=>{v&&!_&&(m==null||m(v))},[v,_,m]);const U=ce=>{if(ce.length>es)return`Message too long (${ce.length}/${es} characters)`;try{return vw(ce),null}catch(fe){return(fe==null?void 0:fe.message)||"Invalid message"}},ue=ce=>{const fe=ce.content||[],$e=fe.filter(et=>et.type==="text").map(et=>et.text).join("");if($e)return $e;try{return JSON.stringify(fe,null,2)}catch{return String(fe)}},we=async ce=>{const fe=ce.trim();if(!(!fe&&X.length===0)){if(fe){const $e=U(fe);if($e){M($e);return}}try{await y(fe||"",{checkpointId:Pe??S??void 0,checkpointNs:Ee??T??void 0,payloadExtras:D?{edit:!0,originalMessageId:D}:void 0,attachments:X}),f==null||f(fe),M(null),Z([]),J(null),re("")}catch($e){const et=($e==null?void 0:$e.message)||"Failed to send message";M(et),m==null||m(et)}}},le=C.useCallback((ce,fe)=>{u&&(J(ce),re(fe),M(null))},[u]),Le=C.useCallback(()=>{J(null),re(""),M(null)},[]),at=C.useCallback((ce,fe)=>{le(ce,fe)},[le]),hn=C.useCallback(ce=>{for(let fe=ce-1;fe>=0;fe--)if(b[fe].role==="user"){const $e=ue(b[fe]);$e&&y($e,{checkpointId:Pe??S??void 0,checkpointNs:Ee??T??void 0});break}},[b,y,Pe,Ee,S,T,ue]),xt=ce=>{const fe=Array.from(ce.target.files||[]);Z($e=>[...$e,...fe])},Pt=ce=>Z(fe=>fe.filter(($e,et)=>ce!==et)),ft=async ce=>{const fe=(ce.target.files||[])[0];if(fe){ee(null),z(null),$(!0);try{await y("",{checkpointId:Pe??S??void 0,checkpointNs:Ee??T??void 0,attachments:[fe]});const $e=`Uploaded ${fe.name} - processing through chat stream`;z($e)}catch($e){const et=$e instanceof Error?$e.message:"Failed to upload Excel file";console.error("Excel upload failed",$e),ee(et),m==null||m(et)}finally{$(!1),ce.target.value=""}}},Ot=ce=>{if(!ce)return"Unknown";const fe=Date.parse(ce);return Number.isNaN(fe)?ce:new Date(fe).toLocaleString()},Nn=async ce=>{if(w){qe(!0);try{if(!ce){await j(),Ue(null),Ae(null);return}const fe=ne.find(et=>et.checkpointId===ce),$e=(fe==null?void 0:fe.checkpointNs)??null;await N(ce,$e),Ue(ce),Ae($e)}finally{qe(!1)}}},Kn=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,qn=`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 ${d.messagesArea||""}`,wt=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return l.jsxs("div",{className:Kn,children:[!!v&&!_&&l.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:[l.jsx("span",{children:v}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:()=>Y(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:l.jsx(oe.X,{size:16})})]}),w&&ne.length>0&&l.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[l.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),l.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:Pe??"",onChange:ce=>{const fe=ce.target.value||null;Nn(fe)},children:[l.jsx("option",{value:"",children:"Latest"}),ne.map(ce=>l.jsxs("option",{value:ce.checkpointId,children:[Ot(ce.createdAt),ce.preview?` — ${ce.preview.slice(0,40)}`:""]},ce.checkpointId))]})]}),l.jsx(Ki,{className:qn,style:r?{maxHeight:r}:void 0,messages:b,isStreaming:g,streamingAssistantId:x,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:ze,enableMessageEditing:u,editingMessageId:D,onStartReached:()=>{P()},onEdit:at,onRegenerate:hn,onCancelEdit:Le,emptyMessage:Q??void 0,isNavigatingCheckpoint:Qe}),l.jsxs("div",{className:wt,children:[D&&l.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(oe.Edit3,{size:16,className:"text-blue-600"}),l.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:Le,className:"text-blue-600 hover:bg-blue-100",children:l.jsx(oe.X,{size:16})})]})}),(a||c)&&l.jsxs("div",{className:"mb-3 space-y-3",children:[a&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:ct,type:"file",multiple:!0,onChange:ce=>xt(ce),className:"hidden"}),X.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2",children:X.map((ce,fe)=>l.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:[l.jsx(oe.Paperclip,{size:14}),l.jsx("span",{className:"truncate max-w-[150px]",children:ce.name}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:()=>Pt(fe),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${ce.name}`,children:l.jsx(oe.X,{size:12})})]},fe))})]}),c&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:ut,type:"file",accept:".xls,.xlsx,.xlsm",onChange:ft,className:"hidden"}),pe&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(oe.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),me&&!pe&&l.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:me}),G&&!pe&&l.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:G})]})]}),W&&l.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:W}),l.jsxs("div",{className:"flex items-end gap-2",children:[(a||c)&&l.jsxs(iS,{children:[l.jsx(aS,{asChild:!0,children:l.jsx(Be,{type:"button",size:"icon",variant:"outline",disabled:g,title:"More input actions",className:d.moreButton||"",children:l.jsx(oe.Plus,{size:16})})}),l.jsxs(Wf,{align:"start",sideOffset:6,className:"w-52",children:[a&&l.jsxs(Sa,{onClick:()=>{var ce;return(ce=ct.current)==null?void 0:ce.click()},className:"cursor-pointer",children:[l.jsx(oe.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),c&&l.jsxs(Sa,{onClick:()=>{var ce;pe||(ce=ut.current)==null||ce.click()},className:`cursor-pointer ${pe?"opacity-60 pointer-events-none":""}`,children:[l.jsx(oe.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),l.jsx("div",{className:"flex-1",children:l.jsx(Ag,{initialValue:K,editingMessageId:D,placeholder:D?"Edit your message...":t,isStreaming:g,disabled:!1,maxLength:es,onSend:we,onCancelEdit:Le,onStop:E,allowEmptySend:X.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${D?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${W?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Yr=h.forwardRef(({className:e,type:t,...n},r)=>l.jsx("input",{type:t,className:L("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}));Yr.displayName="Input";function Ca(e,[t,n]){return Math.min(n,Math.max(t,e))}function pS(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ta="ScrollArea",[Vf,rk]=Kt(Ta),[mS,zt]=Vf(Ta),Kf=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=h.useState(null),[u,d]=h.useState(null),[f,p]=h.useState(null),[m,w]=h.useState(null),[b,g]=h.useState(null),[x,v]=h.useState(0),[y,E]=h.useState(0),[S,T]=h.useState(!1),[I,N]=h.useState(!1),j=Re(t,A=>c(A)),O=ts(o);return l.jsx(mS,{scope:n,type:r,dir:O,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:p,scrollbarX:m,onScrollbarXChange:w,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:b,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:N,onCornerWidthChange:v,onCornerHeightChange:E,children:l.jsx(Ce.div,{dir:O,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});Kf.displayName=Ta;var qf="ScrollAreaViewport",Gf=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=zt(qf,n),a=h.useRef(null),c=Re(t,a,i.onViewportChange);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(Ce.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:l.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Gf.displayName=qf;var ln="ScrollAreaScrollbar",ka=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,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"?l.jsx(gS,{...r,ref:t,forceMount:n}):o.type==="scroll"?l.jsx(xS,{...r,ref:t,forceMount:n}):o.type==="auto"?l.jsx(Yf,{...r,ref:t,forceMount:n}):o.type==="always"?l.jsx(Ea,{...r,ref:t}):null});ka.displayName=ln;var gS=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},d=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),l.jsx(kt,{present:n||s,children:l.jsx(Yf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),xS=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,e.__scopeScrollArea),s=e.orientation==="horizontal",i=vs(()=>c("SCROLL_END"),100),[a,c]=pS("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 u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),h.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const p=()=>{const m=u[d];f!==m&&(c("SCROLL"),i()),f=m};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,s,c,i]),l.jsx(kt,{present:n||a!=="hidden",children:l.jsx(Ea,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:te(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:te(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Yf=h.forwardRef((e,t)=>{const n=zt(ln,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",c=vs(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return ur(n.viewport,c),ur(n.content,c),l.jsx(kt,{present:r||s,children:l.jsx(Ea,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ea=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=zt(ln,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,c]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=eh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function f(p,m){return CS(p,i.current,a,m)}return n==="horizontal"?l.jsx(bS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,m=th(p,a,o.dir);s.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=f(p,o.dir))}}):n==="vertical"?l.jsx(vS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,m=th(p,a);s.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=f(p))}}):null}),bS=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=zt(ln,e.__scopeScrollArea),[i,a]=h.useState(),c=h.useRef(null),u=Re(t,c,s.onScrollbarXChange);return h.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Jf,{"data-orientation":"horizontal",...o,ref:u,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":bs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const p=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(p),rh(p,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:xs(i.paddingLeft),paddingEnd:xs(i.paddingRight)}})}})}),vS=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=zt(ln,e.__scopeScrollArea),[i,a]=h.useState(),c=h.useRef(null),u=Re(t,c,s.onScrollbarYChange);return h.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Jf,{"data-orientation":"vertical",...o,ref:u,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":bs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const p=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(p),rh(p,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:xs(i.paddingTop),paddingEnd:xs(i.paddingBottom)}})}})}),[wS,Xf]=Vf(ln),Jf=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...p}=e,m=zt(ln,n),[w,b]=h.useState(null),g=Re(t,j=>b(j)),x=h.useRef(null),v=h.useRef(""),y=m.viewport,E=r.content-r.viewport,S=dt(d),T=dt(c),I=vs(f,10);function N(j){if(x.current){const O=j.clientX-x.current.left,A=j.clientY-x.current.top;u({x:O,y:A})}}return h.useEffect(()=>{const j=O=>{const A=O.target;(w==null?void 0:w.contains(A))&&S(O,E)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[y,w,E,S]),h.useEffect(T,[r,T]),ur(w,I),ur(m.content,I),l.jsx(wS,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:dt(s),onThumbPointerUp:dt(i),onThumbPositionChange:T,onThumbPointerDown:dt(a),children:l.jsx(Ce.div,{...p,ref:g,style:{position:"absolute",...p.style},onPointerDown:te(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),x.current=w.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),N(j))}),onPointerMove:te(e.onPointerMove,N),onPointerUp:te(e.onPointerUp,j=>{const O=j.target;O.hasPointerCapture(j.pointerId)&&O.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=v.current,m.viewport&&(m.viewport.style.scrollBehavior=""),x.current=null})})})}),gs="ScrollAreaThumb",Zf=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xf(gs,e.__scopeScrollArea);return l.jsx(kt,{present:n||o.hasThumb,children:l.jsx(yS,{ref:t,...r})})}),yS=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=zt(gs,n),i=Xf(gs,n),{onThumbPositionChange:a}=i,c=Re(t,f=>i.onThumbChange(f)),u=h.useRef(void 0),d=vs(()=>{u.current&&(u.current(),u.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const p=()=>{if(d(),!u.current){const m=TS(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[s.viewport,d,a]),l.jsx(Ce.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:te(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),w=f.clientX-m.left,b=f.clientY-m.top;i.onThumbPointerDown({x:w,y:b})}),onPointerUp:te(e.onPointerUp,i.onThumbPointerUp)})});Zf.displayName=gs;var Ia="ScrollAreaCorner",Qf=h.forwardRef((e,t)=>{const n=zt(Ia,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?l.jsx(SS,{...e,ref:t}):null});Qf.displayName=Ia;var SS=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=zt(Ia,n),[s,i]=h.useState(0),[a,c]=h.useState(0),u=!!(s&&a);return ur(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),ur(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?l.jsx(Ce.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 xs(e){return e?parseInt(e,10):0}function eh(e,t){const n=e/t;return isNaN(n)?0:n}function bs(e){const t=eh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function CS(e,t,n,r="ltr"){const o=bs(n),s=o/2,i=t||s,a=o-i,c=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return nh([c,u],f)(e)}function th(e,t,n="ltr"){const r=bs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,c=n==="ltr"?[0,i]:[i*-1,0],u=Ca(e,c);return nh([0,i],[0,a])(u)}function nh(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 rh(e,t){return e>0&&e<t}var TS=(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 vs(e,t){const n=dt(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 ur(e,t){const n=dt(t);lt(()=>{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 oh=Kf,kS=Gf,ES=Qf;const sh=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(oh,{ref:r,className:L("relative overflow-hidden",e),...n,children:[l.jsx(kS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),l.jsx(ih,{}),l.jsx(ES,{})]}));sh.displayName=oh.displayName;const ih=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(ka,{ref:r,orientation:t,className:L("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:l.jsx(Zf,{className:"relative flex-1 rounded-full bg-border"})}));ih.displayName=ka.displayName;function ws({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:c,onThreadCreate:u,onThreadDelete:d}){const{loadThread:f,threads:p,refreshThreads:m,currentThreadId:w,createThread:b,deleteThread:g,renameThread:x}=po(),[v,y]=C.useState(p??[]),[E,S]=C.useState(!1),[T,I]=C.useState(null),[N,j]=C.useState(null),[O,A]=C.useState(""),[F,H]=C.useState(!1);C.useEffect(()=>{y(p??[])},[p]);const D=async $=>{try{await f($),a==null||a($),c==null||c($)}catch(G){console.error("Failed to select thread:",G)}},J=async()=>{try{H(!0);const $=await b();u==null||u($),a==null||a($)}catch($){console.error("Failed to create thread:",$)}finally{H(!1)}},K=async($,G)=>{if(G.stopPropagation(),!!confirm("Delete this thread?"))try{await g($),d==null||d($)}catch(ee){console.error("Failed to delete thread:",ee)}},re=($,G)=>{G.stopPropagation(),j($.threadId),A($.title||`Thread ${$.threadId.slice(0,8)}`)},W=async $=>{if(O.trim())try{await x($,O.trim()),j(null),A("")}catch(G){console.error("Failed to update title:",G)}},M=()=>{j(null),A("")},X=($,G)=>{$.key==="Enter"?W(G):$.key==="Escape"&&M()},Z=$=>{if(!$)return"";try{const G=new Date($),me=new Date().getTime()-G.getTime(),z=Math.floor(me/(1e3*60*60*24));return z===0?G.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):z===1?"Yesterday":z<7?`${z} days ago`:G.toLocaleDateString()}catch{return""}},pe=$=>$.title||`Thread ${$.threadId.slice(0,8)}`;return l.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&l.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:l.jsx(Be,{onClick:J,disabled:F||E,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:F?"Creating...":"New Chat",children:l.jsx(oe.MessageSquarePlus,{size:20})})}),l.jsx(sh,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:l.jsx("div",{className:"p-2 space-y-1 pb-4",children:E?l.jsx("div",{className:"text-center py-8 text-slate-400",children:"Loading…"}):v.length===0?l.jsxs("div",{className:"text-center py-8 text-slate-400",children:[l.jsx(oe.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),l.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):v.slice().sort(($,G)=>new Date(G.updatedAt||G.createdAt||"").getTime()-new Date($.updatedAt||$.createdAt||"").getTime()).map($=>l.jsxs("div",{onClick:()=>D($.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??w)===$.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex-1 min-w-0",children:N===$.threadId?l.jsxs("div",{className:"flex items-center gap-2",onClick:G=>G.stopPropagation(),children:[l.jsx(Yr,{value:O,onChange:G=>A(G.target.value),onKeyDown:G=>X(G,$.threadId),className:"h-6 text-sm",autoFocus:!0}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:()=>W($.threadId),className:"h-6 w-6 p-0",children:l.jsx(oe.Check,{size:12})}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:M,className:"h-6 w-6 p-0",children:l.jsx(oe.X,{size:12})})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:pe($)}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[l.jsx(oe.Calendar,{size:10}),l.jsx("span",{children:Z($.updatedAt||$.createdAt)})]})]})}),l.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&N!==$.threadId&&l.jsx(Be,{variant:"ghost",size:"sm",onClick:G=>re($,G),className:"h-6 w-6 p-0",title:"Edit title",children:l.jsx(oe.Edit3,{size:12})}),n&&l.jsx(Be,{variant:"ghost",size:"sm",onClick:G=>K($.threadId,G),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:l.jsx(oe.Trash2,{size:12})})]})]}),i===$.threadId&&l.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},$.threadId))})})]})}const ah=C.createContext(null);function IS({children:e,basePath:t="/chat"}){const n=C.useMemo(()=>t?t==="/"?"":t.endsWith("/")?t.slice(0,-1):t:"/chat",[t]),r={basePath:n,buildThreadPath:o=>`${n}/${o}`,buildBasePath:()=>n};return l.jsx(ah.Provider,{value:r,children:e})}function NS(){const e=C.useContext(ah);return e||{basePath:"/chat",buildThreadPath:t=>`/chat/${t}`,buildBasePath:()=>"/chat"}}function jS(e){const t=e.apiBase.replace(/\/$/,""),n={...e.authToken?{Authorization:`Bearer ${e.authToken}`}:{},...e.headers??{}};let r=null,o=[];const s=i=>{i?n.Authorization=`Bearer ${i}`:delete n.Authorization};return{stream(i,a){const c=new AbortController;return(async()=>{var u,d;try{const f=await fetch(`${t}/runs/stream`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...n},body:JSON.stringify(i),signal:c.signal});(u=a.onOpen)==null||u.call(a,{threadId:f.headers.get("x-thread-id"),created:(f.headers.get("x-thread-created")||"").toLowerCase()==="true"})}catch(f){(f==null?void 0:f.name)!=="AbortError"&&((d=a.onError)==null||d.call(a,String((f==null?void 0:f.message)||f)))}})(),{close:()=>c.abort()}},getCurrentThreadId(){return r},setCurrentThreadId(i){r=i,i?localStorage.setItem("currentThreadId",i):localStorage.removeItem("currentThreadId")},getThreads(){return o},setThreads(i){o=i},async loadThreads(){try{const a=await(await fetch(`${t}/chat/threads`,{headers:n})).json();o=a.items||a||[]}catch(i){console.error("Failed to load threads:",i),o=[]}},async createThread(i){const c=await(await fetch(`${t}/chat/threads`,{method:"POST",headers:{"Content-Type":"application/json",...n},body:i?JSON.stringify({title:i}):void 0})).json();return await this.loadThreads(),this.setCurrentThreadId(c.threadId),c.threadId},async loadThread(i){this.setCurrentThreadId(i)},async deleteThread(i){await fetch(`${t}/chat/threads/${i}`,{method:"DELETE",headers:n}),await this.loadThreads(),r===i&&this.setCurrentThreadId(null)},async updateThreadTitle(i,a){await fetch(`${t}/chat/threads/${i}`,{method:"PUT",headers:{"Content-Type":"application/json",...n},body:JSON.stringify({title:a})}),await this.loadThreads()},async getMessages(i){const a=new URLSearchParams;return a.set("thread_id",i.threadId),i.checkpointId&&a.set("checkpoint_id",i.checkpointId),i.checkpointNs&&a.set("checkpoint_ns",i.checkpointNs),i.limit&&a.set("limit",i.limit.toString()),i.beforeId&&a.set("before_id",i.beforeId),await(await fetch(`${t}/chat/threads/${i.threadId}/messages?${a}`,{headers:n})).json()},async sendMessage(i,a){return new Promise((c,u)=>{var p;const d={messages:[{id:((p=crypto.randomUUID)==null?void 0:p.call(crypto))||`user-${Date.now()}`,role:"user",content:[{type:"text",text:i.trim()}],createdAt:new Date().toISOString()}]},f={threadId:(a==null?void 0:a.threadId)||"",payload:d,checkpointId:a==null?void 0:a.checkpointId,checkpointNs:a==null?void 0:a.checkpointNs,nodeFilter:a==null?void 0:a.nodeFilter,config:a==null?void 0:a.config};this.stream(f,{onOpen:m=>c(m),onError:m=>u(new Error(m))})})},async getMessageHistory(i){return this.getMessages(i)},updateAuthToken(i){s(i)}}}const lh=C.createContext(null);function AS({client:e,children:t}){return l.jsx(lh.Provider,{value:e,children:t})}function RS(){const e=C.useContext(lh);if(!e)throw new Error("ChatProvider missing");return e}function dr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function _S(e){if(typeof e!="string")return;const t=e.trim();if(t)return t.replace(/\/+$/g,"")}function ch(){const e=[dr("__API_BASE_URL__"),dr("__CHAT_API_BASE_URL__"),dr("__CHAT_API_URL__")];for(const t of e){const n=_S(t);if(n)return n}}function uh(){const e=[dr("__API_AUTH_TOKEN__"),dr("__CHAT_API_KEY__"),dr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function dh(){const e={},t=ch(),n=uh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function fh(){const e=dh(),t=cn.getAuthToken(),n=ch();return{apiBaseUrl:e.baseUrl||cn.baseUrl||n||"http://localhost:8000",apiKey:t||e.apiKey||uh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const hh="chat-settings";function PS(){try{const e=localStorage.getItem(hh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function OS(e){try{localStorage.setItem(hh,JSON.stringify(e)),e.apiKey&&cn.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function MS(){const e=fh(),t=PS(),n=cn.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:cn.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function DS(e){e.apiKey&&cn.setAuthToken(e.apiKey),OS(e)}const Na=768;function LS(){const[e,t]=h.useState(void 0);return h.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Na-1}px)`),r=()=>{t(window.innerWidth<Na)};return n.addEventListener("change",r),t(window.innerWidth<Na),()=>n.removeEventListener("change",r)},[]),!!e}var $S="Separator",ph="horizontal",FS=["horizontal","vertical"],mh=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=ph,...o}=e,s=zS(r)?r:ph,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return l.jsx(Ce.div,{"data-orientation":s,...a,...o,ref:t})});mh.displayName=$S;function zS(e){return FS.includes(e)}var gh=mh;const ja=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>l.jsx(gh,{ref:o,decorative:n,orientation:t,className:L("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ja.displayName=gh.displayName;const xh=Xu,BS=Zv,HS=Ju,bh=h.forwardRef(({className:e,...t},n)=>l.jsx(Yo,{className:L("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}));bh.displayName=Yo.displayName;const US=xr.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"}}),Aa=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>l.jsxs(HS,{children:[l.jsx(bh,{}),l.jsxs(Xo,{ref:o,className:L(US({side:e}),t),...r,children:[n,l.jsxs(Zu,{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:[l.jsx(oe.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Aa.displayName=Xo.displayName;const vh=({className:e,...t})=>l.jsx("div",{className:L("flex flex-col space-y-2 text-center sm:text-left",e),...t});vh.displayName="SheetHeader";const wh=h.forwardRef(({className:e,...t},n)=>l.jsx(Fn,{ref:n,className:L("text-lg font-semibold text-foreground",e),...t}));wh.displayName=Fn.displayName;const yh=h.forwardRef(({className:e,...t},n)=>l.jsx(Jo,{ref:n,className:L("text-sm text-muted-foreground",e),...t}));yh.displayName=Jo.displayName;function Sh({className:e,...t}){return l.jsx("div",{className:L("animate-pulse rounded-md bg-muted",e),...t})}var Ch=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"}),WS="VisuallyHidden",Th=h.forwardRef((e,t)=>l.jsx(Ce.span,{...e,ref:t,style:{...Ch,...e.style}}));Th.displayName=WS;var VS=Th,[ys,ok]=Kt("Tooltip",[cr]),Ss=cr(),kh="TooltipProvider",KS=700,Ra="tooltip.open",[qS,_a]=ys(kh),Eh=e=>{const{__scopeTooltip:t,delayDuration:n=KS,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),c=h.useRef(0);return h.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),l.jsx(qS,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(u=>{a.current=u},[]),disableHoverableContent:o,children:s})};Eh.displayName=kh;var Xr="Tooltip",[GS,Cs]=ys(Xr),Ih=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,c=_a(Xr,e.__scopeTooltip),u=Ss(t),[d,f]=h.useState(null),p=qt(),m=h.useRef(0),w=i??c.disableHoverableContent,b=a??c.delayDuration,g=h.useRef(!1),[x,v]=vn({prop:r,defaultProp:o??!1,onChange:I=>{I?(c.onOpen(),document.dispatchEvent(new CustomEvent(Ra))):c.onClose(),s==null||s(I)},caller:Xr}),y=h.useMemo(()=>x?g.current?"delayed-open":"instant-open":"closed",[x]),E=h.useCallback(()=>{window.clearTimeout(m.current),m.current=0,g.current=!1,v(!0)},[v]),S=h.useCallback(()=>{window.clearTimeout(m.current),m.current=0,v(!1)},[v]),T=h.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{g.current=!0,v(!0),m.current=0},b)},[b,v]);return h.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),l.jsx(la,{...u,children:l.jsx(GS,{scope:t,contentId:p,open:x,stateAttribute:y,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{c.isOpenDelayedRef.current?T():E()},[c.isOpenDelayedRef,T,E]),onTriggerLeave:h.useCallback(()=>{w?S():(window.clearTimeout(m.current),m.current=0)},[S,w]),onOpen:E,onClose:S,disableHoverableContent:w,children:n})})};Ih.displayName=Xr;var Pa="TooltipTrigger",Nh=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Cs(Pa,n),s=_a(Pa,n),i=Ss(n),a=h.useRef(null),c=Re(t,a,o.onTriggerChange),u=h.useRef(!1),d=h.useRef(!1),f=h.useCallback(()=>u.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),l.jsx(ca,{asChild:!0,...i,children:l.jsx(Ce.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:te(e.onPointerMove,p=>{p.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:te(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:te(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:te(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:te(e.onBlur,o.onClose),onClick:te(e.onClick,o.onClose)})})});Nh.displayName=Pa;var YS="TooltipPortal",[sk,XS]=ys(YS,{forceMount:void 0}),fr="TooltipContent",jh=h.forwardRef((e,t)=>{const n=XS(fr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=Cs(fr,e.__scopeTooltip);return l.jsx(kt,{present:r||i.open,children:i.disableHoverableContent?l.jsx(Ah,{side:o,...s,ref:t}):l.jsx(JS,{side:o,...s,ref:t})})}),JS=h.forwardRef((e,t)=>{const n=Cs(fr,e.__scopeTooltip),r=_a(fr,e.__scopeTooltip),o=h.useRef(null),s=Re(t,o),[i,a]=h.useState(null),{trigger:c,onClose:u}=n,d=o.current,{onPointerInTransitChange:f}=r,p=h.useCallback(()=>{a(null),f(!1)},[f]),m=h.useCallback((w,b)=>{const g=w.currentTarget,x={x:w.clientX,y:w.clientY},v=nC(x,g.getBoundingClientRect()),y=rC(x,v),E=oC(b.getBoundingClientRect()),S=iC([...y,...E]);a(S),f(!0)},[f]);return h.useEffect(()=>()=>p(),[p]),h.useEffect(()=>{if(c&&d){const w=g=>m(g,d),b=g=>m(g,c);return c.addEventListener("pointerleave",w),d.addEventListener("pointerleave",b),()=>{c.removeEventListener("pointerleave",w),d.removeEventListener("pointerleave",b)}}},[c,d,m,p]),h.useEffect(()=>{if(i){const w=b=>{const g=b.target,x={x:b.clientX,y:b.clientY},v=(c==null?void 0:c.contains(g))||(d==null?void 0:d.contains(g)),y=!sC(x,i);v?p():y&&(p(),u())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[c,d,i,u,p]),l.jsx(Ah,{...e,ref:s})}),[ZS,QS]=ys(Xr,{isInside:!1}),eC=It.createSlottable("TooltipContent"),Ah=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,c=Cs(fr,n),u=Ss(n),{onClose:d}=c;return h.useEffect(()=>(document.addEventListener(Ra,d),()=>document.removeEventListener(Ra,d)),[d]),h.useEffect(()=>{if(c.trigger){const f=p=>{const m=p.target;m!=null&&m.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),l.jsx(Lr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:l.jsxs(ua,{"data-state":c.stateAttribute,...u,...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:[l.jsx(eC,{children:r}),l.jsx(ZS,{scope:n,isInside:!0,children:l.jsx(VS,{id:c.contentId,role:"tooltip",children:o||r})})]})})});jh.displayName=fr;var Rh="TooltipArrow",tC=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Ss(n);return QS(Rh,n).isInside?null:l.jsx(da,{...o,...r,ref:t})});tC.displayName=Rh;function nC(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 rC(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 oC(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 sC(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],c=t[i],u=a.x,d=a.y,f=c.x,p=c.y;d>r!=p>r&&n<(f-u)*(r-d)/(p-d)+u&&(o=!o)}return o}function iC(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),aC(t)}function aC(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 lC=Eh,cC=Ih,uC=Nh,_h=jh;const dC=lC,fC=cC,hC=uC,Ph=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(_h,{ref:r,sideOffset:t,className:L("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}));Ph.displayName=_h.displayName;const pC="sidebar:state",mC=60*60*24*7,gC="16rem",xC="18rem",bC="3rem",vC="b",Oh=h.createContext(null);function Ts(){const e=h.useContext(Oh);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Mh=h.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:o,children:s,...i},a)=>{const c=LS(),[u,d]=h.useState(!1),[f,p]=h.useState(e),m=t??f,w=h.useCallback(v=>{const y=typeof v=="function"?v(m):v;n?n(y):p(y),document.cookie=`${pC}=${y}; path=/; max-age=${mC}`},[n,m]),b=h.useCallback(()=>c?d(v=>!v):w(v=>!v),[c,w,d]);h.useEffect(()=>{const v=y=>{y.key===vC&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),b())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[b]);const g=m?"expanded":"collapsed",x=h.useMemo(()=>({state:g,open:m,setOpen:w,isMobile:c,openMobile:u,setOpenMobile:d,toggleSidebar:b}),[g,m,w,c,u,d,b]);return l.jsx(Oh.Provider,{value:x,children:l.jsx(dC,{delayDuration:0,children:l.jsx("div",{style:{"--sidebar-width":gC,"--sidebar-width-icon":bC,...o},className:L("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:a,...i,children:s})})})});Mh.displayName="SidebarProvider";const Dh=h.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:o,...s},i)=>{const{isMobile:a,state:c,openMobile:u,setOpenMobile:d}=Ts();return n==="none"?l.jsx("div",{className:L("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...s,children:o}):a?l.jsx(xh,{open:u,onOpenChange:d,...s,children:l.jsx(Aa,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":xC},side:e,children:l.jsx("div",{className:"flex h-full w-full flex-col",children:o})})}):l.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":c,"data-collapsible":c==="collapsed"?n:"","data-variant":t,"data-side":e,children:[l.jsx("div",{className:L("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),l.jsx("div",{className:L("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:l.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:o})})]})});Dh.displayName="Sidebar";const Lh=h.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:o}=Ts();return l.jsxs(Be,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:L("h-7 w-7",e),onClick:s=>{t==null||t(s),o()},...n,children:[l.jsx(oe.PanelLeft,{}),l.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Lh.displayName="SidebarTrigger";const wC=h.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Ts();return l.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:L("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});wC.displayName="SidebarRail";const $h=h.forwardRef(({className:e,...t},n)=>l.jsx("main",{ref:n,className:L("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));$h.displayName="SidebarInset";const yC=h.forwardRef(({className:e,...t},n)=>l.jsx(Yr,{ref:n,"data-sidebar":"input",className:L("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));yC.displayName="SidebarInput";const Fh=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"header",className:L("flex flex-col gap-2 p-2",e),...t}));Fh.displayName="SidebarHeader";const SC=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"footer",className:L("flex flex-col gap-2 p-2",e),...t}));SC.displayName="SidebarFooter";const CC=h.forwardRef(({className:e,...t},n)=>l.jsx(ja,{ref:n,"data-sidebar":"separator",className:L("mx-2 w-auto bg-sidebar-border",e),...t}));CC.displayName="SidebarSeparator";const zh=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"content",className:L("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));zh.displayName="SidebarContent";const Bh=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"group",className:L("relative flex w-full min-w-0 flex-col p-2",e),...t}));Bh.displayName="SidebarGroup";const Hh=h.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?It.Slot:"div";return l.jsx(o,{ref:r,"data-sidebar":"group-label",className:L("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});Hh.displayName="SidebarGroupLabel";const TC=h.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?It.Slot:"button";return l.jsx(o,{ref:r,"data-sidebar":"group-action",className:L("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});TC.displayName="SidebarGroupAction";const Uh=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"group-content",className:L("w-full text-sm",e),...t}));Uh.displayName="SidebarGroupContent";const Wh=h.forwardRef(({className:e,...t},n)=>l.jsx("ul",{ref:n,"data-sidebar":"menu",className:L("flex w-full min-w-0 flex-col gap-1",e),...t}));Wh.displayName="SidebarMenu";const Vh=h.forwardRef(({className:e,...t},n)=>l.jsx("li",{ref:n,"data-sidebar":"menu-item",className:L("group/menu-item relative",e),...t}));Vh.displayName="SidebarMenuItem";const kC=xr.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),Kh=h.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:o,className:s,...i},a)=>{const c=e?It.Slot:"button",{isMobile:u,state:d}=Ts(),f=l.jsx(c,{ref:a,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:L(kC({variant:n,size:r}),s),...i});return o?(typeof o=="string"&&(o={children:o}),l.jsxs(fC,{children:[l.jsx(hC,{asChild:!0,children:f}),l.jsx(Ph,{side:"right",align:"center",hidden:d!=="collapsed"||u,...o})]})):f});Kh.displayName="SidebarMenuButton";const EC=h.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},o)=>{const s=t?It.Slot:"button";return l.jsx(s,{ref:o,"data-sidebar":"menu-action",className:L("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...r})});EC.displayName="SidebarMenuAction";const IC=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:L("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));IC.displayName="SidebarMenuBadge";const NC=h.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const o=h.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return l.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:L("rounded-md h-8 flex gap-2 px-2 items-center",e),...n,children:[t&&l.jsx(Sh,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),l.jsx(Sh,{className:"h-4 flex-1 max-w-[--skeleton-width]","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});NC.displayName="SidebarMenuSkeleton";const jC=h.forwardRef(({className:e,...t},n)=>l.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:L("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));jC.displayName="SidebarMenuSub";const AC=h.forwardRef(({...e},t)=>l.jsx("li",{ref:t,...e}));AC.displayName="SidebarMenuSubItem";const RC=h.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...o},s)=>{const i=e?It.Slot:"a";return l.jsx(i,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:L("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...o})});RC.displayName="SidebarMenuSubButton";function _C({header:e,sidebarTitle:t="Threads",showThreads:n=!0,className:r="",sidebarClassName:o="",chatClassName:s="",...i}){return l.jsx(kr,{...i,children:l.jsxs(Mh,{className:`w-full ${r}`,children:[l.jsxs(Dh,{className:`border-r ${o}`,children:[l.jsx(Fh,{children:l.jsx(Wh,{children:l.jsx(Vh,{children:l.jsx(Kh,{asChild:!0,size:"lg",children:l.jsx("span",{className:"font-semibold",children:t})})})})}),l.jsx(zh,{children:n&&l.jsxs(Bh,{children:[l.jsx(Hh,{children:"Conversations"}),l.jsx(Uh,{children:l.jsx("div",{className:"px-2 py-1",children:l.jsx(ws,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-[calc(100vh-12rem)]"})})})]})})]}),l.jsxs($h,{children:[l.jsxs("header",{className:"h-14 border-b bg-background/60 backdrop-blur flex items-center gap-2 px-4",children:[l.jsx(Lh,{}),l.jsx("div",{className:"flex-1"}),e]}),l.jsx("main",{className:`flex-1 min-h-0 overflow-hidden ${s}`,children:l.jsx(Gr,{})})]})]})})}var PC="Label",qh=h.forwardRef((e,t)=>l.jsx(Ce.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())}}));qh.displayName=PC;var Gh=qh;const OC=xr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Bt=h.forwardRef(({className:e,...t},n)=>l.jsx(Gh,{ref:n,className:L(OC(),e),...t}));Bt.displayName=Gh.displayName;function Yh(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 ks="Switch",[MC,ik]=Kt(ks),[DC,LC]=MC(ks),Xh=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:u,form:d,...f}=e,[p,m]=h.useState(null),w=Re(t,y=>m(y)),b=h.useRef(!1),g=p?d||!!p.closest("form"):!0,[x,v]=vn({prop:o,defaultProp:s??!1,onChange:u,caller:ks});return l.jsxs(DC,{scope:n,checked:x,disabled:a,children:[l.jsx(Ce.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":ep(x),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:w,onClick:te(e.onClick,y=>{v(E=>!E),g&&(b.current=y.isPropagationStopped(),b.current||y.stopPropagation())})}),g&&l.jsx(Qh,{control:p,bubbles:!b.current,name:r,value:c,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Xh.displayName=ks;var Jh="SwitchThumb",Zh=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=LC(Jh,n);return l.jsx(Ce.span,{"data-state":ep(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Zh.displayName=Jh;var $C="SwitchBubbleInput",Qh=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Re(i,s),c=Yh(n),u=Pd(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const w=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(w)}},[c,n,r]),l.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Qh.displayName=$C;function ep(e){return e?"checked":"unchecked"}var tp=Xh,FC=Zh;const kn=h.forwardRef(({className:e,...t},n)=>l.jsx(tp,{className:L("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:l.jsx(FC,{className:L("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")})}));kn.displayName=tp.displayName;var zC=[" ","Enter","ArrowUp","ArrowDown"],BC=[" ","Enter"],Un="Select",[Es,Is,HC]=qi(Un),[hr,ak]=Kt(Un,[HC,cr]),Ns=cr(),[UC,En]=hr(Un),[WC,VC]=hr(Un),np=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:p,required:m,form:w}=e,b=Ns(t),[g,x]=h.useState(null),[v,y]=h.useState(null),[E,S]=h.useState(!1),T=ts(u),[I,N]=vn({prop:r,defaultProp:o??!1,onChange:s,caller:Un}),[j,O]=vn({prop:i,defaultProp:a,onChange:c,caller:Un}),A=h.useRef(null),F=g?w||!!g.closest("form"):!0,[H,D]=h.useState(new Set),J=Array.from(H).map(K=>K.props.value).join(";");return l.jsx(la,{...b,children:l.jsxs(UC,{required:m,scope:t,trigger:g,onTriggerChange:x,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:E,onValueNodeHasChildrenChange:S,contentId:qt(),value:j,onValueChange:O,open:I,onOpenChange:N,dir:T,triggerPointerDownPosRef:A,disabled:p,children:[l.jsx(Es.Provider,{scope:t,children:l.jsx(WC,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(K=>{D(re=>new Set(re).add(K))},[]),onNativeOptionRemove:h.useCallback(K=>{D(re=>{const W=new Set(re);return W.delete(K),W})},[]),children:n})}),F?l.jsxs(Ep,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:K=>O(K.target.value),disabled:p,form:w,children:[j===void 0?l.jsx("option",{value:""}):null,Array.from(H)]},J):null]})})};np.displayName=Un;var rp="SelectTrigger",op=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Ns(n),i=En(rp,n),a=i.disabled||r,c=Re(t,i.onTriggerChange),u=Is(n),d=h.useRef("touch"),[f,p,m]=Np(b=>{const g=u().filter(y=>!y.disabled),x=g.find(y=>y.value===i.value),v=jp(g,b,x);v!==void 0&&i.onValueChange(v.value)}),w=b=>{a||(i.onOpenChange(!0),m()),b&&(i.triggerPointerDownPosRef.current={x:Math.round(b.pageX),y:Math.round(b.pageY)})};return l.jsx(ca,{asChild:!0,...s,children:l.jsx(Ce.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":Ip(i.value)?"":void 0,...o,ref:c,onClick:te(o.onClick,b=>{b.currentTarget.focus(),d.current!=="mouse"&&w(b)}),onPointerDown:te(o.onPointerDown,b=>{d.current=b.pointerType;const g=b.target;g.hasPointerCapture(b.pointerId)&&g.releasePointerCapture(b.pointerId),b.button===0&&b.ctrlKey===!1&&b.pointerType==="mouse"&&(w(b),b.preventDefault())}),onKeyDown:te(o.onKeyDown,b=>{const g=f.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&p(b.key),!(g&&b.key===" ")&&zC.includes(b.key)&&(w(),b.preventDefault())})})})});op.displayName=rp;var sp="SelectValue",ip=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,c=En(sp,n),{onValueNodeHasChildrenChange:u}=c,d=s!==void 0,f=Re(t,c.onValueNodeChange);return lt(()=>{u(d)},[u,d]),l.jsx(Ce.span,{...a,ref:f,style:{pointerEvents:"none"},children:Ip(c.value)?l.jsx(l.Fragment,{children:i}):s})});ip.displayName=sp;var KC="SelectIcon",ap=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return l.jsx(Ce.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});ap.displayName=KC;var qC="SelectPortal",lp=e=>l.jsx($o,{asChild:!0,...e});lp.displayName=qC;var Wn="SelectContent",cp=h.forwardRef((e,t)=>{const n=En(Wn,e.__scopeSelect),[r,o]=h.useState();if(lt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?eo.createPortal(l.jsx(up,{scope:e.__scopeSelect,children:l.jsx(Es.Slot,{scope:e.__scopeSelect,children:l.jsx("div",{children:e.children})})}),s):null}return l.jsx(dp,{...e,ref:t})});cp.displayName=Wn;var Jt=10,[up,In]=hr(Wn),GC="SelectContentImpl",YC=It.createSlot("SelectContent.RemoveScroll"),dp=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:w,hideWhenDetached:b,avoidCollisions:g,...x}=e,v=En(Wn,n),[y,E]=h.useState(null),[S,T]=h.useState(null),I=Re(t,z=>E(z)),[N,j]=h.useState(null),[O,A]=h.useState(null),F=Is(n),[H,D]=h.useState(!1),J=h.useRef(!1);h.useEffect(()=>{if(y)return Bi(y)},[y]),Mi();const K=h.useCallback(z=>{const[_,...Y]=F().map(ne=>ne.ref.current),[Q]=Y.slice(-1),de=document.activeElement;for(const ne of z)if(ne===de||(ne==null||ne.scrollIntoView({block:"nearest"}),ne===_&&S&&(S.scrollTop=0),ne===Q&&S&&(S.scrollTop=S.scrollHeight),ne==null||ne.focus(),document.activeElement!==de))return},[F,S]),re=h.useCallback(()=>K([N,y]),[K,N,y]);h.useEffect(()=>{H&&re()},[H,re]);const{onOpenChange:W,triggerPointerDownPosRef:M}=v;h.useEffect(()=>{if(y){let z={x:0,y:0};const _=Q=>{var de,ne;z={x:Math.abs(Math.round(Q.pageX)-(((de=M.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((ne=M.current)==null?void 0:ne.y)??0))}},Y=Q=>{z.x<=10&&z.y<=10?Q.preventDefault():y.contains(Q.target)||W(!1),document.removeEventListener("pointermove",_),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",_),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",Y,{capture:!0})}}},[y,W,M]),h.useEffect(()=>{const z=()=>W(!1);return window.addEventListener("blur",z),window.addEventListener("resize",z),()=>{window.removeEventListener("blur",z),window.removeEventListener("resize",z)}},[W]);const[X,Z]=Np(z=>{const _=F().filter(de=>!de.disabled),Y=_.find(de=>de.ref.current===document.activeElement),Q=jp(_,z,Y);Q&&setTimeout(()=>Q.ref.current.focus())}),pe=h.useCallback((z,_,Y)=>{const Q=!J.current&&!Y;(v.value!==void 0&&v.value===_||Q)&&(j(z),Q&&(J.current=!0))},[v.value]),$=h.useCallback(()=>y==null?void 0:y.focus(),[y]),G=h.useCallback((z,_,Y)=>{const Q=!J.current&&!Y;(v.value!==void 0&&v.value===_||Q)&&A(z)},[v.value]),ee=r==="popper"?Oa:fp,me=ee===Oa?{side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:w,hideWhenDetached:b,avoidCollisions:g}:{};return l.jsx(up,{scope:n,content:y,viewport:S,onViewportChange:T,itemRefCallback:pe,selectedItem:N,onItemLeave:$,itemTextRefCallback:G,focusSelectedItem:re,selectedItemText:O,position:r,isPositioned:H,searchRef:X,children:l.jsx(Wo,{as:YC,allowPinchZoom:!0,children:l.jsx(Lo,{asChild:!0,trapped:v.open,onMountAutoFocus:z=>{z.preventDefault()},onUnmountAutoFocus:te(o,z=>{var _;(_=v.trigger)==null||_.focus({preventScroll:!0}),z.preventDefault()}),children:l.jsx(Lr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:z=>z.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:l.jsx(ee,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:z=>z.preventDefault(),...x,...me,onPlaced:()=>D(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:te(x.onKeyDown,z=>{const _=z.ctrlKey||z.altKey||z.metaKey;if(z.key==="Tab"&&z.preventDefault(),!_&&z.key.length===1&&Z(z.key),["ArrowUp","ArrowDown","Home","End"].includes(z.key)){let Q=F().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(z.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(z.key)){const de=z.target,ne=Q.indexOf(de);Q=Q.slice(ne+1)}setTimeout(()=>K(Q)),z.preventDefault()}})})})})})})});dp.displayName=GC;var XC="SelectItemAlignedPosition",fp=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=En(Wn,n),i=In(Wn,n),[a,c]=h.useState(null),[u,d]=h.useState(null),f=Re(t,I=>d(I)),p=Is(n),m=h.useRef(!1),w=h.useRef(!0),{viewport:b,selectedItem:g,selectedItemText:x,focusSelectedItem:v}=i,y=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&b&&g&&x){const I=s.trigger.getBoundingClientRect(),N=u.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),O=x.getBoundingClientRect();if(s.dir!=="rtl"){const de=O.left-N.left,ne=j.left-de,_e=I.left-ne,Pe=I.width+_e,Ue=Math.max(Pe,N.width),Ee=window.innerWidth-Jt,Ae=Ca(ne,[Jt,Math.max(Jt,Ee-Ue)]);a.style.minWidth=Pe+"px",a.style.left=Ae+"px"}else{const de=N.right-O.right,ne=window.innerWidth-j.right-de,_e=window.innerWidth-I.right-ne,Pe=I.width+_e,Ue=Math.max(Pe,N.width),Ee=window.innerWidth-Jt,Ae=Ca(ne,[Jt,Math.max(Jt,Ee-Ue)]);a.style.minWidth=Pe+"px",a.style.right=Ae+"px"}const A=p(),F=window.innerHeight-Jt*2,H=b.scrollHeight,D=window.getComputedStyle(u),J=parseInt(D.borderTopWidth,10),K=parseInt(D.paddingTop,10),re=parseInt(D.borderBottomWidth,10),W=parseInt(D.paddingBottom,10),M=J+K+H+W+re,X=Math.min(g.offsetHeight*5,M),Z=window.getComputedStyle(b),pe=parseInt(Z.paddingTop,10),$=parseInt(Z.paddingBottom,10),G=I.top+I.height/2-Jt,ee=F-G,me=g.offsetHeight/2,z=g.offsetTop+me,_=J+K+z,Y=M-_;if(_<=G){const de=A.length>0&&g===A[A.length-1].ref.current;a.style.bottom="0px";const ne=u.clientHeight-b.offsetTop-b.offsetHeight,_e=Math.max(ee,me+(de?$:0)+ne+re),Pe=_+_e;a.style.height=Pe+"px"}else{const de=A.length>0&&g===A[0].ref.current;a.style.top="0px";const _e=Math.max(G,J+b.offsetTop+(de?pe:0)+me)+Y;a.style.height=_e+"px",b.scrollTop=_-G+b.offsetTop}a.style.margin=`${Jt}px 0`,a.style.minHeight=X+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>m.current=!0)}},[p,s.trigger,s.valueNode,a,u,b,g,x,s.dir,r]);lt(()=>y(),[y]);const[E,S]=h.useState();lt(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const T=h.useCallback(I=>{I&&w.current===!0&&(y(),v==null||v(),w.current=!1)},[y,v]);return l.jsx(ZC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:T,children:l.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:l.jsx(Ce.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});fp.displayName=XC;var JC="SelectPopperPosition",Oa=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Jt,...s}=e,i=Ns(n);return l.jsx(ua,{...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)"}})});Oa.displayName=JC;var[ZC,Ma]=hr(Wn,{}),Da="SelectViewport",hp=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=In(Da,n),i=Ma(Da,n),a=Re(t,s.onViewportChange),c=h.useRef(0);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(Es.Slot,{scope:n,children:l.jsx(Ce.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:te(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=i;if(p!=null&&p.current&&f){const m=Math.abs(c.current-d.scrollTop);if(m>0){const w=window.innerHeight-Jt*2,b=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(b,g);if(x<w){const v=x+m,y=Math.min(w,v),E=v-y;f.style.height=y+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});hp.displayName=Da;var pp="SelectGroup",[QC,eT]=hr(pp),tT=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=qt();return l.jsx(QC,{scope:n,id:o,children:l.jsx(Ce.div,{role:"group","aria-labelledby":o,...r,ref:t})})});tT.displayName=pp;var mp="SelectLabel",gp=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=eT(mp,n);return l.jsx(Ce.div,{id:o.id,...r,ref:t})});gp.displayName=mp;var js="SelectItem",[nT,xp]=hr(js),bp=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=En(js,n),c=In(js,n),u=a.value===r,[d,f]=h.useState(s??""),[p,m]=h.useState(!1),w=Re(t,v=>{var y;return(y=c.itemRefCallback)==null?void 0:y.call(c,v,r,o)}),b=qt(),g=h.useRef("touch"),x=()=>{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 l.jsx(nT,{scope:n,value:r,disabled:o,textId:b,isSelected:u,onItemTextChange:h.useCallback(v=>{f(y=>y||((v==null?void 0:v.textContent)??"").trim())},[]),children:l.jsx(Es.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:l.jsx(Ce.div,{role:"option","aria-labelledby":b,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:w,onFocus:te(i.onFocus,()=>m(!0)),onBlur:te(i.onBlur,()=>m(!1)),onClick:te(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:te(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:te(i.onPointerDown,v=>{g.current=v.pointerType}),onPointerMove:te(i.onPointerMove,v=>{var y;g.current=v.pointerType,o?(y=c.onItemLeave)==null||y.call(c):g.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:te(i.onPointerLeave,v=>{var y;v.currentTarget===document.activeElement&&((y=c.onItemLeave)==null||y.call(c))}),onKeyDown:te(i.onKeyDown,v=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&v.key===" "||(BC.includes(v.key)&&x(),v.key===" "&&v.preventDefault())})})})})});bp.displayName=js;var Jr="SelectItemText",vp=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=En(Jr,n),a=In(Jr,n),c=xp(Jr,n),u=VC(Jr,n),[d,f]=h.useState(null),p=Re(t,x=>f(x),c.onItemTextChange,x=>{var v;return(v=a.itemTextRefCallback)==null?void 0:v.call(a,x,c.value,c.disabled)}),m=d==null?void 0:d.textContent,w=h.useMemo(()=>l.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:b,onNativeOptionRemove:g}=u;return lt(()=>(b(w),()=>g(w)),[b,g,w]),l.jsxs(l.Fragment,{children:[l.jsx(Ce.span,{id:c.textId,...s,ref:p}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?eo.createPortal(s.children,i.valueNode):null]})});vp.displayName=Jr;var wp="SelectItemIndicator",yp=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return xp(wp,n).isSelected?l.jsx(Ce.span,{"aria-hidden":!0,...r,ref:t}):null});yp.displayName=wp;var La="SelectScrollUpButton",Sp=h.forwardRef((e,t)=>{const n=In(La,e.__scopeSelect),r=Ma(La,e.__scopeSelect),[o,s]=h.useState(!1),i=Re(t,r.onScrollButtonChange);return lt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollTop>0;s(u)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Tp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});Sp.displayName=La;var $a="SelectScrollDownButton",Cp=h.forwardRef((e,t)=>{const n=In($a,e.__scopeSelect),r=Ma($a,e.__scopeSelect),[o,s]=h.useState(!1),i=Re(t,r.onScrollButtonChange);return lt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Tp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});Cp.displayName=$a;var Tp=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=In("SelectScrollButton",n),i=h.useRef(null),a=Is(n),c=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>c(),[c]),lt(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),l.jsx(Ce.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:te(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:te(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:te(o.onPointerLeave,()=>{c()})})}),rT="SelectSeparator",kp=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return l.jsx(Ce.div,{"aria-hidden":!0,...r,ref:t})});kp.displayName=rT;var Fa="SelectArrow",oT=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ns(n),s=En(Fa,n),i=In(Fa,n);return s.open&&i.position==="popper"?l.jsx(da,{...o,...r,ref:t}):null});oT.displayName=Fa;var sT="SelectBubbleInput",Ep=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Re(r,o),i=Yh(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(Ce.select,{...n,style:{...Ch,...n.style},ref:s,defaultValue:t})});Ep.displayName=sT;function Ip(e){return e===""||e===void 0}function Np(e){const t=dt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function jp(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=iT(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function iT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var aT=np,Ap=op,lT=ip,cT=ap,uT=lp,Rp=cp,dT=hp,_p=gp,Pp=bp,fT=vp,hT=yp,Op=Sp,Mp=Cp,Dp=kp;const Lp=aT,$p=lT,za=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Ap,{ref:r,className:L("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,l.jsx(cT,{asChild:!0,children:l.jsx(oe.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));za.displayName=Ap.displayName;const Fp=h.forwardRef(({className:e,...t},n)=>l.jsx(Op,{ref:n,className:L("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(oe.ChevronUp,{className:"h-4 w-4"})}));Fp.displayName=Op.displayName;const zp=h.forwardRef(({className:e,...t},n)=>l.jsx(Mp,{ref:n,className:L("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(oe.ChevronDown,{className:"h-4 w-4"})}));zp.displayName=Mp.displayName;const Ba=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>l.jsx(uT,{children:l.jsxs(Rp,{ref:o,className:L("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:[l.jsx(Fp,{}),l.jsx(dT,{className:L("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx(zp,{})]})}));Ba.displayName=Rp.displayName;const pT=h.forwardRef(({className:e,...t},n)=>l.jsx(_p,{ref:n,className:L("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));pT.displayName=_p.displayName;const Vn=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Pp,{ref:r,className:L("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(hT,{children:l.jsx(oe.Check,{className:"h-4 w-4"})})}),l.jsx(fT,{children:t})]}));Vn.displayName=Pp.displayName;const mT=h.forwardRef(({className:e,...t},n)=>l.jsx(Dp,{ref:n,className:L("-mx-1 my-1 h-px bg-muted",e),...t}));mT.displayName=Dp.displayName;const As=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));As.displayName="Card";const Rs=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("flex flex-col space-y-1.5 p-6",e),...t}));Rs.displayName="CardHeader";const _s=h.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:L("text-2xl font-semibold leading-none tracking-tight",e),...t}));_s.displayName="CardTitle";const gT=h.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:L("text-sm text-muted-foreground",e),...t}));gT.displayName="CardDescription";const Ps=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("p-6 pt-0",e),...t}));Ps.displayName="CardContent";const xT=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("flex items-center p-6 pt-0",e),...t}));xT.displayName="CardFooter";const bT={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function vT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=C.useState(!1),[s,i]=C.useState(!1),[a,c]=C.useState(e),[u,d]=C.useState(!1),{toast:f}=Ai();C.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),C.useEffect(()=>{c(e)},[e]);const p=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},m=()=>{c(bT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{c(e),d(!1),o(!1)},b=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return l.jsxs(xh,{open:r,onOpenChange:o,children:[l.jsx(BS,{asChild:!0,children:l.jsxs(Be,{variant:"outline",size:"sm",className:n,children:[l.jsx(oe.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&l.jsx(Bc,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),l.jsxs(Aa,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[l.jsxs(vh,{children:[l.jsx(wh,{children:"Chat Settings"}),l.jsx(yh,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),l.jsxs("div",{className:"space-y-6 py-6",children:[l.jsxs(As,{children:[l.jsx(Rs,{className:"pb-3",children:l.jsxs(_s,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.Server,{className:"h-5 w-5"}),"API Configuration"]})}),l.jsxs(Ps,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Bt,{htmlFor:"api-url",children:"API Base URL"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Yr,{id:"api-url",value:a.api.baseUrl,onChange:g=>c(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),l.jsx(Be,{variant:"outline",onClick:b,children:"Test"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Bt,{htmlFor:"enable-auth",children:"Enable Authentication"}),l.jsx(kn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>c(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(Bt,{htmlFor:"auth-token",children:"Authentication Token"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Yr,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>c(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),l.jsx(Be,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?l.jsx(oe.EyeOff,{className:"h-4 w-4"}):l.jsx(oe.Eye,{className:"h-4 w-4"})})]})]})]})]}),l.jsxs(As,{children:[l.jsx(Rs,{className:"pb-3",children:l.jsxs(_s,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),l.jsxs(Ps,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Bt,{htmlFor:"layout",children:"Layout Style"}),l.jsxs(Lp,{value:a.ui.layout,onValueChange:g=>c(x=>({...x,ui:{...x.ui,layout:g}})),children:[l.jsx(za,{children:l.jsx($p,{})}),l.jsxs(Ba,{children:[l.jsx(Vn,{value:"sidebar",children:"Sidebar Layout"}),l.jsx(Vn,{value:"fullscreen",children:"Fullscreen"}),l.jsx(Vn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(Bt,{htmlFor:"theme",children:"Theme"}),l.jsxs(Lp,{value:a.ui.theme,onValueChange:g=>c(x=>({...x,ui:{...x.ui,theme:g}})),children:[l.jsx(za,{children:l.jsx($p,{})}),l.jsxs(Ba,{children:[l.jsx(Vn,{value:"light",children:"Light"}),l.jsx(Vn,{value:"dark",children:"Dark"}),l.jsx(Vn,{value:"system",children:"System"})]})]})]}),l.jsx(ja,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Bt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),l.jsx(kn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Bt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),l.jsx(kn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Bt,{htmlFor:"compact-messages",children:"Compact Messages"}),l.jsx(kn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),l.jsxs(As,{children:[l.jsx(Rs,{className:"pb-3",children:l.jsxs(_s,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),l.jsxs(Ps,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Bt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),l.jsx(kn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Bt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),l.jsx(kn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Bt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),l.jsx(kn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[l.jsxs(Be,{variant:"outline",onClick:m,children:[l.jsx(oe.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Be,{variant:"outline",onClick:w,children:"Cancel"}),l.jsxs(Be,{onClick:p,disabled:!u,children:[l.jsx(oe.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function wT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){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=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),c=C.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s.onThreadChange]);return e==="fullscreen"?l.jsx(kr,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsx(Gr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?l.jsx(kr,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&l.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(ws,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(Gr,{onError:s.onError,enableFileUpload:!0})})]})})}):l.jsx(kr,{...s,onThreadChange:c,children:l.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&l.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(ws,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(Gr,{onError:s.onError,enableFileUpload:!0})})]})})}be.Api=ho,be.ApiClient=ho,be.ChatApi=ho,be.ChatContextProvider=AS,be.ChatInterface=Gr,be.ChatMainLayout=_C,be.ChatProviderFull=kr,be.ChatRoutingProvider=IS,be.ChatSettings=vT,be.MarkdownContent=Oo,be.MessageComponent=od,be.MessageList=Ki,be.ThreadManager=ws,be.apiClient=cn,be.applySettings=DS,be.chatApiClient=cn,be.createChatClient=jS,be.default=wT,be.del=Dl,be.get=Nt,be.getChatToken=_l,be.getCurrentSettings=MS,be.getDefaultApiConfig=dh,be.getDefaultChatSettings=fh,be.onChatTokenChanged=Pl,be.post=Ol,be.put=Ml,be.setChatToken=Xs,be.useChatClient=RS,be.useChatFull=po,be.useChatRouting=NS,be.useChatStream=Ll,be.useMessagesReducer=$l,Object.defineProperties(be,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -3,7 +3,10 @@
3
3
  *
4
4
  * Pure client factory that creates chat clients based on provided configuration.
5
5
  * No environment reading at import time - all configuration comes from the host app.
6
+ *
7
+ * Uses existing types from src/types/api.ts for consistency with the codebase.
6
8
  */
9
+ import type { ThreadSummary, MessagesPayload } from "@/types/api";
7
10
  export type ChatConfig = {
8
11
  apiBase: string;
9
12
  authToken?: string | null;
@@ -17,5 +20,40 @@ export declare function createChatClient(cfg: ChatConfig): {
17
20
  }): {
18
21
  close: () => void;
19
22
  };
23
+ getCurrentThreadId(): string | null;
24
+ setCurrentThreadId(threadId: string | null): void;
25
+ getThreads(): ThreadSummary[];
26
+ setThreads(newThreads: ThreadSummary[]): void;
27
+ loadThreads(): Promise<void>;
28
+ createThread(title?: string): Promise<string>;
29
+ loadThread(threadId: string): Promise<void>;
30
+ deleteThread(threadId: string): Promise<void>;
31
+ updateThreadTitle(threadId: string, title: string): Promise<void>;
32
+ getMessages(params: {
33
+ threadId: string;
34
+ checkpointId?: string;
35
+ checkpointNs?: string;
36
+ limit?: number;
37
+ beforeId?: string | null;
38
+ }): Promise<MessagesPayload>;
39
+ sendMessage(text: string, options?: {
40
+ threadId?: string;
41
+ checkpointId?: string;
42
+ checkpointNs?: string;
43
+ nodeFilter?: string;
44
+ config?: Record<string, unknown>;
45
+ attachments?: File[];
46
+ }): Promise<{
47
+ threadId: string | null;
48
+ created: boolean;
49
+ }>;
50
+ getMessageHistory(params: {
51
+ threadId: string;
52
+ checkpointId?: string;
53
+ checkpointNs?: string;
54
+ limit?: number;
55
+ beforeId?: string | null;
56
+ }): Promise<MessagesPayload>;
57
+ updateAuthToken(token: string | null): void;
20
58
  };
21
59
  export type ChatClient = ReturnType<typeof createChatClient>;
@@ -18,4 +18,39 @@ export declare function useChatClient(): {
18
18
  }): {
19
19
  close: () => void;
20
20
  };
21
+ getCurrentThreadId(): string | null;
22
+ setCurrentThreadId(threadId: string | null): void;
23
+ getThreads(): import(".").ThreadSummary[];
24
+ setThreads(newThreads: import(".").ThreadSummary[]): void;
25
+ loadThreads(): Promise<void>;
26
+ createThread(title?: string): Promise<string>;
27
+ loadThread(threadId: string): Promise<void>;
28
+ deleteThread(threadId: string): Promise<void>;
29
+ updateThreadTitle(threadId: string, title: string): Promise<void>;
30
+ getMessages(params: {
31
+ threadId: string;
32
+ checkpointId?: string;
33
+ checkpointNs?: string;
34
+ limit?: number;
35
+ beforeId?: string | null;
36
+ }): Promise<import("../types/api").MessagesPayload>;
37
+ sendMessage(text: string, options?: {
38
+ threadId?: string;
39
+ checkpointId?: string;
40
+ checkpointNs?: string;
41
+ nodeFilter?: string;
42
+ config?: Record<string, unknown>;
43
+ attachments?: File[];
44
+ }): Promise<{
45
+ threadId: string | null;
46
+ created: boolean;
47
+ }>;
48
+ getMessageHistory(params: {
49
+ threadId: string;
50
+ checkpointId?: string;
51
+ checkpointNs?: string;
52
+ limit?: number;
53
+ beforeId?: string | null;
54
+ }): Promise<import("../types/api").MessagesPayload>;
55
+ updateAuthToken(token: string | null): void;
21
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teodor-new-chat-ui",
3
- "version": "3.0.161",
3
+ "version": "3.0.163",
4
4
  "description": "React chat UI components with streaming support, tool calls, and modern design",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",