quick-chat-react 1.0.2 → 1.0.3
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.cjs +41 -41
- package/dist/index.js +2674 -2671
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),y=require("react"),es=require("@supabase/supabase-js"),oe=require("@tanstack/react-query"),ts=require("react-dom"),_o=require("@emoji-mart/data"),Eo=require("@emoji-mart/react");function ni(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const f=ni(y),ns=ni(ts),ri=y.createContext(null),oi=()=>{const e=y.useContext(ri);if(!e)throw new Error("useQuickChat must be used within QuickChatProvider");return e},ve=()=>oi().supabase,rs=()=>oi().config,Lf=({supabaseUrl:e,supabaseAnonKey:t,config:n,queryClient:r,children:o})=>{const[a]=y.useState(()=>new oe.QueryClient),c=r??a,i=y.useMemo(()=>es.createClient(e,t,{auth:{storage:typeof window<"u"?localStorage:void 0,persistSession:!0,autoRefreshToken:!0}}),[e,t]),l=y.useMemo(()=>({supabase:i,config:n}),[i,n]);return s.jsx(oe.QueryClientProvider,{client:c,children:s.jsx(ri.Provider,{value:l,children:o})})},$f=({children:e,userData:t,supabase:n})=>{const[r,o]=y.useState(null),[a,c]=y.useState(!0),[i,l]=y.useState(null);if(y.useEffect(()=>{if(!t){c(!1);return}if(!t.accessToken){console.warn("[QuickChat] authMode='external' — userData.accessToken is missing. auth.uid() will be NULL and DB/storage operations will fail. Generate a Supabase JWT via the Admin API for full functionality."),c(!1);return}if(!t.refreshToken){console.warn("[QuickChat] authMode='external' — userData.refreshToken is missing. Proceeding without a full Supabase session; token refresh will not work. Pass refreshToken alongside accessToken for full functionality."),c(!1);return}n.auth.setSession({access_token:t.accessToken,refresh_token:t.refreshToken}).then(({data:m,error:h})=>{h?(l(h.message),console.error("[QuickChat] Failed to set Supabase session:",h.message)):o(m.session)}).finally(()=>c(!1))},[t==null?void 0:t.accessToken,n]),i)return s.jsxs("div",{style:{padding:16,color:"red",fontFamily:"sans-serif"},children:[s.jsx("strong",{children:"QuickChat config error:"})," ",i]});const d=t?{id:t.id,email:t.email??"",user_metadata:{display_name:t.name,avatar_url:t.avatar}}:null,u=async()=>{await n.auth.signOut()};return s.jsx(os.Provider,{value:{session:r,user:d,loading:a,authMode:"external",signOut:u},children:e})},os=y.createContext({session:null,user:null,loading:!0,authMode:"built-in",signOut:async()=>{}}),ye=()=>y.useContext(os),Ff=({children:e,authMode:t="built-in",userData:n})=>{const r=ve(),[o,a]=y.useState(null),[c,i]=y.useState(t==="built-in");y.useEffect(()=>{if(t==="external")return;const{data:{subscription:d}}=r.auth.onAuthStateChange((u,m)=>{a(m),i(!1)});return r.auth.getSession().then(({data:{session:u}})=>{a(u),i(!1)}),()=>d.unsubscribe()},[r,t]);const l=async()=>{await r.auth.signOut()};return t==="external"?s.jsx($f,{userData:n,supabase:r,children:e}):s.jsx(os.Provider,{value:{session:o,user:(o==null?void 0:o.user)??null,loading:c,authMode:"built-in",signOut:l},children:e})},si=y.createContext({theme:"system",setTheme:()=>{},resolved:"light"}),zf=()=>y.useContext(si),Wf=({children:e,initialTheme:t})=>{const[n,r]=y.useState(()=>t||localStorage.getItem("chat-theme")||"system"),o=l=>l==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":l,[a,c]=y.useState(o(n)),i=l=>{r(l),localStorage.setItem("chat-theme",l)};return y.useEffect(()=>{const l=o(n);if(c(l),document.documentElement.classList.toggle("dark",l==="dark"),n==="system"){const d=window.matchMedia("(prefers-color-scheme: dark)"),u=m=>{const h=m.matches?"dark":"light";c(h),document.documentElement.classList.toggle("dark",h==="dark")};return d.addEventListener("change",u),()=>d.removeEventListener("change",u)}},[n]),s.jsx(si.Provider,{value:{theme:n,setTheme:i,resolved:a},children:e})};function L(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function aa(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Pr(...e){return t=>{let n=!1;const r=e.map(o=>{const a=aa(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():aa(e[o],null)}}}}function ae(...e){return f.useCallback(Pr(...e),e)}function Bf(e,t){const n=f.createContext(t),r=a=>{const{children:c,...i}=a,l=f.useMemo(()=>i,Object.values(i));return s.jsx(n.Provider,{value:l,children:c})};r.displayName=e+"Provider";function o(a){const c=f.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,o]}function ke(e,t=[]){let n=[];function r(a,c){const i=f.createContext(c),l=n.length;n=[...n,c];const d=m=>{var C;const{scope:h,children:p,...v}=m,g=((C=h==null?void 0:h[e])==null?void 0:C[l])||i,x=f.useMemo(()=>v,Object.values(v));return s.jsx(g.Provider,{value:x,children:p})};d.displayName=a+"Provider";function u(m,h){var g;const p=((g=h==null?void 0:h[e])==null?void 0:g[l])||i,v=f.useContext(p);if(v)return v;if(c!==void 0)return c;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[d,u]}const o=()=>{const a=n.map(c=>f.createContext(c));return function(i){const l=(i==null?void 0:i[e])||a;return f.useMemo(()=>({[`__scope${e}`]:{...i,[e]:l}}),[i,l])}};return o.scopeName=e,[r,qf(o,...t)]}function qf(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const c=r.reduce((i,{useScope:l,scopeName:d})=>{const m=l(a)[`__scope${d}`];return{...i,...m}},{});return f.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}function dn(e){const t=Hf(e),n=f.forwardRef((r,o)=>{const{children:a,...c}=r,i=f.Children.toArray(a),l=i.find(Vf);if(l){const d=l.props.children,u=i.map(m=>m===l?f.Children.count(d)>1?f.Children.only(null):f.isValidElement(d)?d.props.children:null:m);return s.jsx(t,{...c,ref:o,children:f.isValidElement(d)?f.cloneElement(d,void 0,u):null})}return s.jsx(t,{...c,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}var Uf=dn("Slot");function Hf(e){const t=f.forwardRef((n,r)=>{const{children:o,...a}=n;if(f.isValidElement(o)){const c=Yf(o),i=Gf(a,o.props);return o.type!==f.Fragment&&(i.ref=r?Pr(r,c):c),f.cloneElement(o,i)}return f.Children.count(o)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ai=Symbol("radix.slottable");function ii(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=ai,t}function Vf(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ai}function Gf(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...i)=>{const l=a(...i);return o(...i),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Yf(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Kf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],K=Kf.reduce((e,t)=>{const n=dn(`Primitive.${t}`),r=f.forwardRef((o,a)=>{const{asChild:c,...i}=o,l=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(l,{...i,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ss(e,t){e&&ns.flushSync(()=>e.dispatchEvent(t))}function ge(e){const t=f.useRef(e);return f.useEffect(()=>{t.current=e}),f.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Xf(e,t=globalThis==null?void 0:globalThis.document){const n=ge(e);f.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Qf="DismissableLayer",Mo="dismissableLayer.update",Zf="dismissableLayer.pointerDownOutside",Jf="dismissableLayer.focusOutside",ia,ci=f.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Fn=f.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:c,onDismiss:i,...l}=e,d=f.useContext(ci),[u,m]=f.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=f.useState({}),v=ae(t,_=>m(_)),g=Array.from(d.layers),[x]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),C=g.indexOf(x),w=u?g.indexOf(u):-1,b=d.layersWithOutsidePointerEventsDisabled.size>0,S=w>=C,j=tm(_=>{const O=_.target,k=[...d.branches].some(P=>P.contains(O));!S||k||(o==null||o(_),c==null||c(_),_.defaultPrevented||i==null||i())},h),N=nm(_=>{const O=_.target;[...d.branches].some(P=>P.contains(O))||(a==null||a(_),c==null||c(_),_.defaultPrevented||i==null||i())},h);return Xf(_=>{w===d.layers.size-1&&(r==null||r(_),!_.defaultPrevented&&i&&(_.preventDefault(),i()))},h),f.useEffect(()=>{if(u)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(ia=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(u)),d.layers.add(u),ca(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=ia)}},[u,h,n,d]),f.useEffect(()=>()=>{u&&(d.layers.delete(u),d.layersWithOutsidePointerEventsDisabled.delete(u),ca())},[u,d]),f.useEffect(()=>{const _=()=>p({});return document.addEventListener(Mo,_),()=>document.removeEventListener(Mo,_)},[]),s.jsx(K.div,{...l,ref:v,style:{pointerEvents:b?S?"auto":"none":void 0,...e.style},onFocusCapture:L(e.onFocusCapture,N.onFocusCapture),onBlurCapture:L(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:L(e.onPointerDownCapture,j.onPointerDownCapture)})});Fn.displayName=Qf;var em="DismissableLayerBranch",li=f.forwardRef((e,t)=>{const n=f.useContext(ci),r=f.useRef(null),o=ae(t,r);return f.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(K.div,{...e,ref:o})});li.displayName=em;function tm(e,t=globalThis==null?void 0:globalThis.document){const n=ge(e),r=f.useRef(!1),o=f.useRef(()=>{});return f.useEffect(()=>{const a=i=>{if(i.target&&!r.current){let l=function(){di(Zf,n,d,{discrete:!0})};const d={originalEvent:i};i.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function nm(e,t=globalThis==null?void 0:globalThis.document){const n=ge(e),r=f.useRef(!1);return f.useEffect(()=>{const o=a=>{a.target&&!r.current&&di(Jf,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function ca(){const e=new CustomEvent(Mo);document.dispatchEvent(e)}function di(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?ss(o,a):o.dispatchEvent(a)}var rm=Fn,om=li,Fe=globalThis!=null&&globalThis.document?f.useLayoutEffect:()=>{},sm=f[" useId ".trim().toString()]||(()=>{}),am=0;function gt(e){const[t,n]=f.useState(sm());return Fe(()=>{e||n(r=>r??String(am++))},[e]),e||(t?`radix-${t}`:"")}const im=["top","right","bottom","left"],_t=Math.min,Le=Math.max,vr=Math.round,Jn=Math.floor,st=e=>({x:e,y:e}),cm={left:"right",right:"left",bottom:"top",top:"bottom"},lm={start:"end",end:"start"};function To(e,t,n){return Le(e,_t(t,n))}function xt(e,t){return typeof e=="function"?e(t):e}function vt(e){return e.split("-")[0]}function pn(e){return e.split("-")[1]}function as(e){return e==="x"?"y":"x"}function is(e){return e==="y"?"height":"width"}const dm=new Set(["top","bottom"]);function ot(e){return dm.has(vt(e))?"y":"x"}function cs(e){return as(ot(e))}function um(e,t,n){n===void 0&&(n=!1);const r=pn(e),o=cs(e),a=is(o);let c=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(c=yr(c)),[c,yr(c)]}function fm(e){const t=yr(e);return[Ro(e),t,Ro(t)]}function Ro(e){return e.replace(/start|end/g,t=>lm[t])}const la=["left","right"],da=["right","left"],mm=["top","bottom"],pm=["bottom","top"];function hm(e,t,n){switch(e){case"top":case"bottom":return n?t?da:la:t?la:da;case"left":case"right":return t?mm:pm;default:return[]}}function gm(e,t,n,r){const o=pn(e);let a=hm(vt(e),n==="start",r);return o&&(a=a.map(c=>c+"-"+o),t&&(a=a.concat(a.map(Ro)))),a}function yr(e){return e.replace(/left|right|bottom|top/g,t=>cm[t])}function xm(e){return{top:0,right:0,bottom:0,left:0,...e}}function ui(e){return typeof e!="number"?xm(e):{top:e,right:e,bottom:e,left:e}}function br(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 ua(e,t,n){let{reference:r,floating:o}=e;const a=ot(t),c=cs(t),i=is(c),l=vt(t),d=a==="y",u=r.x+r.width/2-o.width/2,m=r.y+r.height/2-o.height/2,h=r[i]/2-o[i]/2;let p;switch(l){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:m};break;case"left":p={x:r.x-o.width,y:m};break;default:p={x:r.x,y:r.y}}switch(pn(t)){case"start":p[c]-=h*(n&&d?-1:1);break;case"end":p[c]+=h*(n&&d?-1:1);break}return p}const vm=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:c}=n,i=a.filter(Boolean),l=await(c.isRTL==null?void 0:c.isRTL(t));let d=await c.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:m}=ua(d,r,l),h=r,p={},v=0;for(let g=0;g<i.length;g++){const{name:x,fn:C}=i[g],{x:w,y:b,data:S,reset:j}=await C({x:u,y:m,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:d,platform:c,elements:{reference:e,floating:t}});u=w??u,m=b??m,p={...p,[x]:{...p[x],...S}},j&&v<=50&&(v++,typeof j=="object"&&(j.placement&&(h=j.placement),j.rects&&(d=j.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:o}):j.rects),{x:u,y:m}=ua(d,h,l)),g=-1)}return{x:u,y:m,placement:h,strategy:o,middlewareData:p}};async function An(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:a,rects:c,elements:i,strategy:l}=e,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:m="floating",altBoundary:h=!1,padding:p=0}=xt(t,e),v=ui(p),x=i[h?m==="floating"?"reference":"floating":m],C=br(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(x)))==null||n?x:x.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(i.floating)),boundary:d,rootBoundary:u,strategy:l})),w=m==="floating"?{x:r,y:o,width:c.floating.width,height:c.floating.height}:c.reference,b=await(a.getOffsetParent==null?void 0:a.getOffsetParent(i.floating)),S=await(a.isElement==null?void 0:a.isElement(b))?await(a.getScale==null?void 0:a.getScale(b))||{x:1,y:1}:{x:1,y:1},j=br(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:w,offsetParent:b,strategy:l}):w);return{top:(C.top-j.top+v.top)/S.y,bottom:(j.bottom-C.bottom+v.bottom)/S.y,left:(C.left-j.left+v.left)/S.x,right:(j.right-C.right+v.right)/S.x}}const ym=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:a,platform:c,elements:i,middlewareData:l}=t,{element:d,padding:u=0}=xt(e,t)||{};if(d==null)return{};const m=ui(u),h={x:n,y:r},p=cs(o),v=is(p),g=await c.getDimensions(d),x=p==="y",C=x?"top":"left",w=x?"bottom":"right",b=x?"clientHeight":"clientWidth",S=a.reference[v]+a.reference[p]-h[p]-a.floating[v],j=h[p]-a.reference[p],N=await(c.getOffsetParent==null?void 0:c.getOffsetParent(d));let _=N?N[b]:0;(!_||!await(c.isElement==null?void 0:c.isElement(N)))&&(_=i.floating[b]||a.floating[v]);const O=S/2-j/2,k=_/2-g[v]/2-1,P=_t(m[C],k),I=_t(m[w],k),A=P,D=_-g[v]-I,E=_/2-g[v]/2+O,F=To(A,E,D),T=!l.arrow&&pn(o)!=null&&E!==F&&a.reference[v]/2-(E<A?P:I)-g[v]/2<0,z=T?E<A?E-A:E-D:0;return{[p]:h[p]+z,data:{[p]:F,centerOffset:E-F-z,...T&&{alignmentOffset:z}},reset:T}}}),bm=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:a,rects:c,initialPlacement:i,platform:l,elements:d}=t,{mainAxis:u=!0,crossAxis:m=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=xt(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const C=vt(o),w=ot(i),b=vt(i)===i,S=await(l.isRTL==null?void 0:l.isRTL(d.floating)),j=h||(b||!g?[yr(i)]:fm(i)),N=v!=="none";!h&&N&&j.push(...gm(i,g,v,S));const _=[i,...j],O=await An(t,x),k=[];let P=((r=a.flip)==null?void 0:r.overflows)||[];if(u&&k.push(O[C]),m){const E=um(o,c,S);k.push(O[E[0]],O[E[1]])}if(P=[...P,{placement:o,overflows:k}],!k.every(E=>E<=0)){var I,A;const E=(((I=a.flip)==null?void 0:I.index)||0)+1,F=_[E];if(F&&(!(m==="alignment"?w!==ot(F):!1)||P.every($=>$.overflows[0]>0&&ot($.placement)===w)))return{data:{index:E,overflows:P},reset:{placement:F}};let T=(A=P.filter(z=>z.overflows[0]<=0).sort((z,$)=>z.overflows[1]-$.overflows[1])[0])==null?void 0:A.placement;if(!T)switch(p){case"bestFit":{var D;const z=(D=P.filter($=>{if(N){const M=ot($.placement);return M===w||M==="y"}return!0}).map($=>[$.placement,$.overflows.filter(M=>M>0).reduce((M,H)=>M+H,0)]).sort(($,M)=>$[1]-M[1])[0])==null?void 0:D[0];z&&(T=z);break}case"initialPlacement":T=i;break}if(o!==T)return{reset:{placement:T}}}return{}}}};function fa(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ma(e){return im.some(t=>e[t]>=0)}const wm=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=xt(e,t);switch(r){case"referenceHidden":{const a=await An(t,{...o,elementContext:"reference"}),c=fa(a,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:ma(c)}}}case"escaped":{const a=await An(t,{...o,altBoundary:!0}),c=fa(a,n.floating);return{data:{escapedOffsets:c,escaped:ma(c)}}}default:return{}}}}},fi=new Set(["left","top"]);async function Cm(e,t){const{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),c=vt(n),i=pn(n),l=ot(n)==="y",d=fi.has(c)?-1:1,u=a&&l?-1:1,m=xt(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return i&&typeof v=="number"&&(p=i==="end"?v*-1:v),l?{x:p*u,y:h*d}:{x:h*d,y:p*u}}const Sm=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:a,placement:c,middlewareData:i}=t,l=await Cm(t,e);return c===((n=i.offset)==null?void 0:n.placement)&&(r=i.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:a+l.y,data:{...l,placement:c}}}}},jm=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:a=!0,crossAxis:c=!1,limiter:i={fn:x=>{let{x:C,y:w}=x;return{x:C,y:w}}},...l}=xt(e,t),d={x:n,y:r},u=await An(t,l),m=ot(vt(o)),h=as(m);let p=d[h],v=d[m];if(a){const x=h==="y"?"top":"left",C=h==="y"?"bottom":"right",w=p+u[x],b=p-u[C];p=To(w,p,b)}if(c){const x=m==="y"?"top":"left",C=m==="y"?"bottom":"right",w=v+u[x],b=v-u[C];v=To(w,v,b)}const g=i.fn({...t,[h]:p,[m]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[h]:a,[m]:c}}}}}},Nm=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:a,middlewareData:c}=t,{offset:i=0,mainAxis:l=!0,crossAxis:d=!0}=xt(e,t),u={x:n,y:r},m=ot(o),h=as(m);let p=u[h],v=u[m];const g=xt(i,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const b=h==="y"?"height":"width",S=a.reference[h]-a.floating[b]+x.mainAxis,j=a.reference[h]+a.reference[b]-x.mainAxis;p<S?p=S:p>j&&(p=j)}if(d){var C,w;const b=h==="y"?"width":"height",S=fi.has(vt(o)),j=a.reference[m]-a.floating[b]+(S&&((C=c.offset)==null?void 0:C[m])||0)+(S?0:x.crossAxis),N=a.reference[m]+a.reference[b]+(S?0:((w=c.offset)==null?void 0:w[m])||0)-(S?x.crossAxis:0);v<j?v=j:v>N&&(v=N)}return{[h]:p,[m]:v}}}},_m=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:a,platform:c,elements:i}=t,{apply:l=()=>{},...d}=xt(e,t),u=await An(t,d),m=vt(o),h=pn(o),p=ot(o)==="y",{width:v,height:g}=a.floating;let x,C;m==="top"||m==="bottom"?(x=m,C=h===(await(c.isRTL==null?void 0:c.isRTL(i.floating))?"start":"end")?"left":"right"):(C=m,x=h==="end"?"top":"bottom");const w=g-u.top-u.bottom,b=v-u.left-u.right,S=_t(g-u[x],w),j=_t(v-u[C],b),N=!t.middlewareData.shift;let _=S,O=j;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(O=b),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(_=w),N&&!h){const P=Le(u.left,0),I=Le(u.right,0),A=Le(u.top,0),D=Le(u.bottom,0);p?O=v-2*(P!==0||I!==0?P+I:Le(u.left,u.right)):_=g-2*(A!==0||D!==0?A+D:Le(u.top,u.bottom))}await l({...t,availableWidth:O,availableHeight:_});const k=await c.getDimensions(i.floating);return v!==k.width||g!==k.height?{reset:{rects:!0}}:{}}}};function Ar(){return typeof window<"u"}function hn(e){return mi(e)?(e.nodeName||"").toLowerCase():"#document"}function $e(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function it(e){var t;return(t=(mi(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function mi(e){return Ar()?e instanceof Node||e instanceof $e(e).Node:!1}function Qe(e){return Ar()?e instanceof Element||e instanceof $e(e).Element:!1}function at(e){return Ar()?e instanceof HTMLElement||e instanceof $e(e).HTMLElement:!1}function pa(e){return!Ar()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof $e(e).ShadowRoot}const Em=new Set(["inline","contents"]);function zn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Ze(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Em.has(o)}const Mm=new Set(["table","td","th"]);function Tm(e){return Mm.has(hn(e))}const Rm=[":popover-open",":modal"];function Or(e){return Rm.some(t=>{try{return e.matches(t)}catch{return!1}})}const km=["transform","translate","scale","rotate","perspective"],Pm=["transform","translate","scale","rotate","perspective","filter"],Am=["paint","layout","strict","content"];function ls(e){const t=ds(),n=Qe(e)?Ze(e):e;return km.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)||Pm.some(r=>(n.willChange||"").includes(r))||Am.some(r=>(n.contain||"").includes(r))}function Om(e){let t=Et(e);for(;at(t)&&!un(t);){if(ls(t))return t;if(Or(t))return null;t=Et(t)}return null}function ds(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Dm=new Set(["html","body","#document"]);function un(e){return Dm.has(hn(e))}function Ze(e){return $e(e).getComputedStyle(e)}function Dr(e){return Qe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Et(e){if(hn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||pa(e)&&e.host||it(e);return pa(t)?t.host:t}function pi(e){const t=Et(e);return un(t)?e.ownerDocument?e.ownerDocument.body:e.body:at(t)&&zn(t)?t:pi(t)}function On(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=pi(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),c=$e(o);if(a){const i=ko(c);return t.concat(c,c.visualViewport||[],zn(o)?o:[],i&&n?On(i):[])}return t.concat(o,On(o,[],n))}function ko(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function hi(e){const t=Ze(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=at(e),a=o?e.offsetWidth:n,c=o?e.offsetHeight:r,i=vr(n)!==a||vr(r)!==c;return i&&(n=a,r=c),{width:n,height:r,$:i}}function us(e){return Qe(e)?e:e.contextElement}function nn(e){const t=us(e);if(!at(t))return st(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:a}=hi(t);let c=(a?vr(n.width):n.width)/r,i=(a?vr(n.height):n.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!i||!Number.isFinite(i))&&(i=1),{x:c,y:i}}const Im=st(0);function gi(e){const t=$e(e);return!ds()||!t.visualViewport?Im:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Lm(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==$e(e)?!1:t}function Ft(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=us(e);let c=st(1);t&&(r?Qe(r)&&(c=nn(r)):c=nn(e));const i=Lm(a,n,r)?gi(a):st(0);let l=(o.left+i.x)/c.x,d=(o.top+i.y)/c.y,u=o.width/c.x,m=o.height/c.y;if(a){const h=$e(a),p=r&&Qe(r)?$e(r):r;let v=h,g=ko(v);for(;g&&r&&p!==v;){const x=nn(g),C=g.getBoundingClientRect(),w=Ze(g),b=C.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,S=C.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,d*=x.y,u*=x.x,m*=x.y,l+=b,d+=S,v=$e(g),g=ko(v)}}return br({width:u,height:m,x:l,y:d})}function fs(e,t){const n=Dr(e).scrollLeft;return t?t.left+n:Ft(it(e)).left+n}function xi(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:fs(e,r)),a=r.top+t.scrollTop;return{x:o,y:a}}function $m(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const a=o==="fixed",c=it(r),i=t?Or(t.floating):!1;if(r===c||i&&a)return n;let l={scrollLeft:0,scrollTop:0},d=st(1);const u=st(0),m=at(r);if((m||!m&&!a)&&((hn(r)!=="body"||zn(c))&&(l=Dr(r)),at(r))){const p=Ft(r);d=nn(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=c&&!m&&!a?xi(c,l,!0):st(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-l.scrollLeft*d.x+u.x+h.x,y:n.y*d.y-l.scrollTop*d.y+u.y+h.y}}function Fm(e){return Array.from(e.getClientRects())}function zm(e){const t=it(e),n=Dr(e),r=e.ownerDocument.body,o=Le(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Le(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let c=-n.scrollLeft+fs(e);const i=-n.scrollTop;return Ze(r).direction==="rtl"&&(c+=Le(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:c,y:i}}function Wm(e,t){const n=$e(e),r=it(e),o=n.visualViewport;let a=r.clientWidth,c=r.clientHeight,i=0,l=0;if(o){a=o.width,c=o.height;const d=ds();(!d||d&&t==="fixed")&&(i=o.offsetLeft,l=o.offsetTop)}return{width:a,height:c,x:i,y:l}}const Bm=new Set(["absolute","fixed"]);function qm(e,t){const n=Ft(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=at(e)?nn(e):st(1),c=e.clientWidth*a.x,i=e.clientHeight*a.y,l=o*a.x,d=r*a.y;return{width:c,height:i,x:l,y:d}}function ha(e,t,n){let r;if(t==="viewport")r=Wm(e,n);else if(t==="document")r=zm(it(e));else if(Qe(t))r=qm(t,n);else{const o=gi(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return br(r)}function vi(e,t){const n=Et(e);return n===t||!Qe(n)||un(n)?!1:Ze(n).position==="fixed"||vi(n,t)}function Um(e,t){const n=t.get(e);if(n)return n;let r=On(e,[],!1).filter(i=>Qe(i)&&hn(i)!=="body"),o=null;const a=Ze(e).position==="fixed";let c=a?Et(e):e;for(;Qe(c)&&!un(c);){const i=Ze(c),l=ls(c);!l&&i.position==="fixed"&&(o=null),(a?!l&&!o:!l&&i.position==="static"&&!!o&&Bm.has(o.position)||zn(c)&&!l&&vi(e,c))?r=r.filter(u=>u!==c):o=i,c=Et(c)}return t.set(e,r),r}function Hm(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const c=[...n==="clippingAncestors"?Or(t)?[]:Um(t,this._c):[].concat(n),r],i=c[0],l=c.reduce((d,u)=>{const m=ha(t,u,o);return d.top=Le(m.top,d.top),d.right=_t(m.right,d.right),d.bottom=_t(m.bottom,d.bottom),d.left=Le(m.left,d.left),d},ha(t,i,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Vm(e){const{width:t,height:n}=hi(e);return{width:t,height:n}}function Gm(e,t,n){const r=at(t),o=it(t),a=n==="fixed",c=Ft(e,!0,a,t);let i={scrollLeft:0,scrollTop:0};const l=st(0);function d(){l.x=fs(o)}if(r||!r&&!a)if((hn(t)!=="body"||zn(o))&&(i=Dr(t)),r){const p=Ft(t,!0,a,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&d();a&&!r&&o&&d();const u=o&&!r&&!a?xi(o,i):st(0),m=c.left+i.scrollLeft-l.x-u.x,h=c.top+i.scrollTop-l.y-u.y;return{x:m,y:h,width:c.width,height:c.height}}function oo(e){return Ze(e).position==="static"}function ga(e,t){if(!at(e)||Ze(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return it(e)===n&&(n=n.ownerDocument.body),n}function yi(e,t){const n=$e(e);if(Or(e))return n;if(!at(e)){let o=Et(e);for(;o&&!un(o);){if(Qe(o)&&!oo(o))return o;o=Et(o)}return n}let r=ga(e,t);for(;r&&Tm(r)&&oo(r);)r=ga(r,t);return r&&un(r)&&oo(r)&&!ls(r)?n:r||Om(e)||n}const Ym=async function(e){const t=this.getOffsetParent||yi,n=this.getDimensions,r=await n(e.floating);return{reference:Gm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Km(e){return Ze(e).direction==="rtl"}const Xm={convertOffsetParentRelativeRectToViewportRelativeRect:$m,getDocumentElement:it,getClippingRect:Hm,getOffsetParent:yi,getElementRects:Ym,getClientRects:Fm,getDimensions:Vm,getScale:nn,isElement:Qe,isRTL:Km};function bi(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Qm(e,t){let n=null,r;const o=it(e);function a(){var i;clearTimeout(r),(i=n)==null||i.disconnect(),n=null}function c(i,l){i===void 0&&(i=!1),l===void 0&&(l=1),a();const d=e.getBoundingClientRect(),{left:u,top:m,width:h,height:p}=d;if(i||t(),!h||!p)return;const v=Jn(m),g=Jn(o.clientWidth-(u+h)),x=Jn(o.clientHeight-(m+p)),C=Jn(u),b={rootMargin:-v+"px "+-g+"px "+-x+"px "+-C+"px",threshold:Le(0,_t(1,l))||1};let S=!0;function j(N){const _=N[0].intersectionRatio;if(_!==l){if(!S)return c();_?c(!1,_):r=setTimeout(()=>{c(!1,1e-7)},1e3)}_===1&&!bi(d,e.getBoundingClientRect())&&c(),S=!1}try{n=new IntersectionObserver(j,{...b,root:o.ownerDocument})}catch{n=new IntersectionObserver(j,b)}n.observe(e)}return c(!0),a}function Zm(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,d=us(e),u=o||a?[...d?On(d):[],...On(t)]:[];u.forEach(C=>{o&&C.addEventListener("scroll",n,{passive:!0}),a&&C.addEventListener("resize",n)});const m=d&&i?Qm(d,n):null;let h=-1,p=null;c&&(p=new ResizeObserver(C=>{let[w]=C;w&&w.target===d&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var b;(b=p)==null||b.observe(t)})),n()}),d&&!l&&p.observe(d),p.observe(t));let v,g=l?Ft(e):null;l&&x();function x(){const C=Ft(e);g&&!bi(g,C)&&n(),g=C,v=requestAnimationFrame(x)}return n(),()=>{var C;u.forEach(w=>{o&&w.removeEventListener("scroll",n),a&&w.removeEventListener("resize",n)}),m==null||m(),(C=p)==null||C.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const Jm=Sm,ep=jm,tp=bm,np=_m,rp=wm,xa=ym,op=Nm,sp=(e,t,n)=>{const r=new Map,o={platform:Xm,...n},a={...o.platform,_c:r};return vm(e,t,{...o,platform:a})};var ap=typeof document<"u",ip=function(){},dr=ap?y.useLayoutEffect:ip;function wr(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(!wr(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 a=o[r];if(!(a==="_owner"&&e.$$typeof)&&!wr(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function wi(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function va(e,t){const n=wi(e);return Math.round(t*n)/n}function so(e){const t=f.useRef(e);return dr(()=>{t.current=e}),t}function cp(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:a,floating:c}={},transform:i=!0,whileElementsMounted:l,open:d}=e,[u,m]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=f.useState(r);wr(h,r)||p(r);const[v,g]=f.useState(null),[x,C]=f.useState(null),w=f.useCallback($=>{$!==N.current&&(N.current=$,g($))},[]),b=f.useCallback($=>{$!==_.current&&(_.current=$,C($))},[]),S=a||v,j=c||x,N=f.useRef(null),_=f.useRef(null),O=f.useRef(u),k=l!=null,P=so(l),I=so(o),A=so(d),D=f.useCallback(()=>{if(!N.current||!_.current)return;const $={placement:t,strategy:n,middleware:h};I.current&&($.platform=I.current),sp(N.current,_.current,$).then(M=>{const H={...M,isPositioned:A.current!==!1};E.current&&!wr(O.current,H)&&(O.current=H,ns.flushSync(()=>{m(H)}))})},[h,t,n,I,A]);dr(()=>{d===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,m($=>({...$,isPositioned:!1})))},[d]);const E=f.useRef(!1);dr(()=>(E.current=!0,()=>{E.current=!1}),[]),dr(()=>{if(S&&(N.current=S),j&&(_.current=j),S&&j){if(P.current)return P.current(S,j,D);D()}},[S,j,D,P,k]);const F=f.useMemo(()=>({reference:N,floating:_,setReference:w,setFloating:b}),[w,b]),T=f.useMemo(()=>({reference:S,floating:j}),[S,j]),z=f.useMemo(()=>{const $={position:n,left:0,top:0};if(!T.floating)return $;const M=va(T.floating,u.x),H=va(T.floating,u.y);return i?{...$,transform:"translate("+M+"px, "+H+"px)",...wi(T.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:H}},[n,i,T.floating,u.x,u.y]);return f.useMemo(()=>({...u,update:D,refs:F,elements:T,floatingStyles:z}),[u,D,F,T,z])}const lp=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?xa({element:r.current,padding:o}).fn(n):{}:r?xa({element:r,padding:o}).fn(n):{}}}},dp=(e,t)=>({...Jm(e),options:[e,t]}),up=(e,t)=>({...ep(e),options:[e,t]}),fp=(e,t)=>({...op(e),options:[e,t]}),mp=(e,t)=>({...tp(e),options:[e,t]}),pp=(e,t)=>({...np(e),options:[e,t]}),hp=(e,t)=>({...rp(e),options:[e,t]}),gp=(e,t)=>({...lp(e),options:[e,t]});var xp="Arrow",Ci=f.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...a}=e;return s.jsx(K.svg,{...a,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ci.displayName=xp;var vp=Ci;function Si(e){const[t,n]=f.useState(void 0);return Fe(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let c,i;if("borderBoxSize"in a){const l=a.borderBoxSize,d=Array.isArray(l)?l[0]:l;c=d.inlineSize,i=d.blockSize}else c=e.offsetWidth,i=e.offsetHeight;n({width:c,height:i})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ms="Popper",[ji,Ir]=ke(ms),[yp,Ni]=ji(ms),_i=e=>{const{__scopePopper:t,children:n}=e,[r,o]=f.useState(null);return s.jsx(yp,{scope:t,anchor:r,onAnchorChange:o,children:n})};_i.displayName=ms;var Ei="PopperAnchor",Mi=f.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=Ni(Ei,n),c=f.useRef(null),i=ae(t,c);return f.useEffect(()=>{a.onAnchorChange((r==null?void 0:r.current)||c.current)}),r?null:s.jsx(K.div,{...o,ref:i})});Mi.displayName=Ei;var ps="PopperContent",[bp,wp]=ji(ps),Ti=f.forwardRef((e,t)=>{var J,Pe,he,ze,Ae,Ve;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:c=0,arrowPadding:i=0,avoidCollisions:l=!0,collisionBoundary:d=[],collisionPadding:u=0,sticky:m="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...g}=e,x=Ni(ps,n),[C,w]=f.useState(null),b=ae(t,Ge=>w(Ge)),[S,j]=f.useState(null),N=Si(S),_=(N==null?void 0:N.width)??0,O=(N==null?void 0:N.height)??0,k=r+(a!=="center"?"-"+a:""),P=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},I=Array.isArray(d)?d:[d],A=I.length>0,D={padding:P,boundary:I.filter(Sp),altBoundary:A},{refs:E,floatingStyles:F,placement:T,isPositioned:z,middlewareData:$}=cp({strategy:"fixed",placement:k,whileElementsMounted:(...Ge)=>Zm(...Ge,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[dp({mainAxis:o+O,alignmentAxis:c}),l&&up({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?fp():void 0,...D}),l&&mp({...D}),pp({...D,apply:({elements:Ge,rects:Gt,availableWidth:Rt,availableHeight:Yt})=>{const{width:kt,height:Pt}=Gt.reference,lt=Ge.floating.style;lt.setProperty("--radix-popper-available-width",`${Rt}px`),lt.setProperty("--radix-popper-available-height",`${Yt}px`),lt.setProperty("--radix-popper-anchor-width",`${kt}px`),lt.setProperty("--radix-popper-anchor-height",`${Pt}px`)}}),S&&gp({element:S,padding:i}),jp({arrowWidth:_,arrowHeight:O}),h&&hp({strategy:"referenceHidden",...D})]}),[M,H]=Pi(T),Z=ge(v);Fe(()=>{z&&(Z==null||Z())},[z,Z]);const V=(J=$.arrow)==null?void 0:J.x,G=(Pe=$.arrow)==null?void 0:Pe.y,B=((he=$.arrow)==null?void 0:he.centerOffset)!==0,[re,ue]=f.useState();return Fe(()=>{C&&ue(window.getComputedStyle(C).zIndex)},[C]),s.jsx("div",{ref:E.setFloating,"data-radix-popper-content-wrapper":"",style:{...F,transform:z?F.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:re,"--radix-popper-transform-origin":[(ze=$.transformOrigin)==null?void 0:ze.x,(Ae=$.transformOrigin)==null?void 0:Ae.y].join(" "),...((Ve=$.hide)==null?void 0:Ve.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(bp,{scope:n,placedSide:M,onArrowChange:j,arrowX:V,arrowY:G,shouldHideArrow:B,children:s.jsx(K.div,{"data-side":M,"data-align":H,...g,ref:b,style:{...g.style,animation:z?void 0:"none"}})})})});Ti.displayName=ps;var Ri="PopperArrow",Cp={top:"bottom",right:"left",bottom:"top",left:"right"},ki=f.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=wp(Ri,r),c=Cp[a.placedSide];return s.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:s.jsx(vp,{...o,ref:n,style:{...o.style,display:"block"}})})});ki.displayName=Ri;function Sp(e){return e!==null}var jp=e=>({name:"transformOrigin",options:e,fn(t){var x,C,w;const{placement:n,rects:r,middlewareData:o}=t,c=((x=o.arrow)==null?void 0:x.centerOffset)!==0,i=c?0:e.arrowWidth,l=c?0:e.arrowHeight,[d,u]=Pi(n),m={start:"0%",center:"50%",end:"100%"}[u],h=(((C=o.arrow)==null?void 0:C.x)??0)+i/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let v="",g="";return d==="bottom"?(v=c?m:`${h}px`,g=`${-l}px`):d==="top"?(v=c?m:`${h}px`,g=`${r.floating.height+l}px`):d==="right"?(v=`${-l}px`,g=c?m:`${p}px`):d==="left"&&(v=`${r.floating.width+l}px`,g=c?m:`${p}px`),{data:{x:v,y:g}}}});function Pi(e){const[t,n="center"]=e.split("-");return[t,n]}var Ai=_i,Oi=Mi,Di=Ti,Ii=ki,Np="Portal",Lr=f.forwardRef((e,t)=>{var i;const{container:n,...r}=e,[o,a]=f.useState(!1);Fe(()=>a(!0),[]);const c=n||o&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return c?ts.createPortal(s.jsx(K.div,{...r,ref:t}),c):null});Lr.displayName=Np;function _p(e,t){return f.useReducer((n,r)=>t[n][r]??n,e)}var Ee=e=>{const{present:t,children:n}=e,r=Ep(t),o=typeof n=="function"?n({present:r.isPresent}):f.Children.only(n),a=ae(r.ref,Mp(o));return typeof n=="function"||r.isPresent?f.cloneElement(o,{ref:a}):null};Ee.displayName="Presence";function Ep(e){const[t,n]=f.useState(),r=f.useRef(null),o=f.useRef(e),a=f.useRef("none"),c=e?"mounted":"unmounted",[i,l]=_p(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return f.useEffect(()=>{const d=er(r.current);a.current=i==="mounted"?d:"none"},[i]),Fe(()=>{const d=r.current,u=o.current;if(u!==e){const h=a.current,p=er(d);e?l("MOUNT"):p==="none"||(d==null?void 0:d.display)==="none"?l("UNMOUNT"):l(u&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Fe(()=>{if(t){let d;const u=t.ownerDocument.defaultView??window,m=p=>{const g=er(r.current).includes(p.animationName);if(p.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",d=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},h=p=>{p.target===t&&(a.current=er(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{u.clearTimeout(d),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:f.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function er(e){return(e==null?void 0:e.animationName)||"none"}function Mp(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Tp=f[" useInsertionEffect ".trim().toString()]||Fe;function qt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,c]=Rp({defaultProp:t,onChange:n}),i=e!==void 0,l=i?e:o;{const u=f.useRef(e!==void 0);f.useEffect(()=>{const m=u.current;m!==i&&console.warn(`${r} is changing from ${m?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=i},[i,r])}const d=f.useCallback(u=>{var m;if(i){const h=kp(u)?u(e):u;h!==e&&((m=c.current)==null||m.call(c,h))}else a(u)},[i,e,a,c]);return[l,d]}function Rp({defaultProp:e,onChange:t}){const[n,r]=f.useState(e),o=f.useRef(n),a=f.useRef(t);return Tp(()=>{a.current=t},[t]),f.useEffect(()=>{var c;o.current!==n&&((c=a.current)==null||c.call(a,n),o.current=n)},[n,o]),[n,r,a]}function kp(e){return typeof e=="function"}var Pp=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"}),Ap="VisuallyHidden",$r=f.forwardRef((e,t)=>s.jsx(K.span,{...e,ref:t,style:{...Pp,...e.style}}));$r.displayName=Ap;var Op=$r,[Fr,X0]=ke("Tooltip",[Ir]),hs=Ir(),Li="TooltipProvider",Dp=700,ya="tooltip.open",[Ip,$i]=Fr(Li),Fi=e=>{const{__scopeTooltip:t,delayDuration:n=Dp,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:a}=e,c=f.useRef(!0),i=f.useRef(!1),l=f.useRef(0);return f.useEffect(()=>{const d=l.current;return()=>window.clearTimeout(d)},[]),s.jsx(Ip,{scope:t,isOpenDelayedRef:c,delayDuration:n,onOpen:f.useCallback(()=>{window.clearTimeout(l.current),c.current=!1},[]),onClose:f.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>c.current=!0,r)},[r]),isPointerInTransitRef:i,onPointerInTransitChange:f.useCallback(d=>{i.current=d},[]),disableHoverableContent:o,children:a})};Fi.displayName=Li;var zi="Tooltip",[Q0,zr]=Fr(zi),Po="TooltipTrigger",Lp=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=zr(Po,n),a=$i(Po,n),c=hs(n),i=f.useRef(null),l=ae(t,i,o.onTriggerChange),d=f.useRef(!1),u=f.useRef(!1),m=f.useCallback(()=>d.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),s.jsx(Oi,{asChild:!0,...c,children:s.jsx(K.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:L(e.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),u.current=!0)}),onPointerLeave:L(e.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:L(e.onPointerDown,()=>{o.open&&o.onClose(),d.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:L(e.onFocus,()=>{d.current||o.onOpen()}),onBlur:L(e.onBlur,o.onClose),onClick:L(e.onClick,o.onClose)})})});Lp.displayName=Po;var $p="TooltipPortal",[Z0,Fp]=Fr($p,{forceMount:void 0}),fn="TooltipContent",Wi=f.forwardRef((e,t)=>{const n=Fp(fn,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...a}=e,c=zr(fn,e.__scopeTooltip);return s.jsx(Ee,{present:r||c.open,children:c.disableHoverableContent?s.jsx(Bi,{side:o,...a,ref:t}):s.jsx(zp,{side:o,...a,ref:t})})}),zp=f.forwardRef((e,t)=>{const n=zr(fn,e.__scopeTooltip),r=$i(fn,e.__scopeTooltip),o=f.useRef(null),a=ae(t,o),[c,i]=f.useState(null),{trigger:l,onClose:d}=n,u=o.current,{onPointerInTransitChange:m}=r,h=f.useCallback(()=>{i(null),m(!1)},[m]),p=f.useCallback((v,g)=>{const x=v.currentTarget,C={x:v.clientX,y:v.clientY},w=Hp(C,x.getBoundingClientRect()),b=Vp(C,w),S=Gp(g.getBoundingClientRect()),j=Kp([...b,...S]);i(j),m(!0)},[m]);return f.useEffect(()=>()=>h(),[h]),f.useEffect(()=>{if(l&&u){const v=x=>p(x,u),g=x=>p(x,l);return l.addEventListener("pointerleave",v),u.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),u.removeEventListener("pointerleave",g)}}},[l,u,p,h]),f.useEffect(()=>{if(c){const v=g=>{const x=g.target,C={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(u==null?void 0:u.contains(x)),b=!Yp(C,c);w?h():b&&(h(),d())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,u,c,d,h]),s.jsx(Bi,{...e,ref:a})}),[Wp,Bp]=Fr(zi,{isInside:!1}),qp=ii("TooltipContent"),Bi=f.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:c,...i}=e,l=zr(fn,n),d=hs(n),{onClose:u}=l;return f.useEffect(()=>(document.addEventListener(ya,u),()=>document.removeEventListener(ya,u)),[u]),f.useEffect(()=>{if(l.trigger){const m=h=>{const p=h.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",m,{capture:!0}),()=>window.removeEventListener("scroll",m,{capture:!0})}},[l.trigger,u]),s.jsx(Fn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:m=>m.preventDefault(),onDismiss:u,children:s.jsxs(Di,{"data-state":l.stateAttribute,...d,...i,ref:t,style:{...i.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:[s.jsx(qp,{children:r}),s.jsx(Wp,{scope:n,isInside:!0,children:s.jsx(Op,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Wi.displayName=fn;var qi="TooltipArrow",Up=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hs(n);return Bp(qi,n).isInside?null:s.jsx(Ii,{...o,...r,ref:t})});Up.displayName=qi;function Hp(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,o,a)){case a:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Vp(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 Gp(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 Yp(e,t){const{x:n,y:r}=e;let o=!1;for(let a=0,c=t.length-1;a<t.length;c=a++){const i=t[a],l=t[c],d=i.x,u=i.y,m=l.x,h=l.y;u>r!=h>r&&n<(m-d)*(r-u)/(h-u)+d&&(o=!o)}return o}function Kp(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),Xp(t)}function Xp(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 a=t[t.length-1],c=t[t.length-2];if((a.x-c.x)*(o.y-c.y)>=(a.y-c.y)*(o.x-c.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 a=n[n.length-1],c=n[n.length-2];if((a.x-c.x)*(o.y-c.y)>=(a.y-c.y)*(o.x-c.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 Qp=Fi,Ui=Wi;function Hi(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Hi(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Vi(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Hi(e))&&(r&&(r+=" "),r+=t);return r}const gs="-",Zp=e=>{const t=eh(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{const i=c.split(gs);return i[0]===""&&i.length!==1&&i.shift(),Gi(i,t)||Jp(c)},getConflictingClassGroupIds:(c,i)=>{const l=n[c]||[];return i&&r[c]?[...l,...r[c]]:l}}},Gi=(e,t)=>{var c;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),o=r?Gi(e.slice(1),r):void 0;if(o)return o;if(t.validators.length===0)return;const a=e.join(gs);return(c=t.validators.find(({validator:i})=>i(a)))==null?void 0:c.classGroupId},ba=/^\[(.+)\]$/,Jp=e=>{if(ba.test(e)){const t=ba.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},eh=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return nh(Object.entries(e.classGroups),n).forEach(([a,c])=>{Ao(c,r,a,t)}),r},Ao=(e,t,n,r)=>{e.forEach(o=>{if(typeof o=="string"){const a=o===""?t:wa(t,o);a.classGroupId=n;return}if(typeof o=="function"){if(th(o)){Ao(o(r),t,n,r);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([a,c])=>{Ao(c,wa(t,a),n,r)})})},wa=(e,t)=>{let n=e;return t.split(gs).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},th=e=>e.isThemeGetter,nh=(e,t)=>t?e.map(([n,r])=>{const o=r.map(a=>typeof a=="string"?t+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([c,i])=>[t+c,i])):a);return[n,o]}):e,rh=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const o=(a,c)=>{n.set(a,c),t++,t>e&&(t=0,r=n,n=new Map)};return{get(a){let c=n.get(a);if(c!==void 0)return c;if((c=r.get(a))!==void 0)return o(a,c),c},set(a,c){n.has(a)?n.set(a,c):o(a,c)}}},Yi="!",oh=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,o=t[0],a=t.length,c=i=>{const l=[];let d=0,u=0,m;for(let x=0;x<i.length;x++){let C=i[x];if(d===0){if(C===o&&(r||i.slice(x,x+a)===t)){l.push(i.slice(u,x)),u=x+a;continue}if(C==="/"){m=x;continue}}C==="["?d++:C==="]"&&d--}const h=l.length===0?i:i.substring(u),p=h.startsWith(Yi),v=p?h.substring(1):h,g=m&&m>u?m-u:void 0;return{modifiers:l,hasImportantModifier:p,baseClassName:v,maybePostfixModifierPosition:g}};return n?i=>n({className:i,parseClassName:c}):c},sh=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},ah=e=>({cache:rh(e.cacheSize),parseClassName:oh(e),...Zp(e)}),ih=/\s+/,ch=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o}=t,a=[],c=e.trim().split(ih);let i="";for(let l=c.length-1;l>=0;l-=1){const d=c[l],{modifiers:u,hasImportantModifier:m,baseClassName:h,maybePostfixModifierPosition:p}=n(d);let v=!!p,g=r(v?h.substring(0,p):h);if(!g){if(!v){i=d+(i.length>0?" "+i:i);continue}if(g=r(h),!g){i=d+(i.length>0?" "+i:i);continue}v=!1}const x=sh(u).join(":"),C=m?x+Yi:x,w=C+g;if(a.includes(w))continue;a.push(w);const b=o(g,v);for(let S=0;S<b.length;++S){const j=b[S];a.push(C+j)}i=d+(i.length>0?" "+i:i)}return i};function lh(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Ki(t))&&(r&&(r+=" "),r+=n);return r}const Ki=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Ki(e[r]))&&(n&&(n+=" "),n+=t);return n};function dh(e,...t){let n,r,o,a=c;function c(l){const d=t.reduce((u,m)=>m(u),e());return n=ah(d),r=n.cache.get,o=n.cache.set,a=i,i(l)}function i(l){const d=r(l);if(d)return d;const u=ch(l,n);return o(l,u),u}return function(){return a(lh.apply(null,arguments))}}const pe=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Xi=/^\[(?:([a-z-]+):)?(.+)\]$/i,uh=/^\d+\/\d+$/,fh=new Set(["px","full","screen"]),mh=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ph=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,hh=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,gh=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,xh=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,pt=e=>rn(e)||fh.has(e)||uh.test(e),wt=e=>gn(e,"length",Nh),rn=e=>!!e&&!Number.isNaN(Number(e)),ao=e=>gn(e,"number",rn),Nn=e=>!!e&&Number.isInteger(Number(e)),vh=e=>e.endsWith("%")&&rn(e.slice(0,-1)),ee=e=>Xi.test(e),Ct=e=>mh.test(e),yh=new Set(["length","size","percentage"]),bh=e=>gn(e,yh,Qi),wh=e=>gn(e,"position",Qi),Ch=new Set(["image","url"]),Sh=e=>gn(e,Ch,Eh),jh=e=>gn(e,"",_h),_n=()=>!0,gn=(e,t,n)=>{const r=Xi.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},Nh=e=>ph.test(e)&&!hh.test(e),Qi=()=>!1,_h=e=>gh.test(e),Eh=e=>xh.test(e),Mh=()=>{const e=pe("colors"),t=pe("spacing"),n=pe("blur"),r=pe("brightness"),o=pe("borderColor"),a=pe("borderRadius"),c=pe("borderSpacing"),i=pe("borderWidth"),l=pe("contrast"),d=pe("grayscale"),u=pe("hueRotate"),m=pe("invert"),h=pe("gap"),p=pe("gradientColorStops"),v=pe("gradientColorStopPositions"),g=pe("inset"),x=pe("margin"),C=pe("opacity"),w=pe("padding"),b=pe("saturate"),S=pe("scale"),j=pe("sepia"),N=pe("skew"),_=pe("space"),O=pe("translate"),k=()=>["auto","contain","none"],P=()=>["auto","hidden","clip","visible","scroll"],I=()=>["auto",ee,t],A=()=>[ee,t],D=()=>["",pt,wt],E=()=>["auto",rn,ee],F=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],T=()=>["solid","dashed","dotted","double","none"],z=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],$=()=>["start","end","center","between","around","evenly","stretch"],M=()=>["","0",ee],H=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Z=()=>[rn,ee];return{cacheSize:500,separator:":",theme:{colors:[_n],spacing:[pt,wt],blur:["none","",Ct,ee],brightness:Z(),borderColor:[e],borderRadius:["none","","full",Ct,ee],borderSpacing:A(),borderWidth:D(),contrast:Z(),grayscale:M(),hueRotate:Z(),invert:M(),gap:A(),gradientColorStops:[e],gradientColorStopPositions:[vh,wt],inset:I(),margin:I(),opacity:Z(),padding:A(),saturate:Z(),scale:Z(),sepia:M(),skew:Z(),space:A(),translate:A()},classGroups:{aspect:[{aspect:["auto","square","video",ee]}],container:["container"],columns:[{columns:[Ct]}],"break-after":[{"break-after":H()}],"break-before":[{"break-before":H()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...F(),ee]}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Nn,ee]}],basis:[{basis:I()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ee]}],grow:[{grow:M()}],shrink:[{shrink:M()}],order:[{order:["first","last","none",Nn,ee]}],"grid-cols":[{"grid-cols":[_n]}],"col-start-end":[{col:["auto",{span:["full",Nn,ee]},ee]}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":[_n]}],"row-start-end":[{row:["auto",{span:[Nn,ee]},ee]}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ee]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ee]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...$()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...$(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...$(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[w]}],px:[{px:[w]}],py:[{py:[w]}],ps:[{ps:[w]}],pe:[{pe:[w]}],pt:[{pt:[w]}],pr:[{pr:[w]}],pb:[{pb:[w]}],pl:[{pl:[w]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[_]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[_]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ee,t]}],"min-w":[{"min-w":[ee,t,"min","max","fit"]}],"max-w":[{"max-w":[ee,t,"none","full","min","max","fit","prose",{screen:[Ct]},Ct]}],h:[{h:[ee,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ee,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ee,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ee,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Ct,wt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",ao]}],"font-family":[{font:[_n]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ee]}],"line-clamp":[{"line-clamp":["none",rn,ao]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",pt,ee]}],"list-image":[{"list-image":["none",ee]}],"list-style-type":[{list:["none","disc","decimal",ee]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[C]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[C]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...T(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",pt,wt]}],"underline-offset":[{"underline-offset":["auto",pt,ee]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:A()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ee]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ee]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[C]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...F(),wh]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",bh]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Sh]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[v]}],"gradient-via-pos":[{via:[v]}],"gradient-to-pos":[{to:[v]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[i]}],"border-w-x":[{"border-x":[i]}],"border-w-y":[{"border-y":[i]}],"border-w-s":[{"border-s":[i]}],"border-w-e":[{"border-e":[i]}],"border-w-t":[{"border-t":[i]}],"border-w-r":[{"border-r":[i]}],"border-w-b":[{"border-b":[i]}],"border-w-l":[{"border-l":[i]}],"border-opacity":[{"border-opacity":[C]}],"border-style":[{border:[...T(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[C]}],"divide-style":[{divide:T()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...T()]}],"outline-offset":[{"outline-offset":[pt,ee]}],"outline-w":[{outline:[pt,wt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:D()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[C]}],"ring-offset-w":[{"ring-offset":[pt,wt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Ct,jh]}],"shadow-color":[{shadow:[_n]}],opacity:[{opacity:[C]}],"mix-blend":[{"mix-blend":[...z(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":z()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Ct,ee]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[m]}],saturate:[{saturate:[b]}],sepia:[{sepia:[j]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[m]}],"backdrop-opacity":[{"backdrop-opacity":[C]}],"backdrop-saturate":[{"backdrop-saturate":[b]}],"backdrop-sepia":[{"backdrop-sepia":[j]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ee]}],duration:[{duration:Z()}],ease:[{ease:["linear","in","out","in-out",ee]}],delay:[{delay:Z()}],animate:[{animate:["none","spin","ping","pulse","bounce",ee]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[Nn,ee]}],"translate-x":[{"translate-x":[O]}],"translate-y":[{"translate-y":[O]}],"skew-x":[{"skew-x":[N]}],"skew-y":[{"skew-y":[N]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ee]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ee]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ee]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[pt,wt,ao]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},Th=dh(Mh);function W(...e){return Th(Vi(e))}const Rh=Qp,kh=f.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(Ui,{ref:r,sideOffset:t,className:W("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}));kh.displayName=Ui.displayName;const Ph=1,Ah=1e6;let io=0;function Oh(){return io=(io+1)%Number.MAX_SAFE_INTEGER,io.toString()}const co=new Map,Ca=e=>{if(co.has(e))return;const t=setTimeout(()=>{co.delete(e),Pn({type:"REMOVE_TOAST",toastId:e})},Ah);co.set(e,t)},Dh=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Ph)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?Ca(n):e.toasts.forEach(r=>{Ca(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},ur=[];let fr={toasts:[]};function Pn(e){fr=Dh(fr,e),ur.forEach(t=>{t(fr)})}function Ih({...e}){const t=Oh(),n=o=>Pn({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Pn({type:"DISMISS_TOAST",toastId:t});return Pn({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function xn(){const[e,t]=f.useState(fr);return f.useEffect(()=>(ur.push(t),()=>{const n=ur.indexOf(t);n>-1&&ur.splice(n,1)}),[e]),{...e,toast:Ih,dismiss:n=>Pn({type:"DISMISS_TOAST",toastId:n})}}function xs(e){const t=e+"CollectionProvider",[n,r]=ke(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=g=>{const{scope:x,children:C}=g,w=y.useRef(null),b=y.useRef(new Map).current;return s.jsx(o,{scope:x,itemMap:b,collectionRef:w,children:C})};c.displayName=t;const i=e+"CollectionSlot",l=dn(i),d=y.forwardRef((g,x)=>{const{scope:C,children:w}=g,b=a(i,C),S=ae(x,b.collectionRef);return s.jsx(l,{ref:S,children:w})});d.displayName=i;const u=e+"CollectionItemSlot",m="data-radix-collection-item",h=dn(u),p=y.forwardRef((g,x)=>{const{scope:C,children:w,...b}=g,S=y.useRef(null),j=ae(x,S),N=a(u,C);return y.useEffect(()=>(N.itemMap.set(S,{ref:S,...b}),()=>void N.itemMap.delete(S))),s.jsx(h,{[m]:"",ref:j,children:w})});p.displayName=u;function v(g){const x=a(e+"CollectionConsumer",g);return y.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const b=Array.from(w.querySelectorAll(`[${m}]`));return Array.from(x.itemMap.values()).sort((N,_)=>b.indexOf(N.ref.current)-b.indexOf(_.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:c,Slot:d,ItemSlot:p},v,r]}var vs="ToastProvider",[ys,Lh,$h]=xs("Toast"),[Zi,J0]=ke("Toast",[$h]),[Fh,Wr]=Zi(vs),Ji=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:a=50,children:c}=e,[i,l]=f.useState(null),[d,u]=f.useState(0),m=f.useRef(!1),h=f.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${vs}\`. Expected non-empty \`string\`.`),s.jsx(ys.Provider,{scope:t,children:s.jsx(Fh,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:a,toastCount:d,viewport:i,onViewportChange:l,onToastAdd:f.useCallback(()=>u(p=>p+1),[]),onToastRemove:f.useCallback(()=>u(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:m,isClosePausedRef:h,children:c})})};Ji.displayName=vs;var ec="ToastViewport",zh=["F8"],Oo="toast.viewportPause",Do="toast.viewportResume",tc=f.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=zh,label:o="Notifications ({hotkey})",...a}=e,c=Wr(ec,n),i=Lh(n),l=f.useRef(null),d=f.useRef(null),u=f.useRef(null),m=f.useRef(null),h=ae(t,m,c.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=c.toastCount>0;f.useEffect(()=>{const x=C=>{var b;r.length!==0&&r.every(S=>C[S]||C.code===S)&&((b=m.current)==null||b.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),f.useEffect(()=>{const x=l.current,C=m.current;if(v&&x&&C){const w=()=>{if(!c.isClosePausedRef.current){const N=new CustomEvent(Oo);C.dispatchEvent(N),c.isClosePausedRef.current=!0}},b=()=>{if(c.isClosePausedRef.current){const N=new CustomEvent(Do);C.dispatchEvent(N),c.isClosePausedRef.current=!1}},S=N=>{!x.contains(N.relatedTarget)&&b()},j=()=>{x.contains(document.activeElement)||b()};return x.addEventListener("focusin",w),x.addEventListener("focusout",S),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",j),window.addEventListener("blur",w),window.addEventListener("focus",b),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",S),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",j),window.removeEventListener("blur",w),window.removeEventListener("focus",b)}}},[v,c.isClosePausedRef]);const g=f.useCallback(({tabbingDirection:x})=>{const w=i().map(b=>{const S=b.ref.current,j=[S,...Jh(S)];return x==="forwards"?j:j.reverse()});return(x==="forwards"?w.reverse():w).flat()},[i]);return f.useEffect(()=>{const x=m.current;if(x){const C=w=>{var j,N,_;const b=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!b){const O=document.activeElement,k=w.shiftKey;if(w.target===x&&k){(j=d.current)==null||j.focus();return}const A=g({tabbingDirection:k?"backwards":"forwards"}),D=A.findIndex(E=>E===O);lo(A.slice(D+1))?w.preventDefault():k?(N=d.current)==null||N.focus():(_=u.current)==null||_.focus()}};return x.addEventListener("keydown",C),()=>x.removeEventListener("keydown",C)}},[i,g]),s.jsxs(om,{ref:l,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&s.jsx(Io,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});lo(x)}}),s.jsx(ys.Slot,{scope:n,children:s.jsx(K.ol,{tabIndex:-1,...a,ref:h})}),v&&s.jsx(Io,{ref:u,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});lo(x)}})]})});tc.displayName=ec;var nc="ToastFocusProxy",Io=f.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,a=Wr(nc,n);return s.jsx($r,{"aria-hidden":!0,tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:c=>{var d;const i=c.relatedTarget;!((d=a.viewport)!=null&&d.contains(i))&&r()}})});Io.displayName=nc;var Wn="Toast",Wh="toast.swipeStart",Bh="toast.swipeMove",qh="toast.swipeCancel",Uh="toast.swipeEnd",rc=f.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:a,...c}=e,[i,l]=qt({prop:r,defaultProp:o??!0,onChange:a,caller:Wn});return s.jsx(Ee,{present:n||i,children:s.jsx(Gh,{open:i,...c,ref:t,onClose:()=>l(!1),onPause:ge(e.onPause),onResume:ge(e.onResume),onSwipeStart:L(e.onSwipeStart,d=>{d.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:L(e.onSwipeMove,d=>{const{x:u,y:m}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","move"),d.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${u}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${m}px`)}),onSwipeCancel:L(e.onSwipeCancel,d=>{d.currentTarget.setAttribute("data-swipe","cancel"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:L(e.onSwipeEnd,d=>{const{x:u,y:m}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","end"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${u}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${m}px`),l(!1)})})})});rc.displayName=Wn;var[Hh,Vh]=Zi(Wn,{onClose(){}}),Gh=f.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:a,onClose:c,onEscapeKeyDown:i,onPause:l,onResume:d,onSwipeStart:u,onSwipeMove:m,onSwipeCancel:h,onSwipeEnd:p,...v}=e,g=Wr(Wn,n),[x,C]=f.useState(null),w=ae(t,E=>C(E)),b=f.useRef(null),S=f.useRef(null),j=o||g.duration,N=f.useRef(0),_=f.useRef(j),O=f.useRef(0),{onToastAdd:k,onToastRemove:P}=g,I=ge(()=>{var F;(x==null?void 0:x.contains(document.activeElement))&&((F=g.viewport)==null||F.focus()),c()}),A=f.useCallback(E=>{!E||E===1/0||(window.clearTimeout(O.current),N.current=new Date().getTime(),O.current=window.setTimeout(I,E))},[I]);f.useEffect(()=>{const E=g.viewport;if(E){const F=()=>{A(_.current),d==null||d()},T=()=>{const z=new Date().getTime()-N.current;_.current=_.current-z,window.clearTimeout(O.current),l==null||l()};return E.addEventListener(Oo,T),E.addEventListener(Do,F),()=>{E.removeEventListener(Oo,T),E.removeEventListener(Do,F)}}},[g.viewport,j,l,d,A]),f.useEffect(()=>{a&&!g.isClosePausedRef.current&&A(j)},[a,j,g.isClosePausedRef,A]),f.useEffect(()=>(k(),()=>P()),[k,P]);const D=f.useMemo(()=>x?dc(x):null,[x]);return g.viewport?s.jsxs(s.Fragment,{children:[D&&s.jsx(Yh,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:D}),s.jsx(Hh,{scope:n,onClose:I,children:ns.createPortal(s.jsx(ys.ItemSlot,{scope:n,children:s.jsx(rm,{asChild:!0,onEscapeKeyDown:L(i,()=>{g.isFocusedToastEscapeKeyDownRef.current||I(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:s.jsx(K.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":a?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:L(e.onKeyDown,E=>{E.key==="Escape"&&(i==null||i(E.nativeEvent),E.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,I()))}),onPointerDown:L(e.onPointerDown,E=>{E.button===0&&(b.current={x:E.clientX,y:E.clientY})}),onPointerMove:L(e.onPointerMove,E=>{if(!b.current)return;const F=E.clientX-b.current.x,T=E.clientY-b.current.y,z=!!S.current,$=["left","right"].includes(g.swipeDirection),M=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,H=$?M(0,F):0,Z=$?0:M(0,T),V=E.pointerType==="touch"?10:2,G={x:H,y:Z},B={originalEvent:E,delta:G};z?(S.current=G,tr(Bh,m,B,{discrete:!1})):Sa(G,g.swipeDirection,V)?(S.current=G,tr(Wh,u,B,{discrete:!1}),E.target.setPointerCapture(E.pointerId)):(Math.abs(F)>V||Math.abs(T)>V)&&(b.current=null)}),onPointerUp:L(e.onPointerUp,E=>{const F=S.current,T=E.target;if(T.hasPointerCapture(E.pointerId)&&T.releasePointerCapture(E.pointerId),S.current=null,b.current=null,F){const z=E.currentTarget,$={originalEvent:E,delta:F};Sa(F,g.swipeDirection,g.swipeThreshold)?tr(Uh,p,$,{discrete:!0}):tr(qh,h,$,{discrete:!0}),z.addEventListener("click",M=>M.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),Yh=e=>{const{__scopeToast:t,children:n,...r}=e,o=Wr(Wn,t),[a,c]=f.useState(!1),[i,l]=f.useState(!1);return Qh(()=>c(!0)),f.useEffect(()=>{const d=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(d)},[]),i?null:s.jsx(Lr,{asChild:!0,children:s.jsx($r,{...r,children:a&&s.jsxs(s.Fragment,{children:[o.label," ",n]})})})},Kh="ToastTitle",oc=f.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return s.jsx(K.div,{...r,ref:t})});oc.displayName=Kh;var Xh="ToastDescription",sc=f.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return s.jsx(K.div,{...r,ref:t})});sc.displayName=Xh;var ac="ToastAction",ic=f.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?s.jsx(lc,{altText:n,asChild:!0,children:s.jsx(bs,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${ac}\`. Expected non-empty \`string\`.`),null)});ic.displayName=ac;var cc="ToastClose",bs=f.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=Vh(cc,n);return s.jsx(lc,{asChild:!0,children:s.jsx(K.button,{type:"button",...r,ref:t,onClick:L(e.onClick,o.onClose)})})});bs.displayName=cc;var lc=f.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return s.jsx(K.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function dc(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),Zh(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",a=r.dataset.radixToastAnnounceExclude==="";if(!o)if(a){const c=r.dataset.radixToastAnnounceAlt;c&&t.push(c)}else t.push(...dc(r))}}),t}function tr(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,a=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?ss(o,a):o.dispatchEvent(a)}var Sa=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),a=r>o;return t==="left"||t==="right"?a&&r>n:!a&&o>n};function Qh(e=()=>{}){const t=ge(e);Fe(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function Zh(e){return e.nodeType===e.ELEMENT_NODE}function Jh(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function lo(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var eg=Ji,uc=tc,fc=rc,mc=oc,pc=sc,hc=ic,gc=bs;const ja=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Na=Vi,ws=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Na(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:a}=t,c=Object.keys(o).map(d=>{const u=n==null?void 0:n[d],m=a==null?void 0:a[d];if(u===null)return null;const h=ja(u)||ja(m);return o[d][h]}),i=n&&Object.entries(n).reduce((d,u)=>{let[m,h]=u;return h===void 0||(d[m]=h),d},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,u)=>{let{class:m,className:h,...p}=u;return Object.entries(p).every(v=>{let[g,x]=v;return Array.isArray(x)?x.includes({...a,...i}[g]):{...a,...i}[g]===x})?[...d,m,h]:d},[]);return Na(e,c,l,n==null?void 0:n.class,n==null?void 0:n.className)};/**
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),y=require("react"),es=require("@supabase/supabase-js"),oe=require("@tanstack/react-query"),ts=require("react-dom"),_o=require("@emoji-mart/data"),Eo=require("@emoji-mart/react");function ni(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const f=ni(y),ns=ni(ts),ri=y.createContext(null),oi=()=>{const e=y.useContext(ri);if(!e)throw new Error("useQuickChat must be used within QuickChatProvider");return e},ve=()=>oi().supabase,rs=()=>oi().config,$f=({supabaseUrl:e,supabaseAnonKey:t,config:n,queryClient:r,children:o})=>{const[a]=y.useState(()=>new oe.QueryClient),c=r??a,i=y.useMemo(()=>es.createClient(e,t,{auth:{storage:typeof window<"u"?localStorage:void 0,persistSession:!0,autoRefreshToken:!0}}),[e,t]),l=y.useMemo(()=>({supabase:i,config:n}),[i,n]);return s.jsx(oe.QueryClientProvider,{client:c,children:s.jsx(ri.Provider,{value:l,children:o})})},Ff=({children:e,userData:t,supabase:n})=>{const[r,o]=y.useState(null),[a,c]=y.useState(!0),[i,l]=y.useState(null);if(y.useEffect(()=>{if(!t){c(!1);return}if(!t.accessToken){console.warn("[QuickChat] authMode='external' — userData.accessToken is missing. auth.uid() will be NULL and DB/storage operations will fail. Generate a Supabase JWT via the Admin API for full functionality."),c(!1);return}if(!t.refreshToken){console.warn("[QuickChat] authMode='external' — userData.refreshToken is missing. Proceeding without a full Supabase session; token refresh will not work. Pass refreshToken alongside accessToken for full functionality."),c(!1);return}n.auth.setSession({access_token:t.accessToken,refresh_token:t.refreshToken}).then(({data:m,error:h})=>{h?(l(h.message),console.error("[QuickChat] Failed to set Supabase session:",h.message)):o(m.session)}).finally(()=>c(!1))},[t==null?void 0:t.accessToken,n]),i)return s.jsxs("div",{style:{padding:16,color:"red",fontFamily:"sans-serif"},children:[s.jsx("strong",{children:"QuickChat config error:"})," ",i]});const d=t?{id:t.id,email:t.email??"",user_metadata:{display_name:t.name,avatar_url:t.avatar}}:null,u=async()=>{await n.auth.signOut()};return s.jsx(os.Provider,{value:{session:r,user:d,loading:a,authMode:"external",signOut:u},children:e})},os=y.createContext({session:null,user:null,loading:!0,authMode:"built-in",signOut:async()=>{}}),ye=()=>y.useContext(os),zf=({children:e,authMode:t="built-in",userData:n})=>{const r=ve(),[o,a]=y.useState(null),[c,i]=y.useState(t==="built-in");y.useEffect(()=>{if(t==="external")return;const{data:{subscription:d}}=r.auth.onAuthStateChange((u,m)=>{a(m),i(!1)});return r.auth.getSession().then(({data:{session:u}})=>{a(u),i(!1)}),()=>d.unsubscribe()},[r,t]);const l=async()=>{await r.auth.signOut()};return t==="external"?s.jsx(Ff,{userData:n,supabase:r,children:e}):s.jsx(os.Provider,{value:{session:o,user:(o==null?void 0:o.user)??null,loading:c,authMode:"built-in",signOut:l},children:e})},si=y.createContext({theme:"system",setTheme:()=>{},resolved:"light"}),Wf=()=>y.useContext(si),Bf=({children:e,initialTheme:t})=>{const[n,r]=y.useState(()=>t||localStorage.getItem("chat-theme")||"system"),o=l=>l==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":l,[a,c]=y.useState(o(n)),i=l=>{r(l),localStorage.setItem("chat-theme",l)};return y.useEffect(()=>{const l=o(n);if(c(l),document.documentElement.classList.toggle("dark",l==="dark"),n==="system"){const d=window.matchMedia("(prefers-color-scheme: dark)"),u=m=>{const h=m.matches?"dark":"light";c(h),document.documentElement.classList.toggle("dark",h==="dark")};return d.addEventListener("change",u),()=>d.removeEventListener("change",u)}},[n]),s.jsx(si.Provider,{value:{theme:n,setTheme:i,resolved:a},children:e})};function L(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function aa(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Pr(...e){return t=>{let n=!1;const r=e.map(o=>{const a=aa(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():aa(e[o],null)}}}}function ae(...e){return f.useCallback(Pr(...e),e)}function qf(e,t){const n=f.createContext(t),r=a=>{const{children:c,...i}=a,l=f.useMemo(()=>i,Object.values(i));return s.jsx(n.Provider,{value:l,children:c})};r.displayName=e+"Provider";function o(a){const c=f.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,o]}function ke(e,t=[]){let n=[];function r(a,c){const i=f.createContext(c),l=n.length;n=[...n,c];const d=m=>{var C;const{scope:h,children:p,...v}=m,g=((C=h==null?void 0:h[e])==null?void 0:C[l])||i,x=f.useMemo(()=>v,Object.values(v));return s.jsx(g.Provider,{value:x,children:p})};d.displayName=a+"Provider";function u(m,h){var g;const p=((g=h==null?void 0:h[e])==null?void 0:g[l])||i,v=f.useContext(p);if(v)return v;if(c!==void 0)return c;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[d,u]}const o=()=>{const a=n.map(c=>f.createContext(c));return function(i){const l=(i==null?void 0:i[e])||a;return f.useMemo(()=>({[`__scope${e}`]:{...i,[e]:l}}),[i,l])}};return o.scopeName=e,[r,Uf(o,...t)]}function Uf(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const c=r.reduce((i,{useScope:l,scopeName:d})=>{const m=l(a)[`__scope${d}`];return{...i,...m}},{});return f.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}function ln(e){const t=Vf(e),n=f.forwardRef((r,o)=>{const{children:a,...c}=r,i=f.Children.toArray(a),l=i.find(Gf);if(l){const d=l.props.children,u=i.map(m=>m===l?f.Children.count(d)>1?f.Children.only(null):f.isValidElement(d)?d.props.children:null:m);return s.jsx(t,{...c,ref:o,children:f.isValidElement(d)?f.cloneElement(d,void 0,u):null})}return s.jsx(t,{...c,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}var Hf=ln("Slot");function Vf(e){const t=f.forwardRef((n,r)=>{const{children:o,...a}=n;if(f.isValidElement(o)){const c=Kf(o),i=Yf(a,o.props);return o.type!==f.Fragment&&(i.ref=r?Pr(r,c):c),f.cloneElement(o,i)}return f.Children.count(o)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ai=Symbol("radix.slottable");function ii(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=ai,t}function Gf(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ai}function Yf(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...i)=>{const l=a(...i);return o(...i),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Kf(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],K=Xf.reduce((e,t)=>{const n=ln(`Primitive.${t}`),r=f.forwardRef((o,a)=>{const{asChild:c,...i}=o,l=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(l,{...i,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ss(e,t){e&&ns.flushSync(()=>e.dispatchEvent(t))}function ge(e){const t=f.useRef(e);return f.useEffect(()=>{t.current=e}),f.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Qf(e,t=globalThis==null?void 0:globalThis.document){const n=ge(e);f.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Zf="DismissableLayer",Mo="dismissableLayer.update",Jf="dismissableLayer.pointerDownOutside",em="dismissableLayer.focusOutside",ia,ci=f.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Fn=f.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:c,onDismiss:i,...l}=e,d=f.useContext(ci),[u,m]=f.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=f.useState({}),v=ae(t,_=>m(_)),g=Array.from(d.layers),[x]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),C=g.indexOf(x),w=u?g.indexOf(u):-1,b=d.layersWithOutsidePointerEventsDisabled.size>0,S=w>=C,j=nm(_=>{const O=_.target,k=[...d.branches].some(P=>P.contains(O));!S||k||(o==null||o(_),c==null||c(_),_.defaultPrevented||i==null||i())},h),N=rm(_=>{const O=_.target;[...d.branches].some(P=>P.contains(O))||(a==null||a(_),c==null||c(_),_.defaultPrevented||i==null||i())},h);return Qf(_=>{w===d.layers.size-1&&(r==null||r(_),!_.defaultPrevented&&i&&(_.preventDefault(),i()))},h),f.useEffect(()=>{if(u)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(ia=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(u)),d.layers.add(u),ca(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=ia)}},[u,h,n,d]),f.useEffect(()=>()=>{u&&(d.layers.delete(u),d.layersWithOutsidePointerEventsDisabled.delete(u),ca())},[u,d]),f.useEffect(()=>{const _=()=>p({});return document.addEventListener(Mo,_),()=>document.removeEventListener(Mo,_)},[]),s.jsx(K.div,{...l,ref:v,style:{pointerEvents:b?S?"auto":"none":void 0,...e.style},onFocusCapture:L(e.onFocusCapture,N.onFocusCapture),onBlurCapture:L(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:L(e.onPointerDownCapture,j.onPointerDownCapture)})});Fn.displayName=Zf;var tm="DismissableLayerBranch",li=f.forwardRef((e,t)=>{const n=f.useContext(ci),r=f.useRef(null),o=ae(t,r);return f.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(K.div,{...e,ref:o})});li.displayName=tm;function nm(e,t=globalThis==null?void 0:globalThis.document){const n=ge(e),r=f.useRef(!1),o=f.useRef(()=>{});return f.useEffect(()=>{const a=i=>{if(i.target&&!r.current){let l=function(){di(Jf,n,d,{discrete:!0})};const d={originalEvent:i};i.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function rm(e,t=globalThis==null?void 0:globalThis.document){const n=ge(e),r=f.useRef(!1);return f.useEffect(()=>{const o=a=>{a.target&&!r.current&&di(em,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function ca(){const e=new CustomEvent(Mo);document.dispatchEvent(e)}function di(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?ss(o,a):o.dispatchEvent(a)}var om=Fn,sm=li,Fe=globalThis!=null&&globalThis.document?f.useLayoutEffect:()=>{},am=f[" useId ".trim().toString()]||(()=>{}),im=0;function gt(e){const[t,n]=f.useState(am());return Fe(()=>{e||n(r=>r??String(im++))},[e]),e||(t?`radix-${t}`:"")}const cm=["top","right","bottom","left"],_t=Math.min,Le=Math.max,vr=Math.round,Jn=Math.floor,st=e=>({x:e,y:e}),lm={left:"right",right:"left",bottom:"top",top:"bottom"},dm={start:"end",end:"start"};function To(e,t,n){return Le(e,_t(t,n))}function xt(e,t){return typeof e=="function"?e(t):e}function vt(e){return e.split("-")[0]}function pn(e){return e.split("-")[1]}function as(e){return e==="x"?"y":"x"}function is(e){return e==="y"?"height":"width"}const um=new Set(["top","bottom"]);function ot(e){return um.has(vt(e))?"y":"x"}function cs(e){return as(ot(e))}function fm(e,t,n){n===void 0&&(n=!1);const r=pn(e),o=cs(e),a=is(o);let c=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(c=yr(c)),[c,yr(c)]}function mm(e){const t=yr(e);return[Ro(e),t,Ro(t)]}function Ro(e){return e.replace(/start|end/g,t=>dm[t])}const la=["left","right"],da=["right","left"],pm=["top","bottom"],hm=["bottom","top"];function gm(e,t,n){switch(e){case"top":case"bottom":return n?t?da:la:t?la:da;case"left":case"right":return t?pm:hm;default:return[]}}function xm(e,t,n,r){const o=pn(e);let a=gm(vt(e),n==="start",r);return o&&(a=a.map(c=>c+"-"+o),t&&(a=a.concat(a.map(Ro)))),a}function yr(e){return e.replace(/left|right|bottom|top/g,t=>lm[t])}function vm(e){return{top:0,right:0,bottom:0,left:0,...e}}function ui(e){return typeof e!="number"?vm(e):{top:e,right:e,bottom:e,left:e}}function br(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 ua(e,t,n){let{reference:r,floating:o}=e;const a=ot(t),c=cs(t),i=is(c),l=vt(t),d=a==="y",u=r.x+r.width/2-o.width/2,m=r.y+r.height/2-o.height/2,h=r[i]/2-o[i]/2;let p;switch(l){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:m};break;case"left":p={x:r.x-o.width,y:m};break;default:p={x:r.x,y:r.y}}switch(pn(t)){case"start":p[c]-=h*(n&&d?-1:1);break;case"end":p[c]+=h*(n&&d?-1:1);break}return p}const ym=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:c}=n,i=a.filter(Boolean),l=await(c.isRTL==null?void 0:c.isRTL(t));let d=await c.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:m}=ua(d,r,l),h=r,p={},v=0;for(let g=0;g<i.length;g++){const{name:x,fn:C}=i[g],{x:w,y:b,data:S,reset:j}=await C({x:u,y:m,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:d,platform:c,elements:{reference:e,floating:t}});u=w??u,m=b??m,p={...p,[x]:{...p[x],...S}},j&&v<=50&&(v++,typeof j=="object"&&(j.placement&&(h=j.placement),j.rects&&(d=j.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:o}):j.rects),{x:u,y:m}=ua(d,h,l)),g=-1)}return{x:u,y:m,placement:h,strategy:o,middlewareData:p}};async function An(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:a,rects:c,elements:i,strategy:l}=e,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:m="floating",altBoundary:h=!1,padding:p=0}=xt(t,e),v=ui(p),x=i[h?m==="floating"?"reference":"floating":m],C=br(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(x)))==null||n?x:x.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(i.floating)),boundary:d,rootBoundary:u,strategy:l})),w=m==="floating"?{x:r,y:o,width:c.floating.width,height:c.floating.height}:c.reference,b=await(a.getOffsetParent==null?void 0:a.getOffsetParent(i.floating)),S=await(a.isElement==null?void 0:a.isElement(b))?await(a.getScale==null?void 0:a.getScale(b))||{x:1,y:1}:{x:1,y:1},j=br(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:w,offsetParent:b,strategy:l}):w);return{top:(C.top-j.top+v.top)/S.y,bottom:(j.bottom-C.bottom+v.bottom)/S.y,left:(C.left-j.left+v.left)/S.x,right:(j.right-C.right+v.right)/S.x}}const bm=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:a,platform:c,elements:i,middlewareData:l}=t,{element:d,padding:u=0}=xt(e,t)||{};if(d==null)return{};const m=ui(u),h={x:n,y:r},p=cs(o),v=is(p),g=await c.getDimensions(d),x=p==="y",C=x?"top":"left",w=x?"bottom":"right",b=x?"clientHeight":"clientWidth",S=a.reference[v]+a.reference[p]-h[p]-a.floating[v],j=h[p]-a.reference[p],N=await(c.getOffsetParent==null?void 0:c.getOffsetParent(d));let _=N?N[b]:0;(!_||!await(c.isElement==null?void 0:c.isElement(N)))&&(_=i.floating[b]||a.floating[v]);const O=S/2-j/2,k=_/2-g[v]/2-1,P=_t(m[C],k),I=_t(m[w],k),A=P,D=_-g[v]-I,E=_/2-g[v]/2+O,F=To(A,E,D),T=!l.arrow&&pn(o)!=null&&E!==F&&a.reference[v]/2-(E<A?P:I)-g[v]/2<0,z=T?E<A?E-A:E-D:0;return{[p]:h[p]+z,data:{[p]:F,centerOffset:E-F-z,...T&&{alignmentOffset:z}},reset:T}}}),wm=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:a,rects:c,initialPlacement:i,platform:l,elements:d}=t,{mainAxis:u=!0,crossAxis:m=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=xt(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const C=vt(o),w=ot(i),b=vt(i)===i,S=await(l.isRTL==null?void 0:l.isRTL(d.floating)),j=h||(b||!g?[yr(i)]:mm(i)),N=v!=="none";!h&&N&&j.push(...xm(i,g,v,S));const _=[i,...j],O=await An(t,x),k=[];let P=((r=a.flip)==null?void 0:r.overflows)||[];if(u&&k.push(O[C]),m){const E=fm(o,c,S);k.push(O[E[0]],O[E[1]])}if(P=[...P,{placement:o,overflows:k}],!k.every(E=>E<=0)){var I,A;const E=(((I=a.flip)==null?void 0:I.index)||0)+1,F=_[E];if(F&&(!(m==="alignment"?w!==ot(F):!1)||P.every($=>$.overflows[0]>0&&ot($.placement)===w)))return{data:{index:E,overflows:P},reset:{placement:F}};let T=(A=P.filter(z=>z.overflows[0]<=0).sort((z,$)=>z.overflows[1]-$.overflows[1])[0])==null?void 0:A.placement;if(!T)switch(p){case"bestFit":{var D;const z=(D=P.filter($=>{if(N){const M=ot($.placement);return M===w||M==="y"}return!0}).map($=>[$.placement,$.overflows.filter(M=>M>0).reduce((M,H)=>M+H,0)]).sort(($,M)=>$[1]-M[1])[0])==null?void 0:D[0];z&&(T=z);break}case"initialPlacement":T=i;break}if(o!==T)return{reset:{placement:T}}}return{}}}};function fa(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ma(e){return cm.some(t=>e[t]>=0)}const Cm=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=xt(e,t);switch(r){case"referenceHidden":{const a=await An(t,{...o,elementContext:"reference"}),c=fa(a,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:ma(c)}}}case"escaped":{const a=await An(t,{...o,altBoundary:!0}),c=fa(a,n.floating);return{data:{escapedOffsets:c,escaped:ma(c)}}}default:return{}}}}},fi=new Set(["left","top"]);async function Sm(e,t){const{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),c=vt(n),i=pn(n),l=ot(n)==="y",d=fi.has(c)?-1:1,u=a&&l?-1:1,m=xt(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return i&&typeof v=="number"&&(p=i==="end"?v*-1:v),l?{x:p*u,y:h*d}:{x:h*d,y:p*u}}const jm=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:a,placement:c,middlewareData:i}=t,l=await Sm(t,e);return c===((n=i.offset)==null?void 0:n.placement)&&(r=i.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:a+l.y,data:{...l,placement:c}}}}},Nm=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:a=!0,crossAxis:c=!1,limiter:i={fn:x=>{let{x:C,y:w}=x;return{x:C,y:w}}},...l}=xt(e,t),d={x:n,y:r},u=await An(t,l),m=ot(vt(o)),h=as(m);let p=d[h],v=d[m];if(a){const x=h==="y"?"top":"left",C=h==="y"?"bottom":"right",w=p+u[x],b=p-u[C];p=To(w,p,b)}if(c){const x=m==="y"?"top":"left",C=m==="y"?"bottom":"right",w=v+u[x],b=v-u[C];v=To(w,v,b)}const g=i.fn({...t,[h]:p,[m]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[h]:a,[m]:c}}}}}},_m=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:a,middlewareData:c}=t,{offset:i=0,mainAxis:l=!0,crossAxis:d=!0}=xt(e,t),u={x:n,y:r},m=ot(o),h=as(m);let p=u[h],v=u[m];const g=xt(i,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const b=h==="y"?"height":"width",S=a.reference[h]-a.floating[b]+x.mainAxis,j=a.reference[h]+a.reference[b]-x.mainAxis;p<S?p=S:p>j&&(p=j)}if(d){var C,w;const b=h==="y"?"width":"height",S=fi.has(vt(o)),j=a.reference[m]-a.floating[b]+(S&&((C=c.offset)==null?void 0:C[m])||0)+(S?0:x.crossAxis),N=a.reference[m]+a.reference[b]+(S?0:((w=c.offset)==null?void 0:w[m])||0)-(S?x.crossAxis:0);v<j?v=j:v>N&&(v=N)}return{[h]:p,[m]:v}}}},Em=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:a,platform:c,elements:i}=t,{apply:l=()=>{},...d}=xt(e,t),u=await An(t,d),m=vt(o),h=pn(o),p=ot(o)==="y",{width:v,height:g}=a.floating;let x,C;m==="top"||m==="bottom"?(x=m,C=h===(await(c.isRTL==null?void 0:c.isRTL(i.floating))?"start":"end")?"left":"right"):(C=m,x=h==="end"?"top":"bottom");const w=g-u.top-u.bottom,b=v-u.left-u.right,S=_t(g-u[x],w),j=_t(v-u[C],b),N=!t.middlewareData.shift;let _=S,O=j;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(O=b),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(_=w),N&&!h){const P=Le(u.left,0),I=Le(u.right,0),A=Le(u.top,0),D=Le(u.bottom,0);p?O=v-2*(P!==0||I!==0?P+I:Le(u.left,u.right)):_=g-2*(A!==0||D!==0?A+D:Le(u.top,u.bottom))}await l({...t,availableWidth:O,availableHeight:_});const k=await c.getDimensions(i.floating);return v!==k.width||g!==k.height?{reset:{rects:!0}}:{}}}};function Ar(){return typeof window<"u"}function hn(e){return mi(e)?(e.nodeName||"").toLowerCase():"#document"}function $e(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function it(e){var t;return(t=(mi(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function mi(e){return Ar()?e instanceof Node||e instanceof $e(e).Node:!1}function Qe(e){return Ar()?e instanceof Element||e instanceof $e(e).Element:!1}function at(e){return Ar()?e instanceof HTMLElement||e instanceof $e(e).HTMLElement:!1}function pa(e){return!Ar()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof $e(e).ShadowRoot}const Mm=new Set(["inline","contents"]);function zn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Ze(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Mm.has(o)}const Tm=new Set(["table","td","th"]);function Rm(e){return Tm.has(hn(e))}const km=[":popover-open",":modal"];function Or(e){return km.some(t=>{try{return e.matches(t)}catch{return!1}})}const Pm=["transform","translate","scale","rotate","perspective"],Am=["transform","translate","scale","rotate","perspective","filter"],Om=["paint","layout","strict","content"];function ls(e){const t=ds(),n=Qe(e)?Ze(e):e;return Pm.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)||Am.some(r=>(n.willChange||"").includes(r))||Om.some(r=>(n.contain||"").includes(r))}function Dm(e){let t=Et(e);for(;at(t)&&!dn(t);){if(ls(t))return t;if(Or(t))return null;t=Et(t)}return null}function ds(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Im=new Set(["html","body","#document"]);function dn(e){return Im.has(hn(e))}function Ze(e){return $e(e).getComputedStyle(e)}function Dr(e){return Qe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Et(e){if(hn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||pa(e)&&e.host||it(e);return pa(t)?t.host:t}function pi(e){const t=Et(e);return dn(t)?e.ownerDocument?e.ownerDocument.body:e.body:at(t)&&zn(t)?t:pi(t)}function On(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=pi(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),c=$e(o);if(a){const i=ko(c);return t.concat(c,c.visualViewport||[],zn(o)?o:[],i&&n?On(i):[])}return t.concat(o,On(o,[],n))}function ko(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function hi(e){const t=Ze(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=at(e),a=o?e.offsetWidth:n,c=o?e.offsetHeight:r,i=vr(n)!==a||vr(r)!==c;return i&&(n=a,r=c),{width:n,height:r,$:i}}function us(e){return Qe(e)?e:e.contextElement}function tn(e){const t=us(e);if(!at(t))return st(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:a}=hi(t);let c=(a?vr(n.width):n.width)/r,i=(a?vr(n.height):n.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!i||!Number.isFinite(i))&&(i=1),{x:c,y:i}}const Lm=st(0);function gi(e){const t=$e(e);return!ds()||!t.visualViewport?Lm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $m(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==$e(e)?!1:t}function Ft(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=us(e);let c=st(1);t&&(r?Qe(r)&&(c=tn(r)):c=tn(e));const i=$m(a,n,r)?gi(a):st(0);let l=(o.left+i.x)/c.x,d=(o.top+i.y)/c.y,u=o.width/c.x,m=o.height/c.y;if(a){const h=$e(a),p=r&&Qe(r)?$e(r):r;let v=h,g=ko(v);for(;g&&r&&p!==v;){const x=tn(g),C=g.getBoundingClientRect(),w=Ze(g),b=C.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,S=C.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,d*=x.y,u*=x.x,m*=x.y,l+=b,d+=S,v=$e(g),g=ko(v)}}return br({width:u,height:m,x:l,y:d})}function fs(e,t){const n=Dr(e).scrollLeft;return t?t.left+n:Ft(it(e)).left+n}function xi(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:fs(e,r)),a=r.top+t.scrollTop;return{x:o,y:a}}function Fm(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const a=o==="fixed",c=it(r),i=t?Or(t.floating):!1;if(r===c||i&&a)return n;let l={scrollLeft:0,scrollTop:0},d=st(1);const u=st(0),m=at(r);if((m||!m&&!a)&&((hn(r)!=="body"||zn(c))&&(l=Dr(r)),at(r))){const p=Ft(r);d=tn(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=c&&!m&&!a?xi(c,l,!0):st(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-l.scrollLeft*d.x+u.x+h.x,y:n.y*d.y-l.scrollTop*d.y+u.y+h.y}}function zm(e){return Array.from(e.getClientRects())}function Wm(e){const t=it(e),n=Dr(e),r=e.ownerDocument.body,o=Le(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Le(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let c=-n.scrollLeft+fs(e);const i=-n.scrollTop;return Ze(r).direction==="rtl"&&(c+=Le(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:c,y:i}}function Bm(e,t){const n=$e(e),r=it(e),o=n.visualViewport;let a=r.clientWidth,c=r.clientHeight,i=0,l=0;if(o){a=o.width,c=o.height;const d=ds();(!d||d&&t==="fixed")&&(i=o.offsetLeft,l=o.offsetTop)}return{width:a,height:c,x:i,y:l}}const qm=new Set(["absolute","fixed"]);function Um(e,t){const n=Ft(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=at(e)?tn(e):st(1),c=e.clientWidth*a.x,i=e.clientHeight*a.y,l=o*a.x,d=r*a.y;return{width:c,height:i,x:l,y:d}}function ha(e,t,n){let r;if(t==="viewport")r=Bm(e,n);else if(t==="document")r=Wm(it(e));else if(Qe(t))r=Um(t,n);else{const o=gi(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return br(r)}function vi(e,t){const n=Et(e);return n===t||!Qe(n)||dn(n)?!1:Ze(n).position==="fixed"||vi(n,t)}function Hm(e,t){const n=t.get(e);if(n)return n;let r=On(e,[],!1).filter(i=>Qe(i)&&hn(i)!=="body"),o=null;const a=Ze(e).position==="fixed";let c=a?Et(e):e;for(;Qe(c)&&!dn(c);){const i=Ze(c),l=ls(c);!l&&i.position==="fixed"&&(o=null),(a?!l&&!o:!l&&i.position==="static"&&!!o&&qm.has(o.position)||zn(c)&&!l&&vi(e,c))?r=r.filter(u=>u!==c):o=i,c=Et(c)}return t.set(e,r),r}function Vm(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const c=[...n==="clippingAncestors"?Or(t)?[]:Hm(t,this._c):[].concat(n),r],i=c[0],l=c.reduce((d,u)=>{const m=ha(t,u,o);return d.top=Le(m.top,d.top),d.right=_t(m.right,d.right),d.bottom=_t(m.bottom,d.bottom),d.left=Le(m.left,d.left),d},ha(t,i,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Gm(e){const{width:t,height:n}=hi(e);return{width:t,height:n}}function Ym(e,t,n){const r=at(t),o=it(t),a=n==="fixed",c=Ft(e,!0,a,t);let i={scrollLeft:0,scrollTop:0};const l=st(0);function d(){l.x=fs(o)}if(r||!r&&!a)if((hn(t)!=="body"||zn(o))&&(i=Dr(t)),r){const p=Ft(t,!0,a,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&d();a&&!r&&o&&d();const u=o&&!r&&!a?xi(o,i):st(0),m=c.left+i.scrollLeft-l.x-u.x,h=c.top+i.scrollTop-l.y-u.y;return{x:m,y:h,width:c.width,height:c.height}}function oo(e){return Ze(e).position==="static"}function ga(e,t){if(!at(e)||Ze(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return it(e)===n&&(n=n.ownerDocument.body),n}function yi(e,t){const n=$e(e);if(Or(e))return n;if(!at(e)){let o=Et(e);for(;o&&!dn(o);){if(Qe(o)&&!oo(o))return o;o=Et(o)}return n}let r=ga(e,t);for(;r&&Rm(r)&&oo(r);)r=ga(r,t);return r&&dn(r)&&oo(r)&&!ls(r)?n:r||Dm(e)||n}const Km=async function(e){const t=this.getOffsetParent||yi,n=this.getDimensions,r=await n(e.floating);return{reference:Ym(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Xm(e){return Ze(e).direction==="rtl"}const Qm={convertOffsetParentRelativeRectToViewportRelativeRect:Fm,getDocumentElement:it,getClippingRect:Vm,getOffsetParent:yi,getElementRects:Km,getClientRects:zm,getDimensions:Gm,getScale:tn,isElement:Qe,isRTL:Xm};function bi(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Zm(e,t){let n=null,r;const o=it(e);function a(){var i;clearTimeout(r),(i=n)==null||i.disconnect(),n=null}function c(i,l){i===void 0&&(i=!1),l===void 0&&(l=1),a();const d=e.getBoundingClientRect(),{left:u,top:m,width:h,height:p}=d;if(i||t(),!h||!p)return;const v=Jn(m),g=Jn(o.clientWidth-(u+h)),x=Jn(o.clientHeight-(m+p)),C=Jn(u),b={rootMargin:-v+"px "+-g+"px "+-x+"px "+-C+"px",threshold:Le(0,_t(1,l))||1};let S=!0;function j(N){const _=N[0].intersectionRatio;if(_!==l){if(!S)return c();_?c(!1,_):r=setTimeout(()=>{c(!1,1e-7)},1e3)}_===1&&!bi(d,e.getBoundingClientRect())&&c(),S=!1}try{n=new IntersectionObserver(j,{...b,root:o.ownerDocument})}catch{n=new IntersectionObserver(j,b)}n.observe(e)}return c(!0),a}function Jm(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,d=us(e),u=o||a?[...d?On(d):[],...On(t)]:[];u.forEach(C=>{o&&C.addEventListener("scroll",n,{passive:!0}),a&&C.addEventListener("resize",n)});const m=d&&i?Zm(d,n):null;let h=-1,p=null;c&&(p=new ResizeObserver(C=>{let[w]=C;w&&w.target===d&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var b;(b=p)==null||b.observe(t)})),n()}),d&&!l&&p.observe(d),p.observe(t));let v,g=l?Ft(e):null;l&&x();function x(){const C=Ft(e);g&&!bi(g,C)&&n(),g=C,v=requestAnimationFrame(x)}return n(),()=>{var C;u.forEach(w=>{o&&w.removeEventListener("scroll",n),a&&w.removeEventListener("resize",n)}),m==null||m(),(C=p)==null||C.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const ep=jm,tp=Nm,np=wm,rp=Em,op=Cm,xa=bm,sp=_m,ap=(e,t,n)=>{const r=new Map,o={platform:Qm,...n},a={...o.platform,_c:r};return ym(e,t,{...o,platform:a})};var ip=typeof document<"u",cp=function(){},dr=ip?y.useLayoutEffect:cp;function wr(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(!wr(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 a=o[r];if(!(a==="_owner"&&e.$$typeof)&&!wr(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function wi(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function va(e,t){const n=wi(e);return Math.round(t*n)/n}function so(e){const t=f.useRef(e);return dr(()=>{t.current=e}),t}function lp(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:a,floating:c}={},transform:i=!0,whileElementsMounted:l,open:d}=e,[u,m]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=f.useState(r);wr(h,r)||p(r);const[v,g]=f.useState(null),[x,C]=f.useState(null),w=f.useCallback($=>{$!==N.current&&(N.current=$,g($))},[]),b=f.useCallback($=>{$!==_.current&&(_.current=$,C($))},[]),S=a||v,j=c||x,N=f.useRef(null),_=f.useRef(null),O=f.useRef(u),k=l!=null,P=so(l),I=so(o),A=so(d),D=f.useCallback(()=>{if(!N.current||!_.current)return;const $={placement:t,strategy:n,middleware:h};I.current&&($.platform=I.current),ap(N.current,_.current,$).then(M=>{const H={...M,isPositioned:A.current!==!1};E.current&&!wr(O.current,H)&&(O.current=H,ns.flushSync(()=>{m(H)}))})},[h,t,n,I,A]);dr(()=>{d===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,m($=>({...$,isPositioned:!1})))},[d]);const E=f.useRef(!1);dr(()=>(E.current=!0,()=>{E.current=!1}),[]),dr(()=>{if(S&&(N.current=S),j&&(_.current=j),S&&j){if(P.current)return P.current(S,j,D);D()}},[S,j,D,P,k]);const F=f.useMemo(()=>({reference:N,floating:_,setReference:w,setFloating:b}),[w,b]),T=f.useMemo(()=>({reference:S,floating:j}),[S,j]),z=f.useMemo(()=>{const $={position:n,left:0,top:0};if(!T.floating)return $;const M=va(T.floating,u.x),H=va(T.floating,u.y);return i?{...$,transform:"translate("+M+"px, "+H+"px)",...wi(T.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:H}},[n,i,T.floating,u.x,u.y]);return f.useMemo(()=>({...u,update:D,refs:F,elements:T,floatingStyles:z}),[u,D,F,T,z])}const dp=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?xa({element:r.current,padding:o}).fn(n):{}:r?xa({element:r,padding:o}).fn(n):{}}}},up=(e,t)=>({...ep(e),options:[e,t]}),fp=(e,t)=>({...tp(e),options:[e,t]}),mp=(e,t)=>({...sp(e),options:[e,t]}),pp=(e,t)=>({...np(e),options:[e,t]}),hp=(e,t)=>({...rp(e),options:[e,t]}),gp=(e,t)=>({...op(e),options:[e,t]}),xp=(e,t)=>({...dp(e),options:[e,t]});var vp="Arrow",Ci=f.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...a}=e;return s.jsx(K.svg,{...a,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ci.displayName=vp;var yp=Ci;function Si(e){const[t,n]=f.useState(void 0);return Fe(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let c,i;if("borderBoxSize"in a){const l=a.borderBoxSize,d=Array.isArray(l)?l[0]:l;c=d.inlineSize,i=d.blockSize}else c=e.offsetWidth,i=e.offsetHeight;n({width:c,height:i})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ms="Popper",[ji,Ir]=ke(ms),[bp,Ni]=ji(ms),_i=e=>{const{__scopePopper:t,children:n}=e,[r,o]=f.useState(null);return s.jsx(bp,{scope:t,anchor:r,onAnchorChange:o,children:n})};_i.displayName=ms;var Ei="PopperAnchor",Mi=f.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=Ni(Ei,n),c=f.useRef(null),i=ae(t,c);return f.useEffect(()=>{a.onAnchorChange((r==null?void 0:r.current)||c.current)}),r?null:s.jsx(K.div,{...o,ref:i})});Mi.displayName=Ei;var ps="PopperContent",[wp,Cp]=ji(ps),Ti=f.forwardRef((e,t)=>{var J,Pe,he,ze,Ae,Ve;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:c=0,arrowPadding:i=0,avoidCollisions:l=!0,collisionBoundary:d=[],collisionPadding:u=0,sticky:m="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...g}=e,x=Ni(ps,n),[C,w]=f.useState(null),b=ae(t,Ge=>w(Ge)),[S,j]=f.useState(null),N=Si(S),_=(N==null?void 0:N.width)??0,O=(N==null?void 0:N.height)??0,k=r+(a!=="center"?"-"+a:""),P=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},I=Array.isArray(d)?d:[d],A=I.length>0,D={padding:P,boundary:I.filter(jp),altBoundary:A},{refs:E,floatingStyles:F,placement:T,isPositioned:z,middlewareData:$}=lp({strategy:"fixed",placement:k,whileElementsMounted:(...Ge)=>Jm(...Ge,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[up({mainAxis:o+O,alignmentAxis:c}),l&&fp({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?mp():void 0,...D}),l&&pp({...D}),hp({...D,apply:({elements:Ge,rects:Vt,availableWidth:Rt,availableHeight:Gt})=>{const{width:kt,height:Pt}=Vt.reference,lt=Ge.floating.style;lt.setProperty("--radix-popper-available-width",`${Rt}px`),lt.setProperty("--radix-popper-available-height",`${Gt}px`),lt.setProperty("--radix-popper-anchor-width",`${kt}px`),lt.setProperty("--radix-popper-anchor-height",`${Pt}px`)}}),S&&xp({element:S,padding:i}),Np({arrowWidth:_,arrowHeight:O}),h&&gp({strategy:"referenceHidden",...D})]}),[M,H]=Pi(T),Z=ge(v);Fe(()=>{z&&(Z==null||Z())},[z,Z]);const V=(J=$.arrow)==null?void 0:J.x,G=(Pe=$.arrow)==null?void 0:Pe.y,B=((he=$.arrow)==null?void 0:he.centerOffset)!==0,[re,ue]=f.useState();return Fe(()=>{C&&ue(window.getComputedStyle(C).zIndex)},[C]),s.jsx("div",{ref:E.setFloating,"data-radix-popper-content-wrapper":"",style:{...F,transform:z?F.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:re,"--radix-popper-transform-origin":[(ze=$.transformOrigin)==null?void 0:ze.x,(Ae=$.transformOrigin)==null?void 0:Ae.y].join(" "),...((Ve=$.hide)==null?void 0:Ve.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(wp,{scope:n,placedSide:M,onArrowChange:j,arrowX:V,arrowY:G,shouldHideArrow:B,children:s.jsx(K.div,{"data-side":M,"data-align":H,...g,ref:b,style:{...g.style,animation:z?void 0:"none"}})})})});Ti.displayName=ps;var Ri="PopperArrow",Sp={top:"bottom",right:"left",bottom:"top",left:"right"},ki=f.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=Cp(Ri,r),c=Sp[a.placedSide];return s.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:s.jsx(yp,{...o,ref:n,style:{...o.style,display:"block"}})})});ki.displayName=Ri;function jp(e){return e!==null}var Np=e=>({name:"transformOrigin",options:e,fn(t){var x,C,w;const{placement:n,rects:r,middlewareData:o}=t,c=((x=o.arrow)==null?void 0:x.centerOffset)!==0,i=c?0:e.arrowWidth,l=c?0:e.arrowHeight,[d,u]=Pi(n),m={start:"0%",center:"50%",end:"100%"}[u],h=(((C=o.arrow)==null?void 0:C.x)??0)+i/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let v="",g="";return d==="bottom"?(v=c?m:`${h}px`,g=`${-l}px`):d==="top"?(v=c?m:`${h}px`,g=`${r.floating.height+l}px`):d==="right"?(v=`${-l}px`,g=c?m:`${p}px`):d==="left"&&(v=`${r.floating.width+l}px`,g=c?m:`${p}px`),{data:{x:v,y:g}}}});function Pi(e){const[t,n="center"]=e.split("-");return[t,n]}var Ai=_i,Oi=Mi,Di=Ti,Ii=ki,_p="Portal",Lr=f.forwardRef((e,t)=>{var i;const{container:n,...r}=e,[o,a]=f.useState(!1);Fe(()=>a(!0),[]);const c=n||o&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return c?ts.createPortal(s.jsx(K.div,{...r,ref:t}),c):null});Lr.displayName=_p;function Ep(e,t){return f.useReducer((n,r)=>t[n][r]??n,e)}var Ee=e=>{const{present:t,children:n}=e,r=Mp(t),o=typeof n=="function"?n({present:r.isPresent}):f.Children.only(n),a=ae(r.ref,Tp(o));return typeof n=="function"||r.isPresent?f.cloneElement(o,{ref:a}):null};Ee.displayName="Presence";function Mp(e){const[t,n]=f.useState(),r=f.useRef(null),o=f.useRef(e),a=f.useRef("none"),c=e?"mounted":"unmounted",[i,l]=Ep(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return f.useEffect(()=>{const d=er(r.current);a.current=i==="mounted"?d:"none"},[i]),Fe(()=>{const d=r.current,u=o.current;if(u!==e){const h=a.current,p=er(d);e?l("MOUNT"):p==="none"||(d==null?void 0:d.display)==="none"?l("UNMOUNT"):l(u&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Fe(()=>{if(t){let d;const u=t.ownerDocument.defaultView??window,m=p=>{const g=er(r.current).includes(p.animationName);if(p.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",d=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},h=p=>{p.target===t&&(a.current=er(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{u.clearTimeout(d),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:f.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function er(e){return(e==null?void 0:e.animationName)||"none"}function Tp(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Rp=f[" useInsertionEffect ".trim().toString()]||Fe;function Bt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,c]=kp({defaultProp:t,onChange:n}),i=e!==void 0,l=i?e:o;{const u=f.useRef(e!==void 0);f.useEffect(()=>{const m=u.current;m!==i&&console.warn(`${r} is changing from ${m?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=i},[i,r])}const d=f.useCallback(u=>{var m;if(i){const h=Pp(u)?u(e):u;h!==e&&((m=c.current)==null||m.call(c,h))}else a(u)},[i,e,a,c]);return[l,d]}function kp({defaultProp:e,onChange:t}){const[n,r]=f.useState(e),o=f.useRef(n),a=f.useRef(t);return Rp(()=>{a.current=t},[t]),f.useEffect(()=>{var c;o.current!==n&&((c=a.current)==null||c.call(a,n),o.current=n)},[n,o]),[n,r,a]}function Pp(e){return typeof e=="function"}var Ap=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"}),Op="VisuallyHidden",$r=f.forwardRef((e,t)=>s.jsx(K.span,{...e,ref:t,style:{...Ap,...e.style}}));$r.displayName=Op;var Dp=$r,[Fr,Q0]=ke("Tooltip",[Ir]),hs=Ir(),Li="TooltipProvider",Ip=700,ya="tooltip.open",[Lp,$i]=Fr(Li),Fi=e=>{const{__scopeTooltip:t,delayDuration:n=Ip,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:a}=e,c=f.useRef(!0),i=f.useRef(!1),l=f.useRef(0);return f.useEffect(()=>{const d=l.current;return()=>window.clearTimeout(d)},[]),s.jsx(Lp,{scope:t,isOpenDelayedRef:c,delayDuration:n,onOpen:f.useCallback(()=>{window.clearTimeout(l.current),c.current=!1},[]),onClose:f.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>c.current=!0,r)},[r]),isPointerInTransitRef:i,onPointerInTransitChange:f.useCallback(d=>{i.current=d},[]),disableHoverableContent:o,children:a})};Fi.displayName=Li;var zi="Tooltip",[Z0,zr]=Fr(zi),Po="TooltipTrigger",$p=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=zr(Po,n),a=$i(Po,n),c=hs(n),i=f.useRef(null),l=ae(t,i,o.onTriggerChange),d=f.useRef(!1),u=f.useRef(!1),m=f.useCallback(()=>d.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),s.jsx(Oi,{asChild:!0,...c,children:s.jsx(K.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:L(e.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),u.current=!0)}),onPointerLeave:L(e.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:L(e.onPointerDown,()=>{o.open&&o.onClose(),d.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:L(e.onFocus,()=>{d.current||o.onOpen()}),onBlur:L(e.onBlur,o.onClose),onClick:L(e.onClick,o.onClose)})})});$p.displayName=Po;var Fp="TooltipPortal",[J0,zp]=Fr(Fp,{forceMount:void 0}),un="TooltipContent",Wi=f.forwardRef((e,t)=>{const n=zp(un,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...a}=e,c=zr(un,e.__scopeTooltip);return s.jsx(Ee,{present:r||c.open,children:c.disableHoverableContent?s.jsx(Bi,{side:o,...a,ref:t}):s.jsx(Wp,{side:o,...a,ref:t})})}),Wp=f.forwardRef((e,t)=>{const n=zr(un,e.__scopeTooltip),r=$i(un,e.__scopeTooltip),o=f.useRef(null),a=ae(t,o),[c,i]=f.useState(null),{trigger:l,onClose:d}=n,u=o.current,{onPointerInTransitChange:m}=r,h=f.useCallback(()=>{i(null),m(!1)},[m]),p=f.useCallback((v,g)=>{const x=v.currentTarget,C={x:v.clientX,y:v.clientY},w=Vp(C,x.getBoundingClientRect()),b=Gp(C,w),S=Yp(g.getBoundingClientRect()),j=Xp([...b,...S]);i(j),m(!0)},[m]);return f.useEffect(()=>()=>h(),[h]),f.useEffect(()=>{if(l&&u){const v=x=>p(x,u),g=x=>p(x,l);return l.addEventListener("pointerleave",v),u.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),u.removeEventListener("pointerleave",g)}}},[l,u,p,h]),f.useEffect(()=>{if(c){const v=g=>{const x=g.target,C={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(u==null?void 0:u.contains(x)),b=!Kp(C,c);w?h():b&&(h(),d())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,u,c,d,h]),s.jsx(Bi,{...e,ref:a})}),[Bp,qp]=Fr(zi,{isInside:!1}),Up=ii("TooltipContent"),Bi=f.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:c,...i}=e,l=zr(un,n),d=hs(n),{onClose:u}=l;return f.useEffect(()=>(document.addEventListener(ya,u),()=>document.removeEventListener(ya,u)),[u]),f.useEffect(()=>{if(l.trigger){const m=h=>{const p=h.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",m,{capture:!0}),()=>window.removeEventListener("scroll",m,{capture:!0})}},[l.trigger,u]),s.jsx(Fn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:m=>m.preventDefault(),onDismiss:u,children:s.jsxs(Di,{"data-state":l.stateAttribute,...d,...i,ref:t,style:{...i.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:[s.jsx(Up,{children:r}),s.jsx(Bp,{scope:n,isInside:!0,children:s.jsx(Dp,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Wi.displayName=un;var qi="TooltipArrow",Hp=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hs(n);return qp(qi,n).isInside?null:s.jsx(Ii,{...o,...r,ref:t})});Hp.displayName=qi;function Vp(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,o,a)){case a:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Gp(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 Yp(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 Kp(e,t){const{x:n,y:r}=e;let o=!1;for(let a=0,c=t.length-1;a<t.length;c=a++){const i=t[a],l=t[c],d=i.x,u=i.y,m=l.x,h=l.y;u>r!=h>r&&n<(m-d)*(r-u)/(h-u)+d&&(o=!o)}return o}function Xp(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),Qp(t)}function Qp(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 a=t[t.length-1],c=t[t.length-2];if((a.x-c.x)*(o.y-c.y)>=(a.y-c.y)*(o.x-c.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 a=n[n.length-1],c=n[n.length-2];if((a.x-c.x)*(o.y-c.y)>=(a.y-c.y)*(o.x-c.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 Zp=Fi,Ui=Wi;function Hi(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Hi(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Vi(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Hi(e))&&(r&&(r+=" "),r+=t);return r}const gs="-",Jp=e=>{const t=th(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{const i=c.split(gs);return i[0]===""&&i.length!==1&&i.shift(),Gi(i,t)||eh(c)},getConflictingClassGroupIds:(c,i)=>{const l=n[c]||[];return i&&r[c]?[...l,...r[c]]:l}}},Gi=(e,t)=>{var c;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),o=r?Gi(e.slice(1),r):void 0;if(o)return o;if(t.validators.length===0)return;const a=e.join(gs);return(c=t.validators.find(({validator:i})=>i(a)))==null?void 0:c.classGroupId},ba=/^\[(.+)\]$/,eh=e=>{if(ba.test(e)){const t=ba.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},th=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return rh(Object.entries(e.classGroups),n).forEach(([a,c])=>{Ao(c,r,a,t)}),r},Ao=(e,t,n,r)=>{e.forEach(o=>{if(typeof o=="string"){const a=o===""?t:wa(t,o);a.classGroupId=n;return}if(typeof o=="function"){if(nh(o)){Ao(o(r),t,n,r);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([a,c])=>{Ao(c,wa(t,a),n,r)})})},wa=(e,t)=>{let n=e;return t.split(gs).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},nh=e=>e.isThemeGetter,rh=(e,t)=>t?e.map(([n,r])=>{const o=r.map(a=>typeof a=="string"?t+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([c,i])=>[t+c,i])):a);return[n,o]}):e,oh=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const o=(a,c)=>{n.set(a,c),t++,t>e&&(t=0,r=n,n=new Map)};return{get(a){let c=n.get(a);if(c!==void 0)return c;if((c=r.get(a))!==void 0)return o(a,c),c},set(a,c){n.has(a)?n.set(a,c):o(a,c)}}},Yi="!",sh=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,o=t[0],a=t.length,c=i=>{const l=[];let d=0,u=0,m;for(let x=0;x<i.length;x++){let C=i[x];if(d===0){if(C===o&&(r||i.slice(x,x+a)===t)){l.push(i.slice(u,x)),u=x+a;continue}if(C==="/"){m=x;continue}}C==="["?d++:C==="]"&&d--}const h=l.length===0?i:i.substring(u),p=h.startsWith(Yi),v=p?h.substring(1):h,g=m&&m>u?m-u:void 0;return{modifiers:l,hasImportantModifier:p,baseClassName:v,maybePostfixModifierPosition:g}};return n?i=>n({className:i,parseClassName:c}):c},ah=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},ih=e=>({cache:oh(e.cacheSize),parseClassName:sh(e),...Jp(e)}),ch=/\s+/,lh=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o}=t,a=[],c=e.trim().split(ch);let i="";for(let l=c.length-1;l>=0;l-=1){const d=c[l],{modifiers:u,hasImportantModifier:m,baseClassName:h,maybePostfixModifierPosition:p}=n(d);let v=!!p,g=r(v?h.substring(0,p):h);if(!g){if(!v){i=d+(i.length>0?" "+i:i);continue}if(g=r(h),!g){i=d+(i.length>0?" "+i:i);continue}v=!1}const x=ah(u).join(":"),C=m?x+Yi:x,w=C+g;if(a.includes(w))continue;a.push(w);const b=o(g,v);for(let S=0;S<b.length;++S){const j=b[S];a.push(C+j)}i=d+(i.length>0?" "+i:i)}return i};function dh(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Ki(t))&&(r&&(r+=" "),r+=n);return r}const Ki=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Ki(e[r]))&&(n&&(n+=" "),n+=t);return n};function uh(e,...t){let n,r,o,a=c;function c(l){const d=t.reduce((u,m)=>m(u),e());return n=ih(d),r=n.cache.get,o=n.cache.set,a=i,i(l)}function i(l){const d=r(l);if(d)return d;const u=lh(l,n);return o(l,u),u}return function(){return a(dh.apply(null,arguments))}}const pe=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Xi=/^\[(?:([a-z-]+):)?(.+)\]$/i,fh=/^\d+\/\d+$/,mh=new Set(["px","full","screen"]),ph=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,hh=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,gh=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,xh=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,vh=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,pt=e=>nn(e)||mh.has(e)||fh.test(e),wt=e=>gn(e,"length",_h),nn=e=>!!e&&!Number.isNaN(Number(e)),ao=e=>gn(e,"number",nn),Nn=e=>!!e&&Number.isInteger(Number(e)),yh=e=>e.endsWith("%")&&nn(e.slice(0,-1)),ee=e=>Xi.test(e),Ct=e=>ph.test(e),bh=new Set(["length","size","percentage"]),wh=e=>gn(e,bh,Qi),Ch=e=>gn(e,"position",Qi),Sh=new Set(["image","url"]),jh=e=>gn(e,Sh,Mh),Nh=e=>gn(e,"",Eh),_n=()=>!0,gn=(e,t,n)=>{const r=Xi.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},_h=e=>hh.test(e)&&!gh.test(e),Qi=()=>!1,Eh=e=>xh.test(e),Mh=e=>vh.test(e),Th=()=>{const e=pe("colors"),t=pe("spacing"),n=pe("blur"),r=pe("brightness"),o=pe("borderColor"),a=pe("borderRadius"),c=pe("borderSpacing"),i=pe("borderWidth"),l=pe("contrast"),d=pe("grayscale"),u=pe("hueRotate"),m=pe("invert"),h=pe("gap"),p=pe("gradientColorStops"),v=pe("gradientColorStopPositions"),g=pe("inset"),x=pe("margin"),C=pe("opacity"),w=pe("padding"),b=pe("saturate"),S=pe("scale"),j=pe("sepia"),N=pe("skew"),_=pe("space"),O=pe("translate"),k=()=>["auto","contain","none"],P=()=>["auto","hidden","clip","visible","scroll"],I=()=>["auto",ee,t],A=()=>[ee,t],D=()=>["",pt,wt],E=()=>["auto",nn,ee],F=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],T=()=>["solid","dashed","dotted","double","none"],z=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],$=()=>["start","end","center","between","around","evenly","stretch"],M=()=>["","0",ee],H=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Z=()=>[nn,ee];return{cacheSize:500,separator:":",theme:{colors:[_n],spacing:[pt,wt],blur:["none","",Ct,ee],brightness:Z(),borderColor:[e],borderRadius:["none","","full",Ct,ee],borderSpacing:A(),borderWidth:D(),contrast:Z(),grayscale:M(),hueRotate:Z(),invert:M(),gap:A(),gradientColorStops:[e],gradientColorStopPositions:[yh,wt],inset:I(),margin:I(),opacity:Z(),padding:A(),saturate:Z(),scale:Z(),sepia:M(),skew:Z(),space:A(),translate:A()},classGroups:{aspect:[{aspect:["auto","square","video",ee]}],container:["container"],columns:[{columns:[Ct]}],"break-after":[{"break-after":H()}],"break-before":[{"break-before":H()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...F(),ee]}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Nn,ee]}],basis:[{basis:I()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ee]}],grow:[{grow:M()}],shrink:[{shrink:M()}],order:[{order:["first","last","none",Nn,ee]}],"grid-cols":[{"grid-cols":[_n]}],"col-start-end":[{col:["auto",{span:["full",Nn,ee]},ee]}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":[_n]}],"row-start-end":[{row:["auto",{span:[Nn,ee]},ee]}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ee]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ee]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...$()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...$(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...$(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[w]}],px:[{px:[w]}],py:[{py:[w]}],ps:[{ps:[w]}],pe:[{pe:[w]}],pt:[{pt:[w]}],pr:[{pr:[w]}],pb:[{pb:[w]}],pl:[{pl:[w]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[_]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[_]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ee,t]}],"min-w":[{"min-w":[ee,t,"min","max","fit"]}],"max-w":[{"max-w":[ee,t,"none","full","min","max","fit","prose",{screen:[Ct]},Ct]}],h:[{h:[ee,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ee,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ee,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ee,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Ct,wt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",ao]}],"font-family":[{font:[_n]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ee]}],"line-clamp":[{"line-clamp":["none",nn,ao]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",pt,ee]}],"list-image":[{"list-image":["none",ee]}],"list-style-type":[{list:["none","disc","decimal",ee]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[C]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[C]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...T(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",pt,wt]}],"underline-offset":[{"underline-offset":["auto",pt,ee]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:A()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ee]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ee]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[C]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...F(),Ch]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",wh]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},jh]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[v]}],"gradient-via-pos":[{via:[v]}],"gradient-to-pos":[{to:[v]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[i]}],"border-w-x":[{"border-x":[i]}],"border-w-y":[{"border-y":[i]}],"border-w-s":[{"border-s":[i]}],"border-w-e":[{"border-e":[i]}],"border-w-t":[{"border-t":[i]}],"border-w-r":[{"border-r":[i]}],"border-w-b":[{"border-b":[i]}],"border-w-l":[{"border-l":[i]}],"border-opacity":[{"border-opacity":[C]}],"border-style":[{border:[...T(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[C]}],"divide-style":[{divide:T()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...T()]}],"outline-offset":[{"outline-offset":[pt,ee]}],"outline-w":[{outline:[pt,wt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:D()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[C]}],"ring-offset-w":[{"ring-offset":[pt,wt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Ct,Nh]}],"shadow-color":[{shadow:[_n]}],opacity:[{opacity:[C]}],"mix-blend":[{"mix-blend":[...z(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":z()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Ct,ee]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[m]}],saturate:[{saturate:[b]}],sepia:[{sepia:[j]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[m]}],"backdrop-opacity":[{"backdrop-opacity":[C]}],"backdrop-saturate":[{"backdrop-saturate":[b]}],"backdrop-sepia":[{"backdrop-sepia":[j]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ee]}],duration:[{duration:Z()}],ease:[{ease:["linear","in","out","in-out",ee]}],delay:[{delay:Z()}],animate:[{animate:["none","spin","ping","pulse","bounce",ee]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[Nn,ee]}],"translate-x":[{"translate-x":[O]}],"translate-y":[{"translate-y":[O]}],"skew-x":[{"skew-x":[N]}],"skew-y":[{"skew-y":[N]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ee]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ee]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ee]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[pt,wt,ao]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},Rh=uh(Th);function W(...e){return Rh(Vi(e))}const kh=Zp,Ph=f.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(Ui,{ref:r,sideOffset:t,className:W("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=Ui.displayName;const Ah=1,Oh=1e6;let io=0;function Dh(){return io=(io+1)%Number.MAX_SAFE_INTEGER,io.toString()}const co=new Map,Ca=e=>{if(co.has(e))return;const t=setTimeout(()=>{co.delete(e),Pn({type:"REMOVE_TOAST",toastId:e})},Oh);co.set(e,t)},Ih=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Ah)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?Ca(n):e.toasts.forEach(r=>{Ca(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},ur=[];let fr={toasts:[]};function Pn(e){fr=Ih(fr,e),ur.forEach(t=>{t(fr)})}function Lh({...e}){const t=Dh(),n=o=>Pn({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Pn({type:"DISMISS_TOAST",toastId:t});return Pn({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function xn(){const[e,t]=f.useState(fr);return f.useEffect(()=>(ur.push(t),()=>{const n=ur.indexOf(t);n>-1&&ur.splice(n,1)}),[e]),{...e,toast:Lh,dismiss:n=>Pn({type:"DISMISS_TOAST",toastId:n})}}function xs(e){const t=e+"CollectionProvider",[n,r]=ke(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=g=>{const{scope:x,children:C}=g,w=y.useRef(null),b=y.useRef(new Map).current;return s.jsx(o,{scope:x,itemMap:b,collectionRef:w,children:C})};c.displayName=t;const i=e+"CollectionSlot",l=ln(i),d=y.forwardRef((g,x)=>{const{scope:C,children:w}=g,b=a(i,C),S=ae(x,b.collectionRef);return s.jsx(l,{ref:S,children:w})});d.displayName=i;const u=e+"CollectionItemSlot",m="data-radix-collection-item",h=ln(u),p=y.forwardRef((g,x)=>{const{scope:C,children:w,...b}=g,S=y.useRef(null),j=ae(x,S),N=a(u,C);return y.useEffect(()=>(N.itemMap.set(S,{ref:S,...b}),()=>void N.itemMap.delete(S))),s.jsx(h,{[m]:"",ref:j,children:w})});p.displayName=u;function v(g){const x=a(e+"CollectionConsumer",g);return y.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const b=Array.from(w.querySelectorAll(`[${m}]`));return Array.from(x.itemMap.values()).sort((N,_)=>b.indexOf(N.ref.current)-b.indexOf(_.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:c,Slot:d,ItemSlot:p},v,r]}var vs="ToastProvider",[ys,$h,Fh]=xs("Toast"),[Zi,e1]=ke("Toast",[Fh]),[zh,Wr]=Zi(vs),Ji=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:a=50,children:c}=e,[i,l]=f.useState(null),[d,u]=f.useState(0),m=f.useRef(!1),h=f.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${vs}\`. Expected non-empty \`string\`.`),s.jsx(ys.Provider,{scope:t,children:s.jsx(zh,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:a,toastCount:d,viewport:i,onViewportChange:l,onToastAdd:f.useCallback(()=>u(p=>p+1),[]),onToastRemove:f.useCallback(()=>u(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:m,isClosePausedRef:h,children:c})})};Ji.displayName=vs;var ec="ToastViewport",Wh=["F8"],Oo="toast.viewportPause",Do="toast.viewportResume",tc=f.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=Wh,label:o="Notifications ({hotkey})",...a}=e,c=Wr(ec,n),i=$h(n),l=f.useRef(null),d=f.useRef(null),u=f.useRef(null),m=f.useRef(null),h=ae(t,m,c.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=c.toastCount>0;f.useEffect(()=>{const x=C=>{var b;r.length!==0&&r.every(S=>C[S]||C.code===S)&&((b=m.current)==null||b.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),f.useEffect(()=>{const x=l.current,C=m.current;if(v&&x&&C){const w=()=>{if(!c.isClosePausedRef.current){const N=new CustomEvent(Oo);C.dispatchEvent(N),c.isClosePausedRef.current=!0}},b=()=>{if(c.isClosePausedRef.current){const N=new CustomEvent(Do);C.dispatchEvent(N),c.isClosePausedRef.current=!1}},S=N=>{!x.contains(N.relatedTarget)&&b()},j=()=>{x.contains(document.activeElement)||b()};return x.addEventListener("focusin",w),x.addEventListener("focusout",S),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",j),window.addEventListener("blur",w),window.addEventListener("focus",b),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",S),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",j),window.removeEventListener("blur",w),window.removeEventListener("focus",b)}}},[v,c.isClosePausedRef]);const g=f.useCallback(({tabbingDirection:x})=>{const w=i().map(b=>{const S=b.ref.current,j=[S,...eg(S)];return x==="forwards"?j:j.reverse()});return(x==="forwards"?w.reverse():w).flat()},[i]);return f.useEffect(()=>{const x=m.current;if(x){const C=w=>{var j,N,_;const b=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!b){const O=document.activeElement,k=w.shiftKey;if(w.target===x&&k){(j=d.current)==null||j.focus();return}const A=g({tabbingDirection:k?"backwards":"forwards"}),D=A.findIndex(E=>E===O);lo(A.slice(D+1))?w.preventDefault():k?(N=d.current)==null||N.focus():(_=u.current)==null||_.focus()}};return x.addEventListener("keydown",C),()=>x.removeEventListener("keydown",C)}},[i,g]),s.jsxs(sm,{ref:l,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&s.jsx(Io,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});lo(x)}}),s.jsx(ys.Slot,{scope:n,children:s.jsx(K.ol,{tabIndex:-1,...a,ref:h})}),v&&s.jsx(Io,{ref:u,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});lo(x)}})]})});tc.displayName=ec;var nc="ToastFocusProxy",Io=f.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,a=Wr(nc,n);return s.jsx($r,{"aria-hidden":!0,tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:c=>{var d;const i=c.relatedTarget;!((d=a.viewport)!=null&&d.contains(i))&&r()}})});Io.displayName=nc;var Wn="Toast",Bh="toast.swipeStart",qh="toast.swipeMove",Uh="toast.swipeCancel",Hh="toast.swipeEnd",rc=f.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:a,...c}=e,[i,l]=Bt({prop:r,defaultProp:o??!0,onChange:a,caller:Wn});return s.jsx(Ee,{present:n||i,children:s.jsx(Yh,{open:i,...c,ref:t,onClose:()=>l(!1),onPause:ge(e.onPause),onResume:ge(e.onResume),onSwipeStart:L(e.onSwipeStart,d=>{d.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:L(e.onSwipeMove,d=>{const{x:u,y:m}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","move"),d.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${u}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${m}px`)}),onSwipeCancel:L(e.onSwipeCancel,d=>{d.currentTarget.setAttribute("data-swipe","cancel"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:L(e.onSwipeEnd,d=>{const{x:u,y:m}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","end"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${u}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${m}px`),l(!1)})})})});rc.displayName=Wn;var[Vh,Gh]=Zi(Wn,{onClose(){}}),Yh=f.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:a,onClose:c,onEscapeKeyDown:i,onPause:l,onResume:d,onSwipeStart:u,onSwipeMove:m,onSwipeCancel:h,onSwipeEnd:p,...v}=e,g=Wr(Wn,n),[x,C]=f.useState(null),w=ae(t,E=>C(E)),b=f.useRef(null),S=f.useRef(null),j=o||g.duration,N=f.useRef(0),_=f.useRef(j),O=f.useRef(0),{onToastAdd:k,onToastRemove:P}=g,I=ge(()=>{var F;(x==null?void 0:x.contains(document.activeElement))&&((F=g.viewport)==null||F.focus()),c()}),A=f.useCallback(E=>{!E||E===1/0||(window.clearTimeout(O.current),N.current=new Date().getTime(),O.current=window.setTimeout(I,E))},[I]);f.useEffect(()=>{const E=g.viewport;if(E){const F=()=>{A(_.current),d==null||d()},T=()=>{const z=new Date().getTime()-N.current;_.current=_.current-z,window.clearTimeout(O.current),l==null||l()};return E.addEventListener(Oo,T),E.addEventListener(Do,F),()=>{E.removeEventListener(Oo,T),E.removeEventListener(Do,F)}}},[g.viewport,j,l,d,A]),f.useEffect(()=>{a&&!g.isClosePausedRef.current&&A(j)},[a,j,g.isClosePausedRef,A]),f.useEffect(()=>(k(),()=>P()),[k,P]);const D=f.useMemo(()=>x?dc(x):null,[x]);return g.viewport?s.jsxs(s.Fragment,{children:[D&&s.jsx(Kh,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:D}),s.jsx(Vh,{scope:n,onClose:I,children:ns.createPortal(s.jsx(ys.ItemSlot,{scope:n,children:s.jsx(om,{asChild:!0,onEscapeKeyDown:L(i,()=>{g.isFocusedToastEscapeKeyDownRef.current||I(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:s.jsx(K.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":a?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:L(e.onKeyDown,E=>{E.key==="Escape"&&(i==null||i(E.nativeEvent),E.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,I()))}),onPointerDown:L(e.onPointerDown,E=>{E.button===0&&(b.current={x:E.clientX,y:E.clientY})}),onPointerMove:L(e.onPointerMove,E=>{if(!b.current)return;const F=E.clientX-b.current.x,T=E.clientY-b.current.y,z=!!S.current,$=["left","right"].includes(g.swipeDirection),M=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,H=$?M(0,F):0,Z=$?0:M(0,T),V=E.pointerType==="touch"?10:2,G={x:H,y:Z},B={originalEvent:E,delta:G};z?(S.current=G,tr(qh,m,B,{discrete:!1})):Sa(G,g.swipeDirection,V)?(S.current=G,tr(Bh,u,B,{discrete:!1}),E.target.setPointerCapture(E.pointerId)):(Math.abs(F)>V||Math.abs(T)>V)&&(b.current=null)}),onPointerUp:L(e.onPointerUp,E=>{const F=S.current,T=E.target;if(T.hasPointerCapture(E.pointerId)&&T.releasePointerCapture(E.pointerId),S.current=null,b.current=null,F){const z=E.currentTarget,$={originalEvent:E,delta:F};Sa(F,g.swipeDirection,g.swipeThreshold)?tr(Hh,p,$,{discrete:!0}):tr(Uh,h,$,{discrete:!0}),z.addEventListener("click",M=>M.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),Kh=e=>{const{__scopeToast:t,children:n,...r}=e,o=Wr(Wn,t),[a,c]=f.useState(!1),[i,l]=f.useState(!1);return Zh(()=>c(!0)),f.useEffect(()=>{const d=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(d)},[]),i?null:s.jsx(Lr,{asChild:!0,children:s.jsx($r,{...r,children:a&&s.jsxs(s.Fragment,{children:[o.label," ",n]})})})},Xh="ToastTitle",oc=f.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return s.jsx(K.div,{...r,ref:t})});oc.displayName=Xh;var Qh="ToastDescription",sc=f.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return s.jsx(K.div,{...r,ref:t})});sc.displayName=Qh;var ac="ToastAction",ic=f.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?s.jsx(lc,{altText:n,asChild:!0,children:s.jsx(bs,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${ac}\`. Expected non-empty \`string\`.`),null)});ic.displayName=ac;var cc="ToastClose",bs=f.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=Gh(cc,n);return s.jsx(lc,{asChild:!0,children:s.jsx(K.button,{type:"button",...r,ref:t,onClick:L(e.onClick,o.onClose)})})});bs.displayName=cc;var lc=f.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return s.jsx(K.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function dc(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),Jh(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",a=r.dataset.radixToastAnnounceExclude==="";if(!o)if(a){const c=r.dataset.radixToastAnnounceAlt;c&&t.push(c)}else t.push(...dc(r))}}),t}function tr(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,a=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?ss(o,a):o.dispatchEvent(a)}var Sa=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),a=r>o;return t==="left"||t==="right"?a&&r>n:!a&&o>n};function Zh(e=()=>{}){const t=ge(e);Fe(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function Jh(e){return e.nodeType===e.ELEMENT_NODE}function eg(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function lo(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var tg=Ji,uc=tc,fc=rc,mc=oc,pc=sc,hc=ic,gc=bs;const ja=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Na=Vi,ws=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Na(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:a}=t,c=Object.keys(o).map(d=>{const u=n==null?void 0:n[d],m=a==null?void 0:a[d];if(u===null)return null;const h=ja(u)||ja(m);return o[d][h]}),i=n&&Object.entries(n).reduce((d,u)=>{let[m,h]=u;return h===void 0||(d[m]=h),d},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,u)=>{let{class:m,className:h,...p}=u;return Object.entries(p).every(v=>{let[g,x]=v;return Array.isArray(x)?x.includes({...a,...i}[g]):{...a,...i}[g]===x})?[...d,m,h]:d},[]);return Na(e,c,l,n==null?void 0:n.class,n==null?void 0:n.className)};/**
|
|
2
2
|
* @license lucide-react v0.462.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const ng=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),xc=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/**
|
|
7
7
|
* @license lucide-react v0.462.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/var
|
|
11
|
+
*/var rg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
12
12
|
* @license lucide-react v0.462.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const og=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:a,iconNode:c,...i},l)=>y.createElement("svg",{ref:l,...rg,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:xc("lucide",o),...i},[...c.map(([d,u])=>y.createElement(d,u)),...Array.isArray(a)?a:[a]]));/**
|
|
17
17
|
* @license lucide-react v0.462.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const X=(e,t)=>{const n=y.forwardRef(({className:r,...o},a)=>y.createElement(
|
|
21
|
+
*/const X=(e,t)=>{const n=y.forwardRef(({className:r,...o},a)=>y.createElement(og,{ref:a,iconNode:t,className:xc(`lucide-${ng(e)}`,r),...o}));return n.displayName=`${e}`,n};/**
|
|
22
22
|
* @license lucide-react v0.462.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const sg=X("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
|
|
27
27
|
* @license lucide-react v0.462.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const ag=X("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
|
32
32
|
* @license lucide-react v0.462.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
*
|
|
39
39
|
* This source code is licensed under the ISC license.
|
|
40
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const
|
|
41
|
+
*/const ig=X("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/**
|
|
42
42
|
* @license lucide-react v0.462.0 - ISC
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const
|
|
46
|
+
*/const cg=X("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/**
|
|
47
47
|
* @license lucide-react v0.462.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
@@ -58,12 +58,12 @@
|
|
|
58
58
|
*
|
|
59
59
|
* This source code is licensed under the ISC license.
|
|
60
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const
|
|
61
|
+
*/const lg=X("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
|
62
62
|
* @license lucide-react v0.462.0 - ISC
|
|
63
63
|
*
|
|
64
64
|
* This source code is licensed under the ISC license.
|
|
65
65
|
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const
|
|
66
|
+
*/const dg=X("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
|
|
67
67
|
* @license lucide-react v0.462.0 - ISC
|
|
68
68
|
*
|
|
69
69
|
* This source code is licensed under the ISC license.
|
|
@@ -83,12 +83,12 @@
|
|
|
83
83
|
*
|
|
84
84
|
* This source code is licensed under the ISC license.
|
|
85
85
|
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const
|
|
86
|
+
*/const ug=X("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
|
87
87
|
* @license lucide-react v0.462.0 - ISC
|
|
88
88
|
*
|
|
89
89
|
* This source code is licensed under the ISC license.
|
|
90
90
|
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
-
*/const
|
|
91
|
+
*/const fg=X("DoorOpen",[["path",{d:"M13 4h3a2 2 0 0 1 2 2v14",key:"hrm0s9"}],["path",{d:"M2 20h3",key:"1gaodv"}],["path",{d:"M13 20h9",key:"s90cdi"}],["path",{d:"M10 12v.01",key:"vx6srw"}],["path",{d:"M13 4.562v16.157a1 1 0 0 1-1.242.97L5 20V5.562a2 2 0 0 1 1.515-1.94l4-1A2 2 0 0 1 13 4.561Z",key:"199qr4"}]]);/**
|
|
92
92
|
* @license lucide-react v0.462.0 - ISC
|
|
93
93
|
*
|
|
94
94
|
* This source code is licensed under the ISC license.
|
|
@@ -98,32 +98,32 @@
|
|
|
98
98
|
*
|
|
99
99
|
* This source code is licensed under the ISC license.
|
|
100
100
|
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
-
*/const
|
|
101
|
+
*/const mg=X("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/**
|
|
102
102
|
* @license lucide-react v0.462.0 - ISC
|
|
103
103
|
*
|
|
104
104
|
* This source code is licensed under the ISC license.
|
|
105
105
|
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
-
*/const
|
|
106
|
+
*/const pg=X("Forward",[["polyline",{points:"15 17 20 12 15 7",key:"1w3sku"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);/**
|
|
107
107
|
* @license lucide-react v0.462.0 - ISC
|
|
108
108
|
*
|
|
109
109
|
* This source code is licensed under the ISC license.
|
|
110
110
|
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
-
*/const
|
|
111
|
+
*/const hg=X("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
|
|
112
112
|
* @license lucide-react v0.462.0 - ISC
|
|
113
113
|
*
|
|
114
114
|
* This source code is licensed under the ISC license.
|
|
115
115
|
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
-
*/const
|
|
116
|
+
*/const rn=X("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
|
117
117
|
* @license lucide-react v0.462.0 - ISC
|
|
118
118
|
*
|
|
119
119
|
* This source code is licensed under the ISC license.
|
|
120
120
|
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
-
*/const
|
|
121
|
+
*/const gg=X("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
|
|
122
122
|
* @license lucide-react v0.462.0 - ISC
|
|
123
123
|
*
|
|
124
124
|
* This source code is licensed under the ISC license.
|
|
125
125
|
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
-
*/const
|
|
126
|
+
*/const xg=X("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
|
|
127
127
|
* @license lucide-react v0.462.0 - ISC
|
|
128
128
|
*
|
|
129
129
|
* This source code is licensed under the ISC license.
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
*
|
|
134
134
|
* This source code is licensed under the ISC license.
|
|
135
135
|
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
-
*/const
|
|
136
|
+
*/const vg=X("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
|
|
137
137
|
* @license lucide-react v0.462.0 - ISC
|
|
138
138
|
*
|
|
139
139
|
* This source code is licensed under the ISC license.
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
*
|
|
144
144
|
* This source code is licensed under the ISC license.
|
|
145
145
|
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
-
*/const
|
|
146
|
+
*/const yg=X("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/**
|
|
147
147
|
* @license lucide-react v0.462.0 - ISC
|
|
148
148
|
*
|
|
149
149
|
* This source code is licensed under the ISC license.
|
|
@@ -158,12 +158,12 @@
|
|
|
158
158
|
*
|
|
159
159
|
* This source code is licensed under the ISC license.
|
|
160
160
|
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
-
*/const
|
|
161
|
+
*/const bg=X("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/**
|
|
162
162
|
* @license lucide-react v0.462.0 - ISC
|
|
163
163
|
*
|
|
164
164
|
* This source code is licensed under the ISC license.
|
|
165
165
|
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
-
*/const
|
|
166
|
+
*/const wg=X("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/**
|
|
167
167
|
* @license lucide-react v0.462.0 - ISC
|
|
168
168
|
*
|
|
169
169
|
* This source code is licensed under the ISC license.
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
*
|
|
189
189
|
* This source code is licensed under the ISC license.
|
|
190
190
|
* See the LICENSE file in the root directory of this source tree.
|
|
191
|
-
*/const
|
|
191
|
+
*/const Cg=X("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
|
|
192
192
|
* @license lucide-react v0.462.0 - ISC
|
|
193
193
|
*
|
|
194
194
|
* This source code is licensed under the ISC license.
|
|
@@ -203,12 +203,12 @@
|
|
|
203
203
|
*
|
|
204
204
|
* This source code is licensed under the ISC license.
|
|
205
205
|
* See the LICENSE file in the root directory of this source tree.
|
|
206
|
-
*/const
|
|
206
|
+
*/const Sg=X("Smile",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/**
|
|
207
207
|
* @license lucide-react v0.462.0 - ISC
|
|
208
208
|
*
|
|
209
209
|
* This source code is licensed under the ISC license.
|
|
210
210
|
* See the LICENSE file in the root directory of this source tree.
|
|
211
|
-
*/const
|
|
211
|
+
*/const jg=X("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
212
212
|
* @license lucide-react v0.462.0 - ISC
|
|
213
213
|
*
|
|
214
214
|
* This source code is licensed under the ISC license.
|
|
@@ -233,13 +233,13 @@
|
|
|
233
233
|
*
|
|
234
234
|
* This source code is licensed under the ISC license.
|
|
235
235
|
* See the LICENSE file in the root directory of this source tree.
|
|
236
|
-
*/const
|
|
236
|
+
*/const Ng=X("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
|
|
237
237
|
* @license lucide-react v0.462.0 - ISC
|
|
238
238
|
*
|
|
239
239
|
* This source code is licensed under the ISC license.
|
|
240
240
|
* See the LICENSE file in the root directory of this source tree.
|
|
241
|
-
*/const vn=X("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Ng=eg,jc=f.forwardRef(({className:e,...t},n)=>s.jsx(uc,{ref:n,className:W("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));jc.displayName=uc.displayName;const _g=ws("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Nc=f.forwardRef(({className:e,variant:t,...n},r)=>s.jsx(fc,{ref:r,className:W(_g({variant:t}),e),...n}));Nc.displayName=fc.displayName;const Eg=f.forwardRef(({className:e,...t},n)=>s.jsx(hc,{ref:n,className:W("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",e),...t}));Eg.displayName=hc.displayName;const _c=f.forwardRef(({className:e,...t},n)=>s.jsx(gc,{ref:n,className:W("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:s.jsx(vn,{className:"h-4 w-4"})}));_c.displayName=gc.displayName;const Ec=f.forwardRef(({className:e,...t},n)=>s.jsx(mc,{ref:n,className:W("text-sm font-semibold",e),...t}));Ec.displayName=mc.displayName;const Mc=f.forwardRef(({className:e,...t},n)=>s.jsx(pc,{ref:n,className:W("text-sm opacity-90",e),...t}));Mc.displayName=pc.displayName;function Mg(){const{toasts:e}=xn();return s.jsxs(Ng,{children:[e.map(function({id:t,title:n,description:r,action:o,...a}){return s.jsxs(Nc,{...a,children:[s.jsxs("div",{className:"grid gap-1",children:[n&&s.jsx(Ec,{children:n}),r&&s.jsx(Mc,{children:r})]}),o,s.jsx(_c,{})]},t)}),s.jsx(jc,{})]})}var Ra=["light","dark"],Tg="(prefers-color-scheme: dark)",Rg=f.createContext(void 0),kg={setTheme:e=>{},themes:[]},Pg=()=>{var e;return(e=f.useContext(Rg))!=null?e:kg};f.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:a,value:c,attrs:i,nonce:l})=>{let d=a==="system",u=n==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${i.map(v=>`'${v}'`).join(",")})`};`:`var d=document.documentElement,n='${n}',s='setAttribute';`,m=o?Ra.includes(a)&&a?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${a}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",h=(v,g=!1,x=!0)=>{let C=c?c[v]:v,w=g?v+"|| ''":`'${C}'`,b="";return o&&x&&!g&&Ra.includes(v)&&(b+=`d.style.colorScheme = '${v}';`),n==="class"?g||C?b+=`c.add(${w})`:b+="null":C&&(b+=`d[s](n,${w})`),b},p=e?`!function(){${u}${h(e)}}()`:r?`!function(){try{${u}var e=localStorage.getItem('${t}');if('system'===e||(!e&&${d})){var t='${Tg}',m=window.matchMedia(t);if(m.media!==t||m.matches){${h("dark")}}else{${h("light")}}}else if(e){${c?`var x=${JSON.stringify(c)};`:""}${h(c?"x[e]":"e",!0)}}${d?"":"else{"+h(a,!1,!1)+"}"}${m}}catch(e){}}()`:`!function(){try{${u}var e=localStorage.getItem('${t}');if(e){${c?`var x=${JSON.stringify(c)};`:""}${h(c?"x[e]":"e",!0)}}else{${h(a,!1,!1)};}${m}}catch(t){}}();`;return f.createElement("script",{nonce:l,dangerouslySetInnerHTML:{__html:p}})});var Ag=e=>{switch(e){case"success":return Ig;case"info":return $g;case"warning":return Lg;case"error":return Fg;default:return null}},Og=Array(12).fill(0),Dg=({visible:e,className:t})=>y.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},y.createElement("div",{className:"sonner-spinner"},Og.map((n,r)=>y.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),Ig=y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},y.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),Lg=y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},y.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),$g=y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},y.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Fg=y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},y.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),zg=y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},y.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),y.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Wg=()=>{let[e,t]=y.useState(document.hidden);return y.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},zo=1,Bg=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:zo++,a=this.toasts.find(i=>i.id===o),c=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),a?this.toasts=this.toasts.map(i=>i.id===o?(this.publish({...i,...e,id:o,title:n}),{...i,...e,id:o,dismissible:c,title:n}):i):this.addToast({title:n,...r,dismissible:c,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,a,c=r.then(async l=>{if(a=["resolve",l],y.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(Ug(l)&&!l.ok){o=!1;let d=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,u=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:d,description:u})}else if(t.success!==void 0){o=!1;let d=typeof t.success=="function"?await t.success(l):t.success,u=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:d,description:u})}}).catch(async l=>{if(a=["reject",l],t.error!==void 0){o=!1;let d=typeof t.error=="function"?await t.error(l):t.error,u=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:d,description:u})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),i=()=>new Promise((l,d)=>c.then(()=>a[0]==="reject"?d(a[1]):l(a[1])).catch(d));return typeof n!="string"&&typeof n!="number"?{unwrap:i}:Object.assign(n,{unwrap:i})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||zo++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Re=new Bg,qg=(e,t)=>{let n=(t==null?void 0:t.id)||zo++;return Re.addToast({title:e,...t,id:n}),n},Ug=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",Hg=qg,Vg=()=>Re.toasts,Gg=()=>Re.getActiveToasts(),Rn=Object.assign(Hg,{success:Re.success,info:Re.info,warning:Re.warning,error:Re.error,custom:Re.custom,message:Re.message,promise:Re.promise,dismiss:Re.dismiss,loading:Re.loading},{getHistory:Vg,getToasts:Gg});function Yg(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}Yg(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
242
|
-
`);function nr(e){return e.label!==void 0}var Kg=3,Xg="32px",Qg="16px",ka=4e3,Zg=356,Jg=14,ex=20,tx=200;function Xe(...e){return e.filter(Boolean).join(" ")}function nx(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var rx=e=>{var t,n,r,o,a,c,i,l,d,u,m;let{invert:h,toast:p,unstyled:v,interacting:g,setHeights:x,visibleToasts:C,heights:w,index:b,toasts:S,expanded:j,removeToast:N,defaultRichColors:_,closeButton:O,style:k,cancelButtonStyle:P,actionButtonStyle:I,className:A="",descriptionClassName:D="",duration:E,position:F,gap:T,loadingIcon:z,expandByDefault:$,classNames:M,icons:H,closeButtonAriaLabel:Z="Close toast",pauseWhenPageIsHidden:V}=e,[G,B]=y.useState(null),[re,ue]=y.useState(null),[J,Pe]=y.useState(!1),[he,ze]=y.useState(!1),[Ae,Ve]=y.useState(!1),[Ge,Gt]=y.useState(!1),[Rt,Yt]=y.useState(!1),[kt,Pt]=y.useState(0),[lt,Kt]=y.useState(0),je=y.useRef(p.duration||E||ka),bn=y.useRef(null),We=y.useRef(null),Yn=b===0,Xt=b+1<=C,we=p.type,et=p.dismissible!==!1,wn=p.className||"",Kn=p.descriptionClassName||"",At=y.useMemo(()=>w.findIndex(Y=>Y.toastId===p.id)||0,[w,p.id]),Cn=y.useMemo(()=>{var Y;return(Y=p.closeButton)!=null?Y:O},[p.closeButton,O]),te=y.useMemo(()=>p.duration||E||ka,[p.duration,E]),Ot=y.useRef(0),tt=y.useRef(0),Xn=y.useRef(0),dt=y.useRef(null),[Sn,Qn]=F.split("-"),Dt=y.useMemo(()=>w.reduce((Y,se,fe)=>fe>=At?Y:Y+se.height,0),[w,At]),Zn=Wg(),eo=p.invert||h,jn=we==="loading";tt.current=y.useMemo(()=>At*T+Dt,[At,Dt]),y.useEffect(()=>{je.current=te},[te]),y.useEffect(()=>{Pe(!0)},[]),y.useEffect(()=>{let Y=We.current;if(Y){let se=Y.getBoundingClientRect().height;return Kt(se),x(fe=>[{toastId:p.id,height:se,position:p.position},...fe]),()=>x(fe=>fe.filter(Oe=>Oe.toastId!==p.id))}},[x,p.id]),y.useLayoutEffect(()=>{if(!J)return;let Y=We.current,se=Y.style.height;Y.style.height="auto";let fe=Y.getBoundingClientRect().height;Y.style.height=se,Kt(fe),x(Oe=>Oe.find(be=>be.toastId===p.id)?Oe.map(be=>be.toastId===p.id?{...be,height:fe}:be):[{toastId:p.id,height:fe,position:p.position},...Oe])},[J,p.title,p.description,x,p.id]);let nt=y.useCallback(()=>{ze(!0),Pt(tt.current),x(Y=>Y.filter(se=>se.toastId!==p.id)),setTimeout(()=>{N(p)},tx)},[p,N,x,tt]);y.useEffect(()=>{if(p.promise&&we==="loading"||p.duration===1/0||p.type==="loading")return;let Y;return j||g||V&&Zn?(()=>{if(Xn.current<Ot.current){let se=new Date().getTime()-Ot.current;je.current=je.current-se}Xn.current=new Date().getTime()})():je.current!==1/0&&(Ot.current=new Date().getTime(),Y=setTimeout(()=>{var se;(se=p.onAutoClose)==null||se.call(p,p),nt()},je.current)),()=>clearTimeout(Y)},[j,g,p,we,V,Zn,nt]),y.useEffect(()=>{p.delete&&nt()},[nt,p.delete]);function to(){var Y,se,fe;return H!=null&&H.loading?y.createElement("div",{className:Xe(M==null?void 0:M.loader,(Y=p==null?void 0:p.classNames)==null?void 0:Y.loader,"sonner-loader"),"data-visible":we==="loading"},H.loading):z?y.createElement("div",{className:Xe(M==null?void 0:M.loader,(se=p==null?void 0:p.classNames)==null?void 0:se.loader,"sonner-loader"),"data-visible":we==="loading"},z):y.createElement(Dg,{className:Xe(M==null?void 0:M.loader,(fe=p==null?void 0:p.classNames)==null?void 0:fe.loader),visible:we==="loading"})}return y.createElement("li",{tabIndex:0,ref:We,className:Xe(A,wn,M==null?void 0:M.toast,(t=p==null?void 0:p.classNames)==null?void 0:t.toast,M==null?void 0:M.default,M==null?void 0:M[we],(n=p==null?void 0:p.classNames)==null?void 0:n[we]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:_,"data-styled":!(p.jsx||p.unstyled||v),"data-mounted":J,"data-promise":!!p.promise,"data-swiped":Rt,"data-removed":he,"data-visible":Xt,"data-y-position":Sn,"data-x-position":Qn,"data-index":b,"data-front":Yn,"data-swiping":Ae,"data-dismissible":et,"data-type":we,"data-invert":eo,"data-swipe-out":Ge,"data-swipe-direction":re,"data-expanded":!!(j||$&&J),style:{"--index":b,"--toasts-before":b,"--z-index":S.length-b,"--offset":`${he?kt:tt.current}px`,"--initial-height":$?"auto":`${lt}px`,...k,...p.style},onDragEnd:()=>{Ve(!1),B(null),dt.current=null},onPointerDown:Y=>{jn||!et||(bn.current=new Date,Pt(tt.current),Y.target.setPointerCapture(Y.pointerId),Y.target.tagName!=="BUTTON"&&(Ve(!0),dt.current={x:Y.clientX,y:Y.clientY}))},onPointerUp:()=>{var Y,se,fe,Oe;if(Ge||!et)return;dt.current=null;let be=Number(((Y=We.current)==null?void 0:Y.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ye=Number(((se=We.current)==null?void 0:se.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ut=new Date().getTime()-((fe=bn.current)==null?void 0:fe.getTime()),Ne=G==="x"?be:Ye,De=Math.abs(Ne)/ut;if(Math.abs(Ne)>=ex||De>.11){Pt(tt.current),(Oe=p.onDismiss)==null||Oe.call(p,p),ue(G==="x"?be>0?"right":"left":Ye>0?"down":"up"),nt(),Gt(!0),Yt(!1);return}Ve(!1),B(null)},onPointerMove:Y=>{var se,fe,Oe,be;if(!dt.current||!et||((se=window.getSelection())==null?void 0:se.toString().length)>0)return;let Ye=Y.clientY-dt.current.y,ut=Y.clientX-dt.current.x,Ne=(fe=e.swipeDirections)!=null?fe:nx(F);!G&&(Math.abs(ut)>1||Math.abs(Ye)>1)&&B(Math.abs(ut)>Math.abs(Ye)?"x":"y");let De={x:0,y:0};G==="y"?(Ne.includes("top")||Ne.includes("bottom"))&&(Ne.includes("top")&&Ye<0||Ne.includes("bottom")&&Ye>0)&&(De.y=Ye):G==="x"&&(Ne.includes("left")||Ne.includes("right"))&&(Ne.includes("left")&&ut<0||Ne.includes("right")&&ut>0)&&(De.x=ut),(Math.abs(De.x)>0||Math.abs(De.y)>0)&&Yt(!0),(Oe=We.current)==null||Oe.style.setProperty("--swipe-amount-x",`${De.x}px`),(be=We.current)==null||be.style.setProperty("--swipe-amount-y",`${De.y}px`)}},Cn&&!p.jsx?y.createElement("button",{"aria-label":Z,"data-disabled":jn,"data-close-button":!0,onClick:jn||!et?()=>{}:()=>{var Y;nt(),(Y=p.onDismiss)==null||Y.call(p,p)},className:Xe(M==null?void 0:M.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(a=H==null?void 0:H.close)!=null?a:zg):null,p.jsx||y.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:y.createElement(y.Fragment,null,we||p.icon||p.promise?y.createElement("div",{"data-icon":"",className:Xe(M==null?void 0:M.icon,(c=p==null?void 0:p.classNames)==null?void 0:c.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||to():null,p.type!=="loading"?p.icon||(H==null?void 0:H[we])||Ag(we):null):null,y.createElement("div",{"data-content":"",className:Xe(M==null?void 0:M.content,(i=p==null?void 0:p.classNames)==null?void 0:i.content)},y.createElement("div",{"data-title":"",className:Xe(M==null?void 0:M.title,(l=p==null?void 0:p.classNames)==null?void 0:l.title)},typeof p.title=="function"?p.title():p.title),p.description?y.createElement("div",{"data-description":"",className:Xe(D,Kn,M==null?void 0:M.description,(d=p==null?void 0:p.classNames)==null?void 0:d.description)},typeof p.description=="function"?p.description():p.description):null),y.isValidElement(p.cancel)?p.cancel:p.cancel&&nr(p.cancel)?y.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||P,onClick:Y=>{var se,fe;nr(p.cancel)&&et&&((fe=(se=p.cancel).onClick)==null||fe.call(se,Y),nt())},className:Xe(M==null?void 0:M.cancelButton,(u=p==null?void 0:p.classNames)==null?void 0:u.cancelButton)},p.cancel.label):null,y.isValidElement(p.action)?p.action:p.action&&nr(p.action)?y.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||I,onClick:Y=>{var se,fe;nr(p.action)&&((fe=(se=p.action).onClick)==null||fe.call(se,Y),!Y.defaultPrevented&&nt())},className:Xe(M==null?void 0:M.actionButton,(m=p==null?void 0:p.classNames)==null?void 0:m.actionButton)},p.action.label):null))};function Pa(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function ox(e,t){let n={};return[e,t].forEach((r,o)=>{let a=o===1,c=a?"--mobile-offset":"--offset",i=a?Qg:Xg;function l(d){["top","right","bottom","left"].forEach(u=>{n[`${c}-${u}`]=typeof d=="number"?`${d}px`:d})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(d=>{r[d]===void 0?n[`${c}-${d}`]=i:n[`${c}-${d}`]=typeof r[d]=="number"?`${r[d]}px`:r[d]}):l(i)}),n}var sx=y.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:a,closeButton:c,className:i,offset:l,mobileOffset:d,theme:u="light",richColors:m,duration:h,style:p,visibleToasts:v=Kg,toastOptions:g,dir:x=Pa(),gap:C=Jg,loadingIcon:w,icons:b,containerAriaLabel:S="Notifications",pauseWhenPageIsHidden:j}=e,[N,_]=y.useState([]),O=y.useMemo(()=>Array.from(new Set([r].concat(N.filter(V=>V.position).map(V=>V.position)))),[N,r]),[k,P]=y.useState([]),[I,A]=y.useState(!1),[D,E]=y.useState(!1),[F,T]=y.useState(u!=="system"?u:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=y.useRef(null),$=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),M=y.useRef(null),H=y.useRef(!1),Z=y.useCallback(V=>{_(G=>{var B;return(B=G.find(re=>re.id===V.id))!=null&&B.delete||Re.dismiss(V.id),G.filter(({id:re})=>re!==V.id)})},[]);return y.useEffect(()=>Re.subscribe(V=>{if(V.dismiss){_(G=>G.map(B=>B.id===V.id?{...B,delete:!0}:B));return}setTimeout(()=>{ts.flushSync(()=>{_(G=>{let B=G.findIndex(re=>re.id===V.id);return B!==-1?[...G.slice(0,B),{...G[B],...V},...G.slice(B+1)]:[V,...G]})})})}),[]),y.useEffect(()=>{if(u!=="system"){T(u);return}if(u==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?T("dark"):T("light")),typeof window>"u")return;let V=window.matchMedia("(prefers-color-scheme: dark)");try{V.addEventListener("change",({matches:G})=>{T(G?"dark":"light")})}catch{V.addListener(({matches:B})=>{try{T(B?"dark":"light")}catch(re){console.error(re)}})}},[u]),y.useEffect(()=>{N.length<=1&&A(!1)},[N]),y.useEffect(()=>{let V=G=>{var B,re;o.every(ue=>G[ue]||G.code===ue)&&(A(!0),(B=z.current)==null||B.focus()),G.code==="Escape"&&(document.activeElement===z.current||(re=z.current)!=null&&re.contains(document.activeElement))&&A(!1)};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[o]),y.useEffect(()=>{if(z.current)return()=>{M.current&&(M.current.focus({preventScroll:!0}),M.current=null,H.current=!1)}},[z.current]),y.createElement("section",{ref:t,"aria-label":`${S} ${$}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},O.map((V,G)=>{var B;let[re,ue]=V.split("-");return N.length?y.createElement("ol",{key:V,dir:x==="auto"?Pa():x,tabIndex:-1,ref:z,className:i,"data-sonner-toaster":!0,"data-theme":F,"data-y-position":re,"data-lifted":I&&N.length>1&&!a,"data-x-position":ue,style:{"--front-toast-height":`${((B=k[0])==null?void 0:B.height)||0}px`,"--width":`${Zg}px`,"--gap":`${C}px`,...p,...ox(l,d)},onBlur:J=>{H.current&&!J.currentTarget.contains(J.relatedTarget)&&(H.current=!1,M.current&&(M.current.focus({preventScroll:!0}),M.current=null))},onFocus:J=>{J.target instanceof HTMLElement&&J.target.dataset.dismissible==="false"||H.current||(H.current=!0,M.current=J.relatedTarget)},onMouseEnter:()=>A(!0),onMouseMove:()=>A(!0),onMouseLeave:()=>{D||A(!1)},onDragEnd:()=>A(!1),onPointerDown:J=>{J.target instanceof HTMLElement&&J.target.dataset.dismissible==="false"||E(!0)},onPointerUp:()=>E(!1)},N.filter(J=>!J.position&&G===0||J.position===V).map((J,Pe)=>{var he,ze;return y.createElement(rx,{key:J.id,icons:b,index:Pe,toast:J,defaultRichColors:m,duration:(he=g==null?void 0:g.duration)!=null?he:h,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(ze=g==null?void 0:g.closeButton)!=null?ze:c,interacting:D,position:V,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:Z,toasts:N.filter(Ae=>Ae.position==J.position),heights:k.filter(Ae=>Ae.position==J.position),setHeights:P,expandByDefault:a,gap:C,loadingIcon:w,expanded:I,pauseWhenPageIsHidden:j,swipeDirections:e.swipeDirections})})):null}))});const ax=({...e})=>{const{theme:t="system"}=Pg();return s.jsx(sx,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})},me={conversations:e=>["qc:conversations",e],messages:e=>["qc:messages",e],unreadIds:(e,t)=>["qc:unread-ids",e,t],contacts:e=>["qc:contacts",e],searchUsers:e=>["qc:searchUsers",e],profile:e=>["qc:profile",e],reactions:e=>["qc:reactions",e]},js=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient(),r=oe.useQuery({queryKey:me.conversations(e==null?void 0:e.id),queryFn:async()=>{if(!e)return[];const{data:o,error:a}=await t.from("conversation_members").select("conversation_id").eq("user_id",e.id);if(a)throw a;const c=(o==null?void 0:o.map(w=>w.conversation_id))??[];if(c.length===0)return[];const{data:i,error:l}=await t.from("conversations").select("*").in("id",c).order("updated_at",{ascending:!1});if(l)throw l;if(!i||i.length===0)return[];const{data:d}=await t.from("conversation_members").select("conversation_id, user_id, role").in("conversation_id",c),u=[...new Set((d??[]).map(w=>w.user_id))],m={};if(u.length>0){const{data:w}=await t.from("profiles").select("id, display_name, avatar_url, is_online, last_seen").in("id",u);(w??[]).forEach(b=>{m[b.id]=b})}const h={};for(const w of d??[]){h[w.conversation_id]||(h[w.conversation_id]=[]);const b=m[w.user_id];b&&h[w.conversation_id].push({user_id:w.user_id,role:w.role,profile:b})}const{data:p}=await t.from("messages").select("id, conversation_id, sender_id").in("conversation_id",c).eq("is_deleted",!1).neq("sender_id",e.id),v=(p??[]).map(w=>w.id),g={};for(const w of p??[])g[w.conversation_id]||(g[w.conversation_id]=[]),g[w.conversation_id].push(w.id);const x=new Set;if(v.length>0)for(let w=0;w<v.length;w+=500){const b=v.slice(w,w+500),{data:S}=await t.from("message_reads").select("message_id").eq("user_id",e.id).in("message_id",b);(S??[]).forEach(j=>x.add(j.message_id))}const C=await Promise.all(i.map(w=>t.from("messages").select("content, type, created_at, sender_id").eq("conversation_id",w.id).eq("is_deleted",!1).order("created_at",{ascending:!1}).limit(1).maybeSingle()));return i.map((w,b)=>{const j=(g[w.id]??[]).filter(N=>!x.has(N)).length;return{id:w.id,type:w.type,name:w.name,avatar_url:w.avatar_url,updated_at:w.updated_at,members:h[w.id]??[],last_message:C[b].data??null,unread_count:j}})},enabled:!!e});return y.useEffect(()=>{if(!e)return;const o=t.channel("conversations-realtime").on("postgres_changes",{event:"*",schema:"public",table:"messages"},()=>{n.invalidateQueries({queryKey:me.conversations(e.id)})}).on("postgres_changes",{event:"*",schema:"public",table:"conversation_members"},()=>{n.invalidateQueries({queryKey:me.conversations(e.id)})}).subscribe();return()=>{t.removeChannel(o)}},[e,n,t]),r},ix=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient();return oe.useMutation({mutationFn:async r=>{if(!e)throw new Error("Not authenticated");const{data:o}=await t.from("conversation_members").select("conversation_id").eq("user_id",e.id),{data:a}=await t.from("conversation_members").select("conversation_id").eq("user_id",r),c=new Set(o==null?void 0:o.map(h=>h.conversation_id)),i=(a==null?void 0:a.filter(h=>c.has(h.conversation_id)).map(h=>h.conversation_id))??[];if(i.length>0){const{data:h}=await t.from("conversations").select("id").in("id",i).eq("type","private").limit(1).maybeSingle();if(h)return h.id}const{data:l,error:d}=await t.from("conversations").insert({type:"private",created_by:e.id}).select("id").single();if(d)throw d;const{error:u}=await t.from("conversation_members").insert({conversation_id:l.id,user_id:e.id,role:"owner"});if(u)throw u;const{error:m}=await t.from("conversation_members").insert({conversation_id:l.id,user_id:r,role:"member"});if(m)throw m;return l.id},onSuccess:()=>{n.invalidateQueries({queryKey:me.conversations(e==null?void 0:e.id)})}})},cx=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient();return oe.useMutation({mutationFn:async({name:r,memberIds:o})=>{if(!e)throw new Error("Not authenticated");const{data:a,error:c}=await t.from("conversations").insert({type:"group",name:r,created_by:e.id}).select("id").single();if(c)throw c;const{error:i}=await t.from("conversation_members").insert({conversation_id:a.id,user_id:e.id,role:"owner"});if(i)throw i;if(o.length>0){const l=o.map(u=>({conversation_id:a.id,user_id:u,role:"member"})),{error:d}=await t.from("conversation_members").insert(l);if(d)throw d}return a.id},onSuccess:()=>{n.invalidateQueries({queryKey:me.conversations(e==null?void 0:e.id)})}})},lx=()=>{const{user:e}=ye(),t=ve();return oe.useQuery({queryKey:me.profile(e==null?void 0:e.id),queryFn:async()=>{if(!e)return null;const{data:n,error:r}=await t.from("profiles").select("*").eq("id",e.id).single();if(r)throw r;return n},enabled:!!e})};var Wo={exports:{}},fo={};/**
|
|
241
|
+
*/const vn=X("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),_g=tg,jc=f.forwardRef(({className:e,...t},n)=>s.jsx(uc,{ref:n,className:W("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));jc.displayName=uc.displayName;const Eg=ws("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Nc=f.forwardRef(({className:e,variant:t,...n},r)=>s.jsx(fc,{ref:r,className:W(Eg({variant:t}),e),...n}));Nc.displayName=fc.displayName;const Mg=f.forwardRef(({className:e,...t},n)=>s.jsx(hc,{ref:n,className:W("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",e),...t}));Mg.displayName=hc.displayName;const _c=f.forwardRef(({className:e,...t},n)=>s.jsx(gc,{ref:n,className:W("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:s.jsx(vn,{className:"h-4 w-4"})}));_c.displayName=gc.displayName;const Ec=f.forwardRef(({className:e,...t},n)=>s.jsx(mc,{ref:n,className:W("text-sm font-semibold",e),...t}));Ec.displayName=mc.displayName;const Mc=f.forwardRef(({className:e,...t},n)=>s.jsx(pc,{ref:n,className:W("text-sm opacity-90",e),...t}));Mc.displayName=pc.displayName;function Tg(){const{toasts:e}=xn();return s.jsxs(_g,{children:[e.map(function({id:t,title:n,description:r,action:o,...a}){return s.jsxs(Nc,{...a,children:[s.jsxs("div",{className:"grid gap-1",children:[n&&s.jsx(Ec,{children:n}),r&&s.jsx(Mc,{children:r})]}),o,s.jsx(_c,{})]},t)}),s.jsx(jc,{})]})}var Ra=["light","dark"],Rg="(prefers-color-scheme: dark)",kg=f.createContext(void 0),Pg={setTheme:e=>{},themes:[]},Ag=()=>{var e;return(e=f.useContext(kg))!=null?e:Pg};f.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:a,value:c,attrs:i,nonce:l})=>{let d=a==="system",u=n==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${i.map(v=>`'${v}'`).join(",")})`};`:`var d=document.documentElement,n='${n}',s='setAttribute';`,m=o?Ra.includes(a)&&a?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${a}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",h=(v,g=!1,x=!0)=>{let C=c?c[v]:v,w=g?v+"|| ''":`'${C}'`,b="";return o&&x&&!g&&Ra.includes(v)&&(b+=`d.style.colorScheme = '${v}';`),n==="class"?g||C?b+=`c.add(${w})`:b+="null":C&&(b+=`d[s](n,${w})`),b},p=e?`!function(){${u}${h(e)}}()`:r?`!function(){try{${u}var e=localStorage.getItem('${t}');if('system'===e||(!e&&${d})){var t='${Rg}',m=window.matchMedia(t);if(m.media!==t||m.matches){${h("dark")}}else{${h("light")}}}else if(e){${c?`var x=${JSON.stringify(c)};`:""}${h(c?"x[e]":"e",!0)}}${d?"":"else{"+h(a,!1,!1)+"}"}${m}}catch(e){}}()`:`!function(){try{${u}var e=localStorage.getItem('${t}');if(e){${c?`var x=${JSON.stringify(c)};`:""}${h(c?"x[e]":"e",!0)}}else{${h(a,!1,!1)};}${m}}catch(t){}}();`;return f.createElement("script",{nonce:l,dangerouslySetInnerHTML:{__html:p}})});var Og=e=>{switch(e){case"success":return Lg;case"info":return Fg;case"warning":return $g;case"error":return zg;default:return null}},Dg=Array(12).fill(0),Ig=({visible:e,className:t})=>y.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},y.createElement("div",{className:"sonner-spinner"},Dg.map((n,r)=>y.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),Lg=y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},y.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),$g=y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},y.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Fg=y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},y.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),zg=y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},y.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Wg=y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},y.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),y.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Bg=()=>{let[e,t]=y.useState(document.hidden);return y.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},zo=1,qg=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:zo++,a=this.toasts.find(i=>i.id===o),c=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),a?this.toasts=this.toasts.map(i=>i.id===o?(this.publish({...i,...e,id:o,title:n}),{...i,...e,id:o,dismissible:c,title:n}):i):this.addToast({title:n,...r,dismissible:c,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,a,c=r.then(async l=>{if(a=["resolve",l],y.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(Hg(l)&&!l.ok){o=!1;let d=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,u=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:d,description:u})}else if(t.success!==void 0){o=!1;let d=typeof t.success=="function"?await t.success(l):t.success,u=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:d,description:u})}}).catch(async l=>{if(a=["reject",l],t.error!==void 0){o=!1;let d=typeof t.error=="function"?await t.error(l):t.error,u=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:d,description:u})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),i=()=>new Promise((l,d)=>c.then(()=>a[0]==="reject"?d(a[1]):l(a[1])).catch(d));return typeof n!="string"&&typeof n!="number"?{unwrap:i}:Object.assign(n,{unwrap:i})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||zo++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Re=new qg,Ug=(e,t)=>{let n=(t==null?void 0:t.id)||zo++;return Re.addToast({title:e,...t,id:n}),n},Hg=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",Vg=Ug,Gg=()=>Re.toasts,Yg=()=>Re.getActiveToasts(),Rn=Object.assign(Vg,{success:Re.success,info:Re.info,warning:Re.warning,error:Re.error,custom:Re.custom,message:Re.message,promise:Re.promise,dismiss:Re.dismiss,loading:Re.loading},{getHistory:Gg,getToasts:Yg});function Kg(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}Kg(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
242
|
+
`);function nr(e){return e.label!==void 0}var Xg=3,Qg="32px",Zg="16px",ka=4e3,Jg=356,ex=14,tx=20,nx=200;function Xe(...e){return e.filter(Boolean).join(" ")}function rx(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var ox=e=>{var t,n,r,o,a,c,i,l,d,u,m;let{invert:h,toast:p,unstyled:v,interacting:g,setHeights:x,visibleToasts:C,heights:w,index:b,toasts:S,expanded:j,removeToast:N,defaultRichColors:_,closeButton:O,style:k,cancelButtonStyle:P,actionButtonStyle:I,className:A="",descriptionClassName:D="",duration:E,position:F,gap:T,loadingIcon:z,expandByDefault:$,classNames:M,icons:H,closeButtonAriaLabel:Z="Close toast",pauseWhenPageIsHidden:V}=e,[G,B]=y.useState(null),[re,ue]=y.useState(null),[J,Pe]=y.useState(!1),[he,ze]=y.useState(!1),[Ae,Ve]=y.useState(!1),[Ge,Vt]=y.useState(!1),[Rt,Gt]=y.useState(!1),[kt,Pt]=y.useState(0),[lt,Yt]=y.useState(0),je=y.useRef(p.duration||E||ka),bn=y.useRef(null),We=y.useRef(null),Yn=b===0,Kt=b+1<=C,we=p.type,et=p.dismissible!==!1,wn=p.className||"",Kn=p.descriptionClassName||"",At=y.useMemo(()=>w.findIndex(Y=>Y.toastId===p.id)||0,[w,p.id]),Cn=y.useMemo(()=>{var Y;return(Y=p.closeButton)!=null?Y:O},[p.closeButton,O]),te=y.useMemo(()=>p.duration||E||ka,[p.duration,E]),Ot=y.useRef(0),tt=y.useRef(0),Xn=y.useRef(0),dt=y.useRef(null),[Sn,Qn]=F.split("-"),Dt=y.useMemo(()=>w.reduce((Y,se,fe)=>fe>=At?Y:Y+se.height,0),[w,At]),Zn=Bg(),eo=p.invert||h,jn=we==="loading";tt.current=y.useMemo(()=>At*T+Dt,[At,Dt]),y.useEffect(()=>{je.current=te},[te]),y.useEffect(()=>{Pe(!0)},[]),y.useEffect(()=>{let Y=We.current;if(Y){let se=Y.getBoundingClientRect().height;return Yt(se),x(fe=>[{toastId:p.id,height:se,position:p.position},...fe]),()=>x(fe=>fe.filter(Oe=>Oe.toastId!==p.id))}},[x,p.id]),y.useLayoutEffect(()=>{if(!J)return;let Y=We.current,se=Y.style.height;Y.style.height="auto";let fe=Y.getBoundingClientRect().height;Y.style.height=se,Yt(fe),x(Oe=>Oe.find(be=>be.toastId===p.id)?Oe.map(be=>be.toastId===p.id?{...be,height:fe}:be):[{toastId:p.id,height:fe,position:p.position},...Oe])},[J,p.title,p.description,x,p.id]);let nt=y.useCallback(()=>{ze(!0),Pt(tt.current),x(Y=>Y.filter(se=>se.toastId!==p.id)),setTimeout(()=>{N(p)},nx)},[p,N,x,tt]);y.useEffect(()=>{if(p.promise&&we==="loading"||p.duration===1/0||p.type==="loading")return;let Y;return j||g||V&&Zn?(()=>{if(Xn.current<Ot.current){let se=new Date().getTime()-Ot.current;je.current=je.current-se}Xn.current=new Date().getTime()})():je.current!==1/0&&(Ot.current=new Date().getTime(),Y=setTimeout(()=>{var se;(se=p.onAutoClose)==null||se.call(p,p),nt()},je.current)),()=>clearTimeout(Y)},[j,g,p,we,V,Zn,nt]),y.useEffect(()=>{p.delete&&nt()},[nt,p.delete]);function to(){var Y,se,fe;return H!=null&&H.loading?y.createElement("div",{className:Xe(M==null?void 0:M.loader,(Y=p==null?void 0:p.classNames)==null?void 0:Y.loader,"sonner-loader"),"data-visible":we==="loading"},H.loading):z?y.createElement("div",{className:Xe(M==null?void 0:M.loader,(se=p==null?void 0:p.classNames)==null?void 0:se.loader,"sonner-loader"),"data-visible":we==="loading"},z):y.createElement(Ig,{className:Xe(M==null?void 0:M.loader,(fe=p==null?void 0:p.classNames)==null?void 0:fe.loader),visible:we==="loading"})}return y.createElement("li",{tabIndex:0,ref:We,className:Xe(A,wn,M==null?void 0:M.toast,(t=p==null?void 0:p.classNames)==null?void 0:t.toast,M==null?void 0:M.default,M==null?void 0:M[we],(n=p==null?void 0:p.classNames)==null?void 0:n[we]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:_,"data-styled":!(p.jsx||p.unstyled||v),"data-mounted":J,"data-promise":!!p.promise,"data-swiped":Rt,"data-removed":he,"data-visible":Kt,"data-y-position":Sn,"data-x-position":Qn,"data-index":b,"data-front":Yn,"data-swiping":Ae,"data-dismissible":et,"data-type":we,"data-invert":eo,"data-swipe-out":Ge,"data-swipe-direction":re,"data-expanded":!!(j||$&&J),style:{"--index":b,"--toasts-before":b,"--z-index":S.length-b,"--offset":`${he?kt:tt.current}px`,"--initial-height":$?"auto":`${lt}px`,...k,...p.style},onDragEnd:()=>{Ve(!1),B(null),dt.current=null},onPointerDown:Y=>{jn||!et||(bn.current=new Date,Pt(tt.current),Y.target.setPointerCapture(Y.pointerId),Y.target.tagName!=="BUTTON"&&(Ve(!0),dt.current={x:Y.clientX,y:Y.clientY}))},onPointerUp:()=>{var Y,se,fe,Oe;if(Ge||!et)return;dt.current=null;let be=Number(((Y=We.current)==null?void 0:Y.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ye=Number(((se=We.current)==null?void 0:se.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ut=new Date().getTime()-((fe=bn.current)==null?void 0:fe.getTime()),Ne=G==="x"?be:Ye,De=Math.abs(Ne)/ut;if(Math.abs(Ne)>=tx||De>.11){Pt(tt.current),(Oe=p.onDismiss)==null||Oe.call(p,p),ue(G==="x"?be>0?"right":"left":Ye>0?"down":"up"),nt(),Vt(!0),Gt(!1);return}Ve(!1),B(null)},onPointerMove:Y=>{var se,fe,Oe,be;if(!dt.current||!et||((se=window.getSelection())==null?void 0:se.toString().length)>0)return;let Ye=Y.clientY-dt.current.y,ut=Y.clientX-dt.current.x,Ne=(fe=e.swipeDirections)!=null?fe:rx(F);!G&&(Math.abs(ut)>1||Math.abs(Ye)>1)&&B(Math.abs(ut)>Math.abs(Ye)?"x":"y");let De={x:0,y:0};G==="y"?(Ne.includes("top")||Ne.includes("bottom"))&&(Ne.includes("top")&&Ye<0||Ne.includes("bottom")&&Ye>0)&&(De.y=Ye):G==="x"&&(Ne.includes("left")||Ne.includes("right"))&&(Ne.includes("left")&&ut<0||Ne.includes("right")&&ut>0)&&(De.x=ut),(Math.abs(De.x)>0||Math.abs(De.y)>0)&&Gt(!0),(Oe=We.current)==null||Oe.style.setProperty("--swipe-amount-x",`${De.x}px`),(be=We.current)==null||be.style.setProperty("--swipe-amount-y",`${De.y}px`)}},Cn&&!p.jsx?y.createElement("button",{"aria-label":Z,"data-disabled":jn,"data-close-button":!0,onClick:jn||!et?()=>{}:()=>{var Y;nt(),(Y=p.onDismiss)==null||Y.call(p,p)},className:Xe(M==null?void 0:M.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(a=H==null?void 0:H.close)!=null?a:Wg):null,p.jsx||y.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:y.createElement(y.Fragment,null,we||p.icon||p.promise?y.createElement("div",{"data-icon":"",className:Xe(M==null?void 0:M.icon,(c=p==null?void 0:p.classNames)==null?void 0:c.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||to():null,p.type!=="loading"?p.icon||(H==null?void 0:H[we])||Og(we):null):null,y.createElement("div",{"data-content":"",className:Xe(M==null?void 0:M.content,(i=p==null?void 0:p.classNames)==null?void 0:i.content)},y.createElement("div",{"data-title":"",className:Xe(M==null?void 0:M.title,(l=p==null?void 0:p.classNames)==null?void 0:l.title)},typeof p.title=="function"?p.title():p.title),p.description?y.createElement("div",{"data-description":"",className:Xe(D,Kn,M==null?void 0:M.description,(d=p==null?void 0:p.classNames)==null?void 0:d.description)},typeof p.description=="function"?p.description():p.description):null),y.isValidElement(p.cancel)?p.cancel:p.cancel&&nr(p.cancel)?y.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||P,onClick:Y=>{var se,fe;nr(p.cancel)&&et&&((fe=(se=p.cancel).onClick)==null||fe.call(se,Y),nt())},className:Xe(M==null?void 0:M.cancelButton,(u=p==null?void 0:p.classNames)==null?void 0:u.cancelButton)},p.cancel.label):null,y.isValidElement(p.action)?p.action:p.action&&nr(p.action)?y.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||I,onClick:Y=>{var se,fe;nr(p.action)&&((fe=(se=p.action).onClick)==null||fe.call(se,Y),!Y.defaultPrevented&&nt())},className:Xe(M==null?void 0:M.actionButton,(m=p==null?void 0:p.classNames)==null?void 0:m.actionButton)},p.action.label):null))};function Pa(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function sx(e,t){let n={};return[e,t].forEach((r,o)=>{let a=o===1,c=a?"--mobile-offset":"--offset",i=a?Zg:Qg;function l(d){["top","right","bottom","left"].forEach(u=>{n[`${c}-${u}`]=typeof d=="number"?`${d}px`:d})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(d=>{r[d]===void 0?n[`${c}-${d}`]=i:n[`${c}-${d}`]=typeof r[d]=="number"?`${r[d]}px`:r[d]}):l(i)}),n}var ax=y.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:a,closeButton:c,className:i,offset:l,mobileOffset:d,theme:u="light",richColors:m,duration:h,style:p,visibleToasts:v=Xg,toastOptions:g,dir:x=Pa(),gap:C=ex,loadingIcon:w,icons:b,containerAriaLabel:S="Notifications",pauseWhenPageIsHidden:j}=e,[N,_]=y.useState([]),O=y.useMemo(()=>Array.from(new Set([r].concat(N.filter(V=>V.position).map(V=>V.position)))),[N,r]),[k,P]=y.useState([]),[I,A]=y.useState(!1),[D,E]=y.useState(!1),[F,T]=y.useState(u!=="system"?u:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=y.useRef(null),$=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),M=y.useRef(null),H=y.useRef(!1),Z=y.useCallback(V=>{_(G=>{var B;return(B=G.find(re=>re.id===V.id))!=null&&B.delete||Re.dismiss(V.id),G.filter(({id:re})=>re!==V.id)})},[]);return y.useEffect(()=>Re.subscribe(V=>{if(V.dismiss){_(G=>G.map(B=>B.id===V.id?{...B,delete:!0}:B));return}setTimeout(()=>{ts.flushSync(()=>{_(G=>{let B=G.findIndex(re=>re.id===V.id);return B!==-1?[...G.slice(0,B),{...G[B],...V},...G.slice(B+1)]:[V,...G]})})})}),[]),y.useEffect(()=>{if(u!=="system"){T(u);return}if(u==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?T("dark"):T("light")),typeof window>"u")return;let V=window.matchMedia("(prefers-color-scheme: dark)");try{V.addEventListener("change",({matches:G})=>{T(G?"dark":"light")})}catch{V.addListener(({matches:B})=>{try{T(B?"dark":"light")}catch(re){console.error(re)}})}},[u]),y.useEffect(()=>{N.length<=1&&A(!1)},[N]),y.useEffect(()=>{let V=G=>{var B,re;o.every(ue=>G[ue]||G.code===ue)&&(A(!0),(B=z.current)==null||B.focus()),G.code==="Escape"&&(document.activeElement===z.current||(re=z.current)!=null&&re.contains(document.activeElement))&&A(!1)};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[o]),y.useEffect(()=>{if(z.current)return()=>{M.current&&(M.current.focus({preventScroll:!0}),M.current=null,H.current=!1)}},[z.current]),y.createElement("section",{ref:t,"aria-label":`${S} ${$}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},O.map((V,G)=>{var B;let[re,ue]=V.split("-");return N.length?y.createElement("ol",{key:V,dir:x==="auto"?Pa():x,tabIndex:-1,ref:z,className:i,"data-sonner-toaster":!0,"data-theme":F,"data-y-position":re,"data-lifted":I&&N.length>1&&!a,"data-x-position":ue,style:{"--front-toast-height":`${((B=k[0])==null?void 0:B.height)||0}px`,"--width":`${Jg}px`,"--gap":`${C}px`,...p,...sx(l,d)},onBlur:J=>{H.current&&!J.currentTarget.contains(J.relatedTarget)&&(H.current=!1,M.current&&(M.current.focus({preventScroll:!0}),M.current=null))},onFocus:J=>{J.target instanceof HTMLElement&&J.target.dataset.dismissible==="false"||H.current||(H.current=!0,M.current=J.relatedTarget)},onMouseEnter:()=>A(!0),onMouseMove:()=>A(!0),onMouseLeave:()=>{D||A(!1)},onDragEnd:()=>A(!1),onPointerDown:J=>{J.target instanceof HTMLElement&&J.target.dataset.dismissible==="false"||E(!0)},onPointerUp:()=>E(!1)},N.filter(J=>!J.position&&G===0||J.position===V).map((J,Pe)=>{var he,ze;return y.createElement(ox,{key:J.id,icons:b,index:Pe,toast:J,defaultRichColors:m,duration:(he=g==null?void 0:g.duration)!=null?he:h,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(ze=g==null?void 0:g.closeButton)!=null?ze:c,interacting:D,position:V,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:Z,toasts:N.filter(Ae=>Ae.position==J.position),heights:k.filter(Ae=>Ae.position==J.position),setHeights:P,expandByDefault:a,gap:C,loadingIcon:w,expanded:I,pauseWhenPageIsHidden:j,swipeDirections:e.swipeDirections})})):null}))});const ix=({...e})=>{const{theme:t="system"}=Ag();return s.jsx(ax,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})},me={conversations:e=>["qc:conversations",e],messages:e=>["qc:messages",e],unreadIds:(e,t)=>["qc:unread-ids",e,t],contacts:e=>["qc:contacts",e],searchUsers:e=>["qc:searchUsers",e],profile:e=>["qc:profile",e],reactions:e=>["qc:reactions",e]},js=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient(),r=oe.useQuery({queryKey:me.conversations(e==null?void 0:e.id),queryFn:async()=>{if(!e)return[];const{data:o,error:a}=await t.from("conversation_members").select("conversation_id").eq("user_id",e.id);if(a)throw a;const c=(o==null?void 0:o.map(w=>w.conversation_id))??[];if(c.length===0)return[];const{data:i,error:l}=await t.from("conversations").select("*").in("id",c).order("updated_at",{ascending:!1});if(l)throw l;if(!i||i.length===0)return[];const{data:d}=await t.from("conversation_members").select("conversation_id, user_id, role").in("conversation_id",c),u=[...new Set((d??[]).map(w=>w.user_id))],m={};if(u.length>0){const{data:w}=await t.from("profiles").select("id, display_name, avatar_url, is_online, last_seen").in("id",u);(w??[]).forEach(b=>{m[b.id]=b})}const h={};for(const w of d??[]){h[w.conversation_id]||(h[w.conversation_id]=[]);const b=m[w.user_id];b&&h[w.conversation_id].push({user_id:w.user_id,role:w.role,profile:b})}const{data:p}=await t.from("messages").select("id, conversation_id, sender_id").in("conversation_id",c).eq("is_deleted",!1).neq("sender_id",e.id),v=(p??[]).map(w=>w.id),g={};for(const w of p??[])g[w.conversation_id]||(g[w.conversation_id]=[]),g[w.conversation_id].push(w.id);const x=new Set;if(v.length>0)for(let w=0;w<v.length;w+=500){const b=v.slice(w,w+500),{data:S}=await t.from("message_reads").select("message_id").eq("user_id",e.id).in("message_id",b);(S??[]).forEach(j=>x.add(j.message_id))}const C=await Promise.all(i.map(w=>t.from("messages").select("content, type, created_at, sender_id").eq("conversation_id",w.id).eq("is_deleted",!1).order("created_at",{ascending:!1}).limit(1).maybeSingle()));return i.map((w,b)=>{const j=(g[w.id]??[]).filter(N=>!x.has(N)).length;return{id:w.id,type:w.type,name:w.name,avatar_url:w.avatar_url,updated_at:w.updated_at,members:h[w.id]??[],last_message:C[b].data??null,unread_count:j}})},enabled:!!e});return y.useEffect(()=>{if(!e)return;const o=t.channel("conversations-realtime").on("postgres_changes",{event:"*",schema:"public",table:"messages"},()=>{n.invalidateQueries({queryKey:me.conversations(e.id)})}).on("postgres_changes",{event:"*",schema:"public",table:"conversation_members"},()=>{n.invalidateQueries({queryKey:me.conversations(e.id)})}).subscribe();return()=>{t.removeChannel(o)}},[e,n,t]),r},cx=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient();return oe.useMutation({mutationFn:async r=>{if(!e)throw new Error("Not authenticated");const{data:o}=await t.from("conversation_members").select("conversation_id").eq("user_id",e.id),{data:a}=await t.from("conversation_members").select("conversation_id").eq("user_id",r),c=new Set(o==null?void 0:o.map(h=>h.conversation_id)),i=(a==null?void 0:a.filter(h=>c.has(h.conversation_id)).map(h=>h.conversation_id))??[];if(i.length>0){const{data:h}=await t.from("conversations").select("id").in("id",i).eq("type","private").limit(1).maybeSingle();if(h)return h.id}const{data:l,error:d}=await t.from("conversations").insert({type:"private",created_by:e.id}).select("id").single();if(d)throw d;const{error:u}=await t.from("conversation_members").insert({conversation_id:l.id,user_id:e.id,role:"owner"});if(u)throw u;const{error:m}=await t.from("conversation_members").insert({conversation_id:l.id,user_id:r,role:"member"});if(m)throw m;return l.id},onSuccess:()=>{n.invalidateQueries({queryKey:me.conversations(e==null?void 0:e.id)})}})},lx=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient();return oe.useMutation({mutationFn:async({name:r,memberIds:o})=>{if(!e)throw new Error("Not authenticated");const{data:a,error:c}=await t.from("conversations").insert({type:"group",name:r,created_by:e.id}).select("id").single();if(c)throw c;const{error:i}=await t.from("conversation_members").insert({conversation_id:a.id,user_id:e.id,role:"owner"});if(i)throw i;if(o.length>0){const l=o.map(u=>({conversation_id:a.id,user_id:u,role:"member"})),{error:d}=await t.from("conversation_members").insert(l);if(d)throw d}return a.id},onSuccess:()=>{n.invalidateQueries({queryKey:me.conversations(e==null?void 0:e.id)})}})},dx=()=>{const{user:e}=ye(),t=ve();return oe.useQuery({queryKey:me.profile(e==null?void 0:e.id),queryFn:async()=>{if(!e)return null;const{data:n,error:r}=await t.from("profiles").select("*").eq("id",e.id).single();if(r)throw r;return n},enabled:!!e})};var Wo={exports:{}},fo={};/**
|
|
243
243
|
* @license React
|
|
244
244
|
* use-sync-external-store-shim.production.js
|
|
245
245
|
*
|
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
*
|
|
248
248
|
* This source code is licensed under the MIT license found in the
|
|
249
249
|
* LICENSE file in the root directory of this source tree.
|
|
250
|
-
*/var Aa;function
|
|
250
|
+
*/var Aa;function ux(){if(Aa)return fo;Aa=1;var e=y;function t(m,h){return m===h&&(m!==0||1/m===1/h)||m!==m&&h!==h}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,a=e.useLayoutEffect,c=e.useDebugValue;function i(m,h){var p=h(),v=r({inst:{value:p,getSnapshot:h}}),g=v[0].inst,x=v[1];return a(function(){g.value=p,g.getSnapshot=h,l(g)&&x({inst:g})},[m,p,h]),o(function(){return l(g)&&x({inst:g}),m(function(){l(g)&&x({inst:g})})},[m]),c(p),p}function l(m){var h=m.getSnapshot;m=m.value;try{var p=h();return!n(m,p)}catch{return!0}}function d(m,h){return h()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:i;return fo.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,fo}var mo={};/**
|
|
251
251
|
* @license React
|
|
252
252
|
* use-sync-external-store-shim.development.js
|
|
253
253
|
*
|
|
@@ -255,12 +255,12 @@
|
|
|
255
255
|
*
|
|
256
256
|
* This source code is licensed under the MIT license found in the
|
|
257
257
|
* LICENSE file in the root directory of this source tree.
|
|
258
|
-
*/var Oa;function ux(){return Oa||(Oa=1,process.env.NODE_ENV!=="production"&&function(){function e(p,v){return p===v&&(p!==0||1/p===1/v)||p!==p&&v!==v}function t(p,v){u||o.startTransition===void 0||(u=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var g=v();if(!m){var x=v();a(g,x)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),m=!0)}x=c({inst:{value:g,getSnapshot:v}});var C=x[0].inst,w=x[1];return l(function(){C.value=g,C.getSnapshot=v,n(C)&&w({inst:C})},[p,g,v]),i(function(){return n(C)&&w({inst:C}),p(function(){n(C)&&w({inst:C})})},[p]),d(g),g}function n(p){var v=p.getSnapshot;p=p.value;try{var g=v();return!a(p,g)}catch{return!0}}function r(p,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=y,a=typeof Object.is=="function"?Object.is:e,c=o.useState,i=o.useEffect,l=o.useLayoutEffect,d=o.useDebugValue,u=!1,m=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:t;mo.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:h,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),mo}process.env.NODE_ENV==="production"?Wo.exports=dx():Wo.exports=ux();var fx=Wo.exports;function mx(){return fx.useSyncExternalStore(px,()=>!0,()=>!1)}function px(){return()=>{}}var Ns="Avatar",[hx,e1]=ke(Ns),[gx,Tc]=hx(Ns),Rc=f.forwardRef((e,t)=>{const{__scopeAvatar:n,...r}=e,[o,a]=f.useState("idle");return s.jsx(gx,{scope:n,imageLoadingStatus:o,onImageLoadingStatusChange:a,children:s.jsx(K.span,{...r,ref:t})})});Rc.displayName=Ns;var kc="AvatarImage",Pc=f.forwardRef((e,t)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:o=()=>{},...a}=e,c=Tc(kc,n),i=xx(r,a),l=ge(d=>{o(d),c.onImageLoadingStatusChange(d)});return Fe(()=>{i!=="idle"&&l(i)},[i,l]),i==="loaded"?s.jsx(K.img,{...a,ref:t,src:r}):null});Pc.displayName=kc;var Ac="AvatarFallback",Oc=f.forwardRef((e,t)=>{const{__scopeAvatar:n,delayMs:r,...o}=e,a=Tc(Ac,n),[c,i]=f.useState(r===void 0);return f.useEffect(()=>{if(r!==void 0){const l=window.setTimeout(()=>i(!0),r);return()=>window.clearTimeout(l)}},[r]),c&&a.imageLoadingStatus!=="loaded"?s.jsx(K.span,{...o,ref:t}):null});Oc.displayName=Ac;function Da(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function xx(e,{referrerPolicy:t,crossOrigin:n}){const r=mx(),o=f.useRef(null),a=r?(o.current||(o.current=new window.Image),o.current):null,[c,i]=f.useState(()=>Da(a,e));return Fe(()=>{i(Da(a,e))},[a,e]),Fe(()=>{const l=m=>()=>{i(m)};if(!a)return;const d=l("loaded"),u=l("error");return a.addEventListener("load",d),a.addEventListener("error",u),t&&(a.referrerPolicy=t),typeof n=="string"&&(a.crossOrigin=n),()=>{a.removeEventListener("load",d),a.removeEventListener("error",u)}},[a,n,t]),c}var Dc=Rc,Ic=Pc,Lc=Oc;const Ce=f.forwardRef(({className:e,...t},n)=>s.jsx(Dc,{ref:n,className:W("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));Ce.displayName=Dc.displayName;const _e=f.forwardRef(({className:e,...t},n)=>s.jsx(Ic,{ref:n,className:W("aspect-square h-full w-full object-cover",e),...t}));_e.displayName=Ic.displayName;const Se=f.forwardRef(({className:e,...t},n)=>s.jsx(Lc,{ref:n,className:W("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));Se.displayName=Lc.displayName;const qe=f.forwardRef(({className:e,type:t,...n},r)=>s.jsx("input",{type:t,className:W("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}));qe.displayName="Input";const _s=ws("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),ne=f.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},a)=>{const c=r?Uf:"button";return s.jsx(c,{className:W(_s({variant:t,size:n,className:e})),ref:a,...o})});ne.displayName="Button";var vx=f.createContext(void 0);function Br(e){const t=f.useContext(vx);return e||t||"ltr"}function yx(e,[t,n]){return Math.min(n,Math.max(t,e))}function bx(e,t){return f.useReducer((n,r)=>t[n][r]??n,e)}var Es="ScrollArea",[$c,t1]=ke(Es),[wx,He]=$c(Es),Fc=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:a=600,...c}=e,[i,l]=f.useState(null),[d,u]=f.useState(null),[m,h]=f.useState(null),[p,v]=f.useState(null),[g,x]=f.useState(null),[C,w]=f.useState(0),[b,S]=f.useState(0),[j,N]=f.useState(!1),[_,O]=f.useState(!1),k=ae(t,I=>l(I)),P=Br(o);return s.jsx(wx,{scope:n,type:r,dir:P,scrollHideDelay:a,scrollArea:i,viewport:d,onViewportChange:u,content:m,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:j,onScrollbarXEnabledChange:N,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:_,onScrollbarYEnabledChange:O,onCornerWidthChange:w,onCornerHeightChange:S,children:s.jsx(K.div,{dir:P,...c,ref:k,style:{position:"relative","--radix-scroll-area-corner-width":C+"px","--radix-scroll-area-corner-height":b+"px",...e.style}})})});Fc.displayName=Es;var zc="ScrollAreaViewport",Wc=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...a}=e,c=He(zc,n),i=f.useRef(null),l=ae(t,i,c.onViewportChange);return s.jsxs(s.Fragment,{children:[s.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}),s.jsx(K.div,{"data-radix-scroll-area-viewport":"",...a,ref:l,style:{overflowX:c.scrollbarXEnabled?"scroll":"hidden",overflowY:c.scrollbarYEnabled?"scroll":"hidden",...e.style},children:s.jsx("div",{ref:c.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Wc.displayName=zc;var ct="ScrollAreaScrollbar",Ms=f.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=He(ct,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:c}=o,i=e.orientation==="horizontal";return f.useEffect(()=>(i?a(!0):c(!0),()=>{i?a(!1):c(!1)}),[i,a,c]),o.type==="hover"?s.jsx(Cx,{...r,ref:t,forceMount:n}):o.type==="scroll"?s.jsx(Sx,{...r,ref:t,forceMount:n}):o.type==="auto"?s.jsx(Bc,{...r,ref:t,forceMount:n}):o.type==="always"?s.jsx(Ts,{...r,ref:t}):null});Ms.displayName=ct;var Cx=f.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=He(ct,e.__scopeScrollArea),[a,c]=f.useState(!1);return f.useEffect(()=>{const i=o.scrollArea;let l=0;if(i){const d=()=>{window.clearTimeout(l),c(!0)},u=()=>{l=window.setTimeout(()=>c(!1),o.scrollHideDelay)};return i.addEventListener("pointerenter",d),i.addEventListener("pointerleave",u),()=>{window.clearTimeout(l),i.removeEventListener("pointerenter",d),i.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),s.jsx(Ee,{present:n||a,children:s.jsx(Bc,{"data-state":a?"visible":"hidden",...r,ref:t})})}),Sx=f.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=He(ct,e.__scopeScrollArea),a=e.orientation==="horizontal",c=Ur(()=>l("SCROLL_END"),100),[i,l]=bx("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 f.useEffect(()=>{if(i==="idle"){const d=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(d)}},[i,o.scrollHideDelay,l]),f.useEffect(()=>{const d=o.viewport,u=a?"scrollLeft":"scrollTop";if(d){let m=d[u];const h=()=>{const p=d[u];m!==p&&(l("SCROLL"),c()),m=p};return d.addEventListener("scroll",h),()=>d.removeEventListener("scroll",h)}},[o.viewport,a,l,c]),s.jsx(Ee,{present:n||i!=="hidden",children:s.jsx(Ts,{"data-state":i==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:L(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:L(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Bc=f.forwardRef((e,t)=>{const n=He(ct,e.__scopeScrollArea),{forceMount:r,...o}=e,[a,c]=f.useState(!1),i=e.orientation==="horizontal",l=Ur(()=>{if(n.viewport){const d=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;c(i?d:u)}},10);return mn(n.viewport,l),mn(n.content,l),s.jsx(Ee,{present:r||a,children:s.jsx(Ts,{"data-state":a?"visible":"hidden",...o,ref:t})})}),Ts=f.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=He(ct,e.__scopeScrollArea),a=f.useRef(null),c=f.useRef(0),[i,l]=f.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=Gc(i.viewport,i.content),u={...r,sizes:i,onSizesChange:l,hasThumb:d>0&&d<1,onThumbChange:h=>a.current=h,onThumbPointerUp:()=>c.current=0,onThumbPointerDown:h=>c.current=h};function m(h,p){return Tx(h,c.current,i,p)}return n==="horizontal"?s.jsx(jx,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollLeft,p=Ia(h,i,o.dir);a.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=m(h,o.dir))}}):n==="vertical"?s.jsx(Nx,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollTop,p=Ia(h,i);a.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=m(h))}}):null}),jx=f.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,a=He(ct,e.__scopeScrollArea),[c,i]=f.useState(),l=f.useRef(null),d=ae(t,l,a.onScrollbarXChange);return f.useEffect(()=>{l.current&&i(getComputedStyle(l.current))},[l]),s.jsx(Uc,{"data-orientation":"horizontal",...o,ref:d,sizes:n,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":qr(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,m)=>{if(a.viewport){const h=a.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),Kc(h,m)&&u.preventDefault()}},onResize:()=>{l.current&&a.viewport&&c&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Nr(c.paddingLeft),paddingEnd:Nr(c.paddingRight)}})}})}),Nx=f.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,a=He(ct,e.__scopeScrollArea),[c,i]=f.useState(),l=f.useRef(null),d=ae(t,l,a.onScrollbarYChange);return f.useEffect(()=>{l.current&&i(getComputedStyle(l.current))},[l]),s.jsx(Uc,{"data-orientation":"vertical",...o,ref:d,sizes:n,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":qr(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,m)=>{if(a.viewport){const h=a.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),Kc(h,m)&&u.preventDefault()}},onResize:()=>{l.current&&a.viewport&&c&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Nr(c.paddingTop),paddingEnd:Nr(c.paddingBottom)}})}})}),[_x,qc]=$c(ct),Uc=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:a,onThumbPointerUp:c,onThumbPointerDown:i,onThumbPositionChange:l,onDragScroll:d,onWheelScroll:u,onResize:m,...h}=e,p=He(ct,n),[v,g]=f.useState(null),x=ae(t,k=>g(k)),C=f.useRef(null),w=f.useRef(""),b=p.viewport,S=r.content-r.viewport,j=ge(u),N=ge(l),_=Ur(m,10);function O(k){if(C.current){const P=k.clientX-C.current.left,I=k.clientY-C.current.top;d({x:P,y:I})}}return f.useEffect(()=>{const k=P=>{const I=P.target;(v==null?void 0:v.contains(I))&&j(P,S)};return document.addEventListener("wheel",k,{passive:!1}),()=>document.removeEventListener("wheel",k,{passive:!1})},[b,v,S,j]),f.useEffect(N,[r,N]),mn(v,_),mn(p.content,_),s.jsx(_x,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:ge(a),onThumbPointerUp:ge(c),onThumbPositionChange:N,onThumbPointerDown:ge(i),children:s.jsx(K.div,{...h,ref:x,style:{position:"absolute",...h.style},onPointerDown:L(e.onPointerDown,k=>{k.button===0&&(k.target.setPointerCapture(k.pointerId),C.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),O(k))}),onPointerMove:L(e.onPointerMove,O),onPointerUp:L(e.onPointerUp,k=>{const P=k.target;P.hasPointerCapture(k.pointerId)&&P.releasePointerCapture(k.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),C.current=null})})})}),jr="ScrollAreaThumb",Hc=f.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=qc(jr,e.__scopeScrollArea);return s.jsx(Ee,{present:n||o.hasThumb,children:s.jsx(Ex,{ref:t,...r})})}),Ex=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,a=He(jr,n),c=qc(jr,n),{onThumbPositionChange:i}=c,l=ae(t,m=>c.onThumbChange(m)),d=f.useRef(void 0),u=Ur(()=>{d.current&&(d.current(),d.current=void 0)},100);return f.useEffect(()=>{const m=a.viewport;if(m){const h=()=>{if(u(),!d.current){const p=Rx(m,i);d.current=p,i()}};return i(),m.addEventListener("scroll",h),()=>m.removeEventListener("scroll",h)}},[a.viewport,u,i]),s.jsx(K.div,{"data-state":c.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:L(e.onPointerDownCapture,m=>{const p=m.target.getBoundingClientRect(),v=m.clientX-p.left,g=m.clientY-p.top;c.onThumbPointerDown({x:v,y:g})}),onPointerUp:L(e.onPointerUp,c.onThumbPointerUp)})});Hc.displayName=jr;var Rs="ScrollAreaCorner",Vc=f.forwardRef((e,t)=>{const n=He(Rs,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?s.jsx(Mx,{...e,ref:t}):null});Vc.displayName=Rs;var Mx=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=He(Rs,n),[a,c]=f.useState(0),[i,l]=f.useState(0),d=!!(a&&i);return mn(o.scrollbarX,()=>{var m;const u=((m=o.scrollbarX)==null?void 0:m.offsetHeight)||0;o.onCornerHeightChange(u),l(u)}),mn(o.scrollbarY,()=>{var m;const u=((m=o.scrollbarY)==null?void 0:m.offsetWidth)||0;o.onCornerWidthChange(u),c(u)}),d?s.jsx(K.div,{...r,ref:t,style:{width:a,height:i,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Nr(e){return e?parseInt(e,10):0}function Gc(e,t){const n=e/t;return isNaN(n)?0:n}function qr(e){const t=Gc(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Tx(e,t,n,r="ltr"){const o=qr(n),a=o/2,c=t||a,i=o-c,l=n.scrollbar.paddingStart+c,d=n.scrollbar.size-n.scrollbar.paddingEnd-i,u=n.content-n.viewport,m=r==="ltr"?[0,u]:[u*-1,0];return Yc([l,d],m)(e)}function Ia(e,t,n="ltr"){const r=qr(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-o,c=t.content-t.viewport,i=a-r,l=n==="ltr"?[0,c]:[c*-1,0],d=yx(e,l);return Yc([0,c],[0,i])(d)}function Yc(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Kc(e,t){return e>0&&e<t}var Rx=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const a={left:e.scrollLeft,top:e.scrollTop},c=n.left!==a.left,i=n.top!==a.top;(c||i)&&t(),n=a,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Ur(e,t){const n=ge(e),r=f.useRef(0);return f.useEffect(()=>()=>window.clearTimeout(r.current),[]),f.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function mn(e,t){const n=ge(t);Fe(()=>{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 Xc=Fc,kx=Wc,Px=Vc;const Wt=f.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(Xc,{ref:r,className:W("relative overflow-hidden",e),...n,children:[s.jsx(kx,{className:"h-full w-full rounded-[inherit]",children:t}),s.jsx(Qc,{}),s.jsx(Px,{})]}));Wt.displayName=Xc.displayName;const Qc=f.forwardRef(({className:e,orientation:t="vertical",...n},r)=>s.jsx(Ms,{ref:r,orientation:t,className:W("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:s.jsx(Hc,{className:"relative flex-1 rounded-full bg-border"})}));Qc.displayName=Ms.displayName;var po=0;function Zc(){f.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??La()),document.body.insertAdjacentElement("beforeend",e[1]??La()),po++,()=>{po===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),po--}},[])}function La(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var ho="focusScope.autoFocusOnMount",go="focusScope.autoFocusOnUnmount",$a={bubbles:!1,cancelable:!0},Ax="FocusScope",ks=f.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...c}=e,[i,l]=f.useState(null),d=ge(o),u=ge(a),m=f.useRef(null),h=ae(t,g=>l(g)),p=f.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;f.useEffect(()=>{if(r){let g=function(b){if(p.paused||!i)return;const S=b.target;i.contains(S)?m.current=S:jt(m.current,{select:!0})},x=function(b){if(p.paused||!i)return;const S=b.relatedTarget;S!==null&&(i.contains(S)||jt(m.current,{select:!0}))},C=function(b){if(document.activeElement===document.body)for(const j of b)j.removedNodes.length>0&&jt(i)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const w=new MutationObserver(C);return i&&w.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),w.disconnect()}}},[r,i,p.paused]),f.useEffect(()=>{if(i){za.add(p);const g=document.activeElement;if(!i.contains(g)){const C=new CustomEvent(ho,$a);i.addEventListener(ho,d),i.dispatchEvent(C),C.defaultPrevented||(Ox(Fx(Jc(i)),{select:!0}),document.activeElement===g&&jt(i))}return()=>{i.removeEventListener(ho,d),setTimeout(()=>{const C=new CustomEvent(go,$a);i.addEventListener(go,u),i.dispatchEvent(C),C.defaultPrevented||jt(g??document.body,{select:!0}),i.removeEventListener(go,u),za.remove(p)},0)}}},[i,d,u,p]);const v=f.useCallback(g=>{if(!n&&!r||p.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,C=document.activeElement;if(x&&C){const w=g.currentTarget,[b,S]=Dx(w);b&&S?!g.shiftKey&&C===S?(g.preventDefault(),n&&jt(b,{select:!0})):g.shiftKey&&C===b&&(g.preventDefault(),n&&jt(S,{select:!0})):C===w&&g.preventDefault()}},[n,r,p.paused]);return s.jsx(K.div,{tabIndex:-1,...c,ref:h,onKeyDown:v})});ks.displayName=Ax;function Ox(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(jt(r,{select:t}),document.activeElement!==n)return}function Dx(e){const t=Jc(e),n=Fa(t,e),r=Fa(t.reverse(),e);return[n,r]}function Jc(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Fa(e,t){for(const n of e)if(!Ix(n,{upTo:t}))return n}function Ix(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Lx(e){return e instanceof HTMLInputElement&&"select"in e}function jt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Lx(e)&&t&&e.select()}}var za=$x();function $x(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Wa(e,t),e.unshift(t)},remove(t){var n;e=Wa(e,t),(n=e[0])==null||n.resume()}}}function Wa(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Fx(e){return e.filter(t=>t.tagName!=="A")}var xo="rovingFocusGroup.onEntryFocus",zx={bubbles:!1,cancelable:!0},qn="RovingFocusGroup",[Bo,el,Wx]=xs(qn),[Bx,Hr]=ke(qn,[Wx]),[qx,Ux]=Bx(qn),tl=f.forwardRef((e,t)=>s.jsx(Bo.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(Bo.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(Hx,{...e,ref:t})})}));tl.displayName=qn;var Hx=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:a,currentTabStopId:c,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:l,onEntryFocus:d,preventScrollOnEntryFocus:u=!1,...m}=e,h=f.useRef(null),p=ae(t,h),v=Br(a),[g,x]=qt({prop:c,defaultProp:i??null,onChange:l,caller:qn}),[C,w]=f.useState(!1),b=ge(d),S=el(n),j=f.useRef(!1),[N,_]=f.useState(0);return f.useEffect(()=>{const O=h.current;if(O)return O.addEventListener(xo,b),()=>O.removeEventListener(xo,b)},[b]),s.jsx(qx,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:f.useCallback(O=>x(O),[x]),onItemShiftTab:f.useCallback(()=>w(!0),[]),onFocusableItemAdd:f.useCallback(()=>_(O=>O+1),[]),onFocusableItemRemove:f.useCallback(()=>_(O=>O-1),[]),children:s.jsx(K.div,{tabIndex:C||N===0?-1:0,"data-orientation":r,...m,ref:p,style:{outline:"none",...e.style},onMouseDown:L(e.onMouseDown,()=>{j.current=!0}),onFocus:L(e.onFocus,O=>{const k=!j.current;if(O.target===O.currentTarget&&k&&!C){const P=new CustomEvent(xo,zx);if(O.currentTarget.dispatchEvent(P),!P.defaultPrevented){const I=S().filter(T=>T.focusable),A=I.find(T=>T.active),D=I.find(T=>T.id===g),F=[A,D,...I].filter(Boolean).map(T=>T.ref.current);ol(F,u)}}j.current=!1}),onBlur:L(e.onBlur,()=>w(!1))})})}),nl="RovingFocusGroupItem",rl=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:a,children:c,...i}=e,l=gt(),d=a||l,u=Ux(nl,n),m=u.currentTabStopId===d,h=el(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:g}=u;return f.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),s.jsx(Bo.ItemSlot,{scope:n,id:d,focusable:r,active:o,children:s.jsx(K.span,{tabIndex:m?0:-1,"data-orientation":u.orientation,...i,ref:t,onMouseDown:L(e.onMouseDown,x=>{r?u.onItemFocus(d):x.preventDefault()}),onFocus:L(e.onFocus,()=>u.onItemFocus(d)),onKeyDown:L(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){u.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const C=Yx(x,u.orientation,u.dir);if(C!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let b=h().filter(S=>S.focusable).map(S=>S.ref.current);if(C==="last")b.reverse();else if(C==="prev"||C==="next"){C==="prev"&&b.reverse();const S=b.indexOf(x.currentTarget);b=u.loop?Kx(b,S+1):b.slice(S+1)}setTimeout(()=>ol(b))}}),children:typeof c=="function"?c({isCurrentTabStop:m,hasTabStop:g!=null}):c})})});rl.displayName=nl;var Vx={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Gx(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Yx(e,t,n){const r=Gx(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Vx[r]}function ol(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Kx(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var sl=tl,al=rl,Xx=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Zt=new WeakMap,rr=new WeakMap,or={},vo=0,il=function(e){return e&&(e.host||il(e.parentNode))},Qx=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=il(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Zx=function(e,t,n,r){var o=Qx(t,Array.isArray(e)?e:[e]);or[n]||(or[n]=new WeakMap);var a=or[n],c=[],i=new Set,l=new Set(o),d=function(m){!m||i.has(m)||(i.add(m),d(m.parentNode))};o.forEach(d);var u=function(m){!m||l.has(m)||Array.prototype.forEach.call(m.children,function(h){if(i.has(h))u(h);else try{var p=h.getAttribute(r),v=p!==null&&p!=="false",g=(Zt.get(h)||0)+1,x=(a.get(h)||0)+1;Zt.set(h,g),a.set(h,x),c.push(h),g===1&&v&&rr.set(h,!0),x===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(C){console.error("aria-hidden: cannot operate on ",h,C)}})};return u(t),i.clear(),vo++,function(){c.forEach(function(m){var h=Zt.get(m)-1,p=a.get(m)-1;Zt.set(m,h),a.set(m,p),h||(rr.has(m)||m.removeAttribute(r),rr.delete(m)),p||m.removeAttribute(n)}),vo--,vo||(Zt=new WeakMap,Zt=new WeakMap,rr=new WeakMap,or={})}},cl=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Xx(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),Zx(r,o,n,"aria-hidden")):function(){return null}},rt=function(){return rt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},rt.apply(this,arguments)};function ll(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Jx(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var mr="right-scroll-bar-position",pr="width-before-scroll-bar",ev="with-scroll-bars-hidden",tv="--removed-body-scroll-bar-size";function yo(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function nv(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var rv=typeof window<"u"?f.useLayoutEffect:f.useEffect,Ba=new WeakMap;function ov(e,t){var n=nv(null,function(r){return e.forEach(function(o){return yo(o,r)})});return rv(function(){var r=Ba.get(n);if(r){var o=new Set(r),a=new Set(e),c=n.current;o.forEach(function(i){a.has(i)||yo(i,null)}),a.forEach(function(i){o.has(i)||yo(i,c)})}Ba.set(n,e)},[e]),n}function sv(e){return e}function av(e,t){t===void 0&&(t=sv);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var c=t(a,r);return n.push(c),function(){n=n.filter(function(i){return i!==c})}},assignSyncMedium:function(a){for(r=!0;n.length;){var c=n;n=[],c.forEach(a)}n={push:function(i){return a(i)},filter:function(){return n}}},assignMedium:function(a){r=!0;var c=[];if(n.length){var i=n;n=[],i.forEach(a),c=n}var l=function(){var u=c;c=[],u.forEach(a)},d=function(){return Promise.resolve().then(l)};d(),n={push:function(u){c.push(u),d()},filter:function(u){return c=c.filter(u),n}}}};return o}function iv(e){e===void 0&&(e={});var t=av(null);return t.options=rt({async:!0,ssr:!1},e),t}var dl=function(e){var t=e.sideCar,n=ll(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return f.createElement(r,rt({},n))};dl.isSideCarExport=!0;function cv(e,t){return e.useMedium(t),dl}var ul=iv(),bo=function(){},Vr=f.forwardRef(function(e,t){var n=f.useRef(null),r=f.useState({onScrollCapture:bo,onWheelCapture:bo,onTouchMoveCapture:bo}),o=r[0],a=r[1],c=e.forwardProps,i=e.children,l=e.className,d=e.removeScrollBar,u=e.enabled,m=e.shards,h=e.sideCar,p=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,C=e.as,w=C===void 0?"div":C,b=e.gapMode,S=ll(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=h,N=ov([n,t]),_=rt(rt({},S),o);return f.createElement(f.Fragment,null,u&&f.createElement(j,{sideCar:ul,removeScrollBar:d,shards:m,noRelative:p,noIsolation:v,inert:g,setCallbacks:a,allowPinchZoom:!!x,lockRef:n,gapMode:b}),c?f.cloneElement(f.Children.only(i),rt(rt({},_),{ref:N})):f.createElement(w,rt({},_,{className:l,ref:N}),i))});Vr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Vr.classNames={fullWidth:pr,zeroRight:mr};var lv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function dv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=lv();return t&&e.setAttribute("nonce",t),e}function uv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function fv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var mv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=dv())&&(uv(t,n),fv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},pv=function(){var e=mv();return function(t,n){f.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},fl=function(){var e=pv(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},hv={left:0,top:0,right:0,gap:0},wo=function(e){return parseInt(e||"",10)||0},gv=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[wo(n),wo(r),wo(o)]},xv=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return hv;var t=gv(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},vv=fl(),sn="data-scroll-locked",yv=function(e,t,n,r){var o=e.left,a=e.top,c=e.right,i=e.gap;return n===void 0&&(n="margin"),`
|
|
259
|
-
.`.concat(
|
|
258
|
+
*/var Oa;function fx(){return Oa||(Oa=1,process.env.NODE_ENV!=="production"&&function(){function e(p,v){return p===v&&(p!==0||1/p===1/v)||p!==p&&v!==v}function t(p,v){u||o.startTransition===void 0||(u=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var g=v();if(!m){var x=v();a(g,x)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),m=!0)}x=c({inst:{value:g,getSnapshot:v}});var C=x[0].inst,w=x[1];return l(function(){C.value=g,C.getSnapshot=v,n(C)&&w({inst:C})},[p,g,v]),i(function(){return n(C)&&w({inst:C}),p(function(){n(C)&&w({inst:C})})},[p]),d(g),g}function n(p){var v=p.getSnapshot;p=p.value;try{var g=v();return!a(p,g)}catch{return!0}}function r(p,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=y,a=typeof Object.is=="function"?Object.is:e,c=o.useState,i=o.useEffect,l=o.useLayoutEffect,d=o.useDebugValue,u=!1,m=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:t;mo.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:h,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),mo}process.env.NODE_ENV==="production"?Wo.exports=ux():Wo.exports=fx();var mx=Wo.exports;function px(){return mx.useSyncExternalStore(hx,()=>!0,()=>!1)}function hx(){return()=>{}}var Ns="Avatar",[gx,t1]=ke(Ns),[xx,Tc]=gx(Ns),Rc=f.forwardRef((e,t)=>{const{__scopeAvatar:n,...r}=e,[o,a]=f.useState("idle");return s.jsx(xx,{scope:n,imageLoadingStatus:o,onImageLoadingStatusChange:a,children:s.jsx(K.span,{...r,ref:t})})});Rc.displayName=Ns;var kc="AvatarImage",Pc=f.forwardRef((e,t)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:o=()=>{},...a}=e,c=Tc(kc,n),i=vx(r,a),l=ge(d=>{o(d),c.onImageLoadingStatusChange(d)});return Fe(()=>{i!=="idle"&&l(i)},[i,l]),i==="loaded"?s.jsx(K.img,{...a,ref:t,src:r}):null});Pc.displayName=kc;var Ac="AvatarFallback",Oc=f.forwardRef((e,t)=>{const{__scopeAvatar:n,delayMs:r,...o}=e,a=Tc(Ac,n),[c,i]=f.useState(r===void 0);return f.useEffect(()=>{if(r!==void 0){const l=window.setTimeout(()=>i(!0),r);return()=>window.clearTimeout(l)}},[r]),c&&a.imageLoadingStatus!=="loaded"?s.jsx(K.span,{...o,ref:t}):null});Oc.displayName=Ac;function Da(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function vx(e,{referrerPolicy:t,crossOrigin:n}){const r=px(),o=f.useRef(null),a=r?(o.current||(o.current=new window.Image),o.current):null,[c,i]=f.useState(()=>Da(a,e));return Fe(()=>{i(Da(a,e))},[a,e]),Fe(()=>{const l=m=>()=>{i(m)};if(!a)return;const d=l("loaded"),u=l("error");return a.addEventListener("load",d),a.addEventListener("error",u),t&&(a.referrerPolicy=t),typeof n=="string"&&(a.crossOrigin=n),()=>{a.removeEventListener("load",d),a.removeEventListener("error",u)}},[a,n,t]),c}var Dc=Rc,Ic=Pc,Lc=Oc;const Ce=f.forwardRef(({className:e,...t},n)=>s.jsx(Dc,{ref:n,className:W("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));Ce.displayName=Dc.displayName;const _e=f.forwardRef(({className:e,...t},n)=>s.jsx(Ic,{ref:n,className:W("aspect-square h-full w-full object-cover",e),...t}));_e.displayName=Ic.displayName;const Se=f.forwardRef(({className:e,...t},n)=>s.jsx(Lc,{ref:n,className:W("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));Se.displayName=Lc.displayName;const qe=f.forwardRef(({className:e,type:t,...n},r)=>s.jsx("input",{type:t,className:W("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}));qe.displayName="Input";const _s=ws("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),ne=f.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},a)=>{const c=r?Hf:"button";return s.jsx(c,{className:W(_s({variant:t,size:n,className:e})),ref:a,...o})});ne.displayName="Button";var yx=f.createContext(void 0);function Br(e){const t=f.useContext(yx);return e||t||"ltr"}var po=0;function $c(){f.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ia()),document.body.insertAdjacentElement("beforeend",e[1]??Ia()),po++,()=>{po===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),po--}},[])}function Ia(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var ho="focusScope.autoFocusOnMount",go="focusScope.autoFocusOnUnmount",La={bubbles:!1,cancelable:!0},bx="FocusScope",Es=f.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...c}=e,[i,l]=f.useState(null),d=ge(o),u=ge(a),m=f.useRef(null),h=ae(t,g=>l(g)),p=f.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;f.useEffect(()=>{if(r){let g=function(b){if(p.paused||!i)return;const S=b.target;i.contains(S)?m.current=S:jt(m.current,{select:!0})},x=function(b){if(p.paused||!i)return;const S=b.relatedTarget;S!==null&&(i.contains(S)||jt(m.current,{select:!0}))},C=function(b){if(document.activeElement===document.body)for(const j of b)j.removedNodes.length>0&&jt(i)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const w=new MutationObserver(C);return i&&w.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),w.disconnect()}}},[r,i,p.paused]),f.useEffect(()=>{if(i){Fa.add(p);const g=document.activeElement;if(!i.contains(g)){const C=new CustomEvent(ho,La);i.addEventListener(ho,d),i.dispatchEvent(C),C.defaultPrevented||(wx(_x(Fc(i)),{select:!0}),document.activeElement===g&&jt(i))}return()=>{i.removeEventListener(ho,d),setTimeout(()=>{const C=new CustomEvent(go,La);i.addEventListener(go,u),i.dispatchEvent(C),C.defaultPrevented||jt(g??document.body,{select:!0}),i.removeEventListener(go,u),Fa.remove(p)},0)}}},[i,d,u,p]);const v=f.useCallback(g=>{if(!n&&!r||p.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,C=document.activeElement;if(x&&C){const w=g.currentTarget,[b,S]=Cx(w);b&&S?!g.shiftKey&&C===S?(g.preventDefault(),n&&jt(b,{select:!0})):g.shiftKey&&C===b&&(g.preventDefault(),n&&jt(S,{select:!0})):C===w&&g.preventDefault()}},[n,r,p.paused]);return s.jsx(K.div,{tabIndex:-1,...c,ref:h,onKeyDown:v})});Es.displayName=bx;function wx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(jt(r,{select:t}),document.activeElement!==n)return}function Cx(e){const t=Fc(e),n=$a(t,e),r=$a(t.reverse(),e);return[n,r]}function Fc(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function $a(e,t){for(const n of e)if(!Sx(n,{upTo:t}))return n}function Sx(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function jx(e){return e instanceof HTMLInputElement&&"select"in e}function jt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&jx(e)&&t&&e.select()}}var Fa=Nx();function Nx(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=za(e,t),e.unshift(t)},remove(t){var n;e=za(e,t),(n=e[0])==null||n.resume()}}}function za(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function _x(e){return e.filter(t=>t.tagName!=="A")}var xo="rovingFocusGroup.onEntryFocus",Ex={bubbles:!1,cancelable:!0},qn="RovingFocusGroup",[Bo,zc,Mx]=xs(qn),[Tx,qr]=ke(qn,[Mx]),[Rx,kx]=Tx(qn),Wc=f.forwardRef((e,t)=>s.jsx(Bo.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(Bo.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(Px,{...e,ref:t})})}));Wc.displayName=qn;var Px=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:a,currentTabStopId:c,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:l,onEntryFocus:d,preventScrollOnEntryFocus:u=!1,...m}=e,h=f.useRef(null),p=ae(t,h),v=Br(a),[g,x]=Bt({prop:c,defaultProp:i??null,onChange:l,caller:qn}),[C,w]=f.useState(!1),b=ge(d),S=zc(n),j=f.useRef(!1),[N,_]=f.useState(0);return f.useEffect(()=>{const O=h.current;if(O)return O.addEventListener(xo,b),()=>O.removeEventListener(xo,b)},[b]),s.jsx(Rx,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:f.useCallback(O=>x(O),[x]),onItemShiftTab:f.useCallback(()=>w(!0),[]),onFocusableItemAdd:f.useCallback(()=>_(O=>O+1),[]),onFocusableItemRemove:f.useCallback(()=>_(O=>O-1),[]),children:s.jsx(K.div,{tabIndex:C||N===0?-1:0,"data-orientation":r,...m,ref:p,style:{outline:"none",...e.style},onMouseDown:L(e.onMouseDown,()=>{j.current=!0}),onFocus:L(e.onFocus,O=>{const k=!j.current;if(O.target===O.currentTarget&&k&&!C){const P=new CustomEvent(xo,Ex);if(O.currentTarget.dispatchEvent(P),!P.defaultPrevented){const I=S().filter(T=>T.focusable),A=I.find(T=>T.active),D=I.find(T=>T.id===g),F=[A,D,...I].filter(Boolean).map(T=>T.ref.current);Uc(F,u)}}j.current=!1}),onBlur:L(e.onBlur,()=>w(!1))})})}),Bc="RovingFocusGroupItem",qc=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:a,children:c,...i}=e,l=gt(),d=a||l,u=kx(Bc,n),m=u.currentTabStopId===d,h=zc(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:g}=u;return f.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),s.jsx(Bo.ItemSlot,{scope:n,id:d,focusable:r,active:o,children:s.jsx(K.span,{tabIndex:m?0:-1,"data-orientation":u.orientation,...i,ref:t,onMouseDown:L(e.onMouseDown,x=>{r?u.onItemFocus(d):x.preventDefault()}),onFocus:L(e.onFocus,()=>u.onItemFocus(d)),onKeyDown:L(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){u.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const C=Dx(x,u.orientation,u.dir);if(C!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let b=h().filter(S=>S.focusable).map(S=>S.ref.current);if(C==="last")b.reverse();else if(C==="prev"||C==="next"){C==="prev"&&b.reverse();const S=b.indexOf(x.currentTarget);b=u.loop?Ix(b,S+1):b.slice(S+1)}setTimeout(()=>Uc(b))}}),children:typeof c=="function"?c({isCurrentTabStop:m,hasTabStop:g!=null}):c})})});qc.displayName=Bc;var Ax={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ox(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Dx(e,t,n){const r=Ox(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ax[r]}function Uc(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ix(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Hc=Wc,Vc=qc,Lx=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Qt=new WeakMap,rr=new WeakMap,or={},vo=0,Gc=function(e){return e&&(e.host||Gc(e.parentNode))},$x=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Gc(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Fx=function(e,t,n,r){var o=$x(t,Array.isArray(e)?e:[e]);or[n]||(or[n]=new WeakMap);var a=or[n],c=[],i=new Set,l=new Set(o),d=function(m){!m||i.has(m)||(i.add(m),d(m.parentNode))};o.forEach(d);var u=function(m){!m||l.has(m)||Array.prototype.forEach.call(m.children,function(h){if(i.has(h))u(h);else try{var p=h.getAttribute(r),v=p!==null&&p!=="false",g=(Qt.get(h)||0)+1,x=(a.get(h)||0)+1;Qt.set(h,g),a.set(h,x),c.push(h),g===1&&v&&rr.set(h,!0),x===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(C){console.error("aria-hidden: cannot operate on ",h,C)}})};return u(t),i.clear(),vo++,function(){c.forEach(function(m){var h=Qt.get(m)-1,p=a.get(m)-1;Qt.set(m,h),a.set(m,p),h||(rr.has(m)||m.removeAttribute(r),rr.delete(m)),p||m.removeAttribute(n)}),vo--,vo||(Qt=new WeakMap,Qt=new WeakMap,rr=new WeakMap,or={})}},Yc=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Lx(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),Fx(r,o,n,"aria-hidden")):function(){return null}},rt=function(){return rt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},rt.apply(this,arguments)};function Kc(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function zx(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var mr="right-scroll-bar-position",pr="width-before-scroll-bar",Wx="with-scroll-bars-hidden",Bx="--removed-body-scroll-bar-size";function yo(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function qx(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Ux=typeof window<"u"?f.useLayoutEffect:f.useEffect,Wa=new WeakMap;function Hx(e,t){var n=qx(null,function(r){return e.forEach(function(o){return yo(o,r)})});return Ux(function(){var r=Wa.get(n);if(r){var o=new Set(r),a=new Set(e),c=n.current;o.forEach(function(i){a.has(i)||yo(i,null)}),a.forEach(function(i){o.has(i)||yo(i,c)})}Wa.set(n,e)},[e]),n}function Vx(e){return e}function Gx(e,t){t===void 0&&(t=Vx);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var c=t(a,r);return n.push(c),function(){n=n.filter(function(i){return i!==c})}},assignSyncMedium:function(a){for(r=!0;n.length;){var c=n;n=[],c.forEach(a)}n={push:function(i){return a(i)},filter:function(){return n}}},assignMedium:function(a){r=!0;var c=[];if(n.length){var i=n;n=[],i.forEach(a),c=n}var l=function(){var u=c;c=[],u.forEach(a)},d=function(){return Promise.resolve().then(l)};d(),n={push:function(u){c.push(u),d()},filter:function(u){return c=c.filter(u),n}}}};return o}function Yx(e){e===void 0&&(e={});var t=Gx(null);return t.options=rt({async:!0,ssr:!1},e),t}var Xc=function(e){var t=e.sideCar,n=Kc(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return f.createElement(r,rt({},n))};Xc.isSideCarExport=!0;function Kx(e,t){return e.useMedium(t),Xc}var Qc=Yx(),bo=function(){},Ur=f.forwardRef(function(e,t){var n=f.useRef(null),r=f.useState({onScrollCapture:bo,onWheelCapture:bo,onTouchMoveCapture:bo}),o=r[0],a=r[1],c=e.forwardProps,i=e.children,l=e.className,d=e.removeScrollBar,u=e.enabled,m=e.shards,h=e.sideCar,p=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,C=e.as,w=C===void 0?"div":C,b=e.gapMode,S=Kc(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=h,N=Hx([n,t]),_=rt(rt({},S),o);return f.createElement(f.Fragment,null,u&&f.createElement(j,{sideCar:Qc,removeScrollBar:d,shards:m,noRelative:p,noIsolation:v,inert:g,setCallbacks:a,allowPinchZoom:!!x,lockRef:n,gapMode:b}),c?f.cloneElement(f.Children.only(i),rt(rt({},_),{ref:N})):f.createElement(w,rt({},_,{className:l,ref:N}),i))});Ur.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Ur.classNames={fullWidth:pr,zeroRight:mr};var Xx=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Qx(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Xx();return t&&e.setAttribute("nonce",t),e}function Zx(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Jx(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ev=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Qx())&&(Zx(t,n),Jx(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},tv=function(){var e=ev();return function(t,n){f.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Zc=function(){var e=tv(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},nv={left:0,top:0,right:0,gap:0},wo=function(e){return parseInt(e||"",10)||0},rv=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[wo(n),wo(r),wo(o)]},ov=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return nv;var t=rv(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},sv=Zc(),on="data-scroll-locked",av=function(e,t,n,r){var o=e.left,a=e.top,c=e.right,i=e.gap;return n===void 0&&(n="margin"),`
|
|
259
|
+
.`.concat(Wx,` {
|
|
260
260
|
overflow: hidden `).concat(r,`;
|
|
261
261
|
padding-right: `).concat(i,"px ").concat(r,`;
|
|
262
262
|
}
|
|
263
|
-
body[`).concat(
|
|
263
|
+
body[`).concat(on,`] {
|
|
264
264
|
overflow: hidden `).concat(r,`;
|
|
265
265
|
overscroll-behavior: contain;
|
|
266
266
|
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
@@ -289,20 +289,20 @@
|
|
|
289
289
|
margin-right: 0 `).concat(r,`;
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
body[`).concat(
|
|
293
|
-
`).concat(
|
|
292
|
+
body[`).concat(on,`] {
|
|
293
|
+
`).concat(Bx,": ").concat(i,`px;
|
|
294
294
|
}
|
|
295
|
-
`)},
|
|
295
|
+
`)},Ba=function(){var e=parseInt(document.body.getAttribute(on)||"0",10);return isFinite(e)?e:0},iv=function(){f.useEffect(function(){return document.body.setAttribute(on,(Ba()+1).toString()),function(){var e=Ba()-1;e<=0?document.body.removeAttribute(on):document.body.setAttribute(on,e.toString())}},[])},cv=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;iv();var a=f.useMemo(function(){return ov(o)},[o]);return f.createElement(sv,{styles:av(a,!t,o,n?"":"!important")})},qo=!1;if(typeof window<"u")try{var sr=Object.defineProperty({},"passive",{get:function(){return qo=!0,!0}});window.addEventListener("test",sr,sr),window.removeEventListener("test",sr,sr)}catch{qo=!1}var Zt=qo?{passive:!1}:!1,lv=function(e){return e.tagName==="TEXTAREA"},Jc=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!lv(e)&&n[t]==="visible")},dv=function(e){return Jc(e,"overflowY")},uv=function(e){return Jc(e,"overflowX")},qa=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=el(e,r);if(o){var a=tl(e,r),c=a[1],i=a[2];if(c>i)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},fv=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},mv=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},el=function(e,t){return e==="v"?dv(t):uv(t)},tl=function(e,t){return e==="v"?fv(t):mv(t)},pv=function(e,t){return e==="h"&&t==="rtl"?-1:1},hv=function(e,t,n,r,o){var a=pv(e,window.getComputedStyle(t).direction),c=a*r,i=n.target,l=t.contains(i),d=!1,u=c>0,m=0,h=0;do{if(!i)break;var p=tl(e,i),v=p[0],g=p[1],x=p[2],C=g-x-a*v;(v||C)&&el(e,i)&&(m+=C,h+=v);var w=i.parentNode;i=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!l&&i!==document.body||l&&(t.contains(i)||t===i));return(u&&(Math.abs(m)<1||!o)||!u&&(Math.abs(h)<1||!o))&&(d=!0),d},ar=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ua=function(e){return[e.deltaX,e.deltaY]},Ha=function(e){return e&&"current"in e?e.current:e},gv=function(e,t){return e[0]===t[0]&&e[1]===t[1]},xv=function(e){return`
|
|
296
296
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
297
297
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
298
|
-
`)},kv=0,en=[];function Pv(e){var t=f.useRef([]),n=f.useRef([0,0]),r=f.useRef(),o=f.useState(kv++)[0],a=f.useState(fl)[0],c=f.useRef(e);f.useEffect(function(){c.current=e},[e]),f.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=Jx([e.lockRef.current],(e.shards||[]).map(Va),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var i=f.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!c.current.allowPinchZoom;var C=ar(g),w=n.current,b="deltaX"in g?g.deltaX:w[0]-C[0],S="deltaY"in g?g.deltaY:w[1]-C[1],j,N=g.target,_=Math.abs(b)>Math.abs(S)?"h":"v";if("touches"in g&&_==="h"&&N.type==="range")return!1;var O=Ua(_,N);if(!O)return!0;if(O?j=_:(j=_==="v"?"h":"v",O=Ua(_,N)),!O)return!1;if(!r.current&&"changedTouches"in g&&(b||S)&&(r.current=j),!j)return!0;var k=r.current||j;return Mv(k,x,g,k==="h"?b:S,!0)},[]),l=f.useCallback(function(g){var x=g;if(!(!en.length||en[en.length-1]!==a)){var C="deltaY"in x?Ha(x):ar(x),w=t.current.filter(function(j){return j.name===x.type&&(j.target===x.target||x.target===j.shadowParent)&&Tv(j.delta,C)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var b=(c.current.shards||[]).map(Va).filter(Boolean).filter(function(j){return j.contains(x.target)}),S=b.length>0?i(x,b[0]):!c.current.noIsolation;S&&x.cancelable&&x.preventDefault()}}},[]),d=f.useCallback(function(g,x,C,w){var b={name:g,delta:x,target:C,should:w,shadowParent:Av(C)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(S){return S!==b})},1)},[]),u=f.useCallback(function(g){n.current=ar(g),r.current=void 0},[]),m=f.useCallback(function(g){d(g.type,Ha(g),g.target,i(g,e.lockRef.current))},[]),h=f.useCallback(function(g){d(g.type,ar(g),g.target,i(g,e.lockRef.current))},[]);f.useEffect(function(){return en.push(a),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Jt),document.addEventListener("touchmove",l,Jt),document.addEventListener("touchstart",u,Jt),function(){en=en.filter(function(g){return g!==a}),document.removeEventListener("wheel",l,Jt),document.removeEventListener("touchmove",l,Jt),document.removeEventListener("touchstart",u,Jt)}},[]);var p=e.removeScrollBar,v=e.inert;return f.createElement(f.Fragment,null,v?f.createElement(a,{styles:Rv(o)}):null,p?f.createElement(wv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Av(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Ov=cv(ul,Pv);var Ps=f.forwardRef(function(e,t){return f.createElement(Vr,rt({},e,{ref:t,sideCar:Ov}))});Ps.classNames=Vr.classNames;var Uo=["Enter"," "],Dv=["ArrowDown","PageUp","Home"],gl=["ArrowUp","PageDown","End"],Iv=[...Dv,...gl],Lv={ltr:[...Uo,"ArrowRight"],rtl:[...Uo,"ArrowLeft"]},$v={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Un="Menu",[In,Fv,zv]=xs(Un),[Ut,Gr]=ke(Un,[zv,Ir,Hr]),Hn=Ir(),xl=Hr(),[vl,Mt]=Ut(Un),[Wv,Vn]=Ut(Un),yl=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:a,modal:c=!0}=e,i=Hn(t),[l,d]=f.useState(null),u=f.useRef(!1),m=ge(a),h=Br(o);return f.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),s.jsx(Ai,{...i,children:s.jsx(vl,{scope:t,open:n,onOpenChange:m,content:l,onContentChange:d,children:s.jsx(Wv,{scope:t,onClose:f.useCallback(()=>m(!1),[m]),isUsingKeyboardRef:u,dir:h,modal:c,children:r})})})};yl.displayName=Un;var Bv="MenuAnchor",As=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Hn(n);return s.jsx(Oi,{...o,...r,ref:t})});As.displayName=Bv;var Os="MenuPortal",[qv,bl]=Ut(Os,{forceMount:void 0}),wl=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,a=Mt(Os,t);return s.jsx(qv,{scope:t,forceMount:n,children:s.jsx(Ee,{present:n||a.open,children:s.jsx(Lr,{asChild:!0,container:o,children:r})})})};wl.displayName=Os;var Ue="MenuContent",[Uv,Ds]=Ut(Ue),Cl=f.forwardRef((e,t)=>{const n=bl(Ue,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=Mt(Ue,e.__scopeMenu),c=Vn(Ue,e.__scopeMenu);return s.jsx(In.Provider,{scope:e.__scopeMenu,children:s.jsx(Ee,{present:r||a.open,children:s.jsx(In.Slot,{scope:e.__scopeMenu,children:c.modal?s.jsx(Hv,{...o,ref:t}):s.jsx(Vv,{...o,ref:t})})})})}),Hv=f.forwardRef((e,t)=>{const n=Mt(Ue,e.__scopeMenu),r=f.useRef(null),o=ae(t,r);return f.useEffect(()=>{const a=r.current;if(a)return cl(a)},[]),s.jsx(Is,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:L(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Vv=f.forwardRef((e,t)=>{const n=Mt(Ue,e.__scopeMenu);return s.jsx(Is,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Gv=dn("MenuContent.ScrollLock"),Is=f.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:c,disableOutsidePointerEvents:i,onEntryFocus:l,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:m,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...g}=e,x=Mt(Ue,n),C=Vn(Ue,n),w=Hn(n),b=xl(n),S=Fv(n),[j,N]=f.useState(null),_=f.useRef(null),O=ae(t,_,x.onContentChange),k=f.useRef(0),P=f.useRef(""),I=f.useRef(0),A=f.useRef(null),D=f.useRef("right"),E=f.useRef(0),F=v?Ps:f.Fragment,T=v?{as:Gv,allowPinchZoom:!0}:void 0,z=M=>{var J,Pe;const H=P.current+M,Z=S().filter(he=>!he.disabled),V=document.activeElement,G=(J=Z.find(he=>he.ref.current===V))==null?void 0:J.textValue,B=Z.map(he=>he.textValue),re=sy(B,H,G),ue=(Pe=Z.find(he=>he.textValue===re))==null?void 0:Pe.ref.current;(function he(ze){P.current=ze,window.clearTimeout(k.current),ze!==""&&(k.current=window.setTimeout(()=>he(""),1e3))})(H),ue&&setTimeout(()=>ue.focus())};f.useEffect(()=>()=>window.clearTimeout(k.current),[]),Zc();const $=f.useCallback(M=>{var Z,V;return D.current===((Z=A.current)==null?void 0:Z.side)&&iy(M,(V=A.current)==null?void 0:V.area)},[]);return s.jsx(Uv,{scope:n,searchRef:P,onItemEnter:f.useCallback(M=>{$(M)&&M.preventDefault()},[$]),onItemLeave:f.useCallback(M=>{var H;$(M)||((H=_.current)==null||H.focus(),N(null))},[$]),onTriggerLeave:f.useCallback(M=>{$(M)&&M.preventDefault()},[$]),pointerGraceTimerRef:I,onPointerGraceIntentChange:f.useCallback(M=>{A.current=M},[]),children:s.jsx(F,{...T,children:s.jsx(ks,{asChild:!0,trapped:o,onMountAutoFocus:L(a,M=>{var H;M.preventDefault(),(H=_.current)==null||H.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:s.jsx(Fn,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:m,onInteractOutside:h,onDismiss:p,children:s.jsx(sl,{asChild:!0,...b,dir:C.dir,orientation:"vertical",loop:r,currentTabStopId:j,onCurrentTabStopIdChange:N,onEntryFocus:L(l,M=>{C.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(Di,{role:"menu","aria-orientation":"vertical","data-state":Fl(x.open),"data-radix-menu-content":"",dir:C.dir,...w,...g,ref:O,style:{outline:"none",...g.style},onKeyDown:L(g.onKeyDown,M=>{const Z=M.target.closest("[data-radix-menu-content]")===M.currentTarget,V=M.ctrlKey||M.altKey||M.metaKey,G=M.key.length===1;Z&&(M.key==="Tab"&&M.preventDefault(),!V&&G&&z(M.key));const B=_.current;if(M.target!==B||!Iv.includes(M.key))return;M.preventDefault();const ue=S().filter(J=>!J.disabled).map(J=>J.ref.current);gl.includes(M.key)&&ue.reverse(),ry(ue)}),onBlur:L(e.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(k.current),P.current="")}),onPointerMove:L(e.onPointerMove,Ln(M=>{const H=M.target,Z=E.current!==M.clientX;if(M.currentTarget.contains(H)&&Z){const V=M.clientX>E.current?"right":"left";D.current=V,E.current=M.clientX}}))})})})})})})});Cl.displayName=Ue;var Yv="MenuGroup",Ls=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(K.div,{role:"group",...r,ref:t})});Ls.displayName=Yv;var Kv="MenuLabel",Sl=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(K.div,{...r,ref:t})});Sl.displayName=Kv;var _r="MenuItem",Ga="menu.itemSelect",Yr=f.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,a=f.useRef(null),c=Vn(_r,e.__scopeMenu),i=Ds(_r,e.__scopeMenu),l=ae(t,a),d=f.useRef(!1),u=()=>{const m=a.current;if(!n&&m){const h=new CustomEvent(Ga,{bubbles:!0,cancelable:!0});m.addEventListener(Ga,p=>r==null?void 0:r(p),{once:!0}),ss(m,h),h.defaultPrevented?d.current=!1:c.onClose()}};return s.jsx(jl,{...o,ref:l,disabled:n,onClick:L(e.onClick,u),onPointerDown:m=>{var h;(h=e.onPointerDown)==null||h.call(e,m),d.current=!0},onPointerUp:L(e.onPointerUp,m=>{var h;d.current||(h=m.currentTarget)==null||h.click()}),onKeyDown:L(e.onKeyDown,m=>{const h=i.searchRef.current!=="";n||h&&m.key===" "||Uo.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})});Yr.displayName=_r;var jl=f.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...a}=e,c=Ds(_r,n),i=xl(n),l=f.useRef(null),d=ae(t,l),[u,m]=f.useState(!1),[h,p]=f.useState("");return f.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[a.children]),s.jsx(In.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:s.jsx(al,{asChild:!0,...i,focusable:!r,children:s.jsx(K.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:d,onPointerMove:L(e.onPointerMove,Ln(v=>{r?c.onItemLeave(v):(c.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:L(e.onPointerLeave,Ln(v=>c.onItemLeave(v))),onFocus:L(e.onFocus,()=>m(!0)),onBlur:L(e.onBlur,()=>m(!1))})})})}),Xv="MenuCheckboxItem",Nl=f.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return s.jsx(Rl,{scope:e.__scopeMenu,checked:n,children:s.jsx(Yr,{role:"menuitemcheckbox","aria-checked":Er(n)?"mixed":n,...o,ref:t,"data-state":zs(n),onSelect:L(o.onSelect,()=>r==null?void 0:r(Er(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Nl.displayName=Xv;var _l="MenuRadioGroup",[Qv,Zv]=Ut(_l,{value:void 0,onValueChange:()=>{}}),El=f.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,a=ge(r);return s.jsx(Qv,{scope:e.__scopeMenu,value:n,onValueChange:a,children:s.jsx(Ls,{...o,ref:t})})});El.displayName=_l;var Ml="MenuRadioItem",Tl=f.forwardRef((e,t)=>{const{value:n,...r}=e,o=Zv(Ml,e.__scopeMenu),a=n===o.value;return s.jsx(Rl,{scope:e.__scopeMenu,checked:a,children:s.jsx(Yr,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":zs(a),onSelect:L(r.onSelect,()=>{var c;return(c=o.onValueChange)==null?void 0:c.call(o,n)},{checkForDefaultPrevented:!1})})})});Tl.displayName=Ml;var $s="MenuItemIndicator",[Rl,Jv]=Ut($s,{checked:!1}),kl=f.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,a=Jv($s,n);return s.jsx(Ee,{present:r||Er(a.checked)||a.checked===!0,children:s.jsx(K.span,{...o,ref:t,"data-state":zs(a.checked)})})});kl.displayName=$s;var ey="MenuSeparator",Pl=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(K.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Pl.displayName=ey;var ty="MenuArrow",Al=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Hn(n);return s.jsx(Ii,{...o,...r,ref:t})});Al.displayName=ty;var Fs="MenuSub",[ny,Ol]=Ut(Fs),Dl=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:o}=e,a=Mt(Fs,t),c=Hn(t),[i,l]=f.useState(null),[d,u]=f.useState(null),m=ge(o);return f.useEffect(()=>(a.open===!1&&m(!1),()=>m(!1)),[a.open,m]),s.jsx(Ai,{...c,children:s.jsx(vl,{scope:t,open:r,onOpenChange:m,content:d,onContentChange:u,children:s.jsx(ny,{scope:t,contentId:gt(),triggerId:gt(),trigger:i,onTriggerChange:l,children:n})})})};Dl.displayName=Fs;var kn="MenuSubTrigger",Il=f.forwardRef((e,t)=>{const n=Mt(kn,e.__scopeMenu),r=Vn(kn,e.__scopeMenu),o=Ol(kn,e.__scopeMenu),a=Ds(kn,e.__scopeMenu),c=f.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:l}=a,d={__scopeMenu:e.__scopeMenu},u=f.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=null},[]);return f.useEffect(()=>u,[u]),f.useEffect(()=>{const m=i.current;return()=>{window.clearTimeout(m),l(null)}},[i,l]),s.jsx(As,{asChild:!0,...d,children:s.jsx(jl,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Fl(n.open),...e,ref:Pr(t,o.onTriggerChange),onClick:m=>{var h;(h=e.onClick)==null||h.call(e,m),!(e.disabled||m.defaultPrevented)&&(m.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:L(e.onPointerMove,Ln(m=>{a.onItemEnter(m),!m.defaultPrevented&&!e.disabled&&!n.open&&!c.current&&(a.onPointerGraceIntentChange(null),c.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:L(e.onPointerLeave,Ln(m=>{var p,v;u();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",C=x?-5:5,w=h[x?"left":"right"],b=h[x?"right":"left"];a.onPointerGraceIntentChange({area:[{x:m.clientX+C,y:m.clientY},{x:w,y:h.top},{x:b,y:h.top},{x:b,y:h.bottom},{x:w,y:h.bottom}],side:g}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(m),m.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:L(e.onKeyDown,m=>{var p;const h=a.searchRef.current!=="";e.disabled||h&&m.key===" "||Lv[r.dir].includes(m.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),m.preventDefault())})})})});Il.displayName=kn;var Ll="MenuSubContent",$l=f.forwardRef((e,t)=>{const n=bl(Ue,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=Mt(Ue,e.__scopeMenu),c=Vn(Ue,e.__scopeMenu),i=Ol(Ll,e.__scopeMenu),l=f.useRef(null),d=ae(t,l);return s.jsx(In.Provider,{scope:e.__scopeMenu,children:s.jsx(Ee,{present:r||a.open,children:s.jsx(In.Slot,{scope:e.__scopeMenu,children:s.jsx(Is,{id:i.contentId,"aria-labelledby":i.triggerId,...o,ref:d,align:"start",side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var m;c.isUsingKeyboardRef.current&&((m=l.current)==null||m.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:L(e.onFocusOutside,u=>{u.target!==i.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:L(e.onEscapeKeyDown,u=>{c.onClose(),u.preventDefault()}),onKeyDown:L(e.onKeyDown,u=>{var p;const m=u.currentTarget.contains(u.target),h=$v[c.dir].includes(u.key);m&&h&&(a.onOpenChange(!1),(p=i.trigger)==null||p.focus(),u.preventDefault())})})})})})});$l.displayName=Ll;function Fl(e){return e?"open":"closed"}function Er(e){return e==="indeterminate"}function zs(e){return Er(e)?"indeterminate":e?"checked":"unchecked"}function ry(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function oy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function sy(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let c=oy(e,Math.max(a,0));o.length===1&&(c=c.filter(d=>d!==n));const l=c.find(d=>d.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function ay(e,t){const{x:n,y:r}=e;let o=!1;for(let a=0,c=t.length-1;a<t.length;c=a++){const i=t[a],l=t[c],d=i.x,u=i.y,m=l.x,h=l.y;u>r!=h>r&&n<(m-d)*(r-u)/(h-u)+d&&(o=!o)}return o}function iy(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return ay(n,t)}function Ln(e){return t=>t.pointerType==="mouse"?e(t):void 0}var zl=yl,Wl=As,Bl=wl,ql=Cl,Ul=Ls,Hl=Sl,Vl=Yr,Gl=Nl,Yl=El,Kl=Tl,Xl=kl,Ql=Pl,Zl=Al,cy=Dl,Jl=Il,ed=$l,Ws="ContextMenu",[ly,n1]=ke(Ws,[Gr]),Te=Gr(),[dy,td]=ly(Ws),nd=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:o,modal:a=!0}=e,[c,i]=f.useState(!1),l=Te(t),d=ge(r),u=f.useCallback(m=>{i(m),d(m)},[d]);return s.jsx(dy,{scope:t,open:c,onOpenChange:u,modal:a,children:s.jsx(zl,{...l,dir:o,open:c,onOpenChange:u,modal:a,children:n})})};nd.displayName=Ws;var rd="ContextMenuTrigger",od=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...o}=e,a=td(rd,n),c=Te(n),i=f.useRef({x:0,y:0}),l=f.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...i.current})}),d=f.useRef(0),u=f.useCallback(()=>window.clearTimeout(d.current),[]),m=h=>{i.current={x:h.clientX,y:h.clientY},a.onOpenChange(!0)};return f.useEffect(()=>u,[u]),f.useEffect(()=>void(r&&u()),[r,u]),s.jsxs(s.Fragment,{children:[s.jsx(Wl,{...c,virtualRef:l}),s.jsx(K.span,{"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,...o,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:L(e.onContextMenu,h=>{u(),m(h),h.preventDefault()}),onPointerDown:r?e.onPointerDown:L(e.onPointerDown,ir(h=>{u(),d.current=window.setTimeout(()=>m(h),700)})),onPointerMove:r?e.onPointerMove:L(e.onPointerMove,ir(u)),onPointerCancel:r?e.onPointerCancel:L(e.onPointerCancel,ir(u)),onPointerUp:r?e.onPointerUp:L(e.onPointerUp,ir(u))})]})});od.displayName=rd;var uy="ContextMenuPortal",sd=e=>{const{__scopeContextMenu:t,...n}=e,r=Te(t);return s.jsx(Bl,{...r,...n})};sd.displayName=uy;var ad="ContextMenuContent",id=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=td(ad,n),a=Te(n),c=f.useRef(!1);return s.jsx(ql,{...a,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:i=>{var l;(l=e.onCloseAutoFocus)==null||l.call(e,i),!i.defaultPrevented&&c.current&&i.preventDefault(),c.current=!1},onInteractOutside:i=>{var l;(l=e.onInteractOutside)==null||l.call(e,i),!i.defaultPrevented&&!o.modal&&(c.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});id.displayName=ad;var fy="ContextMenuGroup",my=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Ul,{...o,...r,ref:t})});my.displayName=fy;var py="ContextMenuLabel",cd=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Hl,{...o,...r,ref:t})});cd.displayName=py;var hy="ContextMenuItem",ld=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Vl,{...o,...r,ref:t})});ld.displayName=hy;var gy="ContextMenuCheckboxItem",dd=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Gl,{...o,...r,ref:t})});dd.displayName=gy;var xy="ContextMenuRadioGroup",vy=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Yl,{...o,...r,ref:t})});vy.displayName=xy;var yy="ContextMenuRadioItem",ud=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Kl,{...o,...r,ref:t})});ud.displayName=yy;var by="ContextMenuItemIndicator",fd=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Xl,{...o,...r,ref:t})});fd.displayName=by;var wy="ContextMenuSeparator",md=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Ql,{...o,...r,ref:t})});md.displayName=wy;var Cy="ContextMenuArrow",Sy=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Zl,{...o,...r,ref:t})});Sy.displayName=Cy;var jy="ContextMenuSubTrigger",pd=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Jl,{...o,...r,ref:t})});pd.displayName=jy;var Ny="ContextMenuSubContent",hd=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(ed,{...o,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});hd.displayName=Ny;function ir(e){return t=>t.pointerType!=="mouse"?e(t):void 0}var _y=nd,Ey=od,My=sd,gd=id,xd=cd,vd=ld,yd=dd,bd=ud,wd=fd,Cd=md,Sd=pd,jd=hd;const Ty=_y,Ry=Ey,ky=f.forwardRef(({className:e,inset:t,children:n,...r},o)=>s.jsxs(Sd,{ref:o,className:W("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent data-[state=open]:text-accent-foreground focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...r,children:[n,s.jsx(Cs,{className:"ml-auto h-4 w-4"})]}));ky.displayName=Sd.displayName;const Py=f.forwardRef(({className:e,...t},n)=>s.jsx(jd,{ref:n,className:W("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),...t}));Py.displayName=jd.displayName;const Nd=f.forwardRef(({className:e,...t},n)=>s.jsx(My,{children:s.jsx(gd,{ref:n,className:W("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 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})}));Nd.displayName=gd.displayName;const hr=f.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(vd,{ref:r,className:W("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...n}));hr.displayName=vd.displayName;const Ay=f.forwardRef(({className:e,children:t,checked:n,...r},o)=>s.jsxs(yd,{ref:o,className:W("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),checked:n,...r,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(wd,{children:s.jsx(zt,{className:"h-4 w-4"})})}),t]}));Ay.displayName=yd.displayName;const Oy=f.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(bd,{ref:r,className:W("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...n,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(wd,{children:s.jsx(vc,{className:"h-2 w-2 fill-current"})})}),t]}));Oy.displayName=bd.displayName;const Dy=f.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(xd,{ref:r,className:W("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",e),...n}));Dy.displayName=xd.displayName;const _d=f.forwardRef(({className:e,...t},n)=>s.jsx(Cd,{ref:n,className:W("-mx-1 my-1 h-px bg-border",e),...t}));_d.displayName=Cd.displayName;function ce(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function yt(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function Iy(e,t){const n=ce(e);return isNaN(t)?yt(e,NaN):(n.setDate(n.getDate()+t),n)}const Ed=6048e5,Ly=864e5,cr=43200,Ya=1440;let $y={};function Gn(){return $y}function $n(e,t){var i,l,d,u;const n=Gn(),r=(t==null?void 0:t.weekStartsOn)??((l=(i=t==null?void 0:t.locale)==null?void 0:i.options)==null?void 0:l.weekStartsOn)??n.weekStartsOn??((u=(d=n.locale)==null?void 0:d.options)==null?void 0:u.weekStartsOn)??0,o=ce(e),a=o.getDay(),c=(a<r?7:0)+a-r;return o.setDate(o.getDate()-c),o.setHours(0,0,0,0),o}function Mr(e){return $n(e,{weekStartsOn:1})}function Md(e){const t=ce(e),n=t.getFullYear(),r=yt(e,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const o=Mr(r),a=yt(e,0);a.setFullYear(n,0,4),a.setHours(0,0,0,0);const c=Mr(a);return t.getTime()>=o.getTime()?n+1:t.getTime()>=c.getTime()?n:n-1}function Tr(e){const t=ce(e);return t.setHours(0,0,0,0),t}function Rr(e){const t=ce(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Fy(e,t){const n=Tr(e),r=Tr(t),o=+n-Rr(n),a=+r-Rr(r);return Math.round((o-a)/Ly)}function zy(e){const t=Md(e),n=yt(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),Mr(n)}function gr(e,t){const n=ce(e),r=ce(t),o=n.getTime()-r.getTime();return o<0?-1:o>0?1:o}function Bs(e){return yt(e,Date.now())}function Td(e,t){const n=Tr(e),r=Tr(t);return+n==+r}function Wy(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function By(e){if(!Wy(e)&&typeof e!="number")return!1;const t=ce(e);return!isNaN(Number(t))}function qy(e,t){const n=ce(e),r=ce(t),o=n.getFullYear()-r.getFullYear(),a=n.getMonth()-r.getMonth();return o*12+a}function Uy(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function Hy(e,t){return+ce(e)-+ce(t)}function Vy(e){const t=ce(e);return t.setHours(23,59,59,999),t}function Gy(e){const t=ce(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function Yy(e){const t=ce(e);return+Vy(t)==+Gy(t)}function Ky(e,t){const n=ce(e),r=ce(t),o=gr(n,r),a=Math.abs(qy(n,r));let c;if(a<1)c=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-o*a);let i=gr(n,r)===-o;Yy(ce(e))&&a===1&&gr(e,r)===1&&(i=!1),c=o*(a-Number(i))}return c===0?0:c}function Xy(e,t,n){const r=Hy(e,t)/1e3;return Uy(n==null?void 0:n.roundingMethod)(r)}function Qy(e){const t=ce(e),n=yt(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}const Zy={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Jy=(e,t,n)=>{let r;const o=Zy[e];return typeof o=="string"?r=o:t===1?r=o.one:r=o.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function Co(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const eb={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},tb={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},nb={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},rb={date:Co({formats:eb,defaultWidth:"full"}),time:Co({formats:tb,defaultWidth:"full"}),dateTime:Co({formats:nb,defaultWidth:"full"})},ob={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},sb=(e,t,n,r)=>ob[e];function En(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let o;if(r==="formatting"&&e.formattingValues){const c=e.defaultFormattingWidth||e.defaultWidth,i=n!=null&&n.width?String(n.width):c;o=e.formattingValues[i]||e.formattingValues[c]}else{const c=e.defaultWidth,i=n!=null&&n.width?String(n.width):e.defaultWidth;o=e.values[i]||e.values[c]}const a=e.argumentCallback?e.argumentCallback(t):t;return o[a]}}const ab={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ib={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},cb={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},lb={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},db={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},ub={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},fb=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},mb={ordinalNumber:fb,era:En({values:ab,defaultWidth:"wide"}),quarter:En({values:ib,defaultWidth:"wide",argumentCallback:e=>e-1}),month:En({values:cb,defaultWidth:"wide"}),day:En({values:lb,defaultWidth:"wide"}),dayPeriod:En({values:db,defaultWidth:"wide",formattingValues:ub,defaultFormattingWidth:"wide"})};function Mn(e){return(t,n={})=>{const r=n.width,o=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(o);if(!a)return null;const c=a[0],i=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?hb(i,m=>m.test(c)):pb(i,m=>m.test(c));let d;d=e.valueCallback?e.valueCallback(l):l,d=n.valueCallback?n.valueCallback(d):d;const u=t.slice(c.length);return{value:d,rest:u}}}function pb(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function hb(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function gb(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const o=r[0],a=t.match(e.parsePattern);if(!a)return null;let c=e.valueCallback?e.valueCallback(a[0]):a[0];c=n.valueCallback?n.valueCallback(c):c;const i=t.slice(o.length);return{value:c,rest:i}}}const xb=/^(\d+)(th|st|nd|rd)?/i,vb=/\d+/i,yb={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},bb={any:[/^b/i,/^(a|c)/i]},wb={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Cb={any:[/1/i,/2/i,/3/i,/4/i]},Sb={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},jb={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Nb={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},_b={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Eb={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Mb={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Tb={ordinalNumber:gb({matchPattern:xb,parsePattern:vb,valueCallback:e=>parseInt(e,10)}),era:Mn({matchPatterns:yb,defaultMatchWidth:"wide",parsePatterns:bb,defaultParseWidth:"any"}),quarter:Mn({matchPatterns:wb,defaultMatchWidth:"wide",parsePatterns:Cb,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Mn({matchPatterns:Sb,defaultMatchWidth:"wide",parsePatterns:jb,defaultParseWidth:"any"}),day:Mn({matchPatterns:Nb,defaultMatchWidth:"wide",parsePatterns:_b,defaultParseWidth:"any"}),dayPeriod:Mn({matchPatterns:Eb,defaultMatchWidth:"any",parsePatterns:Mb,defaultParseWidth:"any"})},Rd={code:"en-US",formatDistance:Jy,formatLong:rb,formatRelative:sb,localize:mb,match:Tb,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Rb(e){const t=ce(e);return Fy(t,Qy(t))+1}function kb(e){const t=ce(e),n=+Mr(t)-+zy(t);return Math.round(n/Ed)+1}function kd(e,t){var u,m,h,p;const n=ce(e),r=n.getFullYear(),o=Gn(),a=(t==null?void 0:t.firstWeekContainsDate)??((m=(u=t==null?void 0:t.locale)==null?void 0:u.options)==null?void 0:m.firstWeekContainsDate)??o.firstWeekContainsDate??((p=(h=o.locale)==null?void 0:h.options)==null?void 0:p.firstWeekContainsDate)??1,c=yt(e,0);c.setFullYear(r+1,0,a),c.setHours(0,0,0,0);const i=$n(c,t),l=yt(e,0);l.setFullYear(r,0,a),l.setHours(0,0,0,0);const d=$n(l,t);return n.getTime()>=i.getTime()?r+1:n.getTime()>=d.getTime()?r:r-1}function Pb(e,t){var i,l,d,u;const n=Gn(),r=(t==null?void 0:t.firstWeekContainsDate)??((l=(i=t==null?void 0:t.locale)==null?void 0:i.options)==null?void 0:l.firstWeekContainsDate)??n.firstWeekContainsDate??((u=(d=n.locale)==null?void 0:d.options)==null?void 0:u.firstWeekContainsDate)??1,o=kd(e,t),a=yt(e,0);return a.setFullYear(o,0,r),a.setHours(0,0,0,0),$n(a,t)}function Ab(e,t){const n=ce(e),r=+$n(n,t)-+Pb(n,t);return Math.round(r/Ed)+1}function ie(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const St={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return ie(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):ie(n+1,2)},d(e,t){return ie(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return ie(e.getHours()%12||12,t.length)},H(e,t){return ie(e.getHours(),t.length)},m(e,t){return ie(e.getMinutes(),t.length)},s(e,t){return ie(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),o=Math.trunc(r*Math.pow(10,n-3));return ie(o,t.length)}},tn={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Ka={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),o=r>0?r:1-r;return n.ordinalNumber(o,{unit:"year"})}return St.y(e,t)},Y:function(e,t,n,r){const o=kd(e,r),a=o>0?o:1-o;if(t==="YY"){const c=a%100;return ie(c,2)}return t==="Yo"?n.ordinalNumber(a,{unit:"year"}):ie(a,t.length)},R:function(e,t){const n=Md(e);return ie(n,t.length)},u:function(e,t){const n=e.getFullYear();return ie(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return ie(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return ie(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return St.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return ie(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const o=Ab(e,r);return t==="wo"?n.ordinalNumber(o,{unit:"week"}):ie(o,t.length)},I:function(e,t,n){const r=kb(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):ie(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):St.d(e,t)},D:function(e,t,n){const r=Rb(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):ie(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const o=e.getDay(),a=(o-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(a);case"ee":return ie(a,2);case"eo":return n.ordinalNumber(a,{unit:"day"});case"eee":return n.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(o,{width:"short",context:"formatting"});case"eeee":default:return n.day(o,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const o=e.getDay(),a=(o-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(a);case"cc":return ie(a,t.length);case"co":return n.ordinalNumber(a,{unit:"day"});case"ccc":return n.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(o,{width:"narrow",context:"standalone"});case"cccccc":return n.day(o,{width:"short",context:"standalone"});case"cccc":default:return n.day(o,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),o=r===0?7:r;switch(t){case"i":return String(o);case"ii":return ie(o,t.length);case"io":return n.ordinalNumber(o,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const o=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let o;switch(r===12?o=tn.noon:r===0?o=tn.midnight:o=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let o;switch(r>=17?o=tn.evening:r>=12?o=tn.afternoon:r>=4?o=tn.morning:o=tn.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return St.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):St.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):ie(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):ie(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):St.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):St.s(e,t)},S:function(e,t){return St.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return Qa(r);case"XXXX":case"XX":return $t(r);case"XXXXX":case"XXX":default:return $t(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return Qa(r);case"xxxx":case"xx":return $t(r);case"xxxxx":case"xxx":default:return $t(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Xa(r,":");case"OOOO":default:return"GMT"+$t(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Xa(r,":");case"zzzz":default:return"GMT"+$t(r,":")}},t:function(e,t,n){const r=Math.trunc(e.getTime()/1e3);return ie(r,t.length)},T:function(e,t,n){const r=e.getTime();return ie(r,t.length)}};function Xa(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),o=Math.trunc(r/60),a=r%60;return a===0?n+String(o):n+String(o)+t+ie(a,2)}function Qa(e,t){return e%60===0?(e>0?"-":"+")+ie(Math.abs(e)/60,2):$t(e,t)}function $t(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),o=ie(Math.trunc(r/60),2),a=ie(r%60,2);return n+o+t+a}const Za=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},Pd=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},Ob=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],o=n[2];if(!o)return Za(e,t);let a;switch(r){case"P":a=t.dateTime({width:"short"});break;case"PP":a=t.dateTime({width:"medium"});break;case"PPP":a=t.dateTime({width:"long"});break;case"PPPP":default:a=t.dateTime({width:"full"});break}return a.replace("{{date}}",Za(r,t)).replace("{{time}}",Pd(o,t))},Db={p:Pd,P:Ob},Ib=/^D+$/,Lb=/^Y+$/,$b=["D","DD","YY","YYYY"];function Fb(e){return Ib.test(e)}function zb(e){return Lb.test(e)}function Wb(e,t,n){const r=Bb(e,t,n);if(console.warn(r),$b.includes(e))throw new RangeError(r)}function Bb(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const qb=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ub=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Hb=/^'([^]*?)'?$/,Vb=/''/g,Gb=/[a-zA-Z]/;function Kr(e,t,n){var u,m,h,p;const r=Gn(),o=r.locale??Rd,a=r.firstWeekContainsDate??((m=(u=r.locale)==null?void 0:u.options)==null?void 0:m.firstWeekContainsDate)??1,c=r.weekStartsOn??((p=(h=r.locale)==null?void 0:h.options)==null?void 0:p.weekStartsOn)??0,i=ce(e);if(!By(i))throw new RangeError("Invalid time value");let l=t.match(Ub).map(v=>{const g=v[0];if(g==="p"||g==="P"){const x=Db[g];return x(v,o.formatLong)}return v}).join("").match(qb).map(v=>{if(v==="''")return{isToken:!1,value:"'"};const g=v[0];if(g==="'")return{isToken:!1,value:Yb(v)};if(Ka[g])return{isToken:!0,value:v};if(g.match(Gb))throw new RangeError("Format string contains an unescaped latin alphabet character `"+g+"`");return{isToken:!1,value:v}});o.localize.preprocessor&&(l=o.localize.preprocessor(i,l));const d={firstWeekContainsDate:a,weekStartsOn:c,locale:o};return l.map(v=>{if(!v.isToken)return v.value;const g=v.value;(zb(g)||Fb(g))&&Wb(g,t,String(e));const x=Ka[g[0]];return x(i,g,o.localize,d)}).join("")}function Yb(e){const t=e.match(Hb);return t?t[1].replace(Vb,"'"):e}function Kb(e,t,n){const r=Gn(),o=(n==null?void 0:n.locale)??r.locale??Rd,a=2520,c=gr(e,t);if(isNaN(c))throw new RangeError("Invalid time value");const i=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:c});let l,d;c>0?(l=ce(t),d=ce(e)):(l=ce(e),d=ce(t));const u=Xy(d,l),m=(Rr(d)-Rr(l))/1e3,h=Math.round((u-m)/60);let p;if(h<2)return n!=null&&n.includeSeconds?u<5?o.formatDistance("lessThanXSeconds",5,i):u<10?o.formatDistance("lessThanXSeconds",10,i):u<20?o.formatDistance("lessThanXSeconds",20,i):u<40?o.formatDistance("halfAMinute",0,i):u<60?o.formatDistance("lessThanXMinutes",1,i):o.formatDistance("xMinutes",1,i):h===0?o.formatDistance("lessThanXMinutes",1,i):o.formatDistance("xMinutes",h,i);if(h<45)return o.formatDistance("xMinutes",h,i);if(h<90)return o.formatDistance("aboutXHours",1,i);if(h<Ya){const v=Math.round(h/60);return o.formatDistance("aboutXHours",v,i)}else{if(h<a)return o.formatDistance("xDays",1,i);if(h<cr){const v=Math.round(h/Ya);return o.formatDistance("xDays",v,i)}else if(h<cr*2)return p=Math.round(h/cr),o.formatDistance("aboutXMonths",p,i)}if(p=Ky(d,l),p<12){const v=Math.round(h/cr);return o.formatDistance("xMonths",v,i)}else{const v=p%12,g=Math.trunc(p/12);return v<3?o.formatDistance("aboutXYears",g,i):v<9?o.formatDistance("overXYears",g,i):o.formatDistance("almostXYears",g+1,i)}}function Ad(e,t){return Kb(e,Bs(e),t)}function Xb(e){return Td(e,Bs(e))}function Qb(e,t){return Iy(e,-t)}function Zb(e){return Td(e,Qb(Bs(e),1))}var Xr="Dialog",[Od,Dd]=ke(Xr),[Jb,Je]=Od(Xr),Id=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:c=!0}=e,i=f.useRef(null),l=f.useRef(null),[d,u]=qt({prop:r,defaultProp:o??!1,onChange:a,caller:Xr});return s.jsx(Jb,{scope:t,triggerRef:i,contentRef:l,contentId:gt(),titleId:gt(),descriptionId:gt(),open:d,onOpenChange:u,onOpenToggle:f.useCallback(()=>u(m=>!m),[u]),modal:c,children:n})};Id.displayName=Xr;var Ld="DialogTrigger",$d=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Je(Ld,n),a=ae(t,o.triggerRef);return s.jsx(K.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Hs(o.open),...r,ref:a,onClick:L(e.onClick,o.onOpenToggle)})});$d.displayName=Ld;var qs="DialogPortal",[ew,Fd]=Od(qs,{forceMount:void 0}),zd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=Je(qs,t);return s.jsx(ew,{scope:t,forceMount:n,children:f.Children.map(r,c=>s.jsx(Ee,{present:n||a.open,children:s.jsx(Lr,{asChild:!0,container:o,children:c})}))})};zd.displayName=qs;var kr="DialogOverlay",Wd=f.forwardRef((e,t)=>{const n=Fd(kr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Je(kr,e.__scopeDialog);return a.modal?s.jsx(Ee,{present:r||a.open,children:s.jsx(nw,{...o,ref:t})}):null});Wd.displayName=kr;var tw=dn("DialogOverlay.RemoveScroll"),nw=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Je(kr,n);return s.jsx(Ps,{as:tw,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(K.div,{"data-state":Hs(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Bt="DialogContent",Bd=f.forwardRef((e,t)=>{const n=Fd(Bt,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Je(Bt,e.__scopeDialog);return s.jsx(Ee,{present:r||a.open,children:a.modal?s.jsx(rw,{...o,ref:t}):s.jsx(ow,{...o,ref:t})})});Bd.displayName=Bt;var rw=f.forwardRef((e,t)=>{const n=Je(Bt,e.__scopeDialog),r=f.useRef(null),o=ae(t,n.contentRef,r);return f.useEffect(()=>{const a=r.current;if(a)return cl(a)},[]),s.jsx(qd,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:L(e.onCloseAutoFocus,a=>{var c;a.preventDefault(),(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:L(e.onPointerDownOutside,a=>{const c=a.detail.originalEvent,i=c.button===0&&c.ctrlKey===!0;(c.button===2||i)&&a.preventDefault()}),onFocusOutside:L(e.onFocusOutside,a=>a.preventDefault())})}),ow=f.forwardRef((e,t)=>{const n=Je(Bt,e.__scopeDialog),r=f.useRef(!1),o=f.useRef(!1);return s.jsx(qd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var c,i;(c=e.onCloseAutoFocus)==null||c.call(e,a),a.defaultPrevented||(r.current||(i=n.triggerRef.current)==null||i.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{var l,d;(l=e.onInteractOutside)==null||l.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=a.target;((d=n.triggerRef.current)==null?void 0:d.contains(c))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),qd=f.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...c}=e,i=Je(Bt,n),l=f.useRef(null),d=ae(t,l);return Zc(),s.jsxs(s.Fragment,{children:[s.jsx(ks,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(Fn,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":Hs(i.open),...c,ref:d,onDismiss:()=>i.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(aw,{titleId:i.titleId}),s.jsx(cw,{contentRef:l,descriptionId:i.descriptionId})]})]})}),Us="DialogTitle",Ud=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Je(Us,n);return s.jsx(K.h2,{id:o.titleId,...r,ref:t})});Ud.displayName=Us;var Hd="DialogDescription",Vd=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Je(Hd,n);return s.jsx(K.p,{id:o.descriptionId,...r,ref:t})});Vd.displayName=Hd;var Gd="DialogClose",Yd=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Je(Gd,n);return s.jsx(K.button,{type:"button",...r,ref:t,onClick:L(e.onClick,()=>o.onOpenChange(!1))})});Yd.displayName=Gd;function Hs(e){return e?"open":"closed"}var Kd="DialogTitleWarning",[sw,Xd]=Bf(Kd,{contentName:Bt,titleName:Us,docsSlug:"dialog"}),aw=({titleId:e})=>{const t=Xd(Kd),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
298
|
+
`)},vv=0,Jt=[];function yv(e){var t=f.useRef([]),n=f.useRef([0,0]),r=f.useRef(),o=f.useState(vv++)[0],a=f.useState(Zc)[0],c=f.useRef(e);f.useEffect(function(){c.current=e},[e]),f.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=zx([e.lockRef.current],(e.shards||[]).map(Ha),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var i=f.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!c.current.allowPinchZoom;var C=ar(g),w=n.current,b="deltaX"in g?g.deltaX:w[0]-C[0],S="deltaY"in g?g.deltaY:w[1]-C[1],j,N=g.target,_=Math.abs(b)>Math.abs(S)?"h":"v";if("touches"in g&&_==="h"&&N.type==="range")return!1;var O=qa(_,N);if(!O)return!0;if(O?j=_:(j=_==="v"?"h":"v",O=qa(_,N)),!O)return!1;if(!r.current&&"changedTouches"in g&&(b||S)&&(r.current=j),!j)return!0;var k=r.current||j;return hv(k,x,g,k==="h"?b:S,!0)},[]),l=f.useCallback(function(g){var x=g;if(!(!Jt.length||Jt[Jt.length-1]!==a)){var C="deltaY"in x?Ua(x):ar(x),w=t.current.filter(function(j){return j.name===x.type&&(j.target===x.target||x.target===j.shadowParent)&&gv(j.delta,C)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var b=(c.current.shards||[]).map(Ha).filter(Boolean).filter(function(j){return j.contains(x.target)}),S=b.length>0?i(x,b[0]):!c.current.noIsolation;S&&x.cancelable&&x.preventDefault()}}},[]),d=f.useCallback(function(g,x,C,w){var b={name:g,delta:x,target:C,should:w,shadowParent:bv(C)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(S){return S!==b})},1)},[]),u=f.useCallback(function(g){n.current=ar(g),r.current=void 0},[]),m=f.useCallback(function(g){d(g.type,Ua(g),g.target,i(g,e.lockRef.current))},[]),h=f.useCallback(function(g){d(g.type,ar(g),g.target,i(g,e.lockRef.current))},[]);f.useEffect(function(){return Jt.push(a),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Zt),document.addEventListener("touchmove",l,Zt),document.addEventListener("touchstart",u,Zt),function(){Jt=Jt.filter(function(g){return g!==a}),document.removeEventListener("wheel",l,Zt),document.removeEventListener("touchmove",l,Zt),document.removeEventListener("touchstart",u,Zt)}},[]);var p=e.removeScrollBar,v=e.inert;return f.createElement(f.Fragment,null,v?f.createElement(a,{styles:xv(o)}):null,p?f.createElement(cv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function bv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const wv=Kx(Qc,yv);var Ms=f.forwardRef(function(e,t){return f.createElement(Ur,rt({},e,{ref:t,sideCar:wv}))});Ms.classNames=Ur.classNames;var Uo=["Enter"," "],Cv=["ArrowDown","PageUp","Home"],nl=["ArrowUp","PageDown","End"],Sv=[...Cv,...nl],jv={ltr:[...Uo,"ArrowRight"],rtl:[...Uo,"ArrowLeft"]},Nv={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Un="Menu",[In,_v,Ev]=xs(Un),[qt,Hr]=ke(Un,[Ev,Ir,qr]),Hn=Ir(),rl=qr(),[ol,Mt]=qt(Un),[Mv,Vn]=qt(Un),sl=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:a,modal:c=!0}=e,i=Hn(t),[l,d]=f.useState(null),u=f.useRef(!1),m=ge(a),h=Br(o);return f.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),s.jsx(Ai,{...i,children:s.jsx(ol,{scope:t,open:n,onOpenChange:m,content:l,onContentChange:d,children:s.jsx(Mv,{scope:t,onClose:f.useCallback(()=>m(!1),[m]),isUsingKeyboardRef:u,dir:h,modal:c,children:r})})})};sl.displayName=Un;var Tv="MenuAnchor",Ts=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Hn(n);return s.jsx(Oi,{...o,...r,ref:t})});Ts.displayName=Tv;var Rs="MenuPortal",[Rv,al]=qt(Rs,{forceMount:void 0}),il=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,a=Mt(Rs,t);return s.jsx(Rv,{scope:t,forceMount:n,children:s.jsx(Ee,{present:n||a.open,children:s.jsx(Lr,{asChild:!0,container:o,children:r})})})};il.displayName=Rs;var Ue="MenuContent",[kv,ks]=qt(Ue),cl=f.forwardRef((e,t)=>{const n=al(Ue,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=Mt(Ue,e.__scopeMenu),c=Vn(Ue,e.__scopeMenu);return s.jsx(In.Provider,{scope:e.__scopeMenu,children:s.jsx(Ee,{present:r||a.open,children:s.jsx(In.Slot,{scope:e.__scopeMenu,children:c.modal?s.jsx(Pv,{...o,ref:t}):s.jsx(Av,{...o,ref:t})})})})}),Pv=f.forwardRef((e,t)=>{const n=Mt(Ue,e.__scopeMenu),r=f.useRef(null),o=ae(t,r);return f.useEffect(()=>{const a=r.current;if(a)return Yc(a)},[]),s.jsx(Ps,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:L(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Av=f.forwardRef((e,t)=>{const n=Mt(Ue,e.__scopeMenu);return s.jsx(Ps,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Ov=ln("MenuContent.ScrollLock"),Ps=f.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:c,disableOutsidePointerEvents:i,onEntryFocus:l,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:m,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...g}=e,x=Mt(Ue,n),C=Vn(Ue,n),w=Hn(n),b=rl(n),S=_v(n),[j,N]=f.useState(null),_=f.useRef(null),O=ae(t,_,x.onContentChange),k=f.useRef(0),P=f.useRef(""),I=f.useRef(0),A=f.useRef(null),D=f.useRef("right"),E=f.useRef(0),F=v?Ms:f.Fragment,T=v?{as:Ov,allowPinchZoom:!0}:void 0,z=M=>{var J,Pe;const H=P.current+M,Z=S().filter(he=>!he.disabled),V=document.activeElement,G=(J=Z.find(he=>he.ref.current===V))==null?void 0:J.textValue,B=Z.map(he=>he.textValue),re=Vv(B,H,G),ue=(Pe=Z.find(he=>he.textValue===re))==null?void 0:Pe.ref.current;(function he(ze){P.current=ze,window.clearTimeout(k.current),ze!==""&&(k.current=window.setTimeout(()=>he(""),1e3))})(H),ue&&setTimeout(()=>ue.focus())};f.useEffect(()=>()=>window.clearTimeout(k.current),[]),$c();const $=f.useCallback(M=>{var Z,V;return D.current===((Z=A.current)==null?void 0:Z.side)&&Yv(M,(V=A.current)==null?void 0:V.area)},[]);return s.jsx(kv,{scope:n,searchRef:P,onItemEnter:f.useCallback(M=>{$(M)&&M.preventDefault()},[$]),onItemLeave:f.useCallback(M=>{var H;$(M)||((H=_.current)==null||H.focus(),N(null))},[$]),onTriggerLeave:f.useCallback(M=>{$(M)&&M.preventDefault()},[$]),pointerGraceTimerRef:I,onPointerGraceIntentChange:f.useCallback(M=>{A.current=M},[]),children:s.jsx(F,{...T,children:s.jsx(Es,{asChild:!0,trapped:o,onMountAutoFocus:L(a,M=>{var H;M.preventDefault(),(H=_.current)==null||H.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:s.jsx(Fn,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:m,onInteractOutside:h,onDismiss:p,children:s.jsx(Hc,{asChild:!0,...b,dir:C.dir,orientation:"vertical",loop:r,currentTabStopId:j,onCurrentTabStopIdChange:N,onEntryFocus:L(l,M=>{C.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(Di,{role:"menu","aria-orientation":"vertical","data-state":Nl(x.open),"data-radix-menu-content":"",dir:C.dir,...w,...g,ref:O,style:{outline:"none",...g.style},onKeyDown:L(g.onKeyDown,M=>{const Z=M.target.closest("[data-radix-menu-content]")===M.currentTarget,V=M.ctrlKey||M.altKey||M.metaKey,G=M.key.length===1;Z&&(M.key==="Tab"&&M.preventDefault(),!V&&G&&z(M.key));const B=_.current;if(M.target!==B||!Sv.includes(M.key))return;M.preventDefault();const ue=S().filter(J=>!J.disabled).map(J=>J.ref.current);nl.includes(M.key)&&ue.reverse(),Uv(ue)}),onBlur:L(e.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(k.current),P.current="")}),onPointerMove:L(e.onPointerMove,Ln(M=>{const H=M.target,Z=E.current!==M.clientX;if(M.currentTarget.contains(H)&&Z){const V=M.clientX>E.current?"right":"left";D.current=V,E.current=M.clientX}}))})})})})})})});cl.displayName=Ue;var Dv="MenuGroup",As=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(K.div,{role:"group",...r,ref:t})});As.displayName=Dv;var Iv="MenuLabel",ll=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(K.div,{...r,ref:t})});ll.displayName=Iv;var jr="MenuItem",Va="menu.itemSelect",Vr=f.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,a=f.useRef(null),c=Vn(jr,e.__scopeMenu),i=ks(jr,e.__scopeMenu),l=ae(t,a),d=f.useRef(!1),u=()=>{const m=a.current;if(!n&&m){const h=new CustomEvent(Va,{bubbles:!0,cancelable:!0});m.addEventListener(Va,p=>r==null?void 0:r(p),{once:!0}),ss(m,h),h.defaultPrevented?d.current=!1:c.onClose()}};return s.jsx(dl,{...o,ref:l,disabled:n,onClick:L(e.onClick,u),onPointerDown:m=>{var h;(h=e.onPointerDown)==null||h.call(e,m),d.current=!0},onPointerUp:L(e.onPointerUp,m=>{var h;d.current||(h=m.currentTarget)==null||h.click()}),onKeyDown:L(e.onKeyDown,m=>{const h=i.searchRef.current!=="";n||h&&m.key===" "||Uo.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})});Vr.displayName=jr;var dl=f.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...a}=e,c=ks(jr,n),i=rl(n),l=f.useRef(null),d=ae(t,l),[u,m]=f.useState(!1),[h,p]=f.useState("");return f.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[a.children]),s.jsx(In.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:s.jsx(Vc,{asChild:!0,...i,focusable:!r,children:s.jsx(K.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:d,onPointerMove:L(e.onPointerMove,Ln(v=>{r?c.onItemLeave(v):(c.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:L(e.onPointerLeave,Ln(v=>c.onItemLeave(v))),onFocus:L(e.onFocus,()=>m(!0)),onBlur:L(e.onBlur,()=>m(!1))})})})}),Lv="MenuCheckboxItem",ul=f.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return s.jsx(gl,{scope:e.__scopeMenu,checked:n,children:s.jsx(Vr,{role:"menuitemcheckbox","aria-checked":Nr(n)?"mixed":n,...o,ref:t,"data-state":Is(n),onSelect:L(o.onSelect,()=>r==null?void 0:r(Nr(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ul.displayName=Lv;var fl="MenuRadioGroup",[$v,Fv]=qt(fl,{value:void 0,onValueChange:()=>{}}),ml=f.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,a=ge(r);return s.jsx($v,{scope:e.__scopeMenu,value:n,onValueChange:a,children:s.jsx(As,{...o,ref:t})})});ml.displayName=fl;var pl="MenuRadioItem",hl=f.forwardRef((e,t)=>{const{value:n,...r}=e,o=Fv(pl,e.__scopeMenu),a=n===o.value;return s.jsx(gl,{scope:e.__scopeMenu,checked:a,children:s.jsx(Vr,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":Is(a),onSelect:L(r.onSelect,()=>{var c;return(c=o.onValueChange)==null?void 0:c.call(o,n)},{checkForDefaultPrevented:!1})})})});hl.displayName=pl;var Os="MenuItemIndicator",[gl,zv]=qt(Os,{checked:!1}),xl=f.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,a=zv(Os,n);return s.jsx(Ee,{present:r||Nr(a.checked)||a.checked===!0,children:s.jsx(K.span,{...o,ref:t,"data-state":Is(a.checked)})})});xl.displayName=Os;var Wv="MenuSeparator",vl=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(K.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});vl.displayName=Wv;var Bv="MenuArrow",yl=f.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Hn(n);return s.jsx(Ii,{...o,...r,ref:t})});yl.displayName=Bv;var Ds="MenuSub",[qv,bl]=qt(Ds),wl=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:o}=e,a=Mt(Ds,t),c=Hn(t),[i,l]=f.useState(null),[d,u]=f.useState(null),m=ge(o);return f.useEffect(()=>(a.open===!1&&m(!1),()=>m(!1)),[a.open,m]),s.jsx(Ai,{...c,children:s.jsx(ol,{scope:t,open:r,onOpenChange:m,content:d,onContentChange:u,children:s.jsx(qv,{scope:t,contentId:gt(),triggerId:gt(),trigger:i,onTriggerChange:l,children:n})})})};wl.displayName=Ds;var kn="MenuSubTrigger",Cl=f.forwardRef((e,t)=>{const n=Mt(kn,e.__scopeMenu),r=Vn(kn,e.__scopeMenu),o=bl(kn,e.__scopeMenu),a=ks(kn,e.__scopeMenu),c=f.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:l}=a,d={__scopeMenu:e.__scopeMenu},u=f.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=null},[]);return f.useEffect(()=>u,[u]),f.useEffect(()=>{const m=i.current;return()=>{window.clearTimeout(m),l(null)}},[i,l]),s.jsx(Ts,{asChild:!0,...d,children:s.jsx(dl,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Nl(n.open),...e,ref:Pr(t,o.onTriggerChange),onClick:m=>{var h;(h=e.onClick)==null||h.call(e,m),!(e.disabled||m.defaultPrevented)&&(m.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:L(e.onPointerMove,Ln(m=>{a.onItemEnter(m),!m.defaultPrevented&&!e.disabled&&!n.open&&!c.current&&(a.onPointerGraceIntentChange(null),c.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:L(e.onPointerLeave,Ln(m=>{var p,v;u();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",C=x?-5:5,w=h[x?"left":"right"],b=h[x?"right":"left"];a.onPointerGraceIntentChange({area:[{x:m.clientX+C,y:m.clientY},{x:w,y:h.top},{x:b,y:h.top},{x:b,y:h.bottom},{x:w,y:h.bottom}],side:g}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(m),m.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:L(e.onKeyDown,m=>{var p;const h=a.searchRef.current!=="";e.disabled||h&&m.key===" "||jv[r.dir].includes(m.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),m.preventDefault())})})})});Cl.displayName=kn;var Sl="MenuSubContent",jl=f.forwardRef((e,t)=>{const n=al(Ue,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=Mt(Ue,e.__scopeMenu),c=Vn(Ue,e.__scopeMenu),i=bl(Sl,e.__scopeMenu),l=f.useRef(null),d=ae(t,l);return s.jsx(In.Provider,{scope:e.__scopeMenu,children:s.jsx(Ee,{present:r||a.open,children:s.jsx(In.Slot,{scope:e.__scopeMenu,children:s.jsx(Ps,{id:i.contentId,"aria-labelledby":i.triggerId,...o,ref:d,align:"start",side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var m;c.isUsingKeyboardRef.current&&((m=l.current)==null||m.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:L(e.onFocusOutside,u=>{u.target!==i.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:L(e.onEscapeKeyDown,u=>{c.onClose(),u.preventDefault()}),onKeyDown:L(e.onKeyDown,u=>{var p;const m=u.currentTarget.contains(u.target),h=Nv[c.dir].includes(u.key);m&&h&&(a.onOpenChange(!1),(p=i.trigger)==null||p.focus(),u.preventDefault())})})})})})});jl.displayName=Sl;function Nl(e){return e?"open":"closed"}function Nr(e){return e==="indeterminate"}function Is(e){return Nr(e)?"indeterminate":e?"checked":"unchecked"}function Uv(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Hv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Vv(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let c=Hv(e,Math.max(a,0));o.length===1&&(c=c.filter(d=>d!==n));const l=c.find(d=>d.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Gv(e,t){const{x:n,y:r}=e;let o=!1;for(let a=0,c=t.length-1;a<t.length;c=a++){const i=t[a],l=t[c],d=i.x,u=i.y,m=l.x,h=l.y;u>r!=h>r&&n<(m-d)*(r-u)/(h-u)+d&&(o=!o)}return o}function Yv(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Gv(n,t)}function Ln(e){return t=>t.pointerType==="mouse"?e(t):void 0}var _l=sl,El=Ts,Ml=il,Tl=cl,Rl=As,kl=ll,Pl=Vr,Al=ul,Ol=ml,Dl=hl,Il=xl,Ll=vl,$l=yl,Kv=wl,Fl=Cl,zl=jl,Ls="ContextMenu",[Xv,n1]=ke(Ls,[Hr]),Te=Hr(),[Qv,Wl]=Xv(Ls),Bl=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:o,modal:a=!0}=e,[c,i]=f.useState(!1),l=Te(t),d=ge(r),u=f.useCallback(m=>{i(m),d(m)},[d]);return s.jsx(Qv,{scope:t,open:c,onOpenChange:u,modal:a,children:s.jsx(_l,{...l,dir:o,open:c,onOpenChange:u,modal:a,children:n})})};Bl.displayName=Ls;var ql="ContextMenuTrigger",Ul=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...o}=e,a=Wl(ql,n),c=Te(n),i=f.useRef({x:0,y:0}),l=f.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...i.current})}),d=f.useRef(0),u=f.useCallback(()=>window.clearTimeout(d.current),[]),m=h=>{i.current={x:h.clientX,y:h.clientY},a.onOpenChange(!0)};return f.useEffect(()=>u,[u]),f.useEffect(()=>void(r&&u()),[r,u]),s.jsxs(s.Fragment,{children:[s.jsx(El,{...c,virtualRef:l}),s.jsx(K.span,{"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,...o,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:L(e.onContextMenu,h=>{u(),m(h),h.preventDefault()}),onPointerDown:r?e.onPointerDown:L(e.onPointerDown,ir(h=>{u(),d.current=window.setTimeout(()=>m(h),700)})),onPointerMove:r?e.onPointerMove:L(e.onPointerMove,ir(u)),onPointerCancel:r?e.onPointerCancel:L(e.onPointerCancel,ir(u)),onPointerUp:r?e.onPointerUp:L(e.onPointerUp,ir(u))})]})});Ul.displayName=ql;var Zv="ContextMenuPortal",Hl=e=>{const{__scopeContextMenu:t,...n}=e,r=Te(t);return s.jsx(Ml,{...r,...n})};Hl.displayName=Zv;var Vl="ContextMenuContent",Gl=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Wl(Vl,n),a=Te(n),c=f.useRef(!1);return s.jsx(Tl,{...a,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:i=>{var l;(l=e.onCloseAutoFocus)==null||l.call(e,i),!i.defaultPrevented&&c.current&&i.preventDefault(),c.current=!1},onInteractOutside:i=>{var l;(l=e.onInteractOutside)==null||l.call(e,i),!i.defaultPrevented&&!o.modal&&(c.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Gl.displayName=Vl;var Jv="ContextMenuGroup",ey=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Rl,{...o,...r,ref:t})});ey.displayName=Jv;var ty="ContextMenuLabel",Yl=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(kl,{...o,...r,ref:t})});Yl.displayName=ty;var ny="ContextMenuItem",Kl=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Pl,{...o,...r,ref:t})});Kl.displayName=ny;var ry="ContextMenuCheckboxItem",Xl=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Al,{...o,...r,ref:t})});Xl.displayName=ry;var oy="ContextMenuRadioGroup",sy=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Ol,{...o,...r,ref:t})});sy.displayName=oy;var ay="ContextMenuRadioItem",Ql=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Dl,{...o,...r,ref:t})});Ql.displayName=ay;var iy="ContextMenuItemIndicator",Zl=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Il,{...o,...r,ref:t})});Zl.displayName=iy;var cy="ContextMenuSeparator",Jl=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Ll,{...o,...r,ref:t})});Jl.displayName=cy;var ly="ContextMenuArrow",dy=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx($l,{...o,...r,ref:t})});dy.displayName=ly;var uy="ContextMenuSubTrigger",ed=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(Fl,{...o,...r,ref:t})});ed.displayName=uy;var fy="ContextMenuSubContent",td=f.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=Te(n);return s.jsx(zl,{...o,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});td.displayName=fy;function ir(e){return t=>t.pointerType!=="mouse"?e(t):void 0}var my=Bl,py=Ul,hy=Hl,nd=Gl,rd=Yl,od=Kl,sd=Xl,ad=Ql,id=Zl,cd=Jl,ld=ed,dd=td;const gy=my,xy=py,vy=f.forwardRef(({className:e,inset:t,children:n,...r},o)=>s.jsxs(ld,{ref:o,className:W("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent data-[state=open]:text-accent-foreground focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...r,children:[n,s.jsx(Cs,{className:"ml-auto h-4 w-4"})]}));vy.displayName=ld.displayName;const yy=f.forwardRef(({className:e,...t},n)=>s.jsx(dd,{ref:n,className:W("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),...t}));yy.displayName=dd.displayName;const ud=f.forwardRef(({className:e,...t},n)=>s.jsx(hy,{children:s.jsx(nd,{ref:n,className:W("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 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})}));ud.displayName=nd.displayName;const hr=f.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(od,{ref:r,className:W("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...n}));hr.displayName=od.displayName;const by=f.forwardRef(({className:e,children:t,checked:n,...r},o)=>s.jsxs(sd,{ref:o,className:W("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),checked:n,...r,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(id,{children:s.jsx(zt,{className:"h-4 w-4"})})}),t]}));by.displayName=sd.displayName;const wy=f.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(ad,{ref:r,className:W("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...n,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(id,{children:s.jsx(vc,{className:"h-2 w-2 fill-current"})})}),t]}));wy.displayName=ad.displayName;const Cy=f.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(rd,{ref:r,className:W("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",e),...n}));Cy.displayName=rd.displayName;const fd=f.forwardRef(({className:e,...t},n)=>s.jsx(cd,{ref:n,className:W("-mx-1 my-1 h-px bg-border",e),...t}));fd.displayName=cd.displayName;function ce(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function yt(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function Sy(e,t){const n=ce(e);return isNaN(t)?yt(e,NaN):(n.setDate(n.getDate()+t),n)}const md=6048e5,jy=864e5,cr=43200,Ga=1440;let Ny={};function Gn(){return Ny}function $n(e,t){var i,l,d,u;const n=Gn(),r=(t==null?void 0:t.weekStartsOn)??((l=(i=t==null?void 0:t.locale)==null?void 0:i.options)==null?void 0:l.weekStartsOn)??n.weekStartsOn??((u=(d=n.locale)==null?void 0:d.options)==null?void 0:u.weekStartsOn)??0,o=ce(e),a=o.getDay(),c=(a<r?7:0)+a-r;return o.setDate(o.getDate()-c),o.setHours(0,0,0,0),o}function _r(e){return $n(e,{weekStartsOn:1})}function pd(e){const t=ce(e),n=t.getFullYear(),r=yt(e,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const o=_r(r),a=yt(e,0);a.setFullYear(n,0,4),a.setHours(0,0,0,0);const c=_r(a);return t.getTime()>=o.getTime()?n+1:t.getTime()>=c.getTime()?n:n-1}function Er(e){const t=ce(e);return t.setHours(0,0,0,0),t}function Mr(e){const t=ce(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function _y(e,t){const n=Er(e),r=Er(t),o=+n-Mr(n),a=+r-Mr(r);return Math.round((o-a)/jy)}function Ey(e){const t=pd(e),n=yt(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),_r(n)}function gr(e,t){const n=ce(e),r=ce(t),o=n.getTime()-r.getTime();return o<0?-1:o>0?1:o}function $s(e){return yt(e,Date.now())}function hd(e,t){const n=Er(e),r=Er(t);return+n==+r}function My(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Ty(e){if(!My(e)&&typeof e!="number")return!1;const t=ce(e);return!isNaN(Number(t))}function Ry(e,t){const n=ce(e),r=ce(t),o=n.getFullYear()-r.getFullYear(),a=n.getMonth()-r.getMonth();return o*12+a}function ky(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function Py(e,t){return+ce(e)-+ce(t)}function Ay(e){const t=ce(e);return t.setHours(23,59,59,999),t}function Oy(e){const t=ce(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function Dy(e){const t=ce(e);return+Ay(t)==+Oy(t)}function Iy(e,t){const n=ce(e),r=ce(t),o=gr(n,r),a=Math.abs(Ry(n,r));let c;if(a<1)c=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-o*a);let i=gr(n,r)===-o;Dy(ce(e))&&a===1&&gr(e,r)===1&&(i=!1),c=o*(a-Number(i))}return c===0?0:c}function Ly(e,t,n){const r=Py(e,t)/1e3;return ky(n==null?void 0:n.roundingMethod)(r)}function $y(e){const t=ce(e),n=yt(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}const Fy={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},zy=(e,t,n)=>{let r;const o=Fy[e];return typeof o=="string"?r=o:t===1?r=o.one:r=o.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function Co(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Wy={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},By={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},qy={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Uy={date:Co({formats:Wy,defaultWidth:"full"}),time:Co({formats:By,defaultWidth:"full"}),dateTime:Co({formats:qy,defaultWidth:"full"})},Hy={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Vy=(e,t,n,r)=>Hy[e];function En(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let o;if(r==="formatting"&&e.formattingValues){const c=e.defaultFormattingWidth||e.defaultWidth,i=n!=null&&n.width?String(n.width):c;o=e.formattingValues[i]||e.formattingValues[c]}else{const c=e.defaultWidth,i=n!=null&&n.width?String(n.width):e.defaultWidth;o=e.values[i]||e.values[c]}const a=e.argumentCallback?e.argumentCallback(t):t;return o[a]}}const Gy={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Yy={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Ky={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Xy={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Qy={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Zy={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Jy=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},eb={ordinalNumber:Jy,era:En({values:Gy,defaultWidth:"wide"}),quarter:En({values:Yy,defaultWidth:"wide",argumentCallback:e=>e-1}),month:En({values:Ky,defaultWidth:"wide"}),day:En({values:Xy,defaultWidth:"wide"}),dayPeriod:En({values:Qy,defaultWidth:"wide",formattingValues:Zy,defaultFormattingWidth:"wide"})};function Mn(e){return(t,n={})=>{const r=n.width,o=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(o);if(!a)return null;const c=a[0],i=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(i)?nb(i,m=>m.test(c)):tb(i,m=>m.test(c));let d;d=e.valueCallback?e.valueCallback(l):l,d=n.valueCallback?n.valueCallback(d):d;const u=t.slice(c.length);return{value:d,rest:u}}}function tb(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function nb(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function rb(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const o=r[0],a=t.match(e.parsePattern);if(!a)return null;let c=e.valueCallback?e.valueCallback(a[0]):a[0];c=n.valueCallback?n.valueCallback(c):c;const i=t.slice(o.length);return{value:c,rest:i}}}const ob=/^(\d+)(th|st|nd|rd)?/i,sb=/\d+/i,ab={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ib={any:[/^b/i,/^(a|c)/i]},cb={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},lb={any:[/1/i,/2/i,/3/i,/4/i]},db={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},ub={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},fb={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},mb={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},pb={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},hb={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},gb={ordinalNumber:rb({matchPattern:ob,parsePattern:sb,valueCallback:e=>parseInt(e,10)}),era:Mn({matchPatterns:ab,defaultMatchWidth:"wide",parsePatterns:ib,defaultParseWidth:"any"}),quarter:Mn({matchPatterns:cb,defaultMatchWidth:"wide",parsePatterns:lb,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Mn({matchPatterns:db,defaultMatchWidth:"wide",parsePatterns:ub,defaultParseWidth:"any"}),day:Mn({matchPatterns:fb,defaultMatchWidth:"wide",parsePatterns:mb,defaultParseWidth:"any"}),dayPeriod:Mn({matchPatterns:pb,defaultMatchWidth:"any",parsePatterns:hb,defaultParseWidth:"any"})},gd={code:"en-US",formatDistance:zy,formatLong:Uy,formatRelative:Vy,localize:eb,match:gb,options:{weekStartsOn:0,firstWeekContainsDate:1}};function xb(e){const t=ce(e);return _y(t,$y(t))+1}function vb(e){const t=ce(e),n=+_r(t)-+Ey(t);return Math.round(n/md)+1}function xd(e,t){var u,m,h,p;const n=ce(e),r=n.getFullYear(),o=Gn(),a=(t==null?void 0:t.firstWeekContainsDate)??((m=(u=t==null?void 0:t.locale)==null?void 0:u.options)==null?void 0:m.firstWeekContainsDate)??o.firstWeekContainsDate??((p=(h=o.locale)==null?void 0:h.options)==null?void 0:p.firstWeekContainsDate)??1,c=yt(e,0);c.setFullYear(r+1,0,a),c.setHours(0,0,0,0);const i=$n(c,t),l=yt(e,0);l.setFullYear(r,0,a),l.setHours(0,0,0,0);const d=$n(l,t);return n.getTime()>=i.getTime()?r+1:n.getTime()>=d.getTime()?r:r-1}function yb(e,t){var i,l,d,u;const n=Gn(),r=(t==null?void 0:t.firstWeekContainsDate)??((l=(i=t==null?void 0:t.locale)==null?void 0:i.options)==null?void 0:l.firstWeekContainsDate)??n.firstWeekContainsDate??((u=(d=n.locale)==null?void 0:d.options)==null?void 0:u.firstWeekContainsDate)??1,o=xd(e,t),a=yt(e,0);return a.setFullYear(o,0,r),a.setHours(0,0,0,0),$n(a,t)}function bb(e,t){const n=ce(e),r=+$n(n,t)-+yb(n,t);return Math.round(r/md)+1}function ie(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const St={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return ie(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):ie(n+1,2)},d(e,t){return ie(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return ie(e.getHours()%12||12,t.length)},H(e,t){return ie(e.getHours(),t.length)},m(e,t){return ie(e.getMinutes(),t.length)},s(e,t){return ie(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),o=Math.trunc(r*Math.pow(10,n-3));return ie(o,t.length)}},en={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Ya={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),o=r>0?r:1-r;return n.ordinalNumber(o,{unit:"year"})}return St.y(e,t)},Y:function(e,t,n,r){const o=xd(e,r),a=o>0?o:1-o;if(t==="YY"){const c=a%100;return ie(c,2)}return t==="Yo"?n.ordinalNumber(a,{unit:"year"}):ie(a,t.length)},R:function(e,t){const n=pd(e);return ie(n,t.length)},u:function(e,t){const n=e.getFullYear();return ie(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return ie(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return ie(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return St.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return ie(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const o=bb(e,r);return t==="wo"?n.ordinalNumber(o,{unit:"week"}):ie(o,t.length)},I:function(e,t,n){const r=vb(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):ie(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):St.d(e,t)},D:function(e,t,n){const r=xb(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):ie(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const o=e.getDay(),a=(o-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(a);case"ee":return ie(a,2);case"eo":return n.ordinalNumber(a,{unit:"day"});case"eee":return n.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(o,{width:"short",context:"formatting"});case"eeee":default:return n.day(o,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const o=e.getDay(),a=(o-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(a);case"cc":return ie(a,t.length);case"co":return n.ordinalNumber(a,{unit:"day"});case"ccc":return n.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(o,{width:"narrow",context:"standalone"});case"cccccc":return n.day(o,{width:"short",context:"standalone"});case"cccc":default:return n.day(o,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),o=r===0?7:r;switch(t){case"i":return String(o);case"ii":return ie(o,t.length);case"io":return n.ordinalNumber(o,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const o=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let o;switch(r===12?o=en.noon:r===0?o=en.midnight:o=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let o;switch(r>=17?o=en.evening:r>=12?o=en.afternoon:r>=4?o=en.morning:o=en.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return St.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):St.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):ie(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):ie(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):St.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):St.s(e,t)},S:function(e,t){return St.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return Xa(r);case"XXXX":case"XX":return $t(r);case"XXXXX":case"XXX":default:return $t(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return Xa(r);case"xxxx":case"xx":return $t(r);case"xxxxx":case"xxx":default:return $t(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Ka(r,":");case"OOOO":default:return"GMT"+$t(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Ka(r,":");case"zzzz":default:return"GMT"+$t(r,":")}},t:function(e,t,n){const r=Math.trunc(e.getTime()/1e3);return ie(r,t.length)},T:function(e,t,n){const r=e.getTime();return ie(r,t.length)}};function Ka(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),o=Math.trunc(r/60),a=r%60;return a===0?n+String(o):n+String(o)+t+ie(a,2)}function Xa(e,t){return e%60===0?(e>0?"-":"+")+ie(Math.abs(e)/60,2):$t(e,t)}function $t(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),o=ie(Math.trunc(r/60),2),a=ie(r%60,2);return n+o+t+a}const Qa=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},vd=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},wb=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],o=n[2];if(!o)return Qa(e,t);let a;switch(r){case"P":a=t.dateTime({width:"short"});break;case"PP":a=t.dateTime({width:"medium"});break;case"PPP":a=t.dateTime({width:"long"});break;case"PPPP":default:a=t.dateTime({width:"full"});break}return a.replace("{{date}}",Qa(r,t)).replace("{{time}}",vd(o,t))},Cb={p:vd,P:wb},Sb=/^D+$/,jb=/^Y+$/,Nb=["D","DD","YY","YYYY"];function _b(e){return Sb.test(e)}function Eb(e){return jb.test(e)}function Mb(e,t,n){const r=Tb(e,t,n);if(console.warn(r),Nb.includes(e))throw new RangeError(r)}function Tb(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Rb=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,kb=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Pb=/^'([^]*?)'?$/,Ab=/''/g,Ob=/[a-zA-Z]/;function Gr(e,t,n){var u,m,h,p;const r=Gn(),o=r.locale??gd,a=r.firstWeekContainsDate??((m=(u=r.locale)==null?void 0:u.options)==null?void 0:m.firstWeekContainsDate)??1,c=r.weekStartsOn??((p=(h=r.locale)==null?void 0:h.options)==null?void 0:p.weekStartsOn)??0,i=ce(e);if(!Ty(i))throw new RangeError("Invalid time value");let l=t.match(kb).map(v=>{const g=v[0];if(g==="p"||g==="P"){const x=Cb[g];return x(v,o.formatLong)}return v}).join("").match(Rb).map(v=>{if(v==="''")return{isToken:!1,value:"'"};const g=v[0];if(g==="'")return{isToken:!1,value:Db(v)};if(Ya[g])return{isToken:!0,value:v};if(g.match(Ob))throw new RangeError("Format string contains an unescaped latin alphabet character `"+g+"`");return{isToken:!1,value:v}});o.localize.preprocessor&&(l=o.localize.preprocessor(i,l));const d={firstWeekContainsDate:a,weekStartsOn:c,locale:o};return l.map(v=>{if(!v.isToken)return v.value;const g=v.value;(Eb(g)||_b(g))&&Mb(g,t,String(e));const x=Ya[g[0]];return x(i,g,o.localize,d)}).join("")}function Db(e){const t=e.match(Pb);return t?t[1].replace(Ab,"'"):e}function Ib(e,t,n){const r=Gn(),o=(n==null?void 0:n.locale)??r.locale??gd,a=2520,c=gr(e,t);if(isNaN(c))throw new RangeError("Invalid time value");const i=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:c});let l,d;c>0?(l=ce(t),d=ce(e)):(l=ce(e),d=ce(t));const u=Ly(d,l),m=(Mr(d)-Mr(l))/1e3,h=Math.round((u-m)/60);let p;if(h<2)return n!=null&&n.includeSeconds?u<5?o.formatDistance("lessThanXSeconds",5,i):u<10?o.formatDistance("lessThanXSeconds",10,i):u<20?o.formatDistance("lessThanXSeconds",20,i):u<40?o.formatDistance("halfAMinute",0,i):u<60?o.formatDistance("lessThanXMinutes",1,i):o.formatDistance("xMinutes",1,i):h===0?o.formatDistance("lessThanXMinutes",1,i):o.formatDistance("xMinutes",h,i);if(h<45)return o.formatDistance("xMinutes",h,i);if(h<90)return o.formatDistance("aboutXHours",1,i);if(h<Ga){const v=Math.round(h/60);return o.formatDistance("aboutXHours",v,i)}else{if(h<a)return o.formatDistance("xDays",1,i);if(h<cr){const v=Math.round(h/Ga);return o.formatDistance("xDays",v,i)}else if(h<cr*2)return p=Math.round(h/cr),o.formatDistance("aboutXMonths",p,i)}if(p=Iy(d,l),p<12){const v=Math.round(h/cr);return o.formatDistance("xMonths",v,i)}else{const v=p%12,g=Math.trunc(p/12);return v<3?o.formatDistance("aboutXYears",g,i):v<9?o.formatDistance("overXYears",g,i):o.formatDistance("almostXYears",g+1,i)}}function yd(e,t){return Ib(e,$s(e),t)}function Lb(e){return hd(e,$s(e))}function $b(e,t){return Sy(e,-t)}function Fb(e){return hd(e,$b($s(e),1))}var Yr="Dialog",[bd,wd]=ke(Yr),[zb,Je]=bd(Yr),Cd=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:c=!0}=e,i=f.useRef(null),l=f.useRef(null),[d,u]=Bt({prop:r,defaultProp:o??!1,onChange:a,caller:Yr});return s.jsx(zb,{scope:t,triggerRef:i,contentRef:l,contentId:gt(),titleId:gt(),descriptionId:gt(),open:d,onOpenChange:u,onOpenToggle:f.useCallback(()=>u(m=>!m),[u]),modal:c,children:n})};Cd.displayName=Yr;var Sd="DialogTrigger",jd=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Je(Sd,n),a=ae(t,o.triggerRef);return s.jsx(K.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ws(o.open),...r,ref:a,onClick:L(e.onClick,o.onOpenToggle)})});jd.displayName=Sd;var Fs="DialogPortal",[Wb,Nd]=bd(Fs,{forceMount:void 0}),_d=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=Je(Fs,t);return s.jsx(Wb,{scope:t,forceMount:n,children:f.Children.map(r,c=>s.jsx(Ee,{present:n||a.open,children:s.jsx(Lr,{asChild:!0,container:o,children:c})}))})};_d.displayName=Fs;var Tr="DialogOverlay",Ed=f.forwardRef((e,t)=>{const n=Nd(Tr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Je(Tr,e.__scopeDialog);return a.modal?s.jsx(Ee,{present:r||a.open,children:s.jsx(qb,{...o,ref:t})}):null});Ed.displayName=Tr;var Bb=ln("DialogOverlay.RemoveScroll"),qb=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Je(Tr,n);return s.jsx(Ms,{as:Bb,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(K.div,{"data-state":Ws(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Wt="DialogContent",Md=f.forwardRef((e,t)=>{const n=Nd(Wt,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Je(Wt,e.__scopeDialog);return s.jsx(Ee,{present:r||a.open,children:a.modal?s.jsx(Ub,{...o,ref:t}):s.jsx(Hb,{...o,ref:t})})});Md.displayName=Wt;var Ub=f.forwardRef((e,t)=>{const n=Je(Wt,e.__scopeDialog),r=f.useRef(null),o=ae(t,n.contentRef,r);return f.useEffect(()=>{const a=r.current;if(a)return Yc(a)},[]),s.jsx(Td,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:L(e.onCloseAutoFocus,a=>{var c;a.preventDefault(),(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:L(e.onPointerDownOutside,a=>{const c=a.detail.originalEvent,i=c.button===0&&c.ctrlKey===!0;(c.button===2||i)&&a.preventDefault()}),onFocusOutside:L(e.onFocusOutside,a=>a.preventDefault())})}),Hb=f.forwardRef((e,t)=>{const n=Je(Wt,e.__scopeDialog),r=f.useRef(!1),o=f.useRef(!1);return s.jsx(Td,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var c,i;(c=e.onCloseAutoFocus)==null||c.call(e,a),a.defaultPrevented||(r.current||(i=n.triggerRef.current)==null||i.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{var l,d;(l=e.onInteractOutside)==null||l.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=a.target;((d=n.triggerRef.current)==null?void 0:d.contains(c))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),Td=f.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...c}=e,i=Je(Wt,n),l=f.useRef(null),d=ae(t,l);return $c(),s.jsxs(s.Fragment,{children:[s.jsx(Es,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(Fn,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":Ws(i.open),...c,ref:d,onDismiss:()=>i.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(Gb,{titleId:i.titleId}),s.jsx(Kb,{contentRef:l,descriptionId:i.descriptionId})]})]})}),zs="DialogTitle",Rd=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Je(zs,n);return s.jsx(K.h2,{id:o.titleId,...r,ref:t})});Rd.displayName=zs;var kd="DialogDescription",Pd=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Je(kd,n);return s.jsx(K.p,{id:o.descriptionId,...r,ref:t})});Pd.displayName=kd;var Ad="DialogClose",Od=f.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Je(Ad,n);return s.jsx(K.button,{type:"button",...r,ref:t,onClick:L(e.onClick,()=>o.onOpenChange(!1))})});Od.displayName=Ad;function Ws(e){return e?"open":"closed"}var Dd="DialogTitleWarning",[Vb,Id]=qf(Dd,{contentName:Wt,titleName:zs,docsSlug:"dialog"}),Gb=({titleId:e})=>{const t=Id(Dd),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
299
299
|
|
|
300
300
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
301
301
|
|
|
302
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return f.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},iw="DialogDescriptionWarning",cw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Xd(iw).contentName}}.`;return f.useEffect(()=>{var a;const o=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Qd=Id,lw=$d,Zd=zd,Vs=Wd,Gs=Bd,Ys=Ud,Ks=Vd,Xs=Yd;const Ht=Qd,dw=Zd,Jd=f.forwardRef(({className:e,...t},n)=>s.jsx(Vs,{ref:n,className:W("fixed inset-0 z-[1050] 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}));Jd.displayName=Vs.displayName;const Tt=f.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(dw,{children:[s.jsx(Jd,{}),s.jsxs(Gs,{ref:r,className:W("fixed left-[50%] top-[50%] z-[1050] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,s.jsxs(Xs,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(vn,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Tt.displayName=Gs.displayName;const yn=({className:e,...t})=>s.jsx("div",{className:W("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});yn.displayName="DialogHeader";const eu=({className:e,...t})=>s.jsx("div",{className:W("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});eu.displayName="DialogFooter";const Vt=f.forwardRef(({className:e,...t},n)=>s.jsx(Ys,{ref:n,className:W("text-lg font-semibold leading-none tracking-tight",e),...t}));Vt.displayName=Ys.displayName;const tu=f.forwardRef(({className:e,...t},n)=>s.jsx(Ks,{ref:n,className:W("text-sm text-muted-foreground",e),...t}));tu.displayName=Ks.displayName;const nu=()=>{const{user:e}=ye(),t=ve();return oe.useQuery({queryKey:me.contacts(e==null?void 0:e.id),queryFn:async()=>{if(!e)return[];const{data:n,error:r}=await t.from("contacts").select("id, contact_id").eq("user_id",e.id);if(r)throw r;if(!n||n.length===0)return[];const o=n.map(i=>i.contact_id),{data:a}=await t.from("profiles").select("id, display_name, avatar_url, is_online, last_seen").in("id",o),c=Object.fromEntries((a??[]).map(i=>[i.id,i]));return n.map(i=>{const l=c[i.contact_id];return l?{id:i.id,contact_id:i.contact_id,profile:l}:null}).filter(i=>i!==null)},enabled:!!e})},uw=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient();return oe.useMutation({mutationFn:async r=>{if(!e)throw new Error("Not authenticated");const{error:o}=await t.from("contacts").insert({user_id:e.id,contact_id:r});if(o)throw o},onSuccess:()=>n.invalidateQueries({queryKey:me.contacts(e==null?void 0:e.id)})})},fw=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient();return oe.useMutation({mutationFn:async r=>{const{error:o}=await t.from("contacts").delete().eq("id",r);if(o)throw o},onSuccess:()=>n.invalidateQueries({queryKey:me.contacts(e==null?void 0:e.id)})})},ru=e=>{const{user:t}=ye(),n=ve();return oe.useQuery({queryKey:me.searchUsers(e),queryFn:async()=>{if(!t||e.length<2)return[];const{data:r,error:o}=await n.from("profiles").select("id, display_name, avatar_url, is_online").neq("id",t.id).ilike("display_name",`%${e}%`).limit(20);if(o)throw o;return r??[]},enabled:!!t&&e.length>=2})};var Qr="Tabs",[mw,r1]=ke(Qr,[Hr]),ou=Hr(),[pw,Qs]=mw(Qr),su=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:a,orientation:c="horizontal",dir:i,activationMode:l="automatic",...d}=e,u=Br(i),[m,h]=qt({prop:r,onChange:o,defaultProp:a??"",caller:Qr});return s.jsx(pw,{scope:n,baseId:gt(),value:m,onValueChange:h,orientation:c,dir:u,activationMode:l,children:s.jsx(K.div,{dir:u,"data-orientation":c,...d,ref:t})})});su.displayName=Qr;var au="TabsList",iu=f.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,a=Qs(au,n),c=ou(n);return s.jsx(sl,{asChild:!0,...c,orientation:a.orientation,dir:a.dir,loop:r,children:s.jsx(K.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});iu.displayName=au;var cu="TabsTrigger",lu=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...a}=e,c=Qs(cu,n),i=ou(n),l=fu(c.baseId,r),d=mu(c.baseId,r),u=r===c.value;return s.jsx(al,{asChild:!0,...i,focusable:!o,active:u,children:s.jsx(K.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":d,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l,...a,ref:t,onMouseDown:L(e.onMouseDown,m=>{!o&&m.button===0&&m.ctrlKey===!1?c.onValueChange(r):m.preventDefault()}),onKeyDown:L(e.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&c.onValueChange(r)}),onFocus:L(e.onFocus,()=>{const m=c.activationMode!=="manual";!u&&!o&&m&&c.onValueChange(r)})})})});lu.displayName=cu;var du="TabsContent",uu=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:a,...c}=e,i=Qs(du,n),l=fu(i.baseId,r),d=mu(i.baseId,r),u=r===i.value,m=f.useRef(u);return f.useEffect(()=>{const h=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(h)},[]),s.jsx(Ee,{present:o||u,children:({present:h})=>s.jsx(K.div,{"data-state":u?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:d,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:m.current?"0s":void 0},children:h&&a})})});uu.displayName=du;function fu(e,t){return`${e}-trigger-${t}`}function mu(e,t){return`${e}-content-${t}`}var hw=su,pu=iu,hu=lu,gu=uu;const gw=hw,xu=f.forwardRef(({className:e,...t},n)=>s.jsx(pu,{ref:n,className:W("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));xu.displayName=pu.displayName;const Ho=f.forwardRef(({className:e,...t},n)=>s.jsx(hu,{ref:n,className:W("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",e),...t}));Ho.displayName=hu.displayName;const Vo=f.forwardRef(({className:e,...t},n)=>s.jsx(gu,{ref:n,className:W("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Vo.displayName=gu.displayName;const xw=({open:e,onOpenChange:t,onStartChat:n})=>{const[r,o]=y.useState(""),{data:a,isLoading:c}=nu(),{data:i}=ru(r),l=uw(),d=fw(),u=ix(),{toast:m}=xn(),h=async g=>{try{await l.mutateAsync(g),m({title:"Contact added"})}catch{m({title:"Error",description:"Contact already exists",variant:"destructive"})}},p=async g=>{try{const x=await u.mutateAsync(g);t(!1),n(x)}catch(x){console.error("handleStartChat error:",x instanceof Error?x.message:String(x)),m({title:"Error creating chat",description:(x==null?void 0:x.message)||"Unknown error",variant:"destructive"})}},v=new Set(a==null?void 0:a.map(g=>g.contact_id));return s.jsx(Ht,{open:e,onOpenChange:t,children:s.jsxs(Tt,{className:"max-w-md",children:[s.jsx(yn,{children:s.jsx(Vt,{children:"Contacts"})}),s.jsxs(gw,{defaultValue:"contacts",children:[s.jsxs(xu,{className:"w-full",children:[s.jsx(Ho,{value:"contacts",className:"flex-1",children:"My Contacts"}),s.jsx(Ho,{value:"search",className:"flex-1",children:"Search"})]}),s.jsx(Vo,{value:"contacts",children:s.jsxs(Wt,{className:"h-[350px]",children:[c&&s.jsx("p",{className:"p-4 text-center text-muted-foreground",children:"Loading..."}),(a==null?void 0:a.length)===0&&s.jsx("p",{className:"p-4 text-center text-muted-foreground",children:"No contacts"}),a==null?void 0:a.map(g=>s.jsxs("div",{className:"flex items-center gap-3 px-2 py-2 hover:bg-accent rounded-lg",children:[s.jsxs(Ce,{children:[s.jsx(_e,{src:g.profile.avatar_url??void 0}),s.jsx(Se,{children:g.profile.display_name.slice(0,2).toUpperCase()})]}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"font-medium",children:g.profile.display_name}),s.jsx("p",{className:"text-xs text-muted-foreground",children:g.profile.is_online?"online":"offline"})]}),s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>p(g.contact_id),children:s.jsx(Cr,{className:"h-4 w-4"})}),s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>d.mutate(g.id),children:s.jsx(Bn,{className:"h-4 w-4 text-destructive"})})]},g.id))]})}),s.jsxs(Vo,{value:"search",children:[s.jsxs("div",{className:"relative mb-3",children:[s.jsx(Dn,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(qe,{placeholder:"Search by name...",value:r,onChange:g=>o(g.target.value),className:"pl-9"})]}),s.jsxs(Wt,{className:"h-[300px]",children:[i==null?void 0:i.map(g=>s.jsxs("div",{className:"flex items-center gap-3 px-2 py-2 hover:bg-accent rounded-lg",children:[s.jsxs(Ce,{children:[s.jsx(_e,{src:g.avatar_url??void 0}),s.jsx(Se,{children:g.display_name.slice(0,2).toUpperCase()})]}),s.jsx("div",{className:"flex-1",children:s.jsx("p",{className:"font-medium",children:g.display_name})}),!v.has(g.id)&&s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>h(g.id),children:s.jsx(Cc,{className:"h-4 w-4"})}),s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>p(g.id),children:s.jsx(Cr,{className:"h-4 w-4"})})]},g.id)),r.length>=2&&(i==null?void 0:i.length)===0&&s.jsx("p",{className:"p-4 text-center text-muted-foreground",children:"No one found"})]})]})]})]})})};function vw(e){const t=f.useRef({value:e,previous:e});return f.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Zr="Checkbox",[yw,o1]=ke(Zr),[bw,Zs]=yw(Zr);function ww(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:o,disabled:a,form:c,name:i,onCheckedChange:l,required:d,value:u="on",internal_do_not_use_render:m}=e,[h,p]=qt({prop:n,defaultProp:o??!1,onChange:l,caller:Zr}),[v,g]=f.useState(null),[x,C]=f.useState(null),w=f.useRef(!1),b=v?!!c||!!v.closest("form"):!0,S={checked:h,disabled:a,setChecked:p,control:v,setControl:g,name:i,form:c,value:u,hasConsumerStoppedPropagationRef:w,required:d,defaultChecked:Nt(o)?!1:o,isFormControl:b,bubbleInput:x,setBubbleInput:C};return s.jsx(bw,{scope:t,...S,children:Cw(m)?m(S):r})}var vu="CheckboxTrigger",yu=f.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},o)=>{const{control:a,value:c,disabled:i,checked:l,required:d,setControl:u,setChecked:m,hasConsumerStoppedPropagationRef:h,isFormControl:p,bubbleInput:v}=Zs(vu,e),g=ae(o,u),x=f.useRef(l);return f.useEffect(()=>{const C=a==null?void 0:a.form;if(C){const w=()=>m(x.current);return C.addEventListener("reset",w),()=>C.removeEventListener("reset",w)}},[a,m]),s.jsx(K.button,{type:"button",role:"checkbox","aria-checked":Nt(l)?"mixed":l,"aria-required":d,"data-state":ju(l),"data-disabled":i?"":void 0,disabled:i,value:c,...r,ref:g,onKeyDown:L(t,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:L(n,C=>{m(w=>Nt(w)?!0:!w),v&&p&&(h.current=C.isPropagationStopped(),h.current||C.stopPropagation())})})});yu.displayName=vu;var Js=f.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:a,required:c,disabled:i,value:l,onCheckedChange:d,form:u,...m}=e;return s.jsx(ww,{__scopeCheckbox:n,checked:o,defaultChecked:a,disabled:i,required:c,onCheckedChange:d,name:r,form:u,value:l,internal_do_not_use_render:({isFormControl:h})=>s.jsxs(s.Fragment,{children:[s.jsx(yu,{...m,ref:t,__scopeCheckbox:n}),h&&s.jsx(Su,{__scopeCheckbox:n})]})})});Js.displayName=Zr;var bu="CheckboxIndicator",wu=f.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,a=Zs(bu,n);return s.jsx(Ee,{present:r||Nt(a.checked)||a.checked===!0,children:s.jsx(K.span,{"data-state":ju(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});wu.displayName=bu;var Cu="CheckboxBubbleInput",Su=f.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:o,checked:a,defaultChecked:c,required:i,disabled:l,name:d,value:u,form:m,bubbleInput:h,setBubbleInput:p}=Zs(Cu,e),v=ae(n,p),g=vw(a),x=Si(r);f.useEffect(()=>{const w=h;if(!w)return;const b=window.HTMLInputElement.prototype,j=Object.getOwnPropertyDescriptor(b,"checked").set,N=!o.current;if(g!==a&&j){const _=new Event("click",{bubbles:N});w.indeterminate=Nt(a),j.call(w,Nt(a)?!1:a),w.dispatchEvent(_)}},[h,g,a,o]);const C=f.useRef(Nt(a)?!1:a);return s.jsx(K.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??C.current,required:i,disabled:l,name:d,value:u,form:m,...t,tabIndex:-1,ref:v,style:{...t.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Su.displayName=Cu;function Cw(e){return typeof e=="function"}function Nt(e){return e==="indeterminate"}function ju(e){return Nt(e)?"indeterminate":e?"checked":"unchecked"}const Nu=f.forwardRef(({className:e,...t},n)=>s.jsx(Js,{ref:n,className:W("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:s.jsx(wu,{className:W("flex items-center justify-center text-current"),children:s.jsx(zt,{className:"h-4 w-4"})})}));Nu.displayName=Js.displayName;const Sw=({open:e,onOpenChange:t,onCreated:n})=>{const[r,o]=y.useState(""),[a,c]=y.useState(""),[i,l]=y.useState(new Set),[d,u]=y.useState(new Map),{data:m}=nu(),{data:h}=ru(a),p=cx(),{toast:v}=xn(),g=new Set(m==null?void 0:m.map(S=>S.contact_id)),x=new Map;m==null||m.forEach(S=>x.set(S.contact_id,{id:S.contact_id,display_name:S.profile.display_name,avatar_url:S.profile.avatar_url})),a.length>=2&&(h==null||h.forEach(S=>{x.has(S.id)||x.set(S.id,{id:S.id,display_name:S.display_name,avatar_url:S.avatar_url})}));const C=a?Array.from(x.values()).filter(S=>S.display_name.toLowerCase().includes(a.toLowerCase())):Array.from(x.values()),w=(S,j)=>{const N=new Set(i),_=new Map(d);N.has(S)?(N.delete(S),_.delete(S)):(N.add(S),_.set(S,j)),l(N),u(_)},b=async()=>{if(!r.trim()){v({title:"Enter a group name",variant:"destructive"});return}if(i.size===0){v({title:"Select at least one member",variant:"destructive"});return}const S=await p.mutateAsync({name:r,memberIds:Array.from(i)});t(!1),n(S),o(""),c(""),l(new Set),u(new Map)};return s.jsx(Ht,{open:e,onOpenChange:t,children:s.jsxs(Tt,{className:"max-w-md",children:[s.jsx(yn,{children:s.jsx(Vt,{className:"text-foreground",children:"New Group"})}),s.jsx(qe,{placeholder:"Group name",value:r,onChange:S=>o(S.target.value),className:"mb-3"}),s.jsxs("div",{className:"relative mb-2",children:[s.jsx(Dn,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(qe,{placeholder:"Search members...",value:a,onChange:S=>c(S.target.value),className:"pl-9"})]}),s.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Select members:"}),s.jsxs(Wt,{className:"h-[260px]",children:[C.map(S=>s.jsxs("label",{className:"flex cursor-pointer items-center gap-3 px-2 py-2 hover:bg-accent rounded-lg",children:[s.jsx(Nu,{checked:i.has(S.id),onCheckedChange:()=>w(S.id,{display_name:S.display_name,avatar_url:S.avatar_url})}),s.jsxs(Ce,{className:"h-8 w-8",children:[s.jsx(_e,{src:S.avatar_url??void 0}),s.jsx(Se,{children:S.display_name.slice(0,2).toUpperCase()})]}),s.jsx("span",{className:"font-medium",children:S.display_name}),!g.has(S.id)&&s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"not a contact"})]},S.id)),C.length===0&&a.length>=2&&s.jsx("p",{className:"p-4 text-center text-muted-foreground",children:"No users found"}),C.length===0&&a.length<2&&s.jsx("p",{className:"p-4 text-center text-muted-foreground",children:"Search to find members"})]}),s.jsx(ne,{onClick:b,disabled:p.isPending,className:"w-full mt-2",children:p.isPending?"Creating...":`Create group (${i.size})`})]})})},_u=f.forwardRef(({className:e,...t},n)=>s.jsx("textarea",{className:W("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));_u.displayName="Textarea";var jw="Label",Eu=f.forwardRef((e,t)=>s.jsx(K.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())}}));Eu.displayName=jw;var Mu=Eu;const Nw=ws("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),an=f.forwardRef(({className:e,...t},n)=>s.jsx(Mu,{ref:n,className:W(Nw(),e),...t}));an.displayName=Mu.displayName;const Tu=({open:e,onOpenChange:t,userId:n})=>{const r=ve(),{user:o}=ye(),a=oe.useQueryClient(),{toast:c}=xn(),i=(o==null?void 0:o.id)===n,[l,d]=y.useState(!1),[u,m]=y.useState(""),[h,p]=y.useState(""),[v,g]=y.useState(!1),[x,C]=y.useState(!1),w=y.useRef(null),{data:b,isLoading:S}=oe.useQuery({queryKey:["profile",n],queryFn:async()=>{const{data:P,error:I}=await r.from("profiles").select("*").eq("id",n).single();if(I)throw I;return P},enabled:e&&!!n}),j=()=>{b&&(m(b.display_name),p(b.bio??""),d(!0))},N=()=>{d(!1)},_=async()=>{if(o){C(!0);try{const{error:P}=await r.from("profiles").update({display_name:u.trim()||(b==null?void 0:b.display_name),bio:h}).eq("id",o.id);if(P)throw P;a.invalidateQueries({queryKey:["profile"]}),a.invalidateQueries({queryKey:["conversations"]}),d(!1),c({title:"Profile updated"})}catch(P){c({title:"Error",description:P.message,variant:"destructive"})}finally{C(!1)}}},O=async P=>{var F;const I=(F=P.target.files)==null?void 0:F[0];if(!I||!o)return;const A={"image/jpeg":"jpg","image/png":"png","image/gif":"gif","image/webp":"webp"};if(!A[I.type]){c({title:"Invalid file type",description:"Only JPEG, PNG, GIF, and WebP are allowed.",variant:"destructive"}),P.target.value="";return}const D=A[I.type],E=`${o.id}/avatar.${D}`;g(!0);try{await r.storage.from("avatars").remove([E]);const{error:T}=await r.storage.from("avatars").upload(E,I,{upsert:!0});if(T)throw T;const{data:z}=r.storage.from("avatars").getPublicUrl(E),{error:$}=await r.from("profiles").update({avatar_url:z.publicUrl}).eq("id",o.id);if($)throw $;a.invalidateQueries({queryKey:["profile"]}),a.invalidateQueries({queryKey:["conversations"]}),c({title:"Avatar updated"})}catch(T){c({title:"Upload error",description:T.message,variant:"destructive"})}finally{g(!1),P.target.value=""}},k=((b==null?void 0:b.display_name)??"?").split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2);return s.jsx(Ht,{open:e,onOpenChange:t,children:s.jsxs(Tt,{className:"sm:max-w-[360px] p-0 overflow-hidden",children:[s.jsx(Vt,{className:"sr-only",children:"User profile"}),s.jsxs("div",{className:"relative flex flex-col items-center pt-8 pb-4 bg-primary/10",children:[s.jsxs("div",{className:"relative group",children:[s.jsxs(Ce,{className:"h-24 w-24 border-4 border-background shadow-lg",children:[s.jsx(_e,{src:(b==null?void 0:b.avatar_url)??void 0}),s.jsx(Se,{className:"text-2xl font-bold",children:k})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:w,type:"file",accept:"image/*",className:"hidden",onChange:O}),s.jsx("button",{onClick:()=>{var P;return(P=w.current)==null?void 0:P.click()},disabled:v,className:"absolute inset-0 flex items-center justify-center rounded-full bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:v?s.jsx(on,{className:"h-6 w-6 text-white animate-spin"}):s.jsx(ig,{className:"h-6 w-6 text-white"})})]})]}),(b==null?void 0:b.is_online)&&s.jsx("span",{className:"absolute top-[88px] right-[calc(50%-28px)] h-4 w-4 rounded-full border-2 border-background bg-online"})]}),s.jsx("div",{className:"px-6 pb-6 space-y-4",children:S?s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(on,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):l?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(an,{htmlFor:"displayName",children:"Display name"}),s.jsx(qe,{id:"displayName",value:u,onChange:P=>m(P.target.value),placeholder:"Your name",maxLength:100})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(an,{htmlFor:"bio",children:"Bio"}),s.jsx(_u,{id:"bio",value:h,onChange:P=>p(P.target.value),placeholder:"Tell about yourself...",rows:3,maxLength:500})]}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(ne,{variant:"ghost",size:"sm",onClick:N,disabled:x,children:[s.jsx(vn,{className:"h-4 w-4 mr-1"})," Cancel"]}),s.jsxs(ne,{size:"sm",onClick:_,disabled:x,children:[x?s.jsx(on,{className:"h-4 w-4 mr-1 animate-spin"}):s.jsx(zt,{className:"h-4 w-4 mr-1"}),"Save"]})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"text-center",children:[s.jsx("h3",{className:"text-lg font-semibold",children:b==null?void 0:b.display_name}),s.jsx("p",{className:"text-sm text-muted-foreground",children:b!=null&&b.is_online?"online":b!=null&&b.last_seen?`last seen ${new Date(b.last_seen).toLocaleDateString()}`:"offline"})]}),(b==null?void 0:b.bio)&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Bio"}),s.jsx("p",{className:"text-sm",children:b.bio})]}),i&&s.jsxs(ne,{variant:"outline",size:"sm",className:"w-full",onClick:j,children:[s.jsx(Sr,{className:"h-4 w-4 mr-2"})," Edit profile"]})]})})]})})},_w=({activeConversationId:e,onSelectConversation:t,onUnreadCountChange:n})=>{const{data:r,isLoading:o}=js(),{user:a,signOut:c,authMode:i}=ye(),l=rs(),{theme:d,setTheme:u,resolved:m}=zf(),[h,p]=y.useState(""),[v,g]=y.useState(!1),[x,C]=y.useState(!1),[w,b]=y.useState(!1),{data:S}=lx(),[j,N]=y.useState(new Set),[_,O]=y.useState(new Set),k=D=>{N(E=>{const F=new Set(E);return F.has(D)?(F.delete(D),Rn("Unpinned")):(F.add(D),Rn("Pinned")),F})},P=D=>{O(E=>{const F=new Set(E);return F.has(D)?(F.delete(D),Rn("Unmuted")):(F.add(D),Rn("Muted")),F})},I=y.useMemo(()=>(r==null?void 0:r.reduce((D,E)=>D+E.unread_count,0))??0,[r]);y.useEffect(()=>{n==null||n(I)},[I,n]);const A=y.useMemo(()=>{if(!r)return[];let D=r;if(l.showGroups||(D=D.filter(E=>E.type!=="group")),h){const E=h.toLowerCase();D=D.filter(F=>Ru(F,(a==null?void 0:a.id)??"").toLowerCase().includes(E))}return[...D].sort((E,F)=>{const T=j.has(E.id)?0:1,z=j.has(F.id)?0:1;return T-z})},[r,h,a,j]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Ce,{className:"h-8 w-8 cursor-pointer",onClick:()=>b(!0),children:[s.jsx(_e,{src:(S==null?void 0:S.avatar_url)??void 0}),s.jsx(Se,{className:"text-xs",children:((S==null?void 0:S.display_name)??"?").slice(0,2).toUpperCase()})]}),s.jsx("h1",{className:"text-lg font-bold text-foreground",children:"Chats"}),I>0&&s.jsx("span",{className:"flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1.5 text-xs font-medium text-primary-foreground",children:I})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>g(!0),children:s.jsx(Cc,{className:"h-5 w-5"})}),l.showGroups&&s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>C(!0),children:s.jsx(jg,{className:"h-5 w-5"})}),s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>u(m==="dark"?"light":"dark"),children:m==="dark"?s.jsx(Fo,{className:"h-5 w-5"}):s.jsx($o,{className:"h-5 w-5"})}),i==="built-in"&&s.jsx(ne,{variant:"ghost",size:"icon",onClick:c,children:s.jsx(Ss,{className:"h-5 w-5"})})]})]}),s.jsx("div",{className:"px-3 py-2",children:s.jsxs("div",{className:"relative",children:[s.jsx(Dn,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(qe,{placeholder:"Search chats...",value:h,onChange:D=>p(D.target.value),className:"pl-9"})]})}),s.jsxs(Wt,{className:"flex-1",children:[o&&s.jsx("div",{className:"p-4 text-center text-muted-foreground",children:"Loading..."}),!o&&A.length===0&&s.jsx("div",{className:"p-4 text-center text-muted-foreground",children:h?"Nothing found":"No chats yet. Add a contact to get started!"}),A.map(D=>s.jsx(Tw,{conversation:D,isActive:D.id===e,currentUserId:(a==null?void 0:a.id)??"",onClick:()=>t(D.id),pinned:j.has(D.id),muted:_.has(D.id),onTogglePin:()=>k(D.id),onToggleMute:()=>P(D.id)},D.id))]}),s.jsx(xw,{open:v,onOpenChange:g,onStartChat:t}),s.jsx(Sw,{open:x,onOpenChange:C,onCreated:t}),a&&s.jsx(Tu,{open:w,onOpenChange:b,userId:a.id})]})};function Ru(e,t){var r;if(e.type==="group")return e.name||"Group";const n=e.members.find(o=>o.user_id!==t);return((r=n==null?void 0:n.profile)==null?void 0:r.display_name)||"Chat"}function Ew(e,t){var r;if(e.type==="group")return e.avatar_url;const n=e.members.find(o=>o.user_id!==t);return(r=n==null?void 0:n.profile)==null?void 0:r.avatar_url}function Mw(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}const Tw=({conversation:e,isActive:t,currentUserId:n,onClick:r,pinned:o,muted:a,onTogglePin:c,onToggleMute:i})=>{var g;const l=Ru(e,n),d=Ew(e,n),u=e.members.find(x=>x.user_id!==n),h=rs().showOnlineStatus&&e.type==="private"&&((g=u==null?void 0:u.profile)==null?void 0:g.is_online),p=e.last_message?e.last_message.type!=="text"?`📎 ${e.last_message.type}`:(e.last_message.content||"").slice(0,50):"No messages",v=e.last_message?Ad(new Date(e.last_message.created_at),{addSuffix:!1}):"";return s.jsxs(Ty,{children:[s.jsx(Ry,{asChild:!0,children:s.jsxs("button",{onClick:r,className:`flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-accent ${t?"bg-chat-active text-chat-active-foreground hover:bg-chat-active":""}`,children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Ce,{className:"h-12 w-12",children:[s.jsx(_e,{src:d??void 0}),s.jsx(Se,{children:Mw(l)})]}),h&&s.jsx("span",{className:"absolute bottom-0 right-0 h-3.5 w-3.5 rounded-full border-2 border-background bg-online"})]}),s.jsxs("div",{className:"flex-1 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[s.jsx("span",{className:"font-semibold truncate",children:l}),o&&s.jsx(Ta,{className:"h-3 w-3 text-muted-foreground rotate-45"}),a&&s.jsx(Lo,{className:"h-3 w-3 text-muted-foreground"})]}),s.jsx("span",{className:`text-xs whitespace-nowrap ${t?"text-chat-active-foreground/70":"text-muted-foreground"}`,children:v})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:`text-sm truncate ${t?"text-chat-active-foreground/70":"text-muted-foreground"}`,children:p}),e.unread_count>0&&!t&&s.jsx("span",{className:"ml-2 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1.5 text-xs font-medium text-primary-foreground",children:e.unread_count})]})]})]})}),s.jsxs(Nd,{className:"w-52",children:[s.jsxs(hr,{onClick:c,children:[s.jsx(Ta,{className:"mr-2 h-4 w-4"}),o?"Unpin":"Pin"]}),s.jsxs(hr,{onClick:i,children:[a?s.jsx(ag,{className:"mr-2 h-4 w-4"}):s.jsx(Lo,{className:"mr-2 h-4 w-4"}),a?"Unmute":"Mute"]}),s.jsx(_d,{}),s.jsxs(hr,{className:"text-destructive focus:text-destructive",onClick:()=>Rn("Left chat"),children:[s.jsx(ug,{className:"mr-2 h-4 w-4"}),e.type==="group"?"Leave group":"Delete chat"]})]})]})},So=30,Rw=e=>{const{user:t}=ye(),n=ve(),r=oe.useQueryClient(),o=oe.useInfiniteQuery({queryKey:me.messages(e),queryFn:async({pageParam:c=0})=>{if(!e||!t)return[];const i=c,l=c+So-1,{data:d,error:u}=await n.from("messages").select("*").eq("conversation_id",e).eq("is_deleted",!1).order("created_at",{ascending:!1}).range(i,l);if(u)throw u;if(!d||d.length===0)return[];const m=[...new Set(d.map(j=>j.sender_id))],{data:h}=await n.from("profiles").select("id, display_name, avatar_url").in("id",m),p=Object.fromEntries((h??[]).map(j=>[j.id,j])),v=[...new Set(d.map(j=>j.reply_to_id).filter(j=>!!j))],g={};if(v.length>0){const{data:j}=await n.from("messages").select("id, content, sender_id").in("id",v);(j??[]).forEach(N=>{g[N.id]={content:N.content,sender_id:N.sender_id}})}const x=[...new Set(d.map(j=>j.forwarded_from_id).filter(j=>!!j))],C={};if(x.length>0){const{data:j}=await n.from("messages").select("id, sender_id").in("id",x),N=[...new Set((j??[]).map(_=>_.sender_id))];if(N.length>0){const{data:_}=await n.from("profiles").select("id, display_name").in("id",N),O=Object.fromEntries((_??[]).map(k=>[k.id,k.display_name]));(j??[]).forEach(k=>{C[k.id]={display_name:O[k.sender_id]??"Unknown",sender_id:k.sender_id}})}}const w=d.map(j=>j.id),b={};w.forEach(j=>{b[j]=[]});const{data:S}=await n.from("message_reads").select("message_id, user_id").in("message_id",w);return(S??[]).forEach(j=>{b[j.message_id]&&b[j.message_id].push(j.user_id)}),d.map(j=>({...j,sender_profile:p[j.sender_id]??void 0,reply_to:j.reply_to_id?g[j.reply_to_id]??null:null,forwarded_from_profile:j.forwarded_from_id?C[j.forwarded_from_id]??null:null,read_by:b[j.id]??[]}))},initialPageParam:0,getNextPageParam:(c,i)=>{if(c.length===So)return i.length*So},enabled:!!e&&!!t});return y.useEffect(()=>{if(!e)return;const c=n.channel(`messages-${e}`).on("postgres_changes",{event:"*",schema:"public",table:"messages",filter:`conversation_id=eq.${e}`},()=>{r.invalidateQueries({queryKey:me.messages(e)})}).on("postgres_changes",{event:"*",schema:"public",table:"message_reads",filter:`message_id=in.(select id from messages where conversation_id=eq.${e})`},()=>{r.invalidateQueries({queryKey:me.messages(e)})}).subscribe();return()=>{n.removeChannel(c)}},[e,r,n]),{messages:y.useMemo(()=>{if(!o.data)return[];const c=[],i=[...o.data.pages].reverse();for(const l of i)c.push(...[...l].reverse());return c},[o.data]),isLoading:o.isLoading,fetchNextPage:o.fetchNextPage,hasNextPage:!!o.hasNextPage,isFetchingNextPage:o.isFetchingNextPage}},kw=e=>{const{user:t}=ye(),n=ve();return oe.useQuery({queryKey:me.unreadIds(e,t==null?void 0:t.id),queryFn:async()=>{if(!e||!t)return new Set;const{data:o}=await n.from("messages").select("id").eq("conversation_id",e).eq("is_deleted",!1).neq("sender_id",t.id);if(!o||o.length===0)return new Set;const a=o.map(l=>l.id),{data:c}=await n.from("message_reads").select("message_id").eq("user_id",t.id).in("message_id",a),i=new Set((c??[]).map(l=>l.message_id));return new Set(o.filter(l=>!i.has(l.id)).map(l=>l.id))},enabled:!!e&&!!t}).data??new Set},ku=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient();return oe.useMutation({mutationFn:async r=>{if(!e)throw new Error("Not authenticated");const{_tempId:o,...a}=r,{data:c,error:i}=await t.from("messages").insert({...a,sender_id:e.id,type:a.type||"text"}).select("*").single();if(i)throw i;return{data:c,_tempId:o}},onMutate:async r=>{var i;if(!e)return;const o=me.messages(r.conversation_id);await n.cancelQueries({queryKey:o});const a=n.getQueryData(o),c={id:r._tempId||`temp-${crypto.randomUUID()}`,conversation_id:r.conversation_id,sender_id:e.id,content:r.content??null,type:r.type||"text",file_url:r.file_url??null,file_name:r.file_name??null,file_size:r.file_size??null,reply_to_id:r.reply_to_id??null,forwarded_from_id:r.forwarded_from_id??null,is_edited:!1,is_deleted:!1,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),sender_profile:{display_name:((i=e.user_metadata)==null?void 0:i.display_name)||"You",avatar_url:null},read_by:[],reply_to:null,_optimistic:!0,_status:"sending"};return n.setQueryData(o,l=>{if(!(l!=null&&l.pages))return l;const d=[...l.pages];return d[0]=[c,...d[0]||[]],{...l,pages:d}}),{previous:a,tempId:c.id}},onSuccess:(r,o)=>{const a=me.messages(o.conversation_id);n.setQueryData(a,c=>{var l;if(!(c!=null&&c.pages))return c;const i={...r.data,sender_profile:{display_name:((l=e.user_metadata)==null?void 0:l.display_name)||"You",avatar_url:null},read_by:[],reply_to:null};return{...c,pages:c.pages.map(d=>d.map(u=>u.id===r._tempId||u.id===o._tempId?i:u))}}),n.invalidateQueries({queryKey:me.conversations(e==null?void 0:e.id)})},onError:(r,o,a)=>{const c=me.messages(o.conversation_id);n.setQueryData(c,i=>i!=null&&i.pages?{...i,pages:i.pages.map(l=>l.map(d=>d.id===(a==null?void 0:a.tempId)||d.id===o._tempId?{...d,_status:"failed",_errorMsg:r instanceof Error?r.message:"Send failed"}:d))}:i)}})},Pw=()=>{const e=ve(),t=oe.useQueryClient();return oe.useMutation({mutationFn:async({id:n,content:r,conversationId:o})=>{const{error:a}=await e.from("messages").update({content:r,is_edited:!0}).eq("id",n);if(a)throw a;return o},onSuccess:n=>{t.invalidateQueries({queryKey:me.messages(n)})}})},Aw=()=>{const e=ve(),t=oe.useQueryClient();return oe.useMutation({mutationFn:async({id:n,conversationId:r})=>{const{error:o}=await e.from("messages").update({is_deleted:!0,content:null}).eq("id",n);if(o)throw o;return r},onSuccess:n=>{t.invalidateQueries({queryKey:me.messages(n)})}})},Ow=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient();return oe.useMutation({mutationFn:async({messageIds:r,conversationId:o})=>{if(!e||r.length===0)return;const a=r.map(c=>({message_id:c,user_id:e.id}));return await t.from("message_reads").upsert(a,{onConflict:"message_id,user_id"}),o},onSuccess:r=>{r&&(n.invalidateQueries({queryKey:me.messages(r)}),n.invalidateQueries({queryKey:me.conversations(e==null?void 0:e.id)}),n.invalidateQueries({queryKey:me.unreadIds(r,e==null?void 0:e.id)}))}})},Dw=e=>{const{user:t}=ye(),n=ve(),r=oe.useQueryClient(),o=oe.useQuery({queryKey:me.reactions(e),queryFn:async()=>{if(!e)return{};const{data:a}=await n.from("messages").select("id").eq("conversation_id",e);if(!a||a.length===0)return{};const c=a.map(m=>m.id),i=[];for(let m=0;m<c.length;m+=500){const h=c.slice(m,m+500),{data:p}=await n.from("message_reactions").select("*").in("message_id",h);p&&i.push(...p)}const l=[...new Set(i.map(m=>m.user_id))],d={};if(l.length>0){const{data:m}=await n.from("profiles").select("id, display_name, avatar_url").in("id",l);m==null||m.forEach(h=>{d[h.id]={display_name:h.display_name,avatar_url:h.avatar_url}})}const u={};for(const m of i){u[m.message_id]||(u[m.message_id]=[]);const h=u[m.message_id],p=h.find(x=>x.emoji===m.emoji),v=d[m.user_id],g={user_id:m.user_id,display_name:(v==null?void 0:v.display_name)||"Unknown",avatar_url:(v==null?void 0:v.avatar_url)??null};p?(p.count++,p.users.push(g),m.user_id===(t==null?void 0:t.id)&&(p.hasReacted=!0)):h.push({emoji:m.emoji,count:1,users:[g],hasReacted:m.user_id===(t==null?void 0:t.id)})}return u},enabled:!!e&&!!t});return y.useEffect(()=>{if(!e)return;const a=n.channel(`reactions-${e}`).on("postgres_changes",{event:"*",schema:"public",table:"message_reactions"},()=>{r.invalidateQueries({queryKey:me.reactions(e)})}).subscribe();return()=>{n.removeChannel(a)}},[e,r,n]),o.data??{}},Iw=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient();return oe.useMutation({mutationFn:async({messageId:r,emoji:o,conversationId:a})=>{if(!e)throw new Error("Not authenticated");const{data:c}=await t.from("message_reactions").select("id").eq("message_id",r).eq("user_id",e.id).eq("emoji",o).maybeSingle();return c?await t.from("message_reactions").delete().eq("id",c.id):await t.from("message_reactions").insert({message_id:r,user_id:e.id,emoji:o}),a},onSuccess:r=>{n.invalidateQueries({queryKey:me.reactions(r)})}})};var Jr="DropdownMenu",[Lw,s1]=ke(Jr,[Gr]),Me=Gr(),[$w,Pu]=Lw(Jr),Au=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:a,onOpenChange:c,modal:i=!0}=e,l=Me(t),d=f.useRef(null),[u,m]=qt({prop:o,defaultProp:a??!1,onChange:c,caller:Jr});return s.jsx($w,{scope:t,triggerId:gt(),triggerRef:d,contentId:gt(),open:u,onOpenChange:m,onOpenToggle:f.useCallback(()=>m(h=>!h),[m]),modal:i,children:s.jsx(zl,{...l,open:u,onOpenChange:m,dir:r,modal:i,children:n})})};Au.displayName=Jr;var Ou="DropdownMenuTrigger",Du=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,a=Pu(Ou,n),c=Me(n);return s.jsx(Wl,{asChild:!0,...c,children:s.jsx(K.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Pr(t,a.triggerRef),onPointerDown:L(e.onPointerDown,i=>{!r&&i.button===0&&i.ctrlKey===!1&&(a.onOpenToggle(),a.open||i.preventDefault())}),onKeyDown:L(e.onKeyDown,i=>{r||(["Enter"," "].includes(i.key)&&a.onOpenToggle(),i.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});Du.displayName=Ou;var Fw="DropdownMenuPortal",Iu=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Me(t);return s.jsx(Bl,{...r,...n})};Iu.displayName=Fw;var Lu="DropdownMenuContent",$u=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Pu(Lu,n),a=Me(n),c=f.useRef(!1);return s.jsx(ql,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...r,ref:t,onCloseAutoFocus:L(e.onCloseAutoFocus,i=>{var l;c.current||(l=o.triggerRef.current)==null||l.focus(),c.current=!1,i.preventDefault()}),onInteractOutside:L(e.onInteractOutside,i=>{const l=i.detail.originalEvent,d=l.button===0&&l.ctrlKey===!0,u=l.button===2||d;(!o.modal||u)&&(c.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)"}})});$u.displayName=Lu;var zw="DropdownMenuGroup",Ww=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Ul,{...o,...r,ref:t})});Ww.displayName=zw;var Bw="DropdownMenuLabel",Fu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Hl,{...o,...r,ref:t})});Fu.displayName=Bw;var qw="DropdownMenuItem",zu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Vl,{...o,...r,ref:t})});zu.displayName=qw;var Uw="DropdownMenuCheckboxItem",Wu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Gl,{...o,...r,ref:t})});Wu.displayName=Uw;var Hw="DropdownMenuRadioGroup",Bu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Yl,{...o,...r,ref:t})});Bu.displayName=Hw;var Vw="DropdownMenuRadioItem",qu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Kl,{...o,...r,ref:t})});qu.displayName=Vw;var Gw="DropdownMenuItemIndicator",Uu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Xl,{...o,...r,ref:t})});Uu.displayName=Gw;var Yw="DropdownMenuSeparator",Hu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Ql,{...o,...r,ref:t})});Hu.displayName=Yw;var Kw="DropdownMenuArrow",Xw=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Zl,{...o,...r,ref:t})});Xw.displayName=Kw;var Qw=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:o,defaultOpen:a}=e,c=Me(t),[i,l]=qt({prop:r,defaultProp:a??!1,onChange:o,caller:"DropdownMenuSub"});return s.jsx(cy,{...c,open:i,onOpenChange:l,children:n})},Zw="DropdownMenuSubTrigger",Vu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Jl,{...o,...r,ref:t})});Vu.displayName=Zw;var Jw="DropdownMenuSubContent",Gu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(ed,{...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)"}})});Gu.displayName=Jw;var e0=Au,t0=Du,n0=Iu,Yu=$u,Ku=Fu,Xu=zu,Qu=Wu,r0=Bu,Zu=qu,Ju=Uu,ef=Hu,o0=Qw,tf=Vu,nf=Gu;const rf=e0,of=t0,s0=o0,a0=r0,sf=f.forwardRef(({className:e,inset:t,children:n,...r},o)=>s.jsxs(tf,{ref:o,className:W("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",t&&"pl-8",e),...r,children:[n,s.jsx(Cs,{className:"ml-auto h-4 w-4"})]}));sf.displayName=tf.displayName;const af=f.forwardRef(({className:e,...t},n)=>s.jsx(nf,{ref:n,className:W("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}));af.displayName=nf.displayName;const ea=f.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(n0,{children:s.jsx(Yu,{ref:r,sideOffset:t,className:W("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})}));ea.displayName=Yu.displayName;const ht=f.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(Xu,{ref:r,className:W("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...n}));ht.displayName=Xu.displayName;const i0=f.forwardRef(({className:e,children:t,checked:n,...r},o)=>s.jsxs(Qu,{ref:o,className:W("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),checked:n,...r,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(Ju,{children:s.jsx(zt,{className:"h-4 w-4"})})}),t]}));i0.displayName=Qu.displayName;const xr=f.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(Zu,{ref:r,className:W("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...n,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(Ju,{children:s.jsx(vc,{className:"h-2 w-2 fill-current"})})}),t]}));xr.displayName=Zu.displayName;const c0=f.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(Ku,{ref:r,className:W("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));c0.displayName=Ku.displayName;const cn=f.forwardRef(({className:e,...t},n)=>s.jsx(ef,{ref:n,className:W("-mx-1 my-1 h-px bg-muted",e),...t}));cn.displayName=ef.displayName;var cf="AlertDialog",[l0,a1]=ke(cf,[Dd]),bt=Dd(),lf=e=>{const{__scopeAlertDialog:t,...n}=e,r=bt(t);return s.jsx(Qd,{...r,...n,modal:!0})};lf.displayName=cf;var d0="AlertDialogTrigger",u0=f.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=bt(n);return s.jsx(lw,{...o,...r,ref:t})});u0.displayName=d0;var f0="AlertDialogPortal",df=e=>{const{__scopeAlertDialog:t,...n}=e,r=bt(t);return s.jsx(Zd,{...r,...n})};df.displayName=f0;var m0="AlertDialogOverlay",uf=f.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=bt(n);return s.jsx(Vs,{...o,...r,ref:t})});uf.displayName=m0;var ln="AlertDialogContent",[p0,h0]=l0(ln),g0=ii("AlertDialogContent"),ff=f.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...o}=e,a=bt(n),c=f.useRef(null),i=ae(t,c),l=f.useRef(null);return s.jsx(sw,{contentName:ln,titleName:mf,docsSlug:"alert-dialog",children:s.jsx(p0,{scope:n,cancelRef:l,children:s.jsxs(Gs,{role:"alertdialog",...a,...o,ref:i,onOpenAutoFocus:L(o.onOpenAutoFocus,d=>{var u;d.preventDefault(),(u=l.current)==null||u.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:[s.jsx(g0,{children:r}),s.jsx(v0,{contentRef:c})]})})})});ff.displayName=ln;var mf="AlertDialogTitle",pf=f.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=bt(n);return s.jsx(Ys,{...o,...r,ref:t})});pf.displayName=mf;var hf="AlertDialogDescription",gf=f.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=bt(n);return s.jsx(Ks,{...o,...r,ref:t})});gf.displayName=hf;var x0="AlertDialogAction",xf=f.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=bt(n);return s.jsx(Xs,{...o,...r,ref:t})});xf.displayName=x0;var vf="AlertDialogCancel",yf=f.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:o}=h0(vf,n),a=bt(n),c=ae(t,o);return s.jsx(Xs,{...a,...r,ref:c})});yf.displayName=vf;var v0=({contentRef:e})=>{const t=`\`${ln}\` requires a description for the component to be accessible for screen reader users.
|
|
302
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return f.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Yb="DialogDescriptionWarning",Kb=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Id(Yb).contentName}}.`;return f.useEffect(()=>{var a;const o=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Ld=Cd,Xb=jd,$d=_d,Bs=Ed,qs=Md,Us=Rd,Hs=Pd,Vs=Od;const Ut=Ld,Qb=$d,Fd=f.forwardRef(({className:e,...t},n)=>s.jsx(Bs,{ref:n,className:W("fixed inset-0 z-[1050] 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}));Fd.displayName=Bs.displayName;const Tt=f.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(Qb,{children:[s.jsx(Fd,{}),s.jsxs(qs,{ref:r,className:W("fixed left-[50%] top-[50%] z-[1050] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,s.jsxs(Vs,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(vn,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Tt.displayName=qs.displayName;const yn=({className:e,...t})=>s.jsx("div",{className:W("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});yn.displayName="DialogHeader";const zd=({className:e,...t})=>s.jsx("div",{className:W("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});zd.displayName="DialogFooter";const Ht=f.forwardRef(({className:e,...t},n)=>s.jsx(Us,{ref:n,className:W("text-lg font-semibold leading-none tracking-tight",e),...t}));Ht.displayName=Us.displayName;const Wd=f.forwardRef(({className:e,...t},n)=>s.jsx(Hs,{ref:n,className:W("text-sm text-muted-foreground",e),...t}));Wd.displayName=Hs.displayName;function Zb(e,[t,n]){return Math.min(n,Math.max(t,e))}function Jb(e,t){return f.useReducer((n,r)=>t[n][r]??n,e)}var Gs="ScrollArea",[Bd,r1]=ke(Gs),[ew,He]=Bd(Gs),qd=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:a=600,...c}=e,[i,l]=f.useState(null),[d,u]=f.useState(null),[m,h]=f.useState(null),[p,v]=f.useState(null),[g,x]=f.useState(null),[C,w]=f.useState(0),[b,S]=f.useState(0),[j,N]=f.useState(!1),[_,O]=f.useState(!1),k=ae(t,I=>l(I)),P=Br(o);return s.jsx(ew,{scope:n,type:r,dir:P,scrollHideDelay:a,scrollArea:i,viewport:d,onViewportChange:u,content:m,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:j,onScrollbarXEnabledChange:N,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:_,onScrollbarYEnabledChange:O,onCornerWidthChange:w,onCornerHeightChange:S,children:s.jsx(K.div,{dir:P,...c,ref:k,style:{position:"relative","--radix-scroll-area-corner-width":C+"px","--radix-scroll-area-corner-height":b+"px",...e.style}})})});qd.displayName=Gs;var Ud="ScrollAreaViewport",Hd=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...a}=e,c=He(Ud,n),i=f.useRef(null),l=ae(t,i,c.onViewportChange);return s.jsxs(s.Fragment,{children:[s.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}),s.jsx(K.div,{"data-radix-scroll-area-viewport":"",...a,ref:l,style:{overflowX:c.scrollbarXEnabled?"scroll":"hidden",overflowY:c.scrollbarYEnabled?"scroll":"hidden",...e.style},children:s.jsx("div",{ref:c.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Hd.displayName=Ud;var ct="ScrollAreaScrollbar",Ys=f.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=He(ct,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:c}=o,i=e.orientation==="horizontal";return f.useEffect(()=>(i?a(!0):c(!0),()=>{i?a(!1):c(!1)}),[i,a,c]),o.type==="hover"?s.jsx(tw,{...r,ref:t,forceMount:n}):o.type==="scroll"?s.jsx(nw,{...r,ref:t,forceMount:n}):o.type==="auto"?s.jsx(Vd,{...r,ref:t,forceMount:n}):o.type==="always"?s.jsx(Ks,{...r,ref:t}):null});Ys.displayName=ct;var tw=f.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=He(ct,e.__scopeScrollArea),[a,c]=f.useState(!1);return f.useEffect(()=>{const i=o.scrollArea;let l=0;if(i){const d=()=>{window.clearTimeout(l),c(!0)},u=()=>{l=window.setTimeout(()=>c(!1),o.scrollHideDelay)};return i.addEventListener("pointerenter",d),i.addEventListener("pointerleave",u),()=>{window.clearTimeout(l),i.removeEventListener("pointerenter",d),i.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),s.jsx(Ee,{present:n||a,children:s.jsx(Vd,{"data-state":a?"visible":"hidden",...r,ref:t})})}),nw=f.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=He(ct,e.__scopeScrollArea),a=e.orientation==="horizontal",c=Xr(()=>l("SCROLL_END"),100),[i,l]=Jb("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 f.useEffect(()=>{if(i==="idle"){const d=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(d)}},[i,o.scrollHideDelay,l]),f.useEffect(()=>{const d=o.viewport,u=a?"scrollLeft":"scrollTop";if(d){let m=d[u];const h=()=>{const p=d[u];m!==p&&(l("SCROLL"),c()),m=p};return d.addEventListener("scroll",h),()=>d.removeEventListener("scroll",h)}},[o.viewport,a,l,c]),s.jsx(Ee,{present:n||i!=="hidden",children:s.jsx(Ks,{"data-state":i==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:L(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:L(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Vd=f.forwardRef((e,t)=>{const n=He(ct,e.__scopeScrollArea),{forceMount:r,...o}=e,[a,c]=f.useState(!1),i=e.orientation==="horizontal",l=Xr(()=>{if(n.viewport){const d=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;c(i?d:u)}},10);return fn(n.viewport,l),fn(n.content,l),s.jsx(Ee,{present:r||a,children:s.jsx(Ks,{"data-state":a?"visible":"hidden",...o,ref:t})})}),Ks=f.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=He(ct,e.__scopeScrollArea),a=f.useRef(null),c=f.useRef(0),[i,l]=f.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=Qd(i.viewport,i.content),u={...r,sizes:i,onSizesChange:l,hasThumb:d>0&&d<1,onThumbChange:h=>a.current=h,onThumbPointerUp:()=>c.current=0,onThumbPointerDown:h=>c.current=h};function m(h,p){return cw(h,c.current,i,p)}return n==="horizontal"?s.jsx(rw,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollLeft,p=Za(h,i,o.dir);a.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=m(h,o.dir))}}):n==="vertical"?s.jsx(ow,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollTop,p=Za(h,i);a.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=m(h))}}):null}),rw=f.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,a=He(ct,e.__scopeScrollArea),[c,i]=f.useState(),l=f.useRef(null),d=ae(t,l,a.onScrollbarXChange);return f.useEffect(()=>{l.current&&i(getComputedStyle(l.current))},[l]),s.jsx(Yd,{"data-orientation":"horizontal",...o,ref:d,sizes:n,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Kr(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,m)=>{if(a.viewport){const h=a.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),Jd(h,m)&&u.preventDefault()}},onResize:()=>{l.current&&a.viewport&&c&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:kr(c.paddingLeft),paddingEnd:kr(c.paddingRight)}})}})}),ow=f.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,a=He(ct,e.__scopeScrollArea),[c,i]=f.useState(),l=f.useRef(null),d=ae(t,l,a.onScrollbarYChange);return f.useEffect(()=>{l.current&&i(getComputedStyle(l.current))},[l]),s.jsx(Yd,{"data-orientation":"vertical",...o,ref:d,sizes:n,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Kr(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,m)=>{if(a.viewport){const h=a.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),Jd(h,m)&&u.preventDefault()}},onResize:()=>{l.current&&a.viewport&&c&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:kr(c.paddingTop),paddingEnd:kr(c.paddingBottom)}})}})}),[sw,Gd]=Bd(ct),Yd=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:a,onThumbPointerUp:c,onThumbPointerDown:i,onThumbPositionChange:l,onDragScroll:d,onWheelScroll:u,onResize:m,...h}=e,p=He(ct,n),[v,g]=f.useState(null),x=ae(t,k=>g(k)),C=f.useRef(null),w=f.useRef(""),b=p.viewport,S=r.content-r.viewport,j=ge(u),N=ge(l),_=Xr(m,10);function O(k){if(C.current){const P=k.clientX-C.current.left,I=k.clientY-C.current.top;d({x:P,y:I})}}return f.useEffect(()=>{const k=P=>{const I=P.target;(v==null?void 0:v.contains(I))&&j(P,S)};return document.addEventListener("wheel",k,{passive:!1}),()=>document.removeEventListener("wheel",k,{passive:!1})},[b,v,S,j]),f.useEffect(N,[r,N]),fn(v,_),fn(p.content,_),s.jsx(sw,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:ge(a),onThumbPointerUp:ge(c),onThumbPositionChange:N,onThumbPointerDown:ge(i),children:s.jsx(K.div,{...h,ref:x,style:{position:"absolute",...h.style},onPointerDown:L(e.onPointerDown,k=>{k.button===0&&(k.target.setPointerCapture(k.pointerId),C.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),O(k))}),onPointerMove:L(e.onPointerMove,O),onPointerUp:L(e.onPointerUp,k=>{const P=k.target;P.hasPointerCapture(k.pointerId)&&P.releasePointerCapture(k.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),C.current=null})})})}),Rr="ScrollAreaThumb",Kd=f.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Gd(Rr,e.__scopeScrollArea);return s.jsx(Ee,{present:n||o.hasThumb,children:s.jsx(aw,{ref:t,...r})})}),aw=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,a=He(Rr,n),c=Gd(Rr,n),{onThumbPositionChange:i}=c,l=ae(t,m=>c.onThumbChange(m)),d=f.useRef(void 0),u=Xr(()=>{d.current&&(d.current(),d.current=void 0)},100);return f.useEffect(()=>{const m=a.viewport;if(m){const h=()=>{if(u(),!d.current){const p=lw(m,i);d.current=p,i()}};return i(),m.addEventListener("scroll",h),()=>m.removeEventListener("scroll",h)}},[a.viewport,u,i]),s.jsx(K.div,{"data-state":c.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:L(e.onPointerDownCapture,m=>{const p=m.target.getBoundingClientRect(),v=m.clientX-p.left,g=m.clientY-p.top;c.onThumbPointerDown({x:v,y:g})}),onPointerUp:L(e.onPointerUp,c.onThumbPointerUp)})});Kd.displayName=Rr;var Xs="ScrollAreaCorner",Xd=f.forwardRef((e,t)=>{const n=He(Xs,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?s.jsx(iw,{...e,ref:t}):null});Xd.displayName=Xs;var iw=f.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=He(Xs,n),[a,c]=f.useState(0),[i,l]=f.useState(0),d=!!(a&&i);return fn(o.scrollbarX,()=>{var m;const u=((m=o.scrollbarX)==null?void 0:m.offsetHeight)||0;o.onCornerHeightChange(u),l(u)}),fn(o.scrollbarY,()=>{var m;const u=((m=o.scrollbarY)==null?void 0:m.offsetWidth)||0;o.onCornerWidthChange(u),c(u)}),d?s.jsx(K.div,{...r,ref:t,style:{width:a,height:i,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function kr(e){return e?parseInt(e,10):0}function Qd(e,t){const n=e/t;return isNaN(n)?0:n}function Kr(e){const t=Qd(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function cw(e,t,n,r="ltr"){const o=Kr(n),a=o/2,c=t||a,i=o-c,l=n.scrollbar.paddingStart+c,d=n.scrollbar.size-n.scrollbar.paddingEnd-i,u=n.content-n.viewport,m=r==="ltr"?[0,u]:[u*-1,0];return Zd([l,d],m)(e)}function Za(e,t,n="ltr"){const r=Kr(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-o,c=t.content-t.viewport,i=a-r,l=n==="ltr"?[0,c]:[c*-1,0],d=Zb(e,l);return Zd([0,c],[0,i])(d)}function Zd(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 Jd(e,t){return e>0&&e<t}var lw=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const a={left:e.scrollLeft,top:e.scrollTop},c=n.left!==a.left,i=n.top!==a.top;(c||i)&&t(),n=a,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Xr(e,t){const n=ge(e),r=f.useRef(0);return f.useEffect(()=>()=>window.clearTimeout(r.current),[]),f.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function fn(e,t){const n=ge(t);Fe(()=>{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 eu=qd,dw=Hd,uw=Xd;const mn=f.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(eu,{ref:r,className:W("relative overflow-hidden",e),...n,children:[s.jsx(dw,{className:"h-full w-full rounded-[inherit]",children:t}),s.jsx(tu,{}),s.jsx(uw,{})]}));mn.displayName=eu.displayName;const tu=f.forwardRef(({className:e,orientation:t="vertical",...n},r)=>s.jsx(Ys,{ref:r,orientation:t,className:W("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:s.jsx(Kd,{className:"relative flex-1 rounded-full bg-border"})}));tu.displayName=Ys.displayName;const nu=()=>{const{user:e}=ye(),t=ve();return oe.useQuery({queryKey:me.contacts(e==null?void 0:e.id),queryFn:async()=>{if(!e)return[];const{data:n,error:r}=await t.from("contacts").select("id, contact_id").eq("user_id",e.id);if(r)throw r;if(!n||n.length===0)return[];const o=n.map(i=>i.contact_id),{data:a}=await t.from("profiles").select("id, display_name, avatar_url, is_online, last_seen").in("id",o),c=Object.fromEntries((a??[]).map(i=>[i.id,i]));return n.map(i=>{const l=c[i.contact_id];return l?{id:i.id,contact_id:i.contact_id,profile:l}:null}).filter(i=>i!==null)},enabled:!!e})},fw=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient();return oe.useMutation({mutationFn:async r=>{if(!e)throw new Error("Not authenticated");const{error:o}=await t.from("contacts").insert({user_id:e.id,contact_id:r});if(o)throw o},onSuccess:()=>n.invalidateQueries({queryKey:me.contacts(e==null?void 0:e.id)})})},mw=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient();return oe.useMutation({mutationFn:async r=>{const{error:o}=await t.from("contacts").delete().eq("id",r);if(o)throw o},onSuccess:()=>n.invalidateQueries({queryKey:me.contacts(e==null?void 0:e.id)})})},ru=e=>{const{user:t}=ye(),n=ve();return oe.useQuery({queryKey:me.searchUsers(e),queryFn:async()=>{if(!t||e.length<2)return[];const{data:r,error:o}=await n.from("profiles").select("id, display_name, avatar_url, is_online").neq("id",t.id).ilike("display_name",`%${e}%`).limit(20);if(o)throw o;return r??[]},enabled:!!t&&e.length>=2})};var Qr="Tabs",[pw,o1]=ke(Qr,[qr]),ou=qr(),[hw,Qs]=pw(Qr),su=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:a,orientation:c="horizontal",dir:i,activationMode:l="automatic",...d}=e,u=Br(i),[m,h]=Bt({prop:r,onChange:o,defaultProp:a??"",caller:Qr});return s.jsx(hw,{scope:n,baseId:gt(),value:m,onValueChange:h,orientation:c,dir:u,activationMode:l,children:s.jsx(K.div,{dir:u,"data-orientation":c,...d,ref:t})})});su.displayName=Qr;var au="TabsList",iu=f.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,a=Qs(au,n),c=ou(n);return s.jsx(Hc,{asChild:!0,...c,orientation:a.orientation,dir:a.dir,loop:r,children:s.jsx(K.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});iu.displayName=au;var cu="TabsTrigger",lu=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...a}=e,c=Qs(cu,n),i=ou(n),l=fu(c.baseId,r),d=mu(c.baseId,r),u=r===c.value;return s.jsx(Vc,{asChild:!0,...i,focusable:!o,active:u,children:s.jsx(K.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":d,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l,...a,ref:t,onMouseDown:L(e.onMouseDown,m=>{!o&&m.button===0&&m.ctrlKey===!1?c.onValueChange(r):m.preventDefault()}),onKeyDown:L(e.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&c.onValueChange(r)}),onFocus:L(e.onFocus,()=>{const m=c.activationMode!=="manual";!u&&!o&&m&&c.onValueChange(r)})})})});lu.displayName=cu;var du="TabsContent",uu=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:a,...c}=e,i=Qs(du,n),l=fu(i.baseId,r),d=mu(i.baseId,r),u=r===i.value,m=f.useRef(u);return f.useEffect(()=>{const h=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(h)},[]),s.jsx(Ee,{present:o||u,children:({present:h})=>s.jsx(K.div,{"data-state":u?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:d,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:m.current?"0s":void 0},children:h&&a})})});uu.displayName=du;function fu(e,t){return`${e}-trigger-${t}`}function mu(e,t){return`${e}-content-${t}`}var gw=su,pu=iu,hu=lu,gu=uu;const xw=gw,xu=f.forwardRef(({className:e,...t},n)=>s.jsx(pu,{ref:n,className:W("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));xu.displayName=pu.displayName;const Ho=f.forwardRef(({className:e,...t},n)=>s.jsx(hu,{ref:n,className:W("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",e),...t}));Ho.displayName=hu.displayName;const Vo=f.forwardRef(({className:e,...t},n)=>s.jsx(gu,{ref:n,className:W("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Vo.displayName=gu.displayName;const vw=({open:e,onOpenChange:t,onStartChat:n})=>{const[r,o]=y.useState(""),{data:a,isLoading:c}=nu(),{data:i}=ru(r),l=fw(),d=mw(),u=cx(),{toast:m}=xn(),h=async g=>{try{await l.mutateAsync(g),m({title:"Contact added"})}catch{m({title:"Error",description:"Contact already exists",variant:"destructive"})}},p=async g=>{try{const x=await u.mutateAsync(g);t(!1),n(x)}catch(x){console.error("handleStartChat error:",x instanceof Error?x.message:String(x)),m({title:"Error creating chat",description:(x==null?void 0:x.message)||"Unknown error",variant:"destructive"})}},v=new Set(a==null?void 0:a.map(g=>g.contact_id));return s.jsx(Ut,{open:e,onOpenChange:t,children:s.jsxs(Tt,{className:"max-w-md",children:[s.jsx(yn,{children:s.jsx(Ht,{children:"Contacts"})}),s.jsxs(xw,{defaultValue:"contacts",children:[s.jsxs(xu,{className:"w-full",children:[s.jsx(Ho,{value:"contacts",className:"flex-1",children:"My Contacts"}),s.jsx(Ho,{value:"search",className:"flex-1",children:"Search"})]}),s.jsx(Vo,{value:"contacts",children:s.jsxs(mn,{className:"h-[350px]",children:[c&&s.jsx("p",{className:"p-4 text-center text-muted-foreground",children:"Loading..."}),(a==null?void 0:a.length)===0&&s.jsx("p",{className:"p-4 text-center text-muted-foreground",children:"No contacts"}),a==null?void 0:a.map(g=>s.jsxs("div",{className:"flex items-center gap-3 px-2 py-2 hover:bg-accent rounded-lg",children:[s.jsxs(Ce,{children:[s.jsx(_e,{src:g.profile.avatar_url??void 0}),s.jsx(Se,{children:g.profile.display_name.slice(0,2).toUpperCase()})]}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"font-medium",children:g.profile.display_name}),s.jsx("p",{className:"text-xs text-muted-foreground",children:g.profile.is_online?"online":"offline"})]}),s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>p(g.contact_id),children:s.jsx(Cr,{className:"h-4 w-4"})}),s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>d.mutate(g.id),children:s.jsx(Bn,{className:"h-4 w-4 text-destructive"})})]},g.id))]})}),s.jsxs(Vo,{value:"search",children:[s.jsxs("div",{className:"relative mb-3",children:[s.jsx(Dn,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(qe,{placeholder:"Search by name...",value:r,onChange:g=>o(g.target.value),className:"pl-9"})]}),s.jsxs(mn,{className:"h-[300px]",children:[i==null?void 0:i.map(g=>s.jsxs("div",{className:"flex items-center gap-3 px-2 py-2 hover:bg-accent rounded-lg",children:[s.jsxs(Ce,{children:[s.jsx(_e,{src:g.avatar_url??void 0}),s.jsx(Se,{children:g.display_name.slice(0,2).toUpperCase()})]}),s.jsx("div",{className:"flex-1",children:s.jsx("p",{className:"font-medium",children:g.display_name})}),!v.has(g.id)&&s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>h(g.id),children:s.jsx(Cc,{className:"h-4 w-4"})}),s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>p(g.id),children:s.jsx(Cr,{className:"h-4 w-4"})})]},g.id)),r.length>=2&&(i==null?void 0:i.length)===0&&s.jsx("p",{className:"p-4 text-center text-muted-foreground",children:"No one found"})]})]})]})]})})};function yw(e){const t=f.useRef({value:e,previous:e});return f.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Zr="Checkbox",[bw,s1]=ke(Zr),[ww,Zs]=bw(Zr);function Cw(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:o,disabled:a,form:c,name:i,onCheckedChange:l,required:d,value:u="on",internal_do_not_use_render:m}=e,[h,p]=Bt({prop:n,defaultProp:o??!1,onChange:l,caller:Zr}),[v,g]=f.useState(null),[x,C]=f.useState(null),w=f.useRef(!1),b=v?!!c||!!v.closest("form"):!0,S={checked:h,disabled:a,setChecked:p,control:v,setControl:g,name:i,form:c,value:u,hasConsumerStoppedPropagationRef:w,required:d,defaultChecked:Nt(o)?!1:o,isFormControl:b,bubbleInput:x,setBubbleInput:C};return s.jsx(ww,{scope:t,...S,children:Sw(m)?m(S):r})}var vu="CheckboxTrigger",yu=f.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},o)=>{const{control:a,value:c,disabled:i,checked:l,required:d,setControl:u,setChecked:m,hasConsumerStoppedPropagationRef:h,isFormControl:p,bubbleInput:v}=Zs(vu,e),g=ae(o,u),x=f.useRef(l);return f.useEffect(()=>{const C=a==null?void 0:a.form;if(C){const w=()=>m(x.current);return C.addEventListener("reset",w),()=>C.removeEventListener("reset",w)}},[a,m]),s.jsx(K.button,{type:"button",role:"checkbox","aria-checked":Nt(l)?"mixed":l,"aria-required":d,"data-state":ju(l),"data-disabled":i?"":void 0,disabled:i,value:c,...r,ref:g,onKeyDown:L(t,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:L(n,C=>{m(w=>Nt(w)?!0:!w),v&&p&&(h.current=C.isPropagationStopped(),h.current||C.stopPropagation())})})});yu.displayName=vu;var Js=f.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:a,required:c,disabled:i,value:l,onCheckedChange:d,form:u,...m}=e;return s.jsx(Cw,{__scopeCheckbox:n,checked:o,defaultChecked:a,disabled:i,required:c,onCheckedChange:d,name:r,form:u,value:l,internal_do_not_use_render:({isFormControl:h})=>s.jsxs(s.Fragment,{children:[s.jsx(yu,{...m,ref:t,__scopeCheckbox:n}),h&&s.jsx(Su,{__scopeCheckbox:n})]})})});Js.displayName=Zr;var bu="CheckboxIndicator",wu=f.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,a=Zs(bu,n);return s.jsx(Ee,{present:r||Nt(a.checked)||a.checked===!0,children:s.jsx(K.span,{"data-state":ju(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});wu.displayName=bu;var Cu="CheckboxBubbleInput",Su=f.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:o,checked:a,defaultChecked:c,required:i,disabled:l,name:d,value:u,form:m,bubbleInput:h,setBubbleInput:p}=Zs(Cu,e),v=ae(n,p),g=yw(a),x=Si(r);f.useEffect(()=>{const w=h;if(!w)return;const b=window.HTMLInputElement.prototype,j=Object.getOwnPropertyDescriptor(b,"checked").set,N=!o.current;if(g!==a&&j){const _=new Event("click",{bubbles:N});w.indeterminate=Nt(a),j.call(w,Nt(a)?!1:a),w.dispatchEvent(_)}},[h,g,a,o]);const C=f.useRef(Nt(a)?!1:a);return s.jsx(K.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??C.current,required:i,disabled:l,name:d,value:u,form:m,...t,tabIndex:-1,ref:v,style:{...t.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Su.displayName=Cu;function Sw(e){return typeof e=="function"}function Nt(e){return e==="indeterminate"}function ju(e){return Nt(e)?"indeterminate":e?"checked":"unchecked"}const Nu=f.forwardRef(({className:e,...t},n)=>s.jsx(Js,{ref:n,className:W("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:s.jsx(wu,{className:W("flex items-center justify-center text-current"),children:s.jsx(zt,{className:"h-4 w-4"})})}));Nu.displayName=Js.displayName;const jw=({open:e,onOpenChange:t,onCreated:n})=>{const[r,o]=y.useState(""),[a,c]=y.useState(""),[i,l]=y.useState(new Set),[d,u]=y.useState(new Map),{data:m}=nu(),{data:h}=ru(a),p=lx(),{toast:v}=xn(),g=new Set(m==null?void 0:m.map(S=>S.contact_id)),x=new Map;m==null||m.forEach(S=>x.set(S.contact_id,{id:S.contact_id,display_name:S.profile.display_name,avatar_url:S.profile.avatar_url})),a.length>=2&&(h==null||h.forEach(S=>{x.has(S.id)||x.set(S.id,{id:S.id,display_name:S.display_name,avatar_url:S.avatar_url})}));const C=a?Array.from(x.values()).filter(S=>S.display_name.toLowerCase().includes(a.toLowerCase())):Array.from(x.values()),w=(S,j)=>{const N=new Set(i),_=new Map(d);N.has(S)?(N.delete(S),_.delete(S)):(N.add(S),_.set(S,j)),l(N),u(_)},b=async()=>{if(!r.trim()){v({title:"Enter a group name",variant:"destructive"});return}if(i.size===0){v({title:"Select at least one member",variant:"destructive"});return}const S=await p.mutateAsync({name:r,memberIds:Array.from(i)});t(!1),n(S),o(""),c(""),l(new Set),u(new Map)};return s.jsx(Ut,{open:e,onOpenChange:t,children:s.jsxs(Tt,{className:"max-w-md",children:[s.jsx(yn,{children:s.jsx(Ht,{className:"text-foreground",children:"New Group"})}),s.jsx(qe,{placeholder:"Group name",value:r,onChange:S=>o(S.target.value),className:"mb-3"}),s.jsxs("div",{className:"relative mb-2",children:[s.jsx(Dn,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(qe,{placeholder:"Search members...",value:a,onChange:S=>c(S.target.value),className:"pl-9"})]}),s.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Select members:"}),s.jsxs(mn,{className:"h-[260px]",children:[C.map(S=>s.jsxs("label",{className:"flex cursor-pointer items-center gap-3 px-2 py-2 hover:bg-accent rounded-lg",children:[s.jsx(Nu,{checked:i.has(S.id),onCheckedChange:()=>w(S.id,{display_name:S.display_name,avatar_url:S.avatar_url})}),s.jsxs(Ce,{className:"h-8 w-8",children:[s.jsx(_e,{src:S.avatar_url??void 0}),s.jsx(Se,{children:S.display_name.slice(0,2).toUpperCase()})]}),s.jsx("span",{className:"font-medium",children:S.display_name}),!g.has(S.id)&&s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"not a contact"})]},S.id)),C.length===0&&a.length>=2&&s.jsx("p",{className:"p-4 text-center text-muted-foreground",children:"No users found"}),C.length===0&&a.length<2&&s.jsx("p",{className:"p-4 text-center text-muted-foreground",children:"Search to find members"})]}),s.jsx(ne,{onClick:b,disabled:p.isPending,className:"w-full mt-2",children:p.isPending?"Creating...":`Create group (${i.size})`})]})})},_u=f.forwardRef(({className:e,...t},n)=>s.jsx("textarea",{className:W("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));_u.displayName="Textarea";var Nw="Label",Eu=f.forwardRef((e,t)=>s.jsx(K.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())}}));Eu.displayName=Nw;var Mu=Eu;const _w=ws("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),sn=f.forwardRef(({className:e,...t},n)=>s.jsx(Mu,{ref:n,className:W(_w(),e),...t}));sn.displayName=Mu.displayName;const Tu=({open:e,onOpenChange:t,userId:n})=>{const r=ve(),{user:o}=ye(),a=oe.useQueryClient(),{toast:c}=xn(),i=(o==null?void 0:o.id)===n,[l,d]=y.useState(!1),[u,m]=y.useState(""),[h,p]=y.useState(""),[v,g]=y.useState(!1),[x,C]=y.useState(!1),w=y.useRef(null),{data:b,isLoading:S}=oe.useQuery({queryKey:["profile",n],queryFn:async()=>{const{data:P,error:I}=await r.from("profiles").select("*").eq("id",n).single();if(I)throw I;return P},enabled:e&&!!n}),j=()=>{b&&(m(b.display_name),p(b.bio??""),d(!0))},N=()=>{d(!1)},_=async()=>{if(o){C(!0);try{const{error:P}=await r.from("profiles").update({display_name:u.trim()||(b==null?void 0:b.display_name),bio:h}).eq("id",o.id);if(P)throw P;a.invalidateQueries({queryKey:["profile"]}),a.invalidateQueries({queryKey:["conversations"]}),d(!1),c({title:"Profile updated"})}catch(P){c({title:"Error",description:P.message,variant:"destructive"})}finally{C(!1)}}},O=async P=>{var F;const I=(F=P.target.files)==null?void 0:F[0];if(!I||!o)return;const A={"image/jpeg":"jpg","image/png":"png","image/gif":"gif","image/webp":"webp"};if(!A[I.type]){c({title:"Invalid file type",description:"Only JPEG, PNG, GIF, and WebP are allowed.",variant:"destructive"}),P.target.value="";return}const D=A[I.type],E=`${o.id}/avatar.${D}`;g(!0);try{await r.storage.from("avatars").remove([E]);const{error:T}=await r.storage.from("avatars").upload(E,I,{upsert:!0});if(T)throw T;const{data:z}=r.storage.from("avatars").getPublicUrl(E),{error:$}=await r.from("profiles").update({avatar_url:z.publicUrl}).eq("id",o.id);if($)throw $;a.invalidateQueries({queryKey:["profile"]}),a.invalidateQueries({queryKey:["conversations"]}),c({title:"Avatar updated"})}catch(T){c({title:"Upload error",description:T.message,variant:"destructive"})}finally{g(!1),P.target.value=""}},k=((b==null?void 0:b.display_name)??"?").split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2);return s.jsx(Ut,{open:e,onOpenChange:t,children:s.jsxs(Tt,{className:"sm:max-w-[360px] p-0 overflow-hidden",children:[s.jsx(Ht,{className:"sr-only",children:"User profile"}),s.jsxs("div",{className:"relative flex flex-col items-center pt-8 pb-4 bg-primary/10",children:[s.jsxs("div",{className:"relative group",children:[s.jsxs(Ce,{className:"h-24 w-24 border-4 border-background shadow-lg",children:[s.jsx(_e,{src:(b==null?void 0:b.avatar_url)??void 0}),s.jsx(Se,{className:"text-2xl font-bold",children:k})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:w,type:"file",accept:"image/*",className:"hidden",onChange:O}),s.jsx("button",{onClick:()=>{var P;return(P=w.current)==null?void 0:P.click()},disabled:v,className:"absolute inset-0 flex items-center justify-center rounded-full bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:v?s.jsx(rn,{className:"h-6 w-6 text-white animate-spin"}):s.jsx(cg,{className:"h-6 w-6 text-white"})})]})]}),(b==null?void 0:b.is_online)&&s.jsx("span",{className:"absolute top-[88px] right-[calc(50%-28px)] h-4 w-4 rounded-full border-2 border-background bg-online"})]}),s.jsx("div",{className:"px-6 pb-6 space-y-4",children:S?s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(rn,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):l?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(sn,{htmlFor:"displayName",children:"Display name"}),s.jsx(qe,{id:"displayName",value:u,onChange:P=>m(P.target.value),placeholder:"Your name",maxLength:100})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(sn,{htmlFor:"bio",children:"Bio"}),s.jsx(_u,{id:"bio",value:h,onChange:P=>p(P.target.value),placeholder:"Tell about yourself...",rows:3,maxLength:500})]}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(ne,{variant:"ghost",size:"sm",onClick:N,disabled:x,children:[s.jsx(vn,{className:"h-4 w-4 mr-1"})," Cancel"]}),s.jsxs(ne,{size:"sm",onClick:_,disabled:x,children:[x?s.jsx(rn,{className:"h-4 w-4 mr-1 animate-spin"}):s.jsx(zt,{className:"h-4 w-4 mr-1"}),"Save"]})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"text-center",children:[s.jsx("h3",{className:"text-lg font-semibold",children:b==null?void 0:b.display_name}),s.jsx("p",{className:"text-sm text-muted-foreground",children:b!=null&&b.is_online?"online":b!=null&&b.last_seen?`last seen ${new Date(b.last_seen).toLocaleDateString()}`:"offline"})]}),(b==null?void 0:b.bio)&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Bio"}),s.jsx("p",{className:"text-sm",children:b.bio})]}),i&&s.jsxs(ne,{variant:"outline",size:"sm",className:"w-full",onClick:j,children:[s.jsx(Sr,{className:"h-4 w-4 mr-2"})," Edit profile"]})]})})]})})},Ew=({activeConversationId:e,onSelectConversation:t,onUnreadCountChange:n})=>{const{data:r,isLoading:o}=js(),{user:a,signOut:c,authMode:i}=ye(),l=rs(),{theme:d,setTheme:u,resolved:m}=Wf(),[h,p]=y.useState(""),[v,g]=y.useState(!1),[x,C]=y.useState(!1),[w,b]=y.useState(!1),{data:S}=dx(),[j,N]=y.useState(new Set),[_,O]=y.useState(new Set),k=D=>{N(E=>{const F=new Set(E);return F.has(D)?(F.delete(D),Rn("Unpinned")):(F.add(D),Rn("Pinned")),F})},P=D=>{O(E=>{const F=new Set(E);return F.has(D)?(F.delete(D),Rn("Unmuted")):(F.add(D),Rn("Muted")),F})},I=y.useMemo(()=>(r==null?void 0:r.reduce((D,E)=>D+E.unread_count,0))??0,[r]);y.useEffect(()=>{n==null||n(I)},[I,n]);const A=y.useMemo(()=>{if(!r)return[];let D=r;if(l.showGroups||(D=D.filter(E=>E.type!=="group")),h){const E=h.toLowerCase();D=D.filter(F=>Ru(F,(a==null?void 0:a.id)??"").toLowerCase().includes(E))}return[...D].sort((E,F)=>{const T=j.has(E.id)?0:1,z=j.has(F.id)?0:1;return T-z})},[r,h,a,j]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Ce,{className:"h-8 w-8 cursor-pointer",onClick:()=>b(!0),children:[s.jsx(_e,{src:(S==null?void 0:S.avatar_url)??void 0}),s.jsx(Se,{className:"text-xs",children:((S==null?void 0:S.display_name)??"?").slice(0,2).toUpperCase()})]}),s.jsx("h1",{className:"text-lg font-bold text-foreground",children:"Chats"}),I>0&&s.jsx("span",{className:"flex h-5 min-w-[1.25rem] items-center justify-center rounded-full bg-primary px-1.5 text-xs font-medium text-primary-foreground whitespace-nowrap",children:ku(I)})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>g(!0),children:s.jsx(Cc,{className:"h-5 w-5"})}),l.showGroups&&s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>C(!0),children:s.jsx(Ng,{className:"h-5 w-5"})}),s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>u(m==="dark"?"light":"dark"),children:m==="dark"?s.jsx(Fo,{className:"h-5 w-5"}):s.jsx($o,{className:"h-5 w-5"})}),i==="built-in"&&s.jsx(ne,{variant:"ghost",size:"icon",onClick:c,children:s.jsx(Ss,{className:"h-5 w-5"})})]})]}),s.jsx("div",{className:"px-3 py-2",children:s.jsxs("div",{className:"relative",children:[s.jsx(Dn,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(qe,{placeholder:"Search chats...",value:h,onChange:D=>p(D.target.value),className:"pl-9"})]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o&&s.jsx("div",{className:"p-4 text-center text-muted-foreground",children:"Loading..."}),!o&&A.length===0&&s.jsx("div",{className:"p-4 text-center text-muted-foreground",children:h?"Nothing found":"No chats yet. Add a contact to get started!"}),A.map(D=>s.jsx(Rw,{conversation:D,isActive:D.id===e,currentUserId:(a==null?void 0:a.id)??"",onClick:()=>t(D.id),pinned:j.has(D.id),muted:_.has(D.id),onTogglePin:()=>k(D.id),onToggleMute:()=>P(D.id)},D.id))]}),s.jsx(vw,{open:v,onOpenChange:g,onStartChat:t}),s.jsx(jw,{open:x,onOpenChange:C,onCreated:t}),a&&s.jsx(Tu,{open:w,onOpenChange:b,userId:a.id})]})};function Ru(e,t){var r;if(e.type==="group")return e.name||"Group";const n=e.members.find(o=>o.user_id!==t);return((r=n==null?void 0:n.profile)==null?void 0:r.display_name)||"Chat"}function Mw(e,t){var r;if(e.type==="group")return e.avatar_url;const n=e.members.find(o=>o.user_id!==t);return(r=n==null?void 0:n.profile)==null?void 0:r.avatar_url}function Tw(e){return e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2)}function ku(e){return e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}const Rw=({conversation:e,isActive:t,currentUserId:n,onClick:r,pinned:o,muted:a,onTogglePin:c,onToggleMute:i})=>{var g;const l=Ru(e,n),d=Mw(e,n),u=e.members.find(x=>x.user_id!==n),h=rs().showOnlineStatus&&e.type==="private"&&((g=u==null?void 0:u.profile)==null?void 0:g.is_online),p=e.last_message?e.last_message.type!=="text"?`📎 ${e.last_message.type}`:(e.last_message.content||"").slice(0,50):"No messages",v=e.last_message?yd(new Date(e.last_message.created_at),{addSuffix:!1}):"";return s.jsxs(gy,{children:[s.jsx(xy,{asChild:!0,children:s.jsxs("button",{onClick:r,className:`flex w-full items-center gap-3 pl-4 pr-5 py-3 text-left transition-colors hover:bg-accent ${t?"bg-chat-active text-chat-active-foreground hover:bg-chat-active":""}`,children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Ce,{className:"h-12 w-12",children:[s.jsx(_e,{src:d??void 0}),s.jsx(Se,{children:Tw(l)})]}),h&&s.jsx("span",{className:"absolute bottom-0 right-0 h-3.5 w-3.5 rounded-full border-2 border-background bg-online"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center",children:[s.jsxs("div",{className:"flex flex-1 min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"font-semibold truncate",children:l}),o&&s.jsx(Ta,{className:"h-3 w-3 shrink-0 text-muted-foreground rotate-45"}),a&&s.jsx(Lo,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}),s.jsx("span",{className:`shrink-0 ml-2 text-xs whitespace-nowrap ${t?"text-chat-active-foreground/70":"text-muted-foreground"}`,children:v})]}),s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:`flex-1 min-w-0 text-sm truncate ${t?"text-chat-active-foreground/70":"text-muted-foreground"}`,children:p}),e.unread_count>0&&!t&&s.jsx("span",{className:"shrink-0 ml-2 flex h-5 min-w-[1.25rem] items-center justify-center rounded-full bg-primary px-1.5 text-xs font-medium text-primary-foreground whitespace-nowrap",children:ku(e.unread_count)})]})]})]})}),s.jsxs(ud,{className:"w-52",children:[s.jsxs(hr,{onClick:c,children:[s.jsx(Ta,{className:"mr-2 h-4 w-4"}),o?"Unpin":"Pin"]}),s.jsxs(hr,{onClick:i,children:[a?s.jsx(ig,{className:"mr-2 h-4 w-4"}):s.jsx(Lo,{className:"mr-2 h-4 w-4"}),a?"Unmute":"Mute"]}),s.jsx(fd,{}),s.jsxs(hr,{className:"text-destructive focus:text-destructive",onClick:()=>Rn("Left chat"),children:[s.jsx(fg,{className:"mr-2 h-4 w-4"}),e.type==="group"?"Leave group":"Delete chat"]})]})]})},So=30,kw=e=>{const{user:t}=ye(),n=ve(),r=oe.useQueryClient(),o=oe.useInfiniteQuery({queryKey:me.messages(e),queryFn:async({pageParam:c=0})=>{if(!e||!t)return[];const i=c,l=c+So-1,{data:d,error:u}=await n.from("messages").select("*").eq("conversation_id",e).eq("is_deleted",!1).order("created_at",{ascending:!1}).range(i,l);if(u)throw u;if(!d||d.length===0)return[];const m=[...new Set(d.map(j=>j.sender_id))],{data:h}=await n.from("profiles").select("id, display_name, avatar_url").in("id",m),p=Object.fromEntries((h??[]).map(j=>[j.id,j])),v=[...new Set(d.map(j=>j.reply_to_id).filter(j=>!!j))],g={};if(v.length>0){const{data:j}=await n.from("messages").select("id, content, sender_id").in("id",v);(j??[]).forEach(N=>{g[N.id]={content:N.content,sender_id:N.sender_id}})}const x=[...new Set(d.map(j=>j.forwarded_from_id).filter(j=>!!j))],C={};if(x.length>0){const{data:j}=await n.from("messages").select("id, sender_id").in("id",x),N=[...new Set((j??[]).map(_=>_.sender_id))];if(N.length>0){const{data:_}=await n.from("profiles").select("id, display_name").in("id",N),O=Object.fromEntries((_??[]).map(k=>[k.id,k.display_name]));(j??[]).forEach(k=>{C[k.id]={display_name:O[k.sender_id]??"Unknown",sender_id:k.sender_id}})}}const w=d.map(j=>j.id),b={};w.forEach(j=>{b[j]=[]});const{data:S}=await n.from("message_reads").select("message_id, user_id").in("message_id",w);return(S??[]).forEach(j=>{b[j.message_id]&&b[j.message_id].push(j.user_id)}),d.map(j=>({...j,sender_profile:p[j.sender_id]??void 0,reply_to:j.reply_to_id?g[j.reply_to_id]??null:null,forwarded_from_profile:j.forwarded_from_id?C[j.forwarded_from_id]??null:null,read_by:b[j.id]??[]}))},initialPageParam:0,getNextPageParam:(c,i)=>{if(c.length===So)return i.length*So},enabled:!!e&&!!t});return y.useEffect(()=>{if(!e)return;const c=n.channel(`messages-${e}`).on("postgres_changes",{event:"*",schema:"public",table:"messages",filter:`conversation_id=eq.${e}`},()=>{r.invalidateQueries({queryKey:me.messages(e)})}).on("postgres_changes",{event:"*",schema:"public",table:"message_reads",filter:`message_id=in.(select id from messages where conversation_id=eq.${e})`},()=>{r.invalidateQueries({queryKey:me.messages(e)})}).subscribe();return()=>{n.removeChannel(c)}},[e,r,n]),{messages:y.useMemo(()=>{if(!o.data)return[];const c=[],i=[...o.data.pages].reverse();for(const l of i)c.push(...[...l].reverse());return c},[o.data]),isLoading:o.isLoading,fetchNextPage:o.fetchNextPage,hasNextPage:!!o.hasNextPage,isFetchingNextPage:o.isFetchingNextPage}},Pw=e=>{const{user:t}=ye(),n=ve();return oe.useQuery({queryKey:me.unreadIds(e,t==null?void 0:t.id),queryFn:async()=>{if(!e||!t)return new Set;const{data:o}=await n.from("messages").select("id").eq("conversation_id",e).eq("is_deleted",!1).neq("sender_id",t.id);if(!o||o.length===0)return new Set;const a=o.map(l=>l.id),{data:c}=await n.from("message_reads").select("message_id").eq("user_id",t.id).in("message_id",a),i=new Set((c??[]).map(l=>l.message_id));return new Set(o.filter(l=>!i.has(l.id)).map(l=>l.id))},enabled:!!e&&!!t}).data??new Set},Pu=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient();return oe.useMutation({mutationFn:async r=>{if(!e)throw new Error("Not authenticated");const{_tempId:o,...a}=r,{data:c,error:i}=await t.from("messages").insert({...a,sender_id:e.id,type:a.type||"text"}).select("*").single();if(i)throw i;return{data:c,_tempId:o}},onMutate:async r=>{var i;if(!e)return;const o=me.messages(r.conversation_id);await n.cancelQueries({queryKey:o});const a=n.getQueryData(o),c={id:r._tempId||`temp-${crypto.randomUUID()}`,conversation_id:r.conversation_id,sender_id:e.id,content:r.content??null,type:r.type||"text",file_url:r.file_url??null,file_name:r.file_name??null,file_size:r.file_size??null,reply_to_id:r.reply_to_id??null,forwarded_from_id:r.forwarded_from_id??null,is_edited:!1,is_deleted:!1,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),sender_profile:{display_name:((i=e.user_metadata)==null?void 0:i.display_name)||"You",avatar_url:null},read_by:[],reply_to:null,_optimistic:!0,_status:"sending"};return n.setQueryData(o,l=>{if(!(l!=null&&l.pages))return l;const d=[...l.pages];return d[0]=[c,...d[0]||[]],{...l,pages:d}}),{previous:a,tempId:c.id}},onSuccess:(r,o)=>{const a=me.messages(o.conversation_id);n.setQueryData(a,c=>{var l;if(!(c!=null&&c.pages))return c;const i={...r.data,sender_profile:{display_name:((l=e.user_metadata)==null?void 0:l.display_name)||"You",avatar_url:null},read_by:[],reply_to:null};return{...c,pages:c.pages.map(d=>d.map(u=>u.id===r._tempId||u.id===o._tempId?i:u))}}),n.invalidateQueries({queryKey:me.conversations(e==null?void 0:e.id)})},onError:(r,o,a)=>{const c=me.messages(o.conversation_id);n.setQueryData(c,i=>i!=null&&i.pages?{...i,pages:i.pages.map(l=>l.map(d=>d.id===(a==null?void 0:a.tempId)||d.id===o._tempId?{...d,_status:"failed",_errorMsg:r instanceof Error?r.message:"Send failed"}:d))}:i)}})},Aw=()=>{const e=ve(),t=oe.useQueryClient();return oe.useMutation({mutationFn:async({id:n,content:r,conversationId:o})=>{const{error:a}=await e.from("messages").update({content:r,is_edited:!0}).eq("id",n);if(a)throw a;return o},onSuccess:n=>{t.invalidateQueries({queryKey:me.messages(n)})}})},Ow=()=>{const e=ve(),t=oe.useQueryClient();return oe.useMutation({mutationFn:async({id:n,conversationId:r})=>{const{error:o}=await e.from("messages").update({is_deleted:!0,content:null}).eq("id",n);if(o)throw o;return r},onSuccess:n=>{t.invalidateQueries({queryKey:me.messages(n)})}})},Dw=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient();return oe.useMutation({mutationFn:async({messageIds:r,conversationId:o})=>{if(!e||r.length===0)return;const a=r.map(c=>({message_id:c,user_id:e.id}));return await t.from("message_reads").upsert(a,{onConflict:"message_id,user_id"}),o},onSuccess:r=>{r&&(n.invalidateQueries({queryKey:me.messages(r)}),n.invalidateQueries({queryKey:me.conversations(e==null?void 0:e.id)}),n.invalidateQueries({queryKey:me.unreadIds(r,e==null?void 0:e.id)}))}})},Iw=e=>{const{user:t}=ye(),n=ve(),r=oe.useQueryClient(),o=oe.useQuery({queryKey:me.reactions(e),queryFn:async()=>{if(!e)return{};const{data:a}=await n.from("messages").select("id").eq("conversation_id",e);if(!a||a.length===0)return{};const c=a.map(m=>m.id),i=[];for(let m=0;m<c.length;m+=500){const h=c.slice(m,m+500),{data:p}=await n.from("message_reactions").select("*").in("message_id",h);p&&i.push(...p)}const l=[...new Set(i.map(m=>m.user_id))],d={};if(l.length>0){const{data:m}=await n.from("profiles").select("id, display_name, avatar_url").in("id",l);m==null||m.forEach(h=>{d[h.id]={display_name:h.display_name,avatar_url:h.avatar_url}})}const u={};for(const m of i){u[m.message_id]||(u[m.message_id]=[]);const h=u[m.message_id],p=h.find(x=>x.emoji===m.emoji),v=d[m.user_id],g={user_id:m.user_id,display_name:(v==null?void 0:v.display_name)||"Unknown",avatar_url:(v==null?void 0:v.avatar_url)??null};p?(p.count++,p.users.push(g),m.user_id===(t==null?void 0:t.id)&&(p.hasReacted=!0)):h.push({emoji:m.emoji,count:1,users:[g],hasReacted:m.user_id===(t==null?void 0:t.id)})}return u},enabled:!!e&&!!t});return y.useEffect(()=>{if(!e)return;const a=n.channel(`reactions-${e}`).on("postgres_changes",{event:"*",schema:"public",table:"message_reactions"},()=>{r.invalidateQueries({queryKey:me.reactions(e)})}).subscribe();return()=>{n.removeChannel(a)}},[e,r,n]),o.data??{}},Lw=()=>{const{user:e}=ye(),t=ve(),n=oe.useQueryClient();return oe.useMutation({mutationFn:async({messageId:r,emoji:o,conversationId:a})=>{if(!e)throw new Error("Not authenticated");const{data:c}=await t.from("message_reactions").select("id").eq("message_id",r).eq("user_id",e.id).eq("emoji",o).maybeSingle();return c?await t.from("message_reactions").delete().eq("id",c.id):await t.from("message_reactions").insert({message_id:r,user_id:e.id,emoji:o}),a},onSuccess:r=>{n.invalidateQueries({queryKey:me.reactions(r)})}})};var Jr="DropdownMenu",[$w,a1]=ke(Jr,[Hr]),Me=Hr(),[Fw,Au]=$w(Jr),Ou=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:a,onOpenChange:c,modal:i=!0}=e,l=Me(t),d=f.useRef(null),[u,m]=Bt({prop:o,defaultProp:a??!1,onChange:c,caller:Jr});return s.jsx(Fw,{scope:t,triggerId:gt(),triggerRef:d,contentId:gt(),open:u,onOpenChange:m,onOpenToggle:f.useCallback(()=>m(h=>!h),[m]),modal:i,children:s.jsx(_l,{...l,open:u,onOpenChange:m,dir:r,modal:i,children:n})})};Ou.displayName=Jr;var Du="DropdownMenuTrigger",Iu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,a=Au(Du,n),c=Me(n);return s.jsx(El,{asChild:!0,...c,children:s.jsx(K.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Pr(t,a.triggerRef),onPointerDown:L(e.onPointerDown,i=>{!r&&i.button===0&&i.ctrlKey===!1&&(a.onOpenToggle(),a.open||i.preventDefault())}),onKeyDown:L(e.onKeyDown,i=>{r||(["Enter"," "].includes(i.key)&&a.onOpenToggle(),i.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});Iu.displayName=Du;var zw="DropdownMenuPortal",Lu=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Me(t);return s.jsx(Ml,{...r,...n})};Lu.displayName=zw;var $u="DropdownMenuContent",Fu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Au($u,n),a=Me(n),c=f.useRef(!1);return s.jsx(Tl,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...r,ref:t,onCloseAutoFocus:L(e.onCloseAutoFocus,i=>{var l;c.current||(l=o.triggerRef.current)==null||l.focus(),c.current=!1,i.preventDefault()}),onInteractOutside:L(e.onInteractOutside,i=>{const l=i.detail.originalEvent,d=l.button===0&&l.ctrlKey===!0,u=l.button===2||d;(!o.modal||u)&&(c.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)"}})});Fu.displayName=$u;var Ww="DropdownMenuGroup",Bw=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Rl,{...o,...r,ref:t})});Bw.displayName=Ww;var qw="DropdownMenuLabel",zu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(kl,{...o,...r,ref:t})});zu.displayName=qw;var Uw="DropdownMenuItem",Wu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Pl,{...o,...r,ref:t})});Wu.displayName=Uw;var Hw="DropdownMenuCheckboxItem",Bu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Al,{...o,...r,ref:t})});Bu.displayName=Hw;var Vw="DropdownMenuRadioGroup",qu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Ol,{...o,...r,ref:t})});qu.displayName=Vw;var Gw="DropdownMenuRadioItem",Uu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Dl,{...o,...r,ref:t})});Uu.displayName=Gw;var Yw="DropdownMenuItemIndicator",Hu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Il,{...o,...r,ref:t})});Hu.displayName=Yw;var Kw="DropdownMenuSeparator",Vu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Ll,{...o,...r,ref:t})});Vu.displayName=Kw;var Xw="DropdownMenuArrow",Qw=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx($l,{...o,...r,ref:t})});Qw.displayName=Xw;var Zw=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:o,defaultOpen:a}=e,c=Me(t),[i,l]=Bt({prop:r,defaultProp:a??!1,onChange:o,caller:"DropdownMenuSub"});return s.jsx(Kv,{...c,open:i,onOpenChange:l,children:n})},Jw="DropdownMenuSubTrigger",Gu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(Fl,{...o,...r,ref:t})});Gu.displayName=Jw;var e0="DropdownMenuSubContent",Yu=f.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Me(n);return s.jsx(zl,{...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)"}})});Yu.displayName=e0;var t0=Ou,n0=Iu,r0=Lu,Ku=Fu,Xu=zu,Qu=Wu,Zu=Bu,o0=qu,Ju=Uu,ef=Hu,tf=Vu,s0=Zw,nf=Gu,rf=Yu;const of=t0,sf=n0,a0=s0,i0=o0,af=f.forwardRef(({className:e,inset:t,children:n,...r},o)=>s.jsxs(nf,{ref:o,className:W("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",t&&"pl-8",e),...r,children:[n,s.jsx(Cs,{className:"ml-auto h-4 w-4"})]}));af.displayName=nf.displayName;const cf=f.forwardRef(({className:e,...t},n)=>s.jsx(rf,{ref:n,className:W("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}));cf.displayName=rf.displayName;const ea=f.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(r0,{children:s.jsx(Ku,{ref:r,sideOffset:t,className:W("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})}));ea.displayName=Ku.displayName;const ht=f.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(Qu,{ref:r,className:W("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...n}));ht.displayName=Qu.displayName;const c0=f.forwardRef(({className:e,children:t,checked:n,...r},o)=>s.jsxs(Zu,{ref:o,className:W("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),checked:n,...r,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(ef,{children:s.jsx(zt,{className:"h-4 w-4"})})}),t]}));c0.displayName=Zu.displayName;const xr=f.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(Ju,{ref:r,className:W("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...n,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(ef,{children:s.jsx(vc,{className:"h-2 w-2 fill-current"})})}),t]}));xr.displayName=Ju.displayName;const l0=f.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(Xu,{ref:r,className:W("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));l0.displayName=Xu.displayName;const an=f.forwardRef(({className:e,...t},n)=>s.jsx(tf,{ref:n,className:W("-mx-1 my-1 h-px bg-muted",e),...t}));an.displayName=tf.displayName;var lf="AlertDialog",[d0,i1]=ke(lf,[wd]),bt=wd(),df=e=>{const{__scopeAlertDialog:t,...n}=e,r=bt(t);return s.jsx(Ld,{...r,...n,modal:!0})};df.displayName=lf;var u0="AlertDialogTrigger",f0=f.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=bt(n);return s.jsx(Xb,{...o,...r,ref:t})});f0.displayName=u0;var m0="AlertDialogPortal",uf=e=>{const{__scopeAlertDialog:t,...n}=e,r=bt(t);return s.jsx($d,{...r,...n})};uf.displayName=m0;var p0="AlertDialogOverlay",ff=f.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=bt(n);return s.jsx(Bs,{...o,...r,ref:t})});ff.displayName=p0;var cn="AlertDialogContent",[h0,g0]=d0(cn),x0=ii("AlertDialogContent"),mf=f.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...o}=e,a=bt(n),c=f.useRef(null),i=ae(t,c),l=f.useRef(null);return s.jsx(Vb,{contentName:cn,titleName:pf,docsSlug:"alert-dialog",children:s.jsx(h0,{scope:n,cancelRef:l,children:s.jsxs(qs,{role:"alertdialog",...a,...o,ref:i,onOpenAutoFocus:L(o.onOpenAutoFocus,d=>{var u;d.preventDefault(),(u=l.current)==null||u.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:[s.jsx(x0,{children:r}),s.jsx(y0,{contentRef:c})]})})})});mf.displayName=cn;var pf="AlertDialogTitle",hf=f.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=bt(n);return s.jsx(Us,{...o,...r,ref:t})});hf.displayName=pf;var gf="AlertDialogDescription",xf=f.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=bt(n);return s.jsx(Hs,{...o,...r,ref:t})});xf.displayName=gf;var v0="AlertDialogAction",vf=f.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=bt(n);return s.jsx(Vs,{...o,...r,ref:t})});vf.displayName=v0;var yf="AlertDialogCancel",bf=f.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:o}=g0(yf,n),a=bt(n),c=ae(t,o);return s.jsx(Vs,{...a,...r,ref:c})});bf.displayName=yf;var y0=({contentRef:e})=>{const t=`\`${cn}\` requires a description for the component to be accessible for screen reader users.
|
|
303
303
|
|
|
304
|
-
You can add a description to the \`${
|
|
304
|
+
You can add a description to the \`${cn}\` by passing a \`${gf}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
305
305
|
|
|
306
|
-
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${
|
|
306
|
+
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${cn}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
307
307
|
|
|
308
|
-
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return f.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},y0=lf,b0=df,bf=uf,wf=ff,Cf=xf,Sf=yf,jf=pf,Nf=gf;const Ja=y0,w0=b0,_f=f.forwardRef(({className:e,...t},n)=>s.jsx(bf,{className:W("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}));_f.displayName=bf.displayName;const Go=f.forwardRef(({className:e,...t},n)=>s.jsxs(w0,{children:[s.jsx(_f,{}),s.jsx(wf,{ref:n,className:W("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));Go.displayName=wf.displayName;const Yo=({className:e,...t})=>s.jsx("div",{className:W("flex flex-col space-y-2 text-center sm:text-left",e),...t});Yo.displayName="AlertDialogHeader";const Ko=({className:e,...t})=>s.jsx("div",{className:W("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ko.displayName="AlertDialogFooter";const Xo=f.forwardRef(({className:e,...t},n)=>s.jsx(jf,{ref:n,className:W("text-lg font-semibold",e),...t}));Xo.displayName=jf.displayName;const Qo=f.forwardRef(({className:e,...t},n)=>s.jsx(Nf,{ref:n,className:W("text-sm text-muted-foreground",e),...t}));Qo.displayName=Nf.displayName;const Zo=f.forwardRef(({className:e,...t},n)=>s.jsx(Cf,{ref:n,className:W(_s(),e),...t}));Zo.displayName=Cf.displayName;const Jo=f.forwardRef(({className:e,...t},n)=>s.jsx(Sf,{ref:n,className:W(_s({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));Jo.displayName=Sf.displayName;const C0=({onSend:e})=>{const[t,n]=y.useState(!1),[r,o]=y.useState(0),a=y.useRef(null),c=y.useRef([]),i=y.useRef(0),l=y.useRef(null),d=y.useRef(null),u=y.useCallback(()=>{var g;l.current&&clearInterval(l.current),(g=d.current)==null||g.getTracks().forEach(x=>x.stop()),a.current=null,d.current=null,c.current=[],o(0),n(!1)},[]),m=y.useCallback(async()=>{try{const g=await navigator.mediaDevices.getUserMedia({audio:!0});d.current=g;const x=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm",C=new MediaRecorder(g,{mimeType:x});a.current=C,c.current=[],C.ondataavailable=w=>{w.data.size>0&&c.current.push(w.data)},C.onstop=()=>{const w=Date.now()-i.current,b=new Blob(c.current,{type:x});b.size>0&&w>500&&e(b,w),u()},C.start(100),i.current=Date.now(),n(!0),l.current=setInterval(()=>{o(Date.now()-i.current)},100)}catch{u()}},[e,u]),h=y.useCallback(()=>{var g;((g=a.current)==null?void 0:g.state)==="recording"&&a.current.stop()},[]),p=y.useCallback(()=>{a.current&&(a.current.ondataavailable=null,a.current.onstop=null,a.current.state==="recording"&&a.current.stop()),u()},[u]);y.useEffect(()=>()=>{var g;((g=a.current)==null?void 0:g.state)==="recording"&&a.current.stop(),u()},[u]);const v=g=>{const x=Math.floor(g/1e3),C=Math.floor(x/60),w=x%60;return`${C}:${w.toString().padStart(2,"0")}`};return t?s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx(ne,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full shrink-0 text-destructive",onClick:p,children:s.jsx(Bn,{className:"h-5 w-5"})}),s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-destructive animate-pulse"}),s.jsx("span",{className:"text-sm font-mono text-muted-foreground",children:v(r)})]}),s.jsx(ne,{size:"icon",className:"h-9 w-9 rounded-full shrink-0",onClick:h,children:s.jsx(Sg,{className:"h-4 w-4",fill:"currentColor"})})]}):s.jsx(ne,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full shrink-0",onClick:m,children:s.jsx(vg,{className:"h-5 w-5"})})},lr=32,S0=({url:e,isMine:t})=>{var w;const[n,r]=y.useState(!1),[o,a]=y.useState(0),[c,i]=y.useState(0),[l,d]=y.useState(()=>Array.from({length:lr},()=>.15+Math.random()*.85)),u=y.useRef(null),m=y.useRef(0),h=y.useRef(!1);y.useEffect(()=>{if(h.current)return;h.current=!0,(async()=>{try{const j=await(await fetch(e)).arrayBuffer(),N=new AudioContext,O=(await N.decodeAudioData(j)).getChannelData(0),k=Math.floor(O.length/lr),P=[];for(let D=0;D<lr;D++){let E=0;const F=D*k;for(let T=F;T<F+k&&T<O.length;T++)E+=Math.abs(O[T]);P.push(E/k)}const I=Math.max(...P,.01),A=P.map(D=>Math.max(.08,D/I));d(A),await N.close()}catch{}})()},[e]);const p=y.useCallback(()=>{const b=u.current;b&&(b.duration&&(a(b.currentTime/b.duration),i(b.duration)),b.paused||(m.current=requestAnimationFrame(p)))},[]);y.useEffect(()=>{const b=new Audio(e);return u.current=b,b.addEventListener("loadedmetadata",()=>{i(b.duration)}),b.addEventListener("ended",()=>{r(!1),a(0)}),()=>{cancelAnimationFrame(m.current),b.pause(),b.src=""}},[e]);const v=()=>{const b=u.current;b&&(n?(b.pause(),cancelAnimationFrame(m.current),r(!1)):(b.play(),r(!0),m.current=requestAnimationFrame(p)))},g=b=>{const S=u.current;if(!S||!S.duration)return;const j=b.currentTarget.getBoundingClientRect(),N=(b.clientX-j.left)/j.width;S.currentTime=N*S.duration,a(N)},x=b=>{if(!b||!isFinite(b))return"0:00";const S=Math.floor(b/60),j=Math.floor(b%60);return`${S}:${j.toString().padStart(2,"0")}`},C=Math.floor(o*lr);return s.jsxs("div",{className:"flex items-center gap-2 min-w-[180px] max-w-[260px]",children:[s.jsx(ne,{variant:"ghost",size:"icon",className:`h-10 w-10 rounded-full shrink-0 ${t?"bg-primary-foreground/20 hover:bg-primary-foreground/30 text-primary-foreground":"bg-primary/10 hover:bg-primary/20 text-primary"}`,onClick:v,children:n?s.jsx(bg,{className:"h-5 w-5",fill:"currentColor"}):s.jsx(bc,{className:"h-5 w-5 ml-0.5",fill:"currentColor"})}),s.jsxs("div",{className:"flex-1 flex flex-col gap-1",children:[s.jsx("div",{className:"flex items-end gap-[2px] h-[28px] cursor-pointer",onClick:g,children:l.map((b,S)=>s.jsx("div",{className:"flex-1 rounded-full transition-colors duration-150",style:{height:`${Math.max(3,b*28)}px`,backgroundColor:S<C?t?"hsl(var(--primary-foreground))":"hsl(var(--primary))":t?"hsl(var(--primary-foreground) / 0.35)":"hsl(var(--primary) / 0.3)"}},S))}),s.jsx("span",{className:`text-[11px] font-mono leading-none ${t?"text-primary-foreground/70":"text-muted-foreground"}`,children:x(n?((w=u.current)==null?void 0:w.currentTime)??0:c)})]})]})},j0=({message:e,open:t,onOpenChange:n})=>{const{data:r}=js(),{user:o}=ye(),a=ku(),c=async l=>{a.mutate({conversation_id:l,content:e.content??"",type:e.type,file_url:e.file_url??void 0,file_name:e.file_name??void 0,file_size:e.file_size??void 0,forwarded_from_id:e.id}),n(!1)},i=l=>{var u;if(l.type==="group")return l.name||"Group";const d=l.members.find(m=>m.user_id!==(o==null?void 0:o.id));return((u=d==null?void 0:d.profile)==null?void 0:u.display_name)||"Chat"};return s.jsx(Ht,{open:t,onOpenChange:n,children:s.jsxs(Tt,{className:"max-w-sm",children:[s.jsx("h3",{className:"text-lg font-semibold mb-3",children:"Forward to:"}),s.jsx(Wt,{className:"h-[300px]",children:r==null?void 0:r.map(l=>s.jsx(ne,{variant:"ghost",className:"w-full justify-start mb-1",onClick:()=>c(l.id),children:i(l)},l.id))})]})})},N0=({url:e,onClose:t,forceVideo:n})=>{y.useEffect(()=>{const o=a=>a.key==="Escape"&&t();return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t]);const r=n||e.match(/\.(mp4|webm|ogg|mov)(\?|$)/i);return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[s.jsxs("div",{className:"absolute right-4 top-4 flex gap-2",children:[s.jsx("a",{href:e,download:!0,target:"_blank",rel:"noopener",onClick:o=>o.stopPropagation(),children:s.jsx(ne,{variant:"secondary",size:"icon",children:s.jsx(yc,{className:"h-5 w-5"})})}),s.jsx(ne,{variant:"secondary",size:"icon",onClick:t,children:s.jsx(vn,{className:"h-5 w-5"})})]}),s.jsx("div",{onClick:o=>o.stopPropagation(),className:"max-h-[90vh] max-w-[90vw]",children:r?s.jsx("video",{src:e,controls:!0,autoPlay:!0,className:"max-h-[90vh] max-w-[90vw] rounded-lg"}):s.jsx("img",{src:e,alt:"media",className:"max-h-[90vh] max-w-[90vw] rounded-lg object-contain"})})]})},_0=({photos:e,initialIndex:t,onClose:n})=>{const[r,o]=y.useState(t),a=y.useCallback(()=>o(l=>Math.min(l+1,e.length-1)),[e.length]),c=y.useCallback(()=>o(l=>Math.max(l-1,0)),[]);y.useEffect(()=>{const l=d=>{d.key==="Escape"&&n(),d.key==="ArrowRight"&&a(),d.key==="ArrowLeft"&&c()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[n,a,c]);const i=e[r];return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/85",onClick:n,children:[s.jsxs("div",{className:"absolute right-4 top-4 flex items-center gap-2 z-10",children:[s.jsxs("span",{className:"text-white/70 text-sm mr-2",children:[r+1," / ",e.length]}),s.jsx("a",{href:i.url,download:!0,target:"_blank",rel:"noopener",onClick:l=>l.stopPropagation(),children:s.jsx(ne,{variant:"secondary",size:"icon",children:s.jsx(yc,{className:"h-5 w-5"})})}),s.jsx(ne,{variant:"secondary",size:"icon",onClick:n,children:s.jsx(vn,{className:"h-5 w-5"})})]}),r>0&&s.jsx("button",{className:"absolute left-4 top-1/2 -translate-y-1/2 z-10 flex h-10 w-10 items-center justify-center rounded-full bg-white/10 text-white backdrop-blur-sm transition hover:bg-white/20",onClick:l=>{l.stopPropagation(),c()},children:s.jsx(lg,{className:"h-6 w-6"})}),r<e.length-1&&s.jsx("button",{className:"absolute right-4 top-1/2 -translate-y-1/2 z-10 flex h-10 w-10 items-center justify-center rounded-full bg-white/10 text-white backdrop-blur-sm transition hover:bg-white/20",onClick:l=>{l.stopPropagation(),a()},children:s.jsx(Cs,{className:"h-6 w-6"})}),s.jsx("div",{onClick:l=>l.stopPropagation(),className:"max-h-[90vh] max-w-[90vw]",children:s.jsx("img",{src:i.url,alt:i.name||"photo",className:"max-h-[90vh] max-w-[90vw] rounded-lg object-contain"})}),e.length>1&&s.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-1.5 z-10",onClick:l=>l.stopPropagation(),children:e.map((l,d)=>s.jsx("button",{onClick:()=>o(d),className:`h-12 w-12 overflow-hidden rounded-md border-2 transition ${d===r?"border-white":"border-transparent opacity-60 hover:opacity-100"}`,children:s.jsx("img",{src:l.url,alt:"",className:"h-full w-full object-cover"})},d))})]})},E0=({photos:e,onPhotoClick:t})=>{const n=e.length;return n===1?s.jsx("div",{className:"cursor-pointer overflow-hidden rounded-lg",onClick:()=>t(0),children:s.jsx("img",{src:e[0].url,alt:e[0].name||"photo",className:"max-h-72 w-full object-cover transition-transform hover:scale-105",loading:"lazy"})}):s.jsx("div",{className:W("grid gap-0.5 overflow-hidden rounded-lg",M0(n)),children:e.map((r,o)=>s.jsx("div",{className:W("relative cursor-pointer overflow-hidden bg-muted",T0(n,o)),onClick:()=>t(o),children:s.jsx("img",{src:r.url,alt:r.name||"photo",className:"h-full w-full object-cover transition-transform hover:scale-105",loading:"lazy"})},o))})};function M0(e){switch(e){case 2:return"grid-cols-2 aspect-[2/1]";case 3:return"grid-cols-3 grid-rows-2 aspect-[3/2]";case 4:return"grid-cols-2 grid-rows-2 aspect-square";case 5:return"grid-cols-6 grid-rows-2 aspect-[3/2]";case 6:return"grid-cols-3 grid-rows-2 aspect-[3/2]";case 7:return"grid-cols-6 grid-rows-3 aspect-[3/2.5]";default:return"grid-cols-2 grid-rows-2 aspect-square"}}function T0(e,t){return e===3?t===0?"row-span-2 col-span-2":"col-span-1":e===5?t<2?"col-span-3":"col-span-2":e===7?t===0?"col-span-3 row-span-2":t<4?"col-span-1":"col-span-2":""}const jo=768;function ta(){const[e,t]=f.useState(void 0);return f.useEffect(()=>{const n=window.matchMedia(`(max-width: ${jo-1}px)`),r=()=>{t(window.innerWidth<jo)};return n.addEventListener("change",r),t(window.innerWidth<jo),()=>n.removeEventListener("change",r)},[]),!!e}const R0=["👍","😁","❤️","😢","🔥","🤣","😱"],Ef=({children:e,message:t,isOwn:n,onReply:r,onEdit:o,onDelete:a,onForward:c,onReact:i})=>{const[l,d]=y.useState(!1),[u,m]=y.useState({x:0,y:0}),[h,p]=y.useState(!1),[v,g]=y.useState(!1),x=ta(),C=y.useRef(null),w=y.useRef(null),b=y.useRef(null),S=y.useRef(null),j=y.useCallback(()=>{d(!1),p(!1),w.current&&(clearTimeout(w.current),w.current=null)},[]);y.useEffect(()=>()=>{C.current&&clearTimeout(C.current),w.current&&clearTimeout(w.current)},[]),y.useEffect(()=>{if(!l)return;const T=z=>{b.current&&!b.current.contains(z.target)&&j()};return document.addEventListener("mousedown",T),document.addEventListener("touchstart",T),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("touchstart",T)}},[l,j]),y.useEffect(()=>{if(!l)return;const T=z=>{z.key==="Escape"&&j()};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[l,j]),y.useEffect(()=>{if(!l||x||!b.current)return;const T=()=>{if(!b.current)return;const $=b.current.getBoundingClientRect(),M=8,H=40,Z=8,V=Math.max(M,window.innerWidth-$.width-H),G=Math.max(Z,window.innerHeight-$.height-Z),B=Math.min(Math.max(u.x,M),V),re=Math.min(Math.max(u.y,Z),G);m(ue=>ue.x===B&&ue.y===re?ue:{x:B,y:re})},z=window.requestAnimationFrame(T);return window.addEventListener("resize",T),()=>{window.cancelAnimationFrame(z),window.removeEventListener("resize",T)}},[l,x,u.x,u.y,h]);const N=y.useCallback(T=>{T.preventDefault(),T.stopPropagation(),!t.is_deleted&&(m({x:T.clientX,y:T.clientY}),d(!0),p(!1),g(!0))},[t.is_deleted]),_=y.useCallback(T=>{if(t.is_deleted)return;const z=T.touches[0];C.current=setTimeout(()=>{var $;C.current=null,($=window.getSelection())==null||$.removeAllRanges(),m({x:z.clientX,y:z.clientY}),d(!0),p(!1),g(!1),w.current=setTimeout(()=>g(!0),350)},500)},[t.is_deleted]),O=y.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),k=y.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),P=T=>{T(),j()},I=T=>{i(T),j()},A=T=>{i(T.native),j()},D=()=>{t.content&&navigator.clipboard.writeText(t.content),j()},E=Kr(new Date(t.created_at),"d MMM yyyy 'at' HH:mm:ss"),F=x?{}:{left:u.x,top:u.y};return s.jsxs("div",{ref:S,onContextMenu:N,onTouchStart:_,onTouchEnd:O,onTouchMove:k,className:"select-none",style:{WebkitTouchCallout:"none"},children:[e,l&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-50 bg-black/30 backdrop-blur-[2px]",onClick:j,onTouchStart:T=>{T.stopPropagation(),j()}}),s.jsx("div",{ref:b,className:[x?"fixed bottom-0 left-0 right-0 z-[60] flex justify-center animate-in slide-in-from-bottom-5 duration-200":"fixed z-[60] animate-in fade-in-0 zoom-in-95 duration-150",x&&!v?"pointer-events-none":""].join(" "),style:x?{}:F,children:s.jsxs("div",{className:`${x?"rounded-t-2xl w-full max-w-[320px]":"rounded-xl"} border border-border bg-popover shadow-2xl overflow-hidden`,children:[!h&&s.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border",children:[R0.map(T=>s.jsx("button",{onClick:()=>I(T),className:"text-2xl hover:scale-125 active:scale-95 transition-transform p-1",children:T},T)),s.jsx("button",{onClick:()=>p(!0),className:"flex items-center justify-center h-9 w-9 rounded-full bg-muted hover:bg-accent transition-colors",children:s.jsx(cg,{className:"h-4 w-4 text-muted-foreground"})})]}),h&&s.jsx("div",{className:"max-h-[350px] overflow-hidden",children:s.jsx(Eo,{data:_o,onEmojiSelect:A,theme:"auto",previewPosition:"none",skinTonePosition:"none",perLine:x?8:9,maxFrequentRows:1})}),!h&&s.jsxs("div",{className:`py-1 ${x?"pb-safe":""}`,children:[s.jsx(Tn,{icon:s.jsx(wc,{className:"h-4 w-4"}),label:"Reply",onClick:()=>P(r)}),s.jsx(Tn,{icon:s.jsx(dg,{className:"h-4 w-4"}),label:"Copy Text",onClick:D}),n&&s.jsx(Tn,{icon:s.jsx(Sr,{className:"h-4 w-4"}),label:"Edit",onClick:()=>P(o)}),s.jsx(Tn,{icon:s.jsx(mg,{className:"h-4 w-4"}),label:"Forward",onClick:()=>P(c)}),s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 text-sm text-muted-foreground",children:[s.jsx("span",{className:"text-xs",children:"🕐"}),s.jsx("span",{className:"text-xs",children:E})]}),n&&s.jsx(Tn,{icon:s.jsx(Bn,{className:"h-4 w-4"}),label:"Delete",onClick:()=>P(a),destructive:!0}),x&&s.jsx("div",{className:"h-4"})]})]})})]})]})},Tn=({icon:e,label:t,onClick:n,destructive:r=!1})=>s.jsxs("button",{onClick:n,className:`flex w-full items-center gap-3 px-4 py-2.5 text-sm transition-colors hover:bg-accent ${r?"text-destructive":"text-popover-foreground"}`,children:[e,s.jsx("span",{children:t})]}),k0=({reactions:e,onToggle:t,isOwn:n})=>{const[r,o]=y.useState(null),a=ta(),c=y.useRef(null),i=y.useRef(null),l=y.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);if(!e||e.length===0)return null;const d=e.find(u=>u.emoji===r);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`flex flex-wrap gap-1 mt-1 ${n?"justify-end":"justify-start"}`,children:e.map(u=>s.jsxs("div",{className:"relative",onMouseEnter:()=>!a&&o(u.emoji),onMouseLeave:()=>!a&&o(null),children:[s.jsxs("button",{onClick:m=>{if(m.stopPropagation(),a&&r===u.emoji){o(null);return}t(u.emoji)},onTouchStart:()=>{c.current=setTimeout(()=>{o(u.emoji)},400)},onTouchEnd:()=>l(),onTouchMove:()=>l(),className:`flex items-center gap-1 rounded-full px-2 py-0.5 text-xs transition-colors border ${u.hasReacted?"bg-primary/15 border-primary/40 text-primary":"bg-muted/60 border-border text-foreground hover:bg-muted"}`,children:[s.jsx("span",{className:"text-sm",children:u.emoji}),s.jsx("span",{className:"font-medium",children:u.count})]}),!a&&r===u.emoji&&s.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50",children:s.jsxs("div",{className:"bg-popover border border-border rounded-lg shadow-xl p-2 min-w-[160px] max-w-[220px]",children:[s.jsx("div",{className:"text-center text-lg mb-1",children:u.emoji}),s.jsx("div",{className:"space-y-1.5",children:u.users.map(m=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Ce,{className:"h-6 w-6 flex-shrink-0",children:[s.jsx(_e,{src:m.avatar_url??void 0}),s.jsx(Se,{className:"text-[10px]",children:m.display_name.slice(0,2).toUpperCase()})]}),s.jsx("span",{className:"text-xs text-popover-foreground truncate",children:m.display_name})]},m.user_id))})]})})]},u.emoji))}),a&&d&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-50 bg-black/30 backdrop-blur-[2px]",onClick:()=>o(null)}),s.jsx("div",{ref:i,className:"fixed bottom-0 left-0 right-0 z-50 flex justify-center animate-in slide-in-from-bottom-5 duration-200",children:s.jsxs("div",{className:"rounded-t-2xl border border-border bg-popover shadow-2xl overflow-hidden w-full max-w-[320px]",children:[s.jsx("div",{className:"text-center text-2xl pt-3 pb-1",children:d.emoji}),s.jsx("div",{className:"px-4 pb-4 space-y-2 max-h-[300px] overflow-y-auto",children:d.users.map(u=>s.jsxs("div",{className:"flex items-center gap-3 py-1.5",children:[s.jsxs(Ce,{className:"h-8 w-8 flex-shrink-0",children:[s.jsx(_e,{src:u.avatar_url??void 0}),s.jsx(Se,{className:"text-xs",children:u.display_name.slice(0,2).toUpperCase()})]}),s.jsx("span",{className:"text-sm text-popover-foreground",children:u.display_name})]},u.user_id))}),s.jsx("div",{className:"h-4"})]})})]})]})},P0=()=>s.jsx("div",{className:"absolute inset-0 pointer-events-none overflow-hidden opacity-[0.07] dark:opacity-[0.05]",children:s.jsxs("svg",{className:"w-full h-full",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("defs",{children:s.jsxs("pattern",{id:"chat-pattern",x:"0",y:"0",width:"200",height:"200",patternUnits:"userSpaceOnUse",children:[s.jsxs("g",{transform:"translate(20, 20) rotate(15)",children:[s.jsx("path",{d:"M0 0 L16 8 L6 10 L4 16 Z",fill:"currentColor"}),s.jsx("path",{d:"M6 10 L16 8 L4 16 Z",fill:"currentColor",opacity:"0.6"})]}),s.jsx("g",{transform:"translate(90, 30)",children:s.jsx("path",{d:"M8 14s-5.5-4-5.5-7.5a3 3 0 0 1 5.5-1.5 3 3 0 0 1 5.5 1.5c0 3.5-5.5 7.5-5.5 7.5z",fill:"currentColor"})}),s.jsx("g",{transform:"translate(160, 15)",children:s.jsx("path",{d:"M8 0l2.5 5 5.5.8-4 3.9.9 5.3L8 12.5 3.1 15l.9-5.3-4-3.9 5.5-.8z",fill:"currentColor"})}),s.jsx("g",{transform:"translate(50, 80)",children:s.jsx("path",{d:"M2 0h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6l-4 3v-3a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2z",fill:"currentColor"})}),s.jsxs("g",{transform:"translate(130, 75)",children:[s.jsx("circle",{cx:"8",cy:"8",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),s.jsx("circle",{cx:"5.5",cy:"6",r:"1",fill:"currentColor"}),s.jsx("circle",{cx:"10.5",cy:"6",r:"1",fill:"currentColor"}),s.jsx("path",{d:"M5 10.5a3.5 3.5 0 0 0 6 0",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]}),s.jsxs("g",{transform:"translate(15, 140)",children:[s.jsx("rect",{x:"0",y:"3",width:"16",height:"11",rx:"2",fill:"currentColor"}),s.jsx("circle",{cx:"8",cy:"9",r:"3.5",fill:"currentColor",opacity:"0.4"}),s.jsx("rect",{x:"5",y:"0",width:"6",height:"4",rx:"1",fill:"currentColor"})]}),s.jsxs("g",{transform:"translate(100, 140)",children:[s.jsx("circle",{cx:"4",cy:"13",r:"3",fill:"currentColor"}),s.jsx("rect",{x:"6.5",y:"2",width:"1.5",height:"11",fill:"currentColor"}),s.jsx("path",{d:"M7 2 Q12 0 12 4",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),s.jsx("g",{transform:"translate(160, 130)",children:s.jsx("path",{d:"M6 14h10a4 4 0 0 0 .9-7.9A5 5 0 0 0 7.2 4 4.5 4.5 0 0 0 2.5 10 3.5 3.5 0 0 0 6 14z",fill:"currentColor"})}),s.jsx("g",{transform:"translate(55, 165)",children:s.jsx("path",{d:"M8 0a5 5 0 0 0-5 5c0 4 5 10 5 10s5-6 5-10a5 5 0 0 0-5-5zm0 7a2 2 0 1 1 0-4 2 2 0 0 1 0 4z",fill:"currentColor"})}),s.jsx("circle",{cx:"40",cy:"60",r:"2",fill:"currentColor"}),s.jsx("circle",{cx:"120",cy:"55",r:"1.5",fill:"currentColor"}),s.jsx("circle",{cx:"180",cy:"95",r:"2",fill:"currentColor"}),s.jsx("circle",{cx:"75",cy:"120",r:"1.5",fill:"currentColor"}),s.jsx("circle",{cx:"145",cy:"110",r:"2",fill:"currentColor"}),s.jsx("circle",{cx:"30",cy:"185",r:"1.5",fill:"currentColor"}),s.jsx("circle",{cx:"175",cy:"175",r:"2",fill:"currentColor"}),s.jsx("g",{transform:"translate(140, 50) rotate(-10) scale(0.7)",children:s.jsx("path",{d:"M0 0 L16 8 L6 10 L4 16 Z",fill:"currentColor"})}),s.jsxs("g",{transform:"translate(85, 175) rotate(-30)",children:[s.jsx("rect",{x:"0",y:"0",width:"3",height:"14",rx:"0.5",fill:"currentColor"}),s.jsx("path",{d:"M0 14 L1.5 18 L3 14Z",fill:"currentColor"})]})]})}),s.jsx("rect",{width:"100%",height:"100%",fill:"url(#chat-pattern)"})]})}),A0=({open:e,onOpenChange:t,members:n,groupName:r,onMemberClick:o})=>{const a=i=>i.profile.is_online?"online":i.profile.last_seen?`last seen ${Ad(new Date(i.profile.last_seen),{addSuffix:!1})} ago`:"offline",c=[...n].sort((i,l)=>{if(i.profile.is_online&&!l.profile.is_online)return-1;if(!i.profile.is_online&&l.profile.is_online)return 1;const d=i.profile.last_seen?new Date(i.profile.last_seen).getTime():0;return(l.profile.last_seen?new Date(l.profile.last_seen).getTime():0)-d});return s.jsx(Ht,{open:e,onOpenChange:t,children:s.jsxs(Tt,{className:"sm:max-w-[400px] p-0 gap-0",children:[s.jsx(yn,{className:"px-4 pt-4 pb-3 border-b border-border",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ce,{className:"h-12 w-12",children:s.jsx(Se,{className:"text-sm font-semibold",children:r.slice(0,2).toUpperCase()})}),s.jsxs("div",{children:[s.jsx(Vt,{className:"text-base",children:r}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:[n.length," members"]})]})]})}),s.jsx(Wt,{className:"max-h-[60vh]",children:s.jsx("div",{className:"py-1",children:c.map(i=>s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>{o==null||o(i.user_id),t(!1)},children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Ce,{className:"h-11 w-11",children:[s.jsx(_e,{src:i.profile.avatar_url??void 0}),s.jsx(Se,{className:"text-sm",children:i.profile.display_name.slice(0,2).toUpperCase()})]}),i.profile.is_online&&s.jsx("div",{className:"absolute bottom-0 right-0 h-3.5 w-3.5 rounded-full bg-green-500 border-2 border-background"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:i.profile.display_name}),s.jsx("p",{className:`text-xs ${i.profile.is_online?"text-green-500":"text-muted-foreground"}`,children:a(i)})]})]},i.user_id))})})]})})},O0=({conversationId:e,onBack:t})=>{var ra,oa,sa;const n=ve(),r=rs(),{user:o}=ye(),{messages:a,isLoading:c,fetchNextPage:i,hasNextPage:l,isFetchingNextPage:d}=Rw(e),u=kw(e),m=Dw(e),h=Iw(),{data:p}=js(),v=ku(),g=Pw(),x=Aw(),C=Ow(),{toast:w}=xn(),b=oe.useQueryClient(),[S,j]=y.useState(""),[N,_]=y.useState(null),[O,k]=y.useState(null),[P,I]=y.useState(null),[A,D]=y.useState(!1),[E,F]=y.useState(""),[T,z]=y.useState(null),[$,M]=y.useState(!1),[H,Z]=y.useState(null),[V,G]=y.useState(0),[B,re]=y.useState(!0),[ue,J]=y.useState(null),[Pe,he]=y.useState(!1),[ze,Ae]=y.useState(!1),[Ve,Ge]=y.useState(""),[Gt,Rt]=y.useState(!1),[Yt,kt]=y.useState(!1),[Pt,lt]=y.useState(!1),Kt=y.useRef(null),je=y.useRef(null),bn=y.useRef(null),We=y.useRef(null),Yn=y.useRef(null),Xt=y.useRef(0),we=y.useRef(!1),et=y.useRef(new Set),wn=y.useRef(null),Kn=y.useRef(C);Kn.current=C;const At=y.useRef(u);At.current=u;const Cn=y.useRef(e);Cn.current=e;const te=p==null?void 0:p.find(R=>R.id===e),Ot=y.useMemo(()=>{if(!a||!o)return null;for(const R of a)if(R.sender_id!==o.id&&u.has(R.id))return R.id;return null},[a,o,u]),tt=u.size,Xn=y.useCallback(()=>{const R=je.current;if(!R)return;const Q=R.scrollHeight-R.scrollTop-R.clientHeight<100;re(Q)},[]);y.useEffect(()=>{if(!a||a.length===0||we.current)return;const R=je.current;R&&requestAnimationFrame(()=>{We.current?We.current.scrollIntoView({block:"center"}):R.scrollTop=R.scrollHeight,we.current=!0})},[a,Ot]),y.useEffect(()=>{we.current=!1},[e]);const dt=y.useRef(0);y.useEffect(()=>{if(!a)return;const R=je.current;R&&(a.length>dt.current&&B&&we.current&&requestAnimationFrame(()=>{R.scrollTop=R.scrollHeight}),dt.current=a.length)},[a,B]),y.useEffect(()=>{const R=bn.current,q=je.current;if(!R||!q)return;const Q=new IntersectionObserver(le=>{le[0].isIntersecting&&l&&!d&&(Xt.current=q.scrollHeight,i())},{root:q,threshold:0});return Q.observe(R),()=>Q.disconnect()},[l,d,i]),y.useEffect(()=>{if(!d&&Xt.current>0){const R=je.current;if(R){const q=R.scrollHeight-Xt.current;R.scrollTop+=q}Xt.current=0}},[d]),y.useEffect(()=>{const R=je.current;if(!R||!o||!e)return;const q=new IntersectionObserver(le=>{for(const de of le)if(de.isIntersecting){const Be=de.target.dataset.msgId;Be&&At.current.has(Be)&&(et.current.add(Be),wn.current&&clearTimeout(wn.current),wn.current=setTimeout(()=>{const U=Array.from(et.current);U.length>0&&Cn.current&&(Kn.current.mutate({messageIds:U,conversationId:Cn.current}),et.current.clear())},500))}},{root:R,threshold:.5});return R.querySelectorAll("[data-unread='true']").forEach(le=>q.observe(le)),()=>q.disconnect()},[a,u,o,e]);const Sn=y.useCallback(()=>{const R=je.current;R&&(R.scrollTo({top:R.scrollHeight,behavior:"smooth"}),u.size>0&&e&&C.mutate({messageIds:Array.from(u),conversationId:e}))},[u,e,C]);y.useEffect(()=>{if(!Pe)return;const R=q=>{Kt.current&&!Kt.current.contains(q.target)&&he(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[Pe]);const Qn=5e3,Dt=async()=>{if(!e||!S.trim())return;if(S.length>Qn){w({title:"Message too long",description:`Messages must be ${Qn} characters or fewer`,variant:"destructive"});return}if(O){g.mutate({id:O.id,content:S,conversationId:e}),k(null),j("");return}const R=`temp-${crypto.randomUUID()}`;v.mutate({conversation_id:e,content:S,reply_to_id:N==null?void 0:N.id,_tempId:R}),j(""),_(null),setTimeout(()=>Sn(),50)},Zn=R=>{if(!e)return;const q=["messages",e];b.setQueryData(q,Q=>Q!=null&&Q.pages?{...Q,pages:Q.pages.map(le=>le.filter(de=>de.id!==R.id))}:Q),v.mutate({conversation_id:e,content:R.content||"",reply_to_id:R.reply_to_id||void 0,_tempId:`temp-${crypto.randomUUID()}`})},eo=R=>{if(!e)return;const q=["messages",e];b.setQueryData(q,Q=>Q!=null&&Q.pages?{...Q,pages:Q.pages.map(le=>le.filter(de=>de.id!==R))}:Q)},jn={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",mp4:"video/mp4",mov:"video/quicktime",pdf:"application/pdf",txt:"text/plain",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",zip:"application/zip"},nt=50*1024*1024,to=async R=>{var le;const q=R.target.files;if(!q||q.length===0||!e||!o)return;const Q=Array.from(q).slice(0,7);q.length>7&&w({title:"Limit exceeded",description:"You can upload up to 7 photos at once",variant:"destructive"});for(const de of Q){if(de.size>nt){w({title:"File too large",description:`${de.name} exceeds the 50 MB limit`,variant:"destructive"});continue}const Be=((le=de.name.split(".").pop())==null?void 0:le.toLowerCase())??"",U=jn[Be];if(!U){w({title:"File type not allowed",description:`${de.name} is not a supported file type`,variant:"destructive"});continue}const ft=`${o.id}/${e}/${crypto.randomUUID()}`,{error:xe}=await n.storage.from("chat-media").upload(ft,de,{contentType:U});if(xe){w({title:"Upload error",description:`${de.name}: ${xe.message}`,variant:"destructive"});continue}const{data:Lt}=n.storage.from("chat-media").getPublicUrl(ft),Qt=U.startsWith("image/"),mt=U.startsWith("video/");v.mutate({conversation_id:e,content:de.name,type:Qt?"photo":mt?"video":"file",file_url:Lt.publicUrl,file_name:de.name,file_size:de.size})}R.target.value=""},Y=async(R,q)=>{if(!e||!o)return;const Q=R.type.includes("webm")?"webm":"ogg",le=`${o.id}/${e}/${crypto.randomUUID()}.${Q}`,{error:de}=await n.storage.from("chat-media").upload(le,R,{contentType:R.type});if(de){w({title:"Upload error",description:de.message,variant:"destructive"});return}const{data:Be}=n.storage.from("chat-media").getPublicUrl(le);v.mutate({conversation_id:e,content:`Voice message (${Math.ceil(q/1e3)}s)`,type:"voice",file_url:Be.publicUrl,file_name:`voice.${Q}`,file_size:R.size}),setTimeout(()=>Sn(),50)},se=async()=>{if(!e||!Ve.trim())return;const{error:R}=await n.from("conversations").update({name:Ve.trim()}).eq("id",e);if(R){w({title:"Error",description:R.message,variant:"destructive"});return}b.invalidateQueries({queryKey:["conversations"]}),Ae(!1),w({title:"Group name updated"})},fe=async()=>{if(!e)return;const{error:R}=await n.from("messages").update({is_deleted:!0,content:null}).eq("conversation_id",e);if(R){w({title:"Error",description:R.message,variant:"destructive"});return}b.invalidateQueries({queryKey:["messages",e]}),Rt(!1),w({title:"Chat history cleared"})},Oe=async()=>{if(!e||!o)return;const{error:R}=await n.from("conversation_members").delete().eq("conversation_id",e).eq("user_id",o.id);if(R){w({title:"Error",description:R.message,variant:"destructive"});return}b.invalidateQueries({queryKey:["conversations"]}),kt(!1),t==null||t(),w({title:"You left the group"})},be=y.useMemo(()=>a?E?a.filter(R=>{var q;return(q=R.content)==null?void 0:q.toLowerCase().includes(E.toLowerCase())}):a:[],[a,E]),Ye=y.useCallback((R,q)=>{e&&h.mutate({messageId:R,emoji:q,conversationId:e})},[e,h]),[ut,Ne]=y.useState(null),[De,na]=y.useState(null);y.useEffect(()=>{if(!De)return;const R=je.current;if(!R)return;const q=requestAnimationFrame(()=>{const Q=R.querySelector(`[data-msg-id="${De}"]`);Q&&(Q.scrollIntoView({behavior:"instant",block:"center"}),Ne(De),setTimeout(()=>Ne(null),2e3),na(null))});return()=>cancelAnimationFrame(q)},[De,a]);const Of=y.useCallback(async R=>{const q=je.current;if(!q)return;const Q=q.querySelector(`[data-msg-id="${R}"]`);if(Q){Q.scrollIntoView({behavior:"instant",block:"center"}),Ne(R),setTimeout(()=>Ne(null),2e3);return}na(R),(async()=>{var U,ft;let de=0;const Be=20;for(;de<Be;){const xe=b.getQueryData(["messages",e]);if(((U=xe==null?void 0:xe.pages)==null?void 0:U.some(mt=>mt.some(Ke=>Ke.id===R)))||!(xe!=null&&xe.pages?((ft=xe.pages[xe.pages.length-1])==null?void 0:ft.length)===30:!1))break;await i(),de++,await new Promise(mt=>setTimeout(mt,100))}})()},[e,i,b]);if(!e)return s.jsx("div",{className:"flex flex-1 items-center justify-center bg-muted/30",children:s.jsx("p",{className:"text-muted-foreground",children:"Select a chat to start messaging"})});const no=te?I0(te,(o==null?void 0:o.id)??""):"Chat",Df=te?L0(te,(o==null?void 0:o.id)??""):null,It=(te==null?void 0:te.type)==="private"?te.members.find(R=>R.user_id!==(o==null?void 0:o.id)):null;return s.jsxs("div",{className:"flex flex-1 flex-col h-full overflow-hidden pt-[60px] md:pt-0",children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-border px-4 py-3 fixed top-0 left-0 right-0 z-40 bg-background md:relative md:top-auto md:left-auto md:right-auto md:z-auto",children:[t&&s.jsx(ne,{variant:"ghost",size:"icon",onClick:t,children:s.jsx(sg,{className:"h-5 w-5"})}),s.jsxs(Ce,{className:"h-10 w-10 cursor-pointer",onClick:()=>{(te==null?void 0:te.type)==="private"&&It&&J(It.user_id)},children:[s.jsx(_e,{src:Df??void 0}),s.jsx(Se,{children:no.slice(0,2).toUpperCase()})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h2",{className:"font-semibold text-foreground cursor-pointer hover:underline truncate",onClick:()=>{(te==null?void 0:te.type)==="private"&&It&&J(It.user_id)},children:no}),(te==null?void 0:te.type)==="group"?s.jsxs("p",{className:"text-xs text-muted-foreground cursor-pointer hover:underline",onClick:()=>lt(!0),children:[te.members.length," members"]}):s.jsx("p",{className:"text-xs text-muted-foreground",children:(ra=It==null?void 0:It.profile)!=null&&ra.is_online?"online":"offline"})]}),s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>{D(!A),F("")},children:s.jsx(Dn,{className:"h-5 w-5"})}),(te==null?void 0:te.type)==="group"&&s.jsxs(rf,{children:[s.jsx(of,{asChild:!0,children:s.jsx(ne,{variant:"ghost",size:"icon",children:s.jsx(fg,{className:"h-5 w-5"})})}),s.jsxs(ea,{align:"end",className:"w-48",children:[s.jsxs(ht,{onClick:()=>{Ge(te.name||""),Ae(!0)},children:[s.jsx(Sr,{className:"h-4 w-4 mr-2"}),"Edit"]}),s.jsxs(ht,{onClick:()=>{te.members.length>0&&J(te.members[0].user_id)},children:[s.jsx(pg,{className:"h-4 w-4 mr-2"}),"Info"]}),s.jsxs(ht,{onClick:()=>w({title:"Notifications muted"}),children:[s.jsx(Lo,{className:"h-4 w-4 mr-2"}),"Mute"]}),s.jsx(cn,{}),s.jsxs(ht,{onClick:()=>Rt(!0),children:[s.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Clear Chat History"]}),s.jsx(cn,{}),s.jsxs(ht,{className:"text-destructive focus:text-destructive",onClick:()=>kt(!0),children:[s.jsx(Ss,{className:"h-4 w-4 mr-2"}),"Leave Group"]})]})]})]}),A&&s.jsx("div",{className:"border-b border-border px-4 py-2",children:s.jsxs("div",{className:"relative",children:[s.jsx(Dn,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(qe,{placeholder:"Search messages...",value:E,onChange:R=>F(R.target.value),className:"pl-9",autoFocus:!0})]})}),s.jsxs("div",{className:"relative flex-1 overflow-hidden md:bg-transparent bg-gradient-to-br from-[hsl(var(--chat-gradient-from))] via-[hsl(var(--chat-gradient-via))] to-[hsl(var(--chat-gradient-to))]",children:[s.jsx("div",{className:"md:hidden",children:s.jsx(P0,{})}),s.jsxs("div",{ref:je,className:"h-full overflow-y-auto px-4 py-2 md:pb-2 pb-20",onScroll:Xn,children:[l&&s.jsx("div",{ref:bn,className:"h-1"}),d&&s.jsx("div",{className:"flex justify-center py-2",children:s.jsx(on,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),c&&s.jsx("div",{className:"flex justify-center py-8 text-muted-foreground",children:"Loading..."}),(()=>{const R=[];for(let q=0;q<be.length;q++){const Q=be[q],le=R[R.length-1];if(le!=null&&le.isPhotoGroup&&Q.type==="photo"&&Q.file_url&&Q.sender_id===le.msgs[0].sender_id&&Math.abs(new Date(Q.created_at).getTime()-new Date(le.msgs[le.msgs.length-1].created_at).getTime())<1e4)le.msgs.push(Q);else{const de=Q.type==="photo"&&!!Q.file_url;R.push({msgs:[Q],isPhotoGroup:de})}}return R.map(q=>{var Q,le,de,Be;if(q.isPhotoGroup&&q.msgs.length>1){const U=q.msgs[0],ft=q.msgs[q.msgs.length-1],xe=U.sender_id===(o==null?void 0:o.id),Lt=be[be.indexOf(U)-1],Qt=!Lt||!ti(new Date(Lt.created_at),new Date(U.created_at)),mt=q.msgs.some(Ie=>Ie.id===Ot),Ke=q.msgs.map(Ie=>({url:Ie.file_url,name:Ie.file_name||void 0})),ro=Kr(new Date(ft.created_at),"HH:mm"),If=q.msgs.some(Ie=>o&&Ie.sender_id!==o.id&&u.has(Ie.id));return s.jsxs("div",{"data-msg-id":U.id,"data-unread":If?"true":"false",children:[Qt&&s.jsx(ei,{date:new Date(U.created_at)}),mt&&s.jsx("div",{ref:We,className:"my-3 flex justify-center",children:s.jsx("span",{className:"rounded-full bg-primary/20 px-3 py-1 text-xs text-primary font-medium",children:"Unread messages"})}),s.jsxs("div",{className:`mb-1 flex ${xe?"justify-end":"justify-start"}`,children:[(te==null?void 0:te.type)==="group"&&!xe&&s.jsxs(Ce,{className:"h-8 w-8 mr-2 mt-1 flex-shrink-0 cursor-pointer",onClick:()=>J(U.sender_id),children:[s.jsx(_e,{src:((Q=U.sender_profile)==null?void 0:Q.avatar_url)??void 0}),s.jsx(Se,{className:"text-xs",children:(de=(le=U.sender_profile)==null?void 0:le.display_name)==null?void 0:de.slice(0,2).toUpperCase()})]}),s.jsx("div",{className:"max-w-[75%]",children:s.jsx(Ef,{message:U,isOwn:xe,onReply:()=>_(U),onEdit:()=>{},onDelete:()=>q.msgs.forEach(Ie=>x.mutate({id:Ie.id,conversationId:e})),onForward:()=>I(U),onReact:Ie=>Ye(U.id,Ie),children:s.jsxs("div",{className:`relative rounded-2xl px-1 py-1 ${xe?"bg-chat-bubble-out text-chat-bubble-out-foreground rounded-br-md":"bg-chat-bubble-in text-chat-bubble-in-foreground rounded-bl-md"}`,children:[(te==null?void 0:te.type)==="group"&&!xe&&s.jsx("p",{className:"mb-0.5 px-2 text-xs font-semibold text-primary cursor-pointer hover:underline truncate max-w-[200px]",onClick:()=>J(U.sender_id),children:(Be=U.sender_profile)==null?void 0:Be.display_name}),s.jsx(E0,{photos:Ke,onPhotoClick:Ie=>{Z(Ke),G(Ie)}}),s.jsxs("div",{className:`mt-0.5 px-2 flex items-center justify-end gap-1 text-[10px] ${xe?"text-chat-bubble-out-foreground/50":"text-chat-bubble-in-foreground/50"}`,children:[s.jsxs("span",{children:[Ke.length," photos"]}),s.jsx("span",{children:ro}),xe&&s.jsx(zt,{className:"h-3 w-3"})]})]})})})]})]},U.id)}return q.msgs.map(U=>{const ft=be.indexOf(U),xe=be[ft-1],Lt=!xe||!ti(new Date(xe.created_at),new Date(U.created_at)),Qt=U.id===Ot,mt=o&&U.sender_id!==o.id&&u.has(U.id);return s.jsxs("div",{"data-msg-id":U.id,"data-unread":mt?"true":"false",className:`transition-colors duration-700 ${ut===U.id?"bg-primary/15 rounded-lg":""}`,children:[Lt&&s.jsx(ei,{date:new Date(U.created_at)}),Qt&&s.jsx("div",{ref:We,className:"my-3 flex justify-center",children:s.jsx("span",{className:"rounded-full bg-primary/20 px-3 py-1 text-xs text-primary font-medium",children:"Unread messages"})}),s.jsx(D0,{message:U,isOwn:U.sender_id===(o==null?void 0:o.id),isGroup:(te==null?void 0:te.type)==="group",onReply:()=>_(U),onEdit:()=>{k(U),j(U.content??"")},onDelete:()=>x.mutate({id:U.id,conversationId:e}),onForward:()=>I(U),onMediaClick:(Ke,ro)=>{z(Ke),M(!!ro)},onReact:Ke=>Ye(U.id,Ke),reactions:m[U.id]??[],searchQuery:E,onProfileClick:Ke=>J(Ke),onRetry:U._optimistic&&U._status==="failed"?()=>Zn(U):void 0,onCancel:U._optimistic&&U._status==="failed"?()=>eo(U.id):void 0,onScrollToReply:Of})]},U.id)})})})()]}),!B&&s.jsxs("button",{onClick:Sn,className:"absolute bottom-20 md:bottom-4 right-4 flex h-10 w-10 items-center justify-center rounded-full bg-card border border-border shadow-lg transition-transform hover:scale-105 active:scale-95 z-10",children:[s.jsx(og,{className:"h-5 w-5 text-foreground"}),tt>0&&s.jsx("span",{className:"absolute -top-2 -right-2 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-bold text-primary-foreground",children:tt>99?"99+":tt})]})]}),(N||O)&&s.jsxs("div",{className:"flex items-center gap-2 border-t border-border bg-muted/50 px-4 py-2 md:relative fixed bottom-14 left-0 right-0 z-40 md:bottom-auto md:left-auto md:right-auto md:z-auto",children:[s.jsx("div",{className:"flex-1 truncate text-sm",children:O?s.jsxs("span",{className:"text-primary",children:[s.jsx(Sr,{className:"mr-1 inline h-3 w-3"}),"Editing"]}):s.jsxs("span",{className:"text-primary",children:[s.jsx(wc,{className:"mr-1 inline h-3 w-3"}),(oa=N==null?void 0:N.sender_profile)==null?void 0:oa.display_name,": ",(sa=N==null?void 0:N.content)==null?void 0:sa.slice(0,50)]})}),s.jsx(ne,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>{_(null),k(null),j("")},children:s.jsx(vn,{className:"h-4 w-4"})})]}),s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 md:border-t md:border-border md:bg-background md:px-4 md:py-3 md:relative fixed bottom-0 left-0 right-0 z-40 md:bottom-auto md:left-auto md:right-auto md:z-auto",children:[s.jsx("input",{ref:Yn,type:"file",className:"hidden",onChange:to,multiple:!0,accept:"image/*,video/*,application/*"}),r.allowFileUpload&&s.jsx(ne,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full md:rounded-md shrink-0",onClick:()=>{var R;return(R=Yn.current)==null?void 0:R.click()},children:s.jsx(yg,{className:"h-5 w-5"})}),s.jsx(qe,{placeholder:"Message...",value:S,onChange:R=>j(R.target.value),onKeyDown:R=>R.key==="Enter"&&!R.shiftKey&&Dt(),className:"flex-1 md:rounded-md rounded-full bg-card/90 md:bg-background backdrop-blur-sm md:backdrop-blur-none border-border/50"}),s.jsxs("div",{className:`relative ${S.trim()?"":"hidden md:block"}`,ref:Kt,children:[s.jsx(ne,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full md:rounded-md shrink-0",onClick:()=>he(R=>!R),children:s.jsx(Cg,{className:"h-5 w-5"})}),Pe&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-50 bg-black/30 backdrop-blur-[2px] md:hidden",onClick:()=>he(!1)}),s.jsx("div",{className:"absolute bottom-12 right-0 z-50 md:block hidden",children:s.jsx(Eo,{data:_o,onEmojiSelect:R=>{j(q=>q+R.native),he(!1)},theme:"auto",previewPosition:"none",skinTonePosition:"none"})}),s.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-50 flex justify-center animate-in slide-in-from-bottom-5 duration-200 md:hidden",children:s.jsx("div",{className:"rounded-t-2xl border border-border bg-popover shadow-2xl overflow-hidden w-full max-w-[360px]",children:s.jsx(Eo,{data:_o,onEmojiSelect:R=>{j(q=>q+R.native),he(!1)},theme:"auto",previewPosition:"none",skinTonePosition:"none",perLine:8})})})]})]}),S.trim()?s.jsx(ne,{size:"icon",className:"h-9 w-9 rounded-full shrink-0",onClick:Dt,children:s.jsx(uo,{className:"h-4 w-4"})}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"hidden md:block",children:s.jsx(ne,{size:"icon",className:"h-9 w-9 rounded-full shrink-0",onClick:Dt,disabled:!0,children:s.jsx(uo,{className:"h-4 w-4"})})}),s.jsx("div",{className:"md:hidden",children:r.allowVoiceMessages?s.jsx(C0,{onSend:Y}):s.jsx(ne,{size:"icon",className:"h-9 w-9 rounded-full shrink-0",onClick:Dt,disabled:!0,children:s.jsx(uo,{className:"h-4 w-4"})})})]})]}),P&&s.jsx(j0,{message:P,open:!!P,onOpenChange:()=>I(null)}),T&&s.jsx(N0,{url:T,onClose:()=>{z(null),M(!1)},forceVideo:$}),H&&s.jsx(_0,{photos:H,initialIndex:V,onClose:()=>Z(null)}),ue&&s.jsx(Tu,{open:!!ue,onOpenChange:R=>{R||J(null)},userId:ue}),(te==null?void 0:te.type)==="group"&&s.jsx(A0,{open:Pt,onOpenChange:lt,members:te.members,groupName:no,onMemberClick:R=>J(R)}),s.jsx(Ht,{open:ze,onOpenChange:Ae,children:s.jsxs(Tt,{className:"sm:max-w-[400px]",children:[s.jsx(yn,{children:s.jsx(Vt,{children:"Edit Group Name"})}),s.jsx(qe,{value:Ve,onChange:R=>Ge(R.target.value),placeholder:"Group name",onKeyDown:R=>R.key==="Enter"&&se(),autoFocus:!0}),s.jsxs(eu,{children:[s.jsx(ne,{variant:"outline",onClick:()=>Ae(!1),children:"Cancel"}),s.jsx(ne,{onClick:se,disabled:!Ve.trim(),children:"Save"})]})]})}),s.jsx(Ja,{open:Gt,onOpenChange:Rt,children:s.jsxs(Go,{children:[s.jsxs(Yo,{children:[s.jsx(Xo,{children:"Clear Chat History"}),s.jsx(Qo,{children:"This will delete all messages in this chat. This action cannot be undone."})]}),s.jsxs(Ko,{children:[s.jsx(Jo,{children:"Cancel"}),s.jsx(Zo,{onClick:fe,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Clear"})]})]})}),s.jsx(Ja,{open:Yt,onOpenChange:kt,children:s.jsxs(Go,{children:[s.jsxs(Yo,{children:[s.jsx(Xo,{children:"Leave Group"}),s.jsx(Qo,{children:"Are you sure you want to leave this group? You won't be able to see messages anymore."})]}),s.jsxs(Ko,{children:[s.jsx(Jo,{children:"Cancel"}),s.jsx(Zo,{onClick:Oe,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Leave"})]})]})})]})},ei=({date:e})=>{const t=Xb(e)?"Today":Zb(e)?"Yesterday":Kr(e,"MMM d, yyyy");return s.jsx("div",{className:"my-3 flex justify-center",children:s.jsx("span",{className:"rounded-full bg-muted px-3 py-1 text-xs text-muted-foreground",children:t})})},D0=({message:e,isOwn:t,isGroup:n,onReply:r,onEdit:o,onDelete:a,onForward:c,onMediaClick:i,onReact:l,reactions:d,searchQuery:u,onProfileClick:m,onRetry:h,onCancel:p,onScrollToReply:v})=>{var _,O,k,P,I,A,D;if(e.is_deleted)return s.jsx("div",{className:`mb-1 flex ${t?"justify-end":"justify-start"}`,children:s.jsx("div",{className:"rounded-xl bg-muted px-3 py-2 text-sm italic text-muted-foreground",children:"Message deleted"})});const g=Kr(new Date(e.created_at),"HH:mm"),C=(e.read_by??[]).length>0,w=new RegExp("^(\\p{Emoji_Presentation}|\\p{Extended_Pictographic}){1,3}$","u"),b=e.type==="text"&&e.content&&w.test(e.content.trim())&&!e.reply_to&&!e.forwarded_from_id,S=b?[...e.content.trim()].filter(E=>new RegExp("\\p{Emoji_Presentation}|\\p{Extended_Pictographic}","u").test(E)).length:0,j=S===1?"text-6xl":S===2?"text-5xl":"text-4xl",N=E=>u?E.split(new RegExp(`(${u})`,"gi")).map((T,z)=>T.toLowerCase()===u.toLowerCase()?s.jsx("mark",{className:"bg-primary/30 rounded px-0.5",children:T},z):T):E;return s.jsxs("div",{className:`mb-1 flex ${t?"justify-end":"justify-start"}`,children:[n&&!t&&s.jsxs(Ce,{className:"h-8 w-8 mr-2 mt-1 flex-shrink-0 cursor-pointer",onClick:()=>m==null?void 0:m(e.sender_id),children:[s.jsx(_e,{src:((_=e.sender_profile)==null?void 0:_.avatar_url)??void 0}),s.jsx(Se,{className:"text-xs",children:(k=(O=e.sender_profile)==null?void 0:O.display_name)==null?void 0:k.slice(0,2).toUpperCase()})]}),s.jsxs("div",{className:"max-w-[75%]",children:[s.jsx(Ef,{message:e,isOwn:t,onReply:r,onEdit:o,onDelete:a,onForward:c,onReact:l,children:b?s.jsxs("div",{className:"relative px-1 py-1",children:[n&&!t&&s.jsx("p",{className:"mb-0.5 text-xs font-semibold text-primary cursor-pointer hover:underline truncate max-w-[200px]",onClick:()=>m==null?void 0:m(e.sender_id),children:(P=e.sender_profile)==null?void 0:P.display_name}),s.jsx("p",{className:`${j} leading-tight`,children:e.content}),s.jsxs("div",{className:"mt-0.5 flex items-center justify-end gap-1 text-[10px] text-muted-foreground",children:[e.is_edited&&s.jsx("span",{children:"edited"}),s.jsx("span",{children:g}),t&&(e._optimistic&&e._status==="sending"?s.jsx(on,{className:"h-3 w-3 animate-spin"}):e._optimistic&&e._status==="failed"?s.jsx(Ea,{className:"h-3 w-3 text-destructive"}):C?s.jsx(_a,{className:"h-3 w-3 text-read"}):s.jsx(zt,{className:"h-3 w-3"}))]})]}):s.jsxs("div",{className:`relative rounded-2xl px-3 py-2 ${t?"bg-chat-bubble-out text-chat-bubble-out-foreground rounded-br-md":"bg-chat-bubble-in text-chat-bubble-in-foreground rounded-bl-md"}`,children:[n&&!t&&s.jsx("p",{className:"mb-0.5 text-xs font-semibold text-primary cursor-pointer hover:underline truncate max-w-[200px]",onClick:()=>m==null?void 0:m(e.sender_id),children:(I=e.sender_profile)==null?void 0:I.display_name}),e.reply_to&&s.jsx("div",{className:"mb-1 rounded border-l-2 border-primary bg-muted/50 px-2 py-1 text-xs cursor-pointer hover:bg-muted/80 transition-colors",onClick:()=>e.reply_to_id&&(v==null?void 0:v(e.reply_to_id)),children:(A=e.reply_to.content)==null?void 0:A.slice(0,60)}),e.forwarded_from_id&&s.jsxs("div",{className:"mb-1 flex items-center gap-1 text-xs text-muted-foreground",children:[s.jsx("span",{className:"text-sm",children:"↗"}),s.jsx("span",{children:"Forwarded from "}),s.jsx("span",{className:"font-semibold text-primary cursor-pointer hover:underline",onClick:E=>{var F;E.stopPropagation(),(F=e.forwarded_from_profile)!=null&&F.sender_id&&(m==null||m(e.forwarded_from_profile.sender_id))},children:((D=e.forwarded_from_profile)==null?void 0:D.display_name)||"Unknown"})]}),e.type==="photo"&&e.file_url&&s.jsx("div",{className:"mb-1 cursor-pointer overflow-hidden rounded-lg",onClick:()=>i(e.file_url),children:s.jsx("img",{src:e.file_url,alt:e.file_name||"photo",className:"max-h-60 w-full object-cover transition-transform hover:scale-105",loading:"lazy"})}),e.type==="video"&&e.file_url&&s.jsxs("div",{className:"relative mb-1 cursor-pointer overflow-hidden rounded-2xl bg-black min-h-[200px] max-w-[280px]",onClick:()=>i(e.file_url,!0),children:[s.jsx("video",{src:`${e.file_url}#t=0.1`,className:"min-h-[200px] max-h-80 w-full object-cover",preload:"metadata",muted:!0,playsInline:!0}),s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-black/50 backdrop-blur-md",children:s.jsx(bc,{className:"h-5 w-5 text-white ml-0.5",fill:"white"})})})]}),e.type==="file"&&e.file_url&&s.jsxs("a",{href:e.file_url,target:"_blank",rel:"noopener noreferrer",className:"mb-1 flex items-center gap-2 rounded bg-muted/50 p-2 text-sm hover:bg-muted",children:["📎 ",e.file_name||"File"]}),e.type==="voice"&&e.file_url&&s.jsx(S0,{url:e.file_url,isMine:t}),e.content&&e.type==="text"&&s.jsx("p",{className:"text-sm whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:N(e.content)}),s.jsxs("div",{className:`mt-0.5 flex items-center justify-end gap-1 text-[10px] ${t?"text-chat-bubble-out-foreground/50":"text-chat-bubble-in-foreground/50"}`,children:[e.is_edited&&s.jsx("span",{children:"edited"}),s.jsx("span",{children:g}),t&&(e._optimistic&&e._status==="sending"?s.jsx(on,{className:"h-3 w-3 animate-spin"}):e._optimistic&&e._status==="failed"?s.jsx(Ea,{className:"h-3 w-3 text-destructive"}):C?s.jsx(_a,{className:"h-3 w-3 text-read"}):s.jsx(zt,{className:"h-3 w-3"}))]})]})}),e._optimistic&&e._status==="failed"&&s.jsxs("div",{className:"mt-1 flex items-center justify-end gap-1",children:[s.jsx("span",{className:"text-[11px] text-destructive mr-1",children:"Not sent"}),s.jsxs(ne,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1 text-primary hover:text-primary",onClick:h,children:[s.jsx(wg,{className:"h-3 w-3"}),"Retry"]}),s.jsxs(ne,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1 text-destructive hover:text-destructive",onClick:p,children:[s.jsx(Bn,{className:"h-3 w-3"}),"Cancel"]})]}),s.jsx(k0,{reactions:d,onToggle:E=>l(E),isOwn:t})]})]})};function ti(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function I0(e,t){var r;if(e.type==="group")return e.name||"Group";const n=e.members.find(o=>o.user_id!==t);return((r=n==null?void 0:n.profile)==null?void 0:r.display_name)||"Chat"}function L0(e,t){var r;if(e.type==="group")return e.avatar_url;const n=e.members.find(o=>o.user_id!==t);return(r=n==null?void 0:n.profile)==null?void 0:r.avatar_url}const $0=({onUnreadCountChange:e,onConversationSelect:t}={})=>{const[n,r]=y.useState(null),o=ta(),[a,c]=y.useState(!0),i=d=>{r(d),t==null||t(d),o&&c(!1)},l=()=>{c(!0),o&&r(null)};return s.jsxs("div",{className:"flex h-full w-full overflow-hidden bg-background",children:[(!o||a)&&s.jsx("div",{className:`${o?"w-full":"w-[380px] min-w-[320px] border-r border-border"} flex flex-col h-full overflow-hidden`,children:s.jsx(_w,{activeConversationId:n,onSelectConversation:i,onUnreadCountChange:e})}),(!o||!a)&&s.jsx("div",{className:"flex flex-1 flex-col h-full overflow-hidden",children:s.jsx(O0,{conversationId:n,onBack:o?l:void 0})})]})},Mf=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:W("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Mf.displayName="Card";const Tf=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:W("flex flex-col space-y-1.5 p-6",e),...t}));Tf.displayName="CardHeader";const Rf=f.forwardRef(({className:e,...t},n)=>s.jsx("h3",{ref:n,className:W("text-2xl font-semibold leading-none tracking-tight text-card-foreground",e),...t}));Rf.displayName="CardTitle";const kf=f.forwardRef(({className:e,...t},n)=>s.jsx("p",{ref:n,className:W("text-sm text-muted-foreground",e),...t}));kf.displayName="CardDescription";const Pf=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:W("p-6 pt-0",e),...t}));Pf.displayName="CardContent";const F0=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:W("flex items-center p-6 pt-0",e),...t}));F0.displayName="CardFooter";const z0=()=>{const e=ve(),[t,n]=y.useState("login"),[r,o]=y.useState(""),[a,c]=y.useState(""),[i,l]=y.useState(""),[d,u]=y.useState(!1),{toast:m}=xn(),h=async g=>{g.preventDefault(),u(!0);const{error:x}=await e.auth.signInWithPassword({email:r,password:a});x&&m({title:"Login error",description:x.message,variant:"destructive"}),u(!1)},p=async g=>{g.preventDefault(),u(!0);const{error:x}=await e.auth.signUp({email:r,password:a,options:{data:{display_name:i},emailRedirectTo:window.location.origin}});x?m({title:"Sign up error",description:x.message,variant:"destructive"}):(m({title:"Check your email",description:"We sent a confirmation link"}),n("login")),u(!1)},v=async g=>{g.preventDefault(),u(!0);const{error:x}=await e.auth.resetPasswordForEmail(r,{redirectTo:`${window.location.origin}/reset-password`});m(x?{title:"Error",description:x.message,variant:"destructive"}:{title:"Check your email",description:"Password reset link sent"}),u(!1)};return s.jsx("div",{className:"flex h-full min-h-0 items-center justify-center bg-background p-4 overflow-y-auto",children:s.jsxs(Mf,{className:"w-full max-w-md",children:[s.jsxs(Tf,{className:"text-center",children:[s.jsx("div",{className:"mx-auto mb-2 flex h-14 w-14 items-center justify-center rounded-2xl bg-primary",children:s.jsx(Cr,{className:"h-7 w-7 text-primary-foreground"})}),s.jsx(Rf,{className:"text-2xl",children:t==="login"?"Sign In":t==="signup"?"Sign Up":"Reset Password"}),s.jsx(kf,{children:t==="login"?"Sign in to your account":t==="signup"?"Create a new account":"Enter your email to reset password"})]}),s.jsxs(Pf,{className:"space-y-4",children:[s.jsxs("form",{onSubmit:t==="login"?h:t==="signup"?p:v,className:"space-y-4",children:[t==="signup"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(an,{htmlFor:"name",children:"Name"}),s.jsxs("div",{className:"relative",children:[s.jsx(Sc,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),s.jsx(qe,{id:"name",placeholder:"Your name",value:i,onChange:g=>l(g.target.value),className:"pl-9",required:!0})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(an,{htmlFor:"email",children:"Email"}),s.jsxs("div",{className:"relative",children:[s.jsx(xg,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),s.jsx(qe,{id:"email",type:"email",placeholder:"you@example.com",value:r,onChange:g=>o(g.target.value),className:"pl-9",required:!0})]})]}),t!=="forgot"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(an,{htmlFor:"password",children:"Password"}),s.jsxs("div",{className:"relative",children:[s.jsx(hg,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),s.jsx(qe,{id:"password",type:"password",placeholder:"••••••••",value:a,onChange:g=>c(g.target.value),className:"pl-9",required:!0,minLength:6})]})]}),s.jsx(ne,{type:"submit",className:"w-full",disabled:d,children:d?"Loading...":t==="login"?"Sign In":t==="signup"?"Sign Up":"Send Reset Link"})]}),s.jsx("div",{className:"flex justify-center gap-4 text-sm",children:t==="login"?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"text-primary hover:underline",onClick:()=>n("signup"),children:"Sign Up"}),s.jsx("button",{className:"text-muted-foreground hover:underline",onClick:()=>n("forgot"),children:"Forgot password?"})]}):s.jsx("button",{className:"text-primary hover:underline",onClick:()=>n("login"),children:"Already have an account? Sign In"})})]})]})})},W0=({authMode:e,userData:t,height:n,width:r,onUnreadCountChange:o,onConversationSelect:a})=>{const{user:c,loading:i}=ye();return i?s.jsx("div",{className:"flex items-center justify-center bg-background",style:{height:n,width:r},children:s.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e==="built-in"&&!c?s.jsx(z0,{}):s.jsx("div",{style:{height:n,width:r},children:s.jsx($0,{onUnreadCountChange:o,onConversationSelect:a})})},B0=({supabaseUrl:e,supabaseAnonKey:t,userData:n,theme:r="system",authMode:o="built-in",showGroups:a=!0,allowVoiceMessages:c=!0,allowFileUpload:i=!0,allowReactions:l=!0,showOnlineStatus:d=!0,showReadReceipts:u=!0,height:m="100vh",width:h="100%",onUnreadCountChange:p,onConversationSelect:v})=>{const g=y.useMemo(()=>({showGroups:a,allowVoiceMessages:c,allowFileUpload:i,allowReactions:l,showOnlineStatus:d,showReadReceipts:u}),[a,c,i,l,d,u]);return s.jsx(Lf,{supabaseUrl:e,supabaseAnonKey:t,config:g,children:s.jsx(Wf,{initialTheme:r,children:s.jsx(Ff,{authMode:o,userData:n,children:s.jsxs(Rh,{children:[s.jsx(Mg,{}),s.jsx(ax,{}),s.jsx(W0,{authMode:o,userData:n,height:m,width:h,onUnreadCountChange:p,onConversationSelect:v})]})})})})},q0={sm:{button:"h-10 w-10",icon:"h-5 w-5",badge:"h-4 w-4 text-[9px] -top-0.5 -right-0.5"},md:{button:"h-14 w-14",icon:"h-6 w-6",badge:"h-5 w-5 text-[10px] -top-1 -right-1"},lg:{button:"h-16 w-16",icon:"h-7 w-7",badge:"h-6 w-6 text-[11px] -top-1 -right-1"}};async function U0(e,t){const{data:n}=await e.from("conversation_members").select("conversation_id").eq("user_id",t),r=(n??[]).map(l=>l.conversation_id);if(r.length===0)return 0;const{data:o}=await e.from("messages").select("id, conversation_id").in("conversation_id",r).eq("is_deleted",!1).neq("sender_id",t);if(!o||o.length===0)return 0;const a=o.map(l=>l.id),c=new Set;for(let l=0;l<a.length;l+=500){const d=a.slice(l,l+500),{data:u}=await e.from("message_reads").select("message_id").eq("user_id",t).in("message_id",d);(u??[]).forEach(m=>c.add(m.message_id))}return new Set(o.filter(l=>!c.has(l.id)).map(l=>l.conversation_id)).size}const H0=({supabaseUrl:e,supabaseAnonKey:t,userData:n,onClick:r,href:o,position:a="bottom-right",unreadCount:c,size:i="md",badgeColor:l,icon:d,floating:u=!0,className:m,style:h,buttonColor:p,iconColor:v,label:g="Open chat"})=>{const[x,C]=y.useState(0),w=c!==void 0?c:x,b=y.useMemo(()=>!e||!t?null:es.createClient(e,t),[e,t]);y.useEffect(()=>{if(c!==void 0||!(n!=null&&n.id)||!b)return;const k=async()=>{const A=await U0(b,n.id);C(A)};(async()=>{n.accessToken&&n.refreshToken&&await b.auth.setSession({access_token:n.accessToken,refresh_token:n.refreshToken}),await k()})();const I=b.channel("chat-button-unread").on("postgres_changes",{event:"*",schema:"public",table:"messages"},k).on("postgres_changes",{event:"*",schema:"public",table:"message_reads"},k).subscribe();return()=>{b.removeChannel(I)}},[b,n==null?void 0:n.id,n==null?void 0:n.accessToken,n==null?void 0:n.refreshToken,c]);const S=q0[i],N=u?`fixed ${a==="bottom-left"?"bottom-4 left-4":"bottom-4 right-4"} z-50`:"relative",_=()=>{if(r){r();return}o&&typeof window<"u"&&/^(https?:\/\/|\/)/.test(o)&&(window.location.href=o)},O={...p?{backgroundColor:p}:{},...v?{color:v}:{},...h};return s.jsxs("button",{onClick:_,className:`${N} ${S.button} rounded-full bg-primary text-primary-foreground shadow-lg flex items-center justify-center hover:scale-105 transition-transform cursor-pointer${m?` ${m}`:""}`,style:O,"aria-label":g,children:[d||s.jsx(Cr,{className:S.icon}),w>0&&s.jsx("span",{className:`absolute ${S.badge} rounded-full font-bold flex items-center justify-center`,style:{backgroundColor:l||"hsl(var(--destructive))",color:"hsl(var(--destructive-foreground))"},children:w>99?"99+":w})]})},No={sm:{avatar:"h-8 w-8",fallback:"text-xs"},md:{avatar:"h-10 w-10",fallback:"text-sm"},lg:{avatar:"h-12 w-12",fallback:"text-base"}},V0={"top-right":"top-4 right-4","top-left":"top-4 left-4","bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4"};function Af(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.length===1?t[0][0].toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase()}function G0(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function Y0({open:e,onOpenChange:t,profile:n,email:r}){const o=(n==null?void 0:n.display_name)??"",a=Af(o||r);return s.jsx(Ht,{open:e,onOpenChange:t,children:s.jsxs(Tt,{className:"sm:max-w-sm",children:[s.jsxs(yn,{children:[s.jsx(Vt,{children:"Profile"}),s.jsx(tu,{className:"sr-only",children:"User profile details"})]}),s.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[s.jsxs(Ce,{className:"h-24 w-24",children:[s.jsx(_e,{src:(n==null?void 0:n.avatar_url)??void 0}),s.jsx(Se,{className:"text-2xl font-semibold",children:a})]}),o&&s.jsx("p",{className:"text-lg font-semibold text-center",children:o}),r&&s.jsx("p",{className:"text-sm text-muted-foreground text-center",children:r}),(n==null?void 0:n.bio)&&s.jsx("p",{className:"text-sm text-center text-foreground/80 max-w-xs",children:n.bio})]})]})})}const K0=({supabaseUrl:e,supabaseAnonKey:t,userData:n,authMode:r="built-in",showName:o=!1,size:a="md",floating:c=!1,position:i="top-right",nameMaxLength:l=20,onThemeChange:d,onProfileClick:u,onLogout:m,onLogin:h,className:p,style:v})=>{var Z,V;const[g,x]=y.useState(null),[C,w]=y.useState(r==="built-in"),[b,S]=y.useState(null),[j,N]=y.useState(()=>typeof window>"u"?"system":localStorage.getItem("chat-theme")||"system"),[_,O]=y.useState(!1),k=y.useMemo(()=>!e||!t?null:es.createClient(e,t,{auth:{persistSession:!0,autoRefreshToken:!0}}),[e,t]);y.useEffect(()=>{if(r!=="built-in"||!k)return;k.auth.getSession().then(({data:{session:B}})=>{x(B),w(!1)});const{data:{subscription:G}}=k.auth.onAuthStateChange((B,re)=>{x(re),w(!1)});return()=>G.unsubscribe()},[k,r]),y.useEffect(()=>{r!=="external"||!k||!(n!=null&&n.accessToken)||!(n!=null&&n.refreshToken)||k.auth.setSession({access_token:n.accessToken,refresh_token:n.refreshToken})},[k,r,n==null?void 0:n.accessToken,n==null?void 0:n.refreshToken]),y.useEffect(()=>{var re;const G=r==="external"?n==null?void 0:n.id:(re=g==null?void 0:g.user)==null?void 0:re.id;if(!k||!G){S(null);return}let B=!1;return k.from("profiles").select("display_name, avatar_url, bio").eq("id",G).single().then(({data:ue})=>{B||S(ue??null)}),()=>{B=!0}},[k,(Z=g==null?void 0:g.user)==null?void 0:Z.id,n==null?void 0:n.id,r]),y.useEffect(()=>{if(typeof window>"u")return;if((B=>{const re=B==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":B;document.documentElement.classList.toggle("dark",re==="dark")})(j),j==="system"){const B=window.matchMedia("(prefers-color-scheme: dark)"),re=ue=>{document.documentElement.classList.toggle("dark",ue.matches)};return B.addEventListener("change",re),()=>B.removeEventListener("change",re)}},[j]);const P=(b==null?void 0:b.avatar_url)??(n==null?void 0:n.avatar)??null,I=(b==null?void 0:b.display_name)??(n==null?void 0:n.name)??"",A=((V=g==null?void 0:g.user)==null?void 0:V.email)??(n==null?void 0:n.email)??"",D=r==="built-in"?g!==null:!!(n!=null&&n.id),E=Af(I||A),F=G=>{const B=G;N(B),typeof window<"u"&&localStorage.setItem("chat-theme",B),d==null||d(B)},T=async()=>{k&&(await k.auth.signOut(),x(null),S(null),m==null||m())},z=()=>{u?u():O(!0)};if(r==="built-in"&&C)return null;const $=No[a],M=c?`fixed ${V0[i]} z-50`:"relative",H=j==="dark"?$o:j==="light"?Fo:Ma;return s.jsxs(s.Fragment,{children:[s.jsxs(rf,{children:[s.jsx(of,{asChild:!0,children:s.jsxs("button",{className:`${M} flex items-center gap-2 rounded-full ring-offset-background transition-opacity hover:opacity-80 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 cursor-pointer${p?` ${p}`:""}`,style:v,"aria-label":I||"User menu",children:[s.jsxs(Ce,{className:$.avatar,children:[s.jsx(_e,{src:P??void 0}),s.jsx(Se,{className:`font-medium ${$.fallback}`,children:E})]}),o&&I&&s.jsx("span",{className:"max-w-[120px] truncate text-sm font-medium",children:G0(I,l)})]})}),s.jsxs(ea,{align:"end",className:"w-56",children:[s.jsxs("div",{className:"flex items-center gap-3 px-2 py-2",children:[s.jsxs(Ce,{className:No.sm.avatar,children:[s.jsx(_e,{src:P??void 0}),s.jsx(Se,{className:`font-medium ${No.sm.fallback}`,children:E})]}),s.jsxs("div",{className:"flex flex-col min-w-0",children:[I&&s.jsx("span",{className:"text-sm font-medium truncate",children:I}),A&&s.jsx("span",{className:"text-xs text-muted-foreground truncate",children:A})]})]}),s.jsx(cn,{}),s.jsxs(ht,{onSelect:z,children:[s.jsx(Sc,{className:"mr-2 h-4 w-4"}),"My Profile"]}),s.jsx(cn,{}),s.jsxs(s0,{children:[s.jsxs(sf,{children:[s.jsx(H,{className:"mr-2 h-4 w-4"}),"Theme"]}),s.jsx(af,{children:s.jsxs(a0,{value:j,onValueChange:F,children:[s.jsxs(xr,{value:"light",children:[s.jsx(Fo,{className:"mr-2 h-4 w-4"}),"Light"]}),s.jsxs(xr,{value:"dark",children:[s.jsx($o,{className:"mr-2 h-4 w-4"}),"Dark"]}),s.jsxs(xr,{value:"system",children:[s.jsx(Ma,{className:"mr-2 h-4 w-4"}),"System"]})]})})]}),r==="built-in"&&s.jsxs(s.Fragment,{children:[s.jsx(cn,{}),D?s.jsxs(ht,{onSelect:T,className:"text-destructive focus:text-destructive",children:[s.jsx(Ss,{className:"mr-2 h-4 w-4"}),"Sign out"]}):s.jsxs(ht,{onSelect:()=>h==null?void 0:h(),children:[s.jsx(gg,{className:"mr-2 h-4 w-4"}),"Sign in"]})]})]})]}),s.jsx(Y0,{open:_,onOpenChange:O,profile:b,email:A})]})};exports.ChatButton=H0;exports.QuickChat=B0;exports.UserAvatar=K0;
|
|
308
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return f.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},b0=df,w0=uf,wf=ff,Cf=mf,Sf=vf,jf=bf,Nf=hf,_f=xf;const Ja=b0,C0=w0,Ef=f.forwardRef(({className:e,...t},n)=>s.jsx(wf,{className:W("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}));Ef.displayName=wf.displayName;const Go=f.forwardRef(({className:e,...t},n)=>s.jsxs(C0,{children:[s.jsx(Ef,{}),s.jsx(Cf,{ref:n,className:W("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));Go.displayName=Cf.displayName;const Yo=({className:e,...t})=>s.jsx("div",{className:W("flex flex-col space-y-2 text-center sm:text-left",e),...t});Yo.displayName="AlertDialogHeader";const Ko=({className:e,...t})=>s.jsx("div",{className:W("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ko.displayName="AlertDialogFooter";const Xo=f.forwardRef(({className:e,...t},n)=>s.jsx(Nf,{ref:n,className:W("text-lg font-semibold",e),...t}));Xo.displayName=Nf.displayName;const Qo=f.forwardRef(({className:e,...t},n)=>s.jsx(_f,{ref:n,className:W("text-sm text-muted-foreground",e),...t}));Qo.displayName=_f.displayName;const Zo=f.forwardRef(({className:e,...t},n)=>s.jsx(Sf,{ref:n,className:W(_s(),e),...t}));Zo.displayName=Sf.displayName;const Jo=f.forwardRef(({className:e,...t},n)=>s.jsx(jf,{ref:n,className:W(_s({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));Jo.displayName=jf.displayName;const S0=({onSend:e})=>{const[t,n]=y.useState(!1),[r,o]=y.useState(0),a=y.useRef(null),c=y.useRef([]),i=y.useRef(0),l=y.useRef(null),d=y.useRef(null),u=y.useCallback(()=>{var g;l.current&&clearInterval(l.current),(g=d.current)==null||g.getTracks().forEach(x=>x.stop()),a.current=null,d.current=null,c.current=[],o(0),n(!1)},[]),m=y.useCallback(async()=>{try{const g=await navigator.mediaDevices.getUserMedia({audio:!0});d.current=g;const x=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm",C=new MediaRecorder(g,{mimeType:x});a.current=C,c.current=[],C.ondataavailable=w=>{w.data.size>0&&c.current.push(w.data)},C.onstop=()=>{const w=Date.now()-i.current,b=new Blob(c.current,{type:x});b.size>0&&w>500&&e(b,w),u()},C.start(100),i.current=Date.now(),n(!0),l.current=setInterval(()=>{o(Date.now()-i.current)},100)}catch{u()}},[e,u]),h=y.useCallback(()=>{var g;((g=a.current)==null?void 0:g.state)==="recording"&&a.current.stop()},[]),p=y.useCallback(()=>{a.current&&(a.current.ondataavailable=null,a.current.onstop=null,a.current.state==="recording"&&a.current.stop()),u()},[u]);y.useEffect(()=>()=>{var g;((g=a.current)==null?void 0:g.state)==="recording"&&a.current.stop(),u()},[u]);const v=g=>{const x=Math.floor(g/1e3),C=Math.floor(x/60),w=x%60;return`${C}:${w.toString().padStart(2,"0")}`};return t?s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx(ne,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full shrink-0 text-destructive",onClick:p,children:s.jsx(Bn,{className:"h-5 w-5"})}),s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-destructive animate-pulse"}),s.jsx("span",{className:"text-sm font-mono text-muted-foreground",children:v(r)})]}),s.jsx(ne,{size:"icon",className:"h-9 w-9 rounded-full shrink-0",onClick:h,children:s.jsx(jg,{className:"h-4 w-4",fill:"currentColor"})})]}):s.jsx(ne,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full shrink-0",onClick:m,children:s.jsx(yg,{className:"h-5 w-5"})})},lr=32,j0=({url:e,isMine:t})=>{var w;const[n,r]=y.useState(!1),[o,a]=y.useState(0),[c,i]=y.useState(0),[l,d]=y.useState(()=>Array.from({length:lr},()=>.15+Math.random()*.85)),u=y.useRef(null),m=y.useRef(0),h=y.useRef(!1);y.useEffect(()=>{if(h.current)return;h.current=!0,(async()=>{try{const j=await(await fetch(e)).arrayBuffer(),N=new AudioContext,O=(await N.decodeAudioData(j)).getChannelData(0),k=Math.floor(O.length/lr),P=[];for(let D=0;D<lr;D++){let E=0;const F=D*k;for(let T=F;T<F+k&&T<O.length;T++)E+=Math.abs(O[T]);P.push(E/k)}const I=Math.max(...P,.01),A=P.map(D=>Math.max(.08,D/I));d(A),await N.close()}catch{}})()},[e]);const p=y.useCallback(()=>{const b=u.current;b&&(b.duration&&(a(b.currentTime/b.duration),i(b.duration)),b.paused||(m.current=requestAnimationFrame(p)))},[]);y.useEffect(()=>{const b=new Audio(e);return u.current=b,b.addEventListener("loadedmetadata",()=>{i(b.duration)}),b.addEventListener("ended",()=>{r(!1),a(0)}),()=>{cancelAnimationFrame(m.current),b.pause(),b.src=""}},[e]);const v=()=>{const b=u.current;b&&(n?(b.pause(),cancelAnimationFrame(m.current),r(!1)):(b.play(),r(!0),m.current=requestAnimationFrame(p)))},g=b=>{const S=u.current;if(!S||!S.duration)return;const j=b.currentTarget.getBoundingClientRect(),N=(b.clientX-j.left)/j.width;S.currentTime=N*S.duration,a(N)},x=b=>{if(!b||!isFinite(b))return"0:00";const S=Math.floor(b/60),j=Math.floor(b%60);return`${S}:${j.toString().padStart(2,"0")}`},C=Math.floor(o*lr);return s.jsxs("div",{className:"flex items-center gap-2 min-w-[180px] max-w-[260px]",children:[s.jsx(ne,{variant:"ghost",size:"icon",className:`h-10 w-10 rounded-full shrink-0 ${t?"bg-primary-foreground/20 hover:bg-primary-foreground/30 text-primary-foreground":"bg-primary/10 hover:bg-primary/20 text-primary"}`,onClick:v,children:n?s.jsx(wg,{className:"h-5 w-5",fill:"currentColor"}):s.jsx(bc,{className:"h-5 w-5 ml-0.5",fill:"currentColor"})}),s.jsxs("div",{className:"flex-1 flex flex-col gap-1",children:[s.jsx("div",{className:"flex items-end gap-[2px] h-[28px] cursor-pointer",onClick:g,children:l.map((b,S)=>s.jsx("div",{className:"flex-1 rounded-full transition-colors duration-150",style:{height:`${Math.max(3,b*28)}px`,backgroundColor:S<C?t?"hsl(var(--primary-foreground))":"hsl(var(--primary))":t?"hsl(var(--primary-foreground) / 0.35)":"hsl(var(--primary) / 0.3)"}},S))}),s.jsx("span",{className:`text-[11px] font-mono leading-none ${t?"text-primary-foreground/70":"text-muted-foreground"}`,children:x(n?((w=u.current)==null?void 0:w.currentTime)??0:c)})]})]})},N0=({message:e,open:t,onOpenChange:n})=>{const{data:r}=js(),{user:o}=ye(),a=Pu(),c=async l=>{a.mutate({conversation_id:l,content:e.content??"",type:e.type,file_url:e.file_url??void 0,file_name:e.file_name??void 0,file_size:e.file_size??void 0,forwarded_from_id:e.id}),n(!1)},i=l=>{var u;if(l.type==="group")return l.name||"Group";const d=l.members.find(m=>m.user_id!==(o==null?void 0:o.id));return((u=d==null?void 0:d.profile)==null?void 0:u.display_name)||"Chat"};return s.jsx(Ut,{open:t,onOpenChange:n,children:s.jsxs(Tt,{className:"max-w-sm",children:[s.jsx("h3",{className:"text-lg font-semibold mb-3",children:"Forward to:"}),s.jsx(mn,{className:"h-[300px]",children:r==null?void 0:r.map(l=>s.jsx(ne,{variant:"ghost",className:"w-full justify-start mb-1",onClick:()=>c(l.id),children:i(l)},l.id))})]})})},_0=({url:e,onClose:t,forceVideo:n})=>{y.useEffect(()=>{const o=a=>a.key==="Escape"&&t();return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t]);const r=n||e.match(/\.(mp4|webm|ogg|mov)(\?|$)/i);return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:t,children:[s.jsxs("div",{className:"absolute right-4 top-4 flex gap-2",children:[s.jsx("a",{href:e,download:!0,target:"_blank",rel:"noopener",onClick:o=>o.stopPropagation(),children:s.jsx(ne,{variant:"secondary",size:"icon",children:s.jsx(yc,{className:"h-5 w-5"})})}),s.jsx(ne,{variant:"secondary",size:"icon",onClick:t,children:s.jsx(vn,{className:"h-5 w-5"})})]}),s.jsx("div",{onClick:o=>o.stopPropagation(),className:"max-h-[90vh] max-w-[90vw]",children:r?s.jsx("video",{src:e,controls:!0,autoPlay:!0,className:"max-h-[90vh] max-w-[90vw] rounded-lg"}):s.jsx("img",{src:e,alt:"media",className:"max-h-[90vh] max-w-[90vw] rounded-lg object-contain"})})]})},E0=({photos:e,initialIndex:t,onClose:n})=>{const[r,o]=y.useState(t),a=y.useCallback(()=>o(l=>Math.min(l+1,e.length-1)),[e.length]),c=y.useCallback(()=>o(l=>Math.max(l-1,0)),[]);y.useEffect(()=>{const l=d=>{d.key==="Escape"&&n(),d.key==="ArrowRight"&&a(),d.key==="ArrowLeft"&&c()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[n,a,c]);const i=e[r];return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/85",onClick:n,children:[s.jsxs("div",{className:"absolute right-4 top-4 flex items-center gap-2 z-10",children:[s.jsxs("span",{className:"text-white/70 text-sm mr-2",children:[r+1," / ",e.length]}),s.jsx("a",{href:i.url,download:!0,target:"_blank",rel:"noopener",onClick:l=>l.stopPropagation(),children:s.jsx(ne,{variant:"secondary",size:"icon",children:s.jsx(yc,{className:"h-5 w-5"})})}),s.jsx(ne,{variant:"secondary",size:"icon",onClick:n,children:s.jsx(vn,{className:"h-5 w-5"})})]}),r>0&&s.jsx("button",{className:"absolute left-4 top-1/2 -translate-y-1/2 z-10 flex h-10 w-10 items-center justify-center rounded-full bg-white/10 text-white backdrop-blur-sm transition hover:bg-white/20",onClick:l=>{l.stopPropagation(),c()},children:s.jsx(dg,{className:"h-6 w-6"})}),r<e.length-1&&s.jsx("button",{className:"absolute right-4 top-1/2 -translate-y-1/2 z-10 flex h-10 w-10 items-center justify-center rounded-full bg-white/10 text-white backdrop-blur-sm transition hover:bg-white/20",onClick:l=>{l.stopPropagation(),a()},children:s.jsx(Cs,{className:"h-6 w-6"})}),s.jsx("div",{onClick:l=>l.stopPropagation(),className:"max-h-[90vh] max-w-[90vw]",children:s.jsx("img",{src:i.url,alt:i.name||"photo",className:"max-h-[90vh] max-w-[90vw] rounded-lg object-contain"})}),e.length>1&&s.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-1.5 z-10",onClick:l=>l.stopPropagation(),children:e.map((l,d)=>s.jsx("button",{onClick:()=>o(d),className:`h-12 w-12 overflow-hidden rounded-md border-2 transition ${d===r?"border-white":"border-transparent opacity-60 hover:opacity-100"}`,children:s.jsx("img",{src:l.url,alt:"",className:"h-full w-full object-cover"})},d))})]})},M0=({photos:e,onPhotoClick:t})=>{const n=e.length;return n===1?s.jsx("div",{className:"cursor-pointer overflow-hidden rounded-lg",onClick:()=>t(0),children:s.jsx("img",{src:e[0].url,alt:e[0].name||"photo",className:"max-h-72 w-full object-cover transition-transform hover:scale-105",loading:"lazy"})}):s.jsx("div",{className:W("grid gap-0.5 overflow-hidden rounded-lg",T0(n)),children:e.map((r,o)=>s.jsx("div",{className:W("relative cursor-pointer overflow-hidden bg-muted",R0(n,o)),onClick:()=>t(o),children:s.jsx("img",{src:r.url,alt:r.name||"photo",className:"h-full w-full object-cover transition-transform hover:scale-105",loading:"lazy"})},o))})};function T0(e){switch(e){case 2:return"grid-cols-2 aspect-[2/1]";case 3:return"grid-cols-3 grid-rows-2 aspect-[3/2]";case 4:return"grid-cols-2 grid-rows-2 aspect-square";case 5:return"grid-cols-6 grid-rows-2 aspect-[3/2]";case 6:return"grid-cols-3 grid-rows-2 aspect-[3/2]";case 7:return"grid-cols-6 grid-rows-3 aspect-[3/2.5]";default:return"grid-cols-2 grid-rows-2 aspect-square"}}function R0(e,t){return e===3?t===0?"row-span-2 col-span-2":"col-span-1":e===5?t<2?"col-span-3":"col-span-2":e===7?t===0?"col-span-3 row-span-2":t<4?"col-span-1":"col-span-2":""}const jo=768;function ta(){const[e,t]=f.useState(void 0);return f.useEffect(()=>{const n=window.matchMedia(`(max-width: ${jo-1}px)`),r=()=>{t(window.innerWidth<jo)};return n.addEventListener("change",r),t(window.innerWidth<jo),()=>n.removeEventListener("change",r)},[]),!!e}const k0=["👍","😁","❤️","😢","🔥","🤣","😱"],Mf=({children:e,message:t,isOwn:n,onReply:r,onEdit:o,onDelete:a,onForward:c,onReact:i})=>{const[l,d]=y.useState(!1),[u,m]=y.useState({x:0,y:0}),[h,p]=y.useState(!1),[v,g]=y.useState(!1),x=ta(),C=y.useRef(null),w=y.useRef(null),b=y.useRef(null),S=y.useRef(null),j=y.useCallback(()=>{d(!1),p(!1),w.current&&(clearTimeout(w.current),w.current=null)},[]);y.useEffect(()=>()=>{C.current&&clearTimeout(C.current),w.current&&clearTimeout(w.current)},[]),y.useEffect(()=>{if(!l)return;const T=z=>{b.current&&!b.current.contains(z.target)&&j()};return document.addEventListener("mousedown",T),document.addEventListener("touchstart",T),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("touchstart",T)}},[l,j]),y.useEffect(()=>{if(!l)return;const T=z=>{z.key==="Escape"&&j()};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[l,j]),y.useEffect(()=>{if(!l||x||!b.current)return;const T=()=>{if(!b.current)return;const $=b.current.getBoundingClientRect(),M=8,H=40,Z=8,V=Math.max(M,window.innerWidth-$.width-H),G=Math.max(Z,window.innerHeight-$.height-Z),B=Math.min(Math.max(u.x,M),V),re=Math.min(Math.max(u.y,Z),G);m(ue=>ue.x===B&&ue.y===re?ue:{x:B,y:re})},z=window.requestAnimationFrame(T);return window.addEventListener("resize",T),()=>{window.cancelAnimationFrame(z),window.removeEventListener("resize",T)}},[l,x,u.x,u.y,h]);const N=y.useCallback(T=>{T.preventDefault(),T.stopPropagation(),!t.is_deleted&&(m({x:T.clientX,y:T.clientY}),d(!0),p(!1),g(!0))},[t.is_deleted]),_=y.useCallback(T=>{if(t.is_deleted)return;const z=T.touches[0];C.current=setTimeout(()=>{var $;C.current=null,($=window.getSelection())==null||$.removeAllRanges(),m({x:z.clientX,y:z.clientY}),d(!0),p(!1),g(!1),w.current=setTimeout(()=>g(!0),350)},500)},[t.is_deleted]),O=y.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),k=y.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),P=T=>{T(),j()},I=T=>{i(T),j()},A=T=>{i(T.native),j()},D=()=>{t.content&&navigator.clipboard.writeText(t.content),j()},E=Gr(new Date(t.created_at),"d MMM yyyy 'at' HH:mm:ss"),F=x?{}:{left:u.x,top:u.y};return s.jsxs("div",{ref:S,onContextMenu:N,onTouchStart:_,onTouchEnd:O,onTouchMove:k,className:"select-none",style:{WebkitTouchCallout:"none"},children:[e,l&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-50 bg-black/30 backdrop-blur-[2px]",onClick:j,onTouchStart:T=>{T.stopPropagation(),j()}}),s.jsx("div",{ref:b,className:[x?"fixed bottom-0 left-0 right-0 z-[60] flex justify-center animate-in slide-in-from-bottom-5 duration-200":"fixed z-[60] animate-in fade-in-0 zoom-in-95 duration-150",x&&!v?"pointer-events-none":""].join(" "),style:x?{}:F,children:s.jsxs("div",{className:`${x?"rounded-t-2xl w-full max-w-[320px]":"rounded-xl"} border border-border bg-popover shadow-2xl overflow-hidden`,children:[!h&&s.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border",children:[k0.map(T=>s.jsx("button",{onClick:()=>I(T),className:"text-2xl hover:scale-125 active:scale-95 transition-transform p-1",children:T},T)),s.jsx("button",{onClick:()=>p(!0),className:"flex items-center justify-center h-9 w-9 rounded-full bg-muted hover:bg-accent transition-colors",children:s.jsx(lg,{className:"h-4 w-4 text-muted-foreground"})})]}),h&&s.jsx("div",{className:"max-h-[350px] overflow-hidden",children:s.jsx(Eo,{data:_o,onEmojiSelect:A,theme:"auto",previewPosition:"none",skinTonePosition:"none",perLine:x?8:9,maxFrequentRows:1})}),!h&&s.jsxs("div",{className:`py-1 ${x?"pb-safe":""}`,children:[s.jsx(Tn,{icon:s.jsx(wc,{className:"h-4 w-4"}),label:"Reply",onClick:()=>P(r)}),s.jsx(Tn,{icon:s.jsx(ug,{className:"h-4 w-4"}),label:"Copy Text",onClick:D}),n&&s.jsx(Tn,{icon:s.jsx(Sr,{className:"h-4 w-4"}),label:"Edit",onClick:()=>P(o)}),s.jsx(Tn,{icon:s.jsx(pg,{className:"h-4 w-4"}),label:"Forward",onClick:()=>P(c)}),s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 text-sm text-muted-foreground",children:[s.jsx("span",{className:"text-xs",children:"🕐"}),s.jsx("span",{className:"text-xs",children:E})]}),n&&s.jsx(Tn,{icon:s.jsx(Bn,{className:"h-4 w-4"}),label:"Delete",onClick:()=>P(a),destructive:!0}),x&&s.jsx("div",{className:"h-4"})]})]})})]})]})},Tn=({icon:e,label:t,onClick:n,destructive:r=!1})=>s.jsxs("button",{onClick:n,className:`flex w-full items-center gap-3 px-4 py-2.5 text-sm transition-colors hover:bg-accent ${r?"text-destructive":"text-popover-foreground"}`,children:[e,s.jsx("span",{children:t})]}),P0=({reactions:e,onToggle:t,isOwn:n})=>{const[r,o]=y.useState(null),a=ta(),c=y.useRef(null),i=y.useRef(null),l=y.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);if(!e||e.length===0)return null;const d=e.find(u=>u.emoji===r);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`flex flex-wrap gap-1 mt-1 ${n?"justify-end":"justify-start"}`,children:e.map(u=>s.jsxs("div",{className:"relative",onMouseEnter:()=>!a&&o(u.emoji),onMouseLeave:()=>!a&&o(null),children:[s.jsxs("button",{onClick:m=>{if(m.stopPropagation(),a&&r===u.emoji){o(null);return}t(u.emoji)},onTouchStart:()=>{c.current=setTimeout(()=>{o(u.emoji)},400)},onTouchEnd:()=>l(),onTouchMove:()=>l(),className:`flex items-center gap-1 rounded-full px-2 py-0.5 text-xs transition-colors border ${u.hasReacted?"bg-primary/15 border-primary/40 text-primary":"bg-muted/60 border-border text-foreground hover:bg-muted"}`,children:[s.jsx("span",{className:"text-sm",children:u.emoji}),s.jsx("span",{className:"font-medium",children:u.count})]}),!a&&r===u.emoji&&s.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50",children:s.jsxs("div",{className:"bg-popover border border-border rounded-lg shadow-xl p-2 min-w-[160px] max-w-[220px]",children:[s.jsx("div",{className:"text-center text-lg mb-1",children:u.emoji}),s.jsx("div",{className:"space-y-1.5",children:u.users.map(m=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Ce,{className:"h-6 w-6 flex-shrink-0",children:[s.jsx(_e,{src:m.avatar_url??void 0}),s.jsx(Se,{className:"text-[10px]",children:m.display_name.slice(0,2).toUpperCase()})]}),s.jsx("span",{className:"text-xs text-popover-foreground truncate",children:m.display_name})]},m.user_id))})]})})]},u.emoji))}),a&&d&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-50 bg-black/30 backdrop-blur-[2px]",onClick:()=>o(null)}),s.jsx("div",{ref:i,className:"fixed bottom-0 left-0 right-0 z-50 flex justify-center animate-in slide-in-from-bottom-5 duration-200",children:s.jsxs("div",{className:"rounded-t-2xl border border-border bg-popover shadow-2xl overflow-hidden w-full max-w-[320px]",children:[s.jsx("div",{className:"text-center text-2xl pt-3 pb-1",children:d.emoji}),s.jsx("div",{className:"px-4 pb-4 space-y-2 max-h-[300px] overflow-y-auto",children:d.users.map(u=>s.jsxs("div",{className:"flex items-center gap-3 py-1.5",children:[s.jsxs(Ce,{className:"h-8 w-8 flex-shrink-0",children:[s.jsx(_e,{src:u.avatar_url??void 0}),s.jsx(Se,{className:"text-xs",children:u.display_name.slice(0,2).toUpperCase()})]}),s.jsx("span",{className:"text-sm text-popover-foreground",children:u.display_name})]},u.user_id))}),s.jsx("div",{className:"h-4"})]})})]})]})},A0=()=>s.jsx("div",{className:"absolute inset-0 pointer-events-none overflow-hidden opacity-[0.07] dark:opacity-[0.05]",children:s.jsxs("svg",{className:"w-full h-full",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("defs",{children:s.jsxs("pattern",{id:"chat-pattern",x:"0",y:"0",width:"200",height:"200",patternUnits:"userSpaceOnUse",children:[s.jsxs("g",{transform:"translate(20, 20) rotate(15)",children:[s.jsx("path",{d:"M0 0 L16 8 L6 10 L4 16 Z",fill:"currentColor"}),s.jsx("path",{d:"M6 10 L16 8 L4 16 Z",fill:"currentColor",opacity:"0.6"})]}),s.jsx("g",{transform:"translate(90, 30)",children:s.jsx("path",{d:"M8 14s-5.5-4-5.5-7.5a3 3 0 0 1 5.5-1.5 3 3 0 0 1 5.5 1.5c0 3.5-5.5 7.5-5.5 7.5z",fill:"currentColor"})}),s.jsx("g",{transform:"translate(160, 15)",children:s.jsx("path",{d:"M8 0l2.5 5 5.5.8-4 3.9.9 5.3L8 12.5 3.1 15l.9-5.3-4-3.9 5.5-.8z",fill:"currentColor"})}),s.jsx("g",{transform:"translate(50, 80)",children:s.jsx("path",{d:"M2 0h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6l-4 3v-3a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2z",fill:"currentColor"})}),s.jsxs("g",{transform:"translate(130, 75)",children:[s.jsx("circle",{cx:"8",cy:"8",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),s.jsx("circle",{cx:"5.5",cy:"6",r:"1",fill:"currentColor"}),s.jsx("circle",{cx:"10.5",cy:"6",r:"1",fill:"currentColor"}),s.jsx("path",{d:"M5 10.5a3.5 3.5 0 0 0 6 0",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]}),s.jsxs("g",{transform:"translate(15, 140)",children:[s.jsx("rect",{x:"0",y:"3",width:"16",height:"11",rx:"2",fill:"currentColor"}),s.jsx("circle",{cx:"8",cy:"9",r:"3.5",fill:"currentColor",opacity:"0.4"}),s.jsx("rect",{x:"5",y:"0",width:"6",height:"4",rx:"1",fill:"currentColor"})]}),s.jsxs("g",{transform:"translate(100, 140)",children:[s.jsx("circle",{cx:"4",cy:"13",r:"3",fill:"currentColor"}),s.jsx("rect",{x:"6.5",y:"2",width:"1.5",height:"11",fill:"currentColor"}),s.jsx("path",{d:"M7 2 Q12 0 12 4",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),s.jsx("g",{transform:"translate(160, 130)",children:s.jsx("path",{d:"M6 14h10a4 4 0 0 0 .9-7.9A5 5 0 0 0 7.2 4 4.5 4.5 0 0 0 2.5 10 3.5 3.5 0 0 0 6 14z",fill:"currentColor"})}),s.jsx("g",{transform:"translate(55, 165)",children:s.jsx("path",{d:"M8 0a5 5 0 0 0-5 5c0 4 5 10 5 10s5-6 5-10a5 5 0 0 0-5-5zm0 7a2 2 0 1 1 0-4 2 2 0 0 1 0 4z",fill:"currentColor"})}),s.jsx("circle",{cx:"40",cy:"60",r:"2",fill:"currentColor"}),s.jsx("circle",{cx:"120",cy:"55",r:"1.5",fill:"currentColor"}),s.jsx("circle",{cx:"180",cy:"95",r:"2",fill:"currentColor"}),s.jsx("circle",{cx:"75",cy:"120",r:"1.5",fill:"currentColor"}),s.jsx("circle",{cx:"145",cy:"110",r:"2",fill:"currentColor"}),s.jsx("circle",{cx:"30",cy:"185",r:"1.5",fill:"currentColor"}),s.jsx("circle",{cx:"175",cy:"175",r:"2",fill:"currentColor"}),s.jsx("g",{transform:"translate(140, 50) rotate(-10) scale(0.7)",children:s.jsx("path",{d:"M0 0 L16 8 L6 10 L4 16 Z",fill:"currentColor"})}),s.jsxs("g",{transform:"translate(85, 175) rotate(-30)",children:[s.jsx("rect",{x:"0",y:"0",width:"3",height:"14",rx:"0.5",fill:"currentColor"}),s.jsx("path",{d:"M0 14 L1.5 18 L3 14Z",fill:"currentColor"})]})]})}),s.jsx("rect",{width:"100%",height:"100%",fill:"url(#chat-pattern)"})]})}),O0=({open:e,onOpenChange:t,members:n,groupName:r,onMemberClick:o})=>{const a=i=>i.profile.is_online?"online":i.profile.last_seen?`last seen ${yd(new Date(i.profile.last_seen),{addSuffix:!1})} ago`:"offline",c=[...n].sort((i,l)=>{if(i.profile.is_online&&!l.profile.is_online)return-1;if(!i.profile.is_online&&l.profile.is_online)return 1;const d=i.profile.last_seen?new Date(i.profile.last_seen).getTime():0;return(l.profile.last_seen?new Date(l.profile.last_seen).getTime():0)-d});return s.jsx(Ut,{open:e,onOpenChange:t,children:s.jsxs(Tt,{className:"sm:max-w-[400px] p-0 gap-0",children:[s.jsx(yn,{className:"px-4 pt-4 pb-3 border-b border-border",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ce,{className:"h-12 w-12",children:s.jsx(Se,{className:"text-sm font-semibold",children:r.slice(0,2).toUpperCase()})}),s.jsxs("div",{children:[s.jsx(Ht,{className:"text-base",children:r}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:[n.length," members"]})]})]})}),s.jsx(mn,{className:"max-h-[60vh]",children:s.jsx("div",{className:"py-1",children:c.map(i=>s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>{o==null||o(i.user_id),t(!1)},children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Ce,{className:"h-11 w-11",children:[s.jsx(_e,{src:i.profile.avatar_url??void 0}),s.jsx(Se,{className:"text-sm",children:i.profile.display_name.slice(0,2).toUpperCase()})]}),i.profile.is_online&&s.jsx("div",{className:"absolute bottom-0 right-0 h-3.5 w-3.5 rounded-full bg-green-500 border-2 border-background"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:i.profile.display_name}),s.jsx("p",{className:`text-xs ${i.profile.is_online?"text-green-500":"text-muted-foreground"}`,children:a(i)})]})]},i.user_id))})})]})})},D0=({conversationId:e,onBack:t})=>{var ra,oa,sa;const n=ve(),r=rs(),{user:o}=ye(),{messages:a,isLoading:c,fetchNextPage:i,hasNextPage:l,isFetchingNextPage:d}=kw(e),u=Pw(e),m=Iw(e),h=Lw(),{data:p}=js(),v=Pu(),g=Aw(),x=Ow(),C=Dw(),{toast:w}=xn(),b=oe.useQueryClient(),[S,j]=y.useState(""),[N,_]=y.useState(null),[O,k]=y.useState(null),[P,I]=y.useState(null),[A,D]=y.useState(!1),[E,F]=y.useState(""),[T,z]=y.useState(null),[$,M]=y.useState(!1),[H,Z]=y.useState(null),[V,G]=y.useState(0),[B,re]=y.useState(!0),[ue,J]=y.useState(null),[Pe,he]=y.useState(!1),[ze,Ae]=y.useState(!1),[Ve,Ge]=y.useState(""),[Vt,Rt]=y.useState(!1),[Gt,kt]=y.useState(!1),[Pt,lt]=y.useState(!1),Yt=y.useRef(null),je=y.useRef(null),bn=y.useRef(null),We=y.useRef(null),Yn=y.useRef(null),Kt=y.useRef(0),we=y.useRef(!1),et=y.useRef(new Set),wn=y.useRef(null),Kn=y.useRef(C);Kn.current=C;const At=y.useRef(u);At.current=u;const Cn=y.useRef(e);Cn.current=e;const te=p==null?void 0:p.find(R=>R.id===e),Ot=y.useMemo(()=>{if(!a||!o)return null;for(const R of a)if(R.sender_id!==o.id&&u.has(R.id))return R.id;return null},[a,o,u]),tt=u.size,Xn=y.useCallback(()=>{const R=je.current;if(!R)return;const Q=R.scrollHeight-R.scrollTop-R.clientHeight<100;re(Q)},[]);y.useEffect(()=>{if(!a||a.length===0||we.current)return;const R=je.current;R&&requestAnimationFrame(()=>{We.current?We.current.scrollIntoView({block:"center"}):R.scrollTop=R.scrollHeight,we.current=!0})},[a,Ot]),y.useEffect(()=>{we.current=!1},[e]);const dt=y.useRef(0);y.useEffect(()=>{if(!a)return;const R=je.current;R&&(a.length>dt.current&&B&&we.current&&requestAnimationFrame(()=>{R.scrollTop=R.scrollHeight}),dt.current=a.length)},[a,B]),y.useEffect(()=>{const R=bn.current,q=je.current;if(!R||!q)return;const Q=new IntersectionObserver(le=>{le[0].isIntersecting&&l&&!d&&(Kt.current=q.scrollHeight,i())},{root:q,threshold:0});return Q.observe(R),()=>Q.disconnect()},[l,d,i]),y.useEffect(()=>{if(!d&&Kt.current>0){const R=je.current;if(R){const q=R.scrollHeight-Kt.current;R.scrollTop+=q}Kt.current=0}},[d]),y.useEffect(()=>{const R=je.current;if(!R||!o||!e)return;const q=new IntersectionObserver(le=>{for(const de of le)if(de.isIntersecting){const Be=de.target.dataset.msgId;Be&&At.current.has(Be)&&(et.current.add(Be),wn.current&&clearTimeout(wn.current),wn.current=setTimeout(()=>{const U=Array.from(et.current);U.length>0&&Cn.current&&(Kn.current.mutate({messageIds:U,conversationId:Cn.current}),et.current.clear())},500))}},{root:R,threshold:.5});return R.querySelectorAll("[data-unread='true']").forEach(le=>q.observe(le)),()=>q.disconnect()},[a,u,o,e]);const Sn=y.useCallback(()=>{const R=je.current;R&&(R.scrollTo({top:R.scrollHeight,behavior:"smooth"}),u.size>0&&e&&C.mutate({messageIds:Array.from(u),conversationId:e}))},[u,e,C]);y.useEffect(()=>{if(!Pe)return;const R=q=>{Yt.current&&!Yt.current.contains(q.target)&&he(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[Pe]);const Qn=5e3,Dt=async()=>{if(!e||!S.trim())return;if(S.length>Qn){w({title:"Message too long",description:`Messages must be ${Qn} characters or fewer`,variant:"destructive"});return}if(O){g.mutate({id:O.id,content:S,conversationId:e}),k(null),j("");return}const R=`temp-${crypto.randomUUID()}`;v.mutate({conversation_id:e,content:S,reply_to_id:N==null?void 0:N.id,_tempId:R}),j(""),_(null),setTimeout(()=>Sn(),50)},Zn=R=>{if(!e)return;const q=["messages",e];b.setQueryData(q,Q=>Q!=null&&Q.pages?{...Q,pages:Q.pages.map(le=>le.filter(de=>de.id!==R.id))}:Q),v.mutate({conversation_id:e,content:R.content||"",reply_to_id:R.reply_to_id||void 0,_tempId:`temp-${crypto.randomUUID()}`})},eo=R=>{if(!e)return;const q=["messages",e];b.setQueryData(q,Q=>Q!=null&&Q.pages?{...Q,pages:Q.pages.map(le=>le.filter(de=>de.id!==R))}:Q)},jn={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",mp4:"video/mp4",mov:"video/quicktime",pdf:"application/pdf",txt:"text/plain",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",zip:"application/zip"},nt=50*1024*1024,to=async R=>{var le;const q=R.target.files;if(!q||q.length===0||!e||!o)return;const Q=Array.from(q).slice(0,7);q.length>7&&w({title:"Limit exceeded",description:"You can upload up to 7 photos at once",variant:"destructive"});for(const de of Q){if(de.size>nt){w({title:"File too large",description:`${de.name} exceeds the 50 MB limit`,variant:"destructive"});continue}const Be=((le=de.name.split(".").pop())==null?void 0:le.toLowerCase())??"",U=jn[Be];if(!U){w({title:"File type not allowed",description:`${de.name} is not a supported file type`,variant:"destructive"});continue}const ft=`${o.id}/${e}/${crypto.randomUUID()}`,{error:xe}=await n.storage.from("chat-media").upload(ft,de,{contentType:U});if(xe){w({title:"Upload error",description:`${de.name}: ${xe.message}`,variant:"destructive"});continue}const{data:Lt}=n.storage.from("chat-media").getPublicUrl(ft),Xt=U.startsWith("image/"),mt=U.startsWith("video/");v.mutate({conversation_id:e,content:de.name,type:Xt?"photo":mt?"video":"file",file_url:Lt.publicUrl,file_name:de.name,file_size:de.size})}R.target.value=""},Y=async(R,q)=>{if(!e||!o)return;const Q=R.type.includes("webm")?"webm":"ogg",le=`${o.id}/${e}/${crypto.randomUUID()}.${Q}`,{error:de}=await n.storage.from("chat-media").upload(le,R,{contentType:R.type});if(de){w({title:"Upload error",description:de.message,variant:"destructive"});return}const{data:Be}=n.storage.from("chat-media").getPublicUrl(le);v.mutate({conversation_id:e,content:`Voice message (${Math.ceil(q/1e3)}s)`,type:"voice",file_url:Be.publicUrl,file_name:`voice.${Q}`,file_size:R.size}),setTimeout(()=>Sn(),50)},se=async()=>{if(!e||!Ve.trim())return;const{error:R}=await n.from("conversations").update({name:Ve.trim()}).eq("id",e);if(R){w({title:"Error",description:R.message,variant:"destructive"});return}b.invalidateQueries({queryKey:["conversations"]}),Ae(!1),w({title:"Group name updated"})},fe=async()=>{if(!e)return;const{error:R}=await n.from("messages").update({is_deleted:!0,content:null}).eq("conversation_id",e);if(R){w({title:"Error",description:R.message,variant:"destructive"});return}b.invalidateQueries({queryKey:["messages",e]}),Rt(!1),w({title:"Chat history cleared"})},Oe=async()=>{if(!e||!o)return;const{error:R}=await n.from("conversation_members").delete().eq("conversation_id",e).eq("user_id",o.id);if(R){w({title:"Error",description:R.message,variant:"destructive"});return}b.invalidateQueries({queryKey:["conversations"]}),kt(!1),t==null||t(),w({title:"You left the group"})},be=y.useMemo(()=>a?E?a.filter(R=>{var q;return(q=R.content)==null?void 0:q.toLowerCase().includes(E.toLowerCase())}):a:[],[a,E]),Ye=y.useCallback((R,q)=>{e&&h.mutate({messageId:R,emoji:q,conversationId:e})},[e,h]),[ut,Ne]=y.useState(null),[De,na]=y.useState(null);y.useEffect(()=>{if(!De)return;const R=je.current;if(!R)return;const q=requestAnimationFrame(()=>{const Q=R.querySelector(`[data-msg-id="${De}"]`);Q&&(Q.scrollIntoView({behavior:"instant",block:"center"}),Ne(De),setTimeout(()=>Ne(null),2e3),na(null))});return()=>cancelAnimationFrame(q)},[De,a]);const Df=y.useCallback(async R=>{const q=je.current;if(!q)return;const Q=q.querySelector(`[data-msg-id="${R}"]`);if(Q){Q.scrollIntoView({behavior:"instant",block:"center"}),Ne(R),setTimeout(()=>Ne(null),2e3);return}na(R),(async()=>{var U,ft;let de=0;const Be=20;for(;de<Be;){const xe=b.getQueryData(["messages",e]);if(((U=xe==null?void 0:xe.pages)==null?void 0:U.some(mt=>mt.some(Ke=>Ke.id===R)))||!(xe!=null&&xe.pages?((ft=xe.pages[xe.pages.length-1])==null?void 0:ft.length)===30:!1))break;await i(),de++,await new Promise(mt=>setTimeout(mt,100))}})()},[e,i,b]);if(!e)return s.jsx("div",{className:"flex flex-1 items-center justify-center bg-muted/30",children:s.jsx("p",{className:"text-muted-foreground",children:"Select a chat to start messaging"})});const no=te?L0(te,(o==null?void 0:o.id)??""):"Chat",If=te?$0(te,(o==null?void 0:o.id)??""):null,It=(te==null?void 0:te.type)==="private"?te.members.find(R=>R.user_id!==(o==null?void 0:o.id)):null;return s.jsxs("div",{className:"flex flex-1 flex-col h-full overflow-hidden pt-[60px] md:pt-0",children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-border px-4 py-3 fixed top-0 left-0 right-0 z-40 bg-background md:relative md:top-auto md:left-auto md:right-auto md:z-auto",children:[t&&s.jsx(ne,{variant:"ghost",size:"icon",onClick:t,children:s.jsx(ag,{className:"h-5 w-5"})}),s.jsxs(Ce,{className:"h-10 w-10 cursor-pointer",onClick:()=>{(te==null?void 0:te.type)==="private"&&It&&J(It.user_id)},children:[s.jsx(_e,{src:If??void 0}),s.jsx(Se,{children:no.slice(0,2).toUpperCase()})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h2",{className:"font-semibold text-foreground cursor-pointer hover:underline truncate",onClick:()=>{(te==null?void 0:te.type)==="private"&&It&&J(It.user_id)},children:no}),(te==null?void 0:te.type)==="group"?s.jsxs("p",{className:"text-xs text-muted-foreground cursor-pointer hover:underline",onClick:()=>lt(!0),children:[te.members.length," members"]}):s.jsx("p",{className:"text-xs text-muted-foreground",children:(ra=It==null?void 0:It.profile)!=null&&ra.is_online?"online":"offline"})]}),s.jsx(ne,{variant:"ghost",size:"icon",onClick:()=>{D(!A),F("")},children:s.jsx(Dn,{className:"h-5 w-5"})}),(te==null?void 0:te.type)==="group"&&s.jsxs(of,{children:[s.jsx(sf,{asChild:!0,children:s.jsx(ne,{variant:"ghost",size:"icon",children:s.jsx(mg,{className:"h-5 w-5"})})}),s.jsxs(ea,{align:"end",className:"w-48",children:[s.jsxs(ht,{onClick:()=>{Ge(te.name||""),Ae(!0)},children:[s.jsx(Sr,{className:"h-4 w-4 mr-2"}),"Edit"]}),s.jsxs(ht,{onClick:()=>{te.members.length>0&&J(te.members[0].user_id)},children:[s.jsx(hg,{className:"h-4 w-4 mr-2"}),"Info"]}),s.jsxs(ht,{onClick:()=>w({title:"Notifications muted"}),children:[s.jsx(Lo,{className:"h-4 w-4 mr-2"}),"Mute"]}),s.jsx(an,{}),s.jsxs(ht,{onClick:()=>Rt(!0),children:[s.jsx(Bn,{className:"h-4 w-4 mr-2"}),"Clear Chat History"]}),s.jsx(an,{}),s.jsxs(ht,{className:"text-destructive focus:text-destructive",onClick:()=>kt(!0),children:[s.jsx(Ss,{className:"h-4 w-4 mr-2"}),"Leave Group"]})]})]})]}),A&&s.jsx("div",{className:"border-b border-border px-4 py-2",children:s.jsxs("div",{className:"relative",children:[s.jsx(Dn,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),s.jsx(qe,{placeholder:"Search messages...",value:E,onChange:R=>F(R.target.value),className:"pl-9",autoFocus:!0})]})}),s.jsxs("div",{className:"relative flex-1 overflow-hidden md:bg-transparent bg-gradient-to-br from-[hsl(var(--chat-gradient-from))] via-[hsl(var(--chat-gradient-via))] to-[hsl(var(--chat-gradient-to))]",children:[s.jsx("div",{className:"md:hidden",children:s.jsx(A0,{})}),s.jsxs("div",{ref:je,className:"h-full overflow-y-auto px-4 py-2 md:pb-2 pb-20",onScroll:Xn,children:[l&&s.jsx("div",{ref:bn,className:"h-1"}),d&&s.jsx("div",{className:"flex justify-center py-2",children:s.jsx(rn,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),c&&s.jsx("div",{className:"flex justify-center py-8 text-muted-foreground",children:"Loading..."}),(()=>{const R=[];for(let q=0;q<be.length;q++){const Q=be[q],le=R[R.length-1];if(le!=null&&le.isPhotoGroup&&Q.type==="photo"&&Q.file_url&&Q.sender_id===le.msgs[0].sender_id&&Math.abs(new Date(Q.created_at).getTime()-new Date(le.msgs[le.msgs.length-1].created_at).getTime())<1e4)le.msgs.push(Q);else{const de=Q.type==="photo"&&!!Q.file_url;R.push({msgs:[Q],isPhotoGroup:de})}}return R.map(q=>{var Q,le,de,Be;if(q.isPhotoGroup&&q.msgs.length>1){const U=q.msgs[0],ft=q.msgs[q.msgs.length-1],xe=U.sender_id===(o==null?void 0:o.id),Lt=be[be.indexOf(U)-1],Xt=!Lt||!ti(new Date(Lt.created_at),new Date(U.created_at)),mt=q.msgs.some(Ie=>Ie.id===Ot),Ke=q.msgs.map(Ie=>({url:Ie.file_url,name:Ie.file_name||void 0})),ro=Gr(new Date(ft.created_at),"HH:mm"),Lf=q.msgs.some(Ie=>o&&Ie.sender_id!==o.id&&u.has(Ie.id));return s.jsxs("div",{"data-msg-id":U.id,"data-unread":Lf?"true":"false",children:[Xt&&s.jsx(ei,{date:new Date(U.created_at)}),mt&&s.jsx("div",{ref:We,className:"my-3 flex justify-center",children:s.jsx("span",{className:"rounded-full bg-primary/20 px-3 py-1 text-xs text-primary font-medium",children:"Unread messages"})}),s.jsxs("div",{className:`mb-1 flex ${xe?"justify-end":"justify-start"}`,children:[(te==null?void 0:te.type)==="group"&&!xe&&s.jsxs(Ce,{className:"h-8 w-8 mr-2 mt-1 flex-shrink-0 cursor-pointer",onClick:()=>J(U.sender_id),children:[s.jsx(_e,{src:((Q=U.sender_profile)==null?void 0:Q.avatar_url)??void 0}),s.jsx(Se,{className:"text-xs",children:(de=(le=U.sender_profile)==null?void 0:le.display_name)==null?void 0:de.slice(0,2).toUpperCase()})]}),s.jsx("div",{className:"max-w-[75%]",children:s.jsx(Mf,{message:U,isOwn:xe,onReply:()=>_(U),onEdit:()=>{},onDelete:()=>q.msgs.forEach(Ie=>x.mutate({id:Ie.id,conversationId:e})),onForward:()=>I(U),onReact:Ie=>Ye(U.id,Ie),children:s.jsxs("div",{className:`relative rounded-2xl px-1 py-1 ${xe?"bg-chat-bubble-out text-chat-bubble-out-foreground rounded-br-md":"bg-chat-bubble-in text-chat-bubble-in-foreground rounded-bl-md"}`,children:[(te==null?void 0:te.type)==="group"&&!xe&&s.jsx("p",{className:"mb-0.5 px-2 text-xs font-semibold text-primary cursor-pointer hover:underline truncate max-w-[200px]",onClick:()=>J(U.sender_id),children:(Be=U.sender_profile)==null?void 0:Be.display_name}),s.jsx(M0,{photos:Ke,onPhotoClick:Ie=>{Z(Ke),G(Ie)}}),s.jsxs("div",{className:`mt-0.5 px-2 flex items-center justify-end gap-1 text-[10px] ${xe?"text-chat-bubble-out-foreground/50":"text-chat-bubble-in-foreground/50"}`,children:[s.jsxs("span",{children:[Ke.length," photos"]}),s.jsx("span",{children:ro}),xe&&s.jsx(zt,{className:"h-3 w-3"})]})]})})})]})]},U.id)}return q.msgs.map(U=>{const ft=be.indexOf(U),xe=be[ft-1],Lt=!xe||!ti(new Date(xe.created_at),new Date(U.created_at)),Xt=U.id===Ot,mt=o&&U.sender_id!==o.id&&u.has(U.id);return s.jsxs("div",{"data-msg-id":U.id,"data-unread":mt?"true":"false",className:`transition-colors duration-700 ${ut===U.id?"bg-primary/15 rounded-lg":""}`,children:[Lt&&s.jsx(ei,{date:new Date(U.created_at)}),Xt&&s.jsx("div",{ref:We,className:"my-3 flex justify-center",children:s.jsx("span",{className:"rounded-full bg-primary/20 px-3 py-1 text-xs text-primary font-medium",children:"Unread messages"})}),s.jsx(I0,{message:U,isOwn:U.sender_id===(o==null?void 0:o.id),isGroup:(te==null?void 0:te.type)==="group",onReply:()=>_(U),onEdit:()=>{k(U),j(U.content??"")},onDelete:()=>x.mutate({id:U.id,conversationId:e}),onForward:()=>I(U),onMediaClick:(Ke,ro)=>{z(Ke),M(!!ro)},onReact:Ke=>Ye(U.id,Ke),reactions:m[U.id]??[],searchQuery:E,onProfileClick:Ke=>J(Ke),onRetry:U._optimistic&&U._status==="failed"?()=>Zn(U):void 0,onCancel:U._optimistic&&U._status==="failed"?()=>eo(U.id):void 0,onScrollToReply:Df})]},U.id)})})})()]}),!B&&s.jsxs("button",{onClick:Sn,className:"absolute bottom-20 md:bottom-4 right-4 flex h-10 w-10 items-center justify-center rounded-full bg-card border border-border shadow-lg transition-transform hover:scale-105 active:scale-95 z-10",children:[s.jsx(sg,{className:"h-5 w-5 text-foreground"}),tt>0&&s.jsx("span",{className:"absolute -top-2 -right-2 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-bold text-primary-foreground",children:tt>99?"99+":tt})]})]}),(N||O)&&s.jsxs("div",{className:"flex items-center gap-2 border-t border-border bg-muted/50 px-4 py-2 md:relative fixed bottom-14 left-0 right-0 z-40 md:bottom-auto md:left-auto md:right-auto md:z-auto",children:[s.jsx("div",{className:"flex-1 truncate text-sm",children:O?s.jsxs("span",{className:"text-primary",children:[s.jsx(Sr,{className:"mr-1 inline h-3 w-3"}),"Editing"]}):s.jsxs("span",{className:"text-primary",children:[s.jsx(wc,{className:"mr-1 inline h-3 w-3"}),(oa=N==null?void 0:N.sender_profile)==null?void 0:oa.display_name,": ",(sa=N==null?void 0:N.content)==null?void 0:sa.slice(0,50)]})}),s.jsx(ne,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>{_(null),k(null),j("")},children:s.jsx(vn,{className:"h-4 w-4"})})]}),s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 md:border-t md:border-border md:bg-background md:px-4 md:py-3 md:relative fixed bottom-0 left-0 right-0 z-40 md:bottom-auto md:left-auto md:right-auto md:z-auto",children:[s.jsx("input",{ref:Yn,type:"file",className:"hidden",onChange:to,multiple:!0,accept:"image/*,video/*,application/*"}),r.allowFileUpload&&s.jsx(ne,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full md:rounded-md shrink-0",onClick:()=>{var R;return(R=Yn.current)==null?void 0:R.click()},children:s.jsx(bg,{className:"h-5 w-5"})}),s.jsx(qe,{placeholder:"Message...",value:S,onChange:R=>j(R.target.value),onKeyDown:R=>R.key==="Enter"&&!R.shiftKey&&Dt(),className:"flex-1 md:rounded-md rounded-full bg-card/90 md:bg-background backdrop-blur-sm md:backdrop-blur-none border-border/50"}),s.jsxs("div",{className:`relative ${S.trim()?"":"hidden md:block"}`,ref:Yt,children:[s.jsx(ne,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full md:rounded-md shrink-0",onClick:()=>he(R=>!R),children:s.jsx(Sg,{className:"h-5 w-5"})}),Pe&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-50 bg-black/30 backdrop-blur-[2px] md:hidden",onClick:()=>he(!1)}),s.jsx("div",{className:"absolute bottom-12 right-0 z-50 md:block hidden",children:s.jsx(Eo,{data:_o,onEmojiSelect:R=>{j(q=>q+R.native),he(!1)},theme:"auto",previewPosition:"none",skinTonePosition:"none"})}),s.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-50 flex justify-center animate-in slide-in-from-bottom-5 duration-200 md:hidden",children:s.jsx("div",{className:"rounded-t-2xl border border-border bg-popover shadow-2xl overflow-hidden w-full max-w-[360px]",children:s.jsx(Eo,{data:_o,onEmojiSelect:R=>{j(q=>q+R.native),he(!1)},theme:"auto",previewPosition:"none",skinTonePosition:"none",perLine:8})})})]})]}),S.trim()?s.jsx(ne,{size:"icon",className:"h-9 w-9 rounded-full shrink-0",onClick:Dt,children:s.jsx(uo,{className:"h-4 w-4"})}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"hidden md:block",children:s.jsx(ne,{size:"icon",className:"h-9 w-9 rounded-full shrink-0",onClick:Dt,disabled:!0,children:s.jsx(uo,{className:"h-4 w-4"})})}),s.jsx("div",{className:"md:hidden",children:r.allowVoiceMessages?s.jsx(S0,{onSend:Y}):s.jsx(ne,{size:"icon",className:"h-9 w-9 rounded-full shrink-0",onClick:Dt,disabled:!0,children:s.jsx(uo,{className:"h-4 w-4"})})})]})]}),P&&s.jsx(N0,{message:P,open:!!P,onOpenChange:()=>I(null)}),T&&s.jsx(_0,{url:T,onClose:()=>{z(null),M(!1)},forceVideo:$}),H&&s.jsx(E0,{photos:H,initialIndex:V,onClose:()=>Z(null)}),ue&&s.jsx(Tu,{open:!!ue,onOpenChange:R=>{R||J(null)},userId:ue}),(te==null?void 0:te.type)==="group"&&s.jsx(O0,{open:Pt,onOpenChange:lt,members:te.members,groupName:no,onMemberClick:R=>J(R)}),s.jsx(Ut,{open:ze,onOpenChange:Ae,children:s.jsxs(Tt,{className:"sm:max-w-[400px]",children:[s.jsx(yn,{children:s.jsx(Ht,{children:"Edit Group Name"})}),s.jsx(qe,{value:Ve,onChange:R=>Ge(R.target.value),placeholder:"Group name",onKeyDown:R=>R.key==="Enter"&&se(),autoFocus:!0}),s.jsxs(zd,{children:[s.jsx(ne,{variant:"outline",onClick:()=>Ae(!1),children:"Cancel"}),s.jsx(ne,{onClick:se,disabled:!Ve.trim(),children:"Save"})]})]})}),s.jsx(Ja,{open:Vt,onOpenChange:Rt,children:s.jsxs(Go,{children:[s.jsxs(Yo,{children:[s.jsx(Xo,{children:"Clear Chat History"}),s.jsx(Qo,{children:"This will delete all messages in this chat. This action cannot be undone."})]}),s.jsxs(Ko,{children:[s.jsx(Jo,{children:"Cancel"}),s.jsx(Zo,{onClick:fe,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Clear"})]})]})}),s.jsx(Ja,{open:Gt,onOpenChange:kt,children:s.jsxs(Go,{children:[s.jsxs(Yo,{children:[s.jsx(Xo,{children:"Leave Group"}),s.jsx(Qo,{children:"Are you sure you want to leave this group? You won't be able to see messages anymore."})]}),s.jsxs(Ko,{children:[s.jsx(Jo,{children:"Cancel"}),s.jsx(Zo,{onClick:Oe,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Leave"})]})]})})]})},ei=({date:e})=>{const t=Lb(e)?"Today":Fb(e)?"Yesterday":Gr(e,"MMM d, yyyy");return s.jsx("div",{className:"my-3 flex justify-center",children:s.jsx("span",{className:"rounded-full bg-muted px-3 py-1 text-xs text-muted-foreground",children:t})})},I0=({message:e,isOwn:t,isGroup:n,onReply:r,onEdit:o,onDelete:a,onForward:c,onMediaClick:i,onReact:l,reactions:d,searchQuery:u,onProfileClick:m,onRetry:h,onCancel:p,onScrollToReply:v})=>{var _,O,k,P,I,A,D;if(e.is_deleted)return s.jsx("div",{className:`mb-1 flex ${t?"justify-end":"justify-start"}`,children:s.jsx("div",{className:"rounded-xl bg-muted px-3 py-2 text-sm italic text-muted-foreground",children:"Message deleted"})});const g=Gr(new Date(e.created_at),"HH:mm"),C=(e.read_by??[]).length>0,w=new RegExp("^(\\p{Emoji_Presentation}|\\p{Extended_Pictographic}){1,3}$","u"),b=e.type==="text"&&e.content&&w.test(e.content.trim())&&!e.reply_to&&!e.forwarded_from_id,S=b?[...e.content.trim()].filter(E=>new RegExp("\\p{Emoji_Presentation}|\\p{Extended_Pictographic}","u").test(E)).length:0,j=S===1?"text-6xl":S===2?"text-5xl":"text-4xl",N=E=>u?E.split(new RegExp(`(${u})`,"gi")).map((T,z)=>T.toLowerCase()===u.toLowerCase()?s.jsx("mark",{className:"bg-primary/30 rounded px-0.5",children:T},z):T):E;return s.jsxs("div",{className:`mb-1 flex ${t?"justify-end":"justify-start"}`,children:[n&&!t&&s.jsxs(Ce,{className:"h-8 w-8 mr-2 mt-1 flex-shrink-0 cursor-pointer",onClick:()=>m==null?void 0:m(e.sender_id),children:[s.jsx(_e,{src:((_=e.sender_profile)==null?void 0:_.avatar_url)??void 0}),s.jsx(Se,{className:"text-xs",children:(k=(O=e.sender_profile)==null?void 0:O.display_name)==null?void 0:k.slice(0,2).toUpperCase()})]}),s.jsxs("div",{className:"max-w-[75%]",children:[s.jsx(Mf,{message:e,isOwn:t,onReply:r,onEdit:o,onDelete:a,onForward:c,onReact:l,children:b?s.jsxs("div",{className:"relative px-1 py-1",children:[n&&!t&&s.jsx("p",{className:"mb-0.5 text-xs font-semibold text-primary cursor-pointer hover:underline truncate max-w-[200px]",onClick:()=>m==null?void 0:m(e.sender_id),children:(P=e.sender_profile)==null?void 0:P.display_name}),s.jsx("p",{className:`${j} leading-tight`,children:e.content}),s.jsxs("div",{className:"mt-0.5 flex items-center justify-end gap-1 text-[10px] text-muted-foreground",children:[e.is_edited&&s.jsx("span",{children:"edited"}),s.jsx("span",{children:g}),t&&(e._optimistic&&e._status==="sending"?s.jsx(rn,{className:"h-3 w-3 animate-spin"}):e._optimistic&&e._status==="failed"?s.jsx(Ea,{className:"h-3 w-3 text-destructive"}):C?s.jsx(_a,{className:"h-3 w-3 text-read"}):s.jsx(zt,{className:"h-3 w-3"}))]})]}):s.jsxs("div",{className:`relative rounded-2xl px-3 py-2 ${t?"bg-chat-bubble-out text-chat-bubble-out-foreground rounded-br-md":"bg-chat-bubble-in text-chat-bubble-in-foreground rounded-bl-md"}`,children:[n&&!t&&s.jsx("p",{className:"mb-0.5 text-xs font-semibold text-primary cursor-pointer hover:underline truncate max-w-[200px]",onClick:()=>m==null?void 0:m(e.sender_id),children:(I=e.sender_profile)==null?void 0:I.display_name}),e.reply_to&&s.jsx("div",{className:"mb-1 rounded border-l-2 border-primary bg-muted/50 px-2 py-1 text-xs cursor-pointer hover:bg-muted/80 transition-colors",onClick:()=>e.reply_to_id&&(v==null?void 0:v(e.reply_to_id)),children:(A=e.reply_to.content)==null?void 0:A.slice(0,60)}),e.forwarded_from_id&&s.jsxs("div",{className:"mb-1 flex items-center gap-1 text-xs text-muted-foreground",children:[s.jsx("span",{className:"text-sm",children:"↗"}),s.jsx("span",{children:"Forwarded from "}),s.jsx("span",{className:"font-semibold text-primary cursor-pointer hover:underline",onClick:E=>{var F;E.stopPropagation(),(F=e.forwarded_from_profile)!=null&&F.sender_id&&(m==null||m(e.forwarded_from_profile.sender_id))},children:((D=e.forwarded_from_profile)==null?void 0:D.display_name)||"Unknown"})]}),e.type==="photo"&&e.file_url&&s.jsx("div",{className:"mb-1 cursor-pointer overflow-hidden rounded-lg",onClick:()=>i(e.file_url),children:s.jsx("img",{src:e.file_url,alt:e.file_name||"photo",className:"max-h-60 w-full object-cover transition-transform hover:scale-105",loading:"lazy"})}),e.type==="video"&&e.file_url&&s.jsxs("div",{className:"relative mb-1 cursor-pointer overflow-hidden rounded-2xl bg-black min-h-[200px] max-w-[280px]",onClick:()=>i(e.file_url,!0),children:[s.jsx("video",{src:`${e.file_url}#t=0.1`,className:"min-h-[200px] max-h-80 w-full object-cover",preload:"metadata",muted:!0,playsInline:!0}),s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-black/50 backdrop-blur-md",children:s.jsx(bc,{className:"h-5 w-5 text-white ml-0.5",fill:"white"})})})]}),e.type==="file"&&e.file_url&&s.jsxs("a",{href:e.file_url,target:"_blank",rel:"noopener noreferrer",className:"mb-1 flex items-center gap-2 rounded bg-muted/50 p-2 text-sm hover:bg-muted",children:["📎 ",e.file_name||"File"]}),e.type==="voice"&&e.file_url&&s.jsx(j0,{url:e.file_url,isMine:t}),e.content&&e.type==="text"&&s.jsx("p",{className:"text-sm whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:N(e.content)}),s.jsxs("div",{className:`mt-0.5 flex items-center justify-end gap-1 text-[10px] ${t?"text-chat-bubble-out-foreground/50":"text-chat-bubble-in-foreground/50"}`,children:[e.is_edited&&s.jsx("span",{children:"edited"}),s.jsx("span",{children:g}),t&&(e._optimistic&&e._status==="sending"?s.jsx(rn,{className:"h-3 w-3 animate-spin"}):e._optimistic&&e._status==="failed"?s.jsx(Ea,{className:"h-3 w-3 text-destructive"}):C?s.jsx(_a,{className:"h-3 w-3 text-read"}):s.jsx(zt,{className:"h-3 w-3"}))]})]})}),e._optimistic&&e._status==="failed"&&s.jsxs("div",{className:"mt-1 flex items-center justify-end gap-1",children:[s.jsx("span",{className:"text-[11px] text-destructive mr-1",children:"Not sent"}),s.jsxs(ne,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1 text-primary hover:text-primary",onClick:h,children:[s.jsx(Cg,{className:"h-3 w-3"}),"Retry"]}),s.jsxs(ne,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs gap-1 text-destructive hover:text-destructive",onClick:p,children:[s.jsx(Bn,{className:"h-3 w-3"}),"Cancel"]})]}),s.jsx(P0,{reactions:d,onToggle:E=>l(E),isOwn:t})]})]})};function ti(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function L0(e,t){var r;if(e.type==="group")return e.name||"Group";const n=e.members.find(o=>o.user_id!==t);return((r=n==null?void 0:n.profile)==null?void 0:r.display_name)||"Chat"}function $0(e,t){var r;if(e.type==="group")return e.avatar_url;const n=e.members.find(o=>o.user_id!==t);return(r=n==null?void 0:n.profile)==null?void 0:r.avatar_url}const F0=({onUnreadCountChange:e,onConversationSelect:t}={})=>{const[n,r]=y.useState(null),o=ta(),[a,c]=y.useState(!0),i=d=>{r(d),t==null||t(d),o&&c(!1)},l=()=>{c(!0),o&&r(null)};return s.jsxs("div",{className:"flex h-full w-full overflow-hidden bg-background",children:[(!o||a)&&s.jsx("div",{className:`${o?"w-full":"w-[380px] min-w-[320px] border-r border-border"} flex flex-col h-full overflow-y-hidden`,children:s.jsx(Ew,{activeConversationId:n,onSelectConversation:i,onUnreadCountChange:e})}),(!o||!a)&&s.jsx("div",{className:"flex flex-1 flex-col h-full overflow-hidden",children:s.jsx(D0,{conversationId:n,onBack:o?l:void 0})})]})},Tf=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:W("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Tf.displayName="Card";const Rf=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:W("flex flex-col space-y-1.5 p-6",e),...t}));Rf.displayName="CardHeader";const kf=f.forwardRef(({className:e,...t},n)=>s.jsx("h3",{ref:n,className:W("text-2xl font-semibold leading-none tracking-tight text-card-foreground",e),...t}));kf.displayName="CardTitle";const Pf=f.forwardRef(({className:e,...t},n)=>s.jsx("p",{ref:n,className:W("text-sm text-muted-foreground",e),...t}));Pf.displayName="CardDescription";const Af=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:W("p-6 pt-0",e),...t}));Af.displayName="CardContent";const z0=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:W("flex items-center p-6 pt-0",e),...t}));z0.displayName="CardFooter";const W0=()=>{const e=ve(),[t,n]=y.useState("login"),[r,o]=y.useState(""),[a,c]=y.useState(""),[i,l]=y.useState(""),[d,u]=y.useState(!1),{toast:m}=xn(),h=async g=>{g.preventDefault(),u(!0);const{error:x}=await e.auth.signInWithPassword({email:r,password:a});x&&m({title:"Login error",description:x.message,variant:"destructive"}),u(!1)},p=async g=>{g.preventDefault(),u(!0);const{error:x}=await e.auth.signUp({email:r,password:a,options:{data:{display_name:i},emailRedirectTo:window.location.origin}});x?m({title:"Sign up error",description:x.message,variant:"destructive"}):(m({title:"Check your email",description:"We sent a confirmation link"}),n("login")),u(!1)},v=async g=>{g.preventDefault(),u(!0);const{error:x}=await e.auth.resetPasswordForEmail(r,{redirectTo:`${window.location.origin}/reset-password`});m(x?{title:"Error",description:x.message,variant:"destructive"}:{title:"Check your email",description:"Password reset link sent"}),u(!1)};return s.jsx("div",{className:"flex h-full min-h-0 items-center justify-center bg-background p-4 overflow-y-auto",children:s.jsxs(Tf,{className:"w-full max-w-md",children:[s.jsxs(Rf,{className:"text-center",children:[s.jsx("div",{className:"mx-auto mb-2 flex h-14 w-14 items-center justify-center rounded-2xl bg-primary",children:s.jsx(Cr,{className:"h-7 w-7 text-primary-foreground"})}),s.jsx(kf,{className:"text-2xl",children:t==="login"?"Sign In":t==="signup"?"Sign Up":"Reset Password"}),s.jsx(Pf,{children:t==="login"?"Sign in to your account":t==="signup"?"Create a new account":"Enter your email to reset password"})]}),s.jsxs(Af,{className:"space-y-4",children:[s.jsxs("form",{onSubmit:t==="login"?h:t==="signup"?p:v,className:"space-y-4",children:[t==="signup"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(sn,{htmlFor:"name",children:"Name"}),s.jsxs("div",{className:"relative",children:[s.jsx(Sc,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),s.jsx(qe,{id:"name",placeholder:"Your name",value:i,onChange:g=>l(g.target.value),className:"pl-9",required:!0})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(sn,{htmlFor:"email",children:"Email"}),s.jsxs("div",{className:"relative",children:[s.jsx(vg,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),s.jsx(qe,{id:"email",type:"email",placeholder:"you@example.com",value:r,onChange:g=>o(g.target.value),className:"pl-9",required:!0})]})]}),t!=="forgot"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(sn,{htmlFor:"password",children:"Password"}),s.jsxs("div",{className:"relative",children:[s.jsx(gg,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),s.jsx(qe,{id:"password",type:"password",placeholder:"••••••••",value:a,onChange:g=>c(g.target.value),className:"pl-9",required:!0,minLength:6})]})]}),s.jsx(ne,{type:"submit",className:"w-full",disabled:d,children:d?"Loading...":t==="login"?"Sign In":t==="signup"?"Sign Up":"Send Reset Link"})]}),s.jsx("div",{className:"flex justify-center gap-4 text-sm",children:t==="login"?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"text-primary hover:underline",onClick:()=>n("signup"),children:"Sign Up"}),s.jsx("button",{className:"text-muted-foreground hover:underline",onClick:()=>n("forgot"),children:"Forgot password?"})]}):s.jsx("button",{className:"text-primary hover:underline",onClick:()=>n("login"),children:"Already have an account? Sign In"})})]})]})})},B0=({authMode:e,userData:t,height:n,width:r,onUnreadCountChange:o,onConversationSelect:a})=>{const{user:c,loading:i}=ye();return i?s.jsx("div",{className:"flex items-center justify-center bg-background",style:{height:n,width:r},children:s.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e==="built-in"&&!c?s.jsx(W0,{}):s.jsx("div",{style:{height:n,width:r},children:s.jsx(F0,{onUnreadCountChange:o,onConversationSelect:a})})},q0=({supabaseUrl:e,supabaseAnonKey:t,userData:n,theme:r="system",authMode:o="built-in",showGroups:a=!0,allowVoiceMessages:c=!0,allowFileUpload:i=!0,allowReactions:l=!0,showOnlineStatus:d=!0,showReadReceipts:u=!0,height:m="100vh",width:h="100%",onUnreadCountChange:p,onConversationSelect:v})=>{const g=y.useMemo(()=>({showGroups:a,allowVoiceMessages:c,allowFileUpload:i,allowReactions:l,showOnlineStatus:d,showReadReceipts:u}),[a,c,i,l,d,u]);return s.jsx($f,{supabaseUrl:e,supabaseAnonKey:t,config:g,children:s.jsx(Bf,{initialTheme:r,children:s.jsx(zf,{authMode:o,userData:n,children:s.jsxs(kh,{children:[s.jsx(Tg,{}),s.jsx(ix,{}),s.jsx(B0,{authMode:o,userData:n,height:m,width:h,onUnreadCountChange:p,onConversationSelect:v})]})})})})},U0={sm:{button:"h-10 w-10",icon:"h-5 w-5",badge:"h-4 w-4 text-[9px] -top-0.5 -right-0.5"},md:{button:"h-14 w-14",icon:"h-6 w-6",badge:"h-5 w-5 text-[10px] -top-1 -right-1"},lg:{button:"h-16 w-16",icon:"h-7 w-7",badge:"h-6 w-6 text-[11px] -top-1 -right-1"}};async function H0(e,t){const{data:n}=await e.from("conversation_members").select("conversation_id").eq("user_id",t),r=(n??[]).map(l=>l.conversation_id);if(r.length===0)return 0;const{data:o}=await e.from("messages").select("id, conversation_id").in("conversation_id",r).eq("is_deleted",!1).neq("sender_id",t);if(!o||o.length===0)return 0;const a=o.map(l=>l.id),c=new Set;for(let l=0;l<a.length;l+=500){const d=a.slice(l,l+500),{data:u}=await e.from("message_reads").select("message_id").eq("user_id",t).in("message_id",d);(u??[]).forEach(m=>c.add(m.message_id))}return new Set(o.filter(l=>!c.has(l.id)).map(l=>l.conversation_id)).size}const V0=({supabaseUrl:e,supabaseAnonKey:t,userData:n,onClick:r,href:o,position:a="bottom-right",unreadCount:c,size:i="md",badgeColor:l,icon:d,floating:u=!0,className:m,style:h,buttonColor:p,iconColor:v,label:g="Open chat"})=>{const[x,C]=y.useState(0),w=c!==void 0?c:x,b=y.useMemo(()=>!e||!t?null:es.createClient(e,t),[e,t]);y.useEffect(()=>{if(c!==void 0||!(n!=null&&n.id)||!b)return;const k=async()=>{const A=await H0(b,n.id);C(A)};(async()=>{n.accessToken&&n.refreshToken&&await b.auth.setSession({access_token:n.accessToken,refresh_token:n.refreshToken}),await k()})();const I=b.channel("chat-button-unread").on("postgres_changes",{event:"*",schema:"public",table:"messages"},k).on("postgres_changes",{event:"*",schema:"public",table:"message_reads"},k).subscribe();return()=>{b.removeChannel(I)}},[b,n==null?void 0:n.id,n==null?void 0:n.accessToken,n==null?void 0:n.refreshToken,c]);const S=U0[i],N=u?`fixed ${a==="bottom-left"?"bottom-4 left-4":"bottom-4 right-4"} z-50`:"relative",_=()=>{if(r){r();return}o&&typeof window<"u"&&/^(https?:\/\/|\/)/.test(o)&&(window.location.href=o)},O={...p?{backgroundColor:p}:{},...v?{color:v}:{},...h};return s.jsxs("button",{onClick:_,className:`${N} ${S.button} rounded-full bg-primary text-primary-foreground shadow-lg flex items-center justify-center hover:scale-105 transition-transform cursor-pointer${m?` ${m}`:""}`,style:O,"aria-label":g,children:[d||s.jsx(Cr,{className:S.icon}),w>0&&s.jsx("span",{className:`absolute ${S.badge} rounded-full font-bold flex items-center justify-center`,style:{backgroundColor:l||"hsl(var(--destructive))",color:"hsl(var(--destructive-foreground))"},children:w>99?"99+":w})]})},No={sm:{avatar:"h-8 w-8",fallback:"text-xs"},md:{avatar:"h-10 w-10",fallback:"text-sm"},lg:{avatar:"h-12 w-12",fallback:"text-base"}},G0={"top-right":"top-4 right-4","top-left":"top-4 left-4","bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4"};function Of(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.length===1?t[0][0].toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase()}function Y0(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function K0({open:e,onOpenChange:t,profile:n,email:r}){const o=(n==null?void 0:n.display_name)??"",a=Of(o||r);return s.jsx(Ut,{open:e,onOpenChange:t,children:s.jsxs(Tt,{className:"sm:max-w-sm",children:[s.jsxs(yn,{children:[s.jsx(Ht,{children:"Profile"}),s.jsx(Wd,{className:"sr-only",children:"User profile details"})]}),s.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[s.jsxs(Ce,{className:"h-24 w-24",children:[s.jsx(_e,{src:(n==null?void 0:n.avatar_url)??void 0}),s.jsx(Se,{className:"text-2xl font-semibold",children:a})]}),o&&s.jsx("p",{className:"text-lg font-semibold text-center",children:o}),r&&s.jsx("p",{className:"text-sm text-muted-foreground text-center",children:r}),(n==null?void 0:n.bio)&&s.jsx("p",{className:"text-sm text-center text-foreground/80 max-w-xs",children:n.bio})]})]})})}const X0=({supabaseUrl:e,supabaseAnonKey:t,userData:n,authMode:r="built-in",showName:o=!1,size:a="md",floating:c=!1,position:i="top-right",nameMaxLength:l=20,onThemeChange:d,onProfileClick:u,onLogout:m,onLogin:h,className:p,style:v})=>{var Z,V;const[g,x]=y.useState(null),[C,w]=y.useState(r==="built-in"),[b,S]=y.useState(null),[j,N]=y.useState(()=>typeof window>"u"?"system":localStorage.getItem("chat-theme")||"system"),[_,O]=y.useState(!1),k=y.useMemo(()=>!e||!t?null:es.createClient(e,t,{auth:{persistSession:!0,autoRefreshToken:!0}}),[e,t]);y.useEffect(()=>{if(r!=="built-in"||!k)return;k.auth.getSession().then(({data:{session:B}})=>{x(B),w(!1)});const{data:{subscription:G}}=k.auth.onAuthStateChange((B,re)=>{x(re),w(!1)});return()=>G.unsubscribe()},[k,r]),y.useEffect(()=>{r!=="external"||!k||!(n!=null&&n.accessToken)||!(n!=null&&n.refreshToken)||k.auth.setSession({access_token:n.accessToken,refresh_token:n.refreshToken})},[k,r,n==null?void 0:n.accessToken,n==null?void 0:n.refreshToken]),y.useEffect(()=>{var re;const G=r==="external"?n==null?void 0:n.id:(re=g==null?void 0:g.user)==null?void 0:re.id;if(!k||!G){S(null);return}let B=!1;return k.from("profiles").select("display_name, avatar_url, bio").eq("id",G).single().then(({data:ue})=>{B||S(ue??null)}),()=>{B=!0}},[k,(Z=g==null?void 0:g.user)==null?void 0:Z.id,n==null?void 0:n.id,r]),y.useEffect(()=>{if(typeof window>"u")return;if((B=>{const re=B==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":B;document.documentElement.classList.toggle("dark",re==="dark")})(j),j==="system"){const B=window.matchMedia("(prefers-color-scheme: dark)"),re=ue=>{document.documentElement.classList.toggle("dark",ue.matches)};return B.addEventListener("change",re),()=>B.removeEventListener("change",re)}},[j]);const P=(b==null?void 0:b.avatar_url)??(n==null?void 0:n.avatar)??null,I=(b==null?void 0:b.display_name)??(n==null?void 0:n.name)??"",A=((V=g==null?void 0:g.user)==null?void 0:V.email)??(n==null?void 0:n.email)??"",D=r==="built-in"?g!==null:!!(n!=null&&n.id),E=Of(I||A),F=G=>{const B=G;N(B),typeof window<"u"&&localStorage.setItem("chat-theme",B),d==null||d(B)},T=async()=>{k&&(await k.auth.signOut(),x(null),S(null),m==null||m())},z=()=>{u?u():O(!0)};if(r==="built-in"&&C)return null;const $=No[a],M=c?`fixed ${G0[i]} z-50`:"relative",H=j==="dark"?$o:j==="light"?Fo:Ma;return s.jsxs(s.Fragment,{children:[s.jsxs(of,{children:[s.jsx(sf,{asChild:!0,children:s.jsxs("button",{className:`${M} flex items-center gap-2 rounded-full ring-offset-background transition-opacity hover:opacity-80 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 cursor-pointer${p?` ${p}`:""}`,style:v,"aria-label":I||"User menu",children:[s.jsxs(Ce,{className:$.avatar,children:[s.jsx(_e,{src:P??void 0}),s.jsx(Se,{className:`font-medium ${$.fallback}`,children:E})]}),o&&I&&s.jsx("span",{className:"max-w-[120px] truncate text-sm font-medium",children:Y0(I,l)})]})}),s.jsxs(ea,{align:"end",className:"w-56",children:[s.jsxs("div",{className:"flex items-center gap-3 px-2 py-2",children:[s.jsxs(Ce,{className:No.sm.avatar,children:[s.jsx(_e,{src:P??void 0}),s.jsx(Se,{className:`font-medium ${No.sm.fallback}`,children:E})]}),s.jsxs("div",{className:"flex flex-col min-w-0",children:[I&&s.jsx("span",{className:"text-sm font-medium truncate",children:I}),A&&s.jsx("span",{className:"text-xs text-muted-foreground truncate",children:A})]})]}),s.jsx(an,{}),s.jsxs(ht,{onSelect:z,children:[s.jsx(Sc,{className:"mr-2 h-4 w-4"}),"My Profile"]}),s.jsx(an,{}),s.jsxs(a0,{children:[s.jsxs(af,{children:[s.jsx(H,{className:"mr-2 h-4 w-4"}),"Theme"]}),s.jsx(cf,{children:s.jsxs(i0,{value:j,onValueChange:F,children:[s.jsxs(xr,{value:"light",children:[s.jsx(Fo,{className:"mr-2 h-4 w-4"}),"Light"]}),s.jsxs(xr,{value:"dark",children:[s.jsx($o,{className:"mr-2 h-4 w-4"}),"Dark"]}),s.jsxs(xr,{value:"system",children:[s.jsx(Ma,{className:"mr-2 h-4 w-4"}),"System"]})]})})]}),r==="built-in"&&s.jsxs(s.Fragment,{children:[s.jsx(an,{}),D?s.jsxs(ht,{onSelect:T,className:"text-destructive focus:text-destructive",children:[s.jsx(Ss,{className:"mr-2 h-4 w-4"}),"Sign out"]}):s.jsxs(ht,{onSelect:()=>h==null?void 0:h(),children:[s.jsx(xg,{className:"mr-2 h-4 w-4"}),"Sign in"]})]})]})]}),s.jsx(K0,{open:_,onOpenChange:O,profile:b,email:A})]})};exports.ChatButton=V0;exports.QuickChat=q0;exports.UserAvatar=X0;
|